20#include "TStopwatch.h"
54 LOG(info) <<
"initializing TRD digitization";
60 static bool finished =
false;
64 LOG(info) <<
"Doing TRD digitization";
70 pc.
inputs().
get<std::array<int, constants::MAXCHAMBER>*>(
"fedchamberstatus");
76 context->initSimChains(o2::detectors::DetID::TRD, mSimChains);
77 auto& irecords = context->getEventRecords();
79 for (
auto& record : irecords) {
80 LOG(
debug) <<
"TRD TIME RECEIVED " << record.getTimeNS();
83 auto& eventParts = context->getEventParts();
84 std::vector<o2::trd::Digit> digitsAccum;
86 std::vector<TriggerRecord> triggers;
88 std::vector<o2::trd::Digit>
digits;
95 bool firstEvent =
true;
104 for (
size_t collID = 0; collID < irecords.size(); ++collID) {
105 LOGF(
debug,
"Collision %lu out of %lu at %.1f ns started processing. Current pileup container size: %lu. Current number of digits accumulated: %lu",
106 collID, irecords.size(), irecords[collID].getTimeNS(), mDigitizer.
getPileupSignals().size(), digitsAccum.size());
107 currentTime = irecords[collID];
113 if (currentTime < firstTF) {
114 LOG(info) <<
"Too early: Not digitizing collision " << collID;
119 bool isNewTrigger =
true;
121 triggerTime = currentTime;
127 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);
128 isNewTrigger =
false;
139 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());
142 triggers.emplace_back(triggerTime, digitsAccum.size(),
digits.size());
143 std::copy(
digits.begin(),
digits.end(), std::back_inserter(digitsAccum));
147 triggerTime = currentTime;
165 for (
auto& part : eventParts[collID]) {
169 std::vector<o2::trd::Hit> hits;
170 context->retrieveHits(mSimChains,
"TRDHit", part.sourceID, part.entryID, &hits);
171 LOGF(
debug,
"Collision %lu processing in total %lu hits", collID, hits.size());
174 previousTime = currentTime;
183 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());
185 triggers.emplace_back(triggerTime, digitsAccum.size(),
digits.size());
186 std::copy(
digits.begin(),
digits.end(), std::back_inserter(digitsAccum));
190 LOGF(info,
"List of TRD chambers with at least one drift velocity out of range: %s", mDigitizer.
dumpFlaggedChambers());
192 LOGF(info,
"TRD digitization timing: Cpu: %.3e Real: %.3e s", timer.CpuTime(), timer.RealTime());
194 LOG(info) <<
"TRD: Sending " << digitsAccum.size() <<
" digits";
197 LOG(info) <<
"TRD: Sending " << labelsAccum.
getNElements() <<
" labels";
202 LOG(info) <<
"TRD: Sending ROMode= " << mROMode <<
" to GRPUpdater";
204 LOG(info) <<
"TRD: Sending trigger records";
214 LOG(info) <<
"CalVdriftExB object has been updated";
219 LOG(info) <<
"CalGain object has been updated";
224 LOG(info) <<
"Fed chamber status has been updated";
225 std::array<int, constants::MAXCHAMBER>* fedStatus = (std::array<int, constants::MAXCHAMBER>*)obj;
226 for (
int det = 0; det < constants::MAXCHAMBER; det++) {
232 LOG(info) <<
"PadStatus object has been updated";
237 LOG(info) <<
"LocalGainFactor object has been updated";
245 std::vector<TChain*> mSimChains;
258 std::vector<OutputSpec> outputs;
259 outputs.emplace_back(
"TRD",
"DIGITS", 1, Lifetime::Timeframe);
260 outputs.emplace_back(
"TRD",
"TRKTRGRD", 1, Lifetime::Timeframe);
262 outputs.emplace_back(
"TRD",
"LABELS", 0, Lifetime::Timeframe);
264 outputs.emplace_back(
"TRD",
"ROMode", 0, Lifetime::Timeframe);
266 std::vector<InputSpec> inputs;
267 inputs.emplace_back(
"collisioncontext",
"SIM",
"COLLISIONCONTEXT",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
268 inputs.emplace_back(
"calvdexb",
"TRD",
"CALVDRIFTEXB", 0, Lifetime::Condition,
ccdbParamSpec(
"TRD/Calib/CalVdriftExB"));
269 inputs.emplace_back(
"calgain",
"TRD",
"CALGAIN", 0, Lifetime::Condition,
ccdbParamSpec(
"TRD/Calib/CalGain"));
270 inputs.emplace_back(
"fedchamberstatus",
"TRD",
"FEDCHAMBERSTATUS", 0, Lifetime::Condition,
ccdbParamSpec(
"TRD/Calib/DCSDPsFedChamberStatus"));
271 inputs.emplace_back(
"padstatus",
"TRD",
"PADSTATUS", 0, Lifetime::Condition,
ccdbParamSpec(
"TRD/Calib/PadStatus"));
272 inputs.emplace_back(
"localgainfactor",
"TRD",
"LOCALGAINFACTOR", 0, Lifetime::Condition,
ccdbParamSpec(
"TRD/Calib/LocalGainFactor"));
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.
std::vector< o2::MCCompLabel > labels
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.
void process(std::vector< Hit > const &)
void setSrcID(int sourceID)
void setTriggerTime(double t)
void setPadStatus(const PadStatus *padStatus)
void setEventID(int entryID)
const std::deque< std::array< SignalContainer, constants::MAXCHAMBER > > & getPileupSignals() const
void setLocalGainFactor(const LocalGainFactor *localGain)
void flush(DigitContainer &, o2::dataformats::MCTruthContainer< MCLabel > &)
void setFedChamberStatus(int det, int value)
void setEventTime(double timeNS)
void clearPileupSignals()
void setCalVdriftExB(const CalVdriftExB *calVdriftExB)
void setCalGain(const CalGain *calGain)
std::string dumpFlaggedChambers() const
void initDigitizerTask(framework::InitContext &ic) override
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj)
void run(framework::ProcessingContext &pc)
Defining ITS Vertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
header::DataHeader::SubSpecificationType SubSpecificationType
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