StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
addJobs.C
1 #include <iostream>
2 #include "TFile.h"
3 #include "TString.h"
4 #include "TH1D.h"
5 #include "TH2D.h"
6 
7 
8 void addJobs(const char* outFile, const char** inFile, int numFiles) {
9 
10  // -- See addCentralities.C for description.
11  // This is the same code as addCentralities.C except we are summing from parallel directories.
12  // Need to keep each z-buffer, multiplicity sub-bin and job separate so we can add ratios
13  // in selectAll.
14  // Had I been more clever I would have made the loop over input files flexible enough
15  // to handle adding jobs or summing centralities within a job.
16  //
17 
18  // Need to determine how many cutBins, parentBins and zBuffers in each file.
19  // I think we need the same numbers of cutBins and parentBins, but we can
20  // allow a different number of zBuffers
21  // Add copying of Density histograms if they are in the file.
22  int nZBins, nzBin[20], ozBin[20], nTotZBins = 0;
23  int nCuts, nCutBins;
24  int nDens, nDenBins;
25  int nParents, nParentBins;
26  for (int jf=0;jf<numFiles;jf++) {
27 cout << "Input file " << inFile[jf] << endl;
28  TFile *in = new TFile(inFile[jf]);
29 
30  nZBins = 0;
31  TString name("NEventsSib_zBuf_"); name += nZBins;
32  while (gDirectory->Get(name.Data())) {
33  name = "NEventsSib_zBuf_"; name += nZBins;
34  nZBins++;
35  }
36  nZBins--;
37  nParents = 0;
38  name = "meanPtP_parentBin"; name += nParents; name += "_zBuf_0";
39  while (gDirectory->Get(name.Data())) {
40  name ="meanPtP_parentBin"; name += nParents; name += "_zBuf_0";
41  nParents++;
42  }
43  nParents--;
44 
45  // Had been looking for number of YtYt histograms to define number of cut bins.
46  // YtYt is now an optional set of histograms.
47  // Look for DEtaDPhi now. So far we always require those.
48  nCuts = 0;
49  name = "SibppDEtaDPhiArr_cutBin_"; name += nCuts; name += "_zBuf_0";
50  while (gDirectory->Get(name.Data())) {
51  name ="SibppDEtaDPhiArr_cutBin_"; name += nCuts; name += "_zBuf_0";
52  nCuts++;
53  }
54  nCuts--;
55 
56  nDens = 0;
57  name = "SibppTPCAvgTSep_cutBin_"; name += nDens; name += "_zBuf_0";
58  while (gDirectory->Get(name.Data())) {
59  name ="SibppTPCAvgTSep_cutBin_"; name += nDens; name += "_zBuf_0";
60  nDens++;
61  }
62  nDens--;
63 
64  nzBin[jf] = nZBins;
65  ozBin[jf] = nTotZBins;
66  nTotZBins += nZBins;
67  if (0 == jf) {
68  nParentBins = nParents;
69  nCutBins = nCuts;
70  nDenBins = nDens;
71  } else {
72  if (nParents != nParentBins) {
73  cout<<"Error in ParentBins. First file had "<< nParentBins << " while file " << jf << " has " << nParents << endl;
74  return;
75  }
76  if (nCuts != nCutBins) {
77  cout<<"Error in CutBins. First file had "<< nCutBins << " while file " << jf << " has " << nCuts << endl;
78  return;
79  }
80  if (nDens != nDenBins) {
81  cout<<"Error in DensityBins. First file had "<< nDenBins << " while file " << jf << " has " << nDens << endl;
82  return;
83  }
84  }
85  in->Close();
86  delete in;
87  }
88 
89  // Declare histograms
90  TH1D *tmp;
91  TH1D *mHmix = 0;
92  TH1D *mHcb = 0;
93  TH1D *mHptAll = 0;
94  TH2D *mHMixedDistance = 0;
95  TH2D *mHMixedMults = 0;
96  TH2D *tmp2;
97 
98  // Hack: Should do memory allocation, but since these are only arrays of pointers
99  // I will just declare them to be bigger than I need.
100  if (nTotZBins > 100) {
101  cout << "Oops... I declared total number of Z bins as less than 100. You have " << nTotZBins << endl;
102  return;
103  }
104  TH1D *mHNEventsSib[100];
105  TH1D *mHNEventsMix[100];
106  TH1D *mHNEventsPosSib[100];
107  TH1D *mHNEventsPosMix[100];
108  TH1D *mHNEventsNegSib[100];
109  TH1D *mHNEventsNegMix[100];
110 
111  if (nParentBins > 20) {
112  cout << "Oops... I declared number of Parent bins as less than 20. You have " << nParentBins << endl;
113  return;
114  }
115  TH1D *mHMeanPtP[20][100];
116  TH1D *mHMeanPtM[20][100];
117  TH1D *mHEtaP[20][100];
118  TH1D *mHEtaM[20][100];
119 
120  if (nCutBins > 40) {
121  cout << "Oops... I declared number of Cut bins as less than 40. You have " << nCutBins << endl;
122  return;
123  }
124  TH2D *mHYtYt[40][100][8];
125  TH2D *mHNYtYt[40][100][8];
126  TH2D *mHPtPt[40][100][8];
127 
128  TH2D *mHPhiPhi[40][100][8];
129  TH2D *mHNPhiPhi[40][100][8];
130  TH2D *mHEtaEta[40][100][8];
131  TH2D *mHPrPhiPhi[40][100][8];
132  TH2D *mHPrEtaEta[40][100][8];
133  TH2D *mHPaPhiPhi[40][100][8];
134  TH2D *mHPaEtaEta[40][100][8];
135  TH2D *mHPbPhiPhi[40][100][8];
136  TH2D *mHPbEtaEta[40][100][8];
137 
138  TH2D *mHAtSYtDYt[40][100][8];
139  TH2D *mHAtNSYtDYt[40][100][8];
140  TH2D *mHJtDEtaDPhi[40][100][8];
141  TH2D *mHJtNDEtaDPhi[40][100][8];
142  TH2D *mHPrJtDEtaDPhi[40][100][8];
143  TH2D *mHPaJtDEtaDPhi[40][100][8];
144  TH2D *mHPbJtDEtaDPhi[40][100][8];
145 
146  TH2D *mHJtSEtaDPhi[40][100][8];
147  TH2D *mHJtNSEtaDPhi[40][100][8];
148  TH2D *mHPrJtSEtaDPhi[40][100][8];
149  TH2D *mHPaJtSEtaDPhi[40][100][8];
150  TH2D *mHPbJtSEtaDPhi[40][100][8];
151 
152  TH1D *mHQinv[40][100][8];
153  TH1D *mHNQinv[40][100][8];
154 
155  // Density histograms. TPC separation
156  if (nDenBins > 40) {
157  cout << "Oops... I declared number of Density bins as less than 40. You have " << nDenBins << endl;
158  return;
159  }
160  TH1D *mHTPCAvgTSep[40][100][8];
161  TH1D *mHTPCAvgZSep[40][100][8];
162  TH1D *mHTPCEntTSep[40][100][8];
163  TH1D *mHTPCEntZSep[40][100][8];
164  TH1D *mHTPCMidTSep[40][100][8];
165  TH1D *mHTPCMidZSep[40][100][8];
166  TH1D *mHTPCExitTSep[40][100][8];
167  TH1D *mHTPCExitZSep[40][100][8];
168 
169  TH1D *mHTPCMidTdptP[40][100][8];
170  TH1D *mHTPCMidTdptN[40][100][8];
171  TH1D *mHTPCMidZdptP[40][100][8];
172  TH1D *mHTPCMidZdptN[40][100][8];
173 
174  TH2D *mHTPCAvgTZ[40][100][8];
175  TH2D *mHTPCEntTZ[40][100][8];
176  TH2D *mHTPCMidTZ[40][100][8];
177  TH2D *mHTPCMidTZC[40][100][8];
178  TH2D *mHTPCMidTZNC[40][100][8];
179  TH2D *mHTPCExitTZ[40][100][8];
180  TH2D *mHTPCEntTdpt[40][100][8];
181  TH2D *mHTPCMidTdpt[40][100][8];
182  TH2D *mHTPCExitTdpt[40][100][8];
183 
184  TFile *out = new TFile(outFile,"RECREATE");
185 
186  // With histograms declared we can loop over files making clones.
187  for (int jf=0;jf<numFiles;jf++) {
188 cout << "Opening input file " << jf << endl;
189  TFile *in = new TFile(inFile[jf]);
190 
191  // Couple of histograms with no cutBin, parentBin or zBuf information.
192  // For first file we make clones, rest of the files we add to existing histograms.
193  in->GetObject("EventMixing",tmp);
194  if (tmp) {
195  if (mHmix) {
196  mHmix->Add(tmp);
197  } else {
198  out->cd();
199  mHmix = (TH1D *) tmp->Clone();
200  }
201  }
202  in->GetObject("hcb",tmp);
203  if (tmp) {
204  if (mHcb) {
205  mHcb->Add(tmp);
206  } else {
207  out->cd();
208  mHcb = (TH1D *) tmp->Clone();
209  }
210  }
211  in->GetObject("ptAll",tmp);
212  if (tmp) {
213  if (mHptAll) {
214  mHptAll->Add(tmp);
215  } else {
216  out->cd();
217  mHptAll = (TH1D *) tmp->Clone();
218  }
219  }
220  in->GetObject("MixedDistance",tmp2);
221  if (tmp2) {
222  if (mHMixedDistance) {
223  mHMixedDistance->Add(tmp2);
224  } else {
225  out->cd();
226  mHMixedDistance = (TH2D *) tmp2->Clone();
227  }
228  }
229  in->GetObject("MixedMults",tmp2);
230  if (tmp2) {
231  if (mHMixedMults) {
232  mHMixedMults->Add(tmp2);
233  } else {
234  out->cd();
235  mHMixedMults = (TH2D *) tmp2->Clone();
236  }
237  }
238 
239 
240  // First set integrated over cutBins (and parentBins)
241  TString histName, outName;
242  for (int iz=0;iz<nzBin[jf];iz++) {
243  histName = "NEventsSib_zBuf_"; histName += iz;
244  in->GetObject(histName.Data(),tmp);
245  out->cd();
246  mHNEventsSib[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
247  outName = "NEventsSib_zBuf_"; outName += iz+ozBin[jf];
248  mHNEventsSib[iz+ozBin[jf]]->SetName(outName.Data());
249 
250  histName = "NEventsMix_zBuf_"; histName += iz;
251  in->GetObject(histName.Data(),tmp);
252  out->cd();
253  mHNEventsMix[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
254  outName = "NEventsMix_zBuf_"; outName += iz+ozBin[jf];
255  mHNEventsMix[iz+ozBin[jf]]->SetName(outName.Data());
256 
257  histName = "NEventsPosSib_zBuf_"; histName += iz;
258  in->GetObject(histName.Data(),tmp);
259  out->cd();
260  mHNEventsPosSib[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
261  outName = "NEventsPosSib_zBuf_"; outName += iz+ozBin[jf];
262  mHNEventsPosSib[iz+ozBin[jf]]->SetName(outName.Data());
263 
264  histName = "NEventsPosMix_zBuf_"; histName += iz;
265  in->GetObject(histName.Data(),tmp);
266  out->cd();
267  mHNEventsPosMix[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
268  outName = "NEventsPosMix_zBuf_"; outName += iz+ozBin[jf];
269  mHNEventsPosMix[iz+ozBin[jf]]->SetName(outName.Data());
270 
271  histName = "NEventsNegSib_zBuf_"; histName += iz;
272  in->GetObject(histName.Data(),tmp);
273  out->cd();
274  mHNEventsNegSib[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
275  outName = "NEventsNegSib_zBuf_"; outName += iz+ozBin[jf];
276  mHNEventsNegSib[iz+ozBin[jf]]->SetName(outName.Data());
277 
278  histName = "NEventsNegMix_zBuf_"; histName += iz;
279  in->GetObject(histName.Data(),tmp);
280  out->cd();
281  mHNEventsNegMix[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
282  outName = "NEventsNegMix_zBuf_"; outName += iz+ozBin[jf];
283  mHNEventsNegMix[iz+ozBin[jf]]->SetName(outName.Data());
284  }
285 
286  // Second set is per parent bin (and zBuf)
287  for (int iz=0;iz<nzBin[jf];iz++) {
288  for (int ip=0;ip<nParentBins;ip++) {
289  histName = "meanPtP_parentBin"; histName += ip; histName += "_zBuf_"; histName += iz;
290  in->GetObject(histName.Data(),tmp);
291  out->cd();
292  mHMeanPtP[ip][iz+ozBin[jf]] = (TH1D *) tmp->Clone();
293  outName = "meanPtP_parentBin"; outName += ip; outName += "_zBuf_"; outName += iz+ozBin[jf];
294  mHMeanPtP[ip][iz+ozBin[jf]]->SetName(outName.Data());
295 
296  histName = "meanPtM_parentBin"; histName += ip; histName += "_zBuf_"; histName += iz;
297  in->GetObject(histName.Data(),tmp);
298  out->cd();
299  mHMeanPtM[ip][iz+ozBin[jf]] = (TH1D *) tmp->Clone();
300  outName = "meanPtM_parentBin"; outName += ip; outName += "_zBuf_"; outName += iz+ozBin[jf];
301  mHMeanPtM[ip][iz+ozBin[jf]]->SetName(outName.Data());
302 
303  histName = "etaP_parentBin"; histName += ip; histName += "_zBuf_"; histName += iz;
304  in->GetObject(histName.Data(),tmp);
305  out->cd();
306  mHEtaP[ip][iz+ozBin[jf]] = (TH1D *) tmp->Clone();
307  outName = "etaP_parentBin"; outName += ip; outName += "_zBuf_"; outName += iz+ozBin[jf];
308  mHEtaP[ip][iz+ozBin[jf]]->SetName(outName.Data());
309 
310  histName = "etaM_parentBin"; histName += ip; histName += "_zBuf_"; histName += iz;
311  in->GetObject(histName.Data(),tmp);
312  out->cd();
313  mHEtaM[ip][iz+ozBin[jf]] = (TH1D *) tmp->Clone();
314  outName = "etaM_parentBin"; outName += ip; outName += "_zBuf_"; outName += iz+ozBin[jf];
315  mHEtaM[ip][iz+ozBin[jf]]->SetName(outName.Data());
316  }
317  }
318 
319 
320 
321  // Largest set is per cut bin.
322  char *type[] = {"Sibpp", "Sibpm", "Sibmp", "Sibmm", "Mixpp", "Mixpm", "Mixmp", "Mixmm"};
323  for (int iz=0;iz<nzBin[jf];iz++) {
324 cout << "Loop over main histograms: zBin = " << iz << endl;
325  for (int ic=0;ic<nCutBins;ic++) {
326  for (int it=0;it<8;it++) {
327  histName = type[it]; histName += "YtYt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
328  in->GetObject(histName.Data(),tmp2);
329  if (tmp2) {
330  out->cd();
331  mHYtYt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
332  outName = type[it]; outName += "YtYt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
333  mHYtYt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
334  } else {
335  mHYtYt[ic][iz+ozBin[jf]][it] = 0;
336  }
337 
338  histName = type[it]; histName += "NYtYt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
339  in->GetObject(histName.Data(),tmp2);
340  if (tmp2) {
341  out->cd();
342  mHNYtYt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
343  outName = type[it]; outName += "NYtYt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
344  mHNYtYt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
345  } else {
346  mHNYtYt[ic][iz+ozBin[jf]][it] = 0;
347  }
348  histName = type[it]; histName += "PtPt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
349  in->GetObject(histName.Data(),tmp2);
350  if (tmp2) {
351  out->cd();
352  mHPtPt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
353  outName = type[it]; outName += "PtPt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
354  mHPtPt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
355  } else {
356  mHPtPt[ic][iz+ozBin[jf]][it] = 0;
357  }
358 
359 
360  histName = type[it]; histName += "PhiPhi_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
361  in->GetObject(histName.Data(),tmp2);
362  if (tmp2) {
363  out->cd();
364  mHPhiPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
365  outName = type[it]; outName += "PhiPhi_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
366  mHPhiPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
367  } else {
368  mHPhiPhi[ic][iz+ozBin[jf]][it] = 0;
369  }
370 
371  histName = type[it]; histName += "NPhiPhi_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
372  in->GetObject(histName.Data(),tmp2);
373  if (tmp2) {
374  out->cd();
375  mHNPhiPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
376  outName = type[it]; outName += "NPhiPhi_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
377  mHNPhiPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
378  } else {
379  mHNPhiPhi[ic][iz+ozBin[jf]][it] = 0;
380  }
381 
382  histName = type[it]; histName += "EtaEta_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
383  in->GetObject(histName.Data(),tmp2);
384  if (tmp2) {
385  out->cd();
386  mHEtaEta[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
387  outName = type[it]; outName += "EtaEta_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
388  mHEtaEta[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
389  } else {
390  mHEtaEta[ic][iz+ozBin[jf]][it] = 0;
391  }
392 
393  histName = type[it]; histName += "PrPhiPhi_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
394  in->GetObject(histName.Data(),tmp2);
395  if (tmp2) {
396  out->cd();
397  mHPrPhiPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
398  outName = type[it]; outName += "PrPhiPhi_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
399  mHPrPhiPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
400  } else {
401  mHPrPhiPhi[ic][iz+ozBin[jf]][it] = 0;
402  }
403 
404  histName = type[it]; histName += "PrEtaEta_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
405  in->GetObject(histName.Data(),tmp2);
406  if (tmp2) {
407  out->cd();
408  mHPrEtaEta[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
409  outName = type[it]; outName += "PrEtaEta_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
410  mHPrEtaEta[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
411  } else {
412  mHPrEtaEta[ic][iz+ozBin[jf]][it] = 0;
413  }
414 
415  histName = type[it]; histName += "PaPhiPhi_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
416  in->GetObject(histName.Data(),tmp2);
417  if (tmp2) {
418  out->cd();
419  mHPaPhiPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
420  outName = type[it]; outName += "PaPhiPhi_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
421  mHPaPhiPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
422  } else {
423  mHPaPhiPhi[ic][iz+ozBin[jf]][it] = 0;
424  }
425 
426  histName = type[it]; histName += "PaEtaEta_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
427  in->GetObject(histName.Data(),tmp2);
428  if (tmp2) {
429  out->cd();
430  mHPaEtaEta[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
431  outName = type[it]; outName += "PaEtaEta_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
432  mHPaEtaEta[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
433  } else {
434  mHPaEtaEta[ic][iz+ozBin[jf]][it] = 0;
435  }
436 
437  histName = type[it]; histName += "PbPhiPhi_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
438  in->GetObject(histName.Data(),tmp2);
439  if (tmp2) {
440  out->cd();
441  mHPbPhiPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
442  outName = type[it]; outName += "PbPhiPhi_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
443  mHPbPhiPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
444  } else {
445  mHPbPhiPhi[ic][iz+ozBin[jf]][it] = 0;
446  }
447 
448  histName = type[it]; histName += "PbEtaEta_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
449  in->GetObject(histName.Data(),tmp2);
450  if (tmp2) {
451  out->cd();
452  mHPbEtaEta[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
453  outName = type[it]; outName += "PbEtaEta_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
454  mHPbEtaEta[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
455  } else {
456  mHPbEtaEta[ic][iz+ozBin[jf]][it] = 0;
457  }
458 
459 
460  histName = type[it]; histName += "SYtDYt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
461  in->GetObject(histName.Data(),tmp2);
462  if (tmp2) {
463  out->cd();
464  mHAtSYtDYt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
465  outName = type[it]; outName += "SYtDYt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
466  mHAtSYtDYt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
467  } else {
468  mHAtSYtDYt[ic][iz+ozBin[jf]][it] = 0;
469  }
470 
471  histName = type[it]; histName += "NSYtDYt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
472  in->GetObject(histName.Data(),tmp2);
473  if (tmp2) {
474  out->cd();
475  mHAtNSYtDYt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
476  outName = type[it]; outName += "NSYtDYt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
477  mHAtNSYtDYt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
478  } else {
479  mHAtNSYtDYt[ic][iz+ozBin[jf]][it] = 0;
480  }
481 
482  histName = type[it]; histName += "DEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
483  in->GetObject(histName.Data(),tmp2);
484  if (tmp2) {
485  out->cd();
486  mHJtDEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
487  outName = type[it]; outName += "DEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
488  mHJtDEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
489  } else {
490  mHJtDEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
491  }
492 
493  histName = type[it]; histName += "NDEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
494  in->GetObject(histName.Data(),tmp2);
495  if (tmp2) {
496  out->cd();
497  mHJtNDEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
498  outName = type[it]; outName += "NDEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
499  mHJtNDEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
500  } else {
501  mHJtNDEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
502  }
503 
504  histName = type[it]; histName += "PrDEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
505  in->GetObject(histName.Data(),tmp2);
506  if (tmp2) {
507  out->cd();
508  mHPrJtDEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
509  outName = type[it]; outName += "PrDEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
510  mHPrJtDEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
511  } else {
512  mHPrJtDEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
513  }
514 
515  histName = type[it]; histName += "PaDEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
516  in->GetObject(histName.Data(),tmp2);
517  if (tmp2) {
518  out->cd();
519  mHPaJtDEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
520  outName = type[it]; outName += "PaDEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
521  mHPaJtDEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
522  } else {
523  mHPaJtDEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
524  }
525 
526  histName = type[it]; histName += "PbDEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
527  in->GetObject(histName.Data(),tmp2);
528  if (tmp2) {
529  out->cd();
530  mHPbJtDEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
531  outName = type[it]; outName += "PbDEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
532  mHPbJtDEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
533  } else {
534  mHPbJtDEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
535  }
536 
537 
538  histName = type[it]; histName += "SEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
539  in->GetObject(histName.Data(),tmp2);
540  if (tmp2) {
541  out->cd();
542  mHJtSEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
543  outName = type[it]; outName += "SEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
544  mHJtSEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
545  } else {
546  mHJtSEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
547  }
548 
549  histName = type[it]; histName += "NSEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
550  in->GetObject(histName.Data(),tmp2);
551  if (tmp2) {
552  out->cd();
553  mHJtNSEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
554  outName = type[it]; outName += "NSEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
555  mHJtNSEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
556  } else {
557  mHJtNSEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
558  }
559 
560  histName = type[it]; histName += "PrSEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
561  in->GetObject(histName.Data(),tmp2);
562  if (tmp2) {
563  out->cd();
564  mHPrJtSEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
565  outName = type[it]; outName += "PrSEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
566  mHPrJtSEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
567  } else {
568  mHPrJtSEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
569  }
570 
571  histName = type[it]; histName += "PaSEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
572  in->GetObject(histName.Data(),tmp2);
573  if (tmp2) {
574  out->cd();
575  mHPaJtSEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
576  outName = type[it]; outName += "PaSEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
577  mHPaJtSEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
578  } else {
579  mHPaJtSEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
580  }
581 
582  histName = type[it]; histName += "PbSEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
583  in->GetObject(histName.Data(),tmp2);
584  if (tmp2) {
585  out->cd();
586  mHPbJtSEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
587  outName = type[it]; outName += "PbSEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
588  mHPbJtSEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
589  } else {
590  mHPbJtSEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
591  }
592 
593 
594  histName = type[it]; histName += "Qinv_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
595  in->GetObject(histName.Data(),tmp);
596  if (tmp) {
597  out->cd();
598  mHQinv[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
599  outName = type[it]; outName += "Qinv_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
600  mHQinv[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
601  } else {
602  mHQinv[ic][iz+ozBin[jf]][it] = 0;
603  }
604 
605  histName = type[it]; histName += "NQinv_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
606  in->GetObject(histName.Data(),tmp);
607  if (tmp) {
608  out->cd();
609  mHNQinv[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
610  outName = type[it]; outName += "NQinv_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
611  mHNQinv[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
612  } else {
613  mHNQinv[ic][iz+ozBin[jf]][it] = 0;
614  }
615  }
616  }
617  }
618 
619  // Density histograms are per cutbin for most cutbinning modes.
620  char *type[] = {"Sibpp", "Sibpm", "Sibmp", "Sibmm", "Mixpp", "Mixpm", "Mixmp", "Mixmm"};
621 
622 
623  for (int iz=0;iz<nzBin[jf];iz++) {
624 cout << "Loop over density histograms: zBin = " << iz << endl;
625  for (int ic=0;ic<nDenBins;ic++) {
626  for (int it=0;it<8;it++) {
627  histName = type[it]; histName += "TPCAvgTSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
628  in->GetObject(histName.Data(),tmp2);
629  out->cd();
630  mHTPCAvgTSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
631  outName = type[it]; outName += "TPCAvgTSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
632  mHTPCAvgTSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
633 
634  histName = type[it]; histName += "TPCAvgZSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
635  in->GetObject(histName.Data(),tmp2);
636  out->cd();
637  mHTPCAvgZSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
638  outName = type[it]; outName += "TPCAvgZSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
639  mHTPCAvgZSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
640 
641  histName = type[it]; histName += "TPCEntTSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
642  in->GetObject(histName.Data(),tmp2);
643  out->cd();
644  mHTPCEntTSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
645  outName = type[it]; outName += "TPCEntTSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
646  mHTPCEntTSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
647 
648  histName = type[it]; histName += "TPCEntZSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
649  in->GetObject(histName.Data(),tmp2);
650  out->cd();
651  mHTPCEntZSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
652  outName = type[it]; outName += "TPCEntZSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
653  mHTPCEntZSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
654 
655  histName = type[it]; histName += "TPCMidTSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
656  in->GetObject(histName.Data(),tmp2);
657  out->cd();
658  mHTPCMidTSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
659  outName = type[it]; outName += "TPCMidTSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
660  mHTPCMidTSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
661 
662  histName = type[it]; histName += "TPCMidZSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
663  in->GetObject(histName.Data(),tmp2);
664  out->cd();
665  mHTPCMidZSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
666  outName = type[it]; outName += "TPCMidZSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
667  mHTPCMidZSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
668 
669  histName = type[it]; histName += "TPCExitTSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
670  in->GetObject(histName.Data(),tmp2);
671  out->cd();
672  mHTPCExitTSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
673  outName = type[it]; outName += "TPCExitTSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
674  mHTPCExitTSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
675 
676  histName = type[it]; histName += "TPCExitZSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
677  in->GetObject(histName.Data(),tmp2);
678  out->cd();
679  mHTPCExitZSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
680  outName = type[it]; outName += "TPCExitZSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
681  mHTPCExitZSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
682 
683 
684  histName = type[it]; histName += "TPCMidTdptP_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
685  in->GetObject(histName.Data(),tmp2);
686  out->cd();
687  mHTPCMidTdptP[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
688  outName = type[it]; outName += "TPCMidTdptP_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
689  mHTPCMidTdptP[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
690 
691  histName = type[it]; histName += "TPCMidTdptN_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
692  in->GetObject(histName.Data(),tmp2);
693  out->cd();
694  mHTPCMidTdptN[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
695  outName = type[it]; outName += "TPCMidTdptN_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
696  mHTPCMidTdptN[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
697 
698  histName = type[it]; histName += "TPCMidZdptP_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
699  in->GetObject(histName.Data(),tmp2);
700  out->cd();
701  mHTPCMidZdptP[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
702  outName = type[it]; outName += "TPCMidZdptP_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
703  mHTPCMidZdptP[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
704 
705  histName = type[it]; histName += "TPCMidZdptN_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
706  in->GetObject(histName.Data(),tmp2);
707  out->cd();
708  mHTPCMidZdptN[ic][iz+ozBin[jf]][it] = (TH1D *) tmp2->Clone();
709  outName = type[it]; outName += "TPCMidZdptN_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
710  mHTPCMidZdptN[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
711 
712  histName = type[it]; histName += "TPCAvgTZ_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
713  in->GetObject(histName.Data(),tmp2);
714  out->cd();
715  mHTPCAvgTZ[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
716  outName = type[it]; outName += "TPCAvgTZ_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
717  mHTPCAvgTZ[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
718 
719  histName = type[it]; histName += "TPCEntTZ_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
720  in->GetObject(histName.Data(),tmp2);
721  out->cd();
722  mHTPCEntTZ[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
723  outName = type[it]; outName += "TPCEntTZ_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
724  mHTPCEntTZ[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
725 
726  histName = type[it]; histName += "TPCMidTZ_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
727  in->GetObject(histName.Data(),tmp2);
728  out->cd();
729  mHTPCMidTZ[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
730  outName = type[it]; outName += "TPCMidTZ_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
731  mHTPCMidTZ[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
732 
733  histName = type[it]; histName += "TPCMidTZC_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
734  in->GetObject(histName.Data(),tmp2);
735  out->cd();
736  mHTPCMidTZC[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
737  outName = type[it]; outName += "TPCMidTZC_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
738  mHTPCMidTZC[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
739 
740  histName = type[it]; histName += "TPCMidTZNC_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
741  in->GetObject(histName.Data(),tmp2);
742  out->cd();
743  mHTPCMidTZNC[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
744  outName = type[it]; outName += "TPCMidTZNC_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
745  mHTPCMidTZNC[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
746 
747  histName = type[it]; histName += "TPCExitTZ_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
748  in->GetObject(histName.Data(),tmp2);
749  out->cd();
750  mHTPCExitTZ[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
751  outName = type[it]; outName += "TPCExitTZ_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
752  mHTPCExitTZ[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
753 
754  histName = type[it]; histName += "TPCEntTdpt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
755  in->GetObject(histName.Data(),tmp2);
756  out->cd();
757  mHTPCEntTdpt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
758  outName = type[it]; outName += "TPCEntTdpt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
759  mHTPCEntTdpt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
760 
761  histName = type[it]; histName += "TPCMidTdpt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
762  in->GetObject(histName.Data(),tmp2);
763  out->cd();
764  mHTPCMidTdpt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
765  outName = type[it]; outName += "TPCMidTdpt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
766  mHTPCMidTdpt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
767 
768  histName = type[it]; histName += "TPCExitTdpt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
769  in->GetObject(histName.Data(),tmp2);
770  out->cd();
771  mHTPCExitTdpt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
772  outName = type[it]; outName += "TPCExitTdpt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
773  mHTPCExitTdpt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
774  }
775  }
776  }
777 cout << "Closing input file " << jf << endl;
778 // Close seems to take an awfully long time. Try leaving file hanging and hope system cleans up quickly.
779 // in->Close();
780 // delete in;
781  }
782 
783  // Now write out all histograms.
784 
785  out->cd();
786  if (mHmix) {
787  mHmix->Write();
788  }
789  if (mHcb) {
790  mHcb->Write();
791  }
792  if (mHptAll) {
793  mHptAll->Write();
794  }
795  if (mHMixedDistance) {
796  mHMixedDistance->Write();
797  }
798  if (mHMixedMults) {
799  mHMixedMults->Write();
800  }
801 
802  for (int iz=0;iz<nTotZBins;iz++) {
803  mHNEventsSib[iz]->Write();
804  mHNEventsMix[iz]->Write();
805  mHNEventsPosSib[iz]->Write();
806  mHNEventsPosMix[iz]->Write();
807  mHNEventsNegSib[iz]->Write();
808  mHNEventsNegMix[iz]->Write();
809 
810  for (int ip=0;ip<nParentBins;ip++) {
811  mHMeanPtP[ip][iz]->Write();
812  mHMeanPtM[ip][iz]->Write();
813  mHEtaP[ip][iz]->Write();
814  mHEtaM[ip][iz]->Write();
815  }
816 
817  for (int ic=0;ic<nCutBins;ic++) {
818  for (int it=0;it<8;it++) {
819  if (mHYtYt[ic][iz][it]) mHYtYt[ic][iz][it]->Write();
820  if (mHNYtYt[ic][iz][it]) mHNYtYt[ic][iz][it]->Write();
821  if (mHPtPt[ic][iz][it]) mHPtPt[ic][iz][it]->Write();
822 
823  if (mHPhiPhi[ic][iz][it]) mHPhiPhi[ic][iz][it]->Write();
824  if (mHNPhiPhi[ic][iz][it]) mHNPhiPhi[ic][iz][it]->Write();
825  if (mHEtaEta[ic][iz][it]) mHEtaEta[ic][iz][it]->Write();
826  if (mHPrPhiPhi[ic][iz][it]) mHPrPhiPhi[ic][iz][it]->Write();
827  if (mHPrEtaEta[ic][iz][it]) mHPrEtaEta[ic][iz][it]->Write();
828  if (mHPaPhiPhi[ic][iz][it]) mHPaPhiPhi[ic][iz][it]->Write();
829  if (mHPaEtaEta[ic][iz][it]) mHPaEtaEta[ic][iz][it]->Write();
830  if (mHPbPhiPhi[ic][iz][it]) mHPbPhiPhi[ic][iz][it]->Write();
831  if (mHPbEtaEta[ic][iz][it]) mHPbEtaEta[ic][iz][it]->Write();
832 
833  if (mHAtSYtDYt[ic][iz][it]) mHAtSYtDYt[ic][iz][it]->Write();
834  if (mHAtNSYtDYt[ic][iz][it]) mHAtNSYtDYt[ic][iz][it]->Write();
835  if (mHJtDEtaDPhi[ic][iz][it]) mHJtDEtaDPhi[ic][iz][it]->Write();
836  if (mHJtNDEtaDPhi[ic][iz][it]) mHJtNDEtaDPhi[ic][iz][it]->Write();
837  if (mHPrJtDEtaDPhi[ic][iz][it]) mHPrJtDEtaDPhi[ic][iz][it]->Write();
838  if (mHPaJtDEtaDPhi[ic][iz][it]) mHPaJtDEtaDPhi[ic][iz][it]->Write();
839  if (mHPbJtDEtaDPhi[ic][iz][it]) mHPbJtDEtaDPhi[ic][iz][it]->Write();
840 
841  if (mHJtSEtaDPhi[ic][iz][it]) mHJtSEtaDPhi[ic][iz][it]->Write();
842  if (mHJtNSEtaDPhi[ic][iz][it]) mHJtNSEtaDPhi[ic][iz][it]->Write();
843  if (mHPrJtSEtaDPhi[ic][iz][it]) mHPrJtSEtaDPhi[ic][iz][it]->Write();
844  if (mHPaJtSEtaDPhi[ic][iz][it]) mHPaJtSEtaDPhi[ic][iz][it]->Write();
845  if (mHPbJtSEtaDPhi[ic][iz][it]) mHPbJtSEtaDPhi[ic][iz][it]->Write();
846 
847  if (mHQinv[ic][iz][it]) mHQinv[ic][iz][it]->Write();
848  if (mHNQinv[ic][iz][it]) mHNQinv[ic][iz][it]->Write();
849  }
850  }
851 
852  for (int ic=0;ic<nDenBins;ic++) {
853  for (int it=0;it<8;it++) {
854  mHTPCAvgTSep[ic][iz][it]->Write();
855  mHTPCAvgZSep[ic][iz][it]->Write();
856  mHTPCEntTSep[ic][iz][it]->Write();
857  mHTPCEntZSep[ic][iz][it]->Write();
858  mHTPCMidTSep[ic][iz][it]->Write();
859  mHTPCMidZSep[ic][iz][it]->Write();
860  mHTPCExitTSep[ic][iz][it]->Write();
861  mHTPCExitZSep[ic][iz][it]->Write();
862 
863  mHTPCMidTdptP[ic][iz][it]->Write();
864  mHTPCMidTdptN[ic][iz][it]->Write();
865  mHTPCMidZdptP[ic][iz][it]->Write();
866  mHTPCMidZdptN[ic][iz][it]->Write();
867 
868  mHTPCAvgTZ[ic][iz][it]->Write();
869  mHTPCEntTZ[ic][iz][it]->Write();
870  mHTPCMidTZ[ic][iz][it]->Write();
871  mHTPCMidTZC[ic][iz][it]->Write();
872  mHTPCMidTZNC[ic][iz][it]->Write();
873  mHTPCExitTZ[ic][iz][it]->Write();
874  mHTPCEntTdpt[ic][iz][it]->Write();
875  mHTPCMidTdpt[ic][iz][it]->Write();
876  mHTPCExitTdpt[ic][iz][it]->Write();
877  }
878  }
879  }
880 // Actually closing file seems to take an infinite amount of time.
881 // I think data is already on disk.
882 // out->Close();
883 // delete out;
884  // That's all (I hope).
885 }