CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
TrackQuality Class Reference

This class analyses the reconstruction quality for a given track. More...

#include <TrackQuality.h>

Classes

struct  Layer
 

Public Types

enum  QualityAlgorithm { QualityAlgorithm::Cut, QualityAlgorithm::GBDT, QualityAlgorithm::NN, QualityAlgorithm::None }
 
typedef std::vector< TrackingParticleRefSimParticleTrail
 

Public Member Functions

void evaluate (SimParticleTrail const &, reco::TrackBaseRef const &, const TrackerTopology *tTopo)
 Compute information about the track reconstruction quality. More...
 
std::vector< float > featureTransform (TTTrack< Ref_Phase2TrackerDigi_ > &aTrack, std::vector< std::string > const &featureNames)
 
const Layerlayer (unsigned int index) const
 Return information about the given layer by index. More...
 
void newEvent (const edm::Event &, const edm::EventSetup &)
 Pre-process event information (for accessing reconstruction information) More...
 
unsigned int numberOfLayers () const
 Return the number of layers with simulated and/or reconstructed hits. More...
 
void setCutParameters (std::string const &AlgorithmString, float maxZ0, float maxEta, float chi2dofMax, float bendchi2Max, float minPt, int nStubmin)
 
void setONNXModel (std::string const &AlgorithmString, edm::FileInPath const &ONNXmodel, std::string const &ONNXInputName, std::vector< std::string > const &featureNames)
 
void setTrackQuality (TTTrack< Ref_Phase2TrackerDigi_ > &aTrack)
 
 TrackQuality ()
 
 TrackQuality (const edm::ParameterSet &, edm::ConsumesCollector &iC)
 Constructor by pset. More...
 
 TrackQuality (const edm::ParameterSet &qualityParams)
 
 ~TrackQuality ()=default
 

Private Attributes

std::unique_ptr< TrackerHitAssociatorassociator_
 
float bendchi2Max_
 
float chi2dofMax_
 
std::vector< std::string > featureNames_
 
std::vector< Layerlayers_
 
float maxEta_
 
float maxZ0_
 
float minPt_
 
int nStubsmin_
 
std::string ONNXInputName_
 
float ONNXInvRScaling_
 
edm::FileInPath ONNXmodel_
 
QualityAlgorithm qualityAlgorithm_ = QualityAlgorithm::None
 
TrackerHitAssociator::Config trackerHitAssociatorConfig_
 

Detailed Description

This class analyses the reconstruction quality for a given track.

Definition at line 29 of file TrackQuality.h.

Member Typedef Documentation

◆ SimParticleTrail

Definition at line 30 of file TrackQuality.h.

Member Enumeration Documentation

◆ QualityAlgorithm

Enumerator
Cut 
GBDT 
NN 
None 

Definition at line 32 of file TrackQuality.h.

32 { Cut, GBDT, NN, None };

Constructor & Destructor Documentation

◆ TrackQuality() [1/3]

TrackQuality::TrackQuality ( )

Definition at line 12 of file TrackQuality.cc.

12 {}

◆ TrackQuality() [2/3]

TrackQuality::TrackQuality ( const edm::ParameterSet qualityParams)

Definition at line 14 of file TrackQuality.cc.

14  {
15  std::string AlgorithmString = qualityParams.getParameter<std::string>("qualityAlgorithm");
16  // Unpacks EDM parameter set itself to save unecessary processing within TrackProducers
17  if (AlgorithmString == "Cut") {
18  setCutParameters(AlgorithmString,
19  (float)qualityParams.getParameter<double>("maxZ0"),
20  (float)qualityParams.getParameter<double>("maxEta"),
21  (float)qualityParams.getParameter<double>("chi2dofMax"),
22  (float)qualityParams.getParameter<double>("bendchi2Max"),
23  (float)qualityParams.getParameter<double>("minPt"),
24  qualityParams.getParameter<int>("nStubsmin"));
25  }
26 
27  else {
28  setONNXModel(AlgorithmString,
29  qualityParams.getParameter<edm::FileInPath>("ONNXmodel"),
30  qualityParams.getParameter<std::string>("ONNXInputName"),
31  qualityParams.getParameter<std::vector<std::string>>("featureNames"));
32  ONNXInvRScaling_ = qualityParams.getParameter<double>("ONNXInvRScale");
33  }
34 }

References edm::ParameterSet::getParameter(), ONNXInvRScaling_, setCutParameters(), setONNXModel(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~TrackQuality()

TrackQuality::~TrackQuality ( )
default

◆ TrackQuality() [3/3]

TrackQuality::TrackQuality ( const edm::ParameterSet config,
edm::ConsumesCollector iC 
)

Constructor by pset.

Definition at line 135 of file TrackQuality.cc.

136  : trackerHitAssociatorConfig_(config.getParameter<edm::ParameterSet>("hitAssociator"), std::move(iC)) {}

Member Function Documentation

◆ evaluate()

void TrackQuality::evaluate ( SimParticleTrail const &  spt,
reco::TrackBaseRef const &  tr,
const TrackerTopology tTopo 
)

Compute information about the track reconstruction quality.

Definition at line 142 of file TrackQuality.cc.

142  {
143  std::vector<MatchedHit> matchedHits;
144 
145  // iterate over reconstructed hits
146  for (trackingRecHit_iterator hit = tr->recHitsBegin(); hit != tr->recHitsEnd(); ++hit) {
147  // on which module the hit lies
148  DetId detId = (*hit)->geographicalId();
149 
150  // FIXME: check for double-sided modules?
151 
152  // didn't find a hit on that module
153  if (!(*hit)->isValid()) {
154  MatchedHit matchedHit;
155  matchedHit.detId = detId;
156  matchedHit.simTrackId = NonMatchedTrackId;
157  // check why hit wasn't valid and propagate information
158  switch ((*hit)->getType()) {
160  matchedHit.state = Layer::Dead;
161  break;
162 
163  case TrackingRecHit::bad:
164  matchedHit.state = Layer::Bad;
165  break;
166 
167  default:
168  matchedHit.state = Layer::Missed;
169  }
170  matchedHit.recHitId = hit - tr->recHitsBegin();
171  matchedHits.push_back(matchedHit);
172  continue;
173  }
174 
175  // find simulated tracks causing hit that was reconstructed
176  std::vector<SimHitIdpr> simIds = associator_->associateHitId(**hit);
177 
178  // must be noise or so
179  if (simIds.empty()) {
180  MatchedHit matchedHit;
181  matchedHit.detId = detId;
182  matchedHit.simTrackId = NonMatchedTrackId;
183  matchedHit.state = Layer::Noise;
184  matchedHit.recHitId = hit - tr->recHitsBegin();
185  matchedHits.push_back(matchedHit);
186  continue;
187  }
188 
189  // register all simulated tracks contributing
190  for (std::vector<SimHitIdpr>::const_iterator i = simIds.begin(); i != simIds.end(); ++i) {
191  MatchedHit matchedHit;
192  matchedHit.detId = detId;
193  matchedHit.simTrackId = i->first;
194  matchedHit.collision = i->second;
195  // RecHit <-> SimHit matcher currently doesn't support muon system
196  if (detId.det() == DetId::Muon)
197  matchedHit.state = Layer::Unknown;
198  else
199  // assume hit was mismatched (until possible confirmation)
200  matchedHit.state = Layer::Misassoc;
201  matchedHit.recHitId = hit - tr->recHitsBegin();
202  matchedHits.push_back(matchedHit);
203  }
204  }
205 
206  // sort hits found so far by module id
207  std::stable_sort(matchedHits.begin(), matchedHits.end());
208 
209  // in case we added missed modules, re-sort
210  std::stable_sort(matchedHits.begin(), matchedHits.end());
211 
212  // prepare for ordering results by layer enum and layer/disk number
213  typedef std::multimap<DetLayer, const MatchedHit *> LayerHitMap;
214  LayerHitMap layerHitMap;
215 
216  // iterate over all simulated/reconstructed hits again
217  for (std::vector<MatchedHit>::const_iterator hit = matchedHits.begin(); hit != matchedHits.end();) {
218  // we can have multiple reco-to-sim matches per module, find best one
219  const MatchedHit *best = nullptr;
220 
221  // this loop iterates over all subsequent hits in the same module
222  do {
223  // update our best hit pointer
224  if (!best || statePriorities[hit->state] > statePriorities[best->state] ||
225  best->simTrackId == NonMatchedTrackId) {
226  best = &*hit;
227  }
228  ++hit;
229  } while (hit != matchedHits.end() && hit->detId == best->detId);
230 
231  // ignore hit in case track reco was looking at the wrong module
232  if (best->simTrackId != NonMatchedTrackId || best->state != Layer::Missed) {
233  layerHitMap.insert(std::make_pair(getDetLayer(best->detId, tTopo), best));
234  }
235  }
236 
237  layers_.clear();
238 
239 #ifdef DEBUG_TRACK_QUALITY
240  std::cout << "---------------------" << std::endl;
241 #endif
242  // now prepare final collection
243  for (LayerHitMap::const_iterator hit = layerHitMap.begin(); hit != layerHitMap.end(); ++hit) {
244 #ifdef DEBUG_TRACK_QUALITY
245  std::cout << "detLayer (" << hit->first.first << ", " << hit->first.second << ")"
246  << " [" << (uint32_t)hit->second->detId << "] sim(" << (int)hit->second->simTrackId << ")"
247  << " hit(" << hit->second->recHitId << ") -> " << hit->second->state << std::endl;
248 #endif
249 
250  // find out if we need to start a new layer
251  Layer *layer = layers_.empty() ? nullptr : &layers_.back();
252  if (!layer || hit->first.first != layer->subDet || hit->first.second != layer->layer) {
253  Layer newLayer;
254  newLayer.subDet = hit->first.first;
255  newLayer.layer = hit->first.second;
256  layers_.push_back(newLayer);
257  layer = &layers_.back();
258  }
259 
260  // create hit and add it to layer
261  Layer::Hit newHit;
262  newHit.recHitId = hit->second->recHitId;
263  newHit.state = hit->second->state;
264 
265  layer->hits.push_back(newHit);
266  }
267 }

References associator_, TrackQuality::Layer::Bad, TrackingRecHit::bad, gather_cfg::cout, TrackQuality::Layer::Dead, DetId::det(), getDetLayer(), TrackQuality::Layer::hits, mps_fire::i, TrackingRecHit::inactive, TrackQuality::Layer::layer, layer(), layers_, TrackQuality::Layer::Misassoc, TrackQuality::Layer::Missed, DetId::Muon, TrackQuality::Layer::Noise, TrackQuality::Layer::Hit::recHitId, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), TrackQuality::Layer::Hit::state, statePriorities, TrackQuality::Layer::subDet, and TrackQuality::Layer::Unknown.

Referenced by TrackClassifier::qualityInformation().

◆ featureTransform()

std::vector< float > TrackQuality::featureTransform ( TTTrack< Ref_Phase2TrackerDigi_ > &  aTrack,
std::vector< std::string > const &  featureNames 
)

Definition at line 36 of file TrackQuality.cc.

37  {
38  // List input features for MVA in proper order below, the features options are
39  // {"log_chi2","log_chi2rphi","log_chi2rz","log_bendchi2","nstubs","lay1_hits","lay2_hits",
40  // "lay3_hits","lay4_hits","lay5_hits","lay6_hits","disk1_hits","disk2_hits","disk3_hits",
41  // "disk4_hits","disk5_hits","rinv","tanl","z0","dtot","ltot","chi2","chi2rz","chi2rphi",
42  // "bendchi2","pt","eta","nlaymiss_interior","phi","bendchi2_bin","chi2rz_bin","chi2rphi_bin"}
43 
44  std::vector<float> transformedFeatures;
45 
46  // Define feature map, filled as features are generated
47  std::map<std::string, float> feature_map;
48 
49  // The following converts the 7 bit hitmask in the TTTrackword to an expected
50  // 11 bit hitmask based on the eta of the track
51  std::vector<int> hitpattern_binary = {0, 0, 0, 0, 0, 0, 0};
52  std::vector<int> hitpattern_expanded_binary = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
53  std::vector<float> eta_bins = {0.0, 0.2, 0.41, 0.62, 0.9, 1.26, 1.68, 2.08, 2.4};
54 
55  // Expected hitmap table, each row corresponds to an eta bin, each value corresponds to
56  // the expected layer in the expanded hit pattern. The expanded hit pattern should be
57  // 11 bits but contains a 12th element so this hitmap table is symmetric
58  int hitmap[8][7] = {{0, 1, 2, 3, 4, 5, 11},
59  {0, 1, 2, 3, 4, 5, 11},
60  {0, 1, 2, 3, 4, 5, 11},
61  {0, 1, 2, 3, 4, 5, 11},
62  {0, 1, 2, 3, 4, 5, 11},
63  {0, 1, 2, 6, 7, 8, 9},
64  {0, 1, 7, 8, 9, 10, 11},
65  {0, 6, 7, 8, 9, 10, 11}};
66 
67  // iterate through bits of the hitpattern and compare to 1 filling the hitpattern binary vector
68  int tmp_trk_hitpattern = aTrack.hitPattern();
69  for (int i = 6; i >= 0; i--) {
70  int k = tmp_trk_hitpattern >> i;
71  if (k & 1)
72  hitpattern_binary[i] = 1;
73  }
74 
75  // calculate number of missed interior layers from hitpattern
76  int nbits = floor(log2(tmp_trk_hitpattern)) + 1;
77  int lay_i = 0;
78  int tmp_trk_nlaymiss_interior = 0;
79  bool seq = false;
80  for (int i = 0; i < nbits; i++) {
81  lay_i = ((1 << i) & tmp_trk_hitpattern) >> i; //0 or 1 in ith bit (right to left)
82 
83  if (lay_i && !seq)
84  seq = true; //sequence starts when first 1 found
85  if (!lay_i && seq)
86  tmp_trk_nlaymiss_interior++;
87  }
88 
89  float eta = abs(aTrack.eta());
90  int eta_size = static_cast<int>(eta_bins.size());
91  // First iterate through eta bins
92 
93  for (int j = 1; j < eta_size; j++) {
94  if (eta < eta_bins[j] && eta >= eta_bins[j - 1]) // if track in eta bin
95  {
96  // Iterate through hitpattern binary
97  for (int k = 0; k <= 6; k++)
98  // Fill expanded binary entries using the expected hitmap table positions
99  hitpattern_expanded_binary[hitmap[j - 1][k]] = hitpattern_binary[k];
100  break;
101  }
102  }
103 
104  int tmp_trk_ltot = 0;
105  //calculate number of layer hits
106  for (int i = 0; i < 6; ++i) {
107  tmp_trk_ltot += hitpattern_expanded_binary[i];
108  }
109 
110  int tmp_trk_dtot = 0;
111  //calculate number of disk hits
112  for (int i = 6; i < 11; ++i) {
113  tmp_trk_dtot += hitpattern_expanded_binary[i];
114  }
115 
116  // bin bendchi2 variable (bins from https://twiki.cern.ch/twiki/bin/viewauth/CMS/HybridDataFormat#Fitted_Tracks_written_by_KalmanF)
117  float tmp_trk_bendchi2 = aTrack.stubPtConsistency();
118  std::array<float, 8> bendchi2_bins{{0, 0.5, 1.25, 2, 3, 5, 10, 50}};
119  int n_bendchi2 = static_cast<int>(bendchi2_bins.size());
120  float tmp_trk_bendchi2_bin = -1;
121  for (int i = 0; i < n_bendchi2; i++) {
122  if (tmp_trk_bendchi2 >= bendchi2_bins[i] && tmp_trk_bendchi2 < bendchi2_bins[i + 1]) {
123  tmp_trk_bendchi2_bin = i;
124  break;
125  }
126  }
127  if (tmp_trk_bendchi2_bin < 0)
128  tmp_trk_bendchi2_bin = n_bendchi2;
129 
130  // bin chi2rphi variable (bins from https://twiki.cern.ch/twiki/bin/viewauth/CMS/HybridDataFormat#Fitted_Tracks_written_by_KalmanF)
131  float tmp_trk_chi2rphi = aTrack.chi2XY();
132  std::array<float, 16> chi2rphi_bins{{0, 0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 40, 100, 200, 500, 1000, 3000}};
133  int n_chi2rphi = static_cast<int>(chi2rphi_bins.size());
134  float tmp_trk_chi2rphi_bin = -1;
135  for (int i = 0; i < n_chi2rphi; i++) {
136  if (tmp_trk_chi2rphi >= chi2rphi_bins[i] && tmp_trk_chi2rphi < chi2rphi_bins[i + 1]) {
137  tmp_trk_chi2rphi_bin = i;
138  break;
139  }
140  }
141  if (tmp_trk_chi2rphi_bin < 0)
142  tmp_trk_chi2rphi_bin = n_chi2rphi;
143 
144  // bin chi2rz variable (bins from https://twiki.cern.ch/twiki/bin/viewauth/CMS/HybridDataFormat#Fitted_Tracks_written_by_KalmanF)
145  float tmp_trk_chi2rz = aTrack.chi2Z();
146  std::array<float, 16> chi2rz_bins{{0, 0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 40, 100, 200, 500, 1000, 3000}};
147  int n_chi2rz = static_cast<int>(chi2rz_bins.size());
148  float tmp_trk_chi2rz_bin = -1;
149  for (int i = 0; i < n_chi2rz; i++) {
150  if (tmp_trk_chi2rz >= chi2rz_bins[i] && tmp_trk_chi2rz < chi2rz_bins[i + 1]) {
151  tmp_trk_chi2rz_bin = i;
152  break;
153  }
154  }
155  if (tmp_trk_chi2rz_bin < 0)
156  tmp_trk_chi2rz_bin = n_chi2rz;
157 
158  // get the nstub
159  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>, TTStub<Ref_Phase2TrackerDigi_>>> stubRefs =
160  aTrack.getStubRefs();
161 
162  // fill the feature map
163  feature_map["nstub"] = stubRefs.size();
164  feature_map["rinv"] = ONNXInvRScaling_ * abs(aTrack.rInv());
165  feature_map["tanl"] = abs(aTrack.tanL());
166  feature_map["z0"] = aTrack.z0();
167  feature_map["phi"] = aTrack.phi();
168  feature_map["pt"] = aTrack.momentum().perp();
169  feature_map["eta"] = aTrack.eta();
170 
171  float tmp_trk_chi2 = aTrack.chi2();
172  feature_map["chi2"] = tmp_trk_chi2;
173  feature_map["log_chi2"] = log(tmp_trk_chi2);
174 
175  feature_map["chi2rphi"] = tmp_trk_chi2rphi;
176  feature_map["log_chi2rphi"] = log(tmp_trk_chi2rphi);
177 
178  feature_map["chi2rz"] = tmp_trk_chi2rz;
179  feature_map["log_chi2rz"] = log(tmp_trk_chi2rz);
180 
181  feature_map["chi2rz"] = tmp_trk_chi2rz;
182  feature_map["log_chi2rz"] = log(tmp_trk_chi2rz);
183 
184  feature_map["bendchi2"] = tmp_trk_bendchi2;
185  feature_map["log_bendchi2"] = log(tmp_trk_bendchi2);
186 
187  feature_map["lay1_hits"] = float(hitpattern_expanded_binary[0]);
188  feature_map["lay2_hits"] = float(hitpattern_expanded_binary[1]);
189  feature_map["lay3_hits"] = float(hitpattern_expanded_binary[2]);
190  feature_map["lay4_hits"] = float(hitpattern_expanded_binary[3]);
191  feature_map["lay5_hits"] = float(hitpattern_expanded_binary[4]);
192  feature_map["lay6_hits"] = float(hitpattern_expanded_binary[5]);
193  feature_map["disk1_hits"] = float(hitpattern_expanded_binary[6]);
194  feature_map["disk2_hits"] = float(hitpattern_expanded_binary[7]);
195  feature_map["disk3_hits"] = float(hitpattern_expanded_binary[8]);
196  feature_map["disk4_hits"] = float(hitpattern_expanded_binary[9]);
197  feature_map["disk5_hits"] = float(hitpattern_expanded_binary[10]);
198 
199  feature_map["dtot"] = float(tmp_trk_dtot);
200  feature_map["ltot"] = float(tmp_trk_ltot);
201 
202  feature_map["nlaymiss_interior"] = float(tmp_trk_nlaymiss_interior);
203  feature_map["bendchi2_bin"] = tmp_trk_bendchi2_bin;
204  feature_map["chi2rphi_bin"] = tmp_trk_chi2rphi_bin;
205  feature_map["chi2rz_bin"] = tmp_trk_chi2rz_bin;
206 
207  // fill tensor with track params
208  transformedFeatures.reserve(featureNames.size());
209  for (const std::string& feature : featureNames)
210  transformedFeatures.push_back(feature_map[feature]);
211 
212  return transformedFeatures;
213 }

References funct::abs(), TTTrack< T >::chi2(), TTTrack< T >::chi2XY(), TTTrack< T >::chi2Z(), PVValHelper::eta, TTTrack< T >::eta(), TrackQualityParams_cfi::featureNames, dqmMemoryStats::float, TTTrack< T >::getStubRefs(), TTTrack< T >::hitPattern(), mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, dqm-mbProfile::log, TTTrack< T >::momentum(), ONNXInvRScaling_, PV3DBase< T, PVType, FrameType >::perp(), TTTrack< T >::phi(), TTTrack< T >::rInv(), cmsswSequenceInfo::seq, AlCaHLTBitMon_QueryRunRegistry::string, TTTrack< T >::stubPtConsistency(), TTTrack< T >::tanL(), and TTTrack< T >::z0().

Referenced by setTrackQuality().

◆ layer()

const Layer& TrackQuality::layer ( unsigned int  index) const
inline

Return information about the given layer by index.

Definition at line 77 of file TrackQuality.h.

77 { return layers_[index]; }

References layers_.

Referenced by evaluate(), geometryXMLparser.DTAlignable::index(), geometryXMLparser.CSCAlignable::index(), and TrackClassifier::qualityInformation().

◆ newEvent()

void TrackQuality::newEvent ( const edm::Event ev,
const edm::EventSetup es 
)

Pre-process event information (for accessing reconstruction information)

Definition at line 138 of file TrackQuality.cc.

138  {
139  associator_ = std::make_unique<TrackerHitAssociator>(ev, trackerHitAssociatorConfig_);
140 }

References associator_, ev, and trackerHitAssociatorConfig_.

Referenced by TrackClassifier::newEvent().

◆ numberOfLayers()

unsigned int TrackQuality::numberOfLayers ( ) const
inline

Return the number of layers with simulated and/or reconstructed hits.

Definition at line 74 of file TrackQuality.h.

74 { return layers_.size(); }

References layers_.

Referenced by TrackClassifier::qualityInformation().

◆ setCutParameters()

void TrackQuality::setCutParameters ( std::string const &  AlgorithmString,
float  maxZ0,
float  maxEta,
float  chi2dofMax,
float  bendchi2Max,
float  minPt,
int  nStubmin 
)

◆ setONNXModel()

void TrackQuality::setONNXModel ( std::string const &  AlgorithmString,
edm::FileInPath const &  ONNXmodel,
std::string const &  ONNXInputName,
std::vector< std::string > const &  featureNames 
)

Definition at line 291 of file TrackQuality.cc.

294  {
295  //Convert algorithm string to Enum class for track by track comparison
296  if (AlgorithmString == "NN") {
298  } else if (AlgorithmString == "GBDT") {
300  } else {
302  }
306 }

References TrackQualityParams_cfi::featureNames, featureNames_, GBDT, NN, None, TrackQualityParams_cfi::ONNXInputName, ONNXInputName_, TrackQualityParams_cfi::ONNXmodel, ONNXmodel_, and qualityAlgorithm_.

Referenced by TrackQuality().

◆ setTrackQuality()

void TrackQuality::setTrackQuality ( TTTrack< Ref_Phase2TrackerDigi_ > &  aTrack)

Definition at line 215 of file TrackQuality.cc.

215  {
217  // Get Track parameters
218  float trk_pt = aTrack.momentum().perp();
219  float trk_bend_chi2 = aTrack.stubPtConsistency();
220  float trk_z0 = aTrack.z0();
221  float trk_eta = aTrack.momentum().eta();
222  float trk_chi2 = aTrack.chi2();
223  const auto& stubRefs = aTrack.getStubRefs();
224  int nStubs = stubRefs.size();
225 
226  float classification = 0.0; // Default classification is 0
227 
228  if (trk_pt >= this->minPt_ && abs(trk_z0) < this->maxZ0_ && abs(trk_eta) < this->maxEta_ &&
229  trk_chi2 < this->chi2dofMax_ && trk_bend_chi2 < this->bendchi2Max_ && nStubs >= this->nStubsmin_)
230  classification = 1.0;
231  // Classification updated to 1 if conditions are met
232 
233  aTrack.settrkMVA1(classification);
234  }
235 
237  // Setup ONNX input and output names and arrays
238  std::vector<std::string> ortinput_names;
239  std::vector<std::string> ortoutput_names;
240 
241  cms::Ort::FloatArrays ortinput;
242  cms::Ort::FloatArrays ortoutputs;
243 
244  std::vector<float> Transformed_features = featureTransform(aTrack, this->featureNames_);
245  cms::Ort::ONNXRuntime Runtime(this->ONNXmodel_.fullPath()); //Setup ONNX runtime
246 
247  ortinput_names.push_back(this->ONNXInputName_);
248  ortoutput_names = Runtime.getOutputNames();
249 
250  //ONNX runtime recieves a vector of vectors of floats so push back the input
251  // vector of float to create a 1,1,21 ortinput
252  ortinput.push_back(Transformed_features);
253 
254  // batch_size 1 as only one set of transformed features is being processed
255  int batch_size = 1;
256  // Run classification
257  ortoutputs = Runtime.run(ortinput_names, ortinput, {}, ortoutput_names, batch_size);
258 
260  aTrack.settrkMVA1(ortoutputs[0][0]);
261  }
262 
263  else if (this->qualityAlgorithm_ == QualityAlgorithm::GBDT) {
264  aTrack.settrkMVA1(ortoutputs[1][1]);
265  }
266  // Slight differences in the ONNX models of the GBDTs and NNs mean different
267  // indices of the ortoutput need to be accessed
268  }
269 
270  else {
271  aTrack.settrkMVA1(-999);
272  }
273 }

References funct::abs(), bendchi2Max_, TTTrack< T >::chi2(), chi2dofMax_, Cut, PV3DBase< T, PVType, FrameType >::eta(), featureNames_, featureTransform(), edm::FileInPath::fullPath(), GBDT, cms::Ort::ONNXRuntime::getOutputNames(), TTTrack< T >::getStubRefs(), maxEta_, maxZ0_, minPt_, TTTrack< T >::momentum(), NN, nStubsmin_, ONNXInputName_, ONNXmodel_, PV3DBase< T, PVType, FrameType >::perp(), qualityAlgorithm_, TTTrack< T >::settrkMVA1(), TTTrack< T >::stubPtConsistency(), and TTTrack< T >::z0().

Member Data Documentation

◆ associator_

std::unique_ptr<TrackerHitAssociator> TrackQuality::associator_
private

Definition at line 81 of file TrackQuality.h.

Referenced by evaluate(), and newEvent().

◆ bendchi2Max_

float TrackQuality::bendchi2Max_
private

Definition at line 72 of file TrackQuality.h.

Referenced by setCutParameters(), and setTrackQuality().

◆ chi2dofMax_

float TrackQuality::chi2dofMax_
private

Definition at line 71 of file TrackQuality.h.

Referenced by setCutParameters(), and setTrackQuality().

