19#include "TStopwatch.h"
51 TOFDPLDigitizerTask(
bool useCCDB, std::string ccdb_url,
int timestamp) : mUseCCDB{useCCDB}, mCCDBurl(ccdb_url), mTimestamp(timestamp),
o2::base::
BaseDPLDigitizer(
o2::base::InitServices::FIELD |
o2::base::InitServices::GEOM), mPass(
o2::conf::DigiParams::Instance().passName){};
55 LOG(info) <<
"Initializing TOF digitization";
57 mSimChains = std::move(std::make_unique<std::vector<TChain*>>());
60 mDigitizer = std::move(std::make_unique<o2::tof::Digitizer>());
62 mDigits = std::move(std::make_unique<std::vector<o2::tof::Digit>>());
67 const bool isContinuous = ic.
options().
get<
int>(
"pileup");
68 LOG(info) <<
"CONTINUOUS " << isContinuous;
69 mDigitizer->setContinuous(isContinuous);
70 mDigitizer->setMCTruthContainer(mLabels.get());
71 LOG(info) <<
"TOF initialization done";
100 static bool finished =
false;
110 LOG(
debug) <<
"GOT " << timesview.size() <<
" COLLISSION TIMES";
115 if (timesview.size() == 0) {
122 LOG(info) <<
" CALLING TOF DIGITIZATION ";
133 if (tofParams->getSize(mPass) < 0) {
134 LOG(info) <<
"Pass " << mPass <<
" requested but not found in the tofParams object -> using unanchored";
135 mPass =
"unanchored";
138 if (tofParams->getSize(mPass) < 0) {
139 LOG(fatal) <<
"Pass " << mPass <<
" not found in the tofParams object (stop here!)";
141 const auto&
params = tofParams->getPars(mPass);
142 if (
params.count(
"time_resolution")) {
143 mDigitizer->setResolution(
params.at(
"time_resolution"));
144 LOG(info) <<
"time_resolution load from ccdb -> " <<
params.at(
"time_resolution");
146 if (
params.count(
"eff_center")) {
147 mDigitizer->setEffCenter(
params.at(
"eff_center"));
148 LOG(info) <<
"eff_center load from ccdb -> " <<
params.at(
"eff_center");
150 if (
params.count(
"eff_boundary1")) {
151 mDigitizer->setEffBoundary1(
params.at(
"eff_boundary1"));
152 LOG(info) <<
"eff_boundary1 load from ccdb -> " <<
params.at(
"eff_boundary1");
154 if (
params.count(
"eff_boundary2")) {
155 mDigitizer->setEffBoundary2(
params.at(
"eff_boundary2"));
156 LOG(info) <<
"eff_boundary2 load from ccdb -> " <<
params.at(
"eff_boundary2");
158 if (
params.count(
"eff_boundary3")) {
159 mDigitizer->setEffBoundary3(
params.at(
"eff_boundary3"));
160 LOG(info) <<
"eff_boundary3 load from ccdb -> " <<
params.at(
"eff_boundary3");
176 LOG(info) <<
"Update CCDB objects since new";
190 }
else if (!mCalibApi) {
194 lhcPhaseDummy->addLHCphase(0, 0);
195 lhcPhaseDummy->addLHCphase(2000000000, 0);
198 channelCalibDummy->addTimeSlewingInfo(ich, 0, 0);
201 channelCalibDummy->setFractionUnderPeak(sector, channelInSector, 1);
206 mCalibApi->
setURL(mCCDBurl);
214 mDigitizer->setCalibApi(mCalibApi);
218 static std::vector<o2::tof::HitType> hits;
220 auto& eventParts = context->getEventParts();
224 for (
int collID = 0; collID < timesview.size(); ++collID) {
227 mDigitizer->setEventTime(
orbit);
231 for (
auto& part : eventParts[collID]) {
232 mDigitizer->setEventID(part.entryID);
233 mDigitizer->setSrcID(part.sourceID);
237 context->retrieveHits(*mSimChains.get(),
"TOFHit", part.sourceID, part.entryID, &hits);
244 mDigitizer->process(&hits, mDigits.get());
247 if (mDigitizer->isContinuous()) {
248 LOG(info) <<
"clear all";
251 LOG(info) <<
"finalize";
252 mDigitizer->flushOutputContainer(*mDigits.get());
255 std::vector<Digit>* digitsVector = mDigitizer->getDigitPerTimeFrame();
256 std::vector<ReadoutWindowData>* readoutwindow = mDigitizer->getReadoutWindowData();
257 std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>* mcLabVecOfVec = mDigitizer->getMCTruthPerTimeFrame();
259 LOG(info) <<
"Post " << digitsVector->size() <<
" digits in " << readoutwindow->size() <<
" RO windows";
263 if (pc.
outputs().
isAllowed({o2::header::gDataOriginTOF,
"DIGITSMCTR", 0})) {
269 std::vector<uint8_t>& patterns = mDigitizer->getPatterns();
272 DigitHeader& digitH = mDigitizer->getDigitHeader();
275 LOG(info) <<
"TOF: Sending ROMode= " << roMode <<
" to GRPUpdater";
279 LOG(info) <<
"Digitization took " << timer.CpuTime() <<
"s";
289 LOGF(
debug,
"TOF Digitizer endOfStream");
293 std::unique_ptr<std::vector<TChain*>> mSimChains;
294 std::unique_ptr<o2::tof::Digitizer> mDigitizer;
295 std::unique_ptr<std::vector<o2::tof::Digit>> mDigits;
296 std::unique_ptr<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> mLabels;
297 bool mUseCCDB =
false;
298 std::string mCCDBurl;
300 bool mUpdateCCDB =
false;
312 std::vector<InputSpec> inputs;
313 inputs.emplace_back(
"collisioncontext",
"SIM",
"COLLISIONCONTEXT",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
320 inputs.emplace_back(
"tofccdbStatus",
"TOF",
"StatusTOF", 0, Lifetime::Condition,
ccdbParamSpec(
"TOF/Calib/FEELIGHT"));
321 inputs.emplace_back(
"tofccdbDia",
"TOF",
"DiagnosticCal", 0, Lifetime::Condition,
ccdbParamSpec(
"TOF/Calib/Diagnostic"));
322 inputs.emplace_back(
"tofccdbLHCphase",
"TOF",
"LHCphaseCal", 0, Lifetime::Condition,
ccdbParamSpec(
"TOF/Calib/LHCphase"));
323 inputs.emplace_back(
"tofccdbChannelCalib",
"TOF",
"ChannelCalibCal", 0, Lifetime::Condition,
ccdbParamSpec(
"TOF/Calib/ChannelCalib"));
324 inputs.emplace_back(
"tofccdbParams",
"TOF",
"parameters", 0, Lifetime::Condition,
ccdbParamSpec(
"TOF/Calib/Params"));
327 std::vector<OutputSpec> outputs;
340 AlgorithmSpec{adaptFromTask<TOFDPLDigitizerTask>(useCCDB, ccdb_url, timestamp)},
341 Options{{
"pileup", VariantType::Int, 1, {
"whether to run in continuous time mode"}}}
Definition of the base digitizer task class.
Class to store the output of the matching to TOF for calibration.
Class to use TOF calibration (decalibration, calibration)
Class to store the output of the matching to TOF for calibration.
Definition of the GeometryManager class.
o2::framework::DataAllocator::SubSpecificationType SubSpecificationType
Header of the General Run Parameters object.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definitions of the containers for the general parameters.
BaseDPLDigitizer()=default
static const HBFUtils & 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.
bool initSimChains(o2::detectors::DetID detid, std::vector< TChain * > &simchains) const
std::vector< o2::InteractionTimeRecord > & getEventRecords(bool withQED=false)
void loadDiagnosticFrequencies()
void readDiagnosticFrequencies()
void readTimeSlewingParam()
void setTimeStamp(long t)
void loadActiveMap(TOFFEElightInfo *fee)
void setURL(const std::string url)
Diagnostic class for TOF.
Class container to hold different parameters meant to be stored on the CCDB.
void initDigitizerTask(framework::InitContext &ic) override
void endOfStream(EndOfStreamContext &ec)
TOFDPLDigitizerTask(bool useCCDB, std::string ccdb_url, int timestamp)
void finaliseCCDB(o2::framework::ConcreteDataMatcher matcher, void *obj)
void run(framework::ProcessingContext &pc)
GLenum const GLfloat * params
constexpr o2::header::DataOrigin gDataOriginTOF
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 getTOFDigitizerSpec(int channel, bool useCCDB, bool mctruth, std::string ccdb_url, int timestamp)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"