Skip to content

Commit 8b7ba4e

Browse files
noferinisawenzel
authored andcommitted
fix in TOF sim digitization (decalibration), and add MC truth for QC plots
1 parent 1d6f86c commit 8b7ba4e

File tree

11 files changed

+88
-40
lines changed

11 files changed

+88
-40
lines changed

DataFormats/Detectors/TOF/include/DataFormatsTOF/Cluster.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Cluster : public o2::BaseCluster<float>
5353

5454
Cluster() = default;
5555

56-
Cluster(std::int16_t sensid, float x, float y, float z, float sy2, float sz2, float syz, double timeRaw, double time, float tot, int L0L1latency, int deltaBC);
56+
Cluster(std::int16_t sensid, float x, float y, float z, float sy2, float sz2, float syz, double timeRaw, double time, float tot, int L0L1latency, int deltaBC, float geanttime = 0.0, double t0 = 0.0);
5757

5858
~Cluster() = default;
5959

@@ -134,6 +134,10 @@ class Cluster : public o2::BaseCluster<float>
134134
int getDigitInfoCH(int idig) const { return mDigitInfoCh[idig]; }
135135
double getDigitInfoT(int idig) const { return mDigitInfoT[idig]; }
136136
float getDigitInfoTOT(int idig) const { return mDigitInfoTOT[idig]; }
137+
float getTgeant() const { return mTgeant; }
138+
void setTgeant(float val) { mTgeant = val; }
139+
double getT0true() const { return mT0true; }
140+
void setT0true(double val) { mT0true = val; }
137141

138142
private:
139143
#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
@@ -153,8 +157,10 @@ class Cluster : public o2::BaseCluster<float>
153157
int mDigitInfoCh[6] = {0, 0, 0, 0, 0, 0};
154158
double mDigitInfoT[6] = {0., 0., 0., 0., 0., 0.};
155159
float mDigitInfoTOT[6] = {0., 0., 0., 0., 0., 0.};
160+
float mTgeant = 0.0;
161+
double mT0true = 0.0;
156162

157-
ClassDefNV(Cluster, 4);
163+
ClassDefNV(Cluster, 5);
158164
};
159165

160166
#ifndef GPUCA_GPUCODE

DataFormats/Detectors/TOF/src/Cluster.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using namespace o2::tof;
2323

2424
ClassImp(o2::tof::Cluster);
2525

