896 std::cout <<
"<TauDQMHistPlotter::endJob>:" << std::endl;
900 edm::LogError (
"endJob") <<
" Error in Configuration ParameterSet --> histograms will NOT be plotted !!";
906 edm::LogError (
"endJob") <<
" Failed to access dqmStore --> histograms will NOT be plotted !!";
917 gROOT->SetBatch(
true);
932 TPostScript* ps =
NULL;
935 ps =
new TPostScript(psFileName.data(), 112);
939 for ( std::list<cfgEntryDrawJob>::const_iterator drawJob =
drawJobs_.begin();
940 drawJob !=
drawJobs_.end(); ++drawJob ) {
943 std::cout <<
"--> processing drawJob " << drawJobName <<
"..." << std::endl;
946 TH1* stackedHistogram_sum =
NULL;
947 std::list<TH1*> histogramsToDelete;
948 std::list<plotDefEntry*> drawOptionsToDelete;
950 typedef std::pair<TH1*, const plotDefEntry*> histogram_drawOption_pair;
951 std::list<histogram_drawOption_pair> allHistograms;
953 for ( plotDefList::const_iterator
plot = drawJob->plots_.begin();
954 plot != drawJob->plots_.end(); ++
plot ) {
958 std::cout <<
" dqmMonitorElementName_full = " << dqmMonitorElementName_full << std::endl;
961 TH1* histogram = dqmMonitorElement->
getTH1F();
967 if ( histogram ==
NULL ) {
968 edm::LogError (
"endJob") <<
" Failed to access dqmMonitorElement = " << dqmMonitorElementName_full <<
","
969 <<
" needed by drawJob = " << drawJobName <<
" --> histograms will NOT be plotted !!";
973 if ( !histogram->GetSumw2N() ) histogram->Sumw2();
975 const cfgEntryDrawOption* drawOptionConfig =
976 findCfgDef<cfgEntryDrawOption>(
plot->drawOptionEntry_,
drawOptionEntries_,
"drawOptionEntry", drawJobName);
977 if ( drawOptionConfig ==
NULL ) {
978 edm::LogError (
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
979 <<
" --> histograms will NOT be plotted !!";
985 TH1* histogram_centralValue =
dynamic_cast<TH1*
>(histogram->Clone());
986 histogram_centralValue->SetName(
std::string(histogram->GetName()).
append(
"_centralValue").data());
987 cfgEntryDrawOption drawOptionConfig_centralValue(*drawOptionConfig);
988 drawOptionConfig_centralValue.fillColor_ = 0;
989 drawOptionConfig_centralValue.fillStyle_ = 0;
990 drawOptionConfig_centralValue.drawOption_ =
"hist";
991 drawOptionConfig_centralValue.drawOptionLegend_ =
"l";
997 (drawOptionName_centralValue, cfgEntryDrawOption(drawOptionName_centralValue, drawOptionConfig_centralValue)));
998 plotDefEntry* plot_centralValue =
new plotDefEntry(*
plot);
999 plot_centralValue->drawOptionEntry_ = drawOptionName_centralValue;
1000 allHistograms.push_back(histogram_drawOption_pair(histogram_centralValue, plot_centralValue));
1001 histogramsToDelete.push_back(histogram_centralValue);
1002 drawOptionsToDelete.push_back(plot_centralValue);
1005 TH1* histogram_ErrorBand =
dynamic_cast<TH1*
>(histogram->Clone());
1006 histogram_ErrorBand->SetName(
std::string(histogram->GetName()).
append(
"_ErrorBand").data());
1007 cfgEntryDrawOption drawOptionConfig_ErrorBand(*drawOptionConfig);
1008 drawOptionConfig_ErrorBand.markerColor_ = drawOptionConfig_ErrorBand.fillColor_;
1009 drawOptionConfig_ErrorBand.markerSize_ = 0.;
1010 drawOptionConfig_ErrorBand.lineColor_ = drawOptionConfig_ErrorBand.fillColor_;
1011 drawOptionConfig_ErrorBand.lineWidth_ = 0;
1012 drawOptionConfig_ErrorBand.drawOption_ =
"e2";
1013 drawOptionConfig_ErrorBand.drawOptionLegend_ =
"f";
1019 (drawOptionName_ErrorBand, cfgEntryDrawOption(drawOptionName_ErrorBand, drawOptionConfig_ErrorBand)));
1020 plotDefEntry* plot_ErrorBand =
new plotDefEntry(*
plot);
1021 plot_ErrorBand->drawOptionEntry_ = drawOptionName_ErrorBand;
1022 plot_ErrorBand->isErrorBand_ =
true;
1023 allHistograms.push_back(histogram_drawOption_pair(histogram_ErrorBand, plot_ErrorBand));
1024 histogramsToDelete.push_back(histogram_ErrorBand);
1025 drawOptionsToDelete.push_back(plot_ErrorBand);
1026 }
else if (
plot->doStack_ ) {
1027 TH1* stackedHistogram =
dynamic_cast<TH1*
>(histogram->Clone());
1028 if ( stackedHistogram_sum ) stackedHistogram->Add(stackedHistogram_sum);
1029 stackedHistogram_sum = stackedHistogram;
1030 histogramsToDelete.push_back(stackedHistogram);
1031 allHistograms.push_back(histogram_drawOption_pair(stackedHistogram, &(*
plot)));
1033 allHistograms.push_back(histogram_drawOption_pair(histogram, &(*
plot)));
1039 double yAxisNorm = 0.;
1040 for ( std::list<histogram_drawOption_pair>::const_iterator it = allHistograms.begin();
1041 it != allHistograms.end(); ++it ) {
1042 yAxisNorm =
TMath::Max(yAxisNorm, it->first->GetMaximum());
1048 const cfgEntryAxisX* xAxisConfig = findCfgDef<cfgEntryAxisX>(drawJob->xAxis_,
xAxes_,
"xAxis", drawJobName);
1049 const cfgEntryAxisY* yAxisConfig = findCfgDef<cfgEntryAxisY>(drawJob->yAxis_,
yAxes_,
"yAxis", drawJobName);
1050 const cfgEntryLegend* legendConfig = findCfgDef<cfgEntryLegend>(drawJob->legend_,
legends_,
"legend", drawJobName);
1051 if ( xAxisConfig ==
NULL || yAxisConfig ==
NULL || legendConfig ==
NULL ) {
1052 edm::LogError (
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
1053 <<
" --> histograms will NOT be plotted !!";
1061 legendConfig->applyTo(&legend);
1063 std::list<histoDrawEntry> smProcessHistogramList;
1064 std::list<histoDrawEntry> bsmProcessHistogramList;
1065 std::list<histoDrawEntry> smSumHistogramList;
1066 std::list<histoDrawEntry> smSumUncertaintyHistogramList;
1067 std::list<histoDrawEntry> dataHistogramList;
1069 for ( std::list<histogram_drawOption_pair>::const_iterator it = allHistograms.begin();
1070 it != allHistograms.end(); ++it ) {
1071 TH1* histogram = it->first;
1074 const cfgEntryDrawOption* drawOptionConfig =
1075 findCfgDef<cfgEntryDrawOption>(drawOption->drawOptionEntry_,
drawOptionEntries_,
"drawOptionEntry", drawJobName);
1076 const cfgEntryProcess* processConfig = findCfgDef<cfgEntryProcess>(drawOption->process_,
processes_,
"process", drawJobName);
1077 if ( drawOptionConfig ==
NULL || processConfig ==
NULL ) {
1078 edm::LogError (
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
1079 <<
" --> histograms will NOT be plotted !!";
1083 if ( drawJob->title_ !=
"" ) histogram->SetTitle(drawJob->title_.data());
1085 xAxisConfig->applyTo(histogram);
1086 yAxisConfig->applyTo(histogram);
1088 bool yLogScale = ( yAxisConfig->yScale_ ==
yScale_log ) ?
true :
false;
1091 canvas.SetLogy(yLogScale);
1093 drawOptionConfig->applyTo(histogram);
1094 histogram->SetStats(
false);
1096 if ( drawOption->isErrorBand_ ) {
1097 smSumUncertaintyHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1099 if ( processConfig->type_ ==
type_smMC ) {
1100 smProcessHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1101 }
else if ( processConfig->type_ ==
type_bsmMC ) {
1102 bsmProcessHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1104 smSumHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1105 }
else if ( processConfig->type_ ==
type_Data ) {
1106 dataHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1111 if ( drawOption->isErrorBand_ ) {
1112 legendEntry = ( drawOption->legendEntryErrorBand_ !=
"" ) ? drawOption->legendEntryErrorBand_ : processConfig->legendEntryErrorBand_;
1113 legendDrawOption =
"f";
1115 legendEntry = ( drawOption->legendEntry_ !=
"" ) ? drawOption->legendEntry_ : processConfig->legendEntry_;
1116 legendDrawOption = drawOptionConfig->drawOptionLegend_;
1119 legend.AddEntry(histogram, legendEntry.data(), legendDrawOption.data());
1122 std::list<TPaveText>
labels;
1123 for ( vstring::const_iterator labelName = drawJob->labels_.begin();
1124 labelName != drawJob->labels_.end(); ++labelName ) {
1125 const cfgEntryLabel* labelConfig = findCfgDef<cfgEntryLabel>(*labelName,
labels_,
"label", drawJobName);
1128 labelConfig->applyTo(&label);
1130 labels.push_back(label);
1140 bool isFirstHistogram =
true;
1146 for ( std::list<histoDrawEntry>::reverse_iterator it = smProcessHistogramList.rbegin();
1147 it != smProcessHistogramList.rend(); ++it ) {
1149 it->first->Draw(drawOption.data());
1150 isFirstHistogram =
false;
1158 for ( std::list<TPaveText>::iterator label = labels.begin();
1159 label != labels.end(); ++
label ) {
1174 canvas.Print(fullFileName.data());
1180 if ( ps ) ps->NewPage();
1183 for ( std::list<TH1*>::const_iterator histogram = histogramsToDelete.begin();
1184 histogram != histogramsToDelete.end(); ++histogram ) {
1185 delete (*histogram);
1188 for ( std::list<plotDefEntry*>::const_iterator drawOption = drawOptionsToDelete.begin();
1189 drawOption != drawOptionsToDelete.end(); ++
drawOption ) {
1190 delete (*drawOption);
1198 if ( ps ) ps->Close();
const std::string type_Data
static void setNorm(double yAxisNorm)
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