#include <SiStripHistoPlotter.h>
Classes | |
struct | PlotParameter |
Public Member Functions | |
bool | condDBPlotsToMake () |
void | createCondDBPlots (DQMStore *dqm_store) |
void | createPlots (DQMStore *dqm_store) |
void | createStaticPlot (MonitorElement *me, const std::string &file_name) |
void | getNamedImageBuffer (const std::string &path, std::string &image) |
bool | plotsToMake () |
void | setNewCondDBPlot (std::string &path, std::string &option, int width, int height) |
void | setNewPlot (std::string &path, std::string &option, int width, int height) |
SiStripHistoPlotter () | |
~SiStripHistoPlotter () | |
Private Member Functions | |
void | createDummyImage (const std::string &name) |
void | fillNamedImageBuffer (TCanvas *c1, const std::string &name) |
(Documentation under construction). | |
void | getDummyImage (std::string &image) |
void | getProjection (MonitorElement *me, TH1F *tp) |
bool | hasNamedImage (const std::string &name) |
void | makeCondDBPlots (DQMStore *dqm_store, const PlotParameter &par) |
void | makePlot (DQMStore *dqm_store, const PlotParameter &par) |
void | setDrawingOption (TH1 *hist) |
Private Attributes | |
std::vector< PlotParameter > | condDBPlotList_ |
std::map< std::string, std::string > | namedPictureBuffer_ |
std::vector< PlotParameter > | plotList_ |
Definition at line 17 of file SiStripHistoPlotter.h.
SiStripHistoPlotter::SiStripHistoPlotter | ( | ) |
Definition at line 26 of file SiStripHistoPlotter.cc.
{ edm::LogInfo("SiStripHistoPlotter") << " Creating SiStripHistoPlotter " << "\n" ; }
SiStripHistoPlotter::~SiStripHistoPlotter | ( | ) |
Definition at line 33 of file SiStripHistoPlotter.cc.
References condDBPlotList_, and plotList_.
{ edm::LogInfo("SiStripHistoPlotter") << " Deleting SiStripHistoPlotter " << "\n" ; plotList_.clear(); condDBPlotList_.clear(); }
bool SiStripHistoPlotter::condDBPlotsToMake | ( | ) | [inline] |
Definition at line 33 of file SiStripHistoPlotter.h.
References condDBPlotList_.
Referenced by SiStripInformationExtractor::createImages().
{ return ((condDBPlotList_.size() > 0) ? true : false);}
void SiStripHistoPlotter::createCondDBPlots | ( | DQMStore * | dqm_store | ) |
Definition at line 326 of file SiStripHistoPlotter.cc.
References condDBPlotList_, createDummyImage(), hasNamedImage(), and makeCondDBPlots().
Referenced by SiStripInformationExtractor::createImages().
{ if (condDBPlotList_.size() == 0) return; std::string name = "Dummy"; if (!hasNamedImage(name)) createDummyImage(name); for (std::vector<PlotParameter>::iterator it = condDBPlotList_.begin(); it != condDBPlotList_.end(); it++) { makeCondDBPlots(dqm_store, (*it)); } condDBPlotList_.clear(); }
void SiStripHistoPlotter::createDummyImage | ( | const std::string & | name | ) | [private] |
Definition at line 316 of file SiPixelHistoPlotter.cc.
References recoMuon::in, and geometryCSVtoXML::line.
Referenced by createCondDBPlots(), createPlots(), and setNewPlot().
{ string line; ostringstream local_str; // Read back the file line by line and temporarily store it in a stringstream ifstream * imagefile = new ifstream("images/EmptyPlot.png",ios::in); if(imagefile->is_open()) { while (getline( *imagefile, line )) { local_str << line << endl ; } } namedPictureBuffer_.insert(pair<string, string>(name, local_str.str())); imagefile->close() ; }
void SiStripHistoPlotter::createPlots | ( | DQMStore * | dqm_store | ) |
Definition at line 56 of file SiStripHistoPlotter.cc.
References createDummyImage(), hasNamedImage(), makePlot(), mergeVDriftHistosByStation::name, and plotList_.
Referenced by SiStripInformationExtractor::createImages().
{ if (plotList_.size() == 0) return; std::string name = "Dummy"; if (!hasNamedImage(name)) createDummyImage(name); for (std::vector<PlotParameter>::iterator it = plotList_.begin(); it != plotList_.end(); it++) { makePlot(dqm_store, (*it)); } plotList_.clear(); }
void SiStripHistoPlotter::createStaticPlot | ( | MonitorElement * | me, |
const std::string & | file_name | ||
) |
Definition at line 352 of file SiPixelHistoPlotter.cc.
References svgfig::canvas(), edmPickEvents::command, cmsPerfSuiteHarvest::file_name, MonitorElement::getRefRootObject(), MonitorElement::getRefTH1(), MonitorElement::getTH1(), and mergeVDriftHistosByStation::name.
Referenced by SiStripInformationExtractor::plotHistosFromLayout().
{ TH1* hist1 = me->getTH1(); TCanvas* canvas = new TCanvas("TKCanvas", "TKCanvas", 600, 400); if (hist1) { TText tTitle; tTitle.SetTextFont(64); tTitle.SetTextSizePixels(20); setDrawingOption(hist1); hist1->Draw(); string name = hist1->GetName(); if (me->getRefRootObject()) { TH1* hist1_ref = me->getRefTH1(); if (hist1_ref) { hist1_ref->SetLineColor(4); hist1_ref->SetMarkerColor(4); if (name.find("SUM") != string::npos) hist1_ref->Draw("same"); else hist1_ref->DrawNormalized("same", hist1->GetEntries()); } } } canvas->Update(); string command = "rm -f " + file_name; gSystem->Exec(command.c_str()); canvas->Print(file_name.c_str(),"png"); canvas->Clear(); delete canvas; }
void SiStripHistoPlotter::fillNamedImageBuffer | ( | TCanvas * | c1, |
const std::string & | name | ||
) | [private] |
(Documentation under construction).
This method
Definition at line 150 of file SiStripHistoPlotter.cc.
References gather_cfg::cout, hasNamedImage(), i, mergeVDriftHistosByStation::name, namedPictureBuffer_, and NULL.
Referenced by makeCondDBPlots(), and makePlot().
{ // DQMScope enter; // Now extract the image // 114 - stands for "no write on Close" // std::cout << ACYellow << ACBold // << "[SiPixelInformationExtractor::fillNamedImageBuffer()] " // << ACPlain // << "A canvas: " // << c1->GetName() // << std::endl ; c1->Update(); c1->Modified(); TImageDump imgdump("tmp.png", 114); c1->Paint(); // get an internal image which will be automatically deleted // in the imgdump destructor TImage *image = imgdump.GetImage(); if( image == NULL ) { std::cout << "No TImage found for " << name << std::endl ; return ; } char *buf; int sz = 0; image->GetImageBuffer(&buf, &sz); std::ostringstream local_str; for (int i = 0; i < sz; i++) local_str << buf[i]; // delete [] buf; ::free(buf); // buf is allocated via realloc() by a C language AfterStep library invoked by the // default (and so far only) TImage implementation in root, TASImage. // clear the first element map if # of entries > 30 if (hasNamedImage(name)) namedPictureBuffer_.erase(name); namedPictureBuffer_[name] = local_str.str(); // if (namedPictureBuffer_[name].size() > 0) std::cout << "image created " << name << std::endl; }
void SiStripHistoPlotter::getDummyImage | ( | std::string & | image | ) | [private] |
Definition at line 213 of file SiStripHistoPlotter.cc.
References recoMuon::in, and geometryCSVtoXML::line.
{ std::string line; std::ostringstream local_str; // Read back the file line by line and temporarily store it in a stringstream std::string localPath = std::string("DQM/TrackerCommon/test/images/EmptyPlot.png"); ifstream * imagefile = new ifstream((edm::FileInPath(localPath).fullPath()).c_str(),std::ios::in); if(imagefile->is_open()) { while (getline( *imagefile, line )) { local_str << line << std::endl ; } } imagefile->close(); image = local_str.str(); }
void SiStripHistoPlotter::getNamedImageBuffer | ( | const std::string & | path, |
std::string & | image | ||
) |
Definition at line 239 of file SiPixelHistoPlotter.cc.
Referenced by SiStripInformationExtractor::getImage().
{ map<string, string>::iterator cPos = namedPictureBuffer_.find(path); if (cPos != namedPictureBuffer_.end()) { image = cPos->second; if (namedPictureBuffer_.size() > 99 ) namedPictureBuffer_.erase(cPos); } else { cPos = namedPictureBuffer_.find("Dummy"); image = cPos->second; } }
void SiStripHistoPlotter::getProjection | ( | MonitorElement * | me, |
TH1F * | tp | ||
) | [private] |
Definition at line 246 of file SiStripHistoPlotter.cc.
References MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::getTH1F(), MonitorElement::getTH2F(), MonitorElement::getTitle(), MonitorElement::getTProfile(), i, j, and MonitorElement::kind().
Referenced by makePlot().
{ std::string ptit = me->getTitle(); ptit += "-Yprojection"; if (me->kind() == MonitorElement::DQM_KIND_TH2F) { TH2F* hist2 = me->getTH2F(); tp = new TH1F(ptit.c_str(),ptit.c_str(),hist2->GetNbinsY(), hist2->GetYaxis()->GetXmin(),hist2->GetYaxis()->GetXmax()); tp->GetXaxis()->SetTitle(ptit.c_str()); for (int j = 1; j < hist2->GetNbinsY()+1; j++) { float tot_count = 0.0; for (int i = 1; i < hist2->GetNbinsX()+1; i++) { tot_count += hist2->GetBinContent(i,j); } tp->SetBinContent(j, tot_count); } } else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) { TProfile* prof = me->getTProfile(); tp = new TH1F(ptit.c_str(),ptit.c_str(),100, 0.0,prof->GetMaximum()*1.2); tp->GetXaxis()->SetTitle(ptit.c_str()); for (int i = 1; i < prof->GetNbinsX()+1; i++) { tp->Fill(prof->GetBinContent(i)); } } else if (me->kind() == MonitorElement::DQM_KIND_TH1F) { TH1F* hist1 = me->getTH1F(); tp = new TH1F(ptit.c_str(),ptit.c_str(),100, 0.0,hist1->GetMaximum()*1.2); tp->GetXaxis()->SetTitle(ptit.c_str()); for (int i = 1; i < hist1->GetNbinsX()+1; i++) { tp->Fill(hist1->GetBinContent(i)); } } }
bool SiStripHistoPlotter::hasNamedImage | ( | const std::string & | name | ) | [private] |
Definition at line 306 of file SiPixelHistoPlotter.cc.
Referenced by createCondDBPlots(), createPlots(), fillNamedImageBuffer(), and setNewPlot().
{ map<string, string>::const_iterator cPos = namedPictureBuffer_.find(name); if (cPos == namedPictureBuffer_.end()) { return false; } else return true; }
void SiStripHistoPlotter::makeCondDBPlots | ( | DQMStore * | dqm_store, |
const PlotParameter & | par | ||
) | [private] |
Definition at line 340 of file SiStripHistoPlotter.cc.
References svgfig::canvas(), SiStripHistoPlotter::PlotParameter::CHeight, SiStripHistoPlotter::PlotParameter::CWidth, fillNamedImageBuffer(), DQMStore::getContents(), MonitorElement::getName(), MonitorElement::getTH1(), timingPdfMaker::histo, SiStripHistoPlotter::PlotParameter::Option, SiStripHistoPlotter::PlotParameter::Path, split, and GlobalPosition_Frontier_DevDB_cff::tag.
Referenced by createCondDBPlots().
{ TCanvas * canvas = new TCanvas("TKCanvas", "TKCanvas", par.CWidth, par.CHeight); std::vector<std::string> htypes; std::string option = par.Option; SiStripUtility::split(option, htypes, ","); std::string tag; std::vector<MonitorElement*> all_mes = dqm_store->getContents(par.Path); for (std::vector<std::string>::const_iterator ih = htypes.begin(); ih!= htypes.end(); ih++) { std::string type = (*ih); if (type.size() == 0) continue; std::string tag = par.Path + "/"; for (std::vector<MonitorElement *>::const_iterator it = all_mes.begin(); it!= all_mes.end(); it++) { MonitorElement * me = (*it); if (!me) continue; std::string hname = me->getName(); if (hname.find(type) != std::string::npos) { TH1* histo = me->getTH1(); histo->Draw(); tag += type; fillNamedImageBuffer(canvas, tag); canvas->Clear(); } } } delete canvas; }
void SiStripHistoPlotter::makePlot | ( | DQMStore * | dqm_store, |
const PlotParameter & | par | ||
) | [private] |
Definition at line 69 of file SiStripHistoPlotter.cc.
References svgfig::canvas(), SiStripHistoPlotter::PlotParameter::CHeight, SiStripHistoPlotter::PlotParameter::CWidth, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::DQM_KIND_TPROFILE2D, fillNamedImageBuffer(), DQMStore::get(), SiStripUtility::getMEStatus(), SiStripUtility::getMEStatusColor(), getProjection(), MonitorElement::getTH1(), timingPdfMaker::histo, MonitorElement::kind(), mergeVDriftHistosByStation::name, SiStripHistoPlotter::PlotParameter::Option, SiStripHistoPlotter::PlotParameter::Path, GlobalPosition_Frontier_DevDB_cff::tag, and groupFilesInBlocks::tt.
Referenced by createPlots().
{ TCanvas * canvas = new TCanvas("TKCanvas", "TKCanvas", par.CWidth, par.CHeight); MonitorElement * me = dqm_store->get(par.Path); if (me) { int istat = SiStripUtility::getMEStatus(me); std::string dopt = par.Option; std::string tag; int icol; SiStripUtility::getMEStatusColor(istat, icol, tag); if (me->kind() == MonitorElement::DQM_KIND_TH1F || me->kind() == MonitorElement::DQM_KIND_TH2F || me->kind() == MonitorElement::DQM_KIND_TPROFILE || me->kind() == MonitorElement::DQM_KIND_TPROFILE2D ) { TH1* histo = me->getTH1(); TH1F* tproject = 0; if (dopt == "projection") { getProjection(me, tproject); if (tproject) tproject->Draw(); else histo->Draw(); } else { dopt = ""; std::string name = histo->GetName(); if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D ) { dopt = "colz"; histo->SetStats( kFALSE ); } else { if (name.find("Summary_Mean") != std::string::npos) { histo->SetStats( kFALSE ); } else { histo->SetFillColor(1); } } histo->Draw(dopt.c_str()); } } TText tTitle; tTitle.SetTextFont(64); tTitle.SetTextSizePixels(20); // tTitle.DrawTextNDC(0.1, 0.92, histo->GetName()); if (icol != 1) { TText tt; tt.SetTextSize(0.12); tt.SetTextColor(icol); tt.DrawTextNDC(0.5, 0.5, tag.c_str()); } fillNamedImageBuffer(canvas, par.Path); canvas->Clear(); } delete canvas; }
bool SiStripHistoPlotter::plotsToMake | ( | ) | [inline] |
Definition at line 32 of file SiStripHistoPlotter.h.
References plotList_.
Referenced by SiStripInformationExtractor::createImages().
{ return ((plotList_.size() > 0) ? true : false);}
void SiStripHistoPlotter::setDrawingOption | ( | TH1 * | hist | ) | [private] |
Definition at line 229 of file SiStripHistoPlotter.cc.
void SiStripHistoPlotter::setNewCondDBPlot | ( | std::string & | path, |
std::string & | option, | ||
int | width, | ||
int | height | ||
) |
Definition at line 315 of file SiStripHistoPlotter.cc.
References SiStripHistoPlotter::PlotParameter::CHeight, condDBPlotList_, SiStripHistoPlotter::PlotParameter::CWidth, SiStripHistoPlotter::PlotParameter::Option, SiStripHistoPlotter::PlotParameter::Path, getHLTPrescaleColumns::path, and tablePrinter::width.
Referenced by SiStripInformationExtractor::getCondDBHistos().
{ PlotParameter local_par; local_par.Path = path; local_par.Option = option; local_par.CWidth = width; local_par.CHeight = height; condDBPlotList_.push_back(local_par); }
void SiStripHistoPlotter::setNewPlot | ( | std::string & | path, |
std::string & | option, | ||
int | width, | ||
int | height | ||
) |
Definition at line 43 of file SiStripHistoPlotter.cc.
References SiStripHistoPlotter::PlotParameter::CHeight, createDummyImage(), SiStripHistoPlotter::PlotParameter::CWidth, hasNamedImage(), mergeVDriftHistosByStation::name, SiStripHistoPlotter::PlotParameter::Option, SiStripHistoPlotter::PlotParameter::Path, getHLTPrescaleColumns::path, plotList_, and tablePrinter::width.
Referenced by SiStripInformationExtractor::getGlobalHistos(), SiStripInformationExtractor::getHistosFromPath(), SiStripInformationExtractor::getTrackerMapHistos(), and SiStripInformationExtractor::readStatusMessage().
{ std::string name = "Dummy"; if (!hasNamedImage(name)) createDummyImage(name); PlotParameter local_par; local_par.Path = path; local_par.Option = option; local_par.CWidth = width; local_par.CHeight = height; plotList_.push_back(local_par); }
std::vector<PlotParameter> SiStripHistoPlotter::condDBPlotList_ [private] |
Definition at line 60 of file SiStripHistoPlotter.h.
Referenced by condDBPlotsToMake(), createCondDBPlots(), setNewCondDBPlot(), and ~SiStripHistoPlotter().
std::map<std::string, std::string> SiStripHistoPlotter::namedPictureBuffer_ [private] |
Definition at line 58 of file SiStripHistoPlotter.h.
Referenced by fillNamedImageBuffer().
std::vector<PlotParameter> SiStripHistoPlotter::plotList_ [private] |
Definition at line 59 of file SiStripHistoPlotter.h.
Referenced by createPlots(), plotsToMake(), setNewPlot(), and ~SiStripHistoPlotter().