StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEStructAcceptance.cxx
1 #include "StEStructAcceptance.h"
2 
3 #include "StEStructPool/AnalysisMaker/StEStructEventCuts.h"
4 #include "StEStructPool/AnalysisMaker/StEStructTrackCuts.h"
5 #include "StEStructPool/EventMaker/StEStructEvent.h"
6 #include "StEStructPool/EventMaker/StEStructTrack.h"
7 
8 StEStructAcceptance::StEStructAcceptance() {
9  mSigZVertex = 60;
10  mMaxZVertex = 30;
11  mMinDetectableRadius = 160;
12  mgRand2Good = false;
13 }
14 StEStructAcceptance::StEStructAcceptance( double sigZVertex,
15  double maxZVertex,
16  double minDetectableRadius ) {
17  mSigZVertex = sigZVertex;
18  mMaxZVertex = maxZVertex;
19  mMinDetectableRadius = minDetectableRadius;
20  mgRand2Good = false;
21 };
22 
23 //-------------------------------------------------------------------------
24 void StEStructAcceptance::SetSeed(int iseed) {
25  cout << " Calling srand48(" << iseed << ") (from StEStructAcceptance class)" << endl;
26  srand48(iseed);
27 }
28 
29 
30 //--------------------------------------------------------------------------
31 double StEStructAcceptance::GetNewZVertex() {
32  double z = 2*mMaxZVertex;
33  while (abs(z) > mMaxZVertex) {
34  z = mSigZVertex * gRand48();
35  }
36  return z;
37 }
38 bool StEStructAcceptance::isTrackInAcceptance( double VertZ, double pt, double eta ) {
39  double r = maxRadius( eta, pt, VertZ );
40  if (r < mMinDetectableRadius) {
41  return false;
42  }
43  return true;
44 }
45 
46 //-------------------------------------------------------------
47 // This method calculates maximum distance of track from beam axis.
48 // This point might be at the endplane or at twice the radius of curvature.
49 double StEStructAcceptance::maxRadius(double eta, double pt, double VertZ) {
50  double pi = 3.14159265359;
51  double lambda = pi/2 - 2*atan(exp(-eta));
52  double s;
53  if (lambda > 0) {
54  s = (+200 - VertZ) / sin(lambda);
55  } else {
56  s = (-200 - VertZ) / sin(lambda);
57  }
58  double r = pt / 0.0015;
59  double phi = s * cos(lambda) / r;
60  if (phi < pi) {
61  return r * sqrt(2 - 2*cos(phi));
62  }
63  return 2*r;
64 }
65 
66 double StEStructAcceptance::gRand48() {
67  double x1, x2, w;
68 
69  if (mgRand2Good) {
70  mgRand2Good = false;
71  return mgRand2;
72  }
73  do {
74  x1 = 2.0 * drand48() - 1.0;
75  x2 = 2.0 * drand48() - 1.0;
76  w = x1 * x1 + x2 * x2;
77  } while ( w >= 1.0 );
78 
79  w = sqrt( (-2.0 * log( w ) ) / w );
80  mgRand2 = x2 * w;
81  mgRand2Good = true;
82  return x1*w;
83 }
84