Skip to content

Commit 623dffe

Browse files
authored
Add more features for AOD making (#67)
- Update o2sim for geo making - Move util functions/classes to AOD header - Add tree of FTOF to AOD - Add more options in AOD creator script - Improve style
1 parent 8fa04c5 commit 623dffe

4 files changed

Lines changed: 287 additions & 193 deletions

File tree

examples/aod/createO2tables.C

Lines changed: 95 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ const double tof_radius = 100.; // [cm] Radius of the TOF detector (used to comp
3939
const double tof_length = 200.; // [cm] Length of the TOF detector (used to compute acceptance)
4040
const double tof_sigmat = 0.02; // [ns] Resolution of the TOF detector
4141
const double tof_sigmat0 = 0.2; // [ns] Time spread of the vertex
42+
// Forward TOF
43+
const double forward_tof_radius = 100.; // [cm] Radius of the Forward TOF detector (used to compute acceptance)
44+
const double forward_tof_radius_in = 10.; // [cm] Inner radius of the Forward TOF detector (used to compute acceptance)
45+
const double forward_tof_length = 200.; // [cm] Length of the Forward TOF detector (used to compute acceptance)
46+
const double forward_tof_sigmat = 0.02; // [ns] Resolution of the Forward TOF detector
47+
const double forward_tof_sigmat0 = 0.2; // [ns] Time spread of the vertex
4248
// RICH
4349
const double rich_radius = 100.; // [cm] Radius of the RICH detector (used to compute acceptance)
4450
const double rich_length = 200.; // [cm] Length of the RICH detector (used to compute acceptance)
@@ -52,65 +58,6 @@ const char* inputFileAccMuonPID = "muonAccEffPID.root";
5258
// Simulation parameters
5359
const bool do_vertexing = true;
5460

55-
// Class to hold the information for the O2 vertexing
56-
class TrackAlice3 : public o2::track::TrackParCov
57-
{
58-
using TimeEst = o2::dataformats::TimeStampWithError<float, float>;
59-
60-
public:
61-
TrackAlice3() = default;
62-
~TrackAlice3() = default;
63-
TrackAlice3(const TrackAlice3& src) = default;
64-
TrackAlice3(const o2::track::TrackParCov& src, const float t = 0, const float te = 1, const int label = 0) : o2::track::TrackParCov(src), timeEst{t, te}, mLabel{label} {}
65-
const TimeEst& getTimeMUS() const { return timeEst; }
66-
const int mLabel;
67-
TimeEst timeEst; ///< time estimate in ns
68-
};
69-
70-
template <typename T>
71-
bool IsSecondary(const T& particleTree, const int& index)
72-
{
73-
auto particle = (GenParticle*)particleTree->At(index);
74-
if (particle->M1 < 0) {
75-
return false;
76-
}
77-
78-
auto mother = (GenParticle*)particleTree->At(particle->M1);
79-
if (!mother) {
80-
return false;
81-
}
82-
// Ancore di salvezza :)
83-
if ((particle->M1 == particle->M2) && (particle->M1 == 0)) {
84-
return false;
85-
}
86-
if (abs(mother->PID) <= 8) {
87-
return false;
88-
}
89-
// 100% secondaries if true here
90-
switch (abs(mother->PID)) {
91-
// K0S
92-
case 310:
93-
// Lambda
94-
case 3122:
95-
// Sigma0
96-
case 3212:
97-
// Sigma-
98-
case 3112:
99-
// Sigma+
100-
case 3222:
101-
// Xi-
102-
case 3312:
103-
// Xi0
104-
case 3322:
105-
// Omega-
106-
case 3334:
107-
return true;
108-
break;
109-
}
110-
111-
return IsSecondary(particleTree, particle->M1);
112-
}
113-
11461
int createO2tables(const char* inputFile = "delphes.root",
11562
const char* outputFile = "AODRun5.root",
11663
int eventOffset = 0)
@@ -150,20 +97,29 @@ int createO2tables(const char* inputFile = "delphes.root",
15097
smearer.loadTable(2212, "lutCovm.pr.dat");
15198

15299
// TOF layer
153-
o2::delphes::TOFLayer toflayer;
154-
toflayer.setup(tof_radius, tof_length, tof_sigmat, tof_sigmat0);
100+
o2::delphes::TOFLayer tof_layer;
101+
tof_layer.setup(tof_radius, tof_length, tof_sigmat, tof_sigmat0);
102+
103+
// Forward TOF layer
104+
o2::delphes::TOFLayer forward_tof_layer;
105+
forward_tof_layer.setup(forward_tof_radius, forward_tof_length, forward_tof_sigmat, forward_tof_sigmat0);
106+
forward_tof_layer.setType(o2::delphes::TOFLayer::kForward);
107+
forward_tof_layer.setRadiusIn(forward_tof_radius_in);
108+
155109
// RICH layer
156-
o2::delphes::RICHdetector richdetector;
157-
richdetector.setup(rich_radius, rich_length);
158-
richdetector.setIndex(rich_index);
159-
richdetector.setRadiatorLength(rich_radiator_length);
160-
richdetector.setEfficiency(rich_efficiency);
161-
richdetector.setSigma(rich_sigma);
110+
o2::delphes::RICHdetector rich_detector;
111+
rich_detector.setup(rich_radius, rich_length);
112+
rich_detector.setIndex(rich_index);
113+
rich_detector.setRadiatorLength(rich_radiator_length);
114+
rich_detector.setEfficiency(rich_efficiency);
115+
rich_detector.setSigma(rich_sigma);
116+
162117
// MID detector
163-
o2::delphes::MIDdetector midDetector;
164-
printf("creating MID detector...\n");
165-
bool isMID = midDetector.setup(inputFileAccMuonPID);
166-
printf("isMID = %d\n", isMID);
118+
o2::delphes::MIDdetector mid_detector;
119+
const bool isMID = mid_detector.setup(inputFileAccMuonPID);
120+
if (isMID) {
121+
Printf("creating MID detector");
122+
}
167123

168124
// create output
169125
auto fout = TFile::Open(outputFile, "RECREATE");
@@ -172,6 +128,7 @@ int createO2tables(const char* inputFile = "delphes.root",
172128
MakeTreeO2track();
173129
MakeTreeO2trackCov();
174130
MakeTreeO2trackExtra();
131+
MakeTreeO2ftof();
175132
MakeTreeO2rich();
176133
MakeTreeO2mid();
177134
MakeTreeO2collision();
@@ -290,64 +247,65 @@ int createO2tables(const char* inputFile = "delphes.root",
290247
FillTree(kMcTrackLabel);
291248

292249
// set track information
293-
mytracks.fIndexCollisions = ientry + eventOffset;
294-
mytracks.fX = o2track.getX();
295-
mytracks.fAlpha = o2track.getAlpha();
296-
mytracks.fY = o2track.getY();
297-
mytracks.fZ = o2track.getZ();
298-
mytracks.fSnp = o2track.getSnp();
299-
mytracks.fTgl = o2track.getTgl();
300-
mytracks.fSigned1Pt = o2track.getQ2Pt();
250+
aod_track.fIndexCollisions = ientry + eventOffset;
251+
aod_track.fX = o2track.getX();
252+
aod_track.fAlpha = o2track.getAlpha();
253+
aod_track.fY = o2track.getY();
254+
aod_track.fZ = o2track.getZ();
255+
aod_track.fSnp = o2track.getSnp();
256+
aod_track.fTgl = o2track.getTgl();
257+
aod_track.fSigned1Pt = o2track.getQ2Pt();
301258

302259
// Modified covariance matrix
303260
// First sigmas on the diagonal
304-
mytracks.fSigmaY = TMath::Sqrt(o2track.getSigmaY2());
305-
mytracks.fSigmaZ = TMath::Sqrt(o2track.getSigmaZ2());
306-
mytracks.fSigmaSnp = TMath::Sqrt(o2track.getSigmaSnp2());
307-
mytracks.fSigmaTgl = TMath::Sqrt(o2track.getSigmaTgl2());
308-
mytracks.fSigma1Pt = TMath::Sqrt(o2track.getSigma1Pt2());
309-
310-
mytracks.fRhoZY = (Char_t)(128. * o2track.getSigmaZY() / mytracks.fSigmaZ / mytracks.fSigmaY);
311-
mytracks.fRhoSnpY = (Char_t)(128. * o2track.getSigmaSnpY() / mytracks.fSigmaSnp / mytracks.fSigmaY);
312-
mytracks.fRhoSnpZ = (Char_t)(128. * o2track.getSigmaSnpZ() / mytracks.fSigmaSnp / mytracks.fSigmaZ);
313-
mytracks.fRhoTglY = (Char_t)(128. * o2track.getSigmaTglY() / mytracks.fSigmaTgl / mytracks.fSigmaY);
314-
mytracks.fRhoTglZ = (Char_t)(128. * o2track.getSigmaTglZ() / mytracks.fSigmaTgl / mytracks.fSigmaZ);
315-
mytracks.fRhoTglSnp = (Char_t)(128. * o2track.getSigmaTglSnp() / mytracks.fSigmaTgl / mytracks.fSigmaSnp);
316-
mytracks.fRho1PtY = (Char_t)(128. * o2track.getSigma1PtY() / mytracks.fSigma1Pt / mytracks.fSigmaY);
317-
mytracks.fRho1PtZ = (Char_t)(128. * o2track.getSigma1PtZ() / mytracks.fSigma1Pt / mytracks.fSigmaZ);
318-
mytracks.fRho1PtSnp = (Char_t)(128. * o2track.getSigma1PtSnp() / mytracks.fSigma1Pt / mytracks.fSigmaSnp);
319-
mytracks.fRho1PtTgl = (Char_t)(128. * o2track.getSigma1PtTgl() / mytracks.fSigma1Pt / mytracks.fSigmaTgl);
261+
aod_track.fSigmaY = TMath::Sqrt(o2track.getSigmaY2());
262+
aod_track.fSigmaZ = TMath::Sqrt(o2track.getSigmaZ2());
263+
aod_track.fSigmaSnp = TMath::Sqrt(o2track.getSigmaSnp2());
264+
aod_track.fSigmaTgl = TMath::Sqrt(o2track.getSigmaTgl2());
265+
aod_track.fSigma1Pt = TMath::Sqrt(o2track.getSigma1Pt2());
266+
267+
aod_track.fRhoZY = (Char_t)(128. * o2track.getSigmaZY() / aod_track.fSigmaZ / aod_track.fSigmaY);
268+
aod_track.fRhoSnpY = (Char_t)(128. * o2track.getSigmaSnpY() / aod_track.fSigmaSnp / aod_track.fSigmaY);
269+
aod_track.fRhoSnpZ = (Char_t)(128. * o2track.getSigmaSnpZ() / aod_track.fSigmaSnp / aod_track.fSigmaZ);
270+
aod_track.fRhoTglY = (Char_t)(128. * o2track.getSigmaTglY() / aod_track.fSigmaTgl / aod_track.fSigmaY);
271+
aod_track.fRhoTglZ = (Char_t)(128. * o2track.getSigmaTglZ() / aod_track.fSigmaTgl / aod_track.fSigmaZ);
272+
aod_track.fRhoTglSnp = (Char_t)(128. * o2track.getSigmaTglSnp() / aod_track.fSigmaTgl / aod_track.fSigmaSnp);
273+
aod_track.fRho1PtY = (Char_t)(128. * o2track.getSigma1PtY() / aod_track.fSigma1Pt / aod_track.fSigmaY);
274+
aod_track.fRho1PtZ = (Char_t)(128. * o2track.getSigma1PtZ() / aod_track.fSigma1Pt / aod_track.fSigmaZ);
275+
aod_track.fRho1PtSnp = (Char_t)(128. * o2track.getSigma1PtSnp() / aod_track.fSigma1Pt / aod_track.fSigmaSnp);
276+
aod_track.fRho1PtTgl = (Char_t)(128. * o2track.getSigma1PtTgl() / aod_track.fSigma1Pt / aod_track.fSigmaTgl);
320277

321278
//FIXME this needs to be fixed
322-
mytracks.fITSClusterMap = 3;
323-
mytracks.fFlags = 4;
279+
aod_track.fITSClusterMap = 3;
280+
aod_track.fFlags = 4;
324281

325282
//FIXME this also needs to be fixed
326-
mytracks.fTrackEtaEMCAL = 0; //track->GetTrackEtaOnEMCal();
327-
mytracks.fTrackPhiEMCAL = 0; //track->GetTrackPhiOnEMCal();
283+
aod_track.fTrackEtaEMCAL = 0; //track->GetTrackEtaOnEMCal();
284+
aod_track.fTrackPhiEMCAL = 0; //track->GetTrackPhiOnEMCal();
328285

329286
// check if has hit the TOF
330-
if (toflayer.hasTOF(*track)) {
331-
mytracks.fLength = track->L * 0.1; // [cm]
332-
mytracks.fTOFSignal = track->TOuter * 1.e12; // [ps]
333-
mytracks.fTOFExpMom = track->P * 0.029979246;
287+
if (tof_layer.hasTOF(*track)) {
288+
aod_track.fLength = track->L * 0.1; // [cm]
289+
aod_track.fTOFSignal = track->TOuter * 1.e12; // [ps]
290+
aod_track.fTOFExpMom = track->P * 0.029979246;
334291
// if primary push to TOF tracks
335-
if (fabs(mytracks.fY) < 3. * mytracks.fSigmaY && fabs(mytracks.fZ) < 3. * mytracks.fSigmaZ)
292+
if (fabs(aod_track.fY) < 3. * aod_track.fSigmaY && fabs(aod_track.fZ) < 3. * aod_track.fSigmaZ)
336293
tof_tracks.push_back(track);
337294
} else {
338-
mytracks.fLength = -999.f;
339-
mytracks.fTOFSignal = -999.f;
340-
mytracks.fTOFExpMom = -999.f;
295+
aod_track.fLength = -999.f;
296+
aod_track.fTOFSignal = -999.f;
297+
aod_track.fTOFExpMom = -999.f;
341298
}
299+
342300
// check if has hit on RICH
343-
if (richdetector.hasRICH(*track)) {
344-
const auto measurement = richdetector.getMeasuredAngle(*track);
301+
if (rich_detector.hasRICH(*track)) {
302+
const auto measurement = rich_detector.getMeasuredAngle(*track);
345303
rich.fIndexCollisions = ientry + eventOffset;
346304
rich.fIndexTracks = fTrackCounter; // Index in the Track table
347305
rich.fRICHSignal = measurement.first;
348306
rich.fRICHSignalError = measurement.second;
349307
std::array<float, 5> deltaangle, nsigma;
350-
richdetector.makePID(*track, deltaangle, nsigma);
308+
rich_detector.makePID(*track, deltaangle, nsigma);
351309
rich.fRICHDeltaEl = deltaangle[0];
352310
rich.fRICHDeltaMu = deltaangle[1];
353311
rich.fRICHDeltaPi = deltaangle[2];
@@ -360,12 +318,36 @@ int createO2tables(const char* inputFile = "delphes.root",
360318
rich.fRICHNsigmaPr = nsigma[4];
361319
FillTree(kRICH);
362320
}
321+
322+
// check if has Forward TOF
323+
if (forward_tof_layer.hasTOF(*track)) {
324+
ftof.fIndexCollisions = ientry + eventOffset;
325+
ftof.fIndexTracks = fTrackCounter; // Index in the Track table
326+
327+
ftof.fFTOFLength = track->L * 0.1; // [cm]
328+
ftof.fFTOFSignal = track->TOuter * 1.e12; // [ps]
329+
330+
std::array<float, 5> deltat, nsigma;
331+
forward_tof_layer.makePID(*track, deltat, nsigma);
332+
ftof.fFTOFDeltaEl = deltat[0];
333+
ftof.fFTOFDeltaMu = deltat[1];
334+
ftof.fFTOFDeltaPi = deltat[2];
335+
ftof.fFTOFDeltaKa = deltat[3];
336+
ftof.fFTOFDeltaPr = deltat[4];
337+
ftof.fFTOFNsigmaEl = nsigma[0];
338+
ftof.fFTOFNsigmaMu = nsigma[1];
339+
ftof.fFTOFNsigmaPi = nsigma[2];
340+
ftof.fFTOFNsigmaKa = nsigma[3];
341+
ftof.fFTOFNsigmaPr = nsigma[4];
342+
FillTree(kFTOF);
343+
}
344+
363345
// check if it is within the acceptance of the MID
364346
if (isMID) {
365-
if (midDetector.hasMID(*track)) {
347+
if (mid_detector.hasMID(*track)) {
366348
mid.fIndexCollisions = ientry + eventOffset;
367349
mid.fIndexTracks = fTrackCounter; // Index in the Track table
368-
mid.fMIDIsMuon = midDetector.isMuon(*track, multiplicity);
350+
mid.fMIDIsMuon = mid_detector.isMuon(*track, multiplicity);
369351
FillTree(kMID);
370352
}
371353
}
@@ -395,7 +377,7 @@ int createO2tables(const char* inputFile = "delphes.root",
395377

396378
// compute the event time
397379
std::array<float, 2> tzero;
398-
if (!toflayer.eventTime(tof_tracks, tzero) && tof_tracks.size() > 0) {
380+
if (!tof_layer.eventTime(tof_tracks, tzero) && tof_tracks.size() > 0) {
399381
Printf("Issue when evaluating the start time");
400382
return 1;
401383
}

0 commit comments

Comments
 (0)