forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathITSTPCMatchingQCSpec.cxx
More file actions
161 lines (140 loc) · 6.09 KB
/
ITSTPCMatchingQCSpec.cxx
File metadata and controls
161 lines (140 loc) · 6.09 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
// 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 ITSTPCMacthingQCSpec.cxx
#include "Framework/ControlService.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/Logger.h"
#include "GlobalTrackingWorkflowQC/ITSTPCMatchingQCSpec.h"
#include "GLOQC/ITSTPCMatchingQCParams.h"
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "DetectorsBase/Propagator.h"
#include "DetectorsVertexing/SVertexerParams.h"
#include "Framework/CCDBParamSpec.h"
#include "CommonUtils/NameConf.h"
#include <TFile.h>
using namespace o2::framework;
namespace o2
{
namespace globaltracking
{
void ITSTPCMatchingQCDevice::init(InitContext& /*ic*/)
{
const o2::gloqc::ITSTPCMatchingQCParams& params = o2::gloqc::ITSTPCMatchingQCParams::Instance();
mMatchITSTPCQC = std::make_unique<o2::gloqc::MatchITSTPCQC>();
mMatchITSTPCQC->setDataRequest(mDataRequest);
mMatchITSTPCQC->setTrkSources(o2::dataformats::GlobalTrackID::getSourcesMask(mTrkSources));
mMatchITSTPCQC->setNBinsPt(params.nBinsPt);
mMatchITSTPCQC->setMinPtITSCut(params.minPtITSCut);
mMatchITSTPCQC->setEtaITSCut(params.etaITSCut);
mMatchITSTPCQC->setMinNClustersITS(params.minNITSClustersCut);
mMatchITSTPCQC->setMaxChi2PerClusterITS(params.maxChi2PerClusterITS);
mMatchITSTPCQC->setMinPtTPCCut(params.minPtTPCCut);
mMatchITSTPCQC->setEtaTPCCut(params.etaTPCCut);
mMatchITSTPCQC->setMinNTPCClustersCut(params.minNTPCClustersCut);
mMatchITSTPCQC->setMinDCAtoBeamPipeDistanceCut(params.minDCACut);
mMatchITSTPCQC->setMinDCAtoBeamPipeYCut(params.minDCACutY);
mMatchITSTPCQC->setPtCut(params.minPtCut);
mMatchITSTPCQC->setMaxPtCut(params.maxPtCut);
mMatchITSTPCQC->setEtaCut(params.etaCut);
mMatchITSTPCQC->setEtaNo0Cut(params.etaNo0Cut);
mMatchITSTPCQC->setCutK0Mass(params.cutK0Mass);
mMatchITSTPCQC->setMaxK0Eta(params.maxEtaK0);
mMatchITSTPCQC->setK0Scaling(params.K0Scaling);
mMatchITSTPCQC->setMinTPCOccpp(params.minTPCOccpp);
mMatchITSTPCQC->setMaxTPCOccpp(params.maxTPCOccpp);
mMatchITSTPCQC->setNBinsTPCOccpp(params.nBinsTPCOccpp);
mMatchITSTPCQC->setMinTPCOccPbPb(params.minTPCOccPbPb);
mMatchITSTPCQC->setMaxTPCOccPbPb(params.maxTPCOccPbPb);
mMatchITSTPCQC->setNBinsTPCOccPbPb(params.nBinsTPCOccPbPb);
mMatchITSTPCQC->setK0MaxDCA(params.maxK0DCA);
mMatchITSTPCQC->setK0MinCosPA(params.minK0CosPA);
o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest);
if (mUseMC) {
mMatchITSTPCQC->setUseMC(mUseMC);
}
if (mDoK0QC) {
mMatchITSTPCQC->setDoK0QC(mDoK0QC);
}
mMatchITSTPCQC->init();
}
//_____________________________________________________________
void ITSTPCMatchingQCDevice::run(o2::framework::ProcessingContext& pc)
{
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
static bool wasSVParamInitialized = false;
if (!wasSVParamInitialized) {
pc.inputs().get<o2::vertexing::SVertexerParams*>("SVParam");
wasSVParamInitialized = true;
}
mMatchITSTPCQC->run(pc);
}
//_____________________________________________________________
void ITSTPCMatchingQCDevice::endOfStream(o2::framework::EndOfStreamContext& ec)
{
mMatchITSTPCQC->finalize();
sendOutput(ec.outputs());
}
//_____________________________________________________________
void ITSTPCMatchingQCDevice::sendOutput(DataAllocator& output)
{
TObjArray objar;
mMatchITSTPCQC->getHistos(objar);
output.snapshot(Output{"GLO", "ITSTPCMATCHQC", 0}, objar);
TFile* f = new TFile(Form("outITSTPCmatchingQC.root"), "RECREATE");
if (f == nullptr) {
LOGP(error, "Cannot write QC to file 'outITSTPCmatchingQC.root'");
return;
}
objar.Write("ObjArray", TObject::kSingleKey);
f->Close();
}
void ITSTPCMatchingQCDevice::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
{
if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
return;
}
if (matcher == ConcreteDataMatcher("GLO", "SVPARAM", 0)) {
return;
}
}
} // namespace globaltracking
namespace framework
{
using GID = o2::dataformats::GlobalTrackID;
DataProcessorSpec getITSTPCMatchingQCDevice(bool useMC, bool doK0QC, std::string trkSources)
{
std::vector<OutputSpec> outputs;
outputs.emplace_back("GLO", "ITSTPCMATCHQC", 0, Lifetime::Sporadic);
auto dataRequest = std::make_shared<o2::globaltracking::DataRequest>();
GID::mask_t srcMask = GID::getSourcesMask(trkSources);
dataRequest->requestTracks(srcMask, useMC);
if (doK0QC) {
dataRequest->requestPrimaryVertices(useMC);
dataRequest->requestSecondaryVertices(useMC);
dataRequest->requestTPCClusters(false);
}
auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
true, // GRPECS=true
true, // GRPLHCIF
true, // GRPMagField
false, // askMatLUT
o2::base::GRPGeomRequest::None, // geometry
dataRequest->inputs);
dataRequest->inputs.emplace_back("SVParam", "GLO", "SVPARAM", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/SVertexerParam"));
return DataProcessorSpec{
.name = "itstpc-matching-qc",
.inputs = dataRequest->inputs,
.outputs = outputs,
.algorithm = AlgorithmSpec{adaptFromTask<o2::globaltracking::ITSTPCMatchingQCDevice>(dataRequest, ccdbRequest, useMC, doK0QC, trkSources)},
};
}
} // namespace framework
} // namespace o2