Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeuLAND Update 1603 #65

Merged
merged 1 commit into from Mar 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions .gitignore
@@ -0,0 +1,33 @@
# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# ROOT specific files
*.d
*.pcm

13 changes: 8 additions & 5 deletions macros/r3b/geo/create_neuland_demo_geo.C
@@ -1,6 +1,6 @@
#include "./helper_neuland_geometry.C"

void create_neuland_demo_geo(const Int_t nPlanes = 8, const Double_t distance = 1100., const char *geoTag = "demo_11m")
void create_neuland_demo_geo(const Int_t nPlanes = 8, const Double_t distance = 1100., const TString geoTag = "demo_11m")
{
new FairGeoLoader("TGeo", "FairGeoLoader");
gGeoManager->SetName("NEULANDgeom");
Expand Down Expand Up @@ -40,8 +40,11 @@ void create_neuland_demo_geo(const Int_t nPlanes = 8, const Double_t distance =

cout << "Done. " << nindex << " Paddles in " << nPlane << " Planes" << endl;

//gGeoManager->GetMasterVolume()->Draw("ogl");
//gGeoManager->GetVolume("volNeuland")->Draw("ogl");
//TGLViewer *v = (TGLViewer *)gPad->GetViewer3D();
//v->SetStyle(TGLRnrCtx::kOutline);
gStyle->SetCanvasPreferGL(kTRUE);
gGeoManager->GetVolume("volNeuland")->Draw("ogl");
TGLViewer *v = (TGLViewer *)gPad->GetViewer3D();
v->CurrentCamera().RotateRad(0, 0.1);
v->SetStyle(TGLRnrCtx::kOutline);
v->RequestDraw();
v->SavePicture("neuland_" + geoTag + ".png");
}
3 changes: 3 additions & 0 deletions macros/r3b/land/tdrV2/.gitignore
@@ -0,0 +1,3 @@
r3bcalibr*
r3bpar*
r3bsim*
2 changes: 1 addition & 1 deletion macros/r3b/land/tdrV2/calibr_mini.c
Expand Up @@ -73,7 +73,7 @@ inline double Efficiency(const TH2F *h, const double &lower, const double &upper
return Integral_2D(h, lower, upper, kappa) / h->GetEntries();
}

double GetCuts(const double *d, double *c) {
void GetCuts(const double *d, double *c) {
c[0] = CUT_ZERO;
// d[0] is kappa!
for (int i = 1; i < N_MAX; i++) {
Expand Down
4 changes: 2 additions & 2 deletions macros/r3b/land/tdrV2/preCalibr.c
@@ -1,10 +1,10 @@
void preCalibr(
const Int_t n_events,
const string basename,
const TString basename,
const Double_t beamE,
const Double_t saturation,
const Double_t integration,
const string output_affix = ""
const TString output_affix = ""
) {

// ----- Files ---------------------------------------------------------------
Expand Down
15 changes: 7 additions & 8 deletions macros/r3b/land/tdrV2/r3blandsim.c
@@ -1,16 +1,19 @@
#include "../../r3ball.C"

void r3blandsim(
const Int_t n_neutrons,
const Int_t n_events,
const string neuland_geo_file,
const string input_file,
const string basename
const TString neuland_geo_file,
const TString input_file,
const TString basename
){

// Output files
const TString out_file = "r3bsim." + basename + ".root";
const TString par_file = "r3bpar." + basename + ".root";

// Constant configuration
const Int_t nEvents = 10000;
const TString target = "LiH";
const TString fMC = "TGeant3";
const TString fGene = "ascii";
Expand All @@ -28,10 +31,6 @@ void r3blandsim(
geometry.Add(new TObjString("SCINTNEULAND"), new TObjString(TString(neuland_geo_file)));


// Load the Main Simulation macro
const TString macro_r3ball = TString(getenv("VMCWORKDIR")) + TString("/macros/r3b/r3ball.C");
gROOT->LoadMacro(macro_r3ball.Data());

// Main Sim function call
r3ball( n_events, &geometry, target, fEventDisplay, fMC, fGene, fUserPList, fR3BMagnet, fMeasCurrent, out_file, par_file, input_file);
r3ball(nEvents, &geometry, target, fEventDisplay, fMC, fGene, fUserPList, fR3BMagnet, fMeasCurrent, out_file, par_file, input_file);
}
6 changes: 6 additions & 0 deletions macros/r3b/neuland/.gitignore
@@ -1,3 +1,9 @@
# Output directories
**/output*/

# Output files
*.png
*.pdf
*.eps
*.log

3 changes: 1 addition & 2 deletions macros/r3b/neuland/demo/Step2_Digitizing.sh
Expand Up @@ -7,8 +7,7 @@ OUTDIR=${1:-output}
trap 'kill $(jobs -pr) 2>/dev/null' SIGINT SIGTERM EXIT

# Run porcess on all simualtion files in "parallel" in background
for f in ${OUTDIR}/*.sim.root
do
for f in ${OUTDIR}/*.sim.root; do
root -l -q -b 'Step2_Digitizing.C('\"${f}\"')' &
done

Expand Down
8 changes: 8 additions & 0 deletions macros/r3b/neuland/matrices/Step0_CreateAllGeometryFiles.sh
@@ -0,0 +1,8 @@
#!/bin/bash

DISTANCE=1400

for NDOUBLEPLANES in $(seq 4 50); do
NPLANES=$((${NDOUBLEPLANES}*2));
root -l -q ${VMCWORKDIR}'/macros/r3b/geo/create_neuland_demo_geo.C('${NPLANES}', '${DISTANCE}', "v2_'${DISTANCE}'cm_'${NDOUBLEPLANES}'dp")';
done
39 changes: 39 additions & 0 deletions macros/r3b/neuland/matrices/Step1_Simulate.C
@@ -0,0 +1,39 @@
#include "macros/r3b/r3ball.C"

void Step1_Simulate(
const Int_t nEvents,
const TString basePath,
const TString baseName,
const TString inputFile,
const TString geoTag
)
{
// System paths
const TString workDirectory = getenv("VMCWORKDIR");
gSystem->Setenv("GEOMPATH", workDirectory + "/geometry");
gSystem->Setenv("CONFIG_DIR", workDirectory + "/gconfig");

// Output files
const TString outFile = basePath + "/" + baseName + ".sim.root";
const TString parFile = basePath + "/" + baseName + ".par.root";

// Constant configuration
const TString target = "LiH";
const TString fMC = "TGeant3";
const TString fGene = "ascii";
const Bool_t fEventDisplay = kTRUE;
const Bool_t fUserPList = kTRUE;
const Bool_t fR3BMagnet = kTRUE;
const Double_t fMeasCurrent = 2500.;

// Geometry
TMap geometry;
geometry.Add(new TObjString("TARGET"), new TObjString("target_" + target + ".geo.root"));
geometry.Add(new TObjString("ALADIN"), new TObjString("aladin_v13a.geo.root"));
geometry.Add(new TObjString("CRYSTALBALL"), new TObjString("cal_v13a.geo.root"));
geometry.Add(new TObjString("DCH"), new TObjString("dch_v13a.geo.root"));
geometry.Add(new TObjString("NEULAND"), new TObjString("neuland_" + geoTag + ".geo.root"));

// Main Sim function call
r3ball(nEvents, &geometry, target, fEventDisplay, fMC, fGene, fUserPList, fR3BMagnet, fMeasCurrent, outFile, parFile, inputFile);
}
41 changes: 41 additions & 0 deletions macros/r3b/neuland/matrices/Step1_Simulate.sh
@@ -0,0 +1,41 @@
#!/bin/bash

# Set output directory from script arguments or use default
OUTDIR=${1:-output}
# Create a folder for root files, so this directory stays clean
mkdir -p ${OUTDIR}

NEVENTS=10000
DISTANCE=1400

# Kill background jobs if script is terminated
trap 'kill $(jobs -pr) 2>/dev/null' SIGINT SIGTERM EXIT

# Run all simulations in "parallel" in background
COUNT=0
#for NDOUBLEPLANES in $(seq 4 30); do
for NDOUBLEPLANES in $(seq 31 50); do
for NNEUTRONS in $(seq 1 4); do
INPUT="$((132-${NNEUTRONS}))Sn_${NNEUTRONS}n_600AMeV_500keV.dat"
NPLANES=$((${NDOUBLEPLANES}*2))
COMMAND="Step1_Simulate.C(${NEVENTS}, \"${OUTDIR}\", \"${DISTANCE}cm_${NDOUBLEPLANES}dp_${NNEUTRONS}n\", \"${INPUT}\", \"v2_${DISTANCE}cm_${NDOUBLEPLANES}dp\")"
# Note: The root call is extemely sensitive to the usage of ' and "
nice -n 19 root -l -q -b -e 'gInterpreter->AddIncludePath("'${VMCWORKDIR}'")' "${COMMAND}" &>/dev/null &
echo ${COMMAND}

# Only spawn so many processes at once
COUNT=$((${COUNT}+1))
if (( ${COUNT} % 30 == 0 )); then
wait
fi
done

done

# Wait for all background jobs to finish
wait

# Remove junk
rm -f calor.out
rm -f flukaerr.dat
rm -f gphysi.dat
39 changes: 39 additions & 0 deletions macros/r3b/neuland/matrices/Step2_DigitizingClustering.C
@@ -0,0 +1,39 @@
inline void ConnectParFileToRuntimeDb(const TString parFile, FairRuntimeDb *rtdb)
{
FairParRootFileIo *io = new FairParRootFileIo();
io->open(parFile);
rtdb->setFirstInput(io);
rtdb->setOutput(io);
rtdb->saveOutput();
}


void Step2_DigitizingClustering(
const TString simFile
)
{
TStopwatch timer;
timer.Start();

const TString parFile = (TString(simFile).ReplaceAll(".sim.", ".par."));
const TString outFile = (TString(simFile).ReplaceAll(".sim.", ".digi."));

FairRunAna *run = new FairRunAna();
run->SetInputFile(simFile);
run->SetOutputFile(outFile);
ConnectParFileToRuntimeDb(parFile, run->GetRuntimeDb());

run->AddTask(new R3BNeulandDigitizer());
run->AddTask(new R3BNeuLandClusterFinder(0));
run->AddTask(new R3BNeutronCalibr2D());

run->Init();
run->Run(0, 0);

timer.Stop();

cout << "Macro finished succesfully!" << endl;
cout << "Output file writen: " << outFile << endl;
cout << "Parameter file writen: " << parFile << endl;
cout << "Real time: " << timer.RealTime() << "s, CPU time: " << timer.CpuTime() << "s" << endl;
}
26 changes: 26 additions & 0 deletions macros/r3b/neuland/matrices/Step2_DigitizingClustering.sh
@@ -0,0 +1,26 @@
#!/bin/bash

# Set output directory from script arguments or use default
OUTDIR=${1:-output}
FILES=(${OUTDIR}/*.sim.root)

# Kill background jobs if script is terminated
trap 'kill $(jobs -pr) 2>/dev/null' SIGINT SIGTERM EXIT

# Run process on all simulation files in "parallel" in background
COUNT=0
for f in "${FILES[@]}"
do
root -l -q -b 'Step2_DigitizingClustering.C('\"${f}\"')' &>/dev/null &

# Only spawn so many processes at once
COUNT=$((${COUNT}+1))
if (( ${COUNT} % 30 == 0 )); then
wait
echo "${COUNT}/${#FILES[@]}"
fi
done

# Wait for all background jobs to finish
wait
echo "${COUNT}/${#FILES[@]}"
15 changes: 15 additions & 0 deletions macros/r3b/neuland/matrices/Step3_Calibr.sh
@@ -0,0 +1,15 @@
#!/bin/bash

# Run all simulations in "parallel" in background
COUNT=0
for NDOUBLEPLANES in $(seq 4 50); do
# Note: The root call is extemely sensitive to the usage of ' and "
root -l -q -b -e 'gInterpreter->AddIncludePath("'${VMCWORKDIR}'")' "calibr_mini.C+(${NDOUBLEPLANES})"
#root -l -q -b -e 'gInterpreter->AddIncludePath("'${VMCWORKDIR}'")' "calibr.C+(${NDOUBLEPLANES})"
done

wait

# Remove junk
rm calibr_mini_C*
rm calibr_C*