Skip to content

Commit c0220c4

Browse files
committed
[WIP] Create LUTs on the fly
1 parent 7e57b4a commit c0220c4

File tree

6 files changed

+68
-43
lines changed

6 files changed

+68
-43
lines changed

examples/scripts/create_luts.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#! /usr/bin/env bash
2+
3+
WHAT=default
4+
FIELD=0.5
5+
RMIN=100.
6+
7+
[ -z "$1" ] || WHAT=$1
8+
[ -z "$2" ] || FIELD=$2
9+
[ -z "$3" ] || RMIN=$3
10+
11+
cp $DELPHESO2_ROOT/lut/lutWrite.$WHAT.cc . || { echo "cannot find lut writer: $DELPHESO2_ROOT/lut/lutWrite.$WHAT.cc" ; exit 1; }
12+
cp $DELPHESO2_ROOT/lut/DetectorK/DetectorK.cxx .
13+
cp $DELPHESO2_ROOT/lut/DetectorK/DetectorK.h .
14+
cp -r $DELPHESO2_ROOT/lut/fwdRes .
15+
cp $DELPHESO2_ROOT/lut/lutWrite.cc .
16+
17+
echo " --- creating LUTs: config = $WHAT, field = $FIELD T, min tracking radius = $RMIN cm"
18+
19+
prepare_libs_macro() {
20+
echo "void create_libs() {"
21+
echo " gROOT->ProcessLine(\".L DetectorK.cxx+\");"
22+
echo "}"
23+
}
24+
25+
prepare_luts_macro() {
26+
27+
echo "R__LOAD_LIBRARY(DetectorK_cxx.so)"
28+
echo "#include \"lutWrite.$WHAT.cc\""
29+
echo "void create_luts() {"
30+
echo " lutWrite_$WHAT(\"lutCovm.el.dat\", 11, $FIELD, $RMIN);"
31+
echo " lutWrite_$WHAT(\"lutCovm.mu.dat\", 13, $FIELD, $RMIN);"
32+
echo " lutWrite_$WHAT(\"lutCovm.pi.dat\", 211, $FIELD, $RMIN);"
33+
echo " lutWrite_$WHAT(\"lutCovm.ka.dat\", 321, $FIELD, $RMIN);"
34+
echo " lutWrite_$WHAT(\"lutCovm.pr.dat\", 2212, $FIELD, $RMIN);"
35+
echo "}"
36+
37+
}
38+
39+
prepare_libs_macro > create_libs.C
40+
root -b -q -l create_libs.C
41+
42+
prepare_luts_macro > create_luts.C
43+
root -b -q -l create_luts.C
44+

examples/scripts/rich.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ echo "maxEta = $RICHETA"
1515

1616
### copy relevant files in the working directory
1717
cp $DELPHESO2_ROOT/examples/cards/propagate.2kG.tcl propagate.tcl
18-
LUTPATH=$HOME/cernbox/ALICE3/DelphesO2/LUTS
19-
tar zxf $LUTPATH/lutCovm.2kG.20cm.default.tgz -C .
20-
tar zxf $LUTPATH/lutCovm.5kG.20cm.default.tgz -C .
21-
for I in el mu pi ka pr; do
22-
ln -sf lutCovm.$I.2kG.20cm.default.dat lutCovm.$I.2kG.dat;
23-
ln -sf lutCovm.$I.5kG.20cm.default.dat lutCovm.$I.5kG.dat;
24-
done
2518
cp $DELPHESO2_ROOT/examples/smearing/rich.C .
2619
cp $DELPHESO2_ROOT/examples/pythia8/pythia8_inel.cfg pythia8.cfg
2720

@@ -32,7 +25,6 @@ echo "Main:numberOfEvents $NEVENTS" >> pythia8.cfg
3225

3326
### set magnetic field
3427
sed -i -e "s/set barrel_Bz .*$/set barrel_Bz ${BFIELD}e\-1/" propagate.tcl
35-
sed -i -e "s/double Bz = .*$/double Bz = ${BFIELD}e\-1\;/" rich.C
3628
### set TOF radius
3729
sed -i -e "s/set barrel_Radius .*$/set barrel_Radius ${RICHRAD}e\-2/" propagate.tcl
3830
sed -i -e "s/double rich_radius = .*$/double rich_radius = ${RICHRAD}\;/" rich.C
@@ -42,6 +34,10 @@ sed -i -e "s/double rich_length = .*$/double rich_length = ${RICHLEN}\;/" rich.C
4234
### set TOF acceptance
4335
sed -i -e "s/set barrel_Acceptance .*$/set barrel_Acceptance \{ 0.0 + 1.0 * fabs(eta) < ${RICHETA} \}/" propagate.tcl
4436

37+
### create LUTs
38+
BFIELDT=`awk -v a=$BFIELD 'BEGIN {print a*0.1}'`
39+
$DELPHESO2_ROOT/examples/scripts/create_luts.sh werner $BFIELDT $TOFRAD
40+
4541
### loop over runs
4642
rm -f .running.* delphes.*.root
4743
for I in $(seq 1 $NRUNS); do

examples/scripts/tof.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ echo "maxEta = $TOFETA"
1616

1717
### copy relevant files in the working directory
1818
cp $DELPHESO2_ROOT/examples/cards/propagate.2kG.tcl propagate.tcl
19-
cp $DELPHESO2_ROOT/examples/smearing/luts/lutCovm.* .
2019
cp $DELPHESO2_ROOT/examples/pythia8/pythia8_inel.cfg .
2120
cp $DELPHESO2_ROOT/examples/smearing/tof.C .
2221

