Project
Loading...
Searching...
No Matches
o2sim_mctracks_to_aod.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12// #include "O2RivetExporter.h"
13#include "../Detectors/AOD/include/AODProducerWorkflow/AODMcProducerHelpers.h"
17
18template <typename T>
20
25 // using Particles = o2::aod::McParticles; //
26 using Particles = o2::aod::StoredMcParticles_001;
27 using XSections = o2::aod::HepMCXSections;
28 using PdfInfos = o2::aod::HepMCPdfInfos;
29 using HeavyIons = o2::aod::HepMCHeavyIons;
48 Configurable<float> IR{"interaction-rate", 100.f,
49 "Interaction rate to simulate"};
50 Configurable<bool> filt{"filter-mctracks", false,
51 "Filter tracks"};
52 Configurable<uint64_t> tfOffset{"tf-offset", 0, "Start TF counter from an offset"};
59
69
72 {
73 LOG(detail) << "=== Running extended MC AOD exporter ===";
74 using namespace o2::aodmchelpers;
75 using McHeader = o2::dataformats::MCEventHeader;
76 using McTrack = o2::MCTrack;
77 using McTracks = std::vector<McTrack>;
78
79 auto nParts = pc.inputs().getNofParts(0);
80 auto nPartsVerify = pc.inputs().getNofParts(1);
81
84
85 if (nParts != nPartsVerify) {
86 LOG(warn) << "Mismatch between number of MC headers and "
87 << "number of track vectors: " << nParts
88 << " != " << nPartsVerify
89 << ", shipping the empty timeframe";
90 pc.outputs().snapshot(Output{"TFF", "TFFilename", 0}, "");
91 pc.outputs().snapshot(Output{"TFN", "TFNumber", 0}, ++mTimeFrame);
92 return;
93 }
94 // TODO: include BC simulation
95 auto bcCounter = 0UL;
96 size_t offset = 0;
97 LOG(detail) << "--- Loop over " << nParts << " parts ---";
98 for (auto i = 0U; i < nParts; ++i) {
99 auto record = mSampler.generateCollisionTime();
100 auto header = pc.inputs().get<McHeader*>("mcheader", i);
101 auto tracks = pc.inputs().get<McTracks>("mctracks", i);
102
103 LOG(detail) << "Updating collision table";
104 auto genID = updateMCCollisions(mCollisions.cursor,
105 bcCounter,
106 record.timeInBCNS * 1.e-3,
107 *header,
108 0,
109 i);
110
111 LOG(detail) << "Updating HepMC tables";
112 updateHepMCXSection(mXSections.cursor, bcCounter, genID, *header);
113 updateHepMCPdfInfo(mPdfInfos.cursor, bcCounter, genID, *header);
114 updateHepMCHeavyIon(mHeavyIons.cursor, bcCounter, genID, *header);
115
116 LOG(detail) << "Updating particles table";
117 TrackToIndex preselect;
118 offset = updateParticles(mParticles.cursor,
119 bcCounter,
120 tracks,
121 preselect,
122 offset,
123 (bool)filt,
124 false);
125
126 LOG(detail) << "Increment BC counter";
127 bcCounter++;
128 }
129
130 pc.outputs().snapshot(Output{"TFF", "TFFilename", 0}, "");
131 pc.outputs().snapshot(Output{"TFN", "TFNumber", 0}, ++mTimeFrame);
132 }
133};
134
142
144{
146
147 auto spec = adaptAnalysisTask<MctracksToAod>(cfgc);
148 spec.inputs.emplace_back("mctracks", "MC", "MCTRACKS", 0.,
149 Lifetime::Timeframe);
150 spec.inputs.emplace_back("mcheader", "MC", "MCHEADER", 0.,
151 Lifetime::Timeframe);
152 spec.outputs.emplace_back("TFF", "TFFilename");
153 spec.outputs.emplace_back("TFN", "TFNumber");
154
155 return {spec};
156}
157//
158// EOF
159//
std::vector< std::string > header
int32_t i
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
std::vector< o2::its::TrackITS > tracks
void snapshot(const Output &spec, T const &object)
decltype(auto) get(R binding, int part=0) const
size_t getNofParts(int pos) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
void setFirstIR(const o2::InteractionRecord &ir)
const o2::InteractionTimeRecord & generateCollisionTime()
void setInteractionRate(float rateHz)
GLintptr offset
Definition glcorearb.h:660
McCollisions_001 McCollisions
std::unordered_map< int, int > TrackToIndex
DataProcessorSpec adaptAnalysisTask(ConfigContext const &ctx, Args &&... args)
Lifetime
Possible Lifetime of objects being exchanged by the DPL.
Definition Lifetime.h:18
std::vector< DataProcessorSpec > WorkflowSpec
MCTrackT< float > MCTrack
Definition MCTrack.h:453
o2::framework::WorkflowSpec WorkflowSpec
WorkflowSpec defineDataProcessing(ConfigContext const &cfgc)
This function hooks up the the workflow specifications into the DPL driver.
o2::framework::Produces< Particles > mParticles
InteractionSampler mSampler
o2::framework::Produces< PdfInfos > mPdfInfos
o2::framework::Produces< Collisions > mCollisions
o2::aod::HepMCXSections XSections
o2::aod::HepMCPdfInfos PdfInfos
o2::framework::Produces< HeavyIons > mHeavyIons
o2::aod::HepMCHeavyIons HeavyIons
o2::aod::McCollisions Collisions
Configurable< uint64_t > tfOffset
void init(o2::framework::InitContext &)
o2::aod::StoredMcParticles_001 Particles
Configurable< bool > filt
o2::framework::Produces< XSections > mXSections
void run(o2::framework::ProcessingContext &pc)
Struct to differentiate task names from possible task string arguments.
decltype(FFL(std::declval< cursor_t >())) cursor
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"