ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/macros/Slices.h
(Generate patch)

Comparing UserCode/CmsHi/JetAnalysis/macros/Slices.h (file contents):
Revision 1.1 by yilmaz, Mon Feb 4 22:02:39 2013 UTC vs.
Revision 1.2 by yilmaz, Fri Feb 15 12:55:05 2013 UTC

# Line 1 | Line 1
1  
2  
3  
4 < void fitSlices(TH2* hCorr, TF1* func = 0){
4 > void fitSlices(TH2* hCorr, TF1* func = 0, bool variableBins = 0){
5  
6    bool useFit = func != 0;
7  
8    int nBins = hCorr->GetNbinsX();
9  
10 <  TH1D* hMean = new TH1D(Form("%s_1",hCorr->GetName()),"",nBins,hCorr->GetXaxis()->GetXmin(),hCorr->GetXaxis()->GetXmax());
11 <  TH1D* hSigma = new TH1D(Form("%s_2",hCorr->GetName()),"",nBins,hCorr->GetXaxis()->GetXmin(),hCorr->GetXaxis()->GetXmax());
10 >  TH1D* hMean;
11 >  TH1D* hSigma;
12 >
13 >  if(variableBins){
14 >    hMean = new TH1D(Form("%s_1",hCorr->GetName()),"",hCorr->GetNbinsX(),hCorr->GetXaxis()->GetXbins()->GetArray());
15 >    hSigma = new TH1D(Form("%s_2",hCorr->GetName()),"",hCorr->GetNbinsX(),hCorr->GetXaxis()->GetXbins()->GetArray());
16 >  }else{
17 >    hMean = new TH1D(Form("%s_1",hCorr->GetName()),"",nBins,hCorr->GetXaxis()->GetXmin(),hCorr->GetXaxis()->GetXmax());
18 >    hSigma = new TH1D(Form("%s_2",hCorr->GetName()),"",nBins,hCorr->GetXaxis()->GetXmin(),hCorr->GetXaxis()->GetXmax());
19 >  }
20  
21    for(int i = 1; i < nBins+1; ++i){
22      int bin = nBins - i;
23      TH1D* h = hCorr->ProjectionY(Form("%s_bin%d",hCorr->GetName(),bin),i,i);
24  
25 <
25 >    if(h->GetEntries() < 5) continue;
26      if(useFit){
27  
28        func->SetParameter(0,h->GetMaximum());
# Line 28 | Line 36 | void fitSlices(TH2* hCorr, TF1* func = 0
36        hSigma->SetBinContent(i,func->GetParameter(2));
37        hSigma->SetBinError(i,func->GetParError(2));
38      }else{
39 +
40        hMean->SetBinContent(i,h->GetMean());
41        hMean->SetBinError(i,h->GetMeanError());
42        hSigma->SetBinContent(i,h->GetRMS());
43        hSigma->SetBinError(i,h->GetRMSError());
44 +
45      }
46  
47    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines