892 std::cout <<
"<TauDQMHistPlotter::endJob>:" << std::endl;
896 edm::LogError (
"endJob") <<
" Error in Configuration ParameterSet --> histograms will NOT be plotted !!";
902 edm::LogError (
"endJob") <<
" Failed to access dqmStore --> histograms will NOT be plotted !!";
913 gROOT->SetBatch(
true);
928 TPostScript* ps =
NULL;
931 ps =
new TPostScript(psFileName.data(), 112);
935 for ( std::list<cfgEntryDrawJob>::const_iterator drawJob =
drawJobs_.begin();
936 drawJob !=
drawJobs_.end(); ++drawJob ) {
939 std::cout <<
"--> processing drawJob " << drawJobName <<
"..." << std::endl;
942 TH1* stackedHistogram_sum =
NULL;
943 std::list<TH1*> histogramsToDelete;
944 std::list<plotDefEntry*> drawOptionsToDelete;
946 typedef std::pair<TH1*, const plotDefEntry*> histogram_drawOption_pair;
947 std::list<histogram_drawOption_pair> allHistograms;
949 for ( plotDefList::const_iterator
plot = drawJob->plots_.begin();
950 plot != drawJob->plots_.end(); ++
plot ) {
954 std::cout <<
" dqmMonitorElementName_full = " << dqmMonitorElementName_full << std::endl;
957 TH1* histogram = dqmMonitorElement->
getTH1F();
963 if ( histogram ==
NULL ) {
964 edm::LogError (
"endJob") <<
" Failed to access dqmMonitorElement = " << dqmMonitorElementName_full <<
"," 965 <<
" needed by drawJob = " << drawJobName <<
" --> histograms will NOT be plotted !!";
969 if ( !histogram->GetSumw2N() ) histogram->Sumw2();
971 const cfgEntryDrawOption* drawOptionConfig =
972 findCfgDef<cfgEntryDrawOption>(
plot->drawOptionEntry_,
drawOptionEntries_,
"drawOptionEntry", drawJobName);
973 if ( drawOptionConfig ==
NULL ) {
974 edm::LogError (
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
975 <<
" --> histograms will NOT be plotted !!";
981 TH1* histogram_centralValue =
dynamic_cast<TH1*
>(histogram->Clone());
982 histogram_centralValue->SetName(
std::string(histogram->GetName()).
append(
"_centralValue").data());
983 cfgEntryDrawOption drawOptionConfig_centralValue(*drawOptionConfig);
984 drawOptionConfig_centralValue.fillColor_ = 0;
985 drawOptionConfig_centralValue.fillStyle_ = 0;
986 drawOptionConfig_centralValue.drawOption_ =
"hist";
987 drawOptionConfig_centralValue.drawOptionLegend_ =
"l";
993 (drawOptionName_centralValue, cfgEntryDrawOption(drawOptionName_centralValue, drawOptionConfig_centralValue)));
994 plotDefEntry* plot_centralValue =
new plotDefEntry(*
plot);
995 plot_centralValue->drawOptionEntry_ = drawOptionName_centralValue;
996 allHistograms.push_back(histogram_drawOption_pair(histogram_centralValue, plot_centralValue));
997 histogramsToDelete.push_back(histogram_centralValue);
998 drawOptionsToDelete.push_back(plot_centralValue);
1001 TH1* histogram_ErrorBand =
dynamic_cast<TH1*
>(histogram->Clone());
1002 histogram_ErrorBand->SetName(
std::string(histogram->GetName()).
append(
"_ErrorBand").data());
1003 cfgEntryDrawOption drawOptionConfig_ErrorBand(*drawOptionConfig);
1004 drawOptionConfig_ErrorBand.markerColor_ = drawOptionConfig_ErrorBand.fillColor_;
1005 drawOptionConfig_ErrorBand.markerSize_ = 0.;
1006 drawOptionConfig_ErrorBand.lineColor_ = drawOptionConfig_ErrorBand.fillColor_;
1007 drawOptionConfig_ErrorBand.lineWidth_ = 0;
1008 drawOptionConfig_ErrorBand.drawOption_ =
"e2";
1009 drawOptionConfig_ErrorBand.drawOptionLegend_ =
"f";
1015 (drawOptionName_ErrorBand, cfgEntryDrawOption(drawOptionName_ErrorBand, drawOptionConfig_ErrorBand)));
1016 plotDefEntry* plot_ErrorBand =
new plotDefEntry(*
plot);
1017 plot_ErrorBand->drawOptionEntry_ = drawOptionName_ErrorBand;
1018 plot_ErrorBand->isErrorBand_ =
true;
1019 allHistograms.push_back(histogram_drawOption_pair(histogram_ErrorBand, plot_ErrorBand));
1020 histogramsToDelete.push_back(histogram_ErrorBand);
1021 drawOptionsToDelete.push_back(plot_ErrorBand);
1022 }
else if (
plot->doStack_ ) {
1023 TH1* stackedHistogram =
dynamic_cast<TH1*
>(histogram->Clone());
1024 if ( stackedHistogram_sum ) stackedHistogram->Add(stackedHistogram_sum);
1025 stackedHistogram_sum = stackedHistogram;
1026 histogramsToDelete.push_back(stackedHistogram);
1027 allHistograms.push_back(histogram_drawOption_pair(stackedHistogram, &(*
plot)));
1029 allHistograms.push_back(histogram_drawOption_pair(histogram, &(*
plot)));
1035 double yAxisNorm = 0.;
1036 for ( std::list<histogram_drawOption_pair>::const_iterator it = allHistograms.begin();
1037 it != allHistograms.end(); ++it ) {
1038 yAxisNorm =
TMath::Max(yAxisNorm, it->first->GetMaximum());
1044 const cfgEntryAxisX* xAxisConfig = findCfgDef<cfgEntryAxisX>(drawJob->xAxis_,
xAxes_,
"xAxis", drawJobName);
1045 const cfgEntryAxisY* yAxisConfig = findCfgDef<cfgEntryAxisY>(drawJob->yAxis_,
yAxes_,
"yAxis", drawJobName);
1046 const cfgEntryLegend* legendConfig = findCfgDef<cfgEntryLegend>(drawJob->legend_,
legends_,
"legend", drawJobName);
1047 if ( xAxisConfig ==
NULL || yAxisConfig ==
NULL || legendConfig ==
NULL ) {
1048 edm::LogError (
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
1049 <<
" --> histograms will NOT be plotted !!";
1057 legendConfig->applyTo(&
legend);
1059 std::list<histoDrawEntry> smProcessHistogramList;
1060 std::list<histoDrawEntry> bsmProcessHistogramList;
1061 std::list<histoDrawEntry> smSumHistogramList;
1062 std::list<histoDrawEntry> smSumUncertaintyHistogramList;
1063 std::list<histoDrawEntry> dataHistogramList;
1065 for ( std::list<histogram_drawOption_pair>::const_iterator it = allHistograms.begin();
1066 it != allHistograms.end(); ++it ) {
1067 TH1* histogram = it->first;
1070 const cfgEntryDrawOption* drawOptionConfig =
1071 findCfgDef<cfgEntryDrawOption>(drawOption->drawOptionEntry_,
drawOptionEntries_,
"drawOptionEntry", drawJobName);
1072 const cfgEntryProcess* processConfig = findCfgDef<cfgEntryProcess>(drawOption->process_,
processes_,
"process", drawJobName);
1073 if ( drawOptionConfig ==
NULL || processConfig ==
NULL ) {
1074 edm::LogError (
"endJob") <<
" Failed to access information needed by drawJob = " << drawJobName
1075 <<
" --> histograms will NOT be plotted !!";
1079 if ( drawJob->title_ !=
"" ) histogram->SetTitle(drawJob->title_.data());
1081 xAxisConfig->applyTo(histogram);
1082 yAxisConfig->applyTo(histogram);
1084 bool yLogScale = ( yAxisConfig->yScale_ ==
yScale_log ) ?
true :
false;
1087 canvas.SetLogy(yLogScale);
1089 drawOptionConfig->applyTo(histogram);
1090 histogram->SetStats(
false);
1092 if ( drawOption->isErrorBand_ ) {
1093 smSumUncertaintyHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1095 if ( processConfig->type_ ==
type_smMC ) {
1096 smProcessHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1097 }
else if ( processConfig->type_ ==
type_bsmMC ) {
1098 bsmProcessHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1100 smSumHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1101 }
else if ( processConfig->type_ ==
type_Data ) {
1102 dataHistogramList.push_back(
histoDrawEntry(histogram, drawOptionConfig->drawOption_.data()));
1107 if ( drawOption->isErrorBand_ ) {
1108 legendEntry = ( drawOption->legendEntryErrorBand_ !=
"" ) ? drawOption->legendEntryErrorBand_ : processConfig->legendEntryErrorBand_;
1109 legendDrawOption =
"f";
1111 legendEntry = ( drawOption->legendEntry_ !=
"" ) ? drawOption->legendEntry_ : processConfig->legendEntry_;
1112 legendDrawOption = drawOptionConfig->drawOptionLegend_;
1115 legend.AddEntry(histogram, legendEntry.data(), legendDrawOption.data());
1118 std::list<TPaveText>
labels;
1119 for ( vstring::const_iterator labelName = drawJob->labels_.begin();
1120 labelName != drawJob->labels_.end(); ++labelName ) {
1121 const cfgEntryLabel* labelConfig = findCfgDef<cfgEntryLabel>(*labelName,
labels_,
"label", drawJobName);
1124 labelConfig->applyTo(&label);
1126 labels.push_back(label);
1136 bool isFirstHistogram =
true;
1142 for ( std::list<histoDrawEntry>::reverse_iterator it = smProcessHistogramList.rbegin();
1143 it != smProcessHistogramList.rend(); ++it ) {
1145 it->first->Draw(drawOption.data());
1146 isFirstHistogram =
false;
1154 for ( std::list<TPaveText>::iterator label = labels.begin();
1155 label != labels.end(); ++
label ) {
1170 canvas.Print(fullFileName.data());
1176 if ( ps ) ps->NewPage();
1179 for ( std::list<TH1*>::const_iterator histogram = histogramsToDelete.begin();
1180 histogram != histogramsToDelete.end(); ++histogram ) {
1181 delete (*histogram);
1184 for ( std::list<plotDefEntry*>::const_iterator drawOption = drawOptionsToDelete.begin();
1185 drawOption != drawOptionsToDelete.end(); ++
drawOption ) {
1186 delete (*drawOption);
1194 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