13 using namespace cmsdt;
20 debug_(
pset.getUntrackedParameter<
bool>(
"debug")),
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")) {
33 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping:: constructor";
38 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping:: destructor";
46 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::initialiase";
51 TString patterns_folder =
"L1Trigger/DTTriggerPhase2/data/";
55 LoadPattern(patterns_folder +
"createdPatterns_MB1_left.root", 0, 0);
56 LoadPattern(patterns_folder +
"createdPatterns_MB1_right.root", 0, 2);
58 LoadPattern(patterns_folder +
"createdPatterns_MB2_left.root", 1, 0);
59 LoadPattern(patterns_folder +
"createdPatterns_MB2_right.root", 1, 2);
61 LoadPattern(patterns_folder +
"createdPatterns_MB3.root", 2, 1);
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);
68 allMatches_ = std::make_unique<CandidateGroupPtrs>();
73 TFile*
f = TFile::Open(pattern_file_name,
"READ");
75 std::vector<std::vector<std::vector<int>>>* pattern_reader =
76 (std::vector<std::vector<std::vector<int>>>*)
f->Get(
"allPatterns");
79 itPattern != (*pattern_reader).end();
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) <<
", ";
86 auto p = std::make_shared<DTPattern>();
89 for (
const auto& itHits : *itPattern) {
92 p = std::make_shared<DTPattern>(
DTPattern(itHits.at(0), itHits.at(1), itHits.at(2)));
97 if (itHits.begin() == itHits.end())
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)));
186 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::initialiase Total number of loaded patterns: " 198 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run";
209 for (
const auto& detUnitIt : digis) {
210 const DTLayerId layer_Id = detUnitIt.first;
220 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run Pattern qualities before cleaning: ";
222 LogDebug(
"PseudoBayesGrouping") << cand_it->nLayerhits() <<
", " << cand_it->nisGood() <<
", " << cand_it->nhits()
223 <<
", " << cand_it->quality() <<
", " << cand_it->candId();
229 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run Number of found patterns: " <<
finalMatches_->size();
234 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run ended run";
241 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run Create pointers ";
244 std::vector<DTPrimitivePtrs> ptrPrimitive_vector;
248 for (
int i = 0;
i < 8;
i++)
249 ptrPrimitive.push_back(std::make_shared<DTPrimitive>());
251 ptrPrimitive_vector.push_back(ptrPrimitive);
258 for (
auto& itDTP : (*itCand)->candHits()) {
260 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run loop over dt hits to fill pointer";
262 int layerHit = (*itDTP).layerId();
265 (*itDTP).setLayerId(layerHit - 4);
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);
283 if (qualityDTP == (qualityDTP | ref8Hit) && qualityDTP2 != (qualityDTP2 | ref8Hit) &&
286 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run Creating additional muon paths";
288 qualityDTP2 = (qualityDTP2 | ref8Hit);
290 int n_prim = ptrPrimitive_vector.size();
292 for (
int j = 0;
j < n_prim;
j++) {
295 tmpPrimitive.push_back(ptrPrimitive_vector.at(
j).at(
i));
300 tmpPrimitive.at(layerHit) = std::make_shared<DTPrimitive>((*itDTP));
304 tmpPrimitive.at(intHit) = std::make_shared<DTPrimitive>((*itDTP));
307 ptrPrimitive_vector.push_back(tmpPrimitive);
314 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::run Adding hit to muon path";
316 qualityDTP = (qualityDTP | ref8Hit);
319 for (
auto prim_it = ptrPrimitive_vector.begin(); prim_it != ptrPrimitive_vector.end(); ++prim_it) {
322 prim_it->at(layerHit) = std::make_shared<DTPrimitive>((*itDTP));
327 prim_it->at(intHit) = std::make_shared<DTPrimitive>((*itDTP));
335 int n_paths = ptrPrimitive_vector.size();
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()));
346 int MB = chamber_ID.
station() - 1;
361 else if (
wheel == 0) {
374 else if (
wheel == 0) {
454 std::vector<DTPrimitive> digisinLUp,
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++) {
467 if ((*pat_it)->sl1() != (LDown) || (*pat_it)->sl2() != (LUp) || (*pat_it)->diff() !=
diff)
470 (*pat_it)->setHitDown(wireDown);
471 auto cand = std::make_shared<CandidateGroup>(*pat_it);
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);
478 cand->addHit((*dtTest_it), dtTest_it->layerId(),
true);
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" 507 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping::FillDigisByLayer Classifying digis by layer";
509 for (
const auto& dtDigi_It : *digis) {
512 for (
auto digiIt = (dtDigi_It.second).first; digiIt != (dtDigi_It.second).second; digiIt++) {
528 << digiIt->wire() - 1;
572 for (
const auto& dt_it : (*itSel)->candHits()) {
573 (*cand_it)->removeHit((*dt_it));
579 LogDebug(
"PseudoBayesGrouping") <<
"Pattern qualities: ";
581 LogDebug(
"PseudoBayesGrouping") << cand_it->nLayerhits() <<
", " << cand_it->nisGood() <<
", " 582 << cand_it->nhits() <<
", " << cand_it->quality() <<
", " << cand_it->candId()
606 LogDebug(
"PseudoBayesGrouping") <<
"PseudoBayesGrouping: finish";
PseudoBayesGrouping(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
std::vector< DTPrimitivePtr > DTPrimitivePtrs
int station() const
Return the station number.
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]
~PseudoBayesGrouping() override
void setLayerId(int layer)
std::vector< MuonPathPtr > MuonPathPtrs
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]
std::bitset< 8 > qualitybits
std::unique_ptr< dtbayesam::CandidateGroupPtrs > allMatches_
void RecognisePatternsByLayerPairs(DTChamberId chamber_ID)
bool allowUncorrelatedPatterns_
std::vector< DTPrimitive > digisinL6_
dtbayesam::DTPatternPtrs L3L7Patterns_[4][3]
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_
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]
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_
constexpr uint32_t rawId() const
get the raw id
void ReCleanPatternsAndDigis()
constexpr int NUM_LAYERS_2SL
dtbayesam::DTPatternPtrs L1L2Patterns_[4][3]
void setSuperLayerId(int lay)
std::vector< DTPrimitive > digisinL7_
int layer() const
Return the layer number.
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
int wheel() const
Return the wheel number.
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]
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
dtbayesam::DTPatternPtrs L0L6Patterns_[4][3]
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
dtbayesam::DTPatternPtrs L1L6Patterns_[4][3]
dtbayesam::DTPatternPtrs L3L5Patterns_[4][3]
dtbayesam::DTPatternPtrs L5L6Patterns_[4][3]