Skip to content

Commit b5849ea

Browse files
committed
ITS3: fix study its3-tracking-study-workflow
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 2a9b34e commit b5849ea

26 files changed

Lines changed: 250 additions & 191 deletions

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class ITSTrackingInterface
8080
TimeFrameN* mTimeFrame = nullptr;
8181

8282
protected:
83+
virtual void overrideParameters(std::vector<TrackingParameters>& t, std::vector<VertexingParameters>& v) {}
8384
virtual void requestTopologyDictionary(framework::ProcessingContext& pc);
8485
virtual void loadROF(gsl::span<const itsmft::ROFRecord>& trackROFspan,
8586
gsl::span<const itsmft::CompClusterExt> clusters,

Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void ITSTrackingInterface::initialise()
5050
}
5151
auto trackParams = TrackingMode::getTrackingParameters(mMode);
5252
auto vertParams = TrackingMode::getVertexingParameters(mMode);
53+
overrideParameters(trackParams, vertParams);
5354
LOGP(info, "Initializing tracker in {} phase reconstruction with {} passes for tracking and {}/{} for vertexing", TrackingMode::toString(mMode), trackParams.size(), o2::its::VertexerParamConfig::Instance().nIterations, vertParams.size());
5455
mTracker->setParameters(trackParams);
5556
mVertexer->setParameters(vertParams);

Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ float Vertexer<NLayers>::clustersToVertices(LogFunc logger)
6161
mMemoryPool->setMaxMemory(mVertParams[iteration].MaxMemory);
6262
unsigned int nTracklets01{0}, nTracklets12{0};
6363
logger(fmt::format("=== ITS {} Seeding vertexer iteration {} summary:", mTraits->getName(), iteration));
64-
trkPars.PhiBins = mTraits->getVertexingParameters()[0].PhiBins;
65-
trkPars.ZBins = mTraits->getVertexingParameters()[0].ZBins;
64+
const auto& currentVtxPars = mTraits->getVertexingParameters()[iteration];
65+
trkPars.PhiBins = currentVtxPars.PhiBins;
66+
trkPars.ZBins = currentVtxPars.ZBins;
67+
trkPars.LayerZ = currentVtxPars.LayerZ;
68+
trkPars.LayerRadii = currentVtxPars.LayerRadii;
6669
trkPars.PassFlags = mVertParams[iteration].PassFlags;
6770
trkPars.PassFlags.set(IterationStep::FirstPass, IterationStep::RebuildClusterLUT);
6871
auto timeInitIteration = evaluateTask(&Vertexer::initialiseVertexer, StateNames[mCurStep = Init], iteration, evalLog, trkPars);

Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/TrackingInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ITS3TrackingInterface final : public its::ITSTrackingInterface
2727
void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final;
2828

2929
protected:
30+
void overrideParameters(std::vector<o2::its::TrackingParameters>& t, std::vector<o2::its::VertexingParameters>& v) final;
3031
void requestTopologyDictionary(framework::ProcessingContext& pc) final;
3132
void loadROF(gsl::span<const itsmft::ROFRecord>& trackROFspan,
3233
gsl::span<const itsmft::CompClusterExt> clusters,

Detectors/Upgrades/ITS3/reconstruction/src/IOUtils.cxx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,20 @@ int loadROFrameDataITS3(its::TimeFrame<7>* tf,
7272

7373
// check for missing/empty/unset rofs
7474
// the code requires consistent monotonically increasing input without gaps
75-
const auto& timing = tf->getROFOverlapTableView().getLayer(layer);
75+
const auto& timing = tf->getROFOverlapTableView().getLayer(layer >= 0 ? layer : 0);
7676
if (timing.mNROFsTF != rofs.size()) {
7777
LOGP(fatal, "Received inconsistent number of rofs on layer:{} expected:{} received:{}", layer, timing.mNROFsTF, rofs.size());
7878
}
7979

80-
its::bounded_vector<uint8_t> clusterSizeVec(clusters.size(), tf->getMemoryPool().get());
80+
its::bounded_vector<uint8_t> clusterSizeVec(tf->getMemoryPool().get());
81+
clusterSizeVec.reserve(clusters.size());
8182

8283
for (size_t iRof{0}; iRof < rofs.size(); ++iRof) {
8384
const auto& rof = rofs[iRof];
8485
for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
8586
const auto& c = clusters[clusterId];
8687
const auto sensorID = c.getSensorID();
87-
const auto layer = geom->getLayer(sensorID);
88+
const auto lay = geom->getLayer(sensorID);
8889

8990
float sigmaY2{0}, sigmaZ2{0}, sigmaYZ{0};
9091
uint8_t clusterSize{0};
@@ -110,30 +111,37 @@ int loadROFrameDataITS3(its::TimeFrame<7>* tf,
110111
}
111112
math_utils::detail::bringToPMPi(alpha); // alpha is defined on -Pi,Pi
112113

113-
tf->addTrackingFrameInfoToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), x, alpha,
114+
tf->addTrackingFrameInfoToLayer(lay, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), x, alpha,
114115
std::array<float, 2>{y, trkXYZ.z()},
115116
std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});
116117

