CMS 3D CMS Logo

RecoTauMuonTools.cc
Go to the documentation of this file.
2 
4 
5 namespace reco {
6  namespace tau {
7  void countHits(const reco::Muon& muon,
8  std::vector<int>& numHitsDT,
9  std::vector<int>& numHitsCSC,
10  std::vector<int>& numHitsRPC) {
11  if (muon.outerTrack().isNonnull()) {
12  const reco::HitPattern& muonHitPattern = muon.outerTrack()->hitPattern();
13  for (int iHit = 0; iHit < muonHitPattern.numberOfAllHits(reco::HitPattern::TRACK_HITS); ++iHit) {
14  uint32_t hit = muonHitPattern.getHitPattern(reco::HitPattern::TRACK_HITS, iHit);
15  if (hit == 0)
16  break;
17  if (muonHitPattern.muonHitFilter(hit) && (muonHitPattern.getHitType(hit) == TrackingRecHit::valid ||
18  muonHitPattern.getHitType(hit) == TrackingRecHit::bad)) {
19  int muonStation = muonHitPattern.getMuonStation(hit) - 1; // CV: map into range 0..3
20  if (muonStation >= 0 && muonStation < 4) {
21  if (muonHitPattern.muonDTHitFilter(hit))
22  ++numHitsDT[muonStation];
23  else if (muonHitPattern.muonCSCHitFilter(hit))
24  ++numHitsCSC[muonStation];
25  else if (muonHitPattern.muonRPCHitFilter(hit))
26  ++numHitsRPC[muonStation];
27  }
28  }
29  }
30  }
31  }
32 
33  std::string format_vint(const std::vector<int>& vi) {
34  std::ostringstream os;
35  os << "{ ";
36  unsigned numEntries = vi.size();
37  for (unsigned iEntry = 0; iEntry < numEntries; ++iEntry) {
38  os << vi[iEntry];
39  if (iEntry < (numEntries - 1))
40  os << ", ";
41  }
42  os << " }";
43  return os.str();
44  }
45 
47  std::vector<int>& numMatchesDT,
48  std::vector<int>& numMatchesCSC,
49  std::vector<int>& numMatchesRPC) {
50  const std::vector<reco::MuonChamberMatch>& muonSegments = muon.matches();
51  for (std::vector<reco::MuonChamberMatch>::const_iterator muonSegment = muonSegments.begin();
52  muonSegment != muonSegments.end();
53  ++muonSegment) {
54  if (muonSegment->segmentMatches.empty())
55  continue;
56  int muonDetector = muonSegment->detector();
57  int muonStation = muonSegment->station() - 1;
58  assert(muonStation >= 0 && muonStation <= 3);
59  if (muonDetector == MuonSubdetId::DT)
60  ++numMatchesDT[muonStation];
61  else if (muonDetector == MuonSubdetId::CSC)
62  ++numMatchesCSC[muonStation];
63  else if (muonDetector == MuonSubdetId::RPC)
64  ++numMatchesRPC[muonStation];
65  }
66  }
67 
68  } // namespace tau
69 } // namespace reco
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:804
void countMatches(const reco::Muon &muon, std::vector< int > &numMatchesDT, std::vector< int > &numMatchesCSC, std::vector< int > &numMatchesRPC)
assert(be >=bs)
static bool muonCSCHitFilter(uint16_t pattern)
Definition: HitPattern.h:645
static uint32_t getHitType(uint16_t pattern)
Definition: HitPattern.h:747
Long64_t numEntries(TFile *hdl, std::string const &trname)
Definition: CollUtil.cc:50
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:537
static bool muonHitFilter(uint16_t pattern)
Definition: HitPattern.h:683
static constexpr int RPC
Definition: MuonSubdetId.h:13
static bool muonDTHitFilter(uint16_t pattern)
Definition: HitPattern.h:636
fixed size matrix
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:755
std::string format_vint(const std::vector< int > &vi)
static constexpr int DT
Definition: MuonSubdetId.h:11
static bool muonRPCHitFilter(uint16_t pattern)
Definition: HitPattern.h:654
static constexpr int CSC
Definition: MuonSubdetId.h:12
void countHits(const reco::Muon &muon, std::vector< int > &numHitsDT, std::vector< int > &numHitsCSC, std::vector< int > &numHitsRPC)