2 #include "StEStructFluctAnal.h"
8 #include "StEStructPool/EventMaker/StEStructEvent.h"
9 #include "StEStructPool/EventMaker/StEStructTrack.h"
10 #include "StEStructPool/AnalysisMaker/StEStructQAHists.h"
20 mEtaSumMode = etaSumMode;
21 mPhiSumMode = phiSumMode;
47 mlocalQAHists =
false;
54 StEStructFluctAnal::~StEStructFluctAnal() {
57 deleteCentralityObjects();
71 printf(
"Invalid centrality object passed into StEStructFluctAnal::setCutFile!!!!!\n");
73 createCentralityObjects();
78 void StEStructFluctAnal::createCentralityObjects() {
79 deleteCentralityObjects();
82 mnCentEvents =
new int[mnCents];
83 for (
int jC=0;jC<mnCents;jC++) {
89 for (
int jC=0;jC<mnCents;jC++) {
96 for (
int jC=0;jC<mnPtCents;jC++) {
97 for (
int jP=0;jP<mnPts;jP++) {
98 sprintf(key,
"%i_%i",jC,jP);
99 int index = jP + jC*mnPts;
104 mptnplus =
new double[mnPts];
105 mptnminus =
new double[mnPts];
106 mptpplus =
new double[mnPts];
107 mptpminus =
new double[mnPts];
109 void StEStructFluctAnal::deleteCentralityObjects() {
111 for (
int i=0;i<mnCents;i++) {
112 delete mFluct[i]; mFluct[i] = 0;
114 delete [] mFluct; mFluct = 0;
117 for (
int i=0;i<mnPts*mnPtCents;i++) {
118 delete [] mPtFluct[i]; mPtFluct[i] = 0;
120 delete [] mPtFluct; mPtFluct = 0;
123 delete [] mnCentEvents; mnCentEvents = 0;
126 delete [] mptnplus; mptnplus = 0;
129 delete [] mptnminus; mptnminus = 0;
132 delete [] mptpplus; mptpplus = 0;
135 delete [] mptpminus; mptpminus = 0;
142 cout<<
"Error Track Cuts Not found to get eta range "<<endl;
147 mEtaMax=tcut->maxVal(
"Eta");
154 cout<<
"Error Track Cuts Not found to get eta range "<<endl;
158 mPtMin=tcut->minVal(
"Pt");
159 mPtMax=tcut->maxVal(
"Pt");
172 if (1 > event->Ntrack()) {
173 delete event;
event = 0;
178 delete mCurrentEvent;
189 void StEStructFluctAnal::fillMultStruct() {
190 StEStructTrackCollection* tc;
191 StEStructTrackIterator Iter;
194 int jEta, jPhi, jPt, jCent, jPtCent, totMult = 0;
197 ms->NewEvent(mCurrentEvent->Vx(), mCurrentEvent->Vy(), mCurrentEvent->Vz() );
198 jCent =
mCentralities->centrality( mCurrentEvent->Centrality() );
199 if ((jCent < 0) || (mnCents <= jCent)) {
202 jPtCent =
mCentralities->ptCentrality( mCurrentEvent->Centrality() );
203 double etaOff = etaOffset( mCurrentEvent->Vz() );
205 tc = mCurrentEvent->TrackCollectionP();
206 for(Iter=tc->begin(); Iter!=tc->end(); ++Iter){
208 if ( (t->Eta() > mEtaMax+etaOff) || (
mEtaMin+etaOff > t->Eta()) ) {
211 jEta = int(NETABINS*(t->Eta()-(
mEtaMin+etaOff))/(mEtaMax-
mEtaMin));
212 if ((jEta < 0) || (NETABINS <= jEta)) {
215 jPhi = int(NPHIBINS*(1.0 + t->Phi()/3.141592654)/2.0);
216 if ((jPhi < 0) || (NPHIBINS <= jPhi)) {
221 ms->AddTrack( jPhi, jEta, jPt, +1, t->Pt() );
228 for (
int ifirst=0;ifirst<46;ifirst++) {
229 if (map->hasHitInRow(kTpcId,ifirst)) {
234 for (
int ilast=45;ilast>0;ilast--) {
235 if (map->hasHitInRow(kTpcId,ilast)) {
240 mFluct[jCent]->fillEtaZ( mCurrentEvent->Vz(), t->Eta(), t->NMaxPoints(),
241 t->NFoundPoints(), t->NFitPoints(), iF, iL );
242 mFluct[jCent]->fillPtHist( t->Pt(), +1 );
243 mFluct[jCent]->fillPhiHist( t->Phi(), +1 );
244 mFluct[jCent]->fillEtaHist( t->Eta(), +1 );
245 int index = jPt + jPtCent*mnPts;
246 if ((-1 < index) && (index < mnPtCents*mnPts)) {
247 mPtFluct[index]->fillEtaZ( mCurrentEvent->Vz(), t->Eta(), t->NMaxPoints(),
248 t->NFoundPoints(), t->NFitPoints(), iF, iL );
249 mPtFluct[index]->fillPtHist( t->Pt(), +1 );
250 mPtFluct[index]->fillPtHist( t->Phi(), +1 );
251 mPtFluct[index]->fillPtHist( t->Eta(), +1 );
255 tc = mCurrentEvent->TrackCollectionM();
256 for(Iter=tc->begin(); Iter!=tc->end(); ++Iter){
258 if ( (t->Eta() > mEtaMax+etaOff) || (
mEtaMin+etaOff > t->Eta()) ) {
261 jEta = int(NETABINS*(t->Eta()-(
mEtaMin+etaOff))/(mEtaMax-
mEtaMin));
262 if ((jEta < 0) || (NETABINS <= jEta)) {
265 jPhi = int(NPHIBINS*(1.0 + t->Phi()/3.141592654)/2.0);
266 if ((jPhi < 0) || (NPHIBINS <= jPhi)) {
271 ms->AddTrack( jPhi, jEta, jPt, -1, t->Pt() );
277 for (
int ifirst=0;ifirst<46;ifirst++) {
278 if (map->hasHitInRow(kTpcId,ifirst)) {
283 for (
int ilast=45;ilast>0;ilast--) {
284 if (map->hasHitInRow(kTpcId,ilast)) {
289 mFluct[jCent]->fillEtaZ( mCurrentEvent->Vz(), t->Eta(), t->NMaxPoints(),
290 t->NFoundPoints(), t->NFitPoints(), iF, iL );
291 mFluct[jCent]->fillPtHist( t->Pt(), -1 );
292 mFluct[jCent]->fillPhiHist( t->Phi(), -1 );
293 mFluct[jCent]->fillEtaHist( t->Eta(), -1 );
294 int index = jPt + jPtCent*mnPts;
295 if ((-1 < index) && (index < mnPtCents*mnPts)) {
296 mPtFluct[index]->fillEtaZ( mCurrentEvent->Vz(), t->Eta(), t->NMaxPoints(),
297 t->NFoundPoints(), t->NFitPoints(), iF, iL );
298 mPtFluct[index]->fillPtHist( t->Pt(), -1 );
299 mPtFluct[index]->fillPtHist( t->Phi(), -1 );
300 mPtFluct[index]->fillPtHist( t->Eta(), -1 );
306 hMultiplicity->Fill(totMult);
307 hMultiplicityBinned->Fill(pow((
double)totMult,0.25));
309 hPtBinned->Fill(pow((
double)totPt,0.25));
311 void StEStructFluctAnal::AddEvent() {
312 double delEta, delPhi;
317 jCent =
mCentralities->centrality( mCurrentEvent->Centrality() );
318 if ((jCent < 0) || (mnCents <= jCent)) {
321 mnCentEvents[jCent]++;
322 jPtCent =
mCentralities->ptCentrality( mCurrentEvent->Centrality() );
327 int iPhi, jPhi, kPhi, lPhi, dPhi, iEta, jEta, kEta, lEta, dEta;
329 double NPlus, NMinus, PtPlus, PtMinus, Pt2Plus, Pt2Minus;
330 double ptNPlus, ptNMinus, ptPtPlus, ptPtMinus, ptPt2Plus, ptPt2Minus;
331 for (jPhi=0;jPhi<NPHIBINS;jPhi++) {
333 for (jEta=0;jEta<NETABINS;jEta++) {
338 jBin = offset[jPhi][jEta];
340 while ( (kPhi=getPhiStart(iPhi,dPhi)) >= 0) {
342 while ( (kEta=getEtaStart(iEta,dEta)) >= 0) {
350 NPlus = 0, NMinus = 0;
351 PtPlus = 0, PtMinus = 0;
352 Pt2Plus = 0, Pt2Minus = 0;
353 for (jPt=0;jPt<mnPts;jPt++) {
355 ptNPlus = 0, ptNMinus = 0;
356 ptPtPlus = 0, ptPtMinus = 0;
357 ptPt2Plus = 0, ptPt2Minus = 0;
358 for (lPhi=kPhi;lPhi<kPhi+dPhi;lPhi++) {
359 for (lEta=kEta;lEta<kEta+dEta;lEta++) {
360 ptNPlus += ms->mTrackBinPlus[jPt][lPhi][lEta][0];
361 ptNMinus += ms->mTrackBinMinus[jPt][lPhi][lEta][0];
362 ptPtPlus += ms->mTrackBinPlus[jPt][lPhi][lEta][1];
363 ptPtMinus += ms->mTrackBinMinus[jPt][lPhi][lEta][1];
364 ptPt2Plus += ms->mTrackBinPlus[jPt][lPhi][lEta][2];
365 ptPt2Minus += ms->mTrackBinMinus[jPt][lPhi][lEta][2];
368 int index = jPt + jPtCent*mnPts;
369 if ((-1 < index) && (index < mnPtCents*mnPts)) {
370 mPtFluct[index]->AddToBin( jBin,
373 ptPt2Plus, ptPt2Minus );
378 PtMinus += ptPtMinus;
379 Pt2Plus += ptPt2Plus;
380 Pt2Minus += ptPt2Minus;
383 mFluct[jCent]->AddToBin( jBin,
396 delEta = (mEtaMax-
mEtaMin) / NETABINS;
397 delPhi = 2.0*3.1415926 / NPHIBINS;
398 double nplus = 0, nminus = 0, pplus = 0, pminus = 0;
400 for (
int jPt=0;jPt<mnPts;jPt++) {
406 for (
int jPhi=0;jPhi<NPHIBINS;jPhi++) {
407 double dp = -3.1415926 + delPhi*(jPhi+0.5);
408 for (
int jEta=0;jEta<NETABINS;jEta++) {
409 double de =
mEtaMin + delEta*(jEta+0.5);
410 double nPlus = 0, nMinus = 0, pPlus = 0, pMinus = 0;
411 for (
int jPt=0;jPt<=mnPts;jPt++) {
412 double np, nm, pp, pm;
413 np = ms->GetNPlus(jPhi,jEta,jPt);
414 nm = ms->GetNMinus(jPhi,jEta,jPt);
415 pp = ms->GetPtPlus(jPhi,jEta,jPt);
416 pm = ms->GetPtMinus(jPhi,jEta,jPt);
419 int index = jPt + jPtCent*mnPts;
420 mPtFluct[index]->fillOccupancies( dp, de, np, nm, pp, pm );
423 mptnminus[jPt] += nm;
425 mptpminus[jPt] += pm;
433 mFluct[jCent]->fillOccupancies( dp, de, nPlus, nMinus, pPlus, pMinus );
443 for (
int jPt=0;jPt<mnPts;jPt++) {
444 double np, nm, pp, pm;
449 int index = jPt + jPtCent*mnPts;
450 mPtFluct[index]->fillMults( np, nm, pp, pm );
453 mFluct[jCent]->fillMults( nplus, nminus, pplus, pminus );
459 int StEStructFluctAnal::getEtaStart(
int iEta,
int dEta ) {
460 if (dEta > NETABINS) {
463 if (1 == mEtaSumMode) {
464 int nEta = NETABINS / dEta;
465 int oEta = NETABINS % dEta;
466 if ( iEta*dEta <= NETABINS ) {
467 return (iEta-1)*dEta;
472 if (oEta+(iEta-nEta)*dEta <= NETABINS) {
473 return oEta+(iEta-nEta-1)*dEta;
476 }
else if (2 == mEtaSumMode) {
477 if (iEta+dEta <= NETABINS) {
482 }
else if (3 == mEtaSumMode) {
488 }
else if (4 == mEtaSumMode) {
492 return NETABINS-dEta-1;
494 }
else if (5 == mEtaSumMode) {
498 return (NETABINS-dEta) / 2;
500 }
else if (6 == mEtaSumMode) {
501 int nEta = NETABINS / dEta;
505 int oEta = (NETABINS % dEta) / 2;
506 return oEta + (iEta-1)*dEta;
510 int StEStructFluctAnal::getPhiStart(
int iPhi,
int dPhi ) {
511 if (dPhi > NPHIBINS) {
514 if (1 == mPhiSumMode) {
515 int nPhi = NPHIBINS / dPhi;
516 int oPhi = NPHIBINS % dPhi;
517 if ( iPhi*dPhi <= NPHIBINS ) {
518 return (iPhi-1)*dPhi;
523 if (oPhi+(iPhi-nPhi)*dPhi <= NPHIBINS) {
524 return oPhi+(iPhi-nPhi-1)*dPhi;
527 }
else if (2 == mPhiSumMode) {
528 if (iPhi+dPhi <= NPHIBINS) {
533 }
else if (3 == mPhiSumMode) {
539 }
else if (4 == mPhiSumMode) {
543 return NPHIBINS-dPhi - 1;
545 }
else if (5 == mPhiSumMode) {
549 return (NPHIBINS-dPhi) / 2;
551 }
else if (6 == mPhiSumMode) {
552 int nPhi = NPHIBINS / dPhi;
556 int oPhi = (NPHIBINS % dPhi) / 2;
557 return oPhi + (iPhi-1)*dPhi;
561 int StEStructFluctAnal::getNumEtaBins(
int dEta ) {
562 if (1 == mEtaSumMode) {
563 int nEta = NETABINS / dEta;
564 int oEta = NETABINS % dEta;
570 }
else if (2 == mEtaSumMode) {
571 return NETABINS + 1 - dEta;
572 }
else if (3 == mEtaSumMode) {
574 }
else if (4 == mEtaSumMode) {
576 }
else if (5 == mEtaSumMode) {
578 }
else if (5 == mEtaSumMode) {
579 int nEta = NETABINS / dEta;
584 int StEStructFluctAnal::getNumPhiBins(
int dPhi ) {
585 if (1 == mPhiSumMode) {
586 int nPhi = NPHIBINS / dPhi;
587 int oPhi = NPHIBINS % dPhi;
593 }
else if (2 == mPhiSumMode) {
594 return NPHIBINS + 1 - dPhi;
595 }
else if (3 == mPhiSumMode) {
597 }
else if (4 == mPhiSumMode) {
599 }
else if (5 == mPhiSumMode) {
601 }
else if (5 == mPhiSumMode) {
602 int nPhi = NPHIBINS / dPhi;
608 void StEStructFluctAnal::writeHistograms(){
610 TH1F *hEtaLimits =
new TH1F(
"EtaLimits",
"EtaLimits",2,1,2);
611 hEtaLimits->SetBinContent(1,
mEtaMin);
612 hEtaLimits->SetBinContent(2,mEtaMax);
614 delete hEtaLimits; hEtaLimits = 0;
615 hMultiplicity->Write();
616 hMultiplicityBinned->Write();
620 for (
int i=0;i<mnCents;i++) {
621 mFluct[i]->writeHistograms();
623 for (
int i=0;i<mnPtCents;i++) {
624 for (
int j=0;j<mnPts;j++) {
625 int index = j + i*mnPts;
626 mPtFluct[index]->writeHistograms();
639 cout <<
"For this analysis we have used mEtaSumMode = " << mEtaSumMode << endl;
640 cout <<
"For this analysis we have used mPhiSumMode = " << mPhiSumMode << endl;
641 cout <<
"(1 = start at bin 0. Fit as many non-overlapping bins as possible" <<endl;
642 cout <<
" If it doesn't end evenly start at end and work back.)" << endl;
643 cout <<
"(2 = start at bin 0, shift over one bin until we hit the end.)" << endl;
644 cout <<
"(3 = use one bin at beginning.)" << endl;
645 cout <<
"(4 = use one bin at end.)" << endl;
646 cout <<
"(5 = use one bin near center.)" << endl;
647 cout <<
"(6 = fit as many non-overlapping bins in as possible.";
648 cout <<
" Coverage as centered as possible.)" << endl;
651 cout <<
"Looped over " << mnTotEvents <<
" total events" << endl;
652 cout <<
" For each centrality have ";
653 for (
int jCent=0;jCent<mnCents;jCent++) {
654 cout << mnCentEvents[jCent] <<
" ";
658 void StEStructFluctAnal::writeQAHists(TFile* qatf) {
669 for (
int i=0;i<mnCents;i++) {
670 mFluct[i]->writeQAHistograms();
672 for (
int i=0;i<mnPtCents;i++) {
673 for (
int j=0;j<mnPts;j++) {
674 int index = j + i*mnPts;
675 mPtFluct[index]->writeQAHistograms();
682 void StEStructFluctAnal::initHistograms(){
684 hMultiplicity =
new TH1F(
"Multiplicity",
"Multiplicity",2000,1,2000);
685 hMultiplicityBinned =
new TH1F(
"MultiplicityBinned",
"MultiplicityBinned",120,1.0,7.0);
686 hPt =
new TH1F(
"Pt",
"Pt",2000,1,2000);
687 hPtBinned =
new TH1F(
"PtBinned",
"PtBinned",120,0.0,6.0);
693 for (
int jPhi=0;jPhi<NPHIBINS;jPhi++) {
695 for (
int jEta=0;jEta<NETABINS;jEta++) {
700 while ( (kPhi=getPhiStart(iPhi,dPhi)) >= 0) {
702 while ( (kEta=getEtaStart(iEta,dEta)) >= 0) {
703 area += double(dEta*dPhi);
709 nBins[jPhi][jEta] = iBin;
710 if (area < NPHIBINS*NETABINS) {
711 fUnique[jPhi][jEta] = 1;
713 fUnique[jPhi][jEta] = double(NPHIBINS*NETABINS) / area;
715 offset[jPhi][jEta] = off;
720 cout <<
"Creating histograms for bins, uniqueness etc. " << endl;
721 hnBins =
new TH2F(
"nBins",
"nBins", NPHIBINS,0.5,NPHIBINS+0.5,NETABINS,0.5,NETABINS+0.5);
722 hoffset =
new TH2F(
"offset",
"offset",NPHIBINS,0.5,NPHIBINS+0.5,NETABINS,0.5,NETABINS+0.5);
723 hfUnique =
new TH2F(
"fUnique",
"fUnique",NPHIBINS,0.5,NPHIBINS+0.5,NETABINS,0.5,NETABINS+0.5);
724 for (
int jPhi=0;jPhi<NPHIBINS;jPhi++) {
725 for (
int jEta=0;jEta<NETABINS;jEta++) {
726 hnBins->SetBinContent(jPhi+1,jEta+1,nBins[jPhi][jEta]);
727 hoffset->SetBinContent(jPhi+1,jEta+1,offset[jPhi][jEta]);
728 hfUnique->SetBinContent(jPhi+1,jEta+1,fUnique[jPhi][jEta]);
733 void StEStructFluctAnal::deleteHistograms() {
735 delete hMultiplicity; hMultiplicity = 0;
737 if (hMultiplicityBinned) {
738 delete hMultiplicityBinned; hMultiplicityBinned = 0;
744 delete hPtBinned; hPtBinned = 0;
747 delete hnBins; hnBins = 0;
750 delete hoffset; hoffset = 0;
753 delete hfUnique; hfUnique = 0;
756 float StEStructFluctAnal::etaOffset(
float vz ) {
bool mlocalQAHists
for QA histogramming
StEStructQAHists * mQAHists
for pairs kine + all paircuts
float mEtaMin
toggle needed for who writes out
StEStructCentrality * mCentralities
pointer to EStruct2pt data