forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventSelectionService.cxx
More file actions
188 lines (156 loc) · 7.03 KB
/
eventSelectionService.cxx
File metadata and controls
188 lines (156 loc) · 7.03 KB
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// Copyright 2019-2020 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.
/// \file eventSelectionTester.cxx
/// \brief unified, self-configuring event selection task
/// \author ALICE
//===============================================================
//
// Unified, self-configuring event selection task
//
//===============================================================
#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "Framework/runDataProcessing.h"
#include "Framework/RunningWorkflowInfo.h"
#include "Common/DataModel/TrackSelectionTables.h"
#include "Common/Core/trackUtilities.h"
#include "ReconstructionDataFormats/DCA.h"
#include "DetectorsBase/Propagator.h"
#include "DetectorsBase/GeometryManager.h"
#include "CommonUtils/NameConf.h"
#include "CCDB/CcdbApi.h"
#include "DataFormatsParameters/GRPMagField.h"
#include "CCDB/BasicCCDBManager.h"
#include "Framework/HistogramRegistry.h"
#include "DataFormatsCalibration/MeanVertexObject.h"
#include "CommonConstants/GeomConstants.h"
#include "Common/Tools/EventSelectionTools.h"
#include "MetadataHelper.h"
using namespace o2;
using namespace o2::framework;
MetadataHelper metadataInfo; // Metadata helper
using BCsWithRun2InfosTimestampsAndMatches = soa::Join<aod::BCs, aod::Run2BCInfos, aod::Timestamps, aod::Run2MatchedToBCSparse>;
using BCsWithRun3Matchings = soa::Join<aod::BCs, aod::Timestamps, aod::Run3MatchedToBCSparse>;
using FullTracks = soa::Join<aod::Tracks, aod::TracksExtra>;
using FullTracksIU = soa::Join<aod::TracksIU, aod::TracksExtra>;
struct eventselectionRun2 {
o2::common::eventselection::bcselConfigurables bcselOpts;
o2::common::eventselection::BcSelectionModule bcselmodule;
o2::common::eventselection::evselConfigurables evselOpts;
o2::common::eventselection::EventSelectionModule evselmodule;
Produces<aod::BcSels> bcsel;
Produces<aod::EvSels> evsel;
// for slicing
SliceCache cache;
// CCDB boilerplate declarations
o2::framework::Configurable<std::string> ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
Service<o2::ccdb::BasicCCDBManager> ccdb;
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
// the best: have readable cursors
// this: a stopgap solution to avoid spawning yet another device
std::vector<o2::common::eventselection::bcselEntry> bcselsbuffer;
// auxiliary
Partition<FullTracks> tracklets = (aod::track::trackType == static_cast<uint8_t>(o2::aod::track::TrackTypeEnum::Run2Tracklet));
Preslice<FullTracks> perCollision = aod::track::collisionId;
void init(o2::framework::InitContext&)
{
// CCDB boilerplate init
ccdb->setCaching(true);
ccdb->setLocalObjectValidityChecking();
ccdb->setURL(ccdburl.value);
// task-specific
bcselmodule.init(bcselOpts, histos);
evselmodule.init(evselOpts, histos, metadataInfo);
}
void process(BCsWithRun2InfosTimestampsAndMatches const& bcs,
aod::Collisions const& collisions,
aod::Zdcs const&,
aod::FV0As const&,
aod::FV0Cs const&,
aod::FT0s const&,
aod::FDDs const&,
FullTracks const&)
{
bcselmodule.processRun2(ccdb, bcs, bcselsbuffer, bcsel);
evselmodule.processRun2(ccdb, histos, collisions, tracklets, cache, bcselsbuffer, evsel);
}
};
struct eventselectionRun3 {
o2::common::eventselection::bcselConfigurables bcselOpts;
o2::common::eventselection::BcSelectionModule bcselmodule;
o2::common::eventselection::evselConfigurables evselOpts;
o2::common::eventselection::EventSelectionModule evselmodule;
o2::common::eventselection::LumiModule lumimodule;
Produces<aod::BcSels> bcsel;
Produces<aod::EvSels> evsel;
// for slicing
SliceCache cache;
// CCDB boilerplate declarations
o2::framework::Configurable<std::string> ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
Service<o2::ccdb::BasicCCDBManager> ccdb;
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
// the best: have readable cursors
// this: a stopgap solution to avoid spawning yet another device
std::vector<o2::common::eventselection::bcselEntry> bcselsbuffer;
// auxiliary
Partition<FullTracksIU> pvTracks = ((aod::track::flags & static_cast<uint32_t>(o2::aod::track::PVContributor)) == static_cast<uint32_t>(o2::aod::track::PVContributor));
Preslice<FullTracksIU> perCollisionIU = aod::track::collisionId;
void init(o2::framework::InitContext&)
{
// CCDB boilerplate init
ccdb->setCaching(true);
ccdb->setLocalObjectValidityChecking();
ccdb->setURL(ccdburl.value);
// task-specific
bcselmodule.init(bcselOpts, histos);
evselmodule.init(evselOpts, histos, metadataInfo);
lumimodule.init(histos);
}
void process(aod::Collisions const& collisions,
BCsWithRun3Matchings const& bcs,
aod::Zdcs const&,
aod::FV0As const&,
aod::FT0s const& ft0s, // to resolve iterator
aod::FDDs const&,
FullTracksIU const&)
{
bcselmodule.processRun3(ccdb, histos, bcs, bcselsbuffer, bcsel);
evselmodule.processRun3(ccdb, histos, bcs, collisions, pvTracks, ft0s, cache, bcselsbuffer, evsel);
lumimodule.process(ccdb, histos, bcs, bcselsbuffer);
}
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
// Parse the metadata for later too
metadataInfo.initMetadata(cfgc);
bool isRun3 = true, hasRunInfo = false;
if (cfgc.options().hasOption("aod-metadata-Run") == true) {
hasRunInfo = true;
if (cfgc.options().get<std::string>("aod-metadata-Run") == "2") {
isRun3 = false;
}
}
LOGF(info, "Event selection autoconfiguring from metadata. Availability of info for Run 2/3 is %i", hasRunInfo);
if (!hasRunInfo) {
LOGF(info, "Metadata info missing or incomplete. Make sure --aod-file is provided at the end of the last workflow and that the AO2D has metadata stored.");
LOGF(info, "Initializing with Run 3 data as default. Please note you will not be able to change settings manually.");
LOGF(info, "You should instead make sure the metadata is read in correctly.");
return WorkflowSpec{adaptAnalysisTask<eventselectionRun3>(cfgc)};
} else {
LOGF(info, "Metadata successfully read in. Is this Run 3? %i - will self-configure.", isRun3);
if (isRun3) {
return WorkflowSpec{adaptAnalysisTask<eventselectionRun3>(cfgc)};
} else {
return WorkflowSpec{adaptAnalysisTask<eventselectionRun2>(cfgc)};
}
}
throw std::runtime_error("Unsupported run type / problem when configuring event selection!");
}