19#include "TStopwatch.h"
42 auto simulatePileup = ic.
options().
get<
int>(
"pileup");
53 auto mctruth = ic.
options().
get<
bool>(
"mctruth");
61 mHits =
new std::vector<Hit>();
69 auto& timesview = context->getEventRecords();
70 LOG(
debug) <<
"GOT " << timesview.size() <<
" COLLISSION TIMES";
74 mInitSimParams =
false;
78 int n = timesview.size();
87 long runStartTime = timesview[0].getTimeNS();
91 LOG(info) <<
" CALLING PHOS DIGITIZATION ";
92 std::vector<TriggerRecord> triggers;
94 int indexStart = mDigitsOut.size();
95 auto& eventParts = context->getEventParts();
99 bool isLastStream =
true;
108 for (
int collID = 0; collID <
n; ++collID) {
113 if (timesview[collID] < firstTF) {
114 LOG(info) <<
"Too early: Not digitizing collision " << collID;
118 double dt = timesview[collID].getTimeNS() - eventTime;
119 if (dt > mReadoutTime && dt < mDeadTime) {
125 eventTime = timesview[collID].getTimeNS();
131 if (collID <
n - 1) {
132 isLastStream = (timesview[collID + 1].getTimeNS() - eventTime > mReadoutTime);
140 auto part = eventParts[collID].begin();
141 while (part != eventParts[collID].
end()) {
143 int source = part->sourceID;
144 int entry = part->entryID;
146 context->retrieveHits(mSimChains,
"PHSHit",
source,
entry, mHits);
149 if (part == eventParts[collID].
end() && isLastStream) {
151 mDigitsFinal.clear();
154 triggers.emplace_back(timesview[eventId], indexStart, mDigitsOut.size() - indexStart);
155 indexStart = mDigitsOut.size();
157 mDigitsTmp.swap(mDigitsFinal);
173 LOG(
debug) <<
"PHOS: Sending ROMode= " << roMode <<
" to GRPUpdater";
177 LOG(info) <<
"Digitization took " << timer.CpuTime() <<
"s";
185 std::vector<OutputSpec> outputs;
186 outputs.emplace_back(
"PHS",
"DIGITS", 0, Lifetime::Timeframe);
187 outputs.emplace_back(
"PHS",
"DIGITTRIGREC", 0, Lifetime::Timeframe);
189 outputs.emplace_back(
"PHS",
"DIGITSMCTR", 0, Lifetime::Timeframe);
191 outputs.emplace_back(
"PHS",
"ROMode", 0, Lifetime::Timeframe);
193 std::vector<o2::framework::InputSpec> inputs;
194 inputs.emplace_back(
"collisioncontext",
"SIM",
"COLLISIONCONTEXT",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
206 AlgorithmSpec{o2::framework::adaptFromTask<DigitizerSpec>()},
207 Options{{
"pileup", VariantType::Int, 1, {
"whether to run in continuous time mode"}},
208 {
"mctruth", VariantType::Bool,
true, {
"whether to process MC info"}}}};
o2::framework::DataAllocator::SubSpecificationType SubSpecificationType
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.
static const PHOSSimParams & Instance()
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.
void run(framework::ProcessingContext &ctx)
run digitizer
void initDigitizerTask(framework::InitContext &ctx) final
init digitizer
long runStartTime() const
void setRunStartTime(long t)
void processHits(const std::vector< Hit > *mHits, const std::vector< Digit > &digitsBg, std::vector< Digit > &digitsOut, o2::dataformats::MCTruthContainer< MCLabel > &mLabels, int source, int entry, double dt)
Steer conversion of hits to digits.
bool initSimChains(o2::detectors::DetID detid, std::vector< TChain * > &simchains) const
GLsizei GLsizei GLchar * source
constexpr o2::header::DataOrigin gDataOriginPHS
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 getPHOSDigitizerSpec(int channel, bool mctruth)
Create new digitizer spec.
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"