Skip to content

Commit d064539

Browse files
committed
add comparison with MC truth for TOF
1 parent 7b6a2f2 commit d064539

File tree

3 files changed

+82
-23
lines changed

3 files changed

+82
-23
lines changed

Modules/PID/src/TaskFT0TOF.cxx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,17 @@ void TaskFT0TOF::monitorData(o2::framework::ProcessingContext& ctx)
353353
mMyTracks.clear();
354354

355355
// Get FT0 RecPointss
356-
// const gsl::span<o2::ft0::RecPoints>* ft0rec = nullptr;
357-
const std::vector<o2::ft0::RecPoints>* ft0rec = nullptr;
356+
std::vector<o2::ft0::RecPoints> ft0Sorted;
358357
if (mUseFT0) {
359358
auto& obj = ctx.inputs().get<const std::vector<o2::ft0::RecPoints>>("recpoints");
360-
// const auto& obj = mRecoCont.getFT0RecPoints();
361-
ft0rec = &obj;
359+
for (const auto& o : obj) {
360+
// ILOG(Info, Support) << "cand -> " << o.mIntRecord.orbit <<ENDM;
361+
ft0Sorted.push_back(o);
362+
}
362363
}
363364

364365
if (mUseFT0) {
365-
ILOG(Info, Support) << "FT0 rec points loaded, size = " << ft0rec->size() << ENDM;
366+
ILOG(Info, Support) << "FT0 rec points loaded, size = " << ft0Sorted.size() << ENDM;
366367
} else {
367368
ILOG(Info, Support) << "FT0 rec points NOT available" << ENDM;
368369
}
@@ -469,19 +470,15 @@ void TaskFT0TOF::monitorData(o2::framework::ProcessingContext& ctx)
469470
} // END if track is ITS-TPC-TRD-TOF
470471

471472
std::vector<MyTrack> tracks;
472-
std::vector<o2::ft0::RecPoints> ft0Sorted;
473473

474-
if (mUseFT0) {
475-
ft0Sorted = *ft0rec;
476-
}
477474
std::vector<o2::ft0::RecPoints> ft0Cand;
478475

479476
// sorting matching in time
480477
std::sort(mMyTracks.begin(), mMyTracks.end(),
481478
[](MyTrack a, MyTrack b) { return a.tofSignalDouble() < b.tofSignalDouble(); });
482479

483480
std::sort(ft0Sorted.begin(), ft0Sorted.end(),
484-
[](o2::ft0::RecPoints a, o2::ft0::RecPoints b) { return a.getInteractionRecord().bc2ns() < b.getInteractionRecord().bc2ns(); });
481+
[](o2::ft0::RecPoints a, o2::ft0::RecPoints b) { return a.mIntRecord.bc2ns() < b.mIntRecord.bc2ns(); });
485482

486483
int ift0 = 0;
487484

@@ -513,12 +510,15 @@ void TaskFT0TOF::monitorData(o2::framework::ProcessingContext& ctx)
513510
double firstTime = tracks[0].tofSignalDouble() - 8 * o2::tof::Geo::BC_TIME_INPS;
514511
double lastTime = tracks[ntrk - 1].tofSignalDouble() + 8 * o2::tof::Geo::BC_TIME_INPS;
515512
for (int j = ift0; j < ft0Sorted.size(); j++) {
516-
auto& obj = ft0Sorted[j];
517-
if (obj.getInteractionRecord().orbit < ft0firstOrbit) {
513+
const auto& obj = ft0Sorted[j];
514+
if (obj.mIntRecord.orbit < ft0firstOrbit) {
515+
ILOG(Info, Support) << "FT0 orbit comes first the first sampled one -> " << obj.mIntRecord.orbit << " - " << ft0firstOrbit << ENDM;
518516
continue; // skip FT0 objects from previous orbits
519517
}
520-
uint32_t orbit = obj.getInteractionRecord().orbit - ft0firstOrbit;
521-
double BCtimeFT0 = ((orbit)*o2::constants::lhc::LHCMaxBunches + obj.getInteractionRecord().bc) * o2::tof::Geo::BC_TIME_INPS;
518+
uint32_t orbit = obj.mIntRecord.orbit - ft0firstOrbit;
519+
double BCtimeFT0 = ((orbit)*o2::constants::lhc::LHCMaxBunches + obj.mIntRecord.bc) * o2::tof::Geo::BC_TIME_INPS;
520+
521+
// ILOG(Info, Support) << "orbit " << orbit << "-> time (ps) " << BCtimeFT0 <<ENDM;
522522

523523
if (BCtimeFT0 < firstTime) {
524524
ift0 = j + 1;
@@ -528,12 +528,12 @@ void TaskFT0TOF::monitorData(o2::framework::ProcessingContext& ctx)
528528
break;
529529
}
530530
// ILOG(Info, Support) << " TOF first=" << firstTime << " < " << BCtimeFT0 << " < TOF last=" << lastTime << ENDM;
531-
// ILOG(Info, Support) << " orbit=" << obj.getInteractionRecord().orbit << " " << obj.getInteractionRecord().orbit - ft0firstOrbit << " BC=" << obj.getInteractionRecord().bc << ENDM;
531+
// ILOG(Info, Support) << " orbit=" << obj.mIntRecord.orbit << " " << obj.mIntRecord.orbit - ft0firstOrbit << " BC=" << obj.mIntRecord.bc << ENDM;
532532

533533
std::array<short, 4> collTimes = { obj.getCollisionTime(0), obj.getCollisionTime(1), obj.getCollisionTime(2), obj.getCollisionTime(3) };
534534

535535
int pos = ft0Cand.size();
536-
ft0Cand.emplace_back(collTimes, 0, 0, o2::InteractionRecord{ obj.getInteractionRecord().bc, orbit }, obj.getTrigger());
536+
ft0Cand.emplace_back(collTimes, 0, 0, o2::InteractionRecord{ obj.mIntRecord.bc, orbit }, obj.getTrigger());
537537
}
538538
}
539539

