EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicBoxGenerator.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicBoxGenerator.cxx
1 //
2 // AYK (ayk@bnl.gov), 2015/07/15
3 //
4 // A complete re-write; inherit from FairGenerator directly; only minimum
5 // functionality is retained with reasonable default values;
6 //
7 
8 #include <cmath>
9 
10 #include <TRandom.h>
11 #include <TMath.h>
12 
13 #include <EicBoxGenerator.h>
14 
15 // ---------------------------------------------------------------------------------------
16 
18 {
19  // Well, momentum and PDG should be defined;
20  if (!mPDGs.size() || !mPmax) {
21  printf("EicBoxGenerator::ReadEvent(): either PDG or momentum range undefined!\n");
22  return kFALSE;
23  } //if
24 
25  // Vertex; as of 2015/11/06 the same for all mMult tracks; after all, what is the
26  // purpose to generate N tracks?; they should originate from the same primary vertex, or?;
27 #if _OLD_
28  double vtx[3];
29  for(unsigned iq=0; iq<3; iq++) {
30  vtx[iq] = mCoord[iq] +
32  (mCoordSigma[iq] ? gRandom->Gaus(0.0, mCoordSigma[iq]) : 0.0) :
33  (mCoordRange[iq] ? gRandom->Uniform(-mCoordRange[iq]/2, mCoordRange[iq]/2) : 0.0));
34  } //for iq
35 #endif
36  TVector3 vtx = GetSimulatedPrimaryVertex();
37 
38  // At some point may want to introduce parameter range check and respective
39  // flag (like 'done') in order to perform this only once;
40 
41  for (unsigned pt=0; pt<mMult; pt++) {
42  double phi = (/*mPhiMin == mPhiMax ? mPhiMin :*/ gRandom->Uniform(mPhiMin, mPhiMax))*
43  TMath::DegToRad();
44 
45  //printf("%f %f\n", cos(mThetaMin* TMath::DegToRad()), cos(mThetaMax* TMath::DegToRad()));
46  double theta = //mThetaMin == mThetaMax ? mThetaMin*TMath::DegToRad() :
47  mUniformTheta ? gRandom->Uniform(mThetaMin, mThetaMax) * TMath::DegToRad() :
48  acos(gRandom->Uniform(cos(mThetaMax * TMath::DegToRad()),
49  cos(mThetaMin * TMath::DegToRad())));
50  double nx = TMath::Sin(theta)*TMath::Cos(phi);
51  double ny = TMath::Sin(theta)*TMath::Sin(phi);
52  double nz = TMath::Cos(theta);
53  double pp = /*mPmin == mPmax ? mPmin :*/ gRandom->Uniform(mPmin, mPmax);
54 
55  {
56  TVector3 pvect = GetModifiedTrack(pp*TVector3(nx, ny, nz));
57  printf("%7.3f %7.3f %7.3f\n", pvect[0], pvect[1], pvect[2]);
58  //primGen->AddTrack(mPDGs[mFlipCounter], pp*nx, pp*ny, pp*nz, vtx[0], vtx[1], vtx[2]);
59  primGen->AddTrack(mPDGs[mFlipCounter], pvect[0], pvect[1], pvect[2], vtx[0], vtx[1], vtx[2]);
60  }
61  mFlipCounter = (mFlipCounter+1)%mPDGs.size();
62  //printf("%d\n", mFlipCounter);
63  } //for iq
64 
65  return kTRUE;
66 } // EicBoxGenerator::ReadEvent()
67 
68 // ---------------------------------------------------------------------------------------
69 // ---------------------------------------------------------------------------------------
70