test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalClientUtils.cc
Go to the documentation of this file.
4 #include <cstdlib>
5 
6 
7 void resetME(const char* name, DQMStore* dbe){
8  if(dbe==NULL) return;
9  MonitorElement* me= dbe->get(name);
10  if(me) dbe->softReset(me);
11  return;
12 }
13 
15 {
16  if (type=="HB" && (depth==1 || depth==2))
17  return true;
18  if (type=="HE" && (depth==1 || depth==2 || depth==3))
19  return true;
20  if (type=="HO" && (depth==4))
21  return true;
22  if (type=="HF" && (depth==1 || depth==2))
23  return true;
24  return false;
25 }
26 
27 bool isValidGeom(int subdet, int iEta, int iPhi, int depth){
28 
29  if(subdet<0 || subdet>3) return false;
30 
31  int EtaMin[4]; int EtaMax[4];
32  int PhiMin[4]; int PhiMax[4];
33  int DepMin[4]; int DepMax[4];
34 
35  //HB ieta/iphi/depths
36  EtaMin[0]=1; EtaMax[0]=16;
37  PhiMin[0]=1; PhiMax[0]=72;
38  DepMin[0]=1; DepMax[0]=2;
39 
40  //HE ieta/iPhi/Depths
41  EtaMin[1]=16; EtaMax[1]=29;
42  PhiMin[1]=1; PhiMax[1]=72;
43  DepMin[1]=1; DepMax[1]=3;
44 
45  //HF ieta/iphi/depths
46  EtaMin[2]=29; EtaMax[2]=41;
47  PhiMin[2]=1; PhiMax[2]=72;
48  DepMin[2]=1; DepMax[2]=2;
49 
50  //HO ieta/iphi/depths
51  EtaMin[3]=1; EtaMax[3]=15;
52  PhiMin[3]=1; PhiMax[3]=72;
53  DepMin[3]=4; DepMax[3]=4;
54 
55  if(iEta!=0) if(abs(iEta)<EtaMin[subdet] || abs(iEta)>EtaMax[subdet]) return false;
56  if(iPhi!=0) if(abs(iPhi)<PhiMin[subdet] || abs(iPhi)>PhiMax[subdet]) return false;
57  if(depth!=0) if(abs(depth)<DepMin[subdet] || abs(depth)>DepMax[subdet]) return false;
58 
59 
60  if(subdet==0 && abs(depth)==2 && abs(iEta)<15) return false;
61  else if(subdet==1){
62  if(abs(iEta)>20 && (iPhi%2)==0) return false;
63  if(abs(iEta)>39 && (iPhi%4)!=3) return false;
64  if(abs(iEta)==16 && abs(depth)!=3) return false;
65  if(abs(iEta)==17 && abs(depth)!=1) return false;
66  if(abs(depth)==3){
67  if(abs(iEta)!=27 && abs(iEta)!=28 &&abs(iEta)!=16) return false;
68  }
69  }
70  else if(subdet==2 && (iPhi%2)==0) return false;
71 
72  return true;
73 }
74 
75 void dumpHisto(TH1F* hist, std::vector<std::string> &names,
76  std::vector<double> &meanX, std::vector<double> &meanY,
77  std::vector<double> &rmsX, std::vector<double> &rmsY){
78 
79  names.push_back((std::string)hist->GetName());
80  meanX.push_back(hist->GetMean(1));
81  meanY.push_back(-123e10);
82  rmsX.push_back(hist->GetRMS(1));
83  rmsY.push_back(-123e10);
84  return;
85 }
86 void dumpHisto2(TH2F* hist, std::vector<std::string> &names,
87  std::vector<double> &meanX, std::vector<double> &meanY,
88  std::vector<double> &rmsX, std::vector<double> &rmsY){
89 
90  names.push_back((std::string)hist->GetName());
91  meanX.push_back(hist->GetMean(1));
92  meanY.push_back(hist->GetMean(2));
93  rmsX.push_back(hist->GetRMS(1));
94  rmsY.push_back(hist->GetRMS(2));
95  return;
96 }
97 
99 
100  for ( unsigned int i = 0; i < title.size(); i++ ) {
101  if ( title.substr(i, 6) == " - Run" ){
102  title.replace(i, title.size()-i, "");
103  }
104  if ( title.substr(i, 4) == "_Run" ){
105  title.replace(i, title.size()-i, "");
106  }
107  if ( title.substr(i, 5) == "__Run" ){
108  title.replace(i, title.size()-i, "");
109  }
110  }
111 }
112 
114 
115  for ( unsigned int i = 0; i < title.size(); i++ ) {
116  if ( title.substr(i, 1) == " " ){
117  title.replace(i, 1, "_");
118  }
119  if ( title.substr(i, 1) == "#" ){
120  title.replace(i, 1, "N");
121  }
122  if ( title.substr(i, 1) == "-" ){
123  title.replace(i, 1, "_");
124  }
125  if ( title.substr(i, 1) == "&" ){
126  title.replace(i, 1, "_and_");
127  }
128  if ( title.substr(i, 1) == "("
129  || title.substr(i, 1) == ")"
130  ) {
131  title.replace(i, 1, "_");
132  }
133  }
134 
135  return;
136 }
137 
138 std::string getIMG2(int runNo,TH2F* hist, int size, std::string htmlDir, const char* xlab, const char* ylab,bool color){
139 
140  if(hist==NULL) {
141  printf("getIMG2: This histo is NULL, %s, %s\n",xlab,ylab);
142  return "";
143  }
144 
145  std::string name = hist->GetTitle();
146  cleanString(name);
147  char dest[512];
148  if(runNo>-1) sprintf(dest,"%s - Run %d",name.c_str(),runNo);
149  else sprintf(dest,"%s",name.c_str());
150  hist->SetTitle(dest);
152 
153  int xwid = 900; int ywid =540;
154  if(size==1){
155  title = title+"_tmb";
156  xwid = 600; ywid = 360;
157  }
158  TCanvas* can = new TCanvas(dest,dest, xwid, ywid);
159 
160  // Put grids on all 2-D histograms
161  can->SetGridx();
162  can->SetGridy();
163 
164 
165  parseString(title);
166  std::string outName = title + ".gif";
167  std::string saveName = htmlDir + outName;
168  hist->SetXTitle(xlab);
169  hist->SetYTitle(ylab);
170  if(color) hist->Draw();
171  else{
172  hist->SetStats(false);
173  hist->Draw("COLZ");
174  }
175  can->SaveAs(saveName.c_str());
176  delete can;
177 
178  return outName;
179 }
180 
181 std::string getIMG(int runNo,TH1F* hist, int size, std::string htmlDir, const char* xlab, const char* ylab){
182 
183  if(hist==NULL) {
184  printf("getIMG: This histo is NULL, %s, %s\n",xlab,ylab);
185  return "";
186  }
187 
188  std::string name = hist->GetTitle();
189  cleanString(name);
190  char dest[512];
191  if(runNo>-1) sprintf(dest,"%s - Run %d",name.c_str(),runNo);
192  else sprintf(dest,"%s",name.c_str());
193  hist->SetTitle(dest);
195 
196  int xwid = 900; int ywid =540;
197  if(size==1){
198  title = title+"_tmb";
199  xwid = 600; ywid = 360;
200  }
201  TCanvas* can = new TCanvas(dest,dest, xwid, ywid);
202 
203  parseString(title);
204  std::string outName = title + ".gif";
205  std::string saveName = htmlDir + outName;
206  hist->SetXTitle(xlab);
207  hist->SetYTitle(ylab);
208  hist->Draw();
209 
210  can->SaveAs(saveName.c_str());
211  delete can;
212 
213  return outName;
214 }
215 
217 
218  if(!dbe_) return NULL;
219 
220  TH2F* out = NULL;
221  char title[150];
222  sprintf(title, "%sHcal/%s",process.c_str(),name.c_str());
223 
224  MonitorElement* me = dbe_->get(title);
225 
226  if ( me ) {
227  if ( verb) std::cout << "Found '" << title << "'" << std::endl;
228  if ( clone) {
229  char histo[150];
230  sprintf(histo, "ME %s",name.c_str());
231  out = dynamic_cast<TH2F*> (me->getTH2F()->Clone(histo));
232  } else {
233  out = me->getTH2F();
234  }
235  }
236  return out;
237 }
238 
240  if(!dbe_) return NULL;
241 
242  char title[150];
243  sprintf(title, "%sHcal/%s",process.c_str(),name.c_str());
244  TH1F* out = NULL;
245 
246  const MonitorElement* me = dbe_->get(title);
247  if (me){
248  if ( verb ) std::cout << "Found '" << title << "'" << std::endl;
249  if ( clone ) {
250  char histo[150];
251  sprintf(histo, "ME %s",name.c_str());
252  out = dynamic_cast<TH1F*> (me->getTH1F()->Clone(histo));
253  } else {
254  out = me->getTH1F();
255  }
256  }
257 
258  return out;
259 }
260 
261 
262 TH2F* getHisto2(const MonitorElement* me, bool verb,bool clone){
263 
264  TH2F* out = NULL;
265 
266  if ( me ) {
267  if ( verb) std::cout << "Found '" << me->getName() << "'" << std::endl;
268  // MonitorElementT<TNamed>* ob = dynamic_cast<MonitorElementT<TNamed>*> (me);
269  if ( clone ) {
270  char histo[150];
271  sprintf(histo, "ME %s", ((std::string)(me->getName())).c_str());
272  out = dynamic_cast<TH2F*> (me->getTH2F()->Clone(histo));
273  } else {
274  out = me->getTH2F();
275  }
276  }
277  return out;
278 }
279 
280 TH1F* getHisto(const MonitorElement* me, bool verb,bool clone){
281  TH1F* out = NULL;
282 
283  if ( me ) {
284  if ( verb ) std::cout << "Found '" << me->getName() << "'" << std::endl;
285  if ( clone ) {
286  char histo[150];
287  sprintf(histo, "ME %s",((std::string)(me->getName())).c_str());
288  out = dynamic_cast<TH1F*> (me->getTH1F()->Clone(histo));
289  } else {
290  out = me->getTH1F();
291  }
292  }
293  return out;
294 }
295 
296 
297 void histoHTML(int runNo, TH1F* hist, const char* xlab, const char* ylab, int width, std::ofstream& htmlFile, std::string htmlDir){
298 
299  if(hist!=NULL){
300  std::string imgNameTMB = "";
301  imgNameTMB = getIMG(runNo,hist,1,htmlDir,xlab,ylab);
302  std::string imgName = "";
303  imgName = getIMG(runNo,hist,2,htmlDir,xlab,ylab);
304 
305  if (imgName.size() != 0 )
306  htmlFile << "<td><a href=\"" << imgName << "\"><img src=\"" << imgNameTMB << "\"></a></td>" << std::endl;
307  else
308  htmlFile << "<td><img src=\"" << " " << "\"></td>" << std::endl;
309  }
310  else htmlFile << "<td><img src=\"" << " " << "\"></td>" << std::endl;
311  return;
312 }
313 
314 void histoHTML2(int runNo, TH2F* hist, const char* xlab, const char* ylab, int width, std::ofstream& htmlFile, std::string htmlDir, bool color){
315  if(hist!=NULL){
316  std::string imgNameTMB = "";
317  imgNameTMB = getIMG2(runNo,hist,1,htmlDir,xlab,ylab,color);
318  std::string imgName = "";
319  imgName = getIMG2(runNo,hist,2,htmlDir,xlab,ylab,color);
320  if (imgName.size() != 0 )
321  htmlFile << "<td><a href=\"" << imgName << "\"><img src=\"" << imgNameTMB << "\"></a></td>" << std::endl;
322  else
323  htmlFile << "<td><img src=\"" << " " << "\"></td>" << std::endl;
324  }
325  else htmlFile << "<td><img src=\"" << " " << "\"></td>" << std::endl;
326  return;
327 }
328 
329 void createXRangeTest(DQMStore* dbe, std::vector<std::string>& params){
330  if (params.size() < 6) return;
331  if(!dbe) return;
332 
333  QCriterion* qc = dbe->getQCriterion(params[1]);
334  if(qc == NULL){
335  qc = dbe->createQTest(ContentsXRange::getAlgoName(),params[1]);
336  // Contents within [Xmin, Xmax]
337  ContentsXRange* me_qc = (ContentsXRange*) qc;
338  //set probability limit for test warning
339  me_qc->setWarningProb(atof(params[2].c_str()));
340  //set probability limit for test error
341  me_qc->setErrorProb(atof(params[3].c_str()));
342  // set allowed range in X-axis (default values: histogram's X-range)
343  me_qc->setAllowedXRange(atof(params[4].c_str()), atof(params[5].c_str()));
344  }
345  // link it to the monitor element
346  dbe->useQTest(params[0], params[1]);
347  return;
348 }
349 
350 void createYRangeTest(DQMStore* dbe, std::vector<std::string>& params){
351  if (params.size() < 6) return;
352  if(!dbe) return;
353 
354  QCriterion* qc = dbe->getQCriterion(params[1]);
355  if(qc == NULL){
356  qc = dbe->createQTest(ContentsYRange::getAlgoName(),params[1]);
357  // Contents within [Xmin, Xmax]
358  ContentsYRange* me_qc = (ContentsYRange*) qc;
359  //set probability limit for test warning
360  me_qc->setWarningProb(atof(params[2].c_str()));
361  //set probability limit for test error
362  me_qc->setErrorProb(atof(params[3].c_str()));
363  // set allowed range in Y-axis (default values: histogram's Y-range)
364  me_qc->setAllowedYRange(atof(params[4].c_str()), atof(params[5].c_str()));
365  }
366  // link it to the monitor element
367  dbe->useQTest(params[0], params[1]);
368  return;
369 }
370 
371 void createMeanValueTest(DQMStore* dbe, std::vector<std::string>& params){
372  if (params.size() < 7 ) return;
373  if(!dbe) return;
374 
375  QCriterion* qc = dbe->getQCriterion(params[1]);
376  if(qc == NULL){
377  qc = dbe->createQTest("MeanWithinExpected",params[1]);
378  // Contents within a mean value
379  MeanWithinExpected* me_qc = (MeanWithinExpected*) qc;
380  //set probability limit for test warning
381  me_qc->setWarningProb(atof(params[2].c_str()));
382  //set probability limit for test error
383  me_qc->setErrorProb(atof(params[3].c_str()));
384  // set Expected Mean
385  me_qc->setExpectedMean(atof(params[4].c_str()));
386  // set Test Type
387  if (params[6] == "useRMS") me_qc->useRMS();
388  else if (params[6] == "useSigma") me_qc->useSigma(atof(params[5].c_str()));
389  }
390  // link it to the monitor element
391  dbe->useQTest(params[0], params[1]);
392  return;
393 }
394 
395 void createH2ContentTest(DQMStore* dbe, std::vector<std::string>& params){
396  if (params.size() < 2 ) return;
397  if(!dbe) return;
398 
399  QCriterion* qc = dbe->getQCriterion(params[1]);
400  MonitorElement* me = dbe->get(params[0]);
401  if(me!=NULL && qc == NULL){
402  /* Time to get with
403  DQMServices/Core V03-00-12-qtest
404  DQMServices/ClientConfig V03-00-04-qtest
405  qc = dbe->createQTest(ContentsTH2FWithinRange::getAlgoName(),params[1]);
406  // Contents within a mean value
407  ContentsTH2FWithinRangeROOT* me_qc = dynamic_cast<ContentsTH2FWithinRangeROOT*> (qc);
408  me_qc->setMeanRange(0,1e-10);
409  me_qc->setRMSRange(0,1e-10);
410  // link it to the monitor element
411  dbe->useQTest(params[0], params[1]);
412  */
413  }
414 
415  return;
416 }
417 
418 void createH2CompTest(DQMStore* dbe, std::vector<std::string>& params, TH2F* ref){
419  if (params.size() < 2 ) return;
420  if(ref==NULL) return;
421  if(!dbe) return;
422 
423  QCriterion* qc = dbe->getQCriterion(params[1]);
424  MonitorElement* me = dbe->get(params[0]);
425  if(me!=NULL && qc == NULL){
426  printf("\n\nDon't have this QC, but have the me!\n\n");
427  const QReport* qr = me->getQReport(params[1]);
428  if(qr) return;
429  printf("\n\nThe ME doesn't have the QC!!\n\n");
430  qc = dbe->createQTest("Comp2RefEqualH2",params[1]);
431  /* Time to get with
432  DQMServices/Core V03-00-12-qtest
433  DQMServices/ClientConfig V03-00-04-qtest
434  // Contents within a mean value
435  Comp2RefEqualH2ROOT* me_qc = dynamic_cast<Comp2RefEqualH2ROOT*> (qc);
436  //set reference histogram
437  me_qc->setReference(ref);
438  // link it to the monitor element
439  printf("\n\nGonna run it...\n\n");
440  dbe->useQTest(params[0], params[1]);
441  */
442  }
443  else printf("\n\nAlready had the QC or didn't have the ME!\n\n");
444 
445  return;
446 }
447 
448 void htmlErrors(int runNo, std::string htmlDir, std::string client, std::string process, DQMStore* dbe, std::map<std::string, std::vector<QReport*> > mapE, std::map<std::string, std::vector<QReport*> > mapW, std::map<std::string, std::vector<QReport*> > mapO){
449  if(!dbe) return;
450 
451  std::map<std::string, std::vector<QReport*> >::iterator mapIter;
452 
453  std::ofstream errorFile;
454  errorFile.open((htmlDir + client+ "Errors.html").c_str());
455  errorFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << std::endl;
456  errorFile << "<html> " << std::endl;
457  errorFile << "<head> " << std::endl;
458  errorFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << std::endl;
459  errorFile << " http-equiv=\"content-type\"> " << std::endl;
460  errorFile << " <title>Monitor: Hcal " << client <<" Task Error Output</title> " << std::endl;
461  errorFile << "</head> " << std::endl;
462  errorFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << std::endl;
463  errorFile << "<body> " << std::endl;
464  errorFile << "<br> " << std::endl;
465  errorFile << "<h2>" << client <<" Errors</h2> " << std::endl;
466 
467  for (mapIter=mapE.begin(); mapIter!=mapE.end();mapIter++){
468  std::string meName = mapIter->first;
469  std::vector<QReport*> errors = mapIter->second;
470  errorFile << "<br>" << std::endl;
471  errorFile << "<hr>" << std::endl;
472  errorFile << "Monitorable '" << meName << "' has the following errors: <br>" << std::endl;
473  for(std::vector<QReport*>::iterator report=errors.begin(); report!=errors.end(); report++){
474  errorFile << " "<< (*report)->getQRName() << ": "<< (*report)->getMessage() << std::endl;
475  }
476  MonitorElement* me = dbe->get(meName);
477  errorFile << "<br>" << std::endl;
478  errorFile << "<br>" << std::endl;
479  const char * substr = strstr(meName.c_str(), client.c_str());
480  if(me->getMeanError(2)==0){
481  TH1F* obj1f = getHisto(substr, process.c_str(), dbe);
482  std::string save = getIMG(runNo,obj1f,1,htmlDir,"X1a","Y1a");
483  errorFile << "<img src=\"" << save << "\">" << std::endl;
484  }
485  else{
486  TH2F* obj2f = getHisto2(substr, process.c_str(), dbe);
487  std::string save = getIMG2(runNo,obj2f,1,htmlDir,"X2a","Y2a");
488  errorFile << "<img src=\"" << save << "\">" << std::endl;
489  }
490  errorFile << "<br>" << std::endl;
491  errorFile << std::endl;
492  }
493  errorFile << "<hr>" << std::endl;
494  errorFile.close();
495 
496 
497  errorFile.open((htmlDir + client+ "Warnings.html").c_str());
498  errorFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << std::endl;
499  errorFile << "<html> " << std::endl;
500  errorFile << "<head> " << std::endl;
501  errorFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << std::endl;
502  errorFile << " http-equiv=\"content-type\"> " << std::endl;
503  errorFile << " <title>Monitor: Hcal " << client <<" Task Warning Output</title> " << std::endl;
504  errorFile << "</head> " << std::endl;
505  errorFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << std::endl;
506  errorFile << "<body> " << std::endl;
507  errorFile << "<br> " << std::endl;
508  errorFile << "<h2>" << client <<" Warnings</h2> " << std::endl;
509 
510  for (mapIter=mapW.begin(); mapIter!=mapW.end();mapIter++){
511  std::string meName = mapIter->first;
512  std::vector<QReport*> errors = mapIter->second;
513  errorFile << "<br>" << std::endl;
514  errorFile << "<hr>" << std::endl;
515  errorFile << "Monitorable '" << meName << "' has the following warnings: <BR>" << std::endl;
516  for(std::vector<QReport*>::iterator report=errors.begin(); report!=errors.end(); report++){
517  errorFile << " "<< (*report)->getQRName() << ": "<< (*report)->getMessage() << std::endl;
518  }
519  MonitorElement* me = dbe->get(meName);
520  errorFile << "<br>" << std::endl;
521  errorFile << "<br>" << std::endl;
522  const char * substr = strstr(meName.c_str(), client.c_str());
523  if(me->getMeanError(2)==0){
524  TH1F* obj1f = getHisto(substr, process.c_str(), dbe);
525  std::string save = getIMG(runNo,obj1f,1,htmlDir,"X1b","Y1b");
526  errorFile << "<img src=\"" << save << "\">" << std::endl;
527  }
528  else{
529  TH2F* obj2f = getHisto2(substr, process.c_str(), dbe);
530  std::string save = getIMG2(runNo,obj2f,1,htmlDir,"X2b","Y2b");
531  errorFile << "<img src=\"" << save << "\">" << std::endl;
532  }
533  errorFile << "<br>" << std::endl;
534  errorFile << std::endl;
535  }
536  errorFile << "<hr>" << std::endl;
537  errorFile.close();
538 
539  errorFile.open((htmlDir + client+ "Messages.html").c_str());
540  errorFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << std::endl;
541  errorFile << "<html> " << std::endl;
542  errorFile << "<head> " << std::endl;
543  errorFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << std::endl;
544  errorFile << " http-equiv=\"content-type\"> " << std::endl;
545  errorFile << " <title>Monitor: Hcal " << client <<" Task Message Output</title> " << std::endl;
546  errorFile << "</head> " << std::endl;
547  errorFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << std::endl;
548  errorFile << "<body> " << std::endl;
549  errorFile << "<br> " << std::endl;
550  errorFile << "<h2>" << client <<" Messages</h2> " << std::endl;
551 
552  for (mapIter=mapO.begin(); mapIter!=mapO.end();mapIter++){
553  std::string meName = mapIter->first;
554  std::vector<QReport*> errors = mapIter->second;
555  errorFile << "<br>" << std::endl;
556  errorFile << "<hr>" << std::endl;
557  errorFile << "Monitorable '" << meName << "' has the following messages: <br>" << std::endl;
558  for(std::vector<QReport*>::iterator report=errors.begin(); report!=errors.end(); report++){
559  errorFile << " "<< (*report)->getQRName() << ": "<< (*report)->getMessage() << std::endl;
560  }
561  errorFile << "<br>" << std::endl;
562  errorFile << "<br>" << std::endl;
563  MonitorElement* me = dbe->get(meName);
564  const char * substr = strstr(meName.c_str(), client.c_str());
565  if(me->getMeanError(2)==0){
566  TH1F* obj1f = getHisto(substr, process.c_str(), dbe);
567  std::string save = getIMG(runNo,obj1f,1,htmlDir,"X1c","Y1c");
568  errorFile << "<img src=\"" << save << "\">" << std::endl;
569  }
570  else{
571  TH2F* obj2f = getHisto2(substr, process.c_str(), dbe);
572  std::string save = getIMG2(runNo,obj2f,1,htmlDir,"X2c","Y2c");
573  errorFile << "<img src=\"" << save << "\">" << std::endl;
574  }
575  errorFile << "<br>" << std::endl;
576  errorFile << std::endl;
577  }
578  errorFile << "<hr>" << std::endl;
579  errorFile.close();
580 
581  return;
582 
583 }
584 
585 
586 
587 // TProfile histogram-related stuff
588 
590  if(!dbe_) return NULL;
591 
592  char title[150];
593  sprintf(title, "%sHcal/%s",process.c_str(),name.c_str());
594  TProfile* out = NULL;
595 
596  const MonitorElement* me = dbe_->get(title);
597  if (me){
598  if ( verb ) std::cout << "Found '" << title << "'" << std::endl;
599  if ( clone ) {
600  char histo[150];
601  sprintf(histo, "ME %s",name.c_str());
602  out = dynamic_cast<TProfile*> (me->getTProfile()->Clone(histo));
603  } else {
604  out = me->getTProfile();
605  }
606  }
607 
608  return out;
609 }
610 
611 TProfile* getHistoTProfile(const MonitorElement* me, bool verb,bool clone){
612  TProfile* out = NULL;
613 
614  if ( me ) {
615  if ( verb ) std::cout << "Found '" << me->getName() << "'" << std::endl;
616  if ( clone ) {
617  char histo[150];
618  sprintf(histo, "ME %s",((std::string)(me->getName())).c_str());
619  out = dynamic_cast<TProfile*> (me->getTProfile()->Clone(histo));
620  } else {
621  out = me->getTProfile();
622  }
623  }
624  return out;
625 }
626 
627 std::string getIMGTProfile(int runNo,TProfile* hist, int size, std::string htmlDir, const char* xlab, const char* ylab, std::string opts){
628 
629  if(hist==NULL) {
630  printf("getIMG: This histo is NULL, %s, %s\n",xlab,ylab);
631  return "";
632  }
633 
634  std::string name = hist->GetTitle();
635  cleanString(name);
636  char dest[512];
637  if(runNo>-1) sprintf(dest,"%s - Run %d",name.c_str(),runNo);
638  else sprintf(dest,"%s",name.c_str());
639  hist->SetTitle(dest);
641 
642  int xwid = 900; int ywid =540;
643  if(size==1){
644  title = title+"_tmb";
645  xwid = 600; ywid = 360;
646  }
647  TCanvas* can = new TCanvas(dest,dest, xwid, ywid);
648 
649  parseString(title);
650  std::string outName = title + ".gif";
651  std::string saveName = htmlDir + outName;
652  hist->SetXTitle(xlab);
653  hist->SetYTitle(ylab);
654  if (opts!="NONE")
655  hist->SetOption(opts.c_str());
656  hist->Draw();
657 
658  can->SaveAs(saveName.c_str());
659  delete can;
660 
661  return outName;
662 }
663 
664 void histoHTMLTProfile(int runNo, TProfile* hist, const char* xlab, const char* ylab, int width, std::ofstream& htmlFile, std::string htmlDir, std::string opts){
665 
666  if(hist!=NULL){
667  std::string imgNameTMB = "";
668  imgNameTMB = getIMGTProfile(runNo,hist,1,htmlDir,xlab,ylab,opts);
669  std::string imgName = "";
670  imgName = getIMGTProfile(runNo,hist,2,htmlDir,xlab,ylab,opts);
671 
672  if (imgName.size() != 0 )
673  htmlFile << "<td><a href=\"" << imgName << "\"><img src=\"" << imgNameTMB << "\"></a></td>" << std::endl;
674  else
675  htmlFile << "<td><img src=\"" << " " << "\"></td>" << std::endl;
676  }
677  else htmlFile << "<td><img src=\"" << " " << "\"></td>" << std::endl;
678  return;
679 }
680 
681 
682 // Get Histograms for TProfile2D
683 
685  if(!dbe_) return NULL;
686 
687  char title[150];
688  sprintf(title, "%sHcal/%s",process.c_str(),name.c_str());
689  TProfile2D* out = NULL;
690 
691  const MonitorElement* me = dbe_->get(title);
692  if (me){
693  if ( verb ) std::cout << "Found '" << title << "'" << std::endl;
694  if ( clone ) {
695  char histo[150];
696  sprintf(histo, "ME %s",name.c_str());
697  out = dynamic_cast<TProfile2D*> (me->getTProfile2D()->Clone(histo));
698  } else {
699  out = me->getTProfile2D();
700  }
701  }
702 
703  return out;
704 }
705 
706 TProfile2D* getHistoTProfile2D(const MonitorElement* me, bool verb,bool clone){
707  TProfile2D* out = NULL;
708 
709  if ( me ) {
710  if ( verb ) std::cout << "Found '" << me->getName() << "'" << std::endl;
711  if ( clone ) {
712  char histo[150];
713  sprintf(histo, "ME %s",((std::string)(me->getName())).c_str());
714  out = dynamic_cast<TProfile2D*> (me->getTProfile2D()->Clone(histo));
715  } else {
716  out = me->getTProfile2D();
717  }
718  }
719  return out;
720 }
721 
722 // Get histograms for TH3F
724  if(!dbe_) return NULL;
725 
726  char title[150];
727  sprintf(title, "%sHcal/%s",process.c_str(),name.c_str());
728  TH3F* out = NULL;
729 
730  const MonitorElement* me = dbe_->get(title);
731  if (me){
732  if ( verb ) std::cout << "Found '" << title << "'" << std::endl;
733  if ( clone ) {
734  char histo[150];
735  sprintf(histo, "ME %s",name.c_str());
736  out = dynamic_cast<TH3F*> (me->getTH3F()->Clone(histo));
737  } else {
738  out = me->getTH3F();
739  }
740  }
741 
742  return out;
743 }
744 
745 TH3F* getHistoTH3F(const MonitorElement* me, bool verb,bool clone){
746  TH3F* out = NULL;
747 
748  if ( me ) {
749  if ( verb ) std::cout << "Found '" << me->getName() << "'" << std::endl;
750  if ( clone ) {
751  char histo[150];
752  sprintf(histo, "ME %s",((std::string)(me->getName())).c_str());
753  out = dynamic_cast<TH3F*> (me->getTH3F()->Clone(histo));
754  } else {
755  out = me->getTH3F();
756  }
757  }
758  return out;
759 }
void setErrorProb(float prob)
Definition: QTest.h:62
QCriterion * getQCriterion(const std::string &qtname) const
Definition: DQMStore.cc:3267
type
Definition: HCALResponse.h:21
const std::string & getName(void) const
get name of ME
void dumpHisto2(TH2F *hist, std::vector< std::string > &names, std::vector< double > &meanX, std::vector< double > &meanY, std::vector< double > &rmsX, std::vector< double > &rmsY)
int i
Definition: DBlmapReader.cc:9
const QReport * getQReport(const std::string &qtname) const
get QReport corresponding to &lt;qtname&gt; (null pointer if QReport does not exist)
void useRMS(void)
Definition: QTest.cc:1247
static const HistoName names[]
TProfile2D * getTProfile2D(void) const
virtual void setAllowedXRange(double xmin, double xmax)
set allowed range in X-axis (default values: histogram&#39;s X-range)
Definition: QTest.h:237
void createXRangeTest(DQMStore *dbe, std::vector< std::string > &params)
TH2F * getHisto2(std::string name, std::string process, DQMStore *dbe_, bool verb=false, bool clone=false)
TProfile2D * getHistoTProfile2D(std::string name, std::string process, DQMStore *dbe_, bool verb=false, bool clone=false)
TH3F * getTH3F(void) const
static std::string getAlgoName(void)
Definition: QTest.h:233
#define NULL
Definition: scimark2.h:8
void useSigma(double expectedSigma)
Definition: QTest.cc:1236
void resetME(const char *name, DQMStore *dbe)
std::string getIMGTProfile(int runNo, TProfile *hist, int size, std::string htmlDir, const char *xlab, const char *ylab, std::string opts="NONE")
void histoHTML2(int runNo, TH2F *hist, const char *xlab, const char *ylab, int width, std::ofstream &htmlFile, std::string htmlDir, bool color=false)
void histoHTML(int runNo, TH1F *hist, const char *xlab, const char *ylab, int width, std::ofstream &htmlFile, std::string htmlDir)
double getMeanError(int axis=1) const
Algorithm for testing if histogram&#39;s mean value is near expected value.
Definition: QTest.h:393
tuple report
Definition: zeeHLT_cff.py:9
void parseString(std::string &title)
TProfile * getHistoTProfile(std::string name, std::string process, DQMStore *dbe_, bool verb=false, bool clone=false)
void dumpHisto(TH1F *hist, std::vector< std::string > &names, std::vector< double > &meanX, std::vector< double > &meanY, std::vector< double > &rmsX, std::vector< double > &rmsY)
void htmlErrors(int runNo, std::string htmlDir, std::string client, std::string process, DQMStore *dbe, std::map< std::string, std::vector< QReport * > > mapE, std::map< std::string, std::vector< QReport * > > mapW, std::map< std::string, std::vector< QReport * > > mapO)
bool isValidGeom(std::string type, int depth)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const double EtaMin[kNumberCalorimeter]
void createMeanValueTest(DQMStore *dbe, std::vector< std::string > &params)
void softReset(MonitorElement *me)
Definition: DQMStore.cc:3404
static std::string getAlgoName(void)
Definition: QTest.h:258
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1775
DQMStore * dbe_
void setExpectedMean(double mean)
Definition: QTest.h:403
void createYRangeTest(DQMStore *dbe, std::vector< std::string > &params)
std::string getIMG2(int runNo, TH2F *hist, int size, std::string htmlDir, const char *xlab, const char *ylab, bool color=false)
TH1F * getTH1F(void) const
void setWarningProb(float prob)
set probability limit for warning and error (default: 90% and 50%)
Definition: QTest.h:61
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
void createH2CompTest(DQMStore *dbe, std::vector< std::string > &params, TH2F *ref)
void cleanString(std::string &title)
list save
Definition: cuy.py:1163
void histoHTMLTProfile(int runNo, TProfile *hist, const char *xlab, const char *ylab, int width, std::ofstream &htmlFile, std::string htmlDir, std::string opts="NONE")
TProfile * getTProfile(void) const
void useQTest(const std::string &dir, const std::string &qtname)
Definition: DQMStore.cc:3299
tuple cout
Definition: gather_cfg.py:145
void createH2ContentTest(DQMStore *dbe, std::vector< std::string > &params)
QCriterion * createQTest(const std::string &algoname, const std::string &qtname)
Definition: DQMStore.cc:3278
TH2F * getTH2F(void) const
tuple process
Definition: LaserDQM_cfg.py:3
std::string getIMG(int runNo, TH1F *hist, int size, std::string htmlDir, const char *xlab, const char *ylab)
virtual void setAllowedYRange(double ymin, double ymax)
Definition: QTest.h:262
TH1F * getHisto(std::string name, std::string process, DQMStore *dbe_, bool verb=false, bool clone=false)
tuple size
Write out results.
TH3F * getHistoTH3F(std::string name, std::string process, DQMStore *dbe_, bool verb=false, bool clone=false)