Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:36:45

0001 //-------------------------------------------------
0002 //
0003 /**  \class  DTTrig
0004  *     Steering routine for L1 trigger simulation in a muon barrel station
0005  *
0006  *
0007  *
0008  *   \author C.Grandi
0009  */
0010 //
0011 //--------------------------------------------------
0012 #ifndef DT_TRIG_H
0013 #define DT_TRIG_H
0014 
0015 //---------------
0016 // C++ Headers --
0017 //---------------
0018 #include <map>
0019 #include <string>
0020 
0021 //------------------------------------
0022 // Collaborating Class Declarations --
0023 //------------------------------------
0024 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0025 #include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
0026 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
0027 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0028 #include "DataFormats/DTDigi/interface/DTDigiCollection.h"
0029 #include "DataFormats/MuonDetId/interface/DTSectCollId.h"
0030 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0031 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0032 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0033 #include "DataFormats/GeometryVector/interface/LocalVector.h"
0034 #include "L1Trigger/DTSectorCollector/interface/DTSCTrigUnit.h"
0035 #include "FWCore/Framework/interface/ConsumesCollector.h"
0036 #include "L1Trigger/DTUtilities/interface/DTTrigData.h"
0037 #include "L1Trigger/DTBti/interface/DTBtiTrigData.h"
0038 #include "L1Trigger/DTTraco/interface/DTTracoTrigData.h"
0039 #include "L1Trigger/DTTriggerServerPhi/interface/DTChambPhSegm.h"
0040 #include "L1Trigger/DTTriggerServerTheta/interface/DTChambThSegm.h"
0041 #include "L1Trigger/DTSectorCollector/interface/DTSectColl.h"
0042 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigManager.h"
0043 
0044 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0045 #include "FWCore/Utilities/interface/ESGetToken.h"
0046 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0047 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0048 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigManager.h"
0049 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigManagerRcd.h"
0050 
0051 #include <memory>
0052 
0053 class InputTag;
0054 
0055 //              ---------------------
0056 //              -- Class Interface --
0057 //              ---------------------
0058 
0059 class DTTrig {
0060 public:
0061   typedef std::map<DTChamberId, DTSCTrigUnit, std::less<DTChamberId> > TUcontainer;
0062   typedef TUcontainer::iterator TU_iterator;
0063   typedef TUcontainer::const_iterator TU_const_iterator;
0064   typedef std::map<DTSectCollId, DTSectColl, std::less<DTSectCollId> > SCcontainer;
0065   typedef SCcontainer::iterator SC_iterator;
0066   typedef SCcontainer::const_iterator SC_const_iterator;
0067   typedef std::pair<TU_iterator, TU_iterator> Range;
0068   typedef std::pair<SC_iterator, SC_iterator> SCRange;
0069   typedef std::map<DTChamberId, DTDigiCollection, std::less<DTChamberId> > DTDigiMap;
0070   typedef DTDigiMap::iterator DTDigiMap_iterator;
0071   typedef DTDigiMap::const_iterator DTDigiMap_const_iterator;
0072 
0073 public:
0074   //! Constructors
0075   DTTrig(const edm::ParameterSet& params, edm::ConsumesCollector&& ix);
0076 
0077   //! Create the trigger units and store them in the cache
0078   void createTUs(const edm::EventSetup& iSetup);
0079 
0080   //! update the eventsetup info
0081   void updateES(const edm::EventSetup& iSetup);
0082 
0083   //! Run the whole trigger reconstruction chain
0084   void triggerReco(const edm::Event& iEvent, const edm::EventSetup& iSetup);
0085 
0086   //! Clear the trigger units cache
0087   void clear();
0088 
0089   //! Size of the trigger units store
0090   int size() const { return _cache.size(); }
0091 
0092   //! Begin of the trigger units store
0093   TU_iterator begin() { /*check();*/ return _cache.begin(); }
0094 
0095   //! End of the trigger units store
0096   TU_iterator end() { /*check();*/ return _cache.end(); }
0097 
0098   //! Find a trigger unit in the map
0099   TU_iterator find(DTChamberId id) { /*check();*/ return _cache.find(id); }
0100 
0101   //! Begin of the trigger units store
0102   Range cache() { /*check();*/ return Range(_cache.begin(), _cache.end()); }
0103 
0104   // ------------ do the same for Sector Collector
0105 
0106   //! Size of the sector collector store
0107   int size1() const { /*check();*/ return _cache1.size(); }
0108 
0109   //! Begin of the sector collector store
0110   SC_iterator begin1() { /*check();*/ return _cache1.begin(); }
0111 
0112   //! End of the sectoor collector store
0113   SC_iterator end1() { /*check();*/ return _cache1.end(); }
0114 
0115   //! Find a Sector Collector in the map
0116   SC_iterator find1(DTSectCollId id) { /*check();*/ return _cache1.find(id); }
0117 
0118   //! Range of the sector collector store
0119   SCRange cache1() { /*check();*/ return SCRange(_cache1.begin(), _cache1.end()); }
0120 
0121   //! Return a trigger unit - Muon numbering
0122   DTSCTrigUnit* trigUnit(DTChamberId sid);
0123 
0124   //! Return a trigger unit - Muon numbering, MTTF numbering
0125   DTSCTrigUnit* trigUnit(int wheel, int stat, int sect);
0126 
0127   //! Return the first phi track segment in req. chamber/step
0128   DTChambPhSegm* chPhiSegm1(DTChamberId sid, int step);
0129 
0130   //! Return the first phi track segment in req. chamber/step
0131   DTChambPhSegm* chPhiSegm1(DTSCTrigUnit* unit, int step);
0132 
0133   //! Return the first phi track segment in req. chamber/step, MTTF numbering
0134   DTChambPhSegm* chPhiSegm1(int wheel, int stat, int sect, int step);
0135 
0136   //! Return the second phi track segment in req. chamber/step
0137   DTChambPhSegm* chPhiSegm2(DTChamberId sid, int step);
0138 
0139   //! Return the second phi track segment in req. chamber/step
0140   DTChambPhSegm* chPhiSegm2(DTSCTrigUnit* unit, int step);
0141 
0142   //! Return the second phi track segment in req. chamber/step, MTTF numbering
0143   DTChambPhSegm* chPhiSegm2(int wheel, int stat, int sect, int step);
0144 
0145   //! Return the theta candidates in req. chamber/step
0146   DTChambThSegm* chThetaSegm(DTChamberId sid, int step);
0147 
0148   //! Return the theta candidates in req. chamber/step
0149   DTChambThSegm* chThetaSegm(DTSCTrigUnit* unit, int step);
0150 
0151   //! Return the theta candidates in req. chamber/step, MTTF numbering
0152   DTChambThSegm* chThetaSegm(int wheel, int stat, int sect, int step);
0153 
0154   // sector collector
0155 
0156   //! Return the first phi track segment in req. chamber/step [SC step]
0157   DTSectCollPhSegm* chSectCollPhSegm1(DTSectColl* unit, int step);
0158 
0159   //! Return the first phi track segment in req. chamber/step, [MTTF numbering & SC step]
0160   DTSectCollPhSegm* chSectCollPhSegm1(int wheel, int sect, int step);
0161 
0162   //! Return the second phi track segment in req. chamber/step [SC step]
0163   DTSectCollPhSegm* chSectCollPhSegm2(DTSectColl* unit, int step);
0164 
0165   //! Return the second phi track segment in req. chamber/step, [MTTF numbering & SC step]
0166   DTSectCollPhSegm* chSectCollPhSegm2(int wheel, int sect, int step);
0167 
0168   //! Return the theta track segment in req. chamber/step [SC step]
0169   DTSectCollThSegm* chSectCollThSegm(DTSectColl* unit, int step);
0170 
0171   //! Return the theta track segment in req. chamber/step, [MTTF numbering & SC step]
0172   DTSectCollThSegm* chSectCollThSegm(int wheel, int sect, int step);
0173 
0174   // end sector collector
0175 
0176   //! Dump the geometry
0177   void dumpGeom() const;
0178 
0179   //! Dump the LUT files
0180   void dumpLuts(short int lut_btic, const DTConfigManager* conf) const;
0181 
0182   //! Get BX Offset
0183   int getBXOffset() const { return _conf_manager->getBXOffset(); }
0184 
0185   // Methods to access intermediate results
0186 
0187   //! Return a copy of all the BTI triggers
0188   std::vector<DTBtiTrigData> BtiTrigs() const;
0189 
0190   //! Return a copy of all the TRACO triggers
0191   std::vector<DTTracoTrigData> TracoTrigs() const;
0192 
0193   //! Return a copy of all the Trigger Server (Phi) triggers
0194   std::vector<DTChambPhSegm> TSPhTrigs() const;
0195 
0196   //! Return a copy of all the Trigger Server (Theta) triggers
0197   std::vector<DTChambThSegm> TSThTrigs() const;
0198 
0199   //! Return a copy of all the Sector Collector (Phi) triggers
0200   std::vector<DTSectCollPhSegm> SCPhTrigs() const;
0201 
0202   //! Return a copy of all the Sector Collector (Theta) triggers
0203   std::vector<DTSectCollThSegm> SCThTrigs() const;
0204 
0205   //! Coordinate of a trigger-data object in chamber frame
0206   LocalPoint localPosition(const DTTrigData* trig) const {
0207     return constTrigUnit(trig->ChamberId())->localPosition(trig);
0208   }
0209 
0210   //! Coordinate of a trigger-data object  in CMS frame
0211   GlobalPoint CMSPosition(const DTTrigData* trig) const { return constTrigUnit(trig->ChamberId())->CMSPosition(trig); }
0212 
0213   //! Direction of a trigger-data object  in chamber frame
0214   LocalVector localDirection(const DTTrigData* trig) const {
0215     return constTrigUnit(trig->ChamberId())->localDirection(trig);
0216   }
0217 
0218   //! Direction of a trigger-data object in CMS frame
0219   GlobalVector CMSDirection(const DTTrigData* trig) const {
0220     return constTrigUnit(trig->ChamberId())->CMSDirection(trig);
0221   }
0222 
0223   //! Print a trigger-data object
0224   void print(DTTrigData* trig) const { constTrigUnit(trig->ChamberId())->print(trig); }
0225 
0226 private:
0227   // const version of the methods to access TUs and SCs are private to avoid misuse
0228   //! Return a trigger unit - Muon numbering - const version
0229   DTSCTrigUnit const* constTrigUnit(DTChamberId sid) const;
0230 
0231   //! Return a trigger unit - Muon numbering, MTTF numbering - const version
0232   DTSCTrigUnit const* constTrigUnit(int wheel, int stat, int sect) const;
0233 
0234   //! Return a SC unit - Muon numbering - const version
0235   DTSectColl const* SCUnit(DTSectCollId scid) const;
0236 
0237   //! Return a SC Unit Muon Numbering, MTTF numbering - const version
0238   DTSectColl const* SCUnit(int wheel, int sect) const;
0239 
0240 private:
0241   TUcontainer _cache;                    // Trigger units
0242   SCcontainer _cache1;                   // Sector Collector units
0243   const DTConfigManager* _conf_manager;  // Configuration Manager class pointer
0244   edm::InputTag _digitag;
0245   edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
0246   edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomBeginRunToken_;
0247   edm::ESGetToken<DTConfigManager, DTConfigManagerRcd> confToken_;
0248   bool _debug;  // Debug flag
0249   bool _inputexist;
0250 
0251   unsigned long long _configid;
0252   unsigned long long _geomid;
0253 };
0254 
0255 #endif