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 matchTypeTightLCT_ =
cscLCT.getParameter<
bool>(
"matchTypeTight");
26 verboseLCT_ =
cscLCT.getParameter<
int>(
"verbose");
27 minNHitsChamberLCT_ =
cscLCT.getParameter<
int>(
"minNHitsChamber");
28 addGhostLCTs_ =
cscLCT.getParameter<
bool>(
"addGhosts");
31 minBXMPLCT_ =
cscMPLCT.getParameter<
int>(
"minBX");
32 maxBXMPLCT_ =
cscMPLCT.getParameter<
int>(
"maxBX");
33 verboseMPLCT_ =
cscMPLCT.getParameter<
int>(
"verbose");
34 minNHitsChamberMPLCT_ =
cscMPLCT.getParameter<
int>(
"minNHitsChamber");
55 gemDigiMatcher_->init(
iEvent, iSetup);
56 cscDigiMatcher_->init(
iEvent, iSetup);
58 iEvent.getByToken(clctToken_, clctsH_);
59 iEvent.getByToken(alctToken_, alctsH_);
60 iEvent.getByToken(lctToken_, lctsH_);
61 iEvent.getByToken(mplctToken_, mplctsH_);
63 cscGeometry_ = &iSetup.
getData(geomToken_);
70 gemDigiMatcher_->match(
t,
v);
71 cscDigiMatcher_->match(
t,
v);
81 if (!alctsH_.isValid()) {
82 edm::LogError(
"CSCStubMatcher") <<
"Cannot get ALCTs with label " << alctInputTag_.encode();
84 matchALCTsToSimTrack(alcts);
87 if (!clctsH_.isValid()) {
88 edm::LogError(
"CSCStubMatcher") <<
"Cannot get CLCTs with label " << clctInputTag_.encode();
90 matchCLCTsToSimTrack(clcts);
93 if (!lctsH_.isValid()) {
94 edm::LogError(
"CSCStubMatcher") <<
"Cannot get LCTs with label " << lctInputTag_.encode();
96 matchLCTsToSimTrack(lcts);
99 if (!mplctsH_.isValid()) {
100 edm::LogError(
"CSCStubMatcher") <<
"Cannot get MPLCTs with label " << mplctInputTag_.encode();
102 matchMPLCTsToSimTrack(mplcts);
107 const auto& cathode_ids = cscDigiMatcher_->chamberIdsStrip(0);
109 for (
const auto&
id : cathode_ids) {
112 edm::LogInfo(
"CSCStubMatcher") <<
"To check CSC chamber " << ch_id;
118 if (cscDigiMatcher_->nLayersWithStripInChamber(ch_id) < minNHitsChamberCLCT_)
122 std::vector<CSCComparatorDigiContainer> comps;
125 comps.push_back(cscDigiMatcher_->comparatorDigisInDetId(layerid));
130 edm::LogInfo(
"CSCStubMatcher") <<
"clct: comparators " << ch_id;
132 for (
const auto&
p : comps) {
134 for (
const auto&
q :
p) {
135 edm::LogInfo(
"CSCStubMatcher") <<
"L" << layer <<
" " <<
q <<
" " <<
q.getHalfStrip() <<
" ";
141 const bool isME1a(ch_id.
station() == 1 and ch_id.
ring() == 4);
145 auto id2 = ch_id2.rawId();
147 const auto& clcts_in_det = clcts.get(ch_id2);
149 for (
auto c = clcts_in_det.first;
c != clcts_in_det.second; ++
c) {
151 edm::LogInfo(
"CSCStubMatcher") <<
"clct " << ch_id2 <<
" " << *
c;
157 if (
c->getBX() < minBXCLCT_ ||
c->getBX() > maxBXCLCT_)
161 chamber_to_clcts_all_[
id2].push_back(*
c);
166 for (
const auto&
p : comps) {
168 for (
const auto&
q :
p) {
170 edm::LogInfo(
"CSCStubMatcher") <<
"L" << layer <<
" " <<
q <<
" " <<
q.getHalfStrip() <<
" " << std::endl;
171 for (
const auto& clctComp : (*c).getHits()[layer - 1]) {
172 if (clctComp == 65535)
175 edm::LogInfo(
"CSCStubMatcher") <<
"\t" << clctComp <<
" ";
177 if (
q.getHalfStrip() == clctComp
or (isME1a and
q.getHalfStrip() + 128 == clctComp)) {
180 edm::LogInfo(
"CSCStubMatcher") <<
"\t\tnMatches " << nMatches << std::endl;
195 if (
std::find(chamber_to_clcts_[
id2].begin(), chamber_to_clcts_[
id2].end(), *
c) == chamber_to_clcts_[
id2].end()) {
196 chamber_to_clcts_[
id2].push_back(*
c);
199 if (chamber_to_clcts_[
id2].size() > 2) {
200 edm::LogInfo(
"CSCStubMatcher") <<
"WARNING!!! too many CLCTs " << chamber_to_clcts_[
id2].size() <<
" in " 202 for (
auto&
c : chamber_to_clcts_[
id2])
209 const auto& anode_ids = cscDigiMatcher_->chamberIdsWire(0);
210 for (
const auto&
id : anode_ids) {
214 const auto& digi_wgs = cscDigiMatcher_->wiregroupsInChamber(
id, 1);
216 cout <<
"alct: digi_wgs " << ch_id <<
" ";
217 copy(digi_wgs.begin(), digi_wgs.end(), ostream_iterator<int>(
cout,
" "));
225 auto id2 = ch_id2.rawId();
227 const auto& alcts_in_det = alcts.get(ch_id2);
228 for (
auto a = alcts_in_det.first;
a != alcts_in_det.second; ++
a) {
233 edm::LogInfo(
"CSCStubMatcher") <<
"alct " << ch_id <<
" " << *
a;
236 if (
a->getBX() < minBXALCT_ ||
a->getBX() > maxBXALCT_)
239 int wg =
a->getKeyWG() + 1;
242 chamber_to_alcts_all_[
id2].push_back(*
a);
245 if (digi_wgs.find(wg) == digi_wgs.end()) {
252 if (
std::find(chamber_to_alcts_[
id2].begin(), chamber_to_alcts_[
id2].end(), *
a) == chamber_to_alcts_[
id2].end()) {
253 chamber_to_alcts_[
id2].push_back(*
a);
256 if (chamber_to_alcts_[
id2].size() > 2) {
257 edm::LogInfo(
"CSCStubMatcher") <<
"WARNING!!! too many ALCTs " << chamber_to_alcts_[
id2].size() <<
" in " 259 for (
auto&
a : chamber_to_alcts_[
id2])
267 const auto& cathode_ids = chamberIdsAllCLCT(0);
268 const auto& anode_ids = chamberIdsAllALCT(0);
270 std::set<int> cathode_and_anode_ids;
271 std::set_union(cathode_ids.begin(),
275 std::inserter(cathode_and_anode_ids, cathode_and_anode_ids.end()));
277 for (
const auto&
id : cathode_and_anode_ids) {
285 auto id2 = ch_id2.rawId();
287 const auto& lcts_in_det = lcts.get(ch_id2);
289 std::map<int, CSCCorrelatedLCTDigiContainer> bx_to_lcts;
293 for (
auto lct = lcts_in_det.first; lct != lcts_in_det.second; ++lct) {
296 lcts_tmp.push_back(*lct);
297 int bx = lct->getBX();
298 bx_to_lcts[
bx].push_back(*lct);
302 if (bx_to_lcts[
bx].size() == 2 and addGhostLCTs_) {
303 auto lct11 = bx_to_lcts[
bx][0];
304 auto lct22 = bx_to_lcts[
bx][1];
305 addGhostLCTs(lct11, lct22, lcts_tmp);
309 for (
const auto& lct : lcts_tmp) {
310 bool lct_clct_match(
false);
311 bool lct_alct_match(
false);
312 bool lct_gem1_match(
false);
313 bool lct_gem2_match(
false);
316 edm::LogInfo(
"CSCStubMatcher") << ch_id <<
" " << ch_id2;
318 edm::LogInfo(
"CSCStubMatcher") <<
"getCLCT " << lct.getCLCT() <<
"\ngetALCT " << lct.getALCT() <<
"\ngetGEM1 " 319 << lct.getGEM1() <<
"\ngetGEM2 " << lct.getGEM2();
322 for (
const auto&
p : clctsInChamber(
id)) {
323 if (
p == lct.getCLCT()) {
324 lct_clct_match =
true;
326 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_clct_match";
332 for (
const auto&
p : alctsInChamber(
id)) {
333 if (
p == lct.getALCT()) {
334 lct_alct_match =
true;
336 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_alct_match";
346 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL1.rawId())) {
347 if (
p == lct.getGEM1()) {
348 lct_gem1_match =
true;
350 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_gem1_match";
357 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL2.rawId())) {
358 if (
p == lct.getGEM2()) {
359 lct_gem2_match =
true;
361 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_gem2_match";
368 const bool alct_clct = lct_clct_match and lct_alct_match;
369 const bool alct_gem = lct_alct_match and lct_gem1_match and lct_gem2_match;
370 const bool clct_gem = lct_clct_match and lct_gem1_match and lct_gem2_match;
372 bool lct_tight_matched = alct_clct
or alct_gem
or clct_gem;
373 bool lct_loose_matched = lct_clct_match
or lct_alct_match;
374 bool lct_matched = matchTypeTightLCT_ ? lct_tight_matched : lct_loose_matched;
379 if (
std::find(chamber_to_lcts_[
id2].begin(), chamber_to_lcts_[
id2].end(), lct) == chamber_to_lcts_[
id2].end()) {
380 chamber_to_lcts_[
id2].emplace_back(lct);
390 const auto& lcts_ids = chamberIdsLCT(0);
393 for (
const auto&
id : lcts_ids) {
394 const auto& mplcts_in_det = mplcts.get(
id);
397 for (
auto lct = mplcts_in_det.first; lct != mplcts_in_det.second; ++lct) {
401 chamber_to_mplcts_all_[
id].emplace_back(*lct);
404 for (
const auto& sim_stub : lctsInChamber(
id)) {
405 if (sim_stub == *lct) {
406 if (
std::find(chamber_to_mplcts_[
id].begin(), chamber_to_mplcts_[
id].end(), *lct) ==
407 chamber_to_mplcts_[
id].end()) {
408 chamber_to_mplcts_[
id].emplace_back(*lct);
417 return selectDetIds(chamber_to_clcts_all_, csc_type);
421 return selectDetIds(chamber_to_alcts_all_, csc_type);
425 return selectDetIds(chamber_to_lcts_all_, csc_type);
429 return selectDetIds(chamber_to_mplcts_all_, csc_type);
433 return selectDetIds(chamber_to_clcts_, csc_type);
437 return selectDetIds(chamber_to_alcts_, csc_type);
441 return selectDetIds(chamber_to_lcts_, csc_type);
445 return selectDetIds(chamber_to_mplcts_, csc_type);
449 if (chamber_to_clcts_all_.find(detid) == chamber_to_clcts_all_.end())
451 return chamber_to_clcts_all_.at(detid);
455 if (chamber_to_alcts_all_.find(detid) == chamber_to_alcts_all_.end())
457 return chamber_to_alcts_all_.at(detid);
461 if (chamber_to_lcts_all_.find(detid) == chamber_to_lcts_all_.end())
463 return chamber_to_lcts_all_.at(detid);
467 if (chamber_to_mplcts_all_.find(detid) == chamber_to_mplcts_all_.end())
469 return chamber_to_mplcts_all_.at(detid);
473 if (chamber_to_clcts_.find(detid) == chamber_to_clcts_.end())
475 return chamber_to_clcts_.at(detid);
479 if (chamber_to_alcts_.find(detid) == chamber_to_alcts_.end())
481 return chamber_to_alcts_.at(detid);
485 if (chamber_to_lcts_.find(detid) == chamber_to_lcts_.end())
487 return chamber_to_lcts_.at(detid);
491 if (chamber_to_mplcts_.find(detid) == chamber_to_mplcts_.end())
493 return chamber_to_mplcts_.at(detid);
498 const auto&
input(clctsInChamber(detid));
501 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
515 const auto&
input(alctsInChamber(detid));
518 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
532 const auto&
input(lctsInChamber(detid));
535 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
549 const auto&
chamber(cscGeometry_->chamber(
id));
550 return fabs(
chamber->layer(layer)->centerOfStrip(20).z());
555 const auto& chamber_ids = chamberIdsCLCT();
556 for (
const auto&
id : chamber_ids) {
557 int nStubChamber = 0;
558 const auto& clcts = clctsInChamber(
id);
559 for (
const auto& clct : clcts) {
562 if (clct.getQuality() >= min_quality) {
566 if (nStubChamber > 0) {
575 const auto& chamber_ids = chamberIdsALCT();
576 for (
const auto&
id : chamber_ids) {
577 int nStubChamber = 0;
578 const auto& alcts = alctsInChamber(
id);
579 for (
const auto& alct : alcts) {
582 if (alct.getQuality() >= min_quality) {
586 if (nStubChamber > 0) {
595 const auto& chamber_ids = chamberIdsLCT();
596 for (
const auto&
id : chamber_ids) {
597 int nStubChamber = 0;
598 const auto& lcts = lctsInChamber(
id);
599 for (
const auto& lct : lcts) {
602 if (lct.getQuality() >= min_quality) {
606 if (nStubChamber > 0) {
615 const auto& chamber_ids = chamberIdsMPLCT();
616 for (
const auto&
id : chamber_ids) {
617 int nStubChamber = 0;
618 const auto& mplcts = mplctsInChamber(
id);
619 for (
const auto& mplct : mplcts) {
620 if (!mplct.isValid())
622 if (mplct.getQuality() >= min_quality) {
626 if (nStubChamber > 0) {
634 for (
const auto& stub : lctsInChamber(
id.
rawId())) {
646 if (cscId.
station() == 1 and (cscId.
ring() == 4 || cscId.
ring() == 1)) {
656 const auto&
chamber = cscGeometry_->chamber(cscId);
659 float wire = layer_geo->middleWireOfGroup(lct.
getKeyWG() + 1);
660 const LocalPoint& csc_intersect = layer_geo->intersectionOfStripAndWire(fractional_strip,
wire);
661 const GlobalPoint& csc_gp = cscGeometry_->idToDet(keyId)->surface().toGlobal(csc_intersect);
666 chamber_to_clcts_all_.clear();
667 chamber_to_alcts_all_.clear();
668 chamber_to_lcts_all_.clear();
669 chamber_to_mplcts_all_.clear();
671 chamber_to_clcts_.clear();
672 chamber_to_alcts_.clear();
673 chamber_to_lcts_.clear();
674 chamber_to_mplcts_.clear();
685 if (!(wg1 == wg2 || hs1 == hs2)) {
691 lcts_tmp.push_back(lct12);
697 lcts_tmp.push_back(lct21);
std::set< unsigned int > chamberIdsAllALCT(int csc_type=MuonHitHelper::CSC_ALL) const
std::vector< CSCCLCTDigi > CSCCLCTDigiContainer
T getParameter(std::string const &) const
const CSCCLCTDigiContainer & allCLCTsInChamber(unsigned int) const
all stubs (not necessarily matching) from a particular crossed chamber
int nChambersWithALCT(int min_quality=0) const
short int zendcap() const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
bool lctInChamber(const CSCDetId &id, const CSCCorrelatedLCTDigi &lct) const
int nChambersWithLCT(int min_quality=0) const
std::set< unsigned int > chamberIdsMPLCT(int csc_type=MuonHitHelper::CSC_ALL) const
int nChambersWithCLCT(int min_quality=0) const
How many CSC chambers with matching stubs of some minimal quality did this SimTrack hit...
const CSCALCTDigiContainer & allALCTsInChamber(unsigned int) const
CSCStubMatcher(edm::ParameterSet const &iPS, edm::ConsumesCollector &&iC)
std::set< unsigned int > chamberIdsAllLCT(int csc_type=MuonHitHelper::CSC_ALL) const
std::set< unsigned int > chamberIdsALCT(int csc_type=MuonHitHelper::CSC_ALL) const
void matchMPLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection &)
std::set< unsigned int > chamberIdsAllCLCT(int csc_type=MuonHitHelper::CSC_ALL) const
crossed chamber detIds with not necessarily matching stubs
GlobalPoint getGlobalPosition(unsigned int rawId, const CSCCorrelatedLCTDigi &lct) const
const CSCCorrelatedLCTDigiContainer & allMPLCTsInChamber(unsigned int) const
std::vector< CSCCorrelatedLCTDigi > CSCCorrelatedLCTDigiContainer
CSCCorrelatedLCTDigi bestLctInChamber(unsigned int) const
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
float zpositionOfLayer(unsigned int detid, int layer) const
static std::string const input
int nChambersWithMPLCT(int min_quality=0) const
std::vector< CSCALCTDigi > CSCALCTDigiContainer
CSCCLCTDigi bestClctInChamber(unsigned int) const
best matching from a particular crossed chamber
std::set< unsigned int > chamberIdsLCT(int csc_type=MuonHitHelper::CSC_ALL) const
const CSCCLCTDigiContainer & clctsInChamber(unsigned int) const
all matching from a particular crossed chamber
void matchLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
const CSCALCTDigiContainer & alctsInChamber(unsigned int) const
const CSCCorrelatedLCTDigiContainer & mplctsInChamber(unsigned int) const
static constexpr int NUM_STRIPS_ME1B
Log< level::Info, false > LogInfo
void matchALCTsToSimTrack(const CSCALCTDigiCollection &)
void matchCLCTsToSimTrack(const CSCCLCTDigiCollection &)
const CSCCorrelatedLCTDigiContainer & lctsInChamber(unsigned int) const
static constexpr int MAX_HALF_STRIP_ME1B
CSCALCTDigi bestAlctInChamber(unsigned int) const
std::set< unsigned int > chamberIdsAllMPLCT(int csc_type=MuonHitHelper::CSC_ALL) const
std::set< unsigned int > chamberIdsCLCT(int csc_type=MuonHitHelper::CSC_ALL) const
chamber detIds with matching stubs
void match(const SimTrack &t, const SimVertex &v)
do the matching
const CSCCorrelatedLCTDigiContainer & allLCTsInChamber(unsigned int) const
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
void addGhostLCTs(const CSCCorrelatedLCTDigi &lct11, const CSCCorrelatedLCTDigi &lct22, CSCCorrelatedLCTDigiContainer &lctcontainer) const