CMS 3D CMS Logo

CSCDigiMatcher.h
Go to the documentation of this file.
1 #ifndef Validation_MuonCSCDigis_CSCDigiMatcher_h
2 #define Validation_MuonCSCDigis_CSCDigiMatcher_h
3 
16 
17 typedef std::vector<CSCComparatorDigi> CSCComparatorDigiContainer;
18 typedef std::vector<CSCStripDigi> CSCStripDigiContainer;
19 typedef std::vector<CSCWireDigi> CSCWireDigiContainer;
20 
21 typedef std::vector<std::pair<unsigned int, CSCComparatorDigi> > CSCComparatorDigiDetIdContainer;
22 typedef std::vector<std::pair<unsigned int, CSCStripDigi> > CSCStripDigiDetIdContainer;
23 typedef std::vector<std::pair<unsigned int, CSCWireDigi> > CSCWireDigiDetIdContainer;
24 
26 public:
27  // constructor
29 
30  // destructor
32 
33  // initialize the event
34  void init(const edm::Event& e, const edm::EventSetup& eventSetup);
35 
36  // do the matching
37  void match(const SimTrack& t, const SimVertex& v);
38 
39  // layer detIds with digis
40  std::set<unsigned int> detIdsComparator(int csc_type = MuonHitHelper::CSC_ALL) const;
41  std::set<unsigned int> detIdsStrip(int csc_type = MuonHitHelper::CSC_ALL) const;
42  std::set<unsigned int> detIdsWire(int csc_type = MuonHitHelper::CSC_ALL) const;
43 
44  // chamber detIds with digis
45  std::set<unsigned int> chamberIdsComparator(int csc_type = MuonHitHelper::CSC_ALL) const;
46  std::set<unsigned int> chamberIdsStrip(int csc_type = MuonHitHelper::CSC_ALL) const;
47  std::set<unsigned int> chamberIdsWire(int csc_type = MuonHitHelper::CSC_ALL) const;
48 
49  // CSC strip digis from a particular layer or chamber
50  const CSCComparatorDigiContainer& comparatorDigisInDetId(unsigned int) const;
51  const CSCComparatorDigiContainer& comparatorDigisInChamber(unsigned int) const;
52 
53  // CSC strip digis from a particular layer or chamber
54  const CSCStripDigiContainer& stripDigisInDetId(unsigned int) const;
55  const CSCStripDigiContainer& stripDigisInChamber(unsigned int) const;
56 
57  // CSC wire digis from a particular layer or chamber
58  const CSCWireDigiContainer& wireDigisInDetId(unsigned int) const;
59  const CSCWireDigiContainer& wireDigisInChamber(unsigned int) const;
60 
61  // #layers with hits
62  int nLayersWithComparatorInChamber(unsigned int) const;
63  int nLayersWithStripInChamber(unsigned int) const;
64  int nLayersWithWireInChamber(unsigned int) const;
65 
66  // How many CSC chambers with minimum number of layer with digis did this simtrack get?
67  int nCoincidenceComparatorChambers(int min_n_layers = 4) const;
68  int nCoincidenceStripChambers(int min_n_layers = 4) const;
69  int nCoincidenceWireChambers(int min_n_layers = 4) const;
70 
71  std::set<int> comparatorsInDetId(unsigned int) const;
72  std::set<int> stripsInDetId(unsigned int) const;
73  std::set<int> wiregroupsInDetId(unsigned int) const;
74 
75  // A non-zero max_gap_to_fill parameter would insert extra half-strips or wiregroups
76  // so that gaps of that size or smaller would be filled.
77  // E.g., if max_gap_to_fill = 1, and there are digis with strips 4 and 6 in a chamber,
78  // the resulting set of digis would be 4,5,6
79  std::set<int> comparatorsInChamber(unsigned int, int max_gap_to_fill = 0) const;
80  std::set<int> stripsInChamber(unsigned int, int max_gap_to_fill = 0) const;
81  std::set<int> wiregroupsInChamber(unsigned int, int max_gap_to_fill = 0) const;
82 
83  std::shared_ptr<CSCSimHitMatcher> muonSimHitMatcher() const { return muonSimHitMatcher_; }
84 
85 private:
86  // match simtracks to digis
90 
91  void clear();
92 
93  template <class T>
94  std::set<unsigned int> selectDetIds(const T& digis, int csc_type) const;
95 
99 
103 
104  std::shared_ptr<CSCSimHitMatcher> muonSimHitMatcher_;
105 
109 
113 
117 
118  std::map<unsigned int, CSCComparatorDigiContainer> detid_to_comparators_;
119  std::map<unsigned int, CSCComparatorDigiContainer> chamber_to_comparators_;
120 
121  std::map<unsigned int, CSCStripDigiContainer> detid_to_strips_;
122  std::map<unsigned int, CSCStripDigiContainer> chamber_to_strips_;
123 
124  std::map<unsigned int, CSCWireDigiContainer> detid_to_wires_;
125  std::map<unsigned int, CSCWireDigiContainer> chamber_to_wires_;
126 
130 };
131 
132 template <class T>
133 std::set<unsigned int> CSCDigiMatcher::selectDetIds(const T& digis, int csc_type) const {
134  std::set<unsigned int> result;
135  for (const auto& p : digis) {
136  const auto& id = p.first;
137  if (csc_type > 0) {
138  CSCDetId detId(id);
139  if (MuonHitHelper::toCSCType(detId.station(), detId.ring()) != csc_type)
140  continue;
141  }
142  result.insert(p.first);
143  }
144  return result;
145 }
146 
147 #endif
std::shared_ptr< CSCSimHitMatcher > muonSimHitMatcher_
static int toCSCType(int st, int ri)
std::set< int > comparatorsInDetId(unsigned int) const
CSCStripDigiContainer no_strips_
int nCoincidenceWireChambers(int min_n_layers=4) const
std::map< unsigned int, CSCWireDigiContainer > detid_to_wires_
CSCComparatorDigiContainer no_comparators_
void match(const SimTrack &t, const SimVertex &v)
do the matching
std::set< unsigned int > detIdsStrip(int csc_type=MuonHitHelper::CSC_ALL) const
std::shared_ptr< CSCSimHitMatcher > muonSimHitMatcher() const
std::set< int > stripsInDetId(unsigned int) const
edm::Handle< CSCComparatorDigiCollection > comparatorDigisH_
std::vector< CSCStripDigi > CSCStripDigiContainer
std::map< unsigned int, CSCComparatorDigiContainer > chamber_to_comparators_
void matchStripsToSimTrack(const CSCStripDigiCollection &strips)
std::set< int > wiregroupsInDetId(unsigned int) const
void matchWiresToSimTrack(const CSCWireDigiCollection &wires)
std::set< int > stripsInChamber(unsigned int, int max_gap_to_fill=0) const
int nLayersWithStripInChamber(unsigned int) const
std::map< unsigned int, CSCWireDigiContainer > chamber_to_wires_
int nCoincidenceStripChambers(int min_n_layers=4) const
std::map< unsigned int, CSCComparatorDigiContainer > detid_to_comparators_
CSCDigiMatcher(edm::ParameterSet const &iPS, edm::ConsumesCollector &&iC)
const CSCComparatorDigiContainer & comparatorDigisInDetId(unsigned int) const
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
std::map< unsigned int, CSCStripDigiContainer > chamber_to_strips_
const CSCStripDigiContainer & stripDigisInChamber(unsigned int) const
std::vector< std::pair< unsigned int, CSCComparatorDigi > > CSCComparatorDigiDetIdContainer
const CSCWireDigiContainer & wireDigisInChamber(unsigned int) const
std::vector< CSCComparatorDigi > CSCComparatorDigiContainer
int station() const
Definition: CSCDetId.h:79
std::vector< CSCWireDigi > CSCWireDigiContainer
std::vector< std::pair< unsigned int, CSCWireDigi > > CSCWireDigiDetIdContainer
edm::EDGetTokenT< CSCWireDigiCollection > wireDigiInput_
edm::Handle< CSCWireDigiCollection > wireDigisH_
void matchComparatorsToSimTrack(const CSCComparatorDigiCollection &comparators)
std::set< unsigned int > chamberIdsComparator(int csc_type=MuonHitHelper::CSC_ALL) const
std::set< unsigned int > chamberIdsStrip(int csc_type=MuonHitHelper::CSC_ALL) const
edm::Handle< CSCStripDigiCollection > stripDigisH_
std::vector< std::pair< unsigned int, CSCStripDigi > > CSCStripDigiDetIdContainer
std::map< unsigned int, CSCStripDigiContainer > detid_to_strips_
const CSCWireDigiContainer & wireDigisInDetId(unsigned int) const
std::set< unsigned int > detIdsComparator(int csc_type=MuonHitHelper::CSC_ALL) const
std::set< unsigned int > chamberIdsWire(int csc_type=MuonHitHelper::CSC_ALL) const
std::set< unsigned int > detIdsWire(int csc_type=MuonHitHelper::CSC_ALL) const
const CSCStripDigiContainer & stripDigisInDetId(unsigned int) const
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
Definition: DigiDM_cff.py:32
int nLayersWithWireInChamber(unsigned int) const
std::set< unsigned int > selectDetIds(const T &digis, int csc_type) const
int ring() const
Definition: CSCDetId.h:68
const CSCComparatorDigiContainer & comparatorDigisInChamber(unsigned int) const
long double T
CSCWireDigiContainer no_wires_
std::set< int > comparatorsInChamber(unsigned int, int max_gap_to_fill=0) const
std::set< int > wiregroupsInChamber(unsigned int, int max_gap_to_fill=0) const
int nLayersWithComparatorInChamber(unsigned int) const
edm::EDGetTokenT< CSCComparatorDigiCollection > comparatorDigiInput_
edm::EDGetTokenT< CSCStripDigiCollection > stripDigiInput_
int nCoincidenceComparatorChambers(int min_n_layers=4) const