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 
18 
20 // initialize static member variables
22 
23 const unsigned int HLTPrescaler::prescaleSeed_ = 65537;
24 
26 // construction/destruction
28 
29 //_____________________________________________________________________________
31  : prescaleSet_(0),
32  prescaleFactor_(1),
33  eventCount_(0),
34  acceptCount_(0),
35  offsetCount_(0),
36  offsetPhase_(iConfig.getParameter<unsigned int>("offset")),
37  prescaleService_(nullptr),
38  newLumi_(true),
39  gtDigiTag_(iConfig.getParameter<edm::InputTag>("L1GtReadoutRecordTag")),
40  gtDigi1Token_(consumes<L1GlobalTriggerReadoutRecord>(gtDigiTag_)),
41  gtDigi2Token_(consumes<GlobalAlgBlkBxCollection>(gtDigiTag_)) {
44  else
45  LogDebug("NoPrescaleService") << "PrescaleService unavailable, prescaleFactor=1!";
46 }
47 
48 //_____________________________________________________________________________
49 HLTPrescaler::~HLTPrescaler() = default;
50 
52 // implementation of member functions
54 
57  desc.add<unsigned int>("offset", 0);
58  desc.add<edm::InputTag>("L1GtReadoutRecordTag", edm::InputTag("hltGtStage2Digis"));
59  descriptions.add("hltPrescaler", desc);
60 }
61 
62 //______________________________________________________________________________
64  newLumi_ = true;
65 }
66 
67 //_____________________________________________________________________________
69  // during the first event of a LumiSection, read from the GT the prescale index for this
70  // LumiSection and get the corresponding prescale factor from the PrescaleService
71  if (newLumi_) {
72  newLumi_ = false;
73 
74  bool needsInit(eventCount_ == 0);
75 
76  if (prescaleService_) {
78  const unsigned int oldSet(prescaleSet_);
79  const unsigned int oldPrescale(prescaleFactor_);
80 
82  iEvent.getByToken(gtDigi2Token_, handle2);
83  if (handle2.isValid()) {
84  if (handle2->begin(0) != handle2->end(0)) {
85  prescaleSet_ = static_cast<unsigned int>(handle2->begin(0)->getPreScColumn());
87  } else {
88  edm::LogWarning("HLT")
89  << "Cannot read prescale column index from GT2 data: using default as defined by configuration or DAQ";
91  }
92  } else {
94  iEvent.getByToken(gtDigi1Token_, handle1);
95  if (handle1.isValid()) {
97  // gtPrescaleFactorIndexTech() is also available
98  // by construction, they should always return the same index
100  } else {
101  edm::LogWarning("HLT")
102  << "Cannot read prescale column index from GT1 data: using default as defined by configuration or DAQ";
104  }
105  }
106 
107  if (prescaleSet_ != oldSet) {
108  edm::LogInfo("ChangedPrescale") << "lumiBlockNb = " << iEvent.getLuminosityBlock().id().luminosityBlock()
109  << ", set = " << prescaleSet_ << " [" << oldSet << "]"
110  << ", path = " << pathName << ": " << prescaleFactor_ << " [" << oldPrescale
111  << "]";
112  // reset the prescale counter
113  needsInit = true;
114  }
115  }
116 
117  if (needsInit && (prescaleFactor_ != 0)) {
118  // initialize the prescale counter to the first event number multiplied by a big "seed"
120  }
121  }
122 
123  const bool result((prescaleFactor_ == 0) ? false : ((eventCount_ + offsetCount_) % prescaleFactor_ == 0));
124 
125  ++eventCount_;
126  if (result)
127  ++acceptCount_;
128  return result;
129 }
130 
131 //_____________________________________________________________________________
133  //since these are std::atomic, it is safe to increment them
134  // even if multiple endStreams are being called.
135  globalCache()->eventCount_ += eventCount_;
136  globalCache()->acceptCount_ += acceptCount_;
137  return;
138 }
139 
140 //_____________________________________________________________________________
142  unsigned int accept(efficiency->acceptCount_);
143  unsigned int event(efficiency->eventCount_);
144  edm::LogInfo("PrescaleSummary") << accept << "/" << event << " ("
145  << 100. * accept / static_cast<double>(std::max(1u, event))
146  << "% of events accepted).";
147  return;
148 }
149 
#define LogDebug(id)
LuminosityBlockID id() const
std::string const & pathName() const
Definition: PathContext.h:30
const_iterator end(int bx) const
EventNumber_t event() const
Definition: EventID.h:40
std::atomic< unsigned int > acceptCount_
Definition: HLTPrescaler.h:36
example_stream int eventCount_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
#define nullptr
edm::service::PrescaleService * prescaleService_
prescale service
Definition: HLTPrescaler.h:83
bool filter(edm::Event &iEvent, edm::EventSetup const &iSetup) override
Definition: HLTPrescaler.cc:68
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTPrescaler.cc:55
void beginLuminosityBlock(edm::LuminosityBlock const &lb, edm::EventSetup const &iSetup) override
Definition: HLTPrescaler.cc:63
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:94
HLTPrescaler(edm::ParameterSet const &iConfig, const trigger::Efficiency *efficiency)
Definition: HLTPrescaler.cc:30
unsigned int acceptCount_
accept counter
Definition: HLTPrescaler.h:76
int iEvent
Definition: GenABIO.cc:224
ModuleCallingContext const * moduleCallingContext() const
Definition: Event.h:247
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PathContext const * pathContext() const
unsigned int eventCount_
event counter
Definition: HLTPrescaler.h:73
bool newLumi_
check for (re)initialization of the prescale
Definition: HLTPrescaler.h:86
unsigned int prescaleSet_
l1 prescale set index
Definition: HLTPrescaler.h:67
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:98
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:70
~HLTPrescaler() override
edm::EDGetTokenT< GlobalAlgBlkBxCollection > gtDigi2Token_
Definition: HLTPrescaler.h:91
const cms_uint16_t gtPrescaleFactorIndexAlgo() const
Definition: L1GtFdlWord.h:195
unsigned long long uint64_t
Definition: Time.h:13
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:80
edm::EventID id() const
Definition: EventBase.h:59
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtDigi1Token_
Definition: HLTPrescaler.h:90
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:79
unsigned int prescaleFactor_
accept one in prescaleFactor_; 0 means never to accept an event
Definition: HLTPrescaler.h:70
void endStream() override
std::atomic< unsigned int > eventCount_
Definition: HLTPrescaler.h:35