26-
Cluster::Cluster(std::int16_t sensid, float x, float y, float z, float sy2, float sz2, float syz, double timeRaw, double time, float tot, int L0L1Latency, int deltaBC) : o2::BaseCluster<float>(sensid, x, y, z, sy2, sz2, syz), mTimeRaw(timeRaw), mTime(time), mTot(tot), mL0L1Latency(L0L1Latency), mDeltaBC(deltaBC)
26+
Cluster::Cluster(std::int16_t sensid, float x, float y, float z, float sy2, float sz2, float syz, double timeRaw, double time, float tot, int L0L1Latency, int deltaBC, float geanttime, double t0) : o2::BaseCluster<float>(sensid, x, y, z, sy2, sz2, syz), mTimeRaw(timeRaw), mTime(time), mTot(tot), mL0L1Latency(L0L1Latency), mDeltaBC(deltaBC), mTgeant(geanttime), mT0true(t0)
2727
{
2828

2929
// caching R and phi

DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MatchInfoTOF
2828
using GTrackID = o2::dataformats::GlobalTrackID;
2929

3030
public:
31-
MatchInfoTOF(int idLocal, int idxTOFCl, double time, float chi2, o2::track::TrackLTIntegral trkIntLT, GTrackID idxTrack, float dt = 0, float z = 0, float dx = 0, float dz = 0, float dy = 0) : mIdLocal(idLocal), mIdxTOFCl(idxTOFCl), mSignal(time), mChi2(chi2), mIntLT(trkIntLT), mIdxTrack(idxTrack), mDeltaT(dt), mZatTOF(z), mDXatTOF(dx), mDZatTOF(dz), mDYatTOF(dy){};
31+
MatchInfoTOF(int idLocal, int idxTOFCl, double time, float chi2, o2::track::TrackLTIntegral trkIntLT, GTrackID idxTrack, float dt = 0, float z = 0, float dx = 0, float dz = 0, float dy = 0, float geanttime = 0.0, double t0 = 0.0) : mIdLocal(idLocal), mIdxTOFCl(idxTOFCl), mSignal(time), mChi2(chi2), mIntLT(trkIntLT), mIdxTrack(idxTrack), mDeltaT(dt), mZatTOF(z), mDXatTOF(dx), mDZatTOF(dz), mDYatTOF(dy), mTgeant(geanttime), mT0true(t0){};
3232
MatchInfoTOF() = default;
3333
void setIdxTOFCl(int index) { mIdxTOFCl = index; }
3434
void setIdxTrack(GTrackID index) { mIdxTrack = index; }
@@ -70,6 +70,10 @@ class MatchInfoTOF
7070
void setVz(float val) { mVz = val; }
7171
int getChannel() const { return mChannel; }
7272
void setChannel(int val) { mChannel = val; }
73+
float getTgeant() const { return mTgeant; }
74+
void setTgeant(float val) { mTgeant = val; }
75+
double getT0true() const { return mT0true; }
76+
void setT0true(double val) { mT0true = val; }
7377

7478
private:
7579
int mIdLocal; // track id in sector of the pair track-TOFcluster
@@ -88,8 +92,10 @@ class MatchInfoTOF
8892
// Hit pattern information
8993
bool mHitUpDown = false; ///< hit pattern in TOF up-down
9094
bool mHitLeftRight = false; ///< hit pattern in TOF left-right
95+
float mTgeant = 0.0; ///< geant time in MC
96+
double mT0true = 0.0; ///< t0true
9197

92-
ClassDefNV(MatchInfoTOF, 7);
98+
ClassDefNV(MatchInfoTOF, 8);
9399
};
94100
} // namespace dataformats
95101
} // namespace o2

Detectors/GlobalTracking/src/MatchTOF.cxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,9 @@ void MatchTOF::doMatching(int sec)
967967
}
968968
}
969969

970+
// adjust accordingly to DeltaY
971+
updateTL(trkLTInt[nStripsCrossedInPropagation - 1], -deltaPosTemp[1]);
972+
970973
detId[nStripsCrossedInPropagation - 1][0] = detIdTemp[0];
971974
detId[nStripsCrossedInPropagation - 1][1] = detIdTemp[1];
972975
detId[nStripsCrossedInPropagation - 1][2] = detIdTemp[2];
@@ -1340,11 +1343,14 @@ void MatchTOF::doMatchingForTPC(int sec)
13401343
for (int ii = 0; ii < 3; ii++) { // we need to change the type...
13411344
posFloat[ii] = pos[ii];
13421345
}
1346+
13431347
while (deltaPosTemp2[1] < -0.05 && detIdTemp2[2] != -1 && nstep < maxnstep) { // continuing propagation if dy is negative and we are still inside the strip volume
13441348
nstep++;
13451349
xStop += 0.1;
13461350
propagateToRefXWithoutCov(trefTrk, xStop, 0.1, mBz, posFloat);
13471351

1352+
posFloat[2] += ZshiftCurrent;
1353+
13481354
Geo::getPadDxDyDz(posFloat, detIdTemp2, deltaPosTemp2, sec);
13491355
if (detIdTemp2[2] != -1) { // if propation was succesful -> update params
13501356
float dx = deltaPosTemp2[0] - deltaPosTemp[0];
@@ -1356,9 +1362,15 @@ void MatchTOF::doMatchingForTPC(int sec)
13561362
detIdTemp[2] = detIdTemp2[2];
13571363
detIdTemp[3] = detIdTemp2[3];
13581364
detIdTemp[4] = detIdTemp2[4];
1365+
deltaPosTemp[0] = deltaPosTemp2[0];
1366+
deltaPosTemp[1] = deltaPosTemp2[1];
1367+
deltaPosTemp[2] = deltaPosTemp2[2];
13591368
}
13601369
}
13611370

