10 minBXCLCT_ =
cscCLCT.getParameter<
int>(
"minBX");
11 maxBXCLCT_ =
cscCLCT.getParameter<
int>(
"maxBX");
12 verboseCLCT_ =
cscCLCT.getParameter<
int>(
"verbose");
13 minNHitsChamberCLCT_ =
cscCLCT.getParameter<
int>(
"minNHitsChamber");
16 minBXALCT_ =
cscALCT.getParameter<
int>(
"minBX");
17 maxBXALCT_ =
cscALCT.getParameter<
int>(
"maxBX");
18 verboseALCT_ =
cscALCT.getParameter<
int>(
"verbose");
19 minNHitsChamberALCT_ =
cscALCT.getParameter<
int>(
"minNHitsChamber");
22 minBXLCT_ =
cscLCT.getParameter<
int>(
"minBX");
23 maxBXLCT_ =
cscLCT.getParameter<
int>(
"maxBX");
24 verboseLCT_ =
cscLCT.getParameter<
int>(
"verbose");
25 minNHitsChamberLCT_ =
cscLCT.getParameter<
int>(
"minNHitsChamber");
26 hsFromSimHitMean_ =
cscLCT.getParameter<
bool>(
"hsFromSimHitMean");
29 minBXMPLCT_ =
cscMPLCT.getParameter<
int>(
"minBX");
30 maxBXMPLCT_ =
cscMPLCT.getParameter<
int>(
"maxBX");
31 verboseMPLCT_ =
cscMPLCT.getParameter<
int>(
"verbose");
32 minNHitsChamberMPLCT_ =
cscMPLCT.getParameter<
int>(
"minNHitsChamber");
44 gemDigiMatcher_->init(
iEvent, iSetup);
45 cscDigiMatcher_->init(
iEvent, iSetup);
47 iEvent.getByToken(clctToken_, clctsH_);
48 iEvent.getByToken(alctToken_, alctsH_);
49 iEvent.getByToken(lctToken_, lctsH_);
50 iEvent.getByToken(mplctToken_, mplctsH_);
53 if (csc_geom_.isValid()) {
54 cscGeometry_ = &*csc_geom_;
56 std::cout <<
"+++ Info: CSC geometry is unavailable. +++\n";
63 gemDigiMatcher_->match(
t,
v);
64 cscDigiMatcher_->match(
t,
v);
71 matchCLCTsToSimTrack(clcts);
72 matchALCTsToSimTrack(alcts);
73 matchLCTsToSimTrack(lcts);
74 matchMPLCTsToSimTrack(mplcts);
78 const auto& cathode_ids = cscDigiMatcher_->chamberIdsStrip(0);
80 for (
const auto&
id : cathode_ids) {
83 cout <<
"To check CSC chamber " << ch_id << endl;
85 if (cscDigiMatcher_->nLayersWithStripInChamber(
id) >= minNHitsChamberCLCT_)
89 const auto& digi_strips = cscDigiMatcher_->stripsInChamber(
id, 1);
91 cout <<
"clct: digi_strips " << ch_id <<
" Nlayers " << cscDigiMatcher_->nLayersWithStripInChamber(
id) <<
" ";
92 copy(digi_strips.begin(), digi_strips.end(), ostream_iterator<int>(
cout,
" "));
101 const auto& clcts_in_det = clcts.get(ch_id2);
103 for (
auto c = clcts_in_det.first;
c != clcts_in_det.second; ++
c) {
105 cout <<
"clct " << ch_id <<
" " << *
c << endl;
111 if (
c->getBX() < minBXCLCT_ ||
c->getBX() > maxBXCLCT_)
114 int half_strip =
c->getKeyStrip() + 1;
115 if (ch_id.
ring() == 4 and ch_id.
station() == 1 and half_strip > 128)
116 half_strip = half_strip - 128;
119 chamber_to_clcts_all_[
id].push_back(*
c);
122 if (digi_strips.find(half_strip) == digi_strips.end()) {
124 cout <<
"clctBAD, half_strip " << half_strip << endl;
128 cout <<
"clctGOOD" << endl;
131 chamber_to_clcts_[
id].push_back(*
c);
133 if (chamber_to_clcts_[
id].
size() > 2) {
134 cout <<
"WARNING!!! too many CLCTs " << chamber_to_clcts_[
id].size() <<
" in " << ch_id << endl;
135 for (
auto&
c : chamber_to_clcts_[
id])
136 cout <<
" " <<
c << endl;
142 const auto& anode_ids = cscDigiMatcher_->chamberIdsWire(0);
144 for (
const auto&
id : anode_ids) {
145 if (cscDigiMatcher_->nLayersWithWireInChamber(
id) >= minNHitsChamberALCT_)
150 const auto& digi_wgs = cscDigiMatcher_->wiregroupsInChamber(
id, 1);
152 cout <<
"alct: digi_wgs " << ch_id <<
" ";
153 copy(digi_wgs.begin(), digi_wgs.end(), ostream_iterator<int>(
cout,
" "));
162 const auto& alcts_in_det = alcts.get(ch_id2);
163 for (
auto a = alcts_in_det.first;
a != alcts_in_det.second; ++
a) {
168 cout <<
"alct " << ch_id <<
" " << *
a << endl;
171 if (
a->getBX() < minBXALCT_ ||
a->getBX() > maxBXALCT_)
174 int wg =
a->getKeyWG() + 1;
177 chamber_to_alcts_all_[
id].push_back(*
a);
180 if (digi_wgs.find(wg) == digi_wgs.end()) {
182 cout <<
"alctBAD" << endl;
186 cout <<
"alctGOOD" << endl;
189 chamber_to_alcts_[
id].push_back(*
a);
191 if (chamber_to_alcts_[
id].
size() > 2) {
192 cout <<
"WARNING!!! too many ALCTs " << chamber_to_alcts_[
id].size() <<
" in " << ch_id << endl;
193 for (
auto&
a : chamber_to_alcts_[
id])
194 cout <<
" " <<
a << endl;
201 const auto& cathode_ids = chamberIdsAllCLCT(0);
202 const auto& anode_ids = chamberIdsAllALCT(0);
204 std::set<int> cathode_and_anode_ids;
205 std::set_union(cathode_ids.begin(),
209 std::inserter(cathode_and_anode_ids, cathode_and_anode_ids.end()));
211 for (
const auto&
id : cathode_and_anode_ids) {
222 const auto& lcts_in_det = lcts.get(ch_id2);
226 for (
auto lct = lcts_in_det.first; lct != lcts_in_det.second; ++lct) {
227 lcts_tmp.push_back(*lct);
230 for (
const auto& lct : lcts_tmp) {
233 bool lct_matched(
false);
234 bool lct_clct_match(
false);
235 bool lct_alct_match(
false);
236 bool lct_gem1_match(
false);
237 bool lct_gem2_match(
false);
240 cout <<
"in LCT, getCLCT " << lct.getCLCT() <<
" getALCT " << lct.getALCT() << endl;
243 for (
const auto&
p : clctsInChamber(
id)) {
244 if (
p == lct.getCLCT()) {
245 lct_clct_match =
true;
251 for (
const auto&
p : alctsInChamber(
id)) {
252 if (
p == lct.getALCT()) {
253 lct_alct_match =
true;
262 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL1.rawId())) {
263 if (
p == lct.getGEM1()) {
264 lct_gem1_match =
true;
271 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL2.rawId())) {
272 if (
p == lct.getGEM2()) {
273 lct_gem2_match =
true;
279 lct_matched = ((lct_clct_match and lct_alct_match)
or (lct_alct_match and lct_gem1_match and lct_gem2_match)
or
280 (lct_clct_match and lct_gem1_match and lct_gem2_match));
284 cout <<
"this LCT matched to simtrack in chamber " << ch_id << endl;
285 chamber_to_lcts_[
id].emplace_back(lct);
294 const auto& lcts_ids = chamberIdsLCT(0);
297 for (
const auto&
id : lcts_ids) {
298 const auto& mplcts_in_det = mplcts.get(
id);
301 for (
auto lct = mplcts_in_det.first; lct != mplcts_in_det.second; ++lct) {
306 chamber_to_mplcts_all_[
id].emplace_back(*lct);
309 for (
const auto& sim_stub : lctsInChamber(
id)) {
310 if (sim_stub == *lct) {
311 chamber_to_mplcts_[
id].emplace_back(*lct);
319 return selectDetIds(chamber_to_clcts_all_, csc_type);
323 return selectDetIds(chamber_to_alcts_all_, csc_type);
327 return selectDetIds(chamber_to_lcts_all_, csc_type);
331 return selectDetIds(chamber_to_mplcts_all_, csc_type);
335 return selectDetIds(chamber_to_clcts_, csc_type);
339 return selectDetIds(chamber_to_alcts_, csc_type);
343 return selectDetIds(chamber_to_lcts_, csc_type);
347 return selectDetIds(chamber_to_mplcts_, csc_type);
351 if (chamber_to_clcts_all_.find(detid) == chamber_to_clcts_all_.end())
353 return chamber_to_clcts_all_.at(detid);
357 if (chamber_to_alcts_all_.find(detid) == chamber_to_alcts_all_.end())
359 return chamber_to_alcts_all_.at(detid);
363 if (chamber_to_lcts_all_.find(detid) == chamber_to_lcts_all_.end())
365 return chamber_to_lcts_all_.at(detid);
369 if (chamber_to_mplcts_all_.find(detid) == chamber_to_mplcts_all_.end())
371 return chamber_to_mplcts_all_.at(detid);
375 if (chamber_to_clcts_.find(detid) == chamber_to_clcts_.end())
377 return chamber_to_clcts_.at(detid);
381 if (chamber_to_alcts_.find(detid) == chamber_to_alcts_.end())
383 return chamber_to_alcts_.at(detid);
387 if (chamber_to_lcts_.find(detid) == chamber_to_lcts_.end())
389 return chamber_to_lcts_.at(detid);
393 if (chamber_to_mplcts_.find(detid) == chamber_to_mplcts_.end())
395 return chamber_to_mplcts_.at(detid);
400 const auto&
input(clctsInChamber(detid));
403 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
417 const auto&
input(alctsInChamber(detid));
420 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
434 const auto&
input(lctsInChamber(detid));
437 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
451 const auto&
chamber(cscGeometry_->chamber(
id));
452 return fabs(
chamber->layer(layer)->centerOfStrip(20).z());
457 const auto& chamber_ids = chamberIdsCLCT();
458 for (
const auto&
id : chamber_ids) {
459 int nStubChamber = 0;
460 const auto& clcts = clctsInChamber(
id);
461 for (
const auto& clct : clcts) {
464 if (clct.getQuality() >= min_quality) {
468 if (nStubChamber > 0) {
477 const auto& chamber_ids = chamberIdsALCT();
478 for (
const auto&
id : chamber_ids) {
479 int nStubChamber = 0;
480 const auto& alcts = alctsInChamber(
id);
481 for (
const auto& alct : alcts) {
484 if (alct.getQuality() >= min_quality) {
488 if (nStubChamber > 0) {
497 const auto& chamber_ids = chamberIdsLCT();
498 for (
const auto&
id : chamber_ids) {
499 int nStubChamber = 0;
500 const auto& lcts = lctsInChamber(
id);
501 for (
const auto& lct : lcts) {
504 if (lct.getQuality() >= min_quality) {
508 if (nStubChamber > 0) {
517 const auto& chamber_ids = chamberIdsMPLCT();
518 for (
const auto&
id : chamber_ids) {
519 int nStubChamber = 0;
520 const auto& mplcts = mplctsInChamber(
id);
521 for (
const auto& mplct : mplcts) {
522 if (!mplct.isValid())
524 if (mplct.getQuality() >= min_quality) {
528 if (nStubChamber > 0) {
536 for (
const auto& stub : lctsInChamber(
id.rawId())) {
546 const auto&
chamber = cscGeometry_->chamber(cscId);
550 float wire = layer_geo->middleWireOfGroup(lct.
getKeyWG() + 1);
551 const LocalPoint& csc_intersect = layer_geo->intersectionOfStripAndWire(fractional_strip, wire);
552 const GlobalPoint& csc_gp = cscGeometry_->idToDet(key_id)->surface().toGlobal(csc_intersect);