Skip to content

Commit 2d413ea

Browse files
Speedup in TOF matching (#7053)
* Speedup in TOF matching Further speedup remove comments clang-format improve printout A bit of comments * Fix test Typo * InitIndices function, so that geo file is not needed for some static arrays * clang-format * optimize tof getpadDxDyDz (#43) Co-authored-by: Francesco Noferini <noferini@bo.infn.it>
1 parent 40f6d7d commit 2d413ea

File tree

4 files changed

+145
-55
lines changed

4 files changed

+145
-55
lines changed

Detectors/GlobalTracking/src/MatchTOF.cxx

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ void MatchTOF::run(const o2::globaltracking::RecoContainer& inp)
6262

6363
mTimerMatchTPC.Reset();
6464
mTimerMatchITSTPC.Reset();
65-
mTimerTot.Start();
66-
67-
mTimerTot.Stop();
68-
LOGF(INFO, "Timing prepareTOFCluster: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1);
69-
mTimerTot.Start();
65+
mTimerTot.Reset();
7066

7167
for (int i = 0; i < trkType::SIZE; i++) {
7268
mMatchedTracks[i].clear();
@@ -88,18 +84,30 @@ void MatchTOF::run(const o2::globaltracking::RecoContainer& inp)
8884
mSideTPC.clear();
8985
mExtraTPCFwdTime.clear();
9086

91-
if (!prepareTOFClusters()) { // check cluster before of tracks to see also if MC is required
87+
mTimerTot.Start();
88+
bool isPrepareTOFClusters = prepareTOFClusters();
89+
mTimerTot.Stop();
90+
LOGF(INFO, "Timing prepareTOFCluster: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1);
91+
92+
if (!isPrepareTOFClusters) { // check cluster before of tracks to see also if MC is required
9293
return;
9394
}
9495

95-
if (!prepareTPCData() || !prepareFITData()) {
96+
mTimerTot.Start();
97+
if (!prepareTPCData()) {
9698
return;
9799
}
98-
99100
mTimerTot.Stop();
100-
LOGF(INFO, "Timing prepare tracks: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1);
101+
LOGF(INFO, "Timing prepare TPC tracks: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1);
102+
101103
mTimerTot.Start();
104+
if (!prepareFITData()) {
105+
return;
106+
}
107+
mTimerTot.Stop();
108+
LOGF(INFO, "Timing prepare FIT data: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1);
102109

110+
mTimerTot.Start();
103111
for (int sec = o2::constants::math::NSectors; sec--;) {
104112
mMatchedTracksPairs.clear(); // new sector
105113
LOG(INFO) << "Doing matching for sector " << sec << "...";
@@ -126,7 +134,7 @@ void MatchTOF::run(const o2::globaltracking::RecoContainer& inp)
126134
mIsITSTPCTRDused = false;
127135

128136
mTimerTot.Stop();
129-
LOGF(INFO, "Timing Do Matching: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1);
137+
LOGF(INFO, "Timing Do Matching: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1);
130138
LOGF(INFO, "Timing Do Matching ITSTPC: Cpu: %.3e s Real: %.3e s in %d slots", mTimerMatchITSTPC.CpuTime(), mTimerMatchITSTPC.RealTime(), mTimerMatchITSTPC.Counter() - 1);
131139
LOGF(INFO, "Timing Do Matching TPC : Cpu: %.3e s Real: %.3e s in %d slots", mTimerMatchTPC.CpuTime(), mTimerMatchTPC.RealTime(), mTimerMatchTPC.Counter() - 1);
132140
}
@@ -371,6 +379,7 @@ bool MatchTOF::prepareTOFClusters()
371379
int nClusterInCurrentChunk = mTOFClustersArrayInp.size();
372380
LOG(DEBUG) << "nClusterInCurrentChunk = " << nClusterInCurrentChunk;
373381
mNumOfClusters += nClusterInCurrentChunk;
382+
mTOFClusWork.reserve(mTOFClusWork.size() + mNumOfClusters);
374383
for (int it = 0; it < nClusterInCurrentChunk; it++) {
375384
const Cluster& clOrig = mTOFClustersArrayInp[it];
376385
// create working copy of track param
@@ -483,7 +492,7 @@ void MatchTOF::doMatching(int sec)
483492
detIdTemp[idet] = -1;
484493
}
485494

486-
Geo::getPadDxDyDz(posFloat, detIdTemp, deltaPosTemp);
495+
Geo::getPadDxDyDz(posFloat, detIdTemp, deltaPosTemp, sec);
487496

488497
reachedPoint += step;
489498

@@ -805,7 +814,7 @@ void MatchTOF::doMatchingForTPC(int sec)
805814
posFloat[2] = pos[2];
806815
}
807816

808-
Geo::getPadDxDyDz(posFloat, detIdTemp, deltaPosTemp);
817+
Geo::getPadDxDyDz(posFloat, detIdTemp, deltaPosTemp, sec);
809818

810819
if (detIdTemp[2] == -1) {
811820
continue;
@@ -1157,7 +1166,7 @@ bool MatchTOF::propagateToRefX(o2::track::TrackParCov& trc, float xRef, float st
11571166
{
11581167
// propagate track to matching reference X
11591168
o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; // material correction method
1160-
const float tanHalfSector = tan(o2::constants::math::SectorSpanRad / 2);
1169+
static const float tanHalfSector = tan(o2::constants::math::SectorSpanRad / 2);
11611170
bool refReached = false;
11621171
float xStart = trc.getX();
11631172
// the first propagation will be from 2m, if the track is not at least at 2m

Detectors/TOF/base/include/TOFBase/Geo.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#define ALICEO2_TOF_GEO_H
1414

1515
#include "Rtypes.h"
16+
#include <array>
17+
#include <vector>
1618
#include "CommonConstants/LHCConstants.h"
1719
//#include "DetectorsRaw/HBFUtils.h"
1820

@@ -59,6 +61,7 @@ class Geo
5961

6062
// From AliTOFGeometry
6163
static void translate(Float_t* xyz, Float_t translationVector[3]);
64+
static void translate(Float_t& x, Float_t& y, Float_t& z, Float_t translationVector[3]);
6265
static void rotate(Float_t* xyz, Double_t rotationAngles[6]);
6366

6467
static void rotateToSector(Float_t* xyz, Int_t isector);
@@ -78,7 +81,7 @@ class Geo
7881
static Float_t getAngles(Int_t iplate, Int_t istrip) { return ANGLES[iplate][istrip]; }
7982
static Float_t getHeights(Int_t iplate, Int_t istrip) { return HEIGHTS[iplate][istrip]; }
8083
static Float_t getDistances(Int_t iplate, Int_t istrip) { return DISTANCES[iplate][istrip]; }
81-
static void getPadDxDyDz(const Float_t* pos, Int_t* det, Float_t* DeltaPos);
84+
static void getPadDxDyDz(const Float_t* pos, Int_t* det, Float_t* DeltaPos, int sector = -1);
8285
enum {
8386
// DAQ characteristics
8487
// cfr. TOF-TDR pag. 105 for Glossary
@@ -100,13 +103,16 @@ class Geo
100103
static constexpr int BC_IN_ORBIT = o2::constants::lhc::LHCMaxBunches; // N. bunch crossing in 1 orbit
101104

102105
static constexpr Int_t NPADX = 48;
106+
static constexpr Float_t NPADX_INV_INT = 1. / NPADX;
103107
static constexpr Int_t NPADZ = 2;
104108
static constexpr Int_t NPADS = NPADX * NPADZ;
109+
static constexpr Float_t NPADS_INV_INT = 1. / NPADS;
105110
static constexpr Int_t NSTRIPA = 15;
106111
static constexpr Int_t NSTRIPB = 19;
107112
static constexpr Int_t NSTRIPC = 19;
108113
static constexpr Int_t NMAXNSTRIP = 20;
109114
static constexpr Int_t NSTRIPXSECTOR = NSTRIPA + 2 * NSTRIPB + 2 * NSTRIPC;
115+
static constexpr Float_t NSTRIPXSECTOR_INV_INT = 1. / NSTRIPXSECTOR;
110116
static constexpr Int_t NPADSXSECTOR = NSTRIPXSECTOR * NPADS;
111117

112118
static constexpr Int_t NSECTORS = 18;
@@ -136,6 +142,7 @@ class Geo
136142
static constexpr Float_t SIGMAFORTAIL12 = 0.5; // Sig2 for simulation of TDC tails
137143

138144
static constexpr Float_t PHISEC = 20; // sector Phi width (deg)
145+
static constexpr Float_t PHISECINV = 1. / PHISEC; // sector Phi width (deg)
139146

140147
static constexpr Float_t TDCBIN = o2::constants::lhc::LHCBunchSpacingNS * 1E3 / 1024; ///< TDC bin width [ps]
141148
static constexpr Float_t NTDCBIN_PER_PS = 1. / TDCBIN; ///< number of TDC bins in 1 ns
@@ -339,6 +346,7 @@ class Geo
339346
static Int_t getCHFromECH(int echan) { return ELCHAN_TO_CHAN[echan]; }
340347

341348
static void Init();
349+
static void InitIndices();
342350

343351
private:
344352
static Int_t getSector(const Float_t* pos);
@@ -353,14 +361,17 @@ class Geo
353361
static Float_t mRotationMatrixSector[NSECTORS + 1][3][3]; // rotation matrixes
354362
static Float_t mRotationMatrixPlateStrip[NPLATES][NMAXNSTRIP][3][3];
355363
static Float_t mPadPosition[NSECTORS][NPLATES][NMAXNSTRIP][NPADZ][NPADX][3];
364+
static Int_t mPlate[NSTRIPXSECTOR];
365+
static Int_t mStripInPlate[NSTRIPXSECTOR];
366+
static std::array<std::vector<float>, 5> mDistances;
356367

357368
// cable length map
358369
static constexpr Float_t CABLEPROPAGATIONDELAY = 0.0513; // Propagation delay [ns/cm]
359370
static const Float_t CABLELENGTH[kNCrate][10][kNChain][kNTdc / 3]; // not constexpr as we initialize it in CableLength.cxx at run time
360371
static const Int_t CHAN_TO_ELCHAN[NCHANNELS];
361372
static const Int_t ELCHAN_TO_CHAN[N_ELECTRONIC_CHANNELS];
362373

363-
ClassDefNV(Geo, 1);
374+
ClassDefNV(Geo, 2);
364375
};
365376
} // namespace tof
366377
} // namespace o2

0 commit comments

Comments
 (0)