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 = CSCDetId::minLayerId(); ilayer <= CSCDetId::maxLayerId(); 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  auto lct11 = bx_to_lcts[bx][0];
279  auto lct22 = bx_to_lcts[bx][1];
280  addGhostLCTs(lct11, lct22, lcts_tmp);
281  }
282  }
283 
284  for (const auto& lct : lcts_tmp) {
285  iLct++;
286 
287  bool lct_clct_match(false);
288  bool lct_alct_match(false);
289  bool lct_gem1_match(false);
290  bool lct_gem2_match(false);
291 
292  if (verboseLCT_) {
293  edm::LogInfo("CSCStubMatcher") << ch_id << " " << ch_id2;
294  edm::LogInfo("CSCStubMatcher") << lct;
295  edm::LogInfo("CSCStubMatcher") << "getCLCT " << lct.getCLCT() << "\ngetALCT " << lct.getALCT() << "\ngetGEM1 "
296  << lct.getGEM1() << "\ngetGEM2 " << lct.getGEM2();
297  }
298  // Check if matched to an CLCT
299  for (const auto& p : clctsInChamber(id)) {
300  if (p == lct.getCLCT()) {
301  lct_clct_match = true;
302  if (verboseLCT_)
303  edm::LogInfo("CSCStubMatcher") << "\t...lct_clct_match";
304  break;
305  }
306  }
307 
308  // Check if matched to an ALCT
309  for (const auto& p : alctsInChamber(id)) {
310  if (p == lct.getALCT()) {
311  lct_alct_match = true;
312  if (verboseLCT_)
313  edm::LogInfo("CSCStubMatcher") << "\t...lct_alct_match";
314  break;
315  }
316  }
317 
318  if (useGEMs_) {
319  // fixME here: double check the timing of GEMPad
320  if (ch_id.ring() == 1 and (ch_id.station() == 1 or ch_id.station() == 2)) {
321  // Check if matched to an GEM pad L1
322  const GEMDetId gemDetIdL1(ch_id.zendcap(), 1, ch_id.station(), 1, ch_id.chamber(), 0);
323  for (const auto& p : gemDigiMatcher_->padsInChamber(gemDetIdL1.rawId())) {
324  if (p == lct.getGEM1()) {
325  lct_gem1_match = true;
326  if (verboseLCT_)
327  edm::LogInfo("CSCStubMatcher") << "\t...lct_gem1_match";
328  break;
329  }
330  }
331 
332  // Check if matched to an GEM pad L2
333  const GEMDetId gemDetIdL2(ch_id.zendcap(), 1, ch_id.station(), 2, ch_id.chamber(), 0);
334  for (const auto& p : gemDigiMatcher_->padsInChamber(gemDetIdL2.rawId())) {
335  if (p == lct.getGEM2()) {
336  lct_gem2_match = true;
337  if (verboseLCT_)
338  edm::LogInfo("CSCStubMatcher") << "\t...lct_gem2_match";
339  break;
340  }
341  }
342  }
343  }
344 
345  const bool alct_clct = lct_clct_match and lct_alct_match;
346  const bool alct_gem = lct_alct_match and lct_gem1_match and lct_gem2_match;
347  const bool clct_gem = lct_clct_match and lct_gem1_match and lct_gem2_match;
348 
349  bool lct_tight_matched = alct_clct or alct_gem or clct_gem;
350  bool lct_loose_matched = lct_clct_match or lct_alct_match;
351  bool lct_matched = lct_loose_matched or lct_tight_matched;
352 
353  if (lct_matched) {
354  if (verboseLCT_)
355  edm::LogInfo("CSCStubMatcher") << "...was matched";
356  if (std::find(chamber_to_lcts_[id].begin(), chamber_to_lcts_[id].end(), lct) == chamber_to_lcts_[id].end()) {
357  chamber_to_lcts_[id].emplace_back(lct);
358  }
359  }
360  } // lct loop over
361  }
362 }
363 
365  // match simtrack to MPC LCT by looking only in chambers
366  // that already have LCTs matched to this simtrack
367  const auto& lcts_ids = chamberIdsLCT(0);
368 
369  // loop on the detids
370  for (const auto& id : lcts_ids) {
371  const auto& mplcts_in_det = mplcts.get(id);
372 
373  // loop on the MPC LCTs in this detid
374  for (auto lct = mplcts_in_det.first; lct != mplcts_in_det.second; ++lct) {
375  if (!lct->isValid())
376  continue;
377 
378  chamber_to_mplcts_all_[id].emplace_back(*lct);
379 
380  // check if this stub corresponds with a previously matched stub
381  for (const auto& sim_stub : lctsInChamber(id)) {
382  if (sim_stub == *lct) {
383  if (std::find(chamber_to_mplcts_[id].begin(), chamber_to_mplcts_[id].end(), *lct) ==
384  chamber_to_mplcts_[id].end()) {
385  chamber_to_mplcts_[id].emplace_back(*lct);
386  }
387  }
388  }
389  }
390  }
391 }
392 
393 std::set<unsigned int> CSCStubMatcher::chamberIdsAllCLCT(int csc_type) const {
394  return selectDetIds(chamber_to_clcts_all_, csc_type);
395 }
396 
397 std::set<unsigned int> CSCStubMatcher::chamberIdsAllALCT(int csc_type) const {
398  return selectDetIds(chamber_to_alcts_all_, csc_type);
399 }
400 
401 std::set<unsigned int> CSCStubMatcher::chamberIdsAllLCT(int csc_type) const {
402  return selectDetIds(chamber_to_lcts_all_, csc_type);
403 }
404 
405 std::set<unsigned int> CSCStubMatcher::chamberIdsAllMPLCT(int csc_type) const {
406  return selectDetIds(chamber_to_mplcts_all_, csc_type);
407 }
408 
409 std::set<unsigned int> CSCStubMatcher::chamberIdsCLCT(int csc_type) const {
410  return selectDetIds(chamber_to_clcts_, csc_type);
411 }
412 
413 std::set<unsigned int> CSCStubMatcher::chamberIdsALCT(int csc_type) const {
414  return selectDetIds(chamber_to_alcts_, csc_type);
415 }
416 
417 std::set<unsigned int> CSCStubMatcher::chamberIdsLCT(int csc_type) const {
418  return selectDetIds(chamber_to_lcts_, csc_type);
419 }
420 
421 std::set<unsigned int> CSCStubMatcher::chamberIdsMPLCT(int csc_type) const {
422  return selectDetIds(chamber_to_mplcts_, csc_type);
423 }
424 
425 const CSCCLCTDigiContainer& CSCStubMatcher::allCLCTsInChamber(unsigned int detid) const {
426  if (chamber_to_clcts_all_.find(detid) == chamber_to_clcts_all_.end())
427  return no_clcts_;
428  return chamber_to_clcts_all_.at(detid);
429 }
430 
431 const CSCALCTDigiContainer& CSCStubMatcher::allALCTsInChamber(unsigned int detid) const {
432  if (chamber_to_alcts_all_.find(detid) == chamber_to_alcts_all_.end())
433  return no_alcts_;
434  return chamber_to_alcts_all_.at(detid);
435 }
436 
438  if (chamber_to_lcts_all_.find(detid) == chamber_to_lcts_all_.end())
439  return no_lcts_;
440  return chamber_to_lcts_all_.at(detid);
441 }
442 
444  if (chamber_to_mplcts_all_.find(detid) == chamber_to_mplcts_all_.end())
445  return no_mplcts_;
446  return chamber_to_mplcts_all_.at(detid);
447 }
448 
449 const CSCCLCTDigiContainer& CSCStubMatcher::clctsInChamber(unsigned int detid) const {
450  if (chamber_to_clcts_.find(detid) == chamber_to_clcts_.end())
451  return no_clcts_;
452  return chamber_to_clcts_.at(detid);
453 }
454 
455 const CSCALCTDigiContainer& CSCStubMatcher::alctsInChamber(unsigned int detid) const {
456  if (chamber_to_alcts_.find(detid) == chamber_to_alcts_.end())
457  return no_alcts_;
458  return chamber_to_alcts_.at(detid);
459 }
460 
462  if (chamber_to_lcts_.find(detid) == chamber_to_lcts_.end())
463  return no_lcts_;
464  return chamber_to_lcts_.at(detid);
465 }
466 
468  if (chamber_to_mplcts_.find(detid) == chamber_to_mplcts_.end())
469  return no_mplcts_;
470  return chamber_to_mplcts_.at(detid);
471 }
472 
474  //sort stubs based on quality
475  const auto& input(clctsInChamber(detid));
476  int bestQ = 0;
477  int index = -1;
478  for (unsigned int i = 0; i < input.size(); ++i) {
479  int quality = input[i].getQuality();
480  if (quality > bestQ) {
481  bestQ = quality;
482  index = i;
483  }
484  }
485  if (index != -1)
486  return input[index];
487  return CSCCLCTDigi();
488 }
489 
491  //sort stubs based on quality
492  const auto& input(alctsInChamber(detid));
493  int bestQ = 0;
494  int index = -1;
495  for (unsigned int i = 0; i < input.size(); ++i) {
496  int quality = input[i].getQuality();
497  if (quality > bestQ) {
498  bestQ = quality;
499  index = i;
500  }
501  }
502  if (index != -1)
503  return input[index];
504  return CSCALCTDigi();
505 }
506 
508  //sort stubs based on quality
509  const auto& input(lctsInChamber(detid));
510  int bestQ = 0;
511  int index = -1;
512  for (unsigned int i = 0; i < input.size(); ++i) {
513  int quality = input[i].getQuality();
514  if (quality > bestQ) {
515  bestQ = quality;
516  index = i;
517  }
518  }
519  if (index != -1)
520  return input[index];
521  return CSCCorrelatedLCTDigi();
522 }
523 
524 float CSCStubMatcher::zpositionOfLayer(unsigned int detid, int layer) const {
525  const auto& id = CSCDetId(detid);
526  const auto& chamber(cscGeometry_->chamber(id));
527  return fabs(chamber->layer(layer)->centerOfStrip(20).z());
528 }
529 
530 int CSCStubMatcher::nChambersWithCLCT(int min_quality) const {
531  int result = 0;
532  const auto& chamber_ids = chamberIdsCLCT();
533  for (const auto& id : chamber_ids) {
534  int nStubChamber = 0;
535  const auto& clcts = clctsInChamber(id);
536  for (const auto& clct : clcts) {
537  if (!clct.isValid())
538  continue;
539  if (clct.getQuality() >= min_quality) {
540  nStubChamber++;
541  }
542  }
543  if (nStubChamber > 0) {
544  ++result;
545  }
546  }
547  return result;
548 }
549 
550 int CSCStubMatcher::nChambersWithALCT(int min_quality) const {
551  int result = 0;
552  const auto& chamber_ids = chamberIdsALCT();
553  for (const auto& id : chamber_ids) {
554  int nStubChamber = 0;
555  const auto& alcts = alctsInChamber(id);
556  for (const auto& alct : alcts) {
557  if (!alct.isValid())
558  continue;
559  if (alct.getQuality() >= min_quality) {
560  nStubChamber++;
561  }
562  }
563  if (nStubChamber > 0) {
564  ++result;
565  }
566  }
567  return result;
568 }
569 
570 int CSCStubMatcher::nChambersWithLCT(int min_quality) const {
571  int result = 0;
572  const auto& chamber_ids = chamberIdsLCT();
573  for (const auto& id : chamber_ids) {
574  int nStubChamber = 0;
575  const auto& lcts = lctsInChamber(id);
576  for (const auto& lct : lcts) {
577  if (!lct.isValid())
578  continue;
579  if (lct.getQuality() >= min_quality) {
580  nStubChamber++;
581  }
582  }
583  if (nStubChamber > 0) {
584  ++result;
585  }
586  }
587  return result;
588 }
589 
590 int CSCStubMatcher::nChambersWithMPLCT(int min_quality) const {
591  int result = 0;
592  const auto& chamber_ids = chamberIdsMPLCT();
593  for (const auto& id : chamber_ids) {
594  int nStubChamber = 0;
595  const auto& mplcts = mplctsInChamber(id);
596  for (const auto& mplct : mplcts) {
597  if (!mplct.isValid())
598  continue;
599  if (mplct.getQuality() >= min_quality) {
600  nStubChamber++;
601  }
602  }
603  if (nStubChamber > 0) {
604  ++result;
605  }
606  }
607  return result;
608 }
609 
610 bool CSCStubMatcher::lctInChamber(const CSCDetId& id, const CSCCorrelatedLCTDigi& lct) const {
611  for (const auto& stub : lctsInChamber(id.rawId())) {
612  if (stub == lct)
613  return true;
614  }
615  return false;
616 }
617 
619  CSCDetId cscId(rawId);
620  CSCDetId keyId(cscId.endcap(), cscId.station(), cscId.ring(), cscId.chamber(), CSCConstants::KEY_CLCT_LAYER);
621  float fractional_strip = lct.getFractionalStrip();
622  // case ME1/a
623  if (cscId.station() == 1 and cscId.ring() == 4 and lct.getStrip() > CSCConstants::MAX_HALF_STRIP_ME1B) {
624  fractional_strip -= CSCConstants::NUM_STRIPS_ME1B;
625  }
626  // regular cases
627  const auto& chamber = cscGeometry_->chamber(cscId);
628  const auto& layer_geo = chamber->layer(CSCConstants::KEY_CLCT_LAYER)->geometry();
629  // LCT::getKeyWG() also starts from 0
630  float wire = layer_geo->middleWireOfGroup(lct.getKeyWG() + 1);
631  const LocalPoint& csc_intersect = layer_geo->intersectionOfStripAndWire(fractional_strip, wire);
632  const GlobalPoint& csc_gp = cscGeometry_->idToDet(keyId)->surface().toGlobal(csc_intersect);
633  return csc_gp;
634 }
635 
637  chamber_to_clcts_all_.clear();
638  chamber_to_alcts_all_.clear();
639  chamber_to_lcts_all_.clear();
640  chamber_to_mplcts_all_.clear();
641 
642  chamber_to_clcts_.clear();
643  chamber_to_alcts_.clear();
644  chamber_to_lcts_.clear();
645  chamber_to_mplcts_.clear();
646 }
647 
649  const CSCCorrelatedLCTDigi& lct22,
650  CSCCorrelatedLCTDigiContainer& lcts_tmp) const {
651  int wg1 = lct11.getKeyWG();
652  int wg2 = lct22.getKeyWG();
653  int hs1 = lct11.getStrip();
654  int hs2 = lct22.getStrip();
655 
656  if (!(wg1 == wg2 || hs1 == hs2)) {
657  // flip the ALCTs
658  CSCCorrelatedLCTDigi lct12 = lct11;
659  lct12.setWireGroup(wg2);
660  lct12.setALCT(lct22.getALCT());
661  lct12.setCLCT(lct11.getCLCT());
662  lcts_tmp.push_back(lct12);
663 
664  CSCCorrelatedLCTDigi lct21 = lct22;
665  lct21.setWireGroup(wg1);
666  lct21.setALCT(lct11.getALCT());
667  lct21.setCLCT(lct22.getCLCT());
668  lcts_tmp.push_back(lct21);
669  }
670 }
CSCStubMatcher::clear
void clear()
Definition: CSCStubMatcher.cc:636
CSCStubMatcher::allLCTsInChamber
const CSCCorrelatedLCTDigiContainer & allLCTsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:437
mps_fire.i
i
Definition: mps_fire.py:428
CSCStubMatcher::bestAlctInChamber
CSCALCTDigi bestAlctInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:490
CSCStubMatcher::alctsInChamber
const CSCALCTDigiContainer & alctsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:455
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:618
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
CSCDetId::zendcap
short int zendcap() const
Definition: CSCDetId.h:91
CSCCorrelatedLCTDigi::getStrip
uint16_t getStrip(uint16_t n=2) const
return the key halfstrip from 0,159
Definition: CSCCorrelatedLCTDigi.cc:86
CSCCorrelatedLCTDigi::getCLCT
const CSCCLCTDigi & getCLCT() const
Definition: CSCCorrelatedLCTDigi.h:220
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:73
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
CSCStubMatcher::lctsInChamber
const CSCCorrelatedLCTDigiContainer & lctsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:461
GEMDigiMatcher
Definition: GEMDigiMatcher.h:31
CSCStubMatcher::nChambersWithLCT
int nChambersWithLCT(int min_quality=0) const
Definition: CSCStubMatcher.cc:570
CSCStubMatcher::addGhostLCTs
void addGhostLCTs(const CSCCorrelatedLCTDigi &lct11, const CSCCorrelatedLCTDigi &lct22, CSCCorrelatedLCTDigiContainer &lctcontainer) const
Definition: CSCStubMatcher.cc:648
CSCCorrelatedLCTDigi::setWireGroup
void setWireGroup(const uint16_t wiregroup)
set wiregroup number
Definition: CSCCorrelatedLCTDigi.h:168
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:115
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
CSCStubMatcher::nChambersWithMPLCT
int nChambersWithMPLCT(int min_quality=0) const
Definition: CSCStubMatcher.cc:590
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:122
CSCGeometry
Definition: CSCGeometry.h:24
CSCCorrelatedLCTDigi::setCLCT
void setCLCT(const CSCCLCTDigi &clct)
Definition: CSCCorrelatedLCTDigi.h:216
CSCCorrelatedLCTDigi::setALCT
void setALCT(const CSCALCTDigi &alct)
Definition: CSCCorrelatedLCTDigi.h:215
CSCStubMatcher::bestClctInChamber
CSCCLCTDigi bestClctInChamber(unsigned int) const
best matching from a particular crossed chamber
Definition: CSCStubMatcher.cc:473
CSCStubMatcher::allCLCTsInChamber
const CSCCLCTDigiContainer & allCLCTsInChamber(unsigned int) const
all stubs (not necessarily matching) from a particular crossed chamber
Definition: CSCStubMatcher.cc:425
CSCConstants::MAX_HALF_STRIP_ME1B
Definition: CSCConstants.h:88
CSCStubMatcher::bestLctInChamber
CSCCorrelatedLCTDigi bestLctInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:507
mps_fire.end
end
Definition: mps_fire.py:242
CSCConstants.h
CSCStubMatcher::clctsInChamber
const CSCCLCTDigiContainer & clctsInChamber(unsigned int) const
all matching from a particular crossed chamber
Definition: CSCStubMatcher.cc:449
Point3DBase< float, GlobalTag >
CSCStubMatcher::allMPLCTsInChamber
const CSCCorrelatedLCTDigiContainer & allMPLCTsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:443
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
CSCDetId::minLayerId
static int minLayerId()
Definition: CSCDetId.h:242
CSCCLCTDigiContainer
std::vector< CSCCLCTDigi > CSCCLCTDigiContainer
Definition: CSCStubMatcher.h:19
CSCStubMatcher::matchMPLCTsToSimTrack
void matchMPLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection &)
Definition: CSCStubMatcher.cc:364
CSCStubMatcher::mplctsInChamber
const CSCCorrelatedLCTDigiContainer & mplctsInChamber(unsigned int) const
Definition: CSCStubMatcher.cc:467
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
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CSCStubMatcher.h
CSCStubMatcher::matchALCTsToSimTrack
void matchALCTsToSimTrack(const CSCALCTDigiCollection &)
Definition: CSCStubMatcher.cc:181
GEMDetId
Definition: GEMDetId.h:18
CSCStubMatcher::chamberIdsAllMPLCT
std::set< unsigned int > chamberIdsAllMPLCT(int csc_type=MuonHitHelper::CSC_ALL) const
Definition: CSCStubMatcher.cc:405
CSCDetId
Definition: CSCDetId.h:26
CSCStubMatcher::chamberIdsMPLCT
std::set< unsigned int > chamberIdsMPLCT(int csc_type=MuonHitHelper::CSC_ALL) const
Definition: CSCStubMatcher.cc:421
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:397
CSCCorrelatedLCTDigi::getALCT
const CSCALCTDigi & getALCT() const
Definition: CSCCorrelatedLCTDigi.h:219
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:530
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:393
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:103
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
CSCDetId::maxLayerId
static int maxLayerId()
Definition: CSCDetId.h:243
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:401
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CSCConstants::NUM_STRIPS_ME1B
Definition: CSCConstants.h:78
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:409
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:524
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
CSCStubMatcher::chamberIdsLCT
std::set< unsigned int > chamberIdsLCT(int csc_type=MuonHitHelper::CSC_ALL) const
Definition: CSCStubMatcher.cc:417
CSCStubMatcher::chamberIdsALCT
std::set< unsigned int > chamberIdsALCT(int csc_type=MuonHitHelper::CSC_ALL) const
Definition: CSCStubMatcher.cc:413
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:431
CSCCorrelatedLCTDigi
Definition: CSCCorrelatedLCTDigi.h:19
CSCStubMatcher::nChambersWithALCT
int nChambersWithALCT(int min_quality=0) const
Definition: CSCStubMatcher.cc:550
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:610