Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-12-02 10:36:18

0001 #ifndef L1TGlobalProducer_h
0002 #define L1TGlobalProducer_h
0003 
0004 // Emulator for L1T Global
0005 // author: Brian Winer  Ohio State
0006 
0007 #include <string>
0008 #include <vector>
0009 #include <iostream>
0010 #include <fstream>
0011 
0012 #include "FWCore/Framework/interface/Frameworkfwd.h"
0013 #include "FWCore/Framework/interface/stream/EDProducer.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "FWCore/Utilities/interface/InputTag.h"
0018 #include "FWCore/Utilities/interface/ESGetToken.h"
0019 
0020 #include "L1Trigger/L1TGlobal/interface/GlobalBoard.h"
0021 
0022 #include "CondFormats/L1TObjects/interface/L1TGlobalParameters.h"
0023 #include "L1Trigger/L1TGlobal/interface/GlobalParamsHelper.h"
0024 #include "L1Trigger/L1TGlobal/interface/PrescalesVetosFractHelper.h"
0025 #include "CondFormats/L1TObjects/interface/L1TUtmTriggerMenu.h"
0026 #include "CondFormats/DataRecord/interface/L1TUtmTriggerMenuRcd.h"
0027 #include "CondFormats/L1TObjects/interface/L1TGlobalParameters.h"
0028 #include "CondFormats/DataRecord/interface/L1TGlobalParametersRcd.h"
0029 #include "CondFormats/L1TObjects/interface/L1TGlobalPrescalesVetosFract.h"
0030 #include "CondFormats/DataRecord/interface/L1TGlobalPrescalesVetosFractRcd.h"
0031 
0032 class L1TGlobalParameters;
0033 class L1GtParameters;
0034 class L1GtBoardMaps;
0035 
0036 class L1GtPrescaleFactors;
0037 class L1GtTriggerMask;
0038 
0039 class TriggerMenu;
0040 
0041 // class declaration
0042 
0043 class L1TGlobalProducer : public edm::stream::EDProducer<> {
0044 public:
0045   explicit L1TGlobalProducer(const edm::ParameterSet&);
0046   ~L1TGlobalProducer() override;
0047 
0048   void produce(edm::Event&, const edm::EventSetup&) override;
0049 
0050   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0051 
0052 private:
0053   /// cached stuff
0054 
0055   /// stable parameters
0056   const L1TGlobalParameters* m_l1GtStablePar;
0057   unsigned long long m_l1GtParCacheID;
0058 
0059   // trigger menu
0060   std::unique_ptr<TriggerMenu> m_l1GtMenu;
0061   unsigned long long m_l1GtMenuCacheID;
0062 
0063   // number of physics triggers
0064   unsigned int m_numberPhysTriggers;
0065 
0066   // number of DAQ partitions
0067   unsigned int m_numberDaqPartitions;
0068 
0069   // number of objects of each type
0070   int m_nrL1Mu;
0071   int m_nrL1MuShower;
0072   int m_nrL1EG;
0073   int m_nrL1Tau;
0074 
0075   int m_nrL1Jet;
0076 
0077   // ... the rest of the objects are global
0078   int m_ifMuEtaNumberBits;
0079   int m_ifCaloEtaNumberBits;
0080 
0081   ///    total number of Bx's in the event coming from EventSetup
0082   int m_totalBxInEvent;
0083 
0084   ///    active boards in L1 GT DAQ record
0085   uint16_t m_activeBoardsGtDaq;
0086 
0087   /// length of BST record (in bytes) from event setup
0088   unsigned int m_bstLengthBytes;
0089 
0090   /// board maps - cache only the record
0091   const L1GtBoardMaps* m_l1GtBM;
0092   unsigned long long m_l1GtBMCacheID;
0093 
0094   /// prescale factors
0095   const l1t::PrescalesVetosFractHelper* m_l1GtPrescalesVetosFract;
0096   unsigned long long m_l1GtPfAlgoCacheID;
0097 
0098   const std::vector<std::vector<double>>* m_prescaleFactorsAlgoTrig;
0099   std::vector<std::vector<double>> m_initialPrescaleFactorsAlgoTrig;
0100 
0101   uint m_currentLumi;
0102 
0103   /// trigger masks & veto masks
0104   const L1GtTriggerMask* m_l1GtTmAlgo;
0105   unsigned long long m_l1GtTmAlgoCacheID;
0106 
0107   const L1GtTriggerMask* m_l1GtTmVetoAlgo;
0108   unsigned long long m_l1GtTmVetoAlgoCacheID;
0109 
0110   const std::vector<unsigned int>* m_triggerMaskAlgoTrig;
0111   std::vector<unsigned int> m_initialTriggerMaskAlgoTrig;
0112 
0113   const std::vector<int>* m_triggerMaskVetoAlgoTrig;
0114   std::vector<int> m_initialTriggerMaskVetoAlgoTrig;
0115 
0116   std::unique_ptr<l1t::GlobalBoard> m_uGtBrd;
0117 
0118   /// input tag for muon collection from GMT
0119   edm::InputTag m_muInputTag;
0120   edm::InputTag m_muShowerInputTag;
0121   edm::EDGetTokenT<BXVector<l1t::Muon>> m_muInputToken;
0122   edm::EDGetTokenT<BXVector<l1t::MuonShower>> m_muShowerInputToken;
0123 
0124   /// input tag for calorimeter collections from GCT
0125   edm::InputTag m_egInputTag;
0126   edm::InputTag m_tauInputTag;
0127   edm::InputTag m_jetInputTag;
0128   edm::InputTag m_sumInputTag;
0129   edm::EDGetTokenT<BXVector<l1t::EGamma>> m_egInputToken;
0130   edm::EDGetTokenT<BXVector<l1t::Tau>> m_tauInputToken;
0131   edm::EDGetTokenT<BXVector<l1t::Jet>> m_jetInputToken;
0132   edm::EDGetTokenT<BXVector<l1t::EtSum>> m_sumInputToken;
0133 
0134   /// input tag for external conditions
0135   edm::InputTag m_extInputTag;
0136   edm::EDGetTokenT<BXVector<GlobalExtBlk>> m_extInputToken;
0137 
0138   /// logical flag to produce the L1 GT DAQ readout record
0139   bool m_produceL1GtDaqRecord;
0140 
0141   /// logical flag to produce the L1 GT object map record
0142   bool m_produceL1GtObjectMapRecord;
0143 
0144   /// logical flag to write the PSB content in the  L1 GT DAQ record
0145   bool m_writePsbL1GtDaqRecord;
0146 
0147   /// number of "bunch crossing in the event" (BxInEvent) to be emulated
0148   /// symmetric around L1Accept (BxInEvent = 0):
0149   ///    1 (BxInEvent = 0); 3 (F 0 1) (standard record); 5 (E F 0 1 2) (debug record)
0150   /// even numbers (except 0) "rounded" to the nearest lower odd number
0151   int m_emulateBxInEvent;
0152 
0153   /// Bx expected in Data coming to GT
0154   int m_L1DataBxInEvent;
0155 
0156   /// alternative for number of BX per active board in GT DAQ record: 0 or 1
0157   /// the position is identical with the active board bit
0158   unsigned int m_alternativeNrBxBoardDaq;
0159 
0160   /// length of BST record (in bytes) from parameter set
0161   int m_psBstLengthBytes;
0162 
0163   /// prescale set used
0164   unsigned int m_prescaleSet;
0165 
0166   /// run algorithm triggers
0167   ///     if true, unprescaled (all prescale factors 1)
0168   ///     will overwrite the event setup
0169   bool m_algorithmTriggersUnprescaled;
0170 
0171   ///     if true, unmasked - all enabled (all trigger masks set to 0)
0172   ///     will overwrite the event setup
0173   bool m_algorithmTriggersUnmasked;
0174 
0175   /// verbosity level
0176   int m_verbosity;
0177   bool m_printL1Menu;
0178   bool m_isDebugEnabled;
0179 
0180   bool m_getPrescaleColumnFromData;
0181   bool m_requireMenuToMatchAlgoBlkInput;
0182   edm::InputTag m_algoblkInputTag;
0183   edm::EDGetToken m_algoblkInputToken;
0184 
0185   edm::ESGetToken<L1TGlobalParameters, L1TGlobalParametersRcd> m_l1GtStableParToken;
0186   edm::ESGetToken<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd> m_l1GtMenuToken;
0187   edm::ESGetToken<L1TGlobalPrescalesVetosFract, L1TGlobalPrescalesVetosFractRcd> m_l1GtPrescaleVetosToken;
0188 
0189   // disables resetting the prescale counters each lumisection (needed for offline)
0190   bool m_resetPSCountersEachLumiSec;
0191 
0192   // initialise prescale counters with a semi-random value in the range [0, prescale*10^precision - 1];
0193   // if false, the prescale counters are initialised to zero
0194   bool m_semiRandomInitialPSCounters;
0195 
0196   // switch to load muon showers in the global board
0197   bool m_useMuonShowers;
0198 };
0199 
0200 #endif  // L1TGlobalProducer_h