CMS 3D CMS Logo

DTTrigPhase2Prod.cc
Go to the documentation of this file.
10 
17 
21 
24 
36 
44 
45 // DT trigger GeomUtils
47 
48 //RPC TP
53 
54 #include <fstream>
55 #include <iostream>
56 #include <queue>
57 #include <cmath>
58 
59 using namespace edm;
60 using namespace std;
61 using namespace cmsdt;
62 
64  typedef std::map<DTChamberId, DTDigiCollection, std::less<DTChamberId>> DTDigiMap;
65  typedef DTDigiMap::iterator DTDigiMap_iterator;
66  typedef DTDigiMap::const_iterator DTDigiMap_const_iterator;
67 
68 public:
71 
73  ~DTTrigPhase2Prod() override;
74 
76  void beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) override;
77 
79  void produce(edm::Event& iEvent, const edm::EventSetup& iEventSetup) override;
80 
82  void endRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) override;
83 
84  // Methods
85  int rango(const metaPrimitive& mp) const;
86  bool outer(const metaPrimitive& mp) const;
87  bool inner(const metaPrimitive& mp) const;
88  void printmP(const std::string& ss, const metaPrimitive& mP) const;
89  void printmPC(const std::string& ss, const metaPrimitive& mP) const;
90  bool hasPosRF(int wh, int sec) const;
91 
92  // Getter-methods
93  MP_QUALITY getMinimumQuality(void);
94 
95  // Setter-methods
96  void setChiSquareThreshold(float ch2Thr);
97  void setMinimumQuality(MP_QUALITY q);
98 
99  // data-members
102  std::vector<std::pair<int, MuonPath>> primitives_;
103 
104 private:
105  // Trigger Configuration Manager CCB validity flag
107 
108  // BX offset used to correct DTTPG output
110 
111  // Debug Flag
112  bool debug_;
113  bool dump_;
117 
118  // shift
120  std::map<int, float> shiftinfo_;
121 
122  // ParameterSet
125 
126  // Grouping attributes and methods
127  int algo_; // Grouping code
128  std::unique_ptr<MotherGrouping> grouping_obj_;
129  std::unique_ptr<MuonPathAnalyzer> mpathanalyzer_;
130  std::unique_ptr<MPFilter> mpathqualityenhancer_;
131  std::unique_ptr<MPFilter> mpathredundantfilter_;
132  std::unique_ptr<MuonPathAssociator> mpathassociator_;
133 
134  // Buffering
138  std::vector<DTDigiCollection*> distribDigis(std::queue<std::pair<DTLayerId, DTDigi>>& inQ);
139  void processDigi(std::queue<std::pair<DTLayerId, DTDigi>>& inQ,
140  std::vector<std::queue<std::pair<DTLayerId, DTDigi>>*>& vec);
141 
142  // RPC
143  std::unique_ptr<RPCIntegrator> rpc_integrator_;
144  bool useRPC_;
145 
146  void assignIndex(std::vector<metaPrimitive>& inMPaths);
147  void assignIndexPerBX(std::vector<metaPrimitive>& inMPaths);
148  int assignQualityOrder(const metaPrimitive& mP) const;
149 
150  const std::unordered_map<int, int> qmap_;
151 };
152 
153 namespace {
154  struct {
155  bool operator()(std::pair<DTLayerId, DTDigi> a, std::pair<DTLayerId, DTDigi> b) const {
156  return (a.second.time() < b.second.time());
157  }
158  } DigiTimeOrdering;
159 } // namespace
160 
162  : qmap_({{9, 9}, {8, 8}, {7, 6}, {6, 7}, {5, 3}, {4, 5}, {3, 4}, {2, 2}, {1, 1}}) {
163  produces<L1Phase2MuDTPhContainer>();
164 
165  debug_ = pset.getUntrackedParameter<bool>("debug");
166  dump_ = pset.getUntrackedParameter<bool>("dump");
167 
168  do_correlation_ = pset.getParameter<bool>("do_correlation");
169  scenario_ = pset.getParameter<int>("scenario");
170 
171  dtDigisToken_ = consumes<DTDigiCollection>(pset.getParameter<edm::InputTag>("digiTag"));
172 
173  rpcRecHitsLabel_ = consumes<RPCRecHitCollection>(pset.getParameter<edm::InputTag>("rpcRecHits"));
174  useRPC_ = pset.getParameter<bool>("useRPC");
175 
176  // Choosing grouping scheme:
177  algo_ = pset.getParameter<int>("algo");
178 
179  edm::ConsumesCollector consumesColl(consumesCollector());
180 
181  if (algo_ == PseudoBayes) {
182  grouping_obj_ =
183  std::make_unique<PseudoBayesGrouping>(pset.getParameter<edm::ParameterSet>("PseudoBayesPattern"), consumesColl);
184  } else if (algo_ == HoughTrans) {
185  grouping_obj_ =
186  std::make_unique<HoughGrouping>(pset.getParameter<edm::ParameterSet>("HoughGrouping"), consumesColl);
187  } else {
188  grouping_obj_ = std::make_unique<InitialGrouping>(pset, consumesColl);
189  }
190 
191  if (algo_ == Standard) {
192  if (debug_)
193  LogDebug("DTTrigPhase2Prod") << "DTp2:constructor: JM analyzer";
194  mpathanalyzer_ = std::make_unique<MuonPathAnalyzerPerSL>(pset, consumesColl);
195  } else {
196  if (debug_)
197  LogDebug("DTTrigPhase2Prod") << "DTp2:constructor: Full chamber analyzer";
198  mpathanalyzer_ = std::make_unique<MuonPathAnalyzerInChamber>(pset, consumesColl);
199  }
200 
201  // Getting buffer option
202  activateBuffer_ = pset.getParameter<bool>("activateBuffer");
203  superCellhalfspacewidth_ = pset.getParameter<int>("superCellspacewidth") / 2;
204  superCelltimewidth_ = pset.getParameter<double>("superCelltimewidth");
205 
206  mpathqualityenhancer_ = std::make_unique<MPQualityEnhancerFilter>(pset);
207  mpathredundantfilter_ = std::make_unique<MPRedundantFilter>(pset);
208  mpathassociator_ = std::make_unique<MuonPathAssociator>(pset, consumesColl);
209  rpc_integrator_ = std::make_unique<RPCIntegrator>(pset, consumesColl);
210 
211  dtGeomH = esConsumes<DTGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
212 }
213 
215  if (debug_)
216  LogDebug("DTTrigPhase2Prod") << "DTp2: calling destructor" << std::endl;
217 }
218 
219 void DTTrigPhase2Prod::beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) {
220  if (debug_)
221  LogDebug("DTTrigPhase2Prod") << "beginRun " << iRun.id().run();
222  if (debug_)
223  LogDebug("DTTrigPhase2Prod") << "beginRun: getting DT geometry";
224 
225  grouping_obj_->initialise(iEventSetup); // Grouping object initialisation
226  mpathanalyzer_->initialise(iEventSetup); // Analyzer object initialisation
227  mpathqualityenhancer_->initialise(iEventSetup); // Filter object initialisation
228  mpathredundantfilter_->initialise(iEventSetup); // Filter object initialisation
229  mpathassociator_->initialise(iEventSetup); // Associator object initialisation
230 
231  const MuonGeometryRecord& geom = iEventSetup.get<MuonGeometryRecord>();
232  dtGeo_ = &geom.get(dtGeomH);
233 }
234 
235 void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) {
236  if (debug_)
237  LogDebug("DTTrigPhase2Prod") << "produce";
239  iEvent.getByToken(dtDigisToken_, dtdigis);
240 
241  if (debug_)
242  LogDebug("DTTrigPhase2Prod") << "\t Getting the RPC RecHits" << std::endl;
244  iEvent.getByToken(rpcRecHitsLabel_, rpcRecHits);
245 
247  // GROUPING CODE:
249  DTDigiMap digiMap;
251  for (const auto& detUnitIt : *dtdigis) {
252  const DTLayerId& layId = detUnitIt.first;
253  const DTChamberId chambId = layId.superlayerId().chamberId();
254  const DTDigiCollection::Range& range = detUnitIt.second;
255  digiMap[chambId].put(range, layId);
256  }
257 
258  // generate a list muon paths for each event!!!
259  if (debug_ && activateBuffer_)
260  LogDebug("DTTrigPhase2Prod") << "produce - Getting and grouping digis per chamber using a buffer and super cells.";
261  else if (debug_)
262  LogDebug("DTTrigPhase2Prod") << "produce - Getting and grouping digis per chamber.";
263 
264  MuonPathPtrs muonpaths;
265  for (const auto& ich : dtGeo_->chambers()) {
266  // The code inside this for loop would ideally later fit inside a trigger unit (in principle, a DT station) of the future Phase 2 DT Trigger.
267  const DTChamber* chamb = ich;
268  DTChamberId chid = chamb->id();
269  DTDigiMap_iterator dmit = digiMap.find(chid);
270 
271  if (dmit == digiMap.end())
272  continue;
273 
274  if (activateBuffer_) { // Use buffering (per chamber) or not
275  // Import digis from the station
276  std::vector<std::pair<DTLayerId, DTDigi>> tmpvec;
277  tmpvec.clear();
278 
279  for (const auto& dtLayerIdIt : (*dmit).second) {
280  for (DTDigiCollection::const_iterator digiIt = (dtLayerIdIt.second).first;
281  digiIt != (dtLayerIdIt.second).second;
282  digiIt++) {
283  tmpvec.emplace_back(dtLayerIdIt.first, *digiIt);
284  }
285  }
286 
287  // Check to enhance CPU time usage
288  if (tmpvec.empty())
289  continue;
290 
291  // Order digis depending on TDC time and insert them into a queue (FIFO buffer). TODO: adapt for MC simulations.
292  std::sort(tmpvec.begin(), tmpvec.end(), DigiTimeOrdering);
293  std::queue<std::pair<DTLayerId, DTDigi>> timequeue;
294 
295  for (const auto& elem : tmpvec)
296  timequeue.emplace(elem);
297  tmpvec.clear();
298 
299  // Distribute the digis from the queue into supercells
300  std::vector<DTDigiCollection*> superCells;
301  superCells = distribDigis(timequeue);
302 
303  // Process each supercell & collect the resulting muonpaths (as the muonpaths std::vector is only enlarged each time
304  // the groupings access it, it's not needed to "collect" the final products).
305  while (!superCells.empty()) {
306  grouping_obj_->run(iEvent, iEventSetup, *(superCells.back()), muonpaths);
307  superCells.pop_back();
308  }
309  } else {
310  grouping_obj_->run(iEvent, iEventSetup, (*dmit).second, muonpaths);
311  }
312  }
313  digiMap.clear();
314 
315  if (dump_) {
316  for (unsigned int i = 0; i < muonpaths.size(); i++) {
317  stringstream ss;
318  ss << iEvent.id().event() << " mpath " << i << ": ";
319  for (int lay = 0; lay < muonpaths.at(i)->nprimitives(); lay++)
320  ss << muonpaths.at(i)->primitive(lay)->channelId() << " ";
321  for (int lay = 0; lay < muonpaths.at(i)->nprimitives(); lay++)
322  ss << muonpaths.at(i)->primitive(lay)->tdcTimeStamp() << " ";
323  for (int lay = 0; lay < muonpaths.at(i)->nprimitives(); lay++)
324  ss << muonpaths.at(i)->primitive(lay)->laterality() << " ";
325  LogInfo("DTTrigPhase2Prod") << ss.str();
326  }
327  }
328 
329  // FILTER GROUPING
330  MuonPathPtrs filteredmuonpaths;
331  if (algo_ == Standard) {
332  mpathredundantfilter_->run(iEvent, iEventSetup, muonpaths, filteredmuonpaths);
333  }
334 
335  if (dump_) {
336  for (unsigned int i = 0; i < filteredmuonpaths.size(); i++) {
337  stringstream ss;
338  ss << iEvent.id().event() << " filt. mpath " << i << ": ";
339  for (int lay = 0; lay < filteredmuonpaths.at(i)->nprimitives(); lay++)
340  ss << filteredmuonpaths.at(i)->primitive(lay)->channelId() << " ";
341  for (int lay = 0; lay < filteredmuonpaths.at(i)->nprimitives(); lay++)
342  ss << filteredmuonpaths.at(i)->primitive(lay)->tdcTimeStamp() << " ";
343  LogInfo("DTTrigPhase2Prod") << ss.str();
344  }
345  }
346 
350  if (debug_)
351  LogDebug("DTTrigPhase2Prod") << "MUON PATHS found: " << muonpaths.size() << " (" << filteredmuonpaths.size()
352  << ") in event " << iEvent.id().event();
353  if (debug_)
354  LogDebug("DTTrigPhase2Prod") << "filling NmetaPrimtives" << std::endl;
355  std::vector<metaPrimitive> metaPrimitives;
356  MuonPathPtrs outmpaths;
357  if (algo_ == Standard) {
358  if (debug_)
359  LogDebug("DTTrigPhase2Prod") << "Fitting 1SL ";
360  mpathanalyzer_->run(iEvent, iEventSetup, filteredmuonpaths, metaPrimitives);
361  } else {
362  // implementation for advanced (2SL) grouping, no filter required..
363  if (debug_)
364  LogDebug("DTTrigPhase2Prod") << "Fitting 2SL at once ";
365  mpathanalyzer_->run(iEvent, iEventSetup, muonpaths, outmpaths);
366  }
367 
368  if (dump_) {
369  for (unsigned int i = 0; i < outmpaths.size(); i++) {
370  LogInfo("DTTrigPhase2Prod") << iEvent.id().event() << " mp " << i << ": " << outmpaths.at(i)->bxTimeValue() << " "
371  << outmpaths.at(i)->horizPos() << " " << outmpaths.at(i)->tanPhi() << " "
372  << outmpaths.at(i)->phi() << " " << outmpaths.at(i)->phiB() << " "
373  << outmpaths.at(i)->quality() << " " << outmpaths.at(i)->chiSquare();
374  }
375  for (unsigned int i = 0; i < metaPrimitives.size(); i++) {
376  stringstream ss;
377  ss << iEvent.id().event() << " mp " << i << ": ";
378  printmP(ss.str(), metaPrimitives.at(i));
379  }
380  }
381 
382  muonpaths.clear();
383  filteredmuonpaths.clear();
384 
386  // FILTER SECTIONS:
388  if (debug_)
389  LogDebug("DTTrigPhase2Prod") << "declaring new vector for filtered" << std::endl;
390 
391  std::vector<metaPrimitive> filteredMetaPrimitives;
392  if (algo_ == Standard)
393  mpathqualityenhancer_->run(iEvent, iEventSetup, metaPrimitives, filteredMetaPrimitives);
394 
395  if (dump_) {
396  for (unsigned int i = 0; i < filteredMetaPrimitives.size(); i++) {
397  stringstream ss;
398  ss << iEvent.id().event() << " filtered mp " << i << ": ";
399  printmP(ss.str(), filteredMetaPrimitives.at(i));
400  }
401  }
402 
403  metaPrimitives.clear();
404  metaPrimitives.erase(metaPrimitives.begin(), metaPrimitives.end());
405 
406  if (debug_)
407  LogDebug("DTTrigPhase2Prod") << "DTp2 in event:" << iEvent.id().event() << " we found "
408  << filteredMetaPrimitives.size() << " filteredMetaPrimitives (superlayer)"
409  << std::endl;
410  if (debug_)
411  LogDebug("DTTrigPhase2Prod") << "filteredMetaPrimitives: starting correlations" << std::endl;
412 
416  std::vector<metaPrimitive> correlatedMetaPrimitives;
417  if (algo_ == Standard)
418  mpathassociator_->run(iEvent, iEventSetup, dtdigis, filteredMetaPrimitives, correlatedMetaPrimitives);
419  else {
420  for (const auto& muonpath : outmpaths) {
421  correlatedMetaPrimitives.emplace_back(muonpath->rawId(),
422  (double)muonpath->bxTimeValue(),
423  muonpath->horizPos(),
424  muonpath->tanPhi(),
425  muonpath->phi(),
426  muonpath->phiB(),
427  muonpath->chiSquare(),
428  (int)muonpath->quality(),
429  muonpath->primitive(0)->channelId(),
430  muonpath->primitive(0)->tdcTimeStamp(),
431  muonpath->primitive(0)->laterality(),
432  muonpath->primitive(1)->channelId(),
433  muonpath->primitive(1)->tdcTimeStamp(),
434  muonpath->primitive(1)->laterality(),
435  muonpath->primitive(2)->channelId(),
436  muonpath->primitive(2)->tdcTimeStamp(),
437  muonpath->primitive(2)->laterality(),
438  muonpath->primitive(3)->channelId(),
439  muonpath->primitive(3)->tdcTimeStamp(),
440  muonpath->primitive(3)->laterality(),
441  muonpath->primitive(4)->channelId(),
442  muonpath->primitive(4)->tdcTimeStamp(),
443  muonpath->primitive(4)->laterality(),
444  muonpath->primitive(5)->channelId(),
445  muonpath->primitive(5)->tdcTimeStamp(),
446  muonpath->primitive(5)->laterality(),
447  muonpath->primitive(6)->channelId(),
448  muonpath->primitive(6)->tdcTimeStamp(),
449  muonpath->primitive(6)->laterality(),
450  muonpath->primitive(7)->channelId(),
451  muonpath->primitive(7)->tdcTimeStamp(),
452  muonpath->primitive(7)->laterality());
453  }
454  }
455  filteredMetaPrimitives.clear();
456 
457  if (debug_)
458  LogDebug("DTTrigPhase2Prod") << "DTp2 in event:" << iEvent.id().event() << " we found "
459  << correlatedMetaPrimitives.size() << " correlatedMetPrimitives (chamber)";
460 
461  if (dump_) {
462  LogInfo("DTTrigPhase2Prod") << "DTp2 in event:" << iEvent.id().event() << " we found "
463  << correlatedMetaPrimitives.size() << " correlatedMetPrimitives (chamber)";
464 
465  for (unsigned int i = 0; i < correlatedMetaPrimitives.size(); i++) {
466  stringstream ss;
467  ss << iEvent.id().event() << " correlated mp " << i << ": ";
468  printmPC(ss.str(), correlatedMetaPrimitives.at(i));
469  }
470  }
471 
472  double shift_back = 0;
473  if (scenario_ == MC) //scope for MC
474  shift_back = 400;
475  else if (scenario_ == DATA) //scope for data
476  shift_back = 0;
477  else if (scenario_ == SLICE_TEST) //scope for slice test
478  shift_back = 0;
479 
480  // RPC integration
481  if (useRPC_) {
482  rpc_integrator_->initialise(iEventSetup, shift_back);
483  rpc_integrator_->prepareMetaPrimitives(rpcRecHits);
484  rpc_integrator_->matchWithDTAndUseRPCTime(correlatedMetaPrimitives);
485  rpc_integrator_->makeRPCOnlySegments();
486  rpc_integrator_->storeRPCSingleHits();
487  rpc_integrator_->removeRPCHitsUsed();
488  }
489 
491  vector<L1Phase2MuDTPhDigi> outP2Ph;
492 
493  // Assigning index value
494  assignIndex(correlatedMetaPrimitives);
495  for (const auto& metaPrimitiveIt : correlatedMetaPrimitives) {
496  DTChamberId chId(metaPrimitiveIt.rawId);
497  if (debug_)
498  LogDebug("DTTrigPhase2Prod") << "looping in final vector: SuperLayerId" << chId << " x=" << metaPrimitiveIt.x
499  << " quality=" << metaPrimitiveIt.quality
500  << " BX=" << round(metaPrimitiveIt.t0 / 25.) << " index=" << metaPrimitiveIt.index;
501 
502  int sectorTP = chId.sector();
503  //sectors 13 and 14 exist only for the outermost stations for sectors 4 and 10 respectively
504  //due to the larger MB4 that are divided into two.
505  if (sectorTP == 13)
506  sectorTP = 4;
507  if (sectorTP == 14)
508  sectorTP = 10;
509  sectorTP = sectorTP - 1;
510  int sl = 0;
511  if (metaPrimitiveIt.quality < LOWLOWQ || metaPrimitiveIt.quality == CHIGHQ) {
512  if (inner(metaPrimitiveIt))
513  sl = 1;
514  else
515  sl = 3;
516  }
517 
518  if (debug_)
519  LogDebug("DTTrigPhase2Prod") << "pushing back phase-2 dataformat carlo-federica dataformat";
520  outP2Ph.push_back(L1Phase2MuDTPhDigi(
521  (int)round(metaPrimitiveIt.t0 / (float)LHC_CLK_FREQ) - shift_back,
522  chId.wheel(), // uwh (m_wheel)
523  sectorTP, // usc (m_sector)
524  chId.station(), // ust (m_station)
525  sl, // ust (m_station)
526  (int)round(metaPrimitiveIt.phi * PHIRES_CONV), // uphi (_phiAngle)
527  (int)round(metaPrimitiveIt.phiB * PHIBRES_CONV), // uphib (m_phiBending)
528  metaPrimitiveIt.quality, // uqua (m_qualityCode)
529  metaPrimitiveIt.index, // uind (m_segmentIndex)
530  (int)round(metaPrimitiveIt.t0) - shift_back * LHC_CLK_FREQ, // ut0 (m_t0Segment)
531  (int)round(metaPrimitiveIt.chi2 * CHI2RES_CONV), // uchi2 (m_chi2Segment)
532  metaPrimitiveIt.rpcFlag // urpc (m_rpcFlag)
533  ));
534  }
535 
536  // Storing RPC hits that were not used elsewhere
537  if (useRPC_) {
538  for (auto rpc_dt_digi = rpc_integrator_->rpcRecHits_translated_.begin();
539  rpc_dt_digi != rpc_integrator_->rpcRecHits_translated_.end();
540  rpc_dt_digi++) {
541  outP2Ph.push_back(*rpc_dt_digi);
542  }
543  }
544 
545  auto resultP2Ph = std::make_unique<L1Phase2MuDTPhContainer>();
546  resultP2Ph->setContainer(outP2Ph);
547  iEvent.put(std::move(resultP2Ph));
548  outP2Ph.clear();
549  outP2Ph.erase(outP2Ph.begin(), outP2Ph.end());
550 }
551 
552 void DTTrigPhase2Prod::endRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) {
553  grouping_obj_->finish();
554  mpathanalyzer_->finish();
555  mpathqualityenhancer_->finish();
556  mpathredundantfilter_->finish();
557  mpathassociator_->finish();
558  rpc_integrator_->finish();
559 };
560 
561 bool DTTrigPhase2Prod::outer(const metaPrimitive& mp) const {
562  int counter = (mp.wi5 != -1) + (mp.wi6 != -1) + (mp.wi7 != -1) + (mp.wi8 != -1);
563  return (counter > 2);
564 }
565 
566 bool DTTrigPhase2Prod::inner(const metaPrimitive& mp) const {
567  int counter = (mp.wi1 != -1) + (mp.wi2 != -1) + (mp.wi3 != -1) + (mp.wi4 != -1);
568  return (counter > 2);
569 }
570 
571 bool DTTrigPhase2Prod::hasPosRF(int wh, int sec) const { return wh > 0 || (wh == 0 && sec % 4 > 1); }
572 
573 void DTTrigPhase2Prod::printmP(const string& ss, const metaPrimitive& mP) const {
574  DTSuperLayerId slId(mP.rawId);
575  LogInfo("DTTrigPhase2Prod") << ss << (int)slId << "\t " << setw(2) << left << mP.wi1 << " " << setw(2) << left
576  << mP.wi2 << " " << setw(2) << left << mP.wi3 << " " << setw(2) << left << mP.wi4 << " "
577  << setw(5) << left << mP.tdc1 << " " << setw(5) << left << mP.tdc2 << " " << setw(5)
578  << left << mP.tdc3 << " " << setw(5) << left << mP.tdc4 << " " << setw(10) << right
579  << mP.x << " " << setw(9) << left << mP.tanPhi << " " << setw(5) << left << mP.t0 << " "
580  << setw(13) << left << mP.chi2 << " r:" << rango(mP);
581 }
582 
583 void DTTrigPhase2Prod::printmPC(const string& ss, const metaPrimitive& mP) const {
584  DTChamberId ChId(mP.rawId);
585  LogInfo("DTTrigPhase2Prod") << ss << (int)ChId << "\t " << setw(2) << left << mP.wi1 << " " << setw(2) << left
586  << mP.wi2 << " " << setw(2) << left << mP.wi3 << " " << setw(2) << left << mP.wi4 << " "
587  << setw(2) << left << mP.wi5 << " " << setw(2) << left << mP.wi6 << " " << setw(2) << left
588  << mP.wi7 << " " << setw(2) << left << mP.wi8 << " " << setw(5) << left << mP.tdc1 << " "
589  << setw(5) << left << mP.tdc2 << " " << setw(5) << left << mP.tdc3 << " " << setw(5)
590  << left << mP.tdc4 << " " << setw(5) << left << mP.tdc5 << " " << setw(5) << left
591  << mP.tdc6 << " " << setw(5) << left << mP.tdc7 << " " << setw(5) << left << mP.tdc8
592  << " " << setw(2) << left << mP.lat1 << " " << setw(2) << left << mP.lat2 << " "
593  << setw(2) << left << mP.lat3 << " " << setw(2) << left << mP.lat4 << " " << setw(2)
594  << left << mP.lat5 << " " << setw(2) << left << mP.lat6 << " " << setw(2) << left
595  << mP.lat7 << " " << setw(2) << left << mP.lat8 << " " << setw(10) << right << mP.x << " "
596  << setw(9) << left << mP.tanPhi << " " << setw(5) << left << mP.t0 << " " << setw(13)
597  << left << mP.chi2 << " r:" << rango(mP);
598 }
599 
601  if (mp.quality == 1 or mp.quality == 2)
602  return 3;
603  if (mp.quality == 3 or mp.quality == 4)
604  return 4;
605  return mp.quality;
606 }
607 
608 void DTTrigPhase2Prod::assignIndex(std::vector<metaPrimitive>& inMPaths) {
609  std::map<int, std::vector<metaPrimitive>> primsPerBX;
610  for (const auto& metaPrimitive : inMPaths) {
611  int BX = round(metaPrimitive.t0 / 25.);
612  primsPerBX[BX].push_back(metaPrimitive);
613  }
614  inMPaths.clear();
615  for (auto& prims : primsPerBX) {
616  assignIndexPerBX(prims.second);
617  for (const auto& primitive : prims.second)
618  inMPaths.push_back(primitive);
619  }
620 }
621 
622 void DTTrigPhase2Prod::assignIndexPerBX(std::vector<metaPrimitive>& inMPaths) {
623  // First we asociate a new index to the metaprimitive depending on quality or phiB;
624  uint32_t rawId = -1;
625  int numP = -1;
626  for (auto& metaPrimitiveIt : inMPaths) {
627  numP++;
628  rawId = metaPrimitiveIt.rawId;
629  int iOrder = assignQualityOrder(metaPrimitiveIt);
630  int inf = 0;
631  int numP2 = -1;
632  for (auto& metaPrimitiveItN : inMPaths) {
633  int nOrder = assignQualityOrder(metaPrimitiveItN);
634  numP2++;
635  if (rawId != metaPrimitiveItN.rawId)
636  continue;
637  if (numP2 == numP) {
638  metaPrimitiveIt.index = inf;
639  break;
640  } else if (iOrder < nOrder) {
641  inf++;
642  } else if (iOrder > nOrder) {
643  metaPrimitiveItN.index++;
644  } else if (iOrder == nOrder) {
645  if (std::abs(metaPrimitiveIt.phiB) >= std::abs(metaPrimitiveItN.phiB)) {
646  inf++;
647  } else if (std::abs(metaPrimitiveIt.phiB) < std::abs(metaPrimitiveItN.phiB)) {
648  metaPrimitiveItN.index++;
649  }
650  }
651  } // ending second for
652  } // ending first for
653 }
654 
656  if (mP.quality > 9 || mP.quality < 1)
657  return -1;
658 
659  return qmap_.find(mP.quality)->second;
660 }
661 
662 std::vector<DTDigiCollection*> DTTrigPhase2Prod::distribDigis(std::queue<std::pair<DTLayerId, DTDigi>>& inQ) {
663  std::vector<std::queue<std::pair<DTLayerId, DTDigi>>*> tmpVector;
664  tmpVector.clear();
665  std::vector<DTDigiCollection*> collVector;
666  collVector.clear();
667  while (!inQ.empty()) {
668  processDigi(inQ, tmpVector);
669  }
670  for (auto& sQ : tmpVector) {
671  DTDigiCollection tmpColl;
672  while (!sQ->empty()) {
673  tmpColl.insertDigi((sQ->front().first), (sQ->front().second));
674  sQ->pop();
675  }
676  collVector.push_back(&tmpColl);
677  }
678  return collVector;
679 }
680 
681 void DTTrigPhase2Prod::processDigi(std::queue<std::pair<DTLayerId, DTDigi>>& inQ,
682  std::vector<std::queue<std::pair<DTLayerId, DTDigi>>*>& vec) {
683  bool classified = false;
684  if (!vec.empty()) {
685  for (auto& sC : vec) { // Conditions for entering a super cell.
686  if ((sC->front().second.time() + superCelltimewidth_) > inQ.front().second.time()) {
687  // Time requirement
688  if (TMath::Abs(sC->front().second.wire() - inQ.front().second.wire()) <= superCellhalfspacewidth_) {
689  // Spatial requirement
690  sC->push(std::move(inQ.front()));
691  classified = true;
692  }
693  }
694  }
695  }
696  if (classified) {
697  inQ.pop();
698  return;
699  }
700 
701  std::queue<std::pair<DTLayerId, DTDigi>> newQueue;
702 
703  std::pair<DTLayerId, DTDigi> tmpPair;
704  tmpPair = std::move(inQ.front());
705  newQueue.push(tmpPair);
706  inQ.pop();
707 
708  vec.push_back(&newQueue);
709 }
710 
DTChamber::id
DTChamberId id() const
Return the DTChamberId of this chamber.
Definition: DTChamber.cc:32
DTGeometry
Definition: DTGeometry.h:28
DTTrigPhase2Prod::inner
bool inner(const metaPrimitive &mp) const
Definition: DTTrigPhase2Prod.cc:566
cmsdt::metaPrimitive
Definition: constants.h:48
Ecal2004TBTDCRanges_v1_cff.endRun
endRun
Definition: Ecal2004TBTDCRanges_v1_cff.py:4
DTSuperLayerId
Definition: DTSuperLayerId.h:12
counter
Definition: counter.py:1
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
DTTrigGeomUtils.h
mps_fire.i
i
Definition: mps_fire.py:428
DTTrigPhase2Prod::debug_
bool debug_
Definition: DTTrigPhase2Prod.cc:112
MessageLogger.h
cmsdt::metaPrimitive::rawId
uint32_t rawId
Definition: constants.h:118
DTTrigPhase2Prod::printmP
void printmP(const std::string &ss, const metaPrimitive &mP) const
Definition: DTTrigPhase2Prod.cc:573
cmsdt::metaPrimitive::x
double x
Definition: constants.h:120
ESHandle.h
DTTrigPhase2Prod::outer
bool outer(const metaPrimitive &mp) const
Definition: DTTrigPhase2Prod.cc:561
DTTrigPhase2Prod::endRun
void endRun(edm::Run const &iRun, const edm::EventSetup &iEventSetup) override
endRun: finish things
Definition: DTTrigPhase2Prod.cc:552
edm::RunID::run
RunNumber_t run() const
Definition: RunID.h:36
DTTrigPhase2Prod::mpathanalyzer_
std::unique_ptr< MuonPathAnalyzer > mpathanalyzer_
Definition: DTTrigPhase2Prod.cc:129
DTTrigPhase2Prod::activateBuffer_
bool activateBuffer_
Definition: DTTrigPhase2Prod.cc:135
edm::Run
Definition: Run.h:45
DTLayerId.h
edm::EDGetTokenT< DTDigiCollection >
DTTrigPhase2Prod::mpathqualityenhancer_
std::unique_ptr< MPFilter > mpathqualityenhancer_
Definition: DTTrigPhase2Prod.cc:130
edm
HLT enums.
Definition: AlignableModifier.h:19
cmsdt::metaPrimitive::lat8
int lat8
Definition: constants.h:149
DTChamber
Definition: DTChamber.h:24
cmsdt::metaPrimitive::wi1
int wi1
Definition: constants.h:126
cmsdt::metaPrimitive::wi8
int wi8
Definition: constants.h:147
DTTrigPhase2Prod::superCelltimewidth_
float superCelltimewidth_
Definition: DTTrigPhase2Prod.cc:137
InitialGrouping.h
ESProducer.h
EDProducer.h
DTTrigPhase2Prod::rango
int rango(const metaPrimitive &mp) const
Definition: DTTrigPhase2Prod.cc:600
cmsdt::metaPrimitive::lat4
int lat4
Definition: constants.h:137
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
DTTrigPhase2Prod::DTDigiMap_const_iterator
DTDigiMap::const_iterator DTDigiMap_const_iterator
Definition: DTTrigPhase2Prod.cc:66
edm::Handle< DTDigiCollection >
cmsdt::metaPrimitive::tdc8
int tdc8
Definition: constants.h:148
ESGetToken.h
MuonPathPtrs
std::vector< MuonPathPtr > MuonPathPtrs
Definition: MuonPath.h:122
DTTrigPhase2Prod::assignQualityOrder
int assignQualityOrder(const metaPrimitive &mP) const
Definition: DTTrigPhase2Prod.cc:655
cmsdt::CHIGHQ
Definition: constants.h:41
DTTrigPhase2Prod::beginRun
void beginRun(edm::Run const &iRun, const edm::EventSetup &iEventSetup) override
Create Trigger Units before starting event processing.
Definition: DTTrigPhase2Prod.cc:219
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
cmsdt::metaPrimitive::tdc1
int tdc1
Definition: constants.h:127
DTTrigPhase2Prod::mpathredundantfilter_
std::unique_ptr< MPFilter > mpathredundantfilter_
Definition: DTTrigPhase2Prod.cc:131
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::FileInPath
Definition: FileInPath.h:64
MakerMacros.h
cmsdt
Definition: constants.h:39
DTTrigPhase2Prod::assignIndexPerBX
void assignIndexPerBX(std::vector< metaPrimitive > &inMPaths)
Definition: DTTrigPhase2Prod.cc:622
constants.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
cmsdt::metaPrimitive::quality
int quality
Definition: constants.h:125
cmsdt::metaPrimitive::lat5
int lat5
Definition: constants.h:140
Abs
T Abs(T a)
Definition: MathUtil.h:49
DTTrigPhase2Prod::DTDigiMap
std::map< DTChamberId, DTDigiCollection, std::less< DTChamberId > > DTDigiMap
Definition: DTTrigPhase2Prod.cc:64
DTTrigPhase2Prod::DTDigiMap_iterator
DTDigiMap::iterator DTDigiMap_iterator
Definition: DTTrigPhase2Prod.cc:65
cmsdt::metaPrimitive::lat6
int lat6
Definition: constants.h:143
SurfaceOrientation::inner
Definition: Surface.h:19
DTGeometry::chambers
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:84
cmsdt::metaPrimitive::wi2
int wi2
Definition: constants.h:129
cmsdt::metaPrimitive::tdc7
int tdc7
Definition: constants.h:145
MPRedundantFilter.h
cmsdt::metaPrimitive::lat1
int lat1
Definition: constants.h:128
MuonPathAnalyzerPerSL.h
Run.h
cmsdt::metaPrimitive::wi7
int wi7
Definition: constants.h:144
cmsdt::metaPrimitive::wi6
int wi6
Definition: constants.h:141
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
cmsdt::MP_QUALITY
MP_QUALITY
Definition: constants.h:41
DTTrigPhase2Prod::~DTTrigPhase2Prod
~DTTrigPhase2Prod() override
Destructor.
Definition: DTTrigPhase2Prod.cc:214
cmsdt::PHIRES_CONV
constexpr float PHIRES_CONV
Definition: constants.h:205
cmsdt::metaPrimitive::tdc3
int tdc3
Definition: constants.h:133
cmsdt::metaPrimitive::lat7
int lat7
Definition: constants.h:146
b
double b
Definition: hdecay.h:118
DTChamberId.h
DTLayerId
Definition: DTLayerId.h:12
HoughGrouping.h
MPFilter.h
createBeamHaloJobs.queue
queue
Definition: createBeamHaloJobs.py:343
DTLayer.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTTrigPhase2Prod::shiftinfo_
std::map< int, float > shiftinfo_
Definition: DTTrigPhase2Prod.cc:120
ESProducts.h
DTTrigPhase2Prod::DTTrigPhase2Prod
DTTrigPhase2Prod(const edm::ParameterSet &pset)
Constructor.
Definition: DTTrigPhase2Prod.cc:161
DTGeometry.h
cmsdt::HoughTrans
Definition: constants.h:164
cmsdt::metaPrimitive::wi5
int wi5
Definition: constants.h:138
RPCDetId.h
DTTrigPhase2Prod::hasPosRF
bool hasPosRF(int wh, int sec) const
Definition: DTTrigPhase2Prod.cc:571
cmsdt::LHC_CLK_FREQ
constexpr int LHC_CLK_FREQ
Definition: constants.h:169
cmsdt::Standard
Definition: constants.h:164
RPCRecHitCollection.h
cscdqm::DATA
Definition: CSCDQM_Summary.h:47
DTTrigPhase2Prod::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iEventSetup) override
Producer: process every event and generates trigger data.
Definition: DTTrigPhase2Prod.cc:235
funct::primitive
Primitive< F, X >::type primitive(const F &f)
Definition: Primitive.h:41
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
cmsdt::SLICE_TEST
Definition: constants.h:166
cmsdt::metaPrimitive::lat2
int lat2
Definition: constants.h:131
DTTrigPhase2Prod::algo_
int algo_
Definition: DTTrigPhase2Prod.cc:127
Event.h
IntegrityClient_cfi.ChId
ChId
Definition: IntegrityClient_cfi.py:18
cmsdt::metaPrimitive::wi4
int wi4
Definition: constants.h:135
DTTrigPhase2Prod::my_BXoffset_
int my_BXoffset_
Definition: DTTrigPhase2Prod.cc:109
DTTrigPhase2Prod
Definition: DTTrigPhase2Prod.cc:63
MPQualityEnhancerFilter.h
DTSuperLayerId::chamberId
DTChamberId chamberId() const
Return the corresponding ChamberId.
Definition: DTSuperLayerId.h:45
DTDigiCollection
DTTrigPhase2Prod::qmap_
const std::unordered_map< int, int > qmap_
Definition: DTTrigPhase2Prod.cc:150
cmsdt::metaPrimitive::tdc5
int tdc5
Definition: constants.h:139
DTTrigPhase2Prod::primitives_
std::vector< std::pair< int, MuonPath > > primitives_
Definition: DTTrigPhase2Prod.cc:102
DTTrigPhase2Prod::dtGeo_
DTGeometry const * dtGeo_
Definition: DTTrigPhase2Prod.cc:100
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
cmsdt::metaPrimitive::tdc6
int tdc6
Definition: constants.h:142
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:38
L1Phase2MuDTPhContainer.h
cmsdt::MC
Definition: constants.h:166
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
edm::EventSetup
Definition: EventSetup.h:57
DTTrigPhase2Prod::shift_filename_
edm::FileInPath shift_filename_
Definition: DTTrigPhase2Prod.cc:119
DTTrigPhase2Prod::dtDigisToken_
edm::EDGetTokenT< DTDigiCollection > dtDigisToken_
Definition: DTTrigPhase2Prod.cc:123
DTTrigPhase2Prod::grouping_obj_
std::unique_ptr< MotherGrouping > grouping_obj_
Definition: DTTrigPhase2Prod.cc:128
cmsdt::metaPrimitive::tanPhi
double tanPhi
Definition: constants.h:121
cmsdt::PHIBRES_CONV
constexpr float PHIBRES_CONV
Definition: constants.h:206
edm::ESGetToken< DTGeometry, MuonGeometryRecord >
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:87
DTTrigPhase2Prod::distribDigis
std::vector< DTDigiCollection * > distribDigis(std::queue< std::pair< DTLayerId, DTDigi >> &inQ)
Definition: DTTrigPhase2Prod.cc:662
cmsdt::metaPrimitive::tdc4
int tdc4
Definition: constants.h:136
L1Phase2MuDTPhDigi.h
DTTrigPhase2Prod::dT0_correlate_TP_
double dT0_correlate_TP_
Definition: DTTrigPhase2Prod.cc:114
cmsdt::metaPrimitive::chi2
double chi2
Definition: constants.h:124
ModuleFactory.h
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DTTrigPhase2Prod::processDigi
void processDigi(std::queue< std::pair< DTLayerId, DTDigi >> &inQ, std::vector< std::queue< std::pair< DTLayerId, DTDigi >> * > &vec)
Definition: DTTrigPhase2Prod.cc:681
DTTrigPhase2Prod::superCellhalfspacewidth_
int superCellhalfspacewidth_
Definition: DTTrigPhase2Prod.cc:136
dqmiodatasetharvest.inf
inf
Definition: dqmiodatasetharvest.py:38
DTWireId.h
DTTrigPhase2Prod::my_CCBValid_
bool my_CCBValid_
Definition: DTTrigPhase2Prod.cc:106
dtTriggerPhase2PrimitiveDigis_cfi.rpcRecHits
rpcRecHits
Definition: dtTriggerPhase2PrimitiveDigis_cfi.py:39
Frameworkfwd.h
L1Phase2MuDTPhDigi
Definition: L1Phase2MuDTPhDigi.h:32
DTTrigPhase2Prod::useRPC_
bool useRPC_
Definition: DTTrigPhase2Prod.cc:144
cmsdt::PseudoBayes
Definition: constants.h:164
MuonPath.h
DTTrigPhase2Prod::dump_
bool dump_
Definition: DTTrigPhase2Prod.cc:113
DTLayerId::superlayerId
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
PseudoBayesGrouping.h
cmsdt::metaPrimitive::tdc2
int tdc2
Definition: constants.h:130
EventSetup.h
MuonPathAnalyzer.h
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
or
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
L1TStage2uGTEmulatorClient_cff.BX
BX
Definition: L1TStage2uGTEmulatorClient_cff.py:9
RPCIntegrator.h
cmsdt::CHI2RES_CONV
constexpr int CHI2RES_CONV
Definition: constants.h:207
DTTrigPhase2Prod::printmPC
void printmPC(const std::string &ss, const metaPrimitive &mP) const
Definition: DTTrigPhase2Prod.cc:583
ConsumesCollector.h
MuonPathAnalyzerInChamber.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DTDigiCollection.h
DTChamberId
Definition: DTChamberId.h:14
cmsdt::LOWLOWQ
Definition: constants.h:41
ParameterSet.h
DTSuperLayerId.h
MuonGeometryRecord.h
SurfaceOrientation::outer
Definition: Surface.h:19
DTTrigPhase2Prod::rpc_integrator_
std::unique_ptr< RPCIntegrator > rpc_integrator_
Definition: DTTrigPhase2Prod.cc:143
DTTrigPhase2Prod::do_correlation_
bool do_correlation_
Definition: DTTrigPhase2Prod.cc:115
DigiContainerIterator
Definition: MuonDigiCollection.h:30
DTTrigPhase2Prod::assignIndex
void assignIndex(std::vector< metaPrimitive > &inMPaths)
Definition: DTTrigPhase2Prod.cc:608
edm::Event
Definition: Event.h:73
MotherGrouping.h
cmsdt::metaPrimitive::lat3
int lat3
Definition: constants.h:134
edm::RunBase::id
RunID const & id() const
Definition: RunBase.h:39
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
DTTrigPhase2Prod::dtGeomH
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH
Definition: DTTrigPhase2Prod.cc:101
RPCGeometry.h
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
edm::InputTag
Definition: InputTag.h:15
DTTrigPhase2Prod::rpcRecHitsLabel_
edm::EDGetTokenT< RPCRecHitCollection > rpcRecHitsLabel_
Definition: DTTrigPhase2Prod.cc:124
MuonPathAssociator.h
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
cmsdt::metaPrimitive::wi3
int wi3
Definition: constants.h:132
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
cmsdt::metaPrimitive::t0
double t0
Definition: constants.h:119
DTTrigPhase2Prod::mpathassociator_
std::unique_ptr< MuonPathAssociator > mpathassociator_
Definition: DTTrigPhase2Prod.cc:132
DTTrigPhase2Prod::scenario_
int scenario_
Definition: DTTrigPhase2Prod.cc:116