Skip to content

Commit 451f837

Browse files
authored
TRD: improve anchoring using CCDB objects (#15890)
1 parent 05b8a9f commit 451f837

6 files changed

Lines changed: 100 additions & 33 deletions

File tree

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

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
1414

1515
#include "TRDSimulation/Detector.h"
1616

17-
#include "TRDBase/Calibrations.h"
17+
#include "TRDBase/Geometry.h"
1818
#include "TRDBase/PadResponse.h"
1919
#include "TRDSimulation/DiffAndTimeStructEstimator.h"
2020
#include "TRDSimulation/PileupTool.h"
2121

2222
#include "DataFormatsTRD/Digit.h"
2323
#include "DataFormatsTRD/SignalArray.h"
2424
#include "DataFormatsTRD/Constants.h"
25+
#include "DataFormatsTRD/CalVdriftExB.h"
26+
#include "DataFormatsTRD/CalGain.h"
27+
#include "TRDBase/PadCalibrationsAliases.h"
2528

2629
#include "MathUtils/RandomRing.h"
2730
#include "SimulationDataFormat/MCTruthContainer.h"
@@ -61,19 +64,40 @@ class Digitizer
6164
void setTriggerTime(double t) { mCurrentTriggerTime = t; }
6265
void setEventID(int entryID) { mEventID = entryID; }
6366
void setSrcID(int sourceID) { mSrcID = sourceID; }
64-
void setCalibrations(Calibrations* calibrations) { mCalib = calibrations; }
67+
void setCalVdriftExB(const CalVdriftExB* calVdriftExB) { mCalVdriftExB = calVdriftExB; }
68+
void setFedChamberStatus(int det, int value)
69+
{
70+
if (det >= constants::MAXCHAMBER) {
71+
return;
72+
}
73+
mFedChamberStatus[det] = value;
74+
}
75+
void setCalGain(const CalGain* calGain) { mCalGain = calGain; }
76+
void setLocalGainFactor(const LocalGainFactor* localGain) { mLocalGainFactor = localGain; }
77+
void setPadStatus(const PadStatus* padStatus) { mPadStatus = padStatus; }
6578
void setCreateSharedDigits(bool flag) { mCreateSharedDigits = flag; }
6679
int getEventTime() const { return mTime; }
6780
int getEventID() const { return mEventID; }
6881
int getSrcID() const { return mSrcID; }
6982
bool getCreateSharedDigits() const { return mCreateSharedDigits; }
83+
int getFedChamberStatus(int det)
84+
{
85+
if (det >= constants::MAXCHAMBER) {
86+
return -1.;
87+
}
88+
return mFedChamberStatus[det];
89+
}
7090
std::string dumpFlaggedChambers() const;
7191

7292
private:
73-
Geometry* mGeo = nullptr; // access to Geometry
74-
PadResponse mPRF{}; // access to PadResponse
75-
SimParam mSimParam{}; // simulation parameters
76-
Calibrations* mCalib = nullptr; // access to Calibrations in CCDB
93+
Geometry* mGeo = nullptr; // access to Geometry
94+
PadResponse mPRF{}; // access to PadResponse
95+
SimParam mSimParam{}; // simulation parameters
96+
const CalVdriftExB* mCalVdriftExB = nullptr; // access to time-dependent calibrations CalVdriftExB in CCDB
97+
const CalGain* mCalGain = nullptr; // access to time-dependent calibrations CalGain in CCDB
98+
const PadStatus* mPadStatus = nullptr; // access to time-dependent calibrations PadStatus in CCDB
99+
const LocalGainFactor* mLocalGainFactor = nullptr; // access to time-dependent calibrations LocalGainFactor in CCDB
100+
std::array<int, constants::MAXCHAMBER> mFedChamberStatus{}; // access to time-dependent FED chamber status in CCDB
77101
PileupTool pileupTool;
78102

79103
// number of digitizer threads

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class SimParam
6666
}
6767

