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 }
ME0SimHitMatcher::simHitsMeanStrip
float simHitsMeanStrip(const edm::PSimHitContainer &sim_hits) const
Definition: ME0SimHitMatcher.cc:137
ME0SimHitMatcher::init
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
Definition: ME0SimHitMatcher.cc:17
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
SimVertex
Definition: SimVertex.h:5
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
ME0SimHitMatcher::superChamberIdsCoincidences
std::set< unsigned int > superChamberIdsCoincidences(int min_n_layers=4) const
Definition: ME0SimHitMatcher.cc:122
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
MuonSimHitMatcher::geometry_
const TrackingGeometry * geometry_
Definition: MuonSimHitMatcher.h:84
ME0SimHitMatcher::ME0SimHitMatcher
ME0SimHitMatcher(const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
Definition: ME0SimHitMatcher.cc:5
MuonSimHitMatcher::verbose_
bool verbose_
Definition: MuonSimHitMatcher.h:81
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ME0Geometry
Definition: ME0Geometry.h:12
MuonSimHitMatcher::detid_to_hits_
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
Definition: MuonSimHitMatcher.h:106
MuonSimHitMatcher::simHitsMeanPosition
GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer &sim_hits) const
Definition: MuonSimHitMatcher.cc:99
ME0SimHitMatcher::nCoincidenceChambers
int nCoincidenceChambers(int min_n_layers=4) const
Definition: ME0SimHitMatcher.cc:133
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
ME0SimHitMatcher::superChamberIds
std::set< unsigned int > superChamberIds() const
Definition: ME0SimHitMatcher.cc:99
MuonSimHitMatcher::simHits_
edm::PSimHitContainer simHits_
Definition: MuonSimHitMatcher.h:97
none
Definition: EcalBoundaryInfoCalculator.h:24
ME0SimHitMatcher::hitStripsInDetId
std::set< int > hitStripsInDetId(unsigned int, int margin_n_strips=0) const
Definition: ME0SimHitMatcher.cc:156
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
ME0SimHitMatcher::hitPartitions
std::set< int > hitPartitions() const
Definition: ME0SimHitMatcher.cc:182
alignCSCRings.s
s
Definition: alignCSCRings.py:92
ME0SimHitMatcher::match
void match(const SimTrack &t, const SimVertex &v)
do the matching
Definition: ME0SimHitMatcher.cc:23
h
ME0DetId::roll
int roll() const
Definition: ME0DetId.h:48
ME0SimHitMatcher::chamberIds
std::set< unsigned int > chamberIds() const
Definition: ME0SimHitMatcher.cc:92
MuonSimHitMatcher::simHitPSet_
edm::ParameterSet simHitPSet_
Definition: MuonSimHitMatcher.h:109
ME0SimHitMatcher::hitsInSuperChamber
const edm::PSimHitContainer & hitsInSuperChamber(unsigned int) const
Definition: ME0SimHitMatcher.cc:106
Point3DBase< float, LocalTag >
MuonSimHitMatcher::track_ids_
std::vector< unsigned > track_ids_
Definition: MuonSimHitMatcher.h:99
MuonSimHitMatcher::no_hits_
edm::PSimHitContainer no_hits_
Definition: MuonSimHitMatcher.h:102
ME0SimHitMatcher::superChamber_to_hits_
std::map< unsigned int, edm::PSimHitContainer > superChamber_to_hits_
Definition: ME0SimHitMatcher.h:75
ME0SimHitMatcher::geomToken_
edm::ESGetToken< ME0Geometry, MuonGeometryRecord > geomToken_
Definition: ME0SimHitMatcher.h:67
MuonSimHitMatcher::discardEleHits_
bool discardEleHits_
Definition: MuonSimHitMatcher.h:80
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
HLTBitAnalyser_cfi.simhits
simhits
SIM objects.
Definition: HLTBitAnalyser_cfi.py:21
edm::ParameterSet
Definition: ParameterSet.h:47
ME0SimHitMatcher::hitPadsInDetId
std::set< int > hitPadsInDetId(unsigned int) const
Definition: ME0SimHitMatcher.cc:175
MuonSimHitMatcher
Definition: MuonSimHitMatcher.h:32
MuonSimHitMatcher::match
void match(const SimTrack &t, const SimVertex &v)
do the matching
Definition: MuonSimHitMatcher.cc:26
ME0SimHitMatcher.h
iEvent
int iEvent
Definition: GenABIO.cc:224
MuonSimHitMatcher::chamber_to_hits_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
Definition: MuonSimHitMatcher.h:107
edm::EventSetup
Definition: EventSetup.h:58
ME0DetId
Definition: ME0DetId.h:16
MuonSimHitMatcher::simHitInput_
edm::EDGetTokenT< edm::PSimHitContainer > simHitInput_
Definition: MuonSimHitMatcher.h:88
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
MuonSimHitMatcher::hitsInDetId
const edm::PSimHitContainer & hitsInDetId(unsigned int) const
Definition: MuonSimHitMatcher.cc:87
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
SimTrack
Definition: SimTrack.h:9
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
ME0SimHitMatcher::matchSimHitsToSimTrack
void matchSimHitsToSimTrack()
Definition: ME0SimHitMatcher.cc:49
ME0SimHitMatcher::nLayersWithHitsInSuperChamber
int nLayersWithHitsInSuperChamber(unsigned int) const
Definition: ME0SimHitMatcher.cc:112
ME0SimHitMatcher::detids_to_pads_
std::map< unsigned int, std::set< int > > detids_to_pads_
Definition: ME0SimHitMatcher.h:70
MuonSimHitMatcher::simMuOnly_
bool simMuOnly_
Definition: MuonSimHitMatcher.h:79
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MuonSimHitMatcher::hitsInChamber
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
Definition: MuonSimHitMatcher.cc:93
ztail.d
d
Definition: ztail.py:151
mps_fire.result
result
Definition: mps_fire.py:311
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
ME0SimHitMatcher::nPadsWithHits
int nPadsWithHits() const
Definition: ME0SimHitMatcher.cc:193
MuonSimHitMatcher::hits_
edm::PSimHitContainer hits_
Definition: MuonSimHitMatcher.h:105
edm::Event
Definition: Event.h:73
EgammaValidation_cff.pdgid
pdgid
Definition: EgammaValidation_cff.py:30
MuonSimHitMatcher::init
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
Definition: MuonSimHitMatcher.cc:17
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
edm::InputTag
Definition: InputTag.h:15
DigiDM_cff.strips
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers....
Definition: DigiDM_cff.py:32
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
ME0SimHitMatcher::detIds
std::set< unsigned int > detIds() const
Definition: ME0SimHitMatcher.cc:85