19#include "TStopwatch.h"
53 LOG(info) <<
"initializing TRD digitization";
59 static bool finished =
false;
63 LOG(info) <<
"Doing TRD digitization";
76 auto& irecords = context->getEventRecords();
78 for (
auto& record : irecords) {
79 LOG(
debug) <<
"TRD TIME RECEIVED " << record.getTimeNS();
82 auto& eventParts = context->getEventParts();
83 std::vector<o2::trd::Digit> digitsAccum;
85 std::vector<TriggerRecord> triggers;
87 std::vector<o2::trd::Digit>
digits;
94 bool firstEvent =
true;
103 for (
size_t collID = 0; collID < irecords.size(); ++collID) {
104 LOGF(
debug,
"Collision %lu out of %lu at %.1f ns started processing. Current pileup container size: %lu. Current number of digits accumulated: %lu",
105 collID, irecords.size(), irecords[collID].getTimeNS(), mDigitizer.
getPileupSignals().size(), digitsAccum.size());
106 currentTime = irecords[collID];
112 if (currentTime < firstTF) {
113 LOG(info) <<
"Too early: Not digitizing collision " << collID;
118 bool isNewTrigger =
true;
120 triggerTime = currentTime;
126 LOGF(
debug,
"Collision %lu Not creating new trigger at time %.2f since dT=%.2f ns < busy time of %.1f us", collID, currentTime.
getTimeNS(), dT, mParams.
busyTimeNS() / 1000);
127 isNewTrigger =
false;
138 LOGF(
debug,
"Collision %lu we got %lu digits and %lu labels. There are %lu pileup containers remaining", currTrig,
digits.size(), labels.
getNElements(), mDigitizer.
getPileupSignals().size());
141 triggers.emplace_back(triggerTime, digitsAccum.size(),
digits.size());
142 std::copy(
digits.begin(),
digits.end(), std::back_inserter(digitsAccum));
146 triggerTime = currentTime;
164 for (
auto& part : eventParts[collID]) {
168 std::vector<o2::trd::Hit> hits;
169 context->retrieveHits(mSimChains,
"TRDHit", part.sourceID, part.entryID, &hits);
170 LOGF(
debug,
"Collision %lu processing in total %lu hits", collID, hits.size());
173 previousTime = currentTime;
182 LOGF(
debug,
"Collision %lu we got %lu digits and %lu labels. There are %lu pileup containers remaining", currTrig,
digits.size(), labels.
getNElements(), mDigitizer.
getPileupSignals().size());
184 triggers.emplace_back(triggerTime, digitsAccum.size(),
digits.size());
185 std::copy(
digits.begin(),
digits.end(), std::back_inserter(digitsAccum));
189 LOGF(info,
"List of TRD chambers with at least one drift velocity out of range: %s", mDigitizer.
dumpFlaggedChambers());
191 LOGF(info,
"TRD digitization timing: Cpu: %.3e Real: %.3e s", timer.CpuTime(), timer.RealTime());
193 LOG(info) <<
"TRD: Sending " << digitsAccum.size() <<
" digits";
196 LOG(info) <<
"TRD: Sending " << labelsAccum.
getNElements() <<
" labels";
201 LOG(info) <<
"TRD: Sending ROMode= " << mROMode <<
" to GRPUpdater";
203 LOG(info) <<
"TRD: Sending trigger records";
212 std::vector<TChain*> mSimChains;
225 std::vector<OutputSpec> outputs;
226 outputs.emplace_back(
"TRD",
"DIGITS", 1, Lifetime::Timeframe);
227 outputs.emplace_back(
"TRD",
"TRKTRGRD", 1, Lifetime::Timeframe);
229 outputs.emplace_back(
"TRD",
"LABELS", 0, Lifetime::Timeframe);
231 outputs.emplace_back(
"TRD",
"ROMode", 0, Lifetime::Timeframe);
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.
BaseDPLDigitizer()=default
static const HBFUtils & Instance()
void snapshot(const Output &spec, T const &object)
o2::header::DataHeader::SubSpecificationType SubSpecificationType
decltype(auto) make(const Output &spec, Args... args)
bool isAllowed(Output const &query)
check if a certain output is allowed
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
void getCCDBObjects(long timestamp)
void process(std::vector< Hit > const &)
void setSrcID(int sourceID)
void setTriggerTime(double t)
void setEventID(int entryID)
const std::deque< std::array< SignalContainer, constants::MAXCHAMBER > > & getPileupSignals() const
void flush(DigitContainer &, o2::dataformats::MCTruthContainer< MCLabel > &)
void setEventTime(double timeNS)
void clearPileupSignals()
void setCalibrations(Calibrations *calibrations)
std::string dumpFlaggedChambers() const
void initDigitizerTask(framework::InitContext &ic) override
void run(framework::ProcessingContext &pc)
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
header::DataHeader::SubSpecificationType SubSpecificationType
std::vector< InputSpec > Inputs
o2::framework::DataProcessorSpec getTRDDigitizerSpec(int channel, bool mctruth=true)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
double getTimeNS() const
get time in ns from orbit=0/bc=0
float busyTimeNS() const
the time for which no new trigger can be received in nanoseconds
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits