27#include "TStopwatch.h"
77 targetbr->ResetAddress();
78 targetbr->DropBaskets(
"all");
81void writeToBranchHelper<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>(TTree&
tree,
87 accum->clear_andfreememory();
91 targetbr->ResetAddress();
92 targetbr->DropBaskets(
"all");
105 LOG(info) <<
"Initializing TPC digitization";
110 auto triggeredMode = ic.
options().
get<
bool>(
"TPCtriggered");
111 mConditions.
init(ic, mDistortionType);
116 if (ic.
options().
get<
bool>(
"tpc-sector-seeding")) {
119 LOG(warning) <<
"TPC sector seeding with DigiParams.seed=0 is not reproducible";
123 LOG(info) <<
"TPC: using sector seeding";
131 if (mInternalWriter) {
140 std::stringstream tmp;
141 tmp <<
"tpc_driftime_digits_lane" << mLaneId <<
".root";
142 if (std::filesystem::exists(tmp.str())) {
143 std::filesystem::remove(tmp.str());
149 if (!mInternalROOTFlushFile) {
150 std::stringstream tmp;
151 tmp <<
"tpc_driftime_digits_lane" << mLaneId <<
".root";
152 mInternalROOTFlushFile =
new TFile(tmp.str().c_str(),
"UPDATE");
153 std::stringstream trname;
155 mInternalROOTFlushTTree =
new TTree(trname.str().c_str(),
"o2sim");
158 std::stringstream brname;
159 brname <<
"TPCDigit_" << mSector;
166 std::stringstream brname;
167 brname <<
"TPCDigitMCTruth_" << mSector;
174 std::stringstream brname;
175 brname <<
"TPCCommonMode_" << mSector;
189 LOG(info) <<
"Processing TPC digitization";
191 mConditions.
update(pc, mDigitizer, [
this](
float vdrift,
float tdriftOffset) {
197 for (
auto const& inputref : it.parts()) {
198 if (inputref.spec->lifetime == o2::framework::Lifetime::Condition) {
202 if (mInternalWriter) {
203 mInternalROOTFlushTTree->SetEntries(mFlushCounter);
204 mInternalROOTFlushFile->Write(
"", TObject::kOverwrite);
205 mInternalROOTFlushFile->Close();
207 delete mInternalROOTFlushFile;
208 mInternalROOTFlushFile =
nullptr;
221 context->
initSimChains(o2::detectors::DetID::TPC, mSimChains);
222 auto& irecords = context->getEventRecords();
227 LOG(info) <<
"TPC: Processing " << irecords.size() <<
" collisions";
228 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(inputref);
235 <<
" to GRPUpdater from channel " << dh->subSpecification;
241 auto const* sectorHeader = DataRefUtils::getHeader<TPCSectorHeader*>(inputref);
242 if (sectorHeader ==
nullptr) {
243 LOG(
error) <<
"TPC: Sector header missing, skipping processing";
246 auto sector = sectorHeader->sector();
248 mListOfSectors.push_back(
sector);
249 LOG(info) <<
"TPC: Processing sector " <<
sector;
252 activeSectors = sectorHeader->activeSectors;
255 auto makeDigitBuffer = [
this,
sector, &pc, activeSectors, &dh]() {
257 header.activeSectors = activeSectors;
258 if (mInternalWriter) {
259 using ContainerType = std::decay_t<
decltype(pc.
outputs().
make<std::vector<o2::tpc::Digit>>(
Output{
"",
"", 0}))>*;
260 return ContainerType(
nullptr);
267 auto snapshotCommonMode = [
this,
sector, &pc, activeSectors, &dh](std::vector<o2::tpc::CommonMode>
const& commonMode) {
269 header.activeSectors = activeSectors;
270 if (!mInternalWriter) {
273 const_cast<std::vector<o2::tpc::CommonMode>&
>(commonMode));
279 header.activeSectors = activeSectors;
281 if (!mInternalWriter) {
283 labels.flatten_to(sharedlabels);
288 auto snapshotEvents = [
this,
sector, &pc, activeSectors, &dh](
const std::vector<DigiGroupRef>&
events) {
290 header.activeSectors = activeSectors;
291 if (!mInternalWriter) {
292 LOG(info) <<
"TPC: Send TRIGGERS for sector " <<
sector <<
" channel " << dh->subSpecification <<
" | size " <<
events.size();
294 const_cast<std::vector<DigiGroupRef>&
>(
events));
298 auto digitsAccum = makeDigitBuffer();
300 std::vector<CommonMode> commonModeAccum;
301 std::vector<DigiGroupRef> eventAccum;
306 throw std::runtime_error(
"Legacy control information is not expected any more");
313 throw std::runtime_error(
"Digitizer can only work on single sectors");
319 auto onFlush = [
this, digitsAccum, &labelAccum, &commonModeAccum]() {
321 if (mInternalWriter) {
326 std::copy(mFlushBuffers.
digits.begin(), mFlushBuffers.
digits.end(), std::back_inserter(*digitsAccum));
330 std::copy(mFlushBuffers.
commonMode.begin(), mFlushBuffers.
commonMode.end(), std::back_inserter(commonModeAccum));
333 eventAccum =
digitizeSector(mDigitizer, *context, mSimChains,
sector, dh->tfCounter, mFlushBuffers, onFlush);
335 if (!mInternalWriter) {
337 snapshotEvents(eventAccum);
339 snapshotCommonMode(commonModeAccum);
340 snapshotLabels(labelAccum);
344 LOG(info) <<
"TPC: Digitization took " << timer.CpuTime() <<
"s";
350 std::vector<TChain*> mSimChains;
352 std::vector<int> mListOfSectors;
353 TFile* mInternalROOTFlushFile =
nullptr;
354 TTree* mInternalROOTFlushTTree =
nullptr;
355 size_t mFlushCounter = 0;
358 bool mWriteGRP =
false;
359 bool mWithMCTruth =
true;
360 bool mInternalWriter =
false;
361 int mDistortionType = 0;
371 std::stringstream
id;
372 id <<
"TPCDigitizer" << channel;
374 std::vector<OutputSpec> outputs;
376 if (!internalwriter) {
377 outputs.emplace_back(
"TPC",
"DIGITS",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
378 outputs.emplace_back(
"TPC",
"DIGTRIGGERS",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
380 outputs.emplace_back(
"TPC",
"DIGITSMCTR",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
382 outputs.emplace_back(
"TPC",
"COMMONMODE",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
385 outputs.emplace_back(
"TPC",
"ROMode", 0, Lifetime::Timeframe);
386 LOG(
debug) <<
"TPC: Channel " << channel <<
" will supply ROMode";
389 std::vector<InputSpec> inputs{
InputSpec{
"collisioncontext",
"SIM",
"COLLISIONCONTEXT",
static_cast<SubSpecificationType>(channel), Lifetime::Timeframe}};
391 options.push_back({
"tpc-sector-seeding", VariantType::Bool,
false, {
"Seed the random numbers of each sector from DigiParams.seed and the sector, so that the digits do not depend on the lane assignment"}});
396 AlgorithmSpec{adaptFromTask<TPCDPLDigitizerTask>(internalwriter, distortionType)},
408 pipelineTemplate[0].
name =
"TPCDigitizer";
410 pipelineTemplate, nLanes, [
size =
sectors.size()]() { return size; }, [&
sectors](
size_t index) { return sectors[index]; });
415 pipelines[0].outputs.emplace_back(
"TPC",
"ROMode", 0, Lifetime::Timeframe);
header::DataOrigin origin
Definition of the base digitizer task class.
Definition of the Detector class.
Simple interface to the CDB manager.
A const (ready only) version of MCTruthContainer.
std::vector< std::string > header
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate sectors
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char events
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to process
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Header of the General Run Parameters object.
char error[CURL_ERROR_SIZE]
A special IO container - splitting a given vector to enable ROOT IO.
std::vector< o2::MCCompLabel > labels
Definition of the parameter class for the GEM stack.
Class to refer to the 1st entry and N elements of some group in the continuous container.
This class contains the algorithms for calculation the distortions and corrections.
Definition of the ALICE TPC digitizer.
Helper class to extract VDrift from different sources.
static const DigiParams & Instance()
T get(const char *key) const
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
ServiceRegistryRef services()
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.
bool initSimChains(o2::detectors::DetID detid, std::vector< TChain * > &simchains) const
void setDistortionScaleType(int distortionScaleType)
void setUseSectorSeeding(ULong64_t seed)
void setContinuousReadout(bool isContinuous)
void setTDriftOffset(float t)
bool isContinuousReadout()
void initDigitizerTask(framework::InitContext &ic) override
void run(framework::ProcessingContext &pc)
void process(framework::ProcessingContext &pc, framework::DataRef const &inputref)
TPCDPLDigitizerTask(bool internalwriter, int distortionType)
void finaliseCCDB(framework::ConcreteDataMatcher &matcher, void *obj)
CCDB conditions and calibration files of the TPC digitizer devices.
static void addInputs(std::vector< framework::InputSpec > &inputs, int distortionType)
CCDB inputs common to the TPC digitizer devices.
bool finaliseCCDB(framework::ConcreteDataMatcher &matcher, void *obj, Digitizer &digitizer)
pass a CCDB object to the digitizer; true if it was a TPC condition
static std::vector< framework::ConfigParamSpec > options()
options common to the TPC digitizer devices
void init(framework::InitContext &ic, int distortionType)
void update(framework::ProcessingContext &pc, Digitizer &digitizer, const std::function< void(float, float)> &setVDrift)
GLuint const GLchar * name
TBranch * getOrMakeBranch(TTree &tree, const char *brname, T *ptr)
Defining ITS Vertex explicitly as messageable.
WorkflowSpec parallelPipeline(const WorkflowSpec &specs, size_t nPipelines, std::function< size_t()> getNumberOfSubspecs, std::function< size_t(size_t)> getSubSpec)
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< dataformats::RangeReference< int, int > > digitizeSector(Digitizer &digitizer, const steer::DigitizationContext &context, const std::vector< TChain * > &simChains, int sector, ULong64_t timeframe, SectorFlushBuffers &buffers, const std::function< void()> &onFlush)
void writeToBranchHelper(TTree &tree, const char *name, T *accum)
o2::framework::DataProcessorSpec getTPCDigitizerSpec(int channel, bool writeGRP, bool mctruth, bool internalwriter, int distortionType)
void copyHelper(T const &origin, R &target)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
class listing possible services
Output buffers of one flush of a sector.
std::vector< CommonMode > commonMode
std::vector< Digit > digits
dataformats::MCTruthContainer< MCCompLabel > labels
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))