forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patho2aod_mc_to_hepmc.cxx
165 lines (155 loc) · 5.77 KB
/
o2aod_mc_to_hepmc.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Copyright 2023-2099 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/** @author Christian Holm Christensen <[email protected]> */
#include <Framework/AnalysisHelpers.h>
#include <Framework/AnalysisTask.h>
#include <Generators/AODToHepMC.h>
//--------------------------------------------------------------------
/** Task to convert AOD MC tables into HepMC event structure
*
* This assumes that the following tables are available on the input:
*
* - @c o2::aod::McCollisions
* - @c o2::aod::McParticles
* - @c o2::aod::HepMCXSections
* - @c o2::aod::HepMCPdfInfos
* - @c o2::aod::HepMCHeavyIons
*
* The application @c o2-sim-mcevent-to-aod publishes these tables.
*
* Ideally, this application should work with the case where only
*
* - @c o2::aod::McCollisions
* - @c o2::aod::McParticles
*
* This is selected by the option `--hepmc-no-aux`
*
* The thing to remember here, is that each task process is expected
* to do a _complete_ job. That is, a process _cannot_ assume that
* another process has been called before-hand or will be called
* later, for the same event in the same order.
*
* That is, each process will get _all_ events of a time-frame and
* then the next process will get _all_ events of the time-frame.
*
* Processed do not process events piece-meal, but rather in whole.
*
*/
struct AodToHepmc {
/** Alias the converter type */
using Converter = o2::eventgen::AODToHepMC;
/** Our converter */
Converter mConverter;
/** @{
* @name Container types */
/** Alias converter header table type */
using Headers = Converter::Headers;
/** Alias converter header type */
using Header = Converter::Header;
/** Alias converter track table type */
using Tracks = Converter::Tracks;
/** Alias converter cross-section table type */
using XSections = Converter::XSections;
/** Alias converter cross-section type */
using XSection = Converter::XSection;
/** Alias converter parton distribution function table type */
using PdfInfos = Converter::PdfInfos;
/** Alias converter parton distribution function type */
using PdfInfo = Converter::PdfInfo;
/** Alias converter heavy-ions table type */
using HeavyIons = Converter::HeavyIons;
/** Alias converter heavy-ions type */
using HeavyIon = Converter::HeavyIon;
/** @} */
/** Initialize the job */
void init(o2::framework::InitContext& ic)
{
mConverter.init();
}
/** Processing of event to extract extra HepMC information
*
* @param collision Event header
* @param tracks Tracks of the event
* @param xsections Cross-section information
* @param pdf Cross-section information
* @param heavyions Heavy ion (geometry) information
*/
void process(Header const& collision,
Tracks const& tracks,
XSections const& xsections,
PdfInfos const& pdfs,
HeavyIons const& heavyions)
{
// Do not run this if --hepmc-no-aux was passed
if (doPlain) {
return;
}
LOG(debug) << "=== Processing everything ===";
mConverter.startEvent();
mConverter.process(collision,
xsections,
pdfs,
heavyions);
mConverter.process(collision, tracks);
mConverter.endEvent();
}
/** Processing of an event for particles only
*
* @param collision Event header
* @param tracks Tracks of the event
*/
void processPlain(Header const& collision,
Tracks const& tracks)
{
// Do not run this if --hepmc-no-aux was not passed
if (not doPlain) {
return;
}
LOG(debug) << "=== Processing only tracks ===";
mConverter.startEvent();
mConverter.process(collision, tracks);
mConverter.endEvent();
}
/**
* Make a process option.
*
* Instead of using the provided preprocessor macro, we instantise
* the template directly here. This is so that we can specify the
* command line argument (@c --hepmc-no-aux) rather than to rely on an
* auto-generated name (would be @c --processPlain).
*/
decltype(o2::framework::ProcessConfigurable{&AodToHepmc::processPlain,
"hepmc-no-aux", false,
"Do not process auxiliary "
"information"})
doPlain = o2::framework::ProcessConfigurable{&AodToHepmc::processPlain,
"hepmc-no-aux", false,
"Do not process auxiliary "
"information"};
};
//--------------------------------------------------------------------
// This _must_ be included after our "customize" function above, or
// that function will not be taken into account.
#include <Framework/runDataProcessing.h>
//--------------------------------------------------------------------
using WorkflowSpec = o2::framework::WorkflowSpec;
using DataProcessorSpec = o2::framework::DataProcessorSpec;
using ConfigContext = o2::framework::ConfigContext;
/** Entry point of @a o2-sim-mcevent-to-hepmc */
WorkflowSpec defineDataProcessing(ConfigContext const& cfg)
{
using o2::framework::adaptAnalysisTask;
// Task: Two entry: header, tracks, and header, tracks, auxiliary
return WorkflowSpec{adaptAnalysisTask<AodToHepmc>(cfg)};
}
//
// EOF
//