117118
/// Rotate to the global frame
118-
tf->addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), tf->getUnsortedClusters()[layer].size());
119-
tf->addClusterExternalIndexToLayer(layer, clusterId);
119+
tf->addClusterToLayer(lay, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), tf->getUnsortedClusters()[lay].size());
120+
tf->addClusterExternalIndexToLayer(lay, clusterId);
121+
}
122+
// effectively calculating an exclusive sum
123+
if (layer >= 0) {
124+
tf->mROFramesClusters[layer][iRof + 1] = tf->mUnsortedClusters[layer].size();
125+
} else {
126+
for (unsigned int iL{0}; iL < tf->mUnsortedClusters.size(); ++iL) {
127+
tf->mROFramesClusters[iL][iRof + 1] = tf->mUnsortedClusters[iL].size();
128+
}
120129
}
121-
tf->mROFramesClusters[layer][iRof + 1] = (int)tf->getUnsortedClusters()[layer].size();
122130
}
123131

124132
tf->setClusterSize(layer, clusterSizeVec);
125133

126-
if (layer == 1) {
127-
for (auto& v : tf->mNTrackletsPerCluster) {
128-
v.resize(tf->getUnsortedClusters()[1].size());
129-
}
130-
for (auto& v : tf->mNTrackletsPerClusterSum) {
131-
v.resize(tf->getUnsortedClusters()[1].size() + 1);
134+
if (layer == 1 || layer == -1) {
135+
for (auto i = 0; i < tf->mNTrackletsPerCluster.size(); ++i) {
136+
tf->mNTrackletsPerCluster[i].resize(tf->mUnsortedClusters[1].size());
137+
tf->mNTrackletsPerClusterSum[i].resize(tf->mUnsortedClusters[1].size() + 1);
132138
}
133139
}
134140

135141
if (mcLabels != nullptr) {
136-
tf->mClusterLabels[layer] = mcLabels;
142+
tf->mClusterLabels[layer >= 0 ? layer : 0] = mcLabels;
143+
} else {
144+
tf->mClusterLabels[layer >= 0 ? layer : 0] = nullptr;
137145
}
138146
return 0;
139147
}

Detectors/Upgrades/ITS3/reconstruction/src/TrackingInterface.cxx

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

12+
#include "ITS3Base/SpecsV2.h"
1213
#include "ITS3Reconstruction/TrackingInterface.h"
1314
#include "ITS3Reconstruction/IOUtils.h"
1415
#include "ITSBase/GeometryTGeo.h"
15-
#include "ITStracking/FastMultEstConfig.h"
16-
#include "ITStracking/TrackingConfigParam.h"
1716
#include "DataFormatsITSMFT/DPLAlpideParam.h"
1817
#include "DetectorsBase/GRPGeomHelper.h"
19-
#include "Framework/DeviceSpec.h"
2018

2119
namespace o2::its3
2220
{
2321

22+
void ITS3TrackingInterface::overrideParameters(std::vector<o2::its::TrackingParameters>& t, std::vector<o2::its::VertexingParameters>& v)
23+
{
24+
// only override IB radii
25+
for (auto& tt : t) {
26+
tt.LayerRadii[0] = constants::radii[0];
27+
tt.LayerRadii[1] = constants::radii[1];
28+
tt.LayerRadii[2] = constants::radii[2];
29+
}
30+
for (auto& vv : v) {
31+
vv.LayerRadii[0] = constants::radii[0];
32+
vv.LayerRadii[1] = constants::radii[1];
33+
vv.LayerRadii[2] = constants::radii[2];
34+
}
35+
}
36+
2437
void ITS3TrackingInterface::requestTopologyDictionary(framework::ProcessingContext& pc)
2538
{
2639
pc.inputs().get<o2::its3::TopologyDictionary*>("itscldict"); // just to trigger the finaliseCCDB

Detectors/Upgrades/ITS3/simulation/src/Digitizer.cxx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ void Digitizer::process(const std::vector<itsmft::Hit>* hits, int evID, int srcI
9696
return (*hits)[lhs].GetDetectorID() < (*hits)[rhs].GetDetectorID();
9797
});
9898
for (int i : hitIdx | std::views::filter([&](int idx) {
99+
if (layer < 0) {
100+
return true;
101+
}
99102
return mGeometry->getLayer((*hits)[idx].GetDetectorID()) == layer;
100103
})) {
101104
processHit((*hits)[i], mROFrameMax, evID, srcID, layer);
@@ -170,7 +173,7 @@ void Digitizer::fillOutputContainer(uint32_t frameLast, int layer)
170173
auto& extra = *(mExtraBuff.front().get());
171174
for (size_t iChip{0}; iChip < mChips.size(); ++iChip) {
172175
auto& chip = mChips[iChip];
173-
if (chip.isDisabled() || mGeometry->getLayer(chip.getChipIndex()) != layer) {
176+
if (chip.isDisabled() || (layer >= 0 && mGeometry->getLayer(chip.getChipIndex()) != layer)) {
174177
continue;
175178
}
176179
chip.addNoise(mROFrameMin, mROFrameMin, &mParams);
@@ -216,7 +219,7 @@ void Digitizer::fillOutputContainer(uint32_t frameLast, int layer)
216219
}
217220
}
218221

219-
void Digitizer::processHit(const o2::itsmft::Hit& hit, uint32_t& maxFr, int evID, int srcID, int layer)
222+
void Digitizer::processHit(const o2::itsmft::Hit& hit, uint32_t& maxFr, int evID, int srcID, int lay)
220223
{
221224
// convert single hit to digits
222225
auto chipID = hit.GetDetectorID();
@@ -248,18 +251,16 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, uint32_t& maxFr, int evID
248251
}
249252
float tTot = mParams.getSignalShape().getMaxDuration();
250253
// frame of the hit signal start wrt event ROFrame
251-
int roFrameRel = int(timeInROF * mParams.getROFrameLengthInv(layer));
254+
int roFrameRel = int(timeInROF * mParams.getROFrameLengthInv(lay));
252255
// frame of the hit signal end wrt event ROFrame: in the triggered mode we read just 1 frame
253-
uint32_t roFrameRelMax = mParams.isContinuous() ? (timeInROF + tTot) * mParams.getROFrameLengthInv(layer) : roFrameRel;
256+
uint32_t roFrameRelMax = mParams.isContinuous() ? (timeInROF + tTot) * mParams.getROFrameLengthInv(lay) : roFrameRel;
254257
int nFrames = roFrameRelMax + 1 - roFrameRel;
255258
uint32_t roFrameMax = mNewROFrame + roFrameRelMax;
256-
if (roFrameMax > maxFr) {
257-
maxFr = roFrameMax; // if signal extends beyond current maxFrame, increase the latter
258-
}
259+
maxFr = std::max(roFrameMax, maxFr); // if signal extends beyond current maxFrame, increase the latter
259260

260261
// here we start stepping in the depth of the sensor to generate charge diffision
261-
int detID{hit.GetDetectorID()};
262-
const auto& matrix = mGeometry->getMatrixL2G(detID);
262+
const int layer = mGeometry->getLayer(chipID);
263+
const auto& matrix = mGeometry->getMatrixL2G(chipID);
263264
int nSteps = chip.isIB() ? mParams.getIBNSimSteps() : mParams.getNSimSteps();
264265
float nStepsInv = chip.isIB() ? mParams.getIBNSimStepsInv() : mParams.getNSimStepsInv();
265266
math_utils::Vector3D<float> xyzLocS, xyzLocE;
@@ -422,7 +423,7 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, uint32_t& maxFr, int evID
422423
continue;
423424
}
424425
uint16_t colIS = icol + colS;
425-
registerDigits(chip, roFrameAbs, timeInROF, nFrames, rowIS, colIS, nEle, lbl, layer);
426+
registerDigits(chip, roFrameAbs, timeInROF, nFrames, rowIS, colIS, nEle, lbl, lay);
426427
}
427428
}
428429
}

Detectors/Upgrades/ITS3/study/include/ITS3TrackingStudy/ITS3TrackingStudyParam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct ITS3TrackingStudyParam : o2::conf::ConfigurableParamHelper<ITS3TrackingSt
3636
int minTPCCls{110};
3737

3838
// propagator
39-
o2::base::PropagatorImpl<float>::MatCorrType CorrType = o2::base::PropagatorImpl<float>::MatCorrType::USEMatCorrLUT;
39+
o2::base::PropagatorImpl<float>::MatCorrType CorrType = o2::base::PropagatorImpl<float>::MatCorrType::USEMatCorrTGeo;
4040

4141
/// studies
4242
bool doDCA = false;

Detectors/Upgrades/ITS3/study/macros/PlotPulls.C

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

12-
/// \file PlotDCA.C
13-
/// \brief Simple macro to plot ITS3 impact parameter resolution
12+
/// \file PlotPulls.C
13+
/// \brief Simple macro to plot ITS3 pulls
1414

1515
#if !defined(__CLING__) || defined(__ROOTCLING__)
16+
#include <array>
17+
#include <cmath>
1618
#include <memory>
19+
#include <vector>
1720

1821
#include <TROOT.h>
1922
#include <TCanvas.h>
@@ -27,7 +30,6 @@
2730