1371+
// adjust accordingly to DeltaY
1372+
updateTL(trkLTInt[ibc][nStripsCrossedInPropagation[ibc] - 1], -deltaPosTemp[1]);
1373+
13621374
detId[ibc][nStripsCrossedInPropagation[ibc] - 1][0] = detIdTemp[0];
13631375
detId[ibc][nStripsCrossedInPropagation[ibc] - 1][1] = detIdTemp[1];
13641376
detId[ibc][nStripsCrossedInPropagation[ibc] - 1][2] = detIdTemp[2];
@@ -1671,6 +1683,10 @@ void MatchTOF::BestMatches(std::vector<o2::dataformats::MatchInfoTOFReco>& match
16711683
if (std::abs(timeNew - timeOld) < 200) {
16721684
// update time information averaging the two (the second one corrected for the difference in the track length)
16731685
prevMatching.setSignal((timeNew + timeOld) * 0.5);
1686+
float geanttime = (TOFClusWork[matchingPair.getTOFClIndex()].getTgeant() + TOFClusWork[prevMatching.getTOFClIndex()].getTgeant() - deltaT * 1E-3) * 0.5;
1687+
double t0 = (TOFClusWork[matchingPair.getTOFClIndex()].getT0true() + TOFClusWork[prevMatching.getTOFClIndex()].getT0true()) * 0.5;
1688+
prevMatching.setTgeant(geanttime);
1689+
prevMatching.setT0true(t0);
16741690
prevMatching.setChi2(0); // flag such cases with chi2 equal to zero
16751691
matchedClustersIndex[matchingPair.getTOFClIndex()] = matchedTracksIndex[trkType][itrk]; // flag also the second cluster as already used
16761692
}
@@ -1682,6 +1698,9 @@ void MatchTOF::BestMatches(std::vector<o2::dataformats::MatchInfoTOFReco>& match
16821698
matchedTracksIndex[trkType][itrk] = matchedTracks[trkTypeSplitted].size(); // index of the MatchInfoTOF correspoding to this track
16831699
matchedClustersIndex[matchingPair.getTOFClIndex()] = matchedTracksIndex[trkType][itrk]; // index of the track that was matched to this cluster
16841700

1701+
matchingPair.setTgeant(TOFClusWork[matchingPair.getTOFClIndex()].getTgeant());
1702+
matchingPair.setT0true(TOFClusWork[matchingPair.getTOFClIndex()].getT0true());
1703+
16851704
// let's check if cluster has multiple-hits (noferini)
16861705
if (TOFClusWork[matchingPair.getTOFClIndex()].getNumOfContributingChannels() > 1) {
16871706
const auto& tofcl = TOFClusWork[matchingPair.getTOFClIndex()];

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class Digit
3232
public:
3333
Digit() = default;
3434

35-
Digit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label = -1, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0);
36-
Digit(Int_t channel, Int_t tdc, Int_t tot, uint32_t orbit, uint16_t bc, Int_t label = -1, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0);
35+
Digit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label = -1, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0, float geanttime = 0, double t0 = 0);
36+
Digit(Int_t channel, Int_t tdc, Int_t tot, uint32_t orbit, uint16_t bc, Int_t label = -1, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0, float geanttime = 0, double t0 = 0);
3737
~Digit() = default;
3838

3939
/// Get global ordering key made of
@@ -66,7 +66,7 @@ class Digit
6666

6767
void printStream(std::ostream& stream) const;
6868

69-
void merge(Int_t tdc, Int_t tot);
69+
bool merge(Int_t tdc, Int_t tot);
7070

7171
void getPhiAndEtaIndex(int& phi, int& eta) const;
7272

@@ -93,6 +93,11 @@ class Digit
9393
void setTriggerBunch(uint16_t value) { mTriggerBunch = value; }
9494
uint16_t getTriggerBunch() const { return mTriggerBunch; }
9595

96+
float getTgeant() const { return mTgeant; }
97+
void setTgeant(float val) { mTgeant = val; }
98+
double getT0true() const { return mT0true; }
99+
void setT0true(double val) { mT0true = val; }
100+
96101
private:
97102
friend class boost::serialization::access;
98103

@@ -107,8 +112,10 @@ class Digit
107112
uint16_t mTriggerBunch = 0; //!< bunch id of trigger event
108113
Bool_t mIsUsedInCluster; //!/< flag to declare that the digit was used to build a cluster
109114
Bool_t mIsProblematic = false; //!< flag to tell whether the channel of the digit was problemati; not persistent; default = ok
115+
float mTgeant = 0.0; ///< geant time in MC
116+
double mT0true = 0.0; ///< t0true
110117

111-
ClassDefNV(Digit, 4);
118+
ClassDefNV(Digit, 5);
112119
};
113120

