Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:55:05

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 the Global Muon Trigger (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 Calo Layer 2 (GCT) or Zero Degree Calorimeter (ZDC)
0125   edm::InputTag m_egInputTag;
0126   edm::InputTag m_tauInputTag;
0127   edm::InputTag m_jetInputTag;
0128   edm::InputTag m_sumInputTag;
0129   edm::InputTag m_sumZdcInputTag;
0130   edm::EDGetTokenT<BXVector<l1t::EGamma>> m_egInputToken;
0131   edm::EDGetTokenT<BXVector<l1t::Tau>> m_tauInputToken;
0132   edm::EDGetTokenT<BXVector<l1t::Jet>> m_jetInputToken;
0133   edm::EDGetTokenT<BXVector<l1t::EtSum>> m_sumInputToken;
0134   edm::EDGetTokenT<BXVector<l1t::EtSum>> m_sumZdcInputToken;
0135 
0136   /// input tag for external conditions
0137   edm::InputTag m_extInputTag;
0138   edm::EDGetTokenT<BXVector<GlobalExtBlk>> m_extInputToken;
0139 
0140   /// logical flag to produce the L1 GT DAQ readout record
0141   bool m_produceL1GtDaqRecord;
0142 
0143   /// logical flag to produce the L1 GT object map record
0144   bool m_produceL1GtObjectMapRecord;
0145 
0146   /// logical flag to write the PSB content in the  L1 GT DAQ record
0147   bool m_writePsbL1GtDaqRecord;
0148 
0149   /// number of "bunch crossing in the event" (BxInEvent) to be emulated
0150   /// symmetric around L1Accept (BxInEvent = 0):
0151   ///    1 (BxInEvent = 0); 3 (F 0 1) (standard record); 5 (E F 0 1 2) (debug record)
0152   /// even numbers (except 0) "rounded" to the nearest lower odd number
0153   int m_emulateBxInEvent;
0154 
0155   /// Bx expected in Data coming to GT
0156   int m_L1DataBxInEvent;
0157 
0158   /// alternative for number of BX per active board in GT DAQ record: 0 or 1
0159   /// the position is identical with the active board bit
0160   unsigned int m_alternativeNrBxBoardDaq;
0161 
0162   /// length of BST record (in bytes) from parameter set
0163   int m_psBstLengthBytes;
0164 
0165   /// prescale set used
0166   unsigned int m_prescaleSet;
0167 
0168   /// run algorithm triggers
0169   ///     if true, unprescaled (all prescale factors 1)
0170   ///     will overwrite the event setup
0171   bool m_algorithmTriggersUnprescaled;
0172 
0173   ///     if true, unmasked - all enabled (all trigger masks set to 0)
0174   ///     will overwrite the event setup
0175   bool m_algorithmTriggersUnmasked;
0176 
0177   /// verbosity level
0178   int m_verbosity;
0179   bool m_printL1Menu;
0180   bool m_isDebugEnabled;
0181 
0182   bool m_getPrescaleColumnFromData;
0183   bool m_requireMenuToMatchAlgoBlkInput;
0184   edm::InputTag m_algoblkInputTag;
0185   edm::EDGetToken m_algoblkInputToken;
0186 
0187   edm::ESGetToken<L1TGlobalParameters, L1TGlobalParametersRcd> m_l1GtStableParToken;
0188   edm::ESGetToken<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd> m_l1GtMenuToken;
0189   edm::ESGetToken<L1TGlobalPrescalesVetosFract, L1TGlobalPrescalesVetosFractRcd> m_l1GtPrescaleVetosToken;
0190 
0191   // disables resetting the prescale counters each lumisection (needed for offline)
0192   bool m_resetPSCountersEachLumiSec;
0193 
0194   // initialise prescale counters with a semi-random value in the range [0, prescale*10^precision - 1];
0195   // if false, the prescale counters are initialised to zero
0196   bool m_semiRandomInitialPSCounters;
0197 
0198   //string to store AXOL1TL model version
0199   std::string m_AXOL1TLModelVersion;
0200 
0201   // switch to load muon showers in the global board
0202   bool m_useMuonShowers;
0203 };
0204 
0205 #endif  // L1TGlobalProducer_h