2831
#include "ReconstructionDataFormats/GlobalTrackID.h"
2932
#include "ReconstructionDataFormats/Track.h"
30-
#include "ReconstructionDataFormats/DCA.h"
3133
#include "SimulationDataFormat/MCTrack.h"
3234
#endif
3335

@@ -49,7 +51,13 @@ void PlotPulls(const char* fName = "its3TrackStudy.root")
4951
{
5052
TH1::SetDefaultSumw2();
5153
std::unique_ptr<TFile> inFile(TFile::Open(fName));
54+
if (!inFile || inFile->IsZombie()) {
55+
return;
56+
}
5257
auto tree = inFile->Get<TTree>("pull");
58+
if (!tree) {
59+
return;
60+
}
5361

5462
uint8_t src; // track type
5563
tree->SetBranchAddress("src", &src);
@@ -133,13 +141,13 @@ void PlotPulls(const char* fName = "its3TrackStudy.root")
133141
std::vector<TH1D*> projs;
134142
const char* fitOpt{"QWMERSB"};
135143
for (int i{0}; i < o2::track::kNParams; ++i) {
136-
for (auto iPt{0}; iPt < nPtBins; ++iPt) {
144+
for (auto iPt{0}; iPt < nPtBins - 1; ++iPt) {
137145
auto hProj = pulls[i]->ProjectionY(Form("%s_%d", pulls[i]->GetName(), iPt), iPt + 1, iPt + 1);
138146
hProj->SetName(Form("p%s_pt%d", pNames[i], iPt));
139147
hProj->SetTitle(Form("Pull %s #it{p}_{T}#in[%.2f, %.2f)", pNames[i], ptLimits[iPt], ptLimits[iPt + 1]));
140148
projs.push_back(hProj);
141149
if (hProj->GetEntries() < 100) {
142-
return;
150+
continue;
143151
}
144152
fGaus->SetParameter(1, 0);
145153
fGaus->SetParameter(2, 1);
@@ -153,14 +161,18 @@ void PlotPulls(const char* fName = "its3TrackStudy.root")
153161
}
154162
}
155163

156-
hMahDist2->Scale(1. / hMahDist2->Integral("width"));
157164
TF1* fchi2Fit = new TF1("fchi2_fit", chi2_pdf, 0.1, 6, 3);
158165
fchi2Fit->SetParNames("A", "k", "s");
159166
fchi2Fit->SetParameter(0, 1);
160167
fchi2Fit->SetParameter(1, 5);
161168
fchi2Fit->SetParameter(2, 1);
162-
auto fitres = hMahDist2->Fit(fchi2Fit, "RMQS");
163-
fitres->Print();
169+
if (hMahDist2->Integral("width") > 0.) {
170+
hMahDist2->Scale(1. / hMahDist2->Integral("width"));
171+
auto fitres = hMahDist2->Fit(fchi2Fit, "RMQS");
172+
if (fitres.Get()) {
173+
fitres->Print();
174+
}
175+
}
164176

165177
TFile outFile("plotPulls.root", "RECREATE");
166178
for (int i{0}; i < o2::track::kNParams; ++i) {

0 commit comments

Comments
 (0)