diff --git a/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h new file mode 100644 index 0000000000000..f60b49e3eda73 --- /dev/null +++ b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h @@ -0,0 +1,75 @@ +//------------------------------------------------- +// +// Class L1Phase2MuDTShower +// +// Description: shower primitive data for the +// muon barrel Phase2 trigger +// +// +// Author List: +// Federica Primavera Bologna INFN +// Carlos Vico Oviedo Spain, +// Daniel Estrada Acevedo Oviedo Spain. +// +// +//-------------------------------------------------- +#ifndef L1Phase2MuDTShower_H +#define L1Phase2MuDTShower_H + +//--------------- +// C++ Headers -- +//--------------- +#include + +// --------------------- +// -- Class Interface -- +// --------------------- + +class L1Phase2MuDTShower { +public: + // 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 + ); + + // Operations + + 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_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/interface/L1Phase2MuDTShowerContainer.h b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h new file mode 100644 index 0000000000000..60fb1a27263e0 --- /dev/null +++ b/DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h @@ -0,0 +1,46 @@ +//------------------------------------------------- +// +// Class L1Phase2MuDTShowerContainer +// +// Description: trigger primtive data for the +// muon barrel Phase2 trigger shower +// +// +// Author List: Daniel Estrada Acevedo Oviedo Spain +// +// +//-------------------------------------------------- +#ifndef L1Phase2MuDTShowerContainer_H +#define L1Phase2MuDTShowerContainer_H + +//------------------------------------ +// Collaborating Class Declarations -- +//------------------------------------ +#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h" + +//---------------------- +// Base Class Headers -- +//---------------------- +#include + +// --------------------- +// -- 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..19e855c19a690 --- /dev/null +++ b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc @@ -0,0 +1,85 @@ +//------------------------------------------------- +// +// Class L1Phase2MuDTShower +// +// Description: trigger primitive data for the +// muon barrel Phase2 trigger showers +// +// +// Author List: +// Carlos Vico Oviedo Spain, +// Daniel Estrada Acevedo Oviedo Spain. +// +// +//-------------------------------------------------- + +//----------------------- +// This Class's Header -- +//----------------------- +#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h" + +//---------------- +// Constructors -- +//---------------- +L1Phase2MuDTShower::L1Phase2MuDTShower() + : 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_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 -- +//-------------- + +int L1Phase2MuDTShower::whNum() const { return m_wheel; } + +int L1Phase2MuDTShower::scNum() const { return m_sector; } + +int L1Phase2MuDTShower::stNum() const { return m_station; } + +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/L1Phase2MuDTShowerContainer.cc b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc new file mode 100644 index 0000000000000..19671cd6aba34 --- /dev/null +++ b/DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShowerContainer.cc @@ -0,0 +1,31 @@ +//------------------------------------------------- +// +// Class L1Phase2MuDTShowerContainer +// +// Description: trigger primitive data for the +// muon barrel Phase2 trigger shower +// +// +// Author List: Daniel Estrada Acevedo Oviedo Spain. +// +// +//-------------------------------------------------- + +//----------------------- +// This Class's Header -- +//----------------------- +#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShowerContainer.h" + +//---------------- +// 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..7e68549b00265 100644 --- a/DataFormats/L1DTTrackFinder/src/classes_def.xml +++ b/DataFormats/L1DTTrackFinder/src/classes_def.xml @@ -16,6 +16,11 @@ + + + + + @@ -28,6 +33,7 @@ + @@ -42,6 +48,11 @@ + + + + + @@ -55,5 +66,11 @@ + + + + + + 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/interface/MPCoincidenceFilter.h b/L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h index 51ba5ffe7e577..c360b8385032f 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/interface/MPThetaMatching.h b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h new file mode 100644 index 0000000000000..9e1ffbd5708d2 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h @@ -0,0 +1,66 @@ +#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, + std::vector &allMPaths, + std::vector &inMPaths, + std::vector &outMPaths) override {}; + void run(edm::Event &iEvent, + const edm::EventSetup &iEventSetup, + MuonPathPtrs &inMPath, + MuonPathPtrs &outMPath) override {}; + + void finish() override; + + // Public attributes + +private: + // Private methods + 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); + + // Function to compare pairs based on the float value, ascending order + 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_; + int th_option_; + int th_quality_; + int scenario_; +}; + +#endif diff --git a/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h new file mode 100644 index 0000000000000..ff3b68fe3aada --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h @@ -0,0 +1,178 @@ +#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; + + 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(); + } + + return aux_avgPos_ / nhits_; + } + + inline 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_; + } + + inline void set_wires_profile(std::vector& wires_profile, DTPrimitives& hits) { + for (auto& hit : hits) { + wires_profile[hit.channelId() - 1]++; + } + } + + 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; + } + + inline void buffer_get_hits(const ShowerBuffer& buffer, DTPrimitives& hits) { + for (const auto& item : buffer) { + hits.push_back(item.second); + } + } + + 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(); + } + } + + 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); + + // 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); + +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 new file mode 100644 index 0000000000000..cb279b31ce43b --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h @@ -0,0 +1,57 @@ +#ifndef L1Trigger_DTTriggerPhase2_ShowerCandidate_h +#define L1Trigger_DTTriggerPhase2_ShowerCandidate_h +#include +#include + +#include "L1Trigger/DTTriggerPhase2/interface/DTprimitive.h" +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" + +class ShowerCandidate { +public: + ShowerCandidate(); + ShowerCandidate& operator=(const ShowerCandidate& other); + + // 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_; +}; + +typedef std::vector ShowerCandidates; +typedef std::shared_ptr ShowerCandidatePtr; +typedef std::vector ShowerCandidatePtrs; + +#endif diff --git a/L1Trigger/DTTriggerPhase2/interface/constants.h b/L1Trigger/DTTriggerPhase2/interface/constants.h index 981043672db1d..44a978adb00da 100644 --- a/L1Trigger/DTTriggerPhase2/interface/constants.h +++ b/L1Trigger/DTTriggerPhase2/interface/constants.h @@ -367,6 +367,13 @@ 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 * diff --git a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc index ef83fce3a665a..553019db1117b 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,9 @@ 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_; bool output_mixer_; @@ -166,6 +170,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 +215,9 @@ 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; dtDigisToken_ = consumes(pset.getParameter("digiTag")); @@ -268,6 +276,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 +302,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 +864,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 +895,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 +911,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 +1320,9 @@ void DTTrigPhase2Prod::fillDescriptions(edm::ConfigurationDescriptions& descript desc.add("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); desc.add("output_mixer", false); desc.add("output_latpredictor", false); diff --git a/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc new file mode 100644 index 0000000000000..bfa5ac4de98c3 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2ShowerProd.cc @@ -0,0 +1,257 @@ +/* + EDProducer class for shower emulation in Phase2 DTs. + Authors: + - Carlos Vico Villalba (U. Oviedo) + - Daniel Estrada Acevedo (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/ShowerBuilder.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 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; + + 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 +}; + +/* 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" << std::endl; + if (showerTaggingAlgo_ == 0) { + LogDebug("DTTrigPhase2ShowerProd") << "Using standalone mode" << std::endl; + } else if (showerTaggingAlgo_ == 1) { + LogDebug("DTTrigPhase2ShowerProd") << "Using firmware emulation mode" << std::endl; + } else + LogError("DTTrigPhase2ShowerProd") << "Unrecognized shower tagging algorithm" << std::endl; + } +} + +DTTrigPhase2ShowerProd::~DTTrigPhase2ShowerProd() { + // Destructor implementation + if (debug_) + 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" << std::endl; + + 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_) + LogDebug("DTTrigPhase2ShowerProd") << "DTTrigPhase2ShowerProd: produce Processing event" << std::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..." << std::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" + << std::endl; + + // 2. Look for showers in each chamber + if (debug_) + LogDebug("DTTrigPhase2ShowerProd") << " Building shower candidates for:" << std::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 << std::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" << std::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..." << std::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" << std::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); +} + +DEFINE_FWK_MODULE(DTTrigPhase2ShowerProd); diff --git a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2PrimitiveDigis_cfi.py index aa10705bbfd3a..b50d2fb012fb3 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,7 +25,10 @@ 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 + 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), output_mixer = cms.bool(False), diff --git a/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py new file mode 100644 index 0000000000000..5ba4a46517d82 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/python/dtTriggerPhase2Showers_cfi.py @@ -0,0 +1,16 @@ +""" 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"), + showerTaggingAlgo = cms.int32(1), + 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/MPCoincidenceFilter.cc b/L1Trigger/DTTriggerPhase2/src/MPCoincidenceFilter.cc index e82a7abb84ab4..cb998d8ffacfd 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; @@ -70,7 +72,13 @@ std::vector MPCoincidenceFilter::filter(std::vector 5) + bool wh2pass = false; + if (abs(wheel) == 2 && station == 1 && co_wh2option == 1) + wh2pass = true; + if (abs(wheel) == 2 && station < 3 && co_wh2option == 2) + wh2pass = true; + + if (co_option == -1 || mp.quality > 5 || wh2pass == 1) outMPs.push_back(mp); else { int sector_p1 = sector + 1; diff --git a/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc new file mode 100644 index 0000000000000..74e7439a19815 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/src/MPThetaMatching.cc @@ -0,0 +1,324 @@ +#include "L1Trigger/DTTriggerPhase2/interface/MPThetaMatching.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "L1Trigger/DTTriggerPhase2/interface/constants.h" + +using namespace cmsdt; + +namespace { + struct { + bool operator()(const metaPrimitive &mp1, const metaPrimitive &mp2) const { + DTChamberId chId1(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 +// ============================================================================ +MPThetaMatching::MPThetaMatching(const edm::ParameterSet &pset) + : MPFilter(pset), + debug_(pset.getUntrackedParameter("debug")), + th_option_(pset.getParameter("th_option")), + 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::run(edm::Event &iEvent, + const edm::EventSetup &iEventSetup, + std::vector &inMPaths, + std::vector &outMPaths) { + if (debug_) + LogDebug("MPThetaMatching") << "MPThetaMatching: run"; + + //static const double shift_back; // Needed for t0 (TDC) calculation, taken from main algo + double temp_shift = 0; + if (scenario_ == MC) + temp_shift = 400; // value used in standard CMSSW simulation + else if (scenario_ == DATA) + temp_shift = 0; + else if (scenario_ == SLICE_TEST) + 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); + 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" + << std::endl; + outMPaths = inMPaths; //no filter at all + } +} + +void MPThetaMatching::finish() {}; + +/////////////////////////// +/// OTHER METHODS + +std::vector MPThetaMatching::filter(std::vector inMPs, 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 if (chId.station() == 4) //No theta matching for MB4, save MP + outMPs.push_back(mp); + 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 + } else + phiMPs.push_back(mp); + } + + //Order Theta MPs by quality + std::sort(thetaMPs.begin(), thetaMPs.end(), compareMPs); + + //Use only best quality theta MP in chamber + thetaMPs = getBestThetaMPInChamber(thetaMPs); + + // Loop on phi, save those at chamber 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 (!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 + } + } + + // Loop on theta (already ordered) + int oldSector = 0; + int oldStation = 0; + int oldWheel = -999; + // container to decide which theta-phi pair to save + std::vector> + deltaTimePosPhiCands; //thetaMP, phiMP, difference in TimePosition + std::vector savedThetaMPs; + + 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) { //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.empty()) + orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); + + deltaTimePosPhiCands.clear(); + oldSector = sector; + oldWheel = wheel; + oldStation = station; + } + + float t0 = ((int)round(mpTheta.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(mpTheta.phi); + + // Loop in Phis + 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 (station2 != station || sector2 != sector || wheel2 != wheel) + continue; + + float t02 = ((int)round(mpPhi.t0 / (float)LHC_CLK_FREQ)) - shift_back; + + float tphi = t02 - abs(posZ / ZRES_CONV - posRefZ) / vwire; + + 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); + + float posRefX = LR * xFE[station - 1]; + float ttheta = t0 - (mpPhi.x / 1000 - posRefX) / vwire; + + deltaTimePosPhiCands.push_back({mpTheta, mpPhi, abs(tphi - ttheta)}); + } //loop in phis + + if (deltaTimePosPhiCands.empty()) { + outMPs.push_back(mpTheta); //save ThetaMP when there is no phi TPs + savedThetaMPs.push_back(mpTheta); + } + } // loop in thetas + + if (!deltaTimePosPhiCands.empty()) + orderAndSave(deltaTimePosPhiCands, &outMPs, &savedThetaMPs); //do once more for last theta TP in loop + + return outMPs; +}; + +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); + + //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(); + 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; + } + + 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++; + } + } + 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; +}; + +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 (std::tuple &p : + deltaTimePosPhiCands) { //save up to nth nearest Theta-Phi pair candidate + 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 + 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; //avoid Theta duplicates when saving more than one pair + } + + 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 (std::get<1>(p).quality > th_quality_) { + //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)); + count++; + } + } else + break; + } +} diff --git a/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc b/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc new file mode 100644 index 0000000000000..dcb4bf849d416 --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/src/ShowerBuilder.cc @@ -0,0 +1,289 @@ +#include "L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h" +#include "L1Trigger/DTTriggerPhase2/interface/ShowerBuilder.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +using namespace cmsdt; + +// ============================================================================ +// Constructors and destructor +// ============================================================================ +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")), + 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")) {} + +// ============================================================================ +// Main methods (initialise, run, finish) +// ============================================================================ +void ShowerBuilder::initialise(const edm::EventSetup &iEventSetup) {} + +void ShowerBuilder::run(edm::Event &iEvent, + const edm::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, std::make_shared()}, + {3, std::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]); +} + +// ============================================================================ +// 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 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 + temp_shift = 0; + else if (scenario_ == SLICE_TEST) //scope for slice test + temp_shift = 400; // slice test to mimic simulation + + static const double shift_back = temp_shift; + + 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 new file mode 100644 index 0000000000000..77580c09937ba --- /dev/null +++ b/L1Trigger/DTTriggerPhase2/src/ShowerCandidate.cc @@ -0,0 +1,34 @@ +#include "L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h" + +#include +#include +#include + +using namespace cmsdt; + +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; +} + +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/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