6868
// Getters
69+
float getT0() const { return mT0; }
70+
float getEffVdriftDefault() const { return mEffVdriftDefault; }
6971
float getGasGain() const { return mGasGain; }
7072
float getNoise() const { return mNoise; }
7173
float getChipGain() const { return mChipGain; }
@@ -135,6 +137,9 @@ class SimParam
135137
float mTRFhi{3.58f}; ///< Higher boundary of the TRF and x-talk
136138
float mInvTRFwid{static_cast<float>(mTRFbin) / (mTRFhi - mTRFlo)}; ///< Inverse of the bin width of the integrated TRF and x-talk
137139
float mGasGain{4000.f}; ///< Gas gain
140+
float mT0{-0.130f}; ///< time delay before amplification peak
141+
142+
float mEffVdriftDefault{1.22f}; ///< The CCDB contains an effective drift velocity, and not the true drift velocity, so we anchor only the variations. This default parameter is the one reproducing data the best for run 568191.
138143

139144
ClassDefNV(SimParam, 2); // The TRD simulation parameters
140145
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct TRDSimParams : public o2::conf::ConfigurableParamHelper<TRDSimParams> {
4141
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)
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
44+
float t0 = -0.130; // Time delay before start of amplification peak, in us
4445
O2ParamDef(TRDSimParams, "TRDSimParams");
4546
};
4647

‎Detectors/TRD/simulation/src/Digitizer.cxx‎

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ void Digitizer::clearContainers()
139139

