Skip to content

Commit 9b73f2d

Browse files
committed
Initial work to bring TOF mismatch to public
1 parent c5b3845 commit 9b73f2d

File tree

2 files changed

+65
-27
lines changed

2 files changed

+65
-27
lines changed

examples/scripts/tof.sh

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
#! /usr/bin/env bash
22

3-
NJOBS=5 # number of max parallel runs
4-
NRUNS=10 # number of runs
5-
NEVENTS=10000 # number of events in a run
3+
NJOBS=5 # number of max parallel runs
4+
NRUNS=10 # number of runs
5+
NEVENTS=10000 # number of events in a run
66

7-
LUTTAG="werner" # LUT tag name
8-
BFIELD=5. # magnetic field [kG]
9-
SIGMAT=0.020 # time resolution [ns]
10-
SIGMA0=0.200 # vertex time spread [ns]
11-
TAILLX=1.0 # tail on left [q]
12-
TAILRX=1.3 # tail on right [q]
13-
TOFRAD=100. # TOF radius [cm]
14-
TOFLEN=200. # TOF half length [cm]
15-
TOFETA=1.443 # TOF max pseudorapidity
7+
LUTTAG="werner" # LUT tag name
8+
PY8CFG="pythia8_ccbar" # pythia8 configuration
9+
BFIELD=5. # magnetic field [kG]
10+
SIGMAT=0.020 # time resolution [ns]
11+
SIGMA0=0.200 # vertex time spread [ns]
12+
TAILLX=1.0 # tail on left [q]
13+
TAILRX=1.0 # tail on right [q]
14+
TOFRAD=100. # TOF radius [cm]
15+
TOFLEN=200. # TOF half length [cm]
16+
TOFETA=1.443 # TOF max pseudorapidity
1617

1718
### calculate max eta from geometry
1819
TOFETA=`awk -v a=$TOFRAD -v b=$TOFLEN 'BEGIN {th=atan2(a,b)*0.5; sth=sin(th); cth=cos(th); print -log(sth/cth)}'`
1920
echo "maxEta = $TOFETA"
2021

2122
### copy relevant files in the working directory
2223
cp $DELPHESO2_ROOT/examples/cards/propagate.2kG.tails.tcl propagate.tcl
23-
cp $DELPHESO2_ROOT/examples/pythia8/pythia8_inel.cfg .
24+
cp $DELPHESO2_ROOT/examples/pythia8/$PY8CFG.cfg pythia8.cfg
2425
cp $DELPHESO2_ROOT/examples/smearing/tof.C .
2526

27+
### adjust pythia8 configuration
28+
echo "" >> pythia8.cfg
29+
echo "### run time configuration" >> pythia8.cfg
30+
echo "Main:numberOfEvents $NEVENTS" >> pythia8.cfg
31+
echo "Beams:allowVertexSpread on " >> pythia8.cfg
32+
echo "Beams:sigmaTime 60." >> pythia8.cfg
33+
2634
### set magnetic field
2735
sed -i -e "s/set barrel_Bz .*$/set barrel_Bz ${BFIELD}e\-1/" propagate.tcl
2836
### set TOF radius
@@ -39,6 +47,9 @@ sed -i -e "s/set barrel_TailRight .*$/set barrel_TailRight ${TAILRX}/" propagate
3947
sed -i -e "s/set barrel_TailLeft .*$/set barrel_TailLeft ${TAILLX}/" propagate.tcl
4048
sed -i -e "s/double tof_sigmat = .*$/double tof_sigmat = ${SIGMAT}\;/" tof.C
4149
sed -i -e "s/double tof_sigma0 = .*$/double tof_sigma0 = ${SIGMA0}\;/" tof.C
50+
### set TOF mismatch information
51+
sed -i -e "s/double tof_mismatch.*$/double tof_mismatch = 0.01;/" tof.C
52+
#sed -i -e "s/std::string tof_mismatch_fname.*$/std::string tof_mismatch_fname = \"tof_mismatch_template.root\";/" tof.C
4253

4354
### create LUTs
4455
BFIELDT=`awk -v a=$BFIELD 'BEGIN {print a*0.1}'`
@@ -58,12 +69,10 @@ for I in $(seq 1 $NRUNS); do
5869
echo " --- starting run $I"
5970
touch .running.$I
6071

61-
### copy pythia8 configuration and adjust it
62-
cp pythia8_inel.cfg pythia8.$I.cfg
63-
echo "Main:numberOfEvents $NEVENTS" >> pythia8.$I.cfg
72+
### copy pythia8 configuration and set random seed
73+
cp pythia8.cfg pythia8.$I.cfg
74+
echo "Random:setSeed on" >> pythia8.$I.cfg
6475
echo "Random:seed = $I" >> pythia8.$I.cfg
65-
echo "Beams:allowVertexSpread on " >> pythia8.$I.cfg
66-
echo "Beams:sigmaTime 60." >> pythia8.$I.cfg
6776

6877
### run Delphes and analysis
6978
DelphesPythia8 propagate.tcl pythia8.$I.cfg delphes.$I.root &> delphes.$I.log &&

examples/smearing/tof.C

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ double tof_length = 200.; // [cm]
66
double tof_sigmat = 0.02; // [ns]
77
double tof_sigma0 = 0.20; // [ns]
88

