Skip to content

Commit 9796e4a

Browse files
committed
possibility to apply shift and small improvement to pile-up correction
1 parent a79506a commit 9796e4a

11 files changed

Lines changed: 37 additions & 23 deletions

File tree

‎Detectors/TRD/base/src/TrackletTransformer.cxx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ float TrackletTransformer::calculateDy(int detector, int slope, const PadPlane*
6161

6262
float TrackletTransformer::calibrateX(double x) const
6363
{
64-
// Hard-coded value will be replaced once t0 calibration is available from CCDB
64+
// Hard-coded value since t0 is rather stable as a function of time
6565
float t0Correction = -0.230;
6666
return x += t0Correction;
6767
}
@@ -105,8 +105,6 @@ CalibratedTracklet TrackletTransformer::transformTracklet(Tracklet64 tracklet, b
105105
float x = mGeo->cdrHght() - 0.5;
106106
float y = tracklet.getUncalibratedY(mApplyShift);
107107
float z = calculateZ(padrow, padPlane);
108-
109-
//LOGF(info, "apply shift: %d", mApplyShift);
110108

111109
float dy = calculateDy(detector, slope, padPlane);
112110

‎Detectors/TRD/calibration/src/TrackBasedCalib.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ int TrackBasedCalib::filldEdx(gsl::span<const TrackTRD>& tracks, bool isTPCTRD)
165165

166166
float localGainCorr = 1.;
167167
if (mLocalGain) {
168-
localGainCorr = mLocalGain->getValue(trkltDet, tracklet.getPadCol(mApplyShift), tracklet.getPadRow());
168+
localGainCorr = mLocalGain->getValue(trkltDet, tracklet.getPadCol(false), tracklet.getPadRow());
169169
}
170170
if (TMath::Abs(localGainCorr) < 0.0001f) {
171-
LOGP(warn, "Invalid localGainCorr {} for det {}, pad col {}, pad row {}", localGainCorr, trkltDet, tracklet.getPadCol(mApplyShift), tracklet.getPadRow());
171+
LOGP(warn, "Invalid localGainCorr {} for det {}, pad col {}, pad row {}", localGainCorr, trkltDet, tracklet.getPadCol(false), tracklet.getPadRow());
172172
continue;
173173
}
174174

‎Detectors/TRD/qc/src/Tracking.cxx‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ void Tracking::checkTrack(const TrackTRD& trkTrd, bool isTPCTRD)
8585

8686
// Find most probable BCs and RMS for pile-up correction and error. Same BC is assumed for all tracklets
8787
float tCorrPileUp = 0.;
88+
float tCorrPileUp_weightedMean = 0.;
8889
float tErrPileUp2 = 0;
8990
float maxProb = 0.f;
9091
// The uncertainty is the RMS wrt the default correction of all possible corrections weighted by their probability
@@ -117,13 +118,15 @@ void Tracking::checkTrack(const TrackTRD& trkTrd, bool isTPCTRD)
117118
sumCorr += probBC * deltaBC;
118119
sumCorr2 += probBC * deltaBC * deltaBC;
119120
sumProb += probBC;
121+
tCorrPileUp_weightedMean -= probBC*deltaBC;
120122
if (probBC > maxProb) {
121123
maxProb = probBC;
122124
tCorrPileUp = -deltaBC;
123125
}
124126
}
125127
if (sumProb > 1e-6) {
126128
tErrPileUp2 = sumCorr2 / sumProb - 2 * tCorrPileUp * sumCorr / sumProb + tCorrPileUp * tCorrPileUp;
129+
tCorrPileUp_weightedMean /= sumProb;
127130
}
128131

129132
for (int iLayer = 0; iLayer < NLAYER; ++iLayer) {
@@ -158,7 +161,8 @@ void Tracking::checkTrack(const TrackTRD& trkTrd, bool isTPCTRD)
158161

159162
// conversion from slope in pad per time bin to slope in cm per BC = tracklets[trkltIdx].getSlopeFloat() * padWidth / BCperTimeBin
160163
float slopeFactor = mTrackletsRaw[trkltId].getSlopeFloat() * pad->getWidthIPad() / 4.f;
161-
float yCorrPileUp = tCorrPileUp * slopeFactor;
164+
//float yCorrPileUp = tCorrPileUp * slopeFactor;
165+
float yCorrPileUp = tCorrPileUp_weightedMean * slopeFactor;
162166
float yAddErrPileUp2 = tErrPileUp2 * slopeFactor * slopeFactor;
163167
float yPosCorrUp = mTrackletsCalib[trkltId].getY() - tiltCorrUp + yCorrPileUp;
164168

@@ -184,7 +188,7 @@ void Tracking::checkTrack(const TrackTRD& trkTrd, bool isTPCTRD)
184188
// \sqrt{ (dx/dx)^2 + (dy/dx)^2 + (dz/dx)^2}
185189
auto tphi = trk.getSnp() / std::sqrt((1.f - trk.getSnp()) * (1.f + trk.getSnp()));
186190
auto trackletLength = std::sqrt(1.f + tphi * tphi + trk.getTgl() * trk.getTgl());
187-
auto cor = mLocalGain.getValue(tracklet.getHCID() / 2, tracklet.getPadCol(mApplyShift), tracklet.getPadRow()) * trackletLength;
191+
auto cor = mLocalGain.getValue(tracklet.getHCID() / 2, tracklet.getPadCol(false), tracklet.getPadRow()) * trackletLength;
188192
float q0{tracklet.getQ0() / cor}, q1{tracklet.getQ1() / cor}, q2{tracklet.getQ2() / cor};
189193

190194
// z-row merging
@@ -193,9 +197,9 @@ void Tracking::checkTrack(const TrackTRD& trkTrd, bool isTPCTRD)
193197
if (tracklet.getTrackletWord() == trklt.getTrackletWord()) { // skip original tracklet
194198
continue;
195199
}
196-
if (std::abs(tracklet.getPadCol(mApplyShift) - trklt.getPadCol(mApplyShift)) <= 1 && std::abs(tracklet.getPadRow() - trklt.getPadRow()) == 1) {
200+
if (std::abs(tracklet.getPadCol(false) - trklt.getPadCol(false)) <= 1 && std::abs(tracklet.getPadRow() - trklt.getPadRow()) == 1) {
197201
// Add charge information
198-
auto cor = mLocalGain.getValue(trklt.getHCID() / 2, trklt.getPadCol(mApplyShift), trklt.getPadRow()) * trackletLength;
202+
auto cor = mLocalGain.getValue(trklt.getHCID() / 2, trklt.getPadCol(false), trklt.getPadRow()) * trackletLength;
199203
q0 += trklt.getQ0() / cor;
200204
q1 += trklt.getQ1() / cor;
201205
q2 += trklt.getQ2() / cor;

‎Detectors/TRD/simulation/include/TRDSimulation/TRDSimParams.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct TRDSimParams : public o2::conf::ConfigurableParamHelper<TRDSimParams> {
3838
bool doTR = true; ///< switch for transition radiation
3939
SimParam::GasMixture gas = SimParam::GasMixture::Xenon; ///< the gas mixture in the TRD
4040
// TRF parameters
41-
int trf = 0; // Sampled TRF function. 0: default TRF, 1: TRF described in TRF TDR, 2: No TRF, 3: Landau dist as TRF (parameters specified below)
41+
int trf = 1; // Sampled TRF function. 0: default TRF, 1: TRF described in TRF TDR, 2: No TRF, 3: Landau dist as TRF (parameters specified below)
4242
float trf_landau_mu = 0.; // Mu of the Landau distribution used to describe TRF
4343
float trf_landau_sigma = .03; // Sigma of the Landau distribution used to describe TRF
4444
float t0 = -0.170; // Time delay before start of amplification peak, in us

‎Detectors/TRD/workflow/include/TRDWorkflow/TRDGlobalTrackingQCSpec.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class TRDGlobalTrackingQC : public Task
5757
if (!mTPCavailable) {
5858
mQC.disablePID();
5959
}
60-
if ((getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) || !ic.options().get<bool>("apply-shift")) {
60+
if (getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) {
6161
// apply artificial pad shift in case non-ideal alignment is used to compensate for shift in current alignment from real data
6262
mQC.setApplyShift(false);
6363
}
@@ -152,8 +152,7 @@ DataProcessorSpec getTRDGlobalTrackingQCSpec(o2::dataformats::GlobalTrackID::mas
152152
"trd-tracking-qc",
153153
dataRequest->inputs,
154154
outputs,
155-
AlgorithmSpec{adaptFromTask<TRDGlobalTrackingQC>(dataRequest, ggRequest, isTPCavailable, src)},
156-
Options{{"apply-shift", o2::framework::VariantType::Bool, true, {"whether we apply the one pad shift in data (never applied in MC)"}}}};
155+
AlgorithmSpec{adaptFromTask<TRDGlobalTrackingQC>(dataRequest, ggRequest, isTPCavailable, src)}};
157156
}
158157

159158
template <typename T>

‎Detectors/TRD/workflow/include/TRDWorkflow/TRDGlobalTrackingSpec.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class TRDGlobalTracking : public o2::framework::Task
8282
float mTPCVdrift{2.58f}; ///< TPC drift velocity (for shifting TPC tracks along Z)
8383
float mTPCTDriftOffset{0.f}; ///< TPC drift time additive offset
8484
int32_t mTCorrPileUp{0}; ///< most probable correction in number of BCs due to pile-up in TRD
85+
int32_t mTCorrPileUp_weightedMean{0}; ///< average correction in number of BCs due to pile-up in TRD
8586
float mTErrPileUp2{0.f}; ///< error on correction in number of BCs due to pile-up in TRD
8687
std::shared_ptr<o2::globaltracking::DataRequest> mDataRequest; ///< seeding input (TPC-only, ITS-TPC or both)
8788
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;

‎Detectors/TRD/workflow/include/TRDWorkflow/TRDPulseHeightSpec.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PuseHeightDevice : public o2::framework::Task
4343
if (ic.options().get<bool>("enable-root-output")) {
4444
mPulseHeight->createOutputFile();
4545
}
46-
if ((getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) || !ic.options().get<bool>("apply-shift")) {
46+
if (getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) {
4747
// apply artificial pad shift in case non-ideal alignment is used to compensate for shift in current alignment from real data
4848
mPulseHeight->setApplyShift(false);
4949
}
@@ -129,8 +129,7 @@ DataProcessorSpec getTRDPulseHeightSpec(GID::mask_t src, bool digitsFromReader)
129129
outputs,
130130
AlgorithmSpec{adaptFromTask<o2::trd::PuseHeightDevice>(dataRequest)},
131131
Options{
132-
{"enable-root-output", VariantType::Bool, false, {"output PH and debug data to root file"}},
133-
{"apply-shift", o2::framework::VariantType::Bool, true, {"whether we apply the one pad shift in data (never applied in MC)"}}}};
132+
{"enable-root-output", VariantType::Bool, false, {"output PH and debug data to root file"}}}};
134133
}
135134
} // namespace framework
136135
} // namespace o2

‎Detectors/TRD/workflow/src/TRDGlobalTrackingSpec.cxx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ void TRDGlobalTracking::run(ProcessingContext& pc)
542542
float sumCorr = 0.f;
543543
float sumCorr2 = 0.f;
544544
float sumProb = 0.f;
545+
mTCorrPileUp_weightedMean = 0.f;
545546
for (int iBC = 0; iBC < mTriggeredBCFT0.size(); iBC++) {
546547
int deltaBC = roundf(mTriggeredBCFT0[iBC] - mChainTracking->mIOPtrs.trdTriggerTimes[trdTrack.getCollisionId()] / o2::constants::lhc::LHCBunchSpacingMUS);
547548
if (deltaBC <= mRecoParam.getPileUpRangeBefore() || deltaBC >= mRecoParam.getPileUpRangeAfter()) {
@@ -565,13 +566,15 @@ void TRDGlobalTracking::run(ProcessingContext& pc)
565566
sumCorr += probBC * deltaBC;
566567
sumCorr2 += probBC * deltaBC * deltaBC;
567568
sumProb += probBC;
569+
mTCorrPileUp_weightedMean -= deltaBC * probBC;
568570
if (probBC > maxProb) {
569571
maxProb = probBC;
570572
mTCorrPileUp = -deltaBC;
571573
}
572574
}
573575
if (sumProb > 1e-6) {
574576
mTErrPileUp2 = sumCorr2 / sumProb - 2 * mTCorrPileUp * sumCorr / sumProb + mTCorrPileUp * mTCorrPileUp;
577+
mTCorrPileUp_weightedMean /= sumProb;
575578
}
576579

577580
nTrackletsAttached += trdTrack.getNtracklets();
@@ -926,7 +929,8 @@ bool TRDGlobalTracking::refitTRDTrack(TrackTRD& trk, float& chi2, bool inwards,
926929

927930
// conversion from slope in pad per time bin to slope in cm per BC = tracklets[trkltIdx].getSlopeFloat() * padWidth / BCperTimeBin
928931
float slopeFactor = mTrackletsRaw[trkltId].getSlopeFloat() * pad->getWidthIPad() / 4.f;
929-
float yCorrPileUp = mTCorrPileUp * slopeFactor;
932+
//float yCorrPileUp = mTCorrPileUp * slopeFactor;
933+
float yCorrPileUp = mTCorrPileUp_weightedMean * slopeFactor;
930934
float yAddErrPileUp2 = mTErrPileUp2 * slopeFactor * slopeFactor;
931935
float yPosCorrUp = mTrackletsCalib[trkltId].getY() - tiltCorrUp + yCorrPileUp;
932936

‎Detectors/TRD/workflow/src/TRDTrackletTransformerSpec.cxx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ void TRDTrackletTransformerSpec::init(o2::framework::InitContext& ic)
3535
if (ic.options().get<bool>("apply-xor")) {
3636
mTransformer.setApplyXOR();
3737
}
38-
if ((getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) || !ic.options().get<bool>("apply-shift")) {
38+
if ((getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) || ic.options().get<bool>("disable-shift")) {
39+
LOGF(info, "TRD pad shift is not applied");
3940
// apply artificial pad shift in case non-ideal alignment is used to compensate for shift in current alignment from real data
4041
mTransformer.setApplyShift(false);
4142
}
@@ -175,7 +176,7 @@ o2::framework::DataProcessorSpec getTRDTrackletTransformerSpec(bool trigRecFilte
175176
AlgorithmSpec{adaptFromTask<TRDTrackletTransformerSpec>(dataRequest, ggRequest, trigRecFilterActive)},
176177
Options{
177178
{"apply-xor", o2::framework::VariantType::Bool, false, {"flip the 8-th bit of slope and position (for processing CTFs from 2021 pilot beam)"}},
178-
{"apply-shift", o2::framework::VariantType::Bool, true, {"whether we apply the one pad shift in data (never applied in MC)"}}}};
179+
{"disable-shift", o2::framework::VariantType::Bool, false, {"whether we apply the one pad shift in data (always disabled in MC)"}}}};
179180
}
180181

181182
} //end namespace trd

‎Detectors/TRD/workflow/src/TrackBasedCalibSpec.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class TRDTrackBasedCalibDevice : public Task
6262
void TRDTrackBasedCalibDevice::init(InitContext& ic)
6363
{
6464
o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
65-
if ((getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) || !ic.options().get<bool>("apply-shift")) {
65+
if (getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) {
6666
// apply artificial pad shift in case non-ideal alignment is used to compensate for shift in current alignment from real data
6767
mCalibrator.setApplyShift(false);
6868
}
@@ -182,7 +182,7 @@ DataProcessorSpec getTRDTrackBasedCalibSpec(o2::dataformats::GlobalTrackID::mask
182182
inputs,
183183
outputs,
184184
AlgorithmSpec{adaptFromTask<TRDTrackBasedCalibDevice>(dataRequest, ggRequest, vdexb, gain)},
185-
Options{{"apply-shift", o2::framework::VariantType::Bool, true, {"whether we apply the one pad shift in data (never applied in MC)"}}}};
185+
Options{}};
186186
}
187187

188188
} // namespace trd

0 commit comments

Comments
 (0)