CMS 3D CMS Logo

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