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  }
43  } else {
44  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
45  }
46 }
48  if (!(h2&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
49  if (h2->GetNbinsX()==me->getNbinsX()){
50  for (int bin=0;bin!=h2->GetNbinsX();bin++){
51  me->setBinContent(bin+1,h2->GetBinContent(bin+1));
52  }
53  } else {
54  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
55  }
56 }
58  if (!(h1&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
59  if (h1->GetNbinsX()==me->getNbinsX()){
60  for (int bin=0;bin!=h1->GetNbinsX();bin++){
61  me->setBinContent(bin+1,h1->GetBinContent(bin+1));
62  me->setBinError(bin+1,h1->GetBinError(bin+1));
63  }
64  } else {
65  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
66  }
67 }
69  if (!(h2&&me)) throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
70  if (h2->GetNbinsX()==me->getNbinsX()){
71  for (int bin=0;bin!=h2->GetNbinsX();bin++){
72  me->setBinContent(bin+1,h2->GetBinContent(bin+1));
73  me->setBinError(bin+1,h2->GetBinError(bin+1));
74  }
75  } else {
76  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
77  }
78 }
~FitSlicesYTool()
Constructor: needs a TH2F.
void setBinContent(int binx, double content)
set content of bin (1-D)
void getFittedSigmaWithError(MonitorElement *)
Fill the ME with the sigma value (with error) of the gaussian fit in each slice.
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4