00001
00002 #ifndef TrackReco_HitPattern_h
00003 #define TrackReco_HitPattern_h
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 #include "DataFormats/DetId/interface/DetId.h"
00112 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00113 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00114 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
00115 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
00116 #include "FWCore/Utilities/interface/GCC11Compatibility.h"
00117 #include <algorithm>
00118 #include <ostream>
00119
00120
00121 namespace reco {
00122 class HitPattern {
00123 public:
00124 enum { MONO = 1, STEREO = 2 };
00125
00126
00127 const static unsigned short PatternSize = 25;
00128
00129
00130 const static unsigned short HitSize = 11;
00131
00132 static const int MaxHits = (PatternSize * 32) / HitSize;
00133
00134
00135
00136 HitPattern() { for (int i=0; i<PatternSize; i++) hitPattern_[i] = 0; }
00137
00138
00139 template<typename I>
00140 HitPattern(const I & begin, const I & end) { set(begin, end); }
00141
00142
00143 template<typename C>
00144 HitPattern(const C & c) { set(c); }
00145
00146
00147
00148
00149 template<typename I>
00150 void set(const I & begin, const I & end) {
00151 for (int i=0; i<PatternSize; i++) hitPattern_[i] = 0;
00152 unsigned int counter = 0;
00153 for (I hit=begin; hit!=end && counter<32*PatternSize/HitSize;
00154 hit++, counter++)
00155 set(*hit, counter);
00156 }
00157
00158
00159
00160 typedef bool filterType(unsigned int);
00161 int countHits(filterType filter) const {
00162 int count = 0;
00163 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00164 uint32_t pattern = getHitPattern(i);
00165 if (pattern == 0) break;
00166 if (filter(pattern)) ++count;
00167 }
00168 return count;
00169 }
00170
00171 int countTypedHits(filterType typeFilter, filterType filter) const {
00172 int count = 0;
00173 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00174 uint32_t pattern = getHitPattern(i);
00175 if (pattern == 0) break;
00176 if (typeFilter(pattern)&&filter(pattern)) ++count;
00177 }
00178 return count;
00179 }
00180
00181 template<typename F>
00182 void call(filterType typeFilter, F f) const {
00183 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00184 uint32_t pattern = getHitPattern(i);
00185 if (pattern == 0) break;
00186
00187 if (typeFilter(pattern) && !f(pattern) ) break;
00188 }
00189 }
00190
00191
00192 void printHitPattern (int position, std::ostream &stream) const;
00193 void print (std::ostream &stream = std::cout) const;
00194
00195
00196 void set(const TrackingRecHit &hit, unsigned int i){setHitPattern(i, encode(hit,i));}
00197
00198
00199 void appendHit(const TrackingRecHit & hit);
00200
00201
00202 uint32_t getHitPattern(int position) const;
00203
00204 static bool trackerHitFilter(uint32_t pattern);
00205 static bool muonHitFilter(uint32_t pattern);
00206
00207 static uint32_t getSubStructure(uint32_t pattern);
00208 static bool pixelHitFilter(uint32_t pattern);
00209 static bool pixelBarrelHitFilter(uint32_t pattern);
00210 static bool pixelEndcapHitFilter(uint32_t pattern);
00211 static bool stripHitFilter(uint32_t pattern);
00212 static bool stripTIBHitFilter(uint32_t pattern);
00213 static bool stripTIDHitFilter(uint32_t pattern);
00214 static bool stripTOBHitFilter(uint32_t pattern);
00215 static bool stripTECHitFilter(uint32_t pattern);
00216 static bool muonDTHitFilter(uint32_t pattern);
00217 static bool muonCSCHitFilter(uint32_t pattern);
00218 static bool muonRPCHitFilter(uint32_t pattern);
00219
00220 static uint32_t getLayer(uint32_t pattern);
00221 static uint32_t getSubSubStructure(uint32_t pattern);
00222
00224 static uint32_t getMuonStation(uint32_t pattern);
00226 static uint32_t getDTSuperLayer(uint32_t pattern);
00228 static uint32_t getCSCRing(uint32_t pattern) ;
00230 static uint32_t getRPCLayer(uint32_t pattern) ;
00232 static uint32_t getRPCregion(uint32_t pattern);
00233
00234 static uint32_t getHitType(uint32_t pattern);
00235 static bool validHitFilter(uint32_t pattern);
00236 static bool type_1_HitFilter(uint32_t pattern);
00237 static bool type_2_HitFilter(uint32_t pattern);
00238 static bool type_3_HitFilter(uint32_t pattern);
00239
00240 static uint32_t getSide (uint32_t pattern);
00241
00242 bool hasValidHitInFirstPixelBarrel() const;
00243 bool hasValidHitInFirstPixelEndcap() const;
00244
00245 int numberOfHits() const;
00246 int numberOfValidHits() const;
00247 int numberOfValidTrackerHits() const;
00248 int numberOfValidMuonHits() const;
00249 int numberOfValidPixelHits() const;
00250 int numberOfValidPixelBarrelHits() const;
00251 int numberOfValidPixelEndcapHits() const;
00252 int numberOfValidStripHits() const;
00253 int numberOfValidStripTIBHits() const;
00254 int numberOfValidStripTIDHits() const;
00255 int numberOfValidStripTOBHits() const;
00256 int numberOfValidStripTECHits() const;
00257 int numberOfValidMuonDTHits() const;
00258 int numberOfValidMuonCSCHits() const;
00259 int numberOfValidMuonRPCHits() const;
00260 int numberOfLostHits() const;
00261 int numberOfLostTrackerHits() const;
00262 int numberOfLostMuonHits() const;
00263 int numberOfLostPixelHits() const;
00264 int numberOfLostPixelBarrelHits() const;
00265 int numberOfLostPixelEndcapHits() const;
00266 int numberOfLostStripHits() const;
00267 int numberOfLostStripTIBHits() const;
00268 int numberOfLostStripTIDHits() const;
00269 int numberOfLostStripTOBHits() const;
00270 int numberOfLostStripTECHits() const;
00271 int numberOfLostMuonDTHits() const;
00272 int numberOfLostMuonCSCHits() const;
00273 int numberOfLostMuonRPCHits() const;
00274 int numberOfBadHits() const;
00275 int numberOfBadMuonHits() const;
00276 int numberOfBadMuonDTHits() const;
00277 int numberOfBadMuonCSCHits() const;
00278 int numberOfBadMuonRPCHits() const;
00279 int numberOfInactiveHits() const;
00280 int numberOfInactiveTrackerHits() const;
00281
00282
00283 int numberOfValidStripLayersWithMonoAndStereo ()
00284 const;
00285
00286 uint32_t getTrackerLayerCase(uint32_t substr, uint32_t layer) const;
00287 uint32_t getTrackerMonoStereo (uint32_t substr, uint32_t layer) const;
00288
00289 int trackerLayersWithMeasurement() const;
00290 int pixelLayersWithMeasurement() const;
00291 int stripLayersWithMeasurement() const;
00292 int pixelBarrelLayersWithMeasurement() const;
00293 int pixelEndcapLayersWithMeasurement() const;
00294 int stripTIBLayersWithMeasurement() const;
00295 int stripTIDLayersWithMeasurement() const;
00296 int stripTOBLayersWithMeasurement() const;
00297 int stripTECLayersWithMeasurement() const;
00298 int trackerLayersWithoutMeasurement() const;
00299 int pixelLayersWithoutMeasurement() const;
00300 int stripLayersWithoutMeasurement() const;
00301 int pixelBarrelLayersWithoutMeasurement() const;
00302 int pixelEndcapLayersWithoutMeasurement() const;
00303 int stripTIBLayersWithoutMeasurement() const;
00304 int stripTIDLayersWithoutMeasurement() const;
00305 int stripTOBLayersWithoutMeasurement() const;
00306 int stripTECLayersWithoutMeasurement() const;
00307 int trackerLayersTotallyOffOrBad() const;
00308 int pixelLayersTotallyOffOrBad() const;
00309 int stripLayersTotallyOffOrBad() const;
00310 int pixelBarrelLayersTotallyOffOrBad() const;
00311 int pixelEndcapLayersTotallyOffOrBad() const;
00312 int stripTIBLayersTotallyOffOrBad() const;
00313 int stripTIDLayersTotallyOffOrBad() const;
00314 int stripTOBLayersTotallyOffOrBad() const;
00315 int stripTECLayersTotallyOffOrBad() const;
00316 int trackerLayersNull() const;
00317 int pixelLayersNull() const;
00318 int stripLayersNull() const;
00319 int pixelBarrelLayersNull() const;
00320 int pixelEndcapLayersNull() const;
00321 int stripTIBLayersNull() const;
00322 int stripTIDLayersNull() const;
00323 int stripTOBLayersNull() const;
00324 int stripTECLayersNull() const;
00325
00326
00327
00329 int muonStations(int subdet, int hitType) const ;
00330
00331 int muonStationsWithValidHits() const ;
00332 int muonStationsWithBadHits() const ;
00333 int muonStationsWithAnyHits() const ;
00334 int dtStationsWithValidHits() const ;
00335 int dtStationsWithBadHits() const ;
00336 int dtStationsWithAnyHits() const ;
00337 int cscStationsWithValidHits() const ;
00338 int cscStationsWithBadHits() const ;
00339 int cscStationsWithAnyHits() const ;
00340 int rpcStationsWithValidHits() const ;
00341 int rpcStationsWithBadHits() const ;
00342 int rpcStationsWithAnyHits() const ;
00343
00345 int innermostMuonStationWithHits(int hitType) const ;
00346 int innermostMuonStationWithValidHits() const ;
00347 int innermostMuonStationWithBadHits() const ;
00348 int innermostMuonStationWithAnyHits() const ;
00349
00351 int outermostMuonStationWithHits(int hitType) const ;
00352 int outermostMuonStationWithValidHits() const ;
00353 int outermostMuonStationWithBadHits() const ;
00354 int outermostMuonStationWithAnyHits() const ;
00355
00356 int numberOfDTStationsWithRPhiView() const ;
00357 int numberOfDTStationsWithRZView() const ;
00358 int numberOfDTStationsWithBothViews() const ;
00359 private:
00360
00361
00362
00363 const static unsigned short SubDetectorOffset = 10;
00364 const static unsigned short SubDetectorMask = 0x1;
00365
00366
00367 const static unsigned short SubstrOffset = 7;
00368 const static unsigned short SubstrMask = 0x7;
00369
00370
00371 const static unsigned short LayerOffset = 3;
00372 const static unsigned short LayerMask = 0xF;
00373
00374
00375 const static unsigned short SideOffset = 2;
00376 const static unsigned short SideMask = 0x1;
00377
00378
00379 const static unsigned short HitTypeOffset = 0;
00380 const static unsigned short HitTypeMask = 0x3;
00381
00382
00383 uint32_t hitPattern_[ PatternSize ];
00384
00385
00386 void setHitPattern(int position, uint32_t pattern);
00387
00388
00389 void set(const TrackingRecHitRef & ref, unsigned int i) { set(* ref, i); }
00390
00391
00392 static uint32_t isStereo (DetId);
00393
00394
00395 uint32_t encode(const TrackingRecHit &,unsigned int);
00396 };
00397
00398
00399
00400 inline bool HitPattern::pixelHitFilter(uint32_t pattern) {
00401 if unlikely(!trackerHitFilter(pattern)) return false;
00402 uint32_t substructure = getSubStructure(pattern);
00403 if (substructure == PixelSubdetector::PixelBarrel ||
00404 substructure == PixelSubdetector::PixelEndcap) return true;
00405 return false;
00406 }
00407
00408 inline bool HitPattern::pixelBarrelHitFilter(uint32_t pattern) {
00409 if unlikely(!trackerHitFilter(pattern)) return false;
00410 uint32_t substructure = getSubStructure(pattern);
00411 if (substructure == PixelSubdetector::PixelBarrel) return true;
00412 return false;
00413 }
00414
00415 inline bool HitPattern::pixelEndcapHitFilter(uint32_t pattern) {
00416 if unlikely(!trackerHitFilter(pattern)) return false;
00417 uint32_t substructure = getSubStructure(pattern);
00418 if (substructure == PixelSubdetector::PixelEndcap) return true;
00419 return false;
00420 }
00421
00422 inline bool HitPattern::stripHitFilter(uint32_t pattern) {
00423 if unlikely(!trackerHitFilter(pattern)) return false;
00424 uint32_t substructure = getSubStructure(pattern);
00425 if (substructure == StripSubdetector::TIB ||
00426 substructure == StripSubdetector::TID ||
00427 substructure == StripSubdetector::TOB ||
00428 substructure == StripSubdetector::TEC) return true;
00429 return false;
00430 }
00431
00432 inline bool HitPattern::stripTIBHitFilter(uint32_t pattern) {
00433 if unlikely(!trackerHitFilter(pattern)) return false;
00434 uint32_t substructure = getSubStructure(pattern);
00435 if (substructure == StripSubdetector::TIB) return true;
00436 return false;
00437 }
00438
00439 inline bool HitPattern::stripTIDHitFilter(uint32_t pattern) {
00440 if unlikely(!trackerHitFilter(pattern)) return false;
00441 uint32_t substructure = getSubStructure(pattern);
00442 if (substructure == StripSubdetector::TID) return true;
00443 return false;
00444 }
00445
00446 inline bool HitPattern::stripTOBHitFilter(uint32_t pattern) {
00447 if unlikely(!trackerHitFilter(pattern)) return false;
00448 uint32_t substructure = getSubStructure(pattern);
00449 if (substructure == StripSubdetector::TOB) return true;
00450 return false;
00451 }
00452
00453 inline bool HitPattern::stripTECHitFilter(uint32_t pattern) {
00454 if unlikely(!trackerHitFilter(pattern)) return false;
00455 uint32_t substructure = getSubStructure(pattern);
00456 if (substructure == StripSubdetector::TEC) return true;
00457 return false;
00458 }
00459
00460 inline bool HitPattern::muonDTHitFilter(uint32_t pattern) {
00461 if unlikely(!muonHitFilter(pattern)) return false;
00462 uint32_t substructure = getSubStructure(pattern);
00463 if (substructure == (uint32_t) MuonSubdetId::DT) return true;
00464 return false;
00465 }
00466
00467 inline bool HitPattern::muonCSCHitFilter(uint32_t pattern) {
00468 if unlikely(!muonHitFilter(pattern)) return false;
00469 uint32_t substructure = getSubStructure(pattern);
00470 if (substructure == (uint32_t) MuonSubdetId::CSC) return true;
00471 return false;
00472 }
00473
00474 inline bool HitPattern::muonRPCHitFilter(uint32_t pattern) {
00475 if unlikely(!muonHitFilter(pattern)) return false;
00476 uint32_t substructure = getSubStructure(pattern);
00477 if (substructure == (uint32_t) MuonSubdetId::RPC) return true;
00478 return false;
00479 }
00480
00481
00482 inline bool HitPattern::trackerHitFilter(uint32_t pattern) {
00483 if unlikely(pattern == 0) return false;
00484 if (((pattern>>SubDetectorOffset) & SubDetectorMask) == 1) return true;
00485 return false;
00486 }
00487
00488 inline bool HitPattern::muonHitFilter(uint32_t pattern) {
00489 if unlikely(pattern == 0) return false;
00490 if (((pattern>>SubDetectorOffset) & SubDetectorMask) == 0) return true;
00491 return false;
00492 }
00493
00494
00495 inline uint32_t HitPattern::getSubStructure(uint32_t pattern) {
00496 if unlikely(pattern == 0) return 999999;
00497 return ((pattern >> SubstrOffset) & SubstrMask);
00498 }
00499
00500
00501 inline uint32_t HitPattern::getLayer(uint32_t pattern) {
00502 if unlikely(pattern == 0) return 999999;
00503 return ((pattern>>LayerOffset) & LayerMask);
00504 }
00505
00506 inline uint32_t HitPattern::getSubSubStructure(uint32_t pattern) {
00507 if unlikely(pattern == 0) return 999999;
00508 return ((pattern>>LayerOffset) & LayerMask);
00509 }
00510
00511
00512 inline uint32_t HitPattern::getSide (uint32_t pattern) {
00513 if unlikely(pattern == 0) return 999999;
00514 return (pattern >> SideOffset) & SideMask;
00515 }
00516
00517 inline uint32_t HitPattern::getHitType( uint32_t pattern ) {
00518 if unlikely(pattern == 0) return 999999;
00519 return ((pattern>>HitTypeOffset) & HitTypeMask);
00520 }
00521
00522 inline uint32_t HitPattern::getMuonStation(uint32_t pattern) {
00523 return (getSubSubStructure(pattern)>>2) + 1;
00524 }
00525
00526 inline uint32_t HitPattern::getDTSuperLayer(uint32_t pattern) {
00527 return (getSubSubStructure(pattern) & 3);
00528 }
00529
00530 inline uint32_t HitPattern::getCSCRing(uint32_t pattern) {
00531 return (getSubSubStructure(pattern) & 3) + 1;
00532 }
00533
00534 inline uint32_t HitPattern::getRPCLayer(uint32_t pattern) {
00535 uint32_t sss = getSubSubStructure(pattern), stat = sss >> 2;
00536 if likely(stat <= 1) return ((sss >> 1) & 1) + 1;
00537 return 0;
00538 }
00539
00540 inline uint32_t HitPattern::getRPCregion(uint32_t pattern) {
00541 return getSubSubStructure(pattern) & 1;
00542 }
00543
00544
00545 inline bool HitPattern::validHitFilter(uint32_t pattern) {
00546 if (getHitType(pattern) == 0) return true;
00547 return false;
00548 }
00549
00550 inline bool HitPattern::type_1_HitFilter(uint32_t pattern) {
00551 if (getHitType(pattern) == 1) return true;
00552 return false;
00553 }
00554
00555 inline bool HitPattern::type_2_HitFilter(uint32_t pattern) {
00556 if (getHitType(pattern) == 2) return true;
00557 return false;
00558 }
00559
00560 inline bool HitPattern::type_3_HitFilter(uint32_t pattern) {
00561 if (getHitType(pattern) == 3) return true;
00562 return false;
00563 }
00564
00565
00566
00567
00568
00569
00570 inline int HitPattern::numberOfValidHits() const {
00571 return countHits(validHitFilter);
00572 }
00573
00574 inline int HitPattern::numberOfValidTrackerHits() const {
00575 return countTypedHits(validHitFilter, trackerHitFilter);
00576 }
00577
00578 inline int HitPattern::numberOfValidMuonHits() const {
00579 return countTypedHits(validHitFilter, muonHitFilter);
00580 }
00581
00582 inline int HitPattern::numberOfValidPixelHits() const {
00583 return countTypedHits(validHitFilter, pixelHitFilter);
00584 }
00585
00586 inline int HitPattern::numberOfValidPixelBarrelHits() const {
00587 return countTypedHits(validHitFilter, pixelBarrelHitFilter);
00588 }
00589
00590 inline int HitPattern::numberOfValidPixelEndcapHits() const {
00591 return countTypedHits(validHitFilter, pixelEndcapHitFilter);
00592 }
00593
00594 inline int HitPattern::numberOfValidStripHits() const {
00595 return countTypedHits(validHitFilter, stripHitFilter);
00596 }
00597
00598 inline int HitPattern::numberOfValidStripTIBHits() const {
00599 return countTypedHits(validHitFilter, stripTIBHitFilter);
00600 }
00601
00602 inline int HitPattern::numberOfValidStripTIDHits() const {
00603 return countTypedHits(validHitFilter, stripTIDHitFilter);
00604 }
00605
00606 inline int HitPattern::numberOfValidStripTOBHits() const {
00607 return countTypedHits(validHitFilter, stripTOBHitFilter);
00608 }
00609
00610 inline int HitPattern::numberOfValidStripTECHits() const {
00611 return countTypedHits(validHitFilter, stripTECHitFilter);
00612 }
00613
00614 inline int HitPattern::numberOfValidMuonDTHits() const {
00615 return countTypedHits(validHitFilter, muonDTHitFilter);
00616 }
00617
00618 inline int HitPattern::numberOfValidMuonCSCHits() const {
00619 return countTypedHits(validHitFilter, muonCSCHitFilter);
00620 }
00621
00622 inline int HitPattern::numberOfValidMuonRPCHits() const {
00623 return countTypedHits(validHitFilter, muonRPCHitFilter);
00624 }
00625
00626
00627 inline int HitPattern::numberOfLostHits() const {
00628 return countHits(type_1_HitFilter);
00629 }
00630
00631 inline int HitPattern::numberOfLostTrackerHits() const {
00632 return countTypedHits(type_1_HitFilter, trackerHitFilter);
00633 }
00634
00635 inline int HitPattern::numberOfLostMuonHits() const {
00636 return countTypedHits(type_1_HitFilter, muonHitFilter);
00637 }
00638
00639 inline int HitPattern::numberOfLostPixelHits() const {
00640 return countTypedHits(type_1_HitFilter, pixelHitFilter);
00641 }
00642
00643 inline int HitPattern::numberOfLostPixelBarrelHits() const {
00644 return countTypedHits(type_1_HitFilter, pixelBarrelHitFilter);
00645 }
00646
00647 inline int HitPattern::numberOfLostPixelEndcapHits() const {
00648 return countTypedHits(type_1_HitFilter, pixelEndcapHitFilter);
00649 }
00650
00651 inline int HitPattern::numberOfLostStripHits() const {
00652 return countTypedHits(type_1_HitFilter, stripHitFilter);
00653 }
00654
00655 inline int HitPattern::numberOfLostStripTIBHits() const {
00656 return countTypedHits(type_1_HitFilter, stripTIBHitFilter);
00657 }
00658
00659 inline int HitPattern::numberOfLostStripTIDHits() const {
00660 return countTypedHits(type_1_HitFilter, stripTIDHitFilter);
00661 }
00662
00663 inline int HitPattern::numberOfLostStripTOBHits() const {
00664 return countTypedHits(type_1_HitFilter, stripTOBHitFilter);
00665 }
00666
00667 inline int HitPattern::numberOfLostStripTECHits() const {
00668 return countTypedHits(type_1_HitFilter, stripTECHitFilter);
00669 }
00670
00671 inline int HitPattern::numberOfLostMuonDTHits() const {
00672 return countTypedHits(type_1_HitFilter, muonDTHitFilter);
00673 }
00674
00675 inline int HitPattern::numberOfLostMuonCSCHits() const {
00676 return countTypedHits(type_1_HitFilter, muonCSCHitFilter);
00677 }
00678
00679 inline int HitPattern::numberOfLostMuonRPCHits() const {
00680 return countTypedHits(type_1_HitFilter, muonRPCHitFilter);
00681 }
00682
00683
00684
00685 inline int HitPattern::numberOfBadHits() const {
00686 return countHits(type_3_HitFilter);
00687 }
00688
00689 inline int HitPattern::numberOfBadMuonHits() const {
00690 return countTypedHits(type_2_HitFilter, muonHitFilter);
00691 }
00692
00693 inline int HitPattern::numberOfBadMuonDTHits() const {
00694 return countTypedHits(type_2_HitFilter, muonDTHitFilter);
00695 }
00696
00697 inline int HitPattern::numberOfBadMuonCSCHits() const {
00698 return countTypedHits(type_2_HitFilter, muonCSCHitFilter);
00699 }
00700
00701 inline int HitPattern::numberOfBadMuonRPCHits() const {
00702 return countTypedHits(type_2_HitFilter, muonRPCHitFilter);
00703 }
00704
00705
00706
00707 inline int HitPattern::numberOfInactiveHits() const {
00708 return countHits(type_2_HitFilter);
00709 }
00710
00711 inline int HitPattern::numberOfInactiveTrackerHits() const {
00712 return countTypedHits(type_2_HitFilter, trackerHitFilter);
00713 }
00714
00715
00716
00717
00718
00719
00720
00721 inline int HitPattern::trackerLayersWithMeasurement() const {
00722 return pixelLayersWithMeasurement() +
00723 stripLayersWithMeasurement();
00724 }
00725
00726 inline int HitPattern::pixelLayersWithMeasurement() const {
00727 return pixelBarrelLayersWithMeasurement() +
00728 pixelEndcapLayersWithMeasurement();
00729 }
00730
00731 inline int HitPattern::stripLayersWithMeasurement() const {
00732 return stripTIBLayersWithMeasurement() +
00733 stripTIDLayersWithMeasurement() +
00734 stripTOBLayersWithMeasurement() +
00735 stripTECLayersWithMeasurement();
00736 }
00737
00738
00739 inline int HitPattern::trackerLayersWithoutMeasurement() const {
00740 return pixelLayersWithoutMeasurement() +
00741 stripLayersWithoutMeasurement();
00742 }
00743
00744 inline int HitPattern::pixelLayersWithoutMeasurement() const {
00745 return pixelBarrelLayersWithoutMeasurement() +
00746 pixelEndcapLayersWithoutMeasurement();
00747 }
00748
00749 inline int HitPattern::stripLayersWithoutMeasurement() const {
00750 return stripTIBLayersWithoutMeasurement() +
00751 stripTIDLayersWithoutMeasurement() +
00752 stripTOBLayersWithoutMeasurement() +
00753 stripTECLayersWithoutMeasurement();
00754 }
00755
00756
00757 inline int HitPattern::trackerLayersTotallyOffOrBad() const {
00758 return pixelLayersTotallyOffOrBad() +
00759 stripLayersTotallyOffOrBad();
00760 }
00761
00762 inline int HitPattern::pixelLayersTotallyOffOrBad() const {
00763 return pixelBarrelLayersTotallyOffOrBad() +
00764 pixelEndcapLayersTotallyOffOrBad();
00765 }
00766
00767 inline int HitPattern::stripLayersTotallyOffOrBad() const {
00768 return stripTIBLayersTotallyOffOrBad() +
00769 stripTIDLayersTotallyOffOrBad() +
00770 stripTOBLayersTotallyOffOrBad() +
00771 stripTECLayersTotallyOffOrBad();
00772 }
00773
00774 inline int HitPattern::trackerLayersNull() const {
00775 return pixelLayersNull() +
00776 stripLayersNull();
00777 }
00778
00779 inline int HitPattern::pixelLayersNull() const {
00780 return pixelBarrelLayersNull() +
00781 pixelEndcapLayersNull();
00782 }
00783
00784 inline int HitPattern::stripLayersNull() const {
00785 return stripTIBLayersNull() +
00786 stripTIDLayersNull() +
00787 stripTOBLayersNull() +
00788 stripTECLayersNull();
00789 }
00790
00791
00792 inline int HitPattern::muonStationsWithValidHits() const { return muonStations(0, 0); }
00793 inline int HitPattern::muonStationsWithBadHits() const { return muonStations(0, 3); }
00794 inline int HitPattern::muonStationsWithAnyHits() const { return muonStations(0,-1); }
00795 inline int HitPattern::dtStationsWithValidHits() const { return muonStations(1, 0); }
00796 inline int HitPattern::dtStationsWithBadHits() const { return muonStations(1, 3); }
00797 inline int HitPattern::dtStationsWithAnyHits() const { return muonStations(1,-1); }
00798 inline int HitPattern::cscStationsWithValidHits() const { return muonStations(2, 0); }
00799 inline int HitPattern::cscStationsWithBadHits() const { return muonStations(2, 3); }
00800 inline int HitPattern::cscStationsWithAnyHits() const { return muonStations(2,-1); }
00801 inline int HitPattern::rpcStationsWithValidHits() const { return muonStations(3, 0); }
00802 inline int HitPattern::rpcStationsWithBadHits() const { return muonStations(3, 3); }
00803 inline int HitPattern::rpcStationsWithAnyHits() const { return muonStations(3,-1); }
00804
00805 inline int HitPattern::innermostMuonStationWithValidHits() const { return innermostMuonStationWithHits(0); }
00806 inline int HitPattern::innermostMuonStationWithBadHits() const { return innermostMuonStationWithHits(3); }
00807 inline int HitPattern::innermostMuonStationWithAnyHits() const { return innermostMuonStationWithHits(-1); }
00808 inline int HitPattern::outermostMuonStationWithValidHits() const { return outermostMuonStationWithHits(0); }
00809 inline int HitPattern::outermostMuonStationWithBadHits() const { return outermostMuonStationWithHits(3); }
00810 inline int HitPattern::outermostMuonStationWithAnyHits() const { return outermostMuonStationWithHits(-1); }
00811
00812 #ifndef CMS_NOCXX11 // cint....
00813
00814 template<int N=reco::HitPattern::MaxHits>
00815 struct PatternSet {
00816 static constexpr int MaxHits=N;
00817 unsigned char hit[N];
00818 unsigned char nhit;
00819
00820 unsigned char const * begin() const { return hit;}
00821 unsigned char const * end() const { return hit+nhit;}
00822 unsigned char * begin() { return hit;}
00823 unsigned char * end() { return hit+nhit;}
00824 int size() const { return nhit;}
00825 unsigned char operator[](int i) const{ return hit[i];}
00826
00827 PatternSet(): nhit(0){}
00828 PatternSet(reco::HitPattern const & hp) {
00829 fill(hp);
00830 }
00831
00832 void fill(reco::HitPattern const & hp) {
00833 int lhit=0;
00834 auto unpack =[&lhit,this](uint32_t pattern) -> bool {
00835 unsigned char p = 255&(pattern>>3);
00836 hit[lhit++]= p;
00837
00838
00839 if (lhit>1)
00840 for (auto h=hit+lhit-1; h!=hit; --h) {
00841 if ( (*(h-1)) <= p) break;
00842 (*h)=*(h-1); *(h-1)=p;
00843 }
00844 return lhit<MaxHits;
00845 };
00846 hp.call(reco::HitPattern::validHitFilter,unpack);
00847 nhit=lhit;
00848 }
00849 };
00850
00851 template<int N>
00852 inline PatternSet<N> commonHits(PatternSet<N> const & p1, PatternSet<N> const & p2) {
00853 PatternSet<N> comm;
00854 comm.nhit = std::set_intersection(p1.begin(),p1.end(),p2.begin(),p2.end(),comm.begin())-comm.begin();
00855 return comm;
00856 }
00857 #endif // gcc11
00858
00859 }
00860
00861 #endif