18 #include "StFlowScalarProdMaker.h"
19 #include "StFlowMaker/StFlowMaker.h"
20 #include "StFlowMaker/StFlowEvent.h"
21 #include "StFlowMaker/StFlowConstants.h"
22 #include "StFlowMaker/StFlowSelection.h"
24 #include "PhysicalConstants.h"
25 #include "SystemOfUnits.h"
32 #include "TProfile2D.h"
33 #include "StMessMgr.h"
35 #define PR(x) cout << "##### FlowScalarProdAnalysis: " << (#x) << " = " << (x) << endl;
47 StFlowScalarProdMaker::StFlowScalarProdMaker(
const Char_t* name,
55 StFlowScalarProdMaker::~StFlowScalarProdMaker() {
66 if (pFlowMaker) pFlowEvent = pFlowMaker->FlowEventPointer();
68 if (pFlowSelect->Select(pFlowEvent)) {
70 FillEventHistograms();
71 if (pFlowEvent) FillParticleHistograms();
73 if (Debug()) StMaker::PrintInfo();
75 gMessMgr->Info(
"##### FlowScalarProdMaker: FlowEvent pointer null");
83 Int_t StFlowScalarProdMaker::Init() {
86 float ptMaxPart = Flow::ptMaxPart;
87 if (pFlowSelect->PtMaxPart()) {
88 ptMaxPart = pFlowSelect->PtMaxPart();
90 int nPtBinsPart = Flow::nPtBinsPart;
91 if (pFlowSelect->PtBinsPart()) {
92 nPtBinsPart = pFlowSelect->PtBinsPart();
94 xLabel =
"Pseudorapidity";
95 if (strlen(pFlowSelect->PidPart()) != 0) { xLabel =
"Rapidity"; }
100 for (
int k = 0; k < Flow::nSels; k++) {
103 histTitle =
new TString(
"Flow_Res_ScalarProd_Sel");
105 histFull[k].mHistRes =
new TProfile(histTitle->Data(), histTitle->Data(),
106 Flow::nHars, 0.5, (float)(Flow::nHars) + 0.5, -1.*FLT_MAX, FLT_MAX,
"");
107 histFull[k].mHistRes->SetXTitle(
"Harmonic");
108 histFull[k].mHistRes->SetYTitle(
"Resolution");
112 histTitle =
new TString(
"Flow_vObs_ScalarProd_Sel");
114 histFull[k].mHist_vObs =
new TProfile(histTitle->Data(), histTitle->Data(),
115 Flow::nHars, 0.5, (float)(Flow::nHars) + 0.5, -10000., 10000.,
"");
116 histFull[k].mHist_vObs->SetXTitle(
"Harmonic");
117 histFull[k].mHist_vObs->SetYTitle(
"vObs (%)");
121 for (
int j = 0; j < Flow::nHars; j++) {
124 histTitle =
new TString(
"Flow_vObs2D_ScalarProd_Sel");
126 histTitle->Append(
"_Har");
128 histFull[k].histFullHar[j].mHist_vObs2D =
new TProfile2D(histTitle->Data(),
129 histTitle->Data(), mNEtaBins, mEtaMin, mEtaMax, nPtBinsPart,
130 Flow::ptMin, ptMaxPart, -10000., 10000.,
"");
131 histFull[k].histFullHar[j].mHist_vObs2D->SetXTitle((
char*)xLabel.Data());
132 histFull[k].histFullHar[j].mHist_vObs2D->SetYTitle(
"Pt (GeV/c)");
136 histTitle =
new TString(
"Flow_vObsEta_ScalarProd_Sel");
138 histTitle->Append(
"_Har");
140 histFull[k].histFullHar[j].mHist_vObsEta =
new TProfile(histTitle->Data(),
141 histTitle->Data(), mNEtaBins, mEtaMin, mEtaMax,
142 -10000., 10000.,
"");
143 histFull[k].histFullHar[j].mHist_vObsEta->SetXTitle((
char*)xLabel.Data());
144 histFull[k].histFullHar[j].mHist_vObsEta->SetYTitle(
"v (%)");
147 histTitle =
new TString(
"Flow_vObsPt_ScalarProd_Sel");
149 histTitle->Append(
"_Har");
151 histFull[k].histFullHar[j].mHist_vObsPt =
new TProfile(histTitle->Data(),
152 histTitle->Data(), nPtBinsPart, Flow::ptMin, ptMaxPart, -10000., 10000.,
"");
153 histFull[k].histFullHar[j].mHist_vObsPt->SetXTitle(
"Pt (GeV/c)");
154 histFull[k].histFullHar[j].mHist_vObsPt->SetYTitle(
"v (%)");
160 gMessMgr->SetLimit(
"##### FlowScalarProd", 2);
161 gMessMgr->Info(
"##### FlowScalarProdAnalysis: $Id: StFlowScalarProdMaker.cxx,v 1.12 2004/12/09 23:47:10 posk Exp $");
163 return StMaker::Init();
170 void StFlowScalarProdMaker::FillFromFlowEvent() {
173 for (
int k = 0; k < Flow::nSels; k++) {
174 pFlowSelect->SetSelection(k);
175 for (
int j = 0; j < Flow::nHars; j++) {
176 pFlowSelect->SetHarmonic(j);
177 for (
int n = 0; n < Flow::nSubs; n++) {
178 pFlowSelect->SetSubevent(n);
179 int i = Flow::nSels*k + n;
181 mQSub[i][j]=pFlowEvent->Q(pFlowSelect);
184 pFlowSelect->SetSubevent(-1);
186 mQ[k][j] = pFlowEvent->Q(pFlowSelect);
194 void StFlowScalarProdMaker::FillEventHistograms() {
197 for (
int k = 0; k < Flow::nSels; k++) {
198 for (
int j = 0; j < Flow::nHars; j++) {
199 float order = (float)(j+1);
201 histFull[k].mHistRes->Fill(order, (mQSub[Flow::nSels*k + 0][j].X()) *
202 (mQSub[Flow::nSels*k + 1][j].X()) + (mQSub[Flow::nSels*k + 0][j].Y())
203 * (mQSub[Flow::nSels*k + 1][j].Y()) );
212 void StFlowScalarProdMaker::FillParticleHistograms() {
216 StFlowTrackCollection* pFlowTracks = pFlowEvent->TrackCollection();
217 StFlowTrackIterator itr;
219 for (itr = pFlowTracks->begin(); itr != pFlowTracks->end(); itr++) {
222 float phi = pFlowTrack->Phi();
223 if (phi < 0.) phi += twopi;
224 float eta = pFlowTrack->Eta();
225 float pt = pFlowTrack->Pt();
229 for (
int k = 0; k < Flow::nSels; k++) {
230 pFlowSelect->SetSelection(k);
231 for (
int j = 0; j < Flow::nHars; j++) {
232 pFlowSelect->SetHarmonic(j);
234 if (pFlowSelect->SelectPart(pFlowTrack)) {
235 bool oddHar = (j+1) % 2;
236 double order = (double)(j+1);
237 TVector2 mQ_i = mQ[k][j];
240 if (pFlowSelect->Select(pFlowTrack)) {
241 double phiWgt = pFlowEvent->PhiWeight(k, j, pFlowTrack);
242 q_i.Set(phiWgt * cos(phi * order), phiWgt * sin(phi * order));
247 u_i.Set(cos(phi*order), sin(phi*order));
248 float v = (mQ_i.X()*u_i.X() + mQ_i.Y()*u_i.Y()) /perCent;
250 if (eta < 0 && oddHar) vFlip *= -1;
251 if (strlen(pFlowSelect->PidPart()) != 0) {
252 float rapidity = pFlowTrack->Y();
253 histFull[k].histFullHar[j].mHist_vObs2D-> Fill(rapidity, pt, v);
254 histFull[k].histFullHar[j].mHist_vObsEta->Fill(rapidity, v);
256 histFull[k].histFullHar[j].mHist_vObs2D-> Fill(eta, pt, v);
257 histFull[k].histFullHar[j].mHist_vObsEta->Fill(eta, v);
259 histFull[k].histFullHar[j].mHist_vObsPt-> Fill(pt, vFlip);
260 histFull[k].mHist_vObs->Fill(order, vFlip);
281 cout << endl <<
"##### Scalar Product Maker:" << endl;
283 for (
int k = 0; k < Flow::nSels; k++) {
286 histTitle =
new TString(
"Flow_v_ScalarProd_Sel");
288 histFull[k].mHist_v =
289 histFull[k].mHist_vObs->ProjectionX(histTitle->Data());
290 histFull[k].mHist_v->SetTitle(histTitle->Data());
291 histFull[k].mHist_v->SetXTitle(
"Harmonic");
292 histFull[k].mHist_v->SetYTitle(
"v (%)");
294 AddHist(histFull[k].mHist_v);
296 for (
int j = 0; j < Flow::nHars; j++) {
299 mRes[k][j] = ::sqrt(histFull[k].mHistRes->GetBinContent(j+1))*2.;
300 mResErr[k][j] = (histFull[k].mHistRes->GetBinError(j+1))*2./mRes[k][j];
303 histTitle =
new TString(
"Flow_v2D_ScalarProd_Sel");
305 histTitle->Append(
"_Har");
307 histFull[k].histFullHar[j].mHist_v2D =
308 histFull[k].histFullHar[j].mHist_vObs2D->ProjectionXY(histTitle->Data());
309 histFull[k].histFullHar[j].mHist_v2D->SetTitle(histTitle->Data());
310 histFull[k].histFullHar[j].mHist_v2D->SetXTitle((
char*)xLabel.Data());
311 histFull[k].histFullHar[j].mHist_v2D->SetYTitle(
"Pt (GeV/c)");
312 histFull[k].histFullHar[j].mHist_v2D->SetZTitle(
"v (%)");
314 AddHist(histFull[k].histFullHar[j].mHist_v2D);
317 histTitle =
new TString(
"Flow_vEta_ScalarProd_Sel");
319 histTitle->Append(
"_Har");
321 histFull[k].histFullHar[j].mHist_vEta =
322 histFull[k].histFullHar[j].mHist_vObsEta->ProjectionX(histTitle->Data());
323 histFull[k].histFullHar[j].mHist_vEta->SetTitle(histTitle->Data());
324 histFull[k].histFullHar[j].mHist_vEta->SetXTitle((
char*)xLabel.Data());
325 histFull[k].histFullHar[j].mHist_vEta->SetYTitle(
"v (%)");
327 AddHist(histFull[k].histFullHar[j].mHist_vEta);
329 TString* histTitle =
new TString(
"Flow_vPt_ScalarProd_Sel");
331 histTitle->Append(
"_Har");
333 histFull[k].histFullHar[j].mHist_vPt =
334 histFull[k].histFullHar[j].mHist_vObsPt->ProjectionX(histTitle->Data());
335 histFull[k].histFullHar[j].mHist_vPt->SetTitle(histTitle->Data());
336 histFull[k].histFullHar[j].mHist_vPt->SetXTitle(
"Pt (GeV/c)");
337 histFull[k].histFullHar[j].mHist_vPt->SetYTitle(
"v (%)");
339 AddHist(histFull[k].histFullHar[j].mHist_vPt);
343 cout <<
"##### Resolution of the " << j+1 <<
"th harmonic = " <<
344 mRes[k][j] <<
" +/- " << mResErr[k][j] << endl;
346 histFull[k].histFullHar[j].mHist_v2D ->Scale(1. / mRes[k][j]);
347 histFull[k].histFullHar[j].mHist_vEta->Scale(1. / mRes[k][j]);
348 histFull[k].histFullHar[j].mHist_vPt ->Scale(1. / mRes[k][j]);
349 content = histFull[k].mHist_v->GetBinContent(j+1);
350 content /= mRes[k][j];
351 histFull[k].mHist_v->SetBinContent(j+1, content);
353 error = histFull[k].mHist_v->GetBinError(j+1);
355 totalError = fabs(content) * ::sqrt((error/content)*(error/content) +
356 (mResErr[k][j]/mRes[k][j])*(mResErr[k][j]/mRes[k][j]));
357 histFull[k].mHist_v->SetBinError(j+1, totalError);
358 cout <<
"##### v" << j+1 <<
"= (" << content <<
" +/- " << error <<
359 " +/- " << totalError <<
"(with syst.)) %" << endl;
361 cout <<
"##### Resolution of the " << j+1 <<
"th harmonic was zero."
363 histFull[k].histFullHar[j].mHist_v2D ->Reset();
364 histFull[k].histFullHar[j].mHist_vEta->Reset();
365 histFull[k].histFullHar[j].mHist_vPt ->Reset();
366 histFull[k].mHist_v->SetBinContent(j+1, 0.);
367 histFull[k].mHist_v->SetBinError(j+1, 0.);
374 TFile histFile(
"flow.scalar.root",
"RECREATE");
375 GetHistList()->Write();
385 void StFlowScalarProdMaker::SetHistoRanges(Bool_t ftpc_included) {
388 mEtaMin = Flow::etaMin;
389 mEtaMax = Flow::etaMax;
390 mNEtaBins = Flow::nEtaBins;
392 mEtaMin = Flow::etaMinTpcOnly;
393 mEtaMax = Flow::etaMaxTpcOnly;
394 mNEtaBins = Flow::nEtaBinsTpcOnly;