Project
Loading...
Searching...
No Matches
TrackCuts.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
14
15// This class is developed in order to be used for extensive track selections. The selections are done detector wise
16//(or for detector combinations).
17// sources: https://github.com/AliceO2Group/AliceO2/blob/e988b0c43346ccb24f3515d1a24f058313f14a0f/DataFormats/Reconstruction/include/ReconstructionDataFormats/GlobalTrackID.h#L40
18//
19// !!! For further development:
20// The main method is isSelected(o2::dataformats::GlobalTrackID, o2::globaltracking::RecoContainer&), which is a boolean
21// that returns true only if all the checks are passed. First, based on the global track id, the track detector source is
22// inquired(e.g. below for ITS and TPC tracks). The source-specific tracks is initialized in order to access the
23// source-specific parameters than one wants to perform selections on.
24// For each detector source, the inquiry should be done in such way that “false” should be returned if the checks are not passed,
25// moving to the next detector source otherwise.
26// (e.g below for TPC tracks, where the track selections used here: https://github.com/AliceO2Group/AliceO2/blob/dev/Detectors/GlobalTracking/src/MatchITSTPCQC.cxx#L318
27// are reproduced;
28// Moreover, an example of how this class should be used can be found here: https://github.com/AliceO2Group/AliceO2/blob/dev/Detectors/GlobalTracking/src/MatchITSTPCQC.cxx#L184).
29
30#ifndef O2_TRACK_CUTS_STUDY_H
31#define O2_TRACK_CUTS_STUDY_H
32
33#include "Framework/Logger.h"
34#include "Framework/DataTypes.h"
43#include <set>
44#include <vector>
45#include "Rtypes.h"
46#include <gsl/span>
47namespace o2
48{
49namespace its
50{
51namespace study
52{
56{
57 public:
59 {
60 const auto& tpcTracks = data.getTPCTracks();
61 const auto& tpcClusRefs = data.getTPCTracksClusterRefs();
62 const auto& tpcClusShMap = data.clusterShMapTPC;
63 const auto& tpcClusAcc = data.getTPCClusters();
64 constexpr int maxRows = 152;
65 constexpr int neighbour = 2;
66 int ntr = tpcTracks.size();
67 mTPCCounters.clear();
68 mTPCCounters.resize(ntr);
69 for (int itr = 0; itr < ntr; itr++) {
70 std::array<bool, maxRows> clMap{}, shMap{};
71 uint8_t sectorIndex, rowIndex;
72 uint32_t clusterIndex;
73 auto& counters = mTPCCounters[itr];
74 const auto& track = tpcTracks[itr];
75 for (int i = 0; i < track.getNClusterReferences(); i++) {
76 o2::tpc::TrackTPC::getClusterReference(tpcClusRefs, i, sectorIndex, rowIndex, clusterIndex, track.getClusterRef());
77 unsigned int absoluteIndex = tpcClusAcc.clusterOffset[sectorIndex][rowIndex] + clusterIndex;
78 clMap[rowIndex] = true;
79 if (tpcClusShMap[absoluteIndex] & o2::gpu::GPUTPCGMMergedTrackHit::flagShared) {
80 if (!shMap[rowIndex]) {
81 counters.shared++;
82 }
83 shMap[rowIndex] = true;
84 }
85 }
86 int last = -1;
87 for (int i = 0; i < maxRows; i++) {
88 if (clMap[i]) {
89 counters.crossed++;
90 counters.found++;
91 last = i;
92 } else if ((i - last) <= neighbour) {
93 counters.crossed++;
94 } else {
95 int lim = std::min(i + 1 + neighbour, maxRows);
96 for (int j = i + 1; j < lim; j++) {
97 if (clMap[j]) {
98 counters.crossed++;
99 break;
100 }
101 }
102 }
103 }
104 }
105 }
108 {
110 auto contributorsGID = data.getSingleDetectorRefs(trackIndex);
111 auto src = trackIndex.getSource(); // make selections depending on track source
112 // ITS tracks
113 if (contributorsGID[GIndex::Source::ITS].isIndexSet()) { // ITS tracks selection
114 isBarrelTrack = true;
115 const auto& itsTrk = data.getITSTrack(contributorsGID[GID::ITS]);
116 int ITSnClusters = itsTrk.getNClusters();
117 float ITSchi2 = itsTrk.getChi2();
118 float itsChi2NCl = ITSnClusters != 0 ? ITSchi2 / (float)ITSnClusters : 0;
119 uint8_t itsClusterMap = itsTrk.getPattern();
120 SetRequireHitsInITSLayers(1, {0, 1, 2});
121 if (itsChi2NCl >= mMaxChi2PerClusterITS ||
122 TrackMethods::FulfillsITSHitRequirements(itsClusterMap, mRequiredITSHits) == false) {
123 // LOGP(info,"FAILURE hits in ITS layers");
124 return false;
125 }
126 }
127 // TPC tracks
128 /* if (contributorsGID[GIndex::Source::TPC].isIndexSet()) {
129 LOGP(info, "****** INSIDE TPC ********");
130 //countTPCClusters(data);
131 isBarrelTrack = true;
132 const auto& tpcTrk = data.getTPCTrack(contributorsGID[GID::TPC]);
133 const auto& tpcClData = mTPCCounters[contributorsGID[GID::TPC]];
134 math_utils::Point3D<float> v{};
135 std::array<float, 2> dca;
136 int tpcNClsFindable = tpcTrk.getNClusters();
137 float tpcChi2NCl = tpcTrk.getNClusters() ? tpcTrk.getChi2() / tpcTrk.getNClusters() : 0;
138 double tpcNClsFindableMinusFound = tpcTrk.getNClusters() - tpcClData.found;
139 double tpcNClsFindableMinusCrossedRows = tpcTrk.getNClusters() - tpcClData.crossed;
140 float tpcNClsCrossedRows = (float)((int16_t)tpcNClsFindable - tpcNClsFindableMinusCrossedRows)/tpcNClsFindable;
141 float tpcCrossedRowsOverFindableCl = (float)tpcNClsCrossedRows / (float)tpcNClsFindable;
142 if(tpcCrossedRowsOverFindableCl < 0.8) {
143 LOGP(info,"FAILURE tpcCrossedRowsOverFindableCl");
144 return false;
145 }
146 if(tpcClData.crossed < 70){
147 LOGP(info,"FAILURE crossed");
148 return false;
149 }
150 if(tpcChi2NCl >= mMaxChi2PerClusterTPC){
151 LOGP(info,"FAILURE tpcChi2NCl");
152 return false;
153 }
154 } */
155 if (isBarrelTrack) { // track selection for barrel tracks
156 trk = data.getTrackParam(trackIndex);
157 if (trk.getPt() < mMinPt && trk.getPt() > mMaxPt && trk.getEta() < mMinEta && trk.getEta() > mMaxEta) {
158 return false;
159 }
160 }
161 return true;
162 }
163
164 void SetRequireHitsInITSLayers(int8_t minNRequiredHits, std::set<uint8_t> requiredLayers)
165 {
166 // layer 0 corresponds to the the innermost ITS layer
167 mRequiredITSHits.push_back(std::make_pair(minNRequiredHits, requiredLayers));
168 // LOG(info) << "Track selection, set require hits in ITS layers: " << static_cast<int>(minNRequiredHits);
169 }
170
171 private:
172 // counters for TPC clusters
173 struct TPCCounters {
174 uint8_t shared = 0;
175 uint8_t found = 0;
176 uint8_t crossed = 0;
177 };
178 std::vector<TPCCounters> mTPCCounters;
179
180 bool isBarrelTrack = true; // all barrel tracks must have either ITS or TPC contribution -> true if ITS || TPC track source condition is passed
181 // cut values
182 float mPtTPCCut = 0.1f;
183 float mEtaTPCCut = 1.4f;
184 int32_t mNTPCClustersCut = 60;
185 float mDCACut = 100.f;
186 float mDCACutY = 10.f;
187 // kinematic cuts
188 float mMinPt{0.1f}, mMaxPt{1e10f}; // range in pT
189 float mMinEta{0.8}, mMaxEta{0.8}; // range in eta
190 float mBz = o2::base::Propagator::Instance()->getNominalBz();
191
192 float mMaxChi2PerClusterITS{36.0}; // max its fit chi2 per ITS cluster
193 float mMaxChi2PerClusterTPC{4.0}; // max its fit chi2 per ITS cluster
194 int mMinNClustersITS{0}; // min number of ITS clusters
195
196 // vector of ITS requirements (minNRequiredHits in specific requiredLayers)
197 int8_t minNRequiredHits = 1;
198 std::set<uint8_t> requiredLayers{0, 1, 2}; // one hit in the first three layers
199 std::vector<std::pair<int8_t, std::set<uint8_t>>> mRequiredITSHits{};
200
201 ClassDefNV(TrackCuts, 1);
202};
203} // namespace study
204} // namespace its
205} // namespace o2
206
207#endif
Wrapper container for different reconstructed object types.
Base track model for the Barrel, params only, w/o covariance.
int32_t i
Class to store the output of the matching to TOF.
uint32_t j
Definition RawData.h:0
Extention of GlobalTrackID by flags relevant for verter-track association.
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
Definition Propagator.h:143
void SetRequireHitsInITSLayers(int8_t minNRequiredHits, std::set< uint8_t > requiredLayers)
Definition TrackCuts.h:164
bool isSelected(GID trackIndex, o2::globaltracking::RecoContainer &data)
Definition TrackCuts.h:107
void countTPCClusters(const o2::globaltracking::RecoContainer &data)
Definition TrackCuts.h:58
static bool FulfillsITSHitRequirements(uint8_t itsClusterMap, std::vector< std::pair< int8_t, std::set< uint8_t > > > mRequiredITSHits)
GLenum src
Definition glcorearb.h:1767
GLint GLint GLsizei GLuint * counters
Definition glcorearb.h:3985
GLboolean * data
Definition glcorearb.h:298
TrackParCovF TrackParCov
Definition Track.h:33
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...