Skip to content

Commit b8829ab

Browse files
committed
Add more info to MCStudy w-flow
1 parent 52d7d58 commit b8829ab

File tree

3 files changed

+58
-17
lines changed

3 files changed

+58
-17
lines changed

Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/TrackMCStudyConfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ struct TrackMCStudyConfig : o2::conf::ConfigurableParamHelper<TrackMCStudyConfig
2828
bool requireITSorTPCTrackRefs = true;
2929
bool requireTopBottomRefs = false;
3030
int minTPCRefsToExtractClRes = 2;
31+
int nOccBinsDrift = 10; // number of bins for TPC max drift time, where we integrate the occupancies
32+
int nTBPerOccBin = 48; // number of TB per occ bin
3133
float rejectClustersResStat = 0.1;
3234
float maxTPCRefExtrap = 2; // max dX to extrapolate the track ref when extrapolating track true posions
3335
int decayPDG[5] = {310, 3122, 411, 421, -1}; // decays to study, must end by -1

Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/TrackMCStudyTypes.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct MCTrackInfo {
3232
int getNITSClusForAB() const;
3333
int getLowestITSLayer() const;
3434
int getHighestITSLayer() const;
35-
35+
std::vector<float> occTPCV{};
3636
o2::track::TrackPar track{};
3737
o2::MCCompLabel label{};
3838
float occTPC = -1.f;
@@ -52,8 +52,24 @@ struct MCTrackInfo {
5252
uint8_t maxTPCRowSect = -1;
5353
int8_t nITSCl = 0;
5454
int8_t pattITSCl = 0;
55-
bool addedAtRecStage = false;
56-
ClassDefNV(MCTrackInfo, 5);
55+
uint8_t flags = 0;
56+
57+
enum Flags : uint32_t { Primary = 0,
58+
AddedAtRecStage = 2,
59+
BitMask = 0xff };
60+
61+
bool isPrimary() const { return isBitSet(Primary); }
62+
bool isAddedAtRecStage() const { return isBitSet(AddedAtRecStage); }
63+
void setPrimary() { setBit(Primary); }
64+
void setAddedAtRecStage() { setBit(AddedAtRecStage); }
65+
66+
uint8_t getBits() const { return flags; }
67+
bool isBitSet(int bit) const { return flags & (0xff & (0x1 << bit)); }
68+
void setBits(std::uint8_t b) { flags = b; }
69+
void setBit(int bit) { flags |= BitMask & (0x1 << bit); }
70+
void resetBit(int bit) { flags &= ~(BitMask & (0x1 << bit)); }
71+
72+
ClassDefNV(MCTrackInfo, 7);
5773
};
5874

5975
struct RecTrack {
@@ -272,7 +288,8 @@ struct MCVertex {
272288
int nTrackSel = 0; // number of selected MC charged tracks
273289
int ID = -1;
274290
std::vector<RecPV> recVtx{};
275-
ClassDefNV(MCVertex, 1);
291+
std::vector<float> occTPCV{};
292+
ClassDefNV(MCVertex, 2);
276293
};
277294

278295
} // namespace o2::trackstudy

Detectors/GlobalTrackingWorkflow/study/src/TrackMCStudy.cxx

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class TrackMCStudy : public Task
109109
void updateTimeDependentParams(ProcessingContext& pc);
110110
float getDCAYCut(float pt) const;
111111

112-
gsl::span<const MCTrack> mCurrMCTracks;
112+
const std::vector<o2::MCTrack>* mCurrMCTracks = nullptr;
113113
TVector3 mCurrMCVertex;
114114
o2::tpc::VDriftHelper mTPCVDriftHelper{};
115115
o2::tpc::CorrectionMapsLoader mTPCCorrMapsLoader{};
@@ -124,7 +124,7 @@ class TrackMCStudy : public Task
124124
bool mCheckSV = false; //< check SV binding (apart from prongs availability)
125125
bool mRecProcStage = false; //< flag that the MC particle was added only at the stage of reco tracks processing
126126
int mNTPCOccBinLength = 0; ///< TPC occ. histo bin length in TBs
127-
float mNTPCOccBinLengthInv;
127+
float mNTPCOccBinLengthInv = -1.f;
128128
int mVerbose = 0;
129129
float mITSTimeBiasMUS = 0.f;
130130
float mITSROFrameLengthMUS = 0.f; ///< ITS RO frame in mus
@@ -182,7 +182,7 @@ void TrackMCStudy::run(ProcessingContext& pc)
182182
}
183183
mDecProdLblPool.clear();
184184
mMCVtVec.clear();
185-
mCurrMCTracks = {};
185+
mCurrMCTracks = nullptr;
186186

