14 #include "StEStructSupport.h"
24 const char* _pair_typename[] = {
"Sib",
"Mix"};
25 const char* _pair_chargename[] = {
"pp",
"pm",
"mp",
"mm"};
26 const char* _pair_ptweight[] = {
"Pr",
"Su"};
28 int _pair_chargemax=4;
29 int _pair_totalmax=_pair_typemax*_pair_chargemax;
36 TString testName(_pair_typename[0]);
37 testName+=_pair_chargename[0];
40 mtf->GetObject(testName.Data(),obj);
41 if(!obj)
return false;
46 bool StEStructSupport::goodName_zBuf(
const char* name,
int zBin){
48 TString testName(_pair_typename[0]);
49 testName+=_pair_chargename[0];
51 testName+=
"_zBuf_"; testName += zBin;
53 mtf->GetObject(testName.Data(),obj);
54 if(!obj)
return false;
60 char* StEStructSupport::getFrontName(
int itype){
64 if(mtmpString)
delete [] mtmpString;
65 mtmpString=
new char[256];
66 std::ostringstream ts;
68 if(itype<_pair_chargemax){
71 j=1; k=itype-_pair_chargemax;
74 ts<<_pair_typename[j]<<_pair_chargename[k];
75 strcpy(mtmpString,(ts.str()).c_str());
80 const char* StEStructSupport::getTypeName(
int itype){
81 return _pair_typename[itype];
85 const char* StEStructSupport::getChargeSignName(
int ics){
86 return _pair_chargename[ics];
95 StEStructSupport::StEStructSupport(TFile* tf,
int bgmode,
float* npairs) : mtf(tf), mbgMode(bgmode), mtmpString(NULL){
105 mDoSymmetrize =
false;
106 mPairNormalization =
false;
107 mPairWeighting =
true;
108 mIdenticalPair =
true;
109 mYtYtNormalization =
false;
110 mYtYtVolumeNormalization =
false;
116 mnpairs =
new float[8];
117 for(
int i=0;i<8;i++)mnpairs[i]=npairs[i];
124 StEStructSupport::~StEStructSupport(){
125 if(mtmpString)
delete [] mtmpString;
126 if(mnpairs)
delete [] mnpairs;
130 int StEStructSupport::getNZBins(){
131 TString hname(
"NEventsSib_zBuf_");
133 for (iZBin=1;iZBin<99;iZBin++) {
134 TString zBinName(hname.Data());
137 mtf->GetObject(zBinName.Data(),tmp);
155 float *StEStructSupport::getCommonNumber(
int zBin) {
156 float *number =
new float[4];
160 hname =
"meanPtPA_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt[0]);
161 hname =
"meanPtMA_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt[1]);
162 hname =
"meanPtPB_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt[2]);
163 hname =
"meanPtMB_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt[3]);
166 number[0] = hpt[0]->Integral() + hpt[2]->Integral();
167 number[1] = hpt[0]->Integral() + hpt[3]->Integral();
168 number[2] = hpt[1]->Integral() + hpt[2]->Integral();
169 number[3] = hpt[1]->Integral() + hpt[3]->Integral();
173 float *StEStructSupport::getCommonPairs(
int zBin) {
174 float *pairs =
new float[4];
175 for (
int i=0;i<4;i++) {
179 hname += _pair_chargename[i];
180 hname +=
"NDEtaDPhi_zBuf_";
183 mtf->GetObject(hname.Data(),tmp);
185 pairs[i] = tmp->Integral();
193 float *StEStructSupport::getChargeNumber(
int zBin) {
194 float *number =
new float[4];
198 hname =
"meanPtPA_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt[0]);
199 hname =
"meanPtMA_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt[1]);
200 hname =
"meanPtPB_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt[2]);
201 hname =
"meanPtMB_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt[3]);
204 number[0] = hpt[0]->Integral() + hpt[2]->Integral();
205 number[0]+= hpt[0]->Integral() + hpt[3]->Integral();
206 number[0]+= hpt[1]->Integral() + hpt[2]->Integral();
207 number[0]+= hpt[1]->Integral() + hpt[3]->Integral();
208 number[1] = number[0];
209 number[2]+= number[0];
210 number[3] = number[0];
214 float *StEStructSupport::getChargePairs(
int zBin) {
215 float *pairs =
new float[4];
216 for (
int i=0;i<4;i++) {
220 hname += _pair_chargename[i];
221 hname +=
"NDEtaDPhi_zBuf_";
224 mtf->GetObject(hname.Data(),tmp);
226 pairs[i] = tmp->Integral();
231 pairs[0] += pairs[3];
232 pairs[1] += pairs[2];
233 pairs[2] = pairs[0] + pairs[1];
234 pairs[3] = pairs[0] + pairs[1];
242 double StEStructSupport::getCIdNdEtadPhi() {
256 for (
int iz=0;iz<mNumZBins;iz++) {
257 hSibName =
"NEventsSib_zBuf_"; hSibName += iz; mtf->GetObject(hSibName.Data(),hNSum); nEvents += hNSum->Integral();
259 hname =
"etaPA_zBuf_"; hname += iz; mtf->GetObject(hname.Data(),hEta); nTracksA += hEta->Integral();
260 hname =
"etaMA_zBuf_"; hname += iz; mtf->GetObject(hname.Data(),hEta); nTracksA += hEta->Integral();
261 hname =
"etaPB_zBuf_"; hname += iz; mtf->GetObject(hname.Data(),hEta); nTracksB += hEta->Integral();
262 hname =
"etaMB_zBuf_"; hname += iz; mtf->GetObject(hname.Data(),hEta); nTracksB += hEta->Integral();
267 mtf->GetObject(
"EtaPhiRange",hEtaPhi);
271 TAxis *x = hEtaPhi->GetXaxis();
272 etaMin = x->GetXmin();
273 etaMax = x->GetXmax();
275 retVal = sqrt( nTracksA * nTracksB ) / (2*3.1415926 * nEvents * (etaMax-etaMin) );
279 double *StEStructSupport::getd2NdEtadPhi(
int zBin,
bool include2s) {
280 double* retVal =
new double[6];
287 TString hSibName(
"NEventsSib_zBuf_"); hSibName += zBin; TH1* hNSum; mtf->GetObject(hSibName.Data(),hNSum);
288 double nEvents = hNSum->Integral();
291 double nTracksAP, nTracksAM, nTracksBP, nTracksBM;
292 double dNdEtaAP, dNdEtaAM, dNdEtaBP, dNdEtaBM;
296 hname =
"etaPA_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hEta); nTracksAP = hEta->Integral();
297 hname =
"etaMA_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hEta); nTracksAM = hEta->Integral();
298 hname =
"etaPB_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hEta); nTracksBP = hEta->Integral();
299 hname =
"etaMB_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hEta); nTracksBM = hEta->Integral();
303 mtf->GetObject(
"EtaPhiRange",hEtaPhi);
307 TAxis *x = hEtaPhi->GetXaxis();
308 etaMin = x->GetXmin();
309 etaMax = x->GetXmax();
312 dNdEtaAP = nTracksAP / (nEvents * (etaMax-etaMin) );
313 dNdEtaAM = nTracksAM / (nEvents * (etaMax-etaMin) );
314 dNdEtaBP = nTracksBP / (nEvents * (etaMax-etaMin) );
315 dNdEtaBM = nTracksBM / (nEvents * (etaMax-etaMin) );
316 retVal[0] = dNdEtaAP*dNdEtaBP / pow(2*3.1415926,2);
317 retVal[1] = dNdEtaAP*dNdEtaBM / pow(2*3.1415926,2);
318 retVal[2] = dNdEtaAM*dNdEtaBP / pow(2*3.1415926,2);
319 retVal[3] = dNdEtaAM*dNdEtaBM / pow(2*3.1415926,2);
325 if (mIdenticalPair) {
326 retVal[4] = (dNdEtaAP + dNdEtaAM) / (2*3.1415926);
331 retVal[4] = (dNdEtaAP + dNdEtaAM + dNdEtaBP + dNdEtaBM) / (2*3.1415926);
341 double *StEStructSupport::getScaleFactors() {
342 double* retVal =
new double[6];
343 for (
int iType=0;iType<6;iType++) {
348 for (
int iz=0;iz<mNumZBins;iz++) {
349 d2NdEtadPhi = getd2NdEtadPhi(iz);
350 for (
int iType=0;iType<5;iType++) {
351 retVal[iType] += d2NdEtadPhi[iType] * d2NdEtadPhi[5];
353 retVal[5] += d2NdEtadPhi[5];
354 delete [] d2NdEtadPhi;
356 for (
int iType=0;iType<5;iType++) {
357 retVal[iType] /= retVal[5];
361 double *StEStructSupport::getScaleFactors(
int zBin) {
362 return getd2NdEtadPhi(zBin);
365 double *StEStructSupport::getptHat() {
366 double* retVal =
new double[4];
369 for (
int iType=0;iType<4;iType++) {
373 for (
int iz=0;iz<mNumZBins;iz++) {
374 ptHat = getptHat(iz);
375 d2NdEtadPhi = getd2NdEtadPhi(iz);
376 for (
int iType=0;iType<4;iType++) {
377 retVal[iType] += ptHat[iType] * d2NdEtadPhi[5];
379 d2N_Tot += d2NdEtadPhi[5];
380 delete [] d2NdEtadPhi;
383 for (
int iType=0;iType<4;iType++) {
384 retVal[iType] /= d2N_Tot;
389 double *StEStructSupport::getptHat(
int zBin) {
390 double* retVal =
new double[4];
394 hname =
"meanPtPA_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt); retVal[0] = hpt->GetMean();
395 hname =
"meanPtMA_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt); retVal[1] = hpt->GetMean();
396 hname =
"meanPtPB_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt); retVal[2] = hpt->GetMean();
397 hname =
"meanPtMB_zBuf_"; hname += zBin; mtf->GetObject(hname.Data(),hpt); retVal[3] = hpt->GetMean();
402 int StEStructSupport::histogramExists(
const char* name,
int zBin){
404 TString hname(getFrontName(0)); hname += name; hname+=
"_zBuf_"; hname+= zBin;
405 mtf->GetObject(hname.Data(),tmpF);
411 TH2D** StEStructSupport::getHists(
const char* name,
int zBin){
414 if ((0 == zBin) && !goodName(name)) {
415 if (!goodName_zBuf(name,zBin)) {
420 retVal =
new TH2D*[8];
421 for (
int i=0;i<_pair_totalmax;i++) {
422 TString hname(getFrontName(i)); hname+=name;
423 mtf->GetObject(hname.Data(),retVal[i]);
425 TString hname(getFrontName(i)); hname += name; hname+=
"_zBuf_"; hname+= zBin;
426 mtf->GetObject(hname.Data(),retVal[i]);
432 TH2D** StEStructSupport::getLocalClones(
const char* name,
int zBin){
439 TH2D** hset=getHists(name,zBin);
440 if(!hset)
return (TH2D**)NULL;
443 TH2D** hlocal=
new TH2D*[_pair_totalmax];
444 for(
int i=0;i<_pair_totalmax;i++) {
445 hlocal[i]=(TH2D*)hset[i]->Clone();
454 void StEStructSupport::rescale(TH2D** hists) {
464 for (
int zBin=0;zBin<mNumZBins;zBin++) {
465 TString hSibName(
"NEventsSib_zBuf_"); hSibName += zBin; mtf->GetObject(hSibName.Data(),hNum);
466 nSib += hNum->Integral();
467 TString hMixName(
"NEventsMix_zBuf_"); hMixName += zBin; mtf->GetObject(hMixName.Data(),hNum);
468 nMix += hNum->Integral();
471 for (
int i=0;i<4;i++) {
473 if (hists[i]->Integral() > 0) {
475 double dx = (hists[i]->GetXaxis())->GetBinWidth(1);
476 double dy = (hists[i]->GetYaxis())->GetBinWidth(1);
477 double binFactor = dx*dy;
478 hists[i]->Scale(1.0/(nSib*binFactor));
479 if (i==0 && !msilent) {
480 cout <<
"Scaling with Nevents " << nSib <<
" and binFactor " << binFactor << endl;
483 if (mPairNormalization) {
485 TH2D *tmp = (TH2D *) hists[i]->Clone();
486 tmp->Divide(hists[i+4]);
487 double scale = tmp->Integral() / (tmp->GetNbinsX() * tmp->GetNbinsY());
488 hists[i+4]->Scale(scale);
490 }
else if (mYtYtNormalization) {
494 hists[i+4]->Scale(hists[i]->Integral()/hists[i+4]->Integral());
495 }
else if (mYtYtVolumeNormalization) {
497 TH2D *tmpA = (TH2D *) hists[i]->Clone();
499 TH2D *tmpB = (TH2D *) hists[i]->Clone();
501 for (
int ix=1;ix<=tmpA->GetNbinsX();ix++) {
502 for (
int iy=1;iy<=tmpA->GetNbinsY();iy++) {
503 double valS = hists[i]->GetBinContent(ix,iy);
504 double valR = hists[i+4]->GetBinContent(ix,iy);
506 tmpA->SetBinContent(ix,iy,valS/sqrt(valR));
508 tmpA->SetBinContent(ix,iy,0);
510 tmpB->SetBinContent(ix,iy,sqrt(valR));
513 double num = tmpA->Integral();
514 double den = tmpB->Integral();
516 hists[i+4]->Scale(num/den);
518 hists[i+4]->Scale(0);
534 hists[i+4]->Scale(0.5/(nMix*binFactor));
536 hists[i+4]->Scale(0);
544 void StEStructSupport::rescale(TH2D** hists,
int zBin) {
552 TString hSibName(
"NEventsSib_zBuf_"); hSibName += zBin; mtf->GetObject(hSibName.Data(),hNum);
553 double nSib = hNum->Integral();
554 TString hMixName(
"NEventsMix_zBuf_"); hMixName += zBin; mtf->GetObject(hMixName.Data(),hNum);
555 double nMix = hNum->Integral();
557 for (
int i=0;i<4;i++) {
559 if (hists[i]->Integral() > 0) {
561 double dx = (hists[i]->GetXaxis())->GetBinWidth(1);
562 double dy = (hists[i]->GetYaxis())->GetBinWidth(1);
563 double binFactor = dx*dy;
564 hists[i]->Scale(1.0/(nSib*binFactor));
565 if (i==0 && !msilent) {
566 cout <<
"Scaling with Nevents " << nSib <<
" and binFactor " << binFactor << endl;
569 if (mPairNormalization) {
571 TH2D *tmp = (TH2D *) hists[i]->Clone();
572 tmp->Divide(hists[i+4]);
573 double scale = tmp->Integral() / (tmp->GetNbinsX() * tmp->GetNbinsY());
574 hists[i+4]->Scale(scale);
576 }
else if (mYtYtNormalization) {
580 hists[i+4]->Scale(hists[i]->Integral()/hists[i+4]->Integral());
581 }
else if (mYtYtVolumeNormalization) {
583 TH2D *tmpA = (TH2D *) hists[i]->Clone();
585 TH2D *tmpB = (TH2D *) hists[i]->Clone();
587 for (
int ix=1;ix<=tmpA->GetNbinsX();ix++) {
588 for (
int iy=1;iy<=tmpA->GetNbinsY();iy++) {
589 double valS = hists[i]->GetBinContent(ix,iy);
590 double valR = hists[i+4]->GetBinContent(ix,iy);
592 tmpA->SetBinContent(ix,iy,valS/sqrt(valR));
594 tmpA->SetBinContent(ix,iy,0);
596 tmpB->SetBinContent(ix,iy,sqrt(valR));
599 double num = tmpA->Integral();
600 double den = tmpB->Integral();
602 hists[i+4]->Scale(num/den);
604 hists[i+4]->Scale(0);
613 hists[i+4]->Scale(0.5/(nMix*binFactor));
615 hists[i+4]->Scale(0);
623 TH2D** StEStructSupport::getPtHists(
const char* name,
int zBin){
630 TString chkName(
"Pr"); chkName += name;
631 if((0 == zBin) && !goodName(chkName.Data())) {
632 if (!goodName_zBuf(chkName.Data(),zBin)) {
637 retVal=
new TH2D*[32];
639 for(
int i=0;i<_pair_totalmax;i++){
640 TString hname(getFrontName(i)),hprname(getFrontName(i)),hpaname(getFrontName(i)),hpbname(getFrontName(i));
641 hname+=name; hname+=
"_zBuf_"; hname+=zBin;
642 hprname+=
"Pr"; hprname+=name; hprname+=
"_zBuf_"; hprname+=zBin;
643 hpaname+=
"Pa"; hpaname+=name; hpaname+=
"_zBuf_"; hpaname+=zBin;
644 hpbname+=
"Pb"; hpbname+=name; hpbname+=
"_zBuf_"; hpbname+=zBin;
645 mtf->GetObject(hname.Data(),retVal[i]);
646 mtf->GetObject(hprname.Data(),retVal[i+8]);
647 mtf->GetObject(hpaname.Data(),retVal[i+16]);
648 mtf->GetObject(hpbname.Data(),retVal[i+24]);
652 double n, pa, pb, er, ea, eb;
653 for (
int ix=1;ix<=retVal[i+8]->GetNbinsX();ix++) {
654 for (
int iy=1;iy<=retVal[i+8]->GetNbinsY();iy++) {
658 n = retVal[i]->GetBinContent(ix,iy);
659 pa = retVal[i+16]->GetBinContent(ix,iy);
660 pb = retVal[i+24]->GetBinContent(ix,iy);
661 er = (0.015*pa*pb/n)*sqrt(2/n);
662 ea = (0.015*pa)/sqrt(n);
663 eb = (0.015*pb)/sqrt(n);
664 retVal[i+8]->SetBinError(ix,iy,er);
665 retVal[i+16]->SetBinError(ix,iy,ea);
666 retVal[i+24]->SetBinError(ix,iy,eb);
674 TH2D** StEStructSupport::getPtClones(
const char* name,
int zBin){
679 TH2D** hset=getPtHists(name,zBin);
680 if(!hset)
return (TH2D**)NULL;
683 TH2D** hlocal=
new TH2D*[_pair_totalmax*4];
684 for(
int i=0;i<_pair_totalmax*4;i++) {
685 hlocal[i]=(TH2D*)hset[i]->Clone();
694 void StEStructSupport::rescalePt(TH2D** hists,
int zBin) {
700 TString hSibName(
"NEventsSib_zBuf_"); hSibName += zBin; mtf->GetObject(hSibName.Data(),hNum);
701 double nSib = hNum->GetEntries();
702 TString hMixName(
"NEventsMix_zBuf_"); hMixName += zBin; mtf->GetObject(hMixName.Data(),hNum);
703 double nMix = hNum->GetEntries();
705 for(
int i=0;i<4;i++) {
706 double dx = (hists[i]->GetXaxis())->GetBinWidth(1);
707 double dy = (hists[i]->GetYaxis())->GetBinWidth(1);
708 double binFactor = dx*dy;
709 double nSibPairs = hists[i]->Integral();
710 double nMixPairs = hists[i+4]->Integral();
713 norm = nSibPairs/(nMixPairs*nSib*binFactor);
717 for (
int j=0;j<4;j++) {
718 if (hists[i+4*j]->Integral() > 0) {
720 if(i==0 && !msilent) cout <<
"Scaling with Nevents " << nSib <<
" and binFactor " << binFactor << endl;
721 hists[i+8*j]->Scale(1.0/(nSib*binFactor));
723 if (mPairNormalization) {
725 hists[i+4+8*j]->Scale(norm);
727 hists[i+4+8*j]->Scale(0);
731 hists[i+4+8*j]->Scale(0.5/(nMix*binFactor));
733 hists[i+4+8*j]->Scale(0);
742 void StEStructSupport::setSymmetrizeUS(
bool symm) {
743 mDoSymmetrize = symm;
746 void StEStructSupport::symmetrizeUS(
const char *name, TH2D** histos) {
751 const char *symHistos[] = {
"YtYt",
"NYtYt",
"PtPt",
752 "PhiPhi",
"NPhiPhi",
"PrPhiPhi",
"PaPhiPhi",
"PbPhiPhi",
753 "EtaEta",
"PrEtaEta",
"PaEtaEta",
"PbEtaEta",
754 "EtaEtaSS",
"PrEtaEtaSS",
"PaEtaEtaSS",
"PbEtaEtaSS",
755 "EtaEtaAS",
"PrEtaEtaAS",
"PaEtaEtaAS",
"PbEtaEtaAS"};
757 int symInt[] = {1,2, 5, 6};
758 for (
int xy=0;xy<20;xy++) {
759 if (!strcmp(name,symHistos[xy])) {
760 for (
int ih=0;ih<4;ih++) {
761 for (
int ix=1;ix<=histos[symInt[ih]]->GetNbinsX();ix++) {
762 for (
int iy=ix;iy<=histos[symInt[ih]]->GetNbinsY();iy++) {
763 double sum = histos[symInt[ih]]->GetBinContent(ix,iy) + histos[symInt[ih]]->GetBinContent(iy,ix);
764 double err = sqrt(pow(histos[symInt[ih]]->GetBinError(ix,iy),2) + pow(histos[symInt[ih]]->GetBinError(iy,ix),2));
765 histos[symInt[ih]]->SetBinContent(ix,iy,sum);
766 histos[symInt[ih]]->SetBinContent(iy,ix,sum);
767 histos[symInt[ih]]->SetBinError(ix,iy,err);
768 histos[symInt[ih]]->SetBinError(iy,ix,err);
776 void StEStructSupport::symmetrizePtUS(
const char *name, TH2D** histos) {
781 const char *symHistos[] = {
"YtYt",
"NYtYt",
"PtPt",
782 "PhiPhi",
"NPhiPhi",
"PrPhiPhi",
"PaPhiPhi",
"PbPhiPhi",
783 "EtaEta",
"PrEtaEta",
"PaEtaEta",
"PbEtaEta",
784 "EtaEtaSS",
"PrEtaEtaSS",
"PaEtaEtaSS",
"PbEtaEtaSS",
785 "EtaEtaAS",
"PrEtaEtaAS",
"PaEtaEtaAS",
"PbEtaEtaAS"};
786 int symInt[] = {1,2, 5, 6};
789 for (
int xy=0;xy<20;xy++) {
790 if (!strcmp(name,symHistos[xy])) {
791 for (
int ig=0;ig<32;ig+=8) {
792 for (
int ih=0;ih<4;ih++) {
793 int histNum = ig + symInt[ih];
794 for (
int ix=1;ix<=histos[histNum]->GetNbinsX();ix++) {
795 for (
int iy=ix;iy<=histos[histNum]->GetNbinsY();iy++) {
796 double sum = histos[histNum]->GetBinContent(ix,iy) + histos[histNum]->GetBinContent(iy,ix);
797 double err = sqrt(pow(histos[histNum]->GetBinContent(ix,iy),2) + pow(histos[histNum]->GetBinContent(iy,ix),2));
798 histos[histNum]->SetBinContent(ix,iy,sum);
799 histos[histNum]->SetBinContent(iy,ix,sum);
800 histos[histNum]->SetBinError(ix,iy,err);
801 histos[histNum]->SetBinError(iy,ix,err);
811 float* StEStructSupport::getNorms(TH2D** histArray){
816 if(!histArray)
return retVal;
819 for(
int i=0;i<_pair_totalmax; i++) retVal[i]=histArray[i]->Integral();
825 TH2D** StEStructSupport::buildCommonRatios(
const char* name,
float* sf){
826 return buildCommon(name,0,sf);
829 TH2D** StEStructSupport::buildCommonCFunctions(
const char* name,
float* sf){
830 return buildCommon(name,1,sf);
833 TH2D** StEStructSupport::buildCommonRFunctions(
const char* name,
float* sf){
834 return buildCommon(name,2,sf);
838 TH2D** StEStructSupport::buildCommonRatios(
const char* name,
float* sf,
int zBin){
839 return buildCommon(name,0,sf,zBin);
842 TH2D** StEStructSupport::buildCommonCFunctions(
const char* name,
float* sf,
int zBin){
843 return buildCommon(name,1,sf,zBin);
846 TH2D** StEStructSupport::buildCommonRFunctions(
const char* name,
float* sf,
int zBin){
847 return buildCommon(name,2,sf,zBin);
869 TH2D** StEStructSupport::buildCommon(
const char* name,
int opt,
float* sf) {
870 TH2D** retVal= buildCommon(name, opt, sf, 0);
876 for (
int iType=0;iType<4;iType++) {
877 if (strstr(retVal[iType]->GetName(),
"_zBuf_0")) {
878 retVal[iType]->SetName(swapIn(retVal[iType]->GetName(),
"_zBuf_0",
""));
880 if (strstr(retVal[iType]->GetTitle(),
"_zBuf_0")) {
881 retVal[iType]->SetTitle(swapIn(retVal[iType]->GetTitle(),
"_zBuf_0",
""));
884 const char* oldName[4] = {
"Sibpp",
"Sibpm",
"Sibmp",
"Sibmm"};
885 const char* newName[4] = {
"PP ",
"PM ",
"MP ",
"MM "};
886 const char* oldTitle[4] = {
"Sibling : +.+",
"Sibling : +.-",
"Sibling : -.+",
"Sibling : -.-"};
887 const char* newTitle[4] = {
"PP : ++ ",
"PM : +- ",
"MP: -+ ",
"MM : -- "};
888 for(
int i=0;i<4;i++) {
889 retVal[i]->SetName(swapIn(retVal[i]->GetName(),oldName[i],newName[i]));
890 retVal[i]->SetTitle(swapIn(retVal[i]->GetTitle(),oldTitle[i],newTitle[i]));
892 for(
int i=0;i<_pair_totalmax;i++) {
912 TH2D*** wScale =
new TH2D**[mNumZBins];
913 TH2D** wTotal =
new TH2D*[4];
914 for (
int iType=0;iType<4;iType++) {
915 TString wName(
"sumWeighting"); wName += iType;
916 wTotal[iType] = (TH2D *) retVal[iType]->Clone(wName.Data());
918 for (
int iz=0;iz<mNumZBins;iz++) {
919 wScale[iz] = getLocalClones(name, iz);
921 for (
int iType=0;iType<4;iType++) {
922 weight = wScale[iz][iType]->Integral();
923 for (
int ix=1;ix<=wScale[iz][iType]->GetNbinsX();ix++) {
924 for (
int iy=1;iy<=wScale[iz][iType]->GetNbinsY();iy++) {
925 double wTot = wTotal[iType]->GetBinContent(ix,iy);
926 if ((wScale[iz][iType]->GetBinContent(ix,iy) == 0) ||
927 (wScale[iz][iType+4]->GetBinContent(ix,iy) == 0)) {
928 wScale[iz][iType]->SetBinContent(ix,iy,0);
930 wScale[iz][iType]->SetBinContent(ix,iy,weight);
931 wTotal[iType]->SetBinContent(ix,iy,wTot+weight);
937 for (
int iz=0;iz<mNumZBins;iz++) {
938 for (
int iType=0;iType<4;iType++) {
939 wScale[iz][iType]->Divide(wTotal[iType]);
944 for (
int iz=0;iz<mNumZBins;iz++) {
945 TH2D** tmpVal= buildCommon(name, opt, sf, iz);
946 for (
int iType=0;iType<4;iType++) {
947 tmpVal[iType]->Multiply(wScale[iz][iType]);
948 retVal[iType]->Add(tmpVal[iType]);
949 delete tmpVal[iType];
961 double *scale = getScaleFactors();
963 cout <<
"@@@@@ In buildCommon: using d^2N/detadphi = " << scale[4] << endl;
965 for (
int iType=0;iType<4;iType++) {
968 }
else if (1 == opt) {
969 retVal[iType]->Scale(scale[iType]);
970 }
else if (2 == opt) {
971 retVal[iType]->Scale(sqrt(scale[iType]));
978 for (
int iType=0;iType<8;iType++) {
979 for (
int iz=0;iz<mNumZBins;iz++) {
980 delete wScale[iz][iType];
983 for (
int iType=0;iType<4;iType++) {
984 delete wTotal[iType];
989 double wIdentical[4] = {1, 1, 1, 1};
990 if (mIdenticalPair) {
1003 for (
int iz=0;iz<mNumZBins;iz++) {
1004 TH2D** tmpVal = getLocalClones(name, iz);
1008 for (
int iType=0;iType<8;iType++) {
1009 retVal[iType]->Add(tmpVal[iType]);
1010 delete tmpVal[iType];
1015 if (mDoSymmetrize) {
1016 symmetrizeUS(name,retVal);
1020 for(
int i=0;i<8;i++) {
1021 retVal[i]->Scale(1.0/mnpairs[i]);
1027 if (strstr(name,
"DEta") || strstr(name,
"SEta")) {
1028 fixDEtaGeometric((TH2**)retVal,8);
1041 scaleBackGround(retVal[0],retVal[4],scf1);
1042 scaleBackGround(retVal[1],retVal[5],scf2);
1043 scaleBackGround(retVal[2],retVal[6],scf2);
1044 scaleBackGround(retVal[3],retVal[7],scf1);
1049 for (
int iType=0;iType<4;iType++) {
1051 if ((0 == retVal[iType]->Integral()) && (0 == retVal[iType]->GetMaximum()) &&
1052 (0 == retVal[iType+4]->Integral()) && (0 == retVal[iType+4]->GetMaximum())) {
1055 retVal[iType]->Scale(wIdentical[iType]);
1056 retVal[iType+4]->Scale(wIdentical[iType]);
1058 bool message =
false;
1059 retVal[iType]->Divide(retVal[iType+4]);
1060 for (
int ix=1;ix<=retVal[iType]->GetNbinsX();ix++) {
1061 for (
int iy=1;iy<=retVal[iType]->GetNbinsY();iy++) {
1062 double rhoSib = retVal[iType]->GetBinContent(ix,iy);
1066 retVal[iType]->SetBinContent(ix,iy,rhoSib-1);
1071 cout <<
"!!!!! Had at least one empty bin in Pt histogram " << name;
1072 cout <<
" type " << iType <<
" option 3 !!!!!" << endl;
1074 }
else if (4 == opt) {
1075 bool message =
false;
1076 for (
int ix=1;ix<=retVal[iType]->GetNbinsX();ix++) {
1077 for (
int iy=1;iy<=retVal[iType]->GetNbinsY();iy++) {
1078 if (0 == retVal[iType]->GetBinContent(ix,iy)) {
1084 cout <<
"!!!!! Had at least one empty bin in Pt histogram " << name;
1085 cout <<
" type " << iType <<
" option 4!!!!!" << endl;
1087 retVal[iType]->Add(retVal[iType+4],-1);
1088 }
else if (5 == opt) {
1091 for (
int zBin=0;zBin<mNumZBins;zBin++) {
1092 TString hSibName(
"NEventsSib_zBuf_"); hSibName += zBin; mtf->GetObject(hSibName.Data(),hNum);
1093 nSib += hNum->Integral();
1095 for (
int ix=1;ix<=retVal[iType]->GetNbinsX();ix++) {
1096 for (
int iy=1;iy<=retVal[iType]->GetNbinsY();iy++) {
1097 double rhoSib = retVal[iType]->GetBinContent(ix,iy);
1098 double rhoRef = retVal[iType+4]->GetBinContent(ix,iy);
1099 double eRhoSib = retVal[iType]->GetBinError(ix,iy);
1100 double eRhoRef = retVal[iType+4]->GetBinError(ix,iy);
1102 double eVal2 = eRhoSib*eRhoSib/rhoRef +
1103 0.25*eRhoRef*eRhoRef*pow(rhoSib/rhoRef+1,2)/rhoRef;
1104 double val = (rhoSib-rhoRef)/sqrt(rhoRef);
1105 retVal[iType]->SetBinContent(ix,iy,val);
1106 retVal[iType]->SetBinError(ix,iy,sqrt(eVal2));
1108 double eVal2 = eRhoSib*eRhoSib + 1;
1109 retVal[iType]->SetBinContent(ix,iy,0);
1111 retVal[iType]->SetBinError(ix,iy,sqrt(eVal2/nSib));
1130 TH2D** StEStructSupport::buildCommon(
const char* name,
int opt,
float* sf,
int zBin) {
1136 TH2D** retVal = getLocalClones(name, zBin);
1141 if (mDoSymmetrize) {
1142 symmetrizeUS(name,retVal);
1146 for(
int i=0;i<8;i++) {
1147 retVal[i]->Scale(1.0/mnpairs[i]);
1150 rescale(retVal, zBin);
1153 if (strstr(name,
"DEta") || strstr(name,
"SEta")) {
1154 fixDEtaGeometric((TH2**)retVal,8);
1167 scaleBackGround(retVal[0],retVal[4],scf1);
1168 scaleBackGround(retVal[1],retVal[5],scf2);
1169 scaleBackGround(retVal[2],retVal[6],scf2);
1170 scaleBackGround(retVal[3],retVal[7],scf1);
1180 for (
int i=0;i<4;i++) {
1182 if ((0 == retVal[i]->Integral()) && (0 == retVal[i]->GetMaximum()) &&
1183 (0 == retVal[i+4]->Integral()) && (0 == retVal[i+4]->GetMaximum())) {
1186 retVal[i]->Divide(retVal[i+4]);
1187 for (
int ix=1;ix<=retVal[i]->GetNbinsX();ix++) {
1188 for (
int iy=1;iy<=retVal[i]->GetNbinsY();iy++) {
1189 double val = retVal[i]->GetBinContent(ix,iy);
1191 retVal[i]->SetBinContent(ix,iy,0);
1193 retVal[i]->SetBinContent(ix,iy,val-1);
1209 TH2D** StEStructSupport::buildPtCommon(
const char* name,
int opt,
int subtract) {
1210 TH2D** retVal= buildPtCommon(name, opt, subtract, 0);
1215 for (
int iType=0;iType<4;iType++) {
1216 if (strstr(retVal[iType]->GetName(),
"_zBuf_0")) {
1217 retVal[iType]->SetName(swapIn(retVal[iType]->GetName(),
"_zBuf_0",
""));
1219 if (strstr(retVal[iType]->GetTitle(),
"_zBuf_0")) {
1220 retVal[iType]->SetTitle(swapIn(retVal[iType]->GetTitle(),
"_zBuf_0",
""));
1223 const char* oldName[4] = {
"Sibpp",
"Sibpm",
"Sibmp",
"Sibmm"};
1224 const char* newName[4] = {
"PP ",
"PM ",
"MP ",
"MM "};
1225 const char* oldTitle[4] = {
"Sibling : +.+",
"Sibling : +.-",
"Sibling : -.+",
"Sibling : -.-"};
1226 const char* newTitle[4] = {
"PP : ++ ",
"PM : +- ",
"MP: -+ ",
"MM : -- "};
1227 for (
int i=0;i<4;i++) {
1228 retVal[i]->SetName(swapIn(retVal[i]->GetName(),oldName[i],newName[i]));
1229 retVal[i]->SetTitle(swapIn(retVal[i]->GetTitle(),oldTitle[i],newTitle[i]));
1246 wScale[0] =
new double[mNumZBins];
1247 wScale[1] =
new double[mNumZBins];
1248 wScale[2] =
new double[mNumZBins];
1249 wScale[3] =
new double[mNumZBins];
1250 double wTotal[4] = {0, 0, 0, 0};
1251 for (
int iz=0;iz<mNumZBins;iz++) {
1252 temp = getLocalClones(name, iz);
1253 for (
int iType=0;iType<4;iType++) {
1254 wScale[iType][iz] = temp[iType]->Integral();
1255 wTotal[iType] += wScale[iType][iz];
1258 for (
int iType=4;iType<8;iType++) {
1265 for (
int iz=0;iz<mNumZBins;iz++) {
1266 TH2D** tmpVal= buildPtCommon(name, opt, subtract, iz);
1267 for (
int iType=0;iType<4;iType++) {
1268 if (0 != wTotal[iType]) {
1269 retVal[iType]->Add(tmpVal[iType], wScale[iType][iz]/wTotal[iType]);
1271 delete tmpVal[iType];
1278 double *scale = getScaleFactors();
1280 cout <<
"@@@@@ In buildPtCommon: using d^2N/detadphi = " << scale[4] << endl;
1282 for (
int iType=0;iType<4;iType++) {
1285 }
else if (1 == opt) {
1286 retVal[iType]->Scale(scale[iType]);
1287 }
else if (2 == opt) {
1288 retVal[iType]->Scale(sqrt(scale[iType]));
1295 TH2D** StEStructSupport::buildPtCommon(
const char* name,
int opt,
int subtract,
int zBin) {
1299 if(!mtf)
return (TH2D**)NULL;
1305 TH2D** hlocal=getPtClones(name,zBin);
1310 if (mDoSymmetrize) {
1311 symmetrizePtUS(name,hlocal);
1313 rescalePt(hlocal, zBin);
1317 TH2D** retVal=
new TH2D*[4];
1318 TH2D** mixVal=
new TH2D*[4];
1319 for (
int i=0;i<4;i++) {
1320 retVal[i]=(TH2D*)hlocal[i]->Clone();
1321 retVal[i]->Scale(0.);
1322 mixVal[i]=(TH2D*)hlocal[0]->Clone();
1323 mixVal[i]->Scale(0.);
1326 if(strstr(name,
"DEta") || strstr(name,
"SEta")) {
1327 fixDEtaGeometric((TH2**)hlocal,32);
1329 double *ptHat = getptHat(zBin);
1330 double ptHatA[4], ptHatB[4];
1331 ptHatA[0] = ptHat[0];
1332 ptHatA[1] = ptHat[0];
1333 ptHatA[2] = ptHat[1];
1334 ptHatA[3] = ptHat[1];
1335 ptHatB[0] = ptHat[2];
1336 ptHatB[1] = ptHat[2];
1337 ptHatB[2] = ptHat[3];
1338 ptHatB[3] = ptHat[3];
1340 for (
int i=0;i<4;i++) {
1341 retVal[i]->Add(hlocal[i+ 8]);
1342 retVal[i]->Add(hlocal[i+16],-ptHatA[i]);
1343 retVal[i]->Add(hlocal[i+24],-ptHatB[i]);
1344 retVal[i]->Add(hlocal[i ],ptHatA[i]*ptHatB[i]);
1346 mixVal[i]->Add(hlocal[i+12]);
1347 mixVal[i]->Add(hlocal[i+20],-ptHatA[i]);
1348 mixVal[i]->Add(hlocal[i+28],-ptHatB[i]);
1349 mixVal[i]->Add(hlocal[i+ 4],ptHatA[i]*ptHatB[i]);
1352 for (
int i=0;i<4;i++) {
1356 for (
int ix=1;ix<=mixVal[i]->GetNbinsX();ix++) {
1357 for (
int iy=1;iy<=mixVal[i]->GetNbinsY();iy++) {
1358 mixVal[i]->SetBinError(ix,iy,0);
1361 retVal[i]->Add(mixVal[i],-1);
1363 retVal[i]->Divide(hlocal[i+4]);
1367 for (
int i=1;i<4;i++) {
1370 for(
int i=0;i<_pair_totalmax*4;i++) {
1380 TH2D** StEStructSupport::buildChargeTypeRatios(
const char* name,
float* sf){
1381 return buildChargeTypes(name,0,sf);
1384 TH2D** StEStructSupport::buildChargeTypeCFunctions(
const char* name,
float* sf){
1385 return buildChargeTypes(name,1,sf);
1388 TH2D** StEStructSupport::buildChargeTypeRFunctions(
const char* name,
float* sf){
1389 return buildChargeTypes(name,2,sf);
1402 TH2D** StEStructSupport::buildChargeTypes(
const char* name,
int opt,
float *sf) {
1410 TH2D** retVal = buildCommon(name, opt, sf);
1416 for (
int iType=0;iType<4;iType++) {
1417 if (strstr(retVal[iType]->GetName(),
"_zBuf_0")) {
1418 retVal[iType]->SetName(swapIn(retVal[iType]->GetName(),
"_zBuf_0",
""));
1420 if (strstr(retVal[iType]->GetTitle(),
"_zBuf_0")) {
1421 retVal[iType]->SetTitle(swapIn(retVal[iType]->GetTitle(),
"_zBuf_0",
""));
1424 const char* oldName[4] = {
"PP ",
"PM ",
"MP ",
"MM "};
1425 const char* newName[4] = {
"LS ",
"US ",
"CD ",
"CI "};
1426 const char* oldTitle[4] = {
"PP : ++ ",
"PM : +- ",
"MP: -+ ",
"MM : -- "};
1427 const char* newTitle[4] = {
"LS : ++ + -- ",
"US : +- + -+ ",
"CD: ++ + -- - +- - -+ ",
"CI : ++ + -- + +- + -+ "};
1428 for(
int i=0;i<4;i++) {
1429 retVal[i]->SetName(swapIn(retVal[i]->GetName(),oldName[i],newName[i]));
1430 retVal[i]->SetTitle(swapIn(retVal[i]->GetTitle(),oldTitle[i],newTitle[i]));
1434 double *scale = getScaleFactors();
1435 for (
int iType=0;iType<4;iType++) {
1438 retVal[iType]->Scale(scale[iType]/pow(scale[4],2));
1439 }
else if (1 == opt) {
1440 retVal[iType]->Scale(1.0);
1441 }
else if (2 == opt) {
1442 retVal[iType]->Scale(sqrt(scale[iType])/scale[4]);
1446 retVal[0]->Add(retVal[3]);
1447 if (mIdenticalPair) {
1448 retVal[1]->Scale(2);
1450 retVal[1]->Add(retVal[2]);
1452 retVal[2]->Add(retVal[0],retVal[1],1,-1);
1453 retVal[3]->Add(retVal[0],retVal[1]);
1458 TH2D** StEStructSupport::buildChargeTypeRatios(
const char* name,
float* sf,
int zBin){
1459 return buildChargeTypes(name,0,sf,zBin);
1462 TH2D** StEStructSupport::buildChargeTypeCFunctions(
const char* name,
float* sf,
int zBin){
1463 return buildChargeTypes(name,1,sf,zBin);
1466 TH2D** StEStructSupport::buildChargeTypeRFunctions(
const char* name,
float* sf,
int zBin){
1467 return buildChargeTypes(name,2,sf,zBin);
1472 TH2D** StEStructSupport::buildChargeTypes(
const char* name,
int opt,
float *sf,
int zBin) {
1477 TH2D** retVal= buildCommon(name, opt, sf, zBin);
1483 for (
int iType=0;iType<4;iType++) {
1484 if (strstr(retVal[iType]->GetName(),
"_zBuf_0")) {
1485 retVal[iType]->SetName(swapIn(retVal[iType]->GetName(),
"_zBuf_0",
""));
1487 if (strstr(retVal[iType]->GetTitle(),
"_zBuf_0")) {
1488 retVal[iType]->SetTitle(swapIn(retVal[iType]->GetTitle(),
"_zBuf_0",
""));
1491 const char* oldName[4] = {
"Sibpp",
"Sibpm",
"Sibmp",
"Sibmm"};
1492 const char* newName[4] = {
"LS ",
"US ",
"CD ",
"CI "};
1493 const char* oldTitle[4] = {
"Sibling : +.+",
"Sibling : +.-",
"Sibling : -.+",
"Sibling : -.-"};
1494 const char* newTitle[4] = {
"LS : ++ + -- ",
"US : +- + -+ ",
"CD: ++ + -- - +- - -+ ",
"CI : ++ + -- + +- + -+ "};
1495 for(
int i=0;i<4;i++) {
1496 retVal[i]->SetName(swapIn(retVal[i]->GetName(),oldName[i],newName[i]));
1497 retVal[i]->SetTitle(swapIn(retVal[i]->GetTitle(),oldTitle[i],newTitle[i]));
1503 double *d2NdEtadPhi = getd2NdEtadPhi(zBin);
1504 double sqrtRho = d2NdEtadPhi[4];
1505 delete [] d2NdEtadPhi;
1506 for (
int iType=0;iType<4;iType++) {
1509 retVal[iType]->Scale(pow(sqrtRho,2));
1510 }
else if (2 == opt) {
1511 retVal[iType]->Scale(sqrtRho);
1514 retVal[iType]->Scale(0.0);
1520 for (
int iType=0;iType<4;iType++) {
1521 retVal[iType]->Add(retVal[iType+4],-1);
1522 for (
int ix=1;ix<=retVal[iType]->GetNbinsX();ix++) {
1523 for (
int iy=1;iy<=retVal[iType]->GetNbinsY();iy++) {
1524 double rhoRef = retVal[iType+4]->GetBinContent(ix,iy);
1526 double val = retVal[iType]->GetBinContent(ix,iy);
1529 retVal[iType]->SetBinContent(ix,iy,val/rhoRef);
1531 }
else if (5 == opt) {
1532 retVal[iType]->SetBinContent(ix,iy,val/sqrt(rhoRef));
1542 retVal[0]->Add(retVal[3]);
1543 retVal[1]->Add(retVal[2]);
1544 retVal[2]->Add(retVal[0],retVal[1],1,-1);
1545 retVal[3]->Add(retVal[0],retVal[1]);
1551 TH2D** StEStructSupport::buildChargeTypesSumOfRatios(
const char* name,
int opt,
float *sf){
1552 TH2D** retVal= buildChargeTypesSumOfRatios(name, opt, sf, 0);
1557 float *nPairs = getChargeNumber(0);
1558 for (
int iType=0;iType<4;iType++) {
1559 retVal[iType]->Scale(nPairs[iType]);
1562 for (
int iType=0;iType<4;iType++) {
1563 if (strstr(retVal[iType]->GetName(),
"_zBuf_0")) {
1564 retVal[iType]->SetName(swapIn(retVal[iType]->GetName(),
"_zBuf_0",
""));
1566 if (strstr(retVal[iType]->GetTitle(),
"_zBuf_0")) {
1567 retVal[iType]->SetTitle(swapIn(retVal[iType]->GetTitle(),
"_zBuf_0",
""));
1570 for (
int iz=1;iz<mNumZBins;iz++) {
1571 TH2D** tmpVal= buildChargeTypesSumOfRatios(name, opt, sf, iz);
1572 float *tempPairs = getChargeNumber(iz);
1573 for (
int iType=0;iType<4;iType++) {
1574 retVal[iType]->Add(tmpVal[iType],tempPairs[iType]);
1575 nPairs[iType]+=tempPairs[iType];
1576 delete tmpVal[iType];
1579 delete [] tempPairs;
1581 for (
int iType=0;iType<4;iType++) {
1582 if (nPairs[iType]) {
1583 retVal[iType]->Scale(1.0/nPairs[iType]);
1585 retVal[iType]->Scale(0.0);
1592 TH2D** StEStructSupport::buildChargeTypesSumOfRatios(
const char* name,
int opt,
float* sf,
int zBin){
1597 TH2D** hlocal=getLocalClones(name,zBin);
1603 for(
int i=0;i<8;i++) hlocal[i]->Scale(1.0/mnpairs[i]);
1604 }
else rescale(hlocal,zBin);
1606 if(strstr(name,
"DEta") || strstr(name,
"SEta"))fixDEtaGeometric((TH2**)hlocal,8);
1609 TH2D** retVal=
new TH2D*[4];
1610 const char* oldName[4]={
"Sibpp",
"Sibpm",
"Sibmp",
"Sibmm"};
1611 const char* newName[4]={
"LS ",
"US ",
"CD ",
"CI "};
1612 const char* oldTitle[4]={
"Sibling : +.+",
"Sibling : +.-",
"Sibling : -.+",
"Sibling : -.-"};
1613 const char* newTitle[4]={
"LS : ++ + -- ",
"US : +- + -+ ",
"CD: ++ + -- - +- - -+ ",
"CI : ++ + -- + +- + -+ "};
1614 for(
int i=0;i<4;i++){
1615 retVal[i]=(TH2D*)hlocal[i]->Clone();
1616 retVal[i]->SetName(swapIn(hlocal[i]->GetName(),oldName[i],newName[i]));
1617 retVal[i]->SetTitle(swapIn(hlocal[i]->GetTitle(),oldTitle[i],newTitle[i]));
1618 retVal[i]->Scale(0.);
1621 hlocal[0]->Add(hlocal[3]);
1622 if(hlocal[2]) hlocal[1]->Add(hlocal[2]);
1623 hlocal[4]->Add(hlocal[7]);
1624 if(hlocal[6]) hlocal[5]->Add(hlocal[6]);
1634 scaleBackGround(hlocal[0],hlocal[4],scf1);
1635 scaleBackGround(hlocal[1],hlocal[5],scf2);
1636 if(opt==3)scaleBackGround(hlocal[3],hlocal[7]);
1639 retVal[0]->Add(hlocal[0]);
1640 retVal[1]->Add(hlocal[1]);
1644 for(
int i=0;i<2;i++){
1645 retVal[i]->Add(hlocal[i+4],-1.0);
1647 retVal[2]->Add(retVal[0],retVal[1],1.,-1.);
1648 retVal[3]->Add(retVal[0],retVal[1],1.,1.);
1651 hlocal[6]->Add(hlocal[4], hlocal[5]);
1652 hlocal[7]->Add(hlocal[4], hlocal[5]);
1654 for(
int i=0;i<4;i++) {
1655 retVal[i]->Divide(hlocal[i+4]);
1659 TString hSibName(
"NEventsSib_zBuf_"); hSibName += zBin;
1660 TH1 *hNum; mtf->GetObject(hSibName.Data(),hNum);
1661 double dNdeta = hNum->GetMean()/2;
1662 retVal[i]->Scale(dNdeta/(2*3.1415926));
1668 for(
int i=0;i<_pair_totalmax;i++) {
1679 TH2D** StEStructSupport::buildPtChargeTypes(
const char* name,
int opt,
int subtract){
1681 TH2D** retVal= buildPtCommon(name, opt, subtract);
1687 for (
int iType=0;iType<4;iType++) {
1688 if (strstr(retVal[iType]->GetName(),
"_zBuf_0")) {
1689 retVal[iType]->SetName(swapIn(retVal[iType]->GetName(),
"_zBuf_0",
""));
1691 if (strstr(retVal[iType]->GetTitle(),
"_zBuf_0")) {
1692 retVal[iType]->SetTitle(swapIn(retVal[iType]->GetTitle(),
"_zBuf_0",
""));
1695 const char* oldName[4] = {
"PP ",
"PM ",
"MP ",
"MM "};
1696 const char* newName[4] = {
"LS ",
"US ",
"CD ",
"CI "};
1697 const char* oldTitle[4] = {
"PP : ++ ",
"PM : +- ",
"MP: -+ ",
"MM : -- "};
1698 const char* newTitle[4] = {
"LS : ++ + -- ",
"US : +- + -+ ",
"CD: ++ + -- - +- - -+ ",
"CI : ++ + -- + +- + -+ "};
1699 for (
int i=0;i<4;i++) {
1700 retVal[i]->SetName(swapIn(retVal[i]->GetName(),oldName[i],newName[i]));
1701 retVal[i]->SetTitle(swapIn(retVal[i]->GetTitle(),oldTitle[i],newTitle[i]));
1706 double *scale = getScaleFactors();
1707 for (
int iType=0;iType<4;iType++) {
1710 retVal[iType]->Scale(scale[iType]/pow(scale[4],2));
1711 }
else if (1 == opt) {
1712 retVal[iType]->Scale(1.0);
1713 }
else if (2 == opt) {
1714 retVal[iType]->Scale(sqrt(scale[iType])/scale[4]);
1718 retVal[0]->Add(retVal[3]);
1719 if (mIdenticalPair) {
1720 retVal[1]->Scale(2);
1722 retVal[1]->Add(retVal[2]);
1724 retVal[2]->Add(retVal[0],retVal[1],1,-1);
1725 retVal[3]->Add(retVal[0],retVal[1]);
1730 TH2D** StEStructSupport::buildPtChargeTypes(
const char* name,
int opt,
int subtract,
int zBin) {
1732 TH2D** retVal= buildPtCommon(name, opt, subtract, zBin);
1738 const char* oldName[4] = {
"Sibpp",
"Sibpm",
"Sibmp",
"Sibmm"};
1739 const char* newName[4] = {
"LS ",
"US ",
"CD ",
"CI "};
1740 const char* oldTitle[4] = {
"Sibling : +.+",
"Sibling : +.-",
"Sibling : -.+",
"Sibling : -.-"};
1741 const char* newTitle[4] = {
"LS : ++ + -- ",
"US : +- + -+ ",
"CD: ++ + -- - +- - -+ ",
"CI : ++ + -- + +- + -+ "};
1742 for(
int i=0;i<4;i++){
1743 retVal[i]->SetName(swapIn(retVal[i]->GetName(),oldName[i],newName[i]));
1744 retVal[i]->SetTitle(swapIn(retVal[i]->GetTitle(),oldTitle[i],newTitle[i]));
1748 retVal[0]->Add(retVal[3]);
1749 retVal[1]->Add(retVal[2]);
1750 retVal[2]->Add(retVal[0],retVal[1],1,-1);
1751 retVal[3]->Add(retVal[0],retVal[1]);
1762 void StEStructSupport::scaleBackGround(TH2D* sib, TH2D* mix,
float sf) {
1767 float hmax = mix->GetMaximum();
1768 for (
int ix=1;ix<=mix->GetNbinsX();ix++) {
1769 for(
int iy=1;iy<=mix->GetNbinsY();iy++) {
1770 float mval = mix->GetBinContent(ix,iy);
1772 float sval = sib->GetBinContent(ix,iy);
1776 float eval = sib->GetBinError(ix,iy)/sval;
1777 float dval = fabs(sval-mval)/sval;
1778 if (sval<mval && dval>3.0*eval && mval/hmax>0.45) {
1780 float rval = sval/mval;
1791 cout<<
"Scaling "<<mix->GetName()<<
" by "<<alpha<<endl;
1796 void StEStructSupport::fixDEtaGeometric(TH2** h,
int numHists) {
1805 if(!mapplyDEtaFix)
return;
1807 TAxis *x = h[0]->GetXaxis();
1808 TAxis *y = h[0]->GetYaxis();
1809 double etaMax = x->GetXmax();
1810 double etaMin = x->GetXmin();
1811 double H = 0.5*( etaMax - etaMin );
1812 double x0 = 0.5*( etaMax + etaMin );
1813 for (
int ix=1;ix<=x->GetNbins();ix++) {
1814 double eta1 = x->GetBinLowEdge(ix);
1815 double eta2 = x->GetBinUpEdge(ix);
1818 corr = H / ( 0.5*(eta2+eta1) - etaMin );
1819 }
else if (eta1 >= x0) {
1820 corr = H / ( etaMax - 0.5*(eta2+eta1) );
1822 double area = H*(eta2-eta1);
1823 double aplus = (eta2-x0)*0.5*(H + etaMax-eta2);
1824 double aminus = (x0-eta1)*0.5*(H + eta1-etaMin);
1825 corr = area / (aplus + aminus);
1827 for (
int iy=1;iy<=y->GetNbins();iy++) {
1828 for (
int ih=0;ih<numHists;ih++) {
1829 double val = h[ih]->GetBinContent(ix,iy);
1830 double err = h[ih]->GetBinError(ix,iy);
1831 h[ih]->SetBinContent(ix,iy,val*corr);
1832 h[ih]->SetBinError(ix,iy,err*corr);
1839 void StEStructSupport::fixDEta(TH2** h,
int numHists) {
1850 if(!mapplyDEtaFix)
return;
1853 acc[0] = (TH2D *) h[4]->Clone();
1855 acc[1] = (TH2D *) h[5]->Clone();
1857 int n = acc[0]->GetNbinsX();
1858 double scale[] = {0, 0};
1861 for (
int iy=12;iy<=25;iy++) {
1862 scale[0] += acc[0]->GetBinContent(mid,iy);
1863 scale[1] += acc[1]->GetBinContent(mid,iy);
1869 for (
int iy=12;iy<=25;iy++) {
1870 scale[0] += acc[0]->GetBinContent(mid,iy);
1871 scale[0] += acc[0]->GetBinContent(mid+1,iy);
1872 scale[1] += acc[1]->GetBinContent(mid,iy);
1873 scale[1] += acc[1]->GetBinContent(mid+1,iy);
1879 acc[0]->Scale(1.0/scale[0]);
1882 acc[1]->Scale(1.0/scale[1]);
1885 for (
int ig=0;ig<numHists;ig+=8) {
1886 if (acc[0]->Integral() > 0) {
1887 h[ig+0]->Divide(acc[0]);
1888 h[ig+1]->Divide(acc[1]);
1889 h[ig+2]->Divide(acc[1]);
1890 h[ig+3]->Divide(acc[0]);
1891 h[ig+4]->Divide(acc[0]);
1892 h[ig+5]->Divide(acc[1]);
1893 h[ig+6]->Divide(acc[1]);
1894 h[ig+7]->Divide(acc[0]);
1902 void StEStructSupport::writeAscii(TH2D** h,
int iHist,
const char* fname,
int optErrors){
1905 int xbins=h[iHist]->GetNbinsX();
1906 TAxis * xa= h[iHist]->GetXaxis();
1907 of<<
"# Histogram Name = "<<h[iHist]->GetName()<<endl;
1908 of<<
"# X-axis: min="<<xa->GetBinLowEdge(1)<<
" max="<<xa->GetBinUpEdge(xbins)<<
" nbins="<<xbins<<endl;
1910 int ybins=h[iHist]->GetNbinsY();
1911 TAxis * ya= h[iHist]->GetYaxis();
1913 of<<
"# Y-axis: min="<<ya->GetBinLowEdge(1)<<
" max="<<ya->GetBinUpEdge(ybins)<<
" nbins="<<ybins<<endl;
1914 of<<
"# ix iy Value "<<endl;
1915 for(
int i=1;i<=xbins;i++){
1916 for(
int j=1;j<=ybins;j++){
1917 of<<i<<
" "<<j<<
" "<<h[iHist]->GetBinContent(i,j);
1918 if(optErrors>0)of<<
" "<<h[iHist]->GetBinError(i,j);
1924 of<<
"# ix Value "<<endl;
1925 for(
int i=1;i<=xbins;i++){
1926 of<<i<<
" "<<h[iHist]->GetBinContent(i);
1927 if(optErrors>0)of<<
" "<<h[iHist]->GetBinError(i);
1937 char* StEStructSupport::swapIn(
const char* name,
const char* s1,
const char* s2){
1943 if(mtmpString)
delete [] mtmpString;
1946 if(!name)
return mtmpString;
1948 int len=strlen(name);
1949 char* tmp=
new char[len+1];
1953 if(!(ptr1=strstr(tmp,s1))) {
1958 int len1=strlen(s1);
1959 mtmpString=
new char[256];
1961 std::ostringstream ts;
1971 strcpy(mtmpString,(ts.str()).c_str());
int mbgMode
for normalization comparing different cuts