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