CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
SiStripHistoPlotter Class Reference

#include <SiStripHistoPlotter.h>

Classes

struct  PlotParameter
 

Public Types

typedef dqm::harvesting::DQMStore DQMStore
 
typedef dqm::harvesting::MonitorElement MonitorElement
 

Public Member Functions

bool condDBPlotsToMake ()
 
void createCondDBPlots (DQMStore *dqm_store)
 
void createPlots (DQMStore *dqm_store)
 
void getNamedImageBuffer (const std::string &path, std::string &image)
 
bool plotsToMake ()
 
void setNewCondDBPlot (std::string const &path, std::string const &option, int width, int height)
 
void setNewPlot (std::string const &path, std::string const &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). More...
 
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 const *dqm_store, const PlotParameter &par)
 
void setDrawingOption (TH1 *hist)
 

Private Attributes

std::vector< PlotParametercondDBPlotList_
 
std::map< std::string, std::string > namedPictureBuffer_
 
std::vector< PlotParameterplotList_
 

Detailed Description

Definition at line 15 of file SiStripHistoPlotter.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 18 of file SiStripHistoPlotter.h.

◆ MonitorElement

Definition at line 17 of file SiStripHistoPlotter.h.

Constructor & Destructor Documentation

◆ SiStripHistoPlotter()

SiStripHistoPlotter::SiStripHistoPlotter ( )

Definition at line 25 of file SiStripHistoPlotter.cc.

25  {
26  edm::LogInfo("SiStripHistoPlotter") << " Creating SiStripHistoPlotter "
27  << "\n";
28 }

◆ ~SiStripHistoPlotter()

SiStripHistoPlotter::~SiStripHistoPlotter ( )

Definition at line 32 of file SiStripHistoPlotter.cc.

32  {
33  edm::LogInfo("SiStripHistoPlotter") << " Deleting SiStripHistoPlotter "
34  << "\n";
35 }

Member Function Documentation

◆ condDBPlotsToMake()

bool SiStripHistoPlotter::condDBPlotsToMake ( )
inline

Definition at line 29 of file SiStripHistoPlotter.h.

29 { return !condDBPlotList_.empty(); }

References condDBPlotList_.

◆ createCondDBPlots()

void SiStripHistoPlotter::createCondDBPlots ( DQMStore dqm_store)

Definition at line 285 of file SiStripHistoPlotter.cc.

285  {
286  if (condDBPlotList_.empty())
287  return;
288  std::string name = "Dummy";
289  if (!hasNamedImage(name))
291 
292  for (std::vector<PlotParameter>::iterator it = condDBPlotList_.begin(); it != condDBPlotList_.end(); it++) {
293  makeCondDBPlots(dqm_store, (*it));
294  }
295  condDBPlotList_.clear();
296 }

References condDBPlotList_, createDummyImage(), hasNamedImage(), makeCondDBPlots(), Skims_PA_cff::name, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ createDummyImage()

void SiStripHistoPlotter::createDummyImage ( const std::string &  name)
private

Definition at line 199 of file SiStripHistoPlotter.cc.

199  {
200  std::string image;
201  getDummyImage(image);
202  namedPictureBuffer_.insert(std::pair<std::string, std::string>(name, image));
203 }

References getDummyImage(), Skims_PA_cff::name, namedPictureBuffer_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createCondDBPlots(), createPlots(), and setNewPlot().

◆ createPlots()

void SiStripHistoPlotter::createPlots ( DQMStore dqm_store)

Definition at line 52 of file SiStripHistoPlotter.cc.

52  {
53  if (plotList_.empty())
54  return;
55  std::string name = "Dummy";
56  if (!hasNamedImage(name))
58  for (auto const& par : plotList_) {
59  makePlot(dqm_store, par);
60  }
61  plotList_.clear();
62 }

References createDummyImage(), hasNamedImage(), makePlot(), Skims_PA_cff::name, plotList_, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ fillNamedImageBuffer()

void SiStripHistoPlotter::fillNamedImageBuffer ( TCanvas *  c1,
const std::string &  name 
)
private

(Documentation under construction).

This method

