CMS 3D CMS Logo

HitPattern.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 #ifndef TrackReco_HitPattern_h
4 #define TrackReco_HitPattern_h
5 
6 //
7 // File: DataFormats/TrackReco/interface/HitPattern.h
8 //
9 // Marcel Vos, INFN Pisa
10 // v1.10 2007/05/08 bellan
11 // Zongru Wan, Kansas State University
12 // Jean-Roch Vlimant
13 // Kevin Burkett
14 // Boris Mangano
15 //
16 // Hit pattern is the summary information of the hits associated to track in
17 // AOD. When RecHits are no longer available, the compact hit pattern should
18 // allow basic track selection based on the hits in various subdetectors.
19 // The hits of a track are saved in unit16_t hitPattern[MaxHits].
20 //
21 // uint16_t
22 // +--------+---------------+---------------------------+-----------------+----------------+
23 // | tk/mu | sub-structure | sub-sub-structure | stereo | hit type |
24 // +--------+---------------+---------------------------+-----------------+----------------+
25 // | 10 | 9 8 7 | 6 5 4 3 | 2 | 1 0 | bit
26 // +--------+---------------+---------------------------+-----------------+----------------|
27 // | tk = 1 | PXB = 1 | layer = 1-3 | | hit type = 0-3 |
28 // | tk = 1 | PXF = 2 | disk = 1-2 | | hit type = 0-3 |
29 // | tk = 1 | TIB = 3 | layer = 1-4 | 0=rphi,1=stereo | hit type = 0-3 |
30 // | tk = 1 | TID = 4 | wheel = 1-3 | 0=rphi,1=stereo | hit type = 0-3 |
31 // | tk = 1 | TOB = 5 | layer = 1-6 | 0=rphi,1=stereo | hit type = 0-3 |
32 // | tk = 1 | TEC = 6 | wheel = 1-9 | 0=rphi,1=stereo | hit type = 0-3 |
33 // | mu = 0 | DT = 1 | 4*(stat-1)+superlayer | | hit type = 0-3 |
34 // | mu = 0 | CSC = 2 | 4*(stat-1)+(ring-1) | | hit type = 0-3 |
35 // | mu = 0 | RPC = 3 | 4*(stat-1)+2*layer+region | | hit type = 0-3 |
36 // | mu = 0 | GEM = 4 | 2*(stat-1)+2*(layer-1) | | hit type = 0-3 |
37 // |mu = 0 | ME0 = 5 | roll | | hit type = 0-3 |
38 // +--------+---------------+---------------------------+-----------------+----------------+
39 //
40 // hit type, see DataFormats/TrackingRecHit/interface/TrackingRecHit.h
41 // VALID = valid hit = 0
42 // MISSING = detector is good, but no rec hit found = 1
43 // INACTIVE = detector is off, so there was no hope = 2
44 // BAD = there were many bad strips within the ellipse = 3
45 //
46 // It had been shown by Zongru using a 100 GeV muon sample with 5000 events
47 // uniform in eta and phi, the average (maximum) number of tracker hits is
48 // 13 (17) and the average (maximum) number of muon detector hits is about
49 // 26 (50). If the number of hits of a track is larger than 80 then the extra
50 // hits are ignored by hit pattern. The static hit pattern array might be
51 // improved to a dynamic one in the future.
52 //
53 // Because of tracking with/without overlaps and with/without hit-splitting,
54 // the final number of hits per track is pretty "variable". Compared with the
55 // number of valid hits, the number of crossed layers with measurement should
56 // be more robust to discriminate between good and fake track.
57 //
58 // Since 4-bit for sub-sub-structure is not enough to specify a muon layer,
59 // the layer case counting methods are implemented for tracker only. This is
60 // different from the hit counting methods which are implemented for both
61 // tracker and muon detector.
62 //
63 // Given a tracker layer, specified by sub-structure and layer, the method
64 // getTrackerLayerCase(substr, layer) groups all of the hits in the hit pattern
65 // array for the layer together and returns one of the four cases
66 //
67 // crossed
68 // layer case 0: VALID + (MISSING, OFF, BAD) ==> with measurement
69 // layer case 1: MISSING + (OFF, BAD) ==> without measurement
70 // layer case 2: OFF, BAD ==> totally off or bad, cannot say much
71 // not crossed
72 // layer case NULL_RETURN: track outside acceptance or in gap ==> null
73 //
74 // Given a tracker layer, specified by sub-structure and layer, the method
75 // getTrackerMonoStereo(substr, layer) groups all of the valid hits in the hit
76 // pattern array for the layer together and returns
77 //
78 // 0: neither a valid mono nor a valid stereo hit
79 // MONO: valid mono hit
80 // STEREO: valid stereo hit
81 // MONO | STEREO: both
82 //
83 //
84 // Given a track, here is an example usage of hit pattern
85 //
86 // // hit pattern of the track
87 // const reco::HitPattern &p = track->hitPattern();
88 //
89 // // loop over the hits of the track.
90 // for (int i = 0; i < p.numberOfAllHits(HitPattern::TRACK_HITS); i++) {
91 // uint32_t hit = p.getHitPattern(HitPattern::TRACK_HITS, i);
92 //
93 // // if the hit is valid and in pixel barrel, print out the layer
94 // if (p.validHitFilter(hit) && p.pixelBarrelHitFilter(hit)){
95 // cout << "valid hit found in pixel barrel layer "
96 // << p.getLayer(hit)
97 // << endl;
98 // }
99 //
100 // // expert level: printout the hit in 11-bit binary format
101 // cout << "hit in 11-bit binary format = ";
102 // for (int j = 10; j >= 0; j--){
103 // int bit = (hit >> j) & 0x1;
104 // cout << bit;
105 // }
106 // cout << endl;
107 // }
108 //
109 // //count the number of valid pixel barrel *** hits ***
110 // cout << "number of of valid pixel barrel hits is "
111 // << p.numberOfValidPixelBarrelHits()
112 // << endl;
113 //
114 // //count the number of pixel barrel *** layers *** with measurement
115 // cout << "number of of pixel barrel layers with measurement is "
116 // << p.pixelBarrelLayersWithMeasurement()
117 // << endl;
118 //
119 
128 
129 #include <utility>
130 #include <algorithm>
131 #include <iostream>
132 #include <ostream>
133 #include <memory>
134 
135 class TrackerTopology;
136 
137 namespace test {
138  namespace TestHitPattern {
139  int test();
140  }
141 }
142 
143 namespace reco
144 {
145 
147 {
148 
149 public:
150  enum {
151  MONO = 1,
152  STEREO = 2
153  };
154 
155  enum HIT_TYPE {
156  VALID = 0,
157  MISSING = 1,
158  INACTIVE = 2,
159  BAD = 3
160  };
161 
162  enum HitCategory {
163  TRACK_HITS = 0,
164  MISSING_INNER_HITS = 1,
165  MISSING_OUTER_HITS = 2
166  };
167  const static unsigned short ARRAY_LENGTH = 50;
168  const static unsigned short HIT_LENGTH = 11;
169  const static unsigned short MaxHits = (8 * sizeof(uint16_t) * ARRAY_LENGTH) / HIT_LENGTH;
170 
171  static const uint32_t NULL_RETURN = 999999;
172  static const uint16_t EMPTY_PATTERN = 0x0;
173 
174  static bool trackerHitFilter(uint16_t pattern);
175  static bool muonHitFilter(uint16_t pattern);
176 
177  static bool validHitFilter(uint16_t pattern);
178  static bool missingHitFilter(uint16_t pattern);
179  static bool inactiveHitFilter(uint16_t pattern);
180  static bool badHitFilter(uint16_t pattern);
181 
182  static bool pixelHitFilter(uint16_t pattern);
183  static bool pixelBarrelHitFilter(uint16_t pattern);
184  static bool pixelEndcapHitFilter(uint16_t pattern);
185  static bool stripHitFilter(uint16_t pattern);
186  static bool stripTIBHitFilter(uint16_t pattern);
187  static bool stripTIDHitFilter(uint16_t pattern);
188  static bool stripTOBHitFilter(uint16_t pattern);
189  static bool stripTECHitFilter(uint16_t pattern);
190 
191  static bool muonDTHitFilter(uint16_t pattern);
192  static bool muonCSCHitFilter(uint16_t pattern);
193  static bool muonRPCHitFilter(uint16_t pattern);
194  static bool muonGEMHitFilter(uint16_t pattern);
195  static bool muonME0HitFilter(uint16_t pattern);
196 
197  static uint32_t getHitType(uint16_t pattern);
198 
199  // mono (0) or stereo (1)
200  static uint32_t getSide(uint16_t pattern);
201  static uint32_t getLayer(uint16_t pattern);
202  static uint32_t getSubSubStructure(uint16_t pattern);
203  static uint32_t getSubStructure(uint16_t pattern);
204  static uint32_t getSubDetector(uint16_t pattern);
205 
207  static uint16_t getMuonStation(uint16_t pattern);
208 
210  static uint16_t getDTSuperLayer(uint16_t pattern); // only for DT patterns
211 
213  static uint16_t getCSCRing(uint16_t pattern) ;
214 
216  static uint16_t getRPCLayer(uint16_t pattern) ;
217 
219  static uint16_t getRPCregion(uint16_t pattern);
220 
222  static uint16_t getGEMStation(uint16_t pattern);
223 
225  static uint16_t getGEMLayer(uint16_t pattern);
226 
227  HitPattern();
228 
229  ~HitPattern();
230 
231  HitPattern(const HitPattern &other);
232 
233  HitPattern &operator=(const HitPattern &other);
234 
235  template<typename I>
236  bool appendHits(const I &begin, const I &end, const TrackerTopology& ttopo);
237  bool appendHit(const TrackingRecHit &hit, const TrackerTopology& ttopo);
238  bool appendHit(const TrackingRecHitRef &ref, const TrackerTopology& ttopo);
239  bool appendHit(const DetId &id, TrackingRecHit::Type hitType, const TrackerTopology& ttopo);
240  bool appendHit(const uint16_t pattern, TrackingRecHit::Type hitType);
241 
248  bool appendTrackerHit(uint16_t subdet, uint16_t layer, uint16_t stereo, TrackingRecHit::Type hitType);
249 
256  bool appendMuonHit(const DetId& id, TrackingRecHit::Type hitType);
257 
258  // get the pattern of the position-th hit
259  uint16_t getHitPattern(HitCategory category, int position) const;
260 
261  void clear();
262 
263  // print the pattern of the position-th hit
264  void printHitPattern(HitCategory category, int position, std::ostream &stream) const;
265  void print(HitCategory category, std::ostream &stream = std::cout) const;
266 
267  // has valid hit in PXB/PXF layer x
268  bool hasValidHitInPixelLayer(enum PixelSubdetector::SubDetector, uint16_t layer) const;
269 
270  int numberOfAllHits(HitCategory category) const; // not-null
271  int numberOfValidHits() const; // not-null, valid
272 
273  int numberOfAllTrackerHits(HitCategory category) const; // not-null, tracker
274  int numberOfValidTrackerHits() const; // not-null, valid, tracker
275  int numberOfValidPixelHits() const; // not-null, valid, pixel
276  int numberOfValidPixelBarrelHits() const; // not-null, valid, pixel PXB
277  int numberOfValidPixelEndcapHits() const; // not-null, valid, pixel PXF
278  int numberOfValidStripHits() const; // not-null, valid, strip
279  int numberOfValidStripTIBHits() const; // not-null, valid, strip TIB
280  int numberOfValidStripTIDHits() const; // not-null, valid, strip TID
281  int numberOfValidStripTOBHits() const; // not-null, valid, strip TOB
282  int numberOfValidStripTECHits() const; // not-null, valid, strip TEC
283 
284 
285  int numberOfLostHits(HitCategory category) const; // not-null, not valid
286  int numberOfLostTrackerHits(HitCategory category) const; // not-null, not valid, tracker
287  int numberOfLostPixelHits(HitCategory category) const; // not-null, not valid, pixel
288  int numberOfLostPixelBarrelHits(HitCategory category) const; // not-null, not valid, pixel PXB
289  int numberOfLostPixelEndcapHits(HitCategory category) const; // not-null, not valid, pixel PXF
290  int numberOfLostStripHits(HitCategory category) const; // not-null, not valid, strip
291  int numberOfLostStripTIBHits(HitCategory category) const; // not-null, not valid, strip TIB
292  int numberOfLostStripTIDHits(HitCategory category) const; // not-null, not valid, strip TID
293  int numberOfLostStripTOBHits(HitCategory category) const; // not-null, not valid, strip TOB
294  int numberOfLostStripTECHits(HitCategory category) const; // not-null, not valid, strip TEC
295 
296  int numberOfMuonHits() const; // not-null, muon
297  int numberOfValidMuonHits() const; // not-null, valid, muon
298  int numberOfValidMuonDTHits() const; // not-null, valid, muon DT
299  int numberOfValidMuonCSCHits() const; // not-null, valid, muon CSC
300  int numberOfValidMuonRPCHits() const; // not-null, valid, muon RPC
301  int numberOfValidMuonGEMHits() const; // not-null, valid, muon GEM
302  int numberOfValidMuonME0Hits() const; // not-null, valid, muon ME0
303 
304  int numberOfLostMuonHits() const; // not-null, not valid, muon
305  int numberOfLostMuonDTHits() const; // not-null, not valid, muon DT
306  int numberOfLostMuonCSCHits() const; // not-null, not valid, muon CSC
307  int numberOfLostMuonRPCHits() const; // not-null, not valid, muon RPC
308  int numberOfLostMuonGEMHits() const; // not-null, not valid, muon GEM
309  int numberOfLostMuonME0Hits() const; // not-null, not valid, muon ME0
310 
311  int numberOfBadHits() const; // not-null, bad (only used in Muon Ch.)
312  int numberOfBadMuonHits() const; // not-null, bad, muon
313  int numberOfBadMuonDTHits() const; // not-null, bad, muon DT
314  int numberOfBadMuonCSCHits() const; // not-null, bad, muon CSC
315  int numberOfBadMuonRPCHits() const; // not-null, bad, muon RPC
316  int numberOfBadMuonGEMHits() const; // not-null, bad, muon GEM
317  int numberOfBadMuonME0Hits() const; // not-null, bad, muon ME0
318 
319  int numberOfInactiveHits() const; // not-null, inactive
320  int numberOfInactiveTrackerHits() const; // not-null, inactive, tracker
321 
322  // count strip layers that have non-null, valid mono and stereo hits
323  int numberOfValidStripLayersWithMonoAndStereo(uint16_t stripdet, uint16_t layer) const;
324  int numberOfValidStripLayersWithMonoAndStereo() const;
325  int numberOfValidTOBLayersWithMonoAndStereo(uint32_t layer = 0) const;
326  int numberOfValidTIBLayersWithMonoAndStereo(uint32_t layer = 0) const;
327  int numberOfValidTIDLayersWithMonoAndStereo(uint32_t layer = 0) const;
328  int numberOfValidTECLayersWithMonoAndStereo(uint32_t layer = 0) const;
329 
330  uint32_t getTrackerLayerCase(HitCategory category, uint16_t substr, uint16_t layer) const;
331  uint16_t getTrackerMonoStereo(HitCategory category, uint16_t substr, uint16_t layer) const;
332 
333  int trackerLayersWithMeasurementOld() const; // case 0: tracker
334  int trackerLayersWithMeasurement() const; // case 0: tracker
335  int pixelLayersWithMeasurementOld() const; // case 0: pixel
336  int pixelLayersWithMeasurement() const; // case 0: pixel
337  int stripLayersWithMeasurement() const; // case 0: strip
338  int pixelBarrelLayersWithMeasurement() const; // case 0: pixel PXB
339  int pixelEndcapLayersWithMeasurement() const; // case 0: pixel PXF
340  int stripTIBLayersWithMeasurement() const; // case 0: strip TIB
341  int stripTIDLayersWithMeasurement() const; // case 0: strip TID
342  int stripTOBLayersWithMeasurement() const; // case 0: strip TOB
343  int stripTECLayersWithMeasurement() const; // case 0: strip TEC
344 
345  int trackerLayersWithoutMeasurement(HitCategory category) const; // case 1: tracker
346  int trackerLayersWithoutMeasurementOld(HitCategory category) const; // case 1: tracker
347  int pixelLayersWithoutMeasurement(HitCategory category) const; // case 1: pixel
348  int stripLayersWithoutMeasurement(HitCategory category) const; // case 1: strip
349  int pixelBarrelLayersWithoutMeasurement(HitCategory category) const; // case 1: pixel PXB
350  int pixelEndcapLayersWithoutMeasurement(HitCategory category) const; // case 1: pixel PXF
351  int stripTIBLayersWithoutMeasurement(HitCategory category) const; // case 1: strip TIB
352  int stripTIDLayersWithoutMeasurement(HitCategory category) const; // case 1: strip TID
353  int stripTOBLayersWithoutMeasurement(HitCategory category) const; // case 1: strip TOB
354  int stripTECLayersWithoutMeasurement(HitCategory category) const; // case 1: strip TEC
355 
356  int trackerLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const; // case 2: tracker
357  int pixelLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const; // case 2: pixel
358  int stripLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const; // case 2: strip
359  int pixelBarrelLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const; // case 2: pixel PXB
360  int pixelEndcapLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const; // case 2: pixel PXF
361  int stripTIBLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const; // case 2: strip TIB
362  int stripTIDLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const; // case 2: strip TID
363  int stripTOBLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const; // case 2: strip TOB
364  int stripTECLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const; // case 2: strip TEC
365 
366  int trackerLayersNull() const; // case NULL_RETURN: tracker
367  int pixelLayersNull() const; // case NULL_RETURN: pixel
368  int stripLayersNull() const; // case NULL_RETURN: strip
369  int pixelBarrelLayersNull() const; // case NULL_RETURN: pixel PXB
370  int pixelEndcapLayersNull() const; // case NULL_RETURN: pixel PXF
371  int stripTIBLayersNull() const; // case NULL_RETURN: strip TIB
372  int stripTIDLayersNull() const; // case NULL_RETURN: strip TID
373  int stripTOBLayersNull() const; // case NULL_RETURN: strip TOB
374  int stripTECLayersNull() const; // case NULL_RETURN: strip TEC
375 
377  int muonStations(int subdet, int hitType) const ;
378 
379  int muonStationsWithValidHits() const;
380  int muonStationsWithBadHits() const;
381  int muonStationsWithAnyHits() const;
382 
383  int dtStationsWithValidHits() const;
384  int dtStationsWithBadHits() const;
385  int dtStationsWithAnyHits() const;
386 
387  int cscStationsWithValidHits() const;
388  int cscStationsWithBadHits() const;
389  int cscStationsWithAnyHits() const;
390 
391  int rpcStationsWithValidHits() const;
392  int rpcStationsWithBadHits() const;
393  int rpcStationsWithAnyHits() const;
394 
395  int gemStationsWithValidHits() const ;
396  int gemStationsWithBadHits() const ;
397  int gemStationsWithAnyHits() const ;
398 
399  int me0StationsWithValidHits() const ;
400  int me0StationsWithBadHits() const ;
401  int me0StationsWithAnyHits() const ;
402 
403 
405  int innermostMuonStationWithHits(int hitType) const;
406  int innermostMuonStationWithValidHits() const;
407  int innermostMuonStationWithBadHits() const;
408  int innermostMuonStationWithAnyHits() const;
409 
411  int outermostMuonStationWithHits(int hitType) const;
412  int outermostMuonStationWithValidHits() const;
413  int outermostMuonStationWithBadHits() const;
414  int outermostMuonStationWithAnyHits() const;
415 
416  int numberOfDTStationsWithRPhiView() const;
417  int numberOfDTStationsWithRZView() const;
418  int numberOfDTStationsWithBothViews() const;
419 
420 private:
421 
422  // 3 bits for hit type
423  const static unsigned short HitTypeOffset = 0;
424  const static unsigned short HitTypeMask = 0x3;
425 
426  // 1 bit to identify the side in double-sided detectors
427  const static unsigned short SideOffset = 2;
428  const static unsigned short SideMask = 0x1;
429 
430  // 4 bits to identify the layer/disk/wheel within the substructure
431  const static unsigned short LayerOffset = 3;
432  const static unsigned short LayerMask = 0xF;
433 
434  // 3 bits to identify the tracker/muon detector substructure
435  const static unsigned short SubstrOffset = 7;
436  const static unsigned short SubstrMask = 0x7;
437 
438  // 1 bit to distinguish tracker and muon subsystems
439  const static unsigned short SubDetectorOffset = 10;
440  const static unsigned short SubDetectorMask = 0x1;
441 
442  const static unsigned short minTrackerWord = 1<< SubDetectorOffset;
443  const static unsigned short minPixelWord = minTrackerWord | (1<<SubstrOffset);
444  const static unsigned short minStripWord = minTrackerWord | (3<<SubstrOffset);
445 
446 
447  // detector side for tracker modules (mono/stereo)
448  static uint16_t isStereo(DetId i, const TrackerTopology& ttopo);
449  static bool stripSubdetectorHitFilter(uint16_t pattern, StripSubdetector::SubDetector substructure);
450 
451  static uint16_t encode(const TrackingRecHit &hit, const TrackerTopology& ttopo);
452  static uint16_t encode(const DetId &id, TrackingRecHit::Type hitType, const TrackerTopology& ttopo);
453  static uint16_t encode(uint16_t det, uint16_t subdet, uint16_t layer, uint16_t side, TrackingRecHit::Type hitType);
454 
455  // generic count methods
456  typedef bool filterType(uint16_t);
457 
458  template<typename F>
459  void call(HitCategory category, filterType typeFilter, F f) const;
460 
461  int countHits(HitCategory category, filterType filter) const;
462  int countTypedHits(HitCategory category, filterType typeFilter, filterType filter) const;
463 
464  bool insertTrackHit(const uint16_t pattern);
465  bool insertExpectedInnerHit(const uint16_t pattern);
466  bool insertExpectedOuterHit(const uint16_t pattern);
467  void insertHit(const uint16_t pattern);
468 
469  uint16_t getHitPatternByAbsoluteIndex(int position) const;
470 
471  std::pair<uint8_t, uint8_t> getCategoryIndexRange(HitCategory category) const;
472 
473  uint16_t hitPattern[ARRAY_LENGTH];
474  uint8_t hitCount;
475 
476  uint8_t beginTrackHits;
477  uint8_t endTrackHits;
478  uint8_t beginInner;
479  uint8_t endInner;
480  uint8_t beginOuter;
481  uint8_t endOuter;
482 
484 
485  template<int N>
486  friend struct PatternSet;
487 };
488 
489 inline std::pair<uint8_t, uint8_t> HitPattern::getCategoryIndexRange(HitCategory category) const
490 {
491  switch (category) {
492  case TRACK_HITS:
493  return std::pair<uint8_t, uint8_t>(beginTrackHits, endTrackHits);
494  break;
495  case MISSING_INNER_HITS:
496  return std::pair<uint8_t, uint8_t>(beginInner, endInner);
497  break;
498  case MISSING_OUTER_HITS:
499  return std::pair<uint8_t, uint8_t>(beginOuter, endOuter);
500  break;
501  }
502  return std::pair<uint8_t, uint8_t>(-1, -1);
503 }
504 
505 template<typename I>
506 bool HitPattern::appendHits(const I &begin, const I &end, const TrackerTopology& ttopo)
507 {
508  for (I hit = begin; hit != end; hit++) {
509  if UNLIKELY((!appendHit(*hit, ttopo))) {
510  return false;
511  }
512  }
513  return true;
514 }
515 
516 inline uint16_t HitPattern::getHitPattern(HitCategory category, int position) const
517 {
518  std::pair<uint8_t, uint8_t> range = getCategoryIndexRange(category);
519  if UNLIKELY((position < 0 || (position + range.first) >= range.second)) {
520  return HitPattern::EMPTY_PATTERN;
521  }
522 
523  return getHitPatternByAbsoluteIndex(range.first + position);
524 }
525 
526 inline int HitPattern::countHits(HitCategory category, filterType filter) const
527 {
528  int count = 0;
529  std::pair<uint8_t, uint8_t> range = getCategoryIndexRange(category);
530  for (int i = range.first; i < range.second; ++i) {
531  if (filter(getHitPatternByAbsoluteIndex(i))) {
532  ++count;
533  }
534  }
535  return count;
536 }
537 
538 
539 template<typename F>
540 void HitPattern::call(HitCategory category, filterType typeFilter, F f) const
541 {
542  std::pair<uint8_t, uint8_t> range = getCategoryIndexRange(category);
543  for (int i = range.first; i < range.second; i++) {
544  uint16_t pattern = getHitPatternByAbsoluteIndex(i);
545  // f() return false to ask to stop looping
546  if (typeFilter(pattern) && !f(pattern)) {
547  break;
548  }
549  }
550 }
551 
552 inline int HitPattern::countTypedHits(HitCategory category, filterType typeFilter, filterType filter) const
553 {
554  int count = 0;
555  std::pair<uint8_t, uint8_t> range = getCategoryIndexRange(category);
556  for (int i = range.first; i < range.second; ++i) {
557  uint16_t pattern = getHitPatternByAbsoluteIndex(i);
558  if (typeFilter(pattern) && filter(pattern)) {
559  ++count;
560  }
561  }
562  return count;
563 }
564 
565 inline bool HitPattern::pixelHitFilter(uint16_t pattern)
566 {
567  if UNLIKELY(!trackerHitFilter(pattern)) {
568  return false;
569  }
570 
571  uint32_t substructure = getSubStructure(pattern);
572  return (substructure == PixelSubdetector::PixelBarrel ||
573  substructure == PixelSubdetector::PixelEndcap);
574 }
575 
576 inline bool HitPattern::pixelBarrelHitFilter(uint16_t pattern)
577 {
578  if UNLIKELY(!trackerHitFilter(pattern)) {
579  return false;
580  }
581 
582  uint32_t substructure = getSubStructure(pattern);
583  return (substructure == PixelSubdetector::PixelBarrel);
584 }
585 
586 inline bool HitPattern::pixelEndcapHitFilter(uint16_t pattern)
587 {
588  if UNLIKELY(!trackerHitFilter(pattern)) {
589  return false;
590  }
591 
592  uint32_t substructure = getSubStructure(pattern);
593  return (substructure == PixelSubdetector::PixelEndcap);
594 }
595 
596 inline bool HitPattern::stripHitFilter(uint16_t pattern)
597 {
598  return pattern > minStripWord;
599 }
600 
601 
602 inline bool HitPattern::stripSubdetectorHitFilter(uint16_t pattern, StripSubdetector::SubDetector substructure)
603 {
604  if UNLIKELY(!trackerHitFilter(pattern)) {
605  return false;
606  }
607 
608  return substructure == getSubStructure(pattern);
609 }
610 
611 inline bool HitPattern::stripTIBHitFilter(uint16_t pattern)
612 {
613  return stripSubdetectorHitFilter(pattern, StripSubdetector::TIB);
614 }
615 
616 inline bool HitPattern::stripTIDHitFilter(uint16_t pattern)
617 {
618  return stripSubdetectorHitFilter(pattern, StripSubdetector::TID);
619 }
620 
621 inline bool HitPattern::stripTOBHitFilter(uint16_t pattern)
622 {
623  return stripSubdetectorHitFilter(pattern, StripSubdetector::TOB);
624 }
625 
626 inline bool HitPattern::stripTECHitFilter(uint16_t pattern)
627 {
628  return stripSubdetectorHitFilter(pattern, StripSubdetector::TEC);
629 }
630 
631 inline bool HitPattern::muonDTHitFilter(uint16_t pattern)
632 {
633  if UNLIKELY(!muonHitFilter(pattern)) {
634  return false;
635  }
636 
637  uint32_t substructure = getSubStructure(pattern);
638  return (substructure == (uint32_t) MuonSubdetId::DT);
639 }
640 
641 inline bool HitPattern::muonCSCHitFilter(uint16_t pattern)
642 {
643  if UNLIKELY(!muonHitFilter(pattern)) {
644  return false;
645  }
646 
647  uint32_t substructure = getSubStructure(pattern);
648  return (substructure == (uint32_t) MuonSubdetId::CSC);
649 }
650 
651 inline bool HitPattern::muonRPCHitFilter(uint16_t pattern)
652 {
653  if UNLIKELY(!muonHitFilter(pattern)) {
654  return false;
655  }
656 
657  uint32_t substructure = getSubStructure(pattern);
658  return (substructure == (uint32_t) MuonSubdetId::RPC);
659 }
660 
661 inline bool HitPattern::muonGEMHitFilter(uint16_t pattern)
662 {
663  if UNLIKELY(!muonHitFilter(pattern)) {
664  return false;
665  }
666 
667  uint32_t substructure = getSubStructure(pattern);
668  return (substructure == (uint32_t) MuonSubdetId::GEM);
669 }
670 
671 inline bool HitPattern::muonME0HitFilter(uint16_t pattern) {
672  if UNLIKELY(!muonHitFilter(pattern)) return false;
673  uint16_t substructure = getSubStructure(pattern);
674  return (substructure == (uint16_t) MuonSubdetId::ME0);
675 }
676 
677 
678 inline bool HitPattern::trackerHitFilter(uint16_t pattern)
679 {
680  return pattern > minTrackerWord;
681 }
682 
683 inline bool HitPattern::muonHitFilter(uint16_t pattern)
684 {
685  if UNLIKELY(pattern == HitPattern::EMPTY_PATTERN) {
686  return false;
687  }
688 
689  return (((pattern >> SubDetectorOffset) & SubDetectorMask) == 0);
690 }
691 
692 inline uint32_t HitPattern::getSubStructure(uint16_t pattern)
693 {
694  if UNLIKELY(pattern == HitPattern::EMPTY_PATTERN) {
695  return NULL_RETURN;
696  }
697 
698  return ((pattern >> SubstrOffset) & SubstrMask);
699 }
700 
701 inline uint32_t HitPattern::getLayer(uint16_t pattern)
702 {
703  return HitPattern::getSubSubStructure(pattern);
704 }
705 
706 inline uint32_t HitPattern::getSubSubStructure(uint16_t pattern)
707 {
708  if UNLIKELY(pattern == HitPattern::EMPTY_PATTERN) {
709  return NULL_RETURN;
710  }
711 
712  return ((pattern >> LayerOffset) & LayerMask);
713 }
714 
715 inline uint32_t HitPattern::getSubDetector(uint16_t pattern)
716 {
717  if UNLIKELY(pattern == HitPattern::EMPTY_PATTERN) {
718  return NULL_RETURN;
719  }
720 
721  return ((pattern >> SubDetectorOffset) & SubDetectorMask);
722 }
723 
724 
725 inline uint32_t HitPattern::getSide(uint16_t pattern)
726 {
727  if UNLIKELY(pattern == HitPattern::EMPTY_PATTERN) {
728  return NULL_RETURN;
729  }
730 
731  return (pattern >> SideOffset) & SideMask;
732 }
733 
734 inline uint32_t HitPattern::getHitType(uint16_t pattern)
735 {
736  if UNLIKELY(pattern == HitPattern::EMPTY_PATTERN) {
737  return NULL_RETURN;
738  }
739 
740  return ((pattern >> HitTypeOffset) & HitTypeMask);
741 }
742 
743 inline uint16_t HitPattern::getMuonStation(uint16_t pattern)
744 {
745  return (getSubSubStructure(pattern) >> 2) + 1;
746 }
747 
748 inline uint16_t HitPattern::getDTSuperLayer(uint16_t pattern)
749 {
750  return (getSubSubStructure(pattern) & 3);
751 }
752 
753 inline uint16_t HitPattern::getCSCRing(uint16_t pattern)
754 {
755  return (getSubSubStructure(pattern) & 3) + 1;
756 }
757 
758 inline uint16_t HitPattern::getRPCLayer(uint16_t pattern)
759 {
760  uint16_t subSubStructure = getSubSubStructure(pattern);
761  uint16_t stat = subSubStructure >> 2;
762 
763  if LIKELY(stat <= 1) {
764  return ((subSubStructure >> 1) & 1) + 1;
765  }
766 
767  return 0;
768 }
769 
770 inline uint16_t HitPattern::getRPCregion(uint16_t pattern)
771 {
772  return getSubSubStructure(pattern) & 1;
773 }
774 
776 inline uint16_t HitPattern::getGEMStation(uint16_t pattern)
777 
778 {
779  uint16_t sss = getSubSubStructure(pattern), stat = sss >> 1;
780  return stat + 1;
781 }
782 
783 inline uint16_t HitPattern::getGEMLayer(uint16_t pattern)
784 {
785  return (getSubSubStructure(pattern) & 1) + 1;
786 }
787 
788 inline bool HitPattern::validHitFilter(uint16_t pattern)
789 {
790  return getHitType(pattern) == HitPattern::VALID;
791 }
792 
793 inline bool HitPattern::missingHitFilter(uint16_t pattern)
794 {
795  return getHitType(pattern) == HitPattern::MISSING;
796 }
797 
798 inline bool HitPattern::inactiveHitFilter(uint16_t pattern)
799 {
800  return getHitType(pattern) == HitPattern::INACTIVE;
801 }
802 
803 inline bool HitPattern::badHitFilter(uint16_t pattern)
804 {
805  return getHitType(pattern) == HitPattern::BAD;
806 }
807 
808 inline int HitPattern::numberOfAllHits(HitCategory category) const
809 {
810  std::pair<uint8_t, uint8_t> range = getCategoryIndexRange(category);
811  return range.second - range.first;
812 }
813 
814 inline int HitPattern::numberOfAllTrackerHits(HitCategory category) const
815 {
816  return countHits(category, trackerHitFilter);
817 }
818 
819 inline int HitPattern::numberOfMuonHits() const
820 {
821  return countHits(TRACK_HITS, muonHitFilter);
822 }
823 
824 inline int HitPattern::numberOfValidHits() const
825 {
826  return countHits(TRACK_HITS, validHitFilter);
827 }
828 
829 inline int HitPattern::numberOfValidTrackerHits() const
830 {
831  return countTypedHits(TRACK_HITS, validHitFilter, trackerHitFilter);
832 }
833 
834 inline int HitPattern::numberOfValidMuonHits() const
835 {
836  return countTypedHits(TRACK_HITS, validHitFilter, muonHitFilter);
837 }
838 
839 inline int HitPattern::numberOfValidPixelHits() const
840 {
841  return countTypedHits(TRACK_HITS, validHitFilter, pixelHitFilter);
842 }
843 
844 inline int HitPattern::numberOfValidPixelBarrelHits() const
845 {
846  return countTypedHits(TRACK_HITS, validHitFilter, pixelBarrelHitFilter);
847 }
848 
849 inline int HitPattern::numberOfValidPixelEndcapHits() const
850 {
851  return countTypedHits(TRACK_HITS, validHitFilter, pixelEndcapHitFilter);
852 }
853 
854 inline int HitPattern::numberOfValidStripHits() const
855 {
856  return countTypedHits(TRACK_HITS, validHitFilter, stripHitFilter);
857 }
858 
859 inline int HitPattern::numberOfValidStripTIBHits() const
860 {
861  return countTypedHits(TRACK_HITS, validHitFilter, stripTIBHitFilter);
862 }
863 
864 inline int HitPattern::numberOfValidStripTIDHits() const
865 {
866  return countTypedHits(TRACK_HITS, validHitFilter, stripTIDHitFilter);
867 }
868 
869 inline int HitPattern::numberOfValidStripTOBHits() const
870 {
871  return countTypedHits(TRACK_HITS, validHitFilter, stripTOBHitFilter);
872 }
873 
874 inline int HitPattern::numberOfValidStripTECHits() const
875 {
876  return countTypedHits(TRACK_HITS, validHitFilter, stripTECHitFilter);
877 }
878 
879 inline int HitPattern::numberOfValidMuonDTHits() const
880 {
881  return countTypedHits(TRACK_HITS, validHitFilter, muonDTHitFilter);
882 }
883 
884 inline int HitPattern::numberOfValidMuonCSCHits() const
885 {
886  return countTypedHits(TRACK_HITS, validHitFilter, muonCSCHitFilter);
887 }
888 
889 inline int HitPattern::numberOfValidMuonRPCHits() const
890 {
891  return countTypedHits(TRACK_HITS, validHitFilter, muonRPCHitFilter);
892 }
893 
894 inline int HitPattern::numberOfValidMuonGEMHits() const
895 {
896  return countTypedHits(TRACK_HITS, validHitFilter, muonGEMHitFilter);
897 }
898 
899 inline int HitPattern::numberOfValidMuonME0Hits() const {
900  return countTypedHits(TRACK_HITS, validHitFilter, muonME0HitFilter);
901 }
902 
903 inline int HitPattern::numberOfLostHits(HitCategory category) const
904 {
905  return countHits(category, missingHitFilter);
906 }
907 
908 inline int HitPattern::numberOfLostTrackerHits(HitCategory category) const
909 {
910  return countTypedHits(category, missingHitFilter, trackerHitFilter);
911 }
912 
913 inline int HitPattern::numberOfLostMuonHits() const
914 {
915  return countTypedHits(TRACK_HITS, missingHitFilter, muonHitFilter);
916 }
917 
918 inline int HitPattern::numberOfLostPixelHits(HitCategory category) const
919 {
920  return countTypedHits(category, missingHitFilter, pixelHitFilter);
921 }
922 
923 inline int HitPattern::numberOfLostPixelBarrelHits(HitCategory category) const
924 {
925  return countTypedHits(category, missingHitFilter, pixelBarrelHitFilter);
926 }
927 
928 inline int HitPattern::numberOfLostPixelEndcapHits(HitCategory category) const
929 {
930  return countTypedHits(category, missingHitFilter, pixelEndcapHitFilter);
931 }
932 
933 inline int HitPattern::numberOfLostStripHits(HitCategory category) const
934 {
935  return countTypedHits(category, missingHitFilter, stripHitFilter);
936 }
937 
938 inline int HitPattern::numberOfLostStripTIBHits(HitCategory category) const
939 {
940  return countTypedHits(category, missingHitFilter, stripTIBHitFilter);
941 }
942 
943 inline int HitPattern::numberOfLostStripTIDHits(HitCategory category) const
944 {
945  return countTypedHits(category, missingHitFilter, stripTIDHitFilter);
946 }
947 
948 inline int HitPattern::numberOfLostStripTOBHits(HitCategory category) const
949 {
950  return countTypedHits(category, missingHitFilter, stripTOBHitFilter);
951 }
952 
953 inline int HitPattern::numberOfLostStripTECHits(HitCategory category) const
954 {
955  return countTypedHits(category, missingHitFilter, stripTECHitFilter);
956 }
957 
958 inline int HitPattern::numberOfLostMuonDTHits() const
959 {
960  return countTypedHits(TRACK_HITS, missingHitFilter, muonDTHitFilter);
961 }
962 
963 inline int HitPattern::numberOfLostMuonCSCHits() const
964 {
965  return countTypedHits(TRACK_HITS, missingHitFilter, muonCSCHitFilter);
966 }
967 
968 inline int HitPattern::numberOfLostMuonRPCHits() const
969 {
970  return countTypedHits(TRACK_HITS, missingHitFilter, muonRPCHitFilter);
971 }
972 
973 inline int HitPattern::numberOfLostMuonGEMHits() const
974 {
975  return countTypedHits(TRACK_HITS, missingHitFilter, muonGEMHitFilter);
976 }
977 
978 inline int HitPattern::numberOfLostMuonME0Hits() const {
979  return countTypedHits(TRACK_HITS, missingHitFilter, muonME0HitFilter);
980 }
981 
982 inline int HitPattern::numberOfBadHits() const
983 {
984  return countHits(TRACK_HITS, badHitFilter);
985 }
986 
987 inline int HitPattern::numberOfBadMuonHits() const
988 {
989  return countTypedHits(TRACK_HITS, inactiveHitFilter, muonHitFilter);
990 }
991 
992 inline int HitPattern::numberOfBadMuonDTHits() const
993 {
994  return countTypedHits(TRACK_HITS, inactiveHitFilter, muonDTHitFilter);
995 }
996 
997 inline int HitPattern::numberOfBadMuonCSCHits() const
998 {
999  return countTypedHits(TRACK_HITS, inactiveHitFilter, muonCSCHitFilter);
1000 }
1001 
1002 inline int HitPattern::numberOfBadMuonRPCHits() const
1003 {
1004  return countTypedHits(TRACK_HITS, inactiveHitFilter, muonRPCHitFilter);
1005 }
1006 
1007 inline int HitPattern::numberOfBadMuonGEMHits() const
1008 {
1009  return countTypedHits(TRACK_HITS, inactiveHitFilter, muonGEMHitFilter);
1010 }
1011 
1012 inline int HitPattern::numberOfBadMuonME0Hits() const {
1013  return countTypedHits(TRACK_HITS, inactiveHitFilter, muonME0HitFilter);
1014 }
1015 
1016 inline int HitPattern::numberOfInactiveHits() const
1017 {
1018  return countHits(TRACK_HITS, inactiveHitFilter);
1019 }
1020 
1021 inline int HitPattern::numberOfInactiveTrackerHits() const
1022 {
1023  return countTypedHits(TRACK_HITS, inactiveHitFilter, trackerHitFilter);
1024 }
1025 
1026 inline int HitPattern::trackerLayersWithMeasurementOld() const
1027 {
1028  return pixelLayersWithMeasurement() + stripLayersWithMeasurement();
1029 }
1030 
1031 inline int HitPattern::pixelLayersWithMeasurementOld() const
1032 {
1033  return pixelBarrelLayersWithMeasurement() + pixelEndcapLayersWithMeasurement();
1034 }
1035 
1036 inline int HitPattern::stripLayersWithMeasurement() const
1037 {
1038  return stripTIBLayersWithMeasurement() + stripTIDLayersWithMeasurement() +
1039  stripTOBLayersWithMeasurement() + stripTECLayersWithMeasurement();
1040 }
1041 
1042 inline int HitPattern::trackerLayersWithoutMeasurementOld(HitCategory category) const
1043 {
1044  return pixelLayersWithoutMeasurement(category) +
1045  stripLayersWithoutMeasurement(category);
1046 }
1047 
1048 inline int HitPattern::pixelLayersWithoutMeasurement(HitCategory category) const
1049 {
1050  return pixelBarrelLayersWithoutMeasurement(category) +
1051  pixelEndcapLayersWithoutMeasurement(category);
1052 }
1053 
1054 inline int HitPattern::stripLayersWithoutMeasurement(HitCategory category) const
1055 {
1056  return stripTIBLayersWithoutMeasurement(category) +
1057  stripTIDLayersWithoutMeasurement(category) +
1058  stripTOBLayersWithoutMeasurement(category) +
1059  stripTECLayersWithoutMeasurement(category);
1060 }
1061 
1062 inline int HitPattern::trackerLayersTotallyOffOrBad(HitCategory category) const
1063 {
1064  return pixelLayersTotallyOffOrBad(category) +
1065  stripLayersTotallyOffOrBad(category);
1066 }
1067 
1068 inline int HitPattern::pixelLayersTotallyOffOrBad(HitCategory category) const
1069 {
1070  return pixelBarrelLayersTotallyOffOrBad(category) +
1071  pixelEndcapLayersTotallyOffOrBad(category);
1072 }
1073 
1074 inline int HitPattern::stripLayersTotallyOffOrBad(HitCategory category) const
1075 {
1076  return stripTIBLayersTotallyOffOrBad(category) +
1077  stripTIDLayersTotallyOffOrBad(category) +
1078  stripTOBLayersTotallyOffOrBad(category) +
1079  stripTECLayersTotallyOffOrBad(category);
1080 }
1081 
1082 inline int HitPattern::trackerLayersNull() const
1083 {
1084  return pixelLayersNull() +
1085  stripLayersNull();
1086 }
1087 
1088 inline int HitPattern::pixelLayersNull() const
1089 {
1090  return pixelBarrelLayersNull() +
1091  pixelEndcapLayersNull();
1092 }
1093 
1094 inline int HitPattern::stripLayersNull() const
1095 {
1096  return stripTIBLayersNull() +
1097  stripTIDLayersNull() +
1098  stripTOBLayersNull() +
1099  stripTECLayersNull();
1100 }
1101 
1102 inline int HitPattern::muonStationsWithValidHits() const
1103 {
1104  return muonStations(0, 0);
1105 }
1106 
1107 inline int HitPattern::muonStationsWithBadHits() const
1108 {
1109  return muonStations(0, 3);
1110 }
1111 
1112 inline int HitPattern::muonStationsWithAnyHits() const
1113 {
1114  return muonStations(0, -1);
1115 }
1116 
1117 inline int HitPattern::dtStationsWithValidHits() const
1118 {
1119  return muonStations(1, 0);
1120 }
1121 
1122 inline int HitPattern::dtStationsWithBadHits() const
1123 {
1124  return muonStations(1, 3);
1125 }
1126 
1127 inline int HitPattern::dtStationsWithAnyHits() const
1128 {
1129  return muonStations(1, -1);
1130 }
1131 
1132 inline int HitPattern::cscStationsWithValidHits() const
1133 {
1134  return muonStations(2, 0);
1135 }
1136 
1137 inline int HitPattern::cscStationsWithBadHits() const
1138 {
1139  return muonStations(2, 3);
1140 }
1141 
1142 inline int HitPattern::cscStationsWithAnyHits() const
1143 {
1144  return muonStations(2, -1);
1145 }
1146 
1147 inline int HitPattern::rpcStationsWithValidHits() const
1148 {
1149  return muonStations(3, 0);
1150 }
1151 
1152 inline int HitPattern::rpcStationsWithBadHits() const
1153 {
1154  return muonStations(3, 3);
1155 }
1156 
1157 inline int HitPattern::rpcStationsWithAnyHits() const
1158 {
1159  return muonStations(3, -1);
1160 }
1161 
1162 inline int HitPattern::gemStationsWithValidHits() const
1163 {
1164  return muonStations(4, 0);
1165 }
1166 
1167 inline int HitPattern::gemStationsWithBadHits() const
1168 {
1169  return muonStations(4, 3);
1170 }
1171 
1172 inline int HitPattern::gemStationsWithAnyHits() const
1173 {
1174  return muonStations(4,-1);
1175 }
1176 
1177 inline int HitPattern::me0StationsWithValidHits() const
1178 {
1179  return muonStations(5, 0);
1180 }
1181 
1182 inline int HitPattern::me0StationsWithBadHits() const
1183 {
1184  return muonStations(5, 3);
1185 }
1186 
1187 inline int HitPattern::me0StationsWithAnyHits() const
1188 {
1189  return muonStations(5,-1);
1190 }
1191 
1192 inline int HitPattern::innermostMuonStationWithValidHits() const
1193 {
1194  return innermostMuonStationWithHits(0);
1195 }
1196 
1197 inline int HitPattern::innermostMuonStationWithBadHits() const
1198 {
1199  return innermostMuonStationWithHits(3);
1200 }
1201 
1202 inline int HitPattern::innermostMuonStationWithAnyHits() const
1203 {
1204  return innermostMuonStationWithHits(-1);
1205 }
1206 
1207 inline int HitPattern::outermostMuonStationWithValidHits() const
1208 {
1209  return outermostMuonStationWithHits(0);
1210 }
1211 
1212 inline int HitPattern::outermostMuonStationWithBadHits() const
1213 {
1214  return outermostMuonStationWithHits(3);
1215 }
1216 
1217 inline int HitPattern::outermostMuonStationWithAnyHits() const
1218 {
1219  return outermostMuonStationWithHits(-1);
1220 }
1221 
1222 
1223 template<int N = HitPattern::MaxHits>
1224 struct PatternSet {
1225  static constexpr int MaxHits = N;
1226  unsigned char hit[N];
1227  unsigned char nhit;
1228 
1229  unsigned char const *begin() const
1230  {
1231  return hit;
1232  }
1233 
1234  unsigned char const *end() const
1235  {
1236  return hit + nhit;
1237  }
1238 
1239  unsigned char *begin()
1240  {
1241  return hit;
1242  }
1243 
1244  unsigned char *end()
1245  {
1246  return hit + nhit;
1247  }
1248 
1249  int size() const
1250  {
1251  return nhit;
1252  }
1253 
1254  unsigned char operator[](int i) const
1255  {
1256  return hit[i];
1257  }
1258 
1259  PatternSet() : nhit(0) {}
1260 
1262  {
1263  fill(category, hp);
1264  }
1265 
1267  {
1268  int lhit = 0;
1269  auto unpack = [&lhit, this](uint16_t pattern) -> bool {
1270  unsigned char p = 255 & (pattern >> 3);
1271  hit[lhit++] = p;
1272 
1273  // bouble sort
1274  if (lhit > 1) {
1275  for (auto h = hit + lhit - 1; h != hit; --h) {
1276  if ((*(h - 1)) <= p) {
1277  break;
1278  }
1279  (*h) = *(h - 1);
1280  *(h - 1) = p;
1281  }
1282  }
1283  return lhit < MaxHits;
1284  };
1285 
1286  hp.call(category, HitPattern::validHitFilter, unpack);
1287  nhit = lhit;
1288  }
1289 };
1290 
1291 template<int N>
1293 {
1294  PatternSet<N> comm;
1295  comm.nhit = std::set_intersection(p1.begin(), p1.end(), p2.begin(), p2.end(), comm.begin()) - comm.begin();
1296  return comm;
1297 }
1298 
1299 } // namespace reco
1300 
1301 #endif
1302 
unsigned char const * begin() const
Definition: HitPattern.h:1229
unsigned char const * end() const
Definition: HitPattern.h:1234
PatternSet< N > commonHits(PatternSet< N > const &p1, PatternSet< N > const &p2)
Definition: HitPattern.h:1292
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
static const int GEM
Definition: MuonSubdetId.h:15
void call(HitCategory category, filterType typeFilter, F f) const
Definition: HitPattern.h:540
unsigned char nhit
Definition: HitPattern.h:1227
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
bool filterType(uint16_t)
Definition: HitPattern.h:456
#define constexpr
uint8_t endInner
Definition: HitPattern.h:479
static const int ME0
Definition: MuonSubdetId.h:16
unsigned char * begin()
Definition: HitPattern.h:1239
static const int CSC
Definition: MuonSubdetId.h:13
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
int size() const
Definition: HitPattern.h:1249
const std::complex< double > I
Definition: I.h:8
double f[11][100]
uint8_t beginInner
Definition: HitPattern.h:478
#define end
Definition: vmac.h:39
double p2[4]
Definition: TauolaWrapper.h:90
uint8_t beginTrackHits
Definition: HitPattern.h:476
unsigned char * end()
Definition: HitPattern.h:1244
Definition: DetId.h:18
uint8_t endTrackHits
Definition: HitPattern.h:477
double const BAD
Definition: Constants.h:17
#define N
Definition: blowfish.cc:9
uint8_t hitCount
Definition: HitPattern.h:474
uint8_t beginOuter
Definition: HitPattern.h:480
def encode(args, files)
fixed size matrix
#define begin
Definition: vmac.h:32
double p1[4]
Definition: TauolaWrapper.h:89
static const int RPC
Definition: MuonSubdetId.h:14
void fill(HitPattern::HitCategory category, HitPattern const &hp)
Definition: HitPattern.h:1266
static int position[264][3]
Definition: ReadPGInfo.cc:509
#define LIKELY(x)
static const int DT
Definition: MuonSubdetId.h:12
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
PatternSet(HitPattern::HitCategory category, HitPattern const &hp)
Definition: HitPattern.h:1261
uint8_t endOuter
Definition: HitPattern.h:481
unsigned char operator[](int i) const
Definition: HitPattern.h:1254
#define UNLIKELY(x)