39#include <TStopwatch.h>
52 std::vector<OutputSpec> outputs;
53 for (
uint32_t iLayer = 0; iLayer < static_cast<uint32_t>(nLayers); ++iLayer) {
54 outputs.emplace_back(detOrig,
"DIGITS", iLayer, Lifetime::Timeframe);
55 outputs.emplace_back(detOrig,
"DIGITSROF", iLayer, Lifetime::Timeframe);
57 outputs.emplace_back(detOrig,
"DIGITSMCTR", iLayer, Lifetime::Timeframe);
60 outputs.emplace_back(detOrig,
"ROMode", 0, Lifetime::Timeframe);
72 if constexpr (N == o2::detectors::DetID::TRK) {
83 static_assert(N == o2::detectors::DetID::TRK || N == o2::detectors::DetID::FT3,
"only TRK and FT3 digitizers are supported");
84 static constexpr o2::detectors::DetID ID{N == o2::detectors::DetID::TRK ? o2::detectors::DetID::TRK : o2::detectors::DetID::FT3};
92 mDisableQED = ic.
options().
get<
bool>(
"disable-qed");
93 mLocalRespFile = ic.
options().
get<std::string>(
"local-response-file");
108 const bool withQED = context->isQEDProvided() && !mDisableQED;
109 auto& timesview = context->getEventRecords(withQED);
110 LOG(info) <<
"GOT " << timesview.size() <<
" COLLISION TIMES";
111 LOG(info) <<
"SIMCHAINS " << mSimChains.size();
114 if (timesview.empty()) {
119 LOG(info) <<
" CALLING " <<
ID.
getName() <<
" DIGITIZATION ";
121 auto& eventParts = context->getEventParts(withQED);
123 for (
uint32_t iLayer = 0; iLayer < static_cast<uint32_t>(mLayers); ++iLayer) {
124 mDigits[iLayer].clear();
125 mROFRecords[iLayer].clear();
126 mROFRecordsAccum[iLayer].clear();
128 mLabels[iLayer].clear();
129 mLabelsAccum[iLayer].clear();
141 const int nROFsPerOrbit = o2::constants::lhc::LHCMaxBunches / roFrameLengthInBC;
143 mROFRecordsAccum[iLayer].reserve(nROFsTF);
145 auto accumulate = [
this, &digitsAccum, &iLayer]() {
148 if (mDigits[iLayer].
empty()) {
151 auto ndigAcc = digitsAccum.size();
152 std::copy(mDigits[iLayer].begin(), mDigits[iLayer].
end(), std::back_inserter(digitsAccum));
154 for (
auto& rof : mROFRecords[iLayer]) {
155 rof.setFirstEntry(ndigAcc + rof.getFirstEntry());
158 std::copy(mROFRecords[iLayer].begin(), mROFRecords[iLayer].
end(), std::back_inserter(mROFRecordsAccum[iLayer]));
160 mLabelsAccum[iLayer].mergeAtBack(mLabels[iLayer]);
162 LOG(info) <<
"Added " << mDigits[iLayer].size() <<
" digits on layer " << iLayer;
163 mLabels[iLayer].clear();
164 mDigits[iLayer].clear();
165 mROFRecords[iLayer].clear();
169 for (
size_t collID = 0; collID < timesview.size(); ++collID) {
170 auto irt = timesview[collID];
171 if (irt.toLong() < bcShift) {
178 for (
auto& part : eventParts[collID]) {
182 if (!mHits.empty()) {
183 LOG(
debug) <<
"For collision " << collID <<
" eventID " << part.entryID
184 <<
" found " << mHits.size() <<
" hits on layer " << iLayer;
185 mDigitizer.
process(&mHits, part.entryID, part.sourceID, iLayer);
192 nDigits += digitsAccum.size();
194 std::vector<o2::trkft3::ROFRecord> expDigitRofVec(nROFsTF);
195 for (
int iROF = 0; iROF < nROFsTF; ++iROF) {
196 auto& rof = expDigitRofVec[iROF];
197 const int orb = iROF * roFrameLengthInBC / o2::constants::lhc::LHCMaxBunches + mFirstOrbitTF;
198 const int bc = iROF * roFrameLengthInBC % o2::constants::lhc::LHCMaxBunches;
200 rof.setROFrame(iROF);
202 rof.setFirstEntry(-1);
205 for (
const auto& rof : mROFRecordsAccum[iLayer]) {
206 const auto&
ir = rof.getBCData();
207 const auto irToFirst =
ir - firstIR;
208 const auto irROF = irToFirst.
toLong() / roFrameLengthInBC;
209 if (irROF < 0 || irROF >= nROFsTF) {
212 auto& expROF = expDigitRofVec[irROF];
213 expROF.setFirstEntry(rof.getFirstEntry());
214 expROF.setNEntries(rof.getNEntries());
215 if (expROF.getBCData() != rof.getBCData()) {
216 LOGP(fatal,
"detected mismatch between expected {} and received {}", expROF.asString(), rof.asString());
221 for (
auto& rof : expDigitRofVec) {
222 if (rof.getFirstEntry() < 0) {
223 rof.setFirstEntry(prevFirst);
225 prevFirst = rof.getFirstEntry();
231 mLabelsAccum[iLayer].flatten_to(sharedlabels);
232 mLabels[iLayer].clear_andfreememory();
233 mLabelsAccum[iLayer].clear_andfreememory();
236 LOG(info) <<
ID.
getName() <<
": Sending ROMode= " << mROMode <<
" to GRPUpdater";
240 LOG(info) <<
"Digitization took " << timer.CpuTime() <<
"s";
241 LOG(info) <<
"Produced " << nDigits <<
" digits";
251 std::unique_ptr<TFile>
file(TFile::Open(mLocalRespFile.data(),
"READ"));
253 LOG(fatal) <<
"Cannot open response file " << mLocalRespFile;
260 static bool initOnce{
false};
267 if constexpr (N == o2::detectors::DetID::TRK) {
269 geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G));
275 geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G));
278 mLayers = getNLayers<N>();
283 mDigits.resize(mLayers);
284 mROFRecords.resize(mLayers);
285 mROFRecordsAccum.resize(mLayers);
286 mLabels.resize(mLayers);
287 mLabelsAccum.resize(mLayers);
291 for (
int iLayer = 0; iLayer < mLayers; ++iLayer) {
293 const auto roFrameLengthInBC = aopt.getROFLengthInBC(parLayer);
294 const auto frameNS = roFrameLengthInBC * o2::constants::lhc::LHCBunchSpacingNS;
295 digipar.setROFrameLengthInBC(roFrameLengthInBC, iLayer);
297 digipar.setROFrameBiasInBC(aopt.getROFBiasInBC(parLayer) + aopt.getROFDelayInBC(parLayer), iLayer);
298 digipar.setStrobeDelay(aopt.getStrobeDelay(parLayer), iLayer);
299 const auto strobeLengthCont = aopt.getStrobeLengthCont(parLayer);
300 digipar.setStrobeLength(strobeLengthCont > 0 ? strobeLengthCont : frameNS - aopt.getStrobeDelay(parLayer), iLayer);
301 digipar.setROFrameLength(frameNS, iLayer);
304 digipar.getSignalShape().setParameters(dopt.strobeFlatTop, dopt.strobeMaxRiseTime, dopt.strobeQRiseTime0);
305 digipar.setChargeThreshold(dopt.chargeThreshold);
306 digipar.setNoisePerPixel(dopt.noisePerPixel);
307 digipar.setTimeOffset(dopt.timeOffset);
308 digipar.setNSimSteps(dopt.nSimSteps);
311 LOG(info) <<
ID.
getName() <<
" simulated in CONTINUOUS RO mode";
329 par.printKeyValues();
338 LOG(info) <<
ID.
getName() <<
" loaded APTSResponseData";
339 if (mLocalRespFile.empty()) {
340 LOG(info) <<
"Using CCDB/APTS response file";
344 LOG(info) <<
"Response function will be loaded from local file: " << mLocalRespFile;
352 bool mWithMCTruth{
true};
353 bool mFinished{
false};
354 bool mDisableQED{
false};
355 unsigned long mFirstOrbitTF = 0x0;
356 std::string mLocalRespFile{
""};
359 std::vector<std::vector<o2::trkft3::Digit>> mDigits{};
360 std::vector<std::vector<o2::trkft3::ROFRecord>> mROFRecords{};
361 std::vector<std::vector<o2::trkft3::ROFRecord>> mROFRecordsAccum{};
362 std::vector<o2::trkft3::Hit> mHits{};
363 std::vector<o2::trkft3::Hit>* mHitsP{&mHits};
364 std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> mLabels{};
365 std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> mLabelsAccum{};
366 std::vector<TChain*> mSimChains{};
374 std::vector<InputSpec> inputs;
375 inputs.emplace_back(
"collisioncontext",
"SIM",
"COLLISIONCONTEXT",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
380 inputs.emplace_back(
"TRK_aptsresp",
"TRK",
"APTSRESP", 0, Lifetime::Condition,
ccdbParamSpec(
"IT3/Calib/APTSResponse"));
383 inputs, makeOutChannels(detOrig, getNLayers<o2::detectors::DetID::TRK>(), mctruth),
384 AlgorithmSpec{adaptFromTask<TRKFT3DPLDigitizerTask<o2::detectors::DetID::TRK>>(mctruth)},
394 std::vector<InputSpec> inputs;
395 inputs.emplace_back(
"collisioncontext",
"SIM",
"COLLISIONCONTEXT",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
396 inputs.emplace_back(
"FT3_aptsresp",
"FT3",
"APTSRESP", 0, Lifetime::Condition,
ccdbParamSpec(
"IT3/Calib/APTSResponse"));
399 inputs, makeOutChannels(detOrig, getNLayers<o2::detectors::DetID::FT3>(), mctruth),
400 AlgorithmSpec{adaptFromTask<TRKFT3DPLDigitizerTask<o2::detectors::DetID::FT3>>(mctruth)},
Definition of the base digitizer task class.
A const (ready only) version of MCTruthContainer.
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
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 TRK/FT3 digitizer.
virtual void init(o2::framework::InitContext &) final
static const HBFUtils & 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()
bool initSimChains(o2::detectors::DetID detid, std::vector< TChain * > &simchains) const
static GeometryTGeo * Instance()
void setResponse(const o2::itsmft::AlpideSimResponse *)
int getROFrameBiasInBC(int layer) const
int getROFrameLengthInBC(int layer) const
void setROFRecords(std::vector< o2::trkft3::ROFRecord > *rec)
void setGeometry(const GeometryTGeo *gm)
void setEventTime(const o2::InteractionTimeRecord &irt, int layer)
void process(const std::vector< o2::trkft3::Hit > *hits, int evID, int srcID, int layer)
Steer conversion of hits to digits.
void resetROFrameBounds()
void setResponseName(const std::string &name)
void setMCLabels(o2::dataformats::MCTruthContainer< o2::MCCompLabel > *mclb)
void fillOutputContainer(uint32_t maxFrame, int layer)
void resetEventROFrames()
o2::trkft3::DigiParams< DetID > & getParams()
void setDigits(std::vector< o2::trkft3::Digit > *dig)
void run(framework::ProcessingContext &pc)
void initDigitizerTask(framework::InitContext &ic) override
void setLocalResponseFunction()
TRKFT3DPLDigitizerTask(bool mctruth=true)
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj)
static constexpr o2::header::DataOrigin Origin
static constexpr o2::detectors::DetID ID
void updateTimeDependentParams(ProcessingContext &pc)
constexpr o2::header::DataOrigin gDataOriginTRK
constexpr o2::header::DataOrigin gDataOriginFT3
Defining ITS Vertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
DataProcessorSpec getTRKDigitizerSpec(int channel, bool mctruth)
DataProcessorSpec getFT3DigitizerSpec(int channel, bool mctruth)
class listing possible services
int getNOrbitsPerTF() const
get IR corresponding to start of the HBF
static constexpr size_t getNLayers()
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
o2::InteractionRecord ir(0, 0)