Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:54

0001 #include "RecoTauTag/RecoTau/interface/RecoTauMuonTools.h"
0002 
0003 #include "DataFormats/TrackReco/interface/HitPattern.h"
0004 
0005 namespace reco {
0006   namespace tau {
0007     void countHits(const reco::Muon& muon,
0008                    std::vector<int>& numHitsDT,
0009                    std::vector<int>& numHitsCSC,
0010                    std::vector<int>& numHitsRPC) {
0011       if (muon.outerTrack().isNonnull()) {
0012         const reco::HitPattern& muonHitPattern = muon.outerTrack()->hitPattern();
0013         for (int iHit = 0; iHit < muonHitPattern.numberOfAllHits(reco::HitPattern::TRACK_HITS); ++iHit) {
0014           uint32_t hit = muonHitPattern.getHitPattern(reco::HitPattern::TRACK_HITS, iHit);
0015           if (hit == 0)
0016             break;
0017           if (muonHitPattern.muonHitFilter(hit) && (muonHitPattern.getHitType(hit) == TrackingRecHit::valid ||
0018                                                     muonHitPattern.getHitType(hit) == TrackingRecHit::bad)) {
0019             int muonStation = muonHitPattern.getMuonStation(hit) - 1;  // CV: map into range 0..3
0020             if (muonStation >= 0 && muonStation < 4) {
0021               if (muonHitPattern.muonDTHitFilter(hit))
0022                 ++numHitsDT[muonStation];
0023               else if (muonHitPattern.muonCSCHitFilter(hit))
0024                 ++numHitsCSC[muonStation];
0025               else if (muonHitPattern.muonRPCHitFilter(hit))
0026                 ++numHitsRPC[muonStation];
0027             }
0028           }
0029         }
0030       }
0031     }
0032 
0033     std::string format_vint(const std::vector<int>& vi) {
0034       std::ostringstream os;
0035       os << "{ ";
0036       unsigned numEntries = vi.size();
0037       for (unsigned iEntry = 0; iEntry < numEntries; ++iEntry) {
0038         os << vi[iEntry];
0039         if (iEntry < (numEntries - 1))
0040           os << ", ";
0041       }
0042       os << " }";
0043       return os.str();
0044     }
0045 
0046     void countMatches(const reco::Muon& muon,
0047                       std::vector<int>& numMatchesDT,
0048                       std::vector<int>& numMatchesCSC,
0049                       std::vector<int>& numMatchesRPC) {
0050       const std::vector<reco::MuonChamberMatch>& muonSegments = muon.matches();
0051       for (std::vector<reco::MuonChamberMatch>::const_iterator muonSegment = muonSegments.begin();
0052            muonSegment != muonSegments.end();
0053            ++muonSegment) {
0054         if (muonSegment->segmentMatches.empty())
0055           continue;
0056         int muonDetector = muonSegment->detector();
0057         int muonStation = muonSegment->station() - 1;
0058         assert(muonStation >= 0 && muonStation <= 3);
0059         if (muonDetector == MuonSubdetId::DT)
0060           ++numMatchesDT[muonStation];
0061         else if (muonDetector == MuonSubdetId::CSC)
0062           ++numMatchesCSC[muonStation];
0063         else if (muonDetector == MuonSubdetId::RPC)
0064           ++numMatchesRPC[muonStation];
0065       }
0066     }
0067 
0068   }  // namespace tau
0069 }  // namespace reco