CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
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:639
static uint32_t getHitType(uint16_t pattern)
Definition: HitPattern.h:741
Long64_t numEntries(TFile *hdl, std::string const &trname)
Definition: CollUtil.cc:50
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:798
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:48
static bool muonHitFilter(uint16_t pattern)
Definition: HitPattern.h:677
static constexpr int RPC
Definition: MuonSubdetId.h:13
std::vector< MuonChamberMatch > & matches()
get muon matching information
Definition: Muon.h:145
static bool muonDTHitFilter(uint16_t pattern)
Definition: HitPattern.h:630
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:749
std::string format_vint(const std::vector< int > &vi)
static constexpr int DT
Definition: MuonSubdetId.h:11
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:531
static bool muonRPCHitFilter(uint16_t pattern)
Definition: HitPattern.h:648
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)