ATLAS Offline Software
DetailedTrackGradeFactory.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "GaudiKernel/MsgStream.h"
7 
9 
10 namespace Analysis
11 {
12 
13 DetailedTrackGradeFactory::DetailedTrackGradeFactory( const std::string& t, const std::string& n, const IInterface* p ) :
14  AthAlgTool( t, n, p )
15 {
16  declareProperty("hitBLayerGrade" , m_hitBLayerGrade = true);
17  declareProperty("useSharedHitInfo" , m_useSharedHitInfo = false);
18 
19  declareProperty("useRun2TrackGrading" , m_useRun2TrackGrading = false);
20  declareProperty("useITkTrackGrading" , m_useITkTrackGrading = false);
21  declareProperty("useInnerLayers0HitInfo", m_useInnerLayers0HitInfo= false);
22  declareProperty("useDetailSplitHitInfo" , m_useDetailSplitHitInfo = false);
23  declareProperty("useDetailSharedHitInfo", m_useDetailSharedHitInfo= true);
24 
25  declareProperty("nSharedBLayer", m_nSharedBLayer = 0);
26  declareProperty("nSharedPix" , m_nSharedPix = 0);
27  declareProperty("nSharedSct" , m_nSharedSct = 1);
28  declareProperty("nSharedSi" , m_nSharedSi = 999);
29 
30  // Flag to toggle track gradation according to Run2 pixel layout
31  declareProperty("nSharedInnermostPixelLayer" , m_nSharedInnermostPixelLayer = 0);
32  declareProperty("nSharedNextToInnermostPixelLayer", m_nSharedNextToInnermostPixelLayer = 0);
33 
34  declareProperty("nOutlierPix" , m_nOutlierPix = 0);
35  declareProperty("nSpoiltPix" , m_nSpoiltPix = 1);
36  //
37  declareProperty("ptFracGrade", m_ptFracGrade = false);
38  declareProperty("ptFracCut", m_ptFracCut = 0.04);
39 
40  declareProperty("ptEtaGrades", m_ptEtaGrades = false);
41  declareProperty("ptLowerCuts", m_ptLowerCuts);
42  declareProperty("etaLowerCuts", m_etaLowerCuts);
43 
44  m_ptLowerCuts.push_back(1000.);
45  m_ptLowerCuts.push_back(4000.);
46  m_ptLowerCuts.push_back(10000.);
47 
48  m_etaLowerCuts.push_back(0.);
49  m_etaLowerCuts.push_back(0.5);
50  m_etaLowerCuts.push_back(1.5);
51 
52  declareProperty("gammaLowerCuts", m_gammaLowerCuts = {{0., 0.25e-3, 0.5e-3, 0.75e-3}, // 0<|eta|<1
53  {0., 0.5e-3, 1e-3, 1.5e-3}, // 1<|eta|<2
54  {0., 1e-3, 2e-3, 3e-3}} ); // |eta|>2
55 
56 
57  declareInterface<ITrackGradeFactory>( this );
58 }
59 
61 {
62 
63  if ( m_useRun2TrackGrading==false ) {
66  }
67 
68  std::vector<TrackGrade> myGrades;
69  int nbGrades=0;
70 
72  if (m_hitBLayerGrade)
73  {
74  myGrades.push_back(TrackGrade(nbGrades,std::string("0HitBLayer")));
75  nbGrades++;
76  }
78  {
79  myGrades.push_back(TrackGrade(nbGrades,std::string("Shared")));
80  nbGrades++;
81  }
82  if(m_useDetailSharedHitInfo) //Add By Bai Yu Nov 28,2011
83  {
84  myGrades.push_back(TrackGrade(nbGrades,std::string("BlaShared")));
85  nbGrades++;
86  myGrades.push_back(TrackGrade(nbGrades,std::string("PixShared")));
87  nbGrades++;
88  myGrades.push_back(TrackGrade(nbGrades,std::string("SctShared")));
89  nbGrades++;
90  }
91  }
92 
93  else if (m_useRun2TrackGrading){
95  myGrades.push_back(TrackGrade(nbGrades,std::string("0HitIn0HitNInExp2")));
96  nbGrades++;
97  myGrades.push_back(TrackGrade(nbGrades,std::string("0HitIn0HitNInExpIn")));
98  nbGrades++;
99  myGrades.push_back(TrackGrade(nbGrades,std::string("0HitIn0HitNInExpNIn")));
100  nbGrades++;
101  myGrades.push_back(TrackGrade(nbGrades,std::string("0HitIn0HitNIn")));
102  nbGrades++;
103  myGrades.push_back(TrackGrade(nbGrades,std::string("0HitInExp")));
104  nbGrades++;
105  myGrades.push_back(TrackGrade(nbGrades,std::string("0HitIn")));
106  nbGrades++;
107  myGrades.push_back(TrackGrade(nbGrades,std::string("0HitNInExp")));
108  nbGrades++;
109  myGrades.push_back(TrackGrade(nbGrades,std::string("0HitNIn")));
110  nbGrades++;
111  }
113  myGrades.push_back(TrackGrade(nbGrades,std::string("InANDNInShared")));
114  nbGrades++;
115  myGrades.push_back(TrackGrade(nbGrades,std::string("PixShared")));
116  nbGrades++;
117  myGrades.push_back(TrackGrade(nbGrades,std::string("SctShared")));
118  nbGrades++;
119  }
121  myGrades.push_back(TrackGrade(nbGrades,std::string("InANDNInSplit")));
122  nbGrades++;
123  myGrades.push_back(TrackGrade(nbGrades,std::string("PixSplit")));
124  nbGrades++;
125  }
126  }
127 
128  else if(m_useITkTrackGrading){
129 
130  // Region A: |eta|<1
131 
132  myGrades.push_back( TrackGrade(nbGrades, std::string( "A01")) ); //no hit 1st pixel layer, no hit 2nd pixel layer
133  nbGrades++;
134  myGrades.push_back( TrackGrade(nbGrades, std::string( "A02")) ); //no hit 1st pixel layer but expected
135  nbGrades++;
136  myGrades.push_back( TrackGrade(nbGrades, std::string( "A03")) ); //no hit 1st pixel layer and not expected
137  nbGrades++;
138  myGrades.push_back( TrackGrade(nbGrades, std::string( "A04")) ); //no hit 2nd pixel layer but expected
139  nbGrades++;
140  myGrades.push_back( TrackGrade(nbGrades, std::string( "A05")) ); //no hit 2nd pixel layer and not expected
141  nbGrades++;
142  myGrades.push_back( TrackGrade(nbGrades, std::string( "A06")) ); //total number of shared pixel hits > 0
143  nbGrades++;
144  myGrades.push_back( TrackGrade(nbGrades, std::string( "A07")) ); //number of outliers in 1st+2nd pixel layer > 0
145  nbGrades++;
146  myGrades.push_back( TrackGrade(nbGrades, std::string( "A08")) ); //number of pixel spoilt hits >=2
147  nbGrades++;
148  myGrades.push_back( TrackGrade(nbGrades, std::string( "A14_1")) ); //good tracks gamma>0.75e-3
149  nbGrades++;
150  myGrades.push_back( TrackGrade(nbGrades, std::string( "A14_2")) ); //good tracks 0.5e-3<gamma<0.75e-3
151  nbGrades++;
152  myGrades.push_back( TrackGrade(nbGrades, std::string( "A14_3")) ); //good tracks 0.25e-3<gamma<0.5e-3
153  nbGrades++;
154  myGrades.push_back( TrackGrade(nbGrades, std::string( "A14_4")) ); //good tracks gamma<0.25e-3
155  nbGrades++;
156 
157  // Region B: 1<|eta|<2
158 
159  myGrades.push_back( TrackGrade(nbGrades, std::string( "B01")) ); //no hit 1st pixel layer, no hit 2nd pixel layer
160  nbGrades++;
161  myGrades.push_back( TrackGrade(nbGrades, std::string( "B02")) ); //no hit 1st pixel layer but expected
162  nbGrades++;
163  myGrades.push_back( TrackGrade(nbGrades, std::string( "B03")) ); //no hit 1st pixel layer and not expected
164  nbGrades++;
165  myGrades.push_back( TrackGrade(nbGrades, std::string( "B04")) ); //no hit 2nd pixel layer but expected
166  nbGrades++;
167  myGrades.push_back( TrackGrade(nbGrades, std::string( "B05")) ); //no hit 2nd pixel layer and not expected
168  nbGrades++;
169  myGrades.push_back( TrackGrade(nbGrades, std::string( "B06")) ); //total number of shared pixel hits > 0
170  nbGrades++;
171  myGrades.push_back( TrackGrade(nbGrades, std::string( "B07")) ); //number of outliers in 1st+2nd pixel layer > 0
172  nbGrades++;
173  myGrades.push_back( TrackGrade(nbGrades, std::string( "B08")) ); //number of pixel spoilt hits >=2
174  nbGrades++;
175  myGrades.push_back( TrackGrade(nbGrades, std::string( "B14_1")) ); //good tracks gamma>1.5e-3
176  nbGrades++;
177  myGrades.push_back( TrackGrade(nbGrades, std::string( "B14_2")) ); //good tracks 1e-3<gamma<1.5e-3
178  nbGrades++;
179  myGrades.push_back( TrackGrade(nbGrades, std::string( "B14_3")) ); //good tracks 0.5e-3<gamma<1e-3
180  nbGrades++;
181  myGrades.push_back( TrackGrade(nbGrades, std::string( "B14_4")) ); //good tracks gamma<0.5e-3
182  nbGrades++;
183 
184  // Region C: |eta|>2
185 
186  myGrades.push_back( TrackGrade(nbGrades, std::string( "C01")) ); //no hit 1st pixel layer, no hit 2nd pixel layer
187  nbGrades++;
188  myGrades.push_back( TrackGrade(nbGrades, std::string( "C02030405")) ); //no hit 1st pixel layer OR no hit 2nd pixel layer
189  nbGrades++;
190  myGrades.push_back( TrackGrade(nbGrades, std::string( "C06")) ); //total number of shared pixel hits > 0
191  nbGrades++;
192  myGrades.push_back( TrackGrade(nbGrades, std::string( "C07")) ); //number of outliers in 1st+2nd pixel layer > 0
193  nbGrades++;
194  myGrades.push_back( TrackGrade(nbGrades, std::string( "C08")) ); //number of pixel spoilt hits >=2
195  nbGrades++;
196  myGrades.push_back( TrackGrade(nbGrades, std::string( "C14_1")) ); //good tracks gamma>3e-3
197  nbGrades++;
198  myGrades.push_back( TrackGrade(nbGrades, std::string( "C14_2")) ); //good tracks 2e-3<gamma<3e-3
199  nbGrades++;
200  myGrades.push_back( TrackGrade(nbGrades, std::string( "C14_3")) ); //good tracks 1e-3<gamma<2e-3
201  nbGrades++;
202  myGrades.push_back( TrackGrade(nbGrades, std::string( "C14_4")) ); //good tracks gamma<1e-3
203  nbGrades++;
204 
205  }
206 
207  if (m_ptFracGrade) {
208  myGrades.push_back(TrackGrade(nbGrades,std::string("PtFrac")));
209  nbGrades++;
210  }
211 
212  // VD comment: the grading according to track eta/phi is only implemented for the good category
213  int ptGradeNumber=m_ptLowerCuts.size();
214  int etaGradeNumber=m_etaLowerCuts.size();
215 
216  if (m_ptEtaGrades) {
217  if (ptGradeNumber==0) {
218  ATH_MSG_ERROR("Vector with pt categories has 0 size!!! You need at least 1 lower cut...");
219  }
220 
221  if (etaGradeNumber==0) {
222  ATH_MSG_ERROR("Vector with eta categories has 0 size!!! You need at least 1 lower cut...");
223  }
224 
225  for (int i=0;i<ptGradeNumber;i++){
226  for (int j=0;j<etaGradeNumber;j++){
227  std::string nameGrade("Good");
228 
229  char namePt[30];
230  if (i<ptGradeNumber-1) {
231  sprintf(namePt,"Pt%.1f-%.1f",m_ptLowerCuts[i]*1e-3,m_ptLowerCuts[i+1]*1e-3);
232  } else {
233  sprintf(namePt,"Pt%.1f-inf",m_ptLowerCuts[i]*1e-3);
234  }
235 
236  char nameEta[30];
237  if (j<etaGradeNumber-1) {
238  sprintf(nameEta,"Eta%.1f-%.1f",m_etaLowerCuts[j],m_etaLowerCuts[j+1]);
239  } else {
240  sprintf(nameEta,"Eta%.1f-2.5",m_etaLowerCuts[j]);
241  }
242 
243  nameGrade+=namePt;
244  nameGrade+=nameEta;
245  ATH_MSG_DEBUG("Adding cat. pt "<<i<<" eta "<<j<<" name of Grade: "<<nameGrade);
246 
247  myGrades.push_back(TrackGrade(nbGrades,nameGrade));
248  nbGrades++;
249  }
250  }
251  } else {
252  myGrades.push_back(TrackGrade(nbGrades,std::string("Good")));
253  }
254 
256 
257  return StatusCode::SUCCESS;
258 }
259 
261 {
263 }
264 
265 
266 
267 
269  const xAOD::IParticle::FourMom_t & jetMomentum) const
270 {
271 
272  bool nohitBLayer(false);
273  bool nohitInnermostLayer(false);
274  bool nohitNextToInnermostLayer(false);
275  bool exphitInnermostLayer(false);
276  bool exphitNextToInnermostLayer(false);
277 
278  bool sharedClass(false);
279  bool blasharedClass(false);
280  bool innermostsharedClass(false);
281  bool nexttoinnermostsharedClass(false);
282  bool pixsharedClass(false);
283  bool sctsharedClass(false);
284 
285  bool innermostsplitClass(false);
286  bool nexttoinnermostsplitClass(false);
287  bool pixsplitClass(false);
288 
289  bool pixoutlierClass(false);
290  bool pixspoiltClass(false);
291 
292  bool ptFrac(false);
293 
294  //Itk specific:
295  int eta_region = -1; // 0 = 0<|eta|<1, 1 = 1<|eta|<2, 2 = 2<|eta|<3 , 3 = |eta|>3
296  int gamma_region = -1;
297 
298 
300  //check if no hit in BLayer
302  uint8_t nbs;
303  if (!track.summaryValue(nbs, xAOD::numberOfInnermostPixelLayerHits)){
304  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfInnermostPixelLayerHits for TrackGrade!");
305  }
306  if (nbs==0) nohitBLayer = true;
307  }
308  else if (m_useRun2TrackGrading){
309  uint8_t nih, nnih;
310  if (!track.summaryValue(nih, xAOD::numberOfInnermostPixelLayerHits)){
311  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfInnermostPixelLayerHits for TrackGrade!");
312  }
313  if (nih==0) nohitInnermostLayer = true;
314 
315  if (!track.summaryValue(nnih, xAOD::numberOfNextToInnermostPixelLayerHits)){
316  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfNextToInnermostPixelLayerHits for TrackGrade!");
317  }
318  if (nnih==0) nohitNextToInnermostLayer = true;
319 
320  uint8_t Enih, Ennih;
321  // getting expected information
322  if (!track.summaryValue(Enih, xAOD::expectInnermostPixelLayerHit)){
323  ATH_MSG_ERROR("#BTAG# Cannot retrieve expectInnermostPixelLayerHit for TrackGrade!");
324  }
325  if (Enih>0) exphitInnermostLayer=true;
326 
327  if (!track.summaryValue(Ennih, xAOD::expectNextToInnermostPixelLayerHit)){
328  ATH_MSG_ERROR("#BTAG# Cannot retrieve expectNextToInnermostPixelLayerHit for TrackGrade!");
329  }
330  if (Ennih>0) exphitNextToInnermostLayer=true;
331  }
332  }
333 
336  //check if shared
337  uint8_t nbs=0, nps=0, nss=0;
338  if (!track.summaryValue(nbs, xAOD::numberOfInnermostPixelLayerSharedHits)){
339  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfBLayerSharedHists for TrackGrade!");
340  }
341 
342  if (!track.summaryValue(nps, xAOD::numberOfPixelSharedHits)){
343  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfPixelSharedHists for TrackGrade!");
344  }
345 
346  if (!track.summaryValue(nss, xAOD::numberOfSCTSharedHits)){
347  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfSCTSharedHists for TrackGrade!");
348  }
349  int nsht = nps+nss ;
350  if(nbs>m_nSharedBLayer) {
351  sharedClass = true;
352  blasharedClass = true;
353  }
354  if(nps>m_nSharedPix) {
355  sharedClass = true;
356  pixsharedClass = true;
357  }
358  if(nss>m_nSharedSct) {
359  sharedClass = true;
360  sctsharedClass = true;
361  }
362  if(nsht>m_nSharedSi) {
363  sharedClass = true;
364  }
365  }
366 
367  else if (m_useRun2TrackGrading) {
368  uint8_t nips=0, nnips=0, nps=0, nss=0;
369  if (!track.summaryValue(nips, xAOD::numberOfInnermostPixelLayerSharedHits)){
370  ATH_MSG_FATAL("#BTAG# Cannot retrieve numberOfInnermostPixelLayerSharedHits for TrackGrade!");
371  }
372 
373  if (!track.summaryValue(nnips, xAOD::numberOfNextToInnermostPixelLayerSharedHits)){
374  ATH_MSG_FATAL("#BTAG# Cannot retrieve numberOfNextToInnermostPixelLayerSharedHits for TrackGrade!");
375  }
376 
377  if (!track.summaryValue(nps, xAOD::numberOfPixelSharedHits)){
378  ATH_MSG_FATAL("#BTAG# Cannot retrieve numberOfPixelSharedHits for TrackGrade!");
379  }
380 
381  if (!track.summaryValue(nss, xAOD::numberOfSCTSharedHits)){
382  ATH_MSG_FATAL("#BTAG# Cannot retrieve numberOfSCTSharedHits for TrackGrade!");
383  }
384 
385  int nsht = nps+nss ;
386  //std::cout << " ... " << Inips << " , " << Innips << " , " << Inps << " , " << Inss << std::endl;
387 
389  sharedClass = true;
390  innermostsharedClass = true;
391  }
393  sharedClass = true;
394  nexttoinnermostsharedClass = true;
395  }
396  if(nps>m_nSharedPix) {
397  sharedClass = true;
398  pixsharedClass = true;
399  }
400  if(nss>m_nSharedSct) {
401  sharedClass = true;
402  sctsharedClass = true;
403  }
404  if(nsht>m_nSharedSi) {
405  sharedClass = true;
406  }
407  }
408  }
409 
410 
412  uint8_t nips, nnips, nps;
413  if (!track.summaryValue(nips, xAOD::numberOfInnermostPixelLayerSplitHits)){
414  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfInnermostPixelLayerSplitHits for TrackGrade!");
415  }
416 
417  if (!track.summaryValue(nnips, xAOD::numberOfNextToInnermostPixelLayerSplitHits)){
418  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfNextToInnermostPixelLayerSplitHits for TrackGrade!");
419  }
420 
421  if (!track.summaryValue(nps, xAOD::numberOfPixelSplitHits)){
422  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfPixelSplitHits for TrackGrade!");
423  }
424 
425  if(nips>0) {
426  //splitClass = true;
427  innermostsplitClass = true;
428  }
429  if(nnips>0) {
430  //splitClass = true;
431  nexttoinnermostsplitClass = true;
432  }
433  if(nps>0) {
434  //splitClass = true;
435  pixsplitClass = true;
436  }
437  }
438 
439 
440  double ptTrack = track.pt();
441  double etaTrack = fabs(track.eta());
442 
443  //check if ptFrac < cut value
444  if (m_ptFracGrade) {
445  double ptJet = jetMomentum.Pt();
446  if ((ptTrack/ptJet) < m_ptFracCut) ptFrac = true;
447  }
448 
449  std::string ptEtaCategoryName;
450 
451  if (m_ptEtaGrades) {
452  int ptGradeNumber=m_ptLowerCuts.size();
453  int etaGradeNumber=m_etaLowerCuts.size();
454 
455  //check pt
456  int ptBin(-1);
457 
458  for (int i=0;i<ptGradeNumber;i++){
459 
460  if (i<ptGradeNumber-1) {
461  if (ptTrack>m_ptLowerCuts[i]&& ptTrack<=m_ptLowerCuts[i+1]) {
462  ptBin=i;
463  break;
464  }
465  } else {
466  if (ptTrack>m_ptLowerCuts[i]) {
467  ptBin=i;
468  break;
469  }
470  }
471  }
472 
473  int etaBin(-1);
474  for (int i=0;i<etaGradeNumber;i++){
475 
476  if (i<etaGradeNumber-1) {
477  if (etaTrack>m_etaLowerCuts[i]&& etaTrack<=m_etaLowerCuts[i+1]) {
478  etaBin=i;
479  break;
480  }
481  } else {
482  if (etaTrack>m_etaLowerCuts[i]) {
483  etaBin=i;
484  break;
485  }
486  }
487  }
488 
489  //now choose the right grade
490  std::string nameGrade("Good");
491 
492  char namePt[30];
493  if (ptBin<ptGradeNumber-1) {
494  sprintf(namePt,"Pt%.1f-%.1f",m_ptLowerCuts[ptBin]*1e-3,m_ptLowerCuts[ptBin+1]*1e-3);
495  } else {
496  sprintf(namePt,"Pt%.1f-inf",m_ptLowerCuts[ptBin]*1e-3);
497  }
498 
499  char nameEta[30];
500  if (etaBin<etaGradeNumber-1) {
501  sprintf(nameEta,"Eta%.1f-%.1f",m_etaLowerCuts[etaBin],m_etaLowerCuts[etaBin+1]);
502  } else {
503  sprintf(nameEta,"Eta%.1f-2.5",m_etaLowerCuts[etaBin]);
504  }
505 
506  nameGrade+=namePt;
507  nameGrade+=nameEta;
508 
509  ptEtaCategoryName=nameGrade;
510  }
511 
512 
513  const TrackGrade * gradeToReturn(0);
514 
516  if (nohitBLayer) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("0HitBLayer"));
517 
518  else if (sharedClass) {
519  if(!m_useDetailSharedHitInfo) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("Shared"));
520 
521  else {
522  if(blasharedClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("BlaShared"));
523 
524  if(pixsharedClass&&(!blasharedClass)) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("PixShared"));
525 
526  if(sctsharedClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("SctShared"));
527  }
528  } else if (ptFrac) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("PtFrac"));
529 
530  else {
531  if (m_ptEtaGrades) {
532  ATH_MSG_VERBOSE(" category "<<ptEtaCategoryName);
533  gradeToReturn=m_trackGradesDefinition.getGrade(ptEtaCategoryName);
534  } else {
535  gradeToReturn=m_trackGradesDefinition.getGrade(std::string("Good"));
536  }
537  }
538  }
539 
540  else if (m_useRun2TrackGrading){
541  /*
542  std::cout << " using Run2 grading" << std::endl;
543  std::cout << " ... " << nohitBLayer << " " << nohitInnermostLayer
544  << " " << nohitNextToInnermostLayer << " " << exphitInnermostLayer
545  << " " << exphitNextToInnermostLayer
546  << " " << sharedClass << " " << blasharedClass
547  << " " << innermostsharedClass << " " << nexttoinnermostsharedClass
548  << " " << pixsharedClass << " " << sctsharedClass
549  << " " << innermostsplitClass << " " << nexttoinnermostsplitClass
550  << " " << pixsplitClass << std::endl;
551  */
552  if ( m_useInnerLayers0HitInfo ) {
553  if ( nohitInnermostLayer && nohitNextToInnermostLayer ) {
554  if ( exphitInnermostLayer && exphitNextToInnermostLayer ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("0HitIn0HitNInExp2"));
555  else if ( exphitInnermostLayer && !exphitNextToInnermostLayer ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("0HitIn0HitNInExpIn"));
556  else if ( !exphitInnermostLayer && exphitNextToInnermostLayer ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("0HitIn0HitNInExpNIn"));
557  else gradeToReturn=m_trackGradesDefinition.getGrade(std::string("0HitIn0HitNIn"));
558  } else if ( nohitInnermostLayer && !nohitNextToInnermostLayer ) {
559  if ( exphitInnermostLayer ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("0HitInExp"));
560  else gradeToReturn=m_trackGradesDefinition.getGrade(std::string("0HitIn"));
561  } else if ( !nohitInnermostLayer && nohitNextToInnermostLayer ) {
562  if ( exphitNextToInnermostLayer ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("0HitNInExp"));
563  else gradeToReturn=m_trackGradesDefinition.getGrade(std::string("0HitNIn"));
564  }
565  }
566 
567  // grade are exclusive so not event attempt the next frade is the grade has already been assigned
568 
569  // shared
570  if (sharedClass && m_useDetailSharedHitInfo && gradeToReturn==0) {
571  if( innermostsharedClass && nexttoinnermostsharedClass ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("InANDNInShared"));
572  else if ( pixsharedClass ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("PixShared"));
573  else if ( sctsharedClass ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("SctShared"));
574  }
575 
576  // split
577  if (m_useDetailSplitHitInfo && pixsplitClass && gradeToReturn==0) {
578  if( innermostsplitClass && nexttoinnermostsplitClass ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("InANDNInSplit"));
579  else gradeToReturn=m_trackGradesDefinition.getGrade(std::string("PixSplit"));
580  }
581  }
582 
583 
584  else if(m_useITkTrackGrading){
585 
586  uint8_t nih, nnih, nieh, nnieh;
587 
588  if(!track.summaryValue(nih, xAOD::numberOfInnermostPixelLayerHits)){
589  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfInnermostPixelLayerHits for TrackGrade!");
590  }
591  if(!track.summaryValue(nieh, xAOD::numberOfInnermostPixelLayerEndcapHits)){
592  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfInnermostPixelLayerEndcapHits for TrackGrade!");
593  }
594  if ((nih+nieh)==0) nohitInnermostLayer = true;
595 
596  if (!track.summaryValue(nnih, xAOD::numberOfNextToInnermostPixelLayerHits)){
597  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfNextToInnermostPixelLayerHits for TrackGrade!");
598  }
599  if (!track.summaryValue(nnieh, xAOD::numberOfNextToInnermostPixelLayerEndcapHits)){
600  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfNextToInnermostPixelLayerEndcapHits for TrackGrade!");
601  }
602  if ((nnih+nnieh)==0) nohitNextToInnermostLayer = true;
603 
604  uint8_t Enih, Ennih;
605 
606  // getting expected information
607  if (!track.summaryValue(Enih, xAOD::expectInnermostPixelLayerHit)){
608  ATH_MSG_ERROR("#BTAG# Cannot retrieve expectInnermostPixelLayerHit for TrackGrade!");
609  }
610  if (Enih>0) exphitInnermostLayer=true;
611 
612  if (!track.summaryValue(Ennih, xAOD::expectNextToInnermostPixelLayerHit)){
613  ATH_MSG_ERROR("#BTAG# Cannot retrieve expectNextToInnermostPixelLayerHit for TrackGrade!");
614  }
615  if (Ennih>0) exphitNextToInnermostLayer=true;
616 
617  //check if shared
618  uint8_t nps, nss;
619 
620  if (!track.summaryValue(nps, xAOD::numberOfPixelSharedHits)){
621  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfPixelSharedHists for TrackGrade!");
622  }
623  if (!track.summaryValue(nss, xAOD::numberOfSCTSharedHits)){
624  ATH_MSG_ERROR("#BTAG# Cannot retrieve numberOfSCTSharedHists for TrackGrade!");
625  }
626  int nsht = nps+nss ;
627 
628  uint8_t nips, nnips;
629  if (!track.summaryValue(nips, xAOD::numberOfInnermostPixelLayerSharedHits)){
630  ATH_MSG_FATAL("#BTAG# Cannot retrieve numberOfInnermostPixelLayerSharedHits for TrackGrade!");
631  }
632  if (!track.summaryValue(nnips, xAOD::numberOfNextToInnermostPixelLayerSharedHits)){
633  ATH_MSG_FATAL("#BTAG# Cannot retrieve numberOfNextToInnermostPixelLayerSharedHits for TrackGrade!");
634  }
635 
636  uint8_t nipo, nnipo;
637  if (!track.summaryValue(nipo, xAOD::numberOfInnermostPixelLayerOutliers)){
638  ATH_MSG_FATAL("#BTAG# Cannot retrieve numberOfInnermostPixelLayerOutliers for TrackGrade!");
639  }
640  if (!track.summaryValue(nnipo, xAOD::numberOfNextToInnermostPixelLayerOutliers)){
641  ATH_MSG_FATAL("#BTAG# Cannot retrieve numberOfNextToInnermostPixelLayerOutliers for TrackGrade!");
642  }
643  int notot = nipo + nnipo;
644 
645  uint8_t npsp;
646  if (!track.summaryValue(npsp, xAOD::numberOfPixelSpoiltHits)){
647  ATH_MSG_FATAL("#BTAG# Cannot retrieve numberOfPixelSpoiltHits for TrackGrade!");
648  }
649 
651  sharedClass = true;
652  innermostsharedClass = true;
653  }
655  sharedClass = true;
656  nexttoinnermostsharedClass = true;
657  }
658  if(nps>m_nSharedPix) {
659  sharedClass = true;
660  pixsharedClass = true;
661  }
662  if(nss>m_nSharedSct) {
663  sharedClass = true;
664  sctsharedClass = true;
665  }
666  if(nsht>m_nSharedSi) {
667  sharedClass = true;
668  }
669  if(notot>m_nOutlierPix){
670  pixoutlierClass = true;
671  }
672  if(npsp>m_nSpoiltPix){
673  pixspoiltClass = true;
674  }
675 
676 
677  double etaTrack = fabs(track.eta());
678  double ptTrack = track.pt();
679  double thetaTrack=track.theta();
680  if (etaTrack<=1) eta_region = 0;
681  else if (etaTrack>1 && etaTrack<=2) eta_region = 1;
682  else if (etaTrack>2) eta_region = 2;
683 
684  double gamma =1./(ptTrack*sqrt(sin(thetaTrack)));
685  if(gamma>m_gammaLowerCuts[eta_region][3]) gamma_region = 0;
686  else if(gamma<=m_gammaLowerCuts[eta_region][3] && gamma>m_gammaLowerCuts[eta_region][2]) gamma_region = 1;
687  else if(gamma<=m_gammaLowerCuts[eta_region][2] && gamma>m_gammaLowerCuts[eta_region][1]) gamma_region = 2;
688  else if(gamma<=m_gammaLowerCuts[eta_region][1] && gamma>m_gammaLowerCuts[eta_region][0]) gamma_region = 3;
689 
690 
691  if(eta_region==0){
692 
693  if( nohitInnermostLayer && nohitNextToInnermostLayer) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A01"));
694 
695  else if ( nohitInnermostLayer && !nohitNextToInnermostLayer ){
696  if ( exphitInnermostLayer ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A02"));
697  else gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A03"));
698  }
699 
700  else if (!nohitInnermostLayer && nohitNextToInnermostLayer){
701  if ( exphitNextToInnermostLayer ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A04"));
702  else gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A05"));
703  }
704 
705  else if (pixsharedClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A06"));
706  else if (pixoutlierClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A07"));
707  else if (pixspoiltClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A08"));
708 
709  else if(gamma_region==0) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A14_1"));
710  else if(gamma_region==1) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A14_2"));
711  else if(gamma_region==2) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A14_3"));
712  else if(gamma_region==3) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("A14_4"));
713 
714  } //eta_region = 0
715 
716  else if(eta_region==1){
717 
718  if( nohitInnermostLayer && nohitNextToInnermostLayer) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B01"));
719 
720  else if ( nohitInnermostLayer && !nohitNextToInnermostLayer ){
721  if ( exphitInnermostLayer ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B02"));
722  else gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B03"));
723  }
724 
725  else if (!nohitInnermostLayer && nohitNextToInnermostLayer){
726  if ( exphitNextToInnermostLayer ) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B04"));
727  else gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B05"));
728  }
729 
730  else if (pixsharedClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B06"));
731  else if (pixoutlierClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B07"));
732  else if (pixspoiltClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B08"));
733 
734  else if(gamma_region==0) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B14_1"));
735  else if(gamma_region==1) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B14_2"));
736  else if(gamma_region==2) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B14_3"));
737  else if(gamma_region==3) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("B14_4"));
738 
739  } //eta_region = 1
740 
741  else if(eta_region==2){
742 
743  if(nohitInnermostLayer && nohitNextToInnermostLayer) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("C01"));
744  else if (nohitInnermostLayer || nohitNextToInnermostLayer) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("C02030405"));
745  else if (pixsharedClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("C06"));
746  else if (pixoutlierClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("C07"));
747  else if (pixspoiltClass) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("C08"));
748 
749  else if(gamma_region==0) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("C14_1"));
750  else if(gamma_region==1) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("C14_2"));
751  else if(gamma_region==2) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("C14_3"));
752  else if(gamma_region==3) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("C14_4"));
753 
754  }
755 
756  }
757 
758 
759 
760 
761  if (gradeToReturn==0) {
762  // others
763  if (ptFrac) gradeToReturn=m_trackGradesDefinition.getGrade(std::string("PtFrac"));
764 
765  else {
766  if (m_ptEtaGrades) {
767  ATH_MSG_VERBOSE(" category "<<ptEtaCategoryName);
768  gradeToReturn=m_trackGradesDefinition.getGrade(ptEtaCategoryName);
769  } else {
770  gradeToReturn=m_trackGradesDefinition.getGrade(std::string("Good"));
771  }
772  }
773  }
774 
775  if (gradeToReturn==0) {
776  ATH_MSG_ERROR("Grade not found. Internal error... ");
777  return nullptr;
778  }
779 
780  return new TrackGrade(*gradeToReturn);
781 }
782 
783 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Analysis::DetailedTrackGradeFactory::m_nSharedPix
int m_nSharedPix
max. number of shared hits in B layer
Definition: DetailedTrackGradeFactory.h:64
xAOD::numberOfInnermostPixelLayerSplitHits
@ numberOfInnermostPixelLayerSplitHits
number of Pixel 0th layer barrel hits split by cluster splitting
Definition: TrackingPrimitives.h:240
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Analysis::TrackGrade
Definition: TrackGrade.h:11
xAOD::numberOfSCTSharedHits
@ numberOfSCTSharedHits
number of SCT hits shared by several tracks [unit8_t].
Definition: TrackingPrimitives.h:272
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
Analysis::DetailedTrackGradeFactory::m_nSharedSi
int m_nSharedSi
max. number of shared hits in SCT
Definition: DetailedTrackGradeFactory.h:66
Analysis::DetailedTrackGradeFactory::DetailedTrackGradeFactory
DetailedTrackGradeFactory(const std::string &, const std::string &, const IInterface *)
Definition: DetailedTrackGradeFactory.cxx:13
Analysis::TrackGradesDefinition::getGrade
const TrackGrade * getGrade(const std::string &) const
Definition: TrackGradesDefinition.cxx:59
xAOD::numberOfNextToInnermostPixelLayerSplitHits
@ numberOfNextToInnermostPixelLayerSplitHits
number of Pixel 1st layer barrel hits split by cluster splitting
Definition: TrackingPrimitives.h:251
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Analysis::TrackGradesDefinition
Definition: TrackGradesDefinition.h:15
Analysis::DetailedTrackGradeFactory::m_hitBLayerGrade
bool m_hitBLayerGrade
Definition: DetailedTrackGradeFactory.h:54
Analysis::DetailedTrackGradeFactory::m_useSharedHitInfo
bool m_useSharedHitInfo
Definition: DetailedTrackGradeFactory.h:55
Analysis::DetailedTrackGradeFactory::m_ptFracCut
double m_ptFracCut
Definition: DetailedTrackGradeFactory.h:73
Analysis::DetailedTrackGradeFactory::m_nSharedSct
int m_nSharedSct
max. number of shared hits in pixels
Definition: DetailedTrackGradeFactory.h:65
xAOD::expectInnermostPixelLayerHit
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
Definition: TrackingPrimitives.h:236
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Analysis::DetailedTrackGradeFactory::getGrade
virtual TrackGrade * getGrade(const xAOD::TrackParticle &track, const xAOD::IParticle::FourMom_t &jetMomentum) const override
Definition: DetailedTrackGradeFactory.cxx:268
Analysis::DetailedTrackGradeFactory::m_nSharedNextToInnermostPixelLayer
int m_nSharedNextToInnermostPixelLayer
max. number of shared hits in innermost pixel layer (IBL)
Definition: DetailedTrackGradeFactory.h:68
Analysis::DetailedTrackGradeFactory::m_nSharedBLayer
int m_nSharedBLayer
Definition: DetailedTrackGradeFactory.h:63
xAOD::IParticle::FourMom_t
TLorentzVector FourMom_t
Definition of the 4-momentum type.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:69
Analysis::DetailedTrackGradeFactory::m_useDetailSplitHitInfo
bool m_useDetailSplitHitInfo
Definition: DetailedTrackGradeFactory.h:61
Analysis::DetailedTrackGradeFactory::m_nOutlierPix
int m_nOutlierPix
max. number of shared hits next-to-innermost pixel layer (Run1 B layer)
Definition: DetailedTrackGradeFactory.h:69
xAOD::numberOfInnermostPixelLayerOutliers
@ numberOfInnermostPixelLayerOutliers
number of 0th layer barrel outliers
Definition: TrackingPrimitives.h:238
xAOD::numberOfInnermostPixelLayerEndcapHits
@ numberOfInnermostPixelLayerEndcapHits
these are the hits in the 0th pixel layer endcap [unit8_t].
Definition: TrackingPrimitives.h:242
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
xAOD::numberOfPixelSharedHits
@ numberOfPixelSharedHits
number of Pixel all-layer hits shared by several tracks [unit8_t].
Definition: TrackingPrimitives.h:262
Analysis::DetailedTrackGradeFactory::m_ptFracGrade
bool m_ptFracGrade
max. number of spoilt hits in pixel
Definition: DetailedTrackGradeFactory.h:72
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::expectNextToInnermostPixelLayerHit
@ expectNextToInnermostPixelLayerHit
Do we expect a 1st-layer barrel hit for this track?
Definition: TrackingPrimitives.h:247
Analysis::DetailedTrackGradeFactory::m_trackGradesDefinition
TrackGradesDefinition m_trackGradesDefinition
Definition: DetailedTrackGradeFactory.h:52
TrigVtx::gamma
@ gamma
Definition: TrigParticleTable.h:26
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
Analysis::DetailedTrackGradeFactory::m_nSharedInnermostPixelLayer
int m_nSharedInnermostPixelLayer
max. number of shared hits in pixels+SCT
Definition: DetailedTrackGradeFactory.h:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Analysis::DetailedTrackGradeFactory::m_etaLowerCuts
std::vector< double > m_etaLowerCuts
Definition: DetailedTrackGradeFactory.h:77
Analysis::DetailedTrackGradeFactory::getTrackGradesDefinition
virtual const TrackGradesDefinition & getTrackGradesDefinition() const override
Definition: DetailedTrackGradeFactory.cxx:260
xAOD::numberOfPixelSplitHits
@ numberOfPixelSplitHits
number of Pixel all-layer hits split by cluster splitting [unit8_t].
Definition: TrackingPrimitives.h:263
xAOD::numberOfNextToInnermostPixelLayerEndcapHits
@ numberOfNextToInnermostPixelLayerEndcapHits
these are the hits in the 0.5th and 1st pixel layer endcap rings [unit8_t].
Definition: TrackingPrimitives.h:253
Analysis::DetailedTrackGradeFactory::m_useITkTrackGrading
bool m_useITkTrackGrading
Definition: DetailedTrackGradeFactory.h:58
xAOD::numberOfNextToInnermostPixelLayerOutliers
@ numberOfNextToInnermostPixelLayerOutliers
number of 1st pixel layer barrel outliers
Definition: TrackingPrimitives.h:249
xAOD::numberOfNextToInnermostPixelLayerHits
@ numberOfNextToInnermostPixelLayerHits
these are the hits in the 1st pixel barrel layer
Definition: TrackingPrimitives.h:248
Analysis
The namespace of all packages in PhysicsAnalysis/JetTagging.
Definition: BTaggingCnvAlg.h:20
xAOD::numberOfPixelSpoiltHits
@ numberOfPixelSpoiltHits
number of pixel hits with broad errors (width/sqrt(12)) [unit8_t].
Definition: TrackingPrimitives.h:267
DetailedTrackGradeFactory.h
Analysis::DetailedTrackGradeFactory::m_ptLowerCuts
std::vector< double > m_ptLowerCuts
grades in pt and/or |eta| of tracks
Definition: DetailedTrackGradeFactory.h:76
Analysis::DetailedTrackGradeFactory::m_nSpoiltPix
int m_nSpoiltPix
max. number of pixel outliers in two first layers
Definition: DetailedTrackGradeFactory.h:70
TrackGrade.h
Analysis::DetailedTrackGradeFactory::initialize
virtual StatusCode initialize() override
AlgTool initialize method.
Definition: DetailedTrackGradeFactory.cxx:60
Analysis::DetailedTrackGradeFactory::m_ptEtaGrades
bool m_ptEtaGrades
cut on ptFrac
Definition: DetailedTrackGradeFactory.h:75
Analysis::DetailedTrackGradeFactory::m_useInnerLayers0HitInfo
bool m_useInnerLayers0HitInfo
Definition: DetailedTrackGradeFactory.h:59
Analysis::DetailedTrackGradeFactory::m_useDetailSharedHitInfo
bool m_useDetailSharedHitInfo
Definition: DetailedTrackGradeFactory.h:60
Analysis::DetailedTrackGradeFactory::m_gammaLowerCuts
std::vector< std::vector< double > > m_gammaLowerCuts
Definition: DetailedTrackGradeFactory.h:79
xAOD::numberOfInnermostPixelLayerSharedHits
@ numberOfInnermostPixelLayerSharedHits
number of Pixel 0th layer barrel hits shared by several tracks.
Definition: TrackingPrimitives.h:239
Analysis::DetailedTrackGradeFactory::m_useRun2TrackGrading
bool m_useRun2TrackGrading
if false the following cuts are ignored
Definition: DetailedTrackGradeFactory.h:57
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
AthAlgTool
Definition: AthAlgTool.h:26
xAOD::numberOfNextToInnermostPixelLayerSharedHits
@ numberOfNextToInnermostPixelLayerSharedHits
number of Pixel 1st layer barrel hits shared by several tracks.
Definition: TrackingPrimitives.h:250
xAOD::numberOfInnermostPixelLayerHits
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
Definition: TrackingPrimitives.h:237