#include <DQM/SiStripMonitorClient/interface/SiStripHistoPlotter.h>
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_ |
Classes | |
struct | PlotParameter |
Definition at line 17 of file SiStripHistoPlotter.h.
SiStripHistoPlotter::SiStripHistoPlotter | ( | ) |
Definition at line 27 of file SiStripHistoPlotter.cc.
00027 { 00028 edm::LogInfo("SiStripHistoPlotter") << 00029 " Creating SiStripHistoPlotter " << "\n" ; 00030 }
SiStripHistoPlotter::~SiStripHistoPlotter | ( | ) |
Definition at line 34 of file SiStripHistoPlotter.cc.
References condDBPlotList_, and plotList_.
00034 { 00035 edm::LogInfo("SiStripHistoPlotter") << 00036 " Deleting SiStripHistoPlotter " << "\n" ; 00037 plotList_.clear(); 00038 condDBPlotList_.clear(); 00039 00040 }
bool SiStripHistoPlotter::condDBPlotsToMake | ( | ) | [inline] |
Definition at line 33 of file SiStripHistoPlotter.h.
References condDBPlotList_.
Referenced by SiStripInformationExtractor::createImages().
00033 { return ((condDBPlotList_.size() > 0) ? true : false);}
Definition at line 301 of file SiStripHistoPlotter.cc.
References condDBPlotList_, createDummyImage(), hasNamedImage(), it, and makeCondDBPlots().
Referenced by SiStripInformationExtractor::createImages().
00301 { 00302 if (condDBPlotList_.size() == 0) return; 00303 string name = "Dummy"; 00304 if (!hasNamedImage(name)) createDummyImage(name); 00305 for (vector<PlotParameter>::iterator it = condDBPlotList_.begin(); 00306 it != condDBPlotList_.end(); it++) { 00307 makeCondDBPlots(dqm_store, (*it)); 00308 } 00309 condDBPlotList_.clear(); 00310 }
void SiStripHistoPlotter::createDummyImage | ( | const std::string & | name | ) | [private] |
Referenced by createCondDBPlots(), and createPlots().
Definition at line 55 of file SiStripHistoPlotter.cc.
References createDummyImage(), hasNamedImage(), it, makePlot(), name, and plotList_.
Referenced by SiStripInformationExtractor::createImages().
00055 { 00056 if (plotList_.size() == 0) return; 00057 string name = "Dummy"; 00058 if (!hasNamedImage(name)) createDummyImage(name); 00059 for (vector<PlotParameter>::iterator it = plotList_.begin(); 00060 it != plotList_.end(); it++) { 00061 makePlot(dqm_store, (*it)); 00062 } 00063 plotList_.clear(); 00064 }
void SiStripHistoPlotter::createStaticPlot | ( | MonitorElement * | me, | |
const std::string & | file_name | |||
) |
Referenced by SiStripInformationExtractor::plotHistosFromLayout().
void SiStripHistoPlotter::fillNamedImageBuffer | ( | TCanvas * | c1, | |
const std::string & | name | |||
) | [private] |
(Documentation under construction).
This method
Definition at line 125 of file SiStripHistoPlotter.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), hasNamedImage(), i, namedPictureBuffer_, and NULL.
Referenced by makeCondDBPlots(), and makePlot().
00126 { 00127 // DQMScope enter; 00128 // Now extract the image 00129 // 114 - stands for "no write on Close" 00130 // cout << ACYellow << ACBold 00131 // << "[SiPixelInformationExtractor::fillNamedImageBuffer()] " 00132 // << ACPlain 00133 // << "A canvas: " 00134 // << c1->GetName() 00135 // << endl ; 00136 c1->Update(); 00137 c1->Modified(); 00138 TImageDump imgdump("tmp.png", 114); 00139 c1->Paint(); 00140 00141 // get an internal image which will be automatically deleted 00142 // in the imgdump destructor 00143 TImage *image = imgdump.GetImage(); 00144 00145 if( image == NULL ) 00146 { 00147 cout << "No TImage found for " 00148 << name 00149 << endl ; 00150 return ; 00151 } 00152 char *buf; 00153 int sz = 0; 00154 image->GetImageBuffer(&buf, &sz); 00155 00156 ostringstream local_str; 00157 for (int i = 0; i < sz; i++) local_str << buf[i]; 00158 00159 // delete [] buf; 00160 ::free(buf); // buf is allocated via realloc() by a C language AfterStep library invoked by the 00161 // default (and so far only) TImage implementation in root, TASImage. 00162 00163 // clear the first element map if # of entries > 30 00164 if (hasNamedImage(name)) namedPictureBuffer_.erase(name); 00165 namedPictureBuffer_[name] = local_str.str(); 00166 // if (namedPictureBuffer_[name].size() > 0) cout << "image created " << name << endl; 00167 }
void SiStripHistoPlotter::getDummyImage | ( | std::string & | image | ) | [private] |
void SiStripHistoPlotter::getNamedImageBuffer | ( | const std::string & | path, | |
std::string & | image | |||
) |
void SiStripHistoPlotter::getProjection | ( | MonitorElement * | me, | |
TH1F * | tp | |||
) | [private] |
Definition at line 221 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().
00221 { 00222 00223 string ptit = me->getTitle(); 00224 ptit += "-Yprojection"; 00225 00226 if (me->kind() == MonitorElement::DQM_KIND_TH2F) { 00227 TH2F* hist2 = me->getTH2F(); 00228 tp = new TH1F(ptit.c_str(),ptit.c_str(),hist2->GetNbinsY(), 00229 hist2->GetYaxis()->GetXmin(),hist2->GetYaxis()->GetXmax()); 00230 tp->GetXaxis()->SetTitle(ptit.c_str()); 00231 for (int j = 1; j < hist2->GetNbinsY()+1; j++) { 00232 float tot_count = 0.0; 00233 for (int i = 1; i < hist2->GetNbinsX()+1; i++) { 00234 tot_count += hist2->GetBinContent(i,j); 00235 } 00236 tp->SetBinContent(j, tot_count); 00237 } 00238 } else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) { 00239 TProfile* prof = me->getTProfile(); 00240 tp = new TH1F(ptit.c_str(),ptit.c_str(),100, 00241 0.0,prof->GetMaximum()*1.2); 00242 tp->GetXaxis()->SetTitle(ptit.c_str()); 00243 for (int i = 1; i < prof->GetNbinsX()+1; i++) { 00244 tp->Fill(prof->GetBinContent(i)); 00245 } 00246 } else if (me->kind() == MonitorElement::DQM_KIND_TH1F) { 00247 TH1F* hist1 = me->getTH1F(); 00248 tp = new TH1F(ptit.c_str(),ptit.c_str(),100, 00249 0.0,hist1->GetMaximum()*1.2); 00250 tp->GetXaxis()->SetTitle(ptit.c_str()); 00251 for (int i = 1; i < hist1->GetNbinsX()+1; i++) { 00252 tp->Fill(hist1->GetBinContent(i)); 00253 } 00254 } 00255 }
bool SiStripHistoPlotter::hasNamedImage | ( | const std::string & | name | ) | [private] |
Referenced by createCondDBPlots(), createPlots(), and fillNamedImageBuffer().
void SiStripHistoPlotter::makeCondDBPlots | ( | DQMStore * | dqm_store, | |
const PlotParameter & | par | |||
) | [private] |
Definition at line 314 of file SiStripHistoPlotter.cc.
References SiStripHistoPlotter::PlotParameter::CHeight, SiStripHistoPlotter::PlotParameter::CWidth, fillNamedImageBuffer(), DQMStore::getContents(), MonitorElement::getName(), MonitorElement::getTH1(), histo, it, SiStripHistoPlotter::PlotParameter::Option, btag::LeptonSelector::option(), SiStripHistoPlotter::PlotParameter::Path, SiStripUtility::split(), and ecalRecalibSequence_cff::tag.
Referenced by createCondDBPlots().
00314 { 00315 TCanvas * canvas = new TCanvas("TKCanvas", "TKCanvas", par.CWidth, par.CHeight); 00316 00317 vector<string> htypes; 00318 string option = par.Option; 00319 SiStripUtility::split(option, htypes, ","); 00320 00321 string tag; 00322 vector<MonitorElement*> all_mes = dqm_store->getContents(par.Path); 00323 00324 for (vector<string>::const_iterator ih = htypes.begin(); 00325 ih!= htypes.end(); ih++) { 00326 string type = (*ih); 00327 if (type.size() == 0) continue; 00328 string tag = par.Path + type;; 00329 for (vector<MonitorElement *>::const_iterator it = all_mes.begin(); 00330 it!= all_mes.end(); it++) { 00331 MonitorElement * me = (*it); 00332 if (!me) continue; 00333 string hname = me->getName(); 00334 if (hname.find(type) != string::npos) { 00335 TH1* histo = me->getTH1(); 00336 histo->Draw(); 00337 canvas->Clear(); 00338 fillNamedImageBuffer(canvas, tag); 00339 } 00340 } 00341 } 00342 delete canvas; 00343 }
void SiStripHistoPlotter::makePlot | ( | DQMStore * | dqm_store, | |
const PlotParameter & | par | |||
) | [private] |
Definition at line 68 of file SiStripHistoPlotter.cc.
References SiStripHistoPlotter::PlotParameter::CHeight, SiStripHistoPlotter::PlotParameter::CWidth, fillNamedImageBuffer(), DQMStore::get(), SiStripUtility::getMEStatus(), SiStripUtility::getMEStatusColor(), getProjection(), MonitorElement::getTH1(), histo, icol, me, SiStripHistoPlotter::PlotParameter::Option, SiStripHistoPlotter::PlotParameter::Path, ecalRecalibSequence_cff::tag, and tt.
Referenced by createPlots().
00068 { 00069 TCanvas * canvas = new TCanvas("TKCanvas", "TKCanvas", par.CWidth, par.CHeight); 00070 00071 MonitorElement * me = dqm_store->get(par.Path); 00072 if (me) { 00073 00074 int istat = SiStripUtility::getMEStatus(me); 00075 00076 string dopt = par.Option; 00077 string tag; 00078 int icol; 00079 SiStripUtility::getMEStatusColor(istat, icol, tag); 00080 00081 TH1* histo = me->getTH1(); 00082 TH1F* tproject = 0; 00083 if (dopt == "projection") { 00084 getProjection(me, tproject); 00085 if (tproject) tproject->Draw(); 00086 else histo->Draw(); 00087 } else { 00088 histo->Draw(); 00089 } 00090 TText tTitle; 00091 tTitle.SetTextFont(64); 00092 tTitle.SetTextSizePixels(20); 00093 tTitle.DrawTextNDC(0.1, 0.92, histo->GetName()); 00094 00095 if (icol != 1) { 00096 TText tt; 00097 tt.SetTextSize(0.12); 00098 tt.SetTextColor(icol); 00099 tt.DrawTextNDC(0.5, 0.5, tag.c_str()); 00100 } 00101 fillNamedImageBuffer(canvas, par.Path); 00102 canvas->Clear(); 00103 } 00104 delete canvas; 00105 }
bool SiStripHistoPlotter::plotsToMake | ( | ) | [inline] |
Definition at line 32 of file SiStripHistoPlotter.h.
References plotList_.
Referenced by SiStripInformationExtractor::createImages().
00032 { return ((plotList_.size() > 0) ? true : false);}
void SiStripHistoPlotter::setDrawingOption | ( | TH1 * | hist | ) | [private] |
Definition at line 204 of file SiStripHistoPlotter.cc.
00204 { 00205 if (!hist) return; 00206 00207 TAxis* xa = hist->GetXaxis(); 00208 TAxis* ya = hist->GetYaxis(); 00209 00210 xa->SetTitleOffset(0.7); 00211 xa->SetTitleSize(0.05); 00212 xa->SetLabelSize(0.04); 00213 00214 ya->SetTitleOffset(0.7); 00215 ya->SetTitleSize(0.05); 00216 ya->SetLabelSize(0.04); 00217 00218 }
void SiStripHistoPlotter::setNewCondDBPlot | ( | std::string & | path, | |
std::string & | option, | |||
int | width, | |||
int | height | |||
) |
Definition at line 290 of file SiStripHistoPlotter.cc.
References SiStripHistoPlotter::PlotParameter::CHeight, condDBPlotList_, SiStripHistoPlotter::PlotParameter::CWidth, SiStripHistoPlotter::PlotParameter::Option, and SiStripHistoPlotter::PlotParameter::Path.
Referenced by SiStripInformationExtractor::getCondDBHistos().
00290 { 00291 PlotParameter local_par; 00292 local_par.Path = path; 00293 local_par.Option = option; 00294 local_par.CWidth = width; 00295 local_par.CHeight = height; 00296 condDBPlotList_.push_back(local_par); 00297 }
void SiStripHistoPlotter::setNewPlot | ( | std::string & | path, | |
std::string & | option, | |||
int | width, | |||
int | height | |||
) |
Definition at line 44 of file SiStripHistoPlotter.cc.
References SiStripHistoPlotter::PlotParameter::CHeight, SiStripHistoPlotter::PlotParameter::CWidth, SiStripHistoPlotter::PlotParameter::Option, SiStripHistoPlotter::PlotParameter::Path, and plotList_.
Referenced by SiStripInformationExtractor::getHistosFromPath(), SiStripInformationExtractor::getTrackerMapHistos(), and SiStripInformationExtractor::readStatusMessage().
00044 { 00045 PlotParameter local_par; 00046 local_par.Path = path; 00047 local_par.Option = option; 00048 local_par.CWidth = width; 00049 local_par.CHeight = height; 00050 plotList_.push_back(local_par); 00051 }
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] |
std::vector<PlotParameter> SiStripHistoPlotter::plotList_ [private] |
Definition at line 59 of file SiStripHistoPlotter.h.
Referenced by createPlots(), plotsToMake(), setNewPlot(), and ~SiStripHistoPlotter().