Skip to content

Commit 3f62bcd

Browse files
committed
extend
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent a2003e1 commit 3f62bcd

File tree

5 files changed

+68
-45
lines changed

5 files changed

+68
-45
lines changed

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

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,27 @@
2121
#include "ReconstructionDataFormats/PrimaryVertex.h"
2222
#include <array>
2323
#include <vector>
24+
#include <bit>
2425

2526
namespace o2::trackstudy
2627
{
27-
struct MCTrackInfo {
2828

29-
inline float getMCTimeMUS() const { return bcInTF * o2::constants::lhc::LHCBunchSpacingMUS; }
30-
inline bool hasITSHitOnLr(int i) const { return (pattITSCl & ((0x1 << i) & 0x7f)) != 0; }
29+
struct ITSTrackInfo {
30+
inline bool hasITSHitOnLr(int i) const { return (pattClITS & ((0x1 << i) & 0x7f)) != 0; }
3131
int getNITSClusCont() const;
3232
int getNITSClusForAB() const;
3333
int getLowestITSLayer() const;
3434
int getHighestITSLayer() const;
35+
int getNITSClusTrackable() const noexcept { return std::popcount(pattClITS); }
36+
37+
uint8_t nClITS = 0;
38+
uint8_t pattClITS = 0;
39+
40+
ClassDefNV(ITSTrackInfo, 1);
41+
};
42+
43+
struct MCTrackInfo : public ITSTrackInfo {
44+
inline float getMCTimeMUS() const { return bcInTF * o2::constants::lhc::LHCBunchSpacingMUS; }
3545

3646
o2::track::TrackPar track{};
3747
o2::MCCompLabel label{};
@@ -41,21 +51,20 @@ struct MCTrackInfo {
4151
int pdg = 0;
4252
int pdgParent = 0;
4353
int parentEntry = -1;
44-
int16_t nTPCCl = 0;
45-
int16_t nTPCClShared = 0;
54+
uint16_t nTPCCl = 0;
55+
uint16_t nTPCClShared = 0;
4656
int8_t parentDecID = -1;
47-
uint8_t minTPCRow = -1;
48-
uint8_t maxTPCRow = 0;
57+
int8_t minTPCRow = -1;
58+
int8_t maxTPCRow = 0;
4959
uint8_t nUsedPadRows = 0;
5060
uint8_t maxTPCRowInner = 0; // highest row in the sector containing the lowest one
51-
uint8_t minTPCRowSect = -1;
52-
uint8_t maxTPCRowSect = -1;
53-
int8_t nITSCl = 0;
54-
int8_t pattITSCl = 0;
55-
ClassDefNV(MCTrackInfo, 4);
61+
int8_t minTPCRowSect = -1;
62+
int8_t maxTPCRowSect = -1;
63+
uint8_t nITSClInv = 0;
64+
ClassDefNV(MCTrackInfo, 5);
5665
};
5766

58-
struct RecTrack {
67+
struct RecTrack : public ITSTrackInfo {
5968
enum FakeFlag {
6069
FakeITS = 0x1 << 0,
6170
FakeTPC = 0x1 << 1,
@@ -71,9 +80,7 @@ struct RecTrack {
7180
o2::MCEventLabel pvLabel{};
7281
short pvID = -1;
7382
uint8_t flags = 0;
74-
uint8_t nClITS = 0;
7583
uint8_t nClTPC = 0;
76-
uint8_t pattITS = 0;
7784
int8_t lowestPadRow = -1;
7885

7986
bool isFakeGLO() const { return flags & FakeGLO; }
@@ -83,7 +90,7 @@ struct RecTrack {
8390
bool isFakeTOF() const { return flags & FakeTOF; }
8491
bool isFakeITSTPC() const { return flags & FakeITSTPC; }
8592

86-
ClassDefNV(RecTrack, 1);
93+
ClassDefNV(RecTrack, 2);
8794
};
8895

8996
struct TrackPairInfo {

Detectors/GlobalTrackingWorkflow/study/src/GlobalTrackingStudyLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#pragma link C++ class std::vector < o2::trackstudy::RecTrack> + ;
2828
#pragma link C++ class o2::trackstudy::TrackFamily + ;
2929
#pragma link C++ class std::vector < o2::trackstudy::TrackFamily> + ;
30+
#pragma link C++ class o2::trackstudy::ITSTrackInfo + ;
3031
#pragma link C++ class o2::trackstudy::MCTrackInfo + ;
3132
#pragma link C++ class std::vector < o2::trackstudy::MCTrackInfo> + ;
3233
#pragma link C++ class o2::trackstudy::RecPV + ;

Detectors/GlobalTrackingWorkflow/study/src/TrackMCStudy.cxx

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
#include <vector>
13-
#include <TStopwatch.h>
1412
#include "DataFormatsGlobalTracking/RecoContainer.h"
1513
#include "DataFormatsGlobalTracking/RecoContainerCreateTracksVariadic.h"
1614
#include "ReconstructionDataFormats/V0.h"
@@ -55,13 +53,16 @@
5553
#include "GPUParam.h"
5654
#include "GPUParam.inc"
5755
#include "MathUtils/fit.h"
56+
5857
#include <TRandom.h>
59-
#include <map>
58+
#include <TStopwatch.h>
59+
60+
#include <vector>
6061
#include <unordered_map>
6162
#include <array>
6263
#include <set>
6364
#include <utility>
64-
#include <gsl/span>
65+
#include <span>
6566

6667
// workflow to study relation of reco tracks to MCTruth
6768
// o2-trackmc-study-workflow --device-verbosity all -b --run
@@ -90,6 +91,7 @@ class TrackMCStudy : public Task
9091
MCV0,
9192
MCV0NotSelected,
9293
MCFiltered,
94+
MCITSCls,
9395
};
9496

9597
public:
@@ -119,7 +121,7 @@ class TrackMCStudy : public Task
119121
void updateTimeDependentParams(ProcessingContext& pc);
120122
float getDCAYCut(float pt) const;
121123

122-
gsl::span<const MCTrack> mCurrMCTracks;
124+
std::span<const MCTrack> mCurrMCTracks;
123125
TVector3 mCurrMCVertex;
124126
o2::tpc::VDriftHelper mTPCVDriftHelper;
125127
o2::tpc::CorrectionMapsLoader mTPCCorrMapsLoader;
@@ -382,7 +384,7 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
382384
LOGP(info, "Event {}", curEvMC);
383385
}
384386
const auto& mt = mcReader.getTracks(curSrcMC, curEvMC);
385-
mCurrMCTracks = gsl::span<const MCTrack>(mt.data(), mt.size());
387+
mCurrMCTracks = std::span<const MCTrack>(mt.data(), mt.size());
386388
const_cast<o2::dataformats::MCEventHeader&>(mcReader.getMCEventHeader(curSrcMC, curEvMC)).GetVertex(mCurrMCVertex);
387389
if (okAccVtx) {
388390
auto& pos = mMCVtVec[curEvMC].pos;
@@ -439,7 +441,7 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
439441
curSrcMC = lbl.getSourceID();
440442
curEvMC = lbl.getEventID();
441443
const auto& mt = mcReader.getTracks(curSrcMC, curEvMC);
442-
mCurrMCTracks = gsl::span<const MCTrack>(mt.data(), mt.size());
444+
mCurrMCTracks = std::span<const MCTrack>(mt.data(), mt.size());
443445
const_cast<o2::dataformats::MCEventHeader&>(mcReader.getMCEventHeader(curSrcMC, curEvMC)).GetVertex(mCurrMCVertex);
444446
}
445447
if (!acceptMCCharged(mCurrMCTracks[lbl.getTrackID()], lbl)) {
@@ -527,7 +529,7 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
527529
auto msk = tref.gid.getSourceDetectorsMask();
528530
if (msk[DetID::ITS]) {
529531
if (gidSet[GTrackID::ITS].isSourceSet()) { // has ITS track rather than AB tracklet
530-
tref.pattITS = getITSPatt(gidSet[GTrackID::ITS], tref.nClITS);
532+
tref.pattClITS = getITSPatt(gidSet[GTrackID::ITS], tref.nClITS);
531533
if (trackFam.entITS < 0) {
532534
trackFam.entITS = tcnt;
533535
}
@@ -539,7 +541,7 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
539541
trackFam.entITSFound = tcnt;
540542
}
541543
} else { // AB ITS tracklet
542-
tref.pattITS = getITSPatt(gidSet[GTrackID::ITSAB], tref.nClITS);
544+
tref.pattClITS = getITSPatt(gidSet[GTrackID::ITSAB], tref.nClITS);
543545
if (recoData.getTrackMCLabel(gidSet[GTrackID::ITSAB]).isFake()) {
544546
tref.flags |= RecTrack::FakeITS;
545547
}
@@ -603,7 +605,7 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
603605
auto v0s = recoData.getV0sIdx();
604606
auto prpr = [](o2::trackstudy::TrackFamily& f) {
605607
std::string s;
606-
s += fmt::format(" par {} Ntpccl={} Nitscl={} ", f.mcTrackInfo.pdgParent, f.mcTrackInfo.nTPCCl, f.mcTrackInfo.nITSCl);
608+
s += fmt::format(" par {} Ntpccl={} Nitscl={} ", f.mcTrackInfo.pdgParent, f.mcTrackInfo.nTPCCl, f.mcTrackInfo.nClITS);
607609
for (auto& t : f.recTracks) {
608610
s += t.gid.asString();
609611
s += " ";
@@ -686,7 +688,13 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
686688
if (dec.foundSVID >= 0 && !refitV0(dec.foundSVID, v0, recoData)) {
687689
v0.invalidate();
688690
}
689-
(*mDBGOut) << decTreeName.c_str() << "pdgPar=" << dec.pdg << "trPar=" << dec.parent << "prod=" << decFam << "found=" << dec.foundSVID << "sv=" << v0 << "\n";
691+
(*mDBGOut) << decTreeName.c_str()
692+
<< "pdgPar=" << dec.pdg
693+
<< "trPar=" << dec.parent
694+
<< "prod=" << decFam
695+
<< "found=" << dec.foundSVID
696+
<< "sv=" << v0
697+
<< "\n";
690698
}
691699
}
692700
}
@@ -905,8 +913,15 @@ void TrackMCStudy::fillMCClusterInfo(const o2::globaltracking::RecoContainer& re
905913
continue;
906914
}
907915
auto& mctr = entry->second.mcTrackInfo;
908-
mctr.nITSCl++;
909-
mctr.pattITSCl |= 0x1 << o2::itsmft::ChipMappingITS::getLayer(ITSClusters[icl].getChipID());
916+
if (!lbl.isValid()) {
917+
mctr.nITSClInv++;
918+
} else {
919+
mctr.nClITS++;
920+
mctr.pattClITS |= 0x1 << o2::itsmft::ChipMappingITS::getLayer(ITSClusters[icl].getChipID());
921+
if (mVerbose[Verbosity::MCITSCls]) {
922+
LOGP(info, "ITS Cluster: MCParticle {}{}: patt: {:07b}[{:3d}] icl={:9d} lay={} par={:8} pdg={:8d}{} pt={:.3f} tgl={:2.3f}", lbl.getRawValue(), lbl.asString(), mctr.pattClITS, mctr.nClITS, icl, o2::itsmft::ChipMappingITS::getLayer(ITSClusters[icl].getChipID()), mctr.pdgParent, mctr.pdg, ITSClusters[icl].asString(), mctr.track.getPt(), mctr.track.getTgl());
923+
}
924+
}
910925
}
911926
}
912927
}

Detectors/GlobalTrackingWorkflow/study/src/TrackMCStudyTypes.cxx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ namespace o2::trackstudy
1717
RecTrack TrackFamily::dummyRecTrack;
1818

1919
// get longest number of clusters on consecutive layers
20-
int MCTrackInfo::getNITSClusCont() const
20+
int ITSTrackInfo::getNITSClusCont() const
2121
{
22-
if (nITSCl < 2) {
23-
return nITSCl;
22+
if (nClITS < 2) {
23+
return nClITS;
2424
}
2525
int longest = 0, current = 0;
2626
for (int i = 0; i < 7; i++) {
27-
if (pattITSCl & (0x1 << i)) {
27+
if (pattClITS & (0x1 << i)) {
2828
longest = ++current;
2929
} else {
3030
current = 0;
@@ -34,12 +34,12 @@ int MCTrackInfo::getNITSClusCont() const
3434
}
3535

3636
// check how many clusters ITS-TPC afterburner could see (consecutively occupied layers starting from the last one)
37-
int MCTrackInfo::getNITSClusForAB() const
37+
int ITSTrackInfo::getNITSClusForAB() const
3838
{
3939
int ncl = 0;
40-
if (nITSCl) {
40+
if (nClITS) {
4141
for (int i = 6; i > 2; i--) {
42-
if (pattITSCl & (0x1 << i)) {
42+
if (pattClITS & (0x1 << i)) {
4343
ncl++;
4444
} else {
4545
break;
@@ -50,11 +50,11 @@ int MCTrackInfo::getNITSClusForAB() const
5050
}
5151

5252
// lowest ITS layer with cluster
53-
int MCTrackInfo::getLowestITSLayer() const
53+
int ITSTrackInfo::getLowestITSLayer() const
5454
{
55-
if (nITSCl) {
55+
if (nClITS) {
5656
for (int i = 0; i < 7; i++) {
57-
if (pattITSCl & (0x1 << i)) {
57+
if (pattClITS & (0x1 << i)) {
5858
return i;
5959
}
6060
}
@@ -63,11 +63,11 @@ int MCTrackInfo::getLowestITSLayer() const
6363
}
6464

6565
// highest ITS layer with cluster
66-
int MCTrackInfo::getHighestITSLayer() const
66+
int ITSTrackInfo::getHighestITSLayer() const
6767
{
68-
if (nITSCl) {
68+
if (nClITS) {
6969
for (int i = 7; i--;) {
70-
if (pattITSCl & (0x1 << i)) {
70+
if (pattClITS & (0x1 << i)) {
7171
return i;
7272
}
7373
}

Detectors/GlobalTrackingWorkflow/study/src/TrackingStudy.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class TrackingStudySpec : public Task
9393
bool mUseMC{false}; ///< MC flag
9494
std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;
9595
std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOutVtx;
96-
std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mTPCRefitter; ///< TPC refitter used for TPC tracks refit during the reconstruction
96+
std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mTPCRefitter; ///< TPC refitter used for TPC tracks refit during the reconstruction
9797
std::vector<float> mTBinClOccAft, mTBinClOccBef, mTBinClOccWgh; ///< TPC occupancy histo: i-th entry is the integrated occupancy for ~1 orbit starting/preceding from the TB = i*mNTPCOccBinLength
9898
std::unique_ptr<TF1> mOccWghFun;
9999
float mITSROFrameLengthMUS = 0.f;
@@ -355,9 +355,9 @@ void TrackingStudySpec::process(o2::globaltracking::RecoContainer& recoData)
355355
dst.ts.setTimeStampError(src.ttimeE);
356356
dst.nClITS = src.nClITS;
357357
dst.nClTPC = src.nClTPC;
358-
dst.pattITS = src.pattITS;
358+
dst.pattClITS = src.pattITS;
359359
if (src.q2ptITS == 0. && dst.nClITS > 0) {
360-
dst.pattITS |= 0x1 << 7;
360+
dst.pattClITS |= 0x1 << 7;
361361
}
362362
dst.lowestPadRow = src.rowMinTPC;
363363
if (this->mUseMC) {

0 commit comments

Comments
 (0)