Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:44

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();*/
0094     return _cache.begin();
0095   }
0096 
0097   //! End of the trigger units store
0098   TU_iterator end() { /*check();*/
0099     return _cache.end();
0100   }
0101 
0102   //! Find a trigger unit in the map
0103   TU_iterator find(DTChamberId id) { /*check();*/
0104     return _cache.find(id);
0105   }
0106 
0107   //! Begin of the trigger units store
0108   Range cache() { /*check();*/
0109     return Range(_cache.begin(), _cache.end());
0110   }
0111 
0112   // ------------ do the same for Sector Collector
0113 
0114   //! Size of the sector collector store
0115   int size1() const { /*check();*/
0116     return _cache1.size();
0117   }
0118 
0119   //! Begin of the sector collector store
0120   SC_iterator begin1() { /*check();*/
0121     return _cache1.begin();
0122   }
0123 
0124   //! End of the sectoor collector store
0125   SC_iterator end1() { /*check();*/
0126     return _cache1.end();
0127   }
0128 
0129   //! Find a Sector Collector in the map
0130   SC_iterator find1(DTSectCollId id) { /*check();*/
0131     return _cache1.find(id);
0132   }
0133 
0134   //! Range of the sector collector store
0135   SCRange cache1() { /*check();*/
0136     return SCRange(_cache1.begin(), _cache1.end());
0137   }
0138 
0139   //! Return a trigger unit - Muon numbering
0140   DTSCTrigUnit* trigUnit(DTChamberId sid);
0141 
0142   //! Return a trigger unit - Muon numbering, MTTF numbering
0143   DTSCTrigUnit* trigUnit(int wheel, int stat, int sect);
0144 
0145   //! Return the first phi track segment in req. chamber/step
0146   DTChambPhSegm* chPhiSegm1(DTChamberId sid, int step);
0147 
0148   //! Return the first phi track segment in req. chamber/step
0149   DTChambPhSegm* chPhiSegm1(DTSCTrigUnit* unit, int step);
0150 
0151   //! Return the first phi track segment in req. chamber/step, MTTF numbering
0152   DTChambPhSegm* chPhiSegm1(int wheel, int stat, int sect, int step);
0153 
0154   //! Return the second phi track segment in req. chamber/step
0155   DTChambPhSegm* chPhiSegm2(DTChamberId sid, int step);
0156 
0157   //! Return the second phi track segment in req. chamber/step
0158   DTChambPhSegm* chPhiSegm2(DTSCTrigUnit* unit, int step);
0159 
0160   //! Return the second phi track segment in req. chamber/step, MTTF numbering
0161   DTChambPhSegm* chPhiSegm2(int wheel, int stat, int sect, int step);
0162 
0163   //! Return the theta candidates in req. chamber/step
0164   DTChambThSegm* chThetaSegm(DTChamberId sid, int step);
0165 
0166   //! Return the theta candidates in req. chamber/step
0167   DTChambThSegm* chThetaSegm(DTSCTrigUnit* unit, int step);
0168 
0169   //! Return the theta candidates in req. chamber/step, MTTF numbering
0170   DTChambThSegm* chThetaSegm(int wheel, int stat, int sect, int step);
0171 
0172   // sector collector
0173 
0174   //! Return the first phi track segment in req. chamber/step [SC step]
0175   DTSectCollPhSegm* chSectCollPhSegm1(DTSectColl* unit, int step);
0176 
0177   //! Return the first phi track segment in req. chamber/step, [MTTF numbering & SC step]
0178   DTSectCollPhSegm* chSectCollPhSegm1(int wheel, int sect, int step);
0179 
0180   //! Return the second phi track segment in req. chamber/step [SC step]
0181   DTSectCollPhSegm* chSectCollPhSegm2(DTSectColl* unit, int step);
0182 
0183   //! Return the second phi track segment in req. chamber/step, [MTTF numbering & SC step]
0184   DTSectCollPhSegm* chSectCollPhSegm2(int wheel, int sect, int step);
0185 
0186   //! Return the theta track segment in req. chamber/step [SC step]
0187   DTSectCollThSegm* chSectCollThSegm(DTSectColl* unit, int step);
0188 
0189   //! Return the theta track segment in req. chamber/step, [MTTF numbering & SC step]
0190   DTSectCollThSegm* chSectCollThSegm(int wheel, int sect, int step);
0191 
0192   // end sector collector
0193 
0194   //! Dump the geometry
0195   void dumpGeom() const;
0196 
0197   //! Dump the LUT files
0198   void dumpLuts(short int lut_btic, const DTConfigManager* conf) const;
0199 
0200   //! Get BX Offset
0201   int getBXOffset() const { return _conf_manager->getBXOffset(); }
0202 
0203   // Methods to access intermediate results
0204 
0205   //! Return a copy of all the BTI triggers
0206   std::vector<DTBtiTrigData> BtiTrigs() const;
0207 
0208   //! Return a copy of all the TRACO triggers
0209   std::vector<DTTracoTrigData> TracoTrigs() const;
0210 
0211   //! Return a copy of all the Trigger Server (Phi) triggers
0212   std::vector<DTChambPhSegm> TSPhTrigs() const;
0213 
0214   //! Return a copy of all the Trigger Server (Theta) triggers
0215   std::vector<DTChambThSegm> TSThTrigs() const;
0216 
0217   //! Return a copy of all the Sector Collector (Phi) triggers
0218   std::vector<DTSectCollPhSegm> SCPhTrigs() const;
0219 
0220   //! Return a copy of all the Sector Collector (Theta) triggers
0221   std::vector<DTSectCollThSegm> SCThTrigs() const;
0222 
0223   //! Coordinate of a trigger-data object in chamber frame
0224   LocalPoint localPosition(const DTTrigData* trig) const {
0225     return constTrigUnit(trig->ChamberId())->localPosition(trig);
0226   }
0227 
0228   //! Coordinate of a trigger-data object  in CMS frame
0229   GlobalPoint CMSPosition(const DTTrigData* trig) const { return constTrigUnit(trig->ChamberId())->CMSPosition(trig); }
0230 
0231   //! Direction of a trigger-data object  in chamber frame
0232   LocalVector localDirection(const DTTrigData* trig) const {
0233     return constTrigUnit(trig->ChamberId())->localDirection(trig);
0234   }
0235 
0236   //! Direction of a trigger-data object in CMS frame
0237   GlobalVector CMSDirection(const DTTrigData* trig) const {
0238     return constTrigUnit(trig->ChamberId())->CMSDirection(trig);
0239   }
0240 
0241   //! Print a trigger-data object
0242   void print(DTTrigData* trig) const { constTrigUnit(trig->ChamberId())->print(trig); }
0243 
0244 private:
0245   // const version of the methods to access TUs and SCs are private to avoid misuse
0246   //! Return a trigger unit - Muon numbering - const version
0247   DTSCTrigUnit const* constTrigUnit(DTChamberId sid) const;
0248 
0249   //! Return a trigger unit - Muon numbering, MTTF numbering - const version
0250   DTSCTrigUnit const* constTrigUnit(int wheel, int stat, int sect) const;
0251 
0252   //! Return a SC unit - Muon numbering - const version
0253   DTSectColl const* SCUnit(DTSectCollId scid) const;
0254 
0255   //! Return a SC Unit Muon Numbering, MTTF numbering - const version
0256   DTSectColl const* SCUnit(int wheel, int sect) const;
0257 
0258 private:
0259   TUcontainer _cache;                    // Trigger units
0260   SCcontainer _cache1;                   // Sector Collector units
0261   const DTConfigManager* _conf_manager;  // Configuration Manager class pointer
0262   edm::InputTag _digitag;
0263   edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
0264   edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomBeginRunToken_;
0265   edm::ESGetToken<DTConfigManager, DTConfigManagerRcd> confToken_;
0266   bool _debug;  // Debug flag
0267   bool _inputexist;
0268 
0269   unsigned long long _configid;
0270   unsigned long long _geomid;
0271 };
0272 
0273 #endif