StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEStructPhiWeight.cxx
1 /**********************************************************************
2  *
3  * $Id: StEStructPhiWeight.cxx,v 1.2 2007/02/05 17:20:28 msd Exp $
4  *
5  * Author: David Kettler
6  *
7  **********************************************************************
8  *
9  * Description: Phi Weight calculation
10  *
11  ***********************************************************************/
12 #include "StEStructPhiWeight.h"
13 
14 #include "TH1F.h"
15 #include "TFile.h"
16 #include "PhysicalConstants.h"
17 
18 #include "StEStructPool/EventMaker/StEStructEvent.h"
19 #include "StEStructPool/EventMaker/StEStructTrack.h"
20 
21 ClassImp(StEStructPhiWeight)
22 
24  //Initialize
25 
26  nPhiBins = 120;
27  phiMin = -pi;
28  phiMax = pi;
29  mPhiHist = new TH1F("Phi","Phi",nPhiBins,phiMin,phiMax);
30 }
31 
32 StEStructPhiWeight::~StEStructPhiWeight() {
33  finish();
34 }
35 
36 bool StEStructPhiWeight::doEvent(StEStructEvent* event) {
37 
38  if(!event) return false;
39  mCurrentEvent=event;
40 
41  StEStructTrackCollection *tp = mCurrentEvent->TrackCollectionP();
42  for(StEStructTrackIterator iter = tp->begin(); iter != tp->end(); iter++) {
43  StEStructTrack* pTrack = *iter;
44  Float_t phi = pTrack->Phi();
45 
46  if(pTrack->TopologyMapTPCNHits() >= 0 || (pTrack->TopologyMapData(0)==0 && pTrack->TopologyMapData(1)==0)) {
47  mPhiHist->Fill(phi);
48  } else {
49  }
50  }
51  StEStructTrackCollection *tm = mCurrentEvent->TrackCollectionM();
52  for(StEStructTrackIterator iter = tm->begin(); iter != tm->end(); iter++) {
53  StEStructTrack* pTrack = *iter;
54  Float_t phi = pTrack->Phi();
55  mPhiHist->Fill(phi);
56  }
57 
58  //itr.~StEStructTrackIterator();
59 
60  return true;
61 }
62 
63 void StEStructPhiWeight::finish(){
64  //Write out the histogram
65  TFile * tf=new TFile(moutFileName,"RECREATE");
66  tf->cd();
67  mPhiHist->Write();
68  tf->Close();
69  delete mPhiHist;
70  delete tf;
71 }
72 
73 /***********************************************************************
74  *
75  * $Log: StEStructPhiWeight.cxx,v $
76  * Revision 1.2 2007/02/05 17:20:28 msd
77  * Added include statement
78  *
79  * Revision 1.1 2006/04/26 18:58:14 dkettler
80  *
81  * Simple version of weight calculation analysis
82  *
83  *
84  *
85  *********************************************************************/