27 void minBias(Int_t firstRunNo, Int_t lastRunNo, Int_t outputRunNo=99) {
29 const int nCens = lastRunNo - firstRunNo + 1;
33 TFile* histFile[nCens+1];
35 TH2* yieldPartHist[nCens];
36 TH1* yieldPartHistPt[nCens];
37 TH1* yieldPartHistEta[nCens];
38 Float_t yieldTotal[nCens];
41 const char* baseName[] = {
54 "Flow_v2D_ScalarProd_",
55 "Flow_vEta_ScalarProd_",
56 "Flow_vPt_ScalarProd_",
58 "Flow_Cumul_vEta_Order2_",
59 "Flow_Cumul_vPt_Order2_",
60 "Flow_Cumul_v_Order2_",
61 "Flow_Cumul_vEta_Order4_",
62 "Flow_Cumul_vPt_Order4_",
63 "Flow_Cumul_v_Order4_"
65 const int nNames =
sizeof(baseName) /
sizeof(
char*);
68 for (
int n = 0; n < nCens; n++) {
69 sprintf(fileName,
"ana%2d.root", firstRunNo + n);
70 cout <<
" file name = " << fileName << endl;
71 histFile[n] =
new TFile(fileName);
73 cout <<
"### Can't find file " << fileName << endl;
77 sprintf(fileName,
"ana%2d.root", outputRunNo);
78 cout <<
" output file name = " << fileName << endl << endl;
79 histFile[nCens] =
new TFile(fileName,
"RECREATE");
84 TIter nextkey(histFile[0]->GetListOfKeys());
85 while (key = (TKey*)nextkey()) {
90 if (obj->InheritsFrom(
"TH1")) {
92 objName = key->GetName();
93 cout <<
"hist name= " << objName << endl;
94 for (
int n = 1; n < nCens; n++) {
95 hist[1] = (TH1*)histFile[n]->Get(objName);
96 hist[0]->Add(hist[1]);
99 histFile[nCens]->cd();
107 for (
int n = 0; n < nCens; n++) {
108 yieldPartHist[n] =
dynamic_cast<TH2*
>(histFile[n]->Get(
"Flow_YieldPart2D"));
109 yieldPartHistPt[n] =
dynamic_cast<TH1*
>(histFile[n]->Get(
"FlowLYZ_YieldPartPt"));
110 yieldPartHistEta[n] =
dynamic_cast<TH1*
>(histFile[n]->Get(
"FlowLYZ_YieldPartEta"));
111 if (yieldPartHistPt[n]) { yieldTotal[n] = yieldPartHistPt[n]->Integral(); }
114 for (
int pageNumber = 0; pageNumber < nNames; pageNumber++ ) {
116 if (strstr(baseName[pageNumber],
"v2D")) twoD = kTRUE;
118 for (
int selN = 0; selN < nSels; selN++) {
121 bool noHars = kFALSE;
123 if (strstr(baseName[pageNumber],
"_v_")!=0 ||
124 strstr(baseName[pageNumber],
"Res")!=0 ||
125 strstr(baseName[pageNumber],
"_V_")!=0 ||
126 strstr(baseName[pageNumber],
"_vr0_")!=0) {
130 for (
int harN = 0; harN < nHar; harN++) {
133 TString* histName =
new TString(baseName[pageNumber]);
142 for (
int n = 0; n < nCens+1; n++) {
143 hist[n] =
dynamic_cast<TH1*
>(histFile[n]->Get(histName->Data()));
145 if (hist[0]) { cout <<
"hist name= " << histName->Data() << endl; }
147 const int lastHist = nCens;
149 if (!hist[lastHist])
continue;
150 int xBins = hist[lastHist]->GetNbinsX();
152 TH1F *yieldY, *yieldPt;
154 yBins = hist[lastHist]->GetNbinsY();
155 nBins = xBins + (xBins + 2) * yBins;
156 float yMax = hist[lastHist]->GetXaxis()->GetXmax();
157 float yMin = hist[lastHist]->GetXaxis()->GetXmin();
158 yieldY =
new TH1F(
"Yield_Y",
"Yield_Y", xBins, yMin, yMax);
159 yieldY->SetXTitle(
"Rapidity");
160 yieldY->SetYTitle(
"Counts");
161 float ptMax = hist[lastHist]->GetYaxis()->GetXmax();
162 yieldPt =
new TH1F(
"Yield_Pt",
"Yield_Pt", yBins, 0., ptMax);
163 yieldPt->SetXTitle(
"Pt (GeV/c)");
164 yieldPt->SetYTitle(
"Counts");
170 if (strstr(baseName[pageNumber],
"Res") ||
171 strstr(baseName[pageNumber],
"Cumul")) {
172 cout <<
" With error weighting" << endl;
173 float content, error, errorSq, meanContent, meanError, weight;
174 for (
int bin = 0; bin < nBins; bin++) {
178 for (
int n = 0; n < nCens; n++) {
180 content = hist[n]->GetBinContent(bin);
181 error = hist[n]->GetBinError(bin);
182 errorSq = error * error;
184 meanContent += content / errorSq;
185 weight += 1. / errorSq;
190 meanContent /= weight;
191 meanError = sqrt(1. / weight);
192 hist[nCens]->SetBinContent(bin, meanContent);
193 hist[nCens]->SetBinError(bin, meanError);
197 cout <<
" With yield weighting" << endl;
198 float v, verr, content, error, yield, y, pt;
199 double vSum, vSum2, error2sum, yieldSum, vRms, verrRms, vSumRms, yieldSumRms, vSumRms2;
200 for (
int bin = 0; bin < nBins; bin++) {
215 for (
int n = 0; n < nCens; n++) {
217 if (strstr(baseName[pageNumber],
"LYZ")) {
218 if (strstr(histName->Data(),
"vEta")) {
219 yield = yieldPartHistEta[n]->GetBinContent(bin);
220 }
else if (strstr(histName->Data(),
"vPt")) {
221 yield = yieldPartHistPt[n]->GetBinContent(bin);
223 yield = yieldTotal[n];
226 if (strstr(histName->Data(),
"v2D")) {
227 yield = yieldPartHist[n]->GetBinContent(bin);
228 }
else if (strstr(histName->Data(),
"vEta")) {
229 yield = yieldPartHist[n]->Integral(bin, bin, 1, yBins);
230 if (selN==0 && harN==0) {
231 y = yieldPartHist[n]->GetXaxis()->GetBinCenter(bin);
232 yieldY->Fill(y, yield);
234 }
else if (strstr(histName->Data(),
"vPt")) {
235 yield = yieldPartHist[n]->Integral(1, xBins, bin, bin);
236 if (selN==0 && harN==0) {
237 pt = yieldPartHist[n]->GetYaxis()->GetBinCenter(bin);
238 yieldPt->Fill(pt, yield);
241 yield = yieldPartHist[n]->Integral();
244 v = hist[n]->GetBinContent(bin);
247 yieldSumRms += yield;
250 verr = hist[n]->GetBinError(bin);
254 vSum2 += v * v * yield;
255 error2sum += pow(yield * verr, 2.);
261 if (yieldSumRms) vRms = vSumRms / yieldSumRms;
263 verrRms = sqrt(vSumRms2 - vSumRms*vSumRms / yieldSumRms)
265 yieldSum += yieldSumRms;
267 error2sum += pow(yieldSumRms * verrRms, 2.);
268 vSum2 += vRms * vRms * yieldSumRms;
272 content = vSum / yieldSum;
273 if (yieldSumRms==1) {
274 error = sqrt(error2sum + vSum2 - vSum*vSum / yieldSum) / yieldSum;
275 error = yieldSum / (yieldSum+1) * sqrt(error*error +
276 (vRms - content)*(vRms - content) / (yieldSum * (yieldSum+1)));
278 error = sqrt(error2sum + vSum2 - vSum*vSum/yieldSum) / yieldSum;
280 hist[nCens]->SetBinContent(bin, content);
281 hist[nCens]->SetBinError(bin, error);
291 histFile[nCens]->Write(0, TObject::kOverwrite);
292 histFile[nCens]->Close();
293 delete histFile[nCens];