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"};
56 uint64_t mTimeFrame = 0;
59
69
72 {
73 LOG(debug) << "=== 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 for (auto i = 0U; i < nParts; ++i) {
98 LOG(debug) << "--- Loop over " << nParts << " parts ---";
99
100 auto record = mSampler.generateCollisionTime();
101 auto header = pc.inputs().get<McHeader*>("mcheader", i);
102 auto tracks = pc.inputs().get<McTracks>("mctracks", i);
103
104 LOG(debug) << "Updating collision table";
105 auto genID = updateMCCollisions(mCollisions.cursor,
106 bcCounter,
107 record.timeInBCNS * 1.e-3,
108 *header,
109 0,
110 i);
111
112 LOG(debug) << "Updating HepMC tables";
113 updateHepMCXSection(mXSections.cursor, bcCounter, genID, *header);
114 updateHepMCPdfInfo(mPdfInfos.cursor, bcCounter, genID, *header);
115 updateHepMCHeavyIon(mHeavyIons.cursor, bcCounter, genID, *header);
116
117 LOG(debug) << "Updating particles table";
118 TrackToIndex preselect;
119 offset = updateParticles(mParticles.cursor,
120 bcCounter,
121 tracks,
122 preselect,
123 offset,
124 (bool)filt,
125 false);
126
127 LOG(debug) << "Increment BC counter";
128 bcCounter++;
129 }
130
131 pc.outputs().snapshot(Output{"TFF", "TFFilename", 0}, "");
132 pc.outputs().snapshot(Output{"TFN", "TFNumber", 0}, ++mTimeFrame);
133 }
134};
135
143
145{
147
148 auto spec = adaptAnalysisTask<MctracksToAod>(cfgc);
149 spec.inputs.emplace_back("mctracks", "MC", "MCTRACKS", 0.,
150 Lifetime::Timeframe);
151 spec.inputs.emplace_back("mcheader", "MC", "MCHEADER", 0.,
152 Lifetime::Timeframe);
153 spec.outputs.emplace_back("TFF", "TFFilename");
154 spec.outputs.emplace_back("TFN", "TFNumber");
155
156 return {spec};
157}
158//
159// EOF
160//
int32_t i
std::ostringstream debug
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:444
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"