@@ -557,14 +557,14 @@ void TaskFT0TOF::monitorData(o2::framework::ProcessingContext& ctx)
557557
if (!ft0.isValidTime(0)) {
558558
continue; // skip invalid FT0AC times
559559
}
560-
if (ft0firstOrbit > ft0.getInteractionRecord().orbit) {
560+
if (ft0firstOrbit > ft0.mIntRecord.orbit) {
561561
continue; // skip FT0 objects from previous orbits
562562
}
563563
if (abs(ft0.getCollisionTime(0)) > 1000) {
564564
continue; // skip bad FT0 time (not from collisions)
565565
}
566566

567-
double ft0time = ((ft0.getInteractionRecord().orbit - ft0firstOrbit) * o2::constants::lhc::LHCMaxBunches + ft0.getInteractionRecord().bc) * o2::tof::Geo::BC_TIME_INPS + ft0.getCollisionTime(0);
567+
double ft0time = ((ft0.mIntRecord.orbit - ft0firstOrbit) * o2::constants::lhc::LHCMaxBunches + ft0.mIntRecord.bc) * o2::tof::Geo::BC_TIME_INPS + ft0.getCollisionTime(0);
568568
double timemax = ft0time + 100E3;
569569
double timemin = ft0time - 30E3;
570570

@@ -679,11 +679,11 @@ void TaskFT0TOF::processEvent(const std::vector<MyTrack>& tracks, const std::vec
679679
mHistDeltaEvTimeTOFVsFT0C->Fill(times[0] - times[3]);
680680

681681
// if same BC
682-
if (nBC % o2::constants::lhc::LHCMaxBunches == obj.getInteractionRecord().bc) {
682+
if (nBC % o2::constants::lhc::LHCMaxBunches == obj.mIntRecord.bc) {
683683
// no need for condition on orbit we select FT0 candidates within 8 BCs
684-
FT0evTimes[0] = obj.getInteractionRecord().bc2ns() * 1E3 + times[1];
685-
FT0evTimes[1] = obj.getInteractionRecord().bc2ns() * 1E3 + times[2];
686-
FT0evTimes[2] = obj.getInteractionRecord().bc2ns() * 1E3 + times[3];
684+
FT0evTimes[0] = obj.mIntRecord.bc2ns() * 1E3 + times[1];
685+
FT0evTimes[1] = obj.mIntRecord.bc2ns() * 1E3 + times[2];
686+
FT0evTimes[2] = obj.mIntRecord.bc2ns() * 1E3 + times[3];
687687
mHistEvTimeTOFVsFT0ACSameBC->Fill(times[0], times[1]);
688688
mHistEvTimeTOFVsFT0ASameBC->Fill(times[0], times[2]);
689689
mHistEvTimeTOFVsFT0CSameBC->Fill(times[0], times[3]);
@@ -692,7 +692,7 @@ void TaskFT0TOF::processEvent(const std::vector<MyTrack>& tracks, const std::vec
692692
mHistDeltaEvTimeTOFVsFT0CSameBC->Fill(times[0] - times[3]);
693693
}
694694

695-
mHistDeltaBCTOFFT0->Fill(nBC % o2::constants::lhc::LHCMaxBunches - obj.getInteractionRecord().bc);
695+
mHistDeltaBCTOFFT0->Fill(nBC % o2::constants::lhc::LHCMaxBunches - obj.mIntRecord.bc);
696696
}
697697
}
698698

Modules/TOF/include/TOF/TOFMatchedTracks.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ class TOFMatchedTracks final : public TaskInterface
125125
TH2F* mDTimeTrk[18] = {};
126126
TH2F* mDTimeTrkTPC[18] = {};
127127
TH2F* mDTimeTrkTRD[18] = {};
128+
TH1F* mDeltaTwMC;
129+
TH2F* mExpTimesPiMC[matchType::SIZE] = {};
130+
TH2F* mExpTimesKaMC[matchType::SIZE] = {};
131+
TH2F* mExpTimesPrMC[matchType::SIZE] = {};
128132

129133
TEfficiency* mEffPt[matchType::SIZE] = {};
130134
TEfficiency* mEffEta[matchType::SIZE] = {};

Modules/TOF/src/TOFMatchedTracks.cxx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,20 @@ namespace o2::quality_control_modules::tof
4545

4646
TOFMatchedTracks::~TOFMatchedTracks()
4747
{
48+
if (mUseMC) {
49+
delete mDeltaTwMC;
50+
}
51+
4852
for (int i = 0; i < matchType::SIZE; ++i) {
4953
delete mMatchedTracksPt[i];
5054
delete mMatchedTracksEta[i];
5155
delete mMatchedTracks2DPtEta[i];
5256
if (mUseMC) {
5357
delete mFakeMatchedTracksPt[i];
5458
delete mFakeMatchedTracksEta[i];
59+
delete mExpTimesPiMC[i];
60+
delete mExpTimesKaMC[i];
61+
delete mExpTimesPrMC[i];
5562
}
5663
delete mInTracksPt[i];
5764
delete mInTracksEta[i];
@@ -142,6 +149,11 @@ void TOFMatchedTracks::initialize(o2::framework::InitContext& /*ctx*/)
142149
}
143150

144151
std::array<std::string, 3> title{ "TPC", "ITSTPC-ITSTPCTRD", "TPCTRD" };
152+
153+
if (mUseMC) {
154+
mDeltaTwMC = new TH1F("mDeltaTwMC", "all types;t_{TOF} - t^{0}_{MC} - t_{geant} (ps)", 100, -500, 500);
155+
}
156+
145157
for (int i = 0; i < matchType::SIZE; ++i) {
146158
mInTracksPt[i] = new TH1F(Form("mInTracksPt_%s", title[i].c_str()), Form("mInTracksPt (matchType: %s); #it{p}_{T}; counts", title[i].c_str()), 100, 0.f, 20.f);
147159
mInTracksEta[i] = new TH1F(Form("mInTracksEta_%s", title[i].c_str()), Form("mInTracksEta (matchType: %s); #eta; counts", title[i].c_str()), 100, -1.0f, 1.0f);
@@ -154,6 +166,9 @@ void TOFMatchedTracks::initialize(o2::framework::InitContext& /*ctx*/)
154166
mFakeMatchedTracksEta[i] = new TH1F(Form("mFakeMatchedTracksEta_%s", title[i].c_str()), Form("mFakeMatchedTracksEta (matchType: %s); #eta; counts", title[i].c_str()), 100, -1.0f, 1.0f);
155167
mFakeFractionTracksPt[i] = new TEfficiency(Form("mFakeFractionPt_%s", title[i].c_str()), Form("Fraction of fake matches vs Pt (matchType: %s); #it{p}_{T}; Eff", title[i].c_str()), 100, 0.f, 20.f);
156168
mFakeFractionTracksEta[i] = new TEfficiency(Form("mFakeFractionEta_%s", title[i].c_str()), Form("Fraction of fake matches vs Eta (matchType: %s); #eta; Eff", title[i].c_str()), 100, -1.0f, 1.0f);
169+
mExpTimesPiMC[i] = new TH2F(Form("mExpTimesPiMC_%s", title[i].c_str()), ";p_{T} (GeV/c);t_{geant} - t_{exp}^{#pi} (ps)", 10, 0, 2, 100, -1000, 1000);
170+
mExpTimesKaMC[i] = new TH2F(Form("mExpTimesKaMC_%s", title[i].c_str()), ";p_{T} (GeV/c);t_{geant} - t_{exp}^{K} (ps)", 10, 0, 2, 100, -1000, 1000);
171+
mExpTimesPrMC[i] = new TH2F(Form("mExpTimesPrMC_%s", title[i].c_str()), ";p_{T} (GeV/c);t_{geant} - t_{exp}^{p} (ps)", 10, 0, 2, 100, -1000, 1000);
157172
}
158173
mEffPt[i] = new TEfficiency(Form("mEffPt_%s", title[i].c_str()), Form("Efficiency vs Pt (matchType: %s); #it{p}_{T}; Eff", title[i].c_str()), 100, 0.f, 20.f);
159174
mEffEta[i] = new TEfficiency(Form("mEffEta_%s", title[i].c_str()), Form("Efficiency vs Eta (matchType: %s); #eta; Eff", title[i].c_str()), 100, -1.f, 1.f);
@@ -181,6 +196,10 @@ void TOFMatchedTracks::initialize(o2::framework::InitContext& /*ctx*/)
181196
}
182197
}
183198

199+
if (mUseMC) {
200+
getObjectsManager()->startPublishing(mDeltaTwMC);
201+
}
202+
184203
if (mSrc[GID::Source::TPCTOF] == 1) {
185204
getObjectsManager()->startPublishing(mInTracksPt[matchType::TPC]);
186205
getObjectsManager()->startPublishing(mInTracksEta[matchType::TPC]);
@@ -193,6 +212,9 @@ void TOFMatchedTracks::initialize(o2::framework::InitContext& /*ctx*/)
193212
getObjectsManager()->startPublishing(mFakeMatchedTracksEta[matchType::TPC]);
194213
getObjectsManager()->startPublishing(mFakeFractionTracksPt[matchType::TPC]);
195214
getObjectsManager()->startPublishing(mFakeFractionTracksEta[matchType::TPC]);
215+
getObjectsManager()->startPublishing(mExpTimesPiMC[matchType::TPC]);
216+
getObjectsManager()->startPublishing(mExpTimesKaMC[matchType::TPC]);
217+
getObjectsManager()->startPublishing(mExpTimesPrMC[matchType::TPC]);
196218
}
197219
getObjectsManager()->startPublishing(mEffPt[matchType::TPC]);
198220
getObjectsManager()->startPublishing(mEffEta[matchType::TPC]);
@@ -219,6 +241,9 @@ void TOFMatchedTracks::initialize(o2::framework::InitContext& /*ctx*/)
219241
getObjectsManager()->startPublishing(mFakeMatchedTracksEta[matchType::TPCTRD]);
220242
getObjectsManager()->startPublishing(mFakeFractionTracksPt[matchType::TPCTRD]);
221243
getObjectsManager()->startPublishing(mFakeFractionTracksEta[matchType::TPCTRD]);
244+
getObjectsManager()->startPublishing(mExpTimesPiMC[matchType::TPCTRD]);
245+
getObjectsManager()->startPublishing(mExpTimesKaMC[matchType::TPCTRD]);
246+
getObjectsManager()->startPublishing(mExpTimesPrMC[matchType::TPCTRD]);
222247
}
223248
getObjectsManager()->startPublishing(mEffPt[matchType::TPCTRD]);
224249
getObjectsManager()->startPublishing(mEffEta[matchType::TPCTRD]);
@@ -245,6 +270,9 @@ void TOFMatchedTracks::initialize(o2::framework::InitContext& /*ctx*/)
245270
getObjectsManager()->startPublishing(mFakeMatchedTracksEta[matchType::ITSTPC_ITSTPCTRD]);
246271
getObjectsManager()->startPublishing(mFakeFractionTracksPt[matchType::ITSTPC_ITSTPCTRD]);
247272
getObjectsManager()->startPublishing(mFakeFractionTracksEta[matchType::ITSTPC_ITSTPCTRD]);
273+
getObjectsManager()->startPublishing(mExpTimesPiMC[matchType::ITSTPC_ITSTPCTRD]);
274+
getObjectsManager()->startPublishing(mExpTimesKaMC[matchType::ITSTPC_ITSTPCTRD]);
275+
getObjectsManager()->startPublishing(mExpTimesPrMC[matchType::ITSTPC_ITSTPCTRD]);
248276
}
249277
getObjectsManager()->startPublishing(mEffPt[matchType::ITSTPC_ITSTPCTRD]);
250278
getObjectsManager()->startPublishing(mEffEta[matchType::ITSTPC_ITSTPCTRD]);
@@ -356,6 +384,11 @@ void TOFMatchedTracks::monitorData(o2::framework::ProcessingContext& ctx)
356384
if (lbl.isFake()) {
357385
mFakeMatchedTracksPt[matchType::TPC]->Fill(trk.getPt());
358386
mFakeMatchedTracksEta[matchType::TPC]->Fill(trk.getEta());
387+
} else {
388+
mDeltaTwMC->Fill(matchTOF.getSignal() - matchTOF.getT0true() - matchTOF.getTgeant() * 1E3);
389+
mExpTimesPiMC[matchType::TPC]->Fill(trk.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(2));
390+
mExpTimesKaMC[matchType::TPC]->Fill(trk.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(3));
391+
mExpTimesPrMC[matchType::TPC]->Fill(trk.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(4));
359392
}
360393
}
361394
}
@@ -418,6 +451,11 @@ void TOFMatchedTracks::monitorData(o2::framework::ProcessingContext& ctx)
418451
if (lbl.isFake()) {
419452
mFakeMatchedTracksPt[matchType::ITSTPC_ITSTPCTRD]->Fill(trkTPC.getPt());
420453
mFakeMatchedTracksEta[matchType::ITSTPC_ITSTPCTRD]->Fill(trkTPC.getEta());
454+
} else {
455+
mDeltaTwMC->Fill(matchTOF.getSignal() - matchTOF.getT0true() - matchTOF.getTgeant() * 1E3);
456+
mExpTimesPiMC[matchType::ITSTPC_ITSTPCTRD]->Fill(trkTPC.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(2));
457+
mExpTimesKaMC[matchType::ITSTPC_ITSTPCTRD]->Fill(trkTPC.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(3));
458+
mExpTimesPrMC[matchType::ITSTPC_ITSTPCTRD]->Fill(trkTPC.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(4));
421459
}
422460
}
423461
}
@@ -458,6 +496,11 @@ void TOFMatchedTracks::monitorData(o2::framework::ProcessingContext& ctx)
458496
if (lbl.isFake()) {
459497
mFakeMatchedTracksPt[matchType::TPCTRD]->Fill(trk.getPt());
460498
mFakeMatchedTracksEta[matchType::TPCTRD]->Fill(trk.getEta());
499+
} else {
500+
mDeltaTwMC->Fill(matchTOF.getSignal() - matchTOF.getT0true() - matchTOF.getTgeant() * 1E3);
501+
mExpTimesPiMC[matchType::TPCTRD]->Fill(trk.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(2));
502+
mExpTimesKaMC[matchType::TPCTRD]->Fill(trk.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(3));
503+
mExpTimesPrMC[matchType::TPCTRD]->Fill(trk.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(4));
461504
}
462505
}
463506
}
@@ -522,6 +565,11 @@ void TOFMatchedTracks::monitorData(o2::framework::ProcessingContext& ctx)
522565
if (lbl.isFake()) {
523566
mFakeMatchedTracksPt[matchType::ITSTPC_ITSTPCTRD]->Fill(trkTPC.getPt());
524567
mFakeMatchedTracksEta[matchType::ITSTPC_ITSTPCTRD]->Fill(trkTPC.getEta());
568+
} else {
569+
mDeltaTwMC->Fill(matchTOF.getSignal() - matchTOF.getT0true() - matchTOF.getTgeant() * 1E3);
570+
mExpTimesPiMC[matchType::ITSTPC_ITSTPCTRD]->Fill(trkTPC.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(2));
571+
mExpTimesKaMC[matchType::ITSTPC_ITSTPCTRD]->Fill(trkTPC.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(3));
572+
mExpTimesPrMC[matchType::ITSTPC_ITSTPCTRD]->Fill(trkTPC.getPt(), matchTOF.getTgeant() * 1E3 - matchTOF.getLTIntegralOut().getTOF(4));
525573
}
526574
}
527575
}
@@ -839,6 +887,10 @@ void TOFMatchedTracks::reset()
839887
{
840888
// clean all the monitor objects here
841889

890+
if (mUseMC) {
891+
mDeltaTwMC->Reset();
892+
}
893+
842894
ILOG(Debug, Devel) << "Resetting the histograms" << ENDM;
843895
for (int i = 0; i < matchType::SIZE; ++i) {
844896
mMatchedTracksPt[i]->Reset();
@@ -847,6 +899,9 @@ void TOFMatchedTracks::reset()
847899
if (mUseMC) {
848900
mFakeMatchedTracksPt[i]->Reset();
849901
mFakeMatchedTracksEta[i]->Reset();
902+
mExpTimesPiMC[i]->Reset();
903+
mExpTimesKaMC[i]->Reset();
904+
mExpTimesPrMC[i]->Reset();
850905
}
851906
mInTracksPt[i]->Reset();
852907
mInTracksEta[i]->Reset();

0 commit comments

Comments
 (0)