18#include "TStopwatch.h"
47 mHits =
new std::vector<Hit>();
49 auto simulatePileup = ic.
options().
get<
int>(
"pileup");
61 static bool updateOnlyOnce =
false;
62 if (!updateOnlyOnce) {
63 LOG(info) <<
"DigitizerSpec::run() : fetching o2::cpv::CPVSimParams from CCDB";
65 LOG(info) <<
"DigitizerSpec::run() : o2::cpv::CPVSimParams::Instance() now is following:";
80 updateOnlyOnce =
true;
86 updateTimeDependentParams(pc);
89 context->
initSimChains(o2::detectors::DetID::CPV, mSimChains);
90 auto& timesview = context->getEventRecords();
91 LOG(
debug) <<
"GOT " << timesview.size() <<
" COLLISSION TIMES";
94 int n = timesview.size();
102 LOG(info) <<
" CALLING CPV DIGITIZATION ";
103 std::vector<TriggerRecord> triggers;
105 int indexStart = mDigitsOut.size();
106 auto& eventParts = context->getEventParts();
108 bool isLastStream =
true;
117 for (
int collID = 0; collID <
n; ++collID) {
122 if (timesview[collID] < firstTF) {
123 LOG(info) <<
"Too early: Not digitizing collision " << collID;
127 double dt = timesview[collID].getTimeNS() - eventTime;
128 if (dt > mReadoutTime && dt < mDeadTime) {
134 eventTime = timesview[collID].getTimeNS();
140 if (collID <
n - 1) {
141 isLastStream = (timesview[collID + 1].getTimeNS() - eventTime > mReadoutTime);
149 auto part = eventParts[collID].begin();
150 while (part != eventParts[collID].
end()) {
152 int source = part->sourceID;
153 int entry = part->entryID;
155 context->retrieveHits(mSimChains,
"CPVHit",
source,
entry, mHits);
157 if (part == eventParts[collID].
end() && isLastStream) {
158 mDigitizer.
processHits(mHits, mDigitsFinal, mDigitsOut, mLabels, collID,
source, dt);
159 mDigitsFinal.clear();
162 triggers.emplace_back(timesview[eventId], indexStart, mDigitsOut.size() - indexStart);
163 indexStart = mDigitsOut.size();
164 mDigitsFinal.clear();
166 mDigitsTmp.swap(mDigitsFinal);
167 mDigitizer.
processHits(mHits, mDigitsTmp, mDigitsFinal, mLabels, collID,
source, dt);
181 LOG(
debug) <<
"CPV: Sending ROMode= " << roMode <<
" to GRPUpdater";
185 LOG(info) <<
"Digitization took " << timer.CpuTime() <<
"s";
195 std::vector<o2::framework::InputSpec> inputs;
196 inputs.emplace_back(
"collisioncontext",
"SIM",
"COLLISIONCONTEXT",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
197 inputs.emplace_back(
"peds",
"CPV",
"CPV_Pedestals", 0, o2::framework::Lifetime::Condition,
o2::framework::ccdbParamSpec(
"CPV/Calib/Pedestals"));
198 inputs.emplace_back(
"badmap",
"CPV",
"CPV_BadMap", 0, o2::framework::Lifetime::Condition,
o2::framework::ccdbParamSpec(
"CPV/Calib/BadChannelMap"));
199 inputs.emplace_back(
"gains",
"CPV",
"CPV_Gains", 0, o2::framework::Lifetime::Condition,
o2::framework::ccdbParamSpec(
"CPV/Calib/Gains"));
200 inputs.emplace_back(
"simparams",
"CPV",
"CPV_SimPars", 0, o2::framework::Lifetime::Condition,
o2::framework::ccdbParamSpec(
"CPV/Config/CPVSimParams"));
203 std::vector<OutputSpec> outputs;
204 outputs.emplace_back(
"CPV",
"DIGITS", 0, Lifetime::Timeframe);
205 outputs.emplace_back(
"CPV",
"DIGITTRIGREC", 0, Lifetime::Timeframe);
207 outputs.emplace_back(
"CPV",
"DIGITSMCTR", 0, Lifetime::Timeframe);
209 outputs.emplace_back(
"CPV",
"ROMode", 0, Lifetime::Timeframe);
215 AlgorithmSpec{o2::framework::adaptFromTask<DigitizerSpec>()},
216 Options{{
"pileup", VariantType::Int, 1, {
"whether to run in continuous time mode"}}}};
Definition of the base digitizer task class.
Class to store event ID and index in the event for objects like track, cluster...
Header of the General Run Parameters object.
Definition of a container to keep Monte Carlo truth external to simulation objects.
void printKeyValues(bool showProv=true, bool useLogger=false, bool withPadding=true, bool showHash=true) const final
static const CPVSimParams & Instance()
CCDB container for bad (masked) channels in CPV.
void run(framework::ProcessingContext &ctx)
run digitizer
void initDigitizerTask(framework::InitContext &ctx) final
init digitizer
void setGains(const CalibParams *gains)
void setBadChannelMap(const BadChannelMap *bcm)
void setPedestals(const Pedestals *peds)
void processHits(const std::vector< Hit > *mHits, const std::vector< Digit > &digitsBg, std::vector< Digit > &digitsOut, o2::dataformats::MCTruthContainer< o2::MCCompLabel > &mLabels, int source, int entry, double dt)
Steer conversion of hits to digits.
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
o2::header::DataHeader::SubSpecificationType SubSpecificationType
bool isAllowed(Output const &query)
check if a certain output is allowed
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
GLsizei GLsizei GLchar * source
DataProcessorSpec getCPVDigitizerSpec(int channel, bool mctruth)
Create new digitizer spec.
Defining ITS Vertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"