CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
hph::HitPatternHelper Class Reference

#include <HitPatternHelper.h>

Public Member Functions

std::vector< int > binary ()
 
std::vector< float > bonusFeatures ()
 
int etaSector ()
 
int findLayer (int layerId)
 
 HitPatternHelper (const Setup *setup, int hitpattern, double cot, double z0)
 
int num2S ()
 
int numExpLayer ()
 
int numMissing2S ()
 
int numMissingInterior1 ()
 
int numMissingInterior2 ()
 
int numMissingPS ()
 
int numPS ()
 
int reducedId (int layerId)
 
 ~HitPatternHelper ()
 

Private Attributes

std::vector< int > binary_
 
std::vector< float > bonusFeatures_
 
int cotBin_
 
int etaBin_
 
std::vector< double > etaRegions_
 
int etaSector_
 
int hitpattern_
 
bool hphDebug_
 
std::vector< int > layerEncoding_
 
std::map< int, const tt::SensorModule * > layerEncodingMap_
 
std::map< int, std::map< int, std::vector< int > > > layermap_
 
int nKalmanLayers_
 
int num2S_
 
int numExpLayer_
 
int numMissing2S_
 
int numMissingInterior1_
 
int numMissingInterior2_
 
int numMissingLayer_
 
int numMissingPS_
 
int numPS_
 
const Setupsetup_
 
bool useNewKF_
 
int zTBin_
 

Detailed Description

Definition at line 89 of file HitPatternHelper.h.

Constructor & Destructor Documentation

◆ HitPatternHelper()

hph::HitPatternHelper::HitPatternHelper ( const Setup setup,
int  hitpattern,
double  cot,
double  z0 
)

Definition at line 58 of file HitPatternHelper.cc.

References binary_, relativeConstraints::empty, etaRegions_, etaSector_, findLayer(), hitpattern_, hphDebug_, mps_fire::i, createfilelist::int, dqmiolumiharvest::j, isotrackApplyRegressor::k, layerEncoding_, layerEncodingMap_, layermap_, nKalmanLayers_, num2S_, numExpLayer_, numMissing2S_, numMissingInterior1_, numMissingInterior2_, numMissingPS_, numPS_, reducedId(), cmsswSequenceInfo::seq, and useNewKF_.

