12 maxBXCLCT_ = cscCLCT.getParameter<
int>(
"maxBX");
13 verboseCLCT_ = cscCLCT.getParameter<
int>(
"verbose");
14 minNHitsChamberCLCT_ = cscCLCT.getParameter<
int>(
"minNHitsChamber");
18 maxBXALCT_ = cscALCT.getParameter<
int>(
"maxBX");
19 verboseALCT_ = cscALCT.getParameter<
int>(
"verbose");
20 minNHitsChamberALCT_ = cscALCT.getParameter<
int>(
"minNHitsChamber");
24 maxBXLCT_ = cscLCT.getParameter<
int>(
"maxBX");
25 verboseLCT_ = cscLCT.getParameter<
int>(
"verbose");
26 minNHitsChamberLCT_ = cscLCT.getParameter<
int>(
"minNHitsChamber");
27 addGhostLCTs_ = cscLCT.getParameter<
bool>(
"addGhosts");
31 maxBXMPLCT_ = cscMPLCT.getParameter<
int>(
"maxBX");
32 verboseMPLCT_ = cscMPLCT.getParameter<
int>(
"verbose");
33 minNHitsChamberMPLCT_ = cscMPLCT.getParameter<
int>(
"minNHitsChamber");
39 clctInputTag_ = cscCLCT.getParameter<
edm::InputTag>(
"inputTag");
40 alctInputTag_ = cscALCT.getParameter<
edm::InputTag>(
"inputTag");
41 lctInputTag_ = cscLCT.getParameter<
edm::InputTag>(
"inputTag");
42 mplctInputTag_ = cscMPLCT.getParameter<
edm::InputTag>(
"inputTag");
54 gemDigiMatcher_->init(iEvent, iSetup);
55 cscDigiMatcher_->init(iEvent, iSetup);
62 cscGeometry_ = &iSetup.
getData(geomToken_);
69 gemDigiMatcher_->match(t, v);
70 cscDigiMatcher_->match(t, v);
80 if (!alctsH_.isValid()) {
81 edm::LogError(
"CSCStubMatcher") <<
"Cannot get ALCTs with label " << alctInputTag_.encode();
83 matchALCTsToSimTrack(alcts);
86 if (!clctsH_.isValid()) {
87 edm::LogError(
"CSCStubMatcher") <<
"Cannot get CLCTs with label " << clctInputTag_.encode();
89 matchCLCTsToSimTrack(clcts);
92 if (!lctsH_.isValid()) {
93 edm::LogError(
"CSCStubMatcher") <<
"Cannot get LCTs with label " << lctInputTag_.encode();
95 matchLCTsToSimTrack(lcts);
98 if (!mplctsH_.isValid()) {
99 edm::LogError(
"CSCStubMatcher") <<
"Cannot get MPLCTs with label " << mplctInputTag_.encode();
101 matchMPLCTsToSimTrack(mplcts);
106 const auto& cathode_ids = cscDigiMatcher_->chamberIdsStrip(0);
108 for (
const auto&
id : cathode_ids) {
111 edm::LogInfo(
"CSCStubMatcher") <<
"To check CSC chamber " << ch_id;
117 if (cscDigiMatcher_->nLayersWithStripInChamber(ch_id) < minNHitsChamberCLCT_)
121 std::vector<CSCComparatorDigiContainer> comps;
124 comps.push_back(cscDigiMatcher_->comparatorDigisInDetId(layerid));
129 edm::LogInfo(
"CSCStubMatcher") <<
"clct: comparators " << ch_id;
131 for (
const auto&
p : comps) {
133 for (
const auto&
q :
p) {
134 edm::LogInfo(
"CSCStubMatcher") <<
"L" << layer <<
" " <<
q <<
" " <<
q.getHalfStrip() <<
" ";
140 const bool isME1a(ch_id.
station() == 1 and ch_id.
ring() == 4);
144 auto id2 = ch_id2.
rawId();
146 const auto& clcts_in_det = clcts.get(ch_id2);
148 for (
auto c = clcts_in_det.first;
c != clcts_in_det.second; ++
c) {
150 edm::LogInfo(
"CSCStubMatcher") <<
"clct " << ch_id2 <<
" " << *
c;
156 if (c->getBX() < minBXCLCT_ || c->getBX() > maxBXCLCT_)
160 chamber_to_clcts_all_[id2].push_back(*c);
165 for (
const auto&
p : comps) {
167 for (
const auto&
q :
p) {
169 edm::LogInfo(
"CSCStubMatcher") <<
"L" << layer <<
" " <<
q <<
" " <<
q.getHalfStrip() <<
" " << std::endl;
170 for (
const auto& clctComp : (*c).getHits()[layer - 1]) {
171 if (clctComp == 65535)
174 edm::LogInfo(
"CSCStubMatcher") <<
"\t" << clctComp <<
" ";
176 if (
q.getHalfStrip() == clctComp
or (isME1a and
q.getHalfStrip() + 128 == clctComp)) {
179 edm::LogInfo(
"CSCStubMatcher") <<
"\t\tnMatches " << nMatches << std::endl;
194 if (
std::find(chamber_to_clcts_[id2].
begin(), chamber_to_clcts_[id2].
end(), *c) == chamber_to_clcts_[id2].
end()) {
195 chamber_to_clcts_[id2].push_back(*c);
198 if (chamber_to_clcts_[id2].
size() > 2) {
199 edm::LogInfo(
"CSCStubMatcher") <<
"WARNING!!! too many CLCTs " << chamber_to_clcts_[id2].size() <<
" in " << ch_id2;
200 for (
auto&
c : chamber_to_clcts_[id2])
207 const auto& anode_ids = cscDigiMatcher_->chamberIdsWire(0);
209 for (
const auto&
id : anode_ids) {
210 if (cscDigiMatcher_->nLayersWithWireInChamber(
id) >= minNHitsChamberALCT_)
215 const auto& digi_wgs = cscDigiMatcher_->wiregroupsInChamber(
id, 1);
217 cout <<
"alct: digi_wgs " << ch_id <<
" ";
218 copy(digi_wgs.begin(), digi_wgs.end(), ostream_iterator<int>(
cout,
" "));
226 auto id2 = ch_id2.
rawId();
228 const auto& alcts_in_det = alcts.get(ch_id2);
229 for (
auto a = alcts_in_det.first;
a != alcts_in_det.second; ++
a) {
234 edm::LogInfo(
"CSCStubMatcher") <<
"alct " << ch_id <<
" " << *
a;
237 if (a->getBX() < minBXALCT_ || a->getBX() > maxBXALCT_)
240 int wg = a->getKeyWG() + 1;
243 chamber_to_alcts_all_[id2].push_back(*a);
246 if (digi_wgs.find(wg) == digi_wgs.end()) {
253 if (
std::find(chamber_to_alcts_[id2].
begin(), chamber_to_alcts_[id2].
end(), *a) == chamber_to_alcts_[id2].
end()) {
254 chamber_to_alcts_[id2].push_back(*a);
257 if (chamber_to_alcts_[id2].
size() > 2) {
258 edm::LogInfo(
"CSCStubMatcher") <<
"WARNING!!! too many ALCTs " << chamber_to_alcts_[id2].size() <<
" in " << ch_id;
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) {
287 auto id2 = ch_id2.
rawId();
289 const auto& lcts_in_det = lcts.get(ch_id2);
291 std::map<int, CSCCorrelatedLCTDigiContainer> bx_to_lcts;
295 for (
auto lct = lcts_in_det.first; lct != lcts_in_det.second; ++lct) {
298 lcts_tmp.push_back(*lct);
299 int bx = lct->getBX();
300 bx_to_lcts[
bx].push_back(*lct);
304 if (bx_to_lcts[bx].
size() == 2 and addGhostLCTs_) {
305 auto lct11 = bx_to_lcts[
bx][0];
306 auto lct22 = bx_to_lcts[
bx][1];
307 addGhostLCTs(lct11, lct22, lcts_tmp);
311 for (
const auto& lct : lcts_tmp) {
314 bool lct_clct_match(
false);
315 bool lct_alct_match(
false);
316 bool lct_gem1_match(
false);
317 bool lct_gem2_match(
false);
320 edm::LogInfo(
"CSCStubMatcher") << ch_id <<
" " << ch_id2;
322 edm::LogInfo(
"CSCStubMatcher") <<
"getCLCT " << lct.getCLCT() <<
"\ngetALCT " << lct.getALCT() <<
"\ngetGEM1 "
323 << lct.getGEM1() <<
"\ngetGEM2 " << lct.getGEM2();
326 for (
const auto&
p : clctsInChamber(
id)) {
327 if (
p == lct.getCLCT()) {
328 lct_clct_match =
true;
330 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_clct_match";
336 for (
const auto&
p : alctsInChamber(
id)) {
337 if (
p == lct.getALCT()) {
338 lct_alct_match =
true;
340 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_alct_match";
350 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL1.rawId())) {
351 if (
p == lct.getGEM1()) {
352 lct_gem1_match =
true;
354 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_gem1_match";
361 for (
const auto&
p : gemDigiMatcher_->padsInChamber(gemDetIdL2.rawId())) {
362 if (
p == lct.getGEM2()) {
363 lct_gem2_match =
true;
365 edm::LogInfo(
"CSCStubMatcher") <<
"\t...lct_gem2_match";
372 const bool alct_clct = lct_clct_match and lct_alct_match;
373 const bool alct_gem = lct_alct_match and lct_gem1_match and lct_gem2_match;
374 const bool clct_gem = lct_clct_match and lct_gem1_match and lct_gem2_match;
376 bool lct_tight_matched = alct_clct
or alct_gem
or clct_gem;
377 bool lct_loose_matched = lct_clct_match
or lct_alct_match;
378 bool lct_matched = lct_loose_matched
or lct_tight_matched;
383 if (
std::find(chamber_to_lcts_[id2].
begin(), chamber_to_lcts_[id2].
end(), lct) == chamber_to_lcts_[id2].
end()) {
384 chamber_to_lcts_[id2].emplace_back(lct);
394 const auto& lcts_ids = chamberIdsLCT(0);
397 for (
const auto&
id : lcts_ids) {
398 const auto& mplcts_in_det = mplcts.get(
id);
401 for (
auto lct = mplcts_in_det.first; lct != mplcts_in_det.second; ++lct) {
405 chamber_to_mplcts_all_[
id].emplace_back(*lct);
408 for (
const auto& sim_stub : lctsInChamber(
id)) {
409 if (sim_stub == *lct) {
410 if (
std::find(chamber_to_mplcts_[
id].
begin(), chamber_to_mplcts_[
id].
end(), *lct) ==
411 chamber_to_mplcts_[
id].
end()) {
412 chamber_to_mplcts_[
id].emplace_back(*lct);
421 return selectDetIds(chamber_to_clcts_all_, csc_type);
425 return selectDetIds(chamber_to_alcts_all_, csc_type);
429 return selectDetIds(chamber_to_lcts_all_, csc_type);
433 return selectDetIds(chamber_to_mplcts_all_, csc_type);
437 return selectDetIds(chamber_to_clcts_, csc_type);
441 return selectDetIds(chamber_to_alcts_, csc_type);
445 return selectDetIds(chamber_to_lcts_, csc_type);
449 return selectDetIds(chamber_to_mplcts_, csc_type);
453 if (chamber_to_clcts_all_.find(detid) == chamber_to_clcts_all_.end())
455 return chamber_to_clcts_all_.at(detid);
459 if (chamber_to_alcts_all_.find(detid) == chamber_to_alcts_all_.end())
461 return chamber_to_alcts_all_.at(detid);
465 if (chamber_to_lcts_all_.find(detid) == chamber_to_lcts_all_.end())
467 return chamber_to_lcts_all_.at(detid);
471 if (chamber_to_mplcts_all_.find(detid) == chamber_to_mplcts_all_.end())
473 return chamber_to_mplcts_all_.at(detid);
477 if (chamber_to_clcts_.find(detid) == chamber_to_clcts_.end())
479 return chamber_to_clcts_.at(detid);
483 if (chamber_to_alcts_.find(detid) == chamber_to_alcts_.end())
485 return chamber_to_alcts_.at(detid);
489 if (chamber_to_lcts_.find(detid) == chamber_to_lcts_.end())
491 return chamber_to_lcts_.at(detid);
495 if (chamber_to_mplcts_.find(detid) == chamber_to_mplcts_.end())
497 return chamber_to_mplcts_.at(detid);
502 const auto&
input(clctsInChamber(detid));
505 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
507 if (quality > bestQ) {
519 const auto&
input(alctsInChamber(detid));
522 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
524 if (quality > bestQ) {
536 const auto&
input(lctsInChamber(detid));
539 for (
unsigned int i = 0;
i <
input.size(); ++
i) {
541 if (quality > bestQ) {
553 const auto& chamber(cscGeometry_->chamber(
id));
554 return fabs(chamber->layer(layer)->centerOfStrip(20).z());
559 const auto& chamber_ids = chamberIdsCLCT();
560 for (
const auto&
id : chamber_ids) {
561 int nStubChamber = 0;
562 const auto& clcts = clctsInChamber(
id);
563 for (
const auto& clct : clcts) {
566 if (clct.getQuality() >= min_quality) {
570 if (nStubChamber > 0) {
579 const auto& chamber_ids = chamberIdsALCT();
580 for (
const auto&
id : chamber_ids) {
581 int nStubChamber = 0;
582 const auto& alcts = alctsInChamber(
id);
583 for (
const auto& alct : alcts) {
586 if (alct.getQuality() >= min_quality) {
590 if (nStubChamber > 0) {
599 const auto& chamber_ids = chamberIdsLCT();
600 for (
const auto&
id : chamber_ids) {
601 int nStubChamber = 0;
602 const auto& lcts = lctsInChamber(
id);
603 for (
const auto& lct : lcts) {
606 if (lct.getQuality() >= min_quality) {
610 if (nStubChamber > 0) {
619 const auto& chamber_ids = chamberIdsMPLCT();
620 for (
const auto&
id : chamber_ids) {
621 int nStubChamber = 0;
622 const auto& mplcts = mplctsInChamber(
id);
623 for (
const auto& mplct : mplcts) {
624 if (!mplct.isValid())
626 if (mplct.getQuality() >= min_quality) {
630 if (nStubChamber > 0) {
638 for (
const auto& stub : lctsInChamber(
id.rawId())) {
650 if (cscId.
station() == 1 and (cscId.
ring() == 4 || cscId.
ring() == 1)) {
660 const auto& chamber = cscGeometry_->
chamber(cscId);
663 float wire = layer_geo->middleWireOfGroup(lct.
getKeyWG() + 1);
664 const LocalPoint& csc_intersect = layer_geo->intersectionOfStripAndWire(fractional_strip, wire);
665 const GlobalPoint& csc_gp = cscGeometry_->idToDet(keyId)->surface().toGlobal(csc_intersect);
670 chamber_to_clcts_all_.clear();
671 chamber_to_alcts_all_.clear();
672 chamber_to_lcts_all_.clear();
673 chamber_to_mplcts_all_.clear();
675 chamber_to_clcts_.clear();
676 chamber_to_alcts_.clear();
677 chamber_to_lcts_.clear();
678 chamber_to_mplcts_.clear();
689 if (!(wg1 == wg2 || hs1 == hs2)) {
695 lcts_tmp.push_back(lct12);
701 lcts_tmp.push_back(lct21);
std::set< unsigned int > chamberIdsAllMPLCT(int csc_type=MuonHitHelper::CSC_ALL) const
std::set< unsigned int > chamberIdsLCT(int csc_type=MuonHitHelper::CSC_ALL) const
std::vector< CSCCLCTDigi > CSCCLCTDigiContainer
int nChambersWithMPLCT(int min_quality=0) const
const edm::EventSetup & c
void addGhostLCTs(const CSCCorrelatedLCTDigi &lct11, const CSCCorrelatedLCTDigi &lct22, CSCCorrelatedLCTDigiContainer &lctcontainer) const
float zpositionOfLayer(unsigned int detid, int layer) const
uint16_t *__restrict__ id
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
CSCALCTDigi bestAlctInChamber(unsigned int) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
CSCStubMatcher(edm::ParameterSet const &iPS, edm::ConsumesCollector &&iC)
uint32_t const *__restrict__ Quality * quality
void matchMPLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection &)
const CSCCLCTDigiContainer & clctsInChamber(unsigned int) const
all matching from a particular crossed chamber
int nChambersWithALCT(int min_quality=0) const
GlobalPoint getGlobalPosition(unsigned int rawId, const CSCCorrelatedLCTDigi &lct) const
constexpr uint32_t rawId() const
get the raw id
std::vector< CSCCorrelatedLCTDigi > CSCCorrelatedLCTDigiContainer
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const CSCALCTDigiContainer & allALCTsInChamber(unsigned int) const
const CSCCorrelatedLCTDigiContainer & mplctsInChamber(unsigned int) const
int nChambersWithCLCT(int min_quality=0) const
How many CSC chambers with matching stubs of some minimal quality did this SimTrack hit...
constexpr std::array< uint8_t, layerIndexSize > layer
static std::string const input
bool getData(T &iHolder) const
std::vector< CSCALCTDigi > CSCALCTDigiContainer
bool lctInChamber(const CSCDetId &id, const CSCCorrelatedLCTDigi &lct) const
std::set< unsigned int > chamberIdsMPLCT(int csc_type=MuonHitHelper::CSC_ALL) const
const CSCALCTDigiContainer & alctsInChamber(unsigned int) const
std::set< unsigned int > chamberIdsALCT(int csc_type=MuonHitHelper::CSC_ALL) const
const CSCCorrelatedLCTDigiContainer & allLCTsInChamber(unsigned int) const
void matchLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection &)
const CSCCorrelatedLCTDigiContainer & allMPLCTsInChamber(unsigned int) const
std::set< unsigned int > chamberIdsCLCT(int csc_type=MuonHitHelper::CSC_ALL) const
chamber detIds with matching stubs
std::set< unsigned int > chamberIdsAllCLCT(int csc_type=MuonHitHelper::CSC_ALL) const
crossed chamber detIds with not necessarily matching stubs
Log< level::Info, false > LogInfo
short int zendcap() const
void matchALCTsToSimTrack(const CSCALCTDigiCollection &)
void matchCLCTsToSimTrack(const CSCCLCTDigiCollection &)
std::set< unsigned int > chamberIdsAllLCT(int csc_type=MuonHitHelper::CSC_ALL) const
T getParameter(std::string const &) const
int nChambersWithLCT(int min_quality=0) const
CSCCLCTDigi bestClctInChamber(unsigned int) const
best matching from a particular crossed chamber
CSCCorrelatedLCTDigi bestLctInChamber(unsigned int) const
void match(const SimTrack &t, const SimVertex &v)
do the matching
const CSCCLCTDigiContainer & allCLCTsInChamber(unsigned int) const
all stubs (not necessarily matching) from a particular crossed chamber
tuple size
Write out results.
const CSCCorrelatedLCTDigiContainer & lctsInChamber(unsigned int) const
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
std::set< unsigned int > chamberIdsAllALCT(int csc_type=MuonHitHelper::CSC_ALL) const