forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHMPMatcherSpec.cxx
More file actions
181 lines (149 loc) · 7.9 KB
/
HMPMatcherSpec.cxx
File metadata and controls
181 lines (149 loc) · 7.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
// 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 HMPMatcherSpec.cxx
#include <vector>
#include <string>
#include "TStopwatch.h"
#include "Framework/ConfigParamRegistry.h"
#include "DetectorsBase/GeometryManager.h"
#include "DetectorsBase/Propagator.h"
#include "CommonUtils/NameConf.h"
#include "DataFormatsParameters/GRPObject.h"
#include "CommonDataFormat/InteractionRecord.h"
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "Framework/Task.h"
#include "Framework/DataProcessorSpec.h"
#include "DetectorsBase/GRPGeomHelper.h"
// from Tracks
#include "ReconstructionDataFormats/GlobalTrackID.h"
#include "ReconstructionDataFormats/GlobalTrackAccessor.h"
#include "ReconstructionDataFormats/GlobalTrackID.h"
#include "DataFormatsTPC/TrackTPC.h"
#include "DataFormatsITS/TrackITS.h"
#include "DataFormatsTRD/TrackTRD.h"
#include "ReconstructionDataFormats/TrackTPCITS.h"
#include "ReconstructionDataFormats/TrackTPCTOF.h"
// from HMPID
#include "DataFormatsHMP/Cluster.h"
#include "GlobalTracking/MatchHMP.h"
#include "GlobalTrackingWorkflow/HMPMatcherSpec.h"
using namespace o2::framework;
// using MCLabelsTr = gsl::span<const o2::MCCompLabel>;
// using GID = o2::dataformats::GlobalTrackID;
// using DetID = o2::detectors::DetID;
using evIdx = o2::dataformats::EvIndex<int, int>;
using MatchOutputType = std::vector<o2::dataformats::MatchInfoHMP>;
using GID = o2::dataformats::GlobalTrackID;
namespace o2
{
namespace globaltracking
{
class HMPMatcherSpec : public Task
{
public:
HMPMatcherSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mUseMC(useMC) {}
~HMPMatcherSpec() override = default;
void init(InitContext& ic) final;
void run(ProcessingContext& pc) final;
void endOfStream(framework::EndOfStreamContext& ec) final;
void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) final;
private:
std::shared_ptr<DataRequest> mDataRequest;
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
bool mUseMC = false; // true
bool mUseFIT = false;
bool mDoTPCRefit = false;
bool mStrict = false;
MatchHMP mMatcher; ///< Cluster finder
TStopwatch mTimer;
};
void HMPMatcherSpec::init(InitContext& ic)
{
mTimer.Stop();
mTimer.Reset();
//-------- init geometry and field --------//
o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
}
void HMPMatcherSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
{
if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
return;
}
}
void HMPMatcherSpec::run(ProcessingContext& pc)
{
mTimer.Start(false);
RecoContainer recoData;
recoData.collectData(pc, *mDataRequest.get());
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
auto creationTime = DataRefUtils::getHeader<DataProcessingHeader*>(pc.inputs().getFirstValid(true))->creation;
// LOG(debug) << "isTrackSourceLoaded: TPC -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPC); LOG(debug) << "isTrackSourceLoaded: ITSTPC -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPC);
LOG(debug) << "isTrackSourceLoaded: TPC -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPC);
//:
LOG(debug) << "isTrackSourceLoaded: TPCTOF -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTOF);
LOG(debug) << "isTrackSourceLoaded: ITSTPC -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPC);
LOG(debug) << "isTrackSourceLoaded: TPCTRD -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTRD);
LOG(debug) << "isTrackSourceLoaded: ITSTPCTRD -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTRD);
LOG(debug) << "isTrackSourceLoaded: ITSTPCTOF -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTOF);
LOG(debug) << "isTrackSourceLoaded: TPCTRDTOF -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTRDTOF);
LOG(debug) << "isTrackSourceLoaded: ITSTPCTRDTOF -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTRDTOF);
bool isTPCused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPC);
bool isITSTPCused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPC);
bool isTPCTRDused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTRD);
bool isTPCTOFused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTOF);
bool isITSTPCTRDused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTRD);
bool isITSTPCTOFused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTOF);
bool isTPCTRDTOFused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTRDTOF);
bool isITSTPCTRDTOFused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTRDTOF);
// uint32_t ss = o2::globaltracking::getSubSpec(mStrict ? o2::globaltracking::MatchingType::Strict : o2::globaltracking::MatchingType::Standard);
mMatcher.run(recoData);
pc.outputs().snapshot(Output{o2::header::gDataOriginHMP, "MATCHES", 0}, mMatcher.getMatchedTrackVector(o2::globaltracking::MatchHMP::trackType::CONSTR));
if (mUseMC) {
pc.outputs().snapshot(Output{o2::header::gDataOriginHMP, "MCLABELS", 0}, mMatcher.getMatchedHMPLabelsVector(o2::globaltracking::MatchHMP::trackType::CONSTR));
}
mTimer.Stop();
}
void HMPMatcherSpec::endOfStream(EndOfStreamContext& ec)
{
LOGF(debug, "HMP matching total timing: Cpu: %.3e Real: %.3e s in %d slots",
mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
}
DataProcessorSpec getHMPMatcherSpec(GID::mask_t src, bool useMC, float extratolerancetrd, float extratolerancetof)
{
// uint32_t ss = o2::globaltracking::getSubSpec(strict ? o2::globaltracking::MatchingType::Strict : o2::globaltracking::MatchingType::Standard);
auto dataRequest = std::make_shared<DataRequest>();
/* if (strict) {
dataRequest->setMatchingInputStrict();
}*/
dataRequest->requestTracks(src, useMC);
dataRequest->requestClusters(GID::getSourceMask(GID::HMP), useMC);
auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
true, // GRPECS=true
true, // GRPLHCIF
true, // GRPMagField
true, // askMatLUT
o2::base::GRPGeomRequest::Aligned, // geometry
dataRequest->inputs,
true);
std::vector<OutputSpec> outputs;
outputs.emplace_back(o2::header::gDataOriginHMP, "MATCHES", 0, Lifetime::Timeframe);
if (useMC) {
outputs.emplace_back(o2::header::gDataOriginHMP, "MCLABELS", 0, Lifetime::Timeframe);
}
return DataProcessorSpec{
"hmp-matcher",
dataRequest->inputs,
outputs,
AlgorithmSpec{adaptFromTask<HMPMatcherSpec>(dataRequest, ggRequest, useMC)},
Options{}};
}
} // namespace globaltracking
} // namespace o2