test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FitSlicesYTool.cc
Go to the documentation of this file.
4 #include "TDirectory.h"
5 
6 using namespace std;
7 
9 {
10  const bool oldAddDir = TH1::AddDirectoryStatus();
11  TH1::AddDirectory(true);
12  // ... create your hists
13  TH2F * h = me->getTH2F();
14  h->FitSlicesY();
15  string name(h->GetName());
16  h0 = (TH1*)gDirectory->Get((name+"_0").c_str());
17  h1 = (TH1*)gDirectory->Get((name+"_1").c_str());
18  h2 = (TH1*)gDirectory->Get((name+"_2").c_str());
19  h3 = (TH1*)gDirectory->Get((name+"_chi2").c_str());
20  TH1::AddDirectory(oldAddDir);
21 }
22 
23 // FitSlicesYTool::FitSlicesYTool(TH2F* h){
24 // h->FitSlicesY();
25 // string name(h->GetName());
26 // h0 = (TH1*)gDirectory->Get((name+"_0").c_str());
27 // h1 = (TH1*)gDirectory->Get((name+"_1").c_str());
28 // h2 = (TH1*)gDirectory->Get((name+"_2").c_str());
29 // h3 = (TH1*)gDirectory->Get((name+"_chi2").c_str());
30 // }
32  delete h0;
33  delete h1;
34  delete h2;
35  delete h3;
36 }
38  if (!(h1&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
39  if (h1->GetNbinsX()==me->getNbinsX()){
40  for (int bin=0;bin!=h1->GetNbinsX();bin++){
41  me->setBinContent(bin+1,h1->GetBinContent(bin+1));
42 // me->setBinEntries(bin+1, 1.);
43  }
44  } else {
45  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
46  }
47 }
49  if (!(h2&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
50  if (h2->GetNbinsX()==me->getNbinsX()){
51  for (int bin=0;bin!=h2->GetNbinsX();bin++){
52  me->setBinContent(bin+1,h2->GetBinContent(bin+1));
53 // me->setBinEntries(bin+1, 1.);
54  }
55  } else {
56  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
57  }
58 }
60  if (!(h1&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
61  if (h1->GetNbinsX()==me->getNbinsX()){
62  for (int bin=0;bin!=h1->GetNbinsX();bin++){
63  me->setBinContent(bin+1,h1->GetBinContent(bin+1));
64 // me->setBinEntries(bin+1, 1.);
65  me->setBinError(bin+1,h1->GetBinError(bin+1));
66  }
67  } else {
68  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
69  }
70 }
72  if (!(h2&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
73  if (h2->GetNbinsX()==me->getNbinsX()){
74  for (int bin=0;bin!=h2->GetNbinsX();bin++){
75  me->setBinContent(bin+1,h2->GetBinContent(bin+1));
76 // me->setBinEntries(bin+1, 1.);
77  me->setBinError(bin+1,h2->GetBinError(bin+1));
78  }
79  } else {
80  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
81  }
82 }
~FitSlicesYTool()
Constructor: needs a TH2F.
void getFittedSigmaWithError(MonitorElement *)
Fill the ME with the sigma value (with error) of the gaussian fit in each slice.
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void getFittedSigma(MonitorElement *)
Fill the ME with the sigma value of the gaussian fit in each slice.
void getFittedMean(MonitorElement *)
Fill the ME with the mean value of the gaussian fit in each slice.
void getFittedMeanWithError(MonitorElement *)
Fill the ME with the mean value (with error) of the gaussian fit in each slice.
FitSlicesYTool(MonitorElement *)
TH2F * getTH2F(void) const