From 2918a3152262fa9308764cfa6a595f5ee11d3707 Mon Sep 17 00:00:00 2001 From: noferini <9963644+noferini@users.noreply.github.com> Date: Mon, 30 Dec 2024 14:22:27 +0100 Subject: [PATCH] fix in TOF sim digitization (decalibration), and add MC truth for QC plots --- .../TOF/include/DataFormatsTOF/Cluster.h | 10 ++++- DataFormats/Detectors/TOF/src/Cluster.cxx | 2 +- .../ReconstructionDataFormats/MatchInfoTOF.h | 10 ++++- Detectors/GlobalTracking/src/MatchTOF.cxx | 7 +++ Detectors/TOF/base/include/TOFBase/Digit.h | 15 +++++-- Detectors/TOF/base/include/TOFBase/Strip.h | 2 +- Detectors/TOF/base/src/Digit.cxx | 12 +++--- Detectors/TOF/base/src/Strip.cxx | 9 ++-- .../TOF/reconstruction/src/Clusterer.cxx | 2 + .../include/TOFSimulation/Digitizer.h | 4 +- Detectors/TOF/simulation/src/Digitizer.cxx | 43 ++++++++++--------- 11 files changed, 76 insertions(+), 40 deletions(-) diff --git a/DataFormats/Detectors/TOF/include/DataFormatsTOF/Cluster.h b/DataFormats/Detectors/TOF/include/DataFormatsTOF/Cluster.h index 589afc8a2cde9..f36150e18fbbc 100644 --- a/DataFormats/Detectors/TOF/include/DataFormatsTOF/Cluster.h +++ b/DataFormats/Detectors/TOF/include/DataFormatsTOF/Cluster.h @@ -53,7 +53,7 @@ class Cluster : public o2::BaseCluster Cluster() = default; - 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); + 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); ~Cluster() = default; @@ -134,6 +134,10 @@ class Cluster : public o2::BaseCluster int getDigitInfoCH(int idig) const { return mDigitInfoCh[idig]; } double getDigitInfoT(int idig) const { return mDigitInfoT[idig]; } float getDigitInfoTOT(int idig) const { return mDigitInfoTOT[idig]; } + float getTgeant() const { return mTgeant; } + void setTgeant(float val) { mTgeant = val; } + double getT0true() const { return mT0true; } + void setT0true(double val) { mT0true = val; } private: #if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE) @@ -153,8 +157,10 @@ class Cluster : public o2::BaseCluster int mDigitInfoCh[6] = {0, 0, 0, 0, 0, 0}; double mDigitInfoT[6] = {0., 0., 0., 0., 0., 0.}; float mDigitInfoTOT[6] = {0., 0., 0., 0., 0., 0.}; + float mTgeant = 0.0; + double mT0true = 0.0; - ClassDefNV(Cluster, 4); + ClassDefNV(Cluster, 5); }; #ifndef GPUCA_GPUCODE diff --git a/DataFormats/Detectors/TOF/src/Cluster.cxx b/DataFormats/Detectors/TOF/src/Cluster.cxx index 2ca3edeb19f0a..a7f3473e0b61c 100644 --- a/DataFormats/Detectors/TOF/src/Cluster.cxx +++ b/DataFormats/Detectors/TOF/src/Cluster.cxx @@ -23,7 +23,7 @@ using namespace o2::tof; ClassImp(o2::tof::Cluster); -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(sensid, x, y, z, sy2, sz2, syz), mTimeRaw(timeRaw), mTime(time), mTot(tot), mL0L1Latency(L0L1Latency), mDeltaBC(deltaBC) +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(sensid, x, y, z, sy2, sz2, syz), mTimeRaw(timeRaw), mTime(time), mTot(tot), mL0L1Latency(L0L1Latency), mDeltaBC(deltaBC), mTgeant(geanttime), mT0true(t0) { // caching R and phi diff --git a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h index edc1b99822ca0..3b872374dd35a 100644 --- a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h +++ b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h @@ -28,7 +28,7 @@ class MatchInfoTOF using GTrackID = o2::dataformats::GlobalTrackID; public: - 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){}; + 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){}; MatchInfoTOF() = default; void setIdxTOFCl(int index) { mIdxTOFCl = index; } void setIdxTrack(GTrackID index) { mIdxTrack = index; } @@ -70,6 +70,10 @@ class MatchInfoTOF void setVz(float val) { mVz = val; } int getChannel() const { return mChannel; } void setChannel(int val) { mChannel = val; } + float getTgeant() const { return mTgeant; } + void setTgeant(float val) { mTgeant = val; } + double getT0true() const { return mT0true; } + void setT0true(double val) { mT0true = val; } private: int mIdLocal; // track id in sector of the pair track-TOFcluster @@ -88,8 +92,10 @@ class MatchInfoTOF // Hit pattern information bool mHitUpDown = false; ///< hit pattern in TOF up-down bool mHitLeftRight = false; ///< hit pattern in TOF left-right + float mTgeant = 0.0; ///< geant time in MC + double mT0true = 0.0; ///< t0true - ClassDefNV(MatchInfoTOF, 7); + ClassDefNV(MatchInfoTOF, 8); }; } // namespace dataformats } // namespace o2 diff --git a/Detectors/GlobalTracking/src/MatchTOF.cxx b/Detectors/GlobalTracking/src/MatchTOF.cxx index 015f9497293af..8fda7477b928c 100644 --- a/Detectors/GlobalTracking/src/MatchTOF.cxx +++ b/Detectors/GlobalTracking/src/MatchTOF.cxx @@ -1671,6 +1671,10 @@ void MatchTOF::BestMatches(std::vector& match if (std::abs(timeNew - timeOld) < 200) { // update time information averaging the two (the second one corrected for the difference in the track length) prevMatching.setSignal((timeNew + timeOld) * 0.5); + float geanttime = (TOFClusWork[matchingPair.getTOFClIndex()].getTgeant() + TOFClusWork[prevMatching.getTOFClIndex()].getTgeant() - deltaT * 1E-3) * 0.5; + double t0 = (TOFClusWork[matchingPair.getTOFClIndex()].getT0true() + TOFClusWork[prevMatching.getTOFClIndex()].getT0true()) * 0.5; + prevMatching.setTgeant(geanttime); + prevMatching.setT0true(t0); prevMatching.setChi2(0); // flag such cases with chi2 equal to zero matchedClustersIndex[matchingPair.getTOFClIndex()] = matchedTracksIndex[trkType][itrk]; // flag also the second cluster as already used } @@ -1682,6 +1686,9 @@ void MatchTOF::BestMatches(std::vector& match matchedTracksIndex[trkType][itrk] = matchedTracks[trkTypeSplitted].size(); // index of the MatchInfoTOF correspoding to this track matchedClustersIndex[matchingPair.getTOFClIndex()] = matchedTracksIndex[trkType][itrk]; // index of the track that was matched to this cluster + matchingPair.setTgeant(TOFClusWork[matchingPair.getTOFClIndex()].getTgeant()); + matchingPair.setT0true(TOFClusWork[matchingPair.getTOFClIndex()].getT0true()); + // let's check if cluster has multiple-hits (noferini) if (TOFClusWork[matchingPair.getTOFClIndex()].getNumOfContributingChannels() > 1) { const auto& tofcl = TOFClusWork[matchingPair.getTOFClIndex()]; diff --git a/Detectors/TOF/base/include/TOFBase/Digit.h b/Detectors/TOF/base/include/TOFBase/Digit.h index d23c138012e81..eef03ef84b97c 100644 --- a/Detectors/TOF/base/include/TOFBase/Digit.h +++ b/Detectors/TOF/base/include/TOFBase/Digit.h @@ -32,8 +32,8 @@ class Digit public: Digit() = default; - 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); - 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); + 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); + 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); ~Digit() = default; /// Get global ordering key made of @@ -66,7 +66,7 @@ class Digit void printStream(std::ostream& stream) const; - void merge(Int_t tdc, Int_t tot); + bool merge(Int_t tdc, Int_t tot); void getPhiAndEtaIndex(int& phi, int& eta) const; @@ -93,6 +93,11 @@ class Digit void setTriggerBunch(uint16_t value) { mTriggerBunch = value; } uint16_t getTriggerBunch() const { return mTriggerBunch; } + float getTgeant() const { return mTgeant; } + void setTgeant(float val) { mTgeant = val; } + double getT0true() const { return mT0true; } + void setT0true(double val) { mT0true = val; } + private: friend class boost::serialization::access; @@ -107,8 +112,10 @@ class Digit uint16_t mTriggerBunch = 0; //!< bunch id of trigger event Bool_t mIsUsedInCluster; //!/< flag to declare that the digit was used to build a cluster Bool_t mIsProblematic = false; //!< flag to tell whether the channel of the digit was problemati; not persistent; default = ok + float mTgeant = 0.0; ///< geant time in MC + double mT0true = 0.0; ///< t0true - ClassDefNV(Digit, 4); + ClassDefNV(Digit, 5); }; std::ostream& operator<<(std::ostream& stream, const Digit& dig); diff --git a/Detectors/TOF/base/include/TOFBase/Strip.h b/Detectors/TOF/base/include/TOFBase/Strip.h index 3d23545552f34..f1152e25ab294 100644 --- a/Detectors/TOF/base/include/TOFBase/Strip.h +++ b/Detectors/TOF/base/include/TOFBase/Strip.h @@ -80,7 +80,7 @@ class Strip /// reset points container o2::tof::Digit* findDigit(ULong64_t key); - 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 + 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 void fillOutputContainer(std::vector& digits); diff --git a/Detectors/TOF/base/src/Digit.cxx b/Detectors/TOF/base/src/Digit.cxx index ed58623877e8d..00f96a0007cec 100644 --- a/Detectors/TOF/base/src/Digit.cxx +++ b/Detectors/TOF/base/src/Digit.cxx @@ -17,14 +17,14 @@ using namespace o2::tof; ClassImp(o2::tof::Digit); -Digit::Digit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label, uint32_t triggerorbit, uint16_t triggerbunch) - : mChannel(channel), mTDC(tdc), mTOT(tot), mIR(0, 0), mLabel(label), mTriggerOrbit(triggerorbit), mTriggerBunch(triggerbunch), mIsUsedInCluster(kFALSE) +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) + : mChannel(channel), mTDC(tdc), mTOT(tot), mIR(0, 0), mLabel(label), mTriggerOrbit(triggerorbit), mTriggerBunch(triggerbunch), mIsUsedInCluster(kFALSE), mTgeant(geanttime), mT0true(t0) { mIR.setFromLong(bc); } //______________________________________________________________________ -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) - : mChannel(channel), mTDC(tdc), mTOT(tot), mIR(bc, orbit), mLabel(label), mTriggerOrbit(triggerorbit), mTriggerBunch(triggerbunch), mIsUsedInCluster(kFALSE) +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) + : mChannel(channel), mTDC(tdc), mTOT(tot), mIR(bc, orbit), mLabel(label), mTriggerOrbit(triggerorbit), mTriggerBunch(triggerbunch), mIsUsedInCluster(kFALSE), mTgeant(geanttime), mT0true(t0) { } //______________________________________________________________________ @@ -44,16 +44,18 @@ std::ostream& operator<<(std::ostream& stream, const Digit& digi) //______________________________________________________________________ -void Digit::merge(Int_t tdc, Int_t tot) +bool Digit::merge(Int_t tdc, Int_t tot) { // merging two digits if (tdc < mTDC) { mTDC = tdc; + return 1; // new came first // TODO: adjust TOT } else { // TODO: adjust TOT + return 0; } } diff --git a/Detectors/TOF/base/src/Strip.cxx b/Detectors/TOF/base/src/Strip.cxx index a008776c2690f..e72bd5183c78e 100644 --- a/Detectors/TOF/base/src/Strip.cxx +++ b/Detectors/TOF/base/src/Strip.cxx @@ -34,7 +34,7 @@ Strip::Strip(Int_t index) { } //_______________________________________________________________________ -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) +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) { // 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 auto dig = findDigit(key); if (dig) { lbl = dig->getLabel(); // getting the label from the already existing digit - dig->merge(tdc, tot); // merging to the existing digit + if (dig->merge(tdc, tot)) { // merging to the existing digit (if new came first upload also MC truth) + dig->setTgeant(geanttime); + dig->setT0true(t0); + } mDigitMerged++; } else { - mDigits.emplace(std::make_pair(key, Digit(channel, tdc, tot, bc, lbl, triggerorbit, triggerbunch))); + mDigits.emplace(std::make_pair(key, Digit(channel, tdc, tot, bc, lbl, triggerorbit, triggerbunch, geanttime, t0))); } return lbl; diff --git a/Detectors/TOF/reconstruction/src/Clusterer.cxx b/Detectors/TOF/reconstruction/src/Clusterer.cxx index 47dcbd805b162..0b393bfd45e78 100644 --- a/Detectors/TOF/reconstruction/src/Clusterer.cxx +++ b/Detectors/TOF/reconstruction/src/Clusterer.cxx @@ -173,6 +173,8 @@ void Clusterer::buildCluster(Cluster& c, MCLabelContainer const* digitMCTruth) } c.setMainContributingChannel(mContributingDigit[0]->getChannel()); + c.setTgeant(mContributingDigit[0]->getTgeant()); + c.setT0true(mContributingDigit[0]->getT0true()); c.setTime(mContributingDigit[0]->getCalibratedTime()); // time in ps (for now we assume it calibrated) c.setTimeRaw(mContributingDigit[0]->getTDC() * Geo::TDCBIN + mContributingDigit[0]->getBC() * o2::constants::lhc::LHCBunchSpacingNS * 1E3); // time in ps (for now we assume it calibrated) diff --git a/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h b/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h index 15a71b9e57c1f..5153f168f176f 100644 --- a/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h +++ b/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h @@ -135,11 +135,11 @@ class Digitizer : public WindowFiller CalibApi* mCalibApi = nullptr; //! calib api to handle the TOF calibration - void fillDigitsInStrip(std::vector* strips, o2::dataformats::MCTruthContainer* mcTruthContainer, int channel, int tdc, int tot, uint64_t nbc, UInt_t istrip, Int_t trackID, Int_t eventID, Int_t sourceID); + void fillDigitsInStrip(std::vector* strips, o2::dataformats::MCTruthContainer* 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); Int_t processHit(const HitType& hit, Double_t event_time); 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, - Int_t trackID); + Int_t trackID, float geanttime = 0, double t0 = 0.0); void checkIfReuseFutureDigits(); diff --git a/Detectors/TOF/simulation/src/Digitizer.cxx b/Detectors/TOF/simulation/src/Digitizer.cxx index 50ea2c194616c..ec899bd35fbff 100644 --- a/Detectors/TOF/simulation/src/Digitizer.cxx +++ b/Detectors/TOF/simulation/src/Digitizer.cxx @@ -170,7 +170,7 @@ Int_t Digitizer::processHit(const HitType& hit, Double_t event_time) Float_t charge = getCharge(hit.GetEnergyLoss()); // NOTE: FROM NOW ON THE TIME IS IN PS ... AND NOT IN NS - Double_t time = getShowerTimeSmeared((double(hit.GetTime()) + event_time) * 1E3, charge); + Double_t time = getShowerTimeSmeared((double(hit.GetTime()) + event_time) * 1E3 + 0.5 * Geo::TDCBIN, charge); Float_t xLocal = deltapos[0]; Float_t zLocal = deltapos[2]; @@ -192,7 +192,7 @@ Int_t Digitizer::processHit(const HitType& hit, Double_t event_time) ndigits++; mXLastShift[mNLastHit] = 0; mZLastShift[mNLastHit] = 0; - addDigit(channel, istrip, time, xLocal, zLocal, charge, 0, 0, detInd[3], trackID); + addDigit(channel, istrip, time, xLocal, zLocal, charge, 0, 0, detInd[3], trackID, hit.GetTime(), event_time * 1E3); } // check PAD 2 @@ -209,7 +209,7 @@ Int_t Digitizer::processHit(const HitType& hit, Double_t event_time) ndigits++; mXLastShift[mNLastHit] = 0; mZLastShift[mNLastHit] = iZshift; - addDigit(channel, istrip, time, xLocal, zLocal, charge, 0, iZshift, detInd[3], trackID); + addDigit(channel, istrip, time, xLocal, zLocal, charge, 0, iZshift, detInd[3], trackID, hit.GetTime(), event_time * 1E3); } // check PAD 3 @@ -223,7 +223,7 @@ Int_t Digitizer::processHit(const HitType& hit, Double_t event_time) ndigits++; mXLastShift[mNLastHit] = -1; mZLastShift[mNLastHit] = 0; - addDigit(channel, istrip, time, xLocal, zLocal, charge, -1, 0, detInd[3], trackID); + addDigit(channel, istrip, time, xLocal, zLocal, charge, -1, 0, detInd[3], trackID, hit.GetTime(), event_time * 1E3); } } @@ -238,7 +238,7 @@ Int_t Digitizer::processHit(const HitType& hit, Double_t event_time) ndigits++; mXLastShift[mNLastHit] = 1; mZLastShift[mNLastHit] = 0; - addDigit(channel, istrip, time, xLocal, zLocal, charge, 1, 0, detInd[3], trackID); + addDigit(channel, istrip, time, xLocal, zLocal, charge, 1, 0, detInd[3], trackID, hit.GetTime(), event_time * 1E3); } } @@ -257,7 +257,7 @@ Int_t Digitizer::processHit(const HitType& hit, Double_t event_time) ndigits++; mXLastShift[mNLastHit] = -1; mZLastShift[mNLastHit] = iZshift; - addDigit(channel, istrip, time, xLocal, zLocal, charge, -1, iZshift, detInd[3], trackID); + addDigit(channel, istrip, time, xLocal, zLocal, charge, -1, iZshift, detInd[3], trackID, hit.GetTime(), event_time * 1E3); } } @@ -276,7 +276,7 @@ Int_t Digitizer::processHit(const HitType& hit, Double_t event_time) ndigits++; mXLastShift[mNLastHit] = 1; mZLastShift[mNLastHit] = iZshift; - addDigit(channel, istrip, time, xLocal, zLocal, charge, 1, iZshift, detInd[3], trackID); + addDigit(channel, istrip, time, xLocal, zLocal, charge, 1, iZshift, detInd[3], trackID, hit.GetTime(), event_time * 1E3); } } return ndigits; @@ -284,7 +284,7 @@ Int_t Digitizer::processHit(const HitType& hit, Double_t event_time) //______________________________________________________________________ void Digitizer::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, Int_t trackID) + Int_t padZfired, Int_t trackID, float geanttime, double t0) { // TOF digit requires: channel, time and time-over-threshold @@ -297,10 +297,11 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x, charge *= getFractionOfCharge(x, z); // tot tuned to reproduce 0.8% of orphans tot(=0) - Float_t tot = gRandom->Gaus(12., 1.5); // time-over-threshold - if (tot < 8.4) { - tot = 0; + Float_t totf = gRandom->Gaus(12. * Geo::NTOTBIN_PER_NS, 1.5 * Geo::NTOTBIN_PER_NS); // time-over-threshold + if (totf < 172) { + totf = 0; } + int tot = int(totf); Float_t xborder = Geo::XPAD * 0.5 - std::abs(x); Float_t zborder = Geo::ZPAD * 0.5 - std::abs(z); @@ -309,7 +310,7 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x, Float_t timewalkX = x * mTimeWalkeSlope; Float_t timewalkZ = (z - (padZfired - 0.5) * Geo::ZPAD) * mTimeWalkeSlope; - if (border < 0) { // keep the effect onlu if hit out of pad + if (border < 0) { // keep the effect only if hit out of pad border *= -1; Float_t extraTimeSmear = border * mTimeSlope; time += gRandom->Gaus(mTimeDelay, extraTimeSmear); @@ -325,7 +326,7 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x, time += TMath::Sqrt(timewalkX * timewalkX + timewalkZ * timewalkZ) - mTimeDelayCorr - mTimeWalkeSlope * 2; // Decalibrate - float tsCorr = mCalibApi->getTimeDecalibration(channel, tot); + float tsCorr = mCalibApi->getTimeDecalibration(channel, tot * Geo::TOTBIN_NS); if (std::abs(tsCorr) > 200E3) { // accept correction up to 200 ns LOG(error) << "Wrong de-calibration correction for ch = " << channel << ", tot = " << tot << " (Skip it)"; return; @@ -344,8 +345,10 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x, int tdc = int((time - Geo::BC_TIME_INPS * nbc) * Geo::NTDCBIN_PER_PS); + static long firstlongbc = long(o2::raw::HBFUtils::Instance().orbitFirstSampled) * o2::constants::lhc::LHCMaxBunches; // add orbit and bc nbc += mEventTime.toLong(); + t0 += (mEventTime.toLong() - firstlongbc - Geo::LATENCYWINDOW_IN_BC) * Geo::BC_TIME_INPS; // printf("orbit = %d -- bc = %d -- nbc = (%d) %d\n",mEventTime.orbit,mEventTime.bc, mEventTime.toLong(),nbc); @@ -386,7 +389,7 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x, mFutureItrackID.push_back(trackID); // fill temporary digits array - insertDigitInFuture(channel, tdc, tot * Geo::NTOTBIN_PER_NS, nbc, lblCurrent); + insertDigitInFuture(channel, tdc, tot, nbc, lblCurrent); return; // don't fill if doesn't match any available readout window } else if (isIfOverlap == MAXWINDOWS) { // add in future digits but also in one of the current readout windows (beacuse of windows overlap) lblCurrent = mFutureIevent.size(); @@ -395,7 +398,7 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x, mFutureItrackID.push_back(trackID); // fill temporary digits array - insertDigitInFuture(channel, tdc, tot * Geo::NTOTBIN_PER_NS, nbc, lblCurrent); + insertDigitInFuture(channel, tdc, tot, nbc, lblCurrent); } if (isnext) { @@ -416,7 +419,7 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x, mcTruthContainer = mMCTruthContainerNext[isnext - 1]; } - fillDigitsInStrip(strips, mcTruthContainer, channel, tdc, tot, nbc, istrip, trackID, mEventID, mSrcID); + fillDigitsInStrip(strips, mcTruthContainer, channel, tdc, tot, nbc, istrip, trackID, mEventID, mSrcID, geanttime, t0); if (isIfOverlap > -1 && isIfOverlap < MAXWINDOWS) { // fill also a second readout window because of the overlap if (!isIfOverlap) { @@ -427,18 +430,18 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x, mcTruthContainer = mMCTruthContainerNext[isIfOverlap - 1]; } - fillDigitsInStrip(strips, mcTruthContainer, channel, tdc, tot, nbc, istrip, trackID, mEventID, mSrcID); + fillDigitsInStrip(strips, mcTruthContainer, channel, tdc, tot, nbc, istrip, trackID, mEventID, mSrcID, geanttime, t0); } } //______________________________________________________________________ -void Digitizer::fillDigitsInStrip(std::vector* strips, o2::dataformats::MCTruthContainer* mcTruthContainer, int channel, int tdc, int tot, uint64_t nbc, UInt_t istrip, Int_t trackID, Int_t eventID, Int_t sourceID) +void Digitizer::fillDigitsInStrip(std::vector* strips, o2::dataformats::MCTruthContainer* mcTruthContainer, int channel, int tdc, int tot, uint64_t nbc, UInt_t istrip, Int_t trackID, Int_t eventID, Int_t sourceID, float geanttime, double t0) { int lblCurrent; if (mcTruthContainer) { lblCurrent = mcTruthContainer->getIndexedSize(); // this is the size of mHeaderArray; } - Int_t lbl = (*strips)[istrip].addDigit(channel, tdc, tot * Geo::NTOTBIN_PER_NS, nbc, lblCurrent); + Int_t lbl = (*strips)[istrip].addDigit(channel, tdc, tot, nbc, lblCurrent, 0, 0, geanttime, t0); if (mcTruthContainer) { if (lbl == lblCurrent) { // it means that the digit was a new one --> we have to add the info in the MC container @@ -1099,7 +1102,7 @@ void Digitizer::checkIfReuseFutureDigits() int trackID = mFutureItrackID[digit->getLabel()]; int sourceID = mFutureIsource[digit->getLabel()]; int eventID = mFutureIevent[digit->getLabel()]; - fillDigitsInStrip(strips, mcTruthContainer, digit->getChannel(), digit->getTDC(), digit->getTOT(), digit->getBC(), digit->getChannel() / Geo::NPADS, trackID, eventID, sourceID); + fillDigitsInStrip(strips, mcTruthContainer, digit->getChannel(), digit->getTDC(), digit->getTOT(), digit->getBC(), digit->getChannel() / Geo::NPADS, trackID, eventID, sourceID, digit->getTgeant()); if (isIfOverlap < 0) { // if there is no overlap candidate // remove digit from array in the future