9+
double tof_mismatch = 0.01;
10+
std::string tof_mismatch_fname;
11+
912
void
1013
tof(const char *inputFile = "delphes.root",
1114
const char *outputFile = "tof.root")
@@ -45,23 +48,33 @@ tof(const char *inputFile = "delphes.root",
4548
double logxmax = std::log10(xmax);
4649
double binwidth = (logxmax - logxmin) / nbins;
4750
double xbins[nbins + 1];
48-
xbins[0] = xmin;
49-
for (Int_t i = 1; i <= nbins; ++i)
50-
xbins[i] = xmin + std::pow(10., logxmin + i * binwidth);
51+
for (Int_t i = 0; i <= nbins; ++i)
52+
xbins[i] = std::pow(10., logxmin + i * binwidth);
5153

5254
// histograms
5355
auto hTime0 = new TH1F("hTime0", ";t_{0} (ns)", 1000, -1., 1.);
5456
auto hBetaP = new TH2F("hBetaP", ";#it{p} (GeV/#it{c});#beta", nbins, xbins, 1000, 0.1, 1.1);
57+
TH2 *hHit = new TH2F("hHit", ";#eta;#it{p}_{T} (GeV/#it{c})", 200, -4., 4., nbins, xbins);
5558
TH2 *hNsigmaPt[5], *hNsigmaPt_true[5][5];
5659
const char *pname[5] = {"el", "mu", "pi", "ka", "pr"};
5760
const char *plabel[5] = {"e", "#mu", "#pi", "K", "p"};
5861
for (int i = 0; i < 5; ++i) {
59-
hNsigmaPt[i] = new TH2F(Form("hNsigmaPt_%s", pname[i]), Form(";#it{p_{T}} (GeV/#it{c});n#sigma_{%s}", plabel[i]), nbins, xbins, 200, -10., 10.);
62+
hNsigmaPt[i] = new TH2F(Form("hNsigmaPt_%s", pname[i]), Form(";#it{p_{T}} (GeV/#it{c});n#sigma_{%s}", plabel[i]), nbins, xbins, 500, -25., 25.);
6063
for (int j = 0; j < 5; ++j) {
61-
hNsigmaPt_true[i][j] = new TH2F(Form("hNsigmaPt_%s_true_%s", pname[i], pname[j]), Form(";#it{p_{T}} (GeV/#it{c});n#sigma_{%s}", plabel[i]), nbins, xbins, 200, -10., 10.);
64+
hNsigmaPt_true[i][j] = new TH2F(Form("hNsigmaPt_%s_true_%s", pname[i], pname[j]), Form(";#it{p_{T}} (GeV/#it{c});n#sigma_{%s}", plabel[i]), nbins, xbins, 500, -25., 25.);
6265
}
6366
}
64-
67+
auto hMismatchTemplateOut = new TH1F("hMismatchTemplate", "", 3000., -5., 25.);
68+
69+
// read mismatch template if requested
70+
TH1 *hMismatchTemplateIn = nullptr;
71+
if (!tof_mismatch_fname.empty()) {
72+
auto fmismatch = TFile::Open(tof_mismatch_fname.c_str());
73+
hMismatchTemplateIn = (TH1 *)fmismatch->Get("hMismatchTemplate");
74+
hMismatchTemplateIn->SetDirectory(0);
75+
fmismatch->Close();
76+
}
77+
6578
std::map<int, int> pidmap = { {11, 0}, {13, 1}, {211, 2}, {321, 3}, {2212, 4} };
6679

6780
for (Int_t ientry = 0; ientry < numberOfEntries; ++ientry) {
@@ -80,13 +93,27 @@ tof(const char *inputFile = "delphes.root",
8093
// smear track
8194
if (!smearer.smearTrack(*track)) continue;
8295

96+
// check if has TOF
97+
if (!toflayer.hasTOF(*track)) continue;
98+
99+
// fill output mismatch template
100+
auto L = std::sqrt(track->XOuter * track->XOuter +
101+
track->YOuter * track->YOuter +
102+
track->ZOuter * track->ZOuter);
103+
hMismatchTemplateOut->Fill(track->TOuter * 1.e9 - L / 299.79246);
104+
105+
// do some random mismatch
106+
if (hMismatchTemplateIn && gRandom->Uniform() < tof_mismatch) {
107+
track->TOuter = (hMismatchTemplateIn->GetRandom() + L / 299.79246) * 1.e-9;
108+
}
109+
83110
// select primaries based on 3 sigma DCA cuts
84111
if (fabs(track->D0 / track->ErrorD0) > 3.) continue;
85112
if (fabs(track->DZ / track->ErrorDZ) > 3.) continue;
86113

87-
// check if has TOF
88-
if (!toflayer.hasTOF(*track)) continue;
89-
114+
// fill hit histogram with true (eta,pt)
115+
hHit->Fill(particle->Eta, particle->PT);
116+
90117
// push track
91118
tof_tracks.push_back(track);
92119

@@ -123,6 +150,8 @@ tof(const char *inputFile = "delphes.root",
123150
auto fout = TFile::Open(outputFile, "RECREATE");
124151
hTime0->Write();
125152
hBetaP->Write();
153+
hHit->Write();
154+
hMismatchTemplateOut->Write();
126155
for (int i = 0; i < 5; ++i) {
127156
hNsigmaPt[i]->Write();
128157
for (int j = 0; j < 5; ++j) {

0 commit comments

Comments
 (0)