CMS 3D CMS Logo

RecoTauMuonTools.cc
Go to the documentation of this file.
2 
4 
5 namespace reco { namespace tau {
6  void countHits(const reco::Muon& muon, std::vector<int>& numHitsDT, std::vector<int>& numHitsCSC, std::vector<int>& numHitsRPC)
7  {
8  if ( muon.outerTrack().isNonnull() ) {
9  const reco::HitPattern &muonHitPattern = muon.outerTrack()->hitPattern();
10  for (int iHit = 0; iHit < muonHitPattern.numberOfAllHits(reco::HitPattern::TRACK_HITS); ++iHit) {
11  uint32_t hit = muonHitPattern.getHitPattern(reco::HitPattern::TRACK_HITS, iHit);
12  if ( hit == 0 ) break;
13  if ( muonHitPattern.muonHitFilter(hit) && (muonHitPattern.getHitType(hit) == TrackingRecHit::valid || muonHitPattern.getHitType(hit) == TrackingRecHit::bad) ) {
14  int muonStation = muonHitPattern.getMuonStation(hit) - 1; // CV: map into range 0..3
15  if ( muonStation >= 0 && muonStation < 4 ) {
16  if ( muonHitPattern.muonDTHitFilter(hit) ) ++numHitsDT[muonStation];
17  else if ( muonHitPattern.muonCSCHitFilter(hit) ) ++numHitsCSC[muonStation];
18  else if ( muonHitPattern.muonRPCHitFilter(hit) ) ++numHitsRPC[muonStation];
19  }
20  }
21  }
22  }
23  }
24 
25  std::string format_vint(const std::vector<int>& vi)
26  {
27  std::ostringstream os;
28  os << "{ ";
29  unsigned numEntries = vi.size();
30  for ( unsigned iEntry = 0; iEntry < numEntries; ++iEntry ) {
31  os << vi[iEntry];
32  if ( iEntry < (numEntries - 1) ) os << ", ";
33  }
34  os << " }";
35  return os.str();
36  }
37 
38  void countMatches(const reco::Muon& muon, std::vector<int>& numMatchesDT, std::vector<int>& numMatchesCSC, std::vector<int>& numMatchesRPC)
39  {
40  const std::vector<reco::MuonChamberMatch>& muonSegments = muon.matches();
41  for ( std::vector<reco::MuonChamberMatch>::const_iterator muonSegment = muonSegments.begin();
42  muonSegment != muonSegments.end(); ++muonSegment ) {
43  if ( muonSegment->segmentMatches.empty() ) continue;
44  int muonDetector = muonSegment->detector();
45  int muonStation = muonSegment->station() - 1;
46  assert(muonStation >= 0 && muonStation <= 3);
47  if ( muonDetector == MuonSubdetId::DT ) ++numMatchesDT[muonStation];
48  else if ( muonDetector == MuonSubdetId::CSC ) ++numMatchesCSC[muonStation];
49  else if ( muonDetector == MuonSubdetId::RPC ) ++numMatchesRPC[muonStation];
50  }
51  }
52 
53 }} // end namespace reco::tau
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
void countMatches(const reco::Muon &muon, std::vector< int > &numMatchesDT, std::vector< int > &numMatchesCSC, std::vector< int > &numMatchesRPC)
static const int CSC
Definition: MuonSubdetId.h:13
static bool muonCSCHitFilter(uint16_t pattern)
Definition: HitPattern.h:678
static uint32_t getHitType(uint16_t pattern)
Definition: HitPattern.h:792
Long64_t numEntries(TFile *hdl, std::string const &trname)
Definition: CollUtil.cc:50
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:875
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
static bool muonHitFilter(uint16_t pattern)
Definition: HitPattern.h:720
std::vector< MuonChamberMatch > & matches()
get muon matching information
Definition: Muon.h:144
static bool muonDTHitFilter(uint16_t pattern)
Definition: HitPattern.h:668
fixed size matrix
static const int RPC
Definition: MuonSubdetId.h:14
static uint16_t getMuonStation(uint16_t pattern)
Muon station (1-4). Only valid for muon patterns, of course. only for patterns from muon...
Definition: HitPattern.h:801
static const int DT
Definition: MuonSubdetId.h:12
std::string format_vint(const std::vector< int > &vi)
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:553
static bool muonRPCHitFilter(uint16_t pattern)
Definition: HitPattern.h:688
void countHits(const reco::Muon &muon, std::vector< int > &numHitsDT, std::vector< int > &numHitsCSC, std::vector< int > &numHitsRPC)