34#include "MFTBase/GeometryTGeo.h"
36#include <TStopwatch.h>
50 static constexpr o2::detectors::DetID ID{N == o2::detectors::DetID::ITS ? o2::detectors::DetID::ITS : o2::detectors::DetID::MFT};
80 LOG(info) <<
" CALLING ITS DIGITIZATION ";
85 const bool withQED = context->isQEDProvided() && !
mDisableQED;
86 auto& timesview = context->getEventRecords(withQED);
87 LOG(info) <<
"GOT " << timesview.size() <<
" COLLISSION TIMES";
91 if (timesview.size() == 0) {
111 auto accumulate = [
this, &digitsAccum, &iLayer]() {
117 auto ndigAcc = digitsAccum.size();
118 std::copy(
mDigits[iLayer].begin(),
mDigits[iLayer].
end(), std::back_inserter(digitsAccum));
125 rof.setFirstEntry(ndigAcc + rof.getFirstEntry());
133 LOG(info) <<
"Added " <<
mDigits[iLayer].size() <<
" digits" << ((
mDoStaggering) ? std::format(
" on layer {}", iLayer) :
"");
140 const auto& eventParts = context->getEventParts(withQED);
143 for (
int collID = 0; collID < timesview.size(); ++collID) {
144 auto irt = timesview[collID];
145 if (irt.toLong() < bcShift) {
154 for (
const auto& part : eventParts[collID]) {
160 if (
mHits.size() > 0) {
161 LOG(
debug) <<
"For collision " << collID <<
" eventID " << part.entryID <<
" found " <<
mHits.size() <<
" hits ";
169 nDigits += digitsAccum.size();
179 std::vector<o2::itsmft::ROFRecord> expDigitRofVec(nROFsLayer);
180 for (
int iROF{0}; iROF < nROFsLayer; ++iROF) {
181 auto& rof = expDigitRofVec[iROF];
186 rof.setROFrame(iROF);
188 rof.setFirstEntry(-1);
192 const auto&
ir = rof.getBCData();
197 auto irToFirst =
ir - firstIR;
204 auto& expROF = expDigitRofVec[irROF];
205 expROF.setFirstEntry(rof.getFirstEntry());
206 expROF.setNEntries(rof.getNEntries());
207 if (expROF.getBCData() != rof.getBCData()) {
208 LOGP(fatal,
"detected mismatch between expected {} and received {}", expROF.asString(), rof.asString());
212 for (
auto& rof : expDigitRofVec) {
213 if (rof.getFirstEntry() < 0) {
214 rof.setFirstEntry(prevFirst);
216 prevFirst = rof.getFirstEntry();
220 expDigitRofVec.resize(nROFsTF);
229 mLabels[iLayer].clear_andfreememory();
232 static std::vector<o2::itsmft::MC2ROFRecord> dummyMC2ROF;
241 LOG(info) <<
"Digitization took " << timer.CpuTime() <<
"s";
242 LOG(info) <<
"Produced " << nDigits <<
" digits";
258 LOG(info) <<
ID.
getName() <<
" static dead map updated";
268 LOGP(fatal,
"Attempt to add time-dependent map to already modified static map");
272 LOG(info) <<
ID.
getName() <<
" time-dependent dead map updated";
274 LOG(info) <<
ID.
getName() <<
" time-dependent dead map is default/empty";
282 par.printKeyValues();
286 LOG(info) <<
ID.
getName() <<
" loaded AlpideResponseData for Vbb=0V";
290 LOG(info) <<
ID.
getName() <<
" loaded AlpideResponseData for Vbb=-3V";
313 digipar.setROFrameBiasInBC(aopt.roFrameBiasInBC);
314 if (dopt.continuous) {
315 auto frameNS = aopt.roFrameLengthInBC * o2::constants::lhc::LHCBunchSpacingNS;
316 digipar.setROFrameLengthInBC(aopt.roFrameLengthInBC);
317 digipar.setROFrameLength(frameNS);
318 digipar.setStrobeDelay(aopt.strobeDelay);
319 digipar.setStrobeLength(aopt.strobeLengthCont > 0 ? aopt.strobeLengthCont : frameNS - aopt.strobeDelay);
321 digipar.setROFrameLength(aopt.roFrameLengthTrig);
322 digipar.setStrobeDelay(aopt.strobeDelay);
323 digipar.setStrobeLength(aopt.strobeLengthTrig);
326 digipar.getSignalShape().setParameters(dopt.strobeFlatTop, dopt.strobeMaxRiseTime, dopt.strobeQRiseTime0);
327 digipar.setChargeThreshold(dopt.chargeThreshold);
328 digipar.setNoisePerPixel(dopt.noisePerPixel);
329 digipar.setTimeOffset(dopt.timeOffset);
330 digipar.setNSimSteps(dopt.nSimSteps);
331 digipar.setIBVbb(dopt.IBVbb);
332 digipar.setOBVbb(dopt.OBVbb);
333 digipar.setVbb(dopt.Vbb);
336 for (
int iLayer{0}; iLayer < o2::itsmft::DPLAlpideParam<N>::getNLayers(); ++iLayer) {
337 auto frameNS = aopt.getROFLengthInBC(iLayer) * o2::constants::lhc::LHCBunchSpacingNS;
338 digipar.addROFrameLayerLengthInBC(aopt.getROFLengthInBC(iLayer));
340 digipar.addROFrameLayerBiasInBC(aopt.getROFBiasInBC(iLayer) + aopt.getROFDelayInBC(iLayer));
341 digipar.addStrobeDelay(aopt.strobeDelay);
342 digipar.addStrobeLength(aopt.strobeLengthCont > 0 ? aopt.strobeLengthCont : frameNS - aopt.strobeDelay);
343 digipar.setROFrameLength(aopt.getROFLengthInBC(iLayer) * o2::constants::lhc::LHCBunchSpacingNS, iLayer);
348 LOG(info) << detstr <<
" simulated in "
354 if constexpr (N == o2::detectors::DetID::ITS) {
359 geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G));
371 std::vector<std::vector<o2::itsmft::Digit>>
mDigits;
376 std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>
mLabels;
377 std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>
mLabelsAccum;
404 std::vector<OutputSpec> outputs;
406 for (uint32_t iLayer = 0; iLayer < nLayers; ++iLayer) {
407 outputs.emplace_back(detOrig,
"DIGITS", iLayer, Lifetime::Timeframe);
408 outputs.emplace_back(detOrig,
"DIGITSROF", iLayer, Lifetime::Timeframe);
410 outputs.emplace_back(detOrig,
"DIGITSMC2ROF", iLayer, Lifetime::Timeframe);
411 outputs.emplace_back(detOrig,
"DIGITSMCTR", iLayer, Lifetime::Timeframe);
414 outputs.emplace_back(detOrig,
"ROMode", 0, Lifetime::Timeframe);
423 std::vector<InputSpec> inputs;
424 inputs.emplace_back(
"collisioncontext",
"SIM",
"COLLISIONCONTEXT",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
425 inputs.emplace_back(
"ITS_noise",
"ITS",
"NOISEMAP", 0, Lifetime::Condition,
ccdbParamSpec(
"ITS/Calib/NoiseMap"));
426 inputs.emplace_back(
"ITS_dead",
"ITS",
"DEADMAP", 0, Lifetime::Condition,
ccdbParamSpec(
"ITS/Calib/DeadMap"));
427 inputs.emplace_back(
"ITS_time_dead",
"ITS",
"TimeDeadMap", 0, Lifetime::Condition,
ccdbParamSpec(
"ITS/Calib/TimeDeadMap"));
428 inputs.emplace_back(
"ITS_alppar",
"ITS",
"ALPIDEPARAM", 0, Lifetime::Condition,
ccdbParamSpec(
"ITS/Config/AlpideParam"));
429 inputs.emplace_back(
"ITS_alpiderespvbb0",
"ITS",
"ALPIDERESPVbb0", 0, Lifetime::Condition,
ccdbParamSpec(
"ITSMFT/Calib/ALPIDEResponseVbb0"));
430 inputs.emplace_back(
"ITS_alpiderespvbbm3",
"ITS",
"ALPIDERESPVbbM3", 0, Lifetime::Condition,
ccdbParamSpec(
"ITSMFT/Calib/ALPIDEResponseVbbM3"));
433 .outputs = makeOutChannels<o2::detectors::DetID::ITS>(detOrig, mctruth, doStag),
434 .algorithm =
AlgorithmSpec{adaptFromTask<ITSDPLDigitizerTask>(mctruth, doStag)},
443 std::vector<InputSpec> inputs;
444 inputs.emplace_back(
"collisioncontext",
"SIM",
"COLLISIONCONTEXT",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
445 inputs.emplace_back(
"MFT_noise",
"MFT",
"NOISEMAP", 0, Lifetime::Condition,
ccdbParamSpec(
"MFT/Calib/NoiseMap"));
446 inputs.emplace_back(
"MFT_dead",
"MFT",
"DEADMAP", 0, Lifetime::Condition,
ccdbParamSpec(
"MFT/Calib/DeadMap"));
447 inputs.emplace_back(
"MFT_time_dead",
"MFT",
"TimeDeadMap", 0, Lifetime::Condition,
ccdbParamSpec(
"MFT/Calib/TimeDeadMap"));
448 inputs.emplace_back(
"MFT_alppar",
"MFT",
"ALPIDEPARAM", 0, Lifetime::Condition,
ccdbParamSpec(
"MFT/Config/AlpideParam"));
449 inputs.emplace_back(
"MFT_alpiderespvbb0",
"MFT",
"ALPIDERESPVbb0", 0, Lifetime::Condition,
ccdbParamSpec(
"ITSMFT/Calib/ALPIDEResponseVbb0"));
450 inputs.emplace_back(
"MFT_alpiderespvbbm3",
"MFT",
"ALPIDERESPVbbM3", 0, Lifetime::Condition,
ccdbParamSpec(
"ITSMFT/Calib/ALPIDEResponseVbbM3"));
453 .outputs = makeOutChannels<o2::detectors::DetID::MFT>(detOrig, mctruth, doStag),
454 .algorithm =
AlgorithmSpec{adaptFromTask<MFTDPLDigitizerTask>(mctruth, doStag)},
Definition of the base digitizer task class.
A const (ready only) version of MCTruthContainer.
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Header of the General Run Parameters object.
Definition of the GeometryTGeo class.
Definition of the ITS digitizer.
Definition of the ITSMFT NoiseMap.
Definition of the ITSMFT time-dependend dead map.
virtual void init(o2::framework::InitContext &) final
static const DPLAlpideParam< N > & Instance()
Static class with identifiers, bitmasks and names for ALICE detectors.
static constexpr const char * getName(ID id)
names of defined detectors
static const std::array< std::vector< std::string >, DetID::nDetectors > DETECTORBRANCHNAMES
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
o2::header::DataHeader::SubSpecificationType SubSpecificationType
decltype(auto) make(const Output &spec, Args... args)
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
static GeometryTGeo * Instance()
int getROFrameBiasInBC(int layer=-1) const
void setContinuous(bool v)
void setDeadChannelsMap(const o2::itsmft::NoiseMap *mp)
void fillOutputContainer(uint32_t maxFrame=0xffffffff, int layer=-1)
void setGeometry(const o2::itsmft::GeometryTGeo *gm)
void setMCLabels(o2::dataformats::MCTruthContainer< o2::MCCompLabel > *mclb)
void setAlpideResponse(const o2::itsmft::AlpideSimResponse *resp, int i)
void setNoiseMap(const o2::itsmft::NoiseMap *mp)
void setROFRecords(std::vector< o2::itsmft::ROFRecord > *rec)
void resetEventROFrames()
void setDigits(std::vector< o2::itsmft::Digit > *dig)
o2::itsmft::DigiParams & getParams()
void resetROFrameBounds()
void setEventTime(const o2::InteractionTimeRecord &irt, int layer=-1)
void process(const std::vector< Hit > *hits, int evID, int srcID, int layer=-1)
Steer conversion of hits to digits.
ITSDPLDigitizerTask(bool mctruth=true, bool doStag=false)
o2::itsmft::NoiseMap * mDeadMap
std::vector< o2::itsmft::Hit > * mHitsP
std::vector< std::vector< o2::itsmft::ROFRecord > > mROFRecords
o2::itsmft::Digitizer mDigitizer
std::vector< o2::dataformats::MCTruthContainer< o2::MCCompLabel > > mLabels
void updateTimeDependentParams(ProcessingContext &pc)
o2::parameters::GRPObject::ROMode mROMode
static constexpr o2::detectors::DetID ID
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj)
void initDigitizerTask(framework::InitContext &ic) override
std::vector< o2::itsmft::Hit > mHits
std::vector< std::vector< o2::itsmft::ROFRecord > > mROFRecordsAccum
static constexpr o2::header::DataOrigin Origin
std::vector< o2::dataformats::MCTruthContainer< o2::MCCompLabel > > mLabelsAccum
std::vector< TChain * > mSimChains
unsigned long mFirstOrbitTF
std::vector< std::vector< o2::itsmft::Digit > > mDigits
ITSMFTDPLDigitizerTask(bool mctruth=true, bool doStag=false)
void run(framework::ProcessingContext &pc)
MFTDPLDigitizerTask(bool mctruth=true, bool doStag=false)
NoiseMap class for the ITS and MFT.
void decodeMap(NoiseMap &noisemap) const
static GeometryTGeo * Instance()
bool initSimChains(o2::detectors::DetID detid, std::vector< TChain * > &simchains) const
GLenum GLuint GLint GLint layer
constexpr o2::header::DataOrigin gDataOriginMFT
constexpr o2::header::DataOrigin gDataOriginITS
Defining ITS Vertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
DataProcessorSpec getMFTDigitizerSpec(int channel, bool mctruth, bool doStag)
DataProcessorSpec getITSDigitizerSpec(int channel, bool mctruth, bool doStag)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string asString() const
class listing possible services
static constexpr int getNLayers()
int getROFDelayInBC(int layer) const noexcept
int getNOrbitsPerTF() const
get IR corresponding to start of the HBF
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
o2::InteractionRecord ir(0, 0)