CMS 3D CMS Logo

CSCMotherboardME11.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Class: CSCMotherboardME11
4 //
5 // Description:
6 // Extended CSCMotherboard for ME11 to handle ME1a and ME1b separately
7 //
8 // Author List: Vadim Khotilovich 12 May 2009
9 //
10 //
11 //-----------------------------------------------------------------------------
12 
14 
16  unsigned station,
17  unsigned sector,
18  unsigned subsector,
19  unsigned chamber,
20  const edm::ParameterSet& conf)
21  : CSCUpgradeMotherboard(endcap, station, sector, subsector, chamber, conf) {
22  if (!isSLHC_)
23  edm::LogError("CSCMotherboardME11|ConfigError")
24  << "+++ Upgrade CSCMotherboardME11 constructed while isSLHC_ is not set! +++\n";
25 
26  cscTmbLUT_.reset(new CSCMotherboardLUTME11());
27 
28  // ignore unphysical ALCT-CLCT matches
29  ignoreAlctCrossClct = tmbParams_.getParameter<bool>("ignoreAlctCrossClct");
30 }
31 
33  if (!isSLHC_)
34  edm::LogError("CSCMotherboardME11|ConfigError")
35  << "+++ Upgrade CSCMotherboardME11 constructed while isSLHC_ is not set! +++\n";
36 }
37 
39 
41 
42 // Set configuration parameters obtained via EventSetup mechanism.
44  alctProc->setConfigParameters(conf);
45  clctProc->setConfigParameters(conf);
46  // No config. parameters in DB for the TMB itself yet.
47 }
48 
50  clear();
51 
52  // Check for existing processors
53  if (!(alctProc && clctProc && isSLHC_)) {
54  if (infoV >= 0)
55  edm::LogError("CSCMotherboardME11|SetupError") << "+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
56  return;
57  }
58 
59  alctProc->setCSCGeometry(cscGeometry_);
60  clctProc->setCSCGeometry(cscGeometry_);
61 
62  alctV = alctProc->run(wiredc); // run anodeLCT
63  clctV = clctProc->run(compdc); // run cathodeLCT
64 
65  // if there are no ALCTs and no CLCTs, it does not make sense to run this TMB
66  if (alctV.empty() and clctV.empty())
67  return;
68 
69  int used_alct_mask[20];
70  int used_clct_mask[20];
71  for (int b = 0; b < 20; b++)
72  used_alct_mask[b] = used_clct_mask[b] = 0;
73 
74  // CLCT-centric CLCT-to-ALCT matching
75  if (clct_to_alct) {
76  for (int bx_clct = 0; bx_clct < CSCConstants::MAX_CLCT_TBINS; bx_clct++) {
77  if (clctProc->getBestCLCT(bx_clct).isValid()) {
78  bool is_matched = false;
79  const int bx_alct_start = bx_clct - match_trig_window_size / 2 + alctClctOffset_;
80  const int bx_alct_stop = bx_clct + match_trig_window_size / 2 + alctClctOffset_;
81  for (int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
82  if (bx_alct < 0 || bx_alct >= CSCConstants::MAX_ALCT_TBINS)
83  continue;
84  if (drop_used_alcts && used_alct_mask[bx_alct])
85  continue;
86  if (alctProc->getBestALCT(bx_alct).isValid()) {
87  if (infoV > 1)
88  LogTrace("CSCMotherboardME11")
89  << "Successful CLCT-ALCT match in ME11: bx_clct = " << bx_clct << "; match window: [" << bx_alct_start
90  << "; " << bx_alct_stop << "]; bx_alct = " << bx_alct;
91  int mbx = bx_alct_stop - bx_alct;
92  correlateLCTsME11(alctProc->getBestALCT(bx_alct),
93  alctProc->getSecondALCT(bx_alct),
94  clctProc->getBestCLCT(bx_clct),
95  clctProc->getSecondCLCT(bx_clct),
96  allLCTs(bx_alct, mbx, 0),
97  allLCTs(bx_alct, mbx, 1));
98  if (allLCTs(bx_alct, mbx, 0).isValid()) {
99  used_alct_mask[bx_alct] += 1;
101  break;
102  }
103  }
104  }
105  // Do not report CLCT-only LCT for ME11
106  if (!is_matched) {
107  if (infoV > 1)
108  LogTrace("CSCMotherboard") << "Unsuccessful ALCT-CLCT match (CLCT only): bx_clct = " << bx_clct
109  << " first CLCT " << clctProc->getBestCLCT(bx_clct) << "; match window: ["
110  << bx_alct_start << "; " << bx_alct_stop << "]";
111  }
112  }
113  } // end of CLCT-centric matching
114 
115  // ALCT-centric ALCT-to-CLCT matching
116  } else {
117  for (int bx_alct = 0; bx_alct < CSCConstants::MAX_ALCT_TBINS; bx_alct++) {
118  if (alctProc->getBestALCT(bx_alct).isValid()) {
119  const int bx_clct_start = bx_alct - match_trig_window_size / 2 - alctClctOffset_;
120  const int bx_clct_stop = bx_alct + match_trig_window_size / 2 - alctClctOffset_;
121 
122  // matching in ME11
123  bool is_matched = false;
124  for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++) {
125  if (bx_clct < 0 || bx_clct >= CSCConstants::MAX_CLCT_TBINS)
126  continue;
127  if (drop_used_clcts && used_clct_mask[bx_clct])
128  continue;
129  if (clctProc->getBestCLCT(bx_clct).isValid()) {
130  if (infoV > 1)
131  LogTrace("CSCMotherboardME11")
132  << "Successful ALCT-CLCT match in ME11: bx_alct = " << bx_alct << "; match window: [" << bx_clct_start
133  << "; " << bx_clct_stop << "]; bx_clct = " << bx_clct;
134  int mbx = bx_clct - bx_clct_start;
135  correlateLCTsME11(alctProc->getBestALCT(bx_alct),
136  alctProc->getSecondALCT(bx_alct),
137  clctProc->getBestCLCT(bx_clct),
138  clctProc->getSecondCLCT(bx_clct),
139  allLCTs(bx_alct, mbx, 0),
140  allLCTs(bx_alct, mbx, 1));
141  if (allLCTs(bx_alct, mbx, 0).isValid()) {
142  is_matched = true;
143  used_clct_mask[bx_clct] += 1;
145  break;
146  }
147  }
148  }
149  if (!is_matched) {
150  if (infoV > 1)
151  LogTrace("CSCMotherboard") << "Unsuccessful ALCT-CLCT match (ALCT only): bx_alct = " << bx_alct
152  << " first ALCT " << alctProc->getBestALCT(bx_alct) << "; match window: ["
153  << bx_clct_start << "; " << bx_clct_stop << "]";
154  }
155  }
156  } // end of ALCT-centric matching
157  }
158 
159  // reduction of nLCTs per each BX
160  //add similar cross bx algorithm to standard TMB in next step
161  for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++) {
162  // counting
163  unsigned int nlct = 0;
164  unsigned int nbx = 0;
165  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++) {
166  bool hasLCT = false;
167  for (int i = 0; i < CSCConstants::MAX_LCTS_PER_CSC; i++) {
168  if (allLCTs(bx, mbx, i).isValid()) {
169  nlct++;
170  hasLCT = true;
171  if (infoV > 0) {
172  LogDebug("CSCMotherboardME11") << "LCT" << i + 1 << " " << bx << "/"
173  << bx + mbx - match_trig_window_size / 2 << ": " << allLCTs(bx, mbx, i);
174  }
175  }
176  }
177  if (hasLCT)
178  nbx++;
179  }
180  if (infoV > 0 && nlct > 0)
181  LogDebug("CSCMotherboardME11") << "bx " << bx << " nLCT: " << nlct << " total mbx with LCTs " << nbx;
182 
183  // some simple cross-bx sorting algorithms
184  if (tmb_cross_bx_algo == 1 and (nlct > 2 or nbx > 1)) {
185  nbx = 0;
186  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++) {
187  nlct = 0;
188  bool hasLCT = false;
189  for (int i = 0; i < CSCConstants::MAX_LCTS_PER_CSC; i++) {
190  if (allLCTs(bx, pref[mbx], i).isValid()) {
191  nlct++;
192  hasLCT = true;
193  if (nlct > CSCConstants::MAX_LCTS_PER_CSC or nbx > 0)
194  allLCTs(bx, pref[mbx], i).clear();
195  }
196  }
197  if (hasLCT)
198  nbx++;
199  }
200 
201  if (infoV > 0)
202  LogDebug("CSCMotherboardME11") << "After x-bx sorting:";
203  nlct = 0;
204  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
205  for (int i = 0; i < CSCConstants::MAX_LCTS_PER_CSC; i++) {
206  if (allLCTs(bx, mbx, i).isValid()) {
207  nlct++;
208  if (infoV > 0) {
209  LogDebug("CSCMotherboardME11") << "LCT" << i + 1 << " " << bx << "/"
210  << bx + mbx - match_trig_window_size / 2 << ": " << allLCTs(bx, mbx, i);
211  }
212  }
213  }
214  if (infoV > 0 && nlct > 0)
215  LogDebug("CSCMotherboardME11") << "bx " << bx << " nnLCT: " << nlct;
216  } // x-bx sorting
217  } // end of for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++)
218 }
219 
220 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::readoutLCTs1a() const { return readoutLCTs(ME1A); }
221 
222 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::readoutLCTs1b() const { return readoutLCTs(ME1B); }
223 
224 // Returns vector of read-out correlated LCTs, if any. Starts with
225 // the vector of all found LCTs and selects the ones in the read-out
226 // time window.
227 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::readoutLCTs(int me1ab) const {
228  std::vector<CSCCorrelatedLCTDigi> tmpV;
229 
230  // The start time of the L1A*LCT coincidence window should be related
231  // to the fifo_pretrig parameter, but I am not completely sure how.
232  // Just choose it such that the window is centered at bx=7. This may
233  // need further tweaking if the value of tmb_l1a_window_size changes.
234  //static int early_tbins = 4;
235  // The number of LCT bins in the read-out is given by the
236  // tmb_l1a_window_size parameter, forced to be odd
237  const int lct_bins = (tmb_l1a_window_size % 2 == 0) ? tmb_l1a_window_size + 1 : tmb_l1a_window_size;
238  const int late_tbins = early_tbins + lct_bins;
239 
240  // Start from the vector of all found correlated LCTs and select
241  // those within the LCT*L1A coincidence window.
242  int bx_readout = -1;
243  std::vector<CSCCorrelatedLCTDigi> all_lcts;
244  if (me1ab == ME1A)
245  all_lcts = getLCTs1a();
246  if (me1ab == ME1B)
247  all_lcts = getLCTs1b();
248  std::vector<CSCCorrelatedLCTDigi>::const_iterator plct = all_lcts.begin();
249  for (; plct != all_lcts.end(); plct++) {
250  if (!plct->isValid())
251  continue;
252 
253  int bx = (*plct).getBX();
254  // Skip LCTs found too early relative to L1Accept.
255  if (bx <= early_tbins)
256  continue;
257 
258  // Skip LCTs found too late relative to L1Accept.
259  if (bx > late_tbins)
260  continue;
261 
262  // If (readout_earliest_2) take only LCTs in the earliest bx in the read-out window:
263  // in digi->raw step, LCTs have to be packed into the TMB header, and
264  // currently there is room just for two.
265  if (readout_earliest_2 && (bx_readout == -1 || bx == bx_readout)) {
266  tmpV.push_back(*plct);
267  if (bx_readout == -1)
268  bx_readout = bx;
269  } else
270  tmpV.push_back(*plct);
271  }
272  return tmpV;
273 }
274 
275 // Returns vector of found correlated LCTs, if any.
276 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::getLCTs1b() const {
277  std::vector<CSCCorrelatedLCTDigi> tmpV;
278 
279  for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++) {
280  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++) {
281  for (int i = 0; i < CSCConstants::MAX_LCTS_PER_CSC; i++) {
282  const CSCCorrelatedLCTDigi& lct = allLCTs.data[bx][mbx][i];
283  if (lct.isValid() and lct.getStrip() < CSCConstants::MAX_HALF_STRIP_ME1B) {
284  tmpV.push_back(lct);
285  }
286  }
287  }
288  }
289  return tmpV;
290 }
291 
292 // Returns vector of found correlated LCTs, if any.
293 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::getLCTs1a() const {
294  std::vector<CSCCorrelatedLCTDigi> tmpV;
295 
296  // disabled ME1a
298  return tmpV;
299 
300  for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++) {
301  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++) {
302  for (int i = 0; i < CSCConstants::MAX_LCTS_PER_CSC; i++) {
303  const CSCCorrelatedLCTDigi& lct = allLCTs.data[bx][mbx][i];
304  if (lct.isValid() and lct.getStrip() >= CSCConstants::MAX_HALF_STRIP_ME1B) {
305  tmpV.push_back(lct);
306  }
307  }
308  }
309  } // Report all LCTs found.
310  return tmpV;
311 }
312 
314  return cscTmbLUT_->doesALCTCrossCLCT(a, c, theEndcap, gangedME1a_);
315 }
316 
318  const CSCALCTDigi& sALCT,
319  const CSCCLCTDigi& bCLCT,
320  const CSCCLCTDigi& sCLCT,
321  CSCCorrelatedLCTDigi& lct1,
322  CSCCorrelatedLCTDigi& lct2) const {
323  // assume that always anodeBestValid && cathodeBestValid
324  CSCALCTDigi bestALCT = bALCT;
325  CSCALCTDigi secondALCT = sALCT;
326  CSCCLCTDigi bestCLCT = bCLCT;
327  CSCCLCTDigi secondCLCT = sCLCT;
328 
329  if (ignoreAlctCrossClct) {
330  const bool anodeBestValid = bestALCT.isValid();
331  const bool anodeSecondValid = secondALCT.isValid();
332  const bool cathodeBestValid = bestCLCT.isValid();
333  const bool cathodeSecondValid = secondCLCT.isValid();
334  if (anodeBestValid and !anodeSecondValid)
335  secondALCT = bestALCT;
336  if (!anodeBestValid and anodeSecondValid)
337  bestALCT = secondALCT;
338  if (cathodeBestValid and !cathodeSecondValid)
339  secondCLCT = bestCLCT;
340  if (!cathodeBestValid and cathodeSecondValid)
341  bestCLCT = secondCLCT;
342  // ALCT-CLCT matching conditions are defined by "trig_enable" configuration
343  // parameters.
344  if ((alct_trig_enable and bestALCT.isValid()) or (clct_trig_enable and bestCLCT.isValid()) or
345  (match_trig_enable and bestALCT.isValid() and bestCLCT.isValid())) {
346  lct1 = constructLCTs(bestALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 1);
347  }
348  if (((secondALCT != bestALCT) or (secondCLCT != bestCLCT)) and
349  ((alct_trig_enable and secondALCT.isValid()) or (clct_trig_enable and secondCLCT.isValid()) or
350  (match_trig_enable and secondALCT.isValid() and secondCLCT.isValid()))) {
351  lct2 = constructLCTs(secondALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 2);
352  }
353  return;
354  } else {
355  if (secondALCT == bestALCT)
356  secondALCT.clear();
357  if (secondCLCT == bestCLCT)
358  secondCLCT.clear();
359 
360  const int ok11 = doesALCTCrossCLCT(bestALCT, bestCLCT);
361  const int ok12 = doesALCTCrossCLCT(bestALCT, secondCLCT);
362  const int ok21 = doesALCTCrossCLCT(secondALCT, bestCLCT);
363  const int ok22 = doesALCTCrossCLCT(secondALCT, secondCLCT);
364  const int code = (ok11 << 3) | (ok12 << 2) | (ok21 << 1) | (ok22);
365 
366  int dbg = 0;
367  if (dbg)
368  LogTrace("CSCMotherboardME11") << "debug correlateLCTs in ME11 " << cscId_ << std::endl
369  << "ALCT1: " << bestALCT << std::endl
370  << "ALCT2: " << secondALCT << std::endl
371  << "CLCT1: " << bestCLCT << std::endl
372  << "CLCT2: " << secondCLCT << std::endl
373  << "ok 11 12 21 22 code = " << ok11 << " " << ok12 << " " << ok21 << " " << ok22
374  << " " << code << std::endl;
375 
376  if (code == 0)
377  return;
378 
379  // LUT defines correspondence between possible ok## combinations
380  // and resulting lct1 and lct2
381  int lut[16][2] = {
382  //ok: 11 12 21 22
383  {0, 0}, // 0 0 0 0
384  {22, 0}, // 0 0 0 1
385  {21, 0}, // 0 0 1 0
386  {21, 22}, // 0 0 1 1
387  {12, 0}, // 0 1 0 0
388  {12, 22}, // 0 1 0 1
389  {12, 21}, // 0 1 1 0
390  {12, 21}, // 0 1 1 1
391  {11, 0}, // 1 0 0 0
392  {11, 22}, // 1 0 0 1
393  {11, 21}, // 1 0 1 0
394  {11, 22}, // 1 0 1 1
395  {11, 12}, // 1 1 0 0
396  {11, 22}, // 1 1 0 1
397  {11, 12}, // 1 1 1 0
398  {11, 22}, // 1 1 1 1
399  };
400 
401  if (dbg)
402  LogTrace("CSCMotherboardME11") << "lut 0 1 = " << lut[code][0] << " " << lut[code][1] << std::endl;
403 
404  switch (lut[code][0]) {
405  case 11:
406  lct1 = constructLCTs(bestALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 1);
407  break;
408  case 12:
409  lct1 = constructLCTs(bestALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 1);
410  break;
411  case 21:
412  lct1 = constructLCTs(secondALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 1);
413  break;
414  case 22:
415  lct1 = constructLCTs(secondALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 1);
416  break;
417  default:
418  return;
419  }
420 
421  if (dbg)
422  LogTrace("CSCMotherboardME11") << "lct1: " << lct1 << std::endl;
423 
424  switch (lut[code][1]) {
425  case 12:
426  lct2 = constructLCTs(bestALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 2);
427  if (dbg)
428  LogTrace("CSCMotherboardME11") << "lct2: " << lct2 << std::endl;
429  return;
430  case 21:
431  lct2 = constructLCTs(secondALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 2);
432  if (dbg)
433  LogTrace("CSCMotherboardME11") << "lct2: " << lct2 << std::endl;
434  return;
435  case 22:
436  lct2 = constructLCTs(secondALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 2);
437  if (dbg)
438  LogTrace("CSCMotherboardME11") << "lct2: " << lct2 << std::endl;
439  return;
440  default:
441  return;
442  }
443  if (dbg)
444  LogTrace("CSCMotherboardME11") << "out of correlateLCTsME11" << std::endl;
445 
446  return;
447  }
448 }
#define LogDebug(id)
int getStrip() const
return the key halfstrip from 0,159
T getParameter(std::string const &) const
std::vector< CSCCLCTDigi > clctV
unsigned int clct_trig_enable
void setConfigParameters(const CSCDBL1TPParameters *conf)
const unsigned theEndcap
Definition: CSCBaseboard.h:37
unsigned int match_trig_window_size
std::vector< CSCCorrelatedLCTDigi > getLCTs1a() const
bool isValid() const
check ALCT validity (1 - valid ALCT)
Definition: CSCALCTDigi.h:32
void clear()
clear this ALCT
Definition: CSCALCTDigi.cc:39
std::unique_ptr< CSCCathodeLCTProcessor > clctProc
bool disableME1a_
Definition: CSCBaseboard.h:81
int pref[CSCConstants::MAX_LCT_TBINS]
CSCDetId cscId_
Definition: CSCBaseboard.h:50
bool gangedME1a_
Definition: CSCBaseboard.h:81
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc) override
unsigned int mpc_block_me1a
void correlateLCTsME11(const CSCALCTDigi &bestALCT, const CSCALCTDigi &secondALCT, const CSCCLCTDigi &bestCLCT, const CSCCLCTDigi &secondCLCT, CSCCorrelatedLCTDigi &lct1, CSCCorrelatedLCTDigi &lct2) const
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
std::vector< CSCALCTDigi > alctV
~CSCMotherboardME11() override
unsigned int tmb_l1a_window_size
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:35
std::unique_ptr< CSCMotherboardLUTME11 > cscTmbLUT_
unsigned int match_trig_enable
CSCCorrelatedLCTDigi constructLCTs(const CSCALCTDigi &aLCT, const CSCCLCTDigi &cLCT, int type, int trknmb) const
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1a() const
#define LogTrace(id)
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1b() const
bool doesALCTCrossCLCT(const CSCALCTDigi &a, const CSCCLCTDigi &c) const
const CSCGeometry * cscGeometry_
Definition: CSCBaseboard.h:58
edm::ParameterSet tmbParams_
Definition: CSCBaseboard.h:65
std::vector< CSCCorrelatedLCTDigi > getLCTs1b() const
double b
Definition: hdecay.h:118
unsigned int alct_trig_enable
bool isValid() const
return valid pattern bit
std::vector< CSCCorrelatedLCTDigi > readoutLCTs() const override
std::unique_ptr< CSCAnodeLCTProcessor > alctProc
double a
Definition: hdecay.h:119
CSCCorrelatedLCTDigi data[CSCConstants::MAX_LCT_TBINS][CSCConstants::MAX_MATCH_WINDOW_SIZE][CSCConstants::MAX_LCTS_PER_CSC]
Definition: LCTContainer.h:43
void clear()
clear this CLCT
Definition: CSCCLCTDigi.cc:54
unsigned int alctClctOffset_
Definition: CSCBaseboard.h:90