890 std::cout <<
"<TauDQMHistPlotter::endJob>:" << std::endl;
894 edm::LogError (
"endJob") <<
" Error in Configuration ParameterSet --> histograms will NOT be plotted !!";
900 edm::LogError (
"endJob") <<
" Failed to access dqmStore --> histograms will NOT be plotted !!";
911 gROOT->SetBatch(
true);
926 TPostScript* ps =
NULL;
929 ps =
new TPostScript(psFileName.data(), 112);
933 for ( std::list<cfgEntryDrawJob>::const_iterator drawJob =
drawJobs_.begin();
934 drawJob !=
drawJobs_.end(); ++drawJob ) {
937 std::cout <<
"--> processing drawJob " << drawJobName <<
"..." << std::endl;
940 TH1* stackedHistogram_sum =
NULL;
941 std::list<TH1*> histogramsToDelete;
942 std::list<plotDefEntry*> drawOptionsToDelete;
944 typedef std::pair<TH1*, const plotDefEntry*> histogram_drawOption_pair;
945 std::list<histogram_drawOption_pair> allHistograms;
947 for ( plotDefList::const_iterator
plot = drawJob->plots_.begin();
948 plot != drawJob->plots_.end(); ++
plot ) {
952 std::cout <<
" dqmMonitorElementName_full = " << dqmMonitorElementName_full << std::endl;
955 TH1* histogram = dqmMonitorElement->
getTH1F();
961 if ( histogram ==
NULL ) {
962 edm::LogError (
"endJob") <<
" Failed to access dqmMonitorElement = " << dqmMonitorElementName_full <<
"," 963 <<
" needed by drawJob = " << drawJobName <<
" --> histograms will NOT be plotted !!";
967 if ( !histogram->GetSumw2N() ) histogram->Sumw2();
969 const cfgEntryDrawOption* drawOptionConfig =
970 findCfgDef<cfgEntryDrawOption>(
plot->drawOptionEntry_,
drawOptionEntries_,
"drawOptionEntry", drawJobName);
971 if ( drawOptionConfig ==
NULL ) {
972 edm::LogError (
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
973 <<
" --> histograms will NOT be plotted !!";
979 TH1* histogram_centralValue =
dynamic_cast<TH1*
>(histogram->Clone());
980 histogram_centralValue->SetName(
std::string(histogram->GetName()).
append(
"_centralValue").data());
981 cfgEntryDrawOption drawOptionConfig_centralValue(*drawOptionConfig);
982 drawOptionConfig_centralValue.fillColor_ = 0;
983 drawOptionConfig_centralValue.fillStyle_ = 0;
984 drawOptionConfig_centralValue.drawOption_ =
"hist";
985 drawOptionConfig_centralValue.drawOptionLegend_ =
"l";
991 (drawOptionName_centralValue, cfgEntryDrawOption(drawOptionName_centralValue, drawOptionConfig_centralValue)));
992 plotDefEntry* plot_centralValue =
new plotDefEntry(*
plot);
993 plot_centralValue->drawOptionEntry_ = drawOptionName_centralValue;
994 allHistograms.push_back(histogram_drawOption_pair(histogram_centralValue, plot_centralValue));
995 histogramsToDelete.push_back(histogram_centralValue);
996 drawOptionsToDelete.push_back(plot_centralValue);
999 TH1* histogram_ErrorBand =
dynamic_cast<TH1*
>(histogram->Clone());
1000 histogram_ErrorBand->SetName(
std::string(histogram->GetName()).
append(
"_ErrorBand").data());
1001 cfgEntryDrawOption drawOptionConfig_ErrorBand(*drawOptionConfig);
1002 drawOptionConfig_ErrorBand.markerColor_ = drawOptionConfig_ErrorBand.fillColor_;
1003 drawOptionConfig_ErrorBand.markerSize_ = 0.;
1004 drawOptionConfig_ErrorBand.lineColor_ = drawOptionConfig_ErrorBand.fillColor_;
1005 drawOptionConfig_ErrorBand.lineWidth_ = 0;
1006 drawOptionConfig_ErrorBand.drawOption_ =
"e2";
1007 drawOptionConfig_ErrorBand.drawOptionLegend_ =
"f";
1013 (drawOptionName_ErrorBand, cfgEntryDrawOption(drawOptionName_ErrorBand, drawOptionConfig_ErrorBand)));
1014 plotDefEntry* plot_ErrorBand =
new plotDefEntry(*
plot);
1015 plot_ErrorBand->drawOptionEntry_ = drawOptionName_ErrorBand;
1016 plot_ErrorBand->isErrorBand_ =
true;
1017 allHistograms.push_back(histogram_drawOption_pair(histogram_ErrorBand, plot_ErrorBand));
1018 histogramsToDelete.push_back(histogram_ErrorBand);
1019 drawOptionsToDelete.push_back(plot_ErrorBand);
1020 }
else if (
plot->doStack_ ) {
1021 TH1* stackedHistogram =
dynamic_cast<TH1*
>(histogram->Clone());
1022 if ( stackedHistogram_sum ) stackedHistogram->Add(stackedHistogram_sum);
1023 stackedHistogram_sum = stackedHistogram;
1024 histogramsToDelete.push_back(stackedHistogram);
1025 allHistograms.push_back(histogram_drawOption_pair(stackedHistogram, &(*
plot)));
1027 allHistograms.push_back(histogram_drawOption_pair(histogram, &(*
plot)));
1033 double yAxisNorm = 0.;
1034 for ( std::list<histogram_drawOption_pair>::const_iterator it = allHistograms.begin();
1035 it != allHistograms.end(); ++it ) {
1036 yAxisNorm =
TMath::Max(yAxisNorm, it->first->GetMaximum());
1041 const cfgEntryAxisX* xAxisConfig = findCfgDef<cfgEntryAxisX>(drawJob->xAxis_,
xAxes_,
"xAxis", drawJobName);
1042 const cfgEntryAxisY* yAxisConfig = findCfgDef<cfgEntryAxisY>(drawJob->yAxis_,
yAxes_,
"yAxis", drawJobName);
1043 const cfgEntryLegend* legendConfig = findCfgDef<cfgEntryLegend>(drawJob->legend_,
legends_,
"legend", drawJobName);
1044 if ( xAxisConfig ==
NULL || yAxisConfig ==
NULL || legendConfig ==
NULL ) {
1045 edm::LogError (
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
1046 <<
" --> histograms will NOT be plotted !!";
1054 legendConfig->applyTo(&
legend);
1056 std::list<histoDrawEntry> smProcessHistogramList;
1057 std::list<histoDrawEntry> bsmProcessHistogramList;
1058 std::list<histoDrawEntry> smSumHistogramList;
1059 std::list<histoDrawEntry> smSumUncertaintyHistogramList;
1060 std::list<histoDrawEntry> dataHistogramList;
1062 for ( std::list<histogram_drawOption_pair>::const_iterator it = allHistograms.begin();
1063 it != allHistograms.end(); ++it ) {
1064 TH1* histogram = it->first;
1067 const cfgEntryDrawOption* drawOptionConfig =
1068 findCfgDef<cfgEntryDrawOption>(drawOption->drawOptionEntry_,
drawOptionEntries_,
"drawOptionEntry", drawJobName);
1069 const cfgEntryProcess* processConfig = findCfgDef<cfgEntryProcess>(drawOption->process_,
processes_,
"process", drawJobName);
1070 if ( drawOptionConfig ==
NULL || processConfig ==
NULL ) {
1071 edm::LogError (
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
1072 <<
" --> histograms will NOT be plotted !!";
1076 if ( drawJob->title_ !=
"" ) histogram->SetTitle(drawJob->title_.data());
1078 xAxisConfig->applyTo(histogram);
1079 yAxisConfig->applyTo(histogram,yAxisNorm);
1081 bool yLogScale = ( yAxisConfig->yScale_ ==
yScale_log ) ?
true :
false;
1084 canvas.SetLogy(yLogScale);
1086 drawOptionConfig->applyTo(histogram);
1087 histogram->SetStats(
false);
1089 if ( drawOption->isErrorBand_ ) {
1090 smSumUncertaintyHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1092 if ( processConfig->type_ ==
type_smMC ) {
1093 smProcessHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1094 }
else if ( processConfig->type_ ==
type_bsmMC ) {
1095 bsmProcessHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1097 smSumHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1098 }
else if ( processConfig->type_ ==
type_Data ) {
1099 dataHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1104 if ( drawOption->isErrorBand_ ) {
1105 legendEntry = ( drawOption->legendEntryErrorBand_ !=
"" ) ? drawOption->legendEntryErrorBand_ : processConfig->legendEntryErrorBand_;
1106 legendDrawOption =
"f";
1108 legendEntry = ( drawOption->legendEntry_ !=
"" ) ? drawOption->legendEntry_ : processConfig->legendEntry_;
1109 legendDrawOption = drawOptionConfig->drawOptionLegend_;
1112 legend.AddEntry(histogram, legendEntry.data(), legendDrawOption.data());
1115 std::list<TPaveText>
labels;
1116 for ( vstring::const_iterator labelName = drawJob->labels_.begin();
1117 labelName != drawJob->labels_.end(); ++labelName ) {
1118 const cfgEntryLabel* labelConfig = findCfgDef<cfgEntryLabel>(*labelName,
labels_,
"label", drawJobName);
1121 labelConfig->applyTo(&label);
1123 labels.push_back(label);
1133 bool isFirstHistogram =
true;
1139 for ( std::list<histoDrawEntry>::reverse_iterator it = smProcessHistogramList.rbegin();
1140 it != smProcessHistogramList.rend(); ++it ) {
1142 it->first->Draw(drawOption.data());
1143 isFirstHistogram =
false;
1151 for ( std::list<TPaveText>::iterator label = labels.begin();
1152 label != labels.end(); ++
label ) {
1167 canvas.Print(fullFileName.data());
1173 if ( ps ) ps->NewPage();
1176 for ( std::list<TH1*>::const_iterator histogram = histogramsToDelete.begin();
1177 histogram != histogramsToDelete.end(); ++histogram ) {
1178 delete (*histogram);
1181 for ( std::list<plotDefEntry*>::const_iterator drawOption = drawOptionsToDelete.begin();
1182 drawOption != drawOptionsToDelete.end(); ++
drawOption ) {
1183 delete (*drawOption);
1191 if ( ps ) ps->Close();
const std::string type_Data
const std::string yScale_log
std::pair< TH1 *, std::string > histoDrawEntry
std::string replace_string(const std::string &src, const std::string &keyword, const std::string ¶meter, unsigned minReplacements, unsigned maxReplacements, int &errorFlag)
std::string dqmDirectoryName(const std::string &dqmRootDirectory, const std::string &dqmSubDirectory)
const double defaultLegendSizeX
const std::string type_bsmMC
const double defaultLegendSizeY
const std::string drawOption_eBand
const std::string type_smMC
std::map< std::string, cfgEntryLegend > legends_
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
void drawHistograms(const std::list< histoDrawEntry > &histogramList, bool &isFirstHistogram)
std::string outputFileName_
std::map< std::string, cfgEntryLabel > labels_
std::map< std::string, cfgEntryProcess > processes_
std::map< std::string, cfgEntryAxisX > xAxes_
const std::string type_smSumMC
const double defaultLegendPosX
TH1F * getTH1F(void) const
std::string outputFilePath_
std::map< std::string, cfgEntryDrawOption > drawOptionEntries_
const std::string plotKeyword
std::list< cfgEntryDrawJob > drawJobs_
const std::string dqmRootDirectory
std::map< std::string, cfgEntryAxisY > yAxes_
std::string indOutputFileName_
const double defaultLegendPosY