CMS 3D CMS Logo

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

#include <HitPatternHelper.h>

Public Member Functions

std::vector< int > binary ()
 
int etaSector ()
 
int findLayer (int layerId)
 
 HitPatternHelper ()
 
 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 ()
 

Static Public Member Functions

static auto equalID (tt::SensorModule lhs, tt::SensorModule rhs)
 
static auto smallerID (tt::SensorModule lhs, tt::SensorModule rhs)
 

Private Attributes

std::vector< int > binary_
 
float chosenRofZ_
 
double cot_
 
float deltaTanL_
 
std::vector< double > etaRegions_
 
int etaSector_
 
int hitpattern_
 
bool hphDebug_
 
std::map< int, std::map< int, std::vector< int > > > layermap_
 
std::vector< tt::SensorModulelayers_
 
int nKalmanLayers_
 
int num2S_
 
int numExpLayer_
 
int numMissing2S_
 
int numMissingInterior1_
 
int numMissingInterior2_
 
int numMissingLayer_
 
int numMissingPS_
 
int numPS_
 
const Setupsetup_
 
bool useNewKF_
 
double z0_
 

Detailed Description

Definition at line 72 of file HitPatternHelper.h.

Constructor & Destructor Documentation

◆ HitPatternHelper() [1/2]

hph::HitPatternHelper::HitPatternHelper ( )
inline

Definition at line 74 of file HitPatternHelper.h.

74 {}

◆ HitPatternHelper() [2/2]

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

Definition at line 44 of file HitPatternHelper.cc.

References funct::abs(), binary_, chosenRofZ_, cot_, ztail::d, deltaTanL_, relativeConstraints::empty, equalID(), ALCARECOTkAlBeamHalo_cff::etaMax, etaRegions_, etaSector_, JetChargeProducer_cfi::exp, findLayer(), hitpattern_, hphDebug_, mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, layermap_, layers_, nKalmanLayers_, num2S_, numExpLayer_, numMissing2S_, numMissingInterior1_, numMissingInterior2_, numMissingPS_, numPS_, ReducedId(), hph::Setup::sensorModules(), cmsswSequenceInfo::seq, setup_, smallerID(), jetUpdater_cfi::sort, funct::tan(), tier0::unique(), useNewKF_, and z0_.

