StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
combineHistograms9.C
1 void combineHistograms9(const char *dirName, const char **inNames, const char *outName, int nCent) {
2 
3  // -- Calculate \Delta\rho/\sqrt{\rho_{ref}} for all quantities, i.e. Phi-Phi, Eta-Eta, DPhi-DEta etc.
4  //
5  // root.exe -q -b combineHistograms9.C("dir","inFileList","outFileName",numFiles)
6  //
7  // inFileList contains centrality information, so I can have a list
8  // like {"Data1", "Data2",...} or {"Sum0_1", "Sum2_3",...}
9  // Before getting here we use hadd to add histograms from different jobs
10  // creating files we call Data{n}.root (where n is a centrality bin)
11  // then we may combine centralities be merging the Data{n} files tagging
12  // histograms with z-vertex index and creating files Sum{n1}_{n2}.root where
13  // n1 and n2 are the limits of the centrality bin range.
14 
15  gROOT->LoadMacro("load2ptLibs.C");
16  load2ptLibs();
17  gSystem->Load("StEStructPoolSupport.so");
18 
19  TFile *tf;
20  StEStructSupport *ehelp;
21  TH2D **ptsedp;
22  TH2D **ptsedpC;
23  TH2D **ptdedp;
24  TH2D **ptdedpC;
25  TH2D **sedp;
26  TH2D **sedpC;
27  TH2D **dedp;
28  TH2D **dedpC;
29  TH2D **ptetaeta;
30  TH2D **ptetaetaC;
31  TH2D **etaeta;
32  TH2D **etaetaC;
33  TH2D **ptphiphi;
34  TH2D **ptphiphiC;
35  TH2D **phiphi;
36  TH2D **phiphiC;
37 
38  const char* binName[]={"all","soft","hard","below4","below3","below2","below1","above1","above2","above3","above4","one","onetwo","onethree","two","twothree","three"};
39  const char* chargeName[] = {"_LS_", "_US_", "_CD_", "_CI_"};
40  const char* chargeType[] = {"_PP_", "_PM_", "_MP_", "_MM_"};
41  char outFileName[1024];
42  sprintf(outFileName,"%s/%s.root",dirName,outName);
43  TFile *out = new TFile(outFileName,"RECREATE");
44 
45  char inFileName[1024];
46 
47  // For axial space near/away side is not useful.
48  for (int ic=0;ic<nCent;ic++) {
49  printf("Centrality %2i: d2N/dEdP pHat_{A+} pHat_{A-} pHat_{B+} pHat_{B-}\n",ic);
50  for (int ibin=0;ibin<17;ibin++) {
51  sprintf(inFileName,"%s/%s%s.root",dirName,inNames[ic],binName[ibin]);
52  tf = new TFile(inFileName);
53  tf->cd();
54  ehelp = new StEStructSupport(tf,0);
55  ehelp->msilent = true;
56  ehelp->mapplyDEtaFix = false;
57  ehelp->mPairNormalization = true;
58  ehelp->mIdenticalPair = true;
59  ehelp->setBGMode(0);
60  int subtract = 1;
61 
62  ptsedpC = ehelp->buildPtCommon("SEtaDPhi",2,subtract);
63  ptdedpC = ehelp->buildPtCommon("DEtaDPhi",2,subtract);
64  ptetaetaC = ehelp->buildPtCommon("EtaEta",2,subtract);
65  ptphiphiC = ehelp->buildPtCommon("PhiPhi",2,subtract);
66 
67  ptsedp = ehelp->buildPtChargeTypes("SEtaDPhi",2,subtract);
68  ptdedp = ehelp->buildPtChargeTypes("DEtaDPhi",2,subtract);
69  ptetaeta = ehelp->buildPtChargeTypes("EtaEta",2,subtract);
70  ptphiphi = ehelp->buildPtChargeTypes("PhiPhi",2,subtract);
71 
72  sedpC = ehelp->buildCommon("SEtaDPhi",2);
73  dedpC = ehelp->buildCommon("DEtaDPhi",2);
74  etaetaC = ehelp->buildCommon("EtaEta",2);
75  phiphiC = ehelp->buildCommon("PhiPhi",2);
76 
77  sedp = ehelp->buildChargeTypes("SEtaDPhi",2);
78  dedp = ehelp->buildChargeTypes("DEtaDPhi",2);
79  etaeta = ehelp->buildChargeTypes("EtaEta",2);
80  phiphi = ehelp->buildChargeTypes("PhiPhi",2);
81 
82  out->cd();
83  for (int icharge=0;icharge<4;icharge++) {
84  TString name(binName[ibin]);
85  name += "_NDEtaDPhi"; name += chargeName[icharge]; name += ic;
86  if (dedp) {
87  dedp[icharge]->SetName(name.Data());
88  dedp[icharge]->SetTitle(name.Data());
89  dedp[icharge]->Write();
90  }
91  TString name(binName[ibin]);
92  name += "_NSEtaDPhi"; name += chargeName[icharge]; name += ic;
93  if (sedp) {
94  sedp[icharge]->SetName(name.Data());
95  sedp[icharge]->SetTitle(name.Data());
96  sedp[icharge]->Write();
97  }
98  TString name(binName[ibin]);
99  name += "_PtDEtaDPhi"; name += chargeName[icharge]; name += ic;
100  if (ptdedp) {
101  ptdedp[icharge]->SetName(name.Data());
102  ptdedp[icharge]->SetTitle(name.Data());
103  ptdedp[icharge]->Write();
104  }
105  TString name(binName[ibin]);
106  name += "_PtSEtaDPhi"; name += chargeName[icharge]; name += ic;
107  if (ptsedp) {
108  ptsedp[icharge]->SetName(name.Data());
109  ptsedp[icharge]->SetTitle(name.Data());
110  ptsedp[icharge]->Write();
111  }
112 
113  TString name(binName[ibin]);
114  name += "_NDEtaDPhi"; name += chargeType[icharge]; name += ic;
115  if (dedpC) {
116  dedpC[icharge]->SetName(name.Data());
117  dedpC[icharge]->SetTitle(name.Data());
118  dedpC[icharge]->Write();
119  }
120  TString name(binName[ibin]);
121  name += "_NSEtaDPhi"; name += chargeType[icharge]; name += ic;
122  if (sedpC) {
123  sedpC[icharge]->SetName(name.Data());
124  sedpC[icharge]->SetTitle(name.Data());
125  sedpC[icharge]->Write();
126  }
127  TString name(binName[ibin]);
128  name += "_PtDEtaDPhi"; name += chargeType[icharge]; name += ic;
129  if (ptdedpC) {
130  ptdedpC[icharge]->SetName(name.Data());
131  ptdedpC[icharge]->SetTitle(name.Data());
132  ptdedpC[icharge]->Write();
133  }
134  TString name(binName[ibin]);
135  name += "_PtSEtaDPhi"; name += chargeType[icharge]; name += ic;
136  if (ptsedpC) {
137  ptsedpC[icharge]->SetName(name.Data());
138  ptsedpC[icharge]->SetTitle(name.Data());
139  ptsedpC[icharge]->Write();
140  }
141 
142 
143  TString name(binName[ibin]);
144  name += "_NEtaEta"; name += chargeName[icharge]; name += ic;
145  if (etaeta) {
146  etaeta[icharge]->SetName(name.Data());
147  etaeta[icharge]->SetTitle(name.Data());
148  etaeta[icharge]->Write();
149  }
150  TString name(binName[ibin]);
151  name += "_PtEtaEta"; name += chargeName[icharge]; name += ic;
152  if (ptetaeta) {
153  ptetaeta[icharge]->SetName(name.Data());
154  ptetaeta[icharge]->SetTitle(name.Data());
155  ptetaeta[icharge]->Write();
156  }
157 
158  TString name(binName[ibin]);
159  name += "_NEtaEta"; name += chargeType[icharge]; name += ic;
160  if (etaetaC) {
161  etaetaC[icharge]->SetName(name.Data());
162  etaetaC[icharge]->SetTitle(name.Data());
163  etaetaC[icharge]->Write();
164  }
165  TString name(binName[ibin]);
166  name += "_PtEtaEta"; name += chargeType[icharge]; name += ic;
167  if (ptetaetaC) {
168  ptetaetaC[icharge]->SetName(name.Data());
169  ptetaetaC[icharge]->SetTitle(name.Data());
170  ptetaetaC[icharge]->Write();
171  }
172 
173 
174  TString name(binName[ibin]);
175  name += "_NPhiPhi"; name += chargeName[icharge]; name += ic;
176  if (phiphi) {
177  phiphi[icharge]->SetName(name.Data());
178  phiphi[icharge]->SetTitle(name.Data());
179  phiphi[icharge]->Write();
180  }
181  TString name(binName[ibin]);
182  name += "_PtPhiPhi"; name += chargeName[icharge]; name += ic;
183  if (ptphiphi) {
184  ptphiphi[icharge]->SetName(name.Data());
185  ptphiphi[icharge]->SetTitle(name.Data());
186  ptphiphi[icharge]->Write();
187  }
188 
189  TString name(binName[ibin]);
190  name += "_NPhiPhi"; name += chargeType[icharge]; name += ic;
191  if (phiphiC) {
192  phiphiC[icharge]->SetName(name.Data());
193  phiphiC[icharge]->SetTitle(name.Data());
194  phiphiC[icharge]->Write();
195  }
196  TString name(binName[ibin]);
197  name += "_PtPhiPhi"; name += chargeType[icharge]; name += ic;
198  if (ptphiphiC) {
199  ptphiphiC[icharge]->SetName(name.Data());
200  ptphiphiC[icharge]->SetTitle(name.Data());
201  ptphiphiC[icharge]->Write();
202  }
203  }
204  // Calculate and print scale factors
205  double scale = ehelp->getCIdNdEtadPhi();
206  double *ptHat = ehelp->getptHat();
207  printf(" bin %8s %7.3f %7.3f %7.3f %7.3f %7.3f\n",binName[ibin],scale,ptHat[0],ptHat[1],ptHat[2],ptHat[3]);
208  delete [] ptHat;
209 
210  delete tf;
211  delete ehelp;
212  }
213  }
214 
215  out->Close();
216 // delete out;
217 }