16 #include "TPaveText.h"
17 #include "TImageDump.h"
20 #include "TPaveLabel.h"
31 " Creating SiPixelHistoPlotter " <<
"\n" ;
38 " Deleting SiPixelHistoPlotter " <<
"\n" ;
56 plotList_.push_back(local_par);
64 string name =
"Dummy";
65 if (!hasNamedImage(name)) createDummyImage(name);
67 for (vector<PlotParameter>::iterator it = plotList_.begin();
68 it != plotList_.end(); it++) {
81 gStyle->SetPalette(1,0);
82 gStyle->SetOptStat(111110);
83 canvas->SetBorderMode(0);
84 canvas->SetFillColor(0);
86 TPaveText * paveOnCanvas =
new TPaveText(0.57,0.79,0.77,0.99,
"NDCtr");
87 paveOnCanvas->SetFillColor(0);
95 { opt =
"COLZ"; gStyle->SetOptStat(10); }
105 string var = (me->
getName()).substr((me->
getName()).find_last_of(
"/")+1);
109 string name = histo->GetName();
113 histo_ref->SetLineColor(4);
114 histo_ref->SetMarkerColor(4);
115 if (name.find(
"SUM") != string::npos) histo_ref->Draw(
"same");
116 else histo_ref->DrawNormalized(
"same", histo->GetEntries());
143 TLine* l_min =
new TLine();
144 TLine* l_max =
new TLine();
145 l_min->SetLineWidth(4);
146 l_max->SetLineWidth(4);
150 TText* statusOnCanvas = paveOnCanvas->AddText(tag.c_str());
151 statusOnCanvas->SetTextSize(0.08);
152 statusOnCanvas->SetTextFont(112);
153 statusOnCanvas->SetNDC(kTRUE);
154 statusOnCanvas->SetTextColor(icol);
160 double warning = -1.;
162 double channelFraction = -1.;
165 setLines(me,var,ymin,ymax,warning,error,channelFraction);
169 string textMessage =
"fraction of channels failing:";
170 TText* messageOnCanvas = paveOnCanvas->AddText(textMessage.c_str());
171 messageOnCanvas->SetTextSize(0.03);
172 messageOnCanvas->SetNDC(kTRUE);
174 sprintf(text,
"%.2f %%",channelFraction);
175 messageOnCanvas = paveOnCanvas->AddText(text);
176 messageOnCanvas->SetTextSize(0.035);
177 messageOnCanvas->SetNDC(kTRUE);
179 if(ymin!= -1. && ymax!=-1.){
181 l_min->SetLineColor(icol);
182 l_max->SetLineColor(icol);
183 if(var.find(
"SUM") != string::npos){
184 xmin = histo->GetXaxis()->GetXmin();
185 xmax = histo->GetXaxis()->GetXmax();
200 ymin = histo->GetYaxis()->GetBinLowEdge(1);
201 ymax = histo->GetMaximum();
217 paveOnCanvas->Draw(
"same");
219 if(((var.find(
"Barrel") != string::npos) && (var.find(
"SUM") != string::npos)) ||
220 ((var.find(
"Endcap") != string::npos) && (var.find(
"SUM") != string::npos)))
221 setSubDetAxisDrawing((me->
getName()),histo);
227 fillNamedImageBuffer(canvas, par.
Path);
230 createDummyImage(par.
Path);
240 map<string, string>::iterator cPos = namedPictureBuffer_.find(path);
241 if (cPos != namedPictureBuffer_.end()) {
242 image = cPos->second;
243 if (namedPictureBuffer_.size() > 99 ) namedPictureBuffer_.erase(cPos);
245 cPos = namedPictureBuffer_.find(
"Dummy");
246 image = cPos->second;
269 TImageDump imgdump(
"tmp.png", 114);
274 TImage *image = imgdump.GetImage();
286 image->GetImageBuffer(&buf, &sz);
288 ostringstream local_str;
289 for (
int i = 0;
i < sz;
i++) local_str << buf[
i];
296 if (hasNamedImage(name)) namedPictureBuffer_.erase(name);
298 namedPictureBuffer_[
name] = local_str.str();
307 map<string, string>::const_iterator cPos = namedPictureBuffer_.find(name);
308 if (cPos == namedPictureBuffer_.end()) {
318 ostringstream local_str;
320 std::ifstream * imagefile =
new std::ifstream(
"images/EmptyPlot.png",
ios::in);
321 if(imagefile->is_open()) {
322 while (getline( *imagefile, line )) {
323 local_str << line << endl ;
326 namedPictureBuffer_.insert(pair<string, string>(name, local_str.str()));
336 TAxis* xa = hist->GetXaxis();
337 TAxis* ya = hist->GetYaxis();
339 xa->SetTitleOffset(0.7);
340 xa->SetTitleSize(0.05);
341 xa->SetLabelSize(0.04);
343 ya->SetTitleOffset(0.7);
344 ya->SetTitleSize(0.05);
345 ya->SetLabelSize(0.04);
353 TH1* hist1 = me->
getTH1();
354 TCanvas*
canvas =
new TCanvas(
"TKCanvas",
"TKCanvas", 600, 400);
357 tTitle.SetTextFont(64);
358 tTitle.SetTextSizePixels(20);
360 setDrawingOption(hist1);
362 string name = hist1->GetName();
366 hist1_ref->SetLineColor(4);
367 hist1_ref->SetMarkerColor(4);
368 if (name.find(
"SUM") != string::npos) hist1_ref->Draw(
"same");
369 else hist1_ref->DrawNormalized(
"same", hist1->GetEntries());
375 gSystem->Exec(command.c_str());
376 canvas->Print(file_name.c_str(),
"png");
388 double & channelFraction) {
390 std::vector<QReport *>
report;
405 for(std::vector<QReport *>::iterator itr=report.begin(); itr!=report.end();++itr ){
408 int num1 = text.find_first_of(
":")+1;
409 int num2 = text.find_first_of(
"-",num1)+1;
410 int num3 = text.find_first_of(
" ",num2);
411 std::stringstream dummy(text.substr(num1,num2-num1-1));
413 std::stringstream dummy1(text.substr(num2,num3-num2));
416 int num4 = text.find_last_of(
"=")+2;
417 std::stringstream dummy2(text.substr(num4));
418 dummy2 >> channelFraction;
419 channelFraction = (1.- channelFraction)*100.;
432 histo->GetXaxis()->SetLabelColor(0);
435 if(detector.find(
"Barrel") != string::npos || detector.find(
"Endcap") != string::npos){
436 if(detector.find(
"Barrel") != string::npos){
439 if(detector.find(
"Endcap") != string::npos){
440 ownName =
"HalfCylinder";
444 tt.SetTextSize(0.04);
445 string mI = ownName +
"_mI"; tt.DrawTextNDC(0.12, 0.04, mI.c_str());
446 string mO = ownName +
"_mO"; tt.DrawTextNDC(0.32, 0.04, mO.c_str());
447 string pI = ownName +
"_pI"; tt.DrawTextNDC(0.52, 0.04, pI.c_str());
448 string pO = ownName +
"_pO"; tt.DrawTextNDC(0.72, 0.04, pO.c_str());
450 if(detector.find(
"Shell") != string::npos){
453 tt.SetTextSize(0.04);
454 string l_one = ownName +
"_1"; tt.DrawTextNDC(0.12, 0.03, l_one.c_str());
455 string l_two = ownName +
"_2"; tt.DrawTextNDC(0.42, 0.03, l_two.c_str());
456 string l_three = ownName +
"_3"; tt.DrawTextNDC(0.72, 0.03, l_three.c_str());
458 if(detector.find(
"HalfCylinder") != string::npos){
461 tt.SetTextSize(0.04);
462 string d_one = ownName +
"_1"; tt.DrawTextNDC(0.12, 0.03, d_one.c_str());
463 string d_two = ownName +
"_2"; tt.DrawTextNDC(0.62, 0.03, d_two.c_str());
bool hasNamedImage(const std::string &name)
const std::string & getName(void) const
get name of ME
TH1 * getRefTH1(void) const
void makePlot(DQMStore *bei, const PlotParameter &par)
void setSubDetAxisDrawing(std::string detector, TH1F *histo)
bool hasError(void) const
true if at least of one of the quality tests returned an error
void setLines(MonitorElement *me, std::string &meName, double &ymin, double &ymax, double &warning, double &error, double &channelFraction)
void setDrawingOption(TH1 *hist)
void getNamedImageBuffer(const std::string &path, std::string &image)
void createDummyImage(const std::string &name)
std::vector< QReport * > getQErrors(void) const
get errors from last set of quality tests
static void setDrawingOption(TH1 *hist, float xlow=-1., float xhigh=-1.)
static int getStatus(MonitorElement *me)
tuple path
else: Piece not in the list, fine.
bool hasWarning(void) const
true if at least of one of the quality tests returned a warning
static void getStatusColor(int status, int &rval, int &gval, int &bval)
Kind kind(void) const
Get the type of the monitor element.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
void fillNamedImageBuffer(TCanvas *c1, const std::string &name)
(Documentation under construction).
void createPlots(DQMStore *bei)
TObject * getRootObject(void) const
std::vector< QReport * > getQOthers(void) const
void createStaticPlot(MonitorElement *me, const std::string &file_name)
bool hasOtherReport(void) const
true if at least of one of the tests returned some other (non-ok) status
return(e1-e2)*(e1-e2)+dp *dp
std::vector< QReport * > getQWarnings(void) const
get warnings from last set of quality tests
static const int STATUS_OK
void setNewPlot(std::string &path, std::string &option, int width, int height)
TObject * getRefRootObject(void) const