CMS 3D CMS Logo

TP.cc
Go to the documentation of this file.
2 
3 namespace l1tVertexFinder {
4 
6  : settings_(nullptr),
7  inTimeBx_(false),
8  physicsCollision_(false),
9  use_(false),
10  useForEff_(false),
11  useForAlgEff_(false),
12  useForVertexReco_(false),
13  nLayersWithStubs_(0) {}
14 
15  TP::TP(const TrackingParticlePtr& tpPtr, const AnalysisSettings& settings)
16  : trackingParticle_(tpPtr), settings_(&settings) {
17  const std::vector<SimTrack>& vst = trackingParticle_->g4Tracks();
18  EncodedEventId eid = vst.at(0).eventId();
19  inTimeBx_ = (eid.bunchCrossing() == 0); // TP from in-time or out-of-time Bx.
20  physicsCollision_ = (eid.event() == 0); // TP from physics collision or from pileup.
21 
22  this->fillUse(); // Fill use_ flag, indicating if TP is worth keeping.
23  this->fillUseForEff(); // Fill useForEff_ flag, indicating if TP is good for tracking efficiency measurement.
24  }
25 
26  //=== Fill truth info with association from tracking particle to stubs.
27  void TP::setMatchingStubs(const std::vector<Stub>& vMatchingStubs) {
28  assocStubs_ = vMatchingStubs;
29 
30  this->fillUseForAlgEff(); // Fill useForAlgEff_ flag.
31  this->fillUseForVertexReco();
32  // Calculate number of tracker layers this TP has stubs in.
34  }
35 
36  //=== Count number of tracker layers a given list of stubs are in.
37  //=== By default, consider both PS+2S modules, but optionally consider only the PS ones.
38 
39  unsigned int TP::countLayers(bool onlyPS) {
40  //=== Unpack configuration parameters
41 
42  // Define layers using layer ID (true) or by bins in radius of 5 cm width (false).
43  bool useLayerID = settings_->useLayerID();
44  // When counting stubs in layers, actually histogram stubs in distance from beam-line with this bin size.
45  float layerIDfromRadiusBin = settings_->layerIDfromRadiusBin();
46  // Inner radius of tracker.
47  float trackerInnerRadius = settings_->trackerInnerRadius();
48 
49  const int maxLayerID(30);
50  std::vector<bool> foundLayers(maxLayerID, false);
51 
52  if (useLayerID) {
53  // Count layers using CMSSW layer ID.
54  for (const Stub& stub : assocStubs_) {
55  if ((!onlyPS) || stub.psModule()) { // Consider only stubs in PS modules if that option specified.
56  int layerID = stub.layerId();
57  if (layerID >= 0 && layerID < maxLayerID) {
58  foundLayers[layerID] = true;
59  } else {
60  throw cms::Exception("Utility::invalid layer ID");
61  }
62  }
63  }
64  } else {
65  // Count layers by binning stub distance from beam line.
66  for (const Stub& stub : assocStubs_) {
67  if ((!onlyPS) || stub.psModule()) { // Consider only stubs in PS modules if that option specified.
68  int layerID = (int)((stub.r() - trackerInnerRadius) / layerIDfromRadiusBin);
69  if (layerID >= 0 && layerID < maxLayerID) {
70  foundLayers[layerID] = true;
71  } else {
72  throw cms::Exception("Utility::invalid layer ID");
73  }
74  }
75  }
76  }
77 
78  unsigned int ncount = 0;
79  for (const bool& found : foundLayers) {
80  if (found)
81  ncount++;
82  }
83 
84  return ncount;
85  }
86 
88  useForVertexReco_ = false;
89  if (use_) {
91  }
92 
93  if (useForVertexReco_) {
95  }
96  }
97 
98  //=== Check if this tracking particle is worth keeping.
99  void TP::fillUse() {
100  // Use looser cuts here those those used for tracking efficiency measurement.
101  // Keep only those TP that have a chance (allowing for finite track resolution) of being reconstructed as L1 tracks. L1 tracks not matching these TP will be defined as fake.
103  }
104 
105  //=== Check if this tracking particle can be used to measure the L1 tracking efficiency.
107  useForEff_ = false;
108  if (use_) {
110  }
111  }
112 
113  //=== Check if this tracking particle can be used to measure the L1 tracking algorithmic efficiency (makes stubs in enough layers).
115  useForAlgEff_ = false;
116  if (useForEff_) {
118  }
119  }
120 
121 } // namespace l1tVertexFinder
TrackingParticlePtr trackingParticle_
Definition: TP.h:63
double trackerInnerRadius() const
Definition: AlgoSettings.h:83
unsigned int nLayersWithStubs_
Definition: TP.h:74
unsigned int countLayers(bool onlyPS=false)
Definition: TP.cc:39
const TrackingParticleSelector & tpsUseForVtxReco() const
double layerIDfromRadiusBin() const
Definition: AlgoSettings.h:85
bool inTimeBx_
Definition: TP.h:66
const std::vector< SimTrack > & g4Tracks() const
void fillUse()
Definition: TP.cc:99
void setMatchingStubs(const std::vector< Stub > &vMatchingStubs)
Definition: TP.cc:27
const AnalysisSettings * settings_
Definition: TP.h:64
void fillUseForVertexReco()
Definition: TP.cc:87
std::vector< Stub > assocStubs_
Definition: TP.h:73
bool useForVertexReco_
Definition: TP.h:71
const TrackingParticleSelector & tpsUse() const
bool useForEff_
Definition: TP.h:69
const TrackingParticleSelector & tpsUseForEff() const
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
void fillUseForEff()
Definition: TP.cc:106
unsigned int genMinStubLayers() const
bool useForAlgEff_
Definition: TP.h:70
void fillUseForAlgEff()
Definition: TP.cc:114
bool physicsCollision_
Definition: TP.h:67