CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PseudoBayesGrouping.cc
Go to the documentation of this file.
1 #include <memory>
2 
6 
7 #include "TFile.h"
8 
10 
11 using namespace edm;
12 using namespace std;
13 using namespace cmsdt;
14 using namespace dtbayesam;
15 // ============================================================================
16 // Constructors and destructor
17 // ============================================================================
19  : MotherGrouping(pset, iC) {
20  // Obtention of parameters
21  debug_ = pset.getUntrackedParameter<bool>("debug");
23  minNLayerHits_ = pset.getUntrackedParameter<int>("minNLayerHits");
24  minSingleSLHitsMax_ = pset.getUntrackedParameter<int>("minSingleSLHitsMax");
25  minSingleSLHitsMin_ = pset.getUntrackedParameter<int>("minSingleSLHitsMin");
26  allowedVariance_ = pset.getUntrackedParameter<int>("allowedVariance");
27  allowDuplicates_ = pset.getUntrackedParameter<bool>("allowDuplicates");
28  allowUncorrelatedPatterns_ = pset.getUntrackedParameter<bool>("allowUncorrelatedPatterns");
29  minUncorrelatedHits_ = pset.getUntrackedParameter<int>("minUncorrelatedHits");
30  maxPathsPerMatch_ = pset.getUntrackedParameter<int>("maxPathsPerMatch");
31  saveOnPlace_ = pset.getUntrackedParameter<bool>("saveOnPlace");
32  setLateralities_ = pset.getUntrackedParameter<bool>("setLateralities");
33  if (debug_)
34  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping:: constructor";
35 }
36 
38  if (debug_)
39  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping:: destructor";
40 }
41 
42 // ============================================================================
43 // Main methods (initialise, run, finish)
44 // ============================================================================
46  if (debug_)
47  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::initialiase";
48  if (debug_)
49  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::initialiase using patterns file " << pattern_filename_;
50  nPatterns_ = 0;
51 
52  TString patterns_folder = "L1Trigger/DTTriggerPhase2/data/";
53 
54  // Load all patterns
55  // MB1
56  LoadPattern(patterns_folder + "createdPatterns_MB1_left.root", 0, 0);
57  LoadPattern(patterns_folder + "createdPatterns_MB1_right.root", 0, 2);
58  // MB2
59  LoadPattern(patterns_folder + "createdPatterns_MB2_left.root", 1, 0);
60  LoadPattern(patterns_folder + "createdPatterns_MB2_right.root", 1, 2);
61  // MB3
62  LoadPattern(patterns_folder + "createdPatterns_MB3.root", 2, 1);
63  // MB4
64  LoadPattern(patterns_folder + "createdPatterns_MB4_left.root", 3, 0);
65  LoadPattern(patterns_folder + "createdPatterns_MB4.root", 3, 1);
66  LoadPattern(patterns_folder + "createdPatterns_MB4_right.root", 3, 2);
67 
68  prelimMatches_ = std::make_unique<CandidateGroupPtrs>();
69  allMatches_ = std::make_unique<CandidateGroupPtrs>();
70  finalMatches_ = std::make_unique<CandidateGroupPtrs>();
71 }
72 
73 void PseudoBayesGrouping::LoadPattern(TString pattern_file_name, int MB_number, int SL_shift) {
74  TFile* f = TFile::Open(pattern_file_name, "READ");
75 
76  std::vector<std::vector<std::vector<int>>>* pattern_reader =
77  (std::vector<std::vector<std::vector<int>>>*)f->Get("allPatterns");
78 
79  for (std::vector<std::vector<std::vector<int>>>::iterator itPattern = (*pattern_reader).begin();
80  itPattern != (*pattern_reader).end();
81  ++itPattern) {
82  if (debug_)
83  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::LoadPattern Loading patterns seeded by: "
84  << itPattern->at(0).at(0) << ", " << itPattern->at(0).at(1) << ", "
85  << itPattern->at(0).at(2) << ", ";
86 
87  auto p = std::make_shared<DTPattern>();
88 
89  bool is_seed = true;
90  for (const auto& itHits : *itPattern) {
91  // First entry is the seeding information
92  if (is_seed) {
93  p = std::make_shared<DTPattern>(DTPattern(itHits.at(0), itHits.at(1), itHits.at(2)));
94  is_seed = false;
95  }
96  // Other entries are the hits information
97  else {
98  if (itHits.begin() == itHits.end())
99  continue;
100  // We need to correct the geometry from pattern generation to reconstruction as they use slightly displaced basis
101  else if (itHits.at(0) % 2 == 0) {
102  p->addHit(std::make_tuple(itHits.at(0), itHits.at(1), itHits.at(2)));
103  } else if (itHits.at(0) % 2 == 1) {
104  p->addHit(std::make_tuple(itHits.at(0), itHits.at(1) - 1, itHits.at(2)));
105  }
106  }
107  }
108  // Classified by seeding layers for optimized search later
109  // TODO::This can be vastly improved using std::bitset<8>, for example
110  if (p->sl1() == 0) {
111  if (p->sl2() == 7)
112  L0L7Patterns_[MB_number][SL_shift].push_back(p);
113  if (p->sl2() == 6)
114  L0L6Patterns_[MB_number][SL_shift].push_back(p);
115  if (p->sl2() == 5)
116  L0L5Patterns_[MB_number][SL_shift].push_back(p);
117  if (p->sl2() == 4)
118  L0L4Patterns_[MB_number][SL_shift].push_back(p);
119  if (p->sl2() == 3)
120  L0L3Patterns_[MB_number][SL_shift].push_back(p);
121  if (p->sl2() == 2)
122  L0L2Patterns_[MB_number][SL_shift].push_back(p);
123  if (p->sl2() == 1)
124  L0L1Patterns_[MB_number][SL_shift].push_back(p);
125  }
126  if (p->sl1() == 1) {
127  if (p->sl2() == 7)
128  L1L7Patterns_[MB_number][SL_shift].push_back(p);
129  if (p->sl2() == 6)
130  L1L6Patterns_[MB_number][SL_shift].push_back(p);
131  if (p->sl2() == 5)
132  L1L5Patterns_[MB_number][SL_shift].push_back(p);
133  if (p->sl2() == 4)
134  L1L4Patterns_[MB_number][SL_shift].push_back(p);
135  if (p->sl2() == 3)
136  L1L3Patterns_[MB_number][SL_shift].push_back(p);
137  if (p->sl2() == 2)
138  L1L2Patterns_[MB_number][SL_shift].push_back(p);
139  }
140  if (p->sl1() == 2) {
141  if (p->sl2() == 7)
142  L2L7Patterns_[MB_number][SL_shift].push_back(p);
143  if (p->sl2() == 6)
144  L2L6Patterns_[MB_number][SL_shift].push_back(p);
145  if (p->sl2() == 5)
146  L2L5Patterns_[MB_number][SL_shift].push_back(p);
147  if (p->sl2() == 4)
148  L2L4Patterns_[MB_number][SL_shift].push_back(p);
149  if (p->sl2() == 3)
150  L2L3Patterns_[MB_number][SL_shift].push_back(p);
151  }
152  if (p->sl1() == 3) {
153  if (p->sl2() == 7)
154  L3L7Patterns_[MB_number][SL_shift].push_back(p);
155  if (p->sl2() == 6)
156  L3L6Patterns_[MB_number][SL_shift].push_back(p);
157  if (p->sl2() == 5)
158  L3L5Patterns_[MB_number][SL_shift].push_back(p);
159  if (p->sl2() == 4)
160  L3L4Patterns_[MB_number][SL_shift].push_back(p);
161  }
162 
163  if (p->sl1() == 4) {
164  if (p->sl2() == 7)
165  L4L7Patterns_[MB_number][SL_shift].push_back(p);
166  if (p->sl2() == 6)
167  L4L6Patterns_[MB_number][SL_shift].push_back(p);
168  if (p->sl2() == 5)
169  L4L5Patterns_[MB_number][SL_shift].push_back(p);
170  }
171  if (p->sl1() == 5) {
172  if (p->sl2() == 7)
173  L5L7Patterns_[MB_number][SL_shift].push_back(p);
174  if (p->sl2() == 6)
175  L5L6Patterns_[MB_number][SL_shift].push_back(p);
176  }
177  if (p->sl1() == 6) {
178  if (p->sl2() == 7)
179  L6L7Patterns_[MB_number][SL_shift].push_back(p);
180  }
181 
182  //Also creating a list of all patterns, needed later for deleting and avoid a memory leak
183  allPatterns_[MB_number][SL_shift].push_back(p);
184  nPatterns_++;
185  }
186  if (debug_)
187  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::initialiase Total number of loaded patterns: "
188  << nPatterns_;
189  f->Close();
190  delete f;
191 }
192 
194  const EventSetup& iEventSetup,
195  const DTDigiCollection& digis,
196  MuonPathPtrs& mpaths) {
197  //Takes dt digis collection and does the grouping for correlated hits, it is saved in a vector of up to 8 (or 4) correlated hits
198  if (debug_)
199  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::run";
200  //Do initial cleaning
202  //Sort digis by layer
203  FillDigisByLayer(&digis);
204 
205  //Sarch for patterns
206  DTChamberId chamber_id;
207  // We just want the chamber ID of the first digi
208  // as they are all the same --> create a loop and break it
209  // after the first iteration
210  for (const auto& detUnitIt : digis) {
211  const DTLayerId layer_Id = detUnitIt.first;
212  chamber_id = layer_Id.superlayerId().chamberId();
213  break;
214  }
215 
216  RecognisePatternsByLayerPairs(chamber_id);
217 
218  // Now sort patterns by qualities
219  std::sort(prelimMatches_->begin(), prelimMatches_->end(), CandPointGreat());
220  if (debug_ && !prelimMatches_->empty()) {
221  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::run Pattern qualities before cleaning: ";
222  for (const auto& cand_it : *prelimMatches_) {
223  LogDebug("PseudoBayesGrouping") << cand_it->nLayerhits() << ", " << cand_it->nisGood() << ", " << cand_it->nhits()
224  << ", " << cand_it->quality() << ", " << cand_it->candId();
225  }
226  }
227  //And ghostbust patterns to retain higher quality ones
229  if (debug_)
230  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::run Number of found patterns: " << finalMatches_->size();
231 
232  //Last organize candidates information into muonpaths to finalize the grouping
233  FillMuonPaths(mpaths);
234  if (debug_)
235  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::run ended run";
236 }
237 
239  //Loop over all selected candidates
240  for (auto itCand = finalMatches_->begin(); itCand != finalMatches_->end(); itCand++) {
241  if (debug_)
242  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::run Create pointers ";
243 
244  // Vector of all muon paths we may find
245  std::vector<DTPrimitivePtrs> ptrPrimitive_vector;
246 
247  // We will have at least one muon path
248  DTPrimitivePtrs ptrPrimitive;
249  for (int i = 0; i < 8; i++)
250  ptrPrimitive.push_back(std::make_shared<DTPrimitive>());
251 
252  ptrPrimitive_vector.push_back(ptrPrimitive);
253 
254  qualitybits qualityDTP;
255  qualitybits qualityDTP2;
256  int intHit = 0;
257 
258  //And for each candidate loop over all grouped hits
259  for (auto& itDTP : (*itCand)->candHits()) {
260  if (debug_)
261  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::run loop over dt hits to fill pointer";
262 
263  int layerHit = (*itDTP).layerId();
264  //Back to the usual basis for SL
265  if (layerHit >= 4) {
266  (*itDTP).setLayerId(layerHit - 4);
267  }
268  qualitybits ref8Hit(std::pow(2, layerHit));
269  //Get the predicted laterality
270  if (setLateralities_) {
271  int predLat = (*itCand)->pattern()->latHitIn(layerHit, (*itDTP).channelId(), allowedVariance_);
272  if (predLat == -10 || predLat == 0) {
273  (*itDTP).setLaterality(NONE);
274  } else if (predLat == -1) {
275  (*itDTP).setLaterality(LEFT);
276  } else if (predLat == +1) {
277  (*itDTP).setLaterality(RIGHT);
278  }
279  }
280 
281  // If one hit is already present in the current layer, for each ptrPrimitive already existing,
282  // create a new with all its hits. Then, fill it with the new hit and add it to the primitives vector.
283  // Do not consider more than 2 hits in the same wire or more than maxPathsPerMatch_ total muonpaths per finalMatches_
284  if (qualityDTP == (qualityDTP | ref8Hit) && qualityDTP2 != (qualityDTP2 | ref8Hit) &&
285  ptrPrimitive_vector.size() < maxPathsPerMatch_) {
286  if (debug_)
287  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::run Creating additional muon paths";
288 
289  qualityDTP2 = (qualityDTP2 | ref8Hit);
290 
291  int n_prim = ptrPrimitive_vector.size();
292 
293  for (int j = 0; j < n_prim; j++) {
294  DTPrimitivePtrs tmpPrimitive;
295  for (int i = 0; i < NUM_LAYERS_2SL; i++) {
296  tmpPrimitive.push_back(ptrPrimitive_vector.at(j).at(i));
297  }
298  // Now save the hit in the new path
299  if (saveOnPlace_) {
300  //This will save the primitive in a place of the vector equal to its L position
301  tmpPrimitive.at(layerHit) = std::make_shared<DTPrimitive>((*itDTP));
302  }
303  if (!saveOnPlace_) {
304  //This will save the primitive in order
305  tmpPrimitive.at(intHit) = std::make_shared<DTPrimitive>((*itDTP));
306  }
307  // Now add the new path to the vector of paths
308  ptrPrimitive_vector.push_back(tmpPrimitive);
309  }
310  }
311 
312  // If there is not one hit already in the layer, fill the DT primitives pointers
313  else {
314  if (debug_)
315  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::run Adding hit to muon path";
316 
317  qualityDTP = (qualityDTP | ref8Hit);
318 
319  // for (all paths --> fill them)
320  for (auto prim_it = ptrPrimitive_vector.begin(); prim_it != ptrPrimitive_vector.end(); ++prim_it) {
321  if (saveOnPlace_) {
322  //This will save the primitive in a place of the vector equal to its L position
323  prim_it->at(layerHit) = std::make_shared<DTPrimitive>((*itDTP));
324  }
325  if (!saveOnPlace_) {
326  //This will save the primitive in order
327  intHit++;
328  prim_it->at(intHit) = std::make_shared<DTPrimitive>((*itDTP));
329  }
330  }
331  }
332  }
333 
334  stringstream ss;
335 
336  int n_paths = ptrPrimitive_vector.size();
337 
338  for (int n_path = 0; n_path < n_paths; ++n_path) {
339  mpaths.emplace_back(std::make_shared<MuonPath>(
340  ptrPrimitive_vector.at(n_path), (short)(*itCand)->nLayerUp(), (short)(*itCand)->nLayerDown()));
341  }
342  }
343 }
344 
346  // chamber_ID traslated to MB, wheel, sector
347  int MB = chamber_ID.station() - 1;
348  int wheel = chamber_ID.wheel();
349  int sector = chamber_ID.sector();
350 
351  // shift of SL3 wrt SL1
352  int shift = -1;
353 
354  // Now define DT geometry depending on its ID
355 
356  // MB1
357  if (MB == 0) {
358  if (wheel == -1 || wheel == -2)
359  shift = 2; // positive (right)
360  else if (wheel == 1 || wheel == 2)
361  shift = 0; // negative (left)
362  else if (wheel == 0) {
363  if (sector == 1 || sector == 4 || sector == 5 || sector == 8 || sector == 9 || sector == 12)
364  shift = 2; // positive (right)
365  else
366  shift = 0; // negative (left)
367  }
368  }
369  // MB2
370  else if (MB == 1) {
371  if (wheel == -1 || wheel == -2)
372  shift = 0; // negative (left)
373  else if (wheel == 1 || wheel == 2)
374  shift = 2; // positive (right)
375  else if (wheel == 0) {
376  if (sector == 1 || sector == 4 || sector == 5 || sector == 8 || sector == 9 || sector == 12)
377  shift = 0; // negative (left)
378  else
379  shift = 2; // positive (right)
380  }
381  }
382  // MB3
383  else if (MB == 2) {
384  shift = 1; // shift is always 0 in MB3
385  }
386  // MB4
387  else if (MB == 3) {
388  if (wheel == -1 || wheel == -2)
389  if (sector == 4 || sector == 9 || sector == 11 || sector == 13)
390  shift = 1; // no shift
391  else if (sector == 5 || sector == 6 || sector == 7 || sector == 8 || sector == 14)
392  shift = 2; // positive (right)
393  else
394  shift = 0; // negative (left)
395  else if (wheel == 1 || wheel == 2)
396  if (sector == 4 || sector == 9 || sector == 11 || sector == 13)
397  shift = 1; // no shift
398  else if (sector == 1 || sector == 2 || sector == 3 || sector == 10 || sector == 12)
399  shift = 2; // positive (right)
400  else
401  shift = 0; // negative (left)
402  else if (wheel == 0)
403  if (sector == 4 || sector == 9 || sector == 11 || sector == 13)
404  shift = 1; // no shift
405  else if (sector == 2 || sector == 3 || sector == 5 || sector == 8 || sector == 10)
406  shift = 2; // positive (right)
407  else
408  shift = 0; // negative (left)
409  else
410  return;
411  }
412 
413  //Separated from main run function for clarity. Do all pattern recognition steps
414  pidx_ = 0;
415  //Compare L0-L7
417  //Compare L0-L6 and L1-L7
420  //Compare L0-L5, L1-L6, L2-L7
424  //L0-L4, L1-L5, L2-L6, L3-L7
429  //L1-L4, L2-L5, L3-L6
433  //L2-L4, L3-L5
436  //L3-L4
438  //Uncorrelated SL1
445  //Uncorrelated SL3
452 }
453 
454 void PseudoBayesGrouping::RecognisePatterns(std::vector<DTPrimitive> digisinLDown,
455  std::vector<DTPrimitive> digisinLUp,
456  DTPatternPtrs patterns) {
457  //Loop over all hits and search for matching patterns (there will be four
458  // amongst ~60, accounting for possible lateralities)
459  for (auto dtPD_it = digisinLDown.begin(); dtPD_it != digisinLDown.end(); dtPD_it++) {
460  int LDown = dtPD_it->layerId();
461  int wireDown = dtPD_it->channelId();
462  for (auto dtPU_it = digisinLUp.begin(); dtPU_it != digisinLUp.end(); dtPU_it++) {
463  int LUp = dtPU_it->layerId();
464  int wireUp = dtPU_it->channelId();
465  int diff = wireUp - wireDown;
466  for (auto pat_it = patterns.begin(); pat_it != patterns.end(); pat_it++) {
467  //For each pair of hits in the layers search for the seeded patterns
468  if ((*pat_it)->sl1() != (LDown) || (*pat_it)->sl2() != (LUp) || (*pat_it)->diff() != diff)
469  continue;
470  //If we are here a pattern was found and we can start comparing
471  (*pat_it)->setHitDown(wireDown);
472  auto cand = std::make_shared<CandidateGroup>(*pat_it);
473  for (auto dtTest_it = alldigis_.begin(); dtTest_it != alldigis_.end(); dtTest_it++) {
474  //Find hits matching to the pattern
475  if (((*pat_it)->latHitIn(dtTest_it->layerId(), dtTest_it->channelId(), allowedVariance_)) != -999) {
476  if (((*pat_it)->latHitIn(dtTest_it->layerId(), dtTest_it->channelId(), allowedVariance_)) == -10)
477  cand->addHit((*dtTest_it), dtTest_it->layerId(), false);
478  else
479  cand->addHit((*dtTest_it), dtTest_it->layerId(), true);
480  }
481  }
482  if ((cand->nhits() >= minNLayerHits_ &&
483  (cand->nLayerUp() >= minSingleSLHitsMax_ || cand->nLayerDown() >= minSingleSLHitsMax_) &&
484  (cand->nLayerUp() >= minSingleSLHitsMin_ && cand->nLayerDown() >= minSingleSLHitsMin_)) ||
485  (allowUncorrelatedPatterns_ && ((cand->nLayerUp() >= minUncorrelatedHits_ && cand->nLayerDown() == 0) ||
486  (cand->nLayerDown() >= minUncorrelatedHits_ && cand->nLayerUp() == 0)))) {
487  if (debug_) {
488  LogDebug("PseudoBayesGrouping")
489  << "PseudoBayesGrouping::RecognisePatterns Pattern found for pair in " << LDown << " ," << wireDown
490  << " ," << LUp << " ," << wireUp << "\n"
491  << "Candidate has " << cand->nhits() << " hits with quality " << cand->quality() << "\n"
492  << *(*pat_it);
493  }
494  //We currently save everything at this level, might want to be more restrictive
495  pidx_++;
496  cand->setCandId(pidx_);
497  prelimMatches_->push_back(std::move(cand));
498  allMatches_->push_back(std::move(cand));
499  }
500  }
501  }
502  }
503 }
504 
506  //First we need to have separated lists of digis by layer
507  if (debug_)
508  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping::FillDigisByLayer Classifying digis by layer";
509  // for (auto dtDigi_It = digis->begin(); dtDigi_It != digis->end(); dtDigi_It++) {
510  for (const auto& dtDigi_It : *digis) {
511  const DTLayerId dtLId = dtDigi_It.first;
512  //Skip digis in SL theta which we are not interested on for the grouping
513  for (auto digiIt = (dtDigi_It.second).first; digiIt != (dtDigi_It.second).second; digiIt++) {
514  //Need to change notation slightly here
515  if (dtLId.superlayer() == 2)
516  continue;
517  int layer = dtLId.layer() - 1;
518  if (dtLId.superlayer() == 3)
519  layer += 4;
520  //Use the same format as for InitialGrouping to avoid tons of replicating classes, we will have some not used variables
521  DTPrimitive dtpAux = DTPrimitive();
522  dtpAux.setTDCTimeStamp(digiIt->time());
523  dtpAux.setChannelId(digiIt->wire() - 1);
524  dtpAux.setLayerId(layer);
525  dtpAux.setSuperLayerId(dtLId.superlayer());
526  dtpAux.setCameraId(dtLId.rawId());
527  if (debug_)
528  LogDebug("PseudoBayesGrouping") << "Hit in L " << layer << " SL " << dtLId.superlayer() << " WIRE "
529  << digiIt->wire() - 1;
530  if (layer == 0)
531  digisinL0_.push_back(dtpAux);
532  else if (layer == 1)
533  digisinL1_.push_back(dtpAux);
534  else if (layer == 2)
535  digisinL2_.push_back(dtpAux);
536  else if (layer == 3)
537  digisinL3_.push_back(dtpAux);
538  else if (layer == 4)
539  digisinL4_.push_back(dtpAux);
540  else if (layer == 5)
541  digisinL5_.push_back(dtpAux);
542  else if (layer == 6)
543  digisinL6_.push_back(dtpAux);
544  else if (layer == 7)
545  digisinL7_.push_back(dtpAux);
546  alldigis_.push_back(dtpAux);
547  }
548  }
549 }
550 
552  //GhostbustPatterns that share hits and are of lower quality
553  if (prelimMatches_->empty()) {
554  return;
555  };
556  while ((prelimMatches_->at(0)->nLayerhits() >= minNLayerHits_ &&
557  (prelimMatches_->at(0)->nLayerUp() >= minSingleSLHitsMax_ ||
558  prelimMatches_->at(0)->nLayerDown() >= minSingleSLHitsMax_) &&
559  (prelimMatches_->at(0)->nLayerUp() >= minSingleSLHitsMin_ &&
560  prelimMatches_->at(0)->nLayerDown() >= minSingleSLHitsMin_)) ||
562  ((prelimMatches_->at(0)->nLayerUp() >= minUncorrelatedHits_ && prelimMatches_->at(0)->nLayerDown() == 0) ||
563  (prelimMatches_->at(0)->nLayerDown() >= minUncorrelatedHits_ && prelimMatches_->at(0)->nLayerUp() == 0)))) {
564  finalMatches_->push_back(prelimMatches_->at(0));
565  auto itSel = finalMatches_->end() - 1;
566  prelimMatches_->erase(prelimMatches_->begin());
567  if (prelimMatches_->empty()) {
568  return;
569  };
570  for (auto cand_it = prelimMatches_->begin(); cand_it != prelimMatches_->end(); cand_it++) {
571  if (*(*cand_it) == *(*itSel) && allowDuplicates_)
572  continue;
573  for (const auto& dt_it : (*itSel)->candHits()) {
574  (*cand_it)->removeHit((*dt_it));
575  }
576  }
577 
578  std::sort(prelimMatches_->begin(), prelimMatches_->end(), CandPointGreat());
579  if (debug_) {
580  LogDebug("PseudoBayesGrouping") << "Pattern qualities: ";
581  for (const auto& cand_it : *prelimMatches_) {
582  LogDebug("PseudoBayesGrouping") << cand_it->nLayerhits() << ", " << cand_it->nisGood() << ", "
583  << cand_it->nhits() << ", " << cand_it->quality() << ", " << cand_it->candId()
584  << "\n";
585  }
586  }
587  }
588 }
589 
591  digisinL0_.clear();
592  digisinL1_.clear();
593  digisinL2_.clear();
594  digisinL3_.clear();
595  digisinL4_.clear();
596  digisinL5_.clear();
597  digisinL6_.clear();
598  digisinL7_.clear();
599  alldigis_.clear();
600  allMatches_->clear();
601  prelimMatches_->clear();
602  finalMatches_->clear();
603 }
604 
606  if (debug_)
607  LogDebug("PseudoBayesGrouping") << "PseudoBayesGrouping: finish";
608 };
PseudoBayesGrouping(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
std::vector< DTPrimitivePtr > DTPrimitivePtrs
Definition: DTprimitive.h:55
dtbayesam::DTPatternPtrs L3L4Patterns_[4][3]
T getUntrackedParameter(std::string const &, T const &) const
dtbayesam::DTPatternPtrs L1L3Patterns_[4][3]
dtbayesam::DTPatternPtrs L4L6Patterns_[4][3]
dtbayesam::DTPatternPtrs L0L2Patterns_[4][3]
dtbayesam::DTPatternPtrs L3L6Patterns_[4][3]
DTChamberId chamberId() const
Return the corresponding ChamberId.
void setLayerId(int layer)
Definition: DTprimitive.h:24
std::vector< MuonPathPtr > MuonPathPtrs
Definition: MuonPath.h:128
void LoadPattern(TString pattern_file_name, int MB_number_input, int SL_shift)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::vector< DTPrimitive > alldigis_
std::vector< DTPrimitive > digisinL5_
dtbayesam::DTPatternPtrs L0L7Patterns_[4][3]
std::bitset< 8 > qualitybits
std::unique_ptr< dtbayesam::CandidateGroupPtrs > allMatches_
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
void RecognisePatternsByLayerPairs(DTChamberId chamber_ID)
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
std::vector< DTPrimitive > digisinL6_
dtbayesam::DTPatternPtrs L3L7Patterns_[4][3]
constexpr std::array< uint8_t, layerIndexSize > layer
dtbayesam::DTPatternPtrs L1L4Patterns_[4][3]
dtbayesam::DTPatternPtrs L2L5Patterns_[4][3]
void setChannelId(int channel)
Definition: DTprimitive.h:23
void setTDCTimeStamp(int tstamp)
Definition: DTprimitive.h:20
int iEvent
Definition: GenABIO.cc:224
std::vector< DTPrimitive > digisinL0_
std::vector< DTPrimitive > digisinL1_
dtbayesam::DTPatternPtrs L4L7Patterns_[4][3]
void FillDigisByLayer(const DTDigiCollection *digis)
dtbayesam::DTPatternPtrs allPatterns_[4][3]
dtbayesam::DTPatternPtrs L6L7Patterns_[4][3]
dtbayesam::DTPatternPtrs L2L7Patterns_[4][3]
dtbayesam::DTPatternPtrs L0L1Patterns_[4][3]
dtbayesam::DTPatternPtrs L1L7Patterns_[4][3]
def move
Definition: eostools.py:511
dtbayesam::DTPatternPtrs L2L4Patterns_[4][3]
dtbayesam::DTPatternPtrs L2L3Patterns_[4][3]
std::vector< DTPrimitive > digisinL4_
std::vector< DTPatternPtr > DTPatternPtrs
dtbayesam::DTPatternPtrs L0L4Patterns_[4][3]
dtbayesam::DTPatternPtrs L2L6Patterns_[4][3]
std::vector< DTPrimitive > digisinL3_
std::vector< DTPrimitive > digisinL2_
void FillMuonPaths(MuonPathPtrs &mpaths)
int superlayer() const
Return the superlayer number (deprecated method name)
constexpr int NUM_LAYERS_2SL
Definition: constants.h:254
dtbayesam::DTPatternPtrs L1L2Patterns_[4][3]
void setSuperLayerId(int lay)
Definition: DTprimitive.h:26
std::vector< DTPrimitive > digisinL7_
dtbayesam::DTPatternPtrs L5L7Patterns_[4][3]
void initialise(const edm::EventSetup &iEventSetup) override
std::unique_ptr< dtbayesam::CandidateGroupPtrs > prelimMatches_
int sector() const
Definition: DTChamberId.h:49
void setCameraId(int camera)
Definition: DTprimitive.h:25
dtbayesam::DTPatternPtrs L4L5Patterns_[4][3]
static unsigned int const shift
dtbayesam::DTPatternPtrs L1L5Patterns_[4][3]
dtbayesam::DTPatternPtrs L0L3Patterns_[4][3]
dtbayesam::DTPatternPtrs L0L6Patterns_[4][3]
int station() const
Return the station number.
Definition: DTChamberId.h:42
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
dtbayesam::DTPatternPtrs L0L5Patterns_[4][3]
void RecognisePatterns(std::vector< DTPrimitive > digisinLDown, std::vector< DTPrimitive > digisinLUp, dtbayesam::DTPatternPtrs patterns)
std::unique_ptr< dtbayesam::CandidateGroupPtrs > finalMatches_
void run(edm::Event &iEvent, const edm::EventSetup &iEventSetup, const DTDigiCollection &digis, MuonPathPtrs &outMpath) override
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
dtbayesam::DTPatternPtrs L1L6Patterns_[4][3]
dtbayesam::DTPatternPtrs L3L5Patterns_[4][3]
#define LogDebug(id)
dtbayesam::DTPatternPtrs L5L6Patterns_[4][3]