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;
98 for (
int ilayer = 1; ilayer <= 6; ilayer++) {
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_) {
280 auto lct11 = bx_to_lcts[
bx][0];
281 auto lct22 = bx_to_lcts[
bx][1];
282 int wg1 = lct11.getKeyWG();
283 int wg2 = lct22.getKeyWG();
284 int hs1 = lct11.getStrip();
285 int hs2 = lct22.getStrip();
291 lct12.
setALCT(lct22.getALCT());
292 lcts_tmp.push_back(lct12);
296 lct21.
setALCT(lct11.getALCT());
297 lcts_tmp.push_back(lct21);
303 for (
const auto& lct : lcts_tmp) {
306 bool lct_clct_match(
false);
307 bool lct_alct_match(
false);
308 bool lct_gem1_match(
false);
309 bool lct_gem2_match(
false);
312 edm::LogInfo(
"CSCStubMatcher") << ch_id <<
" " << ch_id2;
314 edm::LogInfo(
"CSCStubMatcher") <<
"getCLCT " << lct.getCLCT() <<
"\ngetALCT " << lct.getALCT() <<
"\ngetGEM1 "
315 << lct.getGEM1() <<
"\ngetGEM2 " << lct.getGEM2();
318 for (
const auto&
p : clctsInChamber(
id)) {
319 if (
p == lct.getCLCT()) {
320 lct_clct_match =
true;
322 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_clct_match";
328 for (
const auto&
p : alctsInChamber(
id)) {
329 if (
p == lct.getALCT()) {
330 lct_alct_match =
true;
332 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_alct_match";
342 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL1.rawId())) {
343 if (
p == lct.getGEM1()) {
344 lct_gem1_match =
true;
346 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_gem1_match";
353 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL2.rawId())) {
354 if (
p == lct.getGEM2()) {
355 lct_gem2_match =
true;
357 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_gem2_match";
364 const bool alct_clct = lct_clct_match and lct_alct_match;
365 const bool alct_gem = lct_alct_match and lct_gem1_match and lct_gem2_match;
366 const bool clct_gem = lct_clct_match and lct_gem1_match and lct_gem2_match;
368 bool lct_tight_matched = alct_clct
or alct_gem
or clct_gem;
369 bool lct_loose_matched = lct_clct_match
or lct_alct_match;
370 bool lct_matched = lct_loose_matched
or lct_tight_matched;
375 if (
std::find(chamber_to_lcts_[
id].begin(), chamber_to_lcts_[
id].
end(), lct) == chamber_to_lcts_[
id].
end()) {
376 chamber_to_lcts_[
id].emplace_back(lct);
386 const auto& lcts_ids = chamberIdsLCT(0);
389 for (
const auto&
id : lcts_ids) {
390 const auto& mplcts_in_det = mplcts.get(
id);
393 for (
auto lct = mplcts_in_det.first; lct != mplcts_in_det.second; ++lct) {
397 chamber_to_mplcts_all_[
id].emplace_back(*lct);
400 for (
const auto& sim_stub : lctsInChamber(
id)) {
401 if (sim_stub == *lct) {
402 if (
std::find(chamber_to_mplcts_[
id].begin(), chamber_to_mplcts_[
id].
end(), *lct) ==
403 chamber_to_mplcts_[
id].
end()) {
404 chamber_to_mplcts_[
id].emplace_back(*lct);
413 return selectDetIds(chamber_to_clcts_all_, csc_type);
417 return selectDetIds(chamber_to_alcts_all_, csc_type);
421 return selectDetIds(chamber_to_lcts_all_, csc_type);
425 return selectDetIds(chamber_to_mplcts_all_, csc_type);
429 return selectDetIds(chamber_to_clcts_, csc_type);
433 return selectDetIds(chamber_to_alcts_, csc_type);
437 return selectDetIds(chamber_to_lcts_, csc_type);
441 return selectDetIds(chamber_to_mplcts_, csc_type);
445 if (chamber_to_clcts_all_.find(detid) == chamber_to_clcts_all_.end())
447 return chamber_to_clcts_all_.at(detid);
451 if (chamber_to_alcts_all_.find(detid) == chamber_to_alcts_all_.end())
453 return chamber_to_alcts_all_.at(detid);
457 if (chamber_to_lcts_all_.find(detid) == chamber_to_lcts_all_.end())
459 return chamber_to_lcts_all_.at(detid);
463 if (chamber_to_mplcts_all_.find(detid) == chamber_to_mplcts_all_.end())
465 return chamber_to_mplcts_all_.at(detid);
469 if (chamber_to_clcts_.find(detid) == chamber_to_clcts_.end())
471 return chamber_to_clcts_.at(detid);
475 if (chamber_to_alcts_.find(detid) == chamber_to_alcts_.end())
477 return chamber_to_alcts_.at(detid);
481 if (chamber_to_lcts_.find(detid) == chamber_to_lcts_.end())
483 return chamber_to_lcts_.at(detid);
487 if (chamber_to_mplcts_.find(detid) == chamber_to_mplcts_.end())
489 return chamber_to_mplcts_.at(detid);
494 const auto&
input(clctsInChamber(detid));
497 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
511 const auto&
input(alctsInChamber(detid));
514 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
528 const auto&
input(lctsInChamber(detid));
531 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
545 const auto&
chamber(cscGeometry_->chamber(
id));
546 return fabs(
chamber->layer(
layer)->centerOfStrip(20).z());
551 const auto& chamber_ids = chamberIdsCLCT();
552 for (
const auto&
id : chamber_ids) {
553 int nStubChamber = 0;
554 const auto& clcts = clctsInChamber(
id);
555 for (
const auto& clct : clcts) {
558 if (clct.getQuality() >= min_quality) {
562 if (nStubChamber > 0) {
571 const auto& chamber_ids = chamberIdsALCT();
572 for (
const auto&
id : chamber_ids) {
573 int nStubChamber = 0;
574 const auto& alcts = alctsInChamber(
id);
575 for (
const auto& alct : alcts) {
578 if (alct.getQuality() >= min_quality) {
582 if (nStubChamber > 0) {
591 const auto& chamber_ids = chamberIdsLCT();
592 for (
const auto&
id : chamber_ids) {
593 int nStubChamber = 0;
594 const auto& lcts = lctsInChamber(
id);
595 for (
const auto& lct : lcts) {
598 if (lct.getQuality() >= min_quality) {
602 if (nStubChamber > 0) {
611 const auto& chamber_ids = chamberIdsMPLCT();
612 for (
const auto&
id : chamber_ids) {
613 int nStubChamber = 0;
614 const auto& mplcts = mplctsInChamber(
id);
615 for (
const auto& mplct : mplcts) {
616 if (!mplct.isValid())
618 if (mplct.getQuality() >= min_quality) {
622 if (nStubChamber > 0) {
630 for (
const auto& stub : lctsInChamber(
id.rawId())) {
646 const auto&
chamber = cscGeometry_->chamber(cscId);
649 float wire = layer_geo->middleWireOfGroup(lct.
getKeyWG() + 1);
650 const LocalPoint& csc_intersect = layer_geo->intersectionOfStripAndWire(fractional_strip, wire);
651 const GlobalPoint& csc_gp = cscGeometry_->idToDet(keyId)->surface().toGlobal(csc_intersect);
656 chamber_to_clcts_all_.clear();
657 chamber_to_alcts_all_.clear();
658 chamber_to_lcts_all_.clear();
659 chamber_to_mplcts_all_.clear();
661 chamber_to_clcts_.clear();
662 chamber_to_alcts_.clear();
663 chamber_to_lcts_.clear();
664 chamber_to_mplcts_.clear();