Definition at line 145 of file SiStripHistoPlotter.cc.

145  {
146  // DQMScope enter;
147  // Now extract the image
148  // 114 - stands for "no write on Close"
149  // std::cout << ACYellow << ACBold
150  // << "[SiPixelInformationExtractor::fillNamedImageBuffer()] "
151  // << ACPlain
152  // << "A canvas: "
153  // << c1->GetName()
154  // << std::endl ;
155  c1->Update();
156  c1->Modified();
157  TImageDump imgdump("tmp.png", 114);
158  c1->Paint();
159 
160  // get an internal image which will be automatically deleted
161  // in the imgdump destructor
162  TImage* image = imgdump.GetImage();
163 
164  if (image == nullptr) {
165  std::cout << "No TImage found for " << name << std::endl;
166  return;
167  }
168  char* buf;
169  int sz = 0;
170  image->GetImageBuffer(&buf, &sz);
171 
172  std::ostringstream local_str;
173  for (int i = 0; i < sz; i++)
174  local_str << buf[i];
175 
176  // delete [] buf;
177  ::free(buf); // buf is allocated via realloc() by a C language AfterStep library invoked by the
178  // default (and so far only) TImage implementation in root, TASImage.
179 
180  // clear the first element map if # of entries > 30
181  if (hasNamedImage(name))
182  namedPictureBuffer_.erase(name);
183  namedPictureBuffer_[name] = local_str.str();
184  // if (namedPictureBuffer_[name].size() > 0) std::cout << "image created " << name << std::endl;
185 }

References visDQMUpload::buf, alignmentValidation::c1, gather_cfg::cout, hasNamedImage(), mps_fire::i, Skims_PA_cff::name, and namedPictureBuffer_.

Referenced by makeCondDBPlots(), and makePlot().

◆ getDummyImage()

void SiStripHistoPlotter::getDummyImage ( std::string &  image)
private

Definition at line 207 of file SiStripHistoPlotter.cc.

207  {
209  std::ostringstream local_str;
210  // Read back the file line by line and temporarily store it in a stringstream
211  std::string localPath = std::string("DQM/TrackerCommon/test/images/EmptyPlot.png");
212  std::ifstream* imagefile = new std::ifstream((edm::FileInPath(localPath).fullPath()).c_str(), std::ios::in);
213  if (imagefile->is_open()) {
214  while (getline(*imagefile, line)) {
215  local_str << line << std::endl;
216  }
217  }
218  imagefile->close();
219  image = local_str.str();
220 }

References contentValuesFiles::fullPath, recoMuon::in, mps_splice::line, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createDummyImage().

◆ getNamedImageBuffer()

void SiStripHistoPlotter::getNamedImageBuffer ( const std::string &  path,
std::string &  image 
)

Definition at line 122 of file SiStripHistoPlotter.cc.

122  {
123  std::map<std::string, std::string>::iterator cPos;
124  if (path == "dummy_path") {
125  std::cout << " Sending Dummy Image for : " << path << std::endl;
126  cPos = namedPictureBuffer_.find("Dummy");
127  image = cPos->second;
128  } else {
129  cPos = namedPictureBuffer_.find(path);
130  if (cPos != namedPictureBuffer_.end()) {
131  image = cPos->second;
132  if (namedPictureBuffer_.size() > 99)
133  namedPictureBuffer_.erase(cPos);
134  } else {
135  std::cout << " Sending Dummy Image for : " << path << std::endl;
136  cPos = namedPictureBuffer_.find("Dummy");
137  image = cPos->second;
138  }
139  }
140 }

References gather_cfg::cout, namedPictureBuffer_, and castor_dqm_sourceclient_file_cfg::path.

◆ getProjection()

void SiStripHistoPlotter::getProjection ( MonitorElement me,
TH1F *  tp 
)
private

Definition at line 240 of file SiStripHistoPlotter.cc.

