test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalMonitorPrescaler.cc
Go to the documentation of this file.
2 
6 
9 
10 #include <cmath>
11 #include <iostream>
12 
16  (1 << EcalDCCHeaderBlock::PHYSICS_LOCAL), // kPhysics
19  (1 << EcalDCCHeaderBlock::COSMICS_LOCAL), // kCosmics
28  (1 << EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN), // kCalibration
30  (1 << EcalDCCHeaderBlock::LASER_GAP), // kLaser
32  (1 << EcalDCCHeaderBlock::LED_GAP), // kLed
34  (1 << EcalDCCHeaderBlock::TESTPULSE_GAP), // kTestPulse
38 };
39 
41  EcalRawDataCollection_(consumes<EcalRawDataCollection>(_ps.getParameter<edm::InputTag>("EcalRawDataCollection")))
42 {
43  for(unsigned iP(0); iP != nPrescalers; ++iP) prescalers_[iP].first = 0;
44 
45  prescalers_[kPhysics].second = _ps.getUntrackedParameter<unsigned>("physics", -1);
46  prescalers_[kCosmics].second = _ps.getUntrackedParameter<unsigned>("cosmics", -1);
47  prescalers_[kCalibration].second = _ps.getUntrackedParameter<unsigned>("calibration", -1);
48  prescalers_[kLaser].second = _ps.getUntrackedParameter<unsigned>("laser", -1);
49  prescalers_[kLed].second = _ps.getUntrackedParameter<unsigned>("led", -1);
50  prescalers_[kTestPulse].second = _ps.getUntrackedParameter<unsigned>("testPulse", -1);
51  prescalers_[kPedestal].second = _ps.getUntrackedParameter<unsigned>("pedestal", -1);
52 
53  // Backward compatibility
54  prescalers_[kPhysics].second = std::min(prescalers_[kPhysics].second, (unsigned int)(_ps.getUntrackedParameter<int>("occupancyPrescaleFactor", -1)));
55  prescalers_[kPhysics].second = std::min(prescalers_[kPhysics].second, (unsigned int)(_ps.getUntrackedParameter<int>("integrityPrescaleFactor", -1)));
56  prescalers_[kCosmics].second = std::min(prescalers_[kCosmics].second, (unsigned int)(_ps.getUntrackedParameter<int>("cosmicPrescaleFactor", -1)));
57  prescalers_[kLaser].second = std::min(prescalers_[kLaser].second, (unsigned int)(_ps.getUntrackedParameter<int>("laserPrescaleFactor", -1)));
58  prescalers_[kLed].second = std::min(prescalers_[kLed].second, (unsigned int)(_ps.getUntrackedParameter<int>("ledPrescaleFactor", -1)));
59  prescalers_[kPedestal].second = std::min(prescalers_[kPedestal].second, (unsigned int)(_ps.getUntrackedParameter<int>("pedestalPrescaleFactor", -1)));
60  prescalers_[kPedestal].second = std::min(prescalers_[kPedestal].second, (unsigned int)(_ps.getUntrackedParameter<int>("pedestalonlinePrescaleFactor", -1)));
61  prescalers_[kTestPulse].second = std::min(prescalers_[kTestPulse].second, (unsigned int)(_ps.getUntrackedParameter<int>("testpulsePrescaleFactor", -1)));
62  prescalers_[kPedestal].second = std::min(prescalers_[kPedestal].second, (unsigned int)(_ps.getUntrackedParameter<int>("pedestaloffsetPrescaleFactor", -1)));
63  prescalers_[kPhysics].second = std::min(prescalers_[kPhysics].second, (unsigned int)(_ps.getUntrackedParameter<int>("triggertowerPrescaleFactor", -1)));
64  prescalers_[kPhysics].second = std::min(prescalers_[kPhysics].second, (unsigned int)(_ps.getUntrackedParameter<int>("timingPrescaleFactor", -1)));
65  prescalers_[kPhysics].second = std::min(prescalers_[kPhysics].second, (unsigned int)(_ps.getUntrackedParameter<int>("physicsPrescaleFactor", -1)));
66  prescalers_[kPhysics].second = std::min(prescalers_[kPhysics].second, (unsigned int)(_ps.getUntrackedParameter<int>("clusterPrescaleFactor", -1)));
67 }
68 
70 {
71 }
72 
73 void
75 {
76  for(unsigned iP(0); iP != nPrescalers; ++iP) prescalers_[iP].first = 0;
77 }
78 
79 bool
81 {
83 
84  if(!_event.getByToken(EcalRawDataCollection_, dcchs)){
85  edm::LogWarning("EcalMonitorPrescaler") << "EcalRawDataCollection not available";
86  return false;
87  }
88 
89  uint32_t eventBits(0);
90  for(EcalRawDataCollection::const_iterator dcchItr(dcchs->begin()); dcchItr != dcchs->end(); ++dcchItr)
91  eventBits |= (1 << dcchItr->getRunType());
92 
93  for(unsigned iP(0); iP != nPrescalers; ++iP){
94  if((eventBits & filterBits_[iP]) != 0 && ++prescalers_[iP].first % prescalers_[iP].second == 0)
95  return true;
96  }
97 
98  return false;
99 }
100 
T getUntrackedParameter(std::string const &, T const &) const
void beginRun(edm::Run const &, edm::EventSetup const &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< EcalDCCHeaderBlock >::const_iterator const_iterator
bool filter(edm::Event &, edm::EventSetup const &) override
U second(std::pair< T, U > const &p)
T min(T a, T b)
Definition: MathUtil.h:58
EcalMonitorPrescaler(edm::ParameterSet const &)
edm::EDGetTokenT< EcalRawDataCollection > EcalRawDataCollection_
std::pair< unsigned, unsigned > prescalers_[nPrescalers]
Definition: Run.h:42
static uint32_t filterBits_[nPrescalers]