140140
void Digitizer::process(std::vector<Hit> const& hits)
141141
{
142-
if (!mCalib) {
143-
LOG(fatal) << "TRD Calibration database not available";
144-
}
145142

146143
// Get the a hit container for all the hits in a given detector then call convertHits for a given detector (0 - 539)
147144
std::array<std::vector<Hit>, MAXCHAMBER> hitsPerDetector;
@@ -160,7 +157,8 @@ void Digitizer::process(std::vector<Hit> const& hits)
160157
auto& signalsMap = mSignalsMapCollection[det];
161158
// Jump to the next detector if the detector is
162159
// switched off, not installed, etc
163-
if (mCalib->getChamberStatus()->isNoData(det)) {
160+
// In the chamber Fed status, 3 corresponds to good chamber
161+
if (getFedChamberStatus(det) != 3) {
164162
continue;
165163
}
166164
if (!mGeo->chamberInGeometry(det)) {
@@ -199,7 +197,7 @@ bool Digitizer::convertHits(const int det, const std::vector<Hit>& hits, SignalC
199197

200198
double padSignal[mNpad];
201199

202-
const double calExBDetValue = mCalib->getExB(det); // T * V/cm (check units)
200+
const double calExBDetValue = mCalVdriftExB->getExB(det, true); // T * V/cm (check units)
203201
const PadPlane* padPlane = mGeo->getPadPlane(det);
204202
const int layer = mGeo->getLayer(det);
205203
const float rowEndROC = padPlane->getRowEndROC();
@@ -253,8 +251,11 @@ bool Digitizer::convertHits(const int det, const std::vector<Hit>& hits, SignalC
253251
absDriftLength /= std::sqrt(1 / (1 + calExBDetValue * calExBDetValue));
254252
}
255253

256-
float driftVelocity = mCalib->getVDrift(det, colE, rowE); // The drift velocity
257-
float t0 = mCalib->getT0(det, colE, rowE); // The T0 velocity
254+
float driftVelocity = constants::VDRIFTDEFAULT; // The default drift velocity
255+
if (TMath::Abs(mCalVdriftExB->getVdrift(det, true) - constants::VDRIFTDEFAULT) > 1e-6) {
256+
driftVelocity = mCalVdriftExB->getVdrift(det, true) * constants::VDRIFTDEFAULT / mSimParam.getEffVdriftDefault(); // If they are available in the CCDB, we anchor the vdrift variations
257+
}
258+
float t0 = mSimParam.getT0(); // The T0 velocity
258259

259260
// Loop over all created electrons
260261
const int nElectrons = std::fabs(qTotal);
@@ -277,7 +278,8 @@ bool Digitizer::convertHits(const int det, const std::vector<Hit>& hits, SignalC
277278

278279
// Apply E x B effects
279280
if (mSimParam.isExBOn()) {
280-
locCd = locCd + calExBDetValue * driftLength;
281+
// minus sign is necessary to be compatible with how Vdrift and ExB are calibrated
282+
locCd = locCd - TMath::Tan(calExBDetValue) * driftLength;
281283
}
282284
// The electron position after diffusion and ExB in pad coordinates.
283285
rowE = padPlane->getPadRowNumberROC(locRd);
@@ -292,8 +294,6 @@ bool Digitizer::convertHits(const int det, const std::vector<Hit>& hits, SignalC
292294
continue;
293295
}
294296
const double colOffset = padPlane->getPadColOffset(colE, locCd + offsetTilt);
295-
driftVelocity = mCalib->getVDrift(det, colE, rowE); // The drift velocity for the updated col and row
296-
t0 = mCalib->getT0(det, colE, rowE); // The T0 velocity for the updated col and row
297297
// Convert the position to drift time [mus], using either constant drift velocity or
298298
// time structure of drift cells (non-isochronity, GARFIELD calculation).
299299
// Also add absolute time of hits to take pile-up events into account properly
@@ -313,7 +313,8 @@ bool Digitizer::convertHits(const int det, const std::vector<Hit>& hits, SignalC
313313
}
314314

315315
// Apply the gas gain including fluctuations
316-
const double signal = -(mSimParam.getGasGain()) * mLogRandomRings[thread].getNextValue();
316+
double timeDepGainFactor = mCalGain->getMPVdEdx(det, true) / constants::MPVDEDXDEFAULT;
317+
const double signal = -(mSimParam.getGasGain()) * timeDepGainFactor * mLogRandomRings[thread].getNextValue();
317318

318319
// Apply the pad response
319320
if (mSimParam.prfOn()) {
@@ -332,7 +333,7 @@ bool Digitizer::convertHits(const int det, const std::vector<Hit>& hits, SignalC
332333
}
333334

334335
// The time bin (always positive), with t0 distortion
335-
double timeBinIdeal = driftTime * mSamplingRate + t0;
336+
double timeBinIdeal = (driftTime + t0) * mSamplingRate;
336337
// Protection
337338
if (std::fabs(timeBinIdeal) > (2 * mMaxTimeBins)) { // OS: why 2*mMaxTimeBins?
338339
timeBinIdeal = 2 * mMaxTimeBins;
@@ -423,19 +424,13 @@ bool Digitizer::convertSignalsToADC(SignalContainer& signalMapCont, DigitContain
423424
int mcm = (int)(col / 18); // current group of 18 col pads
424425
int halfchamberside = (mcm > 3) ? 1 : 0; // 0=Aside, 1=Bside
425426

426-
// Halfchambers that are switched off, masked by mCalib
427-
if ((halfchamberside == 0 && mCalib->getChamberStatus()->isNoDataSideA(det)) ||
428-
(halfchamberside == 1 && mCalib->getChamberStatus()->isNoDataSideB(det))) {
429-
continue;
430-
}
431-
432427
// Check whether pad is masked
433428
// Bridged pads are not considered yet!!!
434-
if (mCalib->getPadStatus()->isMasked(det, col, row) || mCalib->getPadStatus()->isNotConnected(det, col, row)) {
429+
if (mPadStatus->isMasked(det, col, row) || mPadStatus->isNotConnected(det, col, row)) {
435430
continue;
436431
}
437432

438-
float padgain = mCalib->getPadGainFactor(det, row, col); // The gain factor
433+
float padgain = std::fabs(mLocalGainFactor->getValue(det, col, row)); // The gain factor
439434
if (padgain <= 0) {
440435
LOG(fatal) << "Not a valid gain " << padgain << ", " << det << ", " << col << ", " << row;
441436
}

‎Detectors/TRD/simulation/src/SimParam.cxx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ SimParam::SimParam()
2929
mTRF = TRDSimParams::Instance().trf;
3030
mMu = TRDSimParams::Instance().trf_landau_mu;
3131
mSigma = TRDSimParams::Instance().trf_landau_sigma;
32+
mT0 = TRDSimParams::Instance().t0;
3233
init();
3334
}
3435

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

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Framework/DataProcessorSpec.h"
1616
#include "Framework/DataRefUtils.h"
1717
#include "Framework/Lifetime.h"
18+
#include "Framework/CCDBParamSpec.h"
1819
#include "Headers/DataHeader.h"
1920
#include "TStopwatch.h"
2021
#include "TChain.h"
@@ -64,11 +65,11 @@ class TRDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
6465

6566
bool mctruth = pc.outputs().isAllowed({"TRD", "LABELS", 0});
6667

67-
Calibrations simcal;
68-
// the timestamp can be extracted from the DPL header (it is set in SimReader)
69-
auto creationTime = pc.services().get<o2::framework::TimingInfo>().creation;
70-
simcal.getCCDBObjects(creationTime);
71-
mDigitizer.setCalibrations(&simcal);
68+
pc.inputs().get<o2::trd::CalVdriftExB*>("calvdexb");
69+
pc.inputs().get<o2::trd::CalGain*>("calgain");
70+
pc.inputs().get<std::array<int, constants::MAXCHAMBER>*>("fedchamberstatus");
71+
pc.inputs().get<o2::trd::PadStatus*>("padstatus");
72+
pc.inputs().get<o2::trd::LocalGainFactor*>("localgainfactor");
7273

7374
// read collision context from input
7475
auto context = pc.inputs().get<o2::steer::DigitizationContext*>("collisioncontext");
@@ -207,6 +208,38 @@ class TRDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
207208
finished = true;
208209
}
209210

211+
void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
212+
{
213+
if (matcher == ConcreteDataMatcher("TRD", "CALVDRIFTEXB", 0)) {
214+
LOG(info) << "CalVdriftExB object has been updated";
215+
mDigitizer.setCalVdriftExB((const o2::trd::CalVdriftExB*)obj);
216+
return;
217+
}
218+
if (matcher == ConcreteDataMatcher("TRD", "CALGAIN", 0)) {
219+
LOG(info) << "CalGain object has been updated";
220+
mDigitizer.setCalGain((const o2::trd::CalGain*)obj);
221+
return;
222+
}
223+
if (matcher == ConcreteDataMatcher("TRD", "FEDCHAMBERSTATUS", 0)) {
224+
LOG(info) << "Fed chamber status has been updated";
225+
std::array<int, constants::MAXCHAMBER>* fedStatus = (std::array<int, constants::MAXCHAMBER>*)obj;
226+
for (int det = 0; det < constants::MAXCHAMBER; det++) {
227+
mDigitizer.setFedChamberStatus(det, (*fedStatus)[det]);
228+
}
229+
return;
230+
}
231+
if (matcher == ConcreteDataMatcher("TRD", "PADSTATUS", 0)) {
232+
LOG(info) << "PadStatus object has been updated";
233+
mDigitizer.setPadStatus((const o2::trd::PadStatus*)obj);
234+
return;
235+
}
236+
if (matcher == ConcreteDataMatcher("TRD", "LOCALGAINFACTOR", 0)) {
237+
LOG(info) << "LocalGainFactor object has been updated";
238+
mDigitizer.setLocalGainFactor((const o2::trd::LocalGainFactor*)obj);
239+
return;
240+
}
241+
}
242+
210243
private:
211244
Digitizer mDigitizer;
212245
std::vector<TChain*> mSimChains;
@@ -230,10 +263,18 @@ o2::framework::DataProcessorSpec getTRDDigitizerSpec(int channel, bool mctruth)
230263
}
231264
outputs.emplace_back("TRD", "ROMode", 0, Lifetime::Timeframe);
232265

266+
std::vector<InputSpec> inputs;
267+
inputs.emplace_back("collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
268+
inputs.emplace_back("calvdexb", "TRD", "CALVDRIFTEXB", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/CalVdriftExB"));
269+
inputs.emplace_back("calgain", "TRD", "CALGAIN", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/CalGain"));
270+
inputs.emplace_back("fedchamberstatus", "TRD", "FEDCHAMBERSTATUS", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/DCSDPsFedChamberStatus"));
271+
inputs.emplace_back("padstatus", "TRD", "PADSTATUS", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/PadStatus"));
272+
inputs.emplace_back("localgainfactor", "TRD", "LOCALGAINFACTOR", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/LocalGainFactor"));
273+
233274
return DataProcessorSpec{
234275
"TRDDigitizer",
235-
Inputs{InputSpec{"collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast<SubSpecificationType>(channel), Lifetime::Timeframe}},
236-
276+
// Inputs{InputSpec{"collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast<SubSpecificationType>(channel), Lifetime::Timeframe}},
277+
inputs,
237278
outputs,
238279

239280
AlgorithmSpec{adaptFromTask<TRDDPLDigitizerTask>()},

0 commit comments

Comments
 (0)