240  {
241  std::string ptit = me->getTitle();
242  ptit += "-Yprojection";
243 
244  if (me->kind() == MonitorElement::Kind::TH2F) {
245  TH2F* hist2 = me->getTH2F();
246  tp = new TH1F(
247  ptit.c_str(), ptit.c_str(), hist2->GetNbinsY(), hist2->GetYaxis()->GetXmin(), hist2->GetYaxis()->GetXmax());
248  tp->GetXaxis()->SetTitle(ptit.c_str());
249  for (int j = 1; j < hist2->GetNbinsY() + 1; j++) {
250  float tot_count = 0.0;
251  for (int i = 1; i < hist2->GetNbinsX() + 1; i++) {
252  tot_count += hist2->GetBinContent(i, j);
253  }
254  tp->SetBinContent(j, tot_count);
255  }
256  } else if (me->kind() == MonitorElement::Kind::TPROFILE) {
257  TProfile* prof = me->getTProfile();
258  tp = new TH1F(ptit.c_str(), ptit.c_str(), 100, 0.0, prof->GetMaximum() * 1.2);
259  tp->GetXaxis()->SetTitle(ptit.c_str());
260  for (int i = 1; i < prof->GetNbinsX() + 1; i++) {
261  tp->Fill(prof->GetBinContent(i));
262  }
263  } else if (me->kind() == MonitorElement::Kind::TH1F) {
264  TH1F* hist1 = me->getTH1F();
265  tp = new TH1F(ptit.c_str(), ptit.c_str(), 100, 0.0, hist1->GetMaximum() * 1.2);
266  tp->GetXaxis()->SetTitle(ptit.c_str());
267  for (int i = 1; i < hist1->GetNbinsX() + 1; i++) {
268  tp->Fill(hist1->GetBinContent(i));
269  }
270  }
271 }

References mps_fire::i, dqmiolumiharvest::j, hlt_dqm_clientPB-live_cfg::me, AlCaHLTBitMon_QueryRunRegistry::string, MonitorElementData::TH1F, MonitorElementData::TH2F, cmsswSequenceInfo::tp, and MonitorElementData::TPROFILE.

Referenced by makePlot().

◆ hasNamedImage()

bool SiStripHistoPlotter::hasNamedImage ( const std::string &  name)
private

Definition at line 189 of file SiStripHistoPlotter.cc.

189  {
190  std::map<std::string, std::string>::const_iterator cPos = namedPictureBuffer_.find(name);
191  if (cPos == namedPictureBuffer_.end()) {
192  return false;
193  } else
194  return true;
195 }

References Skims_PA_cff::name, and namedPictureBuffer_.

Referenced by createCondDBPlots(), createPlots(), fillNamedImageBuffer(), and setNewPlot().

◆ makeCondDBPlots()

void SiStripHistoPlotter::makeCondDBPlots ( DQMStore dqm_store,
const PlotParameter par 
)
private

Definition at line 300 of file SiStripHistoPlotter.cc.

300  {
301  TCanvas* canvas = new TCanvas("TKCanvas", "TKCanvas", par.CWidth, par.CHeight);
302 
303  std::vector<std::string> htypes;
304  std::string option = par.Option;
305  SiStripUtility::split(option, htypes, ",");
306 
308  std::vector<MonitorElement*> all_mes = dqm_store->getContents(par.Path);
309 
310  for (std::vector<std::string>::const_iterator ih = htypes.begin(); ih != htypes.end(); ih++) {
311  std::string type = (*ih);
312  if (type.empty())
313  continue;
314  std::string tag = par.Path + "/";
315  for (std::vector<MonitorElement*>::const_iterator it = all_mes.begin(); it != all_mes.end(); it++) {
316  MonitorElement* me = (*it);
317  if (!me)
318  continue;
319  std::string hname = me->getName();
320  if (hname.find(type) != std::string::npos) {
321  TH1* histo = me->getTH1();
322  histo->Draw();
323  tag += type;
325  canvas->Clear();
326  }
327  }
328  }
329  delete canvas;
330 }

