forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrangenessTrackingSpec.cxx
More file actions
175 lines (154 loc) · 7 KB
/
StrangenessTrackingSpec.cxx
File metadata and controls
175 lines (154 loc) · 7 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
// 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 StrangenessTrackingSpec.cxx
/// \brief
#include "TGeoGlobalMagField.h"
#include "Framework/ConfigParamRegistry.h"
#include "Field/MagneticField.h"
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "StrangenessTracking/StrangenessTrackingConfigParam.h"
#include "GlobalTrackingWorkflow/StrangenessTrackingSpec.h"
#include "ITSWorkflow/TrackerSpec.h"
#include "ITSWorkflow/TrackReaderSpec.h"
#include "Framework/CCDBParamSpec.h"
#include "DataFormatsParameters/GRPObject.h"
#include "DataFormatsITSMFT/ROFRecord.h"
#include "DataFormatsITS/TrackITS.h"
#include "ReconstructionDataFormats/TrackTPCITS.h"
#include "SimulationDataFormat/MCCompLabel.h"
#include "ITStracking/IOUtils.h"
#include "DetectorsCommonDataFormats/DetectorNameConf.h"
#include <fmt/format.h>
namespace o2
{
using namespace o2::framework;
namespace strangeness_tracking
{
using StrangeTrack = o2::dataformats::StrangeTrack;
using DataRequest = o2::globaltracking::DataRequest;
StrangenessTrackerSpec::StrangenessTrackerSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool isMC) : mDataRequest{dr}, mGGCCDBRequest(gr), mUseMC{isMC}
{
// no ops
}
void StrangenessTrackerSpec::init(framework::InitContext& ic)
{
mTimer.Stop();
mTimer.Reset();
// load propagator
o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
mTracker.setCorrType(o2::base::PropagatorImpl<float>::MatCorrType::USEMatCorrLUT);
mTracker.setConfigParams(&StrangenessTrackingParamConfig::Instance());
mTracker.setupThreads(1);
mTracker.setupFitters();
LOG(info) << "Initialized strangeness tracker...";
}
void StrangenessTrackerSpec::run(framework::ProcessingContext& pc)
{
mTimer.Start(false);
LOG(debug) << "Running strangeness tracker...";
o2::globaltracking::RecoContainer recoData;
recoData.collectData(pc, *mDataRequest.get());
updateTimeDependentParams(pc);
auto geom = o2::its::GeometryTGeo::Instance();
mTracker.loadData(recoData);
mTracker.prepareITStracks();
mTracker.process();
pc.outputs().snapshot(Output{"GLO", "STRANGETRACKS", 0}, mTracker.getStrangeTrackVec());
pc.outputs().snapshot(Output{"GLO", "CLUSUPDATES", 0}, mTracker.getClusAttachments());
if (mUseMC) {
pc.outputs().snapshot(Output{"GLO", "STRANGETRACKS_MC", 0}, mTracker.getStrangeTrackLabels());
}
mTimer.Stop();
}
///_______________________________________
void StrangenessTrackerSpec::updateTimeDependentParams(ProcessingContext& pc)
{
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
static bool initOnceDone = false;
if (!initOnceDone) { // this params need to be queried only once
initOnceDone = true;
// pc.inputs().get<o2::itsmft::TopologyDictionary*>("cldict"); // just to trigger the finaliseCCDB
if (pc.inputs().getPos("itsTGeo") >= 0) {
pc.inputs().get<o2::its::GeometryTGeo*>("itsTGeo");
}
o2::its::GeometryTGeo* geom = o2::its::GeometryTGeo::Instance();
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::T2GRot, o2::math_utils::TransformType::T2G));
}
if (o2::base::Propagator::Instance()->getNominalBz() != mTracker.getBz()) {
mTracker.setBz(o2::base::Propagator::Instance()->getNominalBz());
mTracker.setupFitters();
}
mTracker.setMCTruthOn(mUseMC);
}
///_______________________________________
void StrangenessTrackerSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
{
if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
return;
}
if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
LOG(info) << "cluster dictionary updated";
mTracker.setClusterDictionaryITS((const o2::itsmft::TopologyDictionary*)obj);
return;
}
if (matcher == ConcreteDataMatcher("ITS", "GEOMTGEO", 0)) {
LOG(info) << "ITS GeomtetryTGeo loaded from ccdb";
o2::its::GeometryTGeo::adopt((o2::its::GeometryTGeo*)obj);
return;
}
#ifdef ENABLE_UPGRADES
if (matcher == ConcreteDataMatcher("IT3", "CLUSDICT", 0)) {
LOG(info) << "it3 cluster dictionary updated";
mTracker.setClusterDictionaryIT3((const o2::its3::TopologyDictionary*)obj);
return;
}
#endif
}
void StrangenessTrackerSpec::endOfStream(framework::EndOfStreamContext& ec)
{
LOGF(info, "Strangeness tracking total timing: Cpu: %.3e Real: %.3e s in %d slots",
mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
}
DataProcessorSpec getStrangenessTrackerSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC, bool useGeom)
{
// ITS
auto dataRequest = std::make_shared<DataRequest>();
dataRequest->requestITSClusters(useMC);
dataRequest->requestTracks(src, useMC);
dataRequest->requestPrimaryVertices(useMC);
dataRequest->requestSecondaryVertices(useMC);
auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
true, // GRPECS=true
false, // GRPLHCIF
true, // GRPMagField
true, // askMatLUT
useGeom ? o2::base::GRPGeomRequest::Aligned : o2::base::GRPGeomRequest::None, // geometry
dataRequest->inputs,
true);
if (!useGeom) {
ggRequest->addInput({"itsTGeo", "ITS", "GEOMTGEO", 0, Lifetime::Condition, framework::ccdbParamSpec("ITS/Config/Geometry")}, dataRequest->inputs);
}
std::vector<OutputSpec> outputs;
outputs.emplace_back("GLO", "STRANGETRACKS", 0, Lifetime::Timeframe);
outputs.emplace_back("GLO", "CLUSUPDATES", 0, Lifetime::Timeframe);
if (useMC) {
outputs.emplace_back("GLO", "STRANGETRACKS_MC", 0, Lifetime::Timeframe);
LOG(info) << "Strangeness tracker will use MC";
}
return DataProcessorSpec{
"strangeness-tracker",
dataRequest->inputs,
outputs,
AlgorithmSpec{adaptFromTask<StrangenessTrackerSpec>(dataRequest, ggRequest, useMC)},
Options{}};
}
} // namespace strangeness_tracking
} // namespace o2