Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:24

0001 #ifndef HLTPrescaler_H
0002 #define HLTPrescaler_H
0003 
0004 /** \class HLTPrescaler
0005  *
0006  *  
0007  *  This class is an EDFilter implementing an HLT
0008  *  Prescaler module with associated book keeping.
0009  *
0010  *
0011  *  \author Martin Grunewald
0012  *  \author Philipp Schieferdecker
0013  */
0014 
0015 #include <atomic>
0016 #include <memory>
0017 
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/stream/EDFilter.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022 #include "FWCore/PrescaleService/interface/PrescaleService.h"
0023 
0024 // legacy/stage-1 L1T:
0025 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0026 
0027 // stage-2 L1T:
0028 #include "DataFormats/L1TGlobal/interface/GlobalAlgBlk.h"
0029 
0030 namespace edm {
0031   class ConfigurationDescriptions;
0032 }
0033 
0034 namespace trigger {
0035   struct Efficiency {
0036     Efficiency() : eventCount_(0), acceptCount_(0) {}
0037     mutable std::atomic<unsigned int> eventCount_;
0038     mutable std::atomic<unsigned int> acceptCount_;
0039   };
0040 }  // namespace trigger
0041 
0042 class HLTPrescaler : public edm::stream::EDFilter<edm::GlobalCache<trigger::Efficiency> > {
0043 public:
0044   //
0045   // construction/destruction
0046   //
0047   explicit HLTPrescaler(edm::ParameterSet const& iConfig, const trigger::Efficiency* efficiency);
0048   ~HLTPrescaler() override;
0049 
0050   static std::unique_ptr<trigger::Efficiency> initializeGlobalCache(edm::ParameterSet const&) {
0051     return std::make_unique<trigger::Efficiency>();
0052   }
0053 
0054   //
0055   // member functions
0056   //
0057   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0058   void beginLuminosityBlock(edm::LuminosityBlock const& lb, edm::EventSetup const& iSetup) override;
0059   bool filter(edm::Event& iEvent, edm::EventSetup const& iSetup) override;
0060   void endStream() override;
0061   static void globalEndJob(const trigger::Efficiency* efficiency);
0062 
0063 private:
0064   //
0065   //member data
0066   //
0067 
0068   /// l1 prescale set index
0069   unsigned int prescaleSet_;
0070 
0071   /// accept one in prescaleFactor_; 0 means never to accept an event
0072   unsigned int prescaleFactor_;
0073 
0074   /// event counter
0075   unsigned int eventCount_;
0076 
0077   /// accept counter
0078   unsigned int acceptCount_;
0079 
0080   /// initial offset
0081   unsigned int offsetCount_;
0082   unsigned int offsetPhase_;
0083 
0084   /// prescale service
0085   edm::service::PrescaleService* prescaleService_;
0086 
0087   /// check for (re)initialization of the prescale
0088   bool newLumi_;
0089 
0090   /// GT payload, to extract the prescale column index
0091   edm::InputTag gtDigiTag_;
0092   edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> gtDigi1Token_;
0093   edm::EDGetTokenT<GlobalAlgBlkBxCollection> gtDigi2Token_;
0094 
0095   /// "seed" used to initialize the prescale counter
0096   static const unsigned int prescaleSeed_;
0097 };
0098 
0099 #endif