StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEStructDstReader.cxx
1 /**********************************************************************
2  *
3  * $Id: StEStructDstReader.cxx,v 1.4 2012/11/16 21:19:06 prindle Exp $
4  *
5  * Author: Jeff Porter
6  *
7  **********************************************************************
8  *
9  * Description: reads Estruct dst via StEStructEventMaker class
10  *
11  ***********************************************************************/
12 
13 #include "StEStructDstReader.h"
14 
15 #include "StEStructEventCuts.h"
16 #include "StEStructTrackCuts.h"
17 #include "StEStructPool/EventMaker/StEStructEvent.h"
18 #include "StEStructPool/EventMaker/StEStructTrack.h"
19 #include "StEStructPool/EventMaker/StEStructEventMaker.h"
20 #include "StDetectorId.h"
21 
22 ClassImp(StEStructDstReader)
23 
24 StEStructDstReader::StEStructDstReader(): mMaker(0), mInChain(false) , mAmDone(false){};
25 
26 
27 StEStructDstReader::StEStructDstReader(StEStructEventMaker* maker, StEStructEventCuts* ecuts, StEStructTrackCuts* tcuts, bool inChain) : mAmDone(false) {
28 
29  mInChain=inChain;
30  setEventMaker(maker,inChain);
31  setEventCuts(ecuts);
32  setTrackCuts(tcuts);
33 
34 };
35 
36 StEStructDstReader::~StEStructDstReader(){};
37 
38 void StEStructDstReader::setEventMaker(StEStructEventMaker* maker, bool inChain){
39  mInChain=inChain;
40  mMaker=maker;
41 };
42 
43 
44 bool StEStructDstReader::hasMaker() { return (mMaker) ? true : false ; }
45 
46 
47 //-------------------------------------------------------------------------
48 StEStructEvent* StEStructDstReader::next() {
49 
50  StEStructEvent* retVal=NULL;
51  if(!mMaker) return retVal;
52  if(!mInChain){
53  int iret=mMaker->Make();
54  if(iret){
55  mAmDone=true;
56  return retVal;
57  }
58  }
59 
60  retVal=mMaker->event();
61  if(!checkEvent(retVal)){
62  delete retVal;
63  retVal=NULL;
64  }
65 
66  return retVal;
67 }
68 
69 //-----------------------------------------------------------
70 bool StEStructDstReader::checkEvent(StEStructEvent* e){
71 
72  // don't have the trigger word yet
73 
74  bool useEvent=true;
75 
76  if(!mECuts->goodPrimaryVertexZ(e->Vz()) ||
77  !mECuts->goodCentrality(e->Centrality())) useEvent=false;
78 
79  mECuts->fillHistogram(mECuts->primaryVertexZName(),e->Vz(),useEvent);
80  mECuts->fillHistogram(mECuts->centralityName(),e->Centrality(),useEvent);
81 
82  return useEvent;
83 }
84 
85 //-------------------------------------------------------------------
86 int StEStructDstReader::getNumberOfTracks(StEStructEvent* e){
87 
88  int numPrimaries=e->Ntrack();
89  if(0==numPrimaries) return 0;
90 
91 
92  int numfinal=0;
93  for(int i=0;i<numPrimaries;i++){
94 
95  StEStructTrack* track=(StEStructTrack*)e->Tracks()->UncheckedAt(i);
96 
97  bool useTrack=true;
98  if(track->Pt()<0.15)continue;
99 
100  useTrack = (mTCuts->goodFlag(track->Flag()) && useTrack);
101  useTrack = ( mTCuts->goodCharge(track->Charge()) && useTrack);
102  useTrack = ( mTCuts->goodNFitPoints(track->NFitPoints()) && useTrack);
103  useTrack = (mTCuts->goodNFitNMax((float)((float)track->NFitPoints()/(float)track->NMaxPoints())) && useTrack);
104 
105  useTrack = (mTCuts->goodGlobalDCA(track->DcaGlobal()) && useTrack);
106  useTrack = (mTCuts->goodEta(track->Eta()) && useTrack);
107  useTrack = (mTCuts->goodChi2(track->Chi2()) && useTrack);
108  useTrack = (mTCuts->goodPhi(track->Phi()) && useTrack);
109 
110  if(useTrack)numfinal++;
111 
112  useTrack = (mTCuts->goodPt(track->Pt()) && useTrack);
113  useTrack = (mTCuts->goodYt(track->Yt()) && useTrack);
114  mTCuts->fillHistograms(useTrack);
115 
116  }
117 
118  return numfinal;
119 }
120 
121 
122 /***********************************************************************
123  *
124  * $Log: StEStructDstReader.cxx,v $
125  * Revision 1.4 2012/11/16 21:19:06 prindle
126  * Moved EventCuts, TrackCuts to EventReader. Affects most readers.
127  * Added support to write and read EStructEvents.
128  * Cuts: 3D histo support, switch to control filling of histogram for reading EStructEvents
129  * EventCuts: A few new cuts
130  * MuDstReader: Add 2D to some histograms, treat ToFCut, PrimaryCuts, VertexRadius histograms like other cut histograms.
131  * QAHists: Add refMult
132  * TrackCuts: Add some hijing cuts.
133  *
134  * Revision 1.3 2006/04/06 00:53:57 prindle
135  * Tried to rationalize the way centrality is defined.
136  * Now the reader gives a float to StEStructEvent and this float is
137  * what is being used to define centrality. When we need a centrality
138  * bin index we pass this number into the centrality singleton object.
139  *
140  * Revision 1.2 2006/02/22 22:03:13 prindle
141  * Removed all references to multRef
142  *
143  * Revision 1.1 2003/10/15 18:20:32 porter
144  * initial check in of Estruct Analysis maker codes.
145  *
146  *
147  *********************************************************************/