ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/SchieferD/jetcalib/mcresponse_x.cpp
(Generate patch)

Comparing UserCode/SchieferD/jetcalib/mcresponse_x.cpp (file contents):
Revision 1.3 by schiefer, Thu Aug 23 07:01:26 2007 UTC vs.
Revision 1.13 by schiefer, Mon Sep 3 17:20:56 2007 UTC

# Line 10 | Line 10
10   #include "utils/cmdline.h"
11   #include "utils/hist.h"
12  
13 + #include <TSystem.h>
14   #include <TROOT.h>
15   #include <TRint.h>
16   #include <TFile.h>
# Line 17 | Line 18
18   #include <TEventList.h>
19   #include <TH1F.h>
20   #include <TF1.h>
21 < #include <TGraphErrors.h>
21 < #include <TMultiGraph.h>
22 < #include <TCanvas.h>
23 < #include <TLegend.h>
21 > #include <TMath.h>
22  
23   #include <iostream>
24   #include <iomanip>
27 #include <fstream>
25   #include <cmath>
26   #include <string>
27   #include <vector>
# Line 34 | Line 31 | using namespace std;
31  
32  
33   ////////////////////////////////////////////////////////////////////////////////
37 // defaults
38 ////////////////////////////////////////////////////////////////////////////////
39 string dflt_etbins ="7,9,12,15,20,25,30,45,65,90,120";
40 string dflt_etabins=".2,.4,.6,.8,1.,1.2,1.4,1.6,1.8,2.,2.3,2.5,2.7,3.0,3.3";
41 string dflt_phibins="-2.75,-2.25,-1.75.,-1.25,-.75,-.25,.25,.75,1.25,1.75,2.25,2.75";
42
43
44 ////////////////////////////////////////////////////////////////////////////////
34   // declare global functions
35   ////////////////////////////////////////////////////////////////////////////////
36 < void     replaceHistos(int nbins,TH1F**& hVar,TH1F**& hEtCorr,TTree**& tVar);
37 < void     fitHistos    (TH1F**  histos,int n,double nsigma);
38 < void     fitHistos    (TH1F*** histos,int n1,int n2,double nsigma);
39 < void     saveHistos   (TH1F**  histos,int n);
40 < void     saveHistos   (TH1F*** histos,int n1,int n2);
36 > void     replaceHistos(int nbins,
37 >                       TH1F**& hVar,TH1F**& hEtCorr,TH1F**& hAbsRsp,TH1F**& hRelRsp,
38 >                       TTree**& tVar);
39 > void     replaceHistos(int nbins1,int nbins2,
40 >                       TH1F***&hVar,TH1F***&hEtCorr,TH1F***&hAbsRsp,TH1F***&hRelRsp,
41 >                       TTree***& tVar);
42 > void     replaceHistos(int nbins1,int nbins2,int nbins3,
43 >                       TH1F****&hVar,TH1F****&hEtCorr,
44 >                       TH1F****&hAbsRsp,TH1F****&hRelRsp,
45 >                       TTree****& tVar);
46 > void     fitHistos    (TH1F**    histos,int n,double nsigma);
47 > void     fitHistos    (TH1F***   histos,int n1,int n2,double nsigma);
48 > void     fitHistos    (TH1F****  histos,int n1,int n2,int n3,double nsigma);
49 > void     saveHistos   (TH1F**&   histos,int n);
50 > void     saveHistos   (TH1F***&  histos,int n1,int n2);
51 > void     saveHistos   (TH1F****& histos,int n1,int n2,int n3);
52  
53  
54  
# Line 63 | Line 63 | int main(int argc,char**argv)
63    cl.parse(argc,argv);
64    
65    vector<string> input     = cl.get_vector<string>("input");
66 <  string         output    = cl.get_value<string> ("output","mcresponse.root");
67 <  string         selection = cl.get_value<string> ("selection",       "njt>0");
68 <  float          drmax     = cl.get_value<float>  ("drmax",               0.3);
69 <  short          applyjes  = cl.get_value<short>  ("applyjes",              0);
70 <  string         treename  = cl.get_value<string> ("treename",            "t");
71 <  float          nsigma    = cl.get_value<float>  ("nsigma",              3.0);
72 <  vector<float>  etbins    = cl.get_vector<float> ("etbins",      dflt_etbins);
73 <  vector<float>  etabins   = cl.get_vector<float> ("etabins",    dflt_etabins);
74 <  vector<float>  phibins   = cl.get_vector<float> ("phibins",    dflt_phibins);
75 <  bool           abseta    = cl.get_value<bool>   ("abseta",             true);
66 >  string         output    = cl.get_value<string> ("output", "mcrsp.root");
67 >  string         selection = cl.get_value<string> ("selection",   "njt>0");
68 >  float          drmax     = cl.get_value<float>  ("drmax",           0.3);
69 >  float          jtetmin   = cl.get_value<float>  ("jtetmin",         0.0);
70 >  float          jtetmax   = cl.get_value<float>  ("jtetmax",        1e06);
71 >  float          jtetamin  = cl.get_value<float>  ("jtetamin",        0.0);
72 >  float          jtetamax  = cl.get_value<float>  ("jtetamax",        9.9);
73 >  short          applyjes  = cl.get_value<short>  ("applyjes",          0);
74 >  string         treename  = cl.get_value<string> ("treename",        "t");
75 >  float          nsigma    = cl.get_value<float>  ("nsigma",          3.0);
76 >  vector<float>  etbins    = cl.get_vector<float> ("etbins",           "");
77 >  vector<float>  etabins   = cl.get_vector<float> ("etabins",          "");
78 >  vector<float>  phibins   = cl.get_vector<float> ("phibins",          "");
79 >  vector<float>  emfbins   = cl.get_vector<float> ("emfbins",          "");
80 >  bool           abseta    = cl.get_value<bool>   ("abseta",         true);
81    
82    if (!cl.check()) return 0;
83    cl.print();
84    
85 <
85 >  int netbins  = (etbins.size() >0) ? etbins.size() +1 : 0;
86 >  int netabins = (etabins.size()>0) ? etabins.size()+1 : 0;
87 >  int nphibins = (phibins.size()>0) ? phibins.size()+1 : 0;
88 >  int nemfbins = (emfbins.size()>0) ? emfbins.size()+1 : 0;
89 >  
90 >  if (netbins+netabins+nphibins+nemfbins==0) {
91 >    cout<<"Must specify bins: etbins, etabins, phibins, AND/OR emfbins!"<<endl;
92 >    return 0;
93 >  }
94 >  
95    // etabins
96 <  if (!abseta) {
96 >  if (netabins>0&&!abseta) {
97      int neta=(int)etabins.size();
98      std::reverse(etabins.begin(),etabins.end());
99      for (int ieta=neta-1;ieta>=0;ieta--) etabins.push_back(etabins[ieta]);
# Line 101 | Line 115 | int main(int argc,char**argv)
115    float weight;
116    char  njt;
117    float jtet[100];
104  float jtpt[100];
118    float jteta[100];
119    float jtphi[100];
120 +  float jtemf[100];
121    float jtgenet[100];
108  float jtgenpt[100];
122    float jtgendr[100];
123    float jtjes[100][3];
124    
112  int netbins  = etbins.size()+1;
113  int netabins = etabins.size()+1;
114  int nphibins = phibins.size()+1;
115  
116  vector<TH1F**>         hGenEt;
117  vector<TH1F**>         hEtCorrGenEt;
118  vector<TH1F**>         hAbsRspGenEt;
119  vector<TH1F**>         hRelRspGenEt;
120
121  vector<TH1F**>         hEt;
122  vector<TH1F**>         hEtCorrEt;
123  vector<TH1F**>         hAbsRspEt;
124  vector<TH1F**>         hRelRspEt;
125
126  vector<TH1F**>         hEta;
127  vector<TH1F**>         hEtCorrEta;
128  vector<TH1F**>         hAbsRspEta;
129  vector<TH1F**>         hRelRspEta;
130
131  vector<TH1F**>         hPhi;
132  vector<TH1F**>         hEtCorrPhi;
133  vector<TH1F**>         hAbsRspPhi;
134  vector<TH1F**>         hRelRspPhi;
135  
136  vector<TH1F***>        hEtEtaEt;
137  vector<TH1F***>        hEtCorrEtaEt;
138  vector<TH1F***>        hAbsRspEtaEt;
139  vector<TH1F***>        hRelRspEtaEt;
140  
141  vector<TGraphErrors*>  gRspVsGenEt;
142  vector<TGraphErrors*>  gSgmVsGenEt;
143  vector<TGraphErrors*>  gRspVsEt;
144  vector<TGraphErrors*>  gSgmVsEt;
145  vector<TGraphErrors*>  gRspVsEta;
146  vector<TGraphErrors*>  gSgmVsEta;
147  vector<TGraphErrors*>  gRspVsPhi;
148  vector<TGraphErrors*>  gSgmVsPhi;
149  
150  vector<TGraphErrors**> gRspVsEtaEt;
151  vector<TGraphErrors**> gSgmVsEtaEt;
152  
125    argc=3; argv[1]="-l"; argv[2]="-b";
126 <  TRint* app = new TRint(argv[0],&argc,argv);
126 >  TRint* app = new TRint(argv[0],&argc,argv); app->Argc();
127    
128    
129    //
130    // loop over all input files
131    //
132 <  TFile* plotfile = new TFile(output.c_str(),"RECREATE");
132 >  TFile* plotfile = new TFile(output.c_str(),"UPDATE");
133    
134    for (unsigned int i=0;i<input.size();++i) {
135 <    TFile* f = new TFile(input[i].c_str(),"UPDATE"); if (!f->IsOpen()) return 0;
135 >    TFile* f = new TFile(input[i].c_str(),"READ"); if (!f->IsOpen()) return 0;
136      TTree* t = (TTree*)f->Get(treename.c_str());
137      
138      TEventList* el = new TEventList("sel","sel");
# Line 169 | Line 141 | int main(int argc,char**argv)
141      t->SetBranchAddress("weight", &weight);
142      t->SetBranchAddress("njt",    &njt);
143      t->SetBranchAddress("jtet",   jtet);
172    t->SetBranchAddress("jtpt",   jtpt);
144      t->SetBranchAddress("jteta",  jteta);
145      t->SetBranchAddress("jtphi",  jtphi);
146 +    t->SetBranchAddress("jtemf",  jtemf);
147      t->SetBranchAddress("jtgenet",jtgenet);
176    t->SetBranchAddress("jtgenpt",jtgenpt);
148      t->SetBranchAddress("jtgendr",jtgendr);
149 <
150 <    if (t->FindBranch("jtjes")) t->SetBranchAddress("jtjes", jtjes);
151 <    else
149 >    
150 >    vector<TBranch*> branches;
151 >    branches.push_back(t->GetBranch("weight"));
152 >    branches.push_back(t->GetBranch("njt"));
153 >    branches.push_back(t->GetBranch("jtet"));
154 >    branches.push_back(t->GetBranch("jteta"));
155 >    branches.push_back(t->GetBranch("jtphi"));
156 >    branches.push_back(t->GetBranch("jtemf"));
157 >    branches.push_back(t->GetBranch("jtgenet"));
158 >    branches.push_back(t->GetBranch("jtgendr"));
159 >    
160 >    if (t->FindBranch("jtjes")) {
161 >      t->SetBranchAddress("jtjes", jtjes);
162 >      branches.push_back(t->GetBranch("jtjes"));
163 >    }
164 >    else {
165        for (int i1=0;i1<100;i1++)
166          for (int i2=0;i2<3;i2++) jtjes[i1][i2]=1.0;
167 <    
184 <    
167 >    }
168      string absrsp_xtitle = "E_{T}^{gen}-E_{T} [GeV]";
169      string relrsp_xtitle = "E_{T}^{rec}/E_{T}";
170 +
171 +    
172 +    TH1F** hGenEt(0);
173 +    TH1F** hEtCorrGenEt(0);
174 +    TH1F** hAbsRspGenEt(0);
175 +    TH1F** hRelRspGenEt(0);
176 +    
177 +    if (netbins>0) {
178 +      hGenEt       = hist::initHistos("GenEt",jetalgs[i],100,
179 +                                      "jet E_{T}^{gen} [GeV]",
180 +                                      "GenEt",etbins);
181 +      hEtCorrGenEt = hist::initHistos("EtCorrGenEt",jetalgs[i],100,
182 +                                      "jet E_{T}^{gen} [GeV]",
183 +                                      "GenEt",etbins);
184 +      hAbsRspGenEt = hist::initHistos("AbsRspGenEt",jetalgs[i],
185 +                                      100,-50,150,
186 +                                      absrsp_xtitle,
187 +                                      "GenEt",etbins);
188 +      hRelRspGenEt = hist::initHistos("RelRspGenEt",jetalgs[i],
189 +                                      100,0,2,
190 +                                      relrsp_xtitle,
191 +                                      "GenEt",etbins);
192 +    }
193 +    
194 +
195 +    TH1F** hEt(0);
196 +    TH1F** hEtCorrEt(0);
197 +    TH1F** hAbsRspEt(0);
198 +    TH1F** hRelRspEt(0);
199 +    
200 +    if (netbins>0) {
201 +      hEt       = hist::initHistos("Et",jetalgs[i],100,
202 +                                   "jet E_{T} [GeV]","Et",etbins);
203 +      hEtCorrEt = hist::initHistos("EtCorrEt",jetalgs[i],100,
204 +                                   "jet E_{T} [GeV]","Et",etbins);
205 +      hAbsRspEt = hist::initHistos("AbsRspEt",jetalgs[i],100,-50,150,
206 +                                   absrsp_xtitle,"Et",etbins);
207 +      hRelRspEt = hist::initHistos("RelRspEt",jetalgs[i],100,0,2,
208 +                                   relrsp_xtitle,"Et",etbins);
209 +    }
210 +    
211 +
212 +    TH1F** hEta(0);
213 +    TH1F** hEtCorrEta(0);
214 +    TH1F** hAbsRspEta(0);
215 +    TH1F** hRelRspEta(0);
216 +    
217 +    if (netabins>0) {
218 +      hEta       = hist::initHistos("Eta",jetalgs[i],100,
219 +                                    "jet #eta","Eta",etabins);
220 +      hEtCorrEta = hist::initHistos("EtCorrEta",jetalgs[i],100,
221 +                                    "jet E_{T} [GeV]","Eta",etabins);
222 +      hAbsRspEta = hist::initHistos("AbsRspEta",jetalgs[i],100,-50,150,
223 +                                    absrsp_xtitle,"Eta",etabins);
224 +      hRelRspEta = hist::initHistos("RelRspEta",jetalgs[i],100,0,2,
225 +                                    relrsp_xtitle,"Eta",etabins);
226 +    }
227 +    
228 +
229 +    TH1F** hPhi(0);
230 +    TH1F** hEtCorrPhi(0);
231 +    TH1F** hAbsRspPhi(0);
232 +    TH1F** hRelRspPhi(0);
233 +    
234 +    if (nphibins>0) {
235 +      hPhi       = hist::initHistos("Phi",jetalgs[i],100,
236 +                                    "jet #phi","Phi",phibins);
237 +      hEtCorrPhi = hist::initHistos("EtCorrPhi",jetalgs[i],100,
238 +                                    "jet E_{T} [Gev]","Phi",phibins);
239 +      hAbsRspPhi = hist::initHistos("AbsRspPhi",jetalgs[i],100,-50,150,
240 +                                    absrsp_xtitle,"Phi",phibins);
241 +      hRelRspPhi = hist::initHistos("RelRspPhi",jetalgs[i],100,0,2,
242 +                                    relrsp_xtitle,"Phi",phibins);
243 +    }
244      
245 <    hGenEt      .push_back(hist::initHistos("GenEt",jetalgs[i],
246 <                                            100,"jet E_{T}^{gen} [GeV]",
247 <                                            "GenEt",etbins));
248 <    hEtCorrGenEt.push_back(hist::initHistos("EtCorrGenEt",jetalgs[i],
249 <                                            100,"jet E_{T}^{gen} [GeV]",
250 <                                            "GenEt",etbins));
251 <    hAbsRspGenEt.push_back(hist::initHistos("AbsRspGenEt",jetalgs[i],
252 <                                            100,-50,150,absrsp_xtitle,
253 <                                            "GenEt",etbins));
254 <    hRelRspGenEt.push_back(hist::initHistos("RelRspGenEt",jetalgs[i],
255 <                                            100,0,2,relrsp_xtitle,
256 <                                            "GenEt",etbins));
257 <    
258 <    hEt         .push_back(hist::initHistos("Et",jetalgs[i],
259 <                                            100,"jet E_{T} [GeV]",
260 <                                            "Et",etbins));
204 <    hEtCorrEt   .push_back(hist::initHistos("EtCorrEt",jetalgs[i],
205 <                                            100,"jet E_{T} [GeV]",
206 <                                            "Et",etbins));
207 <    hAbsRspEt   .push_back(hist::initHistos("AbsRspEt",jetalgs[i],
208 <                                            100,-50,150,absrsp_xtitle,
209 <                                            "Et",etbins));
210 <    hRelRspEt   .push_back(hist::initHistos("RelRspEt",jetalgs[i],
211 <                                            100,0,2,relrsp_xtitle,
212 <                                            "Et",etbins));
213 <    
214 <    hEta        .push_back(hist::initHistos("Eta",jetalgs[i],
215 <                                            100,"jet #eta","Eta",etabins));
216 <    hEtCorrEta  .push_back(hist::initHistos("EtCorrEta",jetalgs[i],
217 <                                            100,"jet E_{T} [GeV]",
218 <                                            "Eta",etabins));
219 <    hAbsRspEta  .push_back(hist::initHistos("AbsRspEta",jetalgs[i],
220 <                                            100,-50,150,absrsp_xtitle,
221 <                                            "Eta",etabins));
222 <    hRelRspEta  .push_back(hist::initHistos("RelRspEta",jetalgs[i],
223 <                                            100,0,2,relrsp_xtitle,
224 <                                            "Eta",etabins));
225 <    
226 <    hPhi        .push_back(hist::initHistos("Phi",jetalgs[i],
227 <                                            100,"jet #phi","Phi",phibins));
228 <    hEtCorrPhi  .push_back(hist::initHistos("EtCorrPhi",jetalgs[i],
229 <                                            100,"jet E_{T} [Gev]",
230 <                                            "Phi",phibins));
231 <    hAbsRspPhi  .push_back(hist::initHistos("AbsRspPhi",jetalgs[i],
232 <                                            100,-50,150,absrsp_xtitle,
233 <                                            "Phi",phibins));
234 <    hRelRspPhi  .push_back(hist::initHistos("RelRspPhi",jetalgs[i],
235 <                                            100,0,2,relrsp_xtitle,
236 <                                            "Phi",phibins));
237 <    
238 <    hEtEtaEt    .push_back(hist::initHistos("Et",jetalgs[i],
239 <                                            100,"jet E_{T} [GeV]",
240 <                                            "Eta",etabins,"Et",etbins));
241 <    hEtCorrEtaEt.push_back(hist::initHistos("EtCorrEtaEt",jetalgs[i],
242 <                                            100,"jet E_{T} [GeV]",
243 <                                            "Eta",etabins,"Et",etbins));
244 <    hAbsRspEtaEt.push_back(hist::initHistos("AbsRspEtaEt",jetalgs[i],
245 <                                            100,-50,150,absrsp_xtitle,
246 <                                            "Eta",etabins,"Et",etbins));
247 <    hRelRspEtaEt.push_back(hist::initHistos("RelRspEtaEt",jetalgs[i],
248 <                                            100,0,2,relrsp_xtitle,
249 <                                            "Eta",etabins,"Et",etbins));
245 >
246 >    TH1F** hEmf(0);
247 >    TH1F** hEtCorrEmf(0);
248 >    TH1F** hAbsRspEmf(0);
249 >    TH1F** hRelRspEmf(0);
250 >    
251 >    if (nemfbins>0) {
252 >      hEmf       = hist::initHistos("Emf",jetalgs[i],100,
253 >                                    "jet emf","Emf",emfbins);
254 >      hEtCorrEmf = hist::initHistos("EtCorrEmf",jetalgs[i],100,
255 >                                    "jet E_{T} [Gev]","Emf",emfbins);
256 >      hAbsRspEmf = hist::initHistos("AbsRspEmf",jetalgs[i],100,-50,150,
257 >                                    absrsp_xtitle,"Emf",emfbins);
258 >      hRelRspEmf = hist::initHistos("RelRspEmf",jetalgs[i],100,0,2,
259 >                                    relrsp_xtitle,"Emf",emfbins);
260 >    }
261      
262      
263 +    TH1F*** hEtEtaEt(0);
264 +    TH1F*** hEtCorrEtaEt(0);
265 +    TH1F*** hAbsRspEtaEt(0);
266 +    TH1F*** hRelRspEtaEt(0);
267 +    
268 +    if (netbins>0&&netabins>0) {
269 +      hEtEtaEt     = hist::initHistos("Et",jetalgs[i],100,"jet E_{T} [GeV]",
270 +                                      "Eta",etabins,"Et",etbins);
271 +      hEtCorrEtaEt = hist::initHistos("EtCorrEtaEt",jetalgs[i],100,
272 +                                      "jet E_{T} [GeV]",
273 +                                      "Eta",etabins,"Et",etbins);
274 +      hAbsRspEtaEt = hist::initHistos("AbsRspEtaEt",jetalgs[i],100,-50,150,
275 +                                      absrsp_xtitle,
276 +                                      "Eta",etabins,"Et",etbins);
277 +      hRelRspEtaEt = hist::initHistos("RelRspEtaEt",jetalgs[i],100,0,2,
278 +                                      relrsp_xtitle,
279 +                                      "Eta",etabins,"Et",etbins);
280 +    }
281 +
282 +
283 +    TH1F*** hEtEmfEt(0);
284 +    TH1F*** hEtCorrEmfEt(0);
285 +    TH1F*** hAbsRspEmfEt(0);
286 +    TH1F*** hRelRspEmfEt(0);
287 +    
288 +    if (netbins>0&&nemfbins>0) {
289 +      hEtEmfEt     = hist::initHistos("Et",jetalgs[i],100,"jet E_{T} [GeV]",
290 +                                      "Emf",emfbins,"Et",etbins);
291 +      hEtCorrEmfEt = hist::initHistos("EtCorrEmfEt",jetalgs[i],100,
292 +                                      "jet E_{T} [GeV]",
293 +                                      "Emf",emfbins,"Et",etbins);
294 +      hAbsRspEmfEt = hist::initHistos("AbsRspEmfEt",jetalgs[i],100,-50,150,
295 +                                      absrsp_xtitle,
296 +                                      "Emf",emfbins,"Et",etbins);
297 +      hRelRspEmfEt = hist::initHistos("RelRspEmfEt",jetalgs[i],100,0,2,
298 +                                      relrsp_xtitle,
299 +                                      "Emf",emfbins,"Et",etbins);
300 +    }
301 +    
302 +
303 +    TH1F**** hEtEmfEtaEt(0);
304 +    TH1F**** hEtCorrEmfEtaEt(0);
305 +    TH1F**** hAbsRspEmfEtaEt(0);
306 +    TH1F**** hRelRspEmfEtaEt(0);
307 +    
308 +    if (netbins>0&&netabins>0&&nemfbins>0) {
309 +      hEtEmfEtaEt     = hist::initHistos("Et",jetalgs[i],100,"jet E_{T} [GeV]",
310 +                                         "Emf",emfbins,
311 +                                         "Eta",etabins,
312 +                                         "Et", etbins);
313 +      hEtCorrEmfEtaEt = hist::initHistos("EtCorrEmfEtaEt",jetalgs[i],100,
314 +                                         "jet E_{T} [GeV]",
315 +                                         "Emf",emfbins,
316 +                                         "Eta",etabins,
317 +                                         "Et", etbins);
318 +      hAbsRspEmfEtaEt = hist::initHistos("AbsRspEmfEtaEt",jetalgs[i],
319 +                                         100,-50,150,absrsp_xtitle,
320 +                                         "Emf",emfbins,
321 +                                         "Eta",etabins,
322 +                                         "Et", etbins);
323 +      hRelRspEmfEtaEt = hist::initHistos("RelRspEmfEtaEt",jetalgs[i],
324 +                                         100,0,2,relrsp_xtitle,
325 +                                         "Emf",emfbins,
326 +                                         "Eta",etabins,
327 +                                         "Et", etbins);
328 +    }
329 +    
330      int nevts = el->GetN();
331      cout<<jetalgs[i]<<": "<<nevts<<" events selected."<<endl;
332 <
332 >    
333      // prepare intermediate trees
334 <    float genet,et,eta,phi,etcorr;
257 <    TTree**  tGenEt   = new TTree*[netbins];
258 <    TTree**  tEt      = new TTree*[netbins];
259 <    TTree**  tEta     = new TTree*[netabins];
260 <    TTree**  tPhi     = new TTree*[nphibins];
261 <    TTree*** tEtEtaEt = new TTree**[netabins];
334 >    float genet,et,eta,phi,emf,etcorr,absrsp,relrsp;
335  
336 +    TTree**   tGenEt(0);
337 +    TTree**   tEt(0);
338 +    TTree**   tEta(0);
339 +    TTree**   tPhi(0);
340 +    TTree**   tEmf(0);
341 +    TTree***  tEtEtaEt(0);
342 +    TTree***  tEtEmfEt(0);
343 +    TTree**** tEtEmfEtaEt(0);
344 +
345 +    gROOT->cd();
346 +    
347 +    if (netbins>0)  tGenEt = new TTree*[netbins];
348 +    if (netbins>0)  tEt    = new TTree*[netbins];
349 +    if (netabins>0) tEta   = new TTree*[netabins];
350 +    if (nphibins>0) tPhi   = new TTree*[nphibins];
351 +    if (nemfbins>0) tEmf   = new TTree*[nemfbins];
352 +    if (netbins>0&&netabins>0) tEtEtaEt = new TTree**[netabins];
353 +    if (netbins>0&&nemfbins>0) tEtEmfEt = new TTree**[nemfbins];
354 +    if (netbins>0&&netabins>0&&nemfbins>0) tEtEmfEtaEt = new TTree***[nemfbins];
355 +    
356      for (int iet=0;iet<netbins;iet++) {
357 +      
358        tGenEt[iet]=new TTree("tGenEt","tGenEt");
359        tGenEt[iet]->Branch("val",   &genet, "val/F");
360        tGenEt[iet]->Branch("etcorr",&etcorr,"etcorr/F");
361 +      tGenEt[iet]->Branch("absrsp",&absrsp,"absrsp/F");
362 +      tGenEt[iet]->Branch("relrsp",&relrsp,"relrsp/F");
363        tGenEt[iet]->Branch("weight",&weight,"weight/F");
364 +
365        tEt[iet]=new TTree("tEt","tEt");
366        tEt[iet]->Branch("val",   &et,    "val/F");
367        tEt[iet]->Branch("etcorr",&etcorr,"etcorr/F");
368 +      tEt[iet]->Branch("absrsp",&absrsp,"absrsp/F");
369 +      tEt[iet]->Branch("relrsp",&relrsp,"relrsp/F");
370        tEt[iet]->Branch("weight",&weight,"weight/F");
371      }
372      for (int ieta=0;ieta<netabins;ieta++) {
373        tEta[ieta]=new TTree("tEta","tEta");
374        tEta[ieta]->Branch("val",   &eta,   "val/F");
375        tEta[ieta]->Branch("etcorr",&etcorr,"etcorr/F");
376 +      tEta[ieta]->Branch("absrsp",&absrsp,"absrsp/F");
377 +      tEta[ieta]->Branch("relrsp",&relrsp,"relrsp/F");
378        tEta[ieta]->Branch("weight",&weight,"weight/F");
379      }
380      for (int iphi=0;iphi<nphibins;iphi++) {
381        tPhi[iphi]=new TTree("tPhi","tPhi");
382        tPhi[iphi]->Branch("val",   &phi,   "val/F");
383        tPhi[iphi]->Branch("etcorr",&etcorr,"etcorr/F");
384 +      tPhi[iphi]->Branch("absrsp",&absrsp,"absrsp/F");
385 +      tPhi[iphi]->Branch("relrsp",&relrsp,"relrsp/F");
386        tPhi[iphi]->Branch("weight",&weight,"weight/F");
387      }
388 <    for (int ieta=0;ieta<netabins;ieta++) {
389 <      tEtEtaEt[ieta] = new TTree*[netbins];
390 <      for (int iet=0;iet<netbins;iet++) {
391 <        tEtEtaEt[ieta][iet] = new TTree("tEtEtaEt","tEtEtaEt");
392 <        tEtEtaEt[ieta][iet]->Branch("val",    &et,   "val/F");
393 <        tEtEtaEt[ieta][iet]->Branch("etcorr",&etcorr,"etcorr/F");
394 <        tEtEtaEt[ieta][iet]->Branch("weight",&weight,"weight/F");
388 >    for (int iemf=0;iemf<nemfbins;iemf++) {
389 >      tEmf[iemf]=new TTree("tEmf","tEmf");
390 >      tEmf[iemf]->Branch("val",   &emf,   "val/F");
391 >      tEmf[iemf]->Branch("etcorr",&etcorr,"etcorr/F");
392 >      tEmf[iemf]->Branch("absrsp",&absrsp,"absrsp/F");
393 >      tEmf[iemf]->Branch("relrsp",&relrsp,"relrsp/F");
394 >      tEmf[iemf]->Branch("weight",&weight,"weight/F");
395 >    }
396 >
397 >    if (netbins>0) {
398 >      for (int ieta=0;ieta<netabins;ieta++) {
399 >        tEtEtaEt[ieta] = new TTree*[netbins];
400 >        for (int iet=0;iet<netbins;iet++) {
401 >          tEtEtaEt[ieta][iet] = new TTree("tEtEtaEt","tEtEtaEt");
402 >          tEtEtaEt[ieta][iet]->Branch("val",   &et,    "val/F");
403 >          tEtEtaEt[ieta][iet]->Branch("etcorr",&etcorr,"etcorr/F");
404 >          tEtEtaEt[ieta][iet]->Branch("absrsp",&absrsp,"absrsp/F");
405 >          tEtEtaEt[ieta][iet]->Branch("relrsp",&relrsp,"relrsp/F");
406 >          tEtEtaEt[ieta][iet]->Branch("weight",&weight,"weight/F");
407 >        }
408 >      }
409 >      for (int iemf=0;iemf<nemfbins;iemf++) {
410 >        tEtEmfEt[iemf] = new TTree*[netbins];
411 >        for (int iet=0;iet<netbins;iet++) {
412 >          tEtEmfEt[iemf][iet] = new TTree("tEtEmfEt","tEtEmfEt");
413 >          tEtEmfEt[iemf][iet]->Branch("val",   &et,    "val/F");
414 >          tEtEmfEt[iemf][iet]->Branch("etcorr",&etcorr,"etcorr/F");
415 >          tEtEmfEt[iemf][iet]->Branch("absrsp",&absrsp,"absrsp/F");
416 >          tEtEmfEt[iemf][iet]->Branch("relrsp",&relrsp,"relrsp/F");
417 >          tEtEmfEt[iemf][iet]->Branch("weight",&weight,"weight/F");
418 >        }
419 >      }
420 >      if (netabins>0) {
421 >        for (int iemf=0;iemf<nemfbins;iemf++) {
422 >          tEtEmfEtaEt[iemf] = new TTree**[netabins];
423 >          for (int ieta=0;ieta<netabins;ieta++) {
424 >            tEtEmfEtaEt[iemf][ieta] = new TTree*[netbins];
425 >            for (int iet=0;iet<netbins;iet++) {
426 >              tEtEmfEtaEt[iemf][ieta][iet] = new TTree("tEtEmfEtaEt",
427 >                                                       "tEtEmfEtaEt");
428 >              tEtEmfEtaEt[iemf][ieta][iet]->Branch("val",   &et,    "val/F");
429 >              tEtEmfEtaEt[iemf][ieta][iet]->Branch("etcorr",&etcorr,"etcorr/F");
430 >              tEtEmfEtaEt[iemf][ieta][iet]->Branch("absrsp",&absrsp,"absrsp/F");
431 >              tEtEmfEtaEt[iemf][ieta][iet]->Branch("relrsp",&relrsp,"relrsp/F");
432 >              tEtEmfEtaEt[iemf][ieta][iet]->Branch("weight",&weight,"weight/F");
433 >            }
434 >          }
435 >        }
436        }
437      }
438      
439 <    
439 >    cout<<jetalgs[i]<<": trees created."<<endl;
440 >
441      // loop over all events
442      for (int ievt=0;ievt<nevts;ievt++) {
443        
444 <      t->GetEntry(el->GetEntry(ievt));
445 <      
444 >      //t->GetEntry(el->GetEntry(ievt));
445 >      for (int ibrnch=0;ibrnch<(int)branches.size();ibrnch++)
446 >        branches[ibrnch]->GetEntry(el->GetEntry(ievt));
447 >
448        // loop over all jets in the event
449        for (int ijt=0;ijt<njt;ijt++) {
450          
451 <        if (jtgendr[ijt]<0.0||jtgendr[ijt]>drmax) continue;
452 <
453 <        if (ijt>0) continue;
451 >        if (jtgendr[ijt]<0.0   ||jtgendr[ijt]>drmax)  continue;
452 >        if (jtet[ijt]<jtetmin  ||jtet[ijt]>jtetmax)   continue;
453 >        if (jteta[ijt]<jtetamin||jteta[ijt]>jtetamax) continue;
454  
455          et      = jtet[ijt];
456          genet   = jtgenet[ijt];
457          eta     = (abseta) ? std::abs(jteta[ijt]) : jteta[ijt];
458          phi     = jtphi[ijt];
459 +        emf     = jtemf[ijt];
460 +
461          etcorr  = (applyjes==0) ? et : et*jtjes[ijt][applyjes-1];
462          
463 <        float absrsp  = genet - etcorr;
464 <        float relrsp  = etcorr/genet;
463 >        absrsp  = genet - etcorr;
464 >        relrsp  = etcorr/genet;
465  
466 <        // genet
318 <        int igenet = hist::get_ibin(genet,etbins);
319 <        hAbsRspGenEt[i][igenet] ->Fill(absrsp,weight);
320 <        hRelRspGenEt[i][igenet] ->Fill(relrsp,weight);
321 <        tGenEt[igenet]->Fill();
322 <        
323 <        // et
324 <        int iet = hist::get_ibin(et,etbins);
325 <        hAbsRspEt[i][iet]->Fill(absrsp,weight);
326 <        hRelRspEt[i][iet]->Fill(relrsp,weight);
327 <        tEt[iet]->Fill();
466 >        if (TMath::IsNaN(emf)) emf = 0.0;
467          
468 <        // eta
469 <        int ieta = hist::get_ibin(eta,etabins);
470 <        hAbsRspEta[i][ieta]->Fill(absrsp,weight);
471 <        hRelRspEta[i][ieta]->Fill(relrsp,weight);
472 <        tEta[ieta]->Fill();
468 >        int igenet = (netbins>0)  ? hist::get_ibin(genet,etbins) : -1;
469 >        int iet    = (netbins>0)  ? hist::get_ibin(et,etbins)    : -1;
470 >        int ieta   = (netabins>0) ? hist::get_ibin(eta,etabins)  : -1;
471 >        int iphi   = (nphibins>0) ? hist::get_ibin(phi,phibins)  : -1;
472 >        int iemf   = (nemfbins>0) ? hist::get_ibin(emf,emfbins)  : -1;
473          
474 <        // phi
475 <        int iphi = hist::get_ibin(phi,phibins);
476 <        hAbsRspPhi[i][iphi]->Fill(absrsp,weight);
477 <        hRelRspPhi[i][iphi]->Fill(relrsp,weight);
478 <        tPhi[iphi]->Fill();
479 <        
480 <        // et-eta
481 <        hAbsRspEtaEt[i][ieta][iet]->Fill(absrsp,weight);
482 <        hRelRspEtaEt[i][ieta][iet]->Fill(relrsp,weight);
483 <        tEtEtaEt[ieta][iet]->Fill();
474 >        if (netbins>0)  tGenEt[igenet]->Fill();
475 >        if (netbins>0)  tEt[iet]->Fill();
476 >        if (netabins>0) tEta[ieta]->Fill();
477 >        if (nphibins>0) tPhi[iphi]->Fill();
478 >        if (nemfbins>0) tEmf[iemf]->Fill();
479 >
480 >        if (netbins>0&&netabins>0) tEtEtaEt[ieta][iet]->Fill();
481 >        if (netbins>0&&nemfbins>0) tEtEmfEt[iemf][iet]->Fill();
482 >
483 >        if (netbins>0&&netabins>0&&nemfbins>0)
484 >          tEtEmfEtaEt[iemf][ieta][iet]->Fill();
485          
486        } // jets
487      } // evts
# Line 350 | Line 490 | int main(int argc,char**argv)
490      
491  
492      // replace histograms
493 <    replaceHistos(netbins,hGenEt[i],hEtCorrGenEt[i],tGenEt);
494 <    replaceHistos(netbins,hEt[i],   hEtCorrEt[i],      tEt);
495 <    replaceHistos(netabins,hEta[i], hEtCorrEta[i],    tEta);
496 <    replaceHistos(nphibins,hPhi[i], hEtCorrPhi[i],    tPhi);
497 <    for (int ieta=0;ieta<netabins;ieta++)
498 <      replaceHistos(netbins,hEtEtaEt[i][ieta],hEtCorrEtaEt[i][ieta],tEtEtaEt[ieta]);
499 <    
500 <    TDirectory* d = plotfile->mkdir(jetalgs[i].c_str());
493 >
494 >    replaceHistos(netbins,
495 >                  hGenEt,hEtCorrGenEt,hAbsRspGenEt,hRelRspGenEt,tGenEt);
496 >    replaceHistos(netbins,hEt,hEtCorrEt,hAbsRspEt,hRelRspEt,tEt);
497 >    replaceHistos(netabins,hEta,hEtCorrEta,hAbsRspEta,hRelRspEta,tEta);
498 >    replaceHistos(nphibins,hPhi,hEtCorrPhi,hAbsRspPhi,hRelRspPhi,tPhi);
499 >    replaceHistos(nemfbins,hEmf,hEtCorrEmf,hAbsRspEmf,hRelRspEmf,tEmf);
500 >    replaceHistos(netabins,netbins,
501 >                  hEtEtaEt,hEtCorrEtaEt,hAbsRspEtaEt,hRelRspEtaEt,
502 >                  tEtEtaEt);
503 >    replaceHistos(nemfbins,netbins,
504 >                  hEtEmfEt,hEtCorrEmfEt,hAbsRspEmfEt,hRelRspEmfEt,
505 >                  tEtEmfEt);
506 >    replaceHistos(nemfbins,netabins,netbins,
507 >                  hEtEmfEtaEt,hEtCorrEmfEtaEt,
508 >                  hAbsRspEmfEtaEt,hRelRspEmfEtaEt,
509 >                  tEtEmfEtaEt);
510 >    
511 >    cout<<jetalgs[i]<<": all histograms replaced, and tree deleted."<<endl;
512 >
513 >    
514 >    plotfile->cd();
515 >    TDirectory* d = plotfile->GetDirectory(jetalgs[i].c_str());
516 >    if (0!=d) plotfile->rmdir(jetalgs[i].c_str());
517 >    d = plotfile->mkdir(jetalgs[i].c_str());
518      d->cd();
519      
520      // fit response histos
521 <    fitHistos(hAbsRspGenEt[i],netbins,nsigma);
522 <    fitHistos(hRelRspGenEt[i],netbins,nsigma);
521 >    fitHistos(hAbsRspGenEt,netbins,nsigma);
522 >    fitHistos(hRelRspGenEt,netbins,nsigma);
523 >    
524 >    fitHistos(hAbsRspEt,   netbins,nsigma);
525 >    fitHistos(hRelRspEt,   netbins,nsigma);
526  
527 <    fitHistos(hAbsRspEt[i],   netbins,nsigma);
528 <    fitHistos(hRelRspEt[i],   netbins,nsigma);
527 >    fitHistos(hAbsRspEta,  netabins,nsigma);
528 >    fitHistos(hRelRspEta,  netabins,nsigma);
529  
530 <    fitHistos(hAbsRspEta[i],  netabins,nsigma);
531 <    fitHistos(hRelRspEta[i],  netabins,nsigma);
530 >    fitHistos(hAbsRspPhi,  nphibins,nsigma);
531 >    fitHistos(hRelRspPhi,  nphibins,nsigma);
532  
533 <    fitHistos(hAbsRspPhi[i],  nphibins,nsigma);
534 <    fitHistos(hRelRspPhi[i],  nphibins,nsigma);
535 <    
536 <    fitHistos(hAbsRspEtaEt[i],netabins,netbins,nsigma);
537 <    fitHistos(hRelRspEtaEt[i],netabins,netbins,nsigma);
533 >    fitHistos(hAbsRspEmf,  nemfbins,nsigma);
534 >    fitHistos(hRelRspEmf,  nemfbins,nsigma);
535 >
536 >    fitHistos(hAbsRspEtaEt,netabins,netbins,nsigma);
537 >    fitHistos(hRelRspEtaEt,netabins,netbins,nsigma);
538 >
539 >    fitHistos(hAbsRspEmfEt,nemfbins,netbins,nsigma);
540 >    fitHistos(hRelRspEmfEt,nemfbins,netbins,nsigma);
541 >
542 >    fitHistos(hAbsRspEmfEtaEt,nemfbins,netabins,netbins,nsigma);
543 >    fitHistos(hRelRspEmfEtaEt,nemfbins,netabins,netbins,nsigma);
544 >
545 >    cout<<jetalgs[i]<<": fits done."<<endl;
546  
547      
548      // save histograms
549 <    saveHistos(hGenEt[i],      netbins);
550 <    saveHistos(hEtCorrGenEt[i],netbins);
551 <    saveHistos(hAbsRspGenEt[i],netbins);
552 <    saveHistos(hRelRspGenEt[i],netbins);
553 <
554 <    saveHistos(hEt[i],         netbins);
555 <    saveHistos(hEtCorrEt[i],   netbins);
556 <    saveHistos(hAbsRspEt[i],   netbins);
557 <    saveHistos(hRelRspEt[i],   netbins);
558 <
559 <    saveHistos(hEta[i],        netabins);
560 <    saveHistos(hEtCorrEta[i],  netabins);
561 <    saveHistos(hAbsRspEta[i],  netabins);
562 <    saveHistos(hRelRspEta[i],  netabins);
563 <
564 <    saveHistos(hPhi[i],        nphibins);
565 <    saveHistos(hEtCorrPhi[i],  nphibins);
566 <    saveHistos(hAbsRspPhi[i],  nphibins);
567 <    saveHistos(hRelRspPhi[i],  nphibins);
568 <    
569 <    saveHistos(hEtEtaEt[i],    netabins,netbins);
570 <    saveHistos(hEtCorrEtaEt[i],netabins,netbins);
571 <    saveHistos(hAbsRspEtaEt[i],netabins,netbins);
572 <    saveHistos(hRelRspEtaEt[i],netabins,netbins);
549 >    saveHistos(hGenEt,      netbins);
550 >    saveHistos(hEtCorrGenEt,netbins);
551 >    saveHistos(hAbsRspGenEt,netbins);
552 >    saveHistos(hRelRspGenEt,netbins);
553 >
554 >    saveHistos(hEt,         netbins);
555 >    saveHistos(hEtCorrEt,   netbins);
556 >    saveHistos(hAbsRspEt,   netbins);
557 >    saveHistos(hRelRspEt,   netbins);
558 >
559 >    saveHistos(hEta,        netabins);
560 >    saveHistos(hEtCorrEta,  netabins);
561 >    saveHistos(hAbsRspEta,  netabins);
562 >    saveHistos(hRelRspEta,  netabins);
563 >
564 >    saveHistos(hPhi,        nphibins);
565 >    saveHistos(hEtCorrPhi,  nphibins);
566 >    saveHistos(hAbsRspPhi,  nphibins);
567 >    saveHistos(hRelRspPhi,  nphibins);
568 >    
569 >    saveHistos(hEmf,        nemfbins);
570 >    saveHistos(hEtCorrEmf,  nemfbins);
571 >    saveHistos(hAbsRspEmf,  nemfbins);
572 >    saveHistos(hRelRspEmf,  nemfbins);
573 >    
574 >    saveHistos(hEtEtaEt,    netabins,netbins);
575 >    saveHistos(hEtCorrEtaEt,netabins,netbins);
576 >    saveHistos(hAbsRspEtaEt,netabins,netbins);
577 >    saveHistos(hRelRspEtaEt,netabins,netbins);
578 >
579 >    saveHistos(hEtEmfEt,    nemfbins,netbins);
580 >    saveHistos(hEtCorrEmfEt,nemfbins,netbins);
581 >    saveHistos(hAbsRspEmfEt,nemfbins,netbins);
582 >    saveHistos(hRelRspEmfEt,nemfbins,netbins);
583 >
584 >    saveHistos(hEtEmfEtaEt,    nemfbins,netabins,netbins);
585 >    saveHistos(hEtCorrEmfEtaEt,nemfbins,netabins,netbins);
586 >    saveHistos(hAbsRspEmfEtaEt,nemfbins,netabins,netbins);
587 >    saveHistos(hRelRspEmfEtaEt,nemfbins,netabins,netbins);
588 >
589 >    cout<<jetalgs[i]<<": histograms saved."<<endl;
590    }
591    
592    plotfile->Write();
593    plotfile->Close();
594    delete plotfile;
595 <  
595 >
596    //app->Run();
597    
598    return 0;
# Line 420 | Line 605 | int main(int argc,char**argv)
605   ////////////////////////////////////////////////////////////////////////////////
606  
607   //______________________________________________________________________________
608 < void replaceHistos(int nbins,TH1F**& hVar,TH1F**& hEtCorr,TTree**& tVar)
608 > void replaceHistos(int nbins,
609 >                   TH1F**& hVar,TH1F**& hEtCorr,TH1F**& hAbsRsp,TH1F**& hRelRsp,
610 >                   TTree**& tVar)
611   {
612 +  if (nbins==0) return;
613 +  
614    TH1::SetDefaultSumw2();
615    for (int ibin=0;ibin<nbins;ibin++) {
616 <
616 >    
617      TH1F* h(0);
618 +    
619 +    if (tVar[ibin]->GetEntries()==0) continue;
620  
621      tVar[ibin]->Project("h(50)","val","weight*(1)");
622      h = (TH1F*)gROOT->FindObject("h");
# Line 442 | Line 633 | void replaceHistos(int nbins,TH1F**& hVa
633      h->SetYTitle(hEtCorr[ibin]->GetYaxis()->GetTitle());
634      delete hEtCorr[ibin];
635      hEtCorr[ibin] = h;
636 <
636 >    
637 >    tVar[ibin]->Project("h(50)","absrsp","weight*(1)");
638 >    h = (TH1F*)gROOT->FindObject("h");
639 >    h->SetNameTitle(hAbsRsp[ibin]->GetName(),hAbsRsp[ibin]->GetTitle());
640 >    h->SetXTitle(hAbsRsp[ibin]->GetXaxis()->GetTitle());
641 >    h->SetYTitle(hAbsRsp[ibin]->GetYaxis()->GetTitle());
642 >    delete hAbsRsp[ibin];
643 >    hAbsRsp[ibin] = h;
644 >    
645 >    tVar[ibin]->Project("h(50)","relrsp","weight*(1)");
646 >    h = (TH1F*)gROOT->FindObject("h");
647 >    h->SetNameTitle(hRelRsp[ibin]->GetName(),hRelRsp[ibin]->GetTitle());
648 >    h->SetXTitle(hRelRsp[ibin]->GetXaxis()->GetTitle());
649 >    h->SetYTitle(hRelRsp[ibin]->GetYaxis()->GetTitle());
650 >    delete hRelRsp[ibin];
651 >    hRelRsp[ibin] = h;
652 >    
653      delete tVar[ibin];
654    }
655    
656    delete [] tVar;
657   }
658  
659 +
660 + //______________________________________________________________________________
661 + void replaceHistos(int nbins1,int nbins2,
662 +                   TH1F***& hVar,TH1F***& hEtCorr,TH1F***& hAbsRsp,TH1F***& hRelRsp,
663 +                   TTree***& tVar)
664 + {
665 +  if (nbins1==0) return;
666 +  
667 +  for (int i1=0;i1<nbins1;i1++)
668 +    replaceHistos(nbins2,hVar[i1],hEtCorr[i1],hAbsRsp[i1],hRelRsp[i1],tVar[i1]);
669 +  delete [] tVar;
670 + }
671 +
672 +
673 + //______________________________________________________________________________
674 + void replaceHistos(int nbins1,int nbins2,int nbins3,
675 +                   TH1F****& hVar,TH1F****& hEtCorr,TH1F****&hAbsRsp,TH1F****&hRelRsp,
676 +                   TTree****& tVar)
677 + {
678 +  if (nbins1==0) return;
679 +  for (int i1=0;i1<nbins1;i1++)
680 +    replaceHistos(nbins2,nbins3,
681 +                  hVar[i1],hEtCorr[i1],hAbsRsp[i1],hRelRsp[i1],tVar[i1]);
682 +  delete [] tVar;
683 + }
684 +
685 +
686   //______________________________________________________________________________
687   void fitHistos(TH1F** histos,int n,double nsigma)
688   {
# Line 462 | Line 696 | void fitHistos(TH1F** histos,int n,doubl
696      f->SetParameter(2,rms);
697      f->SetLineWidth(1);
698      f->SetLineColor(kRed);
699 <    histos[i]->Fit(f,"QR");
699 >    histos[i]->Fit(f,"QR"); // Avoid TCanvas?
700    }
701   }
702  
# Line 470 | Line 704 | void fitHistos(TH1F** histos,int n,doubl
704   //______________________________________________________________________________
705   void fitHistos(TH1F*** histos,int n1,int n2,double nsigma)
706   {
707 +  if (n1==0||n2==0) return;
708    for (int i1=0;i1<n1;i1++) fitHistos(histos[i1],n2,nsigma);
709   }
710  
711  
712   //______________________________________________________________________________
713 < void saveHistos(TH1F** histos,int n)
713 > void fitHistos(TH1F**** histos,int n1,int n2,int n3,double nsigma)
714   {
715 <  for (int i=0;i<n;i++) histos[i]->Write();
715 >  if (n1==0||n2==0||n3==0) return;
716 >  for (int i1=0;i1<n1;i1++) fitHistos(histos[i1],n2,n3,nsigma);
717   }
718  
719  
720   //______________________________________________________________________________
721 < void saveHistos(TH1F*** histos,int n1,int n2)
721 > void saveHistos(TH1F**& histos,int n)
722   {
723 +  if (n==0) return;
724 +  for (int i=0;i<n;i++) {
725 +    histos[i]->Write();
726 +    delete histos[i];
727 +  }
728 +  delete [] histos;
729 + }
730 +
731 +
732 + //______________________________________________________________________________
733 + void saveHistos(TH1F***& histos,int n1,int n2)
734 + {
735 +  if (n1==0) return;
736    for (int i1=0;i1<n1;i1++) saveHistos(histos[i1],n2);
737 +  delete [] histos;
738 + }
739 +
740 +
741 + //______________________________________________________________________________
742 + void saveHistos(TH1F****& histos,int n1,int n2,int n3)
743 + {
744 +  if (n1==0) return;
745 +  for (int i1=0;i1<n1;i1++) saveHistos(histos[i1],n2,n3);
746 +  delete [] histos;
747   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines