Skip to content

Commit 89128da

Browse files
authored
Merge cbf50d0 into sapling-pr-archive-ktf
2 parents 2fb882b + cbf50d0 commit 89128da

File tree

27 files changed

+647
-103
lines changed

27 files changed

+647
-103
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);

Detectors/ITSMFT/ITS/macros/test/CheckTracksCA.C

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void CheckTracksCA(bool doFakeClStud = false,
8787
TTree* mcTree = (TTree*)gFile->Get("o2sim");
8888
mcTree->SetBranchStatus("*", 0); // disable all branches
8989
mcTree->SetBranchStatus("MCTrack*", 1);
90+
mcTree->SetBranchStatus("MCEventHeader*", 1);
9091

9192
std::vector<o2::MCTrack>* mcArr = nullptr;
9293
mcTree->SetBranchAddress("MCTrack", &mcArr);
@@ -115,10 +116,13 @@ void CheckTracksCA(bool doFakeClStud = false,
115116
std::cout << "** Filling particle table ... " << std::flush;
116117
int lastEventIDcl = -1, cf = 0;
117118
int nev = mcTree->GetEntriesFast();
118-
std::vector<std::vector<ParticleInfo>> info(nev);
119+
std::vector<std::vector<ParticleInfo>> info;
120+
info.resize(nev);
121+
TH1D* hZvertex = new TH1D("hZvertex", "Z vertex", 100, -20, 20);
119122
for (int n = 0; n < nev; n++) { // loop over MC events
120123
mcTree->GetEvent(n);
121124
info[n].resize(mcArr->size());
125+
hZvertex->Fill(mcEvent->GetZ());
122126
for (unsigned int mcI{0}; mcI < mcArr->size(); ++mcI) {
123127
auto part = mcArr->at(mcI);
124128
info[n][mcI].event = n;
@@ -196,7 +200,6 @@ void CheckTracksCA(bool doFakeClStud = false,
196200
info[evID][trackID].track.getImpactParams(info[evID][trackID].pvx, info[evID][trackID].pvy, info[evID][trackID].pvz, bz, ip);
197201
info[evID][trackID].dcaxy = ip[0];
198202
info[evID][trackID].dcaz = ip[1];
199-
Info("", "dcaxy=%f dcaz=%f bz=%f", ip[0], ip[1], bz);
200203
}
201204

202205
fakes += fake;
@@ -286,6 +289,10 @@ void CheckTracksCA(bool doFakeClStud = false,
286289
clone->Divide(clone, den, 1, 1, "b");
287290
clone->SetLineColor(3);
288291
clone->Draw("histesame");
292+
TCanvas* c2 = new TCanvas;
293+
c2->SetGridx();
294+
c2->SetGridy();
295+
hZvertex->DrawClone();
289296

290297
std::cout << "** Streaming output TTree to file ... " << std::flush;
291298
TFile file("CheckTracksCA.root", "recreate");

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@ struct TrackingParameters {
9494
unsigned long MaxMemory = 12000000000UL;
9595
float MaxChi2ClusterAttachment = 60.f;
9696
float MaxChi2NDF = 30.f;
97-
float MinPt = 0.f;
97+
std::vector<float> MinPt = {0.f, 0.f, 0.f, 0.f};
9898
unsigned char StartLayerMask = 0x7F;
9999
bool FindShortTracks = false;
100100
bool PerPrimaryVertexProcessing = false;
101101
bool SaveTimeBenchmarks = false;
102102
bool DoUPCIteration = false;
103+
bool FataliseUponFailure = true;
104+
bool DropTFUponFailure = false;
103105
/// Cluster attachment
104106
bool UseTrackFollower = false;
105107
bool UseTrackFollowerTop = false;

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class TimeFrame
259259
void printCellLUTonLayer(int i);
260260
void printTrackletLUTs();
261261
void printCellLUTs();
262-
void printROFInfo(const int rofId);
262+
void printSliceInfo(const int, const int);
263263

264264
IndexTableUtils mIndexTableUtils;
265265

@@ -297,6 +297,13 @@ class TimeFrame
297297
std::vector<uint8_t> mMultiplicityCutMask;
298298

299299
const o2::base::PropagatorImpl<float>* mPropagatorDevice = nullptr; // Needed only for GPU
300+
void dropTracks()
301+
{
302+
for (auto& v : mTracks) {
303+
deepVectorClear(v);
304+
}
305+
}
306+
300307
protected:
301308
template <typename T>
302309
void deepVectorClear(std::vector<T>& vec)

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ namespace its
2222

2323
struct VertexerParamConfig : public o2::conf::ConfigurableParamHelper<VertexerParamConfig> {
2424

25-
int nIterations = 1; // Number of vertexing passes to perform
26-
int vertPerRofThreshold = 0; // Maximum number of vertices per ROF to trigger second a round
27-
bool allowSingleContribClusters = false;
28-
// Number of ROFs to be considered for the vertexing
29-
int deltaRof = 0;
25+
int nIterations = 1; // Number of vertexing passes to perform.
26+
int vertPerRofThreshold = 0; // Maximum number of vertices per ROF to trigger second a iteration.
27+
bool allowSingleContribClusters = false; // attempt to find vertices in case of a single tracklet found.
28+
int deltaRof = 0; // Number of ROFs to be considered for the vertexing.
3029

31-
// geometrical cuts
30+
// geometrical cuts for tracklet selection
3231
float zCut = 0.002f;
3332
float phiCut = 0.005f;
3433
float pairCut = 0.04f;
@@ -42,12 +41,12 @@ struct VertexerParamConfig : public o2::conf::ConfigurableParamHelper<VertexerPa
4241
float maxZPositionAllowed = 25.f; // 4x sZ of the beam
4342

4443
// Artefacts selections
45-
int clusterContributorsCut = 16;
44+
int clusterContributorsCut = 16; // minimum number of contributors for the second vertex found in the same ROF (pileup cut)
4645
int maxTrackletsPerCluster = 1e2;
4746
int phiSpan = -1;
4847
int zSpan = -1;
49-
int ZBins = 1;
50-
int PhiBins = 128;
48+
int ZBins = 1; // z-phi index table configutation: number of z bins
49+
int PhiBins = 128; // z-phi index table configutation: number of phi bins
5150

5251
int nThreads = 1;
5352

@@ -56,11 +55,11 @@ struct VertexerParamConfig : public o2::conf::ConfigurableParamHelper<VertexerPa
5655

5756
struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper<TrackerParamConfig> {
5857
// Use TGeo for mat. budget
59-
bool useMatCorrTGeo = false;
60-
bool useFastMaterial = false;
61-
int deltaRof = 0;
62-
float sysErrY2[7] = {0}; // systematic error^2 in Y per layer
63-
float sysErrZ2[7] = {0}; // systematic error^2 in Z per layer
58+
bool useMatCorrTGeo = false; // use full geometry to corect for material budget accounting in the fits. Default is to use the material budget LUT.
59+
bool useFastMaterial = false; // use faster material approximation for material budget accounting in the fits.
60+
int deltaRof = 0; // configure the width of the window in ROFs to be considered for the tracking.
61+
float sysErrY2[7] = {0}; // systematic error^2 in Y per layer
62+
float sysErrZ2[7] = {0}; // systematic error^2 in Z per layer
6463
float maxChi2ClusterAttachment = -1.f;
6564
float maxChi2NDF = -1.f;
6665
float nSigmaCut = -1.f;
@@ -69,23 +68,25 @@ struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper<TrackerPara
6968
float pvRes = -1.f;
7069
int LUTbinsPhi = -1;
7170
int LUTbinsZ = -1;
72-
float diamondPos[3] = {0.f, 0.f, 0.f};
73-
bool useDiamond = false;
74-
unsigned long maxMemory = 0;
75-
int useTrackFollower = -1; // bit 0: allow mixing implies bits 1&2; bit 1: topwards; bit2: downwards; => 0 off
76-
float trackFollowerNSigmaZ = 1.f; // sigma in z-cut for track-following search rectangle
77-
float trackFollowerNSigmaPhi = 1.f; // sigma in phi-cut for track-following search rectangle
71+
float diamondPos[3] = {0.f, 0.f, 0.f}; // override the position of the vertex
72+
bool useDiamond = false; // enable overriding the vertex position
73+
unsigned long maxMemory = 0; // override default protections on the maximum memory to be used by the tracking
74+
int useTrackFollower = -1; // bit 0: allow mixing implies bits 1&2; bit 1: topwards; bit2: downwards; => 0 off
75+
float trackFollowerNSigmaZ = 1.f; // sigma in z-cut for track-following search rectangle
76+
float trackFollowerNSigmaPhi = 1.f; // sigma in phi-cut for track-following search rectangle
7877
float cellsPerClusterLimit = -1.f;
7978
float trackletsPerClusterLimit = -1.f;
8079
int findShortTracks = -1;
81-
int nThreads = 1;
82-
int nOrbitsPerIterations = 0;
83-
int nROFsPerIterations = 0;
84-
bool perPrimaryVertexProcessing = false;
85-
bool saveTimeBenchmarks = false;
86-
bool overrideBeamEstimation = false; // used by gpuwf only
87-
int trackingMode = -1; // -1: unset, 0=sync, 1=async, 2=cosmics used by gpuwf only
88-
bool doUPCIteration = false;
80+
int nThreads = 1; // number of threads to perform the operations in parallel.
81+
int nROFsPerIterations = 0; // size of the slice of ROFs to be processed at a time, preferably integer divisors of nROFs per TF, to balance the iterations.
82+
int nOrbitsPerIterations = 0; // not implemented: size of the slice of ROFs to be processed at a time, computed using the number of ROFs per orbit.
83+
bool perPrimaryVertexProcessing = false; // perform the full tracking considering the vertex hypotheses one at the time.
84+
bool saveTimeBenchmarks = false; // dump metrics on file
85+
bool overrideBeamEstimation = false; // use beam position from meanVertex CCDB object
86+
int trackingMode = -1; // -1: unset, 0=sync, 1=async, 2=cosmics used by gpuwf only
87+
bool doUPCIteration = false; // Perform an additional iteration for UPC events on tagged vertices. You want to combine this config with VertexerParamConfig.nIterations=2
88+
bool fataliseUponFailure = true; // granular management of the fatalisation in async mode
89+
bool dropTFUponFailure = false;
8990

9091
O2ParamDef(TrackerParamConfig, "ITSCATrackerParam");
9192
};

0 commit comments

Comments
 (0)