forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventSelectionServiceRun2.cxx
More file actions
186 lines (150 loc) · 6.9 KB
/
eventSelectionServiceRun2.cxx
File metadata and controls
186 lines (150 loc) · 6.9 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
// 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 "Common/Core/MetadataHelper.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/Tools/EventSelectionModule.h"
#include "Common/Tools/timestampModule.h"
#include <CCDB/BasicCCDBManager.h>
#include <Framework/AnalysisDataModel.h>
#include <Framework/AnalysisHelpers.h>
#include <Framework/AnalysisTask.h>
#include <Framework/Configurable.h>
#include <Framework/DataTypes.h>
#include <Framework/HistogramRegistry.h>
#include <Framework/InitContext.h>
#include <Framework/OutputObjHeader.h>
#include <Framework/runDataProcessing.h>
#include <cstdint>
#include <stdexcept>
#include <string>
#include <vector>
using namespace o2;
using namespace o2::framework;
o2::common::core::MetadataHelper metadataInfo; // Metadata helper
using BCsWithRun2InfosAndMatches = soa::Join<aod::BCs, aod::Run2BCInfos, aod::Run2MatchedToBCSparse>;
using BCsWithRun3Matchings = soa::Join<aod::BCs, aod::Run3MatchedToBCSparse>;
using FullTracks = soa::Join<aod::Tracks, aod::TracksExtra>;
using FullTracksIU = soa::Join<aod::TracksIU, aod::TracksExtra>;
struct eventselectionRun2 {
o2::common::timestamp::timestampConfigurables timestampConfigurables;
o2::common::timestamp::TimestampModule timestampMod;
o2::common::eventselection::bcselConfigurables bcselOpts;
o2::common::eventselection::BcSelectionModule bcselmodule;
o2::common::eventselection::evselConfigurables evselOpts;
o2::common::eventselection::EventSelectionModule evselmodule;
Produces<aod::Timestamps> timestampTable; /// Table with SOR timestamps produced by the task
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};
// buffering intermediate results for passing
std::vector<uint64_t> timestamps;
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& context)
{
// CCDB boilerplate init
ccdb->setCaching(true);
ccdb->setLocalObjectValidityChecking();
ccdb->setURL(ccdburl.value);
// task-specific
timestampMod.init(timestampConfigurables, metadataInfo);
bcselmodule.init(context, bcselOpts, histos, metadataInfo);
evselmodule.init(context, evselOpts, histos, metadataInfo);
}
void process(BCsWithRun2InfosAndMatches const& bcs,
aod::Collisions const& collisions,
aod::Zdcs const&,
aod::FV0As const&,
aod::FV0Cs const&,
aod::FT0s const&,
aod::FDDs const&,
FullTracks const&)
{
timestampMod.process(bcs, ccdb, timestamps, timestampTable);
bcselmodule.processRun2(ccdb, bcs, timestamps, bcselsbuffer, bcsel);
evselmodule.processRun2(ccdb, histos, collisions, tracklets, cache, timestamps, bcselsbuffer, evsel);
}
};
struct eventselectionRun3 {
o2::common::timestamp::timestampConfigurables timestampConfigurables;
o2::common::timestamp::TimestampModule timestampMod;
o2::common::eventselection::bcselConfigurables bcselOpts;
o2::common::eventselection::BcSelectionModule bcselmodule;
o2::common::eventselection::evselConfigurables evselOpts;
o2::common::eventselection::EventSelectionModule evselmodule;
o2::common::eventselection::lumiConfigurables lumiOpts;
o2::common::eventselection::LumiModule lumimodule;
Produces<aod::Timestamps> timestampTable; /// Table with SOR timestamps produced by the task
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<uint64_t> timestamps;
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& context)
{
// CCDB boilerplate init
ccdb->setCaching(true);
ccdb->setLocalObjectValidityChecking();
ccdb->setURL(ccdburl.value);
// task-specific
timestampMod.init(timestampConfigurables, metadataInfo);
bcselmodule.init(context, bcselOpts, histos, metadataInfo);
evselmodule.init(context, evselOpts, histos, metadataInfo);
lumimodule.init(context, lumiOpts, 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&)
{
timestampMod.process(bcs, ccdb, timestamps, timestampTable);
bcselmodule.processRun3(ccdb, histos, bcs, timestamps, bcselsbuffer, bcsel);
evselmodule.processRun3(ccdb, histos, bcs, collisions, pvTracks, ft0s, cache, timestamps, bcselsbuffer, evsel);
lumimodule.process(ccdb, histos, bcs, timestamps, bcselsbuffer);
}
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
// Parse the metadata for later too
metadataInfo.initMetadata(cfgc);
LOGF(info, "Event selection with forced Run 2 mode engaging in unchecked mode.");
LOGF(info, "To be improved once metadata enabling in defineDataProcessing is worked out.");
// force Run 2 mode
return WorkflowSpec{adaptAnalysisTask<eventselectionRun2>(cfgc)};
}