◆ featureNames_

std::vector<std::string> TrackQuality::featureNames_
private

Definition at line 68 of file TrackQuality.h.

Referenced by setONNXModel(), and setTrackQuality().

◆ layers_

std::vector<Layer> TrackQuality::layers_
private

Definition at line 83 of file TrackQuality.h.

Referenced by evaluate(), layer(), and numberOfLayers().

◆ maxEta_

float TrackQuality::maxEta_
private

Definition at line 70 of file TrackQuality.h.

Referenced by setCutParameters(), and setTrackQuality().

◆ maxZ0_

float TrackQuality::maxZ0_
private

Definition at line 69 of file TrackQuality.h.

Referenced by setCutParameters(), and setTrackQuality().

◆ minPt_

float TrackQuality::minPt_
private

Definition at line 73 of file TrackQuality.h.

Referenced by setCutParameters(), and setTrackQuality().

◆ nStubsmin_

int TrackQuality::nStubsmin_
private

Definition at line 74 of file TrackQuality.h.

Referenced by setCutParameters(), and setTrackQuality().

◆ ONNXInputName_

std::string TrackQuality::ONNXInputName_
private

Definition at line 67 of file TrackQuality.h.

Referenced by setONNXModel(), and setTrackQuality().

◆ ONNXInvRScaling_

float TrackQuality::ONNXInvRScaling_
private

Definition at line 75 of file TrackQuality.h.

Referenced by featureTransform(), and TrackQuality().

◆ ONNXmodel_

edm::FileInPath TrackQuality::ONNXmodel_
private

Definition at line 66 of file TrackQuality.h.

Referenced by setONNXModel(), and setTrackQuality().

◆ qualityAlgorithm_

QualityAlgorithm TrackQuality::qualityAlgorithm_ = QualityAlgorithm::None
private

Definition at line 65 of file TrackQuality.h.

Referenced by setCutParameters(), setONNXModel(), and setTrackQuality().

◆ trackerHitAssociatorConfig_

TrackerHitAssociator::Config TrackQuality::trackerHitAssociatorConfig_
private

Definition at line 80 of file TrackQuality.h.

Referenced by newEvent().

