CMS 3D CMS Logo

HLTPrescaler.cc
Go to the documentation of this file.
1 //
3 // HLTPrescaler
4 // ------------
5 //
6 // 04/25/2008 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
8 
9 
19 
21 // initialize static member variables
23 
24 const unsigned int HLTPrescaler::prescaleSeed_ = 65537;
25 
27 // construction/destruction
29 
30 //_____________________________________________________________________________
32  prescaleSet_(0)
33  , prescaleFactor_(1)
34  , eventCount_(0)
35  , acceptCount_(0)
36  , offsetCount_(0)
37  , offsetPhase_(iConfig.getParameter<unsigned int>("offset"))
38  , prescaleService_(nullptr)
39  , newLumi_(true)
40  , gtDigiTag_ (iConfig.getParameter<edm::InputTag>("L1GtReadoutRecordTag"))
41  , gtDigi1Token_ (consumes<L1GlobalTriggerReadoutRecord>(gtDigiTag_))
42  , gtDigi2Token_ (consumes<GlobalAlgBlkBxCollection>(gtDigiTag_))
43 {
46  else
47  LogDebug("NoPrescaleService")<<"PrescaleService unavailable, prescaleFactor=1!";
48 }
49 
50 //_____________________________________________________________________________
51 HLTPrescaler::~HLTPrescaler() = default;
52 
54 // implementation of member functions
56 
59  desc.add<unsigned int>("offset",0);
60  desc.add<edm::InputTag>("L1GtReadoutRecordTag",edm::InputTag("hltGtStage2Digis"));
61  descriptions.add("hltPrescaler", desc);
62 }
63 
64 //______________________________________________________________________________
66  edm::EventSetup const& iSetup)
67 {
68  newLumi_ = true;
69 }
70 
71 
72 //_____________________________________________________________________________
74 {
75  // during the first event of a LumiSection, read from the GT the prescale index for this
76  // LumiSection and get the corresponding prescale factor from the PrescaleService
77  if (newLumi_) {
78  newLumi_ = false;
79 
80  bool needsInit (eventCount_==0);
81 
82  if (prescaleService_) {
83  std::string const & pathName = iEvent.moduleCallingContext()->placeInPathContext()->pathContext()->pathName();
84  const unsigned int oldSet(prescaleSet_);
85  const unsigned int oldPrescale(prescaleFactor_);
86 
88  iEvent.getByToken(gtDigi2Token_,handle2);
89  if (handle2.isValid()) {
90  if (handle2->begin(0)!=handle2->end(0)) {
91  prescaleSet_ = static_cast<unsigned int>(handle2->begin(0)->getPreScColumn());
93  } else {
94  edm::LogWarning("HLT") << "Cannot read prescale column index from GT2 data: using default as defined by configuration or DAQ";
96  }
97  } else {
99  iEvent.getByToken(gtDigi1Token_,handle1);
100  if (handle1.isValid()) {
102  // gtPrescaleFactorIndexTech() is also available
103  // by construction, they should always return the same index
105  } else {
106  edm::LogWarning("HLT") << "Cannot read prescale column index from GT1 data: using default as defined by configuration or DAQ";
108  }
109  }
110 
111  if (prescaleSet_ != oldSet) {
112  edm::LogInfo("ChangedPrescale")
113  << "lumiBlockNb = " << iEvent.getLuminosityBlock().id().luminosityBlock()
114  << ", set = " << prescaleSet_ << " [" << oldSet <<"]"
115  << ", path = "<< pathName
116  << ": " << prescaleFactor_ << " [" <<oldPrescale<<"]";
117  // reset the prescale counter
118  needsInit = true;
119  }
120  }
121 
122  if (needsInit && (prescaleFactor_ != 0)) {
123  // initialize the prescale counter to the first event number multiplied by a big "seed"
125  }
126  }
127 
128  const bool result ( (prescaleFactor_ == 0) ?
129  false : ((eventCount_ + offsetCount_) % prescaleFactor_ == 0) );
130 
131  ++eventCount_;
132  if (result) ++acceptCount_;
133  return result;
134 }
135 
136 
137 //_____________________________________________________________________________
139 {
140  //since these are std::atomic, it is safe to increment them
141  // even if multiple endStreams are being called.
142  globalCache()->eventCount_ += eventCount_;
143  globalCache()->acceptCount_ += acceptCount_;
144  return;
145 }
146 
147 //_____________________________________________________________________________
149 {
150  unsigned int accept(efficiency->acceptCount_);
151  unsigned int event (efficiency->eventCount_);
152  edm::LogInfo("PrescaleSummary")
153  << accept << "/" << event
154  << " ("
155  << 100.*accept/static_cast<double>(std::max(1u,event))
156  << "% of events accepted).";
157  return;
158 }
159 
#define LogDebug(id)
LuminosityBlockID id() const
std::string const & pathName() const
Definition: PathContext.h:37
const_iterator end(int bx) const
EventNumber_t event() const
Definition: EventID.h:41
virtual ~HLTPrescaler()
std::atomic< unsigned int > acceptCount_
Definition: HLTPrescaler.h:36
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::service::PrescaleService * prescaleService_
prescale service
Definition: HLTPrescaler.h:88
virtual bool filter(edm::Event &iEvent, edm::EventSetup const &iSetup) override
Definition: HLTPrescaler.cc:73
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTPrescaler.cc:57
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lb, edm::EventSetup const &iSetup) override
Definition: HLTPrescaler.cc:65
#define nullptr
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
static const unsigned int prescaleSeed_
"seed" used to initialize the prescale counter
Definition: HLTPrescaler.h:100
HLTPrescaler(edm::ParameterSet const &iConfig, const trigger::Efficiency *efficiency)
Definition: HLTPrescaler.cc:31
unsigned int acceptCount_
accept counter
Definition: HLTPrescaler.h:81
int iEvent
Definition: GenABIO.cc:230
ModuleCallingContext const * moduleCallingContext() const
Definition: Event.h:228
PathContext const * pathContext() const
unsigned int eventCount_
event counter
Definition: HLTPrescaler.h:78
bool newLumi_
check for (re)initialization of the prescale
Definition: HLTPrescaler.h:91
unsigned int prescaleSet_
l1 prescale set index
Definition: HLTPrescaler.h:72
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:86
ParameterDescriptionBase * add(U const &iLabel, T const &value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:74
edm::EDGetTokenT< GlobalAlgBlkBxCollection > gtDigi2Token_
Definition: HLTPrescaler.h:96
const cms_uint16_t gtPrescaleFactorIndexAlgo() const
Definition: L1GtFdlWord.h:267
unsigned long long uint64_t
Definition: Time.h:15
const L1GtFdlWord gtFdlWord(int bxInEventValue) const
get / set FDL word (record) in the GT readout record
unsigned int getPrescale(std::string const &prescaledPath) const
LuminosityBlockNumber_t luminosityBlock() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
unsigned int offsetPhase_
Definition: HLTPrescaler.h:85
edm::EventID id() const
Definition: EventBase.h:60
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtDigi1Token_
Definition: HLTPrescaler.h:95
HLT enums.
static void globalEndJob(const trigger::Efficiency *efficiency)
const_iterator begin(int bx) const
PlaceInPathContext const * placeInPathContext() const
unsigned int offsetCount_
initial offset
Definition: HLTPrescaler.h:84
unsigned int prescaleFactor_
accept one in prescaleFactor_; 0 means never to accept an event
Definition: HLTPrescaler.h:75
virtual void endStream() override
std::atomic< unsigned int > eventCount_
Definition: HLTPrescaler.h:35