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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines