From 70721cfc077c411b935b67802ec32e3ede35a9d1 Mon Sep 17 00:00:00 2001 From: Cesare Date: Sat, 4 Jan 2014 15:58:00 +0100 Subject: [PATCH] adding RMS plot --- .../ClientConfig/interface/DQMGenericClient.h | 3 ++- .../ClientConfig/interface/FitSlicesYTool.h | 4 ++++ .../ClientConfig/plugins/DQMGenericClient.cc | 19 +++++++++++++++---- .../ClientConfig/src/FitSlicesYTool.cc | 15 +++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/DQMServices/ClientConfig/interface/DQMGenericClient.h b/DQMServices/ClientConfig/interface/DQMGenericClient.h index bd154f4c821e3..b3629c1864ba6 100644 --- a/DQMServices/ClientConfig/interface/DQMGenericClient.h +++ b/DQMServices/ClientConfig/interface/DQMGenericClient.h @@ -10,6 +10,7 @@ * $Revision: 1.10 $ * * \author Junghwan Goh - SungKyunKwan University + * \modified Cesare Calabria - Università & INFN Bari */ #include "FWCore/Framework/interface/Frameworkfwd.h" @@ -78,7 +79,7 @@ class DQMGenericClient : public edm::EDAnalyzer void normalizeToEntries(const std::string& startDir, const std::string& histName, const std::string& normHistName); void makeCumulativeDist(const std::string& startDir, const std::string& cdName); - void limitedFit(MonitorElement * srcME, MonitorElement * meanME, MonitorElement * sigmaME); + void limitedFit(MonitorElement * srcME, MonitorElement * meanME, MonitorElement * sigmaME, MonitorElement * rmsME); private: unsigned int verbose_; diff --git a/DQMServices/ClientConfig/interface/FitSlicesYTool.h b/DQMServices/ClientConfig/interface/FitSlicesYTool.h index 65423f2b4662c..d5e17d2a8b003 100644 --- a/DQMServices/ClientConfig/interface/FitSlicesYTool.h +++ b/DQMServices/ClientConfig/interface/FitSlicesYTool.h @@ -7,6 +7,7 @@ * $Date: 2009/03/27 00:16:49 $ * $Revision: 1.1 $ * \author cerati + * \modified calabria */ #include @@ -29,7 +30,10 @@ class FitSlicesYTool { void getFittedMeanWithError(MonitorElement*); /// Fill the ME with the sigma value (with error) of the gaussian fit in each slice void getFittedSigmaWithError(MonitorElement*); + /// Fill the ME with the RMS value (with error) of each slice + void getRMS(MonitorElement*); private: + TH2F* h2D; TH1* h0; TH1* h1; TH1* h2; diff --git a/DQMServices/ClientConfig/plugins/DQMGenericClient.cc b/DQMServices/ClientConfig/plugins/DQMGenericClient.cc index 3b55072b47d8f..fbdb0f504a827 100644 --- a/DQMServices/ClientConfig/plugins/DQMGenericClient.cc +++ b/DQMServices/ClientConfig/plugins/DQMGenericClient.cc @@ -6,6 +6,7 @@ * $Revision: 1.35 $ * * \author Junghwan Goh - SungKyunKwan University + * \modified Cesare Calabria - Università & INFN Bari */ #include "DQMServices/ClientConfig/interface/DQMGenericClient.h" @@ -594,12 +595,14 @@ void DQMGenericClient::computeResolution(const string& startDir, const string& n float * lowedgesfloats = new float[nBin+1]; ME* meanME; ME* sigmaME; + ME* rmsME; if (hSrc->GetXaxis()->GetXbins()->GetSize()) { for (int j=0; jGetXaxis()->GetXbins()->GetAt(j); meanME = theDQM->book1D(newPrefix+"_Mean", titlePrefix+" Mean", nBin, lowedgesfloats); sigmaME = theDQM->book1D(newPrefix+"_Sigma", titlePrefix+" Sigma", nBin, lowedgesfloats); + rmsME = theDQM->book1D(newPrefix+"_RMS", titlePrefix+" RMS", nBin, lowedgesfloats); } else { @@ -608,21 +611,26 @@ void DQMGenericClient::computeResolution(const string& startDir, const string& n hSrc->GetXaxis()->GetXmax()); sigmaME = theDQM->book1D(newPrefix+"_Sigma", titlePrefix+" Sigma", nBin, hSrc->GetXaxis()->GetXmin(), - hSrc->GetXaxis()->GetXmax()); + hSrc->GetXaxis()->GetXmax()); + rmsME = theDQM->book1D(newPrefix+"_RMS", titlePrefix+" RMS", nBin, + hSrc->GetXaxis()->GetXmin(), + hSrc->GetXaxis()->GetXmax()); } - if (meanME && sigmaME) + if (meanME && sigmaME && rmsME) { meanME->setEfficiencyFlag(); sigmaME->setEfficiencyFlag(); + rmsME->setEfficiencyFlag(); if (! resLimitedFit_ ) { FitSlicesYTool fitTool(srcME); fitTool.getFittedMeanWithError(meanME); fitTool.getFittedSigmaWithError(sigmaME); //// fitTool.getFittedChisqWithError(chi2ME); // N/A + fitTool.getRMS(rmsME); } else { - limitedFit(srcME,meanME,sigmaME); + limitedFit(srcME,meanME,sigmaME,rmsME); } } delete[] lowedgesfloats; @@ -730,7 +738,7 @@ void DQMGenericClient::makeCumulativeDist(const std::string& startDir, const std return; } -void DQMGenericClient::limitedFit(MonitorElement * srcME, MonitorElement * meanME, MonitorElement * sigmaME) +void DQMGenericClient::limitedFit(MonitorElement * srcME, MonitorElement * meanME, MonitorElement * sigmaME, MonitorElement * rmsME) { TH2F * histo = srcME->getTH2F(); @@ -745,6 +753,7 @@ void DQMGenericClient::limitedFit(MonitorElement * srcME, MonitorElement * meanM TString iString(i); TH1 *histoY = histo->ProjectionY(" ", i, i); double cont = histoY->GetEntries(); + double rms = histoY->GetRMS(); if (cont >= cont_min) { float minfit = histoY->GetMean() - histoY->GetRMS(); @@ -770,6 +779,8 @@ void DQMGenericClient::limitedFit(MonitorElement * srcME, MonitorElement * meanM // sigmaME->setBinEntries(i, 1.); // sigmaME->setBinError(i,sqrt(err[2]*err[2]+par[2]*par[2])); + rmsME->setBinContent(i, rms); + if(fitFcn) delete fitFcn; if(histoY) delete histoY; } diff --git a/DQMServices/ClientConfig/src/FitSlicesYTool.cc b/DQMServices/ClientConfig/src/FitSlicesYTool.cc index 3469bf82f248e..f1bd08fc54785 100644 --- a/DQMServices/ClientConfig/src/FitSlicesYTool.cc +++ b/DQMServices/ClientConfig/src/FitSlicesYTool.cc @@ -13,6 +13,7 @@ FitSlicesYTool::FitSlicesYTool(MonitorElement* me) TH2F * h = me->getTH2F(); h->FitSlicesY(); string name(h->GetName()); + h2D = (TH2F*)h->Clone(); h0 = (TH1*)gDirectory->Get((name+"_0").c_str()); h1 = (TH1*)gDirectory->Get((name+"_1").c_str()); h2 = (TH1*)gDirectory->Get((name+"_2").c_str()); @@ -29,6 +30,7 @@ FitSlicesYTool::FitSlicesYTool(MonitorElement* me) // h3 = (TH1*)gDirectory->Get((name+"_chi2").c_str()); // } FitSlicesYTool::~FitSlicesYTool(){ + delete h2D; delete h0; delete h1; delete h2; @@ -80,3 +82,16 @@ void FitSlicesYTool::getFittedSigmaWithError(MonitorElement * me){ throw cms::Exception("FitSlicesYTool") << "Different number of bins!"; } } +void FitSlicesYTool::getRMS(MonitorElement * me){ + if (!(h2D&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h2D=" << h2D << " me=" << me; + if (h2D->GetNbinsX()==me->getNbinsX()){ + for (int bin=1;bin!=h2D->GetNbinsX();bin++){ + TH1D * tmp = h2D->ProjectionY(" ", bin, bin); + double rms = tmp->GetRMS(); + tmp->Delete(); + me->setBinContent(bin,rms); + } + } else { + throw cms::Exception("FitSlicesYTool") << "Different number of bins!"; + } +}