CMS 3D CMS Logo

GEMDigiMatcher.h
Go to the documentation of this file.
1 #ifndef Validation_MuonGEMDigis_GEMDigiMatcher_h
2 #define Validation_MuonGEMDigis_GEMDigiMatcher_h
3 
19 
20 #include <vector>
21 #include <map>
22 #include <set>
23 #include <unordered_set>
24 
25 typedef std::vector<GEMDigiSimLink> GEMDigiSimLinkContainer;
26 typedef std::vector<GEMDigi> GEMDigiContainer;
27 typedef std::vector<GEMPadDigi> GEMPadDigiContainer;
28 typedef std::vector<GEMPadDigiCluster> GEMPadDigiClusterContainer;
29 typedef std::vector<GEMCoPadDigi> GEMCoPadDigiContainer;
30 
32 public:
33  // constructor
35 
36  // destructor
38 
39  // initialize the event
40  void init(const edm::Event& e, const edm::EventSetup& eventSetup);
41 
42  // do the matching
43  void match(const SimTrack& t, const SimVertex& v);
44 
45  std::set<unsigned int> detIdsSimLink(int gem_type = MuonHitHelper::GEM_ALL) const;
46 
47  // partition GEM detIds with digis
48  std::set<unsigned int> detIdsDigi(int gem_type = MuonHitHelper::GEM_ALL) const;
49  std::set<unsigned int> detIdsPad(int gem_type = MuonHitHelper::GEM_ALL) const;
50  std::set<unsigned int> detIdsCluster(int gem_type = MuonHitHelper::GEM_ALL) const;
51 
52  // chamber detIds with digis
53  std::set<unsigned int> chamberIdsDigi(int gem_type = MuonHitHelper::GEM_ALL) const;
54  std::set<unsigned int> chamberIdsPad(int gem_type = MuonHitHelper::GEM_ALL) const;
55  std::set<unsigned int> chamberIdsCluster(int gem_type = MuonHitHelper::GEM_ALL) const;
56 
57  // superchamber detIds with digis
58  std::set<unsigned int> superChamberIdsDigi(int gem_type = MuonHitHelper::GEM_ALL) const;
59  std::set<unsigned int> superChamberIdsPad(int gem_type = MuonHitHelper::GEM_ALL) const;
60  std::set<unsigned int> superChamberIdsCluster(int gem_type = MuonHitHelper::GEM_ALL) const;
61  std::set<unsigned int> superChamberIdsCoPad(int gem_type = MuonHitHelper::GEM_ALL) const;
62 
63  const GEMDigiSimLinkContainer& simLinksInDetId(unsigned int) const;
64 
65  // GEM digis from a particular partition, chamber or superchamber
66  const GEMDigiContainer& digisInDetId(unsigned int) const;
67  const GEMDigiContainer& digisInChamber(unsigned int) const;
68  const GEMDigiContainer& digisInSuperChamber(unsigned int) const;
69 
70  // GEM pads from a particular partition, chamber or superchamber
71  const GEMPadDigiContainer& padsInDetId(unsigned int) const;
72  const GEMPadDigiContainer& padsInChamber(unsigned int) const;
73  const GEMPadDigiContainer& padsInSuperChamber(unsigned int) const;
74 
75  // GEM clusters from a particular partition, chamber or superchamber
76  const GEMPadDigiClusterContainer& clustersInDetId(unsigned int) const;
77  const GEMPadDigiClusterContainer& clustersInChamber(unsigned int) const;
78  const GEMPadDigiClusterContainer& clustersInSuperChamber(unsigned int) const;
79 
80  // GEM co-pads from a particular partition or superchamber
81  const GEMCoPadDigiContainer& coPadsInSuperChamber(unsigned int) const;
82 
83  const std::map<unsigned int, GEMPadDigiContainer> allPads() const { return detid_to_pads_; }
84 
85  // #layers with digis from this simtrack
86  int nLayersWithDigisInSuperChamber(unsigned int) const;
87  int nLayersWithPadsInSuperChamber(unsigned int) const;
88  int nLayersWithClustersInSuperChamber(unsigned int) const;
89 
91  int nPads() const;
92 
94  int nCoPads() const;
95 
96  std::set<int> stripNumbersInDetId(unsigned int) const;
97  std::set<int> padNumbersInDetId(unsigned int) const;
98 
99  int extrapolateHsfromGEMPad(unsigned int, int) const;
100  int extrapolateHsfromGEMStrip(unsigned int, int) const;
101 
102  // what unique partitions numbers with digis from this simtrack?
103  std::set<int> partitionNumbers() const;
104  std::set<int> partitionNumbersWithCoPads() const;
105 
106  GlobalPoint getGlobalPointDigi(unsigned int rawId, const GEMDigi& d) const;
107  GlobalPoint getGlobalPointPad(unsigned int rawId, const GEMPadDigi& tp) const;
108 
109  // get the GEMSimHitMatcher
110  std::shared_ptr<GEMSimHitMatcher> muonSimHitMatcher() { return muonSimHitMatcher_; }
111 
112 private:
113  // match digi simlink to a simtrack (based on track Id and particle type)
115  // match digi to a simtrack (based on BX and strip number)
117  // match pad to a simtrack (based on BX and pad number)
119  // match pad to a simtrack (based on BX and pad number)
120  void matchPadsInDetId(const GEMDetId& simhitId, const GEMPadDigiCollection&);
121  // match cluster to a simtrack (based on BX and pad number)
123  // match copad to a simtrack (based on previously matching pads)
125 
126  void clear();
127 
133 
139 
140  std::shared_ptr<GEMSimHitMatcher> muonSimHitMatcher_;
141 
144 
145  template <class T>
146  std::set<unsigned int> selectDetIds(const T&, int) const;
147 
150 
155 
157 
163 
165 
166  // map of raw GEMDetId to containers
167  std::map<unsigned int, GEMDigiSimLinkContainer> detid_to_simLinks_;
168 
169  std::map<unsigned int, GEMDigiContainer> detid_to_digis_;
170  std::map<unsigned int, GEMDigiContainer> chamber_to_digis_;
171  std::map<unsigned int, GEMDigiContainer> superchamber_to_digis_;
172 
173  std::map<unsigned int, GEMPadDigiContainer> detid_to_pads_;
174  std::map<unsigned int, GEMPadDigiContainer> chamber_to_pads_;
175  std::map<unsigned int, GEMPadDigiContainer> superchamber_to_pads_;
176 
177  std::map<unsigned int, GEMPadDigiClusterContainer> detid_to_clusters_;
178  std::map<unsigned int, GEMPadDigiClusterContainer> chamber_to_clusters_;
179  std::map<unsigned int, GEMPadDigiClusterContainer> superchamber_to_clusters_;
180 
181  std::map<unsigned int, GEMCoPadDigiContainer> superchamber_to_copads_;
182 
188 };
189 
190 template <class T>
191 std::set<unsigned int> GEMDigiMatcher::selectDetIds(const T& digis, int gem_type) const {
192  std::set<unsigned int> result;
193  for (const auto& p : digis) {
194  const auto& id = p.first;
195  if (gem_type > 0) {
196  GEMDetId detId(id);
197  if (MuonHitHelper::toGEMType(detId.station(), detId.ring()) != gem_type)
198  continue;
199  }
200  result.insert(p.first);
201  }
202  return result;
203 }
204 
205 #endif
std::map< unsigned int, GEMDigiSimLinkContainer > detid_to_simLinks_
std::set< unsigned int > chamberIdsPad(int gem_type=MuonHitHelper::GEM_ALL) const
void matchCoPadsToSimTrack(const GEMCoPadDigiCollection &)
std::set< int > stripNumbersInDetId(unsigned int) const
std::vector< GEMCoPadDigi > GEMCoPadDigiContainer
std::map< unsigned int, GEMDigiContainer > detid_to_digis_
std::shared_ptr< GEMSimHitMatcher > muonSimHitMatcher_
void match(const SimTrack &t, const SimVertex &v)
do the matching
std::map< unsigned int, GEMDigiContainer > chamber_to_digis_
int nLayersWithPadsInSuperChamber(unsigned int) const
std::set< unsigned int > detIdsCluster(int gem_type=MuonHitHelper::GEM_ALL) const
std::set< unsigned int > superChamberIdsCoPad(int gem_type=MuonHitHelper::GEM_ALL) const
GlobalPoint getGlobalPointPad(unsigned int rawId, const GEMPadDigi &tp) const
std::map< unsigned int, GEMPadDigiClusterContainer > detid_to_clusters_
edm::Handle< GEMCoPadDigiCollection > gemCoPadsH_
std::vector< GEMDigiSimLink > GEMDigiSimLinkContainer
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
std::set< unsigned int > superChamberIdsDigi(int gem_type=MuonHitHelper::GEM_ALL) const
const GEMPadDigiContainer & padsInChamber(unsigned int) const
edm::EDGetTokenT< GEMCoPadDigiCollection > gemCoPadToken_
void matchPadsToSimTrack(const GEMPadDigiCollection &)
int nLayersWithClustersInSuperChamber(unsigned int) const
GEMDigiMatcher(edm::ParameterSet const &iPS, edm::ConsumesCollector &&iC)
int nCoPads() const
How many coincidence pads in GEM did this simtrack get in total?
int nLayersWithDigisInSuperChamber(unsigned int) const
std::set< unsigned int > detIdsDigi(int gem_type=MuonHitHelper::GEM_ALL) const
GlobalPoint getGlobalPointDigi(unsigned int rawId, const GEMDigi &d) const
const GEMPadDigiContainer & padsInSuperChamber(unsigned int) const
void matchClustersToSimTrack(const GEMPadDigiClusterCollection &)
std::set< int > partitionNumbersWithCoPads() const
GEMDigiContainer no_gem_digis_
static int toGEMType(int st, int ri)
const GEMCoPadDigiContainer & coPadsInSuperChamber(unsigned int) const
std::set< unsigned int > selectDetIds(const T &, int) const
edm::EDGetTokenT< edm::DetSetVector< GEMDigiSimLink > > gemSimLinkToken_
std::set< unsigned int > detIdsPad(int gem_type=MuonHitHelper::GEM_ALL) const
edm::Handle< GEMDigiCollection > gemDigisH_
GEMCoPadDigiContainer no_gem_copads_
std::vector< GEMDigi > GEMDigiContainer
std::vector< GEMPadDigiCluster > GEMPadDigiClusterContainer
void matchDigisToSimTrack(const GEMDigiCollection &)
const GEMPadDigiClusterContainer & clustersInSuperChamber(unsigned int) const
edm::EDGetTokenT< GEMPadDigiClusterCollection > gemClusterToken_
const GEMPadDigiContainer & padsInDetId(unsigned int) const
std::map< unsigned int, GEMDigiContainer > superchamber_to_digis_
std::shared_ptr< GEMSimHitMatcher > muonSimHitMatcher()
const GEMGeometry * gemGeometry_
std::set< unsigned int > superChamberIdsCluster(int gem_type=MuonHitHelper::GEM_ALL) const
int extrapolateHsfromGEMStrip(unsigned int, int) const
std::map< unsigned int, GEMPadDigiContainer > chamber_to_pads_
const GEMDigiSimLinkContainer & simLinksInDetId(unsigned int) const
const std::map< unsigned int, GEMPadDigiContainer > allPads() const
const GEMDigiContainer & digisInSuperChamber(unsigned int) const
d
Definition: ztail.py:151
int nPads() const
How many pads in GEM did this simtrack get in total?
const GEMDigiContainer & digisInChamber(unsigned int) const
std::vector< GEMPadDigi > GEMPadDigiContainer
edm::Handle< GEMPadDigiCollection > gemPadsH_
std::set< unsigned int > chamberIdsDigi(int gem_type=MuonHitHelper::GEM_ALL) const
std::map< unsigned int, GEMPadDigiContainer > superchamber_to_pads_
std::set< unsigned int > chamberIdsCluster(int gem_type=MuonHitHelper::GEM_ALL) const
std::map< unsigned int, GEMPadDigiContainer > detid_to_pads_
std::map< unsigned int, GEMCoPadDigiContainer > superchamber_to_copads_
std::map< unsigned int, GEMPadDigiClusterContainer > superchamber_to_clusters_
void matchDigisSLToSimTrack(const edm::DetSetVector< GEMDigiSimLink > &)
edm::Handle< GEMPadDigiClusterCollection > gemClustersH_
std::set< unsigned int > detIdsSimLink(int gem_type=MuonHitHelper::GEM_ALL) const
const GEMDigiContainer & digisInDetId(unsigned int) const
std::map< unsigned int, GEMPadDigiClusterContainer > chamber_to_clusters_
GEMPadDigiClusterContainer no_gem_clusters_
GEMPadDigiContainer no_gem_pads_
void matchPadsInDetId(const GEMDetId &simhitId, const GEMPadDigiCollection &)
std::set< int > padNumbersInDetId(unsigned int) const
const GEMPadDigiClusterContainer & clustersInChamber(unsigned int) const
std::set< int > partitionNumbers() const
edm::EDGetTokenT< GEMDigiCollection > gemDigiToken_
std::set< unsigned int > superChamberIdsPad(int gem_type=MuonHitHelper::GEM_ALL) const
long double T
const GEMPadDigiClusterContainer & clustersInDetId(unsigned int) const
int extrapolateHsfromGEMPad(unsigned int, int) const
GEMDigiSimLinkContainer no_gem_simLinks_
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
edm::Handle< edm::DetSetVector< GEMDigiSimLink > > gemDigisSLH_
edm::EDGetTokenT< GEMPadDigiCollection > gemPadToken_