CMS 3D CMS Logo

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