9 minBXCLCT_ =
cscCLCT.getParameter<
int>(
"minBX");
10 maxBXCLCT_ =
cscCLCT.getParameter<
int>(
"maxBX");
11 verboseCLCT_ =
cscCLCT.getParameter<
int>(
"verbose");
12 minNHitsChamberCLCT_ =
cscCLCT.getParameter<
int>(
"minNHitsChamber");
15 minBXALCT_ =
cscALCT.getParameter<
int>(
"minBX");
16 maxBXALCT_ =
cscALCT.getParameter<
int>(
"maxBX");
17 verboseALCT_ =
cscALCT.getParameter<
int>(
"verbose");
18 minNHitsChamberALCT_ =
cscALCT.getParameter<
int>(
"minNHitsChamber");
21 minBXLCT_ =
cscLCT.getParameter<
int>(
"minBX");
22 maxBXLCT_ =
cscLCT.getParameter<
int>(
"maxBX");
23 verboseLCT_ =
cscLCT.getParameter<
int>(
"verbose");
24 minNHitsChamberLCT_ =
cscLCT.getParameter<
int>(
"minNHitsChamber");
25 addGhostLCTs_ =
cscLCT.getParameter<
bool>(
"addGhosts");
28 minBXMPLCT_ =
cscMPLCT.getParameter<
int>(
"minBX");
29 maxBXMPLCT_ =
cscMPLCT.getParameter<
int>(
"maxBX");
30 verboseMPLCT_ =
cscMPLCT.getParameter<
int>(
"verbose");
31 minNHitsChamberMPLCT_ =
cscMPLCT.getParameter<
int>(
"minNHitsChamber");
45 gemDigiMatcher_->init(
iEvent, iSetup);
46 cscDigiMatcher_->init(
iEvent, iSetup);
48 iEvent.getByToken(clctToken_, clctsH_);
49 iEvent.getByToken(alctToken_, alctsH_);
50 iEvent.getByToken(lctToken_, lctsH_);
51 iEvent.getByToken(mplctToken_, mplctsH_);
53 cscGeometry_ = &iSetup.
getData(geomToken_);
59 gemDigiMatcher_->match(
t,
v);
60 cscDigiMatcher_->match(
t,
v);
70 matchCLCTsToSimTrack(clcts);
71 matchALCTsToSimTrack(alcts);
72 matchLCTsToSimTrack(lcts);
73 matchMPLCTsToSimTrack(mplcts);
77 const auto& cathode_ids = cscDigiMatcher_->chamberIdsStrip(0);
79 for (
const auto&
id : cathode_ids) {
82 edm::LogInfo(
"CSCStubMatcher") <<
"To check CSC chamber " << ch_id;
88 if (cscDigiMatcher_->nLayersWithStripInChamber(ch_id) < minNHitsChamberCLCT_)
92 std::vector<CSCComparatorDigiContainer> comps;
93 for (
int ilayer = 1; ilayer <= 6; ilayer++) {
95 comps.push_back(cscDigiMatcher_->comparatorDigisInDetId(layerid));
100 edm::LogInfo(
"CSCStubMatcher") <<
"clct: comparators " << ch_id;
102 for (
const auto&
p : comps) {
104 for (
const auto&
q :
p) {
105 edm::LogInfo(
"CSCStubMatcher") <<
"L" << layer <<
" " <<
q <<
" " <<
q.getHalfStrip() <<
" ";
111 const bool isME1a(ch_id.
station() == 1 and ch_id.
ring() == 4);
116 const auto& clcts_in_det = clcts.get(ch_id2);
118 for (
auto c = clcts_in_det.first;
c != clcts_in_det.second; ++
c) {
120 edm::LogInfo(
"CSCStubMatcher") <<
"clct " << ch_id2 <<
" " << *
c;
126 if (
c->getBX() < minBXCLCT_ ||
c->getBX() > maxBXCLCT_)
130 chamber_to_clcts_all_[
id].push_back(*
c);
135 for (
const auto&
p : comps) {
137 for (
const auto&
q :
p) {
139 edm::LogInfo(
"CSCStubMatcher") <<
"L" << layer <<
" " <<
q <<
" " <<
q.getHalfStrip() <<
" " << std::endl;
140 for (
const auto& clctComp : (*c).getHits()[layer - 1]) {
141 if (clctComp == 65535)
144 edm::LogInfo(
"CSCStubMatcher") <<
"\t" << clctComp <<
" ";
146 if (
q.getHalfStrip() == clctComp
or (isME1a and
q.getHalfStrip() + 128 == clctComp)) {
149 edm::LogInfo(
"CSCStubMatcher") <<
"\t\tnMatches " << nMatches << std::endl;
164 if (
std::find(chamber_to_clcts_[
id].begin(), chamber_to_clcts_[
id].
end(), *
c) == chamber_to_clcts_[
id].
end()) {
165 chamber_to_clcts_[
id].push_back(*
c);
168 if (chamber_to_clcts_[
id].
size() > 2) {
169 edm::LogInfo(
"CSCStubMatcher") <<
"WARNING!!! too many CLCTs " << chamber_to_clcts_[
id].size() <<
" in " << ch_id;
170 for (
auto&
c : chamber_to_clcts_[
id])
177 const auto& anode_ids = cscDigiMatcher_->chamberIdsWire(0);
179 for (
const auto&
id : anode_ids) {
180 if (cscDigiMatcher_->nLayersWithWireInChamber(
id) >= minNHitsChamberALCT_)
185 const auto& digi_wgs = cscDigiMatcher_->wiregroupsInChamber(
id, 1);
187 cout <<
"alct: digi_wgs " << ch_id <<
" ";
188 copy(digi_wgs.begin(), digi_wgs.end(), ostream_iterator<int>(
cout,
" "));
197 const auto& alcts_in_det = alcts.get(ch_id2);
198 for (
auto a = alcts_in_det.first;
a != alcts_in_det.second; ++
a) {
203 edm::LogInfo(
"CSCStubMatcher") <<
"alct " << ch_id <<
" " << *
a;
206 if (
a->getBX() < minBXALCT_ ||
a->getBX() > maxBXALCT_)
209 int wg =
a->getKeyWG() + 1;
212 chamber_to_alcts_all_[
id].push_back(*
a);
215 if (digi_wgs.find(wg) == digi_wgs.end()) {
222 if (
std::find(chamber_to_alcts_[
id].begin(), chamber_to_alcts_[
id].
end(), *
a) == chamber_to_alcts_[
id].
end()) {
223 chamber_to_alcts_[
id].push_back(*
a);
226 if (chamber_to_alcts_[
id].
size() > 2) {
227 edm::LogInfo(
"CSCStubMatcher") <<
"WARNING!!! too many ALCTs " << chamber_to_alcts_[
id].size() <<
" in " << ch_id;
228 for (
auto&
a : chamber_to_alcts_[
id])
236 const auto& cathode_ids = chamberIdsAllCLCT(0);
237 const auto& anode_ids = chamberIdsAllALCT(0);
239 std::set<int> cathode_and_anode_ids;
240 std::set_union(cathode_ids.begin(),
244 std::inserter(cathode_and_anode_ids, cathode_and_anode_ids.end()));
246 for (
const auto&
id : cathode_and_anode_ids) {
257 const auto& lcts_in_det = lcts.get(ch_id2);
259 std::map<int, CSCCorrelatedLCTDigiContainer> bx_to_lcts;
263 for (
auto lct = lcts_in_det.first; lct != lcts_in_det.second; ++lct) {
266 lcts_tmp.push_back(*lct);
267 int bx = lct->getBX();
268 bx_to_lcts[
bx].push_back(*lct);
272 if (bx_to_lcts[
bx].
size() == 2 and addGhostLCTs_) {
275 auto lct11 = bx_to_lcts[
bx][0];
276 auto lct22 = bx_to_lcts[
bx][1];
277 int wg1 = lct11.getKeyWG();
278 int wg2 = lct22.getKeyWG();
279 int hs1 = lct11.getStrip();
280 int hs2 = lct22.getStrip();
286 lct12.
setALCT(lct22.getALCT());
287 lcts_tmp.push_back(lct12);
291 lct21.
setALCT(lct11.getALCT());
292 lcts_tmp.push_back(lct21);
298 for (
const auto& lct : lcts_tmp) {
301 bool lct_clct_match(
false);
302 bool lct_alct_match(
false);
303 bool lct_gem1_match(
false);
304 bool lct_gem2_match(
false);
307 edm::LogInfo(
"CSCStubMatcher") << ch_id <<
" " << ch_id2;
309 edm::LogInfo(
"CSCStubMatcher") <<
"getCLCT " << lct.getCLCT() <<
"\ngetALCT " << lct.getALCT() <<
"\ngetGEM1 "
310 << lct.getGEM1() <<
"\ngetGEM2 " << lct.getGEM2();
313 for (
const auto&
p : clctsInChamber(
id)) {
314 if (
p == lct.getCLCT()) {
315 lct_clct_match =
true;
317 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_clct_match";
323 for (
const auto&
p : alctsInChamber(
id)) {
324 if (
p == lct.getALCT()) {
325 lct_alct_match =
true;
327 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_alct_match";
336 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL1.rawId())) {
337 if (
p == lct.getGEM1()) {
338 lct_gem1_match =
true;
340 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_gem1_match";
347 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL2.rawId())) {
348 if (
p == lct.getGEM2()) {
349 lct_gem2_match =
true;
351 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_gem2_match";
357 const bool alct_clct = lct_clct_match and lct_alct_match;
358 const bool alct_gem = lct_alct_match and lct_gem1_match and lct_gem2_match;
359 const bool clct_gem = lct_clct_match and lct_gem1_match and lct_gem2_match;
361 bool lct_tight_matched = alct_clct
or alct_gem
or clct_gem;
362 bool lct_loose_matched = lct_clct_match
or lct_alct_match;
363 bool lct_matched = lct_loose_matched
or lct_tight_matched;
368 if (
std::find(chamber_to_lcts_[
id].begin(), chamber_to_lcts_[
id].
end(), lct) == chamber_to_lcts_[
id].
end()) {
369 chamber_to_lcts_[
id].emplace_back(lct);
379 const auto& lcts_ids = chamberIdsLCT(0);
382 for (
const auto&
id : lcts_ids) {
383 const auto& mplcts_in_det = mplcts.get(
id);
386 for (
auto lct = mplcts_in_det.first; lct != mplcts_in_det.second; ++lct) {
390 chamber_to_mplcts_all_[
id].emplace_back(*lct);
393 for (
const auto& sim_stub : lctsInChamber(
id)) {
394 if (sim_stub == *lct) {
395 if (
std::find(chamber_to_mplcts_[
id].begin(), chamber_to_mplcts_[
id].
end(), *lct) ==
396 chamber_to_mplcts_[
id].
end()) {
397 chamber_to_mplcts_[
id].emplace_back(*lct);
406 return selectDetIds(chamber_to_clcts_all_, csc_type);
410 return selectDetIds(chamber_to_alcts_all_, csc_type);
414 return selectDetIds(chamber_to_lcts_all_, csc_type);
418 return selectDetIds(chamber_to_mplcts_all_, csc_type);
422 return selectDetIds(chamber_to_clcts_, csc_type);
426 return selectDetIds(chamber_to_alcts_, csc_type);
430 return selectDetIds(chamber_to_lcts_, csc_type);
434 return selectDetIds(chamber_to_mplcts_, csc_type);
438 if (chamber_to_clcts_all_.find(detid) == chamber_to_clcts_all_.end())
440 return chamber_to_clcts_all_.at(detid);
444 if (chamber_to_alcts_all_.find(detid) == chamber_to_alcts_all_.end())
446 return chamber_to_alcts_all_.at(detid);
450 if (chamber_to_lcts_all_.find(detid) == chamber_to_lcts_all_.end())
452 return chamber_to_lcts_all_.at(detid);
456 if (chamber_to_mplcts_all_.find(detid) == chamber_to_mplcts_all_.end())
458 return chamber_to_mplcts_all_.at(detid);
462 if (chamber_to_clcts_.find(detid) == chamber_to_clcts_.end())
464 return chamber_to_clcts_.at(detid);
468 if (chamber_to_alcts_.find(detid) == chamber_to_alcts_.end())
470 return chamber_to_alcts_.at(detid);
474 if (chamber_to_lcts_.find(detid) == chamber_to_lcts_.end())
476 return chamber_to_lcts_.at(detid);
480 if (chamber_to_mplcts_.find(detid) == chamber_to_mplcts_.end())
482 return chamber_to_mplcts_.at(detid);
487 const auto&
input(clctsInChamber(detid));
490 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
504 const auto&
input(alctsInChamber(detid));
507 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
521 const auto&
input(lctsInChamber(detid));
524 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
538 const auto&
chamber(cscGeometry_->chamber(
id));
539 return fabs(
chamber->layer(layer)->centerOfStrip(20).z());
544 const auto& chamber_ids = chamberIdsCLCT();
545 for (
const auto&
id : chamber_ids) {
546 int nStubChamber = 0;
547 const auto& clcts = clctsInChamber(
id);
548 for (
const auto& clct : clcts) {
551 if (clct.getQuality() >= min_quality) {
555 if (nStubChamber > 0) {
564 const auto& chamber_ids = chamberIdsALCT();
565 for (
const auto&
id : chamber_ids) {
566 int nStubChamber = 0;
567 const auto& alcts = alctsInChamber(
id);
568 for (
const auto& alct : alcts) {
571 if (alct.getQuality() >= min_quality) {
575 if (nStubChamber > 0) {
584 const auto& chamber_ids = chamberIdsLCT();
585 for (
const auto&
id : chamber_ids) {
586 int nStubChamber = 0;
587 const auto& lcts = lctsInChamber(
id);
588 for (
const auto& lct : lcts) {
591 if (lct.getQuality() >= min_quality) {
595 if (nStubChamber > 0) {
604 const auto& chamber_ids = chamberIdsMPLCT();
605 for (
const auto&
id : chamber_ids) {
606 int nStubChamber = 0;
607 const auto& mplcts = mplctsInChamber(
id);
608 for (
const auto& mplct : mplcts) {
609 if (!mplct.isValid())
611 if (mplct.getQuality() >= min_quality) {
615 if (nStubChamber > 0) {
623 for (
const auto& stub : lctsInChamber(
id.rawId())) {
633 const auto&
chamber = cscGeometry_->chamber(cscId);
637 float wire = layer_geo->middleWireOfGroup(lct.
getKeyWG() + 1);
638 const LocalPoint& csc_intersect = layer_geo->intersectionOfStripAndWire(fractional_strip, wire);
639 const GlobalPoint& csc_gp = cscGeometry_->idToDet(key_id)->surface().toGlobal(csc_intersect);
644 chamber_to_clcts_all_.clear();
645 chamber_to_alcts_all_.clear();
646 chamber_to_lcts_all_.clear();
647 chamber_to_mplcts_all_.clear();
649 chamber_to_clcts_.clear();
650 chamber_to_alcts_.clear();
651 chamber_to_lcts_.clear();
652 chamber_to_mplcts_.clear();