20 : hitCount(0), beginTrackHits(0), endTrackHits(0), beginInner(0), endInner(0), beginOuter(0), endOuter(0) {
79 uint16_t encodeMuonLayer(
const DetId&
id) {
80 uint16_t detid =
id.det();
81 uint16_t subdet =
id.subdetId();
96 layer = ((rpcid.
station() - 1) << 2);
97 layer |= (rpcid.
station() <= 2) ? ((rpcid.
layer() - 1) << 1) : 0x0;
102 layer = ((gemid.
station() - 1) << 2);
110 layer = (me0id.
roll());
116 uint16_t encodeTimingLayer(
const DetId&
id) {
117 uint16_t detid =
id.det();
118 uint16_t subdet =
id.subdetId();
119 uint16_t layer = 0x0;
133 throw cms::Exception(
"HitPattern") <<
"Invalid DetId for FastTime det= " << detid <<
" subdet= " << subdet <<
"!";
140 uint16_t detid =
id.det();
141 uint16_t subdet =
id.subdetId();
144 uint16_t layer = 0x0;
146 layer = ttopo.
layer(
id);
148 layer = encodeMuonLayer(
id);
150 layer = encodeTimingLayer(
id);
171 return encode(detid, subdet, layer, side, hitType);
233 <<
" were stored on this object before hits of some other category were inserted " 234 <<
"but hits of the same category should be inserted in a row. " 235 <<
"Please rework the code so it inserts all " 247 <<
"MISSING_INNER_HITS" 248 <<
" were stored on this object before hits of some other category were inserted " 249 <<
"but hits of the same category should be inserted in a row. " 250 <<
"Please rework the code so it inserts all " 251 <<
"MISSING_INNER_HITS" 262 <<
"MISSING_OUTER_HITS" 263 <<
" were stored on this object before hits of some other category were inserted " 264 <<
"but hits of the same category should be inserted in a row. " 265 <<
"Please rework the code so it inserts all " 266 <<
"MISSING_OUTER_HITS" 289 <<
"Got DetId from det " <<
id.det()
290 <<
" that is not Muon in appendMuonHit(), which should only be used for muon hits in the HitPattern IO rule";
293 uint16_t subdet =
id.subdetId();
321 uint16_t bitEndOffset = (position + 1) *
HIT_LENGTH;
322 uint8_t secondWord = (bitEndOffset >> 4);
323 uint8_t secondWordBits = bitEndOffset & (16 - 1);
325 uint8_t lowBitsToTrash = secondWordBits -
HIT_LENGTH;
326 uint16_t myResult = (
hitPattern[secondWord] >> lowBitsToTrash) & ((1 << HIT_LENGTH) - 1);
329 uint8_t firstWordBits =
HIT_LENGTH - secondWordBits;
330 uint16_t firstWordBlock =
hitPattern[secondWord - 1] >> (16 - firstWordBits);
331 uint16_t secondWordBlock =
hitPattern[secondWord] & ((1 << secondWordBits) - 1);
332 uint16_t myResult = firstWordBlock + (secondWordBlock << firstWordBits);
351 memset(hasMono, 0,
sizeof(hasMono));
352 memset(hasStereo, 0,
sizeof(hasStereo));
360 if (stripdet != 0 && subStructure != stripdet) {
370 hasMono[subStructure][
getLayer(pattern)] =
true;
373 hasStereo[subStructure][
getLayer(pattern)] =
true;
385 if (hasMono[
i][
j] && hasStereo[
i][
j]) {
395 std::bitset<128> side[2];
397 for (
int i = range.first;
i < range.second; ++
i) {
404 if (hitType != HIT_TYPE::VALID)
411 return (side[0] & side[1]).count();
431 uint16_t tk_substr_layer =
442 for (
int i = range.first;
i < range.second; ++
i) {
444 if ((pattern & mask) == tk_substr_layer) {
446 if (hitType < layerCase) {
448 layerCase = (hitType ==
HIT_TYPE::BAD ? (uint32_t)HIT_TYPE::INACTIVE : hitType);
449 if (layerCase == HIT_TYPE::VALID) {
459 uint16_t tk_substr_layer =
467 uint16_t monoStereo = 0x0;
469 for (
int i = range.first;
i < range.second; ++
i) {
471 if ((pattern & mask) == tk_substr_layer) {
473 if (hitType == HIT_TYPE::VALID) {
494 std::bitset<128> layerOk;
496 for (
int i = range.first;
i < range.second; ++
i) {
503 if (hitType != HIT_TYPE::VALID)
510 return layerOk.count();
515 std::bitset<128> layerOk;
517 for (
int i = range.first;
i < range.second; ++
i) {
522 if (hitType != HIT_TYPE::VALID)
529 return layerOk.count();
533 std::bitset<128> layerOk;
534 std::bitset<128> layerMissed;
536 for (
int i = range.first;
i < range.second; ++
i) {
543 if (hitType == HIT_TYPE::VALID)
545 if (hitType == HIT_TYPE::MISSING)
548 layerMissed &= ~layerOk;
552 return layerMissed.count();
557 uint16_t NPixBarrel = 4;
558 for (uint16_t layer = 1; layer <= NPixBarrel; layer++) {
568 uint16_t NPixForward = 3;
569 for (uint16_t layer = 1; layer <= NPixForward; layer++) {
579 for (uint16_t layer = 1; layer <= 4; layer++) {
589 for (uint16_t layer = 1; layer <= 3; layer++) {
599 for (uint16_t layer = 1; layer <= 6; layer++) {
609 for (uint16_t layer = 1; layer <= 9; layer++) {
619 uint16_t NPixBarrel = 4;
620 for (uint16_t layer = 1; layer <= NPixBarrel; layer++) {
630 uint16_t NPixForward = 3;
631 for (uint16_t layer = 1; layer <= NPixForward; layer++) {
641 for (uint16_t layer = 1; layer <= 4; layer++) {
651 for (uint16_t layer = 1; layer <= 3; layer++) {
661 for (uint16_t layer = 1; layer <= 6; layer++) {
671 for (uint16_t layer = 1; layer <= 9; layer++) {
681 uint16_t NPixBarrel = 4;
682 for (uint16_t layer = 1; layer <= NPixBarrel; layer++) {
692 uint16_t NPixForward = 3;
693 for (uint16_t layer = 1; layer <= NPixForward; layer++) {
703 for (uint16_t layer = 1; layer <= 4; layer++) {
713 for (uint16_t layer = 1; layer <= 3; layer++) {
723 for (uint16_t layer = 1; layer <= 6; layer++) {
733 for (uint16_t layer = 1; layer <= 9; layer++) {
743 uint16_t NPixBarrel = 4;
744 for (uint16_t layer = 1; layer <= NPixBarrel; layer++) {
754 uint16_t NPixForward = 3;
755 for (uint16_t layer = 1; layer <= NPixForward; layer++) {
765 for (uint16_t layer = 1; layer <= 4; layer++) {
775 for (uint16_t layer = 1; layer <= 3; layer++) {
785 for (uint16_t layer = 1; layer <= 6; layer++) {
795 for (uint16_t layer = 1; layer <= 9; layer++) {
820 stream <<
"\tcsc ring " <<
getCSCRing(pattern);
828 stream <<
"(UNKNOWN Muon SubStructure!) \tsubsubstructure " <<
getSubStructure(pattern);
833 stream <<
"\tlayer " <<
getLayer(pattern);
835 stream <<
"\thit type " <<
getHitType(pattern);
840 stream <<
"HitPattern" << std::endl;
844 std::ios_base::fmtflags
flags = stream.flags();
845 stream.setf(std::ios_base::hex, std::ios_base::basefield);
846 stream.setf(std::ios_base::showbase);
878 int stations[4] = {0, 0, 0, 0};
882 (hitType == -1 ||
int(
getHitType(pattern)) == hitType)) {
887 return stations[0] + stations[1] + stations[2] + stations[3];
896 if (ret == 0 || stat < ret) {
911 if (ret == 0 || stat > ret) {
920 int stations[4] = {0, 0, 0, 0};
928 return stations[0] + stations[1] + stations[2] + stations[3];
932 int stations[4] = {0, 0, 0, 0};
939 return stations[0] + stations[1] + stations[2] + stations[3];
943 int stations[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
951 return stations[0][0] * stations[0][1] + stations[1][0] * stations[1][1] + stations[2][0] * stations[2][1] +
952 stations[3][0] * stations[3][1];
958 int pos = offset +
i;
959 uint16_t bit = (pattern >>
i) & 0
x1;
961 hitPattern[pos >> 4] += bit << ((offset +
i) & (16 - 1));
int stripTOBLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const
int stripTOBLayersWithMeasurement() const
static uint16_t getCSCRing(uint16_t pattern)
CSC ring (1-4). Only valid for muon CSC patterns, of course.
static constexpr auto TEC
int pixelBarrelLayersWithoutMeasurement(HitCategory category) const
static uint32_t getLayer(uint16_t pattern)
void insertHit(const uint16_t pattern)
int outermostMuonStationWithHits(int hitType) const
hitType=-1(all), 0=valid, 3=bad; 0 = no stations at all
static const unsigned short HIT_LENGTH
static const unsigned short ARRAY_LENGTH
static const uint32_t NULL_RETURN
int pixelBarrelLayersNull() const
static bool timingHitFilter(uint16_t pattern)
static bool pixelHitFilter(uint16_t pattern)
int stripTIBLayersNull() const
int pixelBarrelLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const
bool hasValidHitInPixelLayer(enum PixelSubdetector::SubDetector, uint16_t layer) const
static uint16_t isStereo(DetId i, const TrackerTopology &ttopo)
bool tobIsStereo(const DetId &id) const
int stripTIBLayersWithMeasurement() const
int stripTECLayersNull() const
static const unsigned short SideOffset
static const uint16_t EMPTY_PATTERN
int muonStations(int subdet, int hitType) const
subdet = 0(all), 1(DT), 2(CSC), 3(RPC) 4(GEM); hitType=-1(all), 0=valid, 3=bad
static uint16_t getDTSuperLayer(uint16_t pattern)
DT superlayer (1-3). Where the "hit" was a DT segment, superlayer is 0. Only valid for muon DT patter...
static bool muonME0HitFilter(uint16_t pattern)
ret
prodAgent to be discontinued
static const unsigned short SubstrOffset
int stripTOBLayersWithoutMeasurement(HitCategory category) const
int numberOfDTStationsWithRPhiView() const
HitPattern & operator=(const HitPattern &other)
uint16_t getTrackerMonoStereo(HitCategory category, uint16_t substr, uint16_t layer) const
static const unsigned short MaxHits
uint32_t getTrackerLayerCase(HitCategory category, uint16_t substr, uint16_t layer) const
static const unsigned short maxTrackerWord
int pixelLayersWithMeasurement() const
int numberOfValidStripLayersWithMonoAndStereo() const
int pixelEndcapLayersWithoutMeasurement(HitCategory category) const
int trackerLayersWithMeasurement() const
static const unsigned short HitTypeMask
static bool pixelBarrelHitFilter(uint16_t pattern)
int pixelEndcapLayersWithMeasurement() const
Detector identifier base class for the MIP Timing Layer.
bool insertExpectedOuterHit(const uint16_t pattern)
bool tidIsStereo(const DetId &id) const
static bool pixelEndcapHitFilter(uint16_t pattern)
static bool validHitFilter(uint16_t pattern)
void printHitPattern(HitCategory category, int position, std::ostream &stream) const
bool tecIsStereo(const DetId &id) const
static uint16_t getGEMLayer(uint16_t pattern)
GEM layer: 1,2. Only valid for muon GEM patterns, of course.
static const unsigned short minTrackerWord
uint16_t hitPattern[ARRAY_LENGTH]
int stripTIBLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const
static bool muonCSCHitFilter(uint16_t pattern)
static uint32_t getHitType(uint16_t pattern)
int numberOfValidTECLayersWithMonoAndStereo(uint32_t layer=0) const
int stripTIDLayersWithMeasurement() const
static const unsigned short SubDetectorMask
static bool stripHitFilter(uint16_t pattern)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
int numberOfAllHits(HitCategory category) const
Abs< T >::type abs(const T &t)
int superLayer() const
Return the superlayer number.
bool appendHit(const TrackingRecHit &hit, const TrackerTopology &ttopo)
int numberOfDTStationsWithRZView() const
static constexpr auto TOB
int stripTIDLayersNull() const
static const unsigned short HitTypeOffset
int numberOfValidTIDLayersWithMonoAndStereo(uint32_t layer=0) const
bool appendTrackerHit(uint16_t subdet, uint16_t layer, uint16_t stereo, TrackingRecHit::Type hitType)
static uint32_t getSubStructure(uint16_t pattern)
int numberOfDTStationsWithBothViews() const
int numberOfValidTIBLayersWithMonoAndStereo(uint32_t layer=0) const
static uint16_t getRPCregion(uint16_t pattern)
RPC region: 0 = barrel, 1 = endcap. Only valid for muon RPC patterns, of course.
static bool muonGEMHitFilter(uint16_t pattern)
static uint16_t getGEMStation(uint16_t pattern)
GEM station: 1,2. Only valid for muon GEM patterns, of course.
int stripTIDLayersWithoutMeasurement(HitCategory category) const
int innermostMuonStationWithHits(int hitType) const
hitType=-1(all), 0=valid, 3=bad; 0 = no stations at all
static bool muonHitFilter(uint16_t pattern)
static bool trackerHitFilter(uint16_t pattern)
static constexpr auto TIB
static const unsigned short SideMask
static const unsigned short minStripWord
std::pair< uint8_t, uint8_t > getCategoryIndexRange(HitCategory category) const
static const unsigned short SubDetectorOffset
bool tibIsStereo(const DetId &id) const
int pixelBarrelLayersWithMeasurement() const
unsigned int layer(const DetId &id) const
uint16_t getHitPatternByAbsoluteIndex(int position) const
static uint32_t getSide(uint16_t pattern)
int stripTOBLayersNull() const
static bool muonDTHitFilter(uint16_t pattern)
int stripTIDLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const
int trackerLayersWithoutMeasurement(HitCategory category) const
bool insertExpectedInnerHit(const uint16_t pattern)
Detector identifier class for the Endcap Timing Layer.
static const unsigned short SubstrMask
static const unsigned short LayerOffset
static int position[264][3]
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
int mtdSubDetector() const
int pixelEndcapLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const
bool insertTrackHit(const uint16_t pattern)
int stripTECLayersWithMeasurement() const
int stripTECLayersWithoutMeasurement(HitCategory category) const
static uint16_t getRPCLayer(uint16_t pattern)
RPC layer: for station 1 and 2, layer = 1(inner) or 2(outer); for station 3, 4 layer is always 0...
static uint16_t getMuonStation(uint16_t pattern)
Muon station (1-4). Only valid for muon patterns, of course. only for patterns from muon...
void print(HitCategory category, std::ostream &stream=std::cout) const
int numberOfValidTOBLayersWithMonoAndStereo(uint32_t layer=0) const
DetId geographicalId() const
static uint32_t getSubSubStructure(uint16_t pattern)
uint16_t getHitPattern(HitCategory category, int position) const
int station() const
Return the station number.
static const unsigned short LayerMask
static bool muonRPCHitFilter(uint16_t pattern)
static constexpr auto TID
static uint16_t encode(const TrackingRecHit &hit, const TrackerTopology &ttopo)
int stripTECLayersTotallyOffOrBad(HitCategory category=TRACK_HITS) const
int stripTIBLayersWithoutMeasurement(HitCategory category) const
bool appendMuonHit(const DetId &id, TrackingRecHit::Type hitType)
int pixelEndcapLayersNull() const
constexpr Detector det() const
get the detector field from this detid
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.