187187
recoData.collectData(pc, *mDataRequest.get()); // select tracks of needed type, with minimal cuts, the real selected will be done in the vertexer
188188
updateTimeDependentParams(pc); // Make sure this is called after recoData.collectData, which may load some conditions
@@ -346,6 +346,21 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
346346
}
347347
break;
348348
}
349+
if (mNTPCOccBinLengthInv > 0.f) {
350+
mcVtx.occTPCV.resize(params.nOccBinsDrift);
351+
int grp = TMath::Max(1, TMath::Nint(params.nTBPerOccBin * mNTPCOccBinLengthInv));
352+
for (int ib = 0; ib < params.nOccBinsDrift; ib++) {
353+
float smb = 0;
354+
int tbs = occBin + TMath::Nint(ib * params.nTBPerOccBin * mNTPCOccBinLengthInv);
355+
for (int ig = 0; ig < grp; ig++) {
356+
if (tbs >= 0 && tbs < int(mTBinClOccHist.size())) {
357+
smb += mTBinClOccHist[tbs];
358+
}
359+
tbs++;
360+
}
361+
mcVtx.occTPCV[ib] = smb;
362+
}
363+
}
349364
if (rofCount >= ITSClusROFRec.size()) {
350365
mITSOcc.push_back(0); // IR after the last ROF
351366
}
@@ -362,13 +377,15 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
362377
if (nev != (int)mMCVtVec.size()) {
363378
LOGP(debug, "source {} has {} events while {} MC vertices were booked", curSrcMC, nev, mMCVtVec.size());
364379
okAccVtx = false;
380+
if (nev > (int)mMCVtVec.size()) { // QED
381+
continue;
382+
}
365383
}
366384
for (curEvMC = 0; curEvMC < nev; curEvMC++) {
367385
if (mVerbose > 1) {
368386
LOGP(info, "Event {}", curEvMC);
369387
}
370-
const auto& mt = mcReader.getTracks(curSrcMC, curEvMC);
371-
mCurrMCTracks = gsl::span<const MCTrack>(mt.data(), mt.size());
388+
mCurrMCTracks = &mcReader.getTracks(curSrcMC, curEvMC);
372389
const_cast<o2::dataformats::MCEventHeader&>(mcReader.getMCEventHeader(curSrcMC, curEvMC)).GetVertex(mCurrMCVertex);
373390
if (okAccVtx) {
374391
auto& pos = mMCVtVec[curEvMC].pos;
@@ -378,7 +395,7 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
378395
pos[2] = mCurrMCVertex.Z();
379396
}
380397
}
381-
for (int itr = 0; itr < mCurrMCTracks.size(); itr++) {
398+
for (int itr = 0; itr < mCurrMCTracks->size(); itr++) {
382399
processMCParticle(curSrcMC, curEvMC, itr);
383400
}
384401
}
@@ -425,11 +442,10 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
425442
if (lbl.getSourceID() != curSrcMC || lbl.getEventID() != curEvMC) {
426443
curSrcMC = lbl.getSourceID();
427444
curEvMC = lbl.getEventID();
428-
const auto& mt = mcReader.getTracks(curSrcMC, curEvMC);
429-
mCurrMCTracks = gsl::span<const MCTrack>(mt.data(), mt.size());
445+
mCurrMCTracks = &mcReader.getTracks(curSrcMC, curEvMC);
430446
const_cast<o2::dataformats::MCEventHeader&>(mcReader.getMCEventHeader(curSrcMC, curEvMC)).GetVertex(mCurrMCVertex);
431447
}
432-
if (!acceptMCCharged(mCurrMCTracks[lbl.getTrackID()], lbl)) {
448+
if (!acceptMCCharged((*mCurrMCTracks)[lbl.getTrackID()], lbl)) {
433449
continue;
434450
}
435451
entry = mSelMCTracks.find(lbl);
@@ -977,7 +993,7 @@ float TrackMCStudy::getDCAYCut(float pt) const
977993

978994
bool TrackMCStudy::processMCParticle(int src, int ev, int trid)
979995
{
980-
const auto& mcPart = mCurrMCTracks[trid];
996+
const auto& mcPart = (*mCurrMCTracks)[trid];
981997
int pdg = mcPart.GetPdgCode();
982998
bool res = false;
983999
while (true) {
@@ -999,7 +1015,7 @@ bool TrackMCStudy::processMCParticle(int src, int ev, int trid)
9991015
break;
10001016
}
10011017
for (int idd = idd0; idd <= idd1; idd++) {
1002-
const auto& product = mCurrMCTracks[idd];
1018+
const auto& product = (*mCurrMCTracks)[idd];
10031019
auto lbld = o2::MCCompLabel(idd, ev, src);
10041020
if (!acceptMCCharged(product, lbld, decay)) {
10051021
decay = -1; // discard decay
@@ -1097,11 +1113,17 @@ bool TrackMCStudy::addMCParticle(const MCTrack& mcPart, const o2::MCCompLabel& l
10971113
mcEntry.mcTrackInfo.bcInTF = mIntBC[lb.getEventID()];
10981114
mcEntry.mcTrackInfo.occTPC = mTPCOcc[lb.getEventID()];
10991115
mcEntry.mcTrackInfo.occITS = mITSOcc[lb.getEventID()];
1100-
mcEntry.mcTrackInfo.addedAtRecStage = mRecProcStage;
1116+
mcEntry.mcTrackInfo.occTPCV = mMCVtVec[lb.getEventID()].occTPCV;
1117+
if (mRecProcStage) {
1118+
mcEntry.mcTrackInfo.setAddedAtRecStage();
1119+
}
1120+
if (o2::mcutils::MCTrackNavigator::isPhysicalPrimary(mcPart, *mCurrMCTracks)) {
1121+
mcEntry.mcTrackInfo.setPrimary();
1122+
}
11011123
int moth = -1;
11021124
o2::MCCompLabel mclbPar;
11031125
if ((moth = mcPart.getMotherTrackId()) >= 0) {
1104-
const auto& mcPartPar = mCurrMCTracks[moth];
1126+
const auto& mcPartPar = (*mCurrMCTracks)[moth];
11051127
mcEntry.mcTrackInfo.pdgParent = mcPartPar.GetPdgCode();
11061128
}
11071129
if (mcPart.isPrimary() && mcReader.getNEvents(lb.getSourceID()) == mMCVtVec.size()) {

0 commit comments

Comments
 (0)