35#include <TStopwatch.h>
47 std::vector<OutputSpec> outputs;
48 outputs.emplace_back(detOrig,
"DIGITS", 0, Lifetime::Timeframe);
49 outputs.emplace_back(detOrig,
"DIGITSROF", 0, Lifetime::Timeframe);
51 outputs.emplace_back(detOrig,
"DIGITSMC2ROF", 0, Lifetime::Timeframe);
52 outputs.emplace_back(detOrig,
"DIGITSMCTR", 0, Lifetime::Timeframe);
54 outputs.emplace_back(detOrig,
"ROMode", 0, Lifetime::Timeframe);
71 mDisableQED = ic.
options().
get<
bool>(
"disable-qed");
72 mLocalRespFile = ic.
options().
get<std::string>(
"local-response-file");
85 const bool withQED = context->isQEDProvided() && !mDisableQED;
86 auto& timesview = context->getEventRecords(withQED);
87 LOG(info) <<
"GOT " << timesview.size() <<
" COLLISION TIMES";
88 LOG(info) <<
"SIMCHAINS " << mSimChains.size();
91 if (timesview.empty()) {
96 LOG(info) <<
" CALLING TRK DIGITIZATION ";
103 auto& digitsAccum = pc.
outputs().
make<std::vector<itsmft::Digit>>(
Output{mOrigin,
"DIGITS", 0});
105 auto accumulate = [
this, &digitsAccum]() {
108 if (mDigits.empty()) {
109 LOG(
debug) <<
"No digits to accumulate";
112 LOG(
debug) <<
"Accumulating " << mDigits.size() <<
" digits ";
113 auto ndigAcc = digitsAccum.size();
114 std::copy(mDigits.begin(), mDigits.end(), std::back_inserter(digitsAccum));
117 auto nROFRecsOld = mROFRecordsAccum.size();
119 for (
int i = 0;
i < mROFRecords.size();
i++) {
120 auto& rof = mROFRecords[
i];
121 rof.setFirstEntry(ndigAcc + rof.getFirstEntry());
124 if (mFixMC2ROF < mMC2ROFRecordsAccum.size()) {
125 for (
int m2rid = mFixMC2ROF; m2rid < mMC2ROFRecordsAccum.size(); m2rid++) {
127 auto& mc2rof = mMC2ROFRecordsAccum[m2rid];
128 if (rof.getROFrame() == mc2rof.minROF) {
130 mc2rof.rofRecordID = nROFRecsOld +
i;
137 std::copy(mROFRecords.begin(), mROFRecords.end(), std::back_inserter(mROFRecordsAccum));
141 LOG(info) <<
"Added " << mDigits.size() <<
" digits ";
148 auto& eventParts = context->getEventParts(withQED);
152 for (
size_t collID = 0; collID < timesview.size(); ++collID) {
153 auto irt = timesview[collID];
154 if (irt.toLong() < bcShift) {
163 for (
auto& part : eventParts[collID]) {
169 if (!mHits.empty()) {
170 LOG(
debug) <<
"For collision " << collID <<
" eventID " << part.entryID
171 <<
" found " << mHits.size() <<
" hits ";
172 mDigitizer.
process(&mHits, part.entryID, part.sourceID);
179 LOG(
debug) <<
"mDigits size after fill: " << mDigits.size();
193 LOG(info) << mID.
getName() <<
": Sending ROMode= " << mROMode <<
" to GRPUpdater";
197 LOG(info) <<
"Digitization took " << timer.CpuTime() <<
"s";
207 std::unique_ptr<TFile>
file(TFile::Open(mLocalRespFile.data(),
"READ"));
209 LOG(fatal) <<
"Cannot open response file " << mLocalRespFile;
216 static bool initOnce{
false};
230 digipar.setContinuous(dopt.continuous);
232 if (dopt.continuous) {
235 digipar.setROFrameLength(frameNS);
244 digipar.getSignalShape().setParameters(dopt.strobeFlatTop, dopt.strobeMaxRiseTime, dopt.strobeQRiseTime0);
245 digipar.setChargeThreshold(dopt.chargeThreshold);
246 digipar.setNoisePerPixel(dopt.noisePerPixel);
247 digipar.setTimeOffset(dopt.timeOffset);
248 digipar.setNSimSteps(dopt.nSimSteps);
251 LOG(info) << mID.
getName() <<
" simulated in "
269 LOG(info) << mID.
getName() <<
" Alpide param updated";
271 par.printKeyValues();
280 LOG(info) << mID.
getName() <<
" loaded APTSResponseData";
281 if (mLocalRespFile.empty()) {
282 LOG(info) <<
"Using CCDB/APTS response file";
286 LOG(info) <<
"Response function will be loaded from local file: " << mLocalRespFile;
294 bool mWithMCTruth{
true};
295 bool mFinished{
false};
296 bool mDisableQED{
false};
297 std::string mLocalRespFile{
""};
301 std::vector<o2::itsmft::Digit> mDigits{};
302 std::vector<o2::itsmft::ROFRecord> mROFRecords{};
303 std::vector<o2::itsmft::ROFRecord> mROFRecordsAccum{};
304 std::vector<o2::trk::Hit> mHits{};
305 std::vector<o2::trk::Hit>* mHitsP{&mHits};
308 std::vector<o2::itsmft::MC2ROFRecord> mMC2ROFRecordsAccum{};
309 std::vector<TChain*> mSimChains{};
319 std::vector<InputSpec> inputs;
320 inputs.emplace_back(
"collisioncontext",
"SIM",
"COLLISIONCONTEXT",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
321 inputs.emplace_back(
"ITS_alppar",
"ITS",
"ALPIDEPARAM", 0, Lifetime::Condition,
ccdbParamSpec(
"ITS/Config/AlpideParam"));
325 inputs.emplace_back(
"TRK_aptsresp",
"TRK",
"APTSRESP", 0, Lifetime::Condition,
ccdbParamSpec(
"IT3/Calib/APTSResponse"));
328 inputs, makeOutChannels(detOrig, mctruth),
Definition of the base digitizer task class.
A const (ready only) version of MCTruthContainer.
o2::framework::DataAllocator::SubSpecificationType SubSpecificationType
Header of the General Run Parameters object.
Definition of the TRK digitizer.
virtual void init(o2::framework::InitContext &) final
static const DPLDigitizerParam< 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.
bool initSimChains(o2::detectors::DetID detid, std::vector< TChain * > &simchains) const
int getROFrameBiasInBC() const
void setAlpSimResponse(const o2::itsmft::AlpideSimResponse *)
void setEventTime(const o2::InteractionTimeRecord &irt)
void fillOutputContainer(uint32_t maxFrame=0xffffffff)
o2::trk::DigiParams & getParams()
void setResponseName(const std::string &name)
void process(const std::vector< o2::trk::Hit > *hits, int evID, int srcID)
Steer conversion of hits to digits.
uint32_t getEventROFrameMin() const
void setDigits(std::vector< o2::itsmft::Digit > *dig)
void setROFRecords(std::vector< o2::itsmft::ROFRecord > *rec)
void setMCLabels(o2::dataformats::MCTruthContainer< o2::MCCompLabel > *mclb)
void setGeometry(const o2::trk::GeometryTGeo *gm)
uint32_t getEventROFrameMax() const
void resetEventROFrames()
void Print(Option_t *opt="") const
void fillMatrixCache(int mask)
static GeometryTGeo * Instance()
TRKDPLDigitizerTask(bool mctruth=true)
void run(framework::ProcessingContext &pc)
void updateTimeDependentParams(ProcessingContext &pc)
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj)
void setLocalResponseFunction()
void initDigitizerTask(framework::InitContext &ic) override
constexpr o2::header::DataOrigin gDataOriginTRK
constexpr double LHCBunchSpacingNS
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
header::DataHeader::SubSpecificationType SubSpecificationType
DataProcessorSpec getTRKDigitizerSpec(int channel, bool mctruth)
class listing possible services
int roFrameBiasInBC
bias of the start of ROF wrt orbit start: t_irof = (irof*roFrameLengthInBC + roFrameBiasInBC)*BClengt...
float strobeDelay
strobe start (in ns) wrt ROF start
int roFrameLengthInBC
ROF length in BC for continuous mode.
float strobeLengthCont
if < 0, full ROF length - delay
float strobeLengthTrig
length of the strobe in ns (sig. over threshold checked in this window only)
float roFrameLengthTrig
length of RO frame in ns for triggered mode
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"