StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEStructPythia.h
1 /**********************************************************************
2  *
3  * $Id: StEStructPythia.h,v 1.11 2012/11/16 21:23:18 prindle Exp $
4  *
5  * Author: Jeff Porter
6  *
7  **********************************************************************
8  *
9  * Description: EStructEventReader wrapper for (T)Pythia event generator
10  *
11  **********************************************************************/
12 #ifndef __STESTRUCTPYTHIA__H
13 #define __STESTRUCTPYTHIA__H
14 
15 #include "StEStructPool/AnalysisMaker/StEStructEventReader.h"
16 
17 #include "TROOT.h"
18 #include "TMath.h"
19 #include "TPythia6.h"
20 
21 class StEStructEventCuts;
22 class StEStructTrackCuts;
23 
24 
26 
27  TPythia6* mPythia;
28  bool mInChain;
29  bool mAmDone;
30  bool museAllTracks;
31  int mnumTracks;
32  int mEventsToDo;
33  bool mstarTrigger;
34 
35 
36  void fillTracks(StEStructEvent* estructEvent);
37  bool isTrackGood(int i);
38  int countGoodTracks();
39 
40  int mEventCount;
41 
42  public:
43 
45  StEStructPythia(TPythia6* pythia,
46  StEStructEventCuts* ecuts,
47  StEStructTrackCuts* tcuts,
48  bool useAllTracks,
49  int eventsToDo);
50 
51  virtual ~StEStructPythia(){};
52  bool hasGenerator();
53  bool setInChain(bool inChain);
54  bool InChain();
55  bool measureable(int pid);
56  float* globalDCA(float* p, float* v);
57 
58  virtual StEStructEvent* next();
59  virtual bool done();
60 
61  virtual double getNPartonic();
62 
63 
64  ClassDef(StEStructPythia,1)
65 };
66 
67 
68 inline bool StEStructPythia::done(){ return mAmDone; };
69 inline bool StEStructPythia::setInChain(bool inChain) {
70  mInChain = inChain;
71  return mInChain;
72 };
73 inline bool StEStructPythia::InChain(){ return mInChain; };
74 
75 inline bool StEStructPythia::measureable(int pid){
76  bool retVal=false;
77 
78  switch(pid){
79 
80  // I don't think Pythia can produce these, but they are
81  // defined by the pdg (I think, see www.slac.stanford.edu/BFROOT/www/Computing/Environment/NewUser/htmlbug/node51.html)
82  // because GEANT can make them and they are measurable so I
83  // include them here. djp Sept. 13, 2005
84  case 95:
85  { // deuteron
86  retVal=true;
87  break;
88  }
89  case 96:
90  { // triton
91  retVal=true;
92  break;
93  }
94  case 97:
95  { // Helium 4
96  retVal=true;
97  break;
98  }
99  default:
100  {
101  break;
102  }
103  }
104 
105 
106  if(pid<0)pid*=-1;
107 
108  switch(pid){
109 
110  case 211:
111  { // charged pion
112  retVal=true;
113  break;
114  }
115  case 321:
116  { // charged kaon
117  retVal=true;
118  break;
119  }
120  case 2212:
121  { // proton
122  retVal=true;
123  break;
124  }
125  case 11:
126  { // electron
127  retVal=true;
128  break;
129  }
130  case 13:
131  { // muon
132  retVal=true;
133  break;
134  }
135  default:
136  {
137  break;
138  }
139  }
140  return retVal;
141 }
142 
143 inline float* StEStructPythia::globalDCA(float* p, float* v){
144 
145  // assumes primaryVertex at origin
146  float* r=new float[4];
147  r[0]=r[1]=r[2]=r[3]=0;
148 
149  // a is the component of v vector that is parallel to p.
150  float a = v[0] * p[0] + v[1] * p[1] + v[2] * p[2] ;
151  a = a / sqrt(p[0]*p[0] + p[1]*p[1] + p[2]*p[2]);
152  // r is the component of v vector perpendicular to p.
153  r[3] = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2] - a*a);
154  // Since only the magnitude of globalDCA is used,
155  // leave r[0], r[1], r[2] to be 0 here.
156  return r;
157 
158  /*
159  if(fabs(p[2])<0.01){ // then 2D
160  if(fabs(p[0])<0.01){
161  r[3]=r[1]=v[1]; // p=py only
162  return r;
163  }
164  float a = p[1]/p[0];
165  float x = -1.0*(a*v[1])/(a*a+1);
166  float y=a*x+v[1];
167  r[0]=x; r[1]=y;
168  r[3]=sqrt(x*x+y*y);
169  return r;
170  }
171  float ax = p[0]/p[2];
172  float ay = p[1]/p[2];
173  float z = -1.0*(ax*v[0]+ay*v[1])/(ax*ax+ay*ay+1);
174  float x = ax*z+v[0];
175  float y = ay*z+v[1];
176  r[0]=x; r[1]=y; r[2]=z;
177  r[3]=sqrt(x*x+y*y+z*z);
178  */
179 }
180 
181 
182 #endif
183 
184 /**********************************************************************
185  *
186  * $Log: StEStructPythia.h,v $
187  * Revision 1.11 2012/11/16 21:23:18 prindle
188  * EventCuts and TrackCuts were moved to EventReader. Remove that code from
189  * these readers.
190  *
191  * Revision 1.10 2010/03/02 21:46:24 prindle
192  * Option to use getNPartonic as a centrality measure
193  *
194  * Revision 1.9 2009/02/03 14:30:23 fisyak
195  * Add missing includes for ROOT 5.22
196  *
197  * Revision 1.8 2006/04/11 17:51:41 prindle
198  * Remove inChain from constructor arguments (no longer used in macro)
199  *
200  * Revision 1.7 2006/04/04 22:11:27 porter
201  * StEStructPythia now uses StEtructCentrality for selection
202  *
203  * Revision 1.6 2006/02/22 22:05:38 prindle
204  * Removed all references to multRef (?)
205  *
206  * Revision 1.5 2005/09/23 23:37:25 prindle
207  *
208  * Starting to add vertex distribution and track acceptance dependance on
209  * number of possible hits.
210  * Make Pythia interface look like Hijing interface so it now works within
211  * my Fluctuation and Correlation framework.
212  *
213  * Revision 1.4 2004/09/24 01:43:12 prindle
214  * Add call to define centrality by multiplicity.
215  *
216  * Revision 1.3 2004/06/25 03:13:01 porter
217  * added simple trigger selection implemented like BBC-AND plus CTB
218  *
219  * Revision 1.2 2004/02/26 20:20:06 chunhuih
220  *
221  * Fixed the method globalDCA().
222  * Assign the globalDCA, but leave its x, y, z coordinates zero.
223  *
224  * Revision 1.1 2003/11/21 06:25:00 porter
225  * Pythia event generater as an StEStructEventReader
226  *
227  *
228  *********************************************************************/