Skip to content

Commit 3d1e798

Browse files
committed
Optionally fill dphi-dtgl with N Sh.clusters in trackStudy
1 parent 58aec50 commit 3d1e798

File tree

3 files changed

+142
-0
lines changed

3 files changed

+142
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,28 @@ struct RecTrack {
8686
ClassDefNV(RecTrack, 1);
8787
};
8888

89+
struct TrackPairInfo {
90+
RecTrack tr0;
91+
RecTrack tr1;
92+
uint8_t nshTPC = 0;
93+
uint8_t nshTPCRow = 0;
94+
95+
int getComb() const { return tr0.track.getSign() != tr1.track.getSign() ? 0 : (tr0.track.getSign() > 0 ? 1 : 2); }
96+
float getDPhi() const
97+
{
98+
float dphi = tr0.track.getPhi() - tr1.track.getPhi();
99+
if (dphi < -o2::constants::math::PI) {
100+
dphi += o2::constants::math::TwoPI;
101+
} else if (dphi > o2::constants::math::PI) {
102+
dphi -= o2::constants::math::TwoPI;
103+
}
104+
return dphi;
105+
}
106+
float getDTgl() const { return tr0.track.getTgl() - tr1.track.getTgl(); }
107+
108+
ClassDefNV(TrackPairInfo, 1)
109+
};
110+
89111
struct TrackFamily { // set of tracks related to the same MC label
90112
MCTrackInfo mcTrackInfo{};
91113
std::vector<RecTrack> recTracks{};

Detectors/GlobalTrackingWorkflow/study/src/GlobalTrackingStudyLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@
3636
#pragma link C++ class o2::trackstudy::ClResTPC + ;
3737
#pragma link C++ class o2::trackstudy::ClResTPCCont + ;
3838
#pragma link C++ class std::vector < o2::trackstudy::ClResTPCCont> + ;
39+
#pragma link C++ class o2::trackstudy::TrackPairInfo + ;
40+
#pragma link C++ class std::vector < o2::trackstudy::TrackPairInfo> + ;
3941

4042
#endif

Detectors/GlobalTrackingWorkflow/study/src/TrackingStudy.cxx

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "DetectorsBase/GRPGeomHelper.h"
3434
#include "GlobalTrackingStudy/TrackingStudy.h"
3535
#include "GlobalTrackingStudy/TrackInfoExt.h"
36+
#include "GlobalTrackingStudy/TrackMCStudyTypes.h"
3637
#include "TPCBase/ParameterElectronics.h"
3738
#include "ReconstructionDataFormats/PrimaryVertex.h"
3839
#include "ReconstructionDataFormats/PrimaryVertexExt.h"
@@ -108,6 +109,7 @@ class TrackingStudySpec : public Task
108109
int mNHBPerTF = 0;
109110
float mNTPCOccBinLengthInv;
110111
bool mStoreWithITSOnly = false;
112+
bool mDoPairsCorr = false;
111113
std::string mDCAYFormula = "0.0105 + 0.0350 / pow(x, 1.1)";
112114
std::string mDCAZFormula = "0.0105 + 0.0350 / pow(x, 1.1)";
113115
GTrackID::mask_t mTracksSrc{};
@@ -136,6 +138,7 @@ void TrackingStudySpec::init(InitContext& ic)
136138
mMinTPCClusters = ic.options().get<int>("min-tpc-clusters");
137139
mDCAYFormula = ic.options().get<std::string>("dcay-vs-pt");
138140
mDCAZFormula = ic.options().get<std::string>("dcaz-vs-pt");
141+
mDoPairsCorr = ic.options().get<bool>("pair-correlations");
139142
}
140143

141144
void TrackingStudySpec::run(ProcessingContext& pc)
@@ -245,6 +248,7 @@ void TrackingStudySpec::process(o2::globaltracking::RecoContainer& recoData)
245248
float tBiasITS = alpParams.roFrameBiasInBC * o2::constants::lhc::LHCBunchSpacingMUS;
246249
const o2::ft0::InteractionTag& ft0Params = o2::ft0::InteractionTag::Instance();
247250
std::vector<o2::dataformats::TrackInfoExt> trcExtVec;
251+
std::vector<o2::trackstudy::TrackPairInfo> trcPairsVec;
248252
auto vdrit = mTPCVDriftHelper.getVDriftObject().getVDrift();
249253
bool tpcTrackOK = recoData.isTrackSourceLoaded(GTrackID::TPC);
250254

