Project
Loading...
Searching...
No Matches
MFTAssessmentSpec.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.
11
13
17#include "Framework/Logger.h"
19#include "MFTBase/GeometryTGeo.h"
21#include "Field/MagneticField.h"
22#include "TGeoGlobalMagField.h"
24#include <TFile.h>
25
26using namespace o2::framework;
27
28namespace o2
29{
30namespace mft
31{
32
33//_____________________________________________________________
35{
37 mMFTAssessment = std::make_unique<o2::mft::MFTAssessment>(mUseMC);
38 for (int sw = 0; sw < NStopWatches; sw++) {
39 mTimer[sw].Stop();
40 mTimer[sw].Reset();
41 }
42 mTimer[SWTot].Start(false);
43}
44
45//_____________________________________________________________
47{
48 updateTimeDependentParams(pc);
49 mTimer[SWQCAsync].Start(false);
50 mMFTAssessment->runASyncQC(pc);
51 mTimer[SWQCAsync].Stop();
52
53 if (mUseMC) {
54
55 mTimer[SWTrackables].Start(false);
56 mMFTAssessment->processTrackables();
57 mTimer[SWTrackables].Stop();
58
59 if (mProcessGen) {
60 mTimer[SWGenerated].Start(false);
61 mMFTAssessment->processGeneratedTracks();
62 mTimer[SWGenerated].Stop();
63 }
64 mTimer[SWRecoAndTrue].Start(false);
65 mMFTAssessment->processRecoTracks();
66 mMFTAssessment->processTrueAndFakeTracks();
67 mTimer[SWRecoAndTrue].Stop();
68 }
69}
70
71//_____________________________________________________________
73{
74 if (mFinalizeAnalysis) {
75 mTimer[SWAnalysis].Start(false);
76 mMFTAssessment->finalizeAnalysis();
77 mTimer[SWAnalysis].Stop();
78 }
79
80 sendOutput(ec.outputs());
81 mTimer[SWTot].Stop();
82
83 for (int i = 0; i < NStopWatches; i++) {
84 LOGF(info, "Timing %18s: Cpu: %.3e s; Real: %.3e s in %d slots", TimerName[i], mTimer[i].CpuTime(), mTimer[i].RealTime(), mTimer[i].Counter() - 1);
85 }
86}
87
88//_____________________________________________________________
89void MFTAssessmentSpec::sendOutput(DataAllocator& output)
90{
91 TObjArray objar;
92 mMFTAssessment->getHistos(objar);
93
94 output.snapshot(Output{"MFT", "MFTASSESSMENT", 0}, objar);
95
96 TFile* f = new TFile(Form("MFTAssessment.root"), "RECREATE");
97 objar.Write();
98 f->Close();
99}
101void MFTAssessmentSpec::updateTimeDependentParams(ProcessingContext& pc)
102{
104 static bool initOnceDone = false;
105 if (!initOnceDone) { // this params need to be queried only once
106 initOnceDone = true;
107 pc.inputs().get<o2::itsmft::TopologyDictionary*>("cldict"); // just to trigger the finaliseCCDB
108 if (pc.inputs().getPos("mftTGeo") >= 0) {
109 pc.inputs().get<o2::mft::GeometryTGeo*>("mftTGeo");
110 }
111 auto field = static_cast<o2::field::MagneticField*>(TGeoGlobalMagField::Instance()->GetField());
112 double centerMFT[3] = {0, 0, -61.4}; // Field at center of MFT
113 auto Bz = field->getBz(centerMFT);
114 LOG(info) << "Setting MFT Assessment Bz = " << Bz;
115 mMFTAssessment->setBz(Bz);
116 mMFTAssessment->init(mFinalizeAnalysis);
117 mMFTAssessment->setRefOrbit(pc.services().get<o2::framework::TimingInfo>().firstTForbit);
118 }
119}
120
123{
125 return;
126 }
127 if (matcher == ConcreteDataMatcher("MFT", "CLUSDICT", 0)) {
128 LOG(info) << "cluster dictionary updated";
129 mMFTAssessment->setClusterDictionary((const o2::itsmft::TopologyDictionary*)obj);
130 return;
131 }
132 if (matcher == ConcreteDataMatcher("MFT", "GEOMTGEO", 0)) {
133 LOG(info) << "MFT GeomtetryTGeo loaded from ccdb";
135 return;
136 }
137}
138
139//_____________________________________________________________
140DataProcessorSpec getMFTAssessmentSpec(bool useMC, bool useGeom, bool processGen, bool finalizeAnalysis)
141{
142 std::vector<InputSpec> inputs;
143 std::vector<OutputSpec> outputs;
144
145 inputs.emplace_back("compClusters", "MFT", "COMPCLUSTERS", 0, Lifetime::Timeframe);
146 inputs.emplace_back("patterns", "MFT", "PATTERNS", 0, Lifetime::Timeframe);
147 inputs.emplace_back("clustersrofs", "MFT", "CLUSTERSROF", 0, Lifetime::Timeframe);
148 inputs.emplace_back("tracksrofs", "MFT", "MFTTrackROF", 0, Lifetime::Timeframe);
149 inputs.emplace_back("tracks", "MFT", "TRACKS", 0, Lifetime::Timeframe);
150 inputs.emplace_back("trackClIdx", "MFT", "TRACKCLSID", 0, Lifetime::Timeframe);
151 inputs.emplace_back("cldict", "MFT", "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec("MFT/Calib/ClusterDictionary"));
152 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
153 true, // GRPECS=true
154 false, // GRPLHCIF
155 true, // GRPMagField
156 false, // askMatLUT
158 inputs,
159 true);
160 if (!useGeom) {
161 ggRequest->addInput({"mftTGeo", "MFT", "GEOMTGEO", 0, Lifetime::Condition, framework::ccdbParamSpec("MFT/Config/Geometry")}, inputs);
162 }
163 if (useMC) {
164 inputs.emplace_back("clslabels", "MFT", "CLUSTERSMCTR", 0, Lifetime::Timeframe);
165 inputs.emplace_back("trklabels", "MFT", "TRACKSMCTR", 0, Lifetime::Timeframe);
166 }
167
168 outputs.emplace_back("MFT", "MFTASSESSMENT", 0, Lifetime::Sporadic);
169
170 return DataProcessorSpec{
171 "mft-assessment",
172 inputs,
173 outputs,
174 AlgorithmSpec{adaptFromTask<o2::mft::MFTAssessmentSpec>(ggRequest, useMC, processGen, finalizeAnalysis)},
175 Options{{}}};
176}
177
178} // namespace mft
179} // namespace o2
int32_t i
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
Definition of the MagF class.
Definition of the Names Generator class.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
Double_t getBz(const Double_t *xyz) const
Method to calculate the field at point xyz.
int getPos(const char *name) const
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
static void adopt(GeometryTGeo *raw, bool canDelete=false)
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
GLdouble f
Definition glcorearb.h:310
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
DataProcessorSpec getMFTAssessmentSpec(bool useMC, bool useGeom, bool processGen, bool finalizeAnalysis=false)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
TStopwatch sw