@@ -35,6 +34,10 @@ sed -i -e "s/set barrel_Acceptance .*$/set barrel_Acceptance \{ 0.0 + 1.0 * fabs
3534
sed -i -e "s/set barrel_TimeResolution .*$/set barrel_TimeResolution ${SIGMAT}e\-9/" propagate.tcl
3635
sed -i -e "s/double tof_sigmat = .*$/double tof_sigmat = ${SIGMAT}\;/" tof.C
3736

37+
### create LUTs
38+
BFIELDT=`awk -v a=$BFIELD 'BEGIN {print a*0.1}'`
39+
$DELPHESO2_ROOT/examples/scripts/create_luts.sh werner $BFIELDT $TOFRAD
40+
3841
### loop over runs
3942
for I in $(seq 1 $NRUNS); do
4043

examples/smearing/rich.C

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
R__LOAD_LIBRARY(libDelphes)
22
R__LOAD_LIBRARY(libDelphesO2)
33

4-
double Bz = 0.2; // [T]
54
double rich_radius = 100.; // [cm]
65
double rich_length = 200.; // [cm]
76

@@ -33,22 +32,11 @@ rich(const char *inputFile = "delphes.root",
3332

3433
// smearer
3534
o2::delphes::TrackSmearer smearer;
36-
if (Bz == 0.2) {
37-
smearer.loadTable(11, "lutCovm.el.2kG.dat");
38-
smearer.loadTable(13, "lutCovm.mu.2kG.dat");
39-
smearer.loadTable(211, "lutCovm.pi.2kG.dat");
40-
smearer.loadTable(321, "lutCovm.ka.2kG.dat");
41-
smearer.loadTable(2212, "lutCovm.pr.2kG.dat");
42-
} else if (Bz == 0.5) {
43-
smearer.loadTable(11, "lutCovm.el.5kG.dat");
44-
smearer.loadTable(13, "lutCovm.mu.5kG.dat");
45-
smearer.loadTable(211, "lutCovm.pi.5kG.dat");
46-
smearer.loadTable(321, "lutCovm.ka.5kG.dat");
47-
smearer.loadTable(2212, "lutCovm.pr.5kG.dat");
48-
} else {
49-
std::cout << " --- invalid Bz field: " << Bz << std::endl;
50-
return;
51-
}
35+
smearer.loadTable(11, "lutCovm.el.dat");
36+
smearer.loadTable(13, "lutCovm.mu.dat");
37+
smearer.loadTable(211, "lutCovm.pi.dat");
38+
smearer.loadTable(321, "lutCovm.ka.dat");
39+
smearer.loadTable(2212, "lutCovm.pr.dat");
5240

5341
// logx binning
5442
const Int_t nbins = 80;

examples/smearing/tof.C

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
R__LOAD_LIBRARY(libDelphes)
22
R__LOAD_LIBRARY(libDelphesO2)
33

4-
double Bz = 0.2; // [T]
54
double tof_radius = 100.; // [cm]
65
double tof_length = 200.; // [cm]
76
double tof_sigmat = 0.02; // [ns]
@@ -31,22 +30,11 @@ tof(const char *inputFile = "delphes.root",
3130
// smearer
3231
o2::delphes::TrackSmearer smearer;
3332
smearer.useEfficiency(true);
34-
if (Bz == 0.2) {
35-
smearer.loadTable(11, "lutCovm.el.2kG.dat");
36-
smearer.loadTable(13, "lutCovm.mu.2kG.dat");
37-
smearer.loadTable(211, "lutCovm.pi.2kG.dat");
38-
smearer.loadTable(321, "lutCovm.ka.2kG.dat");
39-
smearer.loadTable(2212, "lutCovm.pr.2kG.dat");
40-
} else if (Bz == 0.5) {
41-
smearer.loadTable(11, "lutCovm.el.5kG.dat");
42-
smearer.loadTable(13, "lutCovm.mu.5kG.dat");
43-
smearer.loadTable(211, "lutCovm.pi.5kG.dat");
44-
smearer.loadTable(321, "lutCovm.ka.5kG.dat");
45-
smearer.loadTable(2212, "lutCovm.pr.5kG.dat");
46-
} else {
47-
std::cout << " --- invalid Bz field: " << Bz << std::endl;
48-
return;
49-
}
33+
smearer.loadTable(11, "lutCovm.el.dat");
34+
smearer.loadTable(13, "lutCovm.mu.dat");
35+
smearer.loadTable(211, "lutCovm.pi.dat");
36+
smearer.loadTable(321, "lutCovm.ka.dat");
37+
smearer.loadTable(2212, "lutCovm.pr.dat");
5038

5139
// histograms
5240
auto hTime0 = new TH1F("hTime0", ";t_{0} (ns)", 1000, -1., 1.);

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ install(TARGETS DelphesO2 DESTINATION lib)
5454

5555
install(FILES ${HEADERS} lutCovm.hh DESTINATION include)
5656

57+
FILE(GLOB WRITERS lutWrite.*.cc)
58+
install(FILES DetectorK/DetectorK.cxx DESTINATION lut/DetectorK)
59+
install(FILES DetectorK/DetectorK.h DESTINATION lut/DetectorK)
60+
install(FILES fwdRes/fwdRes.C DESTINATION lut/fwdRes)
61+
install(FILES lutWrite.cc ${WRITERS} DESTINATION lut)
62+
5763
install(FILES
5864
${CMAKE_CURRENT_BINARY_DIR}/libDelphesO2_rdict.pcm
5965
${CMAKE_CURRENT_BINARY_DIR}/libDelphesO2.rootmap

0 commit comments

Comments
 (0)