CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalLSbyLSMonitor.cc
Go to the documentation of this file.
3 
4 /*
5  This task looks at the output from all other tasks (as stored in their
6  ProblemsCurrentLB histograms), and combines the output into its own ProblemsCurrentLB histogram. Its own ProblemsCurrentLB histogram, though, is marked with the setLumiFlag, so that its contents will be stored for every lumi section.
7 */
8 
9 // constructor
11 {
12  Online_ = ps.getUntrackedParameter<bool>("online",false);
13  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
14  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
15  debug_ = ps.getUntrackedParameter<int>("debug",0);
16  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
17  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
18  prefixME_.append("/");
19  subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","LSbyLSMonitor_Hcal");
20  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
21  subdir_.append("/");
22  subdir_=prefixME_+subdir_;
23  AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
24  skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",true);
25  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
26  makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
27 
28  // Specify the directories where the tasks to be check reside
29  TaskList_ = ps.getUntrackedParameter<std::vector<std::string> >("TaskDirectories");
30  // Minimum number of events per lumi section that must be present for checks to be made. *ALL* tasks must contain at least this many events
31  minEvents_ = ps.getUntrackedParameter<int>("minEvents",500);
32 }
33 
35 {
36 } //destructor
37 
39 {
40  // Call base class setup
42 
43  if (debug_>1)
44  std::cout <<"<HcalLSbyLSMonitor::setup> Setting up histograms"<<std::endl;
45 
47  // This will cause this information to be kept for every lumi block
50  this->reset();
51 }
53 {
54  if (debug_>1) std::cout <<"HcalLSbyLSMonitor::bookHistograms"<<std::endl;
56 
57  if (tevt_==0) this->setup(ib); // set up histograms if they have not been created before
58  if (mergeRuns_==false)
59  this->reset();
60 
61  return;
62 } //void HcalLSbyLSMonitor::bookHistograms(...)
63 
64 
66 {
69 } // reset function is empty for now
70 
72  const edm::EventSetup& c)
73 {
74  if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
77  return;
78 } // beginLuminosityBlock(...)
79 
81  const edm::EventSetup& c)
82 {
83  /*// Processing should go here
84  bool enoughEvents=true;
85  int Nevents=0;
86  int TotalEvents=0;
87  int badHB=0;
88  int badHE=0;
89  int badHO=0;
90  int badHF=0;
91  int badHO0=0;
92  int badHO12=0;
93  int badHFLUMI=0;
94 
95  for (unsigned int i=0;i<TaskList_.size();++i)
96  {
97  std::string name=prefixME_+TaskList_[i]+"LSvalues/";
98  dbe_->setCurrentFolder(name.c_str());
99  // Do we need the 'name' prefix here?
100  MonitorElement *me=dbe_->get(name+"ProblemsThisLS");
101  if (me==0)
102  {
103  if (debug_>0) std::cout <<"<HcalLSbyLSMonitor> Error! Could not get histogram "<<name.c_str()<<std::endl;
104  enoughEvents=false;
105  break;
106  }
107 
108  Nevents=(int)me->getBinContent(-1);
109  if (Nevents<minEvents_)
110  {
111  if (debug_>0)
112  std::cout <<"<HcalLSbyLSMonitor> Error! Number of events "<<Nevents<<" for histogram "<<name.c_str()<<" is less than the required minimum of "<<minEvents_<<std::endl;
113  enoughEvents=false;
114  break;
115  }
116  // Total events is the number of events processed in this LS
117  TotalEvents=std::max(TotalEvents,Nevents);
118  // errors are sum over all tests. This WILL lead to double counting in some subdetectors!
119  badHB+=(int)me->getBinContent(1,1);
120  badHE+=(int)me->getBinContent(2,1);
121  badHO+=(int)me->getBinContent(3,1);
122  badHF+=(int)me->getBinContent(4,1);
123  badHO0+=(int)me->getBinContent(5,1);
124  badHO12+=(int)me->getBinContent(6,1);
125  badHFLUMI+=(int)me->getBinContent(7,1);
126  }
127  if (enoughEvents==false) // not enough events to make a decision
128  {
129  return;
130  }
131  ProblemsCurrentLB->setBinContent(-1,-1,TotalEvents);
132  ProblemsCurrentLB->setBinContent(1,1,badHB);
133  ProblemsCurrentLB->setBinContent(2,1,badHE);
134  ProblemsCurrentLB->setBinContent(3,1,badHO);
135  ProblemsCurrentLB->setBinContent(4,1,badHF);
136  ProblemsCurrentLB->setBinContent(5,1,badHO0);
137  ProblemsCurrentLB->setBinContent(6,1,badHO12);
138  ProblemsCurrentLB->setBinContent(7,1,badHFLUMI); */
139  return;
140 }
141 
142 
144 {
145  // moved database dumps to client; we want to be able to sum over results in offline
146  return;
147 
148 } // void HcalLSbyLSMonitor::done()
149 
150 
152 {
153  if (debug_>0) std::cout <<"HcalLSbyLSMonitor::endJob()"<<std::endl;
154  if (enableCleanup_) cleanup(); // when do we force cleanup?
155 }
156 
157 
158 /*void HcalLSbyLSMonitor::cleanup()
159 {
160  if (!enableCleanup_) return;
161  if (dbe_)
162  {
163  dbe_->setCurrentFolder(subdir_);
164  dbe_->removeContents();
165  dbe_->setCurrentFolder(subdir_+"LSvalues");
166  dbe_->removeContents();
167  }
168 }*/
169 
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
T getUntrackedParameter(std::string const &, T const &) const
bool LumiInOrder(int lumisec)
HcalLSbyLSMonitor(const edm::ParameterSet &ps)
MonitorElement * ProblemsCurrentLB
int ib
Definition: cuy.py:660
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< std::string > TaskList_
std::vector< int > AllowedCalibTypes_
virtual void cleanup(void)
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
LuminosityBlockNumber_t luminosityBlock() const
void bookHistograms(DQMStore::IBooker &ib, const edm::Run &run, const edm::EventSetup &c)
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
virtual void reset(void)
void setup(DQMStore::IBooker &)
tuple cout
Definition: gather_cfg.py:121
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
void Reset(void)
reset ME (ie. contents, errors, etc)
virtual void setup(DQMStore::IBooker &)
Definition: Run.h:43