59  : setup_(setup),
65  etaBin_(setup_->etaRegion(z0, cot, true)),
66  cotBin_(setup_->digiCot(cot, etaBin_)),
67  zTBin_(setup_->digiZT(z0, cot, etaBin_)),
68  layerEncoding_(setup->layerEncoding(etaBin_, zTBin_, cotBin_)),
69  layerEncodingMap_(setup->layerEncodingMap(etaBin_, zTBin_, cotBin_)),
71  hitpattern_(hitpattern),
74  numMissingPS_(0),
75  numMissing2S_(0),
76  numPS_(0),
77  num2S_(0),
80  binary_(11, 0), //there are 11 unique layer IDs, as defined in variable "layerIds"
81  bonusFeatures_() {
82  int kf_eta_reg = etaSector_;
83  if (kf_eta_reg < ((int)etaRegions_.size() - 1) / 2) {
84  kf_eta_reg = ((int)etaRegions_.size() - 1) / 2 - 1 - kf_eta_reg;
85  } else {
86  kf_eta_reg = kf_eta_reg - (int)(etaRegions_.size() - 1) / 2;
87  }
88 
89  int nbits = floor(log2(hitpattern_)) + 1;
90  int lay_i = 0;
91  bool seq = false;
92  for (int i = 0; i < nbits; i++) {
93  lay_i = ((1 << i) & hitpattern_) >> i; //0 or 1 in ith bit (right to left)
94 
95  if (lay_i && !seq)
96  seq = true; //sequence starts when first 1 found
97  if (!lay_i && seq) {
98  numMissingInterior1_++; //This is the same as the "tmp_trk_nlaymiss_interior" calculated in Trackquality.cc
99  }
100  if (!lay_i) {
101  bool realhit = false;
102  if (layermap_[kf_eta_reg][i].empty())
103  continue;
104  for (int j : layermap_[kf_eta_reg][i]) {
105  int k = findLayer(j);
106  if (k > 0)
107  realhit = true;
108  }
109  if (realhit)
110  numMissingInterior2_++; //This variable doesn't make sense for new KF because it uses the layermap from Old KF
111  }
112  }
113 
114  if (hphDebug_) {
115  if (useNewKF_) {
116  edm::LogVerbatim("TrackTriggerHPH") << "Running with New KF";
117  } else {
118  edm::LogVerbatim("TrackTriggerHPH") << "Running with Old KF";
119  }
120  edm::LogVerbatim("TrackTriggerHPH") << "======================================================";
121  edm::LogVerbatim("TrackTriggerHPH")
122  << "Looking at hitpattern " << std::bitset<7>(hitpattern_) << "; Looping over KF layers:";
123  }
124 
125  if (useNewKF_) {
126  //New KF uses sensor modules to determine the hitmask already
127  for (int i = 0; i < numExpLayer_; i++) {
128  if (hphDebug_) {
129  edm::LogVerbatim("TrackTriggerHPH") << "--------------------------";
130  edm::LogVerbatim("TrackTriggerHPH") << "Looking at KF layer " << i;
131  if (layerEncoding_[i] < 10) {
132  edm::LogVerbatim("TrackTriggerHPH") << "KF expects L" << layerEncoding_[i];
133  } else {
134  edm::LogVerbatim("TrackTriggerHPH") << "KF expects D" << layerEncoding_[i] - 10;
135  }
136  }
137 
138  if (((1 << i) & hitpattern_) >> i) {
139  if (hphDebug_) {
140  edm::LogVerbatim("TrackTriggerHPH") << "Layer found in hitpattern";
141  }
142 
144  if (layerEncodingMap_[layerEncoding_[i]]->psModule()) {
145  numPS_++;
146  } else {
147  num2S_++;
148  }
149  } else {
150  if (hphDebug_) {
151  edm::LogVerbatim("TrackTriggerHPH") << "Layer missing in hitpattern";
152  }
153 
154  if (layerEncodingMap_[layerEncoding_[i]]->psModule()) {
155  numMissingPS_++;
156  } else {
157  numMissing2S_++;
158  }
159  }
160  }
161 
162  } else {
163  //Old KF uses the hard coded layermap to determien hitmask
164  for (int i = 0; i < nKalmanLayers_; i++) { //Loop over each digit of hitpattern
165 
166  if (hphDebug_) {
167  edm::LogVerbatim("TrackTriggerHPH") << "--------------------------";
168  edm::LogVerbatim("TrackTriggerHPH") << "Looking at KF layer " << i;
169  }
170 
171  if (layermap_[kf_eta_reg][i].empty()) {
172  if (hphDebug_) {
173  edm::LogVerbatim("TrackTriggerHPH") << "KF does not expect this layer";
174  }
175 
176  continue;
177  }
178 
179  for (int j :
180  layermap_[kf_eta_reg][i]) { //Find out which layer the Old KF is dealing with when hitpattern is encoded
181 
182  if (hphDebug_) {
183  if (j < 10) {
184  edm::LogVerbatim("TrackTriggerHPH") << "KF expects L" << j;
185  } else {
186  edm::LogVerbatim("TrackTriggerHPH") << "KF expects D" << j - 10;
187  }
188  }
189 
190  int k = findLayer(j);
191  if (k < 0) {
192  //k<0 means even though layer j is predicted by Old KF, this prediction is rejected because it contradicts
193  if (hphDebug_) { //a more accurate prediction made with the help of information from sensor modules
194  edm::LogVerbatim("TrackTriggerHPH") << "Rejected by sensor modules";
195  }
196 
197  continue;
198  }
199 
200  if (hphDebug_) {
201  edm::LogVerbatim("TrackTriggerHPH") << "Confirmed by sensor modules";
202  }
203  //prediction is accepted
204  if (((1 << i) & hitpattern_) >> i) {
205  if (hphDebug_) {
206  edm::LogVerbatim("TrackTriggerHPH") << "Layer found in hitpattern";
207  }
208 
209  binary_[reducedId(j)] = 1;
210  if (layerEncodingMap_[layerEncoding_[k]]->psModule()) {
211  numPS_++;
212  } else {
213  num2S_++;
214  }
215  } else {
216  if (hphDebug_) {
217  edm::LogVerbatim("TrackTriggerHPH") << "Layer missing in hitpattern";
218  }
219 
220  if (layerEncodingMap_[layerEncoding_[k]]->psModule()) {
221  numMissingPS_++;
222  } else {
223  numMissing2S_++;
224  }
225  }
226  }
227  }
228  }
229 
230  if (hphDebug_) {
231  edm::LogVerbatim("TrackTriggerHPH") << "------------------------------";
232  edm::LogVerbatim("TrackTriggerHPH") << "numPS = " << numPS_ << ", num2S = " << num2S_
233  << ", missingPS = " << numMissingPS_ << ", missing2S = " << numMissing2S_;
234  edm::LogVerbatim("TrackTriggerHPH") << "======================================================";
235  }
236  }
Log< level::Info, true > LogVerbatim
int nKalmanLayers() const
bool useNewKF() const
std::vector< float > bonusFeatures_
int digiZT(double z0, double cot, int binEta) const
bool hphDebug() const
std::vector< int > binary_
std::map< int, const tt::SensorModule * > layerEncodingMap_
std::map< int, std::map< int, std::vector< int > > > layermap() const
std::vector< double > etaRegions_
std::vector< int > layerEncoding_
int findLayer(int layerId)
std::vector< double > etaRegions() const
int reducedId(int layerId)
int digiCot(double cot, int binEta) const
std::map< int, std::map< int, std::vector< int > > > layermap_
int etaRegion(double z0, double cot, bool useNewKF) const

◆ ~HitPatternHelper()

hph::HitPatternHelper::~HitPatternHelper ( )
inline

Definition at line 92 of file HitPatternHelper.h.

92 {}

Member Function Documentation

◆ binary()

std::vector<int> hph::HitPatternHelper::binary ( )
inline

Definition at line 112 of file HitPatternHelper.h.

References binary_.

112 { return binary_; } //11-bit hitmask needed by TrackQuality.cc (0~5->L1~L6;6~10->D1~D5)
std::vector< int > binary_

◆ bonusFeatures()

std::vector<float> hph::HitPatternHelper::bonusFeatures ( )
inline

Definition at line 113 of file HitPatternHelper.h.

References bonusFeatures_.

113 { return bonusFeatures_; } //bonus features for track quality
std::vector< float > bonusFeatures_

◆ etaSector()

int hph::HitPatternHelper::etaSector ( )
inline

Definition at line 94 of file HitPatternHelper.h.

References etaSector_.

94 { return etaSector_; } //Eta sectors defined in KF

◆ findLayer()

int hph::HitPatternHelper::findLayer ( int  layerId)

Definition at line 285 of file HitPatternHelper.cc.

References mps_fire::i, createfilelist::int, and layerEncoding_.

Referenced by HitPatternHelper().

285  {
286  for (int i = 0; i < (int)layerEncoding_.size(); i++) {
287  if (layerId == (int)layerEncoding_[i]) {
288  return i;
289  }
290  }
291  return -1;
292  }
std::vector< int > layerEncoding_

◆ num2S()

int hph::HitPatternHelper::num2S ( )
inline

Definition at line 105 of file HitPatternHelper.h.

References num2S_.

105 { return num2S_; } //The number of 2S layers are found in hitpattern

◆ numExpLayer()

int hph::HitPatternHelper::numExpLayer ( )
inline

Definition at line 95 of file HitPatternHelper.h.

References numExpLayer_.

95 { return numExpLayer_; } //The number of layers KF expects

◆ numMissing2S()

int hph::HitPatternHelper::numMissing2S ( )
inline

Definition at line 101 of file HitPatternHelper.h.

References numMissing2S_.

101  {
102  return numMissing2S_;
103  } //The number of 2S layers that are missing. It includes the two types of layers mentioned above.

◆ numMissingInterior1()

int hph::HitPatternHelper::numMissingInterior1 ( )
inline

Definition at line 106 of file HitPatternHelper.h.

References numMissingInterior1_.

106  {
107  return numMissingInterior1_;
108  } //The number of missing interior layers (using only hitpattern)

◆ numMissingInterior2()

int hph::HitPatternHelper::numMissingInterior2 ( )
inline

Definition at line 109 of file HitPatternHelper.h.

References numMissingInterior2_.

109  {
110  return numMissingInterior2_;
111  } //The number of missing interior layers (using hitpattern, layermap from Old KF and sensor modules)

◆ numMissingPS()

int hph::HitPatternHelper::numMissingPS ( )
inline

Definition at line 96 of file HitPatternHelper.h.

References numMissingPS_.

96  {
97  return numMissingPS_;
98  } //The number of PS layers that are missing. It includes layers that are missing:

◆ numPS()

int hph::HitPatternHelper::numPS ( )
inline

Definition at line 104 of file HitPatternHelper.h.

References numPS_.

104 { return numPS_; } //The number of PS layers are found in hitpattern

◆ reducedId()

int hph::HitPatternHelper::reducedId ( int  layerId)

Definition at line 272 of file HitPatternHelper.cc.

References hphDebug_.

Referenced by HitPatternHelper().

272  {
273  if (hphDebug_ && (layerId > 15 || layerId < 1)) {
274  edm::LogVerbatim("TrackTriggerHPH") << "Warning: invalid layer id !";
275  }
276  if (layerId <= 6) {
277  layerId = layerId - 1;
278  return layerId;
279  } else {
280  layerId = layerId - 5;
281  return layerId;
282  }
283  }
Log< level::Info, true > LogVerbatim

Member Data Documentation

◆ binary_

std::vector<int> hph::HitPatternHelper::binary_
private

Definition at line 141 of file HitPatternHelper.h.

Referenced by binary(), and HitPatternHelper().

◆ bonusFeatures_

std::vector<float> hph::HitPatternHelper::bonusFeatures_
private

Definition at line 142 of file HitPatternHelper.h.

Referenced by bonusFeatures().

◆ cotBin_

int hph::HitPatternHelper::cotBin_
private

Definition at line 127 of file HitPatternHelper.h.

◆ etaBin_

int hph::HitPatternHelper::etaBin_
private

Definition at line 126 of file HitPatternHelper.h.

◆ etaRegions_

std::vector<double> hph::HitPatternHelper::etaRegions_
private

Definition at line 123 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ etaSector_

int hph::HitPatternHelper::etaSector_
private

Definition at line 133 of file HitPatternHelper.h.

Referenced by etaSector(), and HitPatternHelper().

◆ hitpattern_

int hph::HitPatternHelper::hitpattern_
private

Definition at line 132 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ hphDebug_

bool hph::HitPatternHelper::hphDebug_
private

Definition at line 121 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and reducedId().

◆ layerEncoding_

std::vector<int> hph::HitPatternHelper::layerEncoding_
private

Definition at line 129 of file HitPatternHelper.h.

Referenced by findLayer(), and HitPatternHelper().

◆ layerEncodingMap_

std::map<int, const tt::SensorModule*> hph::HitPatternHelper::layerEncodingMap_
private

Definition at line 130 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ layermap_

std::map<int, std::map<int, std::vector<int> > > hph::HitPatternHelper::layermap_
private

Definition at line 124 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ nKalmanLayers_

int hph::HitPatternHelper::nKalmanLayers_
private

Definition at line 125 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ num2S_

int hph::HitPatternHelper::num2S_
private

Definition at line 138 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and num2S().

◆ numExpLayer_

int hph::HitPatternHelper::numExpLayer_
private

Definition at line 131 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numExpLayer().

◆ numMissing2S_

int hph::HitPatternHelper::numMissing2S_
private

Definition at line 136 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numMissing2S().

◆ numMissingInterior1_

int hph::HitPatternHelper::numMissingInterior1_
private

Definition at line 139 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numMissingInterior1().

◆ numMissingInterior2_

int hph::HitPatternHelper::numMissingInterior2_
private

Definition at line 140 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numMissingInterior2().

◆ numMissingLayer_

int hph::HitPatternHelper::numMissingLayer_
private

Definition at line 134 of file HitPatternHelper.h.

◆ numMissingPS_

int hph::HitPatternHelper::numMissingPS_
private

Definition at line 135 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numMissingPS().

◆ numPS_

int hph::HitPatternHelper::numPS_
private

Definition at line 137 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numPS().

◆ setup_

const Setup* hph::HitPatternHelper::setup_
private

◆ useNewKF_

bool hph::HitPatternHelper::useNewKF_
private

Definition at line 122 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ zTBin_

int hph::HitPatternHelper::zTBin_
private

Definition at line 128 of file HitPatternHelper.h.