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 }
14 
18  if (me0_geom_.isValid()) {
19  geometry_ = &*me0_geom_;
20  } else {
21  hasGeometry_ = false;
22  edm::LogWarning("ME0SimHitMatcher") << "+++ Info: ME0 geometry is unavailable. +++\n";
23  }
25 }
26 
29  // instantiates the track ids and simhits
31 
32  if (hasGeometry_) {
34 
35  if (verbose_) {
36  edm::LogInfo("ME0SimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedME0SimHits " << hits_.size()
37  << endl;
38  edm::LogInfo("ME0SimHitMatcher") << "detids ME0 " << detIds().size() << endl;
39 
40  const auto& me0_ch_ids = detIds();
41  for (const auto& id : me0_ch_ids) {
42  const auto& me0_simhits = MuonSimHitMatcher::hitsInChamber(id);
43  const auto& me0_simhits_gp = simHitsMeanPosition(me0_simhits);
44  edm::LogInfo("ME0SimHitMatcher") << "me0chid " << ME0DetId(id) << ": nHits " << me0_simhits.size() << " phi "
45  << me0_simhits_gp.phi() << " nCh " << chamber_to_hits_[id].size() << endl;
46  const auto& strips = hitStripsInDetId(id);
47  edm::LogInfo("ME0SimHitMatcher") << "nStrip " << strips.size() << endl;
48  edm::LogInfo("ME0SimHitMatcher") << "strips : ";
49  for (const auto& p : strips) {
50  edm::LogInfo("ME0SimHitMatcher") << p;
51  }
52  }
53  }
54  }
55 }
56 
58  for (const auto& track_id : track_ids_) {
59  for (const auto& h : simHits_) {
60  if (h.trackId() != track_id)
61  continue;
62  int pdgid = h.particleType();
63  if (simMuOnly_ && std::abs(pdgid) != 13)
64  continue;
65  // discard electron hits in the ME0 chambers
66  if (discardEleHits_ && std::abs(pdgid) == 11)
67  continue;
68 
69  const ME0DetId& layer_id(h.detUnitId());
70  detid_to_hits_[h.detUnitId()].push_back(h);
71  hits_.push_back(h);
72  chamber_to_hits_[layer_id.layerId().rawId()].push_back(h);
73  superChamber_to_hits_[layer_id.chamberId().rawId()].push_back(h);
74  }
75  }
76 
77  // find pads with hits
78  const auto& detids = detIds();
79  for (const auto& d : detids) {
80  ME0DetId id(d);
81  const auto& hits = hitsInDetId(d);
82  const auto& roll = dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id);
83  // int max_npads = roll->npads();
84  set<int> pads;
85  for (const auto& h : hits) {
86  const LocalPoint& lp = h.entryPoint();
87  pads.insert(1 + static_cast<int>(roll->padTopology().channel(lp)));
88  }
89  detids_to_pads_[d] = pads;
90  }
91 }
92 
93 std::set<unsigned int> ME0SimHitMatcher::detIds() const {
94  std::set<unsigned int> result;
95  for (const auto& p : detid_to_hits_)
96  result.insert(p.first);
97  return result;
98 }
99 
100 std::set<unsigned int> ME0SimHitMatcher::chamberIds() const {
101  std::set<unsigned int> result;
102  for (const auto& p : chamber_to_hits_)
103  result.insert(p.first);
104  return result;
105 }
106 
107 std::set<unsigned int> ME0SimHitMatcher::superChamberIds() const {
108  std::set<unsigned int> result;
109  for (const auto& p : superChamber_to_hits_)
110  result.insert(p.first);
111  return result;
112 }
113 
115  if (superChamber_to_hits_.find(detid) == superChamber_to_hits_.end())
116  return no_hits_;
117  return superChamber_to_hits_.at(detid);
118 }
119 
120 int ME0SimHitMatcher::nLayersWithHitsInSuperChamber(unsigned int detid) const {
121  set<int> layers_with_hits;
122  const auto& hits = hitsInSuperChamber(detid);
123  for (const auto& h : hits) {
124  const ME0DetId& idd(h.detUnitId());
125  layers_with_hits.insert(idd.layer());
126  }
127  return layers_with_hits.size();
128 }
129 
130 std::set<unsigned int> ME0SimHitMatcher::superChamberIdsCoincidences(int min_n_layers) const {
131  set<unsigned int> result;
132  // loop over the super chamber Ids
133  for (const auto& p : superChamberIds()) {
134  if (nLayersWithHitsInSuperChamber(p) >= min_n_layers) {
135  result.insert(p);
136  }
137  }
138  return result;
139 }
140 
141 int ME0SimHitMatcher::nCoincidenceChambers(int min_n_layers) const {
142  return superChamberIdsCoincidences(min_n_layers).size();
143 }
144 
146  if (sim_hits.empty())
147  return -1.f;
148 
149  float sums = 0.f;
150  size_t n = 0;
151  for (const auto& h : sim_hits) {
152  const LocalPoint& lp = h.entryPoint();
153  float s;
154  const auto& d = h.detUnitId();
155  s = dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(d)->strip(lp);
156  sums += s;
157  ++n;
158  }
159  if (n == 0)
160  return -1.f;
161  return sums / n;
162 }
163 
164 std::set<int> ME0SimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const {
165  set<int> result;
166  const auto& simhits = hitsInDetId(detid);
167  ME0DetId id(detid);
168  int max_nstrips = dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id)->nstrips();
169  for (const auto& h : simhits) {
170  const LocalPoint& lp = h.entryPoint();
171  int central_strip =
172  1 + static_cast<int>(dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id)->topology().channel(lp));
173  int smin = central_strip - margin_n_strips;
174  smin = (smin > 0) ? smin : 1;
175  int smax = central_strip + margin_n_strips;
176  smax = (smax <= max_nstrips) ? smax : max_nstrips;
177  for (int ss = smin; ss <= smax; ++ss)
178  result.insert(ss);
179  }
180  return result;
181 }
182 
183 std::set<int> ME0SimHitMatcher::hitPadsInDetId(unsigned int detid) const {
184  set<int> none;
185  if (detids_to_pads_.find(detid) == detids_to_pads_.end())
186  return none;
187  return detids_to_pads_.at(detid);
188 }
189 
190 std::set<int> ME0SimHitMatcher::hitPartitions() const {
191  std::set<int> result;
192 
193  const auto& detids = detIds();
194  for (const auto& id : detids) {
195  ME0DetId idd(id);
196  result.insert(idd.roll());
197  }
198  return result;
199 }
200 
202  int result = 0;
203  const auto& pad_ids = detIds();
204  for (const auto& id : pad_ids) {
205  result += hitPadsInDetId(id).size();
206  }
207  return result;
208 }
ME0SimHitMatcher::simHitsMeanStrip
float simHitsMeanStrip(const edm::PSimHitContainer &sim_hits) const
Definition: ME0SimHitMatcher.cc:145
ME0SimHitMatcher::init
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
Definition: ME0SimHitMatcher.cc:16
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:130
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:81
ME0SimHitMatcher::ME0SimHitMatcher
ME0SimHitMatcher(const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
Definition: ME0SimHitMatcher.cc:5
MuonSimHitMatcher::verbose_
bool verbose_
Definition: MuonSimHitMatcher.h:78
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::LogInfo
Definition: MessageLogger.h:254
MuonSimHitMatcher::detid_to_hits_
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
Definition: MuonSimHitMatcher.h:103
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:141
ME0SimHitMatcher::superChamberIds
std::set< unsigned int > superChamberIds() const
Definition: ME0SimHitMatcher.cc:107
MuonSimHitMatcher::simHits_
edm::PSimHitContainer simHits_
Definition: MuonSimHitMatcher.h:94
none
Definition: EcalBoundaryInfoCalculator.h:24
ME0SimHitMatcher::hitStripsInDetId
std::set< int > hitStripsInDetId(unsigned int, int margin_n_strips=0) const
Definition: ME0SimHitMatcher.cc:164
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
ME0SimHitMatcher::hitPartitions
std::set< int > hitPartitions() const
Definition: ME0SimHitMatcher.cc:190
alignCSCRings.s
s
Definition: alignCSCRings.py:92
ME0SimHitMatcher::match
void match(const SimTrack &t, const SimVertex &v)
do the matching
Definition: ME0SimHitMatcher.cc:28
h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
ME0DetId::roll
int roll() const
Definition: ME0DetId.h:48
ecaldqm::topology
const CaloTopology * topology(nullptr)
ME0SimHitMatcher::chamberIds
std::set< unsigned int > chamberIds() const
Definition: ME0SimHitMatcher.cc:100
MuonSimHitMatcher::simHitPSet_
edm::ParameterSet simHitPSet_
Definition: MuonSimHitMatcher.h:106
ME0SimHitMatcher::hitsInSuperChamber
const edm::PSimHitContainer & hitsInSuperChamber(unsigned int) const
Definition: ME0SimHitMatcher.cc:114
Point3DBase< float, LocalTag >
MuonSimHitMatcher::track_ids_
std::vector< unsigned > track_ids_
Definition: MuonSimHitMatcher.h:96
MuonSimHitMatcher::no_hits_
edm::PSimHitContainer no_hits_
Definition: MuonSimHitMatcher.h:99
edm::LogWarning
Definition: MessageLogger.h:141
ME0SimHitMatcher::superChamber_to_hits_
std::map< unsigned int, edm::PSimHitContainer > superChamber_to_hits_
Definition: ME0SimHitMatcher.h:73
MuonSimHitMatcher::discardEleHits_
bool discardEleHits_
Definition: MuonSimHitMatcher.h:77
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:36
ME0SimHitMatcher::hitPadsInDetId
std::set< int > hitPadsInDetId(unsigned int) const
Definition: ME0SimHitMatcher.cc:183
MuonSimHitMatcher
Definition: MuonSimHitMatcher.h:33
MuonSimHitMatcher::match
void match(const SimTrack &t, const SimVertex &v)
do the matching
Definition: MuonSimHitMatcher.cc:26
ME0SimHitMatcher.h
MuonSimHitMatcher::hasGeometry_
bool hasGeometry_
Definition: MuonSimHitMatcher.h:79
iEvent
int iEvent
Definition: GenABIO.cc:224
MuonSimHitMatcher::chamber_to_hits_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
Definition: MuonSimHitMatcher.h:104
edm::EventSetup
Definition: EventSetup.h:57
ME0DetId
Definition: ME0DetId.h:16
get
#define get
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
MuonSimHitMatcher::simHitInput_
edm::EDGetTokenT< edm::PSimHitContainer > simHitInput_
Definition: MuonSimHitMatcher.h:85
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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
ME0SimHitMatcher::me0_geom_
edm::ESHandle< ME0Geometry > me0_geom_
Definition: ME0SimHitMatcher.h:65
SimTrack
Definition: SimTrack.h:6
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
ME0SimHitMatcher::matchSimHitsToSimTrack
void matchSimHitsToSimTrack()
Definition: ME0SimHitMatcher.cc:57
ME0SimHitMatcher::nLayersWithHitsInSuperChamber
int nLayersWithHitsInSuperChamber(unsigned int) const
Definition: ME0SimHitMatcher.cc:120
ME0SimHitMatcher::detids_to_pads_
std::map< unsigned int, std::set< int > > detids_to_pads_
Definition: ME0SimHitMatcher.h:68
MuonSimHitMatcher::simMuOnly_
bool simMuOnly_
Definition: MuonSimHitMatcher.h:76
MuonSimHitMatcher::hitsInChamber
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
Definition: MuonSimHitMatcher.cc:93
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
ztail.d
d
Definition: ztail.py:151
mps_fire.result
result
Definition: mps_fire.py:303
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:201
MuonSimHitMatcher::hits_
edm::PSimHitContainer hits_
Definition: MuonSimHitMatcher.h:102
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:39
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2121
ME0SimHitMatcher::detIds
std::set< unsigned int > detIds() const
Definition: ME0SimHitMatcher.cc:93