Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-16 02:43:00

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