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::beginRun"<<std::endl;
56 
57  if (tevt_==0) this->setup(); // set up histograms if they have not been created before
58  if (mergeRuns_==false)
59  this->reset();
60 
61  return;
62 } //void HcalLSbyLSMonitor::beginRun(...)
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  if (!dbe_) return;
85  bool enoughEvents=true;
86  int Nevents=0;
87  int TotalEvents=0;
88  int badHB=0;
89  int badHE=0;
90  int badHO=0;
91  int badHF=0;
92  int badHO0=0;
93  int badHO12=0;
94  int badHFLUMI=0;
95 
96  for (unsigned int i=0;i<TaskList_.size();++i)
97  {
98  std::string name=prefixME_+TaskList_[i]+"LSvalues/";
99  dbe_->setCurrentFolder(name.c_str());
100  // Do we need the 'name' prefix here?
101  MonitorElement *me=dbe_->get(name+"ProblemsThisLS");
102  if (me==0)
103  {
104  if (debug_>0) std::cout <<"<HcalLSbyLSMonitor> Error! Could not get histogram "<<name.c_str()<<std::endl;
105  enoughEvents=false;
106  break;
107  }
108 
109  Nevents=(int)me->getBinContent(-1);
110  if (Nevents<minEvents_)
111  {
112  if (debug_>0)
113  std::cout <<"<HcalLSbyLSMonitor> Error! Number of events "<<Nevents<<" for histogram "<<name.c_str()<<" is less than the required minimum of "<<minEvents_<<std::endl;
114  enoughEvents=false;
115  break;
116  }
117  // Total events is the number of events processed in this LS
118  TotalEvents=std::max(TotalEvents,Nevents);
119  // errors are sum over all tests. This WILL lead to double counting in some subdetectors!
120  badHB+=(int)me->getBinContent(1,1);
121  badHE+=(int)me->getBinContent(2,1);
122  badHO+=(int)me->getBinContent(3,1);
123  badHF+=(int)me->getBinContent(4,1);
124  badHO0+=(int)me->getBinContent(5,1);
125  badHO12+=(int)me->getBinContent(6,1);
126  badHFLUMI+=(int)me->getBinContent(7,1);
127  }
128  if (enoughEvents==false) // not enough events to make a decision
129  {
130  return;
131  }
132  ProblemsCurrentLB->setBinContent(-1,-1,TotalEvents);
133  ProblemsCurrentLB->setBinContent(1,1,badHB);
134  ProblemsCurrentLB->setBinContent(2,1,badHE);
135  ProblemsCurrentLB->setBinContent(3,1,badHO);
136  ProblemsCurrentLB->setBinContent(4,1,badHF);
137  ProblemsCurrentLB->setBinContent(5,1,badHO0);
138  ProblemsCurrentLB->setBinContent(6,1,badHO12);
139  ProblemsCurrentLB->setBinContent(7,1,badHFLUMI);
140  return;
141 }
142 
143 
145 {
146  // moved database dumps to client; we want to be able to sum over results in offline
147  return;
148 
149 } // void HcalLSbyLSMonitor::done()
150 
151 
153 {
154  if (debug_>0) std::cout <<"HcalLSbyLSMonitor::endJob()"<<std::endl;
155  if (enableCleanup_) cleanup(); // when do we force cleanup?
156 }
157 
158 
160 {
161  if (!enableCleanup_) return;
162  if (dbe_)
163  {
165  dbe_->removeContents();
166  dbe_->setCurrentFolder(subdir_+"LSvalues");
167  dbe_->removeContents();
168  }
169 }
170 
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
bool LumiInOrder(int lumisec)
void setBinContent(int binx, double content)
set content of bin (1-D)
HcalLSbyLSMonitor(const edm::ParameterSet &ps)
MonitorElement * ProblemsCurrentLB
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< std::string > TaskList_
std::vector< int > AllowedCalibTypes_
LuminosityBlockNumber_t luminosityBlock() const
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:3085
const T & max(const T &a, const T &b)
void beginRun(const edm::Run &run, const edm::EventSetup &c)
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1696
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
virtual void reset(void)
double getBinContent(int binx) const
get content of bin (1-D)
tuple cout
Definition: gather_cfg.py:121
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
virtual void setup(void)
void Reset(void)
reset ME (ie. contents, errors, etc)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41