From 57ac71242db10e1a0bae7c53e335462a776a2d6c Mon Sep 17 00:00:00 2001 From: Javier Date: Mon, 22 Jul 2024 16:43:22 +0200 Subject: [PATCH 01/19] First version of Theta-Phi matching --- .../interface/MPThetaMatching.h | 70 ++++++++ .../DTTriggerPhase2/src/MPThetaMatching.cc | 166 ++++++++++++++++++ 2 files changed, 236 insertions(+) create mode 100644 L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h create mode 100644 L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc diff --git a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h new file mode 100644 index 0000000000000..9a42cb0803995 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h @@ -0,0 +1,70 @@ +#ifndef Phase2L1Trigger_DTTrigger_MPThetaMatching_h +#define Phase2L1Trigger_DTTrigger_MPThetaMatching_h + +#include "L1Trigger/DTTriggerPhase2/interface/MPFilter.h" + +#include +#include + +// =============================================================================== +// Previous definitions and declarations +// =============================================================================== + +// =============================================================================== +// Class declarations +// =============================================================================== + + +class MPThetaMatching : public MPFilter { +public: + // Constructors and destructor + MPThetaMatching(const edm::ParameterSet &pset); + ~MPThetaMatching() override = default; + + // Main methods + void initialise(const edm::EventSetup &iEventSetup) override; + void run(edm::Event &iEvent, + const edm::EventSetup &iEventSetup, + std::vector &inMPaths, + std::vector &outMPaths) override; + void run(edm::Event &iEvent, + const edm::EventSetup &iEventSetup, + MuonPathPtrs &inMPath, + MuonPathPtrs &outMPath) override{}; + + void finish() override; + + // Other public methods + + // Public attributes + + float vwire = 24.4 ; // cm/ns +// float zFE[5] = {-654., -389., 123., 389., 654.}; //cm +// float xFE[3] = {199/2., 245/2., 303/2.};//cm + float zFE[5] = {-658.9, -393.3, 126.4, 393.3, 658.9}; //cm + float xFE[3] = {218/2., 266.8/2., 315/2.};//cm + float ZRES_CONV = 65536. / 1500; + +private: + // Private methods + std::vector filter(std::vector inMPs, + int th_option, + int th_quality, + double shift_back); + + bool isThereThetaMPInChamber(int sector,int wheel,int station,std::vector thetaMPs); + // Lambda function to compare pairs based on the float value, ascending order + static bool compare(const std::pair& a, const std::pair& b) { + return a.second < b.second; + }; + + // Private attributes + const bool debug_; + int th_option_; + int th_quality_; + int scenario_; + + +}; + +#endif diff --git a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc new file mode 100644 index 0000000000000..a7140b279ed64 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc @@ -0,0 +1,166 @@ +#include "L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "L1Trigger/DTTriggerPhase2/interface/constants.h" + +using namespace edm; +using namespace std; +using namespace cmsdt; + +// ============================================================================ +// Constructors and destructor +// ============================================================================ +MPThetaMatching::MPThetaMatching(const ParameterSet &pset) + : MPFilter(pset), debug_(pset.getUntrackedParameter("debug")), + th_option_(pset.getParameter("th_option")), + th_quality_(pset.getParameter("th_quality")), + scenario_(pset.getParameter("scenario")) {} + +// ============================================================================ +// Main methods (initialise, run, finish) +// ============================================================================ +void MPThetaMatching::initialise(const edm::EventSetup &iEventSetup) {} + +void MPThetaMatching::run(edm::Event &iEvent, + const edm::EventSetup &iEventSetup, + std::vector &inMPaths, + std::vector &outMPaths) { + + if (debug_) + LogDebug("MPThetaMatching") << "MPThetaMatching: run"; + + double shift_back = 0; // Needed for t0 (TDC) calculation, taken from main algo + if (scenario_ == MC) shift_back = 400; + else if (scenario_ == DATA) shift_back = 0; + else if (scenario_ == SLICE_TEST) shift_back = 400; + + auto filteredMPs = filter(inMPaths, th_option_, th_quality_, shift_back); + for (auto &mp : filteredMPs) + outMPaths.push_back(mp); + +} + +void MPThetaMatching::finish(){}; + +/////////////////////////// +/// OTHER METHODS + +std::vector MPThetaMatching::filter(std::vector inMPs, + int th_option, int th_quality, double shift_back) { + std::vector outMPs; + std::vector thetaMPs; + std::vector phiMPs; + + //survey theta and phi MPs + for (auto & mp: inMPs) { + + DTChamberId chId(mp.rawId); + DTSuperLayerId slId(mp.rawId); + + if(slId.superLayer() == 2) thetaMPs.push_back(mp); + else phiMPs.push_back(mp); + } + + // Loop on phi, save those at station without Theta MPs + for (auto & mp: phiMPs) { + + DTChamberId chId(mp.rawId); + DTSuperLayerId slId(mp.rawId); + + int sector = chId.sector(); + int wheel = chId.wheel(); + int station = chId.station(); + + if (station == 4) {outMPs.push_back(mp); //No theta matching for MB4, save MP + continue;} + + if(!isThereThetaMPInChamber(sector,wheel,station,thetaMPs) ) {outMPs.push_back(mp); // No theta MPs in chamber to match, save MP + continue;} + } + + + // Loop on theta + for (auto & mp1: thetaMPs) { + std::vector> deltaTimePosPhiCands; + + DTChamberId chId(mp1.rawId); + DTSuperLayerId slId(mp1.rawId); + + int sector = chId.sector(); + int wheel = chId.wheel(); + int station = chId.station(); + + if (station == 4) { LogDebug("MPThetaMatching") << "MPThetaMatching: station 4 does NOT have Theta SL 2"; + continue;} + +// float t0 = (mp1.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); + float t0 = ((int)round(mp1.t0 / (float)LHC_CLK_FREQ)) - shift_back; + float posRefZ = zFE[wheel+2]; + if(wheel==0 && (sector ==1 || sector==4 || sector==5 || sector==8 || sector==9 ||sector==12)) posRefZ = -posRefZ; + float posZ = abs(mp1.phi); //??? + + for (auto & mp2: phiMPs) { + + DTChamberId chId2(mp2.rawId); + DTSuperLayerId slId2(mp2.rawId); + + //if (co_option==1 && PhiMP2==0) continue; // Phi Only + //else if (co_option==2 && PhiMP2==1) continue; // Theta Only + + int sector2 = chId2.sector(); + int wheel2 = chId2.wheel(); + int station2 = chId2.station(); + if (station2 == 4) continue; + + if(station2 != station || sector2 != sector || wheel2 != wheel) continue; + + if ((mp2.quality > th_quality)) {outMPs.push_back(mp2); //don't do theta matching for q > X, save + continue; + } + +// float t02 = (mp2.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); + float t02 = ((int)round(mp2.t0 / (float)LHC_CLK_FREQ)) - shift_back; + + //cout<<"posRefZ: "<0) LR = pow(-1,wheel+sector+1); + else if (wheel<0) LR = pow(-1,-wheel+sector); + //cout<<"wh st se: "<< wheel <<" "<< station <<" "<< sector <<" LR: "<< LR<& p : deltaTimePosPhiCands){ //save up to nth nearest Phi candidate + if(count thetaMPs){ + for (auto & mp1: thetaMPs) { + DTChamberId chId(mp1.rawId); + DTSuperLayerId slId(mp1.rawId); + + int sector = chId.sector(); + int wheel = chId.wheel(); + int station = chId.station(); + if (sector==sector2 && wheel == wheel2 && station==station2) return true; +} + return false; +}; + From 34914574bbe7a9c994d3bdfed8b757ddcdb30252 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 26 Jul 2024 18:07:38 +0200 Subject: [PATCH 02/19] Debugged version with Theta selection q=3 --- .../interface/MPThetaMatching.h | 41 +-- .../plugins/DTTrigPhase2Prod.cc | 39 ++- .../dtTriggerPhase2PrimitiveDigis_cfi.py | 2 + .../DTTriggerPhase2/src/MPThetaMatching.cc | 293 +++++++++++------- 4 files changed, 240 insertions(+), 135 deletions(-) diff --git a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h index 9a42cb0803995..ef916fb8138c0 100644 --- a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h +++ b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h @@ -14,7 +14,6 @@ // Class declarations // =============================================================================== - class MPThetaMatching : public MPFilter { public: // Constructors and destructor @@ -27,6 +26,11 @@ class MPThetaMatching : public MPFilter { const edm::EventSetup &iEventSetup, std::vector &inMPaths, std::vector &outMPaths) override; + void run(edm::Event &iEvent, + const edm::EventSetup &iEventSetup, + std::vector &allMPaths, + std::vector &inMPaths, + std::vector &outMPaths) override{}; void run(edm::Event &iEvent, const edm::EventSetup &iEventSetup, MuonPathPtrs &inMPath, @@ -38,33 +42,34 @@ class MPThetaMatching : public MPFilter { // Public attributes - float vwire = 24.4 ; // cm/ns -// float zFE[5] = {-654., -389., 123., 389., 654.}; //cm -// float xFE[3] = {199/2., 245/2., 303/2.};//cm - float zFE[5] = {-658.9, -393.3, 126.4, 393.3, 658.9}; //cm - float xFE[3] = {218/2., 266.8/2., 315/2.};//cm - float ZRES_CONV = 65536. / 1500; + float vwire = 24.4; // cm/ns + // float zFE[5] = {-654., -389., 123., 389., 654.}; //cm + // float xFE[3] = {199/2., 245/2., 303/2.};//cm + float zFE[5] = {-658.9, -393.3, 126.4, 393.3, 658.9}; //cm + float xFE[3] = {218 / 2., 266.8 / 2., 315 / 2.}; //cm + float ZRES_CONV = 65536. / 1500; private: // Private methods std::vector filter(std::vector inMPs, - int th_option, - int th_quality, - double shift_back); + int th_option, + int th_quality, + double shift_back); + + bool isThereThetaMPInChamber(int sector, int wheel, int station, std::vector thetaMPs); + std::vector getBestThetaMPInChamber(std::vector thetaMPs); - bool isThereThetaMPInChamber(int sector,int wheel,int station,std::vector thetaMPs); - // Lambda function to compare pairs based on the float value, ascending order - static bool compare(const std::pair& a, const std::pair& b) { - return a.second < b.second; - }; + // Function to compare pairs based on the float value, ascending order + static bool compare(const std::pair &a, + const std::pair &b) { + return a.second < b.second; + }; // Private attributes const bool debug_; int th_option_; - int th_quality_; + int th_quality_; int scenario_; - - }; #endif diff --git a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc index ef83fce3a665a..b6d67b5cbc28f 100644 --- a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc +++ b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc @@ -40,6 +40,7 @@ #include "L1Trigger/DTTriggerPhase2/interface/MPSLFilter.h" #include "L1Trigger/DTTriggerPhase2/interface/MPCorFilter.h" #include "L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h" +#include "L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h" #include "L1Trigger/DTTriggerPhase2/interface/MPQualityEnhancerFilter.h" #include "L1Trigger/DTTriggerPhase2/interface/MPRedundantFilter.h" #include "L1Trigger/DTTriggerPhase2/interface/MPCleanHitsFilter.h" @@ -138,6 +139,8 @@ class DTTrigPhase2Prod : public edm::stream::EDProducer<> { int df_extended_; int co_option_; //coincidence int co_quality_; + int th_option_; //theta matching + int th_quality_; int max_index_; bool output_mixer_; @@ -166,6 +169,7 @@ class DTTrigPhase2Prod : public edm::stream::EDProducer<> { std::unique_ptr mpathconfirmator_; std::unique_ptr mpathcorfilter_; std::unique_ptr mpathcoifilter_; + std::unique_ptr mpaththetamatching_; std::shared_ptr globalcoordsobtainer_; // Buffering @@ -210,6 +214,8 @@ DTTrigPhase2Prod::DTTrigPhase2Prod(const ParameterSet& pset) df_extended_ = pset.getParameter("df_extended"); co_option_ = pset.getParameter("co_option"); co_quality_ = pset.getParameter("co_quality"); + th_option_ = pset.getParameter("th_option"); + th_quality_ = pset.getParameter("th_quality"); max_index_ = pset.getParameter("max_primitives") - 1; dtDigisToken_ = consumes(pset.getParameter("digiTag")); @@ -268,6 +274,7 @@ DTTrigPhase2Prod::DTTrigPhase2Prod(const ParameterSet& pset) mpathassociator_ = std::make_unique(pset, consumesColl, globalcoordsobtainer_); mpathcorfilter_ = std::make_unique(pset); mpathcoifilter_ = std::make_unique(pset); + mpaththetamatching_ = std::make_unique(pset); rpc_integrator_ = std::make_unique(pset, consumesColl); dtGeomH = esConsumes(); @@ -293,6 +300,7 @@ void DTTrigPhase2Prod::beginRun(edm::Run const& iRun, const edm::EventSetup& iEv mpathassociator_->initialise(iEventSetup); // Associator object initialisation mpathcorfilter_->initialise(iEventSetup); mpathcoifilter_->initialise(iEventSetup); + mpaththetamatching_->initialise(iEventSetup); if (auto geom = iEventSetup.getHandle(dtGeomH)) { dtGeo_ = &(*geom); @@ -854,6 +862,23 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) { allMetaPrimitives.clear(); + // Theta (th) matching filter + std::map> thMatchedMetaPrimitives; + if (algo_ == Standard) { + for (auto& ch_filtcoMetaPrimitives : coMetaPrimitives) { + if (!skip_processing_) + mpaththetamatching_->run(iEvent, + iEventSetup, + coMetaPrimitives[ch_filtcoMetaPrimitives.first], + thMatchedMetaPrimitives[ch_filtcoMetaPrimitives.first]); + else { + for (auto& mp : ch_filtcoMetaPrimitives.second) { + thMatchedMetaPrimitives[ch_filtcoMetaPrimitives.first].push_back(mp); + } + } + } + } + ///////////// double shift_back = 0; @@ -868,8 +893,8 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) { if (useRPC_) { rpc_integrator_->initialise(iEventSetup, shift_back); rpc_integrator_->prepareMetaPrimitives(rpcRecHits); - for (auto& ch_correlatedMetaPrimitives : coMetaPrimitives) { - rpc_integrator_->matchWithDTAndUseRPCTime(ch_correlatedMetaPrimitives.second); // Probably this is a FIXME + for (auto& ch_thMatchedMetaPrimitives : thMatchedMetaPrimitives) { + rpc_integrator_->matchWithDTAndUseRPCTime(ch_thMatchedMetaPrimitives.second); // Probably this is a FIXME } rpc_integrator_->makeRPCOnlySegments(); rpc_integrator_->storeRPCSingleHits(); @@ -884,12 +909,12 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) { // Assigning index value if (!skip_processing_) - for (auto& ch_correlatedMetaPrimitives : coMetaPrimitives) { - assignIndex(ch_correlatedMetaPrimitives.second); + for (auto& ch_thMatchedMetaPrimitives : thMatchedMetaPrimitives) { + assignIndex(ch_thMatchedMetaPrimitives.second); } - for (auto& ch_correlatedMetaPrimitives : coMetaPrimitives) { - for (const auto& metaPrimitiveIt : ch_correlatedMetaPrimitives.second) { + for (auto& ch_thMatchedMetaPrimitives : thMatchedMetaPrimitives) { + for (const auto& metaPrimitiveIt : ch_thMatchedMetaPrimitives.second) { DTChamberId chId(metaPrimitiveIt.rawId); DTSuperLayerId slId(metaPrimitiveIt.rawId); if (debug_) @@ -1293,6 +1318,8 @@ void DTTrigPhase2Prod::fillDescriptions(edm::ConfigurationDescriptions& descript desc.add("df_extended", 0); desc.add("co_option", 0); desc.add("co_quality", 0); + desc.add("th_option", 0); + desc.add("th_quality", 0); desc.add("max_primitives", 999); desc.add("output_mixer", false); desc.add("output_latpredictor", false); diff --git a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py index aa10705bbfd3a..3b66ed44d5de0 100644 --- a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py +++ b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py @@ -25,6 +25,8 @@ df_extended = cms.int32(0), # DF: 0 for standard, 1 for extended, 2 for both co_option = cms.int32(1), # coincidence w.r.t. : -1 = off, 0 = co all, 1 = co phi, 2 = co theta co_quality = cms.int32(1), # quality cut (>X) for coincidence TP + th_option = cms.int32(1), # save 1st, 2nd, 3rd,... closest phi TP to theta TP. 0 disables filtering, i.e. saves all + th_quality = cms.int32(5), # quality cut (>X) for Theta matching: Phi TPs above this quality are not filtered max_primitives = cms.int32(999), output_mixer = cms.bool(False), diff --git a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc index a7140b279ed64..32379a92aae0d 100644 --- a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc +++ b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc @@ -10,10 +10,11 @@ using namespace cmsdt; // Constructors and destructor // ============================================================================ MPThetaMatching::MPThetaMatching(const ParameterSet &pset) - : MPFilter(pset), debug_(pset.getUntrackedParameter("debug")), - th_option_(pset.getParameter("th_option")), - th_quality_(pset.getParameter("th_quality")), - scenario_(pset.getParameter("scenario")) {} + : MPFilter(pset), + debug_(pset.getUntrackedParameter("debug")), + th_option_(pset.getParameter("th_option")), + th_quality_(pset.getParameter("th_quality")), + scenario_(pset.getParameter("scenario")) {} // ============================================================================ // Main methods (initialise, run, finish) @@ -21,22 +22,26 @@ MPThetaMatching::MPThetaMatching(const ParameterSet &pset) void MPThetaMatching::initialise(const edm::EventSetup &iEventSetup) {} void MPThetaMatching::run(edm::Event &iEvent, - const edm::EventSetup &iEventSetup, - std::vector &inMPaths, - std::vector &outMPaths) { - + const edm::EventSetup &iEventSetup, + std::vector &inMPaths, + std::vector &outMPaths) { if (debug_) LogDebug("MPThetaMatching") << "MPThetaMatching: run"; - - double shift_back = 0; // Needed for t0 (TDC) calculation, taken from main algo - if (scenario_ == MC) shift_back = 400; - else if (scenario_ == DATA) shift_back = 0; - else if (scenario_ == SLICE_TEST) shift_back = 400; + + double shift_back = 0; // Needed for t0 (TDC) calculation, taken from main algo + if (scenario_ == MC) + shift_back = 400; + else if (scenario_ == DATA) + shift_back = 0; + else if (scenario_ == SLICE_TEST) + shift_back = 400; auto filteredMPs = filter(inMPaths, th_option_, th_quality_, shift_back); for (auto &mp : filteredMPs) outMPaths.push_back(mp); - + + cout<<"Before filter #TPs:" << inMPaths.size()<<" after: "< MPThetaMatching::filter(std::vector inMPs, - int th_option, int th_quality, double shift_back) { +std::vector MPThetaMatching::filter(std::vector inMPs, + int th_option, + int th_quality, + double shift_back) { std::vector outMPs; std::vector thetaMPs; std::vector phiMPs; //survey theta and phi MPs - for (auto & mp: inMPs) { - - DTChamberId chId(mp.rawId); - DTSuperLayerId slId(mp.rawId); - - if(slId.superLayer() == 2) thetaMPs.push_back(mp); - else phiMPs.push_back(mp); + for (auto &mp : inMPs) { + DTChamberId chId(mp.rawId); + DTSuperLayerId slId(mp.rawId); + + if (slId.superLayer() == 2) + thetaMPs.push_back(mp); + else + phiMPs.push_back(mp); } - // Loop on phi, save those at station without Theta MPs - for (auto & mp: phiMPs) { - - DTChamberId chId(mp.rawId); - DTSuperLayerId slId(mp.rawId); + cout<<"Before #TPs Theta: "<> deltaTimePosPhiCands; + for (auto &mp1 : thetaMPs) { + std::vector> deltaTimePosPhiCands; - DTChamberId chId(mp1.rawId); - DTSuperLayerId slId(mp1.rawId); + DTChamberId chId(mp1.rawId); + DTSuperLayerId slId(mp1.rawId); - int sector = chId.sector(); - int wheel = chId.wheel(); - int station = chId.station(); - - if (station == 4) { LogDebug("MPThetaMatching") << "MPThetaMatching: station 4 does NOT have Theta SL 2"; - continue;} + int sector = chId.sector(); + int wheel = chId.wheel(); + int station = chId.station(); -// float t0 = (mp1.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); + if (station == 4) { + LogDebug("MPThetaMatching") << "MPThetaMatching: station 4 does NOT have Theta SL 2"; + continue; + } + + // float t0 = (mp1.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); float t0 = ((int)round(mp1.t0 / (float)LHC_CLK_FREQ)) - shift_back; - float posRefZ = zFE[wheel+2]; - if(wheel==0 && (sector ==1 || sector==4 || sector==5 || sector==8 || sector==9 ||sector==12)) posRefZ = -posRefZ; - float posZ = abs(mp1.phi); //??? - - for (auto & mp2: phiMPs) { - - DTChamberId chId2(mp2.rawId); - DTSuperLayerId slId2(mp2.rawId); - - //if (co_option==1 && PhiMP2==0) continue; // Phi Only - //else if (co_option==2 && PhiMP2==1) continue; // Theta Only - - int sector2 = chId2.sector(); - int wheel2 = chId2.wheel(); - int station2 = chId2.station(); - if (station2 == 4) continue; - - if(station2 != station || sector2 != sector || wheel2 != wheel) continue; - - if ((mp2.quality > th_quality)) {outMPs.push_back(mp2); //don't do theta matching for q > X, save - continue; - } - -// float t02 = (mp2.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); - float t02 = ((int)round(mp2.t0 / (float)LHC_CLK_FREQ)) - shift_back; - - //cout<<"posRefZ: "<0) LR = pow(-1,wheel+sector+1); - else if (wheel<0) LR = pow(-1,-wheel+sector); - //cout<<"wh st se: "<< wheel <<" "<< station <<" "<< sector <<" LR: "<< LR< th_quality)) { + outMPs.push_back(mp2); //don't do theta matching for q > X, save + continue; + } + + // float t02 = (mp2.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); + float t02 = ((int)round(mp2.t0 / (float)LHC_CLK_FREQ)) - shift_back; + + //cout << "posRefZ: " << posRefZ << " Z: " << posZ / ZRES_CONV << endl; + float tphi = t02 - abs(posZ / ZRES_CONV - posRefZ) / vwire; + //cout << "tphi: " << tphi << endl; + + int LR = -1; + if (wheel == 0 && (sector == 3 || sector == 4 || sector == 7 || sector == 8 || sector == 11 || sector == 12)) + LR = +1; + else if (wheel > 0) + LR = pow(-1, wheel + sector + 1); + else if (wheel < 0) + LR = pow(-1, -wheel + sector); + //cout << "wh st se: " << wheel << " " << station << " " << sector << " LR: " << LR << endl; + float posRefX = LR * xFE[station - 1]; + float ttheta = t0 - (mp2.x / 1000 - posRefX) / vwire; + //cout << "posRefX: " << posRefX << " X: " << mp2.x / 1000 << endl; + //cout << "ttheta: " << ttheta << endl; + deltaTimePosPhiCands.push_back({mp2, abs(tphi - ttheta)}); + + } //loop in phis //reorder deltaTimePosPhiCands according to tphi-ttheta distance std::sort(deltaTimePosPhiCands.begin(), deltaTimePosPhiCands.end(), compare); int count = 0; - for (const std::pair& p : deltaTimePosPhiCands){ //save up to nth nearest Phi candidate - if(count &p : deltaTimePosPhiCands) { //save up to nth nearest Phi candidate + cout << "Count: " << count << " abs(tphi-ttheta): " << p.second << endl; + if (count < th_option || th_option == 0) + outMPs.push_back(p.first); + else + break; + count++; + } + } // loop in thetas + + //finally add Theta TPs too + for (auto &mp : thetaMPs) + outMPs.push_back(mp); + + cout<<"After #TPs Theta: "< thetaMPs){ - for (auto & mp1: thetaMPs) { - DTChamberId chId(mp1.rawId); - DTSuperLayerId slId(mp1.rawId); +}; - int sector = chId.sector(); - int wheel = chId.wheel(); - int station = chId.station(); - if (sector==sector2 && wheel == wheel2 && station==station2) return true; -} - return false; +bool MPThetaMatching::isThereThetaMPInChamber(int sector2, + int wheel2, + int station2, + std::vector thetaMPs) { + for (auto &mp1 : thetaMPs) { + DTChamberId chId(mp1.rawId); + DTSuperLayerId slId(mp1.rawId); + + int sector = chId.sector(); + int wheel = chId.wheel(); + int station = chId.station(); + if (sector == sector2 && wheel == wheel2 && station == station2) + return true; + } + return false; }; +std::vector MPThetaMatching::getBestThetaMPInChamber(std::vector thetaMPs) { + std::vector bestThetaMPs; + for (const auto &mp1 : thetaMPs) { + DTChamberId chId1(mp1.rawId); + DTSuperLayerId slId1(mp1.rawId); + + int sector1 = chId1.sector(); + int wheel1 = chId1.wheel(); + int station1 = chId1.station(); + + // Theta TPs (SL2) can be only q=1 (3hits) or q=3 (4 hits) + if(mp1.quality>1) { bestThetaMPs.push_back(mp1); continue;} + + // if q=1 and there is no q=3, save it + for (const auto &mp2: thetaMPs) { + DTChamberId chId2(mp2.rawId); + DTSuperLayerId slId2(mp2.rawId); + + int sector2 = chId2.sector(); + int wheel2 = chId2.wheel(); + int station2 = chId2.station(); + + //if there are more than 1 theta TPs in chamber, use and save only the one with highest quality + if (sector1 == sector2 && wheel1 == wheel2 && station1 == station2) { + if (mp1.quality > mp2.quality) { + continue; //there is a q=3 and it was alreacy saved + } else if (mp2.quality > mp1.quality) { //not likely case unless topological TPs + bestThetaMPs.push_back(mp2); + } + else bestThetaMPs.push_back(mp2); //if there are more than 1 with same q=1, save both + } + } + } + return bestThetaMPs; +}; From 974b39f2ab85d46cde73eda0ff9a4b02d7e0e2c6 Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 25 Sep 2024 17:13:21 +0200 Subject: [PATCH 03/19] First working version of filter, with couts --- .../interface/MPThetaMatching.h | 16 +- .../DTTriggerPhase2/src/MPThetaMatching.cc | 169 +++++++++++++----- 2 files changed, 135 insertions(+), 50 deletions(-) diff --git a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h index ef916fb8138c0..e82ab448ef6bd 100644 --- a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h +++ b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h @@ -30,11 +30,11 @@ class MPThetaMatching : public MPFilter { const edm::EventSetup &iEventSetup, std::vector &allMPaths, std::vector &inMPaths, - std::vector &outMPaths) override{}; + std::vector &outMPaths) override {}; void run(edm::Event &iEvent, const edm::EventSetup &iEventSetup, MuonPathPtrs &inMPath, - MuonPathPtrs &outMPath) override{}; + MuonPathPtrs &outMPath) override {}; void finish() override; @@ -52,18 +52,20 @@ class MPThetaMatching : public MPFilter { private: // Private methods std::vector filter(std::vector inMPs, - int th_option, - int th_quality, +// int th_option, +// int th_quality, double shift_back); bool isThereThetaMPInChamber(int sector, int wheel, int station, std::vector thetaMPs); std::vector getBestThetaMPInChamber(std::vector thetaMPs); // Function to compare pairs based on the float value, ascending order - static bool compare(const std::pair &a, - const std::pair &b) { - return a.second < b.second; + static bool comparePairs(const std::tuple &a, + const std::tuple &b) { + return std::get<2>(a) < std::get<2>(b); }; + void orderAndSave(std::vector> deltaTimePosPhiCands, + std::vector *outMPaths, std::vector *savedThetas); // Private attributes const bool debug_; diff --git a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc index 32379a92aae0d..11384032b5f36 100644 --- a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc +++ b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc @@ -6,6 +6,37 @@ using namespace edm; using namespace std; using namespace cmsdt; +namespace { + struct { + bool operator()(const metaPrimitive &mp1, const metaPrimitive &mp2) const { + DTChamberId chId1(mp1.rawId); + DTSuperLayerId slId1(mp1.rawId); + + int sector1 = chId1.sector(); + int wheel1 = chId1.wheel(); + int station1 = chId1.station(); + + DTChamberId chId2(mp2.rawId); + DTSuperLayerId slId2(mp2.rawId); + + int sector2 = chId2.sector(); + int wheel2 = chId2.wheel(); + int station2 = chId2.station(); + + // First, compare by chamber + if (sector1 != sector2) + return sector1 < sector2; + if (wheel1 != wheel2) + return wheel1 < wheel2; + if (station1 != station2) + return station1 < station2; + + // If they are in the same category, sort by the value (4th index) + return mp1.quality > mp2.quality; + } + } const compareMPs; +} //namespace + // ============================================================================ // Constructors and destructor // ============================================================================ @@ -36,22 +67,19 @@ void MPThetaMatching::run(edm::Event &iEvent, else if (scenario_ == SLICE_TEST) shift_back = 400; - auto filteredMPs = filter(inMPaths, th_option_, th_quality_, shift_back); + auto filteredMPs = filter(inMPaths, shift_back); for (auto &mp : filteredMPs) outMPaths.push_back(mp); - cout<<"Before filter #TPs:" << inMPaths.size()<<" after: "< MPThetaMatching::filter(std::vector inMPs, - int th_option, - int th_quality, double shift_back) { std::vector outMPs; std::vector thetaMPs; @@ -67,11 +95,15 @@ std::vector MPThetaMatching::filter(std::vector in else phiMPs.push_back(mp); } + bool doLog=false; + if(thetaMPs.size()>0 || phiMPs.size()>0) {cout << "Before #TPs Theta: " << thetaMPs.size() << " Phi: " << phiMPs.size() << endl; + doLog=true;} - cout<<"Before #TPs Theta: "< MPThetaMatching::filter(std::vector in outMPs.push_back(mp); // No theta MPs in chamber to match, save MP continue; } + + if ((mp.quality > th_quality_)) + outMPs.push_back(mp); //don't do theta matching for q > X, save } - // Loop on theta - for (auto &mp1 : thetaMPs) { - std::vector> deltaTimePosPhiCands; + // Loop on theta (already ordered) + int oldSector = 0; + int oldStation = 0; + int oldWheel = 0; + std::vector> + deltaTimePosPhiCands; //thetaMP, phiMP, difference in TimePosition + std::vector savedThetaMPs; + for (auto &mp1 : thetaMPs) { DTChamberId chId(mp1.rawId); DTSuperLayerId slId(mp1.rawId); @@ -109,14 +149,24 @@ std::vector MPThetaMatching::filter(std::vector in continue; } + if (sector != oldSector || wheel != oldWheel || station != oldStation) { //new chamber + if (deltaTimePosPhiCands.size() > 0) orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); + + deltaTimePosPhiCands.clear(); + oldSector = sector; + oldWheel = wheel; + oldStation = station; + } + + // float t0 = (mp1.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); float t0 = ((int)round(mp1.t0 / (float)LHC_CLK_FREQ)) - shift_back; float posRefZ = zFE[wheel + 2]; - //cout << "wh st se: " << wheel << " " << station << " " << sector << endl; + if(doLog) cout << "Theta wh se st q t0: " << wheel << " " << sector << " " << station << " " << mp1.quality<< " " << mp1.t0 << endl; if (wheel == 0 && (sector == 1 || sector == 4 || sector == 5 || sector == 8 || sector == 9 || sector == 12)) posRefZ = -posRefZ; - float posZ = abs(mp1.phi); //??? + float posZ = abs(mp1.phi); //cout << "t0: " << t0 << endl; //cout << "posZ: " << posZ << endl; @@ -128,16 +178,17 @@ std::vector MPThetaMatching::filter(std::vector in int sector2 = chId2.sector(); int wheel2 = chId2.wheel(); int station2 = chId2.station(); + if(doLog) cout << "Phi wheel: " << wheel2<< " sector "<< sector2 << " station: " << station2 << " q: " << mp2.quality + << " t0: " << mp2.t0 << endl; + if (station2 == 4) continue; - if (station2 != station || sector2 != sector || wheel2 != wheel) + if ((mp2.quality > th_quality_)) continue; - if ((mp2.quality > th_quality)) { - outMPs.push_back(mp2); //don't do theta matching for q > X, save + if (station2 != station || sector2 != sector || wheel2 != wheel) continue; - } // float t02 = (mp2.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); float t02 = ((int)round(mp2.t0 / (float)LHC_CLK_FREQ)) - shift_back; @@ -154,32 +205,31 @@ std::vector MPThetaMatching::filter(std::vector in else if (wheel < 0) LR = pow(-1, -wheel + sector); //cout << "wh st se: " << wheel << " " << station << " " << sector << " LR: " << LR << endl; + float posRefX = LR * xFE[station - 1]; float ttheta = t0 - (mp2.x / 1000 - posRefX) / vwire; //cout << "posRefX: " << posRefX << " X: " << mp2.x / 1000 << endl; //cout << "ttheta: " << ttheta << endl; - deltaTimePosPhiCands.push_back({mp2, abs(tphi - ttheta)}); + deltaTimePosPhiCands.push_back({mp1, mp2, abs(tphi - ttheta)}); + //cout << "deltaTimePosPhiCands: " << deltaTimePosPhiCands.size() << endl; } //loop in phis - //reorder deltaTimePosPhiCands according to tphi-ttheta distance - std::sort(deltaTimePosPhiCands.begin(), deltaTimePosPhiCands.end(), compare); - int count = 0; - for (const std::pair &p : deltaTimePosPhiCands) { //save up to nth nearest Phi candidate - cout << "Count: " << count << " abs(tphi-ttheta): " << p.second << endl; - if (count < th_option || th_option == 0) - outMPs.push_back(p.first); - else - break; - count++; - } + if (deltaTimePosPhiCands.size() == 0) + {outMPs.push_back(mp1); //save ThetaMP when there is no phi TPs or if they are High qualityi (>th_quality) + savedThetaMPs.push_back(mp1);} } // loop in thetas + if(deltaTimePosPhiCands.size()>0) orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); //do once more for last theta TP in loop + + //finally add Theta TPs too - for (auto &mp : thetaMPs) - outMPs.push_back(mp); + //for (auto &mp : thetaMPs) + // outMPs.push_back(mp); - cout<<"After #TPs Theta: "<outMPs.size()) cout<<" ########### TP size reduced from: " <inMPs.size()) cout<<" $$$$$$$$$$$$$ TP size enlarged from: " < MPThetaMatching::getBestThetaMPInChamber(std::vector< DTChamberId chId1(mp1.rawId); DTSuperLayerId slId1(mp1.rawId); + //if there are more than 1 theta TPs in chamber, use and save only the one with highest quality int sector1 = chId1.sector(); int wheel1 = chId1.wheel(); int station1 = chId1.station(); - + cout << "Theta wheel: " << wheel1 << " sector " << sector1 << " station1: " << station1 << " q: " << mp1.quality + << " t0: " << mp1.t0 << endl; // Theta TPs (SL2) can be only q=1 (3hits) or q=3 (4 hits) - if(mp1.quality>1) { bestThetaMPs.push_back(mp1); continue;} + if (mp1.quality > 1) { + bestThetaMPs.push_back(mp1); + continue; + } - // if q=1 and there is no q=3, save it - for (const auto &mp2: thetaMPs) { + int nTPs = 0; + bool saved = false; + // if q=1 + for (const auto &mp2 : thetaMPs) { DTChamberId chId2(mp2.rawId); DTSuperLayerId slId2(mp2.rawId); int sector2 = chId2.sector(); int wheel2 = chId2.wheel(); int station2 = chId2.station(); - - //if there are more than 1 theta TPs in chamber, use and save only the one with highest quality + if (sector1 == sector2 && wheel1 == wheel2 && station1 == station2) { - if (mp1.quality > mp2.quality) { - continue; //there is a q=3 and it was alreacy saved - } else if (mp2.quality > mp1.quality) { //not likely case unless topological TPs - bestThetaMPs.push_back(mp2); + if (mp2.quality > mp1.quality) { + saved = true; + break; //there is a q=3 and it was already saved + } else if (mp2.quality == mp1.quality && mp2.t0 != mp1.t0) { + saved = true; + bestThetaMPs.push_back(mp1); + break; //if there are more than 1 with same q=1, save both } - else bestThetaMPs.push_back(mp2); //if there are more than 1 with same q=1, save both + nTPs++; } } + if (nTPs == 1 && !saved) + bestThetaMPs.push_back(mp1); //only one Theta TP in chamber and it is q=1 } return bestThetaMPs; }; + +void MPThetaMatching::orderAndSave(std::vector> deltaTimePosPhiCands, + std::vector* outMPs, std::vector* savedThetaMPs) +{ + //reorder deltaTimePosPhiCands according to tphi-ttheta distance + std::sort(deltaTimePosPhiCands.begin(), deltaTimePosPhiCands.end(), comparePairs); + int count = 0; + for (const std::tuple &p : + deltaTimePosPhiCands) { //save up to nth nearest Theta-Phi pair candidate + cout << "Count: " << count << " abs(tphi-ttheta): " << std::get<2>(p) << " qTheta: "<< std::get<0>(p).quality << " qPhi: "<(p).quality<push_back(std::get<1>(p)); //add PhiMP + outMPs->push_back(std::get<0>(p)); //add ThetaMP + savedThetaMPs->push_back(std::get<0>(p)); //for accounting + } else + break; + + count++; + } +} + + From 58df6f8d73bf110c06bc8a971b9dbbf77bfbb0ac Mon Sep 17 00:00:00 2001 From: Javier Date: Thu, 19 Dec 2024 19:38:31 +0100 Subject: [PATCH 04/19] Version with comments, ExtWheels exception and t0phi --- .../interface/MPThetaMatching.h | 19 +- .../dtTriggerPhase2PrimitiveDigis_cfi.py | 7 +- .../DTTriggerPhase2/src/MPThetaMatching.cc | 262 ++++++++++++------ 3 files changed, 195 insertions(+), 93 deletions(-) diff --git a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h index e82ab448ef6bd..5a70aff22fdd8 100644 --- a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h +++ b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h @@ -18,7 +18,7 @@ class MPThetaMatching : public MPFilter { public: // Constructors and destructor MPThetaMatching(const edm::ParameterSet &pset); - ~MPThetaMatching() override = default; + ~MPThetaMatching() override; // = default; // Main methods void initialise(const edm::EventSetup &iEventSetup) override; @@ -30,11 +30,11 @@ class MPThetaMatching : public MPFilter { const edm::EventSetup &iEventSetup, std::vector &allMPaths, std::vector &inMPaths, - std::vector &outMPaths) override {}; + std::vector &outMPaths) override{}; void run(edm::Event &iEvent, const edm::EventSetup &iEventSetup, MuonPathPtrs &inMPath, - MuonPathPtrs &outMPath) override {}; + MuonPathPtrs &outMPath) override{}; void finish() override; @@ -48,12 +48,14 @@ class MPThetaMatching : public MPFilter { float zFE[5] = {-658.9, -393.3, 126.4, 393.3, 658.9}; //cm float xFE[3] = {218 / 2., 266.8 / 2., 315 / 2.}; //cm float ZRES_CONV = 65536. / 1500; + int totOUTtheta, totINtheta, totOUTphi, totINphi; + int nothetaOUTphi, st4OUTphi, hqOUTphi, nophiOUTtheta; private: // Private methods std::vector filter(std::vector inMPs, -// int th_option, -// int th_quality, + // int th_option, + // int th_quality, double shift_back); bool isThereThetaMPInChamber(int sector, int wheel, int station, std::vector thetaMPs); @@ -64,8 +66,11 @@ class MPThetaMatching : public MPFilter { const std::tuple &b) { return std::get<2>(a) < std::get<2>(b); }; - void orderAndSave(std::vector> deltaTimePosPhiCands, - std::vector *outMPaths, std::vector *savedThetas); + void orderAndSave(std::vector> deltaTimePosPhiCands, + std::vector *outMPaths, + std::vector *savedThetas); + + //float computePosRefX(cmsdt::metaPrimitive); // Private attributes const bool debug_; diff --git a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py index 3b66ed44d5de0..39f87a8a403c1 100644 --- a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py +++ b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py @@ -1,3 +1,4 @@ + import FWCore.ParameterSet.Config as cms from L1TriggerConfig.DTTPGConfigProducers.L1DTTPGConfigFromDB_cff import * @@ -24,9 +25,9 @@ scenario = cms.int32(0), #0 for mc, 1 for data, 2 for slice test df_extended = cms.int32(0), # DF: 0 for standard, 1 for extended, 2 for both co_option = cms.int32(1), # coincidence w.r.t. : -1 = off, 0 = co all, 1 = co phi, 2 = co theta - co_quality = cms.int32(1), # quality cut (>X) for coincidence TP - th_option = cms.int32(1), # save 1st, 2nd, 3rd,... closest phi TP to theta TP. 0 disables filtering, i.e. saves all - th_quality = cms.int32(5), # quality cut (>X) for Theta matching: Phi TPs above this quality are not filtered + co_quality = cms.int32(1), # quality cut (>X) for coincidence TP: request TPs to be above this cut + th_option = cms.int32(1), # save 1st, 2nd,... closest Phi-Theta pair. 0 disables filtering (saves all) + th_quality = cms.int32(2), # quality cut (>X) for Theta matching: Phi TPs above are not filtered max_primitives = cms.int32(999), output_mixer = cms.bool(False), diff --git a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc index 11384032b5f36..d3d2821f6abc0 100644 --- a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc +++ b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc @@ -10,7 +10,6 @@ namespace { struct { bool operator()(const metaPrimitive &mp1, const metaPrimitive &mp2) const { DTChamberId chId1(mp1.rawId); - DTSuperLayerId slId1(mp1.rawId); int sector1 = chId1.sector(); int wheel1 = chId1.wheel(); @@ -47,10 +46,20 @@ MPThetaMatching::MPThetaMatching(const ParameterSet &pset) th_quality_(pset.getParameter("th_quality")), scenario_(pset.getParameter("scenario")) {} +MPThetaMatching::~MPThetaMatching() { finish(); } // ============================================================================ // Main methods (initialise, run, finish) // ============================================================================ -void MPThetaMatching::initialise(const edm::EventSetup &iEventSetup) {} +void MPThetaMatching::initialise(const edm::EventSetup &iEventSetup) { + totINphi = 0; + totOUTphi = 0; + totINtheta = 0; + totOUTtheta = 0; + st4OUTphi = 0; + hqOUTphi = 0; + nothetaOUTphi = 0; + nophiOUTtheta = 0; +} void MPThetaMatching::run(edm::Event &iEvent, const edm::EventSetup &iEventSetup, @@ -67,20 +76,40 @@ void MPThetaMatching::run(edm::Event &iEvent, else if (scenario_ == SLICE_TEST) shift_back = 400; - auto filteredMPs = filter(inMPaths, shift_back); - for (auto &mp : filteredMPs) - outMPaths.push_back(mp); + //cout<<"############NEW EVENT####"<< "inMPaths: "< 0) { + auto filteredMPs = filter(inMPaths, shift_back); + for (auto &mp : filteredMPs) + outMPaths.push_back(mp); + } else { + if (th_option_ < 0) + LogDebug("MPThetaMatching") + << "MPThetaMatching: th_option can NOT be negative!!! Check settings. Saving all MPs for the moment" << endl; + outMPaths = inMPaths; //no filter at all + } //if(doLog) cout << "Before filter #TPs:" << inMPaths.size() << " after: " << outMPaths.size() << endl; } -void MPThetaMatching::finish() {}; +void MPThetaMatching::finish() { + totOUTphi = totOUTphi - st4OUTphi - nothetaOUTphi - nophiOUTtheta; + totINphi = totINphi - nothetaOUTphi - nophiOUTtheta; + std::cout << "Rejected rate Phi: " << 1 - float(totOUTphi) / totINphi << endl; + std::cout << "Rejected rate Theta: " << 1 - float(totOUTtheta) / totINtheta << endl; + std::cout << "Rejected rate total: " << 1 - float(totOUTphi + totOUTtheta) / (totINtheta + totINphi) << endl; + + totOUTphi = totOUTphi - hqOUTphi; + totINphi = totINphi - hqOUTphi; + std::cout << "Rejected rate Phi (excluding HQ): " << 1 - float(totOUTphi) / totINphi << endl; + std::cout << "Rejected rate total (excluding HQ): " << 1 - float(totOUTphi + totOUTtheta) / (totINtheta + totINphi) + << endl; +}; /////////////////////////// /// OTHER METHODS -std::vector MPThetaMatching::filter(std::vector inMPs, - double shift_back) { +std::vector MPThetaMatching::filter(std::vector inMPs, double shift_back) { std::vector outMPs; std::vector thetaMPs; std::vector phiMPs; @@ -92,20 +121,37 @@ std::vector MPThetaMatching::filter(std::vector in if (slId.superLayer() == 2) thetaMPs.push_back(mp); - else + else if (chId.station() == 4) //No theta matching for MB4, save MP + { + outMPs.push_back(mp); + st4OUTphi += 1; + } else if (mp.quality > th_quality_) //don't do theta matching for q > X, save + { + outMPs.push_back(mp); + phiMPs.push_back(mp); //keep them in the loop to filter in Theta for cases where there are no other phiMPs + hqOUTphi += 1; + } else phiMPs.push_back(mp); } - bool doLog=false; - if(thetaMPs.size()>0 || phiMPs.size()>0) {cout << "Before #TPs Theta: " << thetaMPs.size() << " Phi: " << phiMPs.size() << endl; - doLog=true;} - //Order MPs by quality + bool doLog = false; + if (thetaMPs.size() > 0 || phiMPs.size() > 0) { + cout << "Initial #TPs Theta: " << thetaMPs.size() << " Phi: " << phiMPs.size() << endl; + doLog = true; + } + + totINphi += phiMPs.size(); + totINtheta += thetaMPs.size(); + + //Order Theta MPs by quality std::sort(thetaMPs.begin(), thetaMPs.end(), compareMPs); + //Use only best quality theta MP in chamber - thetaMPs = getBestThetaMPInChamber(thetaMPs); - if(doLog) cout << "Filtered #TPs Theta: " << thetaMPs.size() << endl; + //thetaMPs = getBestThetaMPInChamber(thetaMPs); + if (doLog) + cout << "Intermediate #TPs Theta: " << thetaMPs.size() << endl; - // Loop on phi, save those at station without Theta MPs + // Loop on phi, save those at chamber without Theta MPs for (auto &mp : phiMPs) { DTChamberId chId(mp.rawId); DTSuperLayerId slId(mp.rawId); @@ -114,84 +160,76 @@ std::vector MPThetaMatching::filter(std::vector in int wheel = chId.wheel(); int station = chId.station(); - if (station == 4) { - outMPs.push_back(mp); //No theta matching for MB4, save MP - continue; - } - if (!isThereThetaMPInChamber(sector, wheel, station, thetaMPs)) { - outMPs.push_back(mp); // No theta MPs in chamber to match, save MP - continue; + if (mp.quality <= th_quality_) { //Has it been saved already? + outMPs.push_back(mp); // No theta MPs in chamber to match, save MP + nothetaOUTphi += 1; + } } - - if ((mp.quality > th_quality_)) - outMPs.push_back(mp); //don't do theta matching for q > X, save } // Loop on theta (already ordered) int oldSector = 0; int oldStation = 0; int oldWheel = 0; + // container to decide which theta-phi pair to save std::vector> deltaTimePosPhiCands; //thetaMP, phiMP, difference in TimePosition std::vector savedThetaMPs; - for (auto &mp1 : thetaMPs) { - DTChamberId chId(mp1.rawId); - DTSuperLayerId slId(mp1.rawId); + for (metaPrimitive &mpTheta : thetaMPs) { + DTChamberId chId(mpTheta.rawId); + DTSuperLayerId slId(mpTheta.rawId); int sector = chId.sector(); int wheel = chId.wheel(); int station = chId.station(); - if (station == 4) { + if (station == 4) { //not possible LogDebug("MPThetaMatching") << "MPThetaMatching: station 4 does NOT have Theta SL 2"; continue; } if (sector != oldSector || wheel != oldWheel || station != oldStation) { //new chamber - if (deltaTimePosPhiCands.size() > 0) orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); + if (deltaTimePosPhiCands.size() > 0) + orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); deltaTimePosPhiCands.clear(); oldSector = sector; oldWheel = wheel; oldStation = station; } - - // float t0 = (mp1.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); - float t0 = ((int)round(mp1.t0 / (float)LHC_CLK_FREQ)) - shift_back; + // float t0 = (mpTheta.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); + float t0 = ((int)round(mpTheta.t0 / (float)LHC_CLK_FREQ)) - shift_back; float posRefZ = zFE[wheel + 2]; - if(doLog) cout << "Theta wh se st q t0: " << wheel << " " << sector << " " << station << " " << mp1.quality<< " " << mp1.t0 << endl; + if (doLog) + cout << "Theta wh se st q t0: " << wheel << " " << sector << " " << station << " " << mpTheta.quality << " " + << mpTheta.t0 << endl; if (wheel == 0 && (sector == 1 || sector == 4 || sector == 5 || sector == 8 || sector == 9 || sector == 12)) posRefZ = -posRefZ; - float posZ = abs(mp1.phi); + float posZ = abs(mpTheta.phi); //cout << "t0: " << t0 << endl; //cout << "posZ: " << posZ << endl; // Loop in Phis - for (auto &mp2 : phiMPs) { - DTChamberId chId2(mp2.rawId); - DTSuperLayerId slId2(mp2.rawId); + for (metaPrimitive &mpPhi : phiMPs) { + DTChamberId chId2(mpPhi.rawId); + DTSuperLayerId slId2(mpPhi.rawId); int sector2 = chId2.sector(); int wheel2 = chId2.wheel(); int station2 = chId2.station(); - if(doLog) cout << "Phi wheel: " << wheel2<< " sector "<< sector2 << " station: " << station2 << " q: " << mp2.quality - << " t0: " << mp2.t0 << endl; - - if (station2 == 4) - continue; - - if ((mp2.quality > th_quality_)) - continue; + if (doLog) + cout << "Phi wheel: " << wheel2 << " sector " << sector2 << " station: " << station2 << " q: " << mpPhi.quality + << " t0: " << mpPhi.t0 << endl; if (station2 != station || sector2 != sector || wheel2 != wheel) continue; - // float t02 = (mp2.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); - float t02 = ((int)round(mp2.t0 / (float)LHC_CLK_FREQ)) - shift_back; + // float t02 = (mpPhi.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); + float t02 = ((int)round(mpPhi.t0 / (float)LHC_CLK_FREQ)) - shift_back; //cout << "posRefZ: " << posRefZ << " Z: " << posZ / ZRES_CONV << endl; float tphi = t02 - abs(posZ / ZRES_CONV - posRefZ) / vwire; @@ -207,29 +245,62 @@ std::vector MPThetaMatching::filter(std::vector in //cout << "wh st se: " << wheel << " " << station << " " << sector << " LR: " << LR << endl; float posRefX = LR * xFE[station - 1]; - float ttheta = t0 - (mp2.x / 1000 - posRefX) / vwire; + float ttheta = t0 - (mpPhi.x / 1000 - posRefX) / vwire; //cout << "posRefX: " << posRefX << " X: " << mp2.x / 1000 << endl; //cout << "ttheta: " << ttheta << endl; - deltaTimePosPhiCands.push_back({mp1, mp2, abs(tphi - ttheta)}); + deltaTimePosPhiCands.push_back({mpTheta, mpPhi, abs(tphi - ttheta)}); //cout << "deltaTimePosPhiCands: " << deltaTimePosPhiCands.size() << endl; } //loop in phis - if (deltaTimePosPhiCands.size() == 0) - {outMPs.push_back(mp1); //save ThetaMP when there is no phi TPs or if they are High qualityi (>th_quality) - savedThetaMPs.push_back(mp1);} + if (deltaTimePosPhiCands.size() == 0) { + outMPs.push_back(mpTheta); //save ThetaMP when there is no phi TPs + savedThetaMPs.push_back(mpTheta); + nophiOUTtheta += 1; + } } // loop in thetas - if(deltaTimePosPhiCands.size()>0) orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); //do once more for last theta TP in loop + if (deltaTimePosPhiCands.size() > 0) + orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); //do once more for last theta TP in loop + + if (doLog) + cout << "After #TPs Theta: " << savedThetaMPs.size() << " Phi: " << outMPs.size() - savedThetaMPs.size() << endl; - - //finally add Theta TPs too - //for (auto &mp : thetaMPs) - // outMPs.push_back(mp); + if (inMPs.size() > outMPs.size()) + cout << " ########### TP size reduced from: " << inMPs.size() << " to: " << outMPs.size() + << " rate: " << float(outMPs.size()) / inMPs.size() << endl; + else if (outMPs.size() > inMPs.size()) + cout << " $$$$$$$$$$$$$ TP size enlarged from: " << inMPs.size() << " to: " << outMPs.size() << endl; + + if (phiMPs.size() > (outMPs.size() - savedThetaMPs.size())) + cout << " ########### TP Phi size reduced from: " << phiMPs.size() + << " to: " << outMPs.size() - savedThetaMPs.size() + << " rate: " << float((outMPs.size() - savedThetaMPs.size())) / phiMPs.size() << endl; + + if (thetaMPs.size() > savedThetaMPs.size()) + cout << " ########### TP Theta size reduced from: " << thetaMPs.size() << " to: " << savedThetaMPs.size() + << " rate: " << float(savedThetaMPs.size()) / thetaMPs.size() << endl; + + totOUTtheta = totOUTtheta + savedThetaMPs.size(); + totOUTphi = totOUTphi + (outMPs.size() - savedThetaMPs.size()); + + for (const auto &mp1 : outMPs) { + cout << "FINAL OUTPUT OF WHAT IT IS SAVED" << endl; + DTChamberId chId1(mp1.rawId); + DTSuperLayerId slId1(mp1.rawId); + + int sector1 = chId1.sector(); + int wheel1 = chId1.wheel(); + int station1 = chId1.station(); + if (slId1.superLayer() == 2) + cout << "Theta wheel: " << wheel1 << " sector " << sector1 << " station1: " << station1 << " q: " << mp1.quality + << " t0: " << mp1.t0 << endl; + else + cout << "Phi wheel: " << wheel1 << " sector " << sector1 << " station1: " << station1 << " q: " << mp1.quality + << " t0: " << mp1.t0 << endl; + cout << endl; + } - if(doLog) cout << "After #TPs Theta: " << savedThetaMPs.size() << " Phi: " << outMPs.size() - savedThetaMPs.size() << endl; - if(inMPs.size()>outMPs.size()) cout<<" ########### TP size reduced from: " <inMPs.size()) cout<<" $$$$$$$$$$$$$ TP size enlarged from: " < MPThetaMatching::getBestThetaMPInChamber(std::vector< std::vector bestThetaMPs; for (const auto &mp1 : thetaMPs) { DTChamberId chId1(mp1.rawId); - DTSuperLayerId slId1(mp1.rawId); //if there are more than 1 theta TPs in chamber, use and save only the one with highest quality int sector1 = chId1.sector(); @@ -280,41 +350,67 @@ std::vector MPThetaMatching::getBestThetaMPInChamber(std::vector< int station2 = chId2.station(); if (sector1 == sector2 && wheel1 == wheel2 && station1 == station2) { - if (mp2.quality > mp1.quality) { + if (mp2.quality > mp1.quality && (abs(wheel1) != 2 || station1 > 2)) { //exception for WH+-2 MB1/2 saved = true; break; //there is a q=3 and it was already saved } else if (mp2.quality == mp1.quality && mp2.t0 != mp1.t0) { saved = true; bestThetaMPs.push_back(mp1); break; //if there are more than 1 with same q=1, save both + } else if (abs(wheel1) == 2 && station1 < 3) { + saved = true; + bestThetaMPs.push_back(mp1); + break; } + nTPs++; } } if (nTPs == 1 && !saved) bestThetaMPs.push_back(mp1); //only one Theta TP in chamber and it is q=1 } + return bestThetaMPs; }; void MPThetaMatching::orderAndSave(std::vector> deltaTimePosPhiCands, - std::vector* outMPs, std::vector* savedThetaMPs) -{ - //reorder deltaTimePosPhiCands according to tphi-ttheta distance - std::sort(deltaTimePosPhiCands.begin(), deltaTimePosPhiCands.end(), comparePairs); - int count = 0; - for (const std::tuple &p : - deltaTimePosPhiCands) { //save up to nth nearest Theta-Phi pair candidate - cout << "Count: " << count << " abs(tphi-ttheta): " << std::get<2>(p) << " qTheta: "<< std::get<0>(p).quality << " qPhi: "<(p).quality<push_back(std::get<1>(p)); //add PhiMP - outMPs->push_back(std::get<0>(p)); //add ThetaMP - savedThetaMPs->push_back(std::get<0>(p)); //for accounting - } else - break; - - count++; - } -} - + std::vector *outMPs, + std::vector *savedThetaMPs) { + //reorder deltaTimePosPhiCands according to tphi-ttheta distance + std::sort(deltaTimePosPhiCands.begin(), deltaTimePosPhiCands.end(), comparePairs); + int count = 0; + + for ( std::tuple &p : + deltaTimePosPhiCands) { //save up to nth nearest Theta-Phi pair candidate + cout << "Count: " << count << " abs(tphi-ttheta): " << std::get<2>(p) << " qTheta: " << std::get<0>(p).quality + << " qPhi: " << std::get<1>(p).quality << endl; + if (std::get<1>(p).quality > th_quality_) + continue; + DTChamberId chId(std::get<1>(p).rawId); + + //if ((abs(chId.wheel()) == 2 && chId.station() < 3 && count < th_option_ + 1) || //save an extra pair for WH+-2MB1/2 + if( count < th_option_) { + std::get<0>(p).t0 = std::get<1>(p).t0; + outMPs->push_back(std::get<1>(p)); //add PhiMP + outMPs->push_back(std::get<0>(p)); //add ThetaMP + savedThetaMPs->push_back(std::get<0>(p)); //for accounting + count++; + } else + break; //FIXME: avoid Theta duplicates when saving more than one pair + } + for (std::tuple &p : deltaTimePosPhiCands) { + DTChamberId chId(std::get<1>(p).rawId); + if (count < th_option_ ){ //|| (abs(chId.wheel()) == 2 && chId.station() < 3 && count < (th_option_ + 1))) { + if (std::get<1>(p).quality > th_quality_) { + std::get<0>(p).t0 = std::get<1>(p).t0; + outMPs->push_back(std::get<0>(p)); //add ThetaMP + savedThetaMPs->push_back(std::get<0>(p)); + cout << "Count: " << count << " abs(tphi-ttheta): " << std::get<2>(p) << " qTheta: " << std::get<0>(p).quality + << " qPhi: " << std::get<1>(p).quality << " no Phis below qcut to match" << endl; + count++; + } + } else + break; + } +} From bb8b623089c28fd8bc260e16820db3854b357708 Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 5 Mar 2025 17:34:05 +0100 Subject: [PATCH 05/19] Exception on WhMB1 by Dermot Moran --- .../src/MPCoincidenceFilter.cc | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/L1Trigger/DTTriggerPhase2/src/MPCoincidenceFilter.cc b/L1Trigger/DTTriggerPhase2/src/MPCoincidenceFilter.cc index e82a7abb84ab4..e601baba07bee 100644 --- a/L1Trigger/DTTriggerPhase2/src/MPCoincidenceFilter.cc +++ b/L1Trigger/DTTriggerPhase2/src/MPCoincidenceFilter.cc @@ -14,6 +14,7 @@ MPCoincidenceFilter::MPCoincidenceFilter(const ParameterSet &pset) debug_(pset.getUntrackedParameter("debug")), co_option_(pset.getParameter("co_option")), co_quality_(pset.getParameter("co_quality")), + co_wh2option_(pset.getParameter("co_wh2option")), scenario_(pset.getParameter("scenario")) {} // ============================================================================ @@ -37,7 +38,7 @@ void MPCoincidenceFilter::run(edm::Event &iEvent, else if (scenario_ == SLICE_TEST) shift_back = 400; - auto filteredMPs = filter(inMPaths, allMPaths, co_option_, co_quality_, shift_back); + auto filteredMPs = filter(inMPaths, allMPaths, co_option_, co_quality_, co_wh2option_, shift_back); for (auto &mp : filteredMPs) outMPaths.push_back(mp); } @@ -51,6 +52,7 @@ std::vector MPCoincidenceFilter::filter(std::vector allMPs, int co_option, int co_quality, + int co_wh2option, double shift_back) { std::vector outMPs; @@ -58,9 +60,9 @@ std::vector MPCoincidenceFilter::filter(std::vector MPCoincidenceFilter::filter(std::vector 5) + bool wh2pass = 0; + if(abs(wheel)==2 && station==1 && co_wh2option==1)wh2pass=1; + if(abs(wheel)==2 && station<3 && co_wh2option==2)wh2pass=1; + + if (co_option == -1 || mp.quality > 5 || wh2pass==1) outMPs.push_back(mp); else { int sector_p1 = sector + 1; @@ -93,15 +99,15 @@ std::vector MPCoincidenceFilter::filter(std::vector qcut) @@ -120,15 +126,15 @@ std::vector MPCoincidenceFilter::filter(std::vector MPCoincidenceFilter::filter(std::vector MPCoincidenceFilter::filter(std::vector 0.9) { - co_found = true; + co_found = 1; break; } else if (wheel == -2 && k < -0.9) { - co_found = true; + co_found = 1; break; } } @@ -180,7 +186,7 @@ std::vector MPCoincidenceFilter::filter(std::vector Date: Tue, 11 Mar 2025 11:50:38 +0100 Subject: [PATCH 06/19] Exception 2 TPs Wh2 MB1/2, BestThetaWh0, t0phi --- .../interface/MPThetaMatching.h | 2 - .../DTTriggerPhase2/src/MPThetaMatching.cc | 210 +++++------------- 2 files changed, 58 insertions(+), 154 deletions(-) diff --git a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h index 5a70aff22fdd8..c43d2a03be325 100644 --- a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h +++ b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h @@ -48,8 +48,6 @@ class MPThetaMatching : public MPFilter { float zFE[5] = {-658.9, -393.3, 126.4, 393.3, 658.9}; //cm float xFE[3] = {218 / 2., 266.8 / 2., 315 / 2.}; //cm float ZRES_CONV = 65536. / 1500; - int totOUTtheta, totINtheta, totOUTphi, totINphi; - int nothetaOUTphi, st4OUTphi, hqOUTphi, nophiOUTtheta; private: // Private methods diff --git a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc index d3d2821f6abc0..0a3f876eb96c0 100644 --- a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc +++ b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc @@ -50,16 +50,7 @@ MPThetaMatching::~MPThetaMatching() { finish(); } // ============================================================================ // Main methods (initialise, run, finish) // ============================================================================ -void MPThetaMatching::initialise(const edm::EventSetup &iEventSetup) { - totINphi = 0; - totOUTphi = 0; - totINtheta = 0; - totOUTtheta = 0; - st4OUTphi = 0; - hqOUTphi = 0; - nothetaOUTphi = 0; - nophiOUTtheta = 0; -} +void MPThetaMatching::initialise(const edm::EventSetup &iEventSetup) {} void MPThetaMatching::run(edm::Event &iEvent, const edm::EventSetup &iEventSetup, @@ -76,8 +67,6 @@ void MPThetaMatching::run(edm::Event &iEvent, else if (scenario_ == SLICE_TEST) shift_back = 400; - //cout<<"############NEW EVENT####"<< "inMPaths: "< 0) { auto filteredMPs = filter(inMPaths, shift_back); for (auto &mp : filteredMPs) @@ -88,23 +77,9 @@ void MPThetaMatching::run(edm::Event &iEvent, << "MPThetaMatching: th_option can NOT be negative!!! Check settings. Saving all MPs for the moment" << endl; outMPaths = inMPaths; //no filter at all } - - //if(doLog) cout << "Before filter #TPs:" << inMPaths.size() << " after: " << outMPaths.size() << endl; } -void MPThetaMatching::finish() { - totOUTphi = totOUTphi - st4OUTphi - nothetaOUTphi - nophiOUTtheta; - totINphi = totINphi - nothetaOUTphi - nophiOUTtheta; - std::cout << "Rejected rate Phi: " << 1 - float(totOUTphi) / totINphi << endl; - std::cout << "Rejected rate Theta: " << 1 - float(totOUTtheta) / totINtheta << endl; - std::cout << "Rejected rate total: " << 1 - float(totOUTphi + totOUTtheta) / (totINtheta + totINphi) << endl; - - totOUTphi = totOUTphi - hqOUTphi; - totINphi = totINphi - hqOUTphi; - std::cout << "Rejected rate Phi (excluding HQ): " << 1 - float(totOUTphi) / totINphi << endl; - std::cout << "Rejected rate total (excluding HQ): " << 1 - float(totOUTphi + totOUTtheta) / (totINtheta + totINphi) - << endl; -}; +void MPThetaMatching::finish(){}; /////////////////////////// /// OTHER METHODS @@ -122,34 +97,20 @@ std::vector MPThetaMatching::filter(std::vector in if (slId.superLayer() == 2) thetaMPs.push_back(mp); else if (chId.station() == 4) //No theta matching for MB4, save MP - { outMPs.push_back(mp); - st4OUTphi += 1; - } else if (mp.quality > th_quality_) //don't do theta matching for q > X, save + else if (mp.quality > th_quality_) //don't do theta matching for q > X, save { outMPs.push_back(mp); phiMPs.push_back(mp); //keep them in the loop to filter in Theta for cases where there are no other phiMPs - hqOUTphi += 1; } else phiMPs.push_back(mp); } - bool doLog = false; - if (thetaMPs.size() > 0 || phiMPs.size() > 0) { - cout << "Initial #TPs Theta: " << thetaMPs.size() << " Phi: " << phiMPs.size() << endl; - doLog = true; - } - - totINphi += phiMPs.size(); - totINtheta += thetaMPs.size(); - //Order Theta MPs by quality std::sort(thetaMPs.begin(), thetaMPs.end(), compareMPs); //Use only best quality theta MP in chamber - //thetaMPs = getBestThetaMPInChamber(thetaMPs); - if (doLog) - cout << "Intermediate #TPs Theta: " << thetaMPs.size() << endl; + thetaMPs = getBestThetaMPInChamber(thetaMPs); // Loop on phi, save those at chamber without Theta MPs for (auto &mp : phiMPs) { @@ -161,17 +122,15 @@ std::vector MPThetaMatching::filter(std::vector in int station = chId.station(); if (!isThereThetaMPInChamber(sector, wheel, station, thetaMPs)) { - if (mp.quality <= th_quality_) { //Has it been saved already? - outMPs.push_back(mp); // No theta MPs in chamber to match, save MP - nothetaOUTphi += 1; - } + if (mp.quality <= th_quality_) //Has it been saved already? + outMPs.push_back(mp); // No theta MPs in chamber to match, save MP } } // Loop on theta (already ordered) int oldSector = 0; int oldStation = 0; - int oldWheel = 0; + int oldWheel = -999; // container to decide which theta-phi pair to save std::vector> deltaTimePosPhiCands; //thetaMP, phiMP, difference in TimePosition @@ -203,15 +162,10 @@ std::vector MPThetaMatching::filter(std::vector in // float t0 = (mpTheta.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); float t0 = ((int)round(mpTheta.t0 / (float)LHC_CLK_FREQ)) - shift_back; float posRefZ = zFE[wheel + 2]; - if (doLog) - cout << "Theta wh se st q t0: " << wheel << " " << sector << " " << station << " " << mpTheta.quality << " " - << mpTheta.t0 << endl; if (wheel == 0 && (sector == 1 || sector == 4 || sector == 5 || sector == 8 || sector == 9 || sector == 12)) posRefZ = -posRefZ; float posZ = abs(mpTheta.phi); - //cout << "t0: " << t0 << endl; - //cout << "posZ: " << posZ << endl; // Loop in Phis for (metaPrimitive &mpPhi : phiMPs) { @@ -221,19 +175,13 @@ std::vector MPThetaMatching::filter(std::vector in int sector2 = chId2.sector(); int wheel2 = chId2.wheel(); int station2 = chId2.station(); - if (doLog) - cout << "Phi wheel: " << wheel2 << " sector " << sector2 << " station: " << station2 << " q: " << mpPhi.quality - << " t0: " << mpPhi.t0 << endl; if (station2 != station || sector2 != sector || wheel2 != wheel) continue; - // float t02 = (mpPhi.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); float t02 = ((int)round(mpPhi.t0 / (float)LHC_CLK_FREQ)) - shift_back; - //cout << "posRefZ: " << posRefZ << " Z: " << posZ / ZRES_CONV << endl; float tphi = t02 - abs(posZ / ZRES_CONV - posRefZ) / vwire; - //cout << "tphi: " << tphi << endl; int LR = -1; if (wheel == 0 && (sector == 3 || sector == 4 || sector == 7 || sector == 8 || sector == 11 || sector == 12)) @@ -242,65 +190,22 @@ std::vector MPThetaMatching::filter(std::vector in LR = pow(-1, wheel + sector + 1); else if (wheel < 0) LR = pow(-1, -wheel + sector); - //cout << "wh st se: " << wheel << " " << station << " " << sector << " LR: " << LR << endl; float posRefX = LR * xFE[station - 1]; float ttheta = t0 - (mpPhi.x / 1000 - posRefX) / vwire; - //cout << "posRefX: " << posRefX << " X: " << mp2.x / 1000 << endl; - //cout << "ttheta: " << ttheta << endl; deltaTimePosPhiCands.push_back({mpTheta, mpPhi, abs(tphi - ttheta)}); - //cout << "deltaTimePosPhiCands: " << deltaTimePosPhiCands.size() << endl; } //loop in phis if (deltaTimePosPhiCands.size() == 0) { outMPs.push_back(mpTheta); //save ThetaMP when there is no phi TPs savedThetaMPs.push_back(mpTheta); - nophiOUTtheta += 1; } } // loop in thetas if (deltaTimePosPhiCands.size() > 0) orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); //do once more for last theta TP in loop - if (doLog) - cout << "After #TPs Theta: " << savedThetaMPs.size() << " Phi: " << outMPs.size() - savedThetaMPs.size() << endl; - - if (inMPs.size() > outMPs.size()) - cout << " ########### TP size reduced from: " << inMPs.size() << " to: " << outMPs.size() - << " rate: " << float(outMPs.size()) / inMPs.size() << endl; - else if (outMPs.size() > inMPs.size()) - cout << " $$$$$$$$$$$$$ TP size enlarged from: " << inMPs.size() << " to: " << outMPs.size() << endl; - - if (phiMPs.size() > (outMPs.size() - savedThetaMPs.size())) - cout << " ########### TP Phi size reduced from: " << phiMPs.size() - << " to: " << outMPs.size() - savedThetaMPs.size() - << " rate: " << float((outMPs.size() - savedThetaMPs.size())) / phiMPs.size() << endl; - - if (thetaMPs.size() > savedThetaMPs.size()) - cout << " ########### TP Theta size reduced from: " << thetaMPs.size() << " to: " << savedThetaMPs.size() - << " rate: " << float(savedThetaMPs.size()) / thetaMPs.size() << endl; - - totOUTtheta = totOUTtheta + savedThetaMPs.size(); - totOUTphi = totOUTphi + (outMPs.size() - savedThetaMPs.size()); - - for (const auto &mp1 : outMPs) { - cout << "FINAL OUTPUT OF WHAT IT IS SAVED" << endl; - DTChamberId chId1(mp1.rawId); - DTSuperLayerId slId1(mp1.rawId); - - int sector1 = chId1.sector(); - int wheel1 = chId1.wheel(); - int station1 = chId1.station(); - if (slId1.superLayer() == 2) - cout << "Theta wheel: " << wheel1 << " sector " << sector1 << " station1: " << station1 << " q: " << mp1.quality - << " t0: " << mp1.t0 << endl; - else - cout << "Phi wheel: " << wheel1 << " sector " << sector1 << " station1: " << station1 << " q: " << mp1.quality - << " t0: " << mp1.t0 << endl; - cout << endl; - } - return outMPs; }; @@ -329,46 +234,49 @@ std::vector MPThetaMatching::getBestThetaMPInChamber(std::vector< //if there are more than 1 theta TPs in chamber, use and save only the one with highest quality int sector1 = chId1.sector(); int wheel1 = chId1.wheel(); - int station1 = chId1.station(); - cout << "Theta wheel: " << wheel1 << " sector " << sector1 << " station1: " << station1 << " q: " << mp1.quality - << " t0: " << mp1.t0 << endl; - // Theta TPs (SL2) can be only q=1 (3hits) or q=3 (4 hits) - if (mp1.quality > 1) { - bestThetaMPs.push_back(mp1); - continue; - } - - int nTPs = 0; - bool saved = false; - // if q=1 - for (const auto &mp2 : thetaMPs) { - DTChamberId chId2(mp2.rawId); - DTSuperLayerId slId2(mp2.rawId); - - int sector2 = chId2.sector(); - int wheel2 = chId2.wheel(); - int station2 = chId2.station(); + if (wheel1 == 0) { //Exception for Wheel 0 ONLY, to take into account background in other chambers + int station1 = chId1.station(); + // Theta TPs (SL2) can be only q=1 (3hits) or q=3 (4 hits) + if (mp1.quality > 1) { + bestThetaMPs.push_back(mp1); + continue; + } - if (sector1 == sector2 && wheel1 == wheel2 && station1 == station2) { - if (mp2.quality > mp1.quality && (abs(wheel1) != 2 || station1 > 2)) { //exception for WH+-2 MB1/2 - saved = true; - break; //there is a q=3 and it was already saved - } else if (mp2.quality == mp1.quality && mp2.t0 != mp1.t0) { - saved = true; - bestThetaMPs.push_back(mp1); - break; //if there are more than 1 with same q=1, save both - } else if (abs(wheel1) == 2 && station1 < 3) { - saved = true; - bestThetaMPs.push_back(mp1); - break; + int nTPs = 0; + bool saved = false; + // if q=1 + for (const auto &mp2 : thetaMPs) { + DTChamberId chId2(mp2.rawId); + DTSuperLayerId slId2(mp2.rawId); + + int sector2 = chId2.sector(); + int wheel2 = chId2.wheel(); + int station2 = chId2.station(); + + if (sector1 == sector2 && wheel1 == wheel2 && station1 == station2) { + if (mp2.quality > mp1.quality && wheel1 == 0) { + saved = true; + break; //there is a q=3 and it was already saved + } else if (mp2.quality == mp1.quality && mp2.t0 != mp1.t0) { + saved = true; + bestThetaMPs.push_back(mp1); + break; //if there are more than 1 with same q=1, save both + } else if (abs(wheel1) == 2 && station1 < 3) { + saved = true; + bestThetaMPs.push_back(mp1); + break; + } + + nTPs++; } - - nTPs++; } - } - if (nTPs == 1 && !saved) - bestThetaMPs.push_back(mp1); //only one Theta TP in chamber and it is q=1 - } + if (nTPs == 1 && !saved) + bestThetaMPs.push_back(mp1); //only one Theta TP in chamber and it is q=1 + } //wheel ==0 + + else + bestThetaMPs.push_back(mp1); + } // loop in thetaMPs return bestThetaMPs; }; @@ -380,34 +288,32 @@ void MPThetaMatching::orderAndSave(std::vector &p : + for (std::tuple &p : deltaTimePosPhiCands) { //save up to nth nearest Theta-Phi pair candidate - cout << "Count: " << count << " abs(tphi-ttheta): " << std::get<2>(p) << " qTheta: " << std::get<0>(p).quality - << " qPhi: " << std::get<1>(p).quality << endl; if (std::get<1>(p).quality > th_quality_) continue; DTChamberId chId(std::get<1>(p).rawId); - //if ((abs(chId.wheel()) == 2 && chId.station() < 3 && count < th_option_ + 1) || //save an extra pair for WH+-2MB1/2 - if( count < th_option_) { - std::get<0>(p).t0 = std::get<1>(p).t0; + if ((abs(chId.wheel()) == 2 && chId.station() < 3 && count < th_option_ + 1) || //save an extra pair for WH+-2MB1/2 + count < th_option_) { + std::get<0>(p).t0 = std::get<1>(p).t0; //replace t0 by associated phi t0 outMPs->push_back(std::get<1>(p)); //add PhiMP outMPs->push_back(std::get<0>(p)); //add ThetaMP savedThetaMPs->push_back(std::get<0>(p)); //for accounting count++; } else - break; //FIXME: avoid Theta duplicates when saving more than one pair + break; //avoid Theta duplicates when saving more than one pair } - for (std::tuple &p : deltaTimePosPhiCands) { + for (std::tuple &p : + deltaTimePosPhiCands) { // save theta TP when paired Phi was above th_quality_ DTChamberId chId(std::get<1>(p).rawId); - if (count < th_option_ ){ //|| (abs(chId.wheel()) == 2 && chId.station() < 3 && count < (th_option_ + 1))) { + if (count < th_option_ || (abs(chId.wheel()) == 2 && chId.station() < 3 && count < (th_option_ + 1))) { if (std::get<1>(p).quality > th_quality_) { - std::get<0>(p).t0 = std::get<1>(p).t0; - outMPs->push_back(std::get<0>(p)); //add ThetaMP + //if (abs(chId.wheel())!=0) + std::get<0>(p).t0 = std::get<1>(p).t0; //replace t0 by associated phi t0 + outMPs->push_back(std::get<0>(p)); //add ThetaMP savedThetaMPs->push_back(std::get<0>(p)); - cout << "Count: " << count << " abs(tphi-ttheta): " << std::get<2>(p) << " qTheta: " << std::get<0>(p).quality - << " qPhi: " << std::get<1>(p).quality << " no Phis below qcut to match" << endl; count++; } } else From b0ca8108f3c59be2a0a8a3153b3209bc65273e22 Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 25 Mar 2025 19:42:00 +0100 Subject: [PATCH 07/19] Changes from D. Morat to coincidence exception on external chambers --- .../DTTriggerPhase2/interface/MPCoincidenceFilter.h | 2 ++ .../DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc | 12 ++++++++++++ .../python/dtTriggerPhase2PrimitiveDigis_cfi.py | 1 + 3 files changed, 15 insertions(+) diff --git a/L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h b/L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h index 51ba5ffe7e577..a863a32b73ed7 100644 --- a/L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h +++ b/L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h @@ -72,12 +72,14 @@ class MPCoincidenceFilter : public MPFilter { std::vector allMPs, int co_option, int co_quality, + int co_wh2option, double shift_back); // Private attributes const bool debug_; int co_option_; int co_quality_; + int co_wh2option_; int scenario_; }; diff --git a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc index b6d67b5cbc28f..571aa28b311d4 100644 --- a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc +++ b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc @@ -139,6 +139,7 @@ class DTTrigPhase2Prod : public edm::stream::EDProducer<> { int df_extended_; int co_option_; //coincidence int co_quality_; + int co_wh2option_; int th_option_; //theta matching int th_quality_; int max_index_; @@ -214,6 +215,7 @@ DTTrigPhase2Prod::DTTrigPhase2Prod(const ParameterSet& pset) df_extended_ = pset.getParameter("df_extended"); co_option_ = pset.getParameter("co_option"); co_quality_ = pset.getParameter("co_quality"); + co_wh2option_ = pset.getParameter("co_wh2option"); th_option_ = pset.getParameter("th_option"); th_quality_ = pset.getParameter("th_quality"); max_index_ = pset.getParameter("max_primitives") - 1; @@ -831,6 +833,9 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) { } } + //for (auto& ch_filtcorrelatedMetaPrimitives : filtCorrelatedMetaPrimitives) + //cout<<"filtCorrelatedMetaPrimitives: "<("df_extended", 0); desc.add("co_option", 0); desc.add("co_quality", 0); + desc.add("co_wh2option", 0); desc.add("th_option", 0); desc.add("th_quality", 0); desc.add("max_primitives", 999); diff --git a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py index 39f87a8a403c1..b50d2fb012fb3 100644 --- a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py +++ b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py @@ -26,6 +26,7 @@ df_extended = cms.int32(0), # DF: 0 for standard, 1 for extended, 2 for both co_option = cms.int32(1), # coincidence w.r.t. : -1 = off, 0 = co all, 1 = co phi, 2 = co theta co_quality = cms.int32(1), # quality cut (>X) for coincidence TP: request TPs to be above this cut + co_wh2option = cms.int32(1),#0 (filter all stations in Wh2), 1(pass Wh2 St1), 2(pass Wh2 St1+2) th_option = cms.int32(1), # save 1st, 2nd,... closest Phi-Theta pair. 0 disables filtering (saves all) th_quality = cms.int32(2), # quality cut (>X) for Theta matching: Phi TPs above are not filtered max_primitives = cms.int32(999), From e5023723a8cf53e09a7a58939698ae6a88481d38 Mon Sep 17 00:00:00 2001 From: Carlos Vico Villalba Date: Wed, 24 Jul 2024 17:01:15 +0200 Subject: [PATCH 08/19] Create DTTrigPh2ShowerProducer pluging to emulate DT Muon Shower algorithm - only hits counting by chamber --- .../interface/L1Phase2MuDTShower.h | 73 +++++ .../interface/L1Phase2MuDTShowerContainer.h | 50 ++++ .../L1DTTrackFinder/src/L1Phase2MuDTShower.cc | 69 +++++ .../src/L1Phase2MuDTShowerContainer.cc | 41 +++ DataFormats/L1DTTrackFinder/src/classes.h | 2 + .../L1DTTrackFinder/src/classes_def.xml | 15 ++ .../DTTriggerPhase2/interface/ShowerBuffer.h | 44 ++++ .../interface/ShowerCandidate.h | 46 ++++ .../interface/ShowerGrouping.h | 100 +++++++ .../plugins/DTTrigPhase2ShowerProd.cc | 249 ++++++++++++++++++ .../python/dtTriggerPhase2Showers_cfi.py | 12 + L1Trigger/DTTriggerPhase2/src/ShowerBuffer.cc | 18 ++ .../DTTriggerPhase2/src/ShowerCandidate.cc | 49 ++++ .../DTTriggerPhase2/src/ShowerGrouping.cc | 136 ++++++++++ 14 files changed, 904 insertions(+) create mode 100644 DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h create mode 100644 DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h create mode 100644 DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc create mode 100644 DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc create mode 100644 L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h create mode 100644 L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h create mode 100644 L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h create mode 100644 L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc create mode 100644 L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py create mode 100644 L1Trigger/DTTriggerPhase2/src/ShowerBuffer.cc create mode 100644 L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc create mode 100644 L1Trigger/DTTriggerPhase2/src/ShowerGrouping.cc diff --git a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h new file mode 100644 index 0000000000000..c945d0476f700 --- /dev/null +++ b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h @@ -0,0 +1,73 @@ +//------------------------------------------------- +// +// Class L1Phase2MuDTShower +// +// Description: shower primitive data for the +// muon barrel Phase2 trigger +// +// +// Author List: Carlos Vico Oviedo Spain +// +// +//-------------------------------------------------- +#ifndef L1Phase2MuDTShower_H +#define L1Phase2MuDTShower_H + +//------------------------------------ +// Collaborating Class Declarations -- +//------------------------------------ + +//---------------------- +// Base Class Headers -- +//---------------------- + +//--------------- +// C++ Headers -- +//--------------- + +// --------------------- +// -- Class Interface -- +// --------------------- + +class L1Phase2MuDTShower { +public: + // Constructors + L1Phase2MuDTShower(); + + L1Phase2MuDTShower(int bx, // BX estimation + int wh, // Wheel + int sc, // Sector + int st, // Station + int ndigis, // Number of digis within shower + float avg_pos, // Averaged position of the shower + float avg_time); // Averaged time of the shower + + + virtual ~L1Phase2MuDTShower(){}; + + // Operations + int bxNum() const; + + int whNum() const; + int scNum() const; + int stNum() const; + + int ndigis() const; + float avg_time() const; + float avg_pos() const; + +private: + + int m_bx; + + int m_wheel; + int m_sector; + int m_station; + + int m_ndigis; + float m_avg_pos; + float m_avg_time; + +}; + +#endif diff --git a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h new file mode 100644 index 0000000000000..2df99df8f81ae --- /dev/null +++ b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h @@ -0,0 +1,50 @@ +//------------------------------------------------- +// +// Class L1Phase2MuDTPhContainer +// +// Description: trigger primtive data for the +// muon barrel Phase2 trigger +// +// +// Author List: Federica Primavera Bologna INFN +// +// +//-------------------------------------------------- +#ifndef L1Phase2MuDTShowerContainer_H +#define L1Phase2MuDTShowerContainer_H + +//------------------------------------ +// Collaborating Class Declarations -- +//------------------------------------ +#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h" + +//---------------------- +// Base Class Headers -- +//---------------------- +#include + +//--------------- +// C++ Headers -- +//--------------- + +// --------------------- +// -- Class Interface -- +// --------------------- + +class L1Phase2MuDTShowerContainer { +public: + typedef std::vector Shower_Container; + typedef Shower_Container::const_iterator Shower_iterator; + + // Constructor + L1Phase2MuDTShowerContainer(); + + void setContainer(const Shower_Container& inputShowers); + + Shower_Container const* getContainer() const; + +private: + Shower_Container m_showers; +}; + +#endif diff --git a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc new file mode 100644 index 0000000000000..a897f7c8ee624 --- /dev/null +++ b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc @@ -0,0 +1,69 @@ +//------------------------------------------------- +// +// Class L1MuDTChambPhDigi +// +// Description: trigger primtive data for the +// muon barrel Phase2 trigger +// +// +// Author List: Federica Primavera Bologna INFN +// +// +//-------------------------------------------------- + +//----------------------- +// This Class's Header -- +//----------------------- +#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h" + +//------------------------------- +// Collaborating Class Headers -- +//------------------------------- + +//--------------- +// C++ Headers -- +//--------------- + +//------------------- +// Initializations -- +//------------------- + +//---------------- +// Constructors -- +//---------------- +L1Phase2MuDTShower::L1Phase2MuDTShower() + : m_bx(-100), + m_wheel(0), + m_sector(0), + m_station(0), + m_ndigis(0), + m_avg_pos(0), + m_avg_time(0) {} + +L1Phase2MuDTShower::L1Phase2MuDTShower( + int bx, int wh, int sc, int st, int ndigis, float avg_pos, float avg_time) + : m_bx(bx), + m_wheel(wh), + m_sector(sc), + m_station(st), + m_ndigis(ndigis), + m_avg_pos(avg_pos), + m_avg_time(avg_time) {} + +//-------------- +// Operations -- +//-------------- + +int L1Phase2MuDTShower::whNum() const { return m_wheel; } + +int L1Phase2MuDTShower::scNum() const { return m_sector; } + +int L1Phase2MuDTShower::stNum() const { return m_station; } + +int L1Phase2MuDTShower::bxNum() const { return m_bx; } + +int L1Phase2MuDTShower::ndigis() const { return m_ndigis; } + +float L1Phase2MuDTShower::avg_time() const { return m_avg_time; } + +float L1Phase2MuDTShower::avg_pos() const { return m_avg_pos; } diff --git a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc new file mode 100644 index 0000000000000..3ac836edf44ad --- /dev/null +++ b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc @@ -0,0 +1,41 @@ +//------------------------------------------------- +// +// Class L1MuDTChambContainer +// +// Description: trigger primtive data for the +// muon barrel Phase2 trigger +// +// +// Author List: Federica Primavera Bologna INFN +// +// +//-------------------------------------------------- + +//----------------------- +// This Class's Header -- +//----------------------- +#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h" + +//------------------------------- +// Collaborating Class Headers -- +//------------------------------- + +//--------------- +// C++ Headers -- +//--------------- + +//------------------- +// Initializations -- +//------------------- + +//---------------- +// Constructors -- +//---------------- +L1Phase2MuDTShowerContainer::L1Phase2MuDTShowerContainer() {} + +//-------------- +// Operations -- +//-------------- +void L1Phase2MuDTShowerContainer::setContainer(const Shower_Container& inputShowers) { m_showers = inputShowers; } + +L1Phase2MuDTShowerContainer::Shower_Container const* L1Phase2MuDTShowerContainer::getContainer() const { return &m_showers; } diff --git a/DataFormats/L1DTTrackFinder/src/classes.h b/DataFormats/L1DTTrackFinder/src/classes.h index aa47c56aba378..efcd0d5612165 100644 --- a/DataFormats/L1DTTrackFinder/src/classes.h +++ b/DataFormats/L1DTTrackFinder/src/classes.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -12,4 +13,5 @@ #include #include #include +#include #include diff --git a/DataFormats/L1DTTrackFinder/src/classes_def.xml b/DataFormats/L1DTTrackFinder/src/classes_def.xml index c1d75472d0e9f..3c8732ffc2658 100644 --- a/DataFormats/L1DTTrackFinder/src/classes_def.xml +++ b/DataFormats/L1DTTrackFinder/src/classes_def.xml @@ -16,6 +16,14 @@ + + + + + + + + @@ -28,6 +36,7 @@ + @@ -42,6 +51,11 @@ + + + + + @@ -55,5 +69,6 @@ + diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h b/L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h new file mode 100644 index 0000000000000..5e622becb35c9 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h @@ -0,0 +1,44 @@ +#ifndef L1Trigger_DTTriggerPhase2_ShowerBuffer_h +#define L1Trigger_DTTriggerPhase2_ShowerBuffer_h +#include +#include + +#include "L1Trigger/DTTriggerPhase2/interface/DTprimitive.h" + +class ShowerBuffer { +public: + ShowerBuffer(); + virtual ~ShowerBuffer() {} + + // setter methods + void addHit(DTPrimitive &prim); + void rawId(int rawId) { rawId_ = rawId;} + + // Get nHits + int getNhits() { return nprimitives_; } + bool isFlagged(){return shower_flag_;} + DTPrimitivePtrs getHits() { return prim_; } + + // Other methods + int getRawId(){return rawId_;} + void flag(){shower_flag_ = true;} + +private: + //------------------------------------------------------------------ + //--- ShowerBuffer's data + //------------------------------------------------------------------ + /* + Primitives that make up the path. The 0th position holds the channel ID of + the lower layer. The order is critical. + */ + DTPrimitivePtrs prim_; + short nprimitives_; + int rawId_; + bool shower_flag_; +}; + +typedef std::vector ShowerBuffers; +typedef std::shared_ptr ShowerBufferPtr; +typedef std::vector ShowerBufferPtrs; + +#endif diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h b/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h new file mode 100644 index 0000000000000..7bb3d2c3f9916 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h @@ -0,0 +1,46 @@ +#ifndef L1Trigger_DTTriggerPhase2_ShowerCandidate_h +#define L1Trigger_DTTriggerPhase2_ShowerCandidate_h +#include +#include + +#include "L1Trigger/DTTriggerPhase2/interface/DTprimitive.h" +#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h" + +class ShowerCandidate { +public: + ShowerCandidate(); + ShowerCandidate(ShowerBuffer& buff); + ShowerCandidate(ShowerBufferPtr& buffPtr); + virtual ~ShowerCandidate() {} + + // setter methods + void rawId(int rawId) { rawId_ = rawId;} + void setAvgTime(); + void setAvgPos(); + + // Get nHits + int getNhits() { return nhits_; } + + // Other methods + int getRawId(){return rawId_;} + float getAvgTime() {return avgTime_;} + float getAvgPos() {return avgPos_;}; + + +private: + //------------------------------------------------------------------ + //--- ShowerCandidate's data + //------------------------------------------------------------------ + DTPrimitivePtrs hits_; + int nhits_; + int rawId_; + + float avgTime_; + float avgPos_; +}; + +typedef std::vector ShowerCandidates; +typedef std::shared_ptr ShowerCandidatePtr; +typedef std::vector ShowerCandidatePtrs; + +#endif diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h b/L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h new file mode 100644 index 0000000000000..b586695047c75 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h @@ -0,0 +1,100 @@ +#ifndef Phase2L1Trigger_DTTrigger_ShowerGrouping_h +#define Phase2L1Trigger_DTTrigger_ShowerGrouping_h + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Run.h" + +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" +#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h" +#include "L1Trigger/DTTriggerPhase2/interface/constants.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/DTGeometry/interface/DTLayer.h" + +#include +#include + +// =============================================================================== +// Previous definitions and declarations +// =============================================================================== + +// =============================================================================== +// Class declarations +// =============================================================================== + +bool hitWireSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) +{ + int wi1 = hit1.channelId(); + int wi2 = hit2.channelId(); + + if (wi1 < wi2) return true; + else return false; +} + +bool hitLayerSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) +{ + int lay1 = hit1.layerId(); + int lay2 = hit2.layerId(); + + if (lay1 < lay2) return true; + else if (lay1 > lay2) return false; + else return hitWireSort_shower(hit1, hit2); +} + +bool hitTimeSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) +{ + int tdc1 = hit1.tdcTimeStamp(); + int tdc2 = hit2.tdcTimeStamp(); + + if (tdc1 < tdc2) return true; + else if (tdc1 > tdc2) return false; + else return hitLayerSort_shower(hit1, hit2); +} + +class ShowerGrouping { + +public: + // Constructors and destructor + ShowerGrouping(const edm::ParameterSet& pset, edm::ConsumesCollector& iC); + virtual ~ShowerGrouping(); + + // Main methods + virtual void initialise(const edm::EventSetup& iEventSetup); + virtual void run(edm::Event& iEvent, + const edm::EventSetup& iEventSetup, + const DTDigiCollection& digis, + ShowerBufferPtr &showerBuffer); + virtual void finish(); + + // Other public methods + + // Public attributes + +private: + // Private methods + void setInChannels(const DTDigiCollection* digi); + void clearChannels(); + void sortHits(); + bool hitWireSort(const DTPrimitive& hit1, const DTPrimitive& hit2); + bool hitLayerSort(const DTPrimitive& hit1, const DTPrimitive& hit2); + bool hitTimeSort(const DTPrimitive& hit1, const DTPrimitive& hit2); + bool triggerShower(const ShowerBufferPtr& showerBuf); + + // Private attributes + const bool debug_; + + const int nHits_per_bx; + const int threshold_for_shower; + DTPrimitives channelIn_[cmsdt::NUM_LAYERS_2SL][cmsdt::NUM_CH_PER_LAYER]; + DTPrimitives chInDummy_; + DTPrimitives all_hits; + std::map all_hits_perBx; + int showerTaggingAlgo_; + int currentBaseChannel_; + +}; + +#endif diff --git a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc new file mode 100644 index 0000000000000..7a57751ef29ab --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc @@ -0,0 +1,249 @@ +/* + EDProducer class for shower computation in Phase2 DTs. + Author: Carlos Vico Villalba (U. Oviedo) +*/ + +// Include CMSSW plugins +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/Framework/interface/ModuleFactory.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESProducts.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Run.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +// Include Geometry plugins +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/DTGeometry/interface/DTLayer.h" + +// Phase2 trigger dataformats +#include "L1Trigger/DTTriggerPhase2/interface/constants.h" +#include "DataFormats/MuonDetId/interface/DTChamberId.h" +#include "DataFormats/MuonDetId/interface/DTSuperLayerId.h" +#include "DataFormats/MuonDetId/interface/DTLayerId.h" +#include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" +#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h" +#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h" + +// Functionalities +#include "L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h" +#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h" +#include "L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h" + +// DT trigger GeomUtils +#include "DQM/DTMonitorModule/interface/DTTrigGeomUtils.h" + + +// C++ built-ins +#include +#include +#include +#include + +using namespace edm; +using namespace std; +using namespace cmsdt; + +class DTTrigPhase2ShowerProd : public edm::stream::EDProducer<> { + /* Declaration of the plugin */ + + // Types + typedef std::map> DTDigiMap; + typedef DTDigiMap::iterator DTDigiMap_iterator; + typedef DTDigiMap::const_iterator DTDigiMap_const_iterator; + + + public: + // Public methods/attributes + + //! Constructor + DTTrigPhase2ShowerProd(const edm::ParameterSet& pset); + + //! Destructor + ~DTTrigPhase2ShowerProd() override; + + //! Create Trigger Units before starting event processing + void beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) override; + + //! Producer: process every event and generates trigger data + void produce(edm::Event& iEvent, const edm::EventSetup& iEventSetup) override; + + //! endRun: finish things + void endRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) override; + + // Members + const DTGeometry* dtGeo_; + edm::ESGetToken dtGeomH; + + private: + // Private methods/attributes + bool debug_; // Debug flag + int nHits_per_bx_; // Number of hits sent by the OBDT per bx + edm::InputTag digiTag_; // Digi collection label + edm::EDGetTokenT dtDigisToken_; // Digi container + std::unique_ptr showerBuilder; + + + void ShowerDebugger(string msg, int vlevel); + protected: + // Protected methods/attributes +}; + +/* Implementation of the plugin */ +DTTrigPhase2ShowerProd::DTTrigPhase2ShowerProd(const ParameterSet& pset) { + // Constructor implementation + produces(); + + // Unpack information from pset + debug_ = pset.getUntrackedParameter("debug"); + digiTag_ = pset.getParameter("digiTag"); + nHits_per_bx_ = pset.getParameter("nHits_per_bx"); + + // Fetch consumes + dtDigisToken_ = consumes(digiTag_); + + // Algorithm functionalities + edm::ConsumesCollector consumesColl(consumesCollector()); + showerBuilder = std::make_unique(pset, consumesColl); + + // Load geometry + dtGeomH = esConsumes(); + +} + +DTTrigPhase2ShowerProd::~DTTrigPhase2ShowerProd() { + // Destructor implementation +} + +void DTTrigPhase2ShowerProd::beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) { + // beginRun implementation + if (debug_) ShowerDebugger("DTTrigPhase2ShowerProd::beginRun beginRun started", 1); + + showerBuilder->initialise(iEventSetup); + if (auto geom = iEventSetup.getHandle(dtGeomH)) { + dtGeo_ = &(*geom); + } +} + +void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& iEventSetup) { + // produce implementation + if (debug_) ShowerDebugger("DTTrigPhase2ShowerProd::produce Processing event", 1); + + // Fetch the handle for hits + edm::Handle dtdigis; + iEvent.getByToken(dtDigisToken_, dtdigis); + + // 1. Preprocessing: store digi information by chamber + DTDigiMap digiMap; + DTDigiCollection::DigiRangeIterator detUnitIt; + if (debug_) ShowerDebugger("Preprocessing hits...", 2); + for (const auto& detUnitIt : *dtdigis) { + const DTLayerId& layId = detUnitIt.first; + const DTChamberId chambId = layId.superlayerId().chamberId(); + const DTDigiCollection::Range& digi_range = detUnitIt.second; // This is the digi collection + digiMap[chambId].put( digi_range, layId ); + } + + if (debug_) ShowerDebugger("Hits preprocessed.", 2); + + // 2. Look for showers in each station + if (debug_) ShowerDebugger("Searching for showers!", 2); + std::map ShowerBuffers; + for (const auto& ich : dtGeo_->chambers()) { + const DTChamber* chamb = ich; + DTChamberId chid = chamb->id(); + DTDigiMap_iterator dmit = digiMap.find(chid); + + if (dmit == digiMap.end()) + continue; + showerBuilder->run(iEvent, iEventSetup, (*dmit).second, ShowerBuffers[chid.rawId()] ); + + // Save the rawId of this shower + ShowerBuffers[chid.rawId()]->rawId( chid.rawId() ); + } + + // 3. Build shower candidates + if (debug_) ShowerDebugger("Building shower candidates!", 2); + + std::map showerCands; + for (auto& ch_showerBuf : ShowerBuffers) { + // In normal conditions, there's just one buffer per event. + // when considering delays from OBDT, there might be multiple ones + + auto showerBufIt = ch_showerBuf.second; + if (showerBufIt->isFlagged()) { + if (debug_) ShowerDebugger("Building a shower candidate", 3); + + DTChamberId chId(showerBufIt->getRawId()); + + // Create the candidate + auto showerCand = std::make_shared(showerBufIt); + auto rawId = showerBufIt->getRawId(); + + if (debug_) { + ShowerDebugger(" - Properties of this shower candidate:", 3); + ShowerDebugger("Wheel:" + std::to_string(chId.wheel()) , 4); + ShowerDebugger("Sector:" + std::to_string(chId.sector()-1) , 4); + ShowerDebugger("Station:" + std::to_string(chId.station()) , 4); + ShowerDebugger("nHits:" + std::to_string(showerCand->getNhits()) , 4); + ShowerDebugger("avgPos:" + std::to_string(showerCand->getAvgPos()) , 4); + ShowerDebugger("avgTime:" + std::to_string(showerCand->getAvgTime()) , 4); + } + + showerCands[rawId] = std::move(showerCand); + } + } + if (debug_) ShowerDebugger("Storing results!", 2); + + // 4. Storing results + std::vector outShower; + for (auto &chamber_showerCand : showerCands) { + auto showerCandIt = chamber_showerCand.second; + DTChamberId chId(showerCandIt->getRawId()); + + outShower.emplace_back( + L1Phase2MuDTShower( + -1, // BX + chId.wheel(), // Wheel + chId.sector()-1, // Sector + chId.station(), // Station + showerCandIt->getNhits(), // number of digis + showerCandIt->getAvgPos(), // Average position + showerCandIt->getAvgTime() // AVerage time + ) + ); + } + + std::unique_ptr resultShower(new L1Phase2MuDTShowerContainer); + resultShower->setContainer(outShower); + iEvent.put(std::move(resultShower)); + +} + +void DTTrigPhase2ShowerProd::endRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) { + // endRun implementation +} + +void DTTrigPhase2ShowerProd::ShowerDebugger(string msg, int vlevel){ + /* Debugger */ + int indent = vlevel*2; // Each vlevel is a 2 space indent + string indent_txt = string(indent, ' '); + auto indented_msg = indent_txt + msg; + if (vlevel == 1) cout << indent_txt << ">> " << msg << endl; + if (vlevel == 2) cout << indent_txt << "* " << msg << endl; + if (vlevel == 3) cout << indent_txt << "+ " << msg << endl; + if (vlevel == 4) cout << indent_txt << " " << msg << endl; +} + + +DEFINE_FWK_MODULE(DTTrigPhase2ShowerProd); diff --git a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py new file mode 100644 index 0000000000000..ccecfdcf12e16 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py @@ -0,0 +1,12 @@ +""" Basic config for running showers in Phase2 """ +import FWCore.ParameterSet.Config as cms + +from L1TriggerConfig.DTTPGConfigProducers.L1DTTPGConfigFromDB_cff import * + +dtTriggerPhase2Shower = cms.EDProducer("DTTrigPhase2ShowerProd", + digiTag = cms.InputTag("CalibratedDigis"), + nHits_per_bx = cms.int32(3), + threshold_for_shower = cms.int32(20), + showerTaggingAlgo = cms.int32(1), + debug = cms.untracked.bool(True)) + diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerBuffer.cc b/L1Trigger/DTTriggerPhase2/src/ShowerBuffer.cc new file mode 100644 index 0000000000000..85be0435c266c --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/src/ShowerBuffer.cc @@ -0,0 +1,18 @@ +#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h" + +#include +#include +#include + +using namespace cmsdt; + +ShowerBuffer::ShowerBuffer() { + nprimitives_ = 0; + shower_flag_ = false; +} + +void ShowerBuffer::addHit(DTPrimitive &prim){ + prim_.push_back(std::make_shared(prim)); + nprimitives_++; +} + diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc b/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc new file mode 100644 index 0000000000000..72ede0468ff25 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc @@ -0,0 +1,49 @@ +#include "L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h" + +#include +#include +#include + +using namespace cmsdt; + +ShowerCandidate::ShowerCandidate() { + nhits_ = 0; + avgTime_ = 0; + avgPos_ = 0; +} + +ShowerCandidate::ShowerCandidate(ShowerBuffer& buff){ + nhits_ = buff.getNhits(); + rawId_ = buff.getRawId(); + for ( auto& hit : buff.getHits() ){ + hits_.push_back(hit); + } +} + +ShowerCandidate::ShowerCandidate(ShowerBufferPtr& buffPtr){ + nhits_ = buffPtr->getNhits(); + rawId_ = buffPtr->getRawId(); + for ( auto& hit : buffPtr->getHits() ){ + hits_.push_back(hit); + } + + // Set properties of the shower candidate + setAvgTime(); + setAvgPos(); +} + + +void ShowerCandidate::setAvgPos() { + // Sets the average position in X axis + for (auto& hit : hits_) { + avgPos_ = avgPos_ + hit->wireHorizPos(); + } + avgPos_ = avgPos_ / nhits_; +} + +void ShowerCandidate::setAvgTime() { + for (auto& hit : hits_) { + avgTime_ = avgTime_ + hit->tdcTimeStamp(); + } + avgTime_ = avgTime_ / nhits_; +} diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerGrouping.cc b/L1Trigger/DTTriggerPhase2/src/ShowerGrouping.cc new file mode 100644 index 0000000000000..ce9664d17072f --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/src/ShowerGrouping.cc @@ -0,0 +1,136 @@ +#include "L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h" +#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +using namespace edm; +using namespace std; +using namespace cmsdt; + +// ============================================================================ +// Constructors and destructor +// ============================================================================ +ShowerGrouping::ShowerGrouping(const ParameterSet& pset, edm::ConsumesCollector& iC) : + debug_(pset.getUntrackedParameter("debug")), + nHits_per_bx(pset.getParameter("nHits_per_bx")), + threshold_for_shower(pset.getParameter("threshold_for_shower")), + showerTaggingAlgo_(pset.getParameter("showerTaggingAlgo")), + currentBaseChannel_(-1) { + + // Initialise channelIn array + chInDummy_.push_back(DTPrimitive()); + for (int lay = 0; lay < NUM_LAYERS_2SL; lay++) { + for (int ch = 0; ch < NUM_CH_PER_LAYER; ch++) { + channelIn_[lay][ch] = {chInDummy_}; + channelIn_[lay][ch].clear(); + } + } +} + +ShowerGrouping::~ShowerGrouping() {} + +// ============================================================================ +// Main methods (initialise, run, finish) +// ============================================================================ +void ShowerGrouping::initialise(const edm::EventSetup& iEventSetup) {} + +void ShowerGrouping::run(Event& iEvent, + const EventSetup& iEventSetup, + const DTDigiCollection& digis, + ShowerBufferPtr &showerBuffer) { + /* This function returns the analyzable shower collection */ + + // Clear channels from previous event + clearChannels(); + + // Set the incoming hits in the channels + setInChannels(&digis); + + // Now sort them by time + sortHits(); + if (debug_) std::cout << " + Going to study " << all_hits.size() << " hits" << std::endl; + auto showerBuf = std::make_shared(); + + // Create a buffer + for (auto &hit : all_hits) { + // Standalone mode: just save hits in buffer + showerBuf->addHit(hit); + + // TBD: add OBDT delays + } + + if (triggerShower(showerBuf)) { + + if (debug_) std::cout << " o Shower found with " << all_hits.size() << " hits" << std::endl; + showerBuf->flag(); + } + showerBuffer = std::move(showerBuf); + //std::cout << "Shower has " << showerBuf->getNhits() << std::endl; +} + +bool ShowerGrouping::triggerShower(const ShowerBufferPtr& showerBuf) { + // Method to apply shower tagging logic + + auto nHits = showerBuf->getNhits(); + bool tagged_shower = false; + + if (showerTaggingAlgo_ == 1) { + // Method v1: pure counting is over a given threshold + if (nHits >= threshold_for_shower) { + tagged_shower = true; + } + } + if (showerTaggingAlgo_ == 2) { + // Method v2: correlate hits based on distance + // TO BE IMPLEMENTED + return tagged_shower; + } + return tagged_shower; +} + +void ShowerGrouping::clearChannels() { + // This function clears channelIn and allHits collections. + for (int lay = 0; lay < NUM_LAYERS_2SL; lay++) { + if (debug_) std::cout << " o Clearing hits in layer " << lay << std::endl; + for (int ch = 0; ch < NUM_CH_PER_LAYER; ch++) { + channelIn_[lay][ch].clear(); + } + } + all_hits.clear(); +} + +void ShowerGrouping::setInChannels(const DTDigiCollection *digis) { + + for (const auto &dtLayerId_It : *digis) { + const DTLayerId dtLId = dtLayerId_It.first; + + // Now iterate over the digis + for (DTDigiCollection::const_iterator digiIt = (dtLayerId_It.second).first; digiIt != (dtLayerId_It.second).second; + ++digiIt) { + int layer = dtLId.layer() - 1; + int wire = (*digiIt).wire() - 1; + int digiTIME = (*digiIt).time(); + int digiTIMEPhase2 = digiTIME; + + auto dtpAux = DTPrimitive(); + dtpAux.setTDCTimeStamp(digiTIMEPhase2); + dtpAux.setChannelId(wire); + dtpAux.setLayerId(layer); // L=0,1,2,3 + dtpAux.setSuperLayerId(dtLId.superlayer()); // SL=0,1,2 + dtpAux.setCameraId(dtLId.rawId()); + channelIn_[layer][wire].push_back(dtpAux); + all_hits.push_back(dtpAux); + } + } +} + +void ShowerGrouping::sortHits() { + // Sort everything by the time of the hits, so it has the same behaviour as the fw + for (int lay = 0; lay < NUM_LAYERS_2SL; lay++) { + for (int ch = 0; ch < NUM_CH_PER_LAYER; ch++) { + std::stable_sort(channelIn_[lay][ch].begin(), channelIn_[lay][ch].end(), hitTimeSort_shower); + } + } + std::stable_sort(all_hits.begin(), all_hits.end(), hitTimeSort_shower); +} + +void ShowerGrouping::finish(){}; From 55ff2d34362bd2fa78f6180386d1c6b70f52fd1e Mon Sep 17 00:00:00 2001 From: Daniel Estrada Date: Thu, 6 Mar 2025 22:00:01 +0100 Subject: [PATCH 09/19] Refactor DTTrigPh2ShowerProducer change pluging to manage emulation of DT Muon Shower firmware algorithm v 0.2.0 --- .../interface/L1Phase2MuDTShower.h | 39 ++- .../L1DTTrackFinder/src/L1Phase2MuDTShower.cc | 46 ++- .../L1DTTrackFinder/src/classes_def.xml | 4 +- .../DTTriggerPhase2/interface/ShowerBuffer.h | 44 --- .../DTTriggerPhase2/interface/ShowerBuilder.h | 175 +++++++++++ .../interface/ShowerCandidate.h | 70 +++-- .../interface/ShowerGrouping.h | 100 ------ .../plugins/DTTrigPhase2ShowerProd.cc | 178 ++++++----- .../python/dtTriggerPhase2Showers_cfi.py | 10 +- L1Trigger/DTTriggerPhase2/src/ShowerBuffer.cc | 18 -- .../DTTriggerPhase2/src/ShowerBuilder.cc | 296 ++++++++++++++++++ .../DTTriggerPhase2/src/ShowerCandidate.cc | 57 ++-- .../DTTriggerPhase2/src/ShowerGrouping.cc | 136 -------- 13 files changed, 695 insertions(+), 478 deletions(-) delete mode 100644 L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h create mode 100644 L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h delete mode 100644 L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h delete mode 100644 L1Trigger/DTTriggerPhase2/src/ShowerBuffer.cc create mode 100644 L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc delete mode 100644 L1Trigger/DTTriggerPhase2/src/ShowerGrouping.cc diff --git a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h index c945d0476f700..1bb0277b34a8f 100644 --- a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h +++ b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h @@ -6,8 +6,11 @@ // muon barrel Phase2 trigger // // -// Author List: Carlos Vico Oviedo Spain -// +// Author List: +// Federica Primavera Bologna INFN +// Carlos Vico Oviedo Spain, +// Daniel Estrada Acevedo Oviedo Spain. +// // //-------------------------------------------------- #ifndef L1Phase2MuDTShower_H @@ -24,6 +27,7 @@ //--------------- // C++ Headers -- //--------------- +#include // --------------------- // -- Class Interface -- @@ -34,40 +38,49 @@ class L1Phase2MuDTShower { // Constructors L1Phase2MuDTShower(); - L1Phase2MuDTShower(int bx, // BX estimation - int wh, // Wheel + L1Phase2MuDTShower(int wh, // Wheel int sc, // Sector int st, // Station + int sl, // Superlayer int ndigis, // Number of digis within shower + int bx, // BX estimation + int min_wire, // Minimum wire + int max_wire, // Maximum wire float avg_pos, // Averaged position of the shower - float avg_time); // Averaged time of the shower + float avg_time, // Averaged time of the shower + const std::vector wires_profile // Wires profile + ); virtual ~L1Phase2MuDTShower(){}; // Operations - int bxNum() const; - + int whNum() const; int scNum() const; int stNum() const; - + int slNum() const; int ndigis() const; + int bxNum() const; + int minWire() const; + int maxWire() const; float avg_time() const; float avg_pos() const; - + std::vector wiresProfile() const; + private: - int m_bx; - int m_wheel; int m_sector; int m_station; - + int m_superlayer; int m_ndigis; + int m_bx; + int m_min_wire; + int m_max_wire; float m_avg_pos; float m_avg_time; - + std::vector m_wires_profile; }; #endif diff --git a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc index a897f7c8ee624..6b23c86ddf72d 100644 --- a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc +++ b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc @@ -6,7 +6,10 @@ // muon barrel Phase2 trigger // // -// Author List: Federica Primavera Bologna INFN +// Author List: +// Federica Primavera Bologna INFN +// Carlos Vico Oviedo Spain, +// Daniel Estrada Acevedo Oviedo Spain. // // //-------------------------------------------------- @@ -32,23 +35,32 @@ // Constructors -- //---------------- L1Phase2MuDTShower::L1Phase2MuDTShower() - : m_bx(-100), - m_wheel(0), + : m_wheel(0), m_sector(0), m_station(0), + m_superlayer(0), m_ndigis(0), + m_bx(-100), + m_min_wire(0), + m_max_wire(0), m_avg_pos(0), - m_avg_time(0) {} + m_avg_time(0) { + m_wires_profile.resize(96, 0); + } L1Phase2MuDTShower::L1Phase2MuDTShower( - int bx, int wh, int sc, int st, int ndigis, float avg_pos, float avg_time) - : m_bx(bx), - m_wheel(wh), - m_sector(sc), - m_station(st), - m_ndigis(ndigis), - m_avg_pos(avg_pos), - m_avg_time(avg_time) {} + int wh, int sc, int st, int sl, int ndigis, int bx, int min_wire, int max_wire, float avg_pos, float avg_time, const std::vector wires_profile) + : m_wheel(wh), + m_sector(sc), + m_station(st), + m_superlayer(sl), + m_ndigis(ndigis), + m_bx(bx), + m_min_wire(min_wire), + m_max_wire(max_wire), + m_avg_pos(avg_pos), + m_avg_time(avg_time), + m_wires_profile(wires_profile) {} //-------------- // Operations -- @@ -60,10 +72,18 @@ int L1Phase2MuDTShower::scNum() const { return m_sector; } int L1Phase2MuDTShower::stNum() const { return m_station; } -int L1Phase2MuDTShower::bxNum() const { return m_bx; } +int L1Phase2MuDTShower::slNum() const { return m_superlayer; } int L1Phase2MuDTShower::ndigis() const { return m_ndigis; } +int L1Phase2MuDTShower::bxNum() const { return m_bx; } + +int L1Phase2MuDTShower::minWire() const { return m_min_wire; } + +int L1Phase2MuDTShower::maxWire() const { return m_max_wire; } + float L1Phase2MuDTShower::avg_time() const { return m_avg_time; } float L1Phase2MuDTShower::avg_pos() const { return m_avg_pos; } + +std::vector L1Phase2MuDTShower::wiresProfile() const { return m_wires_profile; } diff --git a/DataFormats/L1DTTrackFinder/src/classes_def.xml b/DataFormats/L1DTTrackFinder/src/classes_def.xml index 3c8732ffc2658..53db08b4fbd30 100644 --- a/DataFormats/L1DTTrackFinder/src/classes_def.xml +++ b/DataFormats/L1DTTrackFinder/src/classes_def.xml @@ -17,7 +17,9 @@ - + + + diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h b/L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h deleted file mode 100644 index 5e622becb35c9..0000000000000 --- a/L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef L1Trigger_DTTriggerPhase2_ShowerBuffer_h -#define L1Trigger_DTTriggerPhase2_ShowerBuffer_h -#include -#include - -#include "L1Trigger/DTTriggerPhase2/interface/DTprimitive.h" - -class ShowerBuffer { -public: - ShowerBuffer(); - virtual ~ShowerBuffer() {} - - // setter methods - void addHit(DTPrimitive &prim); - void rawId(int rawId) { rawId_ = rawId;} - - // Get nHits - int getNhits() { return nprimitives_; } - bool isFlagged(){return shower_flag_;} - DTPrimitivePtrs getHits() { return prim_; } - - // Other methods - int getRawId(){return rawId_;} - void flag(){shower_flag_ = true;} - -private: - //------------------------------------------------------------------ - //--- ShowerBuffer's data - //------------------------------------------------------------------ - /* - Primitives that make up the path. The 0th position holds the channel ID of - the lower layer. The order is critical. - */ - DTPrimitivePtrs prim_; - short nprimitives_; - int rawId_; - bool shower_flag_; -}; - -typedef std::vector ShowerBuffers; -typedef std::shared_ptr ShowerBufferPtr; -typedef std::vector ShowerBufferPtrs; - -#endif diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h new file mode 100644 index 0000000000000..e19b66d7918ee --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h @@ -0,0 +1,175 @@ +#ifndef Phase2L1Trigger_DTTrigger_ShowerBuilder_h +#define Phase2L1Trigger_DTTrigger_ShowerBuilder_h + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Run.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" +#include "L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h" +#include "L1Trigger/DTTriggerPhase2/interface/constants.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/DTGeometry/interface/DTLayer.h" + +#include +#include + +// =============================================================================== +// Previous definitions and declarations +// =============================================================================== + +namespace showerb { + typedef std::pair DTPrimPlusBx; + typedef std::deque ShowerBuffer; + + bool hitWireSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2){ + int wi1 = hit1.channelId(); + int wi2 = hit2.channelId(); + + if (wi1 < wi2) return true; + else return false; + } + + bool hitLayerSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) { + int lay1 = hit1.layerId(); + int lay2 = hit2.layerId(); + + if (lay1 < lay2) return true; + else if (lay1 > lay2) return false; + else return hitWireSort_shower(hit1, hit2); + } + + bool hitTimeSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) { + int tdc1 = hit1.tdcTimeStamp(); + int tdc2 = hit2.tdcTimeStamp(); + + if (tdc1 < tdc2) return true; + else return false; + // else if (tdc1 > tdc2) return false; + // else return hitLayerSort_shower(hit1, hit2); --> ignoring those sortings for now + } + + float compute_avg_pos(DTPrimitives& hits) { + int nhits_ = hits.size(); + + if (nhits_ == 0) return -1.0; + + float aux_avgPos_ = 0; + + for (auto& hit : hits) { + aux_avgPos_ += hit.wireHorizPos(); + } + + return aux_avgPos_ / nhits_; + } + + float compute_avg_time(DTPrimitives& hits) { + int nhits_ = hits.size(); + + if (nhits_ == 0) return -1.0; + + float aux_avgTime_ = 0; + + for (auto& hit : hits) { + aux_avgTime_ += hit.tdcTimeStamp(); + } + return aux_avgTime_ / nhits_; + } + + void set_wires_profile(std::vector& wires_profile, DTPrimitives& hits) { + for (auto& hit : hits) { + wires_profile[hit.channelId()-1]++; + } + } + + bool buffer_contains(const ShowerBuffer& buffer, const DTPrimitive& hit) { + for (const auto& item : buffer) { + if (item.second.channelId() == hit.channelId()) return true; + } + return false; + } + + void buffer_get_hits(const ShowerBuffer& buffer, DTPrimitives& hits) { + for (const auto& item : buffer) { + hits.push_back(item.second); + } + } + + void buffer_clear_olds(ShowerBuffer& buffer, const int _current_bx, const int persistence_bx_units) { + while (!buffer.empty() && (_current_bx - buffer.front().first) > persistence_bx_units) { + buffer.pop_front(); + } + } + + void buffer_reset(ShowerBuffer& buffer) { + buffer.clear(); + } +} + +// =============================================================================== +// Class declarations +// =============================================================================== + +class ShowerBuilder { + +public: + // Constructors and destructor + ShowerBuilder(const edm::ParameterSet& pset, edm::ConsumesCollector& iC); + virtual ~ShowerBuilder(); + + // Main methods + virtual void initialise(const edm::EventSetup& iEventSetup); + virtual void run(edm::Event& iEvent, + const edm::EventSetup& iEventSetup, + const DTDigiCollection& digis, + ShowerCandidatePtr &showerCandidate_SL1, + ShowerCandidatePtr &showerCandidate_SL3); + virtual void finish(); + +private: + // Private auxiliary methods + void clear(); + void setInChannels(const DTDigiCollection* digi); + void processHits_standAlone(std::map &showerCands); + void processHitsFirmwareEmulation(std::map &showerCands); + + bool triggerShower(const showerb::ShowerBuffer& buffer); + void set_shower_properties( + ShowerCandidatePtr &showerCand, + showerb::ShowerBuffer& buffer, + int nhits = -1, + int bx = -1, + int min_wire = -1, + int max_wire = -1, + float avg_pos = -1., + float avg_time = -1. + ); + void groupHits_byBx(); + void fill_obdt(const int bx); + void fill_bmtl1_buffers(); + void bxStep(const int _current_bx); + + // Private attributes + const int showerTaggingAlgo_; + const int threshold_for_shower_; + const int nHits_per_bx_; + const int obdt_hits_bxpersistence_; + const int obdt_wire_relaxing_time_; + const int bmtl1_hits_bxpersistence_; + const bool debug_; + const int scenario_; + + // auxiliary variables + DTPrimitives all_hits; + std::map> all_hits_perBx; + showerb::ShowerBuffer obdt_buffer; // Buffer to emulate the OBDT behavior + showerb::ShowerBuffer hot_wires_buffer; // Buffer to emulate the hot wires behavior + showerb::ShowerBuffer bmtl1_sl1_buffer; // Buffer to emulate the BMTL1 shower buffer for SL1 + showerb::ShowerBuffer bmtl1_sl3_buffer; // Buffer to emulate the BMTL1 shower buffer for SL3 +}; + +#endif diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h b/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h index 7bb3d2c3f9916..ac030c5c0d849 100644 --- a/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h @@ -4,39 +4,53 @@ #include #include "L1Trigger/DTTriggerPhase2/interface/DTprimitive.h" -#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h" +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" class ShowerCandidate { public: - ShowerCandidate(); - ShowerCandidate(ShowerBuffer& buff); - ShowerCandidate(ShowerBufferPtr& buffPtr); - virtual ~ShowerCandidate() {} - - // setter methods - void rawId(int rawId) { rawId_ = rawId;} - void setAvgTime(); - void setAvgPos(); - - // Get nHits - int getNhits() { return nhits_; } - - // Other methods - int getRawId(){return rawId_;} - float getAvgTime() {return avgTime_;} - float getAvgPos() {return avgPos_;}; - + ShowerCandidate(); + + ShowerCandidate& operator=(const ShowerCandidate &other); + + virtual ~ShowerCandidate() {} + + // setter methods + void rawId(int rawId) { rawId_ = rawId;} + void setBX(int bx) {bx_ = bx;} + void setNhits(int nhits) {nhits_ = nhits;} + void setMinWire(int wmin) {wmin_ = wmin;} + void setMaxWire(int wmax) {wmax_ = wmax;} + void setAvgPos(float avgPos) {avgPos_ = avgPos;} + void setAvgTime(float avgTime) {avgTime_ = avgTime;} + void flag() {shower_flag_ = true;} + + // getters methods + int getRawId() {return rawId_;} + int getBX() {return bx_;} + int getNhits() { return nhits_; } + int getMinWire() {return wmin_;} + int getMaxWire() {return wmax_;} + float getAvgPos() {return avgPos_;} + float getAvgTime() {return avgTime_;} + std::vector& getWiresProfile() { return wires_profile_; } + bool isFlagged() {return shower_flag_;} + + // Other methods + void clear(); private: - //------------------------------------------------------------------ - //--- ShowerCandidate's data - //------------------------------------------------------------------ - DTPrimitivePtrs hits_; - int nhits_; - int rawId_; - - float avgTime_; - float avgPos_; + //------------------------------------------------------------------ + //--- ShowerCandidate's data + //------------------------------------------------------------------ + int nhits_; + int rawId_; + int bx_; + int wmin_; + int wmax_; + bool shower_flag_; + float avgPos_; + float avgTime_; + std::vector wires_profile_; }; typedef std::vector ShowerCandidates; diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h b/L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h deleted file mode 100644 index b586695047c75..0000000000000 --- a/L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef Phase2L1Trigger_DTTrigger_ShowerGrouping_h -#define Phase2L1Trigger_DTTrigger_ShowerGrouping_h - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/Run.h" - -#include "DataFormats/DTDigi/interface/DTDigiCollection.h" -#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h" -#include "L1Trigger/DTTriggerPhase2/interface/constants.h" - -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "Geometry/DTGeometry/interface/DTLayer.h" - -#include -#include - -// =============================================================================== -// Previous definitions and declarations -// =============================================================================== - -// =============================================================================== -// Class declarations -// =============================================================================== - -bool hitWireSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) -{ - int wi1 = hit1.channelId(); - int wi2 = hit2.channelId(); - - if (wi1 < wi2) return true; - else return false; -} - -bool hitLayerSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) -{ - int lay1 = hit1.layerId(); - int lay2 = hit2.layerId(); - - if (lay1 < lay2) return true; - else if (lay1 > lay2) return false; - else return hitWireSort_shower(hit1, hit2); -} - -bool hitTimeSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) -{ - int tdc1 = hit1.tdcTimeStamp(); - int tdc2 = hit2.tdcTimeStamp(); - - if (tdc1 < tdc2) return true; - else if (tdc1 > tdc2) return false; - else return hitLayerSort_shower(hit1, hit2); -} - -class ShowerGrouping { - -public: - // Constructors and destructor - ShowerGrouping(const edm::ParameterSet& pset, edm::ConsumesCollector& iC); - virtual ~ShowerGrouping(); - - // Main methods - virtual void initialise(const edm::EventSetup& iEventSetup); - virtual void run(edm::Event& iEvent, - const edm::EventSetup& iEventSetup, - const DTDigiCollection& digis, - ShowerBufferPtr &showerBuffer); - virtual void finish(); - - // Other public methods - - // Public attributes - -private: - // Private methods - void setInChannels(const DTDigiCollection* digi); - void clearChannels(); - void sortHits(); - bool hitWireSort(const DTPrimitive& hit1, const DTPrimitive& hit2); - bool hitLayerSort(const DTPrimitive& hit1, const DTPrimitive& hit2); - bool hitTimeSort(const DTPrimitive& hit1, const DTPrimitive& hit2); - bool triggerShower(const ShowerBufferPtr& showerBuf); - - // Private attributes - const bool debug_; - - const int nHits_per_bx; - const int threshold_for_shower; - DTPrimitives channelIn_[cmsdt::NUM_LAYERS_2SL][cmsdt::NUM_CH_PER_LAYER]; - DTPrimitives chInDummy_; - DTPrimitives all_hits; - std::map all_hits_perBx; - int showerTaggingAlgo_; - int currentBaseChannel_; - -}; - -#endif diff --git a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc index 7a57751ef29ab..5456053ae1490 100644 --- a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc +++ b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc @@ -1,6 +1,8 @@ /* - EDProducer class for shower computation in Phase2 DTs. - Author: Carlos Vico Villalba (U. Oviedo) + EDProducer class for shower emulation in Phase2 DTs. + Authors: + - Carlos Vico Villalba (U. Oviedo) + - Daniel Estrada Acevedo (U. Oviedo) */ // Include CMSSW plugins @@ -36,14 +38,12 @@ #include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h" // Functionalities -#include "L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h" -#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h" +#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h" #include "L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h" // DT trigger GeomUtils #include "DQM/DTMonitorModule/interface/DTTrigGeomUtils.h" - // C++ built-ins #include #include @@ -62,7 +62,6 @@ class DTTrigPhase2ShowerProd : public edm::stream::EDProducer<> { typedef DTDigiMap::iterator DTDigiMap_iterator; typedef DTDigiMap::const_iterator DTDigiMap_const_iterator; - public: // Public methods/attributes @@ -80,6 +79,8 @@ class DTTrigPhase2ShowerProd : public edm::stream::EDProducer<> { //! endRun: finish things void endRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); // Members const DTGeometry* dtGeo_; @@ -88,46 +89,51 @@ class DTTrigPhase2ShowerProd : public edm::stream::EDProducer<> { private: // Private methods/attributes bool debug_; // Debug flag - int nHits_per_bx_; // Number of hits sent by the OBDT per bx + int showerTaggingAlgo_; // Shower tagging algorithm edm::InputTag digiTag_; // Digi collection label edm::EDGetTokenT dtDigisToken_; // Digi container - std::unique_ptr showerBuilder; - - - void ShowerDebugger(string msg, int vlevel); - protected: - // Protected methods/attributes + std::unique_ptr showerBuilder; // Shower builder instance }; /* Implementation of the plugin */ DTTrigPhase2ShowerProd::DTTrigPhase2ShowerProd(const ParameterSet& pset) { // Constructor implementation produces(); - // Unpack information from pset debug_ = pset.getUntrackedParameter("debug"); digiTag_ = pset.getParameter("digiTag"); - nHits_per_bx_ = pset.getParameter("nHits_per_bx"); + showerTaggingAlgo_ = pset.getParameter("showerTaggingAlgo"); // Fetch consumes dtDigisToken_ = consumes(digiTag_); // Algorithm functionalities edm::ConsumesCollector consumesColl(consumesCollector()); - showerBuilder = std::make_unique(pset, consumesColl); + showerBuilder = std::make_unique(pset, consumesColl); // Load geometry dtGeomH = esConsumes(); + if (debug_) { + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: constructor" << endl; + if (showerTaggingAlgo_ == 0) { + LogDebug("DTTrigPhase2ShowerProd") << "Using standalone mode" << endl; + } + else if (showerTaggingAlgo_ == 1) { + LogDebug("DTTrigPhase2ShowerProd") << "Using firmware emulation mode" << endl; + } + else LogError("DTTrigPhase2ShowerProd") << "Unrecognized shower tagging algorithm" << endl; + } } DTTrigPhase2ShowerProd::~DTTrigPhase2ShowerProd() { // Destructor implementation + if (debug_) LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: destructor" << endl; } void DTTrigPhase2ShowerProd::beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) { // beginRun implementation - if (debug_) ShowerDebugger("DTTrigPhase2ShowerProd::beginRun beginRun started", 1); + if (debug_) LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: beginRun started" << endl; showerBuilder->initialise(iEventSetup); if (auto geom = iEventSetup.getHandle(dtGeomH)) { @@ -137,7 +143,7 @@ void DTTrigPhase2ShowerProd::beginRun(edm::Run const& iRun, const edm::EventSetu void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& iEventSetup) { // produce implementation - if (debug_) ShowerDebugger("DTTrigPhase2ShowerProd::produce Processing event", 1); + if (debug_) LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: produce Processing event" << endl; // Fetch the handle for hits edm::Handle dtdigis; @@ -146,103 +152,101 @@ void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& // 1. Preprocessing: store digi information by chamber DTDigiMap digiMap; DTDigiCollection::DigiRangeIterator detUnitIt; - if (debug_) ShowerDebugger("Preprocessing hits...", 2); + if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Preprocessing hits..." << endl; + for (const auto& detUnitIt : *dtdigis) { const DTLayerId& layId = detUnitIt.first; const DTChamberId chambId = layId.superlayerId().chamberId(); const DTDigiCollection::Range& digi_range = detUnitIt.second; // This is the digi collection - digiMap[chambId].put( digi_range, layId ); + digiMap[chambId].put(digi_range, layId); } - if (debug_) ShowerDebugger("Hits preprocessed.", 2); + if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Hits preprocessed: " << digiMap.size() + << " DT chambers to analyze" << endl; - // 2. Look for showers in each station - if (debug_) ShowerDebugger("Searching for showers!", 2); - std::map ShowerBuffers; + // 2. Look for showers in each chamber + if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Building shower candidates for:" << endl; + + std::map ShowerCandidates; for (const auto& ich : dtGeo_->chambers()) { const DTChamber* chamb = ich; DTChamberId chid = chamb->id(); DTDigiMap_iterator dmit = digiMap.find(chid); + DTSuperLayerId sl1id = chamb -> superLayer(1) -> id(); + DTSuperLayerId sl3id = chamb -> superLayer(3) -> id(); + if (dmit == digiMap.end()) continue; - showerBuilder->run(iEvent, iEventSetup, (*dmit).second, ShowerBuffers[chid.rawId()] ); - // Save the rawId of this shower - ShowerBuffers[chid.rawId()]->rawId( chid.rawId() ); + if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " " << chid << endl; + + showerBuilder->run(iEvent, iEventSetup, (*dmit).second, ShowerCandidates[sl1id], ShowerCandidates[sl3id]); + + // Save the rawId of these shower candidates + ShowerCandidates[sl1id]->rawId(sl1id.rawId()); + ShowerCandidates[sl3id]->rawId(sl3id.rawId()); } - // 3. Build shower candidates - if (debug_) ShowerDebugger("Building shower candidates!", 2); - - std::map showerCands; - for (auto& ch_showerBuf : ShowerBuffers) { - // In normal conditions, there's just one buffer per event. - // when considering delays from OBDT, there might be multiple ones - - auto showerBufIt = ch_showerBuf.second; - if (showerBufIt->isFlagged()) { - if (debug_) ShowerDebugger("Building a shower candidate", 3); - - DTChamberId chId(showerBufIt->getRawId()); - - // Create the candidate - auto showerCand = std::make_shared(showerBufIt); - auto rawId = showerBufIt->getRawId(); - - if (debug_) { - ShowerDebugger(" - Properties of this shower candidate:", 3); - ShowerDebugger("Wheel:" + std::to_string(chId.wheel()) , 4); - ShowerDebugger("Sector:" + std::to_string(chId.sector()-1) , 4); - ShowerDebugger("Station:" + std::to_string(chId.station()) , 4); - ShowerDebugger("nHits:" + std::to_string(showerCand->getNhits()) , 4); - ShowerDebugger("avgPos:" + std::to_string(showerCand->getAvgPos()) , 4); - ShowerDebugger("avgTime:" + std::to_string(showerCand->getAvgTime()) , 4); - } - - showerCands[rawId] = std::move(showerCand); - } - } - if (debug_) ShowerDebugger("Storing results!", 2); - - // 4. Storing results - std::vector outShower; - for (auto &chamber_showerCand : showerCands) { - auto showerCandIt = chamber_showerCand.second; - DTChamberId chId(showerCandIt->getRawId()); - - outShower.emplace_back( - L1Phase2MuDTShower( - -1, // BX - chId.wheel(), // Wheel - chId.sector()-1, // Sector - chId.station(), // Station - showerCandIt->getNhits(), // number of digis - showerCandIt->getAvgPos(), // Average position - showerCandIt->getAvgTime() // AVerage time - ) - ); + // 3. Check shower candidates and store them if flagged + if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Selecting shower candidates" << endl; + + std::vector outShower; // prepare output container + for (auto& sl_showerCand : ShowerCandidates) { + auto showerCandIt = sl_showerCand.second; + + if (showerCandIt->isFlagged()) { + DTSuperLayerId slId(showerCandIt->getRawId()); + + if (debug_) { + LogDebug("DTTrigPhase2ShowerProd") << " Shower candidate tagged in chamber" + << slId.chamberId() << ", SL" << slId.superlayer(); + } + // 4. Storing results + outShower.emplace_back( + L1Phase2MuDTShower( + slId.wheel(), // Wheel + slId.sector(), // Sector + slId.station(), // Station + slId.superlayer(), // SuperLayer + showerCandIt->getNhits(), // number of digis + showerCandIt->getBX(), // BX + showerCandIt->getMinWire(), // Min wire + showerCandIt->getMaxWire(), // Max wire + showerCandIt->getAvgPos(), // Average position + showerCandIt->getAvgTime(), // Average time + showerCandIt->getWiresProfile() // Wires profile + ) + ); + } } + if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Storing results..." << endl; + // 4.1 Storing results std::unique_ptr resultShower(new L1Phase2MuDTShowerContainer); resultShower->setContainer(outShower); iEvent.put(std::move(resultShower)); - } void DTTrigPhase2ShowerProd::endRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) { // endRun implementation + if (debug_) LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: endRun" << endl; } -void DTTrigPhase2ShowerProd::ShowerDebugger(string msg, int vlevel){ - /* Debugger */ - int indent = vlevel*2; // Each vlevel is a 2 space indent - string indent_txt = string(indent, ' '); - auto indented_msg = indent_txt + msg; - if (vlevel == 1) cout << indent_txt << ">> " << msg << endl; - if (vlevel == 2) cout << indent_txt << "* " << msg << endl; - if (vlevel == 3) cout << indent_txt << "+ " << msg << endl; - if (vlevel == 4) cout << indent_txt << " " << msg << endl; +void DTTrigPhase2ShowerProd::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // dtTriggerPhase2Shower + edm::ParameterSetDescription desc; + desc.add("digiTag", edm::InputTag("CalibratedDigis")); + desc.add("showerTaggingAlgo", 1); + desc.add("threshold_for_shower", 6); + desc.add("nHits_per_bx", 8); + desc.add("obdt_hits_bxpersistence", 4); + desc.add("obdt_wire_relaxing_time", 2); + desc.add("bmtl1_hits_bxpersistence", 16); + desc.add("scenario", 0); + desc.addUntracked("debug", false); + + descriptions.add("dtTriggerPhase2Shower", desc); } diff --git a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py index ccecfdcf12e16..5ba4a46517d82 100644 --- a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py +++ b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py @@ -5,8 +5,12 @@ dtTriggerPhase2Shower = cms.EDProducer("DTTrigPhase2ShowerProd", digiTag = cms.InputTag("CalibratedDigis"), - nHits_per_bx = cms.int32(3), - threshold_for_shower = cms.int32(20), showerTaggingAlgo = cms.int32(1), - debug = cms.untracked.bool(True)) + threshold_for_shower = cms.int32(6), + nHits_per_bx = cms.int32(8), + obdt_hits_bxpersistence = cms.int32(4), + obdt_wire_relaxing_time = cms.int32(2), + bmtl1_hits_bxpersistence = cms.int32(16), + debug = cms.untracked.bool(True), + scenario = cms.int32(0)) diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerBuffer.cc b/L1Trigger/DTTriggerPhase2/src/ShowerBuffer.cc deleted file mode 100644 index 85be0435c266c..0000000000000 --- a/L1Trigger/DTTriggerPhase2/src/ShowerBuffer.cc +++ /dev/null @@ -1,18 +0,0 @@ -#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h" - -#include -#include -#include - -using namespace cmsdt; - -ShowerBuffer::ShowerBuffer() { - nprimitives_ = 0; - shower_flag_ = false; -} - -void ShowerBuffer::addHit(DTPrimitive &prim){ - prim_.push_back(std::make_shared(prim)); - nprimitives_++; -} - diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc b/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc new file mode 100644 index 0000000000000..5f5b5046b59f3 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc @@ -0,0 +1,296 @@ +#include "L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h" +#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +using namespace edm; +using namespace std; +using namespace cmsdt; + +// ============================================================================ +// Constructors and destructor +// ============================================================================ +ShowerBuilder::ShowerBuilder(const ParameterSet& pset, edm::ConsumesCollector& iC) : + // Unpack information from pset + showerTaggingAlgo_(pset.getParameter("showerTaggingAlgo")), + threshold_for_shower_(pset.getParameter("threshold_for_shower")), + nHits_per_bx_(pset.getParameter("nHits_per_bx")), + obdt_hits_bxpersistence_(pset.getParameter("obdt_hits_bxpersistence")), + obdt_wire_relaxing_time_(pset.getParameter("obdt_wire_relaxing_time")), + bmtl1_hits_bxpersistence_(pset.getParameter("bmtl1_hits_bxpersistence")), + debug_(pset.getUntrackedParameter("debug")), + scenario_(pset.getParameter("scenario")) { +} + +ShowerBuilder::~ShowerBuilder() {} + +// ============================================================================ +// Main methods (initialise, run, finish) +// ============================================================================ +void ShowerBuilder::initialise(const edm::EventSetup& iEventSetup) {} + +void ShowerBuilder::run(Event& iEvent, + const EventSetup& iEventSetup, + const DTDigiCollection& digis, + ShowerCandidatePtr &showerCandidate_SL1, + ShowerCandidatePtr &showerCandidate_SL3) { + // Clear auxiliars + clear(); + // Set the incoming hits in the channels + setInChannels(&digis); + + std::map aux_showerCands{ // defined as a map to easy acces with SL number + {1, make_shared()}, + {3, make_shared()} + }; + + int nHits = all_hits.size(); + if (nHits != 0) { + if (debug_) LogDebug("ShowerBuilder") << " - Going to study " << nHits << " hits"; + if (showerTaggingAlgo_ == 0) { + // Standalone mode: just save hits and flag if the number of hits is above the threshold + processHits_standAlone(aux_showerCands); + } + else if (showerTaggingAlgo_ == 1) { + // Firmware emulation: + // mimics the behavior of sending and receiving hits from the OBDT to the shower algorithm in the BMTL1. + processHitsFirmwareEmulation(aux_showerCands); + } + } + else { + if (debug_) LogDebug("ShowerBuilder") << " - No hits to study."; + } + + showerCandidate_SL1 = std::move(aux_showerCands[1]); + showerCandidate_SL3 = std::move(aux_showerCands[3]); +} + +void ShowerBuilder::finish(){}; + +// ============================================================================ +// Auxiliary methods +// ============================================================================ +void ShowerBuilder::clear(){ + all_hits.clear(); + all_hits_perBx.clear(); + showerb::buffer_reset(obdt_buffer); + showerb::buffer_reset(hot_wires_buffer); + showerb::buffer_reset(bmtl1_sl1_buffer); + showerb::buffer_reset(bmtl1_sl3_buffer); +} + +void ShowerBuilder::setInChannels(const DTDigiCollection *digis) { + for (const auto &dtLayerId_It : *digis) { + const DTLayerId id = dtLayerId_It.first; + if (id.superlayer() == 2) continue; // Skip SL2 digis + // Now iterate over the digis + for (DTDigiCollection::const_iterator digiIt = (dtLayerId_It.second).first; + digiIt != (dtLayerId_It.second).second; ++digiIt) { + auto dtpAux = DTPrimitive(); + dtpAux.setTDCTimeStamp((*digiIt).time()); + dtpAux.setChannelId((*digiIt).wire()); + dtpAux.setLayerId(id.layer()); + dtpAux.setSuperLayerId(id.superlayer()); + dtpAux.setCameraId(id.rawId()); + all_hits.push_back(dtpAux); + } + } + // sort the hits by time + std::stable_sort(all_hits.begin(), all_hits.end(), showerb::hitTimeSort_shower); +} + +void ShowerBuilder::processHits_standAlone(std::map &showerCands) { + // For each superlayer, fill the buffer and check if nHits >= threshold + for (auto &hit : all_hits) { + showerb::DTPrimPlusBx _hitpbx(-1, hit); + if (hit.superLayerId() == 1) bmtl1_sl1_buffer.push_back(_hitpbx); + else if (hit.superLayerId() == 3) bmtl1_sl3_buffer.push_back(_hitpbx); + } + + if (triggerShower(bmtl1_sl1_buffer)) { + if (debug_) { + int nHits_sl1 = bmtl1_sl1_buffer.size(); + LogDebug("ShowerBuilder") << " o Shower found in SL1 with " << nHits_sl1 << " hits"; + } + showerCands[1]->flag(); + set_shower_properties(showerCands[1], bmtl1_sl1_buffer); + } + if (triggerShower(bmtl1_sl3_buffer)) { + if (debug_) { + int nHits_sl3 = bmtl1_sl3_buffer.size(); + LogDebug("ShowerBuilder") << " o Shower found in SL3 with " << nHits_sl3 << " hits"; + } + showerCands[3]->flag(); + set_shower_properties(showerCands[3], bmtl1_sl3_buffer); + } +} + +void ShowerBuilder::processHitsFirmwareEmulation(std::map &showerCands) { + // Use a for over BXs to emulate the behavior of the OBDT and BMTL1, this means considering: + // 1. OBDT can only store recived hits during 4 BXs (adjustable with obdt_hits_bxpersistence_) + // 2. OBDT can recive hits from the same wire during 2 BXs (adjustable with obdt_wire_relaxing_time_) + // 3. OBDT can only sends 8 hits per BX to the BMTL1 (adjustable with obdt_hits_per_bx_) + // 4. Shower algorithm in the BMTL1 mantains the hits along 16 BXs and triggers if nHits >= threshold (adjustable with bmtl1_hits_bxpersistence_) + groupHits_byBx(); + + // auxiliary variables + int prev_nHits_sl1 = 0; + int nHits_sl1 = 0; + bool shower_sl1_already_set = false; + int prev_nHits_sl3 = 0; + int nHits_sl3 = 0; + bool shower_sl3_already_set = false; + // ------------------- + + int min_bx = all_hits_perBx.begin()->first; + int max_bx = all_hits_perBx.rbegin()->first; + + if (debug_) LogDebug("ShowerBuilder") << " - bx range: " << min_bx << " - " << max_bx + << ", size: "<< (max_bx-min_bx); + + for (int bx = min_bx; bx <= max_bx + 17; bx++) { + fill_obdt(bx); + + if (debug_) LogDebug("ShowerBuilder") << " ^ " << obdt_buffer.size() + << " hits in obdt_buffer at BX " << bx; + fill_bmtl1_buffers(); + + nHits_sl1 = bmtl1_sl1_buffer.size(); + if (debug_) LogDebug("ShowerBuilder") << " ^ " << nHits_sl1 + << " hits in bmtl1_sl1_buffer at BX " << bx; + nHits_sl3 = bmtl1_sl3_buffer.size(); + if (debug_) LogDebug("ShowerBuilder") << " ^ " << nHits_sl3 + << " hits in bmtl1_sl3_buffer at BX " << bx; + if (triggerShower(bmtl1_sl1_buffer)) { + if (debug_ && !showerCands[1]->isFlagged()) { + LogDebug("ShowerBuilder") << " o Shower found in SL1 with " << nHits_sl1 << " hits"; + } + showerCands[1]->flag(); + } + if (triggerShower(bmtl1_sl3_buffer)) { + if (debug_ && !showerCands[3]->isFlagged()) { + LogDebug("ShowerBuilder") << " o Shower found in SL3 with " << nHits_sl3 << " hits"; + } + showerCands[3]->flag(); + } + + if (nHits_sl1 < prev_nHits_sl1 && showerCands[1]->isFlagged() && !shower_sl1_already_set) { + shower_sl1_already_set = true; + set_shower_properties(showerCands[1], bmtl1_sl1_buffer, nHits_sl1, bx); + } else { + prev_nHits_sl1 = nHits_sl1; + } + + if (nHits_sl3 < prev_nHits_sl3 && showerCands[3]->isFlagged() && !shower_sl3_already_set) { + shower_sl3_already_set = true; + set_shower_properties(showerCands[3], bmtl1_sl3_buffer, nHits_sl3, bx); + } else { + prev_nHits_sl3 = nHits_sl3; + } + + bxStep(bx); + } +} + +bool ShowerBuilder::triggerShower(const showerb::ShowerBuffer& buffer) { + int nHits = buffer.size(); + if (nHits >= threshold_for_shower_) { + return true; + } + return false; +} + +void ShowerBuilder::set_shower_properties( + ShowerCandidatePtr &showerCand, + showerb::ShowerBuffer& buffer, + int nhits, + int bx, + int min_wire, + int max_wire, + float avg_pos, + float avg_time + ) { + DTPrimitives _hits; + + showerb::buffer_get_hits(buffer, _hits); + std::stable_sort(_hits.begin(), _hits.end(), showerb::hitWireSort_shower); + + // change values considering the buffer or the input values + nhits = (nhits == -1) ? _hits.size() : nhits; + min_wire = (min_wire == -1) ? _hits.front().channelId() : min_wire; + max_wire = (max_wire == -1) ? _hits.back().channelId() : max_wire; + avg_pos = (avg_pos == -1) ? showerb::compute_avg_pos(_hits) : avg_pos; + avg_time = (avg_time == -1) ? showerb::compute_avg_time(_hits) : avg_time; + + showerCand->setNhits(nhits); + showerCand->setBX(bx); + showerCand->setMinWire(min_wire); + showerCand->setMaxWire(max_wire); + showerCand->setAvgPos(avg_pos); + showerCand->setAvgTime(avg_time); + showerb::set_wires_profile(showerCand->getWiresProfile(), _hits); +} + +void ShowerBuilder::groupHits_byBx() { + double shift_back = 0; + if (scenario_ == MC) //scope for MC + shift_back = 400; + else if (scenario_ == DATA) //scope for data + shift_back = 0; + else if (scenario_ == SLICE_TEST) //scope for slice test + shift_back = 400; + + all_hits_perBx.clear(); + // Group hits by BX + for (auto &hit : all_hits) { + // Compute the BX from the TDC time + int bx = hit.tdcTimeStamp() / 25 - shift_back; + all_hits_perBx[bx].push_back(hit); + } +} + +void ShowerBuilder::fill_obdt(const int bx) { + // Fill the OBDT buffer with the hits in the current BX this function ensure that hot wires are not added + if (all_hits_perBx.find(bx) != all_hits_perBx.end()) { + for (auto &hit : all_hits_perBx[bx]) { + + if (debug_) LogDebug("ShowerBuilder") << " ^ Trying to add hit with wire " + << hit.channelId() << " in OBDT at BX " << bx; + if (!showerb::buffer_contains(hot_wires_buffer, hit)) { + if (debug_) LogDebug("ShowerBuilder") << " ^ added"; + showerb::DTPrimPlusBx _hit(bx, hit); + obdt_buffer.push_back(_hit); + hot_wires_buffer.push_back(_hit); + } + } + } +} + +void ShowerBuilder::fill_bmtl1_buffers(){ + // Fill the BMTL1 buffer with the hits in the OBDT buffer only nHits_per_bx_ hits are added + if (obdt_buffer.empty()) return; + if (debug_) LogDebug("ShowerBuilder") << " ^ Getting hits from OBDT"; + for (int i = 0; i < nHits_per_bx_; i++) { + if (obdt_buffer.empty()) break; + auto _hitpbx = obdt_buffer.front(); + if (_hitpbx.second.superLayerId() == 1) { + bmtl1_sl1_buffer.push_back(_hitpbx); + } + else if (_hitpbx.second.superLayerId() == 3) { + bmtl1_sl3_buffer.push_back(_hitpbx); + } + obdt_buffer.pop_front(); + } +} + +void ShowerBuilder::bxStep(const int _current_bx) { + // Remove old elements from the buffers + showerb::buffer_clear_olds(obdt_buffer, _current_bx, obdt_hits_bxpersistence_); + showerb::buffer_clear_olds(hot_wires_buffer, _current_bx, obdt_hits_bxpersistence_); + showerb::buffer_clear_olds(bmtl1_sl1_buffer, _current_bx, bmtl1_hits_bxpersistence_); + showerb::buffer_clear_olds(bmtl1_sl3_buffer, _current_bx, bmtl1_hits_bxpersistence_); +} + + + + + diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc b/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc index 72ede0468ff25..87cf72c72f4c0 100644 --- a/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc +++ b/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc @@ -7,43 +7,30 @@ using namespace cmsdt; ShowerCandidate::ShowerCandidate() { - nhits_ = 0; - avgTime_ = 0; - avgPos_ = 0; + clear(); } -ShowerCandidate::ShowerCandidate(ShowerBuffer& buff){ - nhits_ = buff.getNhits(); - rawId_ = buff.getRawId(); - for ( auto& hit : buff.getHits() ){ - hits_.push_back(hit); - } +ShowerCandidate& ShowerCandidate::operator=(const ShowerCandidate &other) { + if (this != &other) { + nhits_ = other.nhits_; + rawId_ = other.rawId_; + bx_ = other.bx_; + wmin_ = other.wmin_; + wmax_ = other.wmax_; + avgPos_ = other.avgPos_; + avgTime_ = other.avgTime_; + shower_flag_ = other.shower_flag_; + } + return *this; } -ShowerCandidate::ShowerCandidate(ShowerBufferPtr& buffPtr){ - nhits_ = buffPtr->getNhits(); - rawId_ = buffPtr->getRawId(); - for ( auto& hit : buffPtr->getHits() ){ - hits_.push_back(hit); - } - - // Set properties of the shower candidate - setAvgTime(); - setAvgPos(); -} - - -void ShowerCandidate::setAvgPos() { - // Sets the average position in X axis - for (auto& hit : hits_) { - avgPos_ = avgPos_ + hit->wireHorizPos(); - } - avgPos_ = avgPos_ / nhits_; -} - -void ShowerCandidate::setAvgTime() { - for (auto& hit : hits_) { - avgTime_ = avgTime_ + hit->tdcTimeStamp(); - } - avgTime_ = avgTime_ / nhits_; +void ShowerCandidate::clear() { + nhits_ = 0; + bx_ = 0; + wmin_ = 0; + wmax_ = 0; + avgPos_ = 0; + avgTime_ = 0; + shower_flag_ = false; + wires_profile_.resize(96, 0); } diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerGrouping.cc b/L1Trigger/DTTriggerPhase2/src/ShowerGrouping.cc deleted file mode 100644 index ce9664d17072f..0000000000000 --- a/L1Trigger/DTTriggerPhase2/src/ShowerGrouping.cc +++ /dev/null @@ -1,136 +0,0 @@ -#include "L1Trigger/DTTriggerPhase2/interface/ShowerGrouping.h" -#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -using namespace edm; -using namespace std; -using namespace cmsdt; - -// ============================================================================ -// Constructors and destructor -// ============================================================================ -ShowerGrouping::ShowerGrouping(const ParameterSet& pset, edm::ConsumesCollector& iC) : - debug_(pset.getUntrackedParameter("debug")), - nHits_per_bx(pset.getParameter("nHits_per_bx")), - threshold_for_shower(pset.getParameter("threshold_for_shower")), - showerTaggingAlgo_(pset.getParameter("showerTaggingAlgo")), - currentBaseChannel_(-1) { - - // Initialise channelIn array - chInDummy_.push_back(DTPrimitive()); - for (int lay = 0; lay < NUM_LAYERS_2SL; lay++) { - for (int ch = 0; ch < NUM_CH_PER_LAYER; ch++) { - channelIn_[lay][ch] = {chInDummy_}; - channelIn_[lay][ch].clear(); - } - } -} - -ShowerGrouping::~ShowerGrouping() {} - -// ============================================================================ -// Main methods (initialise, run, finish) -// ============================================================================ -void ShowerGrouping::initialise(const edm::EventSetup& iEventSetup) {} - -void ShowerGrouping::run(Event& iEvent, - const EventSetup& iEventSetup, - const DTDigiCollection& digis, - ShowerBufferPtr &showerBuffer) { - /* This function returns the analyzable shower collection */ - - // Clear channels from previous event - clearChannels(); - - // Set the incoming hits in the channels - setInChannels(&digis); - - // Now sort them by time - sortHits(); - if (debug_) std::cout << " + Going to study " << all_hits.size() << " hits" << std::endl; - auto showerBuf = std::make_shared(); - - // Create a buffer - for (auto &hit : all_hits) { - // Standalone mode: just save hits in buffer - showerBuf->addHit(hit); - - // TBD: add OBDT delays - } - - if (triggerShower(showerBuf)) { - - if (debug_) std::cout << " o Shower found with " << all_hits.size() << " hits" << std::endl; - showerBuf->flag(); - } - showerBuffer = std::move(showerBuf); - //std::cout << "Shower has " << showerBuf->getNhits() << std::endl; -} - -bool ShowerGrouping::triggerShower(const ShowerBufferPtr& showerBuf) { - // Method to apply shower tagging logic - - auto nHits = showerBuf->getNhits(); - bool tagged_shower = false; - - if (showerTaggingAlgo_ == 1) { - // Method v1: pure counting is over a given threshold - if (nHits >= threshold_for_shower) { - tagged_shower = true; - } - } - if (showerTaggingAlgo_ == 2) { - // Method v2: correlate hits based on distance - // TO BE IMPLEMENTED - return tagged_shower; - } - return tagged_shower; -} - -void ShowerGrouping::clearChannels() { - // This function clears channelIn and allHits collections. - for (int lay = 0; lay < NUM_LAYERS_2SL; lay++) { - if (debug_) std::cout << " o Clearing hits in layer " << lay << std::endl; - for (int ch = 0; ch < NUM_CH_PER_LAYER; ch++) { - channelIn_[lay][ch].clear(); - } - } - all_hits.clear(); -} - -void ShowerGrouping::setInChannels(const DTDigiCollection *digis) { - - for (const auto &dtLayerId_It : *digis) { - const DTLayerId dtLId = dtLayerId_It.first; - - // Now iterate over the digis - for (DTDigiCollection::const_iterator digiIt = (dtLayerId_It.second).first; digiIt != (dtLayerId_It.second).second; - ++digiIt) { - int layer = dtLId.layer() - 1; - int wire = (*digiIt).wire() - 1; - int digiTIME = (*digiIt).time(); - int digiTIMEPhase2 = digiTIME; - - auto dtpAux = DTPrimitive(); - dtpAux.setTDCTimeStamp(digiTIMEPhase2); - dtpAux.setChannelId(wire); - dtpAux.setLayerId(layer); // L=0,1,2,3 - dtpAux.setSuperLayerId(dtLId.superlayer()); // SL=0,1,2 - dtpAux.setCameraId(dtLId.rawId()); - channelIn_[layer][wire].push_back(dtpAux); - all_hits.push_back(dtpAux); - } - } -} - -void ShowerGrouping::sortHits() { - // Sort everything by the time of the hits, so it has the same behaviour as the fw - for (int lay = 0; lay < NUM_LAYERS_2SL; lay++) { - for (int ch = 0; ch < NUM_CH_PER_LAYER; ch++) { - std::stable_sort(channelIn_[lay][ch].begin(), channelIn_[lay][ch].end(), hitTimeSort_shower); - } - } - std::stable_sort(all_hits.begin(), all_hits.end(), hitTimeSort_shower); -} - -void ShowerGrouping::finish(){}; From 2a8f7340934b8e02e06593616cd1239aa7b3aeb6 Mon Sep 17 00:00:00 2001 From: Daniel Estrada Date: Fri, 14 Mar 2025 11:21:44 +0100 Subject: [PATCH 10/19] Incude DTTrigerPh2Shower_cfi It was added to: - L1Trigger/DTTriggerPhase2/test codes. - L1Trigger/Configuration. - L1Trigger/Phase2L1GMT/test codes. --- L1Trigger/Configuration/python/SimL1Emulator_cff.py | 2 ++ ...rimitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg.py | 7 +++++++ ...sPhase2Prod_over_dTDigis_and_4Dsegments_cfg_withRPC.py | 8 ++++++++ .../test/primitivesPhase2Prod_over_hlt_parallel_cfg.py | 1 + .../test/primitivesPhase2Prod_over_mc_cfg.py | 7 +++++++ .../test/primitivesPhase2Prod_over_unpacked_cfg.py | 6 ++++++ .../DTTriggerPhase2/test/test_primitivesPhase2Prod.py | 4 ++++ .../test/test_primitivesPhase2Prod_DEBUG_Grouping_cfg.py | 6 ++++++ ...rimitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg.py | 7 +++++++ L1Trigger/Phase2L1GMT/test/runGMT.py | 6 ++++++ L1Trigger/Phase2L1GMT/test/test.py | 6 +++++- 11 files changed, 59 insertions(+), 1 deletion(-) diff --git a/L1Trigger/Configuration/python/SimL1Emulator_cff.py b/L1Trigger/Configuration/python/SimL1Emulator_cff.py index 3c0e1b8c11580..058056b64f2a8 100644 --- a/L1Trigger/Configuration/python/SimL1Emulator_cff.py +++ b/L1Trigger/Configuration/python/SimL1Emulator_cff.py @@ -77,6 +77,8 @@ _phase2_siml1emulator.add(CalibratedDigis) from L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi import * _phase2_siml1emulator.add(dtTriggerPhase2PrimitiveDigis) +from L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi import * +_phase2_siml1emulator.add(dtTriggerPhase2Shower) # HGCAL TP # ######################################################################## diff --git a/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg.py b/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg.py index 2b804dc1fd6e1..006f6f28e781b 100644 --- a/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg.py +++ b/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg.py @@ -7,6 +7,7 @@ process.DTGeometryESModule.applyAlignment = False process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") #process.GlobalTag.globaltag = "90X_dataRun2_Express_v2" @@ -23,6 +24,12 @@ process.dtTriggerPhase2PrimitiveDigis.scenario = 1 #0 is mc, 1 is data, 2 is slice test +#DTTriggerPhase2Showers +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") +process.dtTriggerPhase2Shower.showerTaggingAlgo = 1 +process.dtTriggerPhase2Shower.debug = False +process.dtTriggerPhase2Shower.scenario = 0 # 0 for mc, 1 for data, 2 for slice test + process.source = cms.Source("PoolSource",fileNames = cms.untracked.vstring( #'file:/eos/user/c/carrillo/digis_segments_Run2016BSingleMuonRAW-RECO.root' diff --git a/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg_withRPC.py b/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg_withRPC.py index f4c5f3fbbb658..be867792641f6 100644 --- a/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg_withRPC.py +++ b/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg_withRPC.py @@ -7,6 +7,7 @@ process.DTGeometryESModule.applyAlignment = False process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") process.GlobalTag.globaltag = "106X_upgrade2018_realistic_v4" @@ -28,6 +29,13 @@ process.dtTriggerPhase2PrimitiveDigis.min_phinhits_match_segment = 4 #process.dtTriggerPhase2PrimitiveDigis.debug = True +#DTTriggerPhase2Showers +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") +process.dtTriggerPhase2Shower.showerTaggingAlgo = 1 +process.dtTriggerPhase2Shower.debug = False +process.dtTriggerPhase2Shower.scenario = 0 # 0 for mc, 1 for data, 2 for slice test + + #Produce RPC clusters from RPCDigi process.load("RecoLocalMuon.RPCRecHit.rpcRecHits_cfi") process.rpcRecHits.rpcDigiLabel = cms.InputTag('simMuonRPCDigis') diff --git a/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_hlt_parallel_cfg.py b/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_hlt_parallel_cfg.py index dfba5f2a9cffc..1459ac99f992a 100644 --- a/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_hlt_parallel_cfg.py +++ b/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_hlt_parallel_cfg.py @@ -7,6 +7,7 @@ process.DTGeometryESModule.applyAlignment = False process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") #process.GlobalTag.globaltag = "90X_dataRun2_Express_v2" diff --git a/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_mc_cfg.py b/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_mc_cfg.py index bd5b788f1a2cc..1baa0e4efe16e 100644 --- a/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_mc_cfg.py +++ b/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_mc_cfg.py @@ -7,6 +7,7 @@ process.DTGeometryESModule.applyAlignment = False process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") #process.GlobalTag.globaltag = "90X_dataRun2_Express_v2" @@ -31,6 +32,12 @@ process.dtTriggerPhase2PrimitiveDigis.scenario = 0 process.dtTriggerPhase2PrimitiveDigis.dump = True +#DTTriggerPhase2Showers +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") +process.dtTriggerPhase2Shower.showerTaggingAlgo = 1 +process.dtTriggerPhase2Shower.debug = False +process.dtTriggerPhase2Shower.scenario = 0 # 0 for mc, 1 for data, 2 for slice test + process.source = cms.Source("PoolSource",fileNames = cms.untracked.vstring( 'file:/eos/cms/store/group/dpg_dt/comm_dt/TriggerSimulation/SamplesReco/SingleMu_FlatPt-2to100/Version_10_5_0/SimRECO_1.root', 'file:/eos/cms/store/group/dpg_dt/comm_dt/TriggerSimulation/SamplesReco/SingleMu_FlatPt-2to100/Version_10_5_0/SimRECO_2.root', diff --git a/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_unpacked_cfg.py b/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_unpacked_cfg.py index dce51ec1569f4..e1d1faafaccd3 100644 --- a/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_unpacked_cfg.py +++ b/L1Trigger/DTTriggerPhase2/test/primitivesPhase2Prod_over_unpacked_cfg.py @@ -7,6 +7,7 @@ process.DTGeometryESModule.applyAlignment = False process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") #process.GlobalTag.globaltag = "90X_dataRun2_Express_v2" @@ -20,10 +21,15 @@ process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") process.dtTriggerPhase2PrimitiveDigis.digiTag=("ogdtab7unpacker") +#DTTriggerPhase2Showers +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") +process.dtTriggerPhase2Shower.digiTag=("ogdtab7unpacker") + #for the moment the part working in phase2 format is the slice test process.dtTriggerPhase2PrimitiveDigis.p2_df = True #for debugging #process.dtTriggerPhase2PrimitiveDigis.debug = True +#process.dtTriggerPhase2Shower.debug = True process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring(#'file:/eos/user/c/carrillo/digis_segments_Run2016BSingleMuonRAW-RECO.root' diff --git a/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod.py b/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod.py index 54151fd7e4b03..3b138e98bb043 100644 --- a/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod.py +++ b/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod.py @@ -6,6 +6,7 @@ process.load('Configuration.Geometry.GeometryExtendedRun4D49_cff') process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") process.load("Configuration.StandardSequences.MagneticField_cff") @@ -14,14 +15,17 @@ process.load("L1Trigger.DTTriggerPhase2.CalibratedDigis_cfi") process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") #scenario process.dtTriggerPhase2PrimitiveDigis.scenario = cms.int32(0) #0 is mc, 1 is data, 2 is slice test +process.dtTriggerPhase2Shower.scenario = cms.int32(0) # 0 for mc, 1 for data, 2 for slice test process.CalibratedDigis.dtDigiTag = "simMuonDTDigis" process.CalibratedDigis.scenario = 0 # STD process.dtTriggerPhase2PrimitiveDigis.algo = 0 ## initial grouping +process.dtTriggerPhase2Shower.showerTaggingAlgo = 1 process.dtTriggerPhase2PrimitiveDigis.df_extended = 0 # COMPARISON WITH FW diff --git a/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod_DEBUG_Grouping_cfg.py b/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod_DEBUG_Grouping_cfg.py index 0845f9c49a45b..1f1979fa0b516 100644 --- a/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod_DEBUG_Grouping_cfg.py +++ b/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod_DEBUG_Grouping_cfg.py @@ -6,6 +6,7 @@ process.load('Configuration.Geometry.GeometryExtendedRun4D49_cff') process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") # process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") process.load("Configuration.StandardSequences.MagneticField_cff") @@ -18,6 +19,10 @@ process.load("L1Trigger.DTTriggerPhase2.CalibratedDigis_cfi") process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +#DTTriggerPhase2Showers +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") +process.dtTriggerPhase2Shower.showerTaggingAlgo = 1 +process.dtTriggerPhase2Shower.debug = True process.dtTriggerPhase2PrimitiveDigis.dump = True process.dtTriggerPhase2PrimitiveDigis.debug = True @@ -35,6 +40,7 @@ #scenario process.dtTriggerPhase2PrimitiveDigis.scenario = 0 #0 is mc, 1 is data, 2 is slice test +process.dtTriggerPhase2Shower.scenario = 0 #0 is mc, 1 is data, 2 is slice test process.CalibratedDigis.dtDigiTag = "simMuonDTDigis" process.CalibratedDigis.scenario = 0 diff --git a/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg.py b/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg.py index b4779c29cddc9..a32c18cc4fcd8 100644 --- a/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg.py +++ b/L1Trigger/DTTriggerPhase2/test/test_primitivesPhase2Prod_over_dTDigis_and_4Dsegments_cfg.py @@ -6,12 +6,15 @@ process.load('Configuration.Geometry.GeometryExtendedRun4D41_cff') process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") + process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") process.GlobalTag.globaltag = "80X_dataRun2_2016SeptRepro_v7" process.load("L1Trigger.DTTriggerPhase2.CalibratedDigis_cfi") process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi") +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") #process.source = cms.Source("PoolSource",fileNames = cms.untracked.vstring('file:/eos/cms/store/user/folguera/P2L1TUpgrade/digis_segments_Run2016BSingleMuonRAW-RECO_camilo.root')) process.source = cms.Source("PoolSource", @@ -20,9 +23,13 @@ process.dtTriggerPhase2PrimitiveDigis.dump = True process.dtTriggerPhase2PrimitiveDigis.debug = False process.dtTriggerPhase2PrimitiveDigis.chi2Th = cms.double(0.16) +#DTTriggerPhase2Showers +process.dtTriggerPhase2Shower.showerTaggingAlgo = 1 +process.dtTriggerPhase2Shower.debug = False #scenario process.dtTriggerPhase2PrimitiveDigis.scenario = 1 +process.dtTriggerPhase2Shower.scenario = 1 # 0 for mc, 1 for data, 2 for slice test process.CalibratedDigis.scenario = 1 process.load("FWCore.MessageLogger.MessageLogger_cfi") diff --git a/L1Trigger/Phase2L1GMT/test/runGMT.py b/L1Trigger/Phase2L1GMT/test/runGMT.py index 8260d79d9b150..5873c50ec733b 100644 --- a/L1Trigger/Phase2L1GMT/test/runGMT.py +++ b/L1Trigger/Phase2L1GMT/test/runGMT.py @@ -107,6 +107,12 @@ process.dtTriggerPhase2PrimitiveDigis.dump = False process.dtTriggerPhase2PrimitiveDigis.scenario = 0 +#DTTriggerPhase2Showers +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") +process.dtTriggerPhase2Shower.showerTaggingAlgo = 1 +process.dtTriggerPhase2Shower.debug = False +process.dtTriggerPhase2Shower.scenario = 0 + process.load("L1Trigger.Phase2L1GMT.gmt_cff") # Path and EndPath definitions diff --git a/L1Trigger/Phase2L1GMT/test/test.py b/L1Trigger/Phase2L1GMT/test/test.py index 3cf08643f67a1..a86e4f89e1d89 100644 --- a/L1Trigger/Phase2L1GMT/test/test.py +++ b/L1Trigger/Phase2L1GMT/test/test.py @@ -153,7 +153,11 @@ process.dtTriggerPhase2PrimitiveDigis.dump = False process.dtTriggerPhase2PrimitiveDigis.scenario = 0 - +#DTTriggerPhase2Showers +process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2Showers_cfi") +process.dtTriggerPhase2Shower.showerTaggingAlgo = 1 +process.dtTriggerPhase2Shower.debug = False +process.dtTriggerPhase2Shower.scenario = 0 #process.schedule = cms.Schedule(process.L1TrackTrigger_step,process.pL1TMuonTPS,process.endjob_step,process.e) # Adding MuonTPS From edc73aaf81db0a706127573cbc635cf783711c8a Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 26 Mar 2025 12:40:49 +0100 Subject: [PATCH 11/19] Code format --- .../interface/L1Phase2MuDTShower.h | 32 +- .../L1DTTrackFinder/src/L1Phase2MuDTShower.cc | 41 +- .../src/L1Phase2MuDTShowerContainer.cc | 4 +- .../interface/MPCoincidenceFilter.h | 2 +- .../interface/MPThetaMatching.h | 4 +- .../DTTriggerPhase2/interface/ShowerBuilder.h | 249 ++++----- .../interface/ShowerCandidate.h | 82 +-- .../plugins/DTTrigPhase2Prod.cc | 5 +- .../plugins/DTTrigPhase2ShowerProd.cc | 351 ++++++------- .../src/MPCoincidenceFilter.cc | 42 +- .../DTTriggerPhase2/src/MPThetaMatching.cc | 10 +- .../DTTriggerPhase2/src/ShowerBuilder.cc | 471 +++++++++--------- .../DTTriggerPhase2/src/ShowerCandidate.cc | 44 +- 13 files changed, 677 insertions(+), 660 deletions(-) diff --git a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h index 1bb0277b34a8f..00de2566b2565 100644 --- a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h +++ b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h @@ -10,7 +10,7 @@ // Federica Primavera Bologna INFN // Carlos Vico Oviedo Spain, // Daniel Estrada Acevedo Oviedo Spain. -// +// // //-------------------------------------------------- #ifndef L1Phase2MuDTShower_H @@ -38,24 +38,23 @@ class L1Phase2MuDTShower { // Constructors L1Phase2MuDTShower(); - L1Phase2MuDTShower(int wh, // Wheel - int sc, // Sector - int st, // Station - int sl, // Superlayer - int ndigis, // Number of digis within shower - int bx, // BX estimation - int min_wire, // Minimum wire - int max_wire, // Maximum wire - float avg_pos, // Averaged position of the shower - float avg_time, // Averaged time of the shower - const std::vector wires_profile // Wires profile - ); - + L1Phase2MuDTShower(int wh, // Wheel + int sc, // Sector + int st, // Station + int sl, // Superlayer + int ndigis, // Number of digis within shower + int bx, // BX estimation + int min_wire, // Minimum wire + int max_wire, // Maximum wire + float avg_pos, // Averaged position of the shower + float avg_time, // Averaged time of the shower + const std::vector wires_profile // Wires profile + ); - virtual ~L1Phase2MuDTShower(){}; + virtual ~L1Phase2MuDTShower() {}; // Operations - + int whNum() const; int scNum() const; int stNum() const; @@ -69,7 +68,6 @@ class L1Phase2MuDTShower { std::vector wiresProfile() const; private: - int m_wheel; int m_sector; int m_station; diff --git a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc index 6b23c86ddf72d..68219e5457029 100644 --- a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc +++ b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc @@ -45,22 +45,31 @@ L1Phase2MuDTShower::L1Phase2MuDTShower() m_max_wire(0), m_avg_pos(0), m_avg_time(0) { - m_wires_profile.resize(96, 0); - } - -L1Phase2MuDTShower::L1Phase2MuDTShower( - int wh, int sc, int st, int sl, int ndigis, int bx, int min_wire, int max_wire, float avg_pos, float avg_time, const std::vector wires_profile) - : m_wheel(wh), - m_sector(sc), - m_station(st), - m_superlayer(sl), - m_ndigis(ndigis), - m_bx(bx), - m_min_wire(min_wire), - m_max_wire(max_wire), - m_avg_pos(avg_pos), - m_avg_time(avg_time), - m_wires_profile(wires_profile) {} + m_wires_profile.resize(96, 0); +} + +L1Phase2MuDTShower::L1Phase2MuDTShower(int wh, + int sc, + int st, + int sl, + int ndigis, + int bx, + int min_wire, + int max_wire, + float avg_pos, + float avg_time, + const std::vector wires_profile) + : m_wheel(wh), + m_sector(sc), + m_station(st), + m_superlayer(sl), + m_ndigis(ndigis), + m_bx(bx), + m_min_wire(min_wire), + m_max_wire(max_wire), + m_avg_pos(avg_pos), + m_avg_time(avg_time), + m_wires_profile(wires_profile) {} //-------------- // Operations -- diff --git a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc index 3ac836edf44ad..5cc6723b91d39 100644 --- a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc +++ b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc @@ -38,4 +38,6 @@ L1Phase2MuDTShowerContainer::L1Phase2MuDTShowerContainer() {} //-------------- void L1Phase2MuDTShowerContainer::setContainer(const Shower_Container& inputShowers) { m_showers = inputShowers; } -L1Phase2MuDTShowerContainer::Shower_Container const* L1Phase2MuDTShowerContainer::getContainer() const { return &m_showers; } +L1Phase2MuDTShowerContainer::Shower_Container const* L1Phase2MuDTShowerContainer::getContainer() const { + return &m_showers; +} diff --git a/L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h b/L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h index a863a32b73ed7..c360b8385032f 100644 --- a/L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h +++ b/L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h @@ -72,7 +72,7 @@ class MPCoincidenceFilter : public MPFilter { std::vector allMPs, int co_option, int co_quality, - int co_wh2option, + int co_wh2option, double shift_back); // Private attributes diff --git a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h index c43d2a03be325..9d4d36070ae0f 100644 --- a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h +++ b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h @@ -30,11 +30,11 @@ class MPThetaMatching : public MPFilter { const edm::EventSetup &iEventSetup, std::vector &allMPaths, std::vector &inMPaths, - std::vector &outMPaths) override{}; + std::vector &outMPaths) override {}; void run(edm::Event &iEvent, const edm::EventSetup &iEventSetup, MuonPathPtrs &inMPath, - MuonPathPtrs &outMPath) override{}; + MuonPathPtrs &outMPath) override {}; void finish() override; diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h index e19b66d7918ee..3bbb70e23897b 100644 --- a/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h @@ -23,153 +23,158 @@ // =============================================================================== namespace showerb { - typedef std::pair DTPrimPlusBx; - typedef std::deque ShowerBuffer; - - bool hitWireSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2){ - int wi1 = hit1.channelId(); - int wi2 = hit2.channelId(); - - if (wi1 < wi2) return true; - else return false; + typedef std::pair DTPrimPlusBx; + typedef std::deque ShowerBuffer; + + inline bool hitWireSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) { + int wi1 = hit1.channelId(); + int wi2 = hit2.channelId(); + + if (wi1 < wi2) + return true; + else + return false; + } + + inline bool hitLayerSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) { + int lay1 = hit1.layerId(); + int lay2 = hit2.layerId(); + + if (lay1 < lay2) + return true; + else if (lay1 > lay2) + return false; + else + return hitWireSort_shower(hit1, hit2); + } + + inline bool hitTimeSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) { + int tdc1 = hit1.tdcTimeStamp(); + int tdc2 = hit2.tdcTimeStamp(); + + if (tdc1 < tdc2) + return true; + else + return false; + // else if (tdc1 > tdc2) return false; + // else return hitLayerSort_shower(hit1, hit2); --> ignoring those sortings for now + } + + inline float compute_avg_pos(DTPrimitives& hits) { + int nhits_ = hits.size(); + + if (nhits_ == 0) + return -1.0; + + float aux_avgPos_ = 0; + + for (auto& hit : hits) { + aux_avgPos_ += hit.wireHorizPos(); } - bool hitLayerSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) { - int lay1 = hit1.layerId(); - int lay2 = hit2.layerId(); + return aux_avgPos_ / nhits_; + } - if (lay1 < lay2) return true; - else if (lay1 > lay2) return false; - else return hitWireSort_shower(hit1, hit2); - } + inline float compute_avg_time(DTPrimitives& hits) { + int nhits_ = hits.size(); - bool hitTimeSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) { - int tdc1 = hit1.tdcTimeStamp(); - int tdc2 = hit2.tdcTimeStamp(); + if (nhits_ == 0) + return -1.0; - if (tdc1 < tdc2) return true; - else return false; - // else if (tdc1 > tdc2) return false; - // else return hitLayerSort_shower(hit1, hit2); --> ignoring those sortings for now - } + float aux_avgTime_ = 0; - float compute_avg_pos(DTPrimitives& hits) { - int nhits_ = hits.size(); - - if (nhits_ == 0) return -1.0; - - float aux_avgPos_ = 0; - - for (auto& hit : hits) { - aux_avgPos_ += hit.wireHorizPos(); - } - - return aux_avgPos_ / nhits_; - } - - float compute_avg_time(DTPrimitives& hits) { - int nhits_ = hits.size(); - - if (nhits_ == 0) return -1.0; - - float aux_avgTime_ = 0; - - for (auto& hit : hits) { - aux_avgTime_ += hit.tdcTimeStamp(); - } - return aux_avgTime_ / nhits_; + for (auto& hit : hits) { + aux_avgTime_ += hit.tdcTimeStamp(); } + return aux_avgTime_ / nhits_; + } - void set_wires_profile(std::vector& wires_profile, DTPrimitives& hits) { - for (auto& hit : hits) { - wires_profile[hit.channelId()-1]++; - } + inline void set_wires_profile(std::vector& wires_profile, DTPrimitives& hits) { + for (auto& hit : hits) { + wires_profile[hit.channelId() - 1]++; } + } - bool buffer_contains(const ShowerBuffer& buffer, const DTPrimitive& hit) { - for (const auto& item : buffer) { - if (item.second.channelId() == hit.channelId()) return true; - } - return false; + inline bool buffer_contains(const ShowerBuffer& buffer, const DTPrimitive& hit) { + for (const auto& item : buffer) { + if (item.second.channelId() == hit.channelId()) + return true; } + return false; + } - void buffer_get_hits(const ShowerBuffer& buffer, DTPrimitives& hits) { - for (const auto& item : buffer) { - hits.push_back(item.second); - } + inline void buffer_get_hits(const ShowerBuffer& buffer, DTPrimitives& hits) { + for (const auto& item : buffer) { + hits.push_back(item.second); } + } - void buffer_clear_olds(ShowerBuffer& buffer, const int _current_bx, const int persistence_bx_units) { - while (!buffer.empty() && (_current_bx - buffer.front().first) > persistence_bx_units) { - buffer.pop_front(); - } + inline void buffer_clear_olds(ShowerBuffer& buffer, const int _current_bx, const int persistence_bx_units) { + while (!buffer.empty() && (_current_bx - buffer.front().first) > persistence_bx_units) { + buffer.pop_front(); } + } - void buffer_reset(ShowerBuffer& buffer) { - buffer.clear(); - } -} + inline void buffer_reset(ShowerBuffer& buffer) { buffer.clear(); } +} // namespace showerb // =============================================================================== // Class declarations // =============================================================================== class ShowerBuilder { - public: - // Constructors and destructor - ShowerBuilder(const edm::ParameterSet& pset, edm::ConsumesCollector& iC); - virtual ~ShowerBuilder(); - - // Main methods - virtual void initialise(const edm::EventSetup& iEventSetup); - virtual void run(edm::Event& iEvent, - const edm::EventSetup& iEventSetup, - const DTDigiCollection& digis, - ShowerCandidatePtr &showerCandidate_SL1, - ShowerCandidatePtr &showerCandidate_SL3); - virtual void finish(); + // Constructors and destructor + ShowerBuilder(const edm::ParameterSet& pset, edm::ConsumesCollector& iC); + virtual ~ShowerBuilder(); + + // Main methods + virtual void initialise(const edm::EventSetup& iEventSetup); + virtual void run(edm::Event& iEvent, + const edm::EventSetup& iEventSetup, + const DTDigiCollection& digis, + ShowerCandidatePtr& showerCandidate_SL1, + ShowerCandidatePtr& showerCandidate_SL3); + virtual void finish(); private: - // Private auxiliary methods - void clear(); - void setInChannels(const DTDigiCollection* digi); - void processHits_standAlone(std::map &showerCands); - void processHitsFirmwareEmulation(std::map &showerCands); - - bool triggerShower(const showerb::ShowerBuffer& buffer); - void set_shower_properties( - ShowerCandidatePtr &showerCand, - showerb::ShowerBuffer& buffer, - int nhits = -1, - int bx = -1, - int min_wire = -1, - int max_wire = -1, - float avg_pos = -1., - float avg_time = -1. - ); - void groupHits_byBx(); - void fill_obdt(const int bx); - void fill_bmtl1_buffers(); - void bxStep(const int _current_bx); - - // Private attributes - const int showerTaggingAlgo_; - const int threshold_for_shower_; - const int nHits_per_bx_; - const int obdt_hits_bxpersistence_; - const int obdt_wire_relaxing_time_; - const int bmtl1_hits_bxpersistence_; - const bool debug_; - const int scenario_; - - // auxiliary variables - DTPrimitives all_hits; - std::map> all_hits_perBx; - showerb::ShowerBuffer obdt_buffer; // Buffer to emulate the OBDT behavior - showerb::ShowerBuffer hot_wires_buffer; // Buffer to emulate the hot wires behavior - showerb::ShowerBuffer bmtl1_sl1_buffer; // Buffer to emulate the BMTL1 shower buffer for SL1 - showerb::ShowerBuffer bmtl1_sl3_buffer; // Buffer to emulate the BMTL1 shower buffer for SL3 + // Private auxiliary methods + void clear(); + void setInChannels(const DTDigiCollection* digi); + void processHits_standAlone(std::map& showerCands); + void processHitsFirmwareEmulation(std::map& showerCands); + + bool triggerShower(const showerb::ShowerBuffer& buffer); + void set_shower_properties(ShowerCandidatePtr& showerCand, + showerb::ShowerBuffer& buffer, + int nhits = -1, + int bx = -1, + int min_wire = -1, + int max_wire = -1, + float avg_pos = -1., + float avg_time = -1.); + void groupHits_byBx(); + void fill_obdt(const int bx); + void fill_bmtl1_buffers(); + void bxStep(const int _current_bx); + + // Private attributes + const int showerTaggingAlgo_; + const int threshold_for_shower_; + const int nHits_per_bx_; + const int obdt_hits_bxpersistence_; + const int obdt_wire_relaxing_time_; + const int bmtl1_hits_bxpersistence_; + const bool debug_; + const int scenario_; + + // auxiliary variables + DTPrimitives all_hits; + std::map> all_hits_perBx; + showerb::ShowerBuffer obdt_buffer; // Buffer to emulate the OBDT behavior + showerb::ShowerBuffer hot_wires_buffer; // Buffer to emulate the hot wires behavior + showerb::ShowerBuffer bmtl1_sl1_buffer; // Buffer to emulate the BMTL1 shower buffer for SL1 + showerb::ShowerBuffer bmtl1_sl3_buffer; // Buffer to emulate the BMTL1 shower buffer for SL3 }; #endif diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h b/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h index ac030c5c0d849..3c553bca6e49c 100644 --- a/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h @@ -8,49 +8,49 @@ class ShowerCandidate { public: - ShowerCandidate(); - - ShowerCandidate& operator=(const ShowerCandidate &other); - - virtual ~ShowerCandidate() {} - - // setter methods - void rawId(int rawId) { rawId_ = rawId;} - void setBX(int bx) {bx_ = bx;} - void setNhits(int nhits) {nhits_ = nhits;} - void setMinWire(int wmin) {wmin_ = wmin;} - void setMaxWire(int wmax) {wmax_ = wmax;} - void setAvgPos(float avgPos) {avgPos_ = avgPos;} - void setAvgTime(float avgTime) {avgTime_ = avgTime;} - void flag() {shower_flag_ = true;} - - // getters methods - int getRawId() {return rawId_;} - int getBX() {return bx_;} - int getNhits() { return nhits_; } - int getMinWire() {return wmin_;} - int getMaxWire() {return wmax_;} - float getAvgPos() {return avgPos_;} - float getAvgTime() {return avgTime_;} - std::vector& getWiresProfile() { return wires_profile_; } - bool isFlagged() {return shower_flag_;} - - // Other methods - void clear(); + ShowerCandidate(); + + ShowerCandidate& operator=(const ShowerCandidate& other); + + virtual ~ShowerCandidate() {} + + // setter methods + void rawId(int rawId) { rawId_ = rawId; } + void setBX(int bx) { bx_ = bx; } + void setNhits(int nhits) { nhits_ = nhits; } + void setMinWire(int wmin) { wmin_ = wmin; } + void setMaxWire(int wmax) { wmax_ = wmax; } + void setAvgPos(float avgPos) { avgPos_ = avgPos; } + void setAvgTime(float avgTime) { avgTime_ = avgTime; } + void flag() { shower_flag_ = true; } + + // getters methods + int getRawId() { return rawId_; } + int getBX() { return bx_; } + int getNhits() { return nhits_; } + int getMinWire() { return wmin_; } + int getMaxWire() { return wmax_; } + float getAvgPos() { return avgPos_; } + float getAvgTime() { return avgTime_; } + std::vector& getWiresProfile() { return wires_profile_; } + bool isFlagged() { return shower_flag_; } + + // Other methods + void clear(); private: - //------------------------------------------------------------------ - //--- ShowerCandidate's data - //------------------------------------------------------------------ - int nhits_; - int rawId_; - int bx_; - int wmin_; - int wmax_; - bool shower_flag_; - float avgPos_; - float avgTime_; - std::vector wires_profile_; + //------------------------------------------------------------------ + //--- ShowerCandidate's data + //------------------------------------------------------------------ + int nhits_; + int rawId_; + int bx_; + int wmin_; + int wmax_; + bool shower_flag_; + float avgPos_; + float avgTime_; + std::vector wires_profile_; }; typedef std::vector ShowerCandidates; diff --git a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc index 571aa28b311d4..b73da113e123c 100644 --- a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc +++ b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc @@ -865,7 +865,7 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) { } } - //for (auto& ch_filtcoMetaPrimitives : coMetaPrimitives) + //for (auto& ch_filtcoMetaPrimitives : coMetaPrimitives) //cout<<"coMetaPrimitives: "< { - /* Declaration of the plugin */ - - // Types - typedef std::map> DTDigiMap; - typedef DTDigiMap::iterator DTDigiMap_iterator; - typedef DTDigiMap::const_iterator DTDigiMap_const_iterator; - - public: - // Public methods/attributes - - //! Constructor - DTTrigPhase2ShowerProd(const edm::ParameterSet& pset); - - //! Destructor - ~DTTrigPhase2ShowerProd() override; - - //! Create Trigger Units before starting event processing - void beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) override; - - //! Producer: process every event and generates trigger data - void produce(edm::Event& iEvent, const edm::EventSetup& iEventSetup) override; - - //! endRun: finish things - void endRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) override; - - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - // Members - const DTGeometry* dtGeo_; - edm::ESGetToken dtGeomH; - - private: - // Private methods/attributes - bool debug_; // Debug flag - int showerTaggingAlgo_; // Shower tagging algorithm - edm::InputTag digiTag_; // Digi collection label - edm::EDGetTokenT dtDigisToken_; // Digi container - std::unique_ptr showerBuilder; // Shower builder instance -}; + /* Declaration of the plugin */ -/* Implementation of the plugin */ -DTTrigPhase2ShowerProd::DTTrigPhase2ShowerProd(const ParameterSet& pset) { - // Constructor implementation - produces(); - // Unpack information from pset - debug_ = pset.getUntrackedParameter("debug"); - digiTag_ = pset.getParameter("digiTag"); - showerTaggingAlgo_ = pset.getParameter("showerTaggingAlgo"); - - // Fetch consumes - dtDigisToken_ = consumes(digiTag_); - - // Algorithm functionalities - edm::ConsumesCollector consumesColl(consumesCollector()); - showerBuilder = std::make_unique(pset, consumesColl); - - // Load geometry - dtGeomH = esConsumes(); - - if (debug_) { - LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: constructor" << endl; - if (showerTaggingAlgo_ == 0) { - LogDebug("DTTrigPhase2ShowerProd") << "Using standalone mode" << endl; - } - else if (showerTaggingAlgo_ == 1) { - LogDebug("DTTrigPhase2ShowerProd") << "Using firmware emulation mode" << endl; - } - else LogError("DTTrigPhase2ShowerProd") << "Unrecognized shower tagging algorithm" << endl; - } -} + // Types + typedef std::map> DTDigiMap; + typedef DTDigiMap::iterator DTDigiMap_iterator; + typedef DTDigiMap::const_iterator DTDigiMap_const_iterator; -DTTrigPhase2ShowerProd::~DTTrigPhase2ShowerProd() { - // Destructor implementation - if (debug_) LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: destructor" << endl; -} +public: + // Public methods/attributes -void DTTrigPhase2ShowerProd::beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) { - // beginRun implementation - if (debug_) LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: beginRun started" << endl; + //! Constructor + DTTrigPhase2ShowerProd(const edm::ParameterSet& pset); - showerBuilder->initialise(iEventSetup); - if (auto geom = iEventSetup.getHandle(dtGeomH)) { - dtGeo_ = &(*geom); - } -} + //! Destructor + ~DTTrigPhase2ShowerProd() override; -void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& iEventSetup) { - // produce implementation - if (debug_) LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: produce Processing event" << endl; - - // Fetch the handle for hits - edm::Handle dtdigis; - iEvent.getByToken(dtDigisToken_, dtdigis); - - // 1. Preprocessing: store digi information by chamber - DTDigiMap digiMap; - DTDigiCollection::DigiRangeIterator detUnitIt; - if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Preprocessing hits..." << endl; - - for (const auto& detUnitIt : *dtdigis) { - const DTLayerId& layId = detUnitIt.first; - const DTChamberId chambId = layId.superlayerId().chamberId(); - const DTDigiCollection::Range& digi_range = detUnitIt.second; // This is the digi collection - digiMap[chambId].put(digi_range, layId); - } - - if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Hits preprocessed: " << digiMap.size() - << " DT chambers to analyze" << endl; + //! Create Trigger Units before starting event processing + void beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) override; - // 2. Look for showers in each chamber - if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Building shower candidates for:" << endl; + //! Producer: process every event and generates trigger data + void produce(edm::Event& iEvent, const edm::EventSetup& iEventSetup) override; - std::map ShowerCandidates; - for (const auto& ich : dtGeo_->chambers()) { - const DTChamber* chamb = ich; - DTChamberId chid = chamb->id(); - DTDigiMap_iterator dmit = digiMap.find(chid); + //! endRun: finish things + void endRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) override; - DTSuperLayerId sl1id = chamb -> superLayer(1) -> id(); - DTSuperLayerId sl3id = chamb -> superLayer(3) -> id(); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - if (dmit == digiMap.end()) - continue; + // Members + const DTGeometry* dtGeo_; + edm::ESGetToken dtGeomH; - if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " " << chid << endl; +private: + // Private methods/attributes + bool debug_; // Debug flag + int showerTaggingAlgo_; // Shower tagging algorithm + edm::InputTag digiTag_; // Digi collection label + edm::EDGetTokenT dtDigisToken_; // Digi container + std::unique_ptr showerBuilder; // Shower builder instance +}; - showerBuilder->run(iEvent, iEventSetup, (*dmit).second, ShowerCandidates[sl1id], ShowerCandidates[sl3id]); +/* Implementation of the plugin */ +DTTrigPhase2ShowerProd::DTTrigPhase2ShowerProd(const ParameterSet& pset) { + // Constructor implementation + produces(); + // Unpack information from pset + debug_ = pset.getUntrackedParameter("debug"); + digiTag_ = pset.getParameter("digiTag"); + showerTaggingAlgo_ = pset.getParameter("showerTaggingAlgo"); + + // Fetch consumes + dtDigisToken_ = consumes(digiTag_); + + // Algorithm functionalities + edm::ConsumesCollector consumesColl(consumesCollector()); + showerBuilder = std::make_unique(pset, consumesColl); + + // Load geometry + dtGeomH = esConsumes(); + + if (debug_) { + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: constructor" << endl; + if (showerTaggingAlgo_ == 0) { + LogDebug("DTTrigPhase2ShowerProd") << "Using standalone mode" << endl; + } else if (showerTaggingAlgo_ == 1) { + LogDebug("DTTrigPhase2ShowerProd") << "Using firmware emulation mode" << endl; + } else + LogError("DTTrigPhase2ShowerProd") << "Unrecognized shower tagging algorithm" << endl; + } +} - // Save the rawId of these shower candidates - ShowerCandidates[sl1id]->rawId(sl1id.rawId()); - ShowerCandidates[sl3id]->rawId(sl3id.rawId()); - } +DTTrigPhase2ShowerProd::~DTTrigPhase2ShowerProd() { + // Destructor implementation + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: destructor" << endl; +} - // 3. Check shower candidates and store them if flagged - if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Selecting shower candidates" << endl; - - std::vector outShower; // prepare output container - for (auto& sl_showerCand : ShowerCandidates) { - auto showerCandIt = sl_showerCand.second; - - if (showerCandIt->isFlagged()) { - DTSuperLayerId slId(showerCandIt->getRawId()); - - if (debug_) { - LogDebug("DTTrigPhase2ShowerProd") << " Shower candidate tagged in chamber" - << slId.chamberId() << ", SL" << slId.superlayer(); - } - // 4. Storing results - outShower.emplace_back( - L1Phase2MuDTShower( - slId.wheel(), // Wheel - slId.sector(), // Sector - slId.station(), // Station - slId.superlayer(), // SuperLayer - showerCandIt->getNhits(), // number of digis - showerCandIt->getBX(), // BX - showerCandIt->getMinWire(), // Min wire - showerCandIt->getMaxWire(), // Max wire - showerCandIt->getAvgPos(), // Average position - showerCandIt->getAvgTime(), // Average time - showerCandIt->getWiresProfile() // Wires profile - ) - ); - } - } - if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Storing results..." << endl; +void DTTrigPhase2ShowerProd::beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) { + // beginRun implementation + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: beginRun started" << endl; + + showerBuilder->initialise(iEventSetup); + if (auto geom = iEventSetup.getHandle(dtGeomH)) { + dtGeo_ = &(*geom); + } +} - // 4.1 Storing results - std::unique_ptr resultShower(new L1Phase2MuDTShowerContainer); - resultShower->setContainer(outShower); - iEvent.put(std::move(resultShower)); +void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& iEventSetup) { + // produce implementation + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: produce Processing event" << endl; + + // Fetch the handle for hits + edm::Handle dtdigis; + iEvent.getByToken(dtDigisToken_, dtdigis); + + // 1. Preprocessing: store digi information by chamber + DTDigiMap digiMap; + DTDigiCollection::DigiRangeIterator detUnitIt; + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << " Preprocessing hits..." << endl; + + for (const auto& detUnitIt : *dtdigis) { + const DTLayerId& layId = detUnitIt.first; + const DTChamberId chambId = layId.superlayerId().chamberId(); + const DTDigiCollection::Range& digi_range = detUnitIt.second; // This is the digi collection + digiMap[chambId].put(digi_range, layId); + } + + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << " Hits preprocessed: " << digiMap.size() << " DT chambers to analyze" + << endl; + + // 2. Look for showers in each chamber + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << " Building shower candidates for:" << endl; + + std::map ShowerCandidates; + for (const auto& ich : dtGeo_->chambers()) { + const DTChamber* chamb = ich; + DTChamberId chid = chamb->id(); + DTDigiMap_iterator dmit = digiMap.find(chid); + + DTSuperLayerId sl1id = chamb->superLayer(1)->id(); + DTSuperLayerId sl3id = chamb->superLayer(3)->id(); + + if (dmit == digiMap.end()) + continue; + + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << " " << chid << endl; + + showerBuilder->run(iEvent, iEventSetup, (*dmit).second, ShowerCandidates[sl1id], ShowerCandidates[sl3id]); + + // Save the rawId of these shower candidates + ShowerCandidates[sl1id]->rawId(sl1id.rawId()); + ShowerCandidates[sl3id]->rawId(sl3id.rawId()); + } + + // 3. Check shower candidates and store them if flagged + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << " Selecting shower candidates" << endl; + + std::vector outShower; // prepare output container + for (auto& sl_showerCand : ShowerCandidates) { + auto showerCandIt = sl_showerCand.second; + + if (showerCandIt->isFlagged()) { + DTSuperLayerId slId(showerCandIt->getRawId()); + + if (debug_) { + LogDebug("DTTrigPhase2ShowerProd") + << " Shower candidate tagged in chamber" << slId.chamberId() << ", SL" << slId.superlayer(); + } + // 4. Storing results + outShower.emplace_back(L1Phase2MuDTShower(slId.wheel(), // Wheel + slId.sector(), // Sector + slId.station(), // Station + slId.superlayer(), // SuperLayer + showerCandIt->getNhits(), // number of digis + showerCandIt->getBX(), // BX + showerCandIt->getMinWire(), // Min wire + showerCandIt->getMaxWire(), // Max wire + showerCandIt->getAvgPos(), // Average position + showerCandIt->getAvgTime(), // Average time + showerCandIt->getWiresProfile() // Wires profile + )); + } + } + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << " Storing results..." << endl; + + // 4.1 Storing results + std::unique_ptr resultShower(new L1Phase2MuDTShowerContainer); + resultShower->setContainer(outShower); + iEvent.put(std::move(resultShower)); } void DTTrigPhase2ShowerProd::endRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) { - // endRun implementation - if (debug_) LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: endRun" << endl; + // endRun implementation + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: endRun" << endl; } void DTTrigPhase2ShowerProd::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // dtTriggerPhase2Shower - edm::ParameterSetDescription desc; - desc.add("digiTag", edm::InputTag("CalibratedDigis")); - desc.add("showerTaggingAlgo", 1); - desc.add("threshold_for_shower", 6); - desc.add("nHits_per_bx", 8); - desc.add("obdt_hits_bxpersistence", 4); - desc.add("obdt_wire_relaxing_time", 2); - desc.add("bmtl1_hits_bxpersistence", 16); - desc.add("scenario", 0); - desc.addUntracked("debug", false); - - descriptions.add("dtTriggerPhase2Shower", desc); + // dtTriggerPhase2Shower + edm::ParameterSetDescription desc; + desc.add("digiTag", edm::InputTag("CalibratedDigis")); + desc.add("showerTaggingAlgo", 1); + desc.add("threshold_for_shower", 6); + desc.add("nHits_per_bx", 8); + desc.add("obdt_hits_bxpersistence", 4); + desc.add("obdt_wire_relaxing_time", 2); + desc.add("bmtl1_hits_bxpersistence", 16); + desc.add("scenario", 0); + desc.addUntracked("debug", false); + + descriptions.add("dtTriggerPhase2Shower", desc); } - DEFINE_FWK_MODULE(DTTrigPhase2ShowerProd); diff --git a/L1Trigger/DTTriggerPhase2/src/MPCoincidenceFilter.cc b/L1Trigger/DTTriggerPhase2/src/MPCoincidenceFilter.cc index e601baba07bee..cb998d8ffacfd 100644 --- a/L1Trigger/DTTriggerPhase2/src/MPCoincidenceFilter.cc +++ b/L1Trigger/DTTriggerPhase2/src/MPCoincidenceFilter.cc @@ -60,9 +60,9 @@ std::vector MPCoincidenceFilter::filter(std::vector MPCoincidenceFilter::filter(std::vector 5 || wh2pass==1) + if (co_option == -1 || mp.quality > 5 || wh2pass == 1) outMPs.push_back(mp); else { int sector_p1 = sector + 1; @@ -99,15 +101,15 @@ std::vector MPCoincidenceFilter::filter(std::vector qcut) @@ -126,15 +128,15 @@ std::vector MPCoincidenceFilter::filter(std::vector MPCoincidenceFilter::filter(std::vector MPCoincidenceFilter::filter(std::vector 0.9) { - co_found = 1; + co_found = true; break; } else if (wheel == -2 && k < -0.9) { - co_found = 1; + co_found = true; break; } } @@ -186,7 +188,7 @@ std::vector MPCoincidenceFilter::filter(std::vector MPThetaMatching::filter(std::vector in } if (sector != oldSector || wheel != oldWheel || station != oldStation) { //new chamber - if (deltaTimePosPhiCands.size() > 0) + if (!deltaTimePosPhiCands.empty()) orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); deltaTimePosPhiCands.clear(); @@ -197,13 +197,13 @@ std::vector MPThetaMatching::filter(std::vector in deltaTimePosPhiCands.push_back({mpTheta, mpPhi, abs(tphi - ttheta)}); } //loop in phis - if (deltaTimePosPhiCands.size() == 0) { + if (deltaTimePosPhiCands.empty()) { outMPs.push_back(mpTheta); //save ThetaMP when there is no phi TPs savedThetaMPs.push_back(mpTheta); } } // loop in thetas - if (deltaTimePosPhiCands.size() > 0) + if (!deltaTimePosPhiCands.empty()) orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); //do once more for last theta TP in loop return outMPs; @@ -272,7 +272,7 @@ std::vector MPThetaMatching::getBestThetaMPInChamber(std::vector< } if (nTPs == 1 && !saved) bestThetaMPs.push_back(mp1); //only one Theta TP in chamber and it is q=1 - } //wheel ==0 + } //wheel ==0 else bestThetaMPs.push_back(mp1); diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc b/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc index 5f5b5046b59f3..7d7150a7deb05 100644 --- a/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc +++ b/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc @@ -9,288 +9,285 @@ using namespace cmsdt; // ============================================================================ // Constructors and destructor // ============================================================================ -ShowerBuilder::ShowerBuilder(const ParameterSet& pset, edm::ConsumesCollector& iC) : - // Unpack information from pset - showerTaggingAlgo_(pset.getParameter("showerTaggingAlgo")), - threshold_for_shower_(pset.getParameter("threshold_for_shower")), - nHits_per_bx_(pset.getParameter("nHits_per_bx")), - obdt_hits_bxpersistence_(pset.getParameter("obdt_hits_bxpersistence")), - obdt_wire_relaxing_time_(pset.getParameter("obdt_wire_relaxing_time")), - bmtl1_hits_bxpersistence_(pset.getParameter("bmtl1_hits_bxpersistence")), - debug_(pset.getUntrackedParameter("debug")), - scenario_(pset.getParameter("scenario")) { -} +ShowerBuilder::ShowerBuilder(const ParameterSet &pset, edm::ConsumesCollector &iC) + : // Unpack information from pset + showerTaggingAlgo_(pset.getParameter("showerTaggingAlgo")), + threshold_for_shower_(pset.getParameter("threshold_for_shower")), + nHits_per_bx_(pset.getParameter("nHits_per_bx")), + obdt_hits_bxpersistence_(pset.getParameter("obdt_hits_bxpersistence")), + obdt_wire_relaxing_time_(pset.getParameter("obdt_wire_relaxing_time")), + bmtl1_hits_bxpersistence_(pset.getParameter("bmtl1_hits_bxpersistence")), + debug_(pset.getUntrackedParameter("debug")), + scenario_(pset.getParameter("scenario")) {} ShowerBuilder::~ShowerBuilder() {} // ============================================================================ // Main methods (initialise, run, finish) // ============================================================================ -void ShowerBuilder::initialise(const edm::EventSetup& iEventSetup) {} +void ShowerBuilder::initialise(const edm::EventSetup &iEventSetup) {} -void ShowerBuilder::run(Event& iEvent, - const EventSetup& iEventSetup, - const DTDigiCollection& digis, +void ShowerBuilder::run(Event &iEvent, + const EventSetup &iEventSetup, + const DTDigiCollection &digis, ShowerCandidatePtr &showerCandidate_SL1, ShowerCandidatePtr &showerCandidate_SL3) { - // Clear auxiliars - clear(); - // Set the incoming hits in the channels - setInChannels(&digis); - - std::map aux_showerCands{ // defined as a map to easy acces with SL number - {1, make_shared()}, - {3, make_shared()} - }; - - int nHits = all_hits.size(); - if (nHits != 0) { - if (debug_) LogDebug("ShowerBuilder") << " - Going to study " << nHits << " hits"; - if (showerTaggingAlgo_ == 0) { - // Standalone mode: just save hits and flag if the number of hits is above the threshold - processHits_standAlone(aux_showerCands); - } - else if (showerTaggingAlgo_ == 1) { - // Firmware emulation: - // mimics the behavior of sending and receiving hits from the OBDT to the shower algorithm in the BMTL1. - processHitsFirmwareEmulation(aux_showerCands); - } - } - else { - if (debug_) LogDebug("ShowerBuilder") << " - No hits to study."; + // Clear auxiliars + clear(); + // Set the incoming hits in the channels + setInChannels(&digis); + + std::map aux_showerCands{// defined as a map to easy acces with SL number + {1, make_shared()}, + {3, make_shared()}}; + + int nHits = all_hits.size(); + if (nHits != 0) { + if (debug_) + LogDebug("ShowerBuilder") << " - Going to study " << nHits << " hits"; + if (showerTaggingAlgo_ == 0) { + // Standalone mode: just save hits and flag if the number of hits is above the threshold + processHits_standAlone(aux_showerCands); + } else if (showerTaggingAlgo_ == 1) { + // Firmware emulation: + // mimics the behavior of sending and receiving hits from the OBDT to the shower algorithm in the BMTL1. + processHitsFirmwareEmulation(aux_showerCands); } + } else { + if (debug_) + LogDebug("ShowerBuilder") << " - No hits to study."; + } - showerCandidate_SL1 = std::move(aux_showerCands[1]); - showerCandidate_SL3 = std::move(aux_showerCands[3]); + showerCandidate_SL1 = std::move(aux_showerCands[1]); + showerCandidate_SL3 = std::move(aux_showerCands[3]); } -void ShowerBuilder::finish(){}; +void ShowerBuilder::finish() {}; // ============================================================================ // Auxiliary methods // ============================================================================ -void ShowerBuilder::clear(){ - all_hits.clear(); - all_hits_perBx.clear(); - showerb::buffer_reset(obdt_buffer); - showerb::buffer_reset(hot_wires_buffer); - showerb::buffer_reset(bmtl1_sl1_buffer); - showerb::buffer_reset(bmtl1_sl3_buffer); +void ShowerBuilder::clear() { + all_hits.clear(); + all_hits_perBx.clear(); + showerb::buffer_reset(obdt_buffer); + showerb::buffer_reset(hot_wires_buffer); + showerb::buffer_reset(bmtl1_sl1_buffer); + showerb::buffer_reset(bmtl1_sl3_buffer); } void ShowerBuilder::setInChannels(const DTDigiCollection *digis) { - for (const auto &dtLayerId_It : *digis) { - const DTLayerId id = dtLayerId_It.first; - if (id.superlayer() == 2) continue; // Skip SL2 digis - // Now iterate over the digis - for (DTDigiCollection::const_iterator digiIt = (dtLayerId_It.second).first; - digiIt != (dtLayerId_It.second).second; ++digiIt) { - auto dtpAux = DTPrimitive(); - dtpAux.setTDCTimeStamp((*digiIt).time()); - dtpAux.setChannelId((*digiIt).wire()); - dtpAux.setLayerId(id.layer()); - dtpAux.setSuperLayerId(id.superlayer()); - dtpAux.setCameraId(id.rawId()); - all_hits.push_back(dtpAux); - } + for (const auto &dtLayerId_It : *digis) { + const DTLayerId id = dtLayerId_It.first; + if (id.superlayer() == 2) + continue; // Skip SL2 digis + // Now iterate over the digis + for (DTDigiCollection::const_iterator digiIt = (dtLayerId_It.second).first; digiIt != (dtLayerId_It.second).second; + ++digiIt) { + auto dtpAux = DTPrimitive(); + dtpAux.setTDCTimeStamp((*digiIt).time()); + dtpAux.setChannelId((*digiIt).wire()); + dtpAux.setLayerId(id.layer()); + dtpAux.setSuperLayerId(id.superlayer()); + dtpAux.setCameraId(id.rawId()); + all_hits.push_back(dtpAux); } - // sort the hits by time - std::stable_sort(all_hits.begin(), all_hits.end(), showerb::hitTimeSort_shower); + } + // sort the hits by time + std::stable_sort(all_hits.begin(), all_hits.end(), showerb::hitTimeSort_shower); } void ShowerBuilder::processHits_standAlone(std::map &showerCands) { - // For each superlayer, fill the buffer and check if nHits >= threshold - for (auto &hit : all_hits) { - showerb::DTPrimPlusBx _hitpbx(-1, hit); - if (hit.superLayerId() == 1) bmtl1_sl1_buffer.push_back(_hitpbx); - else if (hit.superLayerId() == 3) bmtl1_sl3_buffer.push_back(_hitpbx); + // For each superlayer, fill the buffer and check if nHits >= threshold + for (auto &hit : all_hits) { + showerb::DTPrimPlusBx _hitpbx(-1, hit); + if (hit.superLayerId() == 1) + bmtl1_sl1_buffer.push_back(_hitpbx); + else if (hit.superLayerId() == 3) + bmtl1_sl3_buffer.push_back(_hitpbx); + } + + if (triggerShower(bmtl1_sl1_buffer)) { + if (debug_) { + int nHits_sl1 = bmtl1_sl1_buffer.size(); + LogDebug("ShowerBuilder") << " o Shower found in SL1 with " << nHits_sl1 << " hits"; + } + showerCands[1]->flag(); + set_shower_properties(showerCands[1], bmtl1_sl1_buffer); + } + if (triggerShower(bmtl1_sl3_buffer)) { + if (debug_) { + int nHits_sl3 = bmtl1_sl3_buffer.size(); + LogDebug("ShowerBuilder") << " o Shower found in SL3 with " << nHits_sl3 << " hits"; } + showerCands[3]->flag(); + set_shower_properties(showerCands[3], bmtl1_sl3_buffer); + } +} +void ShowerBuilder::processHitsFirmwareEmulation(std::map &showerCands) { + // Use a for over BXs to emulate the behavior of the OBDT and BMTL1, this means considering: + // 1. OBDT can only store recived hits during 4 BXs (adjustable with obdt_hits_bxpersistence_) + // 2. OBDT can recive hits from the same wire during 2 BXs (adjustable with obdt_wire_relaxing_time_) + // 3. OBDT can only sends 8 hits per BX to the BMTL1 (adjustable with obdt_hits_per_bx_) + // 4. Shower algorithm in the BMTL1 mantains the hits along 16 BXs and triggers if nHits >= threshold (adjustable with bmtl1_hits_bxpersistence_) + groupHits_byBx(); + + // auxiliary variables + int prev_nHits_sl1 = 0; + int nHits_sl1 = 0; + bool shower_sl1_already_set = false; + int prev_nHits_sl3 = 0; + int nHits_sl3 = 0; + bool shower_sl3_already_set = false; + // ------------------- + + int min_bx = all_hits_perBx.begin()->first; + int max_bx = all_hits_perBx.rbegin()->first; + + if (debug_) + LogDebug("ShowerBuilder") << " - bx range: " << min_bx << " - " << max_bx << ", size: " << (max_bx - min_bx); + + for (int bx = min_bx; bx <= max_bx + 17; bx++) { + fill_obdt(bx); + + if (debug_) + LogDebug("ShowerBuilder") << " ^ " << obdt_buffer.size() << " hits in obdt_buffer at BX " << bx; + fill_bmtl1_buffers(); + + nHits_sl1 = bmtl1_sl1_buffer.size(); + if (debug_) + LogDebug("ShowerBuilder") << " ^ " << nHits_sl1 << " hits in bmtl1_sl1_buffer at BX " << bx; + nHits_sl3 = bmtl1_sl3_buffer.size(); + if (debug_) + LogDebug("ShowerBuilder") << " ^ " << nHits_sl3 << " hits in bmtl1_sl3_buffer at BX " << bx; if (triggerShower(bmtl1_sl1_buffer)) { - if (debug_) { - int nHits_sl1 = bmtl1_sl1_buffer.size(); - LogDebug("ShowerBuilder") << " o Shower found in SL1 with " << nHits_sl1 << " hits"; - } - showerCands[1]->flag(); - set_shower_properties(showerCands[1], bmtl1_sl1_buffer); + if (debug_ && !showerCands[1]->isFlagged()) { + LogDebug("ShowerBuilder") << " o Shower found in SL1 with " << nHits_sl1 << " hits"; + } + showerCands[1]->flag(); } if (triggerShower(bmtl1_sl3_buffer)) { - if (debug_) { - int nHits_sl3 = bmtl1_sl3_buffer.size(); - LogDebug("ShowerBuilder") << " o Shower found in SL3 with " << nHits_sl3 << " hits"; - } - showerCands[3]->flag(); - set_shower_properties(showerCands[3], bmtl1_sl3_buffer); + if (debug_ && !showerCands[3]->isFlagged()) { + LogDebug("ShowerBuilder") << " o Shower found in SL3 with " << nHits_sl3 << " hits"; + } + showerCands[3]->flag(); } -} -void ShowerBuilder::processHitsFirmwareEmulation(std::map &showerCands) { - // Use a for over BXs to emulate the behavior of the OBDT and BMTL1, this means considering: - // 1. OBDT can only store recived hits during 4 BXs (adjustable with obdt_hits_bxpersistence_) - // 2. OBDT can recive hits from the same wire during 2 BXs (adjustable with obdt_wire_relaxing_time_) - // 3. OBDT can only sends 8 hits per BX to the BMTL1 (adjustable with obdt_hits_per_bx_) - // 4. Shower algorithm in the BMTL1 mantains the hits along 16 BXs and triggers if nHits >= threshold (adjustable with bmtl1_hits_bxpersistence_) - groupHits_byBx(); - - // auxiliary variables - int prev_nHits_sl1 = 0; - int nHits_sl1 = 0; - bool shower_sl1_already_set = false; - int prev_nHits_sl3 = 0; - int nHits_sl3 = 0; - bool shower_sl3_already_set = false; - // ------------------- - - int min_bx = all_hits_perBx.begin()->first; - int max_bx = all_hits_perBx.rbegin()->first; - - if (debug_) LogDebug("ShowerBuilder") << " - bx range: " << min_bx << " - " << max_bx - << ", size: "<< (max_bx-min_bx); - - for (int bx = min_bx; bx <= max_bx + 17; bx++) { - fill_obdt(bx); - - if (debug_) LogDebug("ShowerBuilder") << " ^ " << obdt_buffer.size() - << " hits in obdt_buffer at BX " << bx; - fill_bmtl1_buffers(); - - nHits_sl1 = bmtl1_sl1_buffer.size(); - if (debug_) LogDebug("ShowerBuilder") << " ^ " << nHits_sl1 - << " hits in bmtl1_sl1_buffer at BX " << bx; - nHits_sl3 = bmtl1_sl3_buffer.size(); - if (debug_) LogDebug("ShowerBuilder") << " ^ " << nHits_sl3 - << " hits in bmtl1_sl3_buffer at BX " << bx; - if (triggerShower(bmtl1_sl1_buffer)) { - if (debug_ && !showerCands[1]->isFlagged()) { - LogDebug("ShowerBuilder") << " o Shower found in SL1 with " << nHits_sl1 << " hits"; - } - showerCands[1]->flag(); - } - if (triggerShower(bmtl1_sl3_buffer)) { - if (debug_ && !showerCands[3]->isFlagged()) { - LogDebug("ShowerBuilder") << " o Shower found in SL3 with " << nHits_sl3 << " hits"; - } - showerCands[3]->flag(); - } - - if (nHits_sl1 < prev_nHits_sl1 && showerCands[1]->isFlagged() && !shower_sl1_already_set) { - shower_sl1_already_set = true; - set_shower_properties(showerCands[1], bmtl1_sl1_buffer, nHits_sl1, bx); - } else { - prev_nHits_sl1 = nHits_sl1; - } - - if (nHits_sl3 < prev_nHits_sl3 && showerCands[3]->isFlagged() && !shower_sl3_already_set) { - shower_sl3_already_set = true; - set_shower_properties(showerCands[3], bmtl1_sl3_buffer, nHits_sl3, bx); - } else { - prev_nHits_sl3 = nHits_sl3; - } - - bxStep(bx); + if (nHits_sl1 < prev_nHits_sl1 && showerCands[1]->isFlagged() && !shower_sl1_already_set) { + shower_sl1_already_set = true; + set_shower_properties(showerCands[1], bmtl1_sl1_buffer, nHits_sl1, bx); + } else { + prev_nHits_sl1 = nHits_sl1; } -} -bool ShowerBuilder::triggerShower(const showerb::ShowerBuffer& buffer) { - int nHits = buffer.size(); - if (nHits >= threshold_for_shower_) { - return true; + if (nHits_sl3 < prev_nHits_sl3 && showerCands[3]->isFlagged() && !shower_sl3_already_set) { + shower_sl3_already_set = true; + set_shower_properties(showerCands[3], bmtl1_sl3_buffer, nHits_sl3, bx); + } else { + prev_nHits_sl3 = nHits_sl3; } - return false; + + bxStep(bx); + } } -void ShowerBuilder::set_shower_properties( - ShowerCandidatePtr &showerCand, - showerb::ShowerBuffer& buffer, - int nhits, - int bx, - int min_wire, - int max_wire, - float avg_pos, - float avg_time - ) { - DTPrimitives _hits; - - showerb::buffer_get_hits(buffer, _hits); - std::stable_sort(_hits.begin(), _hits.end(), showerb::hitWireSort_shower); - - // change values considering the buffer or the input values - nhits = (nhits == -1) ? _hits.size() : nhits; - min_wire = (min_wire == -1) ? _hits.front().channelId() : min_wire; - max_wire = (max_wire == -1) ? _hits.back().channelId() : max_wire; - avg_pos = (avg_pos == -1) ? showerb::compute_avg_pos(_hits) : avg_pos; - avg_time = (avg_time == -1) ? showerb::compute_avg_time(_hits) : avg_time; - - showerCand->setNhits(nhits); - showerCand->setBX(bx); - showerCand->setMinWire(min_wire); - showerCand->setMaxWire(max_wire); - showerCand->setAvgPos(avg_pos); - showerCand->setAvgTime(avg_time); - showerb::set_wires_profile(showerCand->getWiresProfile(), _hits); +bool ShowerBuilder::triggerShower(const showerb::ShowerBuffer &buffer) { + int nHits = buffer.size(); + if (nHits >= threshold_for_shower_) { + return true; + } + return false; +} + +void ShowerBuilder::set_shower_properties(ShowerCandidatePtr &showerCand, + showerb::ShowerBuffer &buffer, + int nhits, + int bx, + int min_wire, + int max_wire, + float avg_pos, + float avg_time) { + DTPrimitives _hits; + + showerb::buffer_get_hits(buffer, _hits); + std::stable_sort(_hits.begin(), _hits.end(), showerb::hitWireSort_shower); + + // change values considering the buffer or the input values + nhits = (nhits == -1) ? _hits.size() : nhits; + min_wire = (min_wire == -1) ? _hits.front().channelId() : min_wire; + max_wire = (max_wire == -1) ? _hits.back().channelId() : max_wire; + avg_pos = (avg_pos == -1) ? showerb::compute_avg_pos(_hits) : avg_pos; + avg_time = (avg_time == -1) ? showerb::compute_avg_time(_hits) : avg_time; + + showerCand->setNhits(nhits); + showerCand->setBX(bx); + showerCand->setMinWire(min_wire); + showerCand->setMaxWire(max_wire); + showerCand->setAvgPos(avg_pos); + showerCand->setAvgTime(avg_time); + showerb::set_wires_profile(showerCand->getWiresProfile(), _hits); } void ShowerBuilder::groupHits_byBx() { - double shift_back = 0; - if (scenario_ == MC) //scope for MC - shift_back = 400; - else if (scenario_ == DATA) //scope for data - shift_back = 0; - else if (scenario_ == SLICE_TEST) //scope for slice test - shift_back = 400; - - all_hits_perBx.clear(); - // Group hits by BX - for (auto &hit : all_hits) { - // Compute the BX from the TDC time - int bx = hit.tdcTimeStamp() / 25 - shift_back; - all_hits_perBx[bx].push_back(hit); - } + double shift_back = 0; + if (scenario_ == MC) //scope for MC + shift_back = 400; + else if (scenario_ == DATA) //scope for data + shift_back = 0; + else if (scenario_ == SLICE_TEST) //scope for slice test + shift_back = 400; + + all_hits_perBx.clear(); + // Group hits by BX + for (auto &hit : all_hits) { + // Compute the BX from the TDC time + int bx = hit.tdcTimeStamp() / 25 - shift_back; + all_hits_perBx[bx].push_back(hit); + } } void ShowerBuilder::fill_obdt(const int bx) { - // Fill the OBDT buffer with the hits in the current BX this function ensure that hot wires are not added - if (all_hits_perBx.find(bx) != all_hits_perBx.end()) { - for (auto &hit : all_hits_perBx[bx]) { - - if (debug_) LogDebug("ShowerBuilder") << " ^ Trying to add hit with wire " - << hit.channelId() << " in OBDT at BX " << bx; - if (!showerb::buffer_contains(hot_wires_buffer, hit)) { - if (debug_) LogDebug("ShowerBuilder") << " ^ added"; - showerb::DTPrimPlusBx _hit(bx, hit); - obdt_buffer.push_back(_hit); - hot_wires_buffer.push_back(_hit); - } - } + // Fill the OBDT buffer with the hits in the current BX this function ensure that hot wires are not added + if (all_hits_perBx.find(bx) != all_hits_perBx.end()) { + for (auto &hit : all_hits_perBx[bx]) { + if (debug_) + LogDebug("ShowerBuilder") << " ^ Trying to add hit with wire " << hit.channelId() << " in OBDT at BX " + << bx; + if (!showerb::buffer_contains(hot_wires_buffer, hit)) { + if (debug_) + LogDebug("ShowerBuilder") << " ^ added"; + showerb::DTPrimPlusBx _hit(bx, hit); + obdt_buffer.push_back(_hit); + hot_wires_buffer.push_back(_hit); + } } -} - -void ShowerBuilder::fill_bmtl1_buffers(){ - // Fill the BMTL1 buffer with the hits in the OBDT buffer only nHits_per_bx_ hits are added - if (obdt_buffer.empty()) return; - if (debug_) LogDebug("ShowerBuilder") << " ^ Getting hits from OBDT"; - for (int i = 0; i < nHits_per_bx_; i++) { - if (obdt_buffer.empty()) break; - auto _hitpbx = obdt_buffer.front(); - if (_hitpbx.second.superLayerId() == 1) { - bmtl1_sl1_buffer.push_back(_hitpbx); - } - else if (_hitpbx.second.superLayerId() == 3) { - bmtl1_sl3_buffer.push_back(_hitpbx); - } - obdt_buffer.pop_front(); + } +} + +void ShowerBuilder::fill_bmtl1_buffers() { + // Fill the BMTL1 buffer with the hits in the OBDT buffer only nHits_per_bx_ hits are added + if (obdt_buffer.empty()) + return; + if (debug_) + LogDebug("ShowerBuilder") << " ^ Getting hits from OBDT"; + for (int i = 0; i < nHits_per_bx_; i++) { + if (obdt_buffer.empty()) + break; + auto _hitpbx = obdt_buffer.front(); + if (_hitpbx.second.superLayerId() == 1) { + bmtl1_sl1_buffer.push_back(_hitpbx); + } else if (_hitpbx.second.superLayerId() == 3) { + bmtl1_sl3_buffer.push_back(_hitpbx); } + obdt_buffer.pop_front(); + } } void ShowerBuilder::bxStep(const int _current_bx) { - // Remove old elements from the buffers - showerb::buffer_clear_olds(obdt_buffer, _current_bx, obdt_hits_bxpersistence_); - showerb::buffer_clear_olds(hot_wires_buffer, _current_bx, obdt_hits_bxpersistence_); - showerb::buffer_clear_olds(bmtl1_sl1_buffer, _current_bx, bmtl1_hits_bxpersistence_); - showerb::buffer_clear_olds(bmtl1_sl3_buffer, _current_bx, bmtl1_hits_bxpersistence_); + // Remove old elements from the buffers + showerb::buffer_clear_olds(obdt_buffer, _current_bx, obdt_hits_bxpersistence_); + showerb::buffer_clear_olds(hot_wires_buffer, _current_bx, obdt_hits_bxpersistence_); + showerb::buffer_clear_olds(bmtl1_sl1_buffer, _current_bx, bmtl1_hits_bxpersistence_); + showerb::buffer_clear_olds(bmtl1_sl3_buffer, _current_bx, bmtl1_hits_bxpersistence_); } - - - - - diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc b/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc index 87cf72c72f4c0..77580c09937ba 100644 --- a/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc +++ b/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc @@ -6,31 +6,29 @@ using namespace cmsdt; -ShowerCandidate::ShowerCandidate() { - clear(); -} +ShowerCandidate::ShowerCandidate() { clear(); } -ShowerCandidate& ShowerCandidate::operator=(const ShowerCandidate &other) { - if (this != &other) { - nhits_ = other.nhits_; - rawId_ = other.rawId_; - bx_ = other.bx_; - wmin_ = other.wmin_; - wmax_ = other.wmax_; - avgPos_ = other.avgPos_; - avgTime_ = other.avgTime_; - shower_flag_ = other.shower_flag_; - } - return *this; +ShowerCandidate& ShowerCandidate::operator=(const ShowerCandidate& other) { + if (this != &other) { + nhits_ = other.nhits_; + rawId_ = other.rawId_; + bx_ = other.bx_; + wmin_ = other.wmin_; + wmax_ = other.wmax_; + avgPos_ = other.avgPos_; + avgTime_ = other.avgTime_; + shower_flag_ = other.shower_flag_; + } + return *this; } void ShowerCandidate::clear() { - nhits_ = 0; - bx_ = 0; - wmin_ = 0; - wmax_ = 0; - avgPos_ = 0; - avgTime_ = 0; - shower_flag_ = false; - wires_profile_.resize(96, 0); + nhits_ = 0; + bx_ = 0; + wmin_ = 0; + wmax_ = 0; + avgPos_ = 0; + avgTime_ = 0; + shower_flag_ = false; + wires_profile_.resize(96, 0); } From 4af375bbc947c79dc2d377ca176aba4d660ab2f9 Mon Sep 17 00:00:00 2001 From: Javier Date: Thu, 27 Mar 2025 16:40:47 +0100 Subject: [PATCH 12/19] Remove left couts --- L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc index b73da113e123c..3a68137351053 100644 --- a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc +++ b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc @@ -833,8 +833,6 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) { } } - //for (auto& ch_filtcorrelatedMetaPrimitives : filtCorrelatedMetaPrimitives) - //cout<<"filtCorrelatedMetaPrimitives: "< Date: Thu, 27 Mar 2025 16:45:15 +0100 Subject: [PATCH 13/19] Code format --- L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc index 3a68137351053..553019db1117b 100644 --- a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc +++ b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc @@ -833,7 +833,6 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) { } } - correlatedMetaPrimitives.clear(); filteredMetaPrimitives.clear(); @@ -863,7 +862,6 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) { } } - allMetaPrimitives.clear(); // Theta (th) matching filter @@ -883,7 +881,6 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) { } } - ///////////// double shift_back = 0; From 6f5c86d99be6a7ec9f6e11f44750a4834bed8dd2 Mon Sep 17 00:00:00 2001 From: jfernan2 Date: Tue, 8 Apr 2025 12:34:17 +0200 Subject: [PATCH 14/19] Change needed for the L1Nano FW --- DataFormats/L1DTTrackFinder/src/classes_def.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/DataFormats/L1DTTrackFinder/src/classes_def.xml b/DataFormats/L1DTTrackFinder/src/classes_def.xml index 53db08b4fbd30..6cb83edad181e 100644 --- a/DataFormats/L1DTTrackFinder/src/classes_def.xml +++ b/DataFormats/L1DTTrackFinder/src/classes_def.xml @@ -73,4 +73,9 @@ + + + + + From 81837fd3d2d360c04dc91ee480d3783c1c993ece Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 11 Apr 2025 13:45:00 +0200 Subject: [PATCH 15/19] Comments from BenjaminRS --- .../interface/L1Phase2MuDTShower.h | 11 +------ .../interface/L1Phase2MuDTShowerContainer.h | 10 ++----- .../L1DTTrackFinder/src/L1Phase2MuDTShower.cc | 19 ++---------- .../src/L1Phase2MuDTShowerContainer.cc | 20 +++---------- .../interface/MPThetaMatching.h | 11 +------ .../DTTriggerPhase2/interface/ShowerBuilder.h | 1 - .../interface/ShowerCandidate.h | 3 -- .../plugins/DTTrigPhase2ShowerProd.cc | 29 +++++++++---------- .../DTTriggerPhase2/src/MPThetaMatching.cc | 17 ++++++----- .../DTTriggerPhase2/src/ShowerBuilder.cc | 19 ++++++------ 10 files changed, 45 insertions(+), 95 deletions(-) diff --git a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h index 00de2566b2565..f60b49e3eda73 100644 --- a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h +++ b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h @@ -16,14 +16,6 @@ #ifndef L1Phase2MuDTShower_H #define L1Phase2MuDTShower_H -//------------------------------------ -// Collaborating Class Declarations -- -//------------------------------------ - -//---------------------- -// Base Class Headers -- -//---------------------- - //--------------- // C++ Headers -- //--------------- @@ -36,6 +28,7 @@ class L1Phase2MuDTShower { public: // Constructors + L1Phase2MuDTShower(); L1Phase2MuDTShower(int wh, // Wheel @@ -51,8 +44,6 @@ class L1Phase2MuDTShower { const std::vector wires_profile // Wires profile ); - virtual ~L1Phase2MuDTShower() {}; - // Operations int whNum() const; diff --git a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h index 2df99df8f81ae..60fb1a27263e0 100644 --- a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h +++ b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h @@ -1,12 +1,12 @@ //------------------------------------------------- // -// Class L1Phase2MuDTPhContainer +// Class L1Phase2MuDTShowerContainer // // Description: trigger primtive data for the -// muon barrel Phase2 trigger +// muon barrel Phase2 trigger shower // // -// Author List: Federica Primavera Bologna INFN +// Author List: Daniel Estrada Acevedo Oviedo Spain // // //-------------------------------------------------- @@ -23,10 +23,6 @@ //---------------------- #include -//--------------- -// C++ Headers -- -//--------------- - // --------------------- // -- Class Interface -- // --------------------- diff --git a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc index 68219e5457029..19e855c19a690 100644 --- a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc +++ b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc @@ -1,13 +1,12 @@ //------------------------------------------------- // -// Class L1MuDTChambPhDigi +// Class L1Phase2MuDTShower // -// Description: trigger primtive data for the -// muon barrel Phase2 trigger +// Description: trigger primitive data for the +// muon barrel Phase2 trigger showers // // // Author List: -// Federica Primavera Bologna INFN // Carlos Vico Oviedo Spain, // Daniel Estrada Acevedo Oviedo Spain. // @@ -19,18 +18,6 @@ //----------------------- #include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h" -//------------------------------- -// Collaborating Class Headers -- -//------------------------------- - -//--------------- -// C++ Headers -- -//--------------- - -//------------------- -// Initializations -- -//------------------- - //---------------- // Constructors -- //---------------- diff --git a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc index 5cc6723b91d39..19671cd6aba34 100644 --- a/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc +++ b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc @@ -1,12 +1,12 @@ //------------------------------------------------- // -// Class L1MuDTChambContainer +// Class L1Phase2MuDTShowerContainer // -// Description: trigger primtive data for the -// muon barrel Phase2 trigger +// Description: trigger primitive data for the +// muon barrel Phase2 trigger shower // // -// Author List: Federica Primavera Bologna INFN +// Author List: Daniel Estrada Acevedo Oviedo Spain. // // //-------------------------------------------------- @@ -16,18 +16,6 @@ //----------------------- #include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h" -//------------------------------- -// Collaborating Class Headers -- -//------------------------------- - -//--------------- -// C++ Headers -- -//--------------- - -//------------------- -// Initializations -- -//------------------- - //---------------- // Constructors -- //---------------- diff --git a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h index 9d4d36070ae0f..6ab9f53606797 100644 --- a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h +++ b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h @@ -38,23 +38,16 @@ class MPThetaMatching : public MPFilter { void finish() override; - // Other public methods - // Public attributes float vwire = 24.4; // cm/ns - // float zFE[5] = {-654., -389., 123., 389., 654.}; //cm - // float xFE[3] = {199/2., 245/2., 303/2.};//cm float zFE[5] = {-658.9, -393.3, 126.4, 393.3, 658.9}; //cm float xFE[3] = {218 / 2., 266.8 / 2., 315 / 2.}; //cm float ZRES_CONV = 65536. / 1500; private: // Private methods - std::vector filter(std::vector inMPs, - // int th_option, - // int th_quality, - double shift_back); + std::vector filter(std::vector inMPs, double shift_back); bool isThereThetaMPInChamber(int sector, int wheel, int station, std::vector thetaMPs); std::vector getBestThetaMPInChamber(std::vector thetaMPs); @@ -68,8 +61,6 @@ class MPThetaMatching : public MPFilter { std::vector *outMPaths, std::vector *savedThetas); - //float computePosRefX(cmsdt::metaPrimitive); - // Private attributes const bool debug_; int th_option_; diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h index 3bbb70e23897b..de416c627f282 100644 --- a/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h @@ -135,7 +135,6 @@ class ShowerBuilder { const DTDigiCollection& digis, ShowerCandidatePtr& showerCandidate_SL1, ShowerCandidatePtr& showerCandidate_SL3); - virtual void finish(); private: // Private auxiliary methods diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h b/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h index 3c553bca6e49c..cb279b31ce43b 100644 --- a/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h @@ -9,11 +9,8 @@ class ShowerCandidate { public: ShowerCandidate(); - ShowerCandidate& operator=(const ShowerCandidate& other); - virtual ~ShowerCandidate() {} - // setter methods void rawId(int rawId) { rawId_ = rawId; } void setBX(int bx) { bx_ = bx; } diff --git a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc index e7459e2b573fe..bfa5ac4de98c3 100644 --- a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc +++ b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc @@ -51,7 +51,6 @@ #include using namespace edm; -using namespace std; using namespace cmsdt; class DTTrigPhase2ShowerProd : public edm::stream::EDProducer<> { @@ -115,26 +114,26 @@ DTTrigPhase2ShowerProd::DTTrigPhase2ShowerProd(const ParameterSet& pset) { dtGeomH = esConsumes(); if (debug_) { - LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: constructor" << endl; + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: constructor" << std::endl; if (showerTaggingAlgo_ == 0) { - LogDebug("DTTrigPhase2ShowerProd") << "Using standalone mode" << endl; + LogDebug("DTTrigPhase2ShowerProd") << "Using standalone mode" << std::endl; } else if (showerTaggingAlgo_ == 1) { - LogDebug("DTTrigPhase2ShowerProd") << "Using firmware emulation mode" << endl; + LogDebug("DTTrigPhase2ShowerProd") << "Using firmware emulation mode" << std::endl; } else - LogError("DTTrigPhase2ShowerProd") << "Unrecognized shower tagging algorithm" << endl; + LogError("DTTrigPhase2ShowerProd") << "Unrecognized shower tagging algorithm" << std::endl; } } DTTrigPhase2ShowerProd::~DTTrigPhase2ShowerProd() { // Destructor implementation if (debug_) - LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: destructor" << endl; + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: destructor" << std::endl; } void DTTrigPhase2ShowerProd::beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) { // beginRun implementation if (debug_) - LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: beginRun started" << endl; + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: beginRun started" << std::endl; showerBuilder->initialise(iEventSetup); if (auto geom = iEventSetup.getHandle(dtGeomH)) { @@ -145,7 +144,7 @@ void DTTrigPhase2ShowerProd::beginRun(edm::Run const& iRun, const edm::EventSetu void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& iEventSetup) { // produce implementation if (debug_) - LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: produce Processing event" << endl; + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: produce Processing event" << std::endl; // Fetch the handle for hits edm::Handle dtdigis; @@ -155,7 +154,7 @@ void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& DTDigiMap digiMap; DTDigiCollection::DigiRangeIterator detUnitIt; if (debug_) - LogDebug("DTTrigPhase2ShowerProd") << " Preprocessing hits..." << endl; + LogDebug("DTTrigPhase2ShowerProd") << " Preprocessing hits..." << std::endl; for (const auto& detUnitIt : *dtdigis) { const DTLayerId& layId = detUnitIt.first; @@ -166,11 +165,11 @@ void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& if (debug_) LogDebug("DTTrigPhase2ShowerProd") << " Hits preprocessed: " << digiMap.size() << " DT chambers to analyze" - << endl; + << std::endl; // 2. Look for showers in each chamber if (debug_) - LogDebug("DTTrigPhase2ShowerProd") << " Building shower candidates for:" << endl; + LogDebug("DTTrigPhase2ShowerProd") << " Building shower candidates for:" << std::endl; std::map ShowerCandidates; for (const auto& ich : dtGeo_->chambers()) { @@ -185,7 +184,7 @@ void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& continue; if (debug_) - LogDebug("DTTrigPhase2ShowerProd") << " " << chid << endl; + LogDebug("DTTrigPhase2ShowerProd") << " " << chid << std::endl; showerBuilder->run(iEvent, iEventSetup, (*dmit).second, ShowerCandidates[sl1id], ShowerCandidates[sl3id]); @@ -196,7 +195,7 @@ void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& // 3. Check shower candidates and store them if flagged if (debug_) - LogDebug("DTTrigPhase2ShowerProd") << " Selecting shower candidates" << endl; + LogDebug("DTTrigPhase2ShowerProd") << " Selecting shower candidates" << std::endl; std::vector outShower; // prepare output container for (auto& sl_showerCand : ShowerCandidates) { @@ -225,7 +224,7 @@ void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& } } if (debug_) - LogDebug("DTTrigPhase2ShowerProd") << " Storing results..." << endl; + LogDebug("DTTrigPhase2ShowerProd") << " Storing results..." << std::endl; // 4.1 Storing results std::unique_ptr resultShower(new L1Phase2MuDTShowerContainer); @@ -236,7 +235,7 @@ void DTTrigPhase2ShowerProd::produce(edm::Event& iEvent, const edm::EventSetup& void DTTrigPhase2ShowerProd::endRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) { // endRun implementation if (debug_) - LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: endRun" << endl; + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: endRun" << std::endl; } void DTTrigPhase2ShowerProd::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc index eab8aea0a0c05..adc0ac1660ba2 100644 --- a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc +++ b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc @@ -3,7 +3,6 @@ #include "L1Trigger/DTTriggerPhase2/interface/constants.h" using namespace edm; -using namespace std; using namespace cmsdt; namespace { @@ -47,6 +46,7 @@ MPThetaMatching::MPThetaMatching(const ParameterSet &pset) scenario_(pset.getParameter("scenario")) {} MPThetaMatching::~MPThetaMatching() { finish(); } + // ============================================================================ // Main methods (initialise, run, finish) // ============================================================================ @@ -59,13 +59,16 @@ void MPThetaMatching::run(edm::Event &iEvent, if (debug_) LogDebug("MPThetaMatching") << "MPThetaMatching: run"; - double shift_back = 0; // Needed for t0 (TDC) calculation, taken from main algo + //static const double shift_back; // Needed for t0 (TDC) calculation, taken from main algo + double temp_shift = 0; if (scenario_ == MC) - shift_back = 400; + temp_shift = 400; // value used in standard CMSSW simulation else if (scenario_ == DATA) - shift_back = 0; + temp_shift = 0; else if (scenario_ == SLICE_TEST) - shift_back = 400; + temp_shift = 400; // slice test mimics simulation + + static const double shift_back = temp_shift; // Needed for t0 (TDC) calculation, taken from main algo if (th_option_ > 0) { auto filteredMPs = filter(inMPaths, shift_back); @@ -74,7 +77,8 @@ void MPThetaMatching::run(edm::Event &iEvent, } else { if (th_option_ < 0) LogDebug("MPThetaMatching") - << "MPThetaMatching: th_option can NOT be negative!!! Check settings. Saving all MPs for the moment" << endl; + << "MPThetaMatching: th_option can NOT be negative!!! Check settings. Saving all MPs for the moment" + << std::endl; outMPaths = inMPaths; //no filter at all } } @@ -159,7 +163,6 @@ std::vector MPThetaMatching::filter(std::vector in oldStation = station; } - // float t0 = (mpTheta.t0 - shift_back * LHC_CLK_FREQ) * ((float) TIME_TO_TDC_COUNTS / (float) LHC_CLK_FREQ); float t0 = ((int)round(mpTheta.t0 / (float)LHC_CLK_FREQ)) - shift_back; float posRefZ = zFE[wheel + 2]; diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc b/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc index 7d7150a7deb05..4b65cc5a20bfc 100644 --- a/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc +++ b/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc @@ -3,7 +3,6 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" using namespace edm; -using namespace std; using namespace cmsdt; // ============================================================================ @@ -38,8 +37,8 @@ void ShowerBuilder::run(Event &iEvent, setInChannels(&digis); std::map aux_showerCands{// defined as a map to easy acces with SL number - {1, make_shared()}, - {3, make_shared()}}; + {1, std::make_shared()}, + {3, std::make_shared()}}; int nHits = all_hits.size(); if (nHits != 0) { @@ -62,8 +61,6 @@ void ShowerBuilder::run(Event &iEvent, showerCandidate_SL3 = std::move(aux_showerCands[3]); } -void ShowerBuilder::finish() {}; - // ============================================================================ // Auxiliary methods // ============================================================================ @@ -230,13 +227,15 @@ void ShowerBuilder::set_shower_properties(ShowerCandidatePtr &showerCand, } void ShowerBuilder::groupHits_byBx() { - double shift_back = 0; - if (scenario_ == MC) //scope for MC - shift_back = 400; + double temp_shift = 0; + if (scenario_ == MC) //scope for MC + temp_shift = 400; // value used in standard CMSSW simulation else if (scenario_ == DATA) //scope for data - shift_back = 0; + temp_shift = 0; else if (scenario_ == SLICE_TEST) //scope for slice test - shift_back = 400; + temp_shift = 400; // slice test to mimic simulation + + static const double shift_back = temp_shift; all_hits_perBx.clear(); // Group hits by BX From 239503c2c0ef6a8d9db383c2413248ed1474110b Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 11 Apr 2025 15:57:16 +0200 Subject: [PATCH 16/19] Reset L1Phase2MuDTShower and L1Phase2MuDTShowerContainer class versions to 3 --- DataFormats/L1DTTrackFinder/src/classes_def.xml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/DataFormats/L1DTTrackFinder/src/classes_def.xml b/DataFormats/L1DTTrackFinder/src/classes_def.xml index 6cb83edad181e..7e68549b00265 100644 --- a/DataFormats/L1DTTrackFinder/src/classes_def.xml +++ b/DataFormats/L1DTTrackFinder/src/classes_def.xml @@ -17,13 +17,8 @@ - - - - - - - + + @@ -54,8 +49,8 @@ - - + + From 678ba28f023b31e3d1d022ec679069cb01e7502a Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 11 Apr 2025 17:08:07 +0200 Subject: [PATCH 17/19] Second round of comments from BenjaminRS --- L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h | 5 ++--- L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc | 3 +-- L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc | 9 +++------ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h index de416c627f282..f88d843784023 100644 --- a/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h @@ -126,11 +126,10 @@ class ShowerBuilder { public: // Constructors and destructor ShowerBuilder(const edm::ParameterSet& pset, edm::ConsumesCollector& iC); - virtual ~ShowerBuilder(); // Main methods - virtual void initialise(const edm::EventSetup& iEventSetup); - virtual void run(edm::Event& iEvent, + void initialise(const edm::EventSetup& iEventSetup); + void run(edm::Event& iEvent, const edm::EventSetup& iEventSetup, const DTDigiCollection& digis, ShowerCandidatePtr& showerCandidate_SL1, diff --git a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc index adc0ac1660ba2..74e7439a19815 100644 --- a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc +++ b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc @@ -2,7 +2,6 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "L1Trigger/DTTriggerPhase2/interface/constants.h" -using namespace edm; using namespace cmsdt; namespace { @@ -38,7 +37,7 @@ namespace { // ============================================================================ // Constructors and destructor // ============================================================================ -MPThetaMatching::MPThetaMatching(const ParameterSet &pset) +MPThetaMatching::MPThetaMatching(const edm::ParameterSet &pset) : MPFilter(pset), debug_(pset.getUntrackedParameter("debug")), th_option_(pset.getParameter("th_option")), diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc b/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc index 4b65cc5a20bfc..dcb4bf849d416 100644 --- a/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc +++ b/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc @@ -2,13 +2,12 @@ #include "L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -using namespace edm; using namespace cmsdt; // ============================================================================ // Constructors and destructor // ============================================================================ -ShowerBuilder::ShowerBuilder(const ParameterSet &pset, edm::ConsumesCollector &iC) +ShowerBuilder::ShowerBuilder(const edm::ParameterSet &pset, edm::ConsumesCollector &iC) : // Unpack information from pset showerTaggingAlgo_(pset.getParameter("showerTaggingAlgo")), threshold_for_shower_(pset.getParameter("threshold_for_shower")), @@ -19,15 +18,13 @@ ShowerBuilder::ShowerBuilder(const ParameterSet &pset, edm::ConsumesCollector &i debug_(pset.getUntrackedParameter("debug")), scenario_(pset.getParameter("scenario")) {} -ShowerBuilder::~ShowerBuilder() {} - // ============================================================================ // Main methods (initialise, run, finish) // ============================================================================ void ShowerBuilder::initialise(const edm::EventSetup &iEventSetup) {} -void ShowerBuilder::run(Event &iEvent, - const EventSetup &iEventSetup, +void ShowerBuilder::run(edm::Event &iEvent, + const edm::EventSetup &iEventSetup, const DTDigiCollection &digis, ShowerCandidatePtr &showerCandidate_SL1, ShowerCandidatePtr &showerCandidate_SL3) { From 25be3c92cf5ac84f0aa0dc0da32b6a19a921b66f Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 11 Apr 2025 17:17:59 +0200 Subject: [PATCH 18/19] Comment from @quinnanm --- L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h | 5 ----- L1Trigger/DTTriggerPhase2/interface/constants.h | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h index 6ab9f53606797..9e1ffbd5708d2 100644 --- a/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h +++ b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h @@ -40,11 +40,6 @@ class MPThetaMatching : public MPFilter { // Public attributes - float vwire = 24.4; // cm/ns - float zFE[5] = {-658.9, -393.3, 126.4, 393.3, 658.9}; //cm - float xFE[3] = {218 / 2., 266.8 / 2., 315 / 2.}; //cm - float ZRES_CONV = 65536. / 1500; - private: // Private methods std::vector filter(std::vector inMPs, double shift_back); diff --git a/L1Trigger/DTTriggerPhase2/interface/constants.h b/L1Trigger/DTTriggerPhase2/interface/constants.h index 981043672db1d..b08fd66b1c3ca 100644 --- a/L1Trigger/DTTriggerPhase2/interface/constants.h +++ b/L1Trigger/DTTriggerPhase2/interface/constants.h @@ -367,6 +367,14 @@ namespace cmsdt { constexpr float ZRES_CONV = 65536. / 1500; constexpr float KRES_CONV = 65536. / 2; + /* + * Front-End positions in local chamber coordinates + */ + constexpr float vwire = 24.4; // Wire propagation velocity cm/ns + constexpr float zFE[5] = {-658.9, -393.3, 126.4, 393.3, 658.9}; // Front-End z positions in cm + constexpr float xFE[3] = {218 / 2., 266.8 / 2., 315 / 2.}; // Front-End x positions in cm + + /* * Size of pre-mixer buffers for DTPrimitives * From b36e41a24a14d4adbd5969c4e4b3828cdecffab7 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 11 Apr 2025 17:21:33 +0200 Subject: [PATCH 19/19] Code format --- L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h | 8 ++++---- L1Trigger/DTTriggerPhase2/interface/constants.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h index f88d843784023..ff3b68fe3aada 100644 --- a/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h @@ -130,10 +130,10 @@ class ShowerBuilder { // Main methods void initialise(const edm::EventSetup& iEventSetup); void run(edm::Event& iEvent, - const edm::EventSetup& iEventSetup, - const DTDigiCollection& digis, - ShowerCandidatePtr& showerCandidate_SL1, - ShowerCandidatePtr& showerCandidate_SL3); + const edm::EventSetup& iEventSetup, + const DTDigiCollection& digis, + ShowerCandidatePtr& showerCandidate_SL1, + ShowerCandidatePtr& showerCandidate_SL3); private: // Private auxiliary methods diff --git a/L1Trigger/DTTriggerPhase2/interface/constants.h b/L1Trigger/DTTriggerPhase2/interface/constants.h index b08fd66b1c3ca..44a978adb00da 100644 --- a/L1Trigger/DTTriggerPhase2/interface/constants.h +++ b/L1Trigger/DTTriggerPhase2/interface/constants.h @@ -374,7 +374,6 @@ namespace cmsdt { constexpr float zFE[5] = {-658.9, -393.3, 126.4, 393.3, 658.9}; // Front-End z positions in cm constexpr float xFE[3] = {218 / 2., 266.8 / 2., 315 / 2.}; // Front-End x positions in cm - /* * Size of pre-mixer buffers for DTPrimitives *