CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TRPCTFClient.cc
Go to the documentation of this file.
2 
11 #include "TRandom.h"
12 
13 #include <TF1.h>
14 #include <stdio.h>
15 #include <sstream>
16 #include <math.h>
17 #include <TProfile.h>
18 #include <TProfile2D.h>
19 
20 using namespace edm;
21 using namespace std;
22 
24 {
25  parameters_=ps;
26  initialize();
27 }
28 
30  LogInfo("TriggerDQM")<<"[TriggerDQM]: ending... ";
31 }
32 
33 //--------------------------------------------------------
35 
36  counterLS_=0;
37  counterEvt_=0;
38 
39  // get back-end interface
41 
42  // base folder for the contents of this job
43  monitorName_ = parameters_.getUntrackedParameter<string>("monitorName","");
44 // cout << "Monitor name = " << monitorName_ << endl;
45  prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
46 // cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
47  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
48 // cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
49  output_dir_ = parameters_.getUntrackedParameter<string>("output_dir","");
50 // cout << "DQM output dir = " << output_dir_ << endl;
51  input_dir_ = parameters_.getUntrackedParameter<string>("input_dir","");
52 // cout << "DQM input dir = " << input_dir_ << endl;
53 
54  verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
55 
56  m_runInEventLoop = parameters_.getUntrackedParameter<bool>("runInEventLoop", false);
57  m_runInEndLumi = parameters_.getUntrackedParameter<bool>("runInEndLumi", false);
58  m_runInEndRun = parameters_.getUntrackedParameter<bool>("runInEndRun", false);
59  m_runInEndJob = parameters_.getUntrackedParameter<bool>("runInEndJob", false);
60 
61 
62  LogInfo( "TriggerDQM");
63 
64 
65 }
66 
67 //--------------------------------------------------------
69 
70  LogInfo("TriggerDQM")<<"[TriggerDQM]: Begin Job";
71 
72  // get backendinterface
74 
75  dbe_->setCurrentFolder(output_dir_);
76 
77  m_deadChannels = dbe_->book2D("RPCTF_deadchannels",
78  "RPCTF deadchannels",
79  33, -16.5, 16.5,
80  144, -0.5, 143.5);
81  m_noisyChannels = dbe_->book2D("RPCTF_noisychannels",
82  "RPCTF noisy channels",
83  33, -16.5, 16.5,
84  144, -0.5, 143.5);
85 }
86 //--------------------------------------------------------
87 void L1TRPCTFClient::beginRun(const Run& r, const EventSetup& context) {
88 }
89 
90 //--------------------------------------------------------
91 void L1TRPCTFClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
92  // optionally reset histograms here
93  // clientHisto->Reset();
94 }
95 //--------------------------------------------------------
96 
98  const edm::EventSetup& c)
99 {
100  if (verbose_) std::cout << "L1TRPCTFClient::endLuminosityBlock" << std::endl;
101 
102  if (m_runInEndLumi) {
103 
104  processHistograms();
105  }
106 
107 }
108 
109 //--------------------------------------------------------
110 void L1TRPCTFClient::analyze(const Event& e, const EventSetup& context) {
111  // cout << "L1TRPCTFClient::analyze" << endl;
112  counterEvt_++;
113  if (prescaleEvt_ < 1)
114  return;
115  if (prescaleEvt_ > 0 && counterEvt_ % prescaleEvt_ != 0)
116  return;
117 
118  // there is no loop on events in the offline harvesting step
119  // code here will not be executed offline
120 
121  if (m_runInEventLoop) {
122 
123  processHistograms();
124  }
125 
126 }
127 
128 //--------------------------------------------------------
129 void L1TRPCTFClient::endRun(const Run& r, const EventSetup& context){
130 
131  if (m_runInEndRun) {
132 
133  processHistograms();
134  }
135 
136 }
137 
138 //--------------------------------------------------------
140 
141  if (m_runInEndJob) {
142 
143  processHistograms();
144  }
145 
146 }
147 
148 
149 //--------------------------------------------------------
151 
152  dbe_->setCurrentFolder(input_dir_);
153 
154  {
155 
156  MonitorElement *me
157  = dbe_->get( (input_dir_+"/RPCTF_muons_eta_phi_bx0").c_str() );
158 
159  if (me){
160  const QReport *qreport;
161 
162  qreport = me->getQReport("DeadChannels_RPCTF_2D");
163  if (qreport) {
164  vector<dqm::me_util::Channel> badChannels = qreport->getBadChannels();
165  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
166  channel != badChannels.end();
167  ++channel)
168  {
169  m_deadChannels->setBinContent((*channel).getBinX(),
170  (*channel).getBinY(),
171  100);
172  } // for(badchannels)
173  } //if (qreport)
174 
175  qreport = me->getQReport("HotChannels_RPCTF_2D");
176  if (qreport) {
177  vector<dqm::me_util::Channel> badChannels = qreport->getBadChannels();
178  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
179  channel != badChannels.end();
180  ++channel)
181  {
182  // (*channel).getBinY() == 0 for NoisyChannels QTEST
183  m_noisyChannels->setBinContent((*channel).getBinX(), 100);
184  } // for(badchannels)
185  } //if (qreport)
186  // else std::cout << "dupa" << std::endl;
187  } // if (me)
188 
189 
190  }
191 
192 
193  if (verbose_)
194  {
195  std::vector<string> meVec = dbe_->getMEs();
196  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
197 
198  std::string full_path = input_dir_ + "/" + (*it);
199  MonitorElement * me =dbe_->get(full_path);
200 
201  // for this MEs, get list of associated QTs
202  std::vector<QReport *> Qtest_map = me->getQReports();
203 
204  if (Qtest_map.size() > 0) {
205  std::cout << "Test: " << full_path << std::endl;
206  for (std::vector<QReport *>::const_iterator it = Qtest_map.begin();
207  it != Qtest_map.end();
208  ++it)
209  {
210  std::cout
211  << " Name "<< (*it)->getQRName()
212  << " Status " << (*it)->getStatus()
213  <<std::endl;
214 
215  std::vector<dqm::me_util::Channel> badChannels=(*it)->getBadChannels();
216 
217  vector<dqm::me_util::Channel>::iterator badchsit = badChannels.begin();
218  while(badchsit != badChannels.end())
219  {
220  int ix = (*badchsit).getBinX();
221  int iy = (*badchsit).getBinY();
222  std::cout << "(" << ix <<","<< iy << ") ";
223  ++badchsit;
224  }
225  std::cout << std::endl;
226 
227  }
228  }
229 
230  } //
231  }
232 
233 
234 }
235 
236 
static AlgebraicMatrix initialize()
const QReport * getQReport(const std::string &qtname) const
get QReport corresponding to &lt;qtname&gt; (null pointer if QReport does not exist)
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
void endJob()
Endjob.
L1TRPCTFClient(const edm::ParameterSet &ps)
Constructor.
void processHistograms()
virtual ~L1TRPCTFClient()
Destructor.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1693
void beginJob(void)
BeginJob.
const std::vector< DQMChannel > & getBadChannels(void) const
Definition: QReport.h:33
DQMStore * dbe_
void analyze(const edm::Event &e, const edm::EventSetup &c)
Fake Analyze.
std::vector< QReport * > getQReports(void) const
get map of QReports
std::vector< std::string > getMEs(void) const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1667
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
DQM Client Diagnostic.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
tuple cout
Definition: gather_cfg.py:121
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1070
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41