er  dev
ERGammaGenerator.cxx
1 
2 
3 #include "ERGammaGenerator.h"
4 #include "TMath.h"
5 #include<iostream>
6 
7 #include "G4IonTable.hh"
8 #include "G4ParticleTable.hh"
9 
10 using namespace std;
11 
13 fPhiMinCM(0.),
14 fPhiMaxCM(0.),
15 fThetaMinCM(0.),
16 fThetaMaxCM(0.),
17 fEBeam(0.)
18 {
19  fRnd = new TRandom3();
20 }
21 
23 
24 }
25 
26 Bool_t ERGammaGenerator::ReadEvent(FairPrimaryGenerator* primGen) {
27  Double_t phiCM = fRnd->Uniform()*(fPhiMaxCM - fPhiMinCM) + fPhiMinCM;
28  phiCM *= TMath::DegToRad();
29  G4IonTable* fIonTable = G4IonTable::GetIonTable();
30  G4ParticleTable* fParticleTable = G4ParticleTable::GetParticleTable();
31  fGammaPDG = fParticleTable->FindParticle("gamma")->GetPDGEncoding();
32  fIonMass = fIonTable->GetIonMass(fZ,fA)/1000.;
33  Double_t fullEBeam = fEBeam + fIonMass;
34 
35  Double_t cos_thetaCM = fRnd->Uniform(TMath::Cos(fThetaMaxCM), TMath::Cos(fThetaMinCM));
36  Double_t sin_thetaCM = TMath::Sqrt(1-cos_thetaCM*cos_thetaCM);
37  Double_t pGammaCM = fEGammaCM;
38  Double_t pxCM = pGammaCM*TMath::Cos(phiCM)*sin_thetaCM;
39  Double_t pyCM = pGammaCM*TMath::Sin(phiCM)*sin_thetaCM;
40  Double_t pzCM = pGammaCM*cos_thetaCM;
41 
42  Double_t pBeam = TMath::Sqrt(fullEBeam*fullEBeam - fIonMass*fIonMass);
43  Double_t betaCM = pBeam/fullEBeam;
44  Double_t gammaCM = TMath::Sqrt( 1. / ( 1. - betaCM*betaCM) );
45 
46  Double_t pxLAB = pxCM;
47  Double_t pyLAB = pyCM;
48  Double_t pzLAB = gammaCM * ( pzCM + betaCM * fEGammaCM);
49 
50  Double_t pLAB = TMath::Sqrt(pxLAB*pxLAB + pyLAB*pyLAB + pzLAB*pzLAB);
51  primGen->AddTrack(fGammaPDG, pxLAB, pyLAB, pzLAB,0, 0, 0);
52 
53  return kTRUE;
54 }
55 
56 void ERGammaGenerator::SetGammaCMThetaRange(Double_t thetaMin, Double_t thetaMax)
57 {
58  fThetaMinCM = thetaMin;
59  fThetaMaxCM= thetaMax;
60  cerr << fThetaMinCM << " " << fThetaMaxCM << endl;
61  fThetaMinCM *= TMath::DegToRad();
62  fThetaMaxCM *= TMath::DegToRad();
63 }
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
virtual ~ERGammaGenerator()