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  if (not alct.isValid() and not clct.isValid()) {
131  LogTrace("CSCGEMCMotherboard") << "Warning!!! either ALCT or CLCT not valid, return invalid LCT \n";
132  return thisLCT;
133  }
134 
135  // Determine the case and assign properties depending on the LCT dataformat (old/new)
136  if (alct.isValid() and clct.isValid() and gem1.isValid() and not gem2.isValid()) {
137  pattern = encodePattern(clct.getPattern(), clct.getStripType());
138  quality = findQualityGEM(alct, clct, 1);
139  bx = alct.getBX();
140  keyStrip = clct.getKeyStrip();
141  keyWG = alct.getKeyWG();
142  bend = clct.getBend();
143  thisLCT.setALCT(getBXShiftedALCT(alct));
144  thisLCT.setCLCT(clct);
145  thisLCT.setGEM1(gem1);
147  }
148  else if (alct.isValid() and clct.isValid() and not gem1.isValid() and gem2.isValid()) {
149  pattern = encodePattern(clct.getPattern(), clct.getStripType());
150  quality = findQualityGEM(alct, clct, 2);
151  bx = alct.getBX();
152  keyStrip = clct.getKeyStrip();
153  keyWG = alct.getKeyWG();
154  bend = clct.getBend();
155  thisLCT.setALCT(getBXShiftedALCT(alct));
156  thisLCT.setCLCT(clct);
157  thisLCT.setGEM1(gem2.first());
158  thisLCT.setGEM2(gem2.second());
160  }
161  else if (alct.isValid() and gem2.isValid() and not clct.isValid()) {
162  const auto& mymap1 = getLUT()->get_gem_pad_to_csc_hs(par, p);
163  pattern = promoteALCTGEMpattern_ ? 10 : 0;
164  quality = promoteALCTGEMquality_ ? 15 : 11;
165  bx = alct.getBX();
166  // GEM pad number is counting from 1
167  keyStrip = mymap1[gem2.pad(2) - 1];
168  keyWG = alct.getKeyWG();
169  thisLCT.setALCT(getBXShiftedALCT(alct));
170  thisLCT.setGEM1(gem2.first());
171  thisLCT.setGEM2(gem2.second());
173  }
174  else if (clct.isValid() and gem2.isValid() and not alct.isValid()) {
175  const auto& mymap2 = getLUT()->get_gem_roll_to_csc_wg(par, p);
176  pattern = encodePattern(clct.getPattern(), clct.getStripType());
177  quality = promoteCLCTGEMquality_ ? 15 : 11;
178  bx = gem2.bx(1) + CSCConstants::LCT_CENTRAL_BX;
179  keyStrip = clct.getKeyStrip();
180  // choose the corresponding wire-group in the middle of the partition
181  keyWG = mymap2[gem2.roll()];
182  bend = clct.getBend();
183  thisLCT.setCLCT(clct);
184  thisLCT.setGEM1(gem2.first());
185  thisLCT.setGEM2(gem2.second());
187  }
188 
189  // fill the rest of the properties
190  thisLCT.setTrknmb(trknmb);
191  thisLCT.setValid(1);
192  thisLCT.setQuality(quality);
193  thisLCT.setWireGroup(keyWG);
194  thisLCT.setStrip(keyStrip);
195  thisLCT.setPattern(pattern);
196  thisLCT.setBend(bend);
197  thisLCT.setBX(bx);
198  thisLCT.setMPCLink(0);
199  thisLCT.setBX0(0);
200  thisLCT.setSyncErr(0);
201  thisLCT.setCSCID(theTrigChamber);
202 
203  // future work: add a section that produces LCTs according
204  // to the new LCT dataformat (not yet defined)
205 
206  // return new LCT
207  return thisLCT;
208 }
209 
210 
212 {
213  // this only works for ME1A!
214  const auto& mymap = (getLUT()->get_csc_wg_to_gem_roll(par));
215  for (unsigned i=0; i<mymap.size(); i++) {
216  // overlap region are WGs 10-15
217  if ((i < 10) or (i > 15)) continue;
218  if ((mymap[i].first <= roll) and (roll <= mymap[i].second)) return true;
219  }
220  return false;
221 }
222 
223 bool CSCGEMMotherboard::isGEMDetId(unsigned int p) const
224 {
225  return (DetId(p).subdetId() == MuonSubdetId::GEM and
226  DetId(p).det() == DetId::Muon);
227 }
228 
230 {
231  return p.bx();
232 }
233 
235 {
236  return p.bx(1);
237 }
238 
240 {
241  return GEMDetId(p.first).roll();
242 }
243 
245 {
246  return p.second.roll();
247 }
248 
250 {
251  return (getLUT()->get_csc_wg_to_gem_roll(par))[alct.getKeyWG()].first;
252 }
253 
255 {
256  return p.pad();
257 }
258 
260 {
261  // average pad number for a GEMCoPad
262  return 0.5*(p.pad(1) + p.pad(2));
263 }
264 
266 {
267  const auto& mymap = (getLUT()->get_csc_hs_to_gem_pad(par, part));
268  return 0.5*(mymap[clct.getKeyStrip()].first + mymap[clct.getKeyStrip()].second);
269 }
270 
272 {
274  generator_->setGEMGeometry(gem_g);
275 }
276 
277 void CSCGEMMotherboard::printGEMTriggerPads(int bx_start, int bx_stop, enum CSCPart part)
278 {
279  LogTrace("CSCGEMMotherboard") << "------------------------------------------------------------------------" << std::endl;
280  LogTrace("CSCGEMMotherboard") << "* GEM trigger pads: " << std::endl;
281 
282  for (int bx = bx_start; bx <= bx_stop; bx++) {
283  const auto& in_pads = pads_[bx];
284  LogTrace("CSCGEMMotherboard") << "N(pads) BX " << bx << " : " << in_pads.size() << std::endl;
285 
286  for (const auto& pad : in_pads){
287  LogTrace("CSCGEMMotherboard") << "\tdetId " << GEMDetId(pad.first) << ", pad = " << pad.second;
288  const auto& roll_id(GEMDetId(pad.first));
289 
290  if (part==CSCPart::ME11 and isPadInOverlap(GEMDetId(roll_id).roll()))
291  LogTrace("CSCGEMMotherboard") << " (in overlap)" << std::endl;
292  else
293  LogTrace("CSCGEMMotherboard") << std::endl;
294  }
295  }
296 }
297 
298 
299 void CSCGEMMotherboard::printGEMTriggerCoPads(int bx_start, int bx_stop, enum CSCPart part)
300 {
301  LogTrace("CSCGEMMotherboard") << "------------------------------------------------------------------------" << std::endl;
302  LogTrace("CSCGEMMotherboard") << "* GEM trigger coincidence pads: " << std::endl;
303 
304  for (int bx = bx_start; bx <= bx_stop; bx++) {
305  const auto& in_pads = coPads_[bx];
306  LogTrace("CSCGEMMotherboard") << "N(copads) BX " << bx << " : " << in_pads.size() << std::endl;
307 
308  for (const auto& pad : in_pads){
309  LogTrace("CSCGEMMotherboard") << "\tdetId " << GEMDetId(pad.first) << ", pad = " << pad.second;
310  const auto& roll_id(GEMDetId(pad.first));
311 
312  if (part==CSCPart::ME11 and isPadInOverlap(GEMDetId(roll_id).roll())) LogTrace("CSCGEMMotherboard") << " (in overlap)" << std::endl;
313  else LogTrace("CSCGEMMotherboard") << std::endl;
314  }
315  }
316 }
317 
318 
320  const CSCCLCTDigi& cLCT, int gemlayers) const
321 {
322  // Either ALCT or CLCT is invalid
323  if (!(aLCT.isValid()) || !(cLCT.isValid())) {
324 
325  // No CLCT
326  if (aLCT.isValid() && !(cLCT.isValid()))
327  return LCT_Quality::NO_CLCT;
328 
329  // No ALCT
330  else if (!(aLCT.isValid()) && cLCT.isValid())
331  return LCT_Quality::NO_ALCT;
332 
333  // No ALCT and no CLCT
334  else
335  return LCT_Quality::INVALID;
336  }
337  // Both ALCT and CLCT are valid
338  else {
339  const int pattern(cLCT.getPattern());
340 
341  // Layer-trigger in CLCT
342  if (pattern == 1)
343  return LCT_Quality::CLCT_LAYER_TRIGGER;
344 
345  // Multi-layer pattern in CLCT
346  else {
347  // ALCT quality is the number of layers hit minus 3.
348  bool a4 = false;
349 
350  // Case of ME11 with GEMs: require 4 layers for ALCT
351  if (theStation==1) a4 = aLCT.getQuality() >= 1;
352 
353  // Case of ME21 with GEMs: require 4 layers for ALCT+GEM
354  if (theStation==2) a4 = aLCT.getQuality() + gemlayers >=1;
355 
356  // CLCT quality is the number of layers hit.
357  const bool c4((cLCT.getQuality() >= 4) or (cLCT.getQuality() >= 3 and gemlayers>=1));
358 
359  // quality = 4; "reserved for low-quality muons in future"
360 
361  // marginal anode and cathode
362  if (!a4 && !c4)
363  return LCT_Quality::MARGINAL_ANODE_CATHODE;
364 
365  // HQ anode, but marginal cathode
366  else if ( a4 && !c4)
367  return LCT_Quality::HQ_ANODE_MARGINAL_CATHODE;
368 
369  // HQ cathode, but marginal anode
370  else if (!a4 && c4)
371  return LCT_Quality::HQ_CATHODE_MARGINAL_ANODE;
372 
373  // HQ muon, but accelerator ALCT
374  else if ( a4 && c4) {
375 
376  if (aLCT.getAccelerator())
377  return LCT_Quality::HQ_ACCEL_ALCT;
378 
379  else {
380  // quality = 9; "reserved for HQ muons with future patterns
381  // quality = 10; "reserved for HQ muons with future patterns
382 
383  // High quality muons are determined by their CLCT pattern
384  if (pattern == 2 || pattern == 3)
385  return LCT_Quality::HQ_PATTERN_2_3;
386 
387  else if (pattern == 4 || pattern == 5)
388  return LCT_Quality::HQ_PATTERN_4_5;
389 
390  else if (pattern == 6 || pattern == 7)
391  return LCT_Quality::HQ_PATTERN_6_7;
392 
393  else if (pattern == 8 || pattern == 9)
394  return LCT_Quality::HQ_PATTERN_8_9;
395 
396  else if (pattern == 10)
397  return LCT_Quality::HQ_PATTERN_10;
398 
399  else {
400  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongValues")
401  << "+++ findQuality: Unexpected CLCT pattern id = "
402  << pattern << "+++\n";
403  return LCT_Quality::INVALID;
404  }
405  }
406  }
407  }
408  }
409  return LCT_Quality::INVALID;
410 }
411 
412 
413 template <> const matchesBX<GEMPadDigi>&
414 CSCGEMMotherboard::getPads<GEMPadDigi>() const
415 {
416  return pads_;
417 }
418 
419 template <> const matchesBX<GEMCoPadDigi>&
420 CSCGEMMotherboard::getPads<GEMCoPadDigi>() const
421 {
422  return coPads_;
423 }
424 
425 template <>
426 int CSCGEMMotherboard::getMaxDeltaBX<GEMPadDigi>() const
427 {
428  return maxDeltaBXPad_;
429 }
430 
431 template <>
432 int CSCGEMMotherboard::getMaxDeltaBX<GEMCoPadDigi>() const
433 {
434  return maxDeltaBXCoPad_;
435 }
436 
437 template <>
438 int CSCGEMMotherboard::getLctTrigEnable<CSCALCTDigi>() const
439 {
440  return alct_trig_enable;
441 }
442 
443 template <>
444 int CSCGEMMotherboard::getLctTrigEnable<CSCCLCTDigi>() const
445 {
446  return clct_trig_enable;
447 }
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_
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
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
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
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