Go to the documentation of this file.00001 #include "DQMServices/ClientConfig/interface/FitSlicesYTool.h"
00002 #include "FWCore/Utilities/interface/Exception.h"
00003 #include "DQMServices/Core/interface/MonitorElement.h"
00004 #include "TDirectory.h"
00005
00006 using namespace std;
00007
00008 FitSlicesYTool::FitSlicesYTool(MonitorElement* me)
00009 {
00010 const bool oldAddDir = TH1::AddDirectoryStatus();
00011 TH1::AddDirectory(true);
00012
00013 TH2F * h = me->getTH2F();
00014 h->FitSlicesY();
00015 string name(h->GetName());
00016 h0 = (TH1*)gDirectory->Get((name+"_0").c_str());
00017 h1 = (TH1*)gDirectory->Get((name+"_1").c_str());
00018 h2 = (TH1*)gDirectory->Get((name+"_2").c_str());
00019 h3 = (TH1*)gDirectory->Get((name+"_chi2").c_str());
00020 TH1::AddDirectory(oldAddDir);
00021 }
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 FitSlicesYTool::~FitSlicesYTool(){
00032 delete h0;
00033 delete h1;
00034 delete h2;
00035 delete h3;
00036 }
00037 void FitSlicesYTool::getFittedMean(MonitorElement * me){
00038 if (!(h1&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
00039 if (h1->GetNbinsX()==me->getNbinsX()){
00040 for (int bin=0;bin!=h1->GetNbinsX();bin++){
00041 me->setBinContent(bin+1,h1->GetBinContent(bin+1));
00042 }
00043 } else {
00044 throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
00045 }
00046 }
00047 void FitSlicesYTool::getFittedSigma(MonitorElement * me){
00048 if (!(h2&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
00049 if (h2->GetNbinsX()==me->getNbinsX()){
00050 for (int bin=0;bin!=h2->GetNbinsX();bin++){
00051 me->setBinContent(bin+1,h2->GetBinContent(bin+1));
00052 }
00053 } else {
00054 throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
00055 }
00056 }
00057 void FitSlicesYTool::getFittedMeanWithError(MonitorElement * me){
00058 if (!(h1&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
00059 if (h1->GetNbinsX()==me->getNbinsX()){
00060 for (int bin=0;bin!=h1->GetNbinsX();bin++){
00061 me->setBinContent(bin+1,h1->GetBinContent(bin+1));
00062 me->setBinError(bin+1,h1->GetBinError(bin+1));
00063 }
00064 } else {
00065 throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
00066 }
00067 }
00068 void FitSlicesYTool::getFittedSigmaWithError(MonitorElement * me){
00069 if (!(h2&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
00070 if (h2->GetNbinsX()==me->getNbinsX()){
00071 for (int bin=0;bin!=h2->GetNbinsX();bin++){
00072 me->setBinContent(bin+1,h2->GetBinContent(bin+1));
00073 me->setBinError(bin+1,h2->GetBinError(bin+1));
00074 }
00075 } else {
00076 throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
00077 }
00078 }