Project
Loading...
Searching...
No Matches
TRDGlobalTrackingQCSpec.h
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
12#ifndef O2_TRD_GLOBALTRACKINGQCSPEC_H
13#define O2_TRD_GLOBALTRACKINGQCSPEC_H
14
18
19// input TRD tracks, TRD tracklets, TRD calibrated tracklets, ITS-TPC tracks, TPC tracks
20// output QC histograms
21
22#include "Headers/DataHeader.h"
24#include "Framework/Task.h"
33#include "TRDQC/Tracking.h"
34#include <cstring>
35
37
38using namespace o2::framework;
39using namespace o2::globaltracking;
41
42namespace o2
43{
44namespace trd
45{
46
48{
49 public:
50 TRDGlobalTrackingQC(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool tpcAvailable) : mDataRequest(dr), mGGCCDBRequest(gr), mTPCavailable(tpcAvailable) {}
51 ~TRDGlobalTrackingQC() override = default;
52 void init(InitContext& ic) final
53 {
55 if (!mTPCavailable) {
56 mQC.disablePID();
57 }
58 if (getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) {
59 // apply artificial pad shift in case non-ideal alignment is used to compensate for shift in current alignment from real data
60 mQC.setApplyShift(false);
61 }
62 }
63 void run(ProcessingContext& pc) final
64 {
65 RecoContainer recoData;
66 recoData.collectData(pc, *mDataRequest.get());
67 updateTimeDependentParams(pc); // Make sure this is called after recoData.collectData, which may load some conditions
68 mQC.reset();
69 mQC.setInput(recoData);
70 mQC.run();
71 pc.outputs().snapshot(Output{"TRD", "TRACKINGQC", 0}, mQC.getTrackQC());
72 }
74 void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final
75 {
77 return;
78 }
79 }
80
81 private:
82 void updateTimeDependentParams(framework::ProcessingContext& pc)
83 {
85 static bool initOnceDone = false;
86 if (!initOnceDone) { // these params need to be queried only once
87 initOnceDone = true;
88
89 mQC.init();
90
91 // Local pad gain calibration from krypton run
92 auto localGain = *(pc.inputs().get<o2::trd::LocalGainFactor*>("localgainfactors"));
93 mQC.setLocalGainFactors(localGain);
94 }
95 }
96
97 std::shared_ptr<DataRequest> mDataRequest;
98 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
99 bool mTPCavailable{false};
100 Tracking mQC;
101};
102
104{
105 std::vector<OutputSpec> outputs;
106 outputs.emplace_back("TRD", "TRACKINGQC", 0, Lifetime::Timeframe);
107 auto dataRequest = std::make_shared<DataRequest>();
108 bool isTPCavailable = false;
109
110 if (GTrackID::includesSource(GTrackID::Source::ITSTPC, src)) {
111 LOGF(debug, "Found ITS-TPC tracks as input, loading ITS-TPC-TRD");
112 src |= GTrackID::getSourcesMask("ITS-TPC-TRD");
113 }
114 if (GTrackID::includesSource(GTrackID::Source::TPC, src)) {
115 LOGF(debug, "Found TPC tracks as input, loading TPC-TRD");
116 src |= GTrackID::getSourcesMask("TPC-TRD");
117 isTPCavailable = true;
118 }
119 GTrackID::mask_t srcClu = GTrackID::getSourcesMask("TRD"); // we don't need all clusters, only TRD tracklets
120
121 dataRequest->requestTracks(src, false);
122 dataRequest->requestClusters(srcClu, false);
123 dataRequest->inputs.emplace_back("localgainfactors", "TRD", "LOCALGAINFACTORS", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/LocalGainFactor"));
124 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
125 false, // GRPECS=true
126 false, // GRPLHCIF
127 true, // GRPMagField
128 true, // askMatLUT
130 dataRequest->inputs,
131 true);
132 return DataProcessorSpec{
133 "trd-tracking-qc",
134 dataRequest->inputs,
135 outputs,
136 AlgorithmSpec{adaptFromTask<TRDGlobalTrackingQC>(dataRequest, ggRequest, isTPCavailable)},
137 Options{}};
138}
139
140template <typename T>
142
144{
145 return framework::MakeRootTreeWriterSpec("trd-tracking-qc-writer",
146 "trdQC.root",
147 "qc",
148 BranchDefinition<std::vector<TrackQC>>{InputSpec{"trackingqc", "TRD", "TRACKINGQC"}, "trackQC"})();
149};
150
151} // namespace trd
152} // namespace o2
153
154#endif // O2_TRD_GLOBALTRACKINGQCSPEC_H
Wrapper container for different reconstructed object types.
Definition of the GeometryManager class.
std::ostringstream debug
Helper for geometry and GRP related CCDB requests.
Header of the General Run Parameters object.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Configurable generator for RootTreeWriter processor spec.
Check the performance of the TRD in global tracking.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static mask_t getSourcesMask(const std::string_view srcList)
decltype(auto) get(R binding, int part=0) const
Generate a processor spec for the RootTreeWriter utility.
InputRecord & inputs()
The inputs associated with this processing context.
~TRDGlobalTrackingQC() override=default
TRDGlobalTrackingQC(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, bool tpcAvailable)
void run(ProcessingContext &pc) final
void finaliseCCDB(framework::ConcreteDataMatcher &matcher, void *obj) final
void endOfStream(framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(InitContext &ic) final
void setInput(const o2::globaltracking::RecoContainer &input)
Initialize the input arrays.
Definition Tracking.cxx:31
void run()
Main processing function.
Definition Tracking.cxx:41
std::vector< TrackQC > & getTrackQC()
Definition Tracking.h:98
void disablePID()
Disable TPC dEdx information.
Definition Tracking.h:95
void reset()
Reset the output vector.
Definition Tracking.h:89
void setLocalGainFactors(const o2::trd::LocalGainFactor &localGain)
Definition Tracking.h:101
void init()
Load geometry and apply magnetic field setting.
Definition Tracking.cxx:26
void setApplyShift(bool f)
Definition Tracking.h:83
GLenum src
Definition glcorearb.h:1767
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
DataProcessorSpec getTRDTrackingQCWriterSpec()
DataProcessorSpec getTRDGlobalTrackingQCSpec(o2::dataformats::GlobalTrackID::mask_t src)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)