CMS 3D CMS Logo

CSCTriggerPrimitivesBuilder.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Class: CSCTriggerPrimitivesBuilder
4 //
5 // Description: Algorithm to build anode, cathode, and correlated LCTs
6 // in each endcap muon CSC chamber from wire and comparator
7 // digis.
8 //
9 // Author List: S. Valuev, UCLA.
10 //
11 //
12 // Modifications:
13 //
14 //-----------------------------------------------------------------------------
15 
21 
23 
28 
29 //------------------
30 // Static variables
31 //------------------
42 
43 //-------------
44 // Constructor
45 //-------------
47 {
48  // Receives ParameterSet percolated down from EDProducer.
49 
50  // special configuration parameters for ME11 treatment
51  edm::ParameterSet commonParams = conf.getParameter<edm::ParameterSet>("commonParam");
52  smartME1aME1b = commonParams.getParameter<bool>("smartME1aME1b");
53  disableME1a = commonParams.getParameter<bool>("disableME1a");
54  disableME42 = commonParams.getParameter<bool>("disableME42");
55 
56  checkBadChambers_ = conf.getParameter<bool>("checkBadChambers");
57 
58  runME11ILT_ = commonParams.existsAs<bool>("runME11ILT")?commonParams.getParameter<bool>("runME11ILT"):false;
59  runME21ILT_ = commonParams.existsAs<bool>("runME21ILT")?commonParams.getParameter<bool>("runME21ILT"):false;
60  runME3141ILT_ = commonParams.existsAs<bool>("runME3141ILT")?commonParams.getParameter<bool>("runME3141ILT"):false;
61  useClusters_ = commonParams.existsAs<bool>("useClusters")?commonParams.getParameter<bool>("useClusters"):false;
62 
63  // ORCA way of initializing boards.
64  for (int endc = min_endcap; endc <= max_endcap; endc++)
65  {
66  for (int stat = min_station; stat <= max_station; stat++)
67  {
68  int numsubs = ((stat == 1) ? max_subsector : 1);
69  for (int sect = min_sector; sect <= max_sector; sect++)
70  {
71  for (int subs = min_subsector; subs <= numsubs; subs++)
72  {
73  for (int cham = min_chamber; cham <= max_chamber; cham++)
74  {
75  if ((endc <= 0 || endc > MAX_ENDCAPS) ||
76  (stat <= 0 || stat > MAX_STATIONS) ||
77  (sect <= 0 || sect > MAX_SECTORS) ||
78  (subs <= 0 || subs > MAX_SUBSECTORS) ||
79  (cham <= 0 || cham > MAX_CHAMBERS))
80  {
81  edm::LogError("L1CSCTPEmulatorSetupError")
82  << "+++ trying to instantiate TMB of illegal CSC id ["
83  << " endcap = " << endc << " station = " << stat
84  << " sector = " << sect << " subsector = " << subs
85  << " chamber = " << cham << "]; skipping it... +++\n";
86  continue;
87  }
89  // When the motherboard is instantiated, it instantiates ALCT
90  // and CLCT processors.
91  if (stat==1 && ring==1 && smartME1aME1b && !runME11ILT_)
92  tmb_[endc-1][stat-1][sect-1][subs-1][cham-1].reset( new CSCMotherboardME11(endc, stat, sect, subs, cham, conf) );
93  else if (stat==1 && ring==1 && smartME1aME1b && runME11ILT_)
94  tmb_[endc-1][stat-1][sect-1][subs-1][cham-1].reset( new CSCGEMMotherboardME11(endc, stat, sect, subs, cham, conf) );
95  else if (stat==2 && ring==1 && runME21ILT_)
96  tmb_[endc-1][stat-1][sect-1][subs-1][cham-1].reset( new CSCGEMMotherboardME21(endc, stat, sect, subs, cham, conf) );
97  else
98  tmb_[endc-1][stat-1][sect-1][subs-1][cham-1].reset( new CSCMotherboard(endc, stat, sect, subs, cham, conf) );
99  }
100  }
101  }
102  }
103  }
104 
105  // Get min and max BX to sort LCTs in MPC.
106  m_minBX = conf.getParameter<int>("MinBX");
107  m_maxBX = conf.getParameter<int>("MaxBX");
108 
109  // Init MPC
110  m_muonportcard.reset( new CSCMuonPortCard(conf) );
111 }
112 
113 //------------
114 // Destructor
115 //------------
117 {
118 }
119 
120 //------------
121 // Operations
122 //------------
123 // Set configuration parameters obtained via EventSetup mechanism.
125 {
126  // Receives CSCDBL1TPParameters percolated down from ESProducer.
127 
128  for (int endc = min_endcap; endc <= max_endcap; endc++)
129  {
130  for (int stat = min_station; stat <= max_station; stat++)
131  {
132  int numsubs = ((stat == 1) ? max_subsector : 1);
133  for (int sect = min_sector; sect <= max_sector; sect++)
134  {
135  for (int subs = min_subsector; subs <= numsubs; subs++)
136  {
137  for (int cham = min_chamber; cham <= max_chamber; cham++)
138  {
139  tmb_[endc-1][stat-1][sect-1][subs-1][cham-1]->setConfigParameters(conf);
140  }
141  }
142  }
143  }
144  }
145 }
146 
147 // Build anode, cathode, and correlated LCTs in each chamber and fill them
148 // into output collections. Pass collections of wire and comparator digis
149 // to Trigger MotherBoard (TMB) processors, which, in turn, pass them to
150 // ALCT and CLCT processors. Up to 2 anode and 2 cathode LCTs can be found
151 // in each chamber during any bunch crossing. The 2 projections are then
152 // combined into three-dimensional "correlated" LCTs in the TMB. Finally,
153 // MPC processor sorts up to 18 LCTs from 9 TMBs and writes collections of
154 // up to 3 best LCTs per (sub)sector into Event (to be used by the Sector
155 // Receiver).
157  const CSCWireDigiCollection* wiredc,
158  const CSCComparatorDigiCollection* compdc,
159  const GEMPadDigiCollection* gemPads,
160  const GEMPadDigiClusterCollection* gemClusters,
161  CSCALCTDigiCollection& oc_alct,
162  CSCCLCTDigiCollection& oc_clct,
163  CSCCLCTPreTriggerCollection & oc_pretrig,
165  CSCCorrelatedLCTDigiCollection& oc_sorted_lct,
166  GEMCoPadDigiCollection& oc_gemcopad)
167 {
168  // CSC geometry.
169  for (int endc = min_endcap; endc <= max_endcap; endc++)
170  {
171  for (int stat = min_station; stat <= max_station; stat++)
172  {
173  int numsubs = ((stat == 1) ? max_subsector : 1);
174  for (int sect = min_sector; sect <= max_sector; sect++)
175  {
176  for (int subs = min_subsector; subs <= numsubs; subs++)
177  {
178  for (int cham = min_chamber; cham <= max_chamber; cham++)
179  {
180  // extract the ring number
182 
183  // case when you want to ignore ME42
184  if (disableME42 && stat==4 && ring==2) continue;
185 
186  CSCMotherboard* tmb = tmb_[endc-1][stat-1][sect-1][subs-1][cham-1].get();
187 
188  tmb->setCSCGeometry(csc_g);
189 
190  // actual chamber number =/= trigger chamber number
192 
193  // 0th layer means whole chamber.
194  CSCDetId detid(endc, stat, ring, chid, 0);
195 
196  // Run processors only if chamber exists in geometry.
197  if (tmb == nullptr || csc_g->chamber(detid) == nullptr) continue;
198 
199  // Skip chambers marked as bad (usually includes most of ME4/2 chambers;
200  // also, there's no ME1/a-1/b separation, it's whole ME1/1)
201  if (checkBadChambers_ && badChambers->isInBadChamber(detid)) continue;
202 
203 
204  // running upgraded ME1/1 TMBs
205  if (stat==1 && ring==1 && smartME1aME1b && !runME11ILT_)
206  {
207  CSCMotherboardME11* tmb11 = static_cast<CSCMotherboardME11*>(tmb);
208 
209  //LogTrace("CSCTriggerPrimitivesBuilder")<<"CSCTriggerPrimitivesBuilder::build in E:"<<endc<<" S:"<<stat<<" R:"<<ring;
210 
211  tmb11->run(wiredc,compdc);
212  std::vector<CSCCorrelatedLCTDigi> lctV = tmb11->readoutLCTs1b();
213  std::vector<CSCCorrelatedLCTDigi> lctV1a = tmb11->readoutLCTs1a();
214 
215  std::vector<CSCALCTDigi> alctV1a, alctV = tmb11->alct->readoutALCTs();
216 
217  std::vector<CSCCLCTDigi> clctV = tmb11->clct->readoutCLCTs();
218  std::vector<int> preTriggerBXs = tmb11->clct->preTriggerBXs();
219  std::vector<CSCCLCTDigi> clctV1a = tmb11->clct1a->readoutCLCTs();
220  std::vector<int> preTriggerBXs1a = tmb11->clct1a->preTriggerBXs();
221 
222  // perform simple separation of ALCTs into 1/a and 1/b
223  // for 'smart' case. Some duplication occurs for WG [10,15]
224  std::vector<CSCALCTDigi> tmpV(alctV);
225  alctV.clear();
226  for (unsigned int al=0; al < tmpV.size(); al++)
227  {
228  if (tmpV[al].getKeyWG()<=15) alctV1a.push_back(tmpV[al]);
229  if (tmpV[al].getKeyWG()>=10) alctV.push_back(tmpV[al]);
230  }
231  //LogTrace("CSCTriggerPrimitivesBuilder")<<"CSCTriggerPrimitivesBuilder:: a="<<alctV.size()<<" c="<<clctV.size()<<" l="<<lctV.size()
232  // <<" 1a: a="<<alctV1a.size()<<" c="<<clctV1a.size()<<" l="<<lctV1a.size();
233 
234  // ME1/b
235 
236  if (!(lctV.empty()&&alctV.empty()&&clctV.empty())) {
237  LogTrace("L1CSCTrigger")
238  << "CSCTriggerPrimitivesBuilder results in " <<detid;
239  }
240 
241  // Correlated LCTs.
242  if (!lctV.empty()) {
243  LogTrace("L1CSCTrigger")
244  << "Put " << lctV.size() << " ME1b LCT digi"
245  << ((lctV.size() > 1) ? "s " : " ") << "in collection\n";
246  oc_lct.put(std::make_pair(lctV.begin(),lctV.end()), detid);
247  }
248 
249  // Anode LCTs.
250  if (!alctV.empty()) {
251  LogTrace("L1CSCTrigger")
252  << "Put " << alctV.size() << " ME1b ALCT digi"
253  << ((alctV.size() > 1) ? "s " : " ") << "in collection\n";
254  oc_alct.put(std::make_pair(alctV.begin(),alctV.end()), detid);
255  }
256 
257  // Cathode LCTs.
258  if (!clctV.empty()) {
259  LogTrace("L1CSCTrigger")
260  << "Put " << clctV.size() << " ME1b CLCT digi"
261  << ((clctV.size() > 1) ? "s " : " ") << "in collection\n";
262  oc_clct.put(std::make_pair(clctV.begin(),clctV.end()), detid);
263  }
264 
265  // Cathode LCTs pretriggers
266  if (!preTriggerBXs.empty()) {
267  LogTrace("L1CSCTrigger")
268  << "Put " << preTriggerBXs.size() << " CLCT pretrigger"
269  << ((preTriggerBXs.size() > 1) ? "s " : " ") << "in collection\n";
270  oc_pretrig.put(std::make_pair(preTriggerBXs.begin(),preTriggerBXs.end()), detid);
271  }
272 
273  // ME1/a
274 
275  if (disableME1a) continue;
276 
277  CSCDetId detid1a(endc, stat, 4, chid, 0);
278 
279  if (!(lctV1a.empty()&&alctV1a.empty()&&clctV1a.empty())){
280  LogTrace("L1CSCTrigger") << "CSCTriggerPrimitivesBuilder results in " <<detid1a;
281  }
282 
283  // Correlated LCTs.
284  if (!lctV1a.empty()) {
285  LogTrace("L1CSCTrigger")
286  << "Put " << lctV1a.size() << " ME1a LCT digi"
287  << ((lctV1a.size() > 1) ? "s " : " ") << "in collection\n";
288  oc_lct.put(std::make_pair(lctV1a.begin(),lctV1a.end()), detid1a);
289  }
290 
291  // Anode LCTs.
292  if (!alctV1a.empty()) {
293  LogTrace("L1CSCTrigger")
294  << "Put " << alctV1a.size() << " ME1a ALCT digi"
295  << ((alctV1a.size() > 1) ? "s " : " ") << "in collection\n";
296  oc_alct.put(std::make_pair(alctV1a.begin(),alctV1a.end()), detid1a);
297  }
298 
299  // Cathode LCTs.
300  if (!clctV1a.empty()) {
301  LogTrace("L1CSCTrigger")
302  << "Put " << clctV1a.size() << " ME1a CLCT digi"
303  << ((clctV1a.size() > 1) ? "s " : " ") << "in collection\n";
304  oc_clct.put(std::make_pair(clctV1a.begin(),clctV1a.end()), detid1a);
305  }
306 
307  // Cathode LCTs pretriggers
308  if (!preTriggerBXs1a.empty()) {
309  LogTrace("L1CSCTrigger")
310  << "Put " << preTriggerBXs1a.size() << " CLCT pretrigger"
311  << ((preTriggerBXs1a.size() > 1) ? "s " : " ") << "in collection\n";
312  oc_pretrig.put(std::make_pair(preTriggerBXs1a.begin(),preTriggerBXs1a.end()), detid1a);
313  }
314  } // upgraded TMB
315 
316  // running upgraded ME1/1 TMBs with GEMs
317  else if (stat==1 && ring==1 && smartME1aME1b && runME11ILT_)
318  {
319  CSCGEMMotherboardME11* tmb11GEM = static_cast<CSCGEMMotherboardME11*>(tmb);
320 
321  tmb11GEM->setCSCGeometry(csc_g);
322  tmb11GEM->setGEMGeometry(gem_g);
323  //LogTrace("CSCTriggerPrimitivesBuilder")<<"CSCTriggerPrimitivesBuilder::build in E:"<<endc<<" S:"<<stat<<" R:"<<ring;
324  tmb11GEM->run(wiredc, compdc, gemPads);
325 
326  std::vector<CSCCorrelatedLCTDigi> lctV = tmb11GEM->readoutLCTs1b();
327  std::vector<CSCCorrelatedLCTDigi> lctV1a = tmb11GEM->readoutLCTs1a();
328 
329  std::vector<CSCALCTDigi> alctV1a, alctV = tmb11GEM->alct->readoutALCTs();
330 
331  std::vector<CSCCLCTDigi> clctV = tmb11GEM->clct->readoutCLCTs();
332  std::vector<int> preTriggerBXs = tmb11GEM->clct->preTriggerBXs();
333  std::vector<CSCCLCTDigi> clctV1a = tmb11GEM->clct1a->readoutCLCTs();
334  std::vector<int> preTriggerBXs1a = tmb11GEM->clct1a->preTriggerBXs();
335 
336  std::vector<GEMCoPadDigi> copads = tmb11GEM->coPadProcessor->readoutCoPads();
337  // perform simple separation of ALCTs into 1/a and 1/b
338  // for 'smart' case. Some duplication occurs for WG [10,15]
339  std::vector<CSCALCTDigi> tmpV(alctV);
340  alctV.clear();
341  for (unsigned int al=0; al < tmpV.size(); al++)
342  {
343  if (tmpV[al].getKeyWG()<=15) alctV1a.push_back(tmpV[al]);
344  if (tmpV[al].getKeyWG()>=10) alctV.push_back(tmpV[al]);
345  }
346  //LogTrace("CSCTriggerPrimitivesBuilder")<<"CSCTriggerPrimitivesBuilder:: a="<<alctV.size()<<" c="<<clctV.size()<<" l="<<lctV.size()
347  // <<" 1a: a="<<alctV1a.size()<<" c="<<clctV1a.size()<<" l="<<lctV1a.size();
348 
349  // ME1/b
350 
351  if (!(lctV.empty()&&alctV.empty()&&clctV.empty())) {
352  LogTrace("L1CSCTrigger")
353  << "CSCTriggerPrimitivesBuilder results in " <<detid;
354  }
355 
356  // Correlated LCTs.
357  if (!lctV.empty()) {
358  LogTrace("L1CSCTrigger")
359  << "Put " << lctV.size() << " ME1b LCT digi"
360  << ((lctV.size() > 1) ? "s " : " ") << "in collection\n";
361  oc_lct.put(std::make_pair(lctV.begin(),lctV.end()), detid);
362  }
363 
364  // Anode LCTs.
365  if (!alctV.empty()) {
366  LogTrace("L1CSCTrigger")
367  << "Put " << alctV.size() << " ME1b ALCT digi"
368  << ((alctV.size() > 1) ? "s " : " ") << "in collection\n";
369  oc_alct.put(std::make_pair(alctV.begin(),alctV.end()), detid);
370  }
371 
372  // Cathode LCTs.
373  if (!clctV.empty()) {
374  LogTrace("L1CSCTrigger")
375  << "Put " << clctV.size() << " ME1b CLCT digi"
376  << ((clctV.size() > 1) ? "s " : " ") << "in collection\n";
377  oc_clct.put(std::make_pair(clctV.begin(),clctV.end()), detid);
378  }
379 
380  // Cathode LCTs pretriggers
381  if (!preTriggerBXs.empty()) {
382  LogTrace("L1CSCTrigger")
383  << "Put " << preTriggerBXs.size() << " CLCT pretrigger"
384  << ((preTriggerBXs.size() > 1) ? "s " : " ") << "in collection\n";
385  oc_pretrig.put(std::make_pair(preTriggerBXs.begin(),preTriggerBXs.end()), detid);
386  }
387  // 0th layer means whole chamber.
388  GEMDetId gemId(detid.zendcap(), 1, 1, 0, chid, 0);
389 
390  // GEM coincidence pads
391  if (!copads.empty()) {
392  LogTrace("L1CSCTrigger")
393  << "Put " << copads.size() << " GEM coincidence pad"
394  << ((copads.size() > 1) ? "s " : " ") << "in collection\n";
395  oc_gemcopad.put(std::make_pair(copads.begin(),copads.end()), gemId);
396  }
397 
398  // ME1/a
399 
400  if (disableME1a) continue;
401 
402  CSCDetId detid1a(endc, stat, 4, chid, 0);
403 
404  if (!(lctV1a.empty()&&alctV1a.empty()&&clctV1a.empty())){
405  LogTrace("L1CSCTrigger") << "CSCTriggerPrimitivesBuilder results in " <<detid1a;
406  }
407 
408  // Correlated LCTs.
409  if (!lctV1a.empty()) {
410  LogTrace("L1CSCTrigger")
411  << "Put " << lctV1a.size() << " ME1a LCT digi"
412  << ((lctV1a.size() > 1) ? "s " : " ") << "in collection\n";
413  oc_lct.put(std::make_pair(lctV1a.begin(),lctV1a.end()), detid1a);
414  }
415 
416  // Anode LCTs.
417  if (!alctV1a.empty()) {
418  LogTrace("L1CSCTrigger")
419  << "Put " << alctV1a.size() << " ME1a ALCT digi"
420  << ((alctV1a.size() > 1) ? "s " : " ") << "in collection\n";
421  oc_alct.put(std::make_pair(alctV1a.begin(),alctV1a.end()), detid1a);
422  }
423 
424  // Cathode LCTs.
425  if (!clctV1a.empty()) {
426  LogTrace("L1CSCTrigger")
427  << "Put " << clctV1a.size() << " ME1a CLCT digi"
428  << ((clctV1a.size() > 1) ? "s " : " ") << "in collection\n";
429  oc_clct.put(std::make_pair(clctV1a.begin(),clctV1a.end()), detid1a);
430  }
431 
432  // Cathode LCTs pretriggers
433  if (!preTriggerBXs1a.empty()) {
434  LogTrace("L1CSCTrigger")
435  << "Put " << preTriggerBXs.size() << " CLCT pretrigger"
436  << ((preTriggerBXs.size() > 1) ? "s " : " ") << "in collection\n";
437  oc_pretrig.put(std::make_pair(preTriggerBXs.begin(),preTriggerBXs.end()), detid);
438  }
439  }
440 
441  // running upgraded ME2/1 TMBs
442  else if (stat==2 && ring==1 && runME21ILT_)
443  {
444  CSCGEMMotherboardME21* tmb21GEM = static_cast<CSCGEMMotherboardME21*>(tmb);
445  tmb21GEM->setCSCGeometry(csc_g);
446  tmb21GEM->setGEMGeometry(gem_g);
447  tmb21GEM->run(wiredc, compdc, gemPads);
448  std::vector<CSCCorrelatedLCTDigi> lctV = tmb21GEM->readoutLCTs();
449  std::vector<CSCALCTDigi> alctV = tmb21GEM->alct->readoutALCTs();
450  std::vector<CSCCLCTDigi> clctV = tmb21GEM->clct->readoutCLCTs();
451  std::vector<int> preTriggerBXs = tmb21GEM->clct->preTriggerBXs();
452 
453  std::vector<GEMCoPadDigi> copads = tmb21GEM->coPadProcessor->readoutCoPads();
454 
455  if (!(alctV.empty() && clctV.empty() && lctV.empty())) {
456  LogTrace("L1CSCTrigger")
457  << "CSCTriggerPrimitivesBuilder got results in " <<detid;
458  }
459 
460  // Correlated LCTs.
461  if (!lctV.empty()) {
462  LogTrace("L1CSCTrigger")
463  << "Put " << lctV.size() << " LCT digi"
464  << ((lctV.size() > 1) ? "s " : " ") << "in collection\n";
465  oc_lct.put(std::make_pair(lctV.begin(),lctV.end()), detid);
466  }
467 
468  // Anode LCTs.
469  if (!alctV.empty()) {
470  LogTrace("L1CSCTrigger")
471  << "Put " << alctV.size() << " ALCT digi"
472  << ((alctV.size() > 1) ? "s " : " ") << "in collection\n";
473  oc_alct.put(std::make_pair(alctV.begin(),alctV.end()), detid);
474  }
475 
476  // Cathode LCTs.
477  if (!clctV.empty()) {
478  LogTrace("L1CSCTrigger")
479  << "Put " << clctV.size() << " CLCT digi"
480  << ((clctV.size() > 1) ? "s " : " ") << "in collection\n";
481  oc_clct.put(std::make_pair(clctV.begin(),clctV.end()), detid);
482  }
483 
484  // Cathode LCTs pretriggers
485  if (!preTriggerBXs.empty()) {
486  LogTrace("L1CSCTrigger")
487  << "Put " << preTriggerBXs.size() << " CLCT pretrigger"
488  << ((preTriggerBXs.size() > 1) ? "s " : " ") << "in collection\n";
489  oc_pretrig.put(std::make_pair(preTriggerBXs.begin(),preTriggerBXs.end()), detid);
490  }
491 
492  // 0th layer means whole chamber.
493  GEMDetId gemId(detid.zendcap(), 1, 2, 0, chid, 0);
494 
495  // GEM coincidence pads
496  if (!copads.empty()) {
497  LogTrace("L1CSCTrigger")
498  << "Put " << copads.size() << " GEM coincidence pad"
499  << ((copads.size() > 1) ? "s " : " ") << "in collection\n";
500  oc_gemcopad.put(std::make_pair(copads.begin(),copads.end()), gemId);
501  }
502  }
503  // running non-upgraded TMB
504  else
505  {
506  tmb->run(wiredc,compdc);
507 
508  std::vector<CSCCorrelatedLCTDigi> lctV = tmb->readoutLCTs();
509  std::vector<CSCALCTDigi> alctV = tmb->alct->readoutALCTs();
510  std::vector<CSCCLCTDigi> clctV = tmb->clct->readoutCLCTs();
511  std::vector<int> preTriggerBXs = tmb->clct->preTriggerBXs();
512 
513  if (!(alctV.empty() && clctV.empty() && lctV.empty())) {
514  LogTrace("L1CSCTrigger")
515  << "CSCTriggerPrimitivesBuilder got results in " <<detid;
516  }
517 
518  // Correlated LCTs.
519  if (!lctV.empty()) {
520  LogTrace("L1CSCTrigger")
521  << "Put " << lctV.size() << " LCT digi"
522  << ((lctV.size() > 1) ? "s " : " ") << "in collection\n";
523  oc_lct.put(std::make_pair(lctV.begin(),lctV.end()), detid);
524  }
525 
526  // Anode LCTs.
527  if (!alctV.empty()) {
528  LogTrace("L1CSCTrigger")
529  << "Put " << alctV.size() << " ALCT digi"
530  << ((alctV.size() > 1) ? "s " : " ") << "in collection\n";
531  oc_alct.put(std::make_pair(alctV.begin(),alctV.end()), detid);
532  }
533 
534  // Cathode LCTs.
535  if (!clctV.empty()) {
536  LogTrace("L1CSCTrigger")
537  << "Put " << clctV.size() << " CLCT digi"
538  << ((clctV.size() > 1) ? "s " : " ") << "in collection\n";
539  oc_clct.put(std::make_pair(clctV.begin(),clctV.end()), detid);
540  }
541 
542  // Cathode LCTs pretriggers
543  if (!preTriggerBXs.empty()) {
544  LogTrace("L1CSCTrigger")
545  << "Put " << preTriggerBXs.size() << " CLCT pretrigger"
546  << ((preTriggerBXs.size() > 1) ? "s " : " ") << "in collection\n";
547  oc_pretrig.put(std::make_pair(preTriggerBXs.begin(),preTriggerBXs.end()), detid);
548  }
549  } // non-upgraded TMB
550  }
551  }
552  }
553  }
554  }
555 
556  // run MPC simulation
557  m_muonportcard->loadDigis(oc_lct);
558 
559  // temporary hack to ensure that all MPC LCTs are read out
560  // in the correct readout window
561  if (runOnData_) {
562  m_minBX = 5;
563  m_maxBX = 11;
564  }
565 
566  // sort the LCTs per sector
567  // insert them into the result vector
568  std::vector<csctf::TrackStub> result;
569  for(int bx = m_minBX; bx <= m_maxBX; ++bx)
570  for(int e = min_endcap; e <= max_endcap; ++e)
571  for(int st = min_station; st <= max_station; ++st)
572  for(int se = min_sector; se <= max_sector; ++se)
573  {
574  if(st == 1)
575  {
576  std::vector<csctf::TrackStub> subs1, subs2;
577  subs1 = m_muonportcard->sort(e, st, se, 1, bx);
578  subs2 = m_muonportcard->sort(e, st, se, 2, bx);
579  result.insert(result.end(), subs1.begin(), subs1.end());
580  result.insert(result.end(), subs2.begin(), subs2.end());
581  }
582  else
583  {
584  std::vector<csctf::TrackStub> sector;
585  sector = m_muonportcard->sort(e, st, se, 0, bx);
586  result.insert(result.end(), sector.begin(), sector.end());
587  }
588  }
589 
590  // now convert csctf::TrackStub back into CSCCorrelatedLCTDigi
591  // put MPC stubs into the event
592  std::vector<csctf::TrackStub>::const_iterator itr = result.begin();
593  for (; itr != result.end(); itr++)
594  {
595  oc_sorted_lct.insertDigi(CSCDetId(itr->getDetId().rawId()), *(itr->getDigi()));
596  LogDebug("L1CSCTrigger")
597  << "MPC " << *(itr->getDigi()) << " found in ME"
598  << ((itr->endcap() == 1) ? "+" : "-") << itr->station() << "/"
599  << CSCDetId(itr->getDetId().rawId()).ring() << "/"
600  << CSCDetId(itr->getDetId().rawId()).chamber()
601  << " (sector " << itr->sector()
602  << " trig id. " << itr->cscid() << ")" << "\n";
603  }
604 }
#define LogDebug(id)
T getParameter(std::string const &) const
void setCSCGeometry(const CSCGeometry *g)
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc)
std::unique_ptr< CSCMotherboard > tmb_[MAX_ENDCAPS][MAX_STATIONS][MAX_SECTORS][MAX_SUBSECTORS][MAX_CHAMBERS]
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiCollection *gemPads) override
std::vector< CSCCorrelatedLCTDigi > readoutLCTs()
static int minEndcapId()
Definition: CSCDetId.h:236
void setGEMGeometry(const GEMGeometry *g)
set CSC and GEM geometries for the matching needs
static int maxTriggerSectorId()
static int maxStationId()
Definition: CSCDetId.h:239
void setCSCGeometry(const CSCGeometry *g)
static int minTriggerSectorId()
static int ringFromTriggerLabels(int station, int triggerCSCID)
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1b() const
std::unique_ptr< CSCCathodeLCTProcessor > clct1a
void setConfigParameters(const CSCDBL1TPParameters *conf)
bool isInBadChamber(IndexType ichamber) const
Is the chamber with index &#39;ichamber&#39; flagged as bad?
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1a() const
bool runOnData_
temporary flag to run on data
CSCTriggerPrimitivesBuilder(const edm::ParameterSet &)
std::unique_ptr< GEMCoPadProcessor > coPadProcessor
static int minStationId()
Definition: CSCDetId.h:238
void run(const std::vector< int > w_time[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_WIRES], const std::vector< int > hs_times[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const std::vector< int > ds_times[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
static int maxEndcapId()
Definition: CSCDetId.h:237
std::unique_ptr< CSCCathodeLCTProcessor > clct1a
#define LogTrace(id)
short int zendcap() const
Definition: CSCDetId.h:100
static int minTriggerSubSectorId()
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:118
bool checkBadChambers_
a flag whether to skip chambers from the bad chambers map
std::vector< CSCCorrelatedLCTDigi > readoutLCTs() const
std::unique_ptr< CSCAnodeLCTProcessor > alct
std::unique_ptr< CSCCathodeLCTProcessor > clct
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1b()
std::unique_ptr< CSCMuonPortCard > m_muonportcard
void build(const CSCBadChambers *badChambers, const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiCollection *gemPads, const GEMPadDigiClusterCollection *gemPadClusters, CSCALCTDigiCollection &oc_alct, CSCCLCTDigiCollection &oc_clct, CSCCLCTPreTriggerCollection &oc_pretrig, CSCCorrelatedLCTDigiCollection &oc_lct, CSCCorrelatedLCTDigiCollection &oc_sorted_lct, GEMCoPadDigiCollection &oc_gemcopad)
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
static int maxTriggerSubSectorId()
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1a()
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiCollection *gemPads) override