@@ -278,6 +282,82 @@ void TrackingStudySpec::process(o2::globaltracking::RecoContainer& recoData)
278282
}
279283
};
280284

285+
auto getTPCPairSharing = [&recoData, this](const o2::tpc::TrackTPC& trc0, const o2::tpc::TrackTPC& trc1) {
286+
const auto clRefs = recoData.getTPCTracksClusterRefs();
287+
const auto shMap = recoData.clusterShMapTPC.data();
288+
uint8_t nsh = 0, nshRows = 0, lastSharedRow = -1;
289+
if (recoData.inputsTPCclusters) {
290+
uint8_t clSect0 = 0, clRow0 = 0, clSect1 = 0, clRow1 = 0;
291+
uint32_t clIdx0 = 0, clIdx1 = 0;
292+
int ic1Start = 0;
293+
for (int ic0 = 0; ic0 < trc0.getNClusterReferences(); ic0++) { // outside -> inside
294+
trc0.getClusterReference(clRefs, ic0, clSect0, clRow0, clIdx0);
295+
for (int ic1 = ic1Start; ic1 < trc1.getNClusterReferences(); ic1++) { // outside -> inside
296+
trc1.getClusterReference(clRefs, ic1, clSect1, clRow1, clIdx1);
297+
if (clRow1 > clRow0) {
298+
ic1Start = ic1 + 1;
299+
continue; // catch up ic0
300+
}
301+
if (clRow1 == clRow0) {
302+
if (clSect0 == clSect1 && clIdx0 == clIdx1) {
303+
nsh++;
304+
if (lastSharedRow != clRow0) {
305+
lastSharedRow = clRow0;
306+
nshRows++;
307+
}
308+
ic1Start = ic1 + 1;
309+
break; // check next ic0
310+
}
311+
}
312+
}
313+
}
314+
}
315+
return std::make_pair(nsh, nshRows);
316+
};
317+
318+
auto assignRecTrack = [&recoData, this](const o2::dataformats::TrackInfoExt& src, o2::trackstudy::RecTrack& dst) {
319+
dst.track = src.track;
320+
dst.gid = src.gid;
321+
dst.ts.setTimeStamp(src.ttime);
322+
dst.ts.setTimeStampError(src.ttimeE);
323+
dst.nClITS = src.nClITS;
324+
dst.nClTPC = src.nClTPC;
325+
dst.pattITS = src.pattITS;
326+
if (src.q2ptITS == 0. && dst.nClITS > 0) {
327+
dst.pattITS |= 0x1 << 7;
328+
}
329+
dst.lowestPadRow = src.rowMinTPC;
330+
if (this->mUseMC) {
331+
auto gidSet = recoData.getSingleDetectorRefs(src.gid);
332+
if (recoData.getTrackMCLabel(src.gid).isFake()) {
333+
dst.flags |= RecTrack::FakeGLO;
334+
}
335+
auto msk = src.gid.getSourceDetectorsMask();
336+
if (msk[DetID::ITS]) {
337+
if (gidSet[GTrackID::ITS].isSourceSet()) { // has ITS track rather than AB tracklet
338+
auto lblITS = recoData.getTrackMCLabel(gidSet[GTrackID::ITS]);
339+
if (lblITS.isFake()) {
340+
dst.flags |= RecTrack::FakeITS;
341+
}
342+
} else { // AB ITS tracklet
343+
if (recoData.getTrackMCLabel(gidSet[GTrackID::ITSAB]).isFake()) {
344+
dst.flags |= RecTrack::FakeITS;
345+
}
346+
}
347+
if (msk[DetID::TPC]) { // has both ITS and TPC contribution
348+
if (recoData.getTrackMCLabel(gidSet[GTrackID::ITSTPC]).isFake()) {
349+
dst.flags |= RecTrack::FakeITSTPC;
350+
}
351+
}
352+
}
353+
if (msk[DetID::TPC]) {
354+
if (recoData.getTrackMCLabel(gidSet[GTrackID::TPC]).isFake()) {
355+
dst.flags |= RecTrack::FakeTPC;
356+
}
357+
}
358+
}
359+
};
360+
281361
for (int iv = 0; iv < nv; iv++) {
282362
LOGP(debug, "processing PV {} of {}", iv, nv);
283363
const auto& vtref = vtxRefs[iv];
@@ -309,6 +389,7 @@ void TrackingStudySpec::process(o2::globaltracking::RecoContainer& recoData)
309389
pve.VtxID = iv;
310390
}
311391
trcExtVec.clear();
392+
trcPairsVec.clear();
312393
float q2ptITS, q2ptTPC, q2ptITSTPC, q2ptITSTPCTRD;
313394
for (int is = 0; is < GTrackID::NSources; is++) {
314395
DetID::mask_t dm = GTrackID::getSourceDetectorsMask(is);
@@ -444,6 +525,42 @@ void TrackingStudySpec::process(o2::globaltracking::RecoContainer& recoData)
444525
<< "orbit=" << recoData.startIR.orbit << "tfID=" << TFCount
445526
<< "tpcOccBef=" << tpcOccBef << "tpcOccAft=" << tpcOccAft
446527
<< "pve=" << pveVec[iv] << "trc=" << trcExtVec << "\n";
528+
529+
if (mDoPairsCorr) {
530+
for (int it0 = 0; it0 < (int)trcExtVec.size(); it0++) {
531+
const auto& tr0 = trcExtVec[it0];
532+
if (tr0.nClTPC < 1) {
533+
continue;
534+
}
535+
for (int it1 = it0 + 1; it1 < (int)trcExtVec.size(); it1++) {
536+
const auto& tr1 = trcExtVec[it1];
537+
if (tr1.nClTPC < 1) {
538+
continue;
539+
}
540+
541+
if (std::abs(tr0.track.getTgl() - tr1.track.getTgl()) > 0.25) {
542+
continue;
543+
}
544+
auto dphi = tr0.track.getPhi() - tr1.track.getPhi();
545+
if (dphi < -o2::constants::math::PI) {
546+
dphi += o2::constants::math::TwoPI;
547+
} else if (dphi > o2::constants::math::PI) {
548+
dphi -= o2::constants::math::TwoPI;
549+
}
550+
if (std::abs(dphi) > 0.25) {
551+
continue;
552+
}
553+
auto& pr = trcPairsVec.emplace_back();
554+
assignRecTrack(tr0, pr.tr0);
555+
assignRecTrack(tr1, pr.tr1);
556+
auto shinfo = getTPCPairSharing(recoData.getTPCTrack(recoData.getTPCContributorGID(tr0.gid)), recoData.getTPCTrack(recoData.getTPCContributorGID(tr1.gid)));
557+
pr.nshTPC = shinfo.first;
558+
pr.nshTPCRow = shinfo.second;
559+
}
560+
}
561+
}
562+
(*mDBGOut) << "pairs"
563+
<< "pr=" << trcPairsVec << "\n";
447564
}
448565

449566
int nvtot = mMaxNeighbours < 0 ? -1 : (int)pveVec.size();
@@ -600,6 +717,7 @@ DataProcessorSpec getTrackingStudySpec(GTrackID::mask_t srcTracks, GTrackID::mas
600717
{"max-eta", VariantType::Float, 1.0f, {"Cut on track eta"}},
601718
{"min-pt", VariantType::Float, 0.1f, {"Cut on track pT"}},
602719
{"with-its-only", VariantType::Bool, false, {"Store tracks with ITS only"}},
720+
{"pair-correlations", VariantType::Bool, false, {"Do pairs correlation"}},
603721
{"min-x-prop", VariantType::Float, 100.f, {"track should be propagated to this X at least"}},
604722
};
605723
o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);

0 commit comments

Comments
 (0)