114121
std::ostream& operator<<(std::ostream& stream, const Digit& dig);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Strip
8080
/// reset points container
8181
o2::tof::Digit* findDigit(ULong64_t key);
8282

83-
Int_t addDigit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t lbl = 0, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0); // returns the MC label
83+
Int_t addDigit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t lbl = 0, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0, float geanttime = 0, double t0 = 0); // returns the MC label
8484

8585
void fillOutputContainer(std::vector<o2::tof::Digit>& digits);
8686

Detectors/TOF/base/src/Digit.cxx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ using namespace o2::tof;
1717

1818
ClassImp(o2::tof::Digit);
1919

20-
Digit::Digit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label, uint32_t triggerorbit, uint16_t triggerbunch)
21-
: mChannel(channel), mTDC(tdc), mTOT(tot), mIR(0, 0), mLabel(label), mTriggerOrbit(triggerorbit), mTriggerBunch(triggerbunch), mIsUsedInCluster(kFALSE)
20+
Digit::Digit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label, uint32_t triggerorbit, uint16_t triggerbunch, float geanttime, double t0)
21+
: mChannel(channel), mTDC(tdc), mTOT(tot), mIR(0, 0), mLabel(label), mTriggerOrbit(triggerorbit), mTriggerBunch(triggerbunch), mIsUsedInCluster(kFALSE), mTgeant(geanttime), mT0true(t0)
2222
{
2323
mIR.setFromLong(bc);
2424
}
2525
//______________________________________________________________________
26-
Digit::Digit(Int_t channel, Int_t tdc, Int_t tot, uint32_t orbit, uint16_t bc, Int_t label, uint32_t triggerorbit, uint16_t triggerbunch)
27-
: mChannel(channel), mTDC(tdc), mTOT(tot), mIR(bc, orbit), mLabel(label), mTriggerOrbit(triggerorbit), mTriggerBunch(triggerbunch), mIsUsedInCluster(kFALSE)
26+
Digit::Digit(Int_t channel, Int_t tdc, Int_t tot, uint32_t orbit, uint16_t bc, Int_t label, uint32_t triggerorbit, uint16_t triggerbunch, float geanttime, double t0)
27+
: mChannel(channel), mTDC(tdc), mTOT(tot), mIR(bc, orbit), mLabel(label), mTriggerOrbit(triggerorbit), mTriggerBunch(triggerbunch), mIsUsedInCluster(kFALSE), mTgeant(geanttime), mT0true(t0)
2828
{
2929
}
3030
//______________________________________________________________________
@@ -44,16 +44,18 @@ std::ostream& operator<<(std::ostream& stream, const Digit& digi)
4444

