7 simMuOnly_ =
gemSimLink.getParameter<
bool>(
"simMuOnly");
8 discardEleHits_ =
gemSimLink.getParameter<
bool>(
"discardEleHits");
9 verboseSimLink_ =
gemSimLink.getParameter<
int>(
"verbose");
11 const auto& gemDigi =
pset.getParameterSet(
"gemStripDigi");
12 minBXDigi_ = gemDigi.getParameter<
int>(
"minBX");
13 maxBXDigi_ = gemDigi.getParameter<
int>(
"maxBX");
14 matchDeltaStrip_ = gemDigi.getParameter<
int>(
"matchDeltaStrip");
15 verboseDigi_ = gemDigi.getParameter<
int>(
"verbose");
16 matchToSimLink_ = gemDigi.getParameter<
bool>(
"matchToSimLink");
18 const auto& gemPad =
pset.getParameterSet(
"gemPadDigi");
19 minBXPad_ = gemPad.getParameter<
int>(
"minBX");
20 maxBXPad_ = gemPad.getParameter<
int>(
"maxBX");
21 verbosePad_ = gemPad.getParameter<
int>(
"verbose");
23 const auto& gemCluster =
pset.getParameterSet(
"gemPadCluster");
24 minBXCluster_ = gemCluster.getParameter<
int>(
"minBX");
25 maxBXCluster_ = gemCluster.getParameter<
int>(
"maxBX");
26 verboseCluster_ = gemCluster.getParameter<
int>(
"verbose");
28 const auto& gemCoPad =
pset.getParameterSet(
"gemCoPadDigi");
29 minBXCoPad_ = gemCoPad.getParameter<
int>(
"minBX");
30 maxBXCoPad_ = gemCoPad.getParameter<
int>(
"maxBX");
31 verboseCoPad_ = gemCoPad.getParameter<
int>(
"verbose");
48 muonSimHitMatcher_->init(
iEvent, iSetup);
51 iEvent.getByToken(gemSimLinkToken_, gemDigisSLH_);
52 iEvent.getByToken(gemDigiToken_, gemDigisH_);
53 iEvent.getByToken(gemPadToken_, gemPadsH_);
54 iEvent.getByToken(gemClusterToken_, gemClustersH_);
55 iEvent.getByToken(gemCoPadToken_, gemCoPadsH_);
57 gemGeometry_ = &iSetup.
getData(geomToken_);
63 muonSimHitMatcher_->match(
t,
v);
78 if (matchToSimLink_) {
80 matchDigisSLToSimTrack(gemDigisSL);
82 matchDigisToSimTrack(gemDigis);
83 matchPadsToSimTrack(gemPads);
84 matchClustersToSimTrack(gemClusters);
85 matchCoPadsToSimTrack(gemCoPads);
90 edm::LogInfo(
"GEMDigiMatcher") <<
"Matching simtrack to GEM simlinks" << endl;
93 for (
auto itsimlink = digisSL.
begin(); itsimlink != digisSL.
end(); itsimlink++) {
94 for (
auto sl = itsimlink->data.begin(); sl != itsimlink->data.end(); ++sl) {
98 const auto& detids(muonSimHitMatcher_->detIds());
99 if (detids.find(p_id.rawId()) == detids.end())
103 if (muonSimHitMatcher_->hitsInDetId(p_id.rawId()).
empty())
107 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMDigiSimLink " << p_id <<
" " << sl->getStrip() <<
" " << sl->getBx()
108 <<
" " << sl->getEnergyLoss() <<
" " << sl->getTimeOfFlight() <<
" "
109 << sl->getParticleType() << std::endl;
112 if (simMuOnly_ &&
std::abs(sl->getParticleType()) != 13)
116 if (discardEleHits_ &&
std::abs(sl->getParticleType()) == 11)
120 for (
const auto& simhit : muonSimHitMatcher_->hitsInDetId(p_id.rawId())) {
122 if (simhit.particleType() == sl->getParticleType() and simhit.trackId() == sl->getTrackId() and
123 std::abs(simhit.energyLoss() - sl->getEnergyLoss()) < 0.001 and
124 std::abs(simhit.timeOfFlight() - sl->getTimeOfFlight()) < 0.001 and
125 simhit.entryPoint() == sl->getEntryPoint() and simhit.momentumAtEntry() == sl->getMomentumAtEntry()) {
126 detid_to_simLinks_[p_id.rawId()].push_back(*sl);
128 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
138 edm::LogInfo(
"GEMDigiMatcher") <<
"Matching simtrack to GEM digis" << endl;
139 for (
auto id : muonSimHitMatcher_->detIds()) {
141 const auto& hit_strips = muonSimHitMatcher_->hitStripsInDetId(
id, matchDeltaStrip_);
142 const auto& digis_in_det = digis.get(p_id);
144 for (
auto d = digis_in_det.first;
d != digis_in_det.second; ++
d) {
148 if (
d->bx() < minBXDigi_ ||
d->bx() > maxBXDigi_)
152 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMDigi " << p_id <<
" " << *
d << endl;
155 if (matchToSimLink_) {
157 for (
const auto& sl : detid_to_simLinks_[p_id.
rawId()]) {
158 if (sl.getStrip() ==
d->strip() and sl.getBx() ==
d->bx()) {
167 if (hit_strips.find(
d->strip()) != hit_strips.end()) {
172 detid_to_digis_[p_id.
rawId()].push_back(*
d);
176 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
182 const auto& det_ids = muonSimHitMatcher_->detIds();
183 for (
const auto&
id : det_ids) {
186 const auto& pads_in_det = pads.get(p_id);
188 for (
auto pad = pads_in_det.first; pad != pads_in_det.second; ++pad) {
194 if (pad->bx() < minBXPad_ || pad->bx() > maxBXPad_)
198 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMPad " << p_id <<
" " << *pad << endl;
201 for (
auto digi : detid_to_digis_[p_id.
rawId()]) {
202 if (digi.strip() / 2 == pad->pad()) {
203 detid_to_pads_[p_id.
rawId()].push_back(*pad);
207 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
216 const auto& det_ids = muonSimHitMatcher_->detIds();
217 for (
auto id : det_ids) {
220 auto clusters_in_det =
clusters.get(p_id);
222 for (
auto cluster = clusters_in_det.first; cluster != clusters_in_det.second; ++cluster) {
230 if (cluster->bx() < minBXCluster_ || cluster->bx() > maxBXCluster_)
234 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMCluster " << p_id <<
" " << *cluster << endl;
237 for (
const auto&
p : cluster->pads()) {
238 for (
auto pad : detid_to_pads_[
id]) {
239 if (pad.pad() ==
p) {
245 detid_to_clusters_[
id].push_back(*cluster);
246 chamber_to_clusters_[p_id.
chamberId().
rawId()].push_back(*cluster);
249 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
257 for (
auto d : superChamberIdsPad()) {
260 const auto& co_pads_in_det = co_pads.get(
id);
261 for (
auto copad = co_pads_in_det.first; copad != co_pads_in_det.second; ++copad) {
263 if (copad->bx(1) < minBXCoPad_ || copad->bx(1) > maxBXCoPad_)
267 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMCoPadDigi: " <<
id <<
" " << *copad << endl;
269 bool isMatchedL1 =
false;
270 bool isMatchedL2 =
false;
275 for (
const auto&
p : padsInDetId(gemL1_id.rawId())) {
276 if (
p == copad->first()) {
282 for (
const auto&
p : padsInChamber(gemL2_id.rawId())) {
283 if (
p == copad->second()) {
287 if (isMatchedL1 and isMatchedL2) {
288 superchamber_to_copads_[
id.rawId()].push_back(*copad);
290 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched! " << endl;
297 return selectDetIds(detid_to_simLinks_, gem_type);
301 return selectDetIds(detid_to_digis_, gem_type);
307 return selectDetIds(detid_to_clusters_, gem_type);
311 return selectDetIds(chamber_to_digis_, gem_type);
315 return selectDetIds(chamber_to_pads_, gem_type);
319 return selectDetIds(chamber_to_clusters_, gem_type);
323 return selectDetIds(superchamber_to_digis_, gem_type);
327 return selectDetIds(superchamber_to_pads_, gem_type);
331 return selectDetIds(superchamber_to_clusters_, gem_type);
335 return selectDetIds(superchamber_to_copads_, gem_type);
339 if (detid_to_digis_.find(detid) == detid_to_digis_.end())
340 return no_gem_digis_;
341 return detid_to_digis_.at(detid);
345 if (chamber_to_digis_.find(detid) == chamber_to_digis_.end())
346 return no_gem_digis_;
347 return chamber_to_digis_.at(detid);
351 if (superchamber_to_digis_.find(detid) == superchamber_to_digis_.end())
352 return no_gem_digis_;
353 return superchamber_to_digis_.at(detid);
357 if (detid_to_pads_.find(detid) == detid_to_pads_.end())
359 return detid_to_pads_.at(detid);
363 if (chamber_to_pads_.find(detid) == chamber_to_pads_.end())
365 return chamber_to_pads_.at(detid);
369 if (superchamber_to_pads_.find(detid) == superchamber_to_pads_.end())
371 return superchamber_to_pads_.at(detid);
375 if (detid_to_clusters_.find(detid) == detid_to_clusters_.end())
376 return no_gem_clusters_;
377 return detid_to_clusters_.at(detid);
381 if (chamber_to_clusters_.find(detid) == chamber_to_clusters_.end())
382 return no_gem_clusters_;
383 return chamber_to_clusters_.at(detid);
387 if (superchamber_to_clusters_.find(detid) == superchamber_to_clusters_.end())
388 return no_gem_clusters_;
389 return superchamber_to_clusters_.at(detid);
393 if (superchamber_to_copads_.find(detid) == superchamber_to_copads_.end())
394 return no_gem_copads_;
395 return superchamber_to_copads_.at(detid);
401 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
404 const auto& digis = digisInChamber(ch_id.rawId());
406 if (!digis.empty()) {
416 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
419 const auto& pads = padsInChamber(ch_id.rawId());
431 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
434 const auto&
clusters = clustersInChamber(ch_id.rawId());
445 const auto& ids = superChamberIdsPad();
446 for (
const auto&
id : ids) {
447 n += padsInSuperChamber(
id).size();
454 const auto& ids = superChamberIdsCoPad();
455 for (
const auto&
id : ids) {
456 n += coPadsInSuperChamber(
id).size();
463 const auto& digis = digisInDetId(detid);
464 for (
const auto&
d : digis) {
472 const auto& digis = padsInDetId(detid);
473 for (
const auto&
d : digis) {
482 const auto& detids = detIdsDigi();
483 for (
const auto&
id : detids) {
493 const auto& detids = superChamberIdsCoPad();
494 for (
const auto&
id : detids) {
503 const LocalPoint& gem_lp = gemGeometry_->etaPartition(gem_id)->centreOfStrip(
d.strip());
504 const GlobalPoint& gem_gp = gemGeometry_->idToDet(gem_id)->surface().toGlobal(gem_lp);
510 const LocalPoint& gem_lp = gemGeometry_->etaPartition(gem_id)->centreOfPad(
tp.pad());
511 const GlobalPoint& gem_gp = gemGeometry_->idToDet(gem_id)->surface().toGlobal(gem_lp);
516 detid_to_simLinks_.clear();
518 detid_to_digis_.clear();
519 chamber_to_digis_.clear();
520 superchamber_to_digis_.clear();
522 detid_to_pads_.clear();
523 chamber_to_pads_.clear();
524 superchamber_to_pads_.clear();
526 detid_to_clusters_.clear();
527 chamber_to_clusters_.clear();
528 superchamber_to_clusters_.clear();
530 superchamber_to_copads_.clear();