45  : hitpattern_(hitpattern),
46  numExpLayer_(0),
48  numMissingPS_(0),
49  numMissing2S_(0),
50  numPS_(0),
51  num2S_(0),
54  cot_(cot),
55  z0_(z0),
56  setup_(setup),
57  binary_(11, 0),
65  //Calculating eta sector based on cot and z0
66  float kfzRef = z0_ + chosenRofZ_ * cot_;
67  int kf_eta_reg = 0;
68  for (int iEtaSec = 1; iEtaSec < ((int)etaRegions_.size() - 1); iEtaSec++) { // Doesn't apply eta < 2.4 cut.
69  float etaMax = etaRegions_[iEtaSec];
70  float zRefMax = chosenRofZ_ / tan(2. * atan(exp(-etaMax)));
71  if (kfzRef > zRefMax) {
72  kf_eta_reg = iEtaSec;
73  }
74  }
75  etaSector_ = kf_eta_reg;
76  if (kf_eta_reg < ((int)etaRegions_.size() - 1) / 2) {
77  kf_eta_reg = ((int)etaRegions_.size() - 1) / 2 - 1 - kf_eta_reg;
78  } else {
79  kf_eta_reg = kf_eta_reg - (int)(etaRegions_.size() - 1) / 2;
80  }
81  //Looping over sensor modules to make predictions on which layers particles are expected to hit
82  for (const tt::SensorModule& sm : setup_->sensorModules()) {
83  double d = (z0_ - sm.z() + sm.r() * cot_) / (sm.cosTilt() - sm.sinTilt() * cot_);
84  double d_p =
85  (z0_ - sm.z() + sm.r() * (cot_ + deltaTanL_ / 2)) / (sm.cosTilt() - sm.sinTilt() * (cot_ + deltaTanL_ / 2));
86  double d_m =
87  (z0_ - sm.z() + sm.r() * (cot_ - deltaTanL_ / 2)) / (sm.cosTilt() - sm.sinTilt() * (cot_ - deltaTanL_ / 2));
88  if (useNewKF_ &&
89  (abs(d_p) < sm.numColumns() * sm.pitchCol() / 2. || abs(d_m) < sm.numColumns() * sm.pitchCol() / 2.)) {
90  layers_.push_back(sm);
91  }
92  if (!useNewKF_ && abs(d) < sm.numColumns() * sm.pitchCol() / 2.) {
93  layers_.push_back(sm);
94  }
95  }
96  //layers_ constains all the sensor modules that particles are expected to hit
97  sort(layers_.begin(), layers_.end(), smallerID);
98  layers_.erase(unique(layers_.begin(), layers_.end(), equalID), layers_.end()); //Keep only one sensor per layer
99 
100  numExpLayer_ = layers_.size();
101 
102  int nbits = floor(log2(hitpattern_)) + 1;
103  int lay_i = 0;
104  bool seq = false;
105  for (int i = 0; i < nbits; i++) {
106  lay_i = ((1 << i) & hitpattern_) >> i; //0 or 1 in ith bit (right to left)
107 
108  if (lay_i && !seq)
109  seq = true; //sequence starts when first 1 found
110  if (!lay_i && seq) {
111  numMissingInterior1_++; //This is the same as the "tmp_trk_nlaymiss_interior" calculated in Trackquality.cc
112  }
113  if (!lay_i) {
114  bool realhit = false;
115  if (layermap_[kf_eta_reg][i].empty())
116  continue;
117  for (int j : layermap_[kf_eta_reg][i]) {
118  int k = findLayer(j);
119  if (k > 0)
120  realhit = true;
121  }
122  if (realhit)
123  numMissingInterior2_++; //This variable doesn't make sense for new KF because it uses the layermap from Old KF
124  }
125  }
126 
127  if (hphDebug_) {
128  if (useNewKF_) {
129  edm::LogVerbatim("TrackTriggerHPH") << "Running with New KF";
130  } else {
131  edm::LogVerbatim("TrackTriggerHPH") << "Running with Old KF";
132  }
133  edm::LogVerbatim("TrackTriggerHPH") << "======================================================";
134  edm::LogVerbatim("TrackTriggerHPH")
135  << "Looking at hitpattern " << std::bitset<7>(hitpattern_) << "; Looping over KF layers:";
136  }
137 
138  if (useNewKF_) {
139  //New KF uses sensor modules to determine the hitmask already
140  for (int i = 0; i < numExpLayer_; i++) {
141  if (hphDebug_) {
142  edm::LogVerbatim("TrackTriggerHPH") << "--------------------------";
143  edm::LogVerbatim("TrackTriggerHPH") << "Looking at KF layer " << i;
144  if (layers_[i].layerId() < 10) {
145  edm::LogVerbatim("TrackTriggerHPH") << "KF expects L" << layers_[i].layerId();
146  } else {
147  edm::LogVerbatim("TrackTriggerHPH") << "KF expects D" << layers_[i].layerId() - 10;
148  }
149  }
150 
151  if (((1 << i) & hitpattern_) >> i) {
152  if (hphDebug_) {
153  edm::LogVerbatim("TrackTriggerHPH") << "Layer found in hitpattern";
154  }
155 
156  binary_[ReducedId(layers_[i].layerId())] = 1;
157  if (layers_[i].psModule()) {
158  numPS_++;
159  } else {
160  num2S_++;
161  }
162  } else {
163  if (hphDebug_) {
164  edm::LogVerbatim("TrackTriggerHPH") << "Layer missing in hitpattern";
165  }
166 
167  if (layers_[i].psModule()) {
168  numMissingPS_++;
169  } else {
170  numMissing2S_++;
171  }
172  }
173  }
174 
175  } else {
176  //Old KF uses the hard coded layermap to determien hitmask
177  for (int i = 0; i < nKalmanLayers_; i++) { //Loop over each digit of hitpattern
178 
179  if (hphDebug_) {
180  edm::LogVerbatim("TrackTriggerHPH") << "--------------------------";
181  edm::LogVerbatim("TrackTriggerHPH") << "Looking at KF layer " << i;
182  }
183 
184  if (layermap_[kf_eta_reg][i].empty()) {
185  if (hphDebug_) {
186  edm::LogVerbatim("TrackTriggerHPH") << "KF does not expect this layer";
187  }
188 
189  continue;
190  }
191 
192  for (int j :
193  layermap_[kf_eta_reg][i]) { //Find out which layer the Old KF is dealing with when hitpattern is encoded
194 
195  if (hphDebug_) {
196  if (j < 10) {
197  edm::LogVerbatim("TrackTriggerHPH") << "KF expects L" << j;
198  } else {
199  edm::LogVerbatim("TrackTriggerHPH") << "KF expects D" << j - 10;
200  }
201  }
202 
203  int k = findLayer(j);
204  if (k < 0) {
205  //k<0 means even though layer j is predicted by Old KF, this prediction is rejected because it contradicts
206  if (hphDebug_) { //a more accurate prediction made with the help of information from sensor modules
207  edm::LogVerbatim("TrackTriggerHPH") << "Rejected by sensor modules";
208  }
209 
210  continue;
211  }
212 
213  if (hphDebug_) {
214  edm::LogVerbatim("TrackTriggerHPH") << "Confirmed by sensor modules";
215  }
216  //prediction is accepted
217  if (((1 << i) & hitpattern_) >> i) {
218  if (hphDebug_) {
219  edm::LogVerbatim("TrackTriggerHPH") << "Layer found in hitpattern";
220  }
221 
222  binary_[ReducedId(j)] = 1;
223  if (layers_[k].psModule()) {
224  numPS_++;
225  } else {
226  num2S_++;
227  }
228  } else {
229  if (hphDebug_) {
230  edm::LogVerbatim("TrackTriggerHPH") << "Layer missing in hitpattern";
231  }
232 
233  if (layers_[k].psModule()) {
234  numMissingPS_++;
235  } else {
236  numMissing2S_++;
237  }
238  }
239  }
240  }
241  }
242 
243  if (hphDebug_) {
244  edm::LogVerbatim("TrackTriggerHPH") << "------------------------------";
245  edm::LogVerbatim("TrackTriggerHPH") << "numPS = " << numPS_ << ", num2S = " << num2S_
246  << ", missingPS = " << numMissingPS_ << ", missing2S = " << numMissing2S_;
247  edm::LogVerbatim("TrackTriggerHPH") << "======================================================";
248  }
249  }
Log< level::Info, true > LogVerbatim
int nKalmanLayers() const
static auto equalID(tt::SensorModule lhs, tt::SensorModule rhs)
bool useNewKF() const
double deltaTanL() const
double chosenRofZ() const
bool hphDebug() const
std::vector< int > binary_
static auto smallerID(tt::SensorModule lhs, tt::SensorModule rhs)
std::map< int, std::map< int, std::vector< int > > > layermap() const
std::vector< double > etaRegions_
def unique(seq, keepstr=True)
Definition: tier0.py:24
std::vector< tt::SensorModule > layers_
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
int findLayer(int layerId)
std::vector< tt::SensorModule > sensorModules() const
std::vector< double > etaRegions() const
int ReducedId(int layerId)
std::map< int, std::map< int, std::vector< int > > > layermap_

◆ ~HitPatternHelper()

hph::HitPatternHelper::~HitPatternHelper ( )
inline

Definition at line 76 of file HitPatternHelper.h.

76 {}

Member Function Documentation

◆ binary()

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

Definition at line 96 of file HitPatternHelper.h.

References binary_.

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

◆ equalID()

static auto hph::HitPatternHelper::equalID ( tt::SensorModule  lhs,
tt::SensorModule  rhs 
)
inlinestatic

Definition at line 98 of file HitPatternHelper.h.

References tt::SensorModule::layerId().

Referenced by HitPatternHelper().

98 { return lhs.layerId() == rhs.layerId(); }
int layerId() const
Definition: SensorModule.h:43

◆ etaSector()

int hph::HitPatternHelper::etaSector ( )
inline

Definition at line 78 of file HitPatternHelper.h.

References etaSector_.

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

◆ findLayer()

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

Definition at line 264 of file HitPatternHelper.cc.

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

Referenced by HitPatternHelper().

264  {
265  for (int i = 0; i < (int)layers_.size(); i++) {
266  if (layerId == (int)layers_[i].layerId()) {
267  return i;
268  }
269  }
270  return -1;
271  }
std::vector< tt::SensorModule > layers_

◆ num2S()

int hph::HitPatternHelper::num2S ( )
inline

Definition at line 89 of file HitPatternHelper.h.

References num2S_.

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

◆ numExpLayer()

int hph::HitPatternHelper::numExpLayer ( )
inline

Definition at line 79 of file HitPatternHelper.h.

References numExpLayer_.

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

◆ numMissing2S()

