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 }
00044 } else {
00045 throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
00046 }
00047 }
00048 void FitSlicesYTool::getFittedSigma(MonitorElement * me){
00049 if (!(h2&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
00050 if (h2->GetNbinsX()==me->getNbinsX()){
00051 for (int bin=0;bin!=h2->GetNbinsX();bin++){
00052 me->setBinContent(bin+1,h2->GetBinContent(bin+1));
00053
00054 }
00055 } else {
00056 throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
00057 }
00058 }
00059 void FitSlicesYTool::getFittedMeanWithError(MonitorElement * me){
00060 if (!(h1&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
00061 if (h1->GetNbinsX()==me->getNbinsX()){
00062 for (int bin=0;bin!=h1->GetNbinsX();bin++){
00063 me->setBinContent(bin+1,h1->GetBinContent(bin+1));
00064
00065 me->setBinError(bin+1,h1->GetBinError(bin+1));
00066 }
00067 } else {
00068 throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
00069 }
00070 }
00071 void FitSlicesYTool::getFittedSigmaWithError(MonitorElement * me){
00072 if (!(h2&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
00073 if (h2->GetNbinsX()==me->getNbinsX()){
00074 for (int bin=0;bin!=h2->GetNbinsX();bin++){
00075 me->setBinContent(bin+1,h2->GetBinContent(bin+1));
00076
00077 me->setBinError(bin+1,h2->GetBinError(bin+1));
00078 }
00079 } else {
00080 throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
00081 }
00082 }