Skip to content

Commit d6ecf22

Browse files
committed
improve anchoring
1 parent cefb1d6 commit d6ecf22

File tree

4 files changed

+67
-16
lines changed

4 files changed

+67
-16
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
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"
2527

2628
#include "MathUtils/RandomRing.h"
2729
#include "SimulationDataFormat/MCTruthContainer.h"
@@ -62,18 +64,25 @@ class Digitizer
6264
void setEventID(int entryID) { mEventID = entryID; }
6365
void setSrcID(int sourceID) { mSrcID = sourceID; }
6466
void setCalibrations(Calibrations* calibrations) { mCalib = calibrations; }
67+
void setCalVdriftExB(const CalVdriftExB* calVdriftExB) { mCalVdriftExB = calVdriftExB; }
68+
void setFedChamberStatus(int det, int value) { if (det >= constants::MAXCHAMBER) return; mFedChamberStatus[det] = value; }
69+
void setCalGain(const CalGain* calGain) { mCalGain = calGain; }
6570
void setCreateSharedDigits(bool flag) { mCreateSharedDigits = flag; }
6671
int getEventTime() const { return mTime; }
6772
int getEventID() const { return mEventID; }
6873
int getSrcID() const { return mSrcID; }
6974
bool getCreateSharedDigits() const { return mCreateSharedDigits; }
75+
int getFedChamberStatus(int det) { if (det >= constants::MAXCHAMBER) return -1.; return mFedChamberStatus[det]; }
7076
std::string dumpFlaggedChambers() const;
7177

7278
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
79+
Geometry* mGeo = nullptr; // access to Geometry
80+
PadResponse mPRF{}; // access to PadResponse
81+
SimParam mSimParam{}; // simulation parameters
82+
Calibrations* mCalib = nullptr; // access to Calibrations in CCDB
83+
const CalVdriftExB* mCalVdriftExB = nullptr; // access to time-dependent calibrations CalVdriftExB in CCDB
84+
const CalGain* mCalGain = nullptr; // access to time-dependent calibrations CalGain in CCDB
85+
std::array<int, constants::MAXCHAMBER> mFedChamberStatus{}; // access to time-dependent FED chamber status in CCDB
7786
PileupTool pileupTool;
7887

7988
// number of digitizer threads

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class SimParam
6666
}
6767

6868
// Getters
69+
float getEffVdriftDefault() const { return mEffVdriftDefault; }
6970
float getGasGain() const { return mGasGain; }
7071
float getNoise() const { return mNoise; }
7172
float getChipGain() const { return mChipGain; }
@@ -135,7 +136,9 @@ class SimParam
135136
float mTRFhi{3.58f}; ///< Higher boundary of the TRF and x-talk
136137
float mInvTRFwid{static_cast<float>(mTRFbin) / (mTRFhi - mTRFlo)}; ///< Inverse of the bin width of the integrated TRF and x-talk
137138
float mGasGain{4000.f}; ///< Gas gain
138-
139+
140+
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.
141+
139142
ClassDefNV(SimParam, 2); // The TRD simulation parameters
140143
};
141144