4545
//______________________________________________________________________
4646

47-
void Digit::merge(Int_t tdc, Int_t tot)
47+
bool Digit::merge(Int_t tdc, Int_t tot)
4848
{
4949

5050
// merging two digits
5151

5252
if (tdc < mTDC) {
5353
mTDC = tdc;
54+
return 1; // new came first
5455
// TODO: adjust TOT
5556
} else {
5657
// TODO: adjust TOT
58+
return 0;
5759
}
5860
}
5961

Detectors/TOF/base/src/Strip.cxx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Strip::Strip(Int_t index)
3434
{
3535
}
3636
//_______________________________________________________________________
37-
Int_t Strip::addDigit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t lbl, uint32_t triggerorbit, uint16_t triggerbunch)
37+
Int_t Strip::addDigit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t lbl, uint32_t triggerorbit, uint16_t triggerbunch, float geanttime, double t0)
3838
{
3939

4040
// return the MC label. We pass it also as argument, but it can change in
@@ -44,10 +44,13 @@ Int_t Strip::addDigit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t lb
4444
auto dig = findDigit(key);
4545
if (dig) {
4646
lbl = dig->getLabel(); // getting the label from the already existing digit
47-
dig->merge(tdc, tot); // merging to the existing digit
47+
if (dig->merge(tdc, tot)) { // merging to the existing digit (if new came first upload also MC truth)
48+
dig->setTgeant(geanttime);
49+
dig->setT0true(t0);
50+
}
4851
mDigitMerged++;
4952
} else {
50-
mDigits.emplace(std::make_pair(key, Digit(channel, tdc, tot, bc, lbl, triggerorbit, triggerbunch)));
53+
mDigits.emplace(std::make_pair(key, Digit(channel, tdc, tot, bc, lbl, triggerorbit, triggerbunch, geanttime, t0)));
5154
}
5255

5356
return lbl;

Detectors/TOF/reconstruction/src/Clusterer.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ void Clusterer::buildCluster(Cluster& c, MCLabelContainer const* digitMCTruth)
173173
}
174174

175175
c.setMainContributingChannel(mContributingDigit[0]->getChannel());
176+
c.setTgeant(mContributingDigit[0]->getTgeant());
177+
c.setT0true(mContributingDigit[0]->getT0true());
176178
c.setTime(mContributingDigit[0]->getCalibratedTime()); // time in ps (for now we assume it calibrated)
177179
c.setTimeRaw(mContributingDigit[0]->getTDC() * Geo::TDCBIN + mContributingDigit[0]->getBC() * o2::constants::lhc::LHCBunchSpacingNS * 1E3); // time in ps (for now we assume it calibrated)
178180

Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ class Digitizer : public WindowFiller
135135

136136
CalibApi* mCalibApi = nullptr; //! calib api to handle the TOF calibration
137137

138-
void fillDigitsInStrip(std::vector<Strip>* strips, o2::dataformats::MCTruthContainer<o2::tof::MCLabel>* mcTruthContainer, int channel, int tdc, int tot, uint64_t nbc, UInt_t istrip, Int_t trackID, Int_t eventID, Int_t sourceID);
138+
void fillDigitsInStrip(std::vector<Strip>* strips, o2::dataformats::MCTruthContainer<o2::tof::MCLabel>* mcTruthContainer, int channel, int tdc, int tot, uint64_t nbc, UInt_t istrip, Int_t trackID, Int_t eventID, Int_t sourceID, float geanttime = 0, double t0 = 0.0);
139139

140140
Int_t processHit(const HitType& hit, Double_t event_time);
141141
void addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x, Float_t z, Float_t charge, Int_t iX, Int_t iZ, Int_t padZfired,
142-
Int_t trackID);
142+
Int_t trackID, float geanttime = 0, double t0 = 0.0);
143143

144144
void checkIfReuseFutureDigits();
145145

0 commit comments

Comments
 (0)