13 using namespace cmsdt;
14 using namespace dtbayesam;
34 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping:: constructor";
39 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping:: destructor";
47 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::initialiase";
52 TString patterns_folder =
"L1Trigger/DTTriggerPhase2/data/";
56 LoadPattern(patterns_folder +
"createdPatterns_MB1_left.root", 0, 0);
57 LoadPattern(patterns_folder +
"createdPatterns_MB1_right.root", 0, 2);
59 LoadPattern(patterns_folder +
"createdPatterns_MB2_left.root", 1, 0);
60 LoadPattern(patterns_folder +
"createdPatterns_MB2_right.root", 1, 2);
62 LoadPattern(patterns_folder +
"createdPatterns_MB3.root", 2, 1);
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);
69 allMatches_ = std::make_unique<CandidateGroupPtrs>();
74 TFile*
f = TFile::Open(pattern_file_name,
"READ");
76 std::vector<std::vector<std::vector<int>>>* pattern_reader =
77 (std::vector<std::vector<std::vector<int>>>*)f->Get(
"allPatterns");
80 itPattern != (*pattern_reader).end();
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) <<
", ";
87 auto p = std::make_shared<DTPattern>();
90 for (
const auto& itHits : *itPattern) {
93 p = std::make_shared<DTPattern>(
DTPattern(itHits.at(0), itHits.at(1), itHits.at(2)));
98 if (itHits.begin() == itHits.end())
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)));
187 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::initialiase Total number of loaded patterns: "
199 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run";
210 for (
const auto& detUnitIt : digis) {
211 const DTLayerId layer_Id = detUnitIt.first;
221 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run Pattern qualities before cleaning: ";
223 LogDebug(
"PseudoBayesGrouping") << cand_it->nLayerhits() <<
", " << cand_it->nisGood() <<
", " << cand_it->nhits()
224 <<
", " << cand_it->quality() <<
", " << cand_it->candId();
230 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run Number of found patterns: " <<
finalMatches_->size();
235 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run ended run";
242 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run Create pointers ";
245 std::vector<DTPrimitivePtrs> ptrPrimitive_vector;
249 for (
int i = 0;
i < 8;
i++)
250 ptrPrimitive.push_back(std::make_shared<DTPrimitive>());
252 ptrPrimitive_vector.push_back(ptrPrimitive);
259 for (
auto& itDTP : (*itCand)->candHits()) {
261 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run loop over dt hits to fill pointer";
263 int layerHit = (*itDTP).layerId();
266 (*itDTP).setLayerId(layerHit - 4);
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);
284 if (qualityDTP == (qualityDTP | ref8Hit) && qualityDTP2 != (qualityDTP2 | ref8Hit) &&
287 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run Creating additional muon paths";
289 qualityDTP2 = (qualityDTP2 | ref8Hit);
291 int n_prim = ptrPrimitive_vector.size();
293 for (
int j = 0;
j < n_prim;
j++) {
296 tmpPrimitive.push_back(ptrPrimitive_vector.at(
j).at(
i));
301 tmpPrimitive.at(layerHit) = std::make_shared<DTPrimitive>((*itDTP));
305 tmpPrimitive.at(intHit) = std::make_shared<DTPrimitive>((*itDTP));
308 ptrPrimitive_vector.push_back(tmpPrimitive);
315 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run Adding hit to muon path";
317 qualityDTP = (qualityDTP | ref8Hit);
320 for (
auto prim_it = ptrPrimitive_vector.begin(); prim_it != ptrPrimitive_vector.end(); ++prim_it) {
323 prim_it->at(layerHit) = std::make_shared<DTPrimitive>((*itDTP));
328 prim_it->at(intHit) = std::make_shared<DTPrimitive>((*itDTP));
336 int n_paths = ptrPrimitive_vector.size();
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()));
347 int MB = chamber_ID.
station() - 1;
348 int wheel = chamber_ID.
wheel();
349 int sector = chamber_ID.
sector();
358 if (wheel == -1 || wheel == -2)
360 else if (wheel == 1 || wheel == 2)
362 else if (wheel == 0) {
363 if (sector == 1 || sector == 4 || sector == 5 || sector == 8 || sector == 9 || sector == 12)
371 if (wheel == -1 || wheel == -2)
373 else if (wheel == 1 || wheel == 2)
375 else if (wheel == 0) {
376 if (sector == 1 || sector == 4 || sector == 5 || sector == 8 || sector == 9 || sector == 12)
388 if (wheel == -1 || wheel == -2)
389 if (sector == 4 || sector == 9 || sector == 11 || sector == 13)
391 else if (sector == 5 || sector == 6 || sector == 7 || sector == 8 || sector == 14)
395 else if (wheel == 1 || wheel == 2)
396 if (sector == 4 || sector == 9 || sector == 11 || sector == 13)
398 else if (sector == 1 || sector == 2 || sector == 3 || sector == 10 || sector == 12)
403 if (sector == 4 || sector == 9 || sector == 11 || sector == 13)
405 else if (sector == 2 || sector == 3 || sector == 5 || sector == 8 || sector == 10)
455 std::vector<DTPrimitive> digisinLUp,
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++) {
468 if ((*pat_it)->sl1() != (LDown) || (*pat_it)->sl2() != (LUp) || (*pat_it)->diff() !=
diff)
471 (*pat_it)->setHitDown(wireDown);
472 auto cand = std::make_shared<CandidateGroup>(*pat_it);
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);
479 cand->addHit((*dtTest_it), dtTest_it->layerId(),
true);
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"
496 cand->setCandId(
pidx_);
508 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::FillDigisByLayer Classifying digis by layer";
510 for (
const auto& dtDigi_It : *digis) {
513 for (
auto digiIt = (dtDigi_It.second).first; digiIt != (dtDigi_It.second).second; digiIt++) {
528 LogDebug(
"PseudoBayesGrouping") <<
"Hit in L " << layer <<
" SL " << dtLId.
superlayer() <<
" WIRE "
529 << digiIt->wire() - 1;
573 for (
const auto& dt_it : (*itSel)->candHits()) {
574 (*cand_it)->removeHit((*dt_it));
580 LogDebug(
"PseudoBayesGrouping") <<
"Pattern qualities: ";
582 LogDebug(
"PseudoBayesGrouping") << cand_it->nLayerhits() <<
", " << cand_it->nisGood() <<
", "
583 << cand_it->nhits() <<
", " << cand_it->quality() <<
", " << cand_it->candId()
607 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping: finish";
PseudoBayesGrouping(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
std::vector< DTPrimitivePtr > DTPrimitivePtrs
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]
~PseudoBayesGrouping() override
DTChamberId chamberId() const
Return the corresponding ChamberId.
void setLayerId(int layer)
std::vector< MuonPathPtr > MuonPathPtrs
void LoadPattern(TString pattern_file_name, int MB_number_input, int SL_shift)
constexpr uint32_t rawId() const
get the raw id
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.
void RecognisePatternsByLayerPairs(DTChamberId chamber_ID)
bool allowUncorrelatedPatterns_
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
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)
void setTDCTimeStamp(int tstamp)
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]
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)
std::string pattern_filename_
void ReCleanPatternsAndDigis()
constexpr int NUM_LAYERS_2SL
dtbayesam::DTPatternPtrs L1L2Patterns_[4][3]
void setSuperLayerId(int lay)
std::vector< DTPrimitive > digisinL7_
dtbayesam::DTPatternPtrs L5L7Patterns_[4][3]
void initialise(const edm::EventSetup &iEventSetup) override
std::unique_ptr< dtbayesam::CandidateGroupPtrs > prelimMatches_
void setCameraId(int camera)
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.
int wheel() const
Return the wheel number.
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)
dtbayesam::DTPatternPtrs L1L6Patterns_[4][3]
dtbayesam::DTPatternPtrs L3L5Patterns_[4][3]
dtbayesam::DTPatternPtrs L5L6Patterns_[4][3]