1 #include "./StEpdTrivialEventGenerator.h"
2 #include "TClonesArray.h"
14 double FindPhi(
double v1,
double v2,
double xran){
15 double tolerance=0.01;
17 double hi=2.0*TMath::Pi();
21 double Cvalue = (mid/2.0 + v1*sin(mid) + 0.5*v2*sin(2.0*mid))/TMath::Pi();
22 if (Cvalue > xran){hi=mid;}
24 }
while(hi-lo>tolerance);
30 StEpdTrivialEventGenerator::StEpdTrivialEventGenerator(TH1D* DnDeta, TH1D* V1versusEta, TH1D* V2versusEta){
31 if (DnDeta==0) std::cout <<
"You gave me no dNdeta histogram. Um, okay, but you're getting nothing but empty events-- have fun!\n\n";
33 mV1versusEta = V1versusEta;
34 mV2versusEta = V2versusEta;
37 int nbins = mDnDeta->GetXaxis()->GetNbins();
38 float low = mDnDeta->GetXaxis()->GetBinLowEdge(1);
39 float hi = mDnDeta->GetXaxis()->GetBinUpEdge(1);
40 if ((mV1versusEta->GetXaxis()->GetNbins() != nbins)
41 || (mV2versusEta->GetXaxis()->GetNbins() != nbins)
42 || (fabs(mV1versusEta->GetXaxis()->GetBinLowEdge(1)- low) > 0.000001)
43 || (fabs(mV2versusEta->GetXaxis()->GetBinLowEdge(1)- low) > 0.000001)
44 || (fabs(mV1versusEta->GetXaxis()->GetBinUpEdge(1)- hi) > 0.000001)
45 || (fabs(mV2versusEta->GetXaxis()->GetBinUpEdge(1)- hi) > 0.000001))
50 std::cout <<
"Dude, come on. Give me the same x-axis. I'm killing the v1 and v2 histograms. Your events will be isotropic.\n";
51 std::cout << low <<
" " << mV1versusEta->GetXaxis()->GetBinLowEdge(1) <<
" " << mV2versusEta->GetXaxis()->GetBinLowEdge(1) <<
"\n";
55 mRan =
new TRandom3();
57 mTracks =
new TClonesArray(
"TVector3",1000);
61 StEpdTrivialEventGenerator::~StEpdTrivialEventGenerator(){
66 TClonesArray* StEpdTrivialEventGenerator::Momenta(){
67 if (mDnDeta==0)
return 0;
74 for (
int ibin=1; ibin<=mDnDeta->GetXaxis()->GetNbins(); ibin++){
75 double ave = mDnDeta->GetBinContent(ibin)*mDnDeta->GetXaxis()->GetBinWidth(ibin);
76 if (ave<0.00001)
continue;
77 int n = mRan->Poisson(ave);
78 for (
int i=0; i<n; i++){
79 double eta = mRan->Uniform(mDnDeta->GetXaxis()->GetBinLowEdge(ibin),mDnDeta->GetXaxis()->GetBinUpEdge(ibin));
80 double v1 = (mV1versusEta==0)?0.0:mV1versusEta->GetBinContent(ibin);
81 double v2 = (mV2versusEta==0)?0.0:mV2versusEta->GetBinContent(ibin);
82 double phi = FindPhi(v1,v2,mRan->Uniform());
84 TVector3* v = (TVector3*)mTracks->ConstructedAt(mTracks->GetEntriesFast());
85 v->SetPtEtaPhi(pt,eta,phi);