StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEStructEvent.cxx
1 /**********************************************************************
2  *
3  * $Id: StEStructEvent.cxx,v 1.15 2013/02/08 19:32:52 prindle Exp $
4  *
5  * Author: Jeff Porter as rewrite of Ebye code by Jeff Reid
6  *
7  **********************************************************************
8  *
9  * Description: Event quantities + list of (primary) tracks
10  * Depending on option may use global tracks
11  *
12  **********************************************************************/
13 
14 #include "StEStructEvent.h"
15 #include "StEStructTrack.h"
16 #include "StEStructCentrality.h"
17 #include <math.h>
18 #include "PhysicalConstants.h"
19 #include "TVector2.h"
20 #include "TH1.h"
21 #include "TFile.h"
22 
23 ClassImp(StEStructEvent)
24 
25 //-------------------------------------------------------
27 
28  fTracks = new TClonesArray("StEStructTrack", 1200); // 1200 is not the max size, just an initial suggestion for ROOT
29  mNtrack = 0;
30 
31  mTrackCollectionM = new StEStructTrackCollection();
32  mTrackCollectionP = new StEStructTrackCollection();
33 
34  mPsi = 0.; // Initialize event plane angle
35 }
36 
37 //-------------------------------------------------------
39 
40  mRunID = e.RunID();
41  mEventTime = e.EventTime();
42  mVx = e.Vx();
43  mVy = e.Vy();
44  mVz = e.Vz();
45  mBField = e.BField();
46  mZDCe = e.ZDCe();
47  mZDCw = e.ZDCw();
48  mZDCCoincidence = e.ZDCCoincidence();
49 
50  StEStructTrack::BField = e.BField();
51  mNtrack=0;
52  fTracks = new TClonesArray("StEStructTrack", 1200);
53  for(int i=0;i<e.Ntrack();i++){
54  StEStructTrack* t=(StEStructTrack*)e.Tracks()->UncheckedAt(i);
55  AddTrack(t);
56  }
57 
58  mTrackCollectionM = new StEStructTrackCollection();
59  mTrackCollectionP = new StEStructTrackCollection();
60  FillChargeCollections();
61 
62  mPsi = 0.; // Initialize event plane angle
63 };
64 
65 
66 //-------------------------------------------------------
67 StEStructEvent::~StEStructEvent(){
68 
69  Clear();
70  delete fTracks;
71  // delete mTrackCollectionM;
72  // delete mTrackCollectionP;
73 
74 };
75 
76 //-------------------------------------------------------
77 void StEStructEvent::AddTrack(StEStructTrack* inputTrack) {
78 
79  // Add a new track to the list of tracks for this StEStructEvent.
80  // To avoid calling the very time consuming operator new for each track,
81  // the standard but not well know C++ operator "new with placement"
82  // is called. If tracks[i] is 0, a new Track object will be created
83  // otherwise the previous Track[i] will be overwritten.
84  // [Note: new with placement is now the only way to fill a TClonesArray,
85  // see the ROOT class documentation for details]
86 
87  TClonesArray &tracks = *fTracks; // this is a reference: tracks = *fTracks
88  new(tracks[mNtrack++]) StEStructTrack(inputTrack);
89 }
90 
91 
92 //-------------------------------------------------------
93 void StEStructEvent::Clear(Option_t *option) {
94 
95  mTrackCollectionP->Clear();
96  mTrackCollectionM->Clear();
97  fTracks->Clear(option);
98  mNtrack=0;
99 }
100 
101 
102 //-------------------------------------------------------
103 void StEStructEvent::FillChargeCollections(){
104 
105  int num=Ntrack();
106  if(num<=0) return;
107 
108  int id = mRunID;
109  int time = mEventTime;
110  double vx = mVx;
111  double vy = mVy;
112  double vz = mVz;
113  double b = mBField;
114 
115  for(int i=0;i<num;i++){
116  StEStructTrack* aTrack=(StEStructTrack*)Tracks()->UncheckedAt(i);
117  if(!aTrack->isComplete()){
118  aTrack->FillTransientData();
119  aTrack->FillTpcReferencePoints();
120  aTrack->SetComplete();
121  }
122 
123  if(aTrack->Charge()==-1){
124  TrackCollectionM()->push_back(aTrack);
125  } else if(aTrack->Charge()==1){
126  TrackCollectionP()->push_back(aTrack);
127  } else {
128  cout<<" Track Charge = "<<aTrack->Charge()<<endl;
129  }
130  }
131 
132 }
133 
134 
135 //-------------------------------------------------------
136 StEStructTrackCollection * StEStructEvent::TrackCollectionM() const { return mTrackCollectionM;};
137 StEStructTrackCollection * StEStructEvent::TrackCollectionP() const { return mTrackCollectionP;};
138 
139 //-------------------------------------------------------
140 TVector2 StEStructEvent::Q() {
141  // Event plane vector
142 
143  TVector2 mQ;
144  Float_t mQx=0., mQy=0.;
145 
146 /* if (mUseZDCSMD) { // pFlowSelect is disabled; only 1st order Q generated
147  Float_t eXsum=0., eYsum=0., wXsum=0., wYsum=0.;
148  Float_t eXWgt=0., eYWgt=0., wXWgt=0., wYWgt=0.;
149  for (int v=1; v<8; v++) {
150  eXsum += ZDCSMD_GetPosition(0,0,v)*ZDCSMD(0,0,v);
151  wXsum += ZDCSMD_GetPosition(1,0,v)*ZDCSMD(1,0,v);
152  eXWgt += ZDCSMD(0,0,v);
153  wXWgt += ZDCSMD(1,0,v);
154  } //v
155  for (int h=1;h<9;h++) {
156  eYsum += ZDCSMD_GetPosition(0,1,h)*ZDCSMD(0,1,h);
157  wYsum += ZDCSMD_GetPosition(1,1,h)*ZDCSMD(1,1,h);
158  eYWgt += ZDCSMD(0,1,h);
159  wYWgt += ZDCSMD(1,1,h);
160  }
161  mQx= (eXWgt>0. && wXWgt>0. && eYWgt>0. && wYWgt>0.) ?
162  eXsum/eXWgt - wXsum/wXWgt:0.;
163  mQy= (eXWgt>0. && wXWgt>0. && eYWgt>0. && wYWgt>0.) ?
164  eYsum/eYWgt - wYsum/wYWgt:0.;
165  } //if
166  else { */
167  //int selN = pFlowSelect->Sel();
168  //int harN = pFlowSelect->Har();
169  int harN = 1;
170  double order = (double)(harN + 1);
171 
172  StEStructTrackIterator itr;
173  for (itr = TrackCollectionM()->begin();
174  itr != TrackCollectionM()->end(); itr++) {
175  StEStructTrack* pFlowTrack = *itr;
176  //if (pFlowSelect->Select(pFlowTrack)) {
177  //double phiWgt = PhiWeight(selN, harN, pFlowTrack);
178  double phiWgt = 1.;
179  Float_t phi = pFlowTrack->Phi();
180  //Float_t phiWgt = mPhiWgt->GetBinContent(mPhiWgt->FindBin(phi));
181  mQx += phiWgt * cos(phi * order);
182  mQy += phiWgt * sin(phi * order);
183  //}
184  }
185  for (itr = TrackCollectionP()->begin();
186  itr != TrackCollectionP()->end(); itr++) {
187  StEStructTrack* pFlowTrack = *itr;
188  double phiWgt = 1.;
189  Float_t phi = pFlowTrack->Phi();
190  //Float_t phiWgt = mPhiWgt->GetBinContent(mPhiWgt->FindBin(phi));
191  mQx += phiWgt * cos(phi * order);
192  mQy += phiWgt * sin(phi * order);
193  }
194 // itr.~StEStructTrackIterator(); djp
195 // } //else
196 
197  mQ.Set(mQx, mQy);
198  return mQ;
199 }
200 
201 //-------------------------------------------------------
202 void StEStructEvent::CalculatePsi() {
203  // Event plane angle
204 
205  //int harN = pFlowSelect->Har();
206  int harN = 1;
207  float order = (float)(harN + 1);
208  Float_t psi = 0.;
209 
210  TVector2 mQ = Q();
211 
212  if (mQ.Mod()) {
213  psi= mQ.Phi() / order;
214  if (psi < 0.) { psi += twopi / order; }
215  }
216 
217 // return psi;
218  mPsi = psi;
219 // mQ.~TVector2(); djp
220 }
221 
222 //-------------------------------------------------------
223 Float_t StEStructEvent::Psi() {
224  return mPsi;
225 }
226 
227 //-------------------------------------------------------
228 void StEStructEvent::ShiftPhi() {
229  // First, need to calculate the event plane angle
230  CalculatePsi();
231 
232  StEStructTrackIterator itr;
233  for (itr = TrackCollectionM()->begin();
234  itr != TrackCollectionM()->end(); itr++) {
235  StEStructTrack* pTrack = *itr;
236  Float_t phi = pTrack->Phi();
237  phi -= mPsi;
238  if(phi<-pi) {phi += twopi;}
239  pTrack->SetPhi(phi);
240  }
241  for (itr = TrackCollectionP()->begin();
242  itr != TrackCollectionP()->end(); itr++) {
243  StEStructTrack* pTrack = *itr;
244  Float_t phi = pTrack->Phi();
245  phi -= mPsi;
246  if(phi<-pi) {phi += twopi;}
247  pTrack->SetPhi(phi);
248  }
249 // itr.~StEStructTrackIterator(); djp
250 }
251 
252 //-------------------------------------------------------
253 void StEStructEvent::SetPhiWgt(const char* weightFile) {
254  TFile* tf=new TFile(weightFile);
255  TString hname("PhiWgt");
256  mPhiWgt = (TH1F *) tf->Get(hname.Data());
257 
258  // delete phiWgt;
259 // hname.~TString(); djp
260 // tf->~TFile(); djp
261  delete tf;
262 }
263 
264 /**********************************************************************
265  *
266  * $Log: StEStructEvent.cxx,v $
267  * Revision 1.15 2013/02/08 19:32:52 prindle
268  * Added "Triggered" histograms in StEStruct2ptCorrelations.
269  * Protected against using tracks cuts in StEStruct2ptCorrelations when reading EStruct format events.
270  * Added comment in EventMaker/StEStructTrack.cxx pointing out need to set BField correctly
271  * when reading EStruct format events. (This should be read from file somehow, but...)
272  *
273  * Revision 1.14 2012/11/16 21:24:37 prindle
274  * Changes to support reading/writing of EStructEvent. Fill helix as transient and
275  * get BField from file (?).
276  *
277  * Revision 1.13 2011/08/02 20:36:57 prindle
278  * Event: modifications for ZDCCoincidence
279  * Track: big changes in evalPID. These should be superseded when TOF-dEdx
280  * space is understood better.
281  *
282  * Revision 1.12 2008/05/01 23:41:44 prindle
283  * Just different comments.
284  *
285  * Revision 1.11 2007/02/05 17:20:09 msd
286  * Added include statement
287  *
288  * Revision 1.10 2006/10/02 22:24:02 prindle
289  * Removed a few destructors that I think caused crashes.
290  *
291  * Revision 1.9 2006/04/26 18:49:55 dkettler
292  *
293  * Added reaction plane determination for the analysis
294  *
295  * Added reaction plane angle calculation
296  *
297  * Revision 1.8 2006/04/06 01:06:18 prindle
298  *
299  * Rationalization of centrality binning, as described in AnalysisMaker checkin.
300  *
301  * Revision 1.7 2006/04/04 22:12:30 porter
302  * Set up StEtructCentrality for use in event cut selection - includes impact para for generators
303  *
304  * Revision 1.6 2006/02/22 22:06:05 prindle
305  * Removed all references to multRef (?)
306  *
307  * Revision 1.5 2005/09/14 17:21:14 msd
308  * Simplified helix fitting by taking helix from mudst instead of calculating from scratch
309  *
310  * Revision 1.4 2004/06/25 03:13:41 porter
311  * updated centrality methods and put a test in StEStructEvent.cxx
312  *
313  * Revision 1.3 2004/06/09 22:39:09 prindle
314  * Expanded centrality class.
315  * Call to set centrality from event reader.
316  *
317  *
318  * CVS :nded ----------------------------------------------------------------------
319  *
320  * Revision 1.2 2004/02/27 02:28:04 prindle
321  *
322  * Small modification to StEStructCentrality in EventMaker branch.
323  * Many modifications to Fluctuations branch, although that branch is not
324  * stable yet.
325  *
326  * Revision 1.1 2003/10/15 18:20:51 porter
327  * initial check in of Estruct Analysis maker codes.
328  *
329  *
330  *********************************************************************/
StEStructEvent()
Phi weights.