Detectors/TRD/simulation/src/Digitizer.cxx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ void Digitizer::process(std::vector<Hit> const& hits)
160160
auto& signalsMap = mSignalsMapCollection[det];
161161
// Jump to the next detector if the detector is
162162
// switched off, not installed, etc
163-
if (mCalib->getChamberStatus()->isNoData(det)) {
163+
// In the chamber Fed status, 3 corresponds to good chamber
164+
//if (mCalib->getChamberStatus()->isNoData(det)) {
165+
if (getFedChamberStatus(det) != 3) {
164166
continue;
165167
}
166168
if (!mGeo->chamberInGeometry(det)) {
@@ -199,7 +201,7 @@ bool Digitizer::convertHits(const int det, const std::vector<Hit>& hits, SignalC
199201

200202
double padSignal[mNpad];
201203

202-
const double calExBDetValue = mCalib->getExB(det); // T * V/cm (check units)
204+
const double calExBDetValue = mCalVdriftExB->getExB(det, true); // T * V/cm (check units)
203205
const PadPlane* padPlane = mGeo->getPadPlane(det);
204206
const int layer = mGeo->getLayer(det);
205207
const float rowEndROC = padPlane->getRowEndROC();
@@ -253,8 +255,11 @@ bool Digitizer::convertHits(const int det, const std::vector<Hit>& hits, SignalC
253255
absDriftLength /= std::sqrt(1 / (1 + calExBDetValue * calExBDetValue));
254256
}
255257

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

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

278283
// Apply E x B effects
279284
if (mSimParam.isExBOn()) {
280-
locCd = locCd + calExBDetValue * driftLength;
285+
// minus sign is necessary to be compatible with how Vdrift and ExB are calibrated
286+
locCd = locCd - TMath::Tan(calExBDetValue) * driftLength;
281287
}
282288
// The electron position after diffusion and ExB in pad coordinates.
283289
rowE = padPlane->getPadRowNumberROC(locRd);
@@ -292,7 +298,7 @@ bool Digitizer::convertHits(const int det, const std::vector<Hit>& hits, SignalC
292298
continue;
293299
}
294300
const double colOffset = padPlane->getPadColOffset(colE, locCd + offsetTilt);
295-
driftVelocity = mCalib->getVDrift(det, colE, rowE); // The drift velocity for the updated col and row
301+
//driftVelocity = mCalib->getVDrift(det, colE, rowE); // The drift velocity for the updated col and row
296302
t0 = mCalib->getT0(det, colE, rowE); // The T0 velocity for the updated col and row
297303
// Convert the position to drift time [mus], using either constant drift velocity or
298304
// time structure of drift cells (non-isochronity, GARFIELD calculation).
@@ -313,7 +319,8 @@ bool Digitizer::convertHits(const int det, const std::vector<Hit>& hits, SignalC
313319
}
314320

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

318325
// Apply the pad response
319326
if (mSimParam.prfOn()) {
@@ -424,10 +431,10 @@ bool Digitizer::convertSignalsToADC(SignalContainer& signalMapCont, DigitContain
424431
int halfchamberside = (mcm > 3) ? 1 : 0; // 0=Aside, 1=Bside
425432

426433
// Halfchambers that are switched off, masked by mCalib
427-
if ((halfchamberside == 0 && mCalib->getChamberStatus()->isNoDataSideA(det)) ||
434+
/*if ((halfchamberside == 0 && mCalib->getChamberStatus()->isNoDataSideA(det)) ||
428435
(halfchamberside == 1 && mCalib->getChamberStatus()->isNoDataSideB(det))) {
429436
continue;
430-
}
437+
}*/
431438

432439
// Check whether pad is masked
433440
// Bridged pads are not considered yet!!!

Detectors/TRD/workflow/src/TRDDigitizerSpec.cxx

Lines changed: 34 additions & 2 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"
@@ -69,6 +70,9 @@ class TRDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
6970
auto creationTime = pc.services().get<o2::framework::TimingInfo>().creation;
7071
simcal.getCCDBObjects(creationTime);
7172
mDigitizer.setCalibrations(&simcal);
73+
pc.inputs().get<o2::trd::CalVdriftExB*>("calvdexb");
74+
pc.inputs().get<o2::trd::CalGain*>("calgain");
75+
pc.inputs().get<std::array<int, constants::MAXCHAMBER>*>("fedchamberstatus");
7276

7377
// read collision context from input
7478
auto context = pc.inputs().get<o2::steer::DigitizationContext*>("collisioncontext");
@@ -206,6 +210,28 @@ class TRDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
206210
pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
207211
finished = true;
208212
}
213+
214+
void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
215+
{
216+
if (matcher == ConcreteDataMatcher("TRD", "CALVDRIFTEXB", 0)) {
217+
LOG(info) << "CalVdriftExB object has been updated";
218+
mDigitizer.setCalVdriftExB((const o2::trd::CalVdriftExB*)obj);
219+
return;
220+
}
221+
if (matcher == ConcreteDataMatcher("TRD", "CALGAIN", 0)) {
222+
LOG(info) << "CalGain object has been updated";
223+
mDigitizer.setCalGain((const o2::trd::CalGain*)obj);
224+
return;
225+
}
226+
if (matcher == ConcreteDataMatcher("TRD", "FEDCHAMBERSTATUS", 0)) {
227+
LOG(info) << "Fed chamber status has been updated";
228+
std::array<int, constants::MAXCHAMBER>* fedStatus = (std::array<int, constants::MAXCHAMBER>*) obj;
229+
for (int det = 0; det < constants::MAXCHAMBER; det++) {
230+
mDigitizer.setFedChamberStatus(det, (*fedStatus)[det]);
231+
}
232+
return;
233+
}
234+
}
209235

210236
private:
211237
Digitizer mDigitizer;
@@ -229,11 +255,17 @@ o2::framework::DataProcessorSpec getTRDDigitizerSpec(int channel, bool mctruth)
229255
outputs.emplace_back("TRD", "LABELS", 0, Lifetime::Timeframe);
230256
}
231257
outputs.emplace_back("TRD", "ROMode", 0, Lifetime::Timeframe);
258+
259+
std::vector<InputSpec> inputs;
260+
inputs.emplace_back("collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
261+
inputs.emplace_back("calvdexb", "TRD", "CALVDRIFTEXB", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/CalVdriftExB"));
262+
inputs.emplace_back("calgain", "TRD", "CALGAIN", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/CalGain"));
263+
inputs.emplace_back("fedchamberstatus", "TRD", "FEDCHAMBERSTATUS", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/DCSDPsFedChamberStatus"));
232264

233265
return DataProcessorSpec{
234266
"TRDDigitizer",
235-
Inputs{InputSpec{"collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast<SubSpecificationType>(channel), Lifetime::Timeframe}},
236-
267+
//Inputs{InputSpec{"collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast<SubSpecificationType>(channel), Lifetime::Timeframe}},
268+
inputs,
237269
outputs,
238270

239271
AlgorithmSpec{adaptFromTask<TRDDPLDigitizerTask>()},

0 commit comments

Comments
 (0)