31 mLPMProdTag = ic.
options().
get<std::string>(
"lpmp-prod-tag");
32 mAnchorPass = ic.
options().
get<std::string>(
"anchor-pass");
33 mAnchorProd = ic.
options().
get<std::string>(
"anchor-prod");
34 mRecoPass = ic.
options().
get<std::string>(
"reco-pass");
35 mTFNumber = ic.
options().
get<int64_t>(
"aod-timeframe-id");
36 mFilterMC = ic.
options().
get<
int>(
"filter-mctracks");
37 int truncate = ic.
options().
get<
int>(
"enable-truncation");
38 if (mTFNumber == -1L) {
39 LOG(info) <<
"TFNumber will be obtained from CCDB";
44 LOG(info) <<
"Truncation is not used!";
45 mCollisionPosition = 0xFFFFFFFF;
46 mMcParticleW = 0xFFFFFFFF;
47 mMcParticlePos = 0xFFFFFFFF;
48 mMcParticleMom = 0xFFFFFFFF;
51 mEnableEmbed = ic.
options().
get<
bool>(
"enable-embedding");
55 mSimPrefix = ic.
options().
get<std::string>(
"mckine-fname");
57 std::string hepmcUpdate = ic.
options().
get<std::string>(
"hepmc-update");
60 : hepmcUpdate ==
"always"
62 : hepmcUpdate ==
"all"
63 ? HepMCUpdate::allKeys
64 : HepMCUpdate::anyKey);
65 mXSectionUpdate = when;
66 mPdfInfoUpdate = when;
67 mHeavyIonUpdate = when;
73void AODMcProducerWorkflowDPL::updateHeader(CollisionCursor& collisionCursor,
74 XSectionCursor& xSectionCursor,
75 PdfInfoCursor& pdfInfoCursor,
76 HeavyIonCursor& heavyIonCursor,
77 const MCEventHeader& header,
89 auto genID = updateMCCollisions(collisionCursor,
96 mXSectionUpdate = (updateHepMCXSection(xSectionCursor,
101 ? HepMCUpdate::always
102 : HepMCUpdate::never);
103 mPdfInfoUpdate = (updateHepMCPdfInfo(pdfInfoCursor,
108 ? HepMCUpdate::always
109 : HepMCUpdate::never);
110 mHeavyIonUpdate = (updateHepMCHeavyIon(heavyIonCursor,
115 ? HepMCUpdate::always
116 : HepMCUpdate::never);
129 auto collisionsCursor = createTableCursor<McCollisions>(pc);
130 auto particlesCursor = createTableCursor<McParticles>(pc);
131 auto originCursor = createTableCursor<Origins>(pc);
132 auto xSectionCursor = createTableCursor<XSections>(pc);
133 auto pdfInfoCursor = createTableCursor<PdfInfos>(pc);
134 auto heavyIonCursor = createTableCursor<HeavyIons>(pc);
137 std::unique_ptr<MCKinematicsReader> reader;
138 if (not mEnableEmbed) {
140 std::make_unique<MCKinematicsReader>(mSimPrefix,
143 reader = std::make_unique<MCKinematicsReader>(
"collisioncontext.root");
147 using EventInfo = std::vector<std::tuple<int, int, int>>;
154 if (not mEnableEmbed) {
157 int nSources = reader->getNSources();
158 for (
int isrc = 0; isrc < nSources; isrc++) {
159 short generatorID = isrc;
160 int nEvents = reader->getNEvents(isrc);
161 for (
int ievt = 0; ievt <
nEvents; ievt++) {
162 auto&
header = reader->getMCEventHeader(isrc, ievt);
163 updateHeader(collisionsCursor.cursor,
164 xSectionCursor.cursor,
165 pdfInfoCursor.cursor,
166 heavyIonCursor.cursor,
174 eventInfo.emplace_back(std::make_tuple(icol, isrc, ievt));
182 int nCollisions = reader->getDigitizationContext()->getNCollisions();
183 const auto&
records = reader->getDigitizationContext()->getEventRecords();
184 const auto& parts = reader->getDigitizationContext()->getEventParts();
185 for (
int icol = 0; icol < nCollisions; icol++) {
186 auto& colParts = parts[icol];
187 auto nParts = colParts.size();
188 for (
auto colPart : colParts) {
189 auto eventID = colPart.entryID;
190 auto sourceID = colPart.sourceID;
193 if (nParts == 1 || sourceID == 0) {
195 short generatorID = sourceID;
196 auto&
header = reader->getMCEventHeader(sourceID, eventID);
198 updateHeader(collisionsCursor.cursor,
199 xSectionCursor.cursor,
200 pdfInfoCursor.cursor,
201 heavyIonCursor.cursor,
210 eventInfo.emplace_back(std::make_tuple(icol, sourceID, eventID));
216 std::sort(eventInfo.begin(), eventInfo.end(),
217 [](
typename EventInfo::const_reference
left,
218 typename EventInfo::const_reference
right) {
219 return (std::get<0>(left) < std::get<0>(right));
224 for (
auto& colInfo : eventInfo) {
225 int event = std::get<2>(colInfo);
226 int source = std::get<1>(colInfo);
227 int collisionID = std::get<0>(colInfo);
231 offset = updateParticles(particlesCursor.cursor,
242 reader->releaseTracksForSourceAndEvent(
source,
event);
246 originCursor(tfNumber);
251 std::vector<TString> metaDataKeys = {
"DataType",
259 std::vector<TString> metaDataVals = {
"MC",
283 LOGF(info,
"aod producer dpl total timing: Cpu: %.3e Real: %.3e s in %d slots",
284 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
296 std::vector<OutputSpec> outputs{
309 "aod-mc-producer-workflow",
314 ConfigParamSpec{
"aod-timeframe-id", VariantType::Int64, 1L, {
"Set timeframe number"}},
315 ConfigParamSpec{
"enable-truncation", VariantType::Int, 1, {
"Truncation parameter: 1 -- on, != 1 -- off"}},
316 ConfigParamSpec{
"lpmp-prod-tag", VariantType::String,
"", {
"LPMProductionTag"}},
317 ConfigParamSpec{
"anchor-pass", VariantType::String,
"", {
"AnchorPassName"}},
318 ConfigParamSpec{
"anchor-prod", VariantType::String,
"", {
"AnchorProduction"}},
319 ConfigParamSpec{
"reco-pass", VariantType::String,
"", {
"RecoPassName"}},
320 ConfigParamSpec{
"filter-mctracks", VariantType::Int, 1, {
"Store only physical primary MC tracks and their mothers/daughters. 0 -- off, != 0 -- on"}},
321 ConfigParamSpec{
"enable-embedding", VariantType::Int, 0, {
"Use collisioncontext.root to process embedded events"}},
322 ConfigParamSpec{
"mckine-fname", VariantType::String,
"o2sim", {
"MC kinematics file name prefix: e.g. 'o2sim', 'bkg', 'sgn_1'. Used only if 'enable-embedding' is 0"}},
323 ConfigParamSpec{
"hepmc-update", VariantType::String,
"always", {
"When to update HepMC Aux tables: always - force update, never - never update, all - if all keys are present, any - when any key is present (not valid yet)"}}}};
std::vector< o2::soa::IndexRecord > records
std::vector< std::string > header
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
Utility functions for MC particles.
void init(InitContext &ic) final
void endOfStream(EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(ProcessingContext &pc) final
aod::HepMCXSections XSections
aod::StoredMcParticles McParticles
aod::HepMCHeavyIons HeavyIons
aod::HepMCPdfInfos PdfInfos
aod::McCollisions McCollisions
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
ServiceRegistryRef services()
The services registry associated with this processing context.
GLsizei GLsizei GLchar * source
bool updateHepMCHeavyIon(const HeavyIonCursor &cursor, int collisionID, short generatorID, o2::dataformats::MCEventHeader const &header, HepMCUpdate when=HepMCUpdate::anyKey)
std::unordered_map< int, int > TrackToIndex
short updateMCCollisions(const CollisionCursor &cursor, int bcId, float time, o2::dataformats::MCEventHeader const &header, short generatorId=0, int sourceId=0, unsigned int mask=0xFFFFFFF0)
bool updateHepMCPdfInfo(const PdfInfoCursor &cursor, int collisionID, short generatorID, o2::dataformats::MCEventHeader const &header, HepMCUpdate when=HepMCUpdate::anyKey)
bool updateHepMCXSection(const XSectionCursor &cursor, int collisionID, short generatorID, o2::dataformats::MCEventHeader const &header, HepMCUpdate when=HepMCUpdate::anyKey)
framework::DataProcessorSpec getAODMcProducerWorkflowSpec()
create a processor spec
Defining ITS Vertex explicitly as messageable.
std::vector< InputSpec > Inputs
std::string fullVersion()
get full version information (official O2 release and git commit)
static constexpr auto spec()
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"