CMS 3D CMS Logo

CSCGEMMotherboard.cc
Go to the documentation of this file.
3 
5  unsigned sector, unsigned subsector,
6  unsigned chamber,
7  const edm::ParameterSet& conf) :
8  CSCUpgradeMotherboard(endcap, station, sector, subsector, chamber, conf)
9  , maxDeltaBXPad_(tmbParams_.getParameter<int>("maxDeltaBXPad"))
10  , maxDeltaBXCoPad_(tmbParams_.getParameter<int>("maxDeltaBXCoPad"))
11  , useOldLCTDataFormat_(tmbParams_.getParameter<bool>("useOldLCTDataFormat"))
12  , promoteALCTGEMpattern_(tmbParams_.getParameter<bool>("promoteALCTGEMpattern"))
13  , promoteALCTGEMquality_(tmbParams_.getParameter<bool>("promoteALCTGEMquality"))
14  , doLCTGhostBustingWithGEMs_(tmbParams_.getParameter<bool>("doLCTGhostBustingWithGEMs"))
15 {
16  // super chamber has layer=0!
18 
19  const edm::ParameterSet coPadParams(station==1 ?
20  conf.getParameter<edm::ParameterSet>("copadParamGE11") :
21  conf.getParameter<edm::ParameterSet>("copadParamGE21"));
22  coPadProcessor.reset( new GEMCoPadProcessor(endcap, station, chamber, coPadParams) );
23 
24  maxDeltaPadL1_ = (par ? tmbParams_.getParameter<int>("maxDeltaPadL1Even") :
25  tmbParams_.getParameter<int>("maxDeltaPadL1Odd") );
26  maxDeltaPadL2_ = (par ? tmbParams_.getParameter<int>("maxDeltaPadL2Even") :
27  tmbParams_.getParameter<int>("maxDeltaPadL2Odd") );
28 }
29 
31 {
32 }
33 
35 {
36 }
37 
39 {
40  pads_.clear();
41  coPads_.clear();
42 }
43 
44 
46  const CSCComparatorDigiCollection* compdc,
47  const GEMPadDigiClusterCollection* gemClusters)
48 {
49  std::unique_ptr<GEMPadDigiCollection> gemPads(new GEMPadDigiCollection());
50  coPadProcessor->declusterize(gemClusters, *gemPads);
51  run(wiredc, compdc, gemPads.get());
52 }
53 
54 
56 {
57  pads_.clear();
58  auto superChamber(gem_g->superChamber(id));
59  for (const auto& ch : superChamber->chambers()) {
60  for (const auto& roll : ch->etaPartitions()) {
61  GEMDetId roll_id(roll->id());
62  auto pads_in_det = gemPads->get(roll_id);
63  for (auto pad = pads_in_det.first; pad != pads_in_det.second; ++pad) {
64  const int bx_shifted(CSCConstants::LCT_CENTRAL_BX + pad->bx());
65  // consider matches with BX difference +1/0/-1
66  for (int bx = bx_shifted - maxDeltaBXPad_;bx <= bx_shifted + maxDeltaBXPad_; ++bx) {
67  pads_[bx].emplace_back(roll_id.rawId(), *pad);
68  }
69  }
70  }
71  }
72 }
73 
75 {
76  coPads_.clear();
77  for (const auto& copad: gemCoPadV){
78  GEMDetId detId(theRegion, 1, theStation, 0, theChamber, 0);
79  // only consider matches with same BX
80  coPads_[CSCConstants::LCT_CENTRAL_BX + copad.bx(1)].emplace_back(detId.rawId(), copad);
81  }
82 }
83 
85  const GEMCoPadDigi& gem,
86  enum CSCPart part,
87  int trknmb) const
88 {
89  return constructLCTsGEM(alct, CSCCLCTDigi(), GEMPadDigi(), gem, part, trknmb);
90 }
91 
92 
94  const GEMCoPadDigi& gem,
95  enum CSCPart part,
96  int trknmb) const
97 {
98  return constructLCTsGEM(CSCALCTDigi(), clct, GEMPadDigi(), gem, part, trknmb);
99 }
100 
102  const CSCCLCTDigi& clct,
103  const GEMCoPadDigi& gem,
104  enum CSCPart part,
105  int trknmb) const
106 {
107  return constructLCTsGEM(alct, clct, GEMPadDigi(), gem, part, trknmb);
108 }
109 
110 
112  const CSCCLCTDigi& clct,
113  const GEMPadDigi& gem,
114  enum CSCPart part,
115  int trknmb) const
116 {
117  return constructLCTsGEM(alct, clct, gem, GEMCoPadDigi(), part, trknmb);
118 }
119 
121  const CSCCLCTDigi& clct,
122  const GEMPadDigi& gem1,
123  const GEMCoPadDigi& gem2,
124  enum CSCPart p, int trknmb) const
125 {
126  int pattern = 0, quality = 0, bx = 0, keyStrip = 0, keyWG = 0, bend = 0;
127 
128  // make a new LCT
129  CSCCorrelatedLCTDigi thisLCT;
130 
131  // Determine the case and assign properties depending on the LCT dataformat (old/new)
132  if (alct.isValid() and clct.isValid() and gem1.isValid() and not gem2.isValid()) {
133  pattern = encodePattern(clct.getPattern(), clct.getStripType());
134  quality = findQualityGEM(alct, clct, 1);
135  bx = alct.getBX();
136  keyStrip = clct.getKeyStrip();
137  keyWG = alct.getKeyWG();
138  bend = clct.getBend();
139  thisLCT.setALCT(alct);
140  thisLCT.setCLCT(clct);
141  thisLCT.setGEM1(gem1);
143  }
144  else if (alct.isValid() and clct.isValid() and not gem1.isValid() and gem2.isValid()) {
145  pattern = encodePattern(clct.getPattern(), clct.getStripType());
146  quality = findQualityGEM(alct, clct, 2);
147  bx = alct.getBX();
148  keyStrip = clct.getKeyStrip();
149  keyWG = alct.getKeyWG();
150  bend = clct.getBend();
151  thisLCT.setALCT(alct);
152  thisLCT.setCLCT(clct);
153  thisLCT.setGEM1(gem2.first());
154  thisLCT.setGEM2(gem2.second());
156  }
157  else if (alct.isValid() and gem2.isValid()) {
158  const auto& mymap1 = getLUT()->get_gem_pad_to_csc_hs(par, p);
159  pattern = promoteALCTGEMpattern_ ? 10 : 0;
160  quality = promoteALCTGEMquality_ ? 15 : 11;
161  bx = alct.getBX();
162  keyStrip = mymap1[gem2.pad(2)];
163  keyWG = alct.getKeyWG();
164  thisLCT.setALCT(alct);
165  thisLCT.setGEM1(gem2.first());
166  thisLCT.setGEM2(gem2.second());
168  }
169  else if (clct.isValid() and gem2.isValid()) {
170  const auto& mymap2 = getLUT()->get_gem_roll_to_csc_wg(par, p);
171  pattern = encodePattern(clct.getPattern(), clct.getStripType());
172  quality = promoteCLCTGEMquality_ ? 15 : 11;
173  bx = gem2.bx(1) + CSCConstants::LCT_CENTRAL_BX;
174  keyStrip = clct.getKeyStrip();
175  // choose the corresponding wire-group in the middle of the partition
176  keyWG = mymap2[gem2.roll()];
177  bend = clct.getBend();
178  thisLCT.setCLCT(clct);
179  thisLCT.setGEM1(gem2.first());
180  thisLCT.setGEM2(gem2.second());
182  }
183 
184  // fill the rest of the properties
185  thisLCT.setTrknmb(trknmb);
186  thisLCT.setValid(1);
187  thisLCT.setQuality(quality);
188  thisLCT.setWireGroup(keyWG);
189  thisLCT.setStrip(keyStrip);
190  thisLCT.setPattern(pattern);
191  thisLCT.setBend(bend);
192  thisLCT.setBX(bx);
193  thisLCT.setMPCLink(0);
194  thisLCT.setBX0(0);
195  thisLCT.setSyncErr(0);
196  thisLCT.setCSCID(theTrigChamber);
197 
198  // future work: add a section that produces LCTs according
199  // to the new LCT dataformat (not yet defined)
200 
201  // return new LCT
202  return thisLCT;
203 }
204 
205 
207 {
208  // this only works for ME1A!
209  const auto& mymap = (getLUT()->get_csc_wg_to_gem_roll(par));
210  for (unsigned i=0; i<mymap.size(); i++) {
211  // overlap region are WGs 10-15
212  if ((i < 10) or (i > 15)) continue;
213  if ((mymap[i].first <= roll) and (roll <= mymap[i].second)) return true;
214  }
215  return false;
216 }
217 
218 bool CSCGEMMotherboard::isGEMDetId(unsigned int p) const
219 {
220  return (DetId(p).subdetId() == MuonSubdetId::GEM and
221  DetId(p).det() == DetId::Muon);
222 }
223 
225 {
226  return p.bx();
227 }
228 
230 {
231  return p.bx(1);
232 }
233 
235 {
236  return GEMDetId(p.first).roll();
237 }
238 
240 {
241  return p.second.roll();
242 }
243 
245 {
246  return (getLUT()->get_csc_wg_to_gem_roll(par))[alct.getKeyWG()].first;
247 }
248 
250 {
251  return p.pad();
252 }
253 
255 {
256  // average pad number for a GEMCoPad
257  return 0.5*(p.pad(1) + p.pad(2));
258 }
259 
261 {
262  const auto& mymap = (getLUT()->get_csc_hs_to_gem_pad(par, part));
263  return 0.5*(mymap[clct.getKeyStrip()].first + mymap[clct.getKeyStrip()].second);
264 }
265 
267 {
269  generator_->setGEMGeometry(gem_g);
270 }
271 
272 void CSCGEMMotherboard::printGEMTriggerPads(int bx_start, int bx_stop, enum CSCPart part)
273 {
274  LogTrace("CSCGEMMotherboard") << "------------------------------------------------------------------------" << std::endl;
275  LogTrace("CSCGEMMotherboard") << "* GEM trigger pads: " << std::endl;
276 
277  for (int bx = bx_start; bx <= bx_stop; bx++) {
278  const auto& in_pads = pads_[bx];
279  LogTrace("CSCGEMMotherboard") << "N(pads) BX " << bx << " : " << in_pads.size() << std::endl;
280 
281  for (const auto& pad : in_pads){
282  LogTrace("CSCGEMMotherboard") << "\tdetId " << GEMDetId(pad.first) << ", pad = " << pad.second;
283  const auto& roll_id(GEMDetId(pad.first));
284 
285  if (part==CSCPart::ME11 and isPadInOverlap(GEMDetId(roll_id).roll()))
286  LogTrace("CSCGEMMotherboard") << " (in overlap)" << std::endl;
287  else
288  LogTrace("CSCGEMMotherboard") << std::endl;
289  }
290  }
291 }
292 
293 
294 void CSCGEMMotherboard::printGEMTriggerCoPads(int bx_start, int bx_stop, enum CSCPart part)
295 {
296  LogTrace("CSCGEMMotherboard") << "------------------------------------------------------------------------" << std::endl;
297  LogTrace("CSCGEMMotherboard") << "* GEM trigger coincidence pads: " << std::endl;
298 
299  for (int bx = bx_start; bx <= bx_stop; bx++) {
300  const auto& in_pads = coPads_[bx];
301  LogTrace("CSCGEMMotherboard") << "N(copads) BX " << bx << " : " << in_pads.size() << std::endl;
302 
303  for (const auto& pad : in_pads){
304  LogTrace("CSCGEMMotherboard") << "\tdetId " << GEMDetId(pad.first) << ", pad = " << pad.second;
305  const auto& roll_id(GEMDetId(pad.first));
306 
307  if (part==CSCPart::ME11 and isPadInOverlap(GEMDetId(roll_id).roll())) LogTrace("CSCGEMMotherboard") << " (in overlap)" << std::endl;
308  else LogTrace("CSCGEMMotherboard") << std::endl;
309  }
310  }
311 }
312 
313 
315  const CSCCLCTDigi& cLCT, int gemlayers) const
316 {
317  // Either ALCT or CLCT is invalid
318  if (!(aLCT.isValid()) || !(cLCT.isValid())) {
319 
320  // No CLCT
321  if (aLCT.isValid() && !(cLCT.isValid()))
322  return LCT_Quality::NO_CLCT;
323 
324  // No ALCT
325  else if (!(aLCT.isValid()) && cLCT.isValid())
326  return LCT_Quality::NO_ALCT;
327 
328  // No ALCT and no CLCT
329  else
330  return LCT_Quality::INVALID;
331  }
332  // Both ALCT and CLCT are valid
333  else {
334  const int pattern(cLCT.getPattern());
335 
336  // Layer-trigger in CLCT
337  if (pattern == 1)
338  return LCT_Quality::CLCT_LAYER_TRIGGER;
339 
340  // Multi-layer pattern in CLCT
341  else {
342  // ALCT quality is the number of layers hit minus 3.
343  bool a4 = false;
344 
345  // Case of ME11 with GEMs: require 4 layers for ALCT
346  if (theStation==1) a4 = aLCT.getQuality() >= 1;
347 
348  // Case of ME21 with GEMs: require 4 layers for ALCT+GEM
349  if (theStation==2) a4 = aLCT.getQuality() + gemlayers >=1;
350 
351  // CLCT quality is the number of layers hit.
352  const bool c4((cLCT.getQuality() >= 4) or (cLCT.getQuality() >= 3 and gemlayers>=1));
353 
354  // quality = 4; "reserved for low-quality muons in future"
355 
356  // marginal anode and cathode
357  if (!a4 && !c4)
358  return LCT_Quality::MARGINAL_ANODE_CATHODE;
359 
360  // HQ anode, but marginal cathode
361  else if ( a4 && !c4)
362  return LCT_Quality::HQ_ANODE_MARGINAL_CATHODE;
363 
364  // HQ cathode, but marginal anode
365  else if (!a4 && c4)
366  return LCT_Quality::HQ_CATHODE_MARGINAL_ANODE;
367 
368  // HQ muon, but accelerator ALCT
369  else if ( a4 && c4) {
370 
371  if (aLCT.getAccelerator())
372  return LCT_Quality::HQ_ACCEL_ALCT;
373 
374  else {
375  // quality = 9; "reserved for HQ muons with future patterns
376  // quality = 10; "reserved for HQ muons with future patterns
377 
378  // High quality muons are determined by their CLCT pattern
379  if (pattern == 2 || pattern == 3)
380  return LCT_Quality::HQ_PATTERN_2_3;
381 
382  else if (pattern == 4 || pattern == 5)
383  return LCT_Quality::HQ_PATTERN_4_5;
384 
385  else if (pattern == 6 || pattern == 7)
386  return LCT_Quality::HQ_PATTERN_6_7;
387 
388  else if (pattern == 8 || pattern == 9)
389  return LCT_Quality::HQ_PATTERN_8_9;
390 
391  else if (pattern == 10)
392  return LCT_Quality::HQ_PATTERN_10;
393 
394  else {
395  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongValues")
396  << "+++ findQuality: Unexpected CLCT pattern id = "
397  << pattern << "+++\n";
398  return LCT_Quality::INVALID;
399  }
400  }
401  }
402  }
403  }
404  return LCT_Quality::INVALID;
405 }
406 
407 
408 template <> const matchesBX<GEMPadDigi>&
409 CSCGEMMotherboard::getPads<GEMPadDigi>() const
410 {
411  return pads_;
412 }
413 
414 template <> const matchesBX<GEMCoPadDigi>&
415 CSCGEMMotherboard::getPads<GEMCoPadDigi>() const
416 {
417  return coPads_;
418 }
419 
420 template <>
421 int CSCGEMMotherboard::getMaxDeltaBX<GEMPadDigi>() const
422 {
423  return maxDeltaBXPad_;
424 }
425 
426 template <>
427 int CSCGEMMotherboard::getMaxDeltaBX<GEMCoPadDigi>() const
428 {
429  return maxDeltaBXCoPad_;
430 }
431 
432 template <>
433 int CSCGEMMotherboard::getLctTrigEnable<CSCALCTDigi>() const
434 {
435  return alct_trig_enable;
436 }
437 
438 template <>
439 int CSCGEMMotherboard::getLctTrigEnable<CSCCLCTDigi>() const
440 {
441  return clct_trig_enable;
442 }
443 
int getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:36
bool isValid() const
Definition: GEMPadDigi.cc:48
void retrieveGEMPads(const GEMPadDigiCollection *pads, unsigned id)
T getParameter(std::string const &) const
match< GEMCoPadDigi > GEMCoPadDigiId
void setALCT(const CSCALCTDigi &alct)
void setGEM2(const GEMPadDigi &gem)
unsigned int clct_trig_enable
void setWireGroup(unsigned int wiregroup)
set wiregroup number
void setBend(unsigned int b)
set bend
std::unique_ptr< CSCUpgradeMotherboardLUTGenerator > generator_
const unsigned theTrigChamber
bool isValid() const
check ALCT validity (1 - valid ALCT)
Definition: CSCALCTDigi.h:30
GEMCoPadDigiIdsBX coPads_
CSCCorrelatedLCTDigi constructLCTsGEM(const CSCALCTDigi &alct, const GEMCoPadDigi &gem, enum CSCPart, int i) const
void setBX0(unsigned int b)
set bx0
static const int GEM
Definition: MuonSubdetId.h:15
int roll() const
Definition: GEMDetId.h:80
std::vector< int > get_gem_roll_to_csc_wg(Parity par, int layer=1) const
void setQuality(unsigned int q)
set quality code
int getBX(const GEMPadDigi &p) const
int pad(int l) const
Definition: GEMCoPadDigi.cc:38
int getStripType() const
return striptype
Definition: CSCCLCTDigi.h:48
A class for AMC data.
Definition: AMC13Event.h:6
std::vector< GEMCoPadDigi > gemCoPadV
int getBend() const
return bend
Definition: CSCCLCTDigi.h:54
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
void setMPCLink(const uint16_t &link)
Set mpc link number after MPC sorting.
U second(std::pair< T, U > const &p)
bool isValid() const
Definition: GEMCoPadDigi.cc:32
match< GEMPadDigi > GEMPadDigiId
const unsigned theStation
void setPattern(unsigned int p)
set pattern
void setValid(unsigned int v)
set valid
std::unique_ptr< GEMCoPadProcessor > coPadProcessor
virtual void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiCollection *gemPads)=0
void setSyncErr(unsigned int s)
set syncErr
int bx(int l) const
Definition: GEMCoPadDigi.cc:46
void setStrip(unsigned int s)
set strip
unsigned int findQualityGEM(const CSCALCTDigi &, const CSCCLCTDigi &, int gemlayer) const
virtual std::vector< std::pair< int, int > > get_csc_hs_to_gem_pad(Parity par, enum CSCPart) const =0
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
int pad() const
Definition: GEMPadDigi.h:27
void printGEMTriggerCoPads(int bx_start, int bx_stop, enum CSCPart)
GEMPadDigi first() const
Definition: GEMCoPadDigi.h:30
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:30
int getRoll(const GEMPadDigiId &p) const
void setCSCID(unsigned int c)
set cscID
bool isGEMDetId(unsigned int) const
int roll() const
Definition: GEMCoPadDigi.h:26
#define LogTrace(id)
const GEMSuperChamber * superChamber(GEMDetId id) const
Definition: GEMGeometry.cc:91
int getBX() const
return BX - five low bits of BXN counter tagged by the ALCT
Definition: CSCALCTDigi.h:63
bool isPadInOverlap(int roll) const
float getPad(const GEMPadDigi &) const
virtual std::vector< int > get_gem_pad_to_csc_hs(Parity par, enum CSCPart) const =0
edm::ParameterSet tmbParams_
Definition: DetId.h:18
int getQuality() const
return quality of a pattern
Definition: CSCALCTDigi.h:36
int getAccelerator() const
Definition: CSCALCTDigi.h:43
void setBX(unsigned int b)
set bx
int bx() const
Definition: GEMPadDigi.h:28
int getPattern() const
return pattern
Definition: CSCCLCTDigi.h:42
part
Definition: HCALResponse.h:20
MuonDigiCollection< GEMDetId, GEMPadDigi > GEMPadDigiCollection
GEMPadDigi second() const
Definition: GEMCoPadDigi.h:31
unsigned int encodePattern(const int ptn, const int highPt) const
unsigned int alct_trig_enable
virtual const CSCGEMMotherboardLUT * getLUT() const =0
GEMPadDigiIdsBX pads_
std::unique_ptr< CSCAnodeLCTProcessor > alct
std::unique_ptr< CSCCathodeLCTProcessor > clct
~CSCGEMMotherboard() override
int getKeyStrip() const
Definition: CSCCLCTDigi.h:89
const GEMGeometry * gem_g
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting LCTs.
void setCLCT(const CSCCLCTDigi &clct)
int getKeyWG() const
return key wire group
Definition: CSCALCTDigi.h:57
void setGEM1(const GEMPadDigi &gem)
void printGEMTriggerPads(int bx_start, int bx_stop, enum CSCPart)
std::vector< std::pair< int, int > > get_csc_wg_to_gem_roll(Parity par, int layer=1) const