CMS 3D CMS Logo

CSCStubMatcher.cc
Go to the documentation of this file.
3 #include <algorithm>
4 
5 using namespace std;
6 
8  useGEMs_ = pSet.getParameter<bool>("useGEMs");
9 
10  const auto& cscCLCT = pSet.getParameter<edm::ParameterSet>("cscCLCT");
11  minBXCLCT_ = cscCLCT.getParameter<int>("minBX");
12  maxBXCLCT_ = cscCLCT.getParameter<int>("maxBX");
13  verboseCLCT_ = cscCLCT.getParameter<int>("verbose");
14  minNHitsChamberCLCT_ = cscCLCT.getParameter<int>("minNHitsChamber");
15 
16  const auto& cscALCT = pSet.getParameter<edm::ParameterSet>("cscALCT");
17  minBXALCT_ = cscALCT.getParameter<int>("minBX");
18  maxBXALCT_ = cscALCT.getParameter<int>("maxBX");
19  verboseALCT_ = cscALCT.getParameter<int>("verbose");
20  minNHitsChamberALCT_ = cscALCT.getParameter<int>("minNHitsChamber");
21 
22  const auto& cscLCT = pSet.getParameter<edm::ParameterSet>("cscLCT");
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");
28 
29  const auto& cscMPLCT = pSet.getParameter<edm::ParameterSet>("cscMPLCT");
30  minBXMPLCT_ = cscMPLCT.getParameter<int>("minBX");
31  maxBXMPLCT_ = cscMPLCT.getParameter<int>("maxBX");
32  verboseMPLCT_ = cscMPLCT.getParameter<int>("verbose");
33  minNHitsChamberMPLCT_ = cscMPLCT.getParameter<int>("minNHitsChamber");
34 
35  if (useGEMs_)
36  gemDigiMatcher_.reset(new GEMDigiMatcher(pSet, std::move(iC)));
37  cscDigiMatcher_.reset(new CSCDigiMatcher(pSet, std::move(iC)));
38 
39  clctToken_ = iC.consumes<CSCCLCTDigiCollection>(cscCLCT.getParameter<edm::InputTag>("inputTag"));
40  alctToken_ = iC.consumes<CSCALCTDigiCollection>(cscALCT.getParameter<edm::InputTag>("inputTag"));
41  lctToken_ = iC.consumes<CSCCorrelatedLCTDigiCollection>(cscLCT.getParameter<edm::InputTag>("inputTag"));
42  mplctToken_ = iC.consumes<CSCCorrelatedLCTDigiCollection>(cscMPLCT.getParameter<edm::InputTag>("inputTag"));
43 
44  geomToken_ = iC.esConsumes<CSCGeometry, MuonGeometryRecord>();
45 }
46 
48  if (useGEMs_)
49  gemDigiMatcher_->init(iEvent, iSetup);
50  cscDigiMatcher_->init(iEvent, iSetup);
51 
52  iEvent.getByToken(clctToken_, clctsH_);
53  iEvent.getByToken(alctToken_, alctsH_);
54  iEvent.getByToken(lctToken_, lctsH_);
55  iEvent.getByToken(mplctToken_, mplctsH_);
56 
57  cscGeometry_ = &iSetup.getData(geomToken_);
58 }
59 
60 // do the matching
61 void CSCStubMatcher::match(const SimTrack& t, const SimVertex& v) {
62  // match simhits first
63  if (useGEMs_)
64  gemDigiMatcher_->match(t, v);
65  cscDigiMatcher_->match(t, v);
66 
67  const CSCCLCTDigiCollection& clcts = *clctsH_.product();
68  const CSCALCTDigiCollection& alcts = *alctsH_.product();
69  const CSCCorrelatedLCTDigiCollection& lcts = *lctsH_.product();
70  const CSCCorrelatedLCTDigiCollection& mplcts = *mplctsH_.product();
71 
72  // clear collections
73  clear();
74 
75  matchCLCTsToSimTrack(clcts);
76  matchALCTsToSimTrack(alcts);
77  matchLCTsToSimTrack(lcts);
78  matchMPLCTsToSimTrack(mplcts);
79 }
80 
82  const auto& cathode_ids = cscDigiMatcher_->chamberIdsStrip(0);
83 
84  for (const auto& id : cathode_ids) {
85  CSCDetId ch_id(id);
86  if (verboseCLCT_) {
87  edm::LogInfo("CSCStubMatcher") << "To check CSC chamber " << ch_id;
88  }
89 
90  int ring = ch_id.ring();
91 
92  // do not consider CSCs with too few hits
93  if (cscDigiMatcher_->nLayersWithStripInChamber(ch_id) < minNHitsChamberCLCT_)
94  continue;
95 
96  // get the comparator digis in this chamber
97  std::vector<CSCComparatorDigiContainer> comps;
98  for (int ilayer = 1; ilayer <= 6; ilayer++) {
99  CSCDetId layerid(ch_id.endcap(), ch_id.station(), ring, ch_id.chamber(), ilayer);
100  comps.push_back(cscDigiMatcher_->comparatorDigisInDetId(layerid));
101  }
102 
103  // print out the digis
104  if (verboseCLCT_) {
105  edm::LogInfo("CSCStubMatcher") << "clct: comparators " << ch_id;
106  int layer = 0;
107  for (const auto& p : comps) {
108  layer++;
109  for (const auto& q : p) {
110  edm::LogInfo("CSCStubMatcher") << "L" << layer << " " << q << " " << q.getHalfStrip() << " ";
111  }
112  }
113  }
114 
115  //use ME1b id to get CLCTs
116  const bool isME1a(ch_id.station() == 1 and ch_id.ring() == 4);
117  if (isME1a)
118  ring = 1;
119  CSCDetId ch_id2(ch_id.endcap(), ch_id.station(), ring, ch_id.chamber(), 0);
120 
121  const auto& clcts_in_det = clcts.get(ch_id2);
122 
123  for (auto c = clcts_in_det.first; c != clcts_in_det.second; ++c) {
124  if (verboseCLCT_)
125  edm::LogInfo("CSCStubMatcher") << "clct " << ch_id2 << " " << *c;
126 
127  if (!c->isValid())
128  continue;
129 
130  // check that the BX for this stub wasn't too early or too late
131  if (c->getBX() < minBXCLCT_ || c->getBX() > maxBXCLCT_)
132  continue;
133 
134  // store all CLCTs in this chamber
135  chamber_to_clcts_all_[id].push_back(*c);
136 
137  // check that at least 3 comparator digis were matched!
138  int nMatches = 0;
139  int layer = 0;
140  for (const auto& p : comps) {
141  layer++;
142  for (const auto& q : p) {
143  if (verboseCLCT_)
144  edm::LogInfo("CSCStubMatcher") << "L" << layer << " " << q << " " << q.getHalfStrip() << " " << std::endl;
145  for (const auto& clctComp : (*c).getHits()[layer - 1]) {
146  if (clctComp == 65535)
147  continue;
148  if (verboseCLCT_) {
149  edm::LogInfo("CSCStubMatcher") << "\t" << clctComp << " ";
150  }
151  if (q.getHalfStrip() == clctComp or (isME1a and q.getHalfStrip() + 128 == clctComp)) {
152  nMatches++;
153  if (verboseCLCT_) {
154  edm::LogInfo("CSCStubMatcher") << "\t\tnMatches " << nMatches << std::endl;
155  }
156  }
157  }
158  }
159  }
160 
161  // require at least 3 good matches
162  if (nMatches < 3)
163  continue;
164 
165  if (verboseCLCT_)
166  edm::LogInfo("CSCStubMatcher") << "clctGOOD";
167 
168  // store matching CLCTs in this chamber
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);
171  }
172  }
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])
176  edm::LogInfo("CSCStubMatcher") << " " << c;
177  }
178  }
179 }
180 
182  const auto& anode_ids = cscDigiMatcher_->chamberIdsWire(0);
183  int n_minLayers = 0;
184  for (const auto& id : anode_ids) {
185  if (cscDigiMatcher_->nLayersWithWireInChamber(id) >= minNHitsChamberALCT_)
186  ++n_minLayers;
187  CSCDetId ch_id(id);
188 
189  // fill 1 WG wide gaps
190  const auto& digi_wgs = cscDigiMatcher_->wiregroupsInChamber(id, 1);
191  if (verboseALCT_) {
192  cout << "alct: digi_wgs " << ch_id << " ";
193  copy(digi_wgs.begin(), digi_wgs.end(), ostream_iterator<int>(cout, " "));
194  cout << endl;
195  }
196 
197  int ring = ch_id.ring();
198  if (ring == 4)
199  ring = 1; //use ME1b id to get CLCTs
200  CSCDetId ch_id2(ch_id.endcap(), ch_id.station(), ring, ch_id.chamber(), 0);
201 
202  const auto& alcts_in_det = alcts.get(ch_id2);
203  for (auto a = alcts_in_det.first; a != alcts_in_det.second; ++a) {
204  if (!a->isValid())
205  continue;
206 
207  if (verboseALCT_)
208  edm::LogInfo("CSCStubMatcher") << "alct " << ch_id << " " << *a;
209 
210  // check that the BX for stub wasn't too early or too late
211  if (a->getBX() < minBXALCT_ || a->getBX() > maxBXALCT_)
212  continue;
213 
214  int wg = a->getKeyWG() + 1; // as ALCT wiregroups numbers start from 0
215 
216  // store all ALCTs in this chamber
217  chamber_to_alcts_all_[id].push_back(*a);
218 
219  // match by wiregroup with the digis
220  if (digi_wgs.find(wg) == digi_wgs.end()) {
221  continue;
222  }
223  if (verboseALCT_)
224  edm::LogInfo("CSCStubMatcher") << "alctGOOD";
225 
226  // store matching ALCTs in this chamber
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);
229  }
230  }
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])
234  edm::LogInfo("CSCStubMatcher") << " " << a;
235  }
236  }
237 }
238 
240  // only look for stubs in chambers that already have CLCT and ALCT
241  const auto& cathode_ids = chamberIdsAllCLCT(0);
242  const auto& anode_ids = chamberIdsAllALCT(0);
243 
244  std::set<int> cathode_and_anode_ids;
245  std::set_union(cathode_ids.begin(),
246  cathode_ids.end(),
247  anode_ids.begin(),
248  anode_ids.end(),
249  std::inserter(cathode_and_anode_ids, cathode_and_anode_ids.end()));
250 
251  for (const auto& id : cathode_and_anode_ids) {
252  int iLct = -1;
253 
254  CSCDetId ch_id(id);
255 
256  //use ME1b id to get LCTs
257  int ring = ch_id.ring();
258  if (ring == 4)
259  ring = 1;
260  CSCDetId ch_id2(ch_id.endcap(), ch_id.station(), ring, ch_id.chamber(), 0);
261 
262  const auto& lcts_in_det = lcts.get(ch_id2);
263 
264  std::map<int, CSCCorrelatedLCTDigiContainer> bx_to_lcts;
265 
266  // collect all valid LCTs in a handy container
268  for (auto lct = lcts_in_det.first; lct != lcts_in_det.second; ++lct) {
269  if (!lct->isValid())
270  continue;
271  lcts_tmp.push_back(*lct);
272  int bx = lct->getBX();
273  bx_to_lcts[bx].push_back(*lct);
274 
275  // Add ghost LCTs when there are two in bx
276  // and the two don't share half-strip or wiregroup
277  if (bx_to_lcts[bx].size() == 2 and addGhostLCTs_) {
278  // don't do this in station ME1/1 or ME2/1
279  if (!(ch_id.ring() == 1 and (ch_id.station() == 1 or ch_id.station() == 2))) {
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();
286 
287  if (!(wg1 == wg2 || hs1 == hs2) and lct11.getType() == CSCCorrelatedLCTDigi::ALCTCLCT and
288  lct22.getType() == CSCCorrelatedLCTDigi::ALCTCLCT) {
289  CSCCorrelatedLCTDigi lct12 = lct11;
290  lct12.setWireGroup(wg2);
291  lct12.setALCT(lct22.getALCT());
292  lcts_tmp.push_back(lct12);
293 
294  CSCCorrelatedLCTDigi lct21 = lct22;
295  lct21.setWireGroup(wg1);
296  lct21.setALCT(lct11.getALCT());
297  lcts_tmp.push_back(lct21);
298  }
299  }
300  }
301  }
302 
303  for (const auto& lct : lcts_tmp) {
304  iLct++;
305 
306  bool lct_clct_match(false);
307  bool lct_alct_match(false);
308  bool lct_gem1_match(false);
309  bool lct_gem2_match(false);
310 
311  if (verboseLCT_) {
312  edm::LogInfo("CSCStubMatcher") << ch_id << " " << ch_id2;
313  edm::LogInfo("CSCStubMatcher") << lct;
314  edm::LogInfo("CSCStubMatcher") << "getCLCT " << lct.getCLCT() << "\ngetALCT " << lct.getALCT() << "\ngetGEM1 "
315  << lct.getGEM1() << "\ngetGEM2 " << lct.getGEM2();
316  }
317  // Check if matched to an CLCT
318  for (const auto& p : clctsInChamber(id)) {
319  if (p == lct.getCLCT()) {
320  lct_clct_match = true;
321  if (verboseLCT_)
322  edm::LogInfo("CSCStubMatcher") << "\t...lct_clct_match";
323  break;
324  }
325  }
326 
327  // Check if matched to an ALCT
328  for (const auto& p : alctsInChamber(id)) {
329  if (p == lct.getALCT()) {
330  lct_alct_match = true;
331  if (verboseLCT_)
332  edm::LogInfo("CSCStubMatcher") << "\t...lct_alct_match";
333  break;
334  }
335  }
336 
337  if (useGEMs_) {
338  // fixME here: double check the timing of GEMPad
339  if (ch_id.ring() == 1 and (ch_id.station() == 1 or ch_id.station() == 2)) {
340  // Check if matched to an GEM pad L1
341  const GEMDetId gemDetIdL1(ch_id.zendcap(), 1, ch_id.station(), 1, ch_id.chamber(), 0);
342  for (const auto& p : gemDigiMatcher_->padsInChamber(gemDetIdL1.rawId())) {
343  if (p == lct.getGEM1()) {
344  lct_gem1_match = true;
345  if (verboseLCT_)
346  edm::LogInfo("CSCStubMatcher") << "\t...lct_gem1_match";
347  break;
348  }
349  }
350 
351  // Check if matched to an GEM pad L2
352  const GEMDetId gemDetIdL2(ch_id.zendcap(), 1, ch_id.station(), 2, ch_id.chamber(), 0);
353  for (const auto& p : gemDigiMatcher_->padsInChamber(gemDetIdL2.rawId())) {
354  if (p == lct.getGEM2()) {
355  lct_gem2_match = true;
356  if (verboseLCT_)
357  edm::LogInfo("CSCStubMatcher") << "\t...lct_gem2_match";
358  break;
359  }
360  }
361  }
362  }
363 
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;
367 
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;
371 
372  if (lct_matched) {
373  if (verboseLCT_)
374  edm::LogInfo("CSCStubMatcher") << "...was 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);
377  }
378  }
379  } // lct loop over
380  }
381 }
382 
384  // match simtrack to MPC LCT by looking only in chambers
385  // that already have LCTs matched to this simtrack
386  const auto& lcts_ids = chamberIdsLCT(0);
387 
388  // loop on the detids
389  for (const auto& id : lcts_ids) {
390  const auto& mplcts_in_det = mplcts.get(id);
391 
392  // loop on the MPC LCTs in this detid
393  for (auto lct = mplcts_in_det.first; lct != mplcts_in_det.second; ++lct) {
394  if (!lct->isValid())
395  continue;
396 
397  chamber_to_mplcts_all_[id].emplace_back(*lct);
398 
399  // check if this stub corresponds with a previously matched stub
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);
405  }
406  }
407  }
408  }
409  }
410 }
411 
412 std::set<unsigned int> CSCStubMatcher::chamberIdsAllCLCT(int csc_type) const {
413  return selectDetIds(chamber_to_clcts_all_, csc_type);
414 }
415 
416 std::set<unsigned int> CSCStubMatcher::chamberIdsAllALCT(int csc_type) const {
417  return selectDetIds(chamber_to_alcts_all_, csc_type);
418 }
419 
420 std::set<unsigned int> CSCStubMatcher::chamberIdsAllLCT(int csc_type) const {
421  return selectDetIds(chamber_to_lcts_all_, csc_type);
422 }
423 
424 std::set<unsigned int> CSCStubMatcher::chamberIdsAllMPLCT(int csc_type) const {
425  return selectDetIds(chamber_to_mplcts_all_, csc_type);
426 }
427 
428 std::set<unsigned int> CSCStubMatcher::chamberIdsCLCT(int csc_type) const {
429  return selectDetIds(chamber_to_clcts_, csc_type);
430 }
431 
432 std::set<unsigned int> CSCStubMatcher::chamberIdsALCT(int csc_type) const {
433  return selectDetIds(chamber_to_alcts_, csc_type);
434 }
435 
436 std::set<unsigned int> CSCStubMatcher::chamberIdsLCT(int csc_type) const {
437  return selectDetIds(chamber_to_lcts_, csc_type);
438 }
439 
440 std::set<unsigned int> CSCStubMatcher::chamberIdsMPLCT(int csc_type) const {
441  return selectDetIds(chamber_to_mplcts_, csc_type);
442 }
443 
444 const CSCCLCTDigiContainer& CSCStubMatcher::allCLCTsInChamber(unsigned int detid) const {
445  if (chamber_to_clcts_all_.find(detid) == chamber_to_clcts_all_.end())
446  return no_clcts_;
447  return chamber_to_clcts_all_.at(detid);
448 }
449 
450 const CSCALCTDigiContainer& CSCStubMatcher::allALCTsInChamber(unsigned int detid) const {
451  if (chamber_to_alcts_all_.find(detid) == chamber_to_alcts_all_.end())
452  return no_alcts_;
453  return chamber_to_alcts_all_.at(detid);
454 }
455 
457  if (chamber_to_lcts_all_.find(detid) == chamber_to_lcts_all_.end())
458  return no_lcts_;
459  return chamber_to_lcts_all_.at(detid);
460 }
461 
463  if (chamber_to_mplcts_all_.find(detid) == chamber_to_mplcts_all_.end())
464  return no_mplcts_;
465  return chamber_to_mplcts_all_.at(detid);
466 }
467 
468 const CSCCLCTDigiContainer& CSCStubMatcher::clctsInChamber(unsigned int detid) const {
469  if (chamber_to_clcts_.find(detid) == chamber_to_clcts_.end())
470  return no_clcts_;
471  return chamber_to_clcts_.at(detid);
472 }
473 
474 const CSCALCTDigiContainer& CSCStubMatcher::alctsInChamber(unsigned int detid) const {
475  if (chamber_to_alcts_.find(detid) == chamber_to_alcts_.end())
476  return no_alcts_;
477  return chamber_to_alcts_.at(detid);
478 }
479 
481  if (chamber_to_lcts_.find(detid) == chamber_to_lcts_.end())
482  return no_lcts_;
483  return chamber_to_lcts_.at(detid);
484 }
485 
487  if (chamber_to_mplcts_.find(detid) == chamber_to_mplcts_.end())
488  return no_mplcts_;
489  return chamber_to_mplcts_.at(detid);
490 }
491 
493  //sort stubs based on quality
494  const auto& input(clctsInChamber(detid));
495  int bestQ = 0;
496  int index = -1;
497  for (unsigned int i = 0; i < input.size(); ++i) {
498  int quality = input[i].getQuality();
499  if (quality > bestQ) {
500  bestQ = quality;
501  index = i;
502  }
503  }
504  if (index != -1)
505  return input[index];
506  return CSCCLCTDigi();
507 }
508 
510  //sort stubs based on quality
511  const auto& input(alctsInChamber(detid));
512  int bestQ = 0;
513  int index = -1;
514  for (unsigned int i = 0; i < input.size(); ++i) {
515  int quality = input[i].getQuality();
516  if (quality > bestQ) {
517  bestQ = quality;
518  index = i;
519  }
520  }
521  if (index != -1)
522  return input[index];
523  return CSCALCTDigi();
524 }
525 
527  //sort stubs based on quality
528  const auto& input(lctsInChamber(detid));
529  int bestQ = 0;
530  int index = -1;
531  for (unsigned int i = 0; i < input.size(); ++i) {
532  int quality = input[i].getQuality();
533  if (quality > bestQ) {
534  bestQ = quality;
535  index = i;
536  }
537  }
538  if (index != -1)
539  return input[index];
540  return CSCCorrelatedLCTDigi();
541 }
542 
543 float CSCStubMatcher::zpositionOfLayer(unsigned int detid, int layer) const {
544  const auto& id = CSCDetId(detid);
545  const auto& chamber(cscGeometry_->chamber(id));
546  return fabs(chamber->layer(layer)->centerOfStrip(20).z());
547 }
548 
549 int CSCStubMatcher::nChambersWithCLCT(int min_quality) const {
550  int result = 0;
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) {
556  if (!clct.isValid())
557  continue;
558  if (clct.getQuality() >= min_quality) {
559  nStubChamber++;
560  }
561  }
562  if (nStubChamber > 0) {
563  ++result;
564  }
565  }
566  return result;
567 }
568 
569 int CSCStubMatcher::nChambersWithALCT(int min_quality) const {
570  int result = 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) {
576  if (!alct.isValid())
577  continue;
578  if (alct.getQuality() >= min_quality) {
579  nStubChamber++;
580  }
581  }
582  if (nStubChamber > 0) {
583  ++result;
584  }
585  }
586  return result;
587 }
588 
589 int CSCStubMatcher::nChambersWithLCT(int min_quality) const {
590  int result = 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) {
596  if (!lct.isValid())
597  continue;
598  if (lct.getQuality() >= min_quality) {
599  nStubChamber++;
600  }
601  }
602  if (nStubChamber > 0) {
603  ++result;
604  }
605  }
606  return result;
607 }
608 
609 int CSCStubMatcher::nChambersWithMPLCT(int min_quality) const {
610  int result = 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())
617  continue;
618  if (mplct.getQuality() >= min_quality) {
619  nStubChamber++;
620  }
621  }
622  if (nStubChamber > 0) {
623  ++result;
624  }
625  }
626  return result;
627 }
628 
629 bool CSCStubMatcher::lctInChamber(const CSCDetId& id, const CSCCorrelatedLCTDigi& lct) const {
630  for (const auto& stub : lctsInChamber(id.rawId())) {
631  if (stub == lct)
632  return true;
633  }
634  return false;
635 }
636 
638  CSCDetId cscId(rawId);
639  CSCDetId keyId(cscId.endcap(), cscId.station(), cscId.ring(), cscId.chamber(), CSCConstants::KEY_CLCT_LAYER);
640  float fractional_strip = lct.getFractionalStrip();
641  // case ME1/a
642  if (cscId.station() == 1 and cscId.ring() == 4 and lct.getStrip() > CSCConstants::MAX_HALF_STRIP_ME1B) {
643  fractional_strip -= CSCConstants::MAX_NUM_STRIPS_ME1B;
644  }
645  // regular cases
646  const auto& chamber = cscGeometry_->chamber(cscId);
647  const auto& layer_geo = chamber->layer(CSCConstants::KEY_CLCT_LAYER)->geometry();
648  // LCT::getKeyWG() also starts from 0
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);
652  return csc_gp;
653 }
654 
656  chamber_to_clcts_all_.clear();
657  chamber_to_alcts_all_.clear();
658  chamber_to_lcts_all_.clear();
659  chamber_to_mplcts_all_.clear();
660 
661  chamber_to_clcts_.clear();
662  chamber_to_alcts_.clear();
663  chamber_to_lcts_.clear();
664  chamber_to_mplcts_.clear();
665 }
CSCStubMatcher::clear
void clear()
Definition: CSCStubMatcher.cc:655
CSCStubMatcher::allLCTsInChamber
const CSCCorrelatedLCTDigiContainer & allLCTsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:456
mps_fire.i
i
Definition: mps_fire.py:428
CSCStubMatcher::bestAlctInChamber
CSCALCTDigi bestAlctInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:509
CSCStubMatcher::alctsInChamber
const CSCALCTDigiContainer & alctsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:474
input
static const std::string input
Definition: EdmProvDump.cc:48
SimVertex
Definition: SimVertex.h:5
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
CSCStubMatcher::getGlobalPosition
GlobalPoint getGlobalPosition(unsigned int rawId, const CSCCorrelatedLCTDigi &lct) const
Definition: CSCStubMatcher.cc:637
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
CSCDetId::zendcap
short int zendcap() const
Definition: CSCDetId.h:91
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CSCCorrelatedLCTDigi::getStrip
uint16_t getStrip(uint16_t n=2) const
return the key halfstrip from 0,159
Definition: CSCCorrelatedLCTDigi.cc:72
gather_cfg.cout
cout
Definition: gather_cfg.py:144
CSCCorrelatedLCTDigi::getKeyWG
uint16_t getKeyWG() const
return the key wire group. counts from 0.
Definition: CSCCorrelatedLCTDigi.h:61
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
CSCStubMatcher::lctsInChamber
const CSCCorrelatedLCTDigiContainer & lctsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:480
GEMDigiMatcher
Definition: GEMDigiMatcher.h:31
CSCStubMatcher::nChambersWithLCT
int nChambersWithLCT(int min_quality=0) const
Definition: CSCStubMatcher.cc:589
CSCCorrelatedLCTDigi::setWireGroup
void setWireGroup(const uint16_t wiregroup)
set wiregroup number
Definition: CSCCorrelatedLCTDigi.h:157
CSCCorrelatedLCTDigiContainer
std::vector< CSCCorrelatedLCTDigi > CSCCorrelatedLCTDigiContainer
Definition: CSCStubMatcher.h:20
CSCCorrelatedLCTDigi::getFractionalStrip
float getFractionalStrip(uint16_t n=2) const
return the fractional strip
Definition: CSCCorrelatedLCTDigi.cc:137
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
findQualityFiles.v
v
Definition: findQualityFiles.py:179
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
CSCCLCTDigi
Definition: CSCCLCTDigi.h:17
CSCCorrelatedLCTDigi::ALCTCLCT
Definition: CSCCorrelatedLCTDigi.h:203
CSCStubMatcher::nChambersWithMPLCT
int nChambersWithMPLCT(int min_quality=0) const
Definition: CSCStubMatcher.cc:609
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:109
CSCGeometry
Definition: CSCGeometry.h:24
CSCCorrelatedLCTDigi::setALCT
void setALCT(const CSCALCTDigi &alct)
Definition: CSCCorrelatedLCTDigi.h:216
CSCStubMatcher::bestClctInChamber
CSCCLCTDigi bestClctInChamber(unsigned int) const
best matching from a particular crossed chamber
Definition: CSCStubMatcher.cc:492
CSCStubMatcher::allCLCTsInChamber
const CSCCLCTDigiContainer & allCLCTsInChamber(unsigned int) const
all stubs (not necessarily matching) from a particular crossed chamber
Definition: CSCStubMatcher.cc:444
CSCStubMatcher::bestLctInChamber
CSCCorrelatedLCTDigi bestLctInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:526
mps_fire.end
end
Definition: mps_fire.py:242
CSCConstants::MAX_NUM_STRIPS_ME1B
Definition: CSCConstants.h:40
CSCConstants.h
CSCStubMatcher::clctsInChamber
const CSCCLCTDigiContainer & clctsInChamber(unsigned int) const
all matching from a particular crossed chamber
Definition: CSCStubMatcher.cc:468
Point3DBase< float, GlobalTag >
CSCStubMatcher::allMPLCTsInChamber
const CSCCorrelatedLCTDigiContainer & allMPLCTsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:462
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
CSCDigiMatcher
Definition: CSCDigiMatcher.h:25
muonCSCStubPSet.cscMPLCT
cscMPLCT
Definition: muonCSCStubPSet.py:30
CSCCLCTDigiContainer
std::vector< CSCCLCTDigi > CSCCLCTDigiContainer
Definition: CSCStubMatcher.h:19
CSCStubMatcher::matchMPLCTsToSimTrack
void matchMPLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection &)
Definition: CSCStubMatcher.cc:383
CSCStubMatcher::mplctsInChamber
const CSCCorrelatedLCTDigiContainer & mplctsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:486
CSCStubMatcher::matchCLCTsToSimTrack
void matchCLCTsToSimTrack(const CSCCLCTDigiCollection &)
Definition: CSCStubMatcher.cc:81
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
clear
void clear(HadCaloObj &c)
Definition: data.h:124
CSCStubMatcher.h
CSCStubMatcher::matchALCTsToSimTrack
void matchALCTsToSimTrack(const CSCALCTDigiCollection &)
Definition: CSCStubMatcher.cc:181
CSCConstants::MAX_HALF_STRIP_ME1B
Definition: CSCConstants.h:39
GEMDetId
Definition: GEMDetId.h:18
CSCStubMatcher::chamberIdsAllMPLCT
std::set< unsigned int > chamberIdsAllMPLCT(int csc_type=MuonHitHelper::CSC_ALL) const
Definition: CSCStubMatcher.cc:424
CSCDetId
Definition: CSCDetId.h:26
CSCStubMatcher::chamberIdsMPLCT
std::set< unsigned int > chamberIdsMPLCT(int csc_type=MuonHitHelper::CSC_ALL) const
Definition: CSCStubMatcher.cc:440
CSCStubMatcher::init
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
Definition: CSCStubMatcher.cc:47
iEvent
int iEvent
Definition: GenABIO.cc:224
CSCStubMatcher::chamberIdsAllALCT
std::set< unsigned int > chamberIdsAllALCT(int csc_type=MuonHitHelper::CSC_ALL) const
Definition: CSCStubMatcher.cc:416
CSCALCTDigiCollection
CSCStubMatcher::nChambersWithCLCT
int nChambersWithCLCT(int min_quality=0) const
How many CSC chambers with matching stubs of some minimal quality did this SimTrack hit?
Definition: CSCStubMatcher.cc:549
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
edm::EventSetup
Definition: EventSetup.h:58
CSCCorrelatedLCTDigiCollection
muonCSCStubPSet.cscCLCT
cscCLCT
Definition: muonCSCStubPSet.py:5
CSCALCTDigiContainer
std::vector< CSCALCTDigi > CSCALCTDigiContainer
Definition: CSCStubMatcher.h:18
muonCSCStubPSet.cscALCT
cscALCT
Definition: muonCSCStubPSet.py:13
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
CSCStubMatcher::CSCStubMatcher
CSCStubMatcher(edm::ParameterSet const &iPS, edm::ConsumesCollector &&iC)
Definition: CSCStubMatcher.cc:7
CSCStubMatcher::chamberIdsAllCLCT
std::set< unsigned int > chamberIdsAllCLCT(int csc_type=MuonHitHelper::CSC_ALL) const
crossed chamber detIds with not necessarily matching stubs
Definition: CSCStubMatcher.cc:412
muonCSCStubPSet.cscLCT
cscLCT
Definition: muonCSCStubPSet.py:21
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
SimTrack
Definition: SimTrack.h:9
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
CSCCLCTDigiCollection
CSCALCTDigi
Definition: CSCALCTDigi.h:17
CSCConstants::KEY_CLCT_LAYER
Definition: CSCConstants.h:46
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
CSCStubMatcher::match
void match(const SimTrack &t, const SimVertex &v)
do the matching
Definition: CSCStubMatcher.cc:61
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
or
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
Definition: Activities.doc:12
CSCStubMatcher::chamberIdsAllLCT
std::set< unsigned int > chamberIdsAllLCT(int csc_type=MuonHitHelper::CSC_ALL) const
Definition: CSCStubMatcher.cc:420
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
CSCStubMatcher::chamberIdsCLCT
std::set< unsigned int > chamberIdsCLCT(int csc_type=MuonHitHelper::CSC_ALL) const
chamber detIds with matching stubs
Definition: CSCStubMatcher.cc:428
mps_fire.result
result
Definition: mps_fire.py:311
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
CSCStubMatcher::zpositionOfLayer
float zpositionOfLayer(unsigned int detid, int layer) const
Definition: CSCStubMatcher.cc:543
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
CSCStubMatcher::chamberIdsLCT
std::set< unsigned int > chamberIdsLCT(int csc_type=MuonHitHelper::CSC_ALL) const
Definition: CSCStubMatcher.cc:436
CSCStubMatcher::chamberIdsALCT
std::set< unsigned int > chamberIdsALCT(int csc_type=MuonHitHelper::CSC_ALL) const
Definition: CSCStubMatcher.cc:432
edm::Event
Definition: Event.h:73
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
CSCStubMatcher::allALCTsInChamber
const CSCALCTDigiContainer & allALCTsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:450
CSCCorrelatedLCTDigi
Definition: CSCCorrelatedLCTDigi.h:19
CSCStubMatcher::nChambersWithALCT
int nChambersWithALCT(int min_quality=0) const
Definition: CSCStubMatcher.cc:569
CSCStubMatcher::matchLCTsToSimTrack
void matchLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection &)
Definition: CSCStubMatcher.cc:239
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
CSCStubMatcher::lctInChamber
bool lctInChamber(const CSCDetId &id, const CSCCorrelatedLCTDigi &lct) const
Definition: CSCStubMatcher.cc:629