15 #include <TPostScript.h> 30 const double defaultMinX = -1.;
31 const double defaultMaxX = -1.;
32 const double defaultXaxisTitleOffset = 1.0;
33 const double defaultXaxisTitleSize = 0.05;
36 const double defaultMinY_linear = 0.;
37 const double defaultMinY_log = 1.e-2;
38 const double defaultMaxY_linear = -1.;
39 const double defaultMaxY_log = -1.;
43 const double defaultYaxisTitleOffset = 1.0;
44 const double defaultYaxisTitleSize = 0.05;
45 const double defaultYaxisMaximumScaleFactor_linear = 1.6;
46 const double defaultYaxisMaximumScaleFactor_log = 5.e+2;
49 const double defaultLegendPosX = 0.50;
50 const double defaultLegendPosY = 0.55;
51 const double defaultLegendSizeX = 0.39;
52 const double defaultLegendSizeY = 0.34;
55 const int defaultLegendBorderSize = 0;
56 const int defaultLegendFillColor = 0;
59 const double defaultLabelPosX = 0.66;
60 const double defaultLabelPosY = 0.82;
61 const double defaultLabelSizeX = 0.26;
62 const double defaultLabelSizeY = 0.10;
64 const int defaultLabelBorderSize = 0;
65 const int defaultLabelFillColor = 0;
66 const int defaultLabelTextColor = 1;
67 const double defaultLabelTextSize = 0.05;
68 const int defaultLabelTextAlign = 22;
69 const double defaultLabelTextAngle = 0.;
72 const int defaultMarkerColor = 1;
73 const int defaultMarkerSize = 1;
74 const int defaultMarkerStyle = 2;
75 const int defaultLineColor = 0;
76 const int defaultLineStyle = 1;
77 const int defaultLineWidth = 2;
78 const int defaultFillColor = 0;
79 const int defaultFillStyle = 1001;
86 const int defaultCanvasSizeX = 800;
87 const int defaultCanvasSizeY = 600;
95 std::map<std::string, T>&
def,
99 if (
def.find(cfgEntryName) ==
def.end()) {
100 edm::LogError(
"checkCfgDef") <<
" " << defType <<
" = " << cfgEntryName
101 <<
" undefined, needed by drawJob = " << drawJobName <<
" !!";
107 void checkCfgDefs(
const std::vector<std::string>& cfgEntryNames,
108 std::map<std::string, T>&
def,
112 for (std::vector<std::string>::const_iterator cfgEntryName = cfgEntryNames.begin();
113 cfgEntryName != cfgEntryNames.end();
115 checkCfgDef(*cfgEntryName,
def, errorFlag, defType, drawJobName);
121 std::map<std::string, T>&
def,
124 typename std::map<std::string, T>::const_iterator
it =
def.find(cfgEntryName);
125 if (
it !=
def.end()) {
126 return &(
it->second);
128 edm::LogError(
"findCfgDef") <<
" " << defType <<
" = " << cfgEntryName
129 <<
" undefined, needed by drawJob = " << drawJobName <<
" !!";
138 typedef std::pair<TH1*, std::string> histoDrawEntry;
140 void drawHistograms(
const std::list<histoDrawEntry>& histogramList,
bool& isFirstHistogram) {
141 for (std::list<histoDrawEntry>::const_iterator
it = histogramList.begin();
it != histogramList.end(); ++
it) {
144 isFirstHistogram =
false;
152 bool find_vstring(
const std::vector<std::string>& vs,
const std::string&
s) {
153 for (std::vector<std::string>::const_iterator
it = vs.begin();
it != vs.end(); ++
it) {
180 std::cout <<
"<TauDQMHistPlotter::cfgEntryProcess::print>:" << std::endl;
181 std::cout <<
" name = " << name_ << std::endl;
182 std::cout <<
" dqmDirectory = " << dqmDirectory_ << std::endl;
183 std::cout <<
" legendEntry = " << legendEntry_ << std::endl;
184 std::cout <<
" legendEntryErrorBand = " << legendEntryErrorBand_ << std::endl;
185 std::cout <<
" type = " << type_ << std::endl;
195 minX_ = (
cfg.exists(
"minX")) ?
cfg.getParameter<
double>(
"minX") : defaultMinX;
196 maxX_ = (
cfg.exists(
"maxX")) ?
cfg.getParameter<
double>(
"maxX") : defaultMaxX;
199 (
cfg.exists(
"xAxisTitleOffset")) ?
cfg.getParameter<
double>(
"xAxisTitleOffset") : defaultXaxisTitleOffset;
200 xAxisTitleSize_ = (
cfg.exists(
"xAxisTitleSize")) ?
cfg.getParameter<
double>(
"xAxisTitleSize") : defaultXaxisTitleSize;
207 std::cout <<
"<TauDQMHistPlotter::cfgEntryAxisX::print>:" << std::endl;
208 std::cout <<
" name = " << name_ << std::endl;
209 std::cout <<
" minX_ = " << minX_ << std::endl;
210 std::cout <<
" maxX_ = " << maxX_ << std::endl;
211 std::cout <<
" xAxisTitle = " << xAxisTitle_ << std::endl;
212 std::cout <<
" xAxisTitleOffset = " << xAxisTitleOffset_ << std::endl;
213 std::cout <<
" xAxisTitleSize = " << xAxisTitleSize_ << std::endl;
218 double xMin = (minX_ != defaultMinX) ? minX_ : histogram->GetXaxis()->GetXmin();
219 double xMax = (maxX_ != defaultMaxX) ? maxX_ : histogram->GetXaxis()->GetXmax();
220 histogram->SetAxisRange(
xMin,
xMax,
"X");
221 histogram->GetXaxis()->SetTitle(xAxisTitle_.data());
222 histogram->GetXaxis()->SetTitleOffset(xAxisTitleOffset_);
223 histogram->GetXaxis()->SetTitleSize(xAxisTitleSize_);
234 minY_linear_ = (
cfg.exists(
"minY_linear")) ?
cfg.getParameter<
double>(
"minY_linear") : defaultMinY_linear;
235 minY_log_ = (
cfg.exists(
"minY_log")) ?
cfg.getParameter<
double>(
"minY_log") : defaultMinY_log;
236 maxY_linear_ = (
cfg.exists(
"maxY_linear")) ?
cfg.getParameter<
double>(
"maxY_linear") : defaultMaxY_linear;
237 maxY_log_ = (
cfg.exists(
"maxY_log")) ?
cfg.getParameter<
double>(
"maxY_log") : defaultMaxY_log;
238 yScale_ = (
cfg.exists(
"yScale")) ?
cfg.getParameter<
std::string>(
"yScale") : defaultYscale;
241 (
cfg.exists(
"yAxisTitleOffset")) ?
cfg.getParameter<
double>(
"yAxisTitleOffset") : defaultYaxisTitleOffset;
242 yAxisTitleSize_ = (
cfg.exists(
"yAxisTitleSize")) ?
cfg.getParameter<
double>(
"yAxisTitleSize") : defaultYaxisTitleSize;
249 std::cout <<
"<TauDQMHistPlotter::cfgEntryAxisY::print>:" << std::endl;
250 std::cout <<
" name = " << name_ << std::endl;
251 std::cout <<
" minY_linear = " << minY_linear_ << std::endl;
252 std::cout <<
" minY_log = " << minY_log_ << std::endl;
253 std::cout <<
" maxY_linear = " << maxY_linear_ << std::endl;
254 std::cout <<
" maxY_log = " << maxY_log_ << std::endl;
255 std::cout <<
" yScale = " << yScale_ << std::endl;
256 std::cout <<
" yAxisTitle = " << yAxisTitle_ << std::endl;
257 std::cout <<
" yAxisTitleOffset = " << yAxisTitleOffset_ << std::endl;
258 std::cout <<
" yAxisTitleSize = " << yAxisTitleSize_ << std::endl;
263 bool yLogScale = (yScale_ == yScale_log) ?
true :
false;
264 double minY = (yLogScale) ? minY_log_ : minY_linear_;
265 histogram->SetMinimum(
minY);
266 double maxY = (yLogScale) ? maxY_log_ : maxY_linear_;
267 double defaultMaxY = (yLogScale) ? defaultMaxY_log : defaultMaxY_linear;
268 if (
maxY != defaultMaxY) {
270 histogram->SetMaximum(
maxY);
275 double defaultYaxisMaximumScaleFactor =
276 (yLogScale) ? defaultYaxisMaximumScaleFactor_log : defaultYaxisMaximumScaleFactor_linear;
277 histogram->SetMaximum(defaultYaxisMaximumScaleFactor * norm);
279 histogram->GetYaxis()->SetTitle(yAxisTitle_.data());
280 histogram->GetYaxis()->SetTitleOffset(yAxisTitleOffset_);
281 histogram->GetYaxis()->SetTitleSize(yAxisTitleSize_);
292 posX_ = (
cfg.exists(
"posX")) ?
cfg.getParameter<
double>(
"posX") : defaultLegendPosX;
293 posY_ = (
cfg.exists(
"posY")) ?
cfg.getParameter<
double>(
"posY") : defaultLegendPosY;
294 sizeX_ = (
cfg.exists(
"sizeX")) ?
cfg.getParameter<
double>(
"sizeX") : defaultLegendSizeX;
295 sizeY_ = (
cfg.exists(
"sizeY")) ?
cfg.getParameter<
double>(
"sizeY") : defaultLegendSizeY;
296 header_ = (
cfg.exists(
"header")) ?
cfg.getParameter<
std::string>(
"header") : defaultLegendHeader;
297 option_ = (
cfg.exists(
"option")) ?
cfg.getParameter<
std::string>(
"option") : defaultLegendOptions;
298 borderSize_ = (
cfg.exists(
"borderSize")) ?
cfg.getParameter<
int>(
"borderSize") : defaultLegendBorderSize;
299 fillColor_ = (
cfg.exists(
"fillColor")) ?
cfg.getParameter<
int>(
"fillColor") : defaultLegendFillColor;
306 std::cout <<
"<TauDQMHistPlotter::cfgEntryLegend::print>:" << std::endl;
307 std::cout <<
" name = " << name_ << std::endl;
308 std::cout <<
" posX = " << posX_ << std::endl;
309 std::cout <<
" posY = " << posY_ << std::endl;
310 std::cout <<
" sizeX = " << sizeX_ << std::endl;
311 std::cout <<
" sizeY = " << sizeY_ << std::endl;
312 std::cout <<
" header = " << header_ << std::endl;
313 std::cout <<
" option = " << option_ << std::endl;
314 std::cout <<
" borderSize = " << borderSize_ << std::endl;
315 std::cout <<
" fillColor = " << fillColor_ << std::endl;
322 legend->SetX2(posX_ + sizeX_);
323 legend->SetY2(posY_ + sizeY_);
324 legend->SetHeader(header_.data());
325 legend->SetOption(option_.data());
326 legend->SetBorderSize(borderSize_);
327 legend->SetFillColor(fillColor_);
338 posX_ = (
cfg.exists(
"posX")) ?
cfg.getParameter<
double>(
"posX") : defaultLabelPosX;
339 posY_ = (
cfg.exists(
"posY")) ?
cfg.getParameter<
double>(
"posY") : defaultLabelPosY;
340 sizeX_ = (
cfg.exists(
"sizeX")) ?
cfg.getParameter<
double>(
"sizeX") : defaultLabelSizeX;
341 sizeY_ = (
cfg.exists(
"sizeY")) ?
cfg.getParameter<
double>(
"sizeY") : defaultLabelSizeY;
342 option_ = (
cfg.exists(
"option")) ?
cfg.getParameter<
std::string>(
"option") : defaultLabelOptions;
343 borderSize_ = (
cfg.exists(
"borderSize")) ?
cfg.getParameter<
int>(
"borderSize") : defaultLabelBorderSize;
344 fillColor_ = (
cfg.exists(
"fillColor")) ?
cfg.getParameter<
int>(
"fillColor") : defaultLabelFillColor;
345 textColor_ = (
cfg.exists(
"textColor")) ?
cfg.getParameter<
int>(
"textColor") : defaultLabelTextColor;
346 textSize_ = (
cfg.exists(
"textSize")) ?
cfg.getParameter<
double>(
"textSize") : defaultLabelTextSize;
347 textAlign_ = (
cfg.exists(
"textAlign")) ?
cfg.getParameter<
int>(
"textAlign") : defaultLabelTextAlign;
348 textAngle_ = (
cfg.exists(
"textAngle")) ?
cfg.getParameter<
double>(
"textAngle") : defaultLabelTextAngle;
356 std::cout <<
"<TauDQMHistPlotter::cfgEntryLabel::print>:" << std::endl;
357 std::cout <<
" name = " << name_ << std::endl;
358 std::cout <<
" posX = " << posX_ << std::endl;
359 std::cout <<
" posY = " << posY_ << std::endl;
360 std::cout <<
" sizeX = " << sizeX_ << std::endl;
361 std::cout <<
" sizeY = " << sizeY_ << std::endl;
362 std::cout <<
" option = " << option_ << std::endl;
363 std::cout <<
" borderSize = " << borderSize_ << std::endl;
364 std::cout <<
" fillColor = " << fillColor_ << std::endl;
365 std::cout <<
" textColor = " << textColor_ << std::endl;
366 std::cout <<
" textSize = " << textSize_ << std::endl;
367 std::cout <<
" textAlign = " << textAlign_ << std::endl;
368 std::cout <<
" textAngle = " << textAngle_ << std::endl;
378 label->SetX1NDC(posX_);
379 label->SetY1NDC(posY_);
380 label->SetX2NDC(posX_ + sizeX_);
381 label->SetY2NDC(posY_ + sizeY_);
382 label->SetOption(option_.data());
383 label->SetBorderSize(borderSize_);
384 label->SetFillColor(fillColor_);
385 label->SetTextColor(textColor_);
386 label->SetTextSize(textSize_);
387 label->SetTextAlign(textAlign_);
388 label->SetTextAngle(textAngle_);
389 for (vstring::const_iterator
line = text_.begin();
line != text_.end(); ++
line) {
402 markerColor_ = (
cfg.exists(
"markerColor")) ?
cfg.getParameter<
int>(
"markerColor") : defaultMarkerColor;
403 markerSize_ = (
cfg.exists(
"markerSize")) ?
cfg.getParameter<
double>(
"markerSize") : defaultMarkerSize;
404 markerStyle_ = (
cfg.exists(
"markerStyle")) ?
cfg.getParameter<
int>(
"markerStyle") : defaultMarkerStyle;
406 lineColor_ = (
cfg.exists(
"lineColor")) ?
cfg.getParameter<
int>(
"lineColor") : defaultLineColor;
407 lineStyle_ = (
cfg.exists(
"lineStyle")) ?
cfg.getParameter<
int>(
"lineStyle") : defaultLineStyle;
408 lineWidth_ = (
cfg.exists(
"lineWidth")) ?
cfg.getParameter<
int>(
"lineWidth") : defaultLineWidth;
410 fillColor_ = (
cfg.exists(
"fillColor")) ?
cfg.getParameter<
int>(
"fillColor") : defaultFillColor;
411 fillStyle_ = (
cfg.exists(
"fillStyle")) ?
cfg.getParameter<
int>(
"fillStyle") : defaultFillStyle;
413 drawOption_ = (
cfg.exists(
"drawOption")) ?
cfg.getParameter<
std::string>(
"drawOption") : defaultDrawOption;
415 (
cfg.exists(
"drawOptionLegend")) ?
cfg.getParameter<
std::string>(
"drawOptionLegend") : defaultDrawOptionLegend;
423 markerColor_(blueprint.markerColor_),
424 markerSize_(blueprint.markerSize_),
425 markerStyle_(blueprint.markerStyle_),
426 lineColor_(blueprint.lineColor_),
427 lineStyle_(blueprint.lineStyle_),
428 lineWidth_(blueprint.lineWidth_),
429 fillColor_(blueprint.fillColor_),
430 fillStyle_(blueprint.fillStyle_),
431 drawOption_(blueprint.drawOption_),
432 drawOptionLegend_(blueprint.drawOptionLegend_) {
438 std::cout <<
"<TauDQMHistPlotter::cfgEntryDrawOption::print>:" << std::endl;
439 std::cout <<
" name = " << name_ << std::endl;
440 std::cout <<
" markerColor = " << markerColor_ << std::endl;
441 std::cout <<
" markerSize = " << markerSize_ << std::endl;
442 std::cout <<
" markerStyle = " << markerStyle_ << std::endl;
443 std::cout <<
" lineColor = " << lineColor_ << std::endl;
444 std::cout <<
" lineStyle = " << lineStyle_ << std::endl;
445 std::cout <<
" lineWidth = " << lineWidth_ << std::endl;
446 std::cout <<
" fillColor = " << fillColor_ << std::endl;
447 std::cout <<
" fillStyle = " << fillStyle_ << std::endl;
448 std::cout <<
" drawOption = " << drawOption_ << std::endl;
449 std::cout <<
" drawOptionLegend = " << drawOptionLegend_ << std::endl;
454 histogram->SetMarkerColor(markerColor_);
455 histogram->SetMarkerSize(markerSize_);
456 histogram->SetMarkerStyle(markerStyle_);
457 histogram->SetLineColor(lineColor_);
458 histogram->SetLineStyle(lineStyle_);
459 histogram->SetLineWidth(lineWidth_);
460 histogram->SetFillColor(fillColor_);
461 histogram->SetFillStyle(fillStyle_);
475 : dqmMonitorElement_(dqmMonitorElement),
476 drawOptionEntry_(drawOptionEntry),
478 legendEntryErrorBand_(legendEntryErrorBand),
481 isErrorBand_(
false) {
486 : dqmMonitorElement_(blueprint.dqmMonitorElement_),
487 drawOptionEntry_(blueprint.drawOptionEntry_),
488 legendEntry_(blueprint.legendEntry_),
489 legendEntryErrorBand_(blueprint.legendEntryErrorBand_),
490 process_(blueprint.process_),
491 doStack_(blueprint.doStack_),
492 isErrorBand_(
false) {
497 std::cout <<
"<TauDQMHistPlotter::plotDefEntry::print>:" << std::endl;
498 std::cout <<
" dqmMonitorElement = " << dqmMonitorElement_ << std::endl;
499 std::cout <<
" drawOptionEntry = " << drawOptionEntry_ << std::endl;
500 std::cout <<
" legendEntry = " << legendEntry_ << std::endl;
501 std::cout <<
" legendEntryErrorBand = " << legendEntryErrorBand_ << std::endl;
502 std::cout <<
" process = " << process_ << std::endl;
503 std::cout <<
" doStack = " << doStack_ << std::endl;
539 std::cout <<
"<TauDQMHistPlotter::cfgSetDrawJob::print>:" << std::endl;
540 std::cout <<
" name = " << name_ << std::endl;
542 for (plotDefList::const_iterator
plot = plots_.begin();
plot != plots_.end(); ++
plot) {
546 std::cout <<
" title = " << title_ << std::endl;
547 std::cout <<
" xAxis = " << xAxis_ << std::endl;
548 std::cout <<
" yAxis = " << yAxis_ << std::endl;
549 std::cout <<
" legend = " << legend_ << std::endl;
558 usesResource(
"DQMStore");
560 std::cout <<
"<TauDQMHistPlotter::TauDQMHistPlotter>:" << std::endl;
562 toFile_ =
cfg.getParameter<
bool>(
"PrintToFile");
568 readCfgParameter<cfgEntryProcess>(cfgParSet_processes,
processes_);
573 int numProcesses_Data = 0;
574 int numProcesses_sumMC = 0;
579 if (!((
type == type_smMC) || (
type == type_bsmMC) || (
type == type_smSumMC) || (
type == type_Data))) {
580 edm::LogError(
"TauDQMHistPlotter") <<
" Undefined process type = " <<
type <<
" !!";
584 if (
type == type_smSumMC)
585 ++numProcesses_sumMC;
586 if (
type == type_Data)
590 if ((numProcesses_Data > 1) || (numProcesses_sumMC > 1)) {
591 edm::LogError(
"TauDQMHistPlotter") <<
" Cannot have more than one process of types sumMC and Data !!";
598 readCfgParameter<cfgEntryAxisX>(cfgParSet_xAxes,
xAxes_);
603 readCfgParameter<cfgEntryAxisY>(cfgParSet_yAxes,
yAxes_);
608 readCfgParameter<cfgEntryLegend>(cfgParSet_legends,
legends_);
613 readCfgParameter<cfgEntryLabel>(cfgParSet_labels,
labels_);
617 if (
cfg.exists(
"drawOptionSets")) {
620 for (vstring::const_iterator drawOptionSetName = drawOptionSetNames.begin();
621 drawOptionSetName != drawOptionSetNames.end();
622 ++drawOptionSetName) {
626 for (vstring::const_iterator drawOptionEntryName = drawOptionEntryNames.begin();
627 drawOptionEntryName != drawOptionEntryNames.end();
628 ++drawOptionEntryName) {
632 std::string(*drawOptionSetName).append(drawOptionSeparator).append(*drawOptionEntryName);
634 drawOptionEntryName_full,
cfgEntryDrawOption(drawOptionEntryName_full, drawOptionEntry)));
639 if (
cfg.exists(
"drawOptionEntries")) {
641 readCfgParameter<cfgEntryDrawOption>(cfgParSet_drawOptionEntries,
drawOptionEntries_);
648 for (vstring::const_iterator drawJobName = drawJobNames.begin(); drawJobName != drawJobNames.end(); ++drawJobName) {
651 std::map<int, plotDefList> plotDefMap;
666 for (vstring::const_iterator dqmMonitorElement = dqmMonitorElements.begin();
667 dqmMonitorElement != dqmMonitorElements.end();
668 ++dqmMonitorElement) {
669 bool stack_dqmMonitorElement = find_vstring(
stack, *
process);
671 plotDefMap[
index].push_back(
672 plotDefEntry(*dqmMonitorElement, drawOptionEntry,
"",
"", *
process, stack_dqmMonitorElement));
677 typedef std::vector<edm::ParameterSet> vParameterSet;
693 if (
plot->exists(
"legendEntry")) {
695 legendEntryErrorBand = (
plot->exists(
"legendEntryErrorBand"))
704 for (vstring::const_iterator dqmMonitorElement = dqmMonitorElements.begin();
705 dqmMonitorElement != dqmMonitorElements.end();
706 ++dqmMonitorElement) {
707 plotDefMap[
index].push_back(
715 unsigned numMonitorElements_ref = 0;
716 bool isFirstEntry =
true;
717 for (std::map<int, plotDefList>::const_iterator
plot = plotDefMap.begin();
plot != plotDefMap.end(); ++
plot) {
719 numMonitorElements_ref =
plot->second.size();
720 isFirstEntry =
false;
722 if (
plot->second.size() != numMonitorElements_ref) {
724 <<
" Numbers of dqmMonitorElements must be the same for all plots" 725 <<
" --> skipping drawJob = " << (*drawJobName) <<
" !!";
732 for (std::map<int, plotDefList>::iterator
plot = plotDefMap.begin();
plot != plotDefMap.end(); ++
plot) {
749 entry->dqmMonitorElement_ = dqmMonitorElement_expanded;
754 edm::LogError(
"TauDQMHistPlotter::TauDQMHistPlotter") <<
" Undefined process = " <<
process <<
" !!";
771 for (std::map<int, plotDefList>::iterator
plot = plotDefMap.begin();
plot != plotDefMap.end(); ++
plot) {
772 if (drawJob.
exists(
"parameter")) {
787 plot_expanded.push_back(
plotDefEntry(dqmMonitorElement_expanded,
788 entry->drawOptionEntry_,
790 entry->legendEntryErrorBand_,
823 for (std::list<cfgEntryDrawJob>::const_iterator drawJob =
drawJobs_.begin(); drawJob !=
drawJobs_.end(); ++drawJob) {
824 for (plotDefList::const_iterator
plot = drawJob->plots_.begin();
plot != drawJob->plots_.end(); ++
plot) {
825 checkCfgDef<cfgEntryDrawOption>(
830 checkCfgDef<cfgEntryAxisX>(drawJob->xAxis_,
xAxes_,
cfgError_,
"xAxis", drawJob->name_);
831 checkCfgDef<cfgEntryAxisY>(drawJob->yAxis_,
yAxes_,
cfgError_,
"yAxis", drawJob->name_);
833 checkCfgDef<cfgEntryLegend>(drawJob->legend_,
legends_,
cfgError_,
"legend", drawJob->name_);
835 checkCfgDefs<cfgEntryLabel>(drawJob->labels_,
labels_,
cfgError_,
"label", drawJob->name_);
840 canvasSizeX_ = (
cfg.exists(
"canvasSizeX")) ?
cfg.getParameter<
int>(
"canvasSizeX") : defaultCanvasSizeX;
841 canvasSizeY_ = (
cfg.exists(
"canvasSizeY")) ?
cfg.getParameter<
int>(
"canvasSizeY") : defaultCanvasSizeY;
858 edm::LogError(
"TauDQMHistPlotter") <<
" Failed to determine type of graphics format from indOutputFileName = " 870 edm::LogError(
"TauDQMHistPlotter") <<
" Either outputFileName or indOutputFileName must be specified !!";
875 edm::LogError(
"TauDQMHistPlotter") <<
" Must not specify outputFileName and indOutputFileName simultaneously !!";
893 std::cout <<
"<TauDQMHistPlotter::endJob>:" << std::endl;
897 edm::LogError(
"endJob") <<
" Error in Configuration ParameterSet --> histograms will NOT be plotted !!";
903 edm::LogError(
"endJob") <<
" Failed to access dqmStore --> histograms will NOT be plotted !!";
914 gROOT->SetBatch(
true);
929 TPostScript* ps =
nullptr;
937 for (std::list<cfgEntryDrawJob>::const_iterator drawJob =
drawJobs_.begin(); drawJob !=
drawJobs_.end(); ++drawJob) {
940 std::cout <<
"--> processing drawJob " << drawJobName <<
"..." << std::endl;
943 TH1* stackedHistogram_sum =
nullptr;
944 std::list<TH1*> histogramsToDelete;
945 std::list<plotDefEntry*> drawOptionsToDelete;
947 typedef std::pair<TH1*, const plotDefEntry*> histogram_drawOption_pair;
948 std::list<histogram_drawOption_pair> allHistograms;
950 for (plotDefList::const_iterator
plot = drawJob->plots_.begin();
plot != drawJob->plots_.end(); ++
plot) {
954 std::cout <<
" dqmMonitorElementName_full = " << dqmMonitorElementName_full << std::endl;
957 TH1* histogram = dqmMonitorElement->
getTH1F();
959 std::cout <<
"Got Histogram " << std::endl;
963 if (histogram ==
nullptr) {
964 edm::LogError(
"endJob") <<
" Failed to access dqmMonitorElement = " << dqmMonitorElementName_full <<
"," 965 <<
" needed by drawJob = " << drawJobName <<
" --> histograms will NOT be plotted !!";
969 if (!histogram->GetSumw2N())
973 findCfgDef<cfgEntryDrawOption>(
plot->drawOptionEntry_,
drawOptionEntries_,
"drawOptionEntry", drawJobName);
974 if (drawOptionConfig ==
nullptr) {
975 edm::LogError(
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
976 <<
" --> histograms will NOT be plotted !!";
980 if (drawOptionConfig->
drawOption_ == drawOption_eBand) {
982 TH1* histogram_centralValue =
dynamic_cast<TH1*
>(histogram->Clone());
983 histogram_centralValue->SetName(
std::string(histogram->GetName()).
append(
"_centralValue").data());
987 drawOptionConfig_centralValue.
drawOption_ =
"hist";
994 drawOptionName_centralValue,
998 allHistograms.push_back(histogram_drawOption_pair(histogram_centralValue, plot_centralValue));
999 histogramsToDelete.push_back(histogram_centralValue);
1000 drawOptionsToDelete.push_back(plot_centralValue);
1003 TH1* histogram_ErrorBand =
dynamic_cast<TH1*
>(histogram->Clone());
1004 histogram_ErrorBand->SetName(
std::string(histogram->GetName()).
append(
"_ErrorBand").data());
1017 drawOptionName_ErrorBand,
cfgEntryDrawOption(drawOptionName_ErrorBand, drawOptionConfig_ErrorBand)));
1021 allHistograms.push_back(histogram_drawOption_pair(histogram_ErrorBand, plot_ErrorBand));
1022 histogramsToDelete.push_back(histogram_ErrorBand);
1023 drawOptionsToDelete.push_back(plot_ErrorBand);
1024 }
else if (
plot->doStack_) {
1025 TH1* stackedHistogram =
dynamic_cast<TH1*
>(histogram->Clone());
1026 if (stackedHistogram_sum)
1027 stackedHistogram->Add(stackedHistogram_sum);
1028 stackedHistogram_sum = stackedHistogram;
1029 histogramsToDelete.push_back(stackedHistogram);
1030 allHistograms.push_back(histogram_drawOption_pair(stackedHistogram, &(*
plot)));
1032 allHistograms.push_back(histogram_drawOption_pair(histogram, &(*
plot)));
1038 double yAxisNorm = 0.;
1039 for (std::list<histogram_drawOption_pair>::const_iterator
it = allHistograms.begin();
it != allHistograms.end();
1041 yAxisNorm =
TMath::Max(yAxisNorm,
it->first->GetMaximum());
1046 const cfgEntryAxisX* xAxisConfig = findCfgDef<cfgEntryAxisX>(drawJob->xAxis_,
xAxes_,
"xAxis", drawJobName);
1047 const cfgEntryAxisY* yAxisConfig = findCfgDef<cfgEntryAxisY>(drawJob->yAxis_,
yAxes_,
"yAxis", drawJobName);
1048 const cfgEntryLegend* legendConfig = findCfgDef<cfgEntryLegend>(drawJob->legend_,
legends_,
"legend", drawJobName);
1049 if (xAxisConfig ==
nullptr || yAxisConfig ==
nullptr || legendConfig ==
nullptr) {
1050 edm::LogError(
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
1051 <<
" --> histograms will NOT be plotted !!";
1058 TLegend
legend(defaultLegendPosX,
1060 defaultLegendPosX + defaultLegendSizeX,
1061 defaultLegendPosY + defaultLegendSizeY);
1062 legendConfig->applyTo(&
legend);
1064 std::list<histoDrawEntry> smProcessHistogramList;
1065 std::list<histoDrawEntry> bsmProcessHistogramList;
1066 std::list<histoDrawEntry> smSumHistogramList;
1067 std::list<histoDrawEntry> smSumUncertaintyHistogramList;
1068 std::list<histoDrawEntry> dataHistogramList;
1070 for (std::list<histogram_drawOption_pair>::const_iterator
it = allHistograms.begin();
it != allHistograms.end();
1072 TH1* histogram =
it->first;
1079 if (drawOptionConfig ==
nullptr || processConfig ==
nullptr) {
1080 edm::LogError(
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
1081 <<
" --> histograms will NOT be plotted !!";
1085 if (!drawJob->title_.empty())
1086 histogram->SetTitle(drawJob->title_.data());
1088 xAxisConfig->
applyTo(histogram);
1089 yAxisConfig->applyTo(histogram, yAxisNorm);
1091 bool yLogScale = (yAxisConfig->yScale_ == yScale_log) ?
true :
false;
1094 canvas.SetLogy(yLogScale);
1096 drawOptionConfig->
applyTo(histogram);
1097 histogram->SetStats(
false);
1100 smSumUncertaintyHistogramList.push_back(histoDrawEntry(histogram, drawOptionConfig->
drawOption_.data()));
1102 if (processConfig->type_ == type_smMC) {
1103 smProcessHistogramList.push_back(histoDrawEntry(histogram, drawOptionConfig->
drawOption_.data()));
1104 }
else if (processConfig->type_ == type_bsmMC) {
1105 bsmProcessHistogramList.push_back(histoDrawEntry(histogram, drawOptionConfig->
drawOption_.data()));
1106 }
else if (processConfig->type_ == type_smSumMC) {
1107 smSumHistogramList.push_back(histoDrawEntry(histogram, drawOptionConfig->
drawOption_.data()));
1108 }
else if (processConfig->type_ == type_Data) {
1109 dataHistogramList.push_back(histoDrawEntry(histogram, drawOptionConfig->
drawOption_.data()));
1116 : processConfig->legendEntryErrorBand_;
1117 legendDrawOption =
"f";
1126 std::list<TPaveText>
labels;
1127 for (vstring::const_iterator
labelName = drawJob->labels_.begin();
labelName != drawJob->labels_.end();
1144 bool isFirstHistogram =
true;
1145 drawHistograms(smSumUncertaintyHistogramList, isFirstHistogram);
1146 drawHistograms(smSumHistogramList, isFirstHistogram);
1150 for (std::list<histoDrawEntry>::reverse_iterator
it = smProcessHistogramList.rbegin();
1151 it != smProcessHistogramList.rend();
1155 isFirstHistogram =
false;
1158 drawHistograms(bsmProcessHistogramList, isFirstHistogram);
1159 drawHistograms(dataHistogramList, isFirstHistogram);
1178 : modIndOutputFileName;
1179 canvas.Print(fullFileName.data());
1189 for (std::list<TH1*>::const_iterator histogram = histogramsToDelete.begin(); histogram != histogramsToDelete.end();
1191 delete (*histogram);
1194 for (std::list<plotDefEntry*>::const_iterator
drawOption = drawOptionsToDelete.begin();
1197 delete (*drawOption);
const std::string processDirKeyword
std::string drawOptionLegend_
int def(FILE *, FILE *, int)
void applyTo(TLegend *) const
T getParameter(std::string const &) const
void applyTo(TPaveText *) const
cfgEntryLabel(const std::string &, const edm::ParameterSet &)
void endRun(const edm::Run &r, const edm::EventSetup &c) override
std::string legendEntryErrorBand_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::string replace_string(const std::string &src, const std::string &keyword, const std::string ¶meter, unsigned minReplacements, unsigned maxReplacements, int &errorFlag)
std::string dqmDirectory_
cfgEntryAxisX(const std::string &, const edm::ParameterSet &)
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
Log< level::Error, false > LogError
std::string dqmDirectoryName(const std::string &dqmRootDirectory, const std::string &dqmSubDirectory)
cfgEntryDrawOption(const std::string &, const edm::ParameterSet &)
void applyTo(TH1 *) const
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
#define DEFINE_FWK_MODULE(type)
std::map< std::string, cfgEntryLegend > legends_
~TauDQMHistPlotter() override
const std::string parKeyword
std::vector< std::string > vstring
std::string format_vstring(const std::vector< std::string > &vs)
cfgEntryProcess(const std::string &, const edm::ParameterSet &)
std::string outputFileName_
std::map< std::string, cfgEntryLabel > labels_
std::map< std::string, cfgEntryProcess > processes_
std::map< std::string, cfgEntryAxisX > xAxes_
labelName
Custom Jet reco ####.
virtual TH1F * getTH1F() const
cfgEntryAxisY(const std::string &, const edm::ParameterSet &)
std::list< plotDefEntry > plotDefList
std::string drawOptionEntry_
std::string outputFilePath_
std::map< std::string, cfgEntryDrawOption > drawOptionEntries_
const std::string plotKeyword
plotDefEntry(const std::string &, const std::string &, const std::string &, const std::string &, const std::string &, bool)
cfgEntryDrawJob(const std::string &, const plotDefList &, const std::string &, const std::string &, const std::string &, const std::string &, const vstring &)
std::list< cfgEntryDrawJob > drawJobs_
const std::string dqmRootDirectory
TauDQMHistPlotter(const edm::ParameterSet &)
std::map< std::string, cfgEntryAxisY > yAxes_
std::string indOutputFileName_
void applyTo(TH1 *, double norm) const
void applyTo(TH1 *) const
cfgEntryLegend(const std::string &, const edm::ParameterSet &)
void analyze(const edm::Event &, const edm::EventSetup &) override