00001 #include "DataFormats/TrackReco/interface/HitPattern.h"
00002 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00003 #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
00004 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
00005 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00006 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00007 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00008 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00009 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
00010 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00011 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00012 using namespace reco;
00013
00014
00015 uint32_t HitPattern::encode(const TrackingRecHit & hit, unsigned int i){
00016
00017
00018 if (i >= 32 * PatternSize / HitSize) return 0;
00019
00020
00021 DetId id = hit.geographicalId();
00022 uint32_t detid = id.det();
00023 uint32_t hitType = (uint32_t) hit.getType();
00024
00025
00026 uint32_t pattern = 0;
00027
00028
00029 pattern += ((detid)&SubDetectorMask)<<SubDetectorOffset;
00030
00031
00032 uint32_t subdet = id.subdetId();
00033 pattern += ((subdet)&SubstrMask)<<SubstrOffset;
00034
00035
00036 uint32_t layer = 0;
00037 if (detid == DetId::Tracker) {
00038 if (subdet == PixelSubdetector::PixelBarrel)
00039 layer = PXBDetId(id).layer();
00040 else if (subdet == PixelSubdetector::PixelEndcap)
00041 layer = PXFDetId(id).disk();
00042 else if (subdet == StripSubdetector::TIB)
00043 layer = TIBDetId(id).layer();
00044 else if (subdet == StripSubdetector::TID)
00045 layer = TIDDetId(id).wheel();
00046 else if (subdet == StripSubdetector::TOB)
00047 layer = TOBDetId(id).layer();
00048 else if (subdet == StripSubdetector::TEC)
00049 layer = TECDetId(id).wheel();
00050 } else if (detid == DetId::Muon) {
00051 if (subdet == (uint32_t) MuonSubdetId::DT)
00052 layer = ((DTLayerId(id.rawId()).station()-1)<<2) + DTLayerId(id.rawId()).superLayer();
00053 else if (subdet == (uint32_t) MuonSubdetId::CSC)
00054 layer = ((CSCDetId(id.rawId()).station()-1)<<2) + (CSCDetId(id.rawId()).ring()-1);
00055 else if (subdet == (uint32_t) MuonSubdetId::RPC) {
00056 RPCDetId rpcid(id.rawId());
00057 layer = ((rpcid.station()-1)<<2) + abs(rpcid.region());
00058 if (rpcid.station() <= 2) layer += 2*(rpcid.layer()-1);
00059 }
00060 }
00061 pattern += (layer&LayerMask)<<LayerOffset;
00062
00063
00064 uint32_t side = 0;
00065 if (detid == DetId::Tracker) {
00066 side = isStereo(id);
00067 } else if (detid == DetId::Muon) {
00068 side = 0;
00069 }
00070 pattern += (side&SideMask)<<SideOffset;
00071
00072
00073 pattern += (hitType&HitTypeMask)<<HitTypeOffset;
00074
00075 return pattern;
00076 }
00077
00078
00079 void HitPattern::setHitPattern(int position, uint32_t pattern) {
00080 int offset = position * HitSize;
00081 for (int i=0; i<HitSize; i++) {
00082 int pos = offset + i;
00083 uint32_t bit = (pattern >> i) & 0x1;
00084 hitPattern_[pos / 32] += bit << ((offset + i) % 32);
00085 }
00086 }
00087
00088 void HitPattern::appendHit(const TrackingRecHit & hit){
00089
00090
00091 DetId id = hit.geographicalId();
00092 uint32_t detid = id.det();
00093 uint32_t subdet = id.subdetId();
00094
00095 std::vector<const TrackingRecHit*> hits;
00096
00097
00098 if (detid == DetId::Tracker)
00099 hits.push_back(&hit);
00100
00101 if (detid == DetId::Muon) {
00102
00103 if (subdet == (uint32_t) MuonSubdetId::DT){
00104
00105
00106 if(hit.dimension() == 1)
00107 hits.push_back(&hit);
00108
00109
00110 else if(hit.dimension() > 1){
00111 std::vector<const TrackingRecHit*> seg2D = hit.recHits();
00112
00113 for(std::vector<const TrackingRecHit*>::const_iterator it = seg2D.begin(); it != seg2D.end(); ++it){
00114 std::vector<const TrackingRecHit*> hits1D = (*it)->recHits();
00115 copy(hits1D.begin(),hits1D.end(),back_inserter(hits));
00116 }
00117 }
00118 }
00119
00120 else if (subdet == (uint32_t) MuonSubdetId::CSC){
00121
00122
00123 if(hit.dimension() == 2)
00124 hits.push_back(&hit);
00125
00126
00127 if(hit.dimension() == 4)
00128 hits = hit.recHits();
00129 }
00130
00131 else if (subdet == (uint32_t) MuonSubdetId::RPC) {
00132 hits.push_back(&hit);
00133 }
00134 }
00135
00136 unsigned int i = numberOfHits();
00137 for(std::vector<const TrackingRecHit*>::const_iterator it = hits.begin(); it != hits.end(); ++it)
00138 set(**it,i++);
00139
00140
00141 }
00142
00143
00144 uint32_t HitPattern::getHitPattern(int position) const {
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 uint16_t bitEndOffset = (position+1) * HitSize;
00164 uint8_t secondWord = (bitEndOffset >> 5);
00165 uint8_t secondWordBits = bitEndOffset & (32-1);
00166 if (secondWordBits >= HitSize) {
00167 uint8_t lowBitsToTrash = secondWordBits - HitSize;
00168 uint32_t myResult = (hitPattern_[secondWord] >> lowBitsToTrash) & ((1 << HitSize)-1);
00169 return myResult;
00170 } else {
00171 uint8_t firstWordBits = HitSize - secondWordBits;
00172 uint32_t firstWordBlock = hitPattern_[secondWord-1] >> (32-firstWordBits);
00173 uint32_t secondWordBlock = hitPattern_[secondWord] & ((1<<secondWordBits)-1);
00174 uint32_t myResult = firstWordBlock + (secondWordBlock << firstWordBits);
00175 return myResult;
00176 }
00177 }
00178
00179
00180
00181
00182
00183 bool HitPattern::hasValidHitInFirstPixelBarrel() const {
00184 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00185 uint32_t pattern = getHitPattern(i);
00186 if (pattern == 0) break;
00187 if (pixelBarrelHitFilter(pattern)) {
00188 if (getLayer(pattern) == 1) {
00189 if (validHitFilter(pattern)) {
00190 return true;
00191 }
00192 }
00193 }
00194 }
00195 return false;
00196 }
00197
00198 bool HitPattern::hasValidHitInFirstPixelEndcap() const {
00199 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00200 uint32_t pattern = getHitPattern(i);
00201 if (pattern == 0) break;
00202 if (pixelEndcapHitFilter(pattern)) {
00203 if (getLayer(pattern) == 1) {
00204 if (validHitFilter(pattern)) {
00205 return true;
00206 }
00207 }
00208 }
00209 }
00210 return false;
00211 }
00212
00213 int HitPattern::numberOfHits() const {
00214 int count = 0;
00215 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00216 uint32_t pattern = getHitPattern(i);
00217 if (pattern == 0) break;
00218 ++count;
00219 }
00220 return count;
00221 }
00222
00223
00224 int HitPattern::numberOfValidStripLayersWithMonoAndStereo () const {
00225 static const int nHits = (PatternSize * 32) / HitSize;
00226 bool hasMono[SubstrMask + 1][LayerMask + 1];
00227
00228 memset(hasMono, 0, sizeof(hasMono));
00229 bool hasStereo[SubstrMask + 1][LayerMask + 1];
00230 memset(hasStereo, 0, sizeof(hasStereo));
00231
00232 for (int i = 0; i < nHits; i++) {
00233 uint32_t pattern = getHitPattern(i);
00234 if (pattern == 0) break;
00235 if (validHitFilter(pattern) && stripHitFilter(pattern)) {
00236 switch (getSide(pattern)) {
00237 case 0:
00238 hasMono[getSubStructure(pattern)][getLayer(pattern)]
00239 = true;
00240 break;
00241 case 1:
00242 hasStereo[getSubStructure(pattern)][getLayer(pattern)]
00243 = true;
00244 break;
00245 default:
00246 break;
00247 }
00248 }
00249
00250 }
00251
00252 int count = 0;
00253 for (int i = 0; i < SubstrMask + 1; ++i)
00254 for (int j = 0; j < LayerMask + 1; ++j)
00255 if (hasMono[i][j] && hasStereo[i][j])
00256 count++;
00257 return count;
00258 }
00259
00260 uint32_t HitPattern::getTrackerLayerCase(uint32_t substr, uint32_t layer) const {
00261 uint32_t tk_substr_layer =
00262 (1 << SubDetectorOffset) +
00263 ((substr & SubstrMask) << SubstrOffset) +
00264 ((layer & LayerMask) << LayerOffset);
00265
00266 uint32_t mask =
00267 (SubDetectorMask << SubDetectorOffset) +
00268 (SubstrMask << SubstrOffset) +
00269 (LayerMask << LayerOffset);
00270
00271
00272
00273
00274
00275
00276
00277
00278 uint32_t layerCase = 999999;
00279 for (int i=0; i<(PatternSize * 32) / HitSize; i++)
00280 {
00281 uint32_t pattern = getHitPattern(i);
00282 if (pattern == 0) break;
00283 if ((pattern & mask) == tk_substr_layer) {
00284 uint32_t hitType = (pattern >> HitTypeOffset) & HitTypeMask;
00285 if (hitType < layerCase) {
00286 layerCase = hitType;
00287 if (hitType == 3) layerCase = 2;
00288 }
00289 }
00290 }
00291 return layerCase;
00292 }
00293
00294 uint32_t HitPattern::getTrackerMonoStereo (uint32_t substr, uint32_t layer) const
00295 {
00296 uint32_t tk_substr_layer =
00297 (1 << SubDetectorOffset) +
00298 ((substr & SubstrMask) << SubstrOffset) +
00299 ((layer & LayerMask) << LayerOffset);
00300
00301 uint32_t mask =
00302 (SubDetectorMask << SubDetectorOffset) +
00303 (SubstrMask << SubstrOffset) +
00304 (LayerMask << LayerOffset);
00305
00306
00307
00308
00309
00310 uint32_t monoStereo = 0;
00311 for (int i=0; i<(PatternSize * 32) / HitSize; i++)
00312 {
00313 uint32_t pattern = getHitPattern(i);
00314 if (pattern == 0) break;
00315 if ((pattern & mask) == tk_substr_layer)
00316 {
00317 uint32_t hitType = (pattern >> HitTypeOffset) & HitTypeMask;
00318 if (hitType == 0) {
00319 switch (getSide(pattern)) {
00320 case 0:
00321 monoStereo |= MONO;
00322 break;
00323 case 1:
00324 monoStereo |= STEREO;
00325 break;
00326 default:
00327 break;
00328 }
00329 }
00330 }
00331 }
00332 return monoStereo;
00333 }
00334
00335
00336
00337 int HitPattern::pixelBarrelLayersWithMeasurement() const {
00338 int count = 0;
00339 uint32_t substr = PixelSubdetector::PixelBarrel;
00340 for (uint32_t layer=1; layer<=3; layer++) {
00341 if (getTrackerLayerCase(substr, layer) == 0) count++;
00342 }
00343 return count;
00344 }
00345
00346 int HitPattern::pixelEndcapLayersWithMeasurement() const {
00347 int count = 0;
00348 uint32_t substr = PixelSubdetector::PixelEndcap;
00349 for (uint32_t layer=1; layer<=2; layer++) {
00350 if (getTrackerLayerCase(substr, layer) == 0) count++;
00351 }
00352 return count;
00353 }
00354
00355 int HitPattern::stripTIBLayersWithMeasurement() const {
00356 int count = 0;
00357 uint32_t substr = StripSubdetector::TIB;
00358 for (uint32_t layer=1; layer<=4; layer++) {
00359 if (getTrackerLayerCase(substr, layer) == 0) count++;
00360 }
00361 return count;
00362 }
00363
00364 int HitPattern::stripTIDLayersWithMeasurement() const {
00365 int count = 0;
00366 uint32_t substr = StripSubdetector::TID;
00367 for (uint32_t layer=1; layer<=3; layer++) {
00368 if (getTrackerLayerCase(substr, layer) == 0) count++;
00369 }
00370 return count;
00371 }
00372
00373 int HitPattern::stripTOBLayersWithMeasurement() const {
00374 int count = 0;
00375 uint32_t substr = StripSubdetector::TOB;
00376 for (uint32_t layer=1; layer<=6; layer++) {
00377 if (getTrackerLayerCase(substr, layer) == 0) count++;
00378 }
00379 return count;
00380 }
00381
00382 int HitPattern::stripTECLayersWithMeasurement() const {
00383 int count = 0;
00384 uint32_t substr = StripSubdetector::TEC;
00385 for (uint32_t layer=1; layer<=9; layer++) {
00386 if (getTrackerLayerCase(substr, layer) == 0) count++;
00387 }
00388 return count;
00389 }
00390
00391
00392 int HitPattern::pixelBarrelLayersWithoutMeasurement() const {
00393 int count = 0;
00394 uint32_t substr = PixelSubdetector::PixelBarrel;
00395 for (uint32_t layer=1; layer<=3; layer++) {
00396 if (getTrackerLayerCase(substr, layer) == 1) count++;
00397 }
00398 return count;
00399 }
00400
00401 int HitPattern::pixelEndcapLayersWithoutMeasurement() const {
00402 int count = 0;
00403 uint32_t substr = PixelSubdetector::PixelEndcap;
00404 for (uint32_t layer=1; layer<=2; layer++) {
00405 if (getTrackerLayerCase(substr, layer) == 1) count++;
00406 }
00407 return count;
00408 }
00409
00410 int HitPattern::stripTIBLayersWithoutMeasurement() const {
00411 int count = 0;
00412 uint32_t substr = StripSubdetector::TIB;
00413 for (uint32_t layer=1; layer<=4; layer++) {
00414 if (getTrackerLayerCase(substr, layer) == 1) count++;
00415 }
00416 return count;
00417 }
00418
00419 int HitPattern::stripTIDLayersWithoutMeasurement() const {
00420 int count = 0;
00421 uint32_t substr = StripSubdetector::TID;
00422 for (uint32_t layer=1; layer<=3; layer++) {
00423 if (getTrackerLayerCase(substr, layer) == 1) count++;
00424 }
00425 return count;
00426 }
00427
00428 int HitPattern::stripTOBLayersWithoutMeasurement() const {
00429 int count = 0;
00430 uint32_t substr = StripSubdetector::TOB;
00431 for (uint32_t layer=1; layer<=6; layer++) {
00432 if (getTrackerLayerCase(substr, layer) == 1) count++;
00433 }
00434 return count;
00435 }
00436
00437 int HitPattern::stripTECLayersWithoutMeasurement() const {
00438 int count = 0;
00439 uint32_t substr = StripSubdetector::TEC;
00440 for (uint32_t layer=1; layer<=9; layer++) {
00441 if (getTrackerLayerCase(substr, layer) == 1) count++;
00442 }
00443 return count;
00444 }
00445
00446
00447 int HitPattern::pixelBarrelLayersTotallyOffOrBad() const {
00448 int count = 0;
00449 uint32_t substr = PixelSubdetector::PixelBarrel;
00450 for (uint32_t layer=1; layer<=3; layer++) {
00451 if (getTrackerLayerCase(substr, layer) == 2) count++;
00452 }
00453 return count;
00454 }
00455
00456 int HitPattern::pixelEndcapLayersTotallyOffOrBad() const {
00457 int count = 0;
00458 uint32_t substr = PixelSubdetector::PixelEndcap;
00459 for (uint32_t layer=1; layer<=2; layer++) {
00460 if (getTrackerLayerCase(substr, layer) == 2) count++;
00461 }
00462 return count;
00463 }
00464
00465 int HitPattern::stripTIBLayersTotallyOffOrBad() const {
00466 int count = 0;
00467 uint32_t substr = StripSubdetector::TIB;
00468 for (uint32_t layer=1; layer<=4; layer++) {
00469 if (getTrackerLayerCase(substr, layer) == 2) count++;
00470 }
00471 return count;
00472 }
00473
00474 int HitPattern::stripTIDLayersTotallyOffOrBad() const {
00475 int count = 0;
00476 uint32_t substr = StripSubdetector::TID;
00477 for (uint32_t layer=1; layer<=3; layer++) {
00478 if (getTrackerLayerCase(substr, layer) == 2) count++;
00479 }
00480 return count;
00481 }
00482
00483 int HitPattern::stripTOBLayersTotallyOffOrBad() const {
00484 int count = 0;
00485 uint32_t substr = StripSubdetector::TOB;
00486 for (uint32_t layer=1; layer<=6; layer++) {
00487 if (getTrackerLayerCase(substr, layer) == 2) count++;
00488 }
00489 return count;
00490 }
00491
00492 int HitPattern::stripTECLayersTotallyOffOrBad() const {
00493 int count = 0;
00494 uint32_t substr = StripSubdetector::TEC;
00495 for (uint32_t layer=1; layer<=9; layer++) {
00496 if (getTrackerLayerCase(substr, layer) == 2) count++;
00497 }
00498 return count;
00499 }
00500
00501
00502 int HitPattern::pixelBarrelLayersNull() const {
00503 int count = 0;
00504 uint32_t substr = PixelSubdetector::PixelBarrel;
00505 for (uint32_t layer=1; layer<=3; layer++) {
00506 if (getTrackerLayerCase(substr, layer) == 999999) count++;
00507 }
00508 return count;
00509 }
00510
00511 int HitPattern::pixelEndcapLayersNull() const {
00512 int count = 0;
00513 uint32_t substr = PixelSubdetector::PixelEndcap;
00514 for (uint32_t layer=1; layer<=2; layer++) {
00515 if (getTrackerLayerCase(substr, layer) == 999999) count++;
00516 }
00517 return count;
00518 }
00519
00520 int HitPattern::stripTIBLayersNull() const {
00521 int count = 0;
00522 uint32_t substr = StripSubdetector::TIB;
00523 for (uint32_t layer=1; layer<=4; layer++) {
00524 if (getTrackerLayerCase(substr, layer) == 999999) count++;
00525 }
00526 return count;
00527 }
00528
00529 int HitPattern::stripTIDLayersNull() const {
00530 int count = 0;
00531 uint32_t substr = StripSubdetector::TID;
00532 for (uint32_t layer=1; layer<=3; layer++) {
00533 if (getTrackerLayerCase(substr, layer) == 999999) count++;
00534 }
00535 return count;
00536 }
00537
00538 int HitPattern::stripTOBLayersNull() const {
00539 int count = 0;
00540 uint32_t substr = StripSubdetector::TOB;
00541 for (uint32_t layer=1; layer<=6; layer++) {
00542 if (getTrackerLayerCase(substr, layer) == 999999) count++;
00543 }
00544 return count;
00545 }
00546
00547 int HitPattern::stripTECLayersNull() const {
00548 int count = 0;
00549 uint32_t substr = StripSubdetector::TEC;
00550 for (uint32_t layer=1; layer<=9; layer++) {
00551 if (getTrackerLayerCase(substr, layer) == 999999) count++;
00552 }
00553 return count;
00554 }
00555
00556 void HitPattern::printHitPattern (int position, std::ostream &stream) const
00557 {
00558 uint32_t pattern = getHitPattern(position);
00559 stream << "\t";
00560 if (muonHitFilter(pattern))
00561 stream << "muon";
00562 if (trackerHitFilter(pattern))
00563 stream << "tracker";
00564 stream << "\tsubstructure " << getSubStructure(pattern);
00565 if (muonHitFilter(pattern)) {
00566 stream << "\tstation " << getMuonStation(pattern);
00567 if (muonDTHitFilter(pattern)) {
00568 stream << "\tdt superlayer " << getDTSuperLayer(pattern);
00569 } else if (muonCSCHitFilter(pattern)) {
00570 stream << "\tcsc ring " << getCSCRing(pattern);
00571 } else if (muonRPCHitFilter(pattern)) {
00572 stream << "\trpc " << (getRPCregion(pattern) ? "endcaps" : "barrel") << ", layer " << getRPCLayer(pattern);
00573 } else {
00574 stream << "(UNKNOWN Muon SubStructure!) \tsubsubstructure " << getSubStructure(pattern);
00575 }
00576 } else {
00577 stream << "\tlayer " << getLayer(pattern);
00578 }
00579 stream << "\thit type " << getHitType(pattern);
00580 stream << std::endl;
00581 }
00582
00583 void HitPattern::print (std::ostream &stream) const
00584 {
00585 stream << "HitPattern" << std::endl;
00586 for (int i = 0; i < numberOfHits(); i++)
00587 printHitPattern(i, stream);
00588 std::ios_base::fmtflags flags = stream.flags();
00589 stream.setf ( std::ios_base::hex, std::ios_base::basefield );
00590 stream.setf ( std::ios_base::showbase );
00591 for (int i = 0; i < numberOfHits(); i++) {
00592 uint32_t pattern = getHitPattern(i);
00593 stream << pattern << std::endl;
00594 }
00595 stream.flags(flags);
00596 }
00597
00598 uint32_t HitPattern::isStereo (DetId i)
00599 {
00600 switch (i.det()) {
00601 case DetId::Tracker:
00602 switch (i.subdetId()) {
00603 case PixelSubdetector::PixelBarrel:
00604 case PixelSubdetector::PixelEndcap:
00605 return 0;
00606 case StripSubdetector::TIB:
00607 {
00608 TIBDetId id = i;
00609 return id.isStereo();
00610 }
00611 case StripSubdetector::TID:
00612 {
00613 TIDDetId id = i;
00614 return id.isStereo();
00615 }
00616 case StripSubdetector::TOB:
00617 {
00618 TOBDetId id = i;
00619 return id.isStereo();
00620 }
00621 case StripSubdetector::TEC:
00622 {
00623 TECDetId id = i;
00624 return id.isStereo();
00625 }
00626 default:
00627 return 0;
00628 }
00629 break;
00630 default:
00631 return 0;
00632 }
00633 }
00634
00635 int HitPattern::muonStations(int subdet, int hitType) const {
00636 int stations[4] = { 0,0,0,0 };
00637 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00638 uint32_t pattern = getHitPattern(i);
00639 if (pattern == 0) break;
00640 if (muonHitFilter(pattern) &&
00641 (subdet == 0 || int(getSubStructure(pattern)) == subdet) &&
00642 (hitType == -1 || int(getHitType(pattern)) == hitType)) {
00643 stations[getMuonStation(pattern)-1] = 1;
00644 }
00645 }
00646 return stations[0]+stations[1]+stations[2]+stations[3];
00647 }
00648
00649
00650 int HitPattern::innermostMuonStationWithHits(int hitType) const {
00651 int ret = 0;
00652 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00653 uint32_t pattern = getHitPattern(i);
00654 if (pattern == 0) break;
00655 if (muonHitFilter(pattern) &&
00656 (hitType == -1 || int(getHitType(pattern)) == hitType)) {
00657 int stat = getMuonStation(pattern);
00658 if (ret == 0 || stat < ret) ret = stat;
00659 }
00660 }
00661 return ret;
00662 }
00663
00664 int HitPattern::outermostMuonStationWithHits(int hitType) const {
00665 int ret = 0;
00666 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00667 uint32_t pattern = getHitPattern(i);
00668 if (pattern == 0) break;
00669 if (muonHitFilter(pattern) &&
00670 (hitType == -1 || int(getHitType(pattern)) == hitType)) {
00671 int stat = getMuonStation(pattern);
00672 if (ret == 0 || stat > ret) ret = stat;
00673 }
00674 }
00675 return ret;
00676 }
00677
00678
00679 int HitPattern::numberOfDTStationsWithRPhiView() const {
00680 int stations[4] = { 0,0,0,0 };
00681 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00682 uint32_t pattern = getHitPattern(i);
00683 if (pattern == 0) break;
00684 if (muonDTHitFilter(pattern) && validHitFilter(pattern) && getDTSuperLayer(pattern) != 2) {
00685 stations[getMuonStation(pattern)-1] = 1;
00686 }
00687 }
00688 return stations[0]+stations[1]+stations[2]+stations[3];
00689 }
00690
00691 int HitPattern::numberOfDTStationsWithRZView() const {
00692 int stations[4] = { 0,0,0,0 };
00693 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00694 uint32_t pattern = getHitPattern(i);
00695 if (pattern == 0) break;
00696 if (muonDTHitFilter(pattern) && validHitFilter(pattern) && getDTSuperLayer(pattern) == 2) {
00697 stations[getMuonStation(pattern)-1] = 1;
00698 }
00699 }
00700 return stations[0]+stations[1]+stations[2]+stations[3];
00701 }
00702
00703 int HitPattern::numberOfDTStationsWithBothViews() const {
00704 int stations[4][2] = { {0,0}, {0,0}, {0,0}, {0,0} };
00705 for (int i=0; i<(PatternSize * 32) / HitSize; i++) {
00706 uint32_t pattern = getHitPattern(i);
00707 if (pattern == 0) break;
00708 if (muonDTHitFilter(pattern) && validHitFilter(pattern)) {
00709 stations[getMuonStation(pattern)-1][getDTSuperLayer(pattern) == 2] = 1;
00710 }
00711 }
00712 return stations[0][0]*stations[0][1] + stations[1][0]*stations[1][1] + stations[2][0]*stations[2][1] + stations[3][0]*stations[3][1];
00713 }
00714
00715
00716