Project
Loading...
Searching...
No Matches
StrangenessTrackingSpec.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
13
14#include <TMap.h>
15#include <TObjString.h>
16#include "TGeoGlobalMagField.h"
18#include "Field/MagneticField.h"
27
32#include "ITStracking/IOUtils.h"
34
35#include <fmt/format.h>
36namespace o2
37{
38using namespace o2::framework;
39namespace strangeness_tracking
40{
41
44
45StrangenessTrackerSpec::StrangenessTrackerSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool isMC) : mDataRequest{dr}, mGGCCDBRequest(gr), mUseMC{isMC}
46{
47 // no ops
48}
49
51{
52 mTimer.Stop();
53 mTimer.Reset();
54
55 // load propagator
56
60 mTracker.setupThreads(1);
61 mTracker.setupFitters();
62
63 LOG(info) << "Initialized strangeness tracker...";
64}
65
67{
68 mTimer.Start(false);
69 LOG(debug) << "Running strangeness tracker...";
70
72 recoData.collectData(pc, *mDataRequest.get());
73 updateTimeDependentParams(pc);
74 storeConfigs(pc);
76 mTracker.loadData(recoData);
77 mTracker.prepareITStracks();
78 mTracker.process();
79 pc.outputs().snapshot(Output{"GLO", "STRANGETRACKS", 0}, mTracker.getStrangeTrackVec());
80 pc.outputs().snapshot(Output{"GLO", "CLUSUPDATES", 0}, mTracker.getClusAttachments());
81
82 if (mUseMC) {
83 pc.outputs().snapshot(Output{"GLO", "STRANGETRACKS_MC", 0}, mTracker.getStrangeTrackLabels());
84 }
85
86 mTimer.Stop();
87}
88
89void StrangenessTrackerSpec::storeConfigs(framework::ProcessingContext& pc)
90{
91 static bool first = true;
92 if (first) {
93 first = false;
97 TMap md;
98 md.SetOwnerKeyValue();
99 md.Add(new TObjString(conf.getName().c_str()), new TObjString(o2::conf::ConfigurableParam::asJSON(conf.getName()).c_str()));
100 pc.outputs().snapshot(Output{"META", "STRTRACKER", 0}, md);
101 }
102 }
103}
104
106void StrangenessTrackerSpec::updateTimeDependentParams(ProcessingContext& pc)
107{
109 static bool initOnceDone = false;
110 if (!initOnceDone) { // this params need to be queried only once
111 initOnceDone = true;
112 // pc.inputs().get<o2::itsmft::TopologyDictionary*>("cldict"); // just to trigger the finaliseCCDB
113 if (pc.inputs().getPos("itsTGeo") >= 0) {
114 pc.inputs().get<o2::its::GeometryTGeo*>("itsTGeo");
115 }
118 }
119 if (o2::base::Propagator::Instance()->getNominalBz() != mTracker.getBz()) {
120 mTracker.setBz(o2::base::Propagator::Instance()->getNominalBz());
121 mTracker.setupFitters();
122 }
123 mTracker.setMCTruthOn(mUseMC);
124}
125
128{
130 return;
131 }
132 if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
133 LOG(info) << "cluster dictionary updated";
135 return;
136 }
137 if (matcher == ConcreteDataMatcher("ITS", "GEOMTGEO", 0)) {
138 LOG(info) << "ITS GeomtetryTGeo loaded from ccdb";
140 return;
141 }
142#ifdef ENABLE_UPGRADES
143 if (matcher == ConcreteDataMatcher("IT3", "CLUSDICT", 0)) {
144 LOG(info) << "it3 cluster dictionary updated";
145 mTracker.setClusterDictionaryIT3((const o2::its3::TopologyDictionary*)obj);
146 return;
147 }
148#endif
149}
150
152{
153 LOGF(info, "Strangeness tracking total timing: Cpu: %.3e Real: %.3e s in %d slots",
154 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
155}
156
158{
159 // ITS
160 auto dataRequest = std::make_shared<DataRequest>();
161 dataRequest->requestITSClusters(useMC);
162 dataRequest->requestTracks(src, useMC);
163 dataRequest->requestPrimaryVertices(useMC);
164 dataRequest->requestSecondaryVertices(useMC);
165
166 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
167 true, // GRPECS=true
168 false, // GRPLHCIF
169 true, // GRPMagField
170 true, // askMatLUT
172 dataRequest->inputs,
173 true);
174 if (!useGeom) {
175 ggRequest->addInput({"itsTGeo", "ITS", "GEOMTGEO", 0, Lifetime::Condition, framework::ccdbParamSpec("ITS/Config/Geometry")}, dataRequest->inputs);
176 }
177 std::vector<OutputSpec> outputs;
178 outputs.emplace_back("GLO", "STRANGETRACKS", 0, Lifetime::Timeframe);
179 outputs.emplace_back("GLO", "CLUSUPDATES", 0, Lifetime::Timeframe);
180 if (useMC) {
181 outputs.emplace_back("GLO", "STRANGETRACKS_MC", 0, Lifetime::Timeframe);
182 LOG(info) << "Strangeness tracker will use MC";
183 }
184 outputs.emplace_back("META", "STRTRACKER", 0, Lifetime::Sporadic);
185
186 return DataProcessorSpec{
187 "strangeness-tracker",
188 dataRequest->inputs,
189 outputs,
190 AlgorithmSpec{adaptFromTask<StrangenessTrackerSpec>(dataRequest, ggRequest, useMC)},
191 Options{}};
192}
193
194} // namespace strangeness_tracking
195} // namespace o2
Wrapper container for different reconstructed object types.
Definition of the Names Generator class.
std::ostringstream debug
Header of the General Run Parameters object.
Definition of the ITSMFT ROFrame (trigger) record.
Definition of the MagF class.
Definition of the ITS track.
Result of refitting TPC-ITS matched track.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static std::string getConfigOutputFileName(const std::string &procName, const std::string &confName="", bool json=true)
Definition NameConf.cxx:120
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
Definition Propagator.h:178
static std::string asJSON(std::string const &keyOnly="")
static void write(std::string const &filename, std::string const &keyOnly="")
void snapshot(const Output &spec, T const &object)
int getPos(const char *name) const
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
static GeometryTGeo * Instance()
void fillMatrixCache(int mask) override
static void adopt(GeometryTGeo *raw, bool canDelete=false)
StrangenessTrackerSpec(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, bool isMC)
void finaliseCCDB(framework::ConcreteDataMatcher &matcher, void *obj) final
void run(framework::ProcessingContext &pc) final
void endOfStream(framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void setConfigParams(const StrangenessTrackingParamConfig *params)
std::vector< StrangeTrack > & getStrangeTrackVec(int iThread=0)
void setCorrType(const o2::base::PropagatorImpl< float >::MatCorrType &type)
std::vector< ClusAttachments > & getClusAttachments(int iThread=0)
void setClusterDictionaryITS(const o2::itsmft::TopologyDictionary *d)
bool loadData(const o2::globaltracking::RecoContainer &recoData)
std::vector< o2::MCCompLabel > & getStrangeTrackLabels(int iThread=0)
GLenum src
Definition glcorearb.h:1767
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getStrangenessTrackerSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC, bool useGeom)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string name
The name of the associated DataProcessorSpec.
Definition DeviceSpec.h:50
size_t inputTimesliceId
The time pipelining id of this particular device.
Definition DeviceSpec.h:68
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
static constexpr int T2L
Definition Cartesian.h:56
static constexpr int T2GRot
Definition Cartesian.h:58
static constexpr int T2G
Definition Cartesian.h:57
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"