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  //total digis, no match required
62  int totalComparators(unsigned int) const;
63  int totalStrips(unsigned int) const;
64  int totalWires(unsigned int) const;
65 
66  // #layers with hits
67  int nLayersWithComparatorInChamber(unsigned int) const;
68  int nLayersWithStripInChamber(unsigned int) const;
69  int nLayersWithWireInChamber(unsigned int) const;
70 
71  // How many CSC chambers with minimum number of layer with digis did this simtrack get?
72  int nCoincidenceComparatorChambers(int min_n_layers = 4) const;
73  int nCoincidenceStripChambers(int min_n_layers = 4) const;
74  int nCoincidenceWireChambers(int min_n_layers = 4) const;
75 
76  std::set<int> comparatorsInDetId(unsigned int) const;
77  std::set<int> stripsInDetId(unsigned int) const;
78  std::set<int> wiregroupsInDetId(unsigned int) const;
79 
80  // A non-zero max_gap_to_fill parameter would insert extra half-strips or wiregroups
81  // so that gaps of that size or smaller would be filled.
82  // E.g., if max_gap_to_fill = 1, and there are digis with strips 4 and 6 in a chamber,
83  // the resulting set of digis would be 4,5,6
84  std::set<int> comparatorsInChamber(unsigned int, int max_gap_to_fill = 0) const;
85  std::set<int> stripsInChamber(unsigned int, int max_gap_to_fill = 0) const;
86  std::set<int> wiregroupsInChamber(unsigned int, int max_gap_to_fill = 0) const;
87 
88  std::shared_ptr<CSCSimHitMatcher> muonSimHitMatcher() const { return muonSimHitMatcher_; }
89 
90 private:
91  // match simtracks to digis
95 
96  void clear();
97 
98  template <class T>
99  std::set<unsigned int> selectDetIds(const T& digis, int csc_type) const;
100 
104 
108 
109  std::shared_ptr<CSCSimHitMatcher> muonSimHitMatcher_;
110 
114 
118 
122 
123  std::map<unsigned int, CSCComparatorDigiContainer> detid_to_comparators_;
124  std::map<unsigned int, CSCComparatorDigiContainer> chamber_to_comparators_;
125  std::map<unsigned int, int> detid_to_totalcomparators_;
126 
127  std::map<unsigned int, CSCStripDigiContainer> detid_to_strips_;
128  std::map<unsigned int, CSCStripDigiContainer> chamber_to_strips_;
129  std::map<unsigned int, int> detid_to_totalstrips_;
130 
131  std::map<unsigned int, CSCWireDigiContainer> detid_to_wires_;
132  std::map<unsigned int, CSCWireDigiContainer> chamber_to_wires_;
133  std::map<unsigned int, int> detid_to_totalwires_;
134 
138 };
139 
140 template <class T>
141 std::set<unsigned int> CSCDigiMatcher::selectDetIds(const T& digis, int csc_type) const {
142  std::set<unsigned int> result;
143  for (const auto& p : digis) {
144  const auto& id = p.first;
145  if (csc_type > 0) {
146  CSCDetId detId(id);
147  if (MuonHitHelper::toCSCType(detId.station(), detId.ring()) != csc_type)
148  continue;
149  }
150  result.insert(p.first);
151  }
152  return result;
153 }
154 
155 #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::map< unsigned int, int > detid_to_totalcomparators_
int totalWires(unsigned int) const
int totalComparators(unsigned int) const
std::shared_ptr< CSCSimHitMatcher > muonSimHitMatcher() const
std::set< int > stripsInDetId(unsigned int) const
edm::Handle< CSCComparatorDigiCollection > comparatorDigisH_
std::map< unsigned int, int > detid_to_totalwires_
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_
int totalStrips(unsigned int) const
const CSCStripDigiContainer & stripDigisInChamber(unsigned int) const
std::vector< std::pair< unsigned int, CSCComparatorDigi > > CSCComparatorDigiDetIdContainer
const CSCWireDigiContainer & wireDigisInChamber(unsigned int) const
std::vector< CSCComparatorDigi > CSCComparatorDigiContainer
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::map< unsigned int, int > detid_to_totalstrips_
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
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