Project
Loading...
Searching...
No Matches
TOFMatchChecker.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
14#include <vector>
15#include <string>
16#include "TStopwatch.h"
23#include "Framework/Task.h"
25
26// from Tracks
34
35// from TOF
36#include "TOFBase/Geo.h"
38//#include "GlobalTracking/MatchTOF.h"
40
41using namespace o2::framework;
42// using MCLabelsTr = gsl::span<const o2::MCCompLabel>;
43// using GID = o2::dataformats::GlobalTrackID;
45
47using MatchOutputType = std::vector<o2::dataformats::MatchInfoTOF>;
49
50namespace o2
51{
52namespace globaltracking
53{
54
55class TOFMatchChecker : public Task
56{
57 public:
58 TOFMatchChecker(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mUseMC(useMC) {}
59 ~TOFMatchChecker() override = default;
60 void init(InitContext& ic) final;
61 void run(ProcessingContext& pc) final;
63 void checkMatching(GID gid);
64 void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) final;
65
66 private:
67 void updateTimeDependentParams(ProcessingContext& pc);
68 bool mIsTPC;
69 bool mIsTPCTRD;
70 bool mIsITSTPCTRD;
71 bool mIsITSTPC;
72 gsl::span<const o2::tof::Cluster> mTOFClustersArrayInp;
73
74 RecoContainer mRecoData;
75 std::shared_ptr<DataRequest> mDataRequest;
76 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
77 bool mUseMC = true;
78 TStopwatch mTimer;
79};
80
82{
83 if (!gid.includesDet(DetID::TOF)) {
84 return;
85 }
86 const o2::dataformats::MatchInfoTOF& match = mRecoData.getTOFMatch(gid);
87
88 int trksource = 5;
89 if (gid.getSource() == GID::TPCTOF) {
90 trksource = 0;
91 } else if (gid.getSource() == GID::ITSTPCTOF) {
92 trksource = 1;
93 } else if (gid.getSource() == GID::TPCTRDTOF) {
94 trksource = 2;
95 } else if (gid.getSource() == GID::ITSTPCTRDTOF) {
96 trksource = 3;
97 }
98
99 const char* sources[5] = {"TPC", "ITS-TPC", "TPC-TRD", "ITS-TPC-TRD", "NONE"};
100
101 int tofcl = match.getIdxTOFCl();
102 int trIndex = match.getTrackIndex();
103 float chi2 = match.getChi2();
104 float ttof = mTOFClustersArrayInp[tofcl].getTime();
105 float x = mTOFClustersArrayInp[tofcl].getX();
106 float y = mTOFClustersArrayInp[tofcl].getY();
107 float z = mTOFClustersArrayInp[tofcl].getZ();
108 int sector = mTOFClustersArrayInp[tofcl].getSector();
109 LOG(info) << "trkSource=" << sources[trksource] << " -- cl=" << tofcl << " - trk=" << trIndex << " - chi2 =" << chi2 << " - time=" << ttof << " - coordinates (to be rotated, sector=" << sector << ") = (" << x << "," << y << "," << z << ")";
110
111 // digit coordinates
112 int mainCh = mTOFClustersArrayInp[tofcl].getMainContributingChannel();
113 int addCh;
114 int det[5];
115 float pos[3];
118 LOG(debug) << "Cluster mult = " << mTOFClustersArrayInp[tofcl].getNumOfContributingChannels() << " - main channel (" << mainCh << ") -> pos(" << pos[0] << "," << pos[1] << "," << pos[2] << ")";
119
120 // top->+48, bottom->-48, left->-1, right->+1
121 if (mTOFClustersArrayInp[tofcl].getNumOfContributingChannels() > 1) {
122 if (mTOFClustersArrayInp[tofcl].isAdditionalChannelSet(o2::tof::Cluster::kUpRight)) {
123 addCh = mainCh + 48 + 1;
126 LOG(debug) << "top right (" << addCh << ") -> pos(" << pos[0] << "," << pos[1] << "," << pos[2] << ")";
127 }
128 if (mTOFClustersArrayInp[tofcl].isAdditionalChannelSet(o2::tof::Cluster::kUp)) {
129 addCh = mainCh + 48;
132 LOG(debug) << "top (" << addCh << ") -> pos(" << pos[0] << "," << pos[1] << "," << pos[2] << ")";
133 }
134 if (mTOFClustersArrayInp[tofcl].isAdditionalChannelSet(o2::tof::Cluster::kUpLeft)) {
135 addCh = mainCh + 48 - 1;
138 LOG(debug) << "top left (" << addCh << ") -> pos(" << pos[0] << "," << pos[1] << "," << pos[2] << ")";
139 }
140 if (mTOFClustersArrayInp[tofcl].isAdditionalChannelSet(o2::tof::Cluster::kRight)) {
141 addCh = mainCh + 1;
144 LOG(debug) << "right (" << addCh << ") -> pos(" << pos[0] << "," << pos[1] << "," << pos[2] << ")";
145 }
146 if (mTOFClustersArrayInp[tofcl].isAdditionalChannelSet(o2::tof::Cluster::kLeft)) {
147 addCh = mainCh - 1;
150 LOG(debug) << "left (" << addCh << ") -> pos(" << pos[0] << "," << pos[1] << "," << pos[2] << ")";
151 }
152 if (mTOFClustersArrayInp[tofcl].isAdditionalChannelSet(o2::tof::Cluster::kDownRight)) {
153 addCh = mainCh - 48 + 1;
156 LOG(debug) << "down right (" << addCh << ") -> pos(" << pos[0] << "," << pos[1] << "," << pos[2] << ")";
157 }
158 if (mTOFClustersArrayInp[tofcl].isAdditionalChannelSet(o2::tof::Cluster::kDown)) {
159 addCh = mainCh - 48;
162 LOG(debug) << "down (" << addCh << ") -> pos(" << pos[0] << "," << pos[1] << "," << pos[2] << ")";
163 }
164 if (mTOFClustersArrayInp[tofcl].isAdditionalChannelSet(o2::tof::Cluster::kDownLeft)) {
165 addCh = mainCh - 48 - 1;
168 LOG(debug) << "down left (" << addCh << ") -> pos(" << pos[0] << "," << pos[1] << "," << pos[2] << ")";
169 }
170 }
171
172 LOG(debug) << "";
173}
174
176{
177 mTimer.Stop();
178 mTimer.Reset();
180}
181
183{
184 mTimer.Start(false);
185
186 mRecoData.collectData(pc, *mDataRequest.get());
187 updateTimeDependentParams(pc);
188
193
194 mTOFClustersArrayInp = mRecoData.getTOFClusters();
195
196 LOG(debug) << "isTrackSourceLoaded: TPC -> " << mIsTPC << " (t=" << mRecoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTOF) << ",m=" << mRecoData.isMatchSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTOF) << ")";
197 LOG(debug) << "isTrackSourceLoaded: ITSTPC -> " << mIsITSTPC << " (t=" << mRecoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTOF) << ",m=" << mRecoData.isMatchSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTOF) << ")";
198 LOG(debug) << "isTrackSourceLoaded: TPCTRD -> " << mIsTPCTRD << " (t=" << mRecoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTRDTOF) << ",m=" << mRecoData.isMatchSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTRDTOF) << ")";
199 LOG(debug) << "isTrackSourceLoaded: ITSTPCTRD -> " << mIsITSTPCTRD << " (t=" << mRecoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTRDTOF) << ",m=" << mRecoData.isMatchSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTRDTOF) << ")";
200 LOG(debug) << "TOF cluster size = " << mTOFClustersArrayInp.size();
201
202 if (!mTOFClustersArrayInp.size()) {
203 return;
204 }
205
206 auto creator = [this](auto& trk, GID gid, float time0, float terr) {
207 this->checkMatching(gid);
208 return true;
209 };
210 mRecoData.createTracksVariadic(creator);
211
212 mTimer.Stop();
213}
214
216{
217 LOGF(debug, "TOF matching total timing: Cpu: %.3e Real: %.3e s in %d slots",
218 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
219}
220
222{
224 return;
225 }
226}
227
228void TOFMatchChecker::updateTimeDependentParams(ProcessingContext& pc)
229{
231 static bool initOnceDone = false;
232 if (!initOnceDone) { // this params need to be queried only once
233 initOnceDone = true;
234 // put here one-time inits
235 }
236 // we may have other params which need to be queried regularly
237}
238
240{
241 auto dataRequest = std::make_shared<DataRequest>();
242
243 // request TOF clusters
244 dataRequest->requestTracks(src, useMC);
245 dataRequest->requestClusters(GID::getSourceMask(GID::TOF), useMC);
246 dataRequest->requestTOFMatches(src, useMC);
247 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
248 false, // GRPECS=true
249 false, // GRPLHCIF
250 false, // GRPMagField
251 false, // askMatLUT
253 dataRequest->inputs,
254 true);
255 return DataProcessorSpec{
256 "tof-matcher",
257 dataRequest->inputs,
258 {},
259 AlgorithmSpec{adaptFromTask<TOFMatchChecker>(dataRequest, ggRequest, useMC)},
260 Options{}};
261}
262
263} // namespace globaltracking
264} // namespace o2
Wrapper container for different reconstructed object types.
Definition of the TOF cluster.
std::ostringstream debug
Helper for geometry and GRP related CCDB requests.
Accessor for TrackParCov derived objects from multiple containers.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
std::vector< o2::dataformats::MatchInfoHMP > MatchOutputType
Class to perform TPC ITS matching.
Definition of the Names Generator class.
uint16_t pos
Definition RawData.h:3
Wrapper container for different reconstructed object types.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
static constexpr ID TOF
Definition DetID.h:66
TOFMatchChecker(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, bool useMC)
void init(InitContext &ic) final
void endOfStream(framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(ProcessingContext &pc) final
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
static void getPos(Int_t *det, Float_t *pos)
Definition Geo.cxx:491
static void getVolumeIndices(Int_t index, Int_t *detId)
Definition Geo.cxx:543
bool match(const std::vector< std::string > &queries, const char *pattern)
Definition dcs-ccdb.cxx:229
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
GLsizei GLenum * sources
Definition glcorearb.h:2516
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
framework::DataProcessorSpec getTOFMatchCheckerSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC)
create a processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
bool isMatchSourceLoaded(int src) const
void createTracksVariadic(T creator, GTrackID::mask_t srcSel=GTrackID::getSourcesMask("all")) const
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
const o2::dataformats::MatchInfoTOF & getTOFMatch(GTrackID id) const
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"