References svgfig::canvas(), SiStripHistoPlotter::PlotParameter::CHeight, SiStripHistoPlotter::PlotParameter::CWidth, fillNamedImageBuffer(), dqm::implementation::IGetter::getContents(), timingPdfMaker::histo, hlt_dqm_clientPB-live_cfg::me, SiStripHistoPlotter::PlotParameter::Option, fileinputsource_cfi::option, SiStripHistoPlotter::PlotParameter::Path, SiStripUtility::split(), AlCaHLTBitMon_QueryRunRegistry::string, and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by createCondDBPlots().

◆ makePlot()

void SiStripHistoPlotter::makePlot ( DQMStore const *  dqm_store,
const PlotParameter par 
)
private

Definition at line 66 of file SiStripHistoPlotter.cc.

66  {
67  TCanvas* canvas = new TCanvas("TKCanvas", "TKCanvas", par.CWidth, par.CHeight);
68 
69  MonitorElement* me = dqm_store->get(par.Path);
70  if (me) {
71  int istat = SiStripUtility::getMEStatus(me);
72 
73  std::string dopt = par.Option;
75  int icol;
77  if (me->kind() == MonitorElement::Kind::TH1F || me->kind() == MonitorElement::Kind::TH2F ||
79  TH1* histo = me->getTH1();
80  TH1F* tproject = nullptr;
81  if (dopt == "projection") {
82  getProjection(me, tproject);
83  if (tproject)
84  tproject->Draw();
85  else
86  histo->Draw();
87  } else {
88  dopt = "";
89  std::string name = histo->GetName();
90  if (me->kind() == MonitorElement::Kind::TPROFILE2D) {
91  dopt = "colz";
92  histo->SetStats(kFALSE);
93  } else {
94  if (name.find("Summary_Mean") != std::string::npos) {
95  histo->SetStats(kFALSE);
96  } else {
97  histo->SetFillColor(1);
98  }
99  }
100  histo->Draw(dopt.c_str());
101  }
102  }
103  TText tTitle;
104  tTitle.SetTextFont(64);
105  tTitle.SetTextSizePixels(20);
106  // tTitle.DrawTextNDC(0.1, 0.92, histo->GetName());
107 
108  if (icol != 1) {
109  TText tt;
110  tt.SetTextSize(0.12);
111  tt.SetTextColor(icol);
112  tt.DrawTextNDC(0.5, 0.5, tag.c_str());
113  }
114  fillNamedImageBuffer(canvas, par.Path);
115  canvas->Clear();
116  }
117  delete canvas;
118 }

References svgfig::canvas(), SiStripHistoPlotter::PlotParameter::CHeight, SiStripHistoPlotter::PlotParameter::CWidth, fillNamedImageBuffer(), dqm::implementation::IGetter::get(), SiStripUtility::getMEStatus(), SiStripUtility::getMEStatusColor(), getProjection(), timingPdfMaker::histo, hlt_dqm_clientPB-live_cfg::me, Skims_PA_cff::name, SiStripHistoPlotter::PlotParameter::Option, SiStripHistoPlotter::PlotParameter::Path, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, MonitorElementData::TH1F, MonitorElementData::TH2F, MonitorElementData::TPROFILE, MonitorElementData::TPROFILE2D, and groupFilesInBlocks::tt.

Referenced by createPlots().

◆ plotsToMake()

bool SiStripHistoPlotter::plotsToMake ( )
inline

Definition at line 28 of file SiStripHistoPlotter.h.

28 { return !plotList_.empty(); }

References plotList_.

◆ setDrawingOption()

void SiStripHistoPlotter::setDrawingOption ( TH1 *  hist)
private

Definition at line 223 of file SiStripHistoPlotter.cc.

223  {
224  if (!hist)
225  return;
226 
227  TAxis* xa = hist->GetXaxis();
228  TAxis* ya = hist->GetYaxis();
229 
230  xa->SetTitleOffset(0.7);
231  xa->SetTitleSize(0.05);
232  xa->SetLabelSize(0.04);
233 
234  ya->SetTitleOffset(0.7);
235  ya->SetTitleSize(0.05);
236  ya->SetLabelSize(0.04);
237 }

References gpuVertexFinder::hist.

◆ setNewCondDBPlot()

void SiStripHistoPlotter::setNewCondDBPlot ( std::string const &  path,
std::string const &  option,
int  width,
int  height 
)

