11 minBXCLCT_ =
cscCLCT.getParameter<
int>(
"minBX");
12 maxBXCLCT_ =
cscCLCT.getParameter<
int>(
"maxBX");
13 verboseCLCT_ =
cscCLCT.getParameter<
int>(
"verbose");
14 minNHitsChamberCLCT_ =
cscCLCT.getParameter<
int>(
"minNHitsChamber");
17 minBXALCT_ =
cscALCT.getParameter<
int>(
"minBX");
18 maxBXALCT_ =
cscALCT.getParameter<
int>(
"maxBX");
19 verboseALCT_ =
cscALCT.getParameter<
int>(
"verbose");
20 minNHitsChamberALCT_ =
cscALCT.getParameter<
int>(
"minNHitsChamber");
23 minBXLCT_ =
cscLCT.getParameter<
int>(
"minBX");
24 maxBXLCT_ =
cscLCT.getParameter<
int>(
"maxBX");
25 verboseLCT_ =
cscLCT.getParameter<
int>(
"verbose");
26 minNHitsChamberLCT_ =
cscLCT.getParameter<
int>(
"minNHitsChamber");
27 addGhostLCTs_ =
cscLCT.getParameter<
bool>(
"addGhosts");
30 minBXMPLCT_ =
cscMPLCT.getParameter<
int>(
"minBX");
31 maxBXMPLCT_ =
cscMPLCT.getParameter<
int>(
"maxBX");
32 verboseMPLCT_ =
cscMPLCT.getParameter<
int>(
"verbose");
33 minNHitsChamberMPLCT_ =
cscMPLCT.getParameter<
int>(
"minNHitsChamber");
49 gemDigiMatcher_->init(
iEvent, iSetup);
50 cscDigiMatcher_->init(
iEvent, iSetup);
52 iEvent.getByToken(clctToken_, clctsH_);
53 iEvent.getByToken(alctToken_, alctsH_);
54 iEvent.getByToken(lctToken_, lctsH_);
55 iEvent.getByToken(mplctToken_, mplctsH_);
57 cscGeometry_ = &iSetup.
getData(geomToken_);
64 gemDigiMatcher_->match(
t,
v);
65 cscDigiMatcher_->match(
t,
v);
75 matchCLCTsToSimTrack(clcts);
76 matchALCTsToSimTrack(alcts);
77 matchLCTsToSimTrack(lcts);
78 matchMPLCTsToSimTrack(mplcts);
82 const auto& cathode_ids = cscDigiMatcher_->chamberIdsStrip(0);
84 for (
const auto&
id : cathode_ids) {
87 edm::LogInfo(
"CSCStubMatcher") <<
"To check CSC chamber " << ch_id;
93 if (cscDigiMatcher_->nLayersWithStripInChamber(ch_id) < minNHitsChamberCLCT_)
97 std::vector<CSCComparatorDigiContainer> comps;
100 comps.push_back(cscDigiMatcher_->comparatorDigisInDetId(layerid));
105 edm::LogInfo(
"CSCStubMatcher") <<
"clct: comparators " << ch_id;
107 for (
const auto&
p : comps) {
109 for (
const auto&
q :
p) {
110 edm::LogInfo(
"CSCStubMatcher") <<
"L" <<
layer <<
" " <<
q <<
" " <<
q.getHalfStrip() <<
" ";
116 const bool isME1a(ch_id.
station() == 1 and ch_id.
ring() == 4);
121 const auto& clcts_in_det = clcts.get(ch_id2);
123 for (
auto c = clcts_in_det.first;
c != clcts_in_det.second; ++
c) {
125 edm::LogInfo(
"CSCStubMatcher") <<
"clct " << ch_id2 <<
" " << *
c;
131 if (
c->getBX() < minBXCLCT_ ||
c->getBX() > maxBXCLCT_)
135 chamber_to_clcts_all_[
id].push_back(*
c);
140 for (
const auto&
p : comps) {
142 for (
const auto&
q :
p) {
144 edm::LogInfo(
"CSCStubMatcher") <<
"L" <<
layer <<
" " <<
q <<
" " <<
q.getHalfStrip() <<
" " << std::endl;
145 for (
const auto& clctComp : (*c).getHits()[
layer - 1]) {
146 if (clctComp == 65535)
149 edm::LogInfo(
"CSCStubMatcher") <<
"\t" << clctComp <<
" ";
151 if (
q.getHalfStrip() == clctComp
or (isME1a and
q.getHalfStrip() + 128 == clctComp)) {
154 edm::LogInfo(
"CSCStubMatcher") <<
"\t\tnMatches " << nMatches << std::endl;
169 if (
std::find(chamber_to_clcts_[
id].begin(), chamber_to_clcts_[
id].
end(), *
c) == chamber_to_clcts_[
id].
end()) {
170 chamber_to_clcts_[
id].push_back(*
c);
173 if (chamber_to_clcts_[
id].
size() > 2) {
174 edm::LogInfo(
"CSCStubMatcher") <<
"WARNING!!! too many CLCTs " << chamber_to_clcts_[
id].size() <<
" in " << ch_id;
175 for (
auto&
c : chamber_to_clcts_[
id])
182 const auto& anode_ids = cscDigiMatcher_->chamberIdsWire(0);
184 for (
const auto&
id : anode_ids) {
185 if (cscDigiMatcher_->nLayersWithWireInChamber(
id) >= minNHitsChamberALCT_)
190 const auto& digi_wgs = cscDigiMatcher_->wiregroupsInChamber(
id, 1);
192 cout <<
"alct: digi_wgs " << ch_id <<
" ";
193 copy(digi_wgs.begin(), digi_wgs.end(), ostream_iterator<int>(
cout,
" "));
202 const auto& alcts_in_det = alcts.get(ch_id2);
203 for (
auto a = alcts_in_det.first;
a != alcts_in_det.second; ++
a) {
208 edm::LogInfo(
"CSCStubMatcher") <<
"alct " << ch_id <<
" " << *
a;
211 if (
a->getBX() < minBXALCT_ ||
a->getBX() > maxBXALCT_)
214 int wg =
a->getKeyWG() + 1;
217 chamber_to_alcts_all_[
id].push_back(*
a);
220 if (digi_wgs.find(wg) == digi_wgs.end()) {
227 if (
std::find(chamber_to_alcts_[
id].begin(), chamber_to_alcts_[
id].
end(), *
a) == chamber_to_alcts_[
id].
end()) {
228 chamber_to_alcts_[
id].push_back(*
a);
231 if (chamber_to_alcts_[
id].
size() > 2) {
232 edm::LogInfo(
"CSCStubMatcher") <<
"WARNING!!! too many ALCTs " << chamber_to_alcts_[
id].size() <<
" in " << ch_id;
233 for (
auto&
a : chamber_to_alcts_[
id])
241 const auto& cathode_ids = chamberIdsAllCLCT(0);
242 const auto& anode_ids = chamberIdsAllALCT(0);
244 std::set<int> cathode_and_anode_ids;
245 std::set_union(cathode_ids.begin(),
249 std::inserter(cathode_and_anode_ids, cathode_and_anode_ids.end()));
251 for (
const auto&
id : cathode_and_anode_ids) {
262 const auto& lcts_in_det = lcts.get(ch_id2);
264 std::map<int, CSCCorrelatedLCTDigiContainer> bx_to_lcts;
268 for (
auto lct = lcts_in_det.first; lct != lcts_in_det.second; ++lct) {
271 lcts_tmp.push_back(*lct);
272 int bx = lct->getBX();
273 bx_to_lcts[
bx].push_back(*lct);
277 if (bx_to_lcts[
bx].
size() == 2 and addGhostLCTs_) {
278 auto lct11 = bx_to_lcts[
bx][0];
279 auto lct22 = bx_to_lcts[
bx][1];
280 addGhostLCTs(lct11, lct22, lcts_tmp);
284 for (
const auto& lct : lcts_tmp) {
287 bool lct_clct_match(
false);
288 bool lct_alct_match(
false);
289 bool lct_gem1_match(
false);
290 bool lct_gem2_match(
false);
293 edm::LogInfo(
"CSCStubMatcher") << ch_id <<
" " << ch_id2;
295 edm::LogInfo(
"CSCStubMatcher") <<
"getCLCT " << lct.getCLCT() <<
"\ngetALCT " << lct.getALCT() <<
"\ngetGEM1 "
296 << lct.getGEM1() <<
"\ngetGEM2 " << lct.getGEM2();
299 for (
const auto&
p : clctsInChamber(
id)) {
300 if (
p == lct.getCLCT()) {
301 lct_clct_match =
true;
303 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_clct_match";
309 for (
const auto&
p : alctsInChamber(
id)) {
310 if (
p == lct.getALCT()) {
311 lct_alct_match =
true;
313 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_alct_match";
323 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL1.rawId())) {
324 if (
p == lct.getGEM1()) {
325 lct_gem1_match =
true;
327 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_gem1_match";
334 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL2.rawId())) {
335 if (
p == lct.getGEM2()) {
336 lct_gem2_match =
true;
338 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_gem2_match";
345 const bool alct_clct = lct_clct_match and lct_alct_match;
346 const bool alct_gem = lct_alct_match and lct_gem1_match and lct_gem2_match;
347 const bool clct_gem = lct_clct_match and lct_gem1_match and lct_gem2_match;
349 bool lct_tight_matched = alct_clct
or alct_gem
or clct_gem;
350 bool lct_loose_matched = lct_clct_match
or lct_alct_match;
351 bool lct_matched = lct_loose_matched
or lct_tight_matched;
356 if (
std::find(chamber_to_lcts_[
id].begin(), chamber_to_lcts_[
id].
end(), lct) == chamber_to_lcts_[
id].
end()) {
357 chamber_to_lcts_[
id].emplace_back(lct);
367 const auto& lcts_ids = chamberIdsLCT(0);
370 for (
const auto&
id : lcts_ids) {
371 const auto& mplcts_in_det = mplcts.get(
id);
374 for (
auto lct = mplcts_in_det.first; lct != mplcts_in_det.second; ++lct) {
378 chamber_to_mplcts_all_[
id].emplace_back(*lct);
381 for (
const auto& sim_stub : lctsInChamber(
id)) {
382 if (sim_stub == *lct) {
383 if (
std::find(chamber_to_mplcts_[
id].begin(), chamber_to_mplcts_[
id].
end(), *lct) ==
384 chamber_to_mplcts_[
id].
end()) {
385 chamber_to_mplcts_[
id].emplace_back(*lct);
394 return selectDetIds(chamber_to_clcts_all_, csc_type);
398 return selectDetIds(chamber_to_alcts_all_, csc_type);
402 return selectDetIds(chamber_to_lcts_all_, csc_type);
406 return selectDetIds(chamber_to_mplcts_all_, csc_type);
410 return selectDetIds(chamber_to_clcts_, csc_type);
414 return selectDetIds(chamber_to_alcts_, csc_type);
418 return selectDetIds(chamber_to_lcts_, csc_type);
422 return selectDetIds(chamber_to_mplcts_, csc_type);
426 if (chamber_to_clcts_all_.find(detid) == chamber_to_clcts_all_.end())
428 return chamber_to_clcts_all_.at(detid);
432 if (chamber_to_alcts_all_.find(detid) == chamber_to_alcts_all_.end())
434 return chamber_to_alcts_all_.at(detid);
438 if (chamber_to_lcts_all_.find(detid) == chamber_to_lcts_all_.end())
440 return chamber_to_lcts_all_.at(detid);
444 if (chamber_to_mplcts_all_.find(detid) == chamber_to_mplcts_all_.end())
446 return chamber_to_mplcts_all_.at(detid);
450 if (chamber_to_clcts_.find(detid) == chamber_to_clcts_.end())
452 return chamber_to_clcts_.at(detid);
456 if (chamber_to_alcts_.find(detid) == chamber_to_alcts_.end())
458 return chamber_to_alcts_.at(detid);
462 if (chamber_to_lcts_.find(detid) == chamber_to_lcts_.end())
464 return chamber_to_lcts_.at(detid);
468 if (chamber_to_mplcts_.find(detid) == chamber_to_mplcts_.end())
470 return chamber_to_mplcts_.at(detid);
475 const auto&
input(clctsInChamber(detid));
478 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
492 const auto&
input(alctsInChamber(detid));
495 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
509 const auto&
input(lctsInChamber(detid));
512 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
526 const auto&
chamber(cscGeometry_->chamber(
id));
527 return fabs(
chamber->layer(
layer)->centerOfStrip(20).z());
532 const auto& chamber_ids = chamberIdsCLCT();
533 for (
const auto&
id : chamber_ids) {
534 int nStubChamber = 0;
535 const auto& clcts = clctsInChamber(
id);
536 for (
const auto& clct : clcts) {
539 if (clct.getQuality() >= min_quality) {
543 if (nStubChamber > 0) {
552 const auto& chamber_ids = chamberIdsALCT();
553 for (
const auto&
id : chamber_ids) {
554 int nStubChamber = 0;
555 const auto& alcts = alctsInChamber(
id);
556 for (
const auto& alct : alcts) {
559 if (alct.getQuality() >= min_quality) {
563 if (nStubChamber > 0) {
572 const auto& chamber_ids = chamberIdsLCT();
573 for (
const auto&
id : chamber_ids) {
574 int nStubChamber = 0;
575 const auto& lcts = lctsInChamber(
id);
576 for (
const auto& lct : lcts) {
579 if (lct.getQuality() >= min_quality) {
583 if (nStubChamber > 0) {
592 const auto& chamber_ids = chamberIdsMPLCT();
593 for (
const auto&
id : chamber_ids) {
594 int nStubChamber = 0;
595 const auto& mplcts = mplctsInChamber(
id);
596 for (
const auto& mplct : mplcts) {
597 if (!mplct.isValid())
599 if (mplct.getQuality() >= min_quality) {
603 if (nStubChamber > 0) {
611 for (
const auto& stub : lctsInChamber(
id.rawId())) {
627 const auto&
chamber = cscGeometry_->chamber(cscId);
630 float wire = layer_geo->middleWireOfGroup(lct.
getKeyWG() + 1);
631 const LocalPoint& csc_intersect = layer_geo->intersectionOfStripAndWire(fractional_strip, wire);
632 const GlobalPoint& csc_gp = cscGeometry_->idToDet(keyId)->surface().toGlobal(csc_intersect);
637 chamber_to_clcts_all_.clear();
638 chamber_to_alcts_all_.clear();
639 chamber_to_lcts_all_.clear();
640 chamber_to_mplcts_all_.clear();
642 chamber_to_clcts_.clear();
643 chamber_to_alcts_.clear();
644 chamber_to_lcts_.clear();
645 chamber_to_mplcts_.clear();
656 if (!(wg1 == wg2 || hs1 == hs2)) {
662 lcts_tmp.push_back(lct12);
668 lcts_tmp.push_back(lct21);