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);
80 matchDigisSLToSimTrack(gemDigisSL);
81 matchDigisToSimTrack(gemDigis);
82 matchPadsToSimTrack(gemPads);
83 matchClustersToSimTrack(gemClusters);
84 matchCoPadsToSimTrack(gemCoPads);
89 edm::LogInfo(
"GEMDigiMatcher") <<
"Matching simtrack to GEM simlinks" << endl;
92 for (
auto itsimlink = digisSL.
begin(); itsimlink != digisSL.
end(); itsimlink++) {
93 for (
auto sl = itsimlink->data.begin(); sl != itsimlink->data.end(); ++sl) {
97 const auto& detids(muonSimHitMatcher_->detIds());
98 if (detids.find(p_id.rawId()) == detids.end())
102 if (muonSimHitMatcher_->hitsInDetId(p_id.rawId()).
empty())
106 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMDigiSimLink " << p_id <<
" " << sl->getStrip() <<
" " << sl->getBx()
107 <<
" " << sl->getEnergyLoss() <<
" " << sl->getTimeOfFlight() <<
" "
108 << sl->getParticleType() << std::endl;
111 if (simMuOnly_ &&
std::abs(sl->getParticleType()) != 13)
115 if (discardEleHits_ &&
std::abs(sl->getParticleType()) == 11)
119 for (
const auto& simhit : muonSimHitMatcher_->hitsInDetId(p_id.rawId())) {
121 if (simhit.particleType() == sl->getParticleType() and simhit.trackId() == sl->getTrackId() and
122 std::abs(simhit.energyLoss() - sl->getEnergyLoss()) < 0.001 and
123 std::abs(simhit.timeOfFlight() - sl->getTimeOfFlight()) < 0.001 and
124 simhit.entryPoint() == sl->getEntryPoint() and simhit.momentumAtEntry() == sl->getMomentumAtEntry()) {
125 detid_to_simLinks_[p_id.rawId()].push_back(*sl);
127 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
137 edm::LogInfo(
"GEMDigiMatcher") <<
"Matching simtrack to GEM digis" << endl;
138 for (
auto id : muonSimHitMatcher_->detIds()) {
140 const auto& hit_strips = muonSimHitMatcher_->hitStripsInDetId(
id, matchDeltaStrip_);
141 const auto& digis_in_det = digis.get(p_id);
143 for (
auto d = digis_in_det.first;
d != digis_in_det.second; ++
d) {
147 if (
d->bx() < minBXDigi_ ||
d->bx() > maxBXDigi_)
151 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMDigi " << p_id <<
" " << *
d << endl;
154 if (matchToSimLink_) {
156 for (
const auto& sl : detid_to_simLinks_[p_id.
rawId()]) {
157 if (sl.getStrip() ==
d->strip() and sl.getBx() ==
d->bx()) {
166 if (hit_strips.find(
d->strip()) != hit_strips.end()) {
171 detid_to_digis_[p_id.
rawId()].push_back(*
d);
175 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
181 const auto& det_ids = muonSimHitMatcher_->detIds();
182 for (
const auto&
id : det_ids) {
185 const auto& pads_in_det = pads.get(p_id);
187 for (
auto pad = pads_in_det.first; pad != pads_in_det.second; ++pad) {
193 if (pad->bx() < minBXPad_ || pad->bx() > maxBXPad_)
197 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMPad " << p_id <<
" " << *pad << endl;
200 for (
auto digi : detid_to_digis_[p_id.
rawId()]) {
201 if (digi.strip() / 2 == pad->pad()) {
202 detid_to_pads_[p_id.
rawId()].push_back(*pad);
206 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
215 const auto& det_ids = muonSimHitMatcher_->detIds();
216 for (
auto id : det_ids) {
219 auto clusters_in_det =
clusters.get(p_id);
221 for (
auto cluster = clusters_in_det.first; cluster != clusters_in_det.second; ++cluster) {
229 if (cluster->bx() < minBXCluster_ || cluster->bx() > maxBXCluster_)
233 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMCluster " << p_id <<
" " << *cluster << endl;
236 for (
const auto&
p : cluster->pads()) {
237 for (
auto pad : detid_to_pads_[
id]) {
238 if (pad.pad() ==
p) {
244 detid_to_clusters_[
id].push_back(*cluster);
245 chamber_to_clusters_[p_id.
chamberId().
rawId()].push_back(*cluster);
248 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
256 for (
auto d : superChamberIdsPad()) {
259 const auto& co_pads_in_det = co_pads.get(
id);
260 for (
auto copad = co_pads_in_det.first; copad != co_pads_in_det.second; ++copad) {
262 if (copad->bx(1) < minBXCoPad_ || copad->bx(1) > maxBXCoPad_)
266 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMCoPadDigi: " <<
id <<
" " << *copad << endl;
268 bool isMatchedL1 =
false;
269 bool isMatchedL2 =
false;
274 for (
const auto&
p : padsInDetId(gemL1_id.rawId())) {
275 if (
p == copad->first()) {
281 for (
const auto&
p : padsInChamber(gemL2_id.rawId())) {
282 if (
p == copad->second()) {
286 if (isMatchedL1 and isMatchedL2) {
287 superchamber_to_copads_[
id.rawId()].push_back(*copad);
289 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched! " << endl;
296 return selectDetIds(detid_to_simLinks_, gem_type);
300 return selectDetIds(detid_to_digis_, gem_type);
306 return selectDetIds(detid_to_clusters_, gem_type);
310 return selectDetIds(chamber_to_digis_, gem_type);
314 return selectDetIds(chamber_to_pads_, gem_type);
318 return selectDetIds(chamber_to_clusters_, gem_type);
322 return selectDetIds(superchamber_to_digis_, gem_type);
326 return selectDetIds(superchamber_to_pads_, gem_type);
330 return selectDetIds(superchamber_to_clusters_, gem_type);
334 return selectDetIds(superchamber_to_copads_, gem_type);
338 if (detid_to_digis_.find(detid) == detid_to_digis_.end())
339 return no_gem_digis_;
340 return detid_to_digis_.at(detid);
344 if (chamber_to_digis_.find(detid) == chamber_to_digis_.end())
345 return no_gem_digis_;
346 return chamber_to_digis_.at(detid);
350 if (superchamber_to_digis_.find(detid) == superchamber_to_digis_.end())
351 return no_gem_digis_;
352 return superchamber_to_digis_.at(detid);
356 if (detid_to_pads_.find(detid) == detid_to_pads_.end())
358 return detid_to_pads_.at(detid);
362 if (chamber_to_pads_.find(detid) == chamber_to_pads_.end())
364 return chamber_to_pads_.at(detid);
368 if (superchamber_to_pads_.find(detid) == superchamber_to_pads_.end())
370 return superchamber_to_pads_.at(detid);
374 if (detid_to_clusters_.find(detid) == detid_to_clusters_.end())
375 return no_gem_clusters_;
376 return detid_to_clusters_.at(detid);
380 if (chamber_to_clusters_.find(detid) == chamber_to_clusters_.end())
381 return no_gem_clusters_;
382 return chamber_to_clusters_.at(detid);
386 if (superchamber_to_clusters_.find(detid) == superchamber_to_clusters_.end())
387 return no_gem_clusters_;
388 return superchamber_to_clusters_.at(detid);
392 if (superchamber_to_copads_.find(detid) == superchamber_to_copads_.end())
393 return no_gem_copads_;
394 return superchamber_to_copads_.at(detid);
400 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
403 const auto& digis = digisInChamber(ch_id.rawId());
405 if (!digis.empty()) {
415 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
418 const auto& pads = padsInChamber(ch_id.rawId());
430 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
433 const auto&
clusters = clustersInChamber(ch_id.rawId());
444 const auto& ids = superChamberIdsPad();
445 for (
const auto&
id : ids) {
446 n += padsInSuperChamber(
id).size();
453 const auto& ids = superChamberIdsCoPad();
454 for (
const auto&
id : ids) {
455 n += coPadsInSuperChamber(
id).size();
462 const auto& digis = digisInDetId(detid);
463 for (
const auto&
d : digis) {
471 const auto& digis = padsInDetId(detid);
472 for (
const auto&
d : digis) {
481 const auto& detids = detIdsDigi();
482 for (
const auto&
id : detids) {
492 const auto& detids = superChamberIdsCoPad();
493 for (
const auto&
id : detids) {
502 const LocalPoint& gem_lp = gemGeometry_->etaPartition(gem_id)->centreOfStrip(
d.strip());
503 const GlobalPoint& gem_gp = gemGeometry_->idToDet(gem_id)->surface().toGlobal(gem_lp);
509 const LocalPoint& gem_lp = gemGeometry_->etaPartition(gem_id)->centreOfPad(
tp.pad());
510 const GlobalPoint& gem_gp = gemGeometry_->idToDet(gem_id)->surface().toGlobal(gem_lp);
515 detid_to_simLinks_.clear();
517 detid_to_digis_.clear();
518 chamber_to_digis_.clear();
519 superchamber_to_digis_.clear();
521 detid_to_pads_.clear();
522 chamber_to_pads_.clear();
523 superchamber_to_pads_.clear();
525 detid_to_clusters_.clear();
526 chamber_to_clusters_.clear();
527 superchamber_to_clusters_.clear();
529 superchamber_to_copads_.clear();