6 const auto& gemDigi =
pset.getParameterSet(
"gemStripDigi");
7 minBXDigi_ = gemDigi.getParameter<
int>(
"minBX");
8 maxBXDigi_ = gemDigi.getParameter<
int>(
"maxBX");
9 matchDeltaStrip_ = gemDigi.getParameter<
int>(
"matchDeltaStrip");
10 verboseDigi_ = gemDigi.getParameter<
int>(
"verbose");
12 const auto& gemPad =
pset.getParameterSet(
"gemPadDigi");
13 minBXPad_ = gemPad.getParameter<
int>(
"minBX");
14 maxBXPad_ = gemPad.getParameter<
int>(
"maxBX");
15 verbosePad_ = gemPad.getParameter<
int>(
"verbose");
17 const auto& gemCluster =
pset.getParameterSet(
"gemPadCluster");
18 minBXCluster_ = gemCluster.getParameter<
int>(
"minBX");
19 maxBXCluster_ = gemCluster.getParameter<
int>(
"maxBX");
20 verboseCluster_ = gemCluster.getParameter<
int>(
"verbose");
22 const auto& gemCoPad =
pset.getParameterSet(
"gemCoPadDigi");
23 minBXCoPad_ = gemCoPad.getParameter<
int>(
"minBX");
24 maxBXCoPad_ = gemCoPad.getParameter<
int>(
"maxBX");
25 verboseCoPad_ = gemCoPad.getParameter<
int>(
"verbose");
37 muonSimHitMatcher_->init(
iEvent, iSetup);
39 iEvent.getByToken(gemDigiToken_, gemDigisH_);
40 iEvent.getByToken(gemPadToken_, gemPadsH_);
41 iEvent.getByToken(gemClusterToken_, gemClustersH_);
42 iEvent.getByToken(gemCoPadToken_, gemCoPadsH_);
45 if (gem_geom_.isValid()) {
46 gemGeometry_ = &*gem_geom_;
48 std::cout <<
"+++ Info: GEM geometry is unavailable. +++\n";
55 muonSimHitMatcher_->match(
t,
v);
64 matchDigisToSimTrack(gemDigis);
65 matchPadsToSimTrack(gemPads);
66 matchClustersToSimTrack(gemClusters);
67 matchCoPadsToSimTrack(gemCoPads);
72 cout <<
"Matching simtrack to GEM digis" << endl;
73 const auto& det_ids = muonSimHitMatcher_->detIds();
74 for (
const auto&
id : det_ids) {
76 const auto& hit_strips = muonSimHitMatcher_->hitStripsInDetId(
id, matchDeltaStrip_);
78 cout <<
"hit_strips_fat ";
79 copy(hit_strips.begin(), hit_strips.end(), ostream_iterator<int>(
cout,
" "));
83 const auto& digis_in_det = digis.get(
GEMDetId(
id));
85 for (
auto d = digis_in_det.first;
d != digis_in_det.second; ++
d) {
87 cout <<
"GEMDigi " << p_id <<
" " << *
d << endl;
89 if (
d->bx() < minBXDigi_ ||
d->bx() > maxBXDigi_)
92 if (hit_strips.find(
d->strip()) == hit_strips.end())
95 cout <<
"...was matched!" << endl;
97 detid_to_digis_[
id].push_back(*
d);
105 const auto& det_ids = muonSimHitMatcher_->detIds();
106 for (
const auto&
id : det_ids) {
110 const auto& hit_pads = muonSimHitMatcher_->hitPadsInDetId(
id);
111 const auto& pads_in_det = pads.get(p_id);
114 cout <<
"checkpads " << hit_pads.size() <<
" " <<
std::distance(pads_in_det.first, pads_in_det.second)
116 copy(hit_pads.begin(), hit_pads.end(), ostream_iterator<int>(
cout,
" "));
120 for (
auto pad = pads_in_det.first; pad != pads_in_det.second; ++pad) {
122 cout <<
"chp " << *pad << endl;
124 if (pad->bx() < minBXPad_ || pad->bx() > maxBXPad_)
127 cout <<
"chp1" << endl;
129 if (hit_pads.find(pad->pad()) == hit_pads.end())
132 cout <<
"chp2" << endl;
134 detid_to_pads_[
id].push_back(*pad);
136 superchamber_to_pads_[superch_id()].push_back(*pad);
142 const auto& det_ids = muonSimHitMatcher_->detIds();
143 for (
auto id : det_ids) {
147 auto hit_pads = muonSimHitMatcher_->hitPadsInDetId(
id);
148 auto clusters_in_det =
clusters.get(p_id);
150 for (
auto cluster = clusters_in_det.first; cluster != clusters_in_det.second; ++cluster) {
152 if (cluster->bx() < minBXCluster_ || cluster->bx() > maxBXCluster_)
156 for (
const auto&
p : cluster->pads()) {
157 if (hit_pads.find(
p) == hit_pads.end()) {
158 detid_to_clusters_[
id].push_back(*cluster);
159 chamber_to_clusters_[p_id.
chamberId().
rawId()].push_back(*cluster);
160 superchamber_to_clusters_[superch_id()].push_back(*cluster);
169 const auto& det_ids = muonSimHitMatcher_->detIdsCoincidences();
170 for (
const auto&
id : det_ids) {
174 const auto& hit_co_pads = muonSimHitMatcher_->hitCoPadsInDetId(
id);
175 const auto& co_pads_in_det = co_pads.get(superch_id);
178 cout <<
"matching CoPads in detid " << superch_id << std::endl;
179 cout <<
"checkcopads from gemhits" << hit_co_pads.size() <<
" from copad collection "
180 <<
std::distance(co_pads_in_det.first, co_pads_in_det.second) <<
" hit_pads: ";
181 copy(hit_co_pads.begin(), hit_co_pads.end(), ostream_iterator<int>(
cout,
" "));
185 for (
auto pad = co_pads_in_det.first; pad != co_pads_in_det.second; ++pad) {
187 bool matchL1 =
false;
190 cout <<
"CoPad: chp " << *pad << endl;
191 for (
const auto&
p : padsInChamber(gemL1_id.rawId())) {
192 if (
p == pad->first()) {
198 bool matchL2 =
false;
200 for (
const auto&
p : padsInChamber(gemL2_id.rawId())) {
201 if (
p == pad->second()) {
207 if (matchL1 and matchL2) {
209 cout <<
"CoPad: was matched! " << endl;
210 superchamber_to_copads_[superch_id()].push_back(*pad);
217 return selectDetIds(detid_to_digis_, gem_type);
223 return selectDetIds(detid_to_clusters_, gem_type);
227 return selectDetIds(chamber_to_digis_, gem_type);
231 return selectDetIds(chamber_to_pads_, gem_type);
235 return selectDetIds(chamber_to_clusters_, gem_type);
239 return selectDetIds(superchamber_to_digis_, gem_type);
243 return selectDetIds(superchamber_to_pads_, gem_type);
247 return selectDetIds(superchamber_to_clusters_, gem_type);
251 return selectDetIds(superchamber_to_copads_, gem_type);
255 if (detid_to_digis_.find(detid) == detid_to_digis_.end())
256 return no_gem_digis_;
257 return detid_to_digis_.at(detid);
261 if (chamber_to_digis_.find(detid) == chamber_to_digis_.end())
262 return no_gem_digis_;
263 return chamber_to_digis_.at(detid);
267 if (superchamber_to_digis_.find(detid) == superchamber_to_digis_.end())
268 return no_gem_digis_;
269 return superchamber_to_digis_.at(detid);
273 if (detid_to_pads_.find(detid) == detid_to_pads_.end())
275 return detid_to_pads_.at(detid);
279 if (chamber_to_pads_.find(detid) == chamber_to_pads_.end())
281 return chamber_to_pads_.at(detid);
285 if (superchamber_to_pads_.find(detid) == superchamber_to_pads_.end())
287 return superchamber_to_pads_.at(detid);
291 if (detid_to_clusters_.find(detid) == detid_to_clusters_.end())
292 return no_gem_clusters_;
293 return detid_to_clusters_.at(detid);
297 if (chamber_to_clusters_.find(detid) == chamber_to_clusters_.end())
298 return no_gem_clusters_;
299 return chamber_to_clusters_.at(detid);
303 if (superchamber_to_clusters_.find(detid) == superchamber_to_clusters_.end())
304 return no_gem_clusters_;
305 return superchamber_to_clusters_.at(detid);
309 if (superchamber_to_copads_.find(detid) == superchamber_to_copads_.end())
310 return no_gem_copads_;
311 return superchamber_to_copads_.at(detid);
317 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
320 const auto& digis = digisInChamber(ch_id.rawId());
322 if (!digis.empty()) {
332 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
335 const auto& pads = padsInChamber(ch_id.rawId());
346 const auto& ids = superChamberIdsPad();
347 for (
const auto&
id : ids) {
348 n += padsInSuperChamber(
id).size();
355 const auto& ids = superChamberIdsCoPad();
356 for (
const auto&
id : ids) {
357 n += coPadsInSuperChamber(
id).size();
364 const auto& digis = digisInDetId(detid);
365 for (
const auto&
d : digis) {
373 const auto& digis = padsInDetId(detid);
374 for (
const auto&
d : digis) {
383 const auto& detids = detIdsDigi();
384 for (
const auto&
id : detids) {
394 const auto& detids = superChamberIdsCoPad();
395 for (
const auto&
id : detids) {
404 const LocalPoint& gem_lp = gemGeometry_->etaPartition(gem_id)->centreOfStrip(
d.strip());
405 const GlobalPoint& gem_gp = gemGeometry_->idToDet(gem_id)->surface().toGlobal(gem_lp);
411 const LocalPoint& gem_lp = gemGeometry_->etaPartition(gem_id)->centreOfPad(
tp.pad());
412 const GlobalPoint& gem_gp = gemGeometry_->idToDet(gem_id)->surface().toGlobal(gem_lp);