CMS 3D CMS Logo

ME0SimHitMatcher.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 
6  : MuonSimHitMatcher(ps, std::move(iC)) {
7  simHitPSet_ = ps.getParameterSet("me0SimHit");
8  verbose_ = simHitPSet_.getParameter<int>("verbose");
9  simMuOnly_ = simHitPSet_.getParameter<bool>("simMuOnly");
10  discardEleHits_ = simHitPSet_.getParameter<bool>("discardEleHits");
11 
13  geomToken_ = iC.esConsumes<ME0Geometry, MuonGeometryRecord>();
14 }
15 
18  geometry_ = &iSetup.getData(geomToken_);
20 }
21 
24  // instantiates the track ids and simhits
26 
28 
29  if (verbose_) {
30  edm::LogInfo("ME0SimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedME0SimHits " << hits_.size();
31  edm::LogInfo("ME0SimHitMatcher") << "detids ME0 " << detIds().size();
32 
33  const auto& me0_ch_ids = detIds();
34  for (const auto& id : me0_ch_ids) {
35  const auto& me0_simhits = MuonSimHitMatcher::hitsInChamber(id);
36  const auto& me0_simhits_gp = simHitsMeanPosition(me0_simhits);
37  edm::LogInfo("ME0SimHitMatcher") << "me0chid " << ME0DetId(id) << ": nHits " << me0_simhits.size() << " phi "
38  << me0_simhits_gp.phi() << " nCh " << chamber_to_hits_[id].size();
39  const auto& strips = hitStripsInDetId(id);
40  edm::LogInfo("ME0SimHitMatcher") << "nStrip " << strips.size();
41  edm::LogInfo("ME0SimHitMatcher") << "strips : ";
42  for (const auto& p : strips) {
43  edm::LogInfo("ME0SimHitMatcher") << p;
44  }
45  }
46  }
47 }
48 
50  for (const auto& track_id : track_ids_) {
51  for (const auto& h : simHits_) {
52  if (h.trackId() != track_id)
53  continue;
54  int pdgid = h.particleType();
55  if (simMuOnly_ && std::abs(pdgid) != 13)
56  continue;
57  // discard electron hits in the ME0 chambers
58  if (discardEleHits_ && std::abs(pdgid) == 11)
59  continue;
60 
61  const ME0DetId& layer_id(h.detUnitId());
62  detid_to_hits_[h.detUnitId()].push_back(h);
63  hits_.push_back(h);
64  chamber_to_hits_[layer_id.layerId().rawId()].push_back(h);
65  superChamber_to_hits_[layer_id.chamberId().rawId()].push_back(h);
66  }
67  }
68 
69  // find pads with hits
70  const auto& detids = detIds();
71  for (const auto& d : detids) {
72  ME0DetId id(d);
73  const auto& hits = hitsInDetId(d);
74  const auto& roll = dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id);
75  // int max_npads = roll->npads();
76  set<int> pads;
77  for (const auto& h : hits) {
78  const LocalPoint& lp = h.entryPoint();
79  pads.insert(1 + static_cast<int>(roll->padTopology().channel(lp)));
80  }
81  detids_to_pads_[d] = pads;
82  }
83 }
84 
85 std::set<unsigned int> ME0SimHitMatcher::detIds() const {
86  std::set<unsigned int> result;
87  for (const auto& p : detid_to_hits_)
88  result.insert(p.first);
89  return result;
90 }
91 
92 std::set<unsigned int> ME0SimHitMatcher::chamberIds() const {
93  std::set<unsigned int> result;
94  for (const auto& p : chamber_to_hits_)
95  result.insert(p.first);
96  return result;
97 }
98 
99 std::set<unsigned int> ME0SimHitMatcher::superChamberIds() const {
100  std::set<unsigned int> result;
101  for (const auto& p : superChamber_to_hits_)
102  result.insert(p.first);
103  return result;
104 }
105 
107  if (superChamber_to_hits_.find(detid) == superChamber_to_hits_.end())
108  return no_hits_;
109  return superChamber_to_hits_.at(detid);
110 }
111 
112 int ME0SimHitMatcher::nLayersWithHitsInSuperChamber(unsigned int detid) const {
113  set<int> layers_with_hits;
114  const auto& hits = hitsInSuperChamber(detid);
115  for (const auto& h : hits) {
116  const ME0DetId& idd(h.detUnitId());
117  layers_with_hits.insert(idd.layer());
118  }
119  return layers_with_hits.size();
120 }
121 
122 std::set<unsigned int> ME0SimHitMatcher::superChamberIdsCoincidences(int min_n_layers) const {
123  set<unsigned int> result;
124  // loop over the super chamber Ids
125  for (const auto& p : superChamberIds()) {
126  if (nLayersWithHitsInSuperChamber(p) >= min_n_layers) {
127  result.insert(p);
128  }
129  }
130  return result;
131 }
132 
133 int ME0SimHitMatcher::nCoincidenceChambers(int min_n_layers) const {
134  return superChamberIdsCoincidences(min_n_layers).size();
135 }
136 
138  if (sim_hits.empty())
139  return -1.f;
140 
141  float sums = 0.f;
142  size_t n = 0;
143  for (const auto& h : sim_hits) {
144  const LocalPoint& lp = h.entryPoint();
145  float s;
146  const auto& d = h.detUnitId();
147  s = dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(d)->strip(lp);
148  sums += s;
149  ++n;
150  }
151  if (n == 0)
152  return -1.f;
153  return sums / n;
154 }
155 
156 std::set<int> ME0SimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const {
157  set<int> result;
158  const auto& simhits = hitsInDetId(detid);
159  ME0DetId id(detid);
160  int max_nstrips = dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id)->nstrips();
161  for (const auto& h : simhits) {
162  const LocalPoint& lp = h.entryPoint();
163  int central_strip =
164  1 + static_cast<int>(dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id)->topology().channel(lp));
165  int smin = central_strip - margin_n_strips;
166  smin = (smin > 0) ? smin : 1;
167  int smax = central_strip + margin_n_strips;
168  smax = (smax <= max_nstrips) ? smax : max_nstrips;
169  for (int ss = smin; ss <= smax; ++ss)
170  result.insert(ss);
171  }
172  return result;
173 }
174 
175 std::set<int> ME0SimHitMatcher::hitPadsInDetId(unsigned int detid) const {
176  set<int> none;
177  if (detids_to_pads_.find(detid) == detids_to_pads_.end())
178  return none;
179  return detids_to_pads_.at(detid);
180 }
181 
182 std::set<int> ME0SimHitMatcher::hitPartitions() const {
183  std::set<int> result;
184 
185  const auto& detids = detIds();
186  for (const auto& id : detids) {
187  ME0DetId idd(id);
188  result.insert(idd.roll());
189  }
190  return result;
191 }
192 
194  int result = 0;
195  const auto& pad_ids = detIds();
196  for (const auto& id : pad_ids) {
197  result += hitPadsInDetId(id).size();
198  }
199  return result;
200 }
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const TrackingGeometry * geometry_
edm::PSimHitContainer hits_
edm::ESGetToken< ME0Geometry, MuonGeometryRecord > geomToken_
std::set< int > hitPadsInDetId(unsigned int) const
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer &sim_hits) const
ParameterSet const & getParameterSet(std::string const &) const
std::map< unsigned int, std::set< int > > detids_to_pads_
std::vector< unsigned > track_ids_
int nLayersWithHitsInSuperChamber(unsigned int) const
int nPadsWithHits() const
int iEvent
Definition: GenABIO.cc:224
std::set< unsigned int > detIds() const
edm::PSimHitContainer simHits_
float simHitsMeanStrip(const edm::PSimHitContainer &sim_hits) const
edm::ParameterSet simHitPSet_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
std::set< unsigned int > superChamberIdsCoincidences(int min_n_layers=4) const
bool getData(T &iHolder) const
Definition: EventSetup.h:122
d
Definition: ztail.py:151
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
Log< level::Info, false > LogInfo
edm::PSimHitContainer no_hits_
ME0SimHitMatcher(const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
void match(const SimTrack &t, const SimVertex &v)
do the matching
std::set< unsigned int > superChamberIds() const
edm::EDGetTokenT< edm::PSimHitContainer > simHitInput_
int nCoincidenceChambers(int min_n_layers=4) const
std::set< int > hitPartitions() const
const edm::PSimHitContainer & hitsInDetId(unsigned int) const
void match(const SimTrack &t, const SimVertex &v)
do the matching
int roll() const
Definition: ME0DetId.h:48
std::set< unsigned int > chamberIds() const
std::set< int > hitStripsInDetId(unsigned int, int margin_n_strips=0) 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
std::vector< PSimHit > PSimHitContainer
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
const edm::PSimHitContainer & hitsInSuperChamber(unsigned int) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
def move(src, dest)
Definition: eostools.py:511
std::map< unsigned int, edm::PSimHitContainer > superChamber_to_hits_