StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
QoslCMSCorrFctnRPkT.cxx
1 #include "StHbtMaker/CorrFctn/QoslCMSCorrFctnRPkT.h"
2 #include <cstdio>
3 #include "StHbtMaker/Infrastructure/StHbtReactionPlaneAnalysis.h"
4 #include "PhysicalConstants.h"
5 #include "TString.h"
6 #include "TH3S.h"
7 
8 #ifdef __ROOT__
9 ClassImp(QoslCMSCorrFctnRPkT)
10 #endif
11 //____________________________
12 QoslCMSCorrFctnRPkT::QoslCMSCorrFctnRPkT(char* title, const int& nbinso, const float& QoLo, const float& QoHi,
13  const int& nbinss, const float& QsLo, const float& QsHi,
14  const int& nbinsl, const float& QlLo, const float& QlHi, const int& rpBins){
15 
16  mCorrection = new StHbtCoulomb;
17  mCorrection->SetRadius(5.0);
18  mCorrection->SetChargeProduct(1.0);
19 
20  qMax = QoHi;
21 
22  nRPbins = rpBins;
23  nKtBins = 4;
24 
25  for(int i=0; i<nRPbins; i++) {
26  TString TitAngle=Form("_phi%i",i*180/nRPbins);
27 
28  for(int j=0; j<nKtBins; j++) {
29  TString TitKt=Form("_kt%i",j);
30 
31  // set up numerator
32  TString TitNum = "Num";
33  TitNum += title;
34  TitNum += TitAngle.Data();
35  TitNum += TitKt.Data();
36  mNumerator[i][j] = new TH3S(TitNum.Data(),TitNum.Data(),nbinso,QoLo,QoHi,
37  nbinss,QsLo,QsHi,
38  nbinsl,QlLo,QlHi);
39 
40  // set up denominator
41  TString TitDen = "Den";
42  TitDen += title;
43  TitDen += TitAngle.Data();
44  TitDen += TitKt.Data();
45  mDenominator[i][j] = new TH3S(TitDen.Data(),TitDen.Data(),nbinso,QoLo,QoHi,
46  nbinss,QsLo,QsHi,
47  nbinsl,QlLo,QlHi);
48 
50  //char TitQinv[100] = "Qinv";
51  //strcat(TitQinv,title);
52  //strcat(TitQinv,TitAngle.Data());
53  //strcat(TitQinv,TitKt.Data());
54  //mQinvHisto[i][j] = new StHbt3DHisto(TitQinv,TitQinv,nbinso,QoLo,QoHi,nbinss,QsLo,QsHi,nbinsl,QlLo,QlHi);
55 
56  // set up ave qInv
57  TString TitCoul = "Coul";
58  TitCoul += title;
59  TitCoul += TitAngle.Data();
60  TitCoul += TitKt.Data();
61  mCoulHisto[i][j] = new StHbt3DHisto(TitCoul.Data(),TitCoul.Data(),nbinso,QoLo,QoHi,nbinss,QsLo,QsHi,nbinsl,QlLo,QlHi);
62 
63  // to enable error bar calculation...
64  //mCoulHisto[i][j]->Sumw2();
65 
66  }
67  }
68 
69 }
70 
71 //____________________________
72 QoslCMSCorrFctnRPkT::~QoslCMSCorrFctnRPkT(){
73  for(int i=0; i<nRPbins; i++) {
74  for(int j=0; j<nKtBins; j++) {
75  delete mNumerator[i][j];
76  delete mDenominator[i][j];
77  delete mCoulHisto[i][j];
78  }
79  }
80 }
81 //_________________________
82 void QoslCMSCorrFctnRPkT::Finish(){
83  // here is where we should normalize, fit, etc...
84 // for(int i=0; i<nRPbins; i++) {
85 // for(int j=0; j<nKtBins; j++) {
86 // mQinvHisto[i][j]->Divide(mDenominator[i][j]);
87 // }
88 // }
89 
90 }
91 
92 //____________________________
93 StHbtString QoslCMSCorrFctnRPkT::Report(){
94  string stemp = "QoslCMS Correlation Function Report:\n";
95  char ctemp[100];
96  sprintf(ctemp,"Number of entries in numerator:\t%E\n",mNumerator[0][0]->GetEntries());
97  stemp += ctemp;
98  sprintf(ctemp,"Number of entries in denominator:\t%E\n",mDenominator[0][0]->GetEntries());
99  stemp += ctemp;
100  // stemp += mCoulombWeight->Report();
101 
102  StHbtString returnThis = stemp;
103  return returnThis;
104 }
105 //____________________________
106 void QoslCMSCorrFctnRPkT::AddRealPair(const StHbtPair* pair){
107 
108  int rpBin, ktBin;
109  rpBin = GetRPBin(pair);
110  ktBin = GetKtBin(pair);
111  if(ktBin<0) return;
112 
113  double Qo = pair->qOutCMS();
114  double Qs = pair->qSideCMS();
115  double Ql = pair->qLongCMS();
116 
117  if(fabs(Qo)>qMax || fabs(Qs)>qMax || fabs(Ql)>qMax) return;
118 
119  Ql = fabs(Ql);
120  if ( Qs<0.0 ) {
121  Qs*=-1.0;
122  Qo*=-1.0;
123  }
124  mNumerator[rpBin][ktBin]->Fill(Qo,Qs,Ql);
125 }
126 //____________________________
127 void QoslCMSCorrFctnRPkT::AddMixedPair(const StHbtPair* pair){
128 
129  int rpBin, ktBin;
130  rpBin = GetRPBin(pair);
131  ktBin = GetKtBin(pair);
132  if(ktBin<0) return;
133 
134  //double Qinv = fabs(pair->qInv());
135 
136  double weight = 1.0;
137  if (mCorrection) weight = mCorrection->CoulombCorrect(pair);
138 
139  double Qo = pair->qOutCMS();
140  double Qs = pair->qSideCMS();
141  double Ql = pair->qLongCMS();
142 
143  if(fabs(Qo)>qMax || fabs(Qs)>qMax || fabs(Ql)>qMax) return;
144 
145  Ql = fabs(Ql);
146  if ( Qs<0.0 ) {
147  Qs*=-1.0;
148  Qo*=-1.0;
149  }
150  mDenominator[rpBin][ktBin]->Fill(Qo,Qs,Ql);
151  mCoulHisto[rpBin][ktBin]->Fill(Qo,Qs,Ql,weight);
152 
153 }
154 //____________________________
155 int QoslCMSCorrFctnRPkT::GetRPBin(const StHbtPair* pair) {
156 
157  // Get pair angle, put it between 0 and 360
158  double pxTotal = pair->fourMomentumSum().x();
159  double pyTotal = pair->fourMomentumSum().y();
160  double angle = atan2(pyTotal,pxTotal)*180.0/pi;
161  if (angle<0.0) angle+=360.0;
162 
163  // Get RP angle
165  double RPangle = RPanal->ReactionPlane()*180.0/pi;
166 
167  // Get angle difference, put it within full rp bin range
168  // (low edge of '0' bin to upper edge of highest bin)
169  // for example: if nRPbins=3, then -30 < angleDiff < 150
170  // This assumes we're looking at 2nd harmonic of RP only
171  double angleDifference = angle-RPangle;
172  if (angleDifference<0.0) angleDifference+=360.0;
173  if (angleDifference>=180.0) angleDifference-=180.0;
174  if (angleDifference>=(180.0-90.0/nRPbins)) angleDifference-=180.0;
175 
176  // Determine rp bin ( 0 <= rpBin <= nRPbins-1 )
177  int rpBin;
178  rpBin = (int) ((angleDifference*nRPbins/180.0)+0.5);
179  if(rpBin>=nRPbins || ((angleDifference*nRPbins/180.0)+0.5)<0.0)
180  cout << endl << endl << endl << endl << "PROBLEM!!!!" << endl << endl << endl
181  << endl << endl << endl;
182  return rpBin;
183 
184 }
185 //____________________________
186 int QoslCMSCorrFctnRPkT::GetKtBin(const StHbtPair* pair) {
187 
188  double kT = fabs(pair->kT());
189  int ktBin;
190 
191  if(kT<0.15 || kT>0.6) return -1;
192 
193  if(kT<0.25)
194  ktBin = 0;
195  else if( kT >= 0.25 && kT < 0.35 )
196  ktBin = 1;
197  else if( kT >= 0.35 && kT < 0.45 )
198  ktBin = 2;
199  else if( kT >= 0.45 && kT <= 0.6 )
200  ktBin = 3;
201 
202  return ktBin;
203 
204 }
205 //____________________________
206 void QoslCMSCorrFctnRPkT::SetCorrection(StHbtCoulomb* coulomb) {
207  mCorrection = coulomb;
208 }
209 
210