CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
17 
19 // initialize static member variables
21 
22 const unsigned int HLTPrescaler::prescaleSeed_ = 65537;
23 
25 // construction/destruction
27 
28 //_____________________________________________________________________________
30  prescaleSet_(0)
31  , prescaleFactor_(1)
32  , eventCount_(0)
33  , acceptCount_(0)
34  , offsetCount_(0)
35  , offsetPhase_(iConfig.existsAs<unsigned int>("offset") ? iConfig.getParameter<unsigned int>("offset") : 0)
36  , prescaleService_(0)
37  , newLumi_(true)
38  , gtDigi_ (iConfig.getParameter<edm::InputTag>("L1GtReadoutRecordTag"))
39 {
42  else
43  LogDebug("NoPrescaleService")<<"PrescaleService unavailable, prescaleFactor=1!";
44 }
45 
46 //_____________________________________________________________________________
48 {
49 
50 }
51 
52 
54 // implementation of member functions
56 
57 //______________________________________________________________________________
59  edm::EventSetup const& iSetup)
60 {
61  newLumi_ = true;
62 
63  return true;
64 }
65 
66 
67 //_____________________________________________________________________________
69 {
70  // during the first event of a LumiSection, read from the GT the prescale index for this
71  // LumiSection and get the corresponding prescale factor from the PrescaleService
72  if (newLumi_) {
73  newLumi_ = false;
74 
75  bool needsInit (eventCount_==0);
76 
77  if (prescaleService_) {
78  std::string const & pathName = * currentContext()->pathName();
79  const unsigned int oldSet(prescaleSet_);
80  const unsigned int oldPrescale(prescaleFactor_);
81 
83  iEvent.getByLabel(gtDigi_ , handle);
84  if (handle.isValid()) {
85  prescaleSet_ = handle->gtFdlWord().gtPrescaleFactorIndexAlgo();
86  // gtPrescaleFactorIndexTech() is also available
87  // by construction, they should always return the same index
89  } else {
90  edm::LogWarning("HLT") << "Cannot read prescale column index from GT data: using default as defined by configuration or DAQ";
92  }
93 
94  if (prescaleSet_ != oldSet) {
95  edm::LogInfo("ChangedPrescale")
96  << "lumiBlockNb = " << iEvent.getLuminosityBlock().id().luminosityBlock()
97  << ", set = " << prescaleSet_ << " [" << oldSet <<"]"
98  << ", path = "<< pathName
99  << ": " << prescaleFactor_ << " [" <<oldPrescale<<"]";
100  // reset the prescale counter
101  needsInit = true;
102  }
103  }
104 
105  if (needsInit && (prescaleFactor_ != 0)) {
106  // initialize the prescale counter to the first event number multiplied by a big "seed"
108  }
109  }
110 
111  const bool result ( (prescaleFactor_ == 0) ?
112  false : ((eventCount_ + offsetCount_) % prescaleFactor_ == 0) );
113 
114  ++eventCount_;
115  if (result) ++acceptCount_;
116  return result;
117 }
118 
119 
120 //_____________________________________________________________________________
122 {
123  edm::LogInfo("PrescaleSummary")
124  << acceptCount_<< "/" <<eventCount_
125  << " ("
126  << 100.*acceptCount_/static_cast<double>(std::max(1u,eventCount_))
127  << "% of events accepted).";
128  return;
129 }
#define LogDebug(id)
LuminosityBlockID id() const
EventNumber_t event() const
Definition: EventID.h:44
virtual ~HLTPrescaler()
Definition: HLTPrescaler.cc:47
edm::InputTag gtDigi_
GT payload, to extract the prescale column index.
Definition: HLTPrescaler.h:71
edm::service::PrescaleService * prescaleService_
prescale service
Definition: HLTPrescaler.h:65
virtual void endJob()
static const unsigned int prescaleSeed_
&quot;seed&quot; used to initialize the prescale counter
Definition: HLTPrescaler.h:75
unsigned int acceptCount_
accept counter
Definition: HLTPrescaler.h:58
int iEvent
Definition: GenABIO.cc:243
virtual bool beginLuminosityBlock(edm::LuminosityBlock &lb, edm::EventSetup const &iSetup)
Definition: HLTPrescaler.cc:58
const T & max(const T &a, const T &b)
tuple result
Definition: query.py:137
unsigned int eventCount_
event counter
Definition: HLTPrescaler.h:55
bool newLumi_
check for (re)initialization of the prescale
Definition: HLTPrescaler.h:68
tuple handle
Definition: patZpeak.py:22
unsigned int prescaleSet_
l1 prescale set index
Definition: HLTPrescaler.h:49
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:59
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
unsigned long long uint64_t
Definition: Time.h:15
LuminosityBlockNumber_t luminosityBlock() const
unsigned int offsetPhase_
Definition: HLTPrescaler.h:62
edm::EventID id() const
Definition: EventBase.h:56
HLTPrescaler(edm::ParameterSet const &iConfig)
Definition: HLTPrescaler.cc:29
unsigned int offsetCount_
initial offset
Definition: HLTPrescaler.h:61
std::string const * pathName() const
virtual bool filter(edm::Event &iEvent, edm::EventSetup const &iSetup)
Definition: HLTPrescaler.cc:68
CurrentProcessingContext const * currentContext() const
Definition: EDFilter.cc:115
unsigned int prescaleFactor_
accept one in prescaleFactor_; 0 means never to accept an event
Definition: HLTPrescaler.h:52
unsigned int getPrescale(unsigned int lvl1Index, std::string const &prescaledPath)