er  dev
ERGenerator.cxx
1 #include "ERGenerator.h"
2 
3 #include <stdio.h> //for NULL, sprintf
4 
5 #include "TDatabasePDG.h" //for TDatabasePDG
6 #include "TVector3.h"
7 #include "TLorentzVector.h" //for TLorentzVector
8 #include "TVirtualMC.h"
9 
10 #include "G4IonTable.hh"
11 #include "G4ParticleTable.hh"
12 
13 #include "FairRunSim.h"
14 #include<iostream>
15 
16 #include "ERTarget.h" //for ERTarget
17 
18 
19 using namespace std;
20 
21 // ----- Initialsisation of static variables --------------------------
22 Int_t ERGenerator::fgNIon = 0;
23 // ------------------------------------------------------------------------
24 
26 fPhiMinCM(0.),
27 fPhiMaxCM(0.),
28 fThetaMinCM(0.),
29 fThetaMaxCM(0.),
30 fEBeam(0.)
31 {
32  fRnd = new TRandom3();
33 }
34 
35 ERGenerator::ERGenerator(Int_t z, Int_t a, Int_t q,
36  Double_t px, Double_t py, Double_t pz,
37  Double_t vx, Double_t vy, Double_t vz):
38 fPx(Double_t(a)*px), fPy(Double_t(a)*py), fPz(Double_t(a)*pz),
39 fVx(vx), fVy(vy), fVz(vz),fPrimaryIon(NULL), fSecondIon(NULL), fThirdIon(NULL)
40 {
41  fPrimaryIon= new FairIon("ExpertPrimaryIon", z, a, q);
42  FairRunSim* run = FairRunSim::Instance();
43  if ( ! run ) {
44  cout << "-E- ERGenerator: No FairRun instantised!" << endl;
45  Fatal("ERGenerator", "No FairRun instantised!");
46  } else {
47  run->AddNewIon(fPrimaryIon);
48  }
49 }
50 
52 
53 }
54 
55 Bool_t ERGenerator::ReadEvent(FairPrimaryGenerator* primGen) {
56  //Добавление первичного иона в стек.
57  TParticlePDG* thisPart =
58  TDatabasePDG::Instance()->GetParticle(fPrimaryIon->GetName());
59  if ( ! thisPart ) {
60  cout << "-W- FairIonGenerator: Ion " << fPrimaryIon->GetName()
61  << " not found in database!" << endl;
62  return kFALSE;
63  }
64 
65  int primaryIonPDG = thisPart->PdgCode();
66 
67  cout << "-I- ERGenerator: Generating ion of type "
68  << fPrimaryIon->GetName() << " (PDG code " << primaryIonPDG << ")" << endl;
69  cout << " Momentum (" << fPx << ", " << fPy << ", " << fPz
70  << ") Gev from vertex (" << fVx << ", " << fVy
71  << ", " << fVz << ") cm" << endl;
72 
73  primGen->AddTrack(primaryIonPDG, fPx, fPy, fPz, fVx, fVy, fVz);
74  return kTRUE;
75 }
76 
77 
78 ClassImp(ERGenerator)
virtual ~ERGenerator()
Definition: ERGenerator.cxx:51
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
Definition: ERGenerator.cxx:55
FairIon * fPrimaryIon
Number of the instance of this class.
Definition: ERGenerator.h:61