int hph::HitPatternHelper::numMissing2S ( )
inline

Definition at line 85 of file HitPatternHelper.h.

References numMissing2S_.

85  {
86  return numMissing2S_;
87  } //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 90 of file HitPatternHelper.h.

References numMissingInterior1_.

90  {
91  return numMissingInterior1_;
92  } //The number of missing interior layers (using only hitpattern)

◆ numMissingInterior2()

int hph::HitPatternHelper::numMissingInterior2 ( )
inline

Definition at line 93 of file HitPatternHelper.h.

References numMissingInterior2_.

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

◆ numMissingPS()

int hph::HitPatternHelper::numMissingPS ( )
inline

Definition at line 80 of file HitPatternHelper.h.

References numMissingPS_.

80  {
81  return numMissingPS_;
82  } //The number of PS layers that are missing. It includes layers that are missing:

◆ numPS()

int hph::HitPatternHelper::numPS ( )
inline

Definition at line 88 of file HitPatternHelper.h.

References numPS_.

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

◆ ReducedId()

int hph::HitPatternHelper::ReducedId ( int  layerId)

Definition at line 251 of file HitPatternHelper.cc.

References hphDebug_.

Referenced by HitPatternHelper().

251  {
252  if (hphDebug_ && (layerId > 15 || layerId < 1)) {
253  edm::LogVerbatim("TrackTriggerHPH") << "Warning: invalid layer id !";
254  }
255  if (layerId <= 6) {
256  layerId = layerId - 1;
257  return layerId;
258  } else {
259  layerId = layerId - 5;
260  return layerId;
261  }
262  };
Log< level::Info, true > LogVerbatim

◆ smallerID()

static auto hph::HitPatternHelper::smallerID ( tt::SensorModule  lhs,
tt::SensorModule  rhs 
)
inlinestatic

Definition at line 97 of file HitPatternHelper.h.

References tt::SensorModule::layerId().

Referenced by HitPatternHelper().

97 { return lhs.layerId() < rhs.layerId(); }
int layerId() const
Definition: SensorModule.h:43

Member Data Documentation

◆ binary_

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

Definition at line 119 of file HitPatternHelper.h.

Referenced by binary(), and HitPatternHelper().

◆ chosenRofZ_

float hph::HitPatternHelper::chosenRofZ_
private

Definition at line 122 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ cot_

double hph::HitPatternHelper::cot_
private

Definition at line 115 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ deltaTanL_

float hph::HitPatternHelper::deltaTanL_
private

Definition at line 123 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ etaRegions_

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

Definition at line 124 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ etaSector_

int hph::HitPatternHelper::etaSector_
private

Definition at line 105 of file HitPatternHelper.h.

Referenced by etaSector(), and HitPatternHelper().

◆ hitpattern_

int hph::HitPatternHelper::hitpattern_
private

Definition at line 106 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ hphDebug_

bool hph::HitPatternHelper::hphDebug_
private

Definition at line 120 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and ReducedId().

◆ layermap_

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

Definition at line 126 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ layers_

std::vector<tt::SensorModule> hph::HitPatternHelper::layers_
private

Definition at line 118 of file HitPatternHelper.h.

Referenced by findLayer(), and 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 112 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and num2S().

◆ numExpLayer_

int hph::HitPatternHelper::numExpLayer_
private

Definition at line 107 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numExpLayer().

◆ numMissing2S_

int hph::HitPatternHelper::numMissing2S_
private

Definition at line 110 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numMissing2S().

◆ numMissingInterior1_

int hph::HitPatternHelper::numMissingInterior1_
private

Definition at line 113 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numMissingInterior1().

◆ numMissingInterior2_

int hph::HitPatternHelper::numMissingInterior2_
private

Definition at line 114 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numMissingInterior2().

◆ numMissingLayer_

int hph::HitPatternHelper::numMissingLayer_
private

Definition at line 108 of file HitPatternHelper.h.

◆ numMissingPS_

int hph::HitPatternHelper::numMissingPS_
private

Definition at line 109 of file HitPatternHelper.h.

Referenced by HitPatternHelper(), and numMissingPS().

◆ numPS_

int hph::HitPatternHelper::numPS_
private

Definition at line 111 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 121 of file HitPatternHelper.h.

Referenced by HitPatternHelper().

◆ z0_

double hph::HitPatternHelper::z0_
private

Definition at line 116 of file HitPatternHelper.h.

Referenced by HitPatternHelper().