TrackQuality::QualityAlgorithm::GBDT
TrackQuality::Layer::hits
std::vector< Hit > hits
Definition: TrackQuality.h:56
TTTrack::chi2XY
double chi2XY() const
Chi2XY.
Definition: TTTrack.h:340
mps_fire.i
i
Definition: mps_fire.py:428
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
TTTrack::chi2
double chi2() const
Chi2.
Definition: TTTrack.h:328
cmsswSequenceInfo.seq
seq
Definition: cmsswSequenceInfo.py:539
TTTrack::momentum
GlobalVector momentum() const
Track momentum.
Definition: TTTrack.h:287
TrackQuality::maxZ0_
float maxZ0_
Definition: TrackQuality.h:69
TrackQuality::layers_
std::vector< Layer > layers_
Definition: TrackQuality.h:83
TTTrack::chi2Z
double chi2Z() const
Chi2Z.
Definition: TTTrack.h:334
TrackQuality::setCutParameters
void setCutParameters(std::string const &AlgorithmString, float maxZ0, float maxEta, float chi2dofMax, float bendchi2Max, float minPt, int nStubmin)
Definition: TrackQuality.cc:275
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
gather_cfg.cout
cout
Definition: gather_cfg.py:144
TrackQuality::qualityAlgorithm_
QualityAlgorithm qualityAlgorithm_
Definition: TrackQuality.h:65
TrackQuality::maxEta_
float maxEta_
Definition: TrackQuality.h:70
TrackQualityParams_cfi.maxZ0
maxZ0
Definition: TrackQualityParams_cfi.py:13
TTTrack::phi
double phi() const
Track phi.
Definition: TTTrack.h:307
TrackQuality::chi2dofMax_
float chi2dofMax_
Definition: TrackQuality.h:71
TrackQuality::QualityAlgorithm::NN
TrackQuality::setONNXModel
void setONNXModel(std::string const &AlgorithmString, edm::FileInPath const &ONNXmodel, std::string const &ONNXInputName, std::vector< std::string > const &featureNames)
Definition: TrackQuality.cc:291
TTTrack::rInv
double rInv() const
Track curvature.
Definition: TTTrack.h:292
TrackQualityParams_cfi.ONNXmodel
ONNXmodel
Definition: TrackQualityParams_cfi.py:4
TrackQuality::associator_
std::unique_ptr< TrackerHitAssociator > associator_
Definition: TrackQuality.h:81
cms::Ort::ONNXRuntime::getOutputNames
const std::vector< std::string > & getOutputNames() const
Definition: ONNXRuntime.cc:153
TrackQuality::layer
const Layer & layer(unsigned int index) const
Return information about the given layer by index.
Definition: TrackQuality.h:77
LayerTriplets::Layer
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
config
Definition: config.py:1
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:64
TTTrack::hitPattern
unsigned int hitPattern() const
Hit Pattern.
Definition: TTTrack.h:410
TTTrack::getStubRefs
std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > getStubRefs() const
Track components.
Definition: TTTrack.h:93
TrackQuality::ONNXInputName_
std::string ONNXInputName_
Definition: TrackQuality.h:67
None
Definition: APVGainStruct.h:53
TrackQualityParams_cfi.chi2dofMax
chi2dofMax
Definition: TrackQualityParams_cfi.py:15
TrackQuality::minPt_
float minPt_
Definition: TrackQuality.h:73
TrackQuality::Layer::Unknown
Definition: TrackQuality.h:47
PVValHelper::eta
Definition: PVValidationHelpers.h:70
TTStub
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
maxEta
double maxEta
Definition: PFJetBenchmarkAnalyzer.cc:76
TrackQuality::QualityAlgorithm::None
TrackQuality::ONNXInvRScaling_
float ONNXInvRScaling_
Definition: TrackQuality.h:75
dqmdumpme.k
k
Definition: dqmdumpme.py:60
TrackQuality::nStubsmin_
int nStubsmin_
Definition: TrackQuality.h:74
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
TrackQuality::featureNames_
std::vector< std::string > featureNames_
Definition: TrackQuality.h:68
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackingRecHit::bad
Definition: TrackingRecHit.h:49
TrackQualityParams_cfi.bendchi2Max
bendchi2Max
Definition: TrackQualityParams_cfi.py:16
TrackQuality::Layer::Noise
Definition: TrackQuality.h:47
statePriorities
static const int statePriorities[]
Definition: TrackQuality.cc:82
edm::ParameterSet
Definition: ParameterSet.h:47
TTTrack::stubPtConsistency
double stubPtConsistency() const
Stub Pt consistency.
Definition: TTTrack.h:404
TTTrack::tanL
double tanL() const
Track tanL.
Definition: TTTrack.h:297
TTTrack::z0
double z0() const
Track z0.
Definition: TTTrack.h:317
TrackQuality::Layer::Bad
Definition: TrackQuality.h:47
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
TrackQuality::featureTransform
std::vector< float > featureTransform(TTTrack< Ref_Phase2TrackerDigi_ > &aTrack, std::vector< std::string > const &featureNames)
Definition: TrackQuality.cc:36
TrackQuality::Layer::Missed
Definition: TrackQuality.h:47
beam_dqm_sourceclient-live_cfg.minPt
minPt
Definition: beam_dqm_sourceclient-live_cfg.py:328
TrackQuality::bendchi2Max_
float bendchi2Max_
Definition: TrackQuality.h:72
TrackQuality::trackerHitAssociatorConfig_
TrackerHitAssociator::Config trackerHitAssociatorConfig_
Definition: TrackQuality.h:80
cms::Ort::FloatArrays
std::vector< std::vector< float > > FloatArrays
Definition: ONNXRuntime.h:23
getDetLayer
DetLayer getDetLayer(DetId detId, const TrackerTopology *tTopo)
Definition: TrackQuality.cc:92
eostools.move
def move(src, dest)
Definition: eostools.py:511
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
TrackQuality::Layer::layer
short int layer
Definition: TrackQuality.h:55
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
TTTrack::settrkMVA1
void settrkMVA1(double atrkMVA1)
Definition: TTTrack.h:368
cms::Ort::ONNXRuntime
Definition: ONNXRuntime.h:25
TrackingRecHit::inactive
Definition: TrackingRecHit.h:48
DetId::Muon
Definition: DetId.h:26
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrackQualityParams_cfi.featureNames
featureNames
Definition: TrackQualityParams_cfi.py:9
TrackQuality::Layer::subDet
SubDet subDet
Definition: TrackQuality.h:54
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TrackQuality::Layer::Dead
Definition: TrackQuality.h:47
TrackQuality::Layer::Misassoc
Definition: TrackQuality.h:47
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
TrackQuality::QualityAlgorithm::Cut
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
hit
Definition: SiStripHitEffFromCalibTree.cc:88
Hit
SeedingHitSet::ConstRecHitPointer Hit
Definition: SeedGeneratorFromProtoTracksEDProducer.cc:34
TTTrack::eta
double eta() const
Track eta.
Definition: TTTrack.h:302
TrackQualityParams_cfi.ONNXInputName
ONNXInputName
Definition: TrackQualityParams_cfi.py:7
TrackQuality::ONNXmodel_
edm::FileInPath ONNXmodel_
Definition: TrackQuality.h:66