StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
addCentralities.C
1 #include <iostream>
2 #include "TFile.h"
3 #include "TString.h"
4 #include "TH1D.h"
5 #include "TH2D.h"
6 
7  /* 09/27/12 djp Now taking eta range from Cuts file. Had been interrogating
8  * binning class for detaMax. Extract from special purpose histogram ("EtaPhiRange") instead.
9  * For this to work I need to pass histogram to sum file.
10  */
11 
12 void addCentralities(const char* dirName, const char* inFile, const char* outFile, int *nFile, int numFiles) {
13 
14  // -- Combine files by renaming z-buffer indices. This allows the Support code to
15  // calculate the ratios for all centralitles and z-buffers.
16  // Note: The assumption built in here is that you have split a centrality bin into parts
17  // because the acceptance or efficiency of each part is different. When combining
18  // centrality bins or z-buffers we form the ratio \Delta\rho/\rho_{ref} and do a
19  // weighted averages of these. An alternative method of combining centralities
20  // would be to sum \rho (sib and mix separately) over centralities for each z-buffer,
21  // then average \Delta\rho/\rho_{ref}. If that's what you wanted you probably
22  // shouldn't have split the centrality bin to begin with.
23  //
24  // root.exe -q -b addCentralities.C("dir","inFileBase","outFile", nFile, numFiles)
25  //
26  // where dir is directory to look for histogram files,
27  // inFileBase will be something like "Data" (where we append 0, 1, 2 etc to get actual name)
28  // outFile is name of out file (such as Sum5_6, dir will be pre-pended and .root appended)
29  // nFile will be an array like int numbers[] = {5, 6, 7}
30  // and numFiles is the number of entries in nFile (3 in this case.)
31  //
32 
33  // Need to determine how many cutBins, parentBins and zBuffers in each file.
34  // I think we need the same numbers of cutBins and parentBins, but we can
35  // allow a different number of zBuffers
36  // Add copying of Density histograms if they are in the file.
37  int nZBins, nzBin[20], ozBin[20], nTotZBins = 0;
38  int nCuts, nCutBins;
39  int nDens, nDenBins;
40  int nParents, nParentBins;
41  for (int jf=0;jf<numFiles;jf++) {
42  TString fileName(dirName); fileName += "/"; fileName += inFile; fileName += nFile[jf]; fileName += ".root";
43 cout << "Input file " << fileName.Data() << endl;
44  TFile *in = new TFile(fileName.Data());
45 
46  nZBins = 0;
47  TString name("NEventsSib_zBuf_"); name += nZBins;
48  while (in->Get(name.Data())) {
49  name = "NEventsSib_zBuf_"; name += nZBins;
50  nZBins++;
51  }
52  nZBins--;
53  nParents = 0;
54  name = "meanPtP_parentBin"; name += nParents; name += "_zBuf_0";
55  while (in->Get(name.Data())) {
56  name ="meanPtP_parentBin"; name += nParents; name += "_zBuf_0";
57  nParents++;
58  }
59  nParents--;
60 
61  // Had been looking for number of YtYt histograms to define number of cut bins.
62  // YtYt is now an optional set of histograms.
63  // Look for DEtaDPhi now. So far we always require those.
64  nCuts = 0;
65  name = "SibppDEtaDPhiArr_cutBin_"; name += nCuts; name += "_zBuf_0";
66  while (in->Get(name.Data())) {
67  name ="SibppDEtaDPhiArr_cutBin_"; name += nCuts; name += "_zBuf_0";
68  nCuts++;
69  }
70  nCuts--;
71 
72  nDens = 0;
73  name = "SibppTPCAvgTSep_cutBin_"; name += nDens; name += "_zBuf_0";
74  while (in->Get(name.Data())) {
75  name ="SibppTPCAvgTSep_cutBin_"; name += nDens; name += "_zBuf_0";
76  nDens++;
77  }
78  nDens--;
79 
80  nzBin[jf] = nZBins;
81  ozBin[jf] = nTotZBins;
82  nTotZBins += nZBins;
83  if (0 == jf) {
84  nParentBins = nParents;
85  nCutBins = nCuts;
86  nDenBins = nDens;
87  } else {
88  if (nParents != nParentBins) {
89  cout<<"Error in ParentBins. First file had "<< nParentBins << " while file " << jf << " has " << nParents << endl;
90  return;
91  }
92  if (nCuts != nCutBins) {
93  cout<<"Error in CutBins. First file had "<< nCutBins << " while file " << jf << " has " << nCuts << endl;
94  return;
95  }
96  if (nDens != nDenBins) {
97  cout<<"Error in DensityBins. First file had "<< nDenBins << " while file " << jf << " has " << nDens << endl;
98  return;
99  }
100  }
101  in->Close();
102  delete in;
103  }
104 
105  // Declare histograms
106  TH1D *tmp;
107 // TH1D *mHmix;
108  TH1D *mHcb;
109  TH1D *mHptAll;
110  TH2D *mHEtaPhi;
111  TH2D *tmp2;
112 
113  TH2D *mHMixed_Z_dN;
114  TH2D *mHMixed_Z_N;
115  TH2D *mHMixed_Z_dC;
116  TH2D *mHMixed_Z_C;
117  TH2D *mHMixed_Z_dZ;
118  TH2D *mHMixed_dZ_dN;
119  TH2D *mHMixed_dZ_N;
120  TH2D *mHMixed_dZ_dC;
121  TH2D *mHMixed_dZ_C;
122  TH2D *mHMixed_N_C;
123  TH2D *mHMixed_N_dC;
124  TH2D *mHMixed_N_dN;
125  TH2D *mHMixed_dN_C;
126  TH2D *mHMixed_dN_dC;
127  TH2D *mHMixed_C_dC;
128 
129  // Hack: Should do memory allocation, but since these are only arrays of pointers
130  // I will just declare them to be bigger than I need.
131  if (nTotZBins > 100) {
132  cout << "Oops... I declared total number of Z bins as less than 100. You have " << nTotZBins << endl;
133  return;
134  }
135  TH1D *mHNEventsSib[100];
136  TH1D *mHNEventsMix[100];
137  TH1D *mHNEventsPosSib[100];
138  TH1D *mHNEventsPosMix[100];
139  TH1D *mHNEventsNegSib[100];
140  TH1D *mHNEventsNegMix[100];
141 
142  if (nParentBins > 20) {
143  cout << "Oops... I declared number of Parent bins as less than 20. You have " << nParentBins << endl;
144  return;
145  }
146  TH1D *mHMeanPtP[20][100];
147  TH1D *mHMeanPtM[20][100];
148  TH1D *mHEtaP[20][100];
149  TH1D *mHEtaM[20][100];
150 
151  if (nCutBins > 50) {
152  cout << "Oops... I declared number of Cut bins as less than 50. You have " << nCutBins << endl;
153  return;
154  }
155  TH2D *mHYtYt[50][100][8];
156  TH2D *mHNYtYt[50][100][8];
157  TH2D *mHPtPt[50][100][8];
158 
159  TH2D *mHPhiPhi[50][100][8];
160  TH2D *mHNPhiPhi[50][100][8];
161  TH2D *mHEtaEta[50][100][8];
162  TH2D *mHPrPhiPhi[50][100][8];
163  TH2D *mHPrEtaEta[50][100][8];
164  TH2D *mHPaPhiPhi[50][100][8];
165  TH2D *mHPaEtaEta[50][100][8];
166  TH2D *mHPbPhiPhi[50][100][8];
167  TH2D *mHPbEtaEta[50][100][8];
168 
169  TH2D *mHAtSYtDYt[50][100][8];
170  TH2D *mHAtNSYtDYt[50][100][8];
171  TH2D *mHJtDEtaDPhi[50][100][8];
172  TH2D *mHJtNDEtaDPhi[50][100][8];
173  TH2D *mHPrJtDEtaDPhi[50][100][8];
174  TH2D *mHPaJtDEtaDPhi[50][100][8];
175  TH2D *mHPbJtDEtaDPhi[50][100][8];
176 
177  TH2D *mHJtSEtaDPhi[50][100][8];
178  TH2D *mHJtNSEtaDPhi[50][100][8];
179  TH2D *mHPrJtSEtaDPhi[50][100][8];
180  TH2D *mHPaJtSEtaDPhi[50][100][8];
181  TH2D *mHPbJtSEtaDPhi[50][100][8];
182 
183  TH1D *mHQinv[50][100][8];
184  TH1D *mHNQinv[50][100][8];
185 
186  // Density histograms. TPC separation
187  if (nDenBins > 40) {
188  cout << "Oops... I declared number of Density bins as less than 40. You have " << nDenBins << endl;
189  return;
190  }
191  TH1D *mHTPCAvgTSep[40][100][8];
192  TH1D *mHTPCAvgZSep[40][100][8];
193  TH1D *mHTPCEntTSep[40][100][8];
194  TH1D *mHTPCEntZSep[40][100][8];
195  TH1D *mHTPCMidTSep[40][100][8];
196  TH1D *mHTPCMidZSep[40][100][8];
197  TH1D *mHTPCExitTSep[40][100][8];
198  TH1D *mHTPCExitZSep[40][100][8];
199 
200  TH1D *mHTPCMidTdptP[40][100][8];
201  TH1D *mHTPCMidTdptN[40][100][8];
202  TH1D *mHTPCMidZdptP[40][100][8];
203  TH1D *mHTPCMidZdptN[40][100][8];
204 
205  TH2D *mHTPCAvgTZ[40][100][8];
206  TH2D *mHTPCEntTZ[40][100][8];
207  TH2D *mHTPCMidTZ[40][100][8];
208  TH2D *mHTPCMidTZC[40][100][8];
209  TH2D *mHTPCMidTZNC[40][100][8];
210  TH2D *mHTPCExitTZ[40][100][8];
211  TH2D *mHTPCEntTdpt[40][100][8];
212  TH2D *mHTPCMidTdpt[40][100][8];
213  TH2D *mHTPCExitTdpt[40][100][8];
214 
215  TString fileName(dirName); fileName += "/"; fileName += outFile; fileName += ".root";
216  TFile *out = new TFile(fileName.Data(),"RECREATE");
217 
218  // With histograms declared we can loop over files making clones.
219  for (int jf=0;jf<numFiles;jf++) {
220 cout << "Opening input file " << jf << endl;
221  TString fileName(dirName); fileName += "/"; fileName += inFile; fileName += nFile[jf]; fileName += ".root";
222  TFile *in = new TFile(fileName.Data());
223 
224  // Couple of histograms with no cutBin, parentBin or zBuf information.
225  // For first file we make clones, rest of the files we add to existing histograms.
226 // in->GetObject("EventMixing",tmp);
227 // out->cd();
228 // if (0 == jf) {
229 // mHmix = (TH1D *) tmp->Clone();
230 // } else {
231 // mHmix->Add(tmp);
232 // }
233  // Seem to have changed hcb to a 2D histogram at some point.
234  // Use explicit cast.
235  tmp = (TH1D *) in->Get("hcb");
236  out->cd();
237  if (0 == jf) {
238  mHcb = (TH1D *) tmp->Clone();
239  } else {
240  mHcb->Add(tmp);
241  }
242  in->GetObject("ptAll",tmp);
243  out->cd();
244  if (0 == jf) {
245  mHptAll = (TH1D *) tmp->Clone();
246  } else {
247  mHptAll->Add(tmp);
248  }
249  in->GetObject("EtaPhiRange",tmp2);
250  out->cd();
251  if (0 == jf) {
252  mHEtaPhi = (TH2D *) tmp2->Clone();
253  } else {
254  mHEtaPhi->Add(tmp2);
255  }
256 
257  in->GetObject("Mixed_Z_dN",tmp2);
258  // Can't count on mixed event quality information always being there.
259  // If one of the histograms exist assume thay all do.
260  if (tmp2) {
261  out->cd();
262  if (0 == jf) {
263  mHMixed_Z_dN = (TH2D *) tmp2->Clone();
264  } else {
265  mHMixed_Z_dN->Add(tmp2);
266  }
267  in->GetObject("Mixed_Z_N",tmp2);
268  out->cd();
269  if (0 == jf) {
270  mHMixed_Z_N = (TH2D *) tmp2->Clone();
271  } else {
272  mHMixed_Z_N->Add(tmp2);
273  }
274  in->GetObject("Mixed_Z_dC",tmp2);
275  out->cd();
276  if (0 == jf) {
277  mHMixed_Z_dC = (TH2D *) tmp2->Clone();
278  } else {
279  mHMixed_Z_dC->Add(tmp2);
280  }
281  in->GetObject("Mixed_Z_C",tmp2);
282  out->cd();
283  if (0 == jf) {
284  mHMixed_Z_C = (TH2D *) tmp2->Clone();
285  } else {
286  mHMixed_Z_C->Add(tmp2);
287  }
288  in->GetObject("Mixed_Z_dZ",tmp2);
289  out->cd();
290  if (0 == jf) {
291  mHMixed_Z_dZ = (TH2D *) tmp2->Clone();
292  } else {
293  mHMixed_Z_dZ->Add(tmp2);
294  }
295  in->GetObject("Mixed_dZ_dN",tmp2);
296  out->cd();
297  if (0 == jf) {
298  mHMixed_dZ_dN = (TH2D *) tmp2->Clone();
299  } else {
300  mHMixed_dZ_dN->Add(tmp2);
301  }
302  in->GetObject("Mixed_dZ_N",tmp2);
303  out->cd();
304  if (0 == jf) {
305  mHMixed_dZ_N = (TH2D *) tmp2->Clone();
306  } else {
307  mHMixed_dZ_N->Add(tmp2);
308  }
309  in->GetObject("Mixed_dZ_dC",tmp2);
310  out->cd();
311  if (0 == jf) {
312  mHMixed_dZ_dC = (TH2D *) tmp2->Clone();
313  } else {
314  mHMixed_dZ_dC->Add(tmp2);
315  }
316  in->GetObject("Mixed_dZ_C",tmp2);
317  out->cd();
318  if (0 == jf) {
319  mHMixed_dZ_C = (TH2D *) tmp2->Clone();
320  } else {
321  mHMixed_dZ_C->Add(tmp2);
322  }
323  in->GetObject("Mixed_N_dC",tmp2);
324  out->cd();
325  if (0 == jf) {
326  mHMixed_N_dC = (TH2D *) tmp2->Clone();
327  } else {
328  mHMixed_N_dC->Add(tmp2);
329  }
330  in->GetObject("Mixed_N_C",tmp2);
331  out->cd();
332  if (0 == jf) {
333  mHMixed_N_C = (TH2D *) tmp2->Clone();
334  } else {
335  mHMixed_N_C->Add(tmp2);
336  }
337  in->GetObject("Mixed_N_dN",tmp2);
338  out->cd();
339  if (0 == jf) {
340  mHMixed_N_dN = (TH2D *) tmp2->Clone();
341  } else {
342  mHMixed_N_dN->Add(tmp2);
343  }
344  in->GetObject("Mixed_dN_dC",tmp2);
345  out->cd();
346  if (0 == jf) {
347  mHMixed_dN_dC = (TH2D *) tmp2->Clone();
348  } else {
349  mHMixed_dN_dC->Add(tmp2);
350  }
351  in->GetObject("Mixed_dN_C",tmp2);
352  out->cd();
353  if (0 == jf) {
354  mHMixed_dN_C = (TH2D *) tmp2->Clone();
355  } else {
356  mHMixed_dN_C->Add(tmp2);
357  }
358  in->GetObject("Mixed_C_dC",tmp2);
359  out->cd();
360  if (0 == jf) {
361  mHMixed_C_dC = (TH2D *) tmp2->Clone();
362  } else {
363  mHMixed_C_dC->Add(tmp2);
364  }
365  } else {
366  mHMixed_Z_dN = 0;
367  mHMixed_Z_N = 0;
368  mHMixed_Z_dC = 0;
369  mHMixed_Z_C = 0;
370  mHMixed_Z_dZ = 0;
371  mHMixed_dZ_dN = 0;
372  mHMixed_dZ_N = 0;
373  mHMixed_dZ_dC = 0;
374  mHMixed_dZ_C = 0;
375  mHMixed_N_C = 0;
376  mHMixed_N_dC = 0;
377  mHMixed_N_dN = 0;
378  mHMixed_dN_C = 0;
379  mHMixed_dN_dC = 0;
380  mHMixed_C_dC = 0;
381  }
382 
383 
384  // First set integrated over cutBins (and parentBins)
385  TString histName, outName;
386  for (int iz=0;iz<nzBin[jf];iz++) {
387  histName = "NEventsSib_zBuf_"; histName += iz;
388  in->GetObject(histName.Data(),tmp);
389  out->cd();
390  mHNEventsSib[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
391  outName = "NEventsSib_zBuf_"; outName += iz+ozBin[jf];
392  mHNEventsSib[iz+ozBin[jf]]->SetName(outName.Data());
393 
394  histName = "NEventsMix_zBuf_"; histName += iz;
395  in->GetObject(histName.Data(),tmp);
396  out->cd();
397  mHNEventsMix[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
398  outName = "NEventsMix_zBuf_"; outName += iz+ozBin[jf];
399  mHNEventsMix[iz+ozBin[jf]]->SetName(outName.Data());
400 
401  histName = "NEventsPosSib_zBuf_"; histName += iz;
402  in->GetObject(histName.Data(),tmp);
403  out->cd();
404  mHNEventsPosSib[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
405  outName = "NEventsPosSib_zBuf_"; outName += iz+ozBin[jf];
406  mHNEventsPosSib[iz+ozBin[jf]]->SetName(outName.Data());
407 
408  histName = "NEventsPosMix_zBuf_"; histName += iz;
409  in->GetObject(histName.Data(),tmp);
410  out->cd();
411  mHNEventsPosMix[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
412  outName = "NEventsPosMix_zBuf_"; outName += iz+ozBin[jf];
413  mHNEventsPosMix[iz+ozBin[jf]]->SetName(outName.Data());
414 
415  histName = "NEventsNegSib_zBuf_"; histName += iz;
416  in->GetObject(histName.Data(),tmp);
417  out->cd();
418  mHNEventsNegSib[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
419  outName = "NEventsNegSib_zBuf_"; outName += iz+ozBin[jf];
420  mHNEventsNegSib[iz+ozBin[jf]]->SetName(outName.Data());
421 
422  histName = "NEventsNegMix_zBuf_"; histName += iz;
423  in->GetObject(histName.Data(),tmp);
424  out->cd();
425  mHNEventsNegMix[iz+ozBin[jf]] = (TH1D *) tmp->Clone();
426  outName = "NEventsNegMix_zBuf_"; outName += iz+ozBin[jf];
427  mHNEventsNegMix[iz+ozBin[jf]]->SetName(outName.Data());
428  }
429 
430  // Second set is per parent bin (and zBuf)
431  for (int iz=0;iz<nzBin[jf];iz++) {
432  for (int ip=0;ip<nParentBins;ip++) {
433  histName = "meanPtP_parentBin"; histName += ip; histName += "_zBuf_"; histName += iz;
434  in->GetObject(histName.Data(),tmp);
435  out->cd();
436  mHMeanPtP[ip][iz+ozBin[jf]] = (TH1D *) tmp->Clone();
437  outName = "meanPtP_parentBin"; outName += ip; outName += "_zBuf_"; outName += iz+ozBin[jf];
438  mHMeanPtP[ip][iz+ozBin[jf]]->SetName(outName.Data());
439 
440  histName = "meanPtM_parentBin"; histName += ip; histName += "_zBuf_"; histName += iz;
441  in->GetObject(histName.Data(),tmp);
442  out->cd();
443  mHMeanPtM[ip][iz+ozBin[jf]] = (TH1D *) tmp->Clone();
444  outName = "meanPtM_parentBin"; outName += ip; outName += "_zBuf_"; outName += iz+ozBin[jf];
445  mHMeanPtM[ip][iz+ozBin[jf]]->SetName(outName.Data());
446 
447  histName = "etaP_parentBin"; histName += ip; histName += "_zBuf_"; histName += iz;
448  in->GetObject(histName.Data(),tmp);
449  out->cd();
450  mHEtaP[ip][iz+ozBin[jf]] = (TH1D *) tmp->Clone();
451  outName = "etaP_parentBin"; outName += ip; outName += "_zBuf_"; outName += iz+ozBin[jf];
452  mHEtaP[ip][iz+ozBin[jf]]->SetName(outName.Data());
453 
454  histName = "etaM_parentBin"; histName += ip; histName += "_zBuf_"; histName += iz;
455  in->GetObject(histName.Data(),tmp);
456  out->cd();
457  mHEtaM[ip][iz+ozBin[jf]] = (TH1D *) tmp->Clone();
458  outName = "etaM_parentBin"; outName += ip; outName += "_zBuf_"; outName += iz+ozBin[jf];
459  mHEtaM[ip][iz+ozBin[jf]]->SetName(outName.Data());
460  }
461  }
462 
463 
464 
465  // Largest set is per cut bin.
466  char *type[] = {"Sibpp", "Sibpm", "Sibmp", "Sibmm", "Mixpp", "Mixpm", "Mixmp", "Mixmm"};
467  for (int iz=0;iz<nzBin[jf];iz++) {
468 cout << "Loop over main histograms: zBin = " << iz << endl;
469  for (int ic=0;ic<nCutBins;ic++) {
470  for (int it=0;it<8;it++) {
471  histName = type[it]; histName += "YtYt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
472  in->GetObject(histName.Data(),tmp2);
473  if (tmp2) {
474  out->cd();
475  mHYtYt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
476  outName = type[it]; outName += "YtYt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
477  mHYtYt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
478  } else {
479  mHYtYt[ic][iz+ozBin[jf]][it] = 0;
480  }
481 
482  histName = type[it]; histName += "NYtYt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
483  in->GetObject(histName.Data(),tmp2);
484  if (tmp2) {
485  out->cd();
486  mHNYtYt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
487  outName = type[it]; outName += "NYtYt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
488  mHNYtYt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
489  } else {
490  mHNYtYt[ic][iz+ozBin[jf]][it] = 0;
491  }
492  histName = type[it]; histName += "PtPt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
493  in->GetObject(histName.Data(),tmp2);
494  if (tmp2) {
495  out->cd();
496  mHPtPt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
497  outName = type[it]; outName += "PtPt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
498  mHPtPt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
499  } else {
500  mHPtPt[ic][iz+ozBin[jf]][it] = 0;
501  }
502 
503 
504  histName = type[it]; histName += "PhiPhi_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
505  in->GetObject(histName.Data(),tmp2);
506  if (tmp2) {
507  out->cd();
508  mHPhiPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
509  outName = type[it]; outName += "PhiPhi_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
510  mHPhiPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
511  } else {
512  mHPhiPhi[ic][iz+ozBin[jf]][it] = 0;
513  }
514 
515  histName = type[it]; histName += "NPhiPhi_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
516  in->GetObject(histName.Data(),tmp2);
517  if (tmp2) {
518  out->cd();
519  mHNPhiPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
520  outName = type[it]; outName += "NPhiPhi_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
521  mHNPhiPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
522  } else {
523  mHNPhiPhi[ic][iz+ozBin[jf]][it] = 0;
524  }
525 
526  histName = type[it]; histName += "EtaEta_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
527  in->GetObject(histName.Data(),tmp2);
528  if (tmp2) {
529  out->cd();
530  mHEtaEta[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
531  outName = type[it]; outName += "EtaEta_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
532  mHEtaEta[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
533  } else {
534  mHEtaEta[ic][iz+ozBin[jf]][it] = 0;
535  }
536 
537  histName = type[it]; histName += "PrPhiPhi_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
538  in->GetObject(histName.Data(),tmp2);
539  if (tmp2) {
540  out->cd();
541  mHPrPhiPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
542  outName = type[it]; outName += "PrPhiPhi_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
543  mHPrPhiPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
544  } else {
545  mHPrPhiPhi[ic][iz+ozBin[jf]][it] = 0;
546  }
547 
548  histName = type[it]; histName += "PrEtaEta_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
549  in->GetObject(histName.Data(),tmp2);
550  if (tmp2) {
551  out->cd();
552  mHPrEtaEta[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
553  outName = type[it]; outName += "PrEtaEta_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
554  mHPrEtaEta[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
555  } else {
556  mHPrEtaEta[ic][iz+ozBin[jf]][it] = 0;
557  }
558 
559  histName = type[it]; histName += "PaPhiPhi_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
560  in->GetObject(histName.Data(),tmp2);
561  if (tmp2) {
562  out->cd();
563  mHPaPhiPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
564  outName = type[it]; outName += "PaPhiPhi_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
565  mHPaPhiPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
566  } else {
567  mHPaPhiPhi[ic][iz+ozBin[jf]][it] = 0;
568  }
569 
570  histName = type[it]; histName += "PaEtaEta_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
571  in->GetObject(histName.Data(),tmp2);
572  if (tmp2) {
573  out->cd();
574  mHPaEtaEta[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
575  outName = type[it]; outName += "PaEtaEta_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
576  mHPaEtaEta[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
577  } else {
578  mHPaEtaEta[ic][iz+ozBin[jf]][it] = 0;
579  }
580 
581  histName = type[it]; histName += "PbPhiPhi_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
582  in->GetObject(histName.Data(),tmp2);
583  if (tmp2) {
584  out->cd();
585  mHPbPhiPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
586  outName = type[it]; outName += "PbPhiPhi_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
587  mHPbPhiPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
588  } else {
589  mHPbPhiPhi[ic][iz+ozBin[jf]][it] = 0;
590  }
591 
592  histName = type[it]; histName += "PbEtaEta_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
593  in->GetObject(histName.Data(),tmp2);
594  if (tmp2) {
595  out->cd();
596  mHPbEtaEta[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
597  outName = type[it]; outName += "PbEtaEta_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
598  mHPbEtaEta[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
599  } else {
600  mHPbEtaEta[ic][iz+ozBin[jf]][it] = 0;
601  }
602 
603  // SS and AS EtaEta
604  histName = type[it]; histName += "EtaEtaSS_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
605  in->GetObject(histName.Data(),tmp2);
606  if (tmp2) {
607  out->cd();
608  mHEtaEtaSS[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
609  outName = type[it]; outName += "EtaEtaSS_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
610  mHEtaEtaSS[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
611  } else {
612  mHEtaEtaSS[ic][iz+ozBin[jf]][it] = 0;
613  }
614  histName = type[it]; histName += "PrEtaEtaSS_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
615  in->GetObject(histName.Data(),tmp2);
616  if (tmp2) {
617  out->cd();
618  mHPrEtaEtaSS[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
619  outName = type[it]; outName += "PrEtaEtaSS_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
620  mHPrEtaEtaSS[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
621  } else {
622  mHPrEtaEtaSS[ic][iz+ozBin[jf]][it] = 0;
623  }
624  histName = type[it]; histName += "PaEtaEtaSS_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
625  in->GetObject(histName.Data(),tmp2);
626  if (tmp2) {
627  out->cd();
628  mHPaEtaEtaSS[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
629  outName = type[it]; outName += "PaEtaEtaSS_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
630  mHPaEtaEtaSS[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
631  } else {
632  mHPaEtaEtaSS[ic][iz+ozBin[jf]][it] = 0;
633  }
634  histName = type[it]; histName += "PbEtaEtaSS_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
635  in->GetObject(histName.Data(),tmp2);
636  if (tmp2) {
637  out->cd();
638  mHPbEtaEtaSS[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
639  outName = type[it]; outName += "PbEtaEtaSS_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
640  mHPbEtaEtaSS[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
641  } else {
642  mHPbEtaEtaSS[ic][iz+ozBin[jf]][it] = 0;
643  }
644  histName = type[it]; histName += "EtaEtaAS_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
645  in->GetObject(histName.Data(),tmp2);
646  if (tmp2) {
647  out->cd();
648  mHEtaEtaAS[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
649  outName = type[it]; outName += "EtaEtaAS_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
650  mHEtaEtaAS[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
651  } else {
652  mHEtaEtaAS[ic][iz+ozBin[jf]][it] = 0;
653  }
654  histName = type[it]; histName += "PrEtaEtaAS_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
655  in->GetObject(histName.Data(),tmp2);
656  if (tmp2) {
657  out->cd();
658  mHPrEtaEtaAS[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
659  outName = type[it]; outName += "PrEtaEtaAS_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
660  mHPrEtaEtaAS[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
661  } else {
662  mHPrEtaEtaAS[ic][iz+ozBin[jf]][it] = 0;
663  }
664  histName = type[it]; histName += "PaEtaEtaAS_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
665  in->GetObject(histName.Data(),tmp2);
666  if (tmp2) {
667  out->cd();
668  mHPaEtaEtaAS[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
669  outName = type[it]; outName += "PaEtaEtaAS_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
670  mHPaEtaEtaAS[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
671  } else {
672  mHPaEtaEtaAS[ic][iz+ozBin[jf]][it] = 0;
673  }
674  histName = type[it]; histName += "PbEtaEtaAS_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
675  in->GetObject(histName.Data(),tmp2);
676  if (tmp2) {
677  out->cd();
678  mHPbEtaEtaAS[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
679  outName = type[it]; outName += "PbEtaEtaAS_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
680  mHPbEtaEtaAS[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
681  } else {
682  mHPbEtaEtaAS[ic][iz+ozBin[jf]][it] = 0;
683  }
684 
685 
686  histName = type[it]; histName += "SYtDYt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
687  in->GetObject(histName.Data(),tmp2);
688  if (tmp2) {
689  out->cd();
690  mHAtSYtDYt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
691  outName = type[it]; outName += "SYtDYt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
692  mHAtSYtDYt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
693  } else {
694  mHAtSYtDYt[ic][iz+ozBin[jf]][it] = 0;
695  }
696 
697  histName = type[it]; histName += "NSYtDYt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
698  in->GetObject(histName.Data(),tmp2);
699  if (tmp2) {
700  out->cd();
701  mHAtNSYtDYt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
702  outName = type[it]; outName += "NSYtDYt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
703  mHAtNSYtDYt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
704  } else {
705  mHAtNSYtDYt[ic][iz+ozBin[jf]][it] = 0;
706  }
707 
708  histName = type[it]; histName += "DEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
709  in->GetObject(histName.Data(),tmp2);
710  if (tmp2) {
711  out->cd();
712  mHJtDEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
713  outName = type[it]; outName += "DEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
714  mHJtDEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
715  } else {
716  mHJtDEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
717  }
718 
719  histName = type[it]; histName += "NDEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
720  in->GetObject(histName.Data(),tmp2);
721  if (tmp2) {
722  out->cd();
723  mHJtNDEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
724  outName = type[it]; outName += "NDEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
725  mHJtNDEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
726  } else {
727  mHJtNDEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
728  }
729 
730  histName = type[it]; histName += "PrDEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
731  in->GetObject(histName.Data(),tmp2);
732  if (tmp2) {
733  out->cd();
734  mHPrJtDEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
735  outName = type[it]; outName += "PrDEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
736  mHPrJtDEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
737  } else {
738  mHPrJtDEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
739  }
740 
741  histName = type[it]; histName += "PaDEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
742  in->GetObject(histName.Data(),tmp2);
743  if (tmp2) {
744  out->cd();
745  mHPaJtDEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
746  outName = type[it]; outName += "PaDEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
747  mHPaJtDEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
748  } else {
749  mHPaJtDEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
750  }
751 
752  histName = type[it]; histName += "PbDEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
753  in->GetObject(histName.Data(),tmp2);
754  if (tmp2) {
755  out->cd();
756  mHPbJtDEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
757  outName = type[it]; outName += "PbDEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
758  mHPbJtDEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
759  } else {
760  mHPbJtDEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
761  }
762 
763 
764  histName = type[it]; histName += "SEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
765  in->GetObject(histName.Data(),tmp2);
766  if (tmp2) {
767  out->cd();
768  mHJtSEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
769  outName = type[it]; outName += "SEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
770  mHJtSEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
771  } else {
772  mHJtSEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
773  }
774 
775  histName = type[it]; histName += "NSEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
776  in->GetObject(histName.Data(),tmp2);
777  if (tmp2) {
778  out->cd();
779  mHJtNSEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
780  outName = type[it]; outName += "NSEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
781  mHJtNSEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
782  } else {
783  mHJtNSEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
784  }
785 
786  histName = type[it]; histName += "PrSEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
787  in->GetObject(histName.Data(),tmp2);
788  if (tmp2) {
789  out->cd();
790  mHPrJtSEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
791  outName = type[it]; outName += "PrSEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
792  mHPrJtSEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
793  } else {
794  mHPrJtSEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
795  }
796 
797  histName = type[it]; histName += "PaSEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
798  in->GetObject(histName.Data(),tmp2);
799  if (tmp2) {
800  out->cd();
801  mHPaJtSEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
802  outName = type[it]; outName += "PaSEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
803  mHPaJtSEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
804  } else {
805  mHPaJtSEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
806  }
807 
808  histName = type[it]; histName += "PbSEtaDPhiArr_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
809  in->GetObject(histName.Data(),tmp2);
810  if (tmp2) {
811  out->cd();
812  mHPbJtSEtaDPhi[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
813  outName = type[it]; outName += "PbSEtaDPhiArr_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
814  mHPbJtSEtaDPhi[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
815  } else {
816  mHPbJtSEtaDPhi[ic][iz+ozBin[jf]][it] = 0;
817  }
818 
819 
820  histName = type[it]; histName += "Qinv_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
821  in->GetObject(histName.Data(),tmp);
822  if (tmp) {
823  out->cd();
824  mHQinv[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
825  outName = type[it]; outName += "Qinv_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
826  mHQinv[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
827  } else {
828  mHQinv[ic][iz+ozBin[jf]][it] = 0;
829  }
830 
831  histName = type[it]; histName += "NQinv_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
832  in->GetObject(histName.Data(),tmp);
833  if (tmp) {
834  out->cd();
835  mHNQinv[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
836  outName = type[it]; outName += "NQinv_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
837  mHNQinv[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
838  } else {
839  mHNQinv[ic][iz+ozBin[jf]][it] = 0;
840  }
841  }
842  }
843  }
844 
845  // Density histograms are per cutbin for most cutbinning modes.
846  char *type[] = {"Sibpp", "Sibpm", "Sibmp", "Sibmm", "Mixpp", "Mixpm", "Mixmp", "Mixmm"};
847 
848 
849  for (int iz=0;iz<nzBin[jf];iz++) {
850 cout << "Loop over density histograms: zBin = " << iz << endl;
851  for (int ic=0;ic<nDenBins;ic++) {
852  for (int it=0;it<8;it++) {
853  histName = type[it]; histName += "TPCAvgTSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
854  in->GetObject(histName.Data(),tmp);
855  out->cd();
856  mHTPCAvgTSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
857  outName = type[it]; outName += "TPCAvgTSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
858  mHTPCAvgTSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
859 
860  histName = type[it]; histName += "TPCAvgZSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
861  in->GetObject(histName.Data(),tmp);
862  out->cd();
863  mHTPCAvgZSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
864  outName = type[it]; outName += "TPCAvgZSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
865  mHTPCAvgZSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
866 
867  histName = type[it]; histName += "TPCEntTSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
868  in->GetObject(histName.Data(),tmp);
869  out->cd();
870  mHTPCEntTSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
871  outName = type[it]; outName += "TPCEntTSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
872  mHTPCEntTSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
873 
874  histName = type[it]; histName += "TPCEntZSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
875  in->GetObject(histName.Data(),tmp);
876  out->cd();
877  mHTPCEntZSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
878  outName = type[it]; outName += "TPCEntZSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
879  mHTPCEntZSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
880 
881  histName = type[it]; histName += "TPCMidTSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
882  in->GetObject(histName.Data(),tmp);
883  out->cd();
884  mHTPCMidTSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
885  outName = type[it]; outName += "TPCMidTSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
886  mHTPCMidTSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
887 
888  histName = type[it]; histName += "TPCMidZSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
889  in->GetObject(histName.Data(),tmp);
890  out->cd();
891  mHTPCMidZSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
892  outName = type[it]; outName += "TPCMidZSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
893  mHTPCMidZSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
894 
895  histName = type[it]; histName += "TPCExitTSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
896  in->GetObject(histName.Data(),tmp);
897  out->cd();
898  mHTPCExitTSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
899  outName = type[it]; outName += "TPCExitTSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
900  mHTPCExitTSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
901 
902  histName = type[it]; histName += "TPCExitZSep_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
903  in->GetObject(histName.Data(),tmp);
904  out->cd();
905  mHTPCExitZSep[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
906  outName = type[it]; outName += "TPCExitZSep_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
907  mHTPCExitZSep[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
908 
909 
910  histName = type[it]; histName += "TPCMidTdptP_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
911  in->GetObject(histName.Data(),tmp);
912  out->cd();
913  mHTPCMidTdptP[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
914  outName = type[it]; outName += "TPCMidTdptP_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
915  mHTPCMidTdptP[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
916 
917  histName = type[it]; histName += "TPCMidTdptN_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
918  in->GetObject(histName.Data(),tmp);
919  out->cd();
920  mHTPCMidTdptN[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
921  outName = type[it]; outName += "TPCMidTdptN_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
922  mHTPCMidTdptN[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
923 
924  histName = type[it]; histName += "TPCMidZdptP_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
925  in->GetObject(histName.Data(),tmp);
926  out->cd();
927  mHTPCMidZdptP[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
928  outName = type[it]; outName += "TPCMidZdptP_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
929  mHTPCMidZdptP[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
930 
931  histName = type[it]; histName += "TPCMidZdptN_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
932  in->GetObject(histName.Data(),tmp);
933  out->cd();
934  mHTPCMidZdptN[ic][iz+ozBin[jf]][it] = (TH1D *) tmp->Clone();
935  outName = type[it]; outName += "TPCMidZdptN_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
936  mHTPCMidZdptN[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
937 
938  histName = type[it]; histName += "TPCAvgTZ_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
939  in->GetObject(histName.Data(),tmp2);
940  out->cd();
941  mHTPCAvgTZ[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
942  outName = type[it]; outName += "TPCAvgTZ_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
943  mHTPCAvgTZ[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
944 
945  histName = type[it]; histName += "TPCEntTZ_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
946  in->GetObject(histName.Data(),tmp2);
947  out->cd();
948  mHTPCEntTZ[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
949  outName = type[it]; outName += "TPCEntTZ_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
950  mHTPCEntTZ[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
951 
952  histName = type[it]; histName += "TPCMidTZ_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
953  in->GetObject(histName.Data(),tmp2);
954  out->cd();
955  mHTPCMidTZ[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
956  outName = type[it]; outName += "TPCMidTZ_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
957  mHTPCMidTZ[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
958 
959  histName = type[it]; histName += "TPCMidTZC_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
960  in->GetObject(histName.Data(),tmp2);
961  out->cd();
962  mHTPCMidTZC[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
963  outName = type[it]; outName += "TPCMidTZC_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
964  mHTPCMidTZC[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
965 
966  histName = type[it]; histName += "TPCMidTZNC_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
967  in->GetObject(histName.Data(),tmp2);
968  out->cd();
969  mHTPCMidTZNC[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
970  outName = type[it]; outName += "TPCMidTZNC_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
971  mHTPCMidTZNC[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
972 
973  histName = type[it]; histName += "TPCExitTZ_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
974  in->GetObject(histName.Data(),tmp2);
975  out->cd();
976  mHTPCExitTZ[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
977  outName = type[it]; outName += "TPCExitTZ_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
978  mHTPCExitTZ[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
979 
980  histName = type[it]; histName += "TPCEntTdpt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
981  in->GetObject(histName.Data(),tmp2);
982  out->cd();
983  mHTPCEntTdpt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
984  outName = type[it]; outName += "TPCEntTdpt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
985  mHTPCEntTdpt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
986 
987  histName = type[it]; histName += "TPCMidTdpt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
988  in->GetObject(histName.Data(),tmp2);
989  out->cd();
990  mHTPCMidTdpt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
991  outName = type[it]; outName += "TPCMidTdpt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
992  mHTPCMidTdpt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
993 
994  histName = type[it]; histName += "TPCExitTdpt_cutBin_"; histName += ic; histName += "_zBuf_"; histName += iz;
995  in->GetObject(histName.Data(),tmp2);
996  out->cd();
997  mHTPCExitTdpt[ic][iz+ozBin[jf]][it] = (TH2D *) tmp2->Clone();
998  outName = type[it]; outName += "TPCExitTdpt_cutBin_"; outName += ic; outName += "_zBuf_"; outName += iz+ozBin[jf];
999  mHTPCExitTdpt[ic][iz+ozBin[jf]][it]->SetName(outName.Data());
1000  }
1001  }
1002  }
1003 cout << "Closing input file " << jf << endl;
1004 // Close seems to take an awfully long time. Try leaving file hanging and hope system cleans up quickly.
1005 // in->Close();
1006 // delete in;
1007  }
1008 
1009  // Now write out all histograms.
1010 
1011 // mHmix->Write();
1012  mHcb->Write();
1013  mHptAll->Write();
1014  mHEtaPhi->Write();
1015 
1016  if (mHMixed_Z_dN) {
1017  mHMixed_Z_dN->Write();
1018  mHMixed_Z_N->Write();
1019  mHMixed_Z_dC->Write();
1020  mHMixed_Z_C->Write();
1021  mHMixed_Z_dZ->Write();
1022  mHMixed_dZ_dN->Write();
1023  mHMixed_dZ_N->Write();
1024  mHMixed_dZ_dC->Write();
1025  mHMixed_dZ_C->Write();
1026  mHMixed_N_dC->Write();
1027  mHMixed_N_C->Write();
1028  mHMixed_N_dN->Write();
1029  mHMixed_dN_dC->Write();
1030  mHMixed_dN_C->Write();
1031  mHMixed_C_dC->Write();
1032  }
1033 
1034  for (int iz=0;iz<nTotZBins;iz++) {
1035  mHNEventsSib[iz]->Write();
1036  mHNEventsMix[iz]->Write();
1037  mHNEventsPosSib[iz]->Write();
1038  mHNEventsPosMix[iz]->Write();
1039  mHNEventsNegSib[iz]->Write();
1040  mHNEventsNegMix[iz]->Write();
1041 
1042  for (int ip=0;ip<nParentBins;ip++) {
1043  mHMeanPtP[ip][iz]->Write();
1044  mHMeanPtM[ip][iz]->Write();
1045  mHEtaP[ip][iz]->Write();
1046  mHEtaM[ip][iz]->Write();
1047  }
1048 
1049  for (int ic=0;ic<nCutBins;ic++) {
1050  for (int it=0;it<8;it++) {
1051  if (mHYtYt[ic][iz][it]) mHYtYt[ic][iz][it]->Write();
1052  if (mHNYtYt[ic][iz][it]) mHNYtYt[ic][iz][it]->Write();
1053  if (mHPtPt[ic][iz][it]) mHPtPt[ic][iz][it]->Write();
1054 
1055  if (mHPhiPhi[ic][iz][it]) mHPhiPhi[ic][iz][it]->Write();
1056  if (mHNPhiPhi[ic][iz][it]) mHNPhiPhi[ic][iz][it]->Write();
1057  if (mHEtaEta[ic][iz][it]) mHEtaEta[ic][iz][it]->Write();
1058  if (mHPrPhiPhi[ic][iz][it]) mHPrPhiPhi[ic][iz][it]->Write();
1059  if (mHPrEtaEta[ic][iz][it]) mHPrEtaEta[ic][iz][it]->Write();
1060  if (mHPaPhiPhi[ic][iz][it]) mHPaPhiPhi[ic][iz][it]->Write();
1061  if (mHPaEtaEta[ic][iz][it]) mHPaEtaEta[ic][iz][it]->Write();
1062  if (mHPbPhiPhi[ic][iz][it]) mHPbPhiPhi[ic][iz][it]->Write();
1063  if (mHPbEtaEta[ic][iz][it]) mHPbEtaEta[ic][iz][it]->Write();
1064 
1065  if (mHEtaEtaSS[ic][iz][it]) mHEtaEtaSS[ic][iz][it]->Write();
1066  if (mHPrEtaEtaSS[ic][iz][it]) mHPrEtaEtaSS[ic][iz][it]->Write();
1067  if (mHPaEtaEtaSS[ic][iz][it]) mHPaEtaEtaSS[ic][iz][it]->Write();
1068  if (mHPbEtaEtaSS[ic][iz][it]) mHPbEtaEtaSS[ic][iz][it]->Write();
1069  if (mHEtaEtaAS[ic][iz][it]) mHEtaEtaAS[ic][iz][it]->Write();
1070  if (mHPrEtaEtaAS[ic][iz][it]) mHPrEtaEtaAS[ic][iz][it]->Write();
1071  if (mHPaEtaEtaAS[ic][iz][it]) mHPaEtaEtaAS[ic][iz][it]->Write();
1072  if (mHPbEtaEtaAS[ic][iz][it]) mHPbEtaEtaAS[ic][iz][it]->Write();
1073 
1074  if (mHAtSYtDYt[ic][iz][it]) mHAtSYtDYt[ic][iz][it]->Write();
1075  if (mHAtNSYtDYt[ic][iz][it]) mHAtNSYtDYt[ic][iz][it]->Write();
1076  if (mHJtDEtaDPhi[ic][iz][it]) mHJtDEtaDPhi[ic][iz][it]->Write();
1077  if (mHJtNDEtaDPhi[ic][iz][it]) mHJtNDEtaDPhi[ic][iz][it]->Write();
1078  if (mHPrJtDEtaDPhi[ic][iz][it]) mHPrJtDEtaDPhi[ic][iz][it]->Write();
1079  if (mHPaJtDEtaDPhi[ic][iz][it]) mHPaJtDEtaDPhi[ic][iz][it]->Write();
1080  if (mHPbJtDEtaDPhi[ic][iz][it]) mHPbJtDEtaDPhi[ic][iz][it]->Write();
1081 
1082  if (mHJtSEtaDPhi[ic][iz][it]) mHJtSEtaDPhi[ic][iz][it]->Write();
1083  if (mHJtNSEtaDPhi[ic][iz][it]) mHJtNSEtaDPhi[ic][iz][it]->Write();
1084  if (mHPrJtSEtaDPhi[ic][iz][it]) mHPrJtSEtaDPhi[ic][iz][it]->Write();
1085  if (mHPaJtSEtaDPhi[ic][iz][it]) mHPaJtSEtaDPhi[ic][iz][it]->Write();
1086  if (mHPbJtSEtaDPhi[ic][iz][it]) mHPbJtSEtaDPhi[ic][iz][it]->Write();
1087 
1088  if (mHQinv[ic][iz][it]) mHQinv[ic][iz][it]->Write();
1089  if (mHNQinv[ic][iz][it]) mHNQinv[ic][iz][it]->Write();
1090  }
1091  }
1092 
1093  for (int ic=0;ic<nDenBins;ic++) {
1094  for (int it=0;it<8;it++) {
1095  mHTPCAvgTSep[ic][iz][it]->Write();
1096  mHTPCAvgZSep[ic][iz][it]->Write();
1097  mHTPCEntTSep[ic][iz][it]->Write();
1098  mHTPCEntZSep[ic][iz][it]->Write();
1099  mHTPCMidTSep[ic][iz][it]->Write();
1100  mHTPCMidZSep[ic][iz][it]->Write();
1101  mHTPCExitTSep[ic][iz][it]->Write();
1102  mHTPCExitZSep[ic][iz][it]->Write();
1103 
1104  mHTPCMidTdptP[ic][iz][it]->Write();
1105  mHTPCMidTdptN[ic][iz][it]->Write();
1106  mHTPCMidZdptP[ic][iz][it]->Write();
1107  mHTPCMidZdptN[ic][iz][it]->Write();
1108 
1109  mHTPCAvgTZ[ic][iz][it]->Write();
1110  mHTPCEntTZ[ic][iz][it]->Write();
1111  mHTPCMidTZ[ic][iz][it]->Write();
1112  mHTPCMidTZC[ic][iz][it]->Write();
1113  mHTPCMidTZNC[ic][iz][it]->Write();
1114  mHTPCExitTZ[ic][iz][it]->Write();
1115  mHTPCEntTdpt[ic][iz][it]->Write();
1116  mHTPCMidTdpt[ic][iz][it]->Write();
1117  mHTPCExitTdpt[ic][iz][it]->Write();
1118  }
1119  }
1120  }
1121 // Actually closing file seems to take an infinite amount of time.
1122 // I think data is already on disk.
1123 // out->Close();
1124 // delete out;
1125  // That's all (I hope).
1126 }