Definition at line 275 of file SiStripHistoPlotter.cc.

278  {
279  PlotParameter local_par{path, option, width, height};
280  condDBPlotList_.push_back(std::move(local_par));
281 }

References condDBPlotList_, eostools::move(), fileinputsource_cfi::option, castor_dqm_sourceclient_file_cfg::path, and ApeEstimator_cff::width.

◆ setNewPlot()

void SiStripHistoPlotter::setNewPlot ( std::string const &  path,
std::string const &  option,
int  width,
int  height 
)

Member Data Documentation

◆ condDBPlotList_

std::vector<PlotParameter> SiStripHistoPlotter::condDBPlotList_
private

Definition at line 51 of file SiStripHistoPlotter.h.

Referenced by condDBPlotsToMake(), createCondDBPlots(), and setNewCondDBPlot().

◆ namedPictureBuffer_

std::map<std::string, std::string> SiStripHistoPlotter::namedPictureBuffer_
private

◆ plotList_

std::vector<PlotParameter> SiStripHistoPlotter::plotList_
private

Definition at line 50 of file SiStripHistoPlotter.h.

Referenced by createPlots(), plotsToMake(), and setNewPlot().

svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
mps_fire.i
i
Definition: mps_fire.py:428
dqm::implementation::IGetter::getContents
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:593
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
MonitorElementData::Kind::TH1F
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiStripHistoPlotter::hasNamedImage
bool hasNamedImage(const std::string &name)
Definition: SiStripHistoPlotter.cc:189
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
fileinputsource_cfi.option
option
Definition: fileinputsource_cfi.py:94
SiStripHistoPlotter::namedPictureBuffer_
std::map< std::string, std::string > namedPictureBuffer_
Definition: SiStripHistoPlotter.h:49
SiStripHistoPlotter::condDBPlotList_
std::vector< PlotParameter > condDBPlotList_
Definition: SiStripHistoPlotter.h:51
MonitorElementData::Kind::TH2F
edm::FileInPath
Definition: FileInPath.h:64
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripHistoPlotter::makeCondDBPlots
void makeCondDBPlots(DQMStore *dqm_store, const PlotParameter &par)
Definition: SiStripHistoPlotter.cc:300
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gpuVertexFinder::hist
__shared__ Hist hist
Definition: gpuClusterTracksDBSCAN.h:48
recoMuon::in
Definition: RecoMuonEnumerators.h:6
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
SiStripHistoPlotter::makePlot
void makePlot(DQMStore const *dqm_store, const PlotParameter &par)
Definition: SiStripHistoPlotter.cc:66
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
eostools.move
def move(src, dest)
Definition: eostools.py:511
SiStripUtility::split
static void split(std::string const &str, std::vector< std::string > &tokens, std::string const &delimiters=" ")
Definition: SiStripUtility.cc:54
SiStripHistoPlotter::getProjection
void getProjection(MonitorElement *me, TH1F *tp)
Definition: SiStripHistoPlotter.cc:240
MonitorElementData::Kind::TPROFILE2D
SiStripHistoPlotter::fillNamedImageBuffer
void fillNamedImageBuffer(TCanvas *c1, const std::string &name)
(Documentation under construction).
Definition: SiStripHistoPlotter.cc:145
SiStripHistoPlotter::plotList_
std::vector< PlotParameter > plotList_
Definition: SiStripHistoPlotter.h:50
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
SiStripUtility::getMEStatusColor
static void getMEStatusColor(int status, int &rval, int &gval, int &bval)
Definition: SiStripUtility.cc:75
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
mps_splice.line
line
Definition: mps_splice.py:76
SiStripHistoPlotter::createDummyImage
void createDummyImage(const std::string &name)
Definition: SiStripHistoPlotter.cc:199
MonitorElementData::Kind::TPROFILE
SiStripUtility::getMEStatus
static int getMEStatus(MonitorElement const *me)
Definition: SiStripUtility.cc:169
SiStripHistoPlotter::getDummyImage
void getDummyImage(std::string &image)
Definition: SiStripHistoPlotter.cc:207