95 uint16_t encodeMuonLayer(
const DetId&
id) {
96 uint16_t detid =
id.det();
97 uint16_t subdet =
id.subdetId();
113 layer = ((rpcid.
station() - 1) << 2);
114 layer |= (rpcid.
station() <= 2) ? ((rpcid.
layer() - 1) << 1) : 0x0;
121 layer = ((gemid.
station()-1)<<2);
131 layer = (me0id.
roll());
138 uint16_t encodeTimingLayer(
const DetId&
id) {
139 uint16_t detid =
id.det();
140 uint16_t subdet =
id.subdetId();
141 uint16_t layer = 0x0;
157 <<
"Invalid DetId for FastTime det= " <<detid <<
" subdet= " << subdet <<
"!";
165 uint16_t detid =
id.det();
166 uint16_t subdet =
id.subdetId();
169 uint16_t layer = 0x0;
171 layer = ttopo.
layer(
id);
173 layer = encodeMuonLayer(
id);
175 layer = encodeTimingLayer(
id);
196 return encode(detid, subdet, layer, side, hitType);
262 <<
" were stored on this object before hits of some other category were inserted " 263 <<
"but hits of the same category should be inserted in a row. " 264 <<
"Please rework the code so it inserts all " 275 <<
"MISSING_INNER_HITS" 276 <<
" were stored on this object before hits of some other category were inserted " 277 <<
"but hits of the same category should be inserted in a row. " 278 <<
"Please rework the code so it inserts all " 279 <<
"MISSING_INNER_HITS" 289 <<
"MISSING_OUTER_HITS" 290 <<
" were stored on this object before hits of some other category were inserted " 291 <<
"but hits of the same category should be inserted in a row. " 292 <<
"Please rework the code so it inserts all " 293 <<
"MISSING_OUTER_HITS" 315 throw cms::Exception(
"HitPattern") <<
"Got DetId from det " <<
id.det() <<
" that is not Muon in appendMuonHit(), which should only be used for muon hits in the HitPattern IO rule";
318 uint16_t subdet =
id.subdetId();
348 uint16_t bitEndOffset = (position + 1) *
HIT_LENGTH;
349 uint8_t secondWord = (bitEndOffset >> 4);
350 uint8_t secondWordBits = bitEndOffset & (16 - 1);
352 uint8_t lowBitsToTrash = secondWordBits -
HIT_LENGTH;
353 uint16_t myResult = (
hitPattern[secondWord] >> lowBitsToTrash) & ((1 << HIT_LENGTH) - 1);
356 uint8_t firstWordBits =
HIT_LENGTH - secondWordBits;
357 uint16_t firstWordBlock =
hitPattern[secondWord - 1] >> (16 - firstWordBits);
358 uint16_t secondWordBlock =
hitPattern[secondWord] & ((1 << secondWordBits) - 1);
359 uint16_t myResult = firstWordBlock + (secondWordBlock << firstWordBits);
383 memset(hasMono, 0,
sizeof(hasMono));
384 memset(hasStereo, 0,
sizeof(hasStereo));
392 if (stripdet != 0 && subStructure != stripdet) {
402 hasMono[subStructure][
getLayer(pattern)] =
true;
405 hasStereo[subStructure][
getLayer(pattern)] =
true;
417 for (
int j = 0; j <
LayerMask + 1; ++j) {
418 if (hasMono[
i][j] && hasStereo[
i][j]) {
429 std::bitset<128> side[2];
431 for (
int i = range.first;
i < range.second; ++
i) {
436 if (hitType != HIT_TYPE::VALID)
continue;
442 return (side[0]&side[1]).count();
483 for (
int i = range.first;
i < range.second; ++
i) {
485 if ((pattern & mask) == tk_substr_layer) {
487 if (hitType < layerCase) {
489 layerCase = (hitType ==
HIT_TYPE::BAD ? HIT_TYPE::INACTIVE : hitType);
490 if (layerCase == HIT_TYPE::VALID) {
512 uint16_t monoStereo = 0x0;
514 for (
int i = range.first;
i < range.second; ++
i) {
516 if ((pattern & mask) == tk_substr_layer) {
518 if (hitType == HIT_TYPE::VALID) {
540 std::bitset<128> layerOk;
542 for (
int i = range.first;
i < range.second; ++
i) {
547 if (hitType != HIT_TYPE::VALID)
continue;
553 return layerOk.count();
559 std::bitset<128> layerOk;
561 for (
int i = range.first;
i < range.second; ++
i) {
565 if (hitType != HIT_TYPE::VALID)
continue;
571 return layerOk.count();
575 std::bitset<128> layerOk;
576 std::bitset<128> layerMissed;
578 for (
int i = range.first;
i < range.second; ++
i) {
584 if (hitType == HIT_TYPE::VALID) layerOk.set(
pattern);
585 if (hitType == HIT_TYPE::MISSING) layerMissed.set(
pattern);
587 layerMissed &= ~layerOk;
591 return layerMissed.count();
600 uint16_t NPixBarrel = 4;
601 for (uint16_t layer = 1; layer <= NPixBarrel; layer++) {
612 uint16_t NPixForward = 3;
613 for (uint16_t layer = 1; layer <= NPixForward; layer++) {
624 for (uint16_t layer = 1; layer <= 4; layer++) {
635 for (uint16_t layer = 1; layer <= 3; layer++) {
646 for (uint16_t layer = 1; layer <= 6; layer++) {
657 for (uint16_t layer = 1; layer <= 9; layer++) {
668 uint16_t NPixBarrel = 4;
669 for (uint16_t layer = 1; layer <= NPixBarrel; layer++) {
680 uint16_t NPixForward = 3;
681 for (uint16_t layer = 1; layer <= NPixForward; layer++) {
692 for (uint16_t layer = 1; layer <= 4; layer++) {
703 for (uint16_t layer = 1; layer <= 3; layer++) {
714 for (uint16_t layer = 1; layer <= 6; layer++) {
725 for (uint16_t layer = 1; layer <= 9; layer++) {
737 uint16_t NPixBarrel = 4;
738 for (uint16_t layer = 1; layer <= NPixBarrel; layer++) {
749 uint16_t NPixForward = 3;
750 for (uint16_t layer = 1; layer <= NPixForward; layer++) {
761 for (uint16_t layer = 1; layer <= 4; layer++) {
772 for (uint16_t layer = 1; layer <= 3; layer++) {
783 for (uint16_t layer = 1; layer <= 6; layer++) {
795 for (uint16_t layer = 1; layer <= 9; layer++) {
806 uint16_t NPixBarrel = 4;
807 for (uint16_t layer = 1; layer <= NPixBarrel; layer++) {
818 uint16_t NPixForward = 3;
819 for (uint16_t layer = 1; layer <= NPixForward; layer++) {
830 for (uint16_t layer = 1; layer <= 4; layer++) {
841 for (uint16_t layer = 1; layer <= 3; layer++) {
852 for (uint16_t layer = 1; layer <= 6; layer++) {
863 for (uint16_t layer = 1; layer <= 9; layer++) {
889 stream <<
"\tcsc ring " <<
getCSCRing(pattern);
891 stream <<
"\trpc " << (
getRPCregion(pattern) ?
"endcaps" :
"barrel")
894 stream <<
"\tgem " << (
getGEMLayer(pattern) ?
"layer1" :
"layer2")
899 stream <<
"(UNKNOWN Muon SubStructure!) \tsubsubstructure " 905 stream <<
"\tlayer " <<
getLayer(pattern);
907 stream <<
"\thit type " <<
getHitType(pattern);
913 stream <<
"HitPattern" << std::endl;
917 std::ios_base::fmtflags
flags = stream.flags();
918 stream.setf(std::ios_base::hex, std::ios_base::basefield);
919 stream.setf(std::ios_base::showbase);
953 int stations[4] = {0, 0, 0, 0};
958 && (hitType == -1 ||
int(
getHitType(pattern)) == hitType)) {
963 return stations[0] + stations[1] + stations[2] + stations[3];
972 && (hitType == -1 ||
int(
getHitType(pattern)) == hitType)) {
974 if (ret == 0 || stat < ret) {
989 (hitType == -1 ||
int(
getHitType(pattern)) == hitType)) {
991 if (ret == 0 || stat > ret) {
1001 int stations[4] = {0, 0, 0, 0};
1010 return stations[0] + stations[1] + stations[2] + stations[3];
1015 int stations[4] = {0, 0, 0, 0};
1023 return stations[0] + stations[1] + stations[2] + stations[3];
1028 int stations[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
1036 return stations[0][0] * stations[0][1]
1037 + stations[1][0] * stations[1][1]
1038 + stations[2][0] * stations[2][1]
1039 + stations[3][0] * stations[3][1];
1046 int pos = offset +
i;
1047 uint16_t bit = (pattern >>
i) & 0
x1;
1049 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.
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)
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
std::vector< Variable::Flags > flags
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
int layer() const
Layer id: each station have two layers of chambers: layer 1 is the inner chamber and layer 2 is the o...
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
int station() const
Station id : the station is the pair of chambers at same disk.
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
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 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 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.