8 #include "ERIonGenerator.h" 11 #include "TDatabasePDG.h" 12 #include "TObjArray.h" 13 #include "TParticle.h" 14 #include "TParticlePDG.h" 18 #include "FairParticle.h" 19 #include "FairPrimaryGenerator.h" 20 #include "FairRunSim.h" 21 #include "FairLogger.h" 22 #include "G4IonTable.hh" 40 FairRunSim* fRun=FairRunSim::Instance();
41 TObjArray* UserIons=fRun->GetUserDefIons();
42 TObjArray* UserParticles=fRun->GetUserDefParticles();
44 fIon =
static_cast<FairIon*
>(UserIons->FindObject(ionName));
49 part=
static_cast<FairParticle*
>(UserParticles->FindObject(ionName));
51 TParticle* particle=part->GetParticle();
55 if(
fIon==0 && part==0 ) {
56 LOG(FATAL) <<
"Ion or Particle is not defined !" 67 fX1(0),fY1(0),fX2(0),
fY2(0),
78 fRho(0), fCenterX(0), fCenterY(0)
82 G4IonTable* fIonTable = G4IonTable::GetIonTable();
83 fIonMass = fIonTable->GetIonMass(z,a)/1000.;
84 FairRunSim* run = FairRunSim::Instance();
86 LOG(ERROR) <<
"No FairRunSim instantised!" 100 fIon->SetExcEnergy(eExc);
106 fPMin = TMath::Sqrt(kinEMin*kinEMin + 2.*kinEMin*
fIonMass);
107 fPMax = TMath::Sqrt(kinEMax*kinEMax + 2.*kinEMax*fIonMass);
114 fSigmaP = sigmaKinE*(kinE +
fIonMass) / TMath::Sqrt(kinE*kinE + 2.*kinE*fIonMass);
126 for (Int_t k = 0; k <
fMult; k++) {
129 TParticlePDG* thisPart =
130 TDatabasePDG::Instance()->GetParticle(
fIon->GetName());
132 LOG(WARNING) <<
"ERIonGenerator: Ion " <<
fIon->GetName()
133 <<
" not found in database!" << FairLogger::endl;
137 int pdgType = thisPart->PdgCode();
139 LOG(DEBUG) <<
"ERIonGenerator: Generating " << fMult <<
" ions of type " 140 <<
fIon->GetName() <<
" (PDG code " << pdgType <<
")" 142 LOG(DEBUG) <<
" Momentum (" << fPx <<
", " << fPy <<
", " <<
fPz 143 <<
") Gev from vertex (" << fX <<
", " << fY
144 <<
", " <<
fZ <<
") cm" << FairLogger::endl;
145 primGen->AddTrack(pdgType, fPx, fPy,
fPz, fX, fY,
fZ);
153 Double32_t pabs=0, phi, pt=0, theta=0, eta, y, mt, kinE;
157 phi = gRandom->Uniform(fPhiMin,
fPhiMax) * TMath::DegToRad();
160 pabs = gRandom->Uniform(fPMin,
fPMax);
163 pt = gRandom->Uniform(fPtMin,
fPtMax);
174 theta = acos(gRandom->Uniform(cos(fThetaMin* TMath::DegToRad()),
177 theta = gRandom->Uniform(fThetaMin,
fThetaMax) * TMath::DegToRad();
180 eta = gRandom->Uniform(fEtaMin,
fEtaMax);
181 theta = 2*TMath::ATan(TMath::Exp(-eta));
183 y = gRandom->Uniform(fYMin,
fYMax);
185 fPz = mt * TMath::SinH(y);
190 fPz = pabs*TMath::Cos(theta);
191 pt = pabs*TMath::Sin(theta);
193 fPz = pt/TMath::Tan(theta);
197 fPx = pt*TMath::Cos(phi);
198 fPy = pt*TMath::Sin(phi);
201 fX = gRandom->Uniform(fX1,fX2);
202 fY = gRandom->Uniform(fY1,
fY2);
205 Bool_t isInCircle = kFALSE;
206 while (!isInCircle) {
207 fX = gRandom->Uniform(0, fRho);
208 fY = gRandom->Uniform(0, fRho);
209 if (sqrt(pow(fX, 2) + pow(fY, 2)) <= fRho) {
217 fX = gRandom->Gaus(fGausX,fSigmaX);
222 LOG(DEBUG) <<
"Coord on target x = " << fX <<
"; y = " << fY
223 <<
"; theta = " << theta << FairLogger::endl;
224 Double_t l =
fZ / TMath::Cos(theta);
225 fX = l * TMath::Sin(theta) * TMath::Cos(phi) + fX;
226 fY = l * TMath::Sin(theta) * TMath::Sin(phi) + fY;
227 LOG(DEBUG) <<
"Coord on start x = " << fX <<
"; y = " << fY
228 <<
"; theta = " << theta << FairLogger::endl;
Bool_t fRoundXYIsSet
True if spot spreading of the start position in XY-plane is setted.
Double32_t fPhiMax
Azimuth angle range [degree].
Double32_t fGausTheta
Amplitude value of theta angle in Gauss distibution [degree].
Bool_t fPtRangeIsSet
True if transverse momentum range is set.
Double32_t fGausP
Amplitude value of momentum in Gauss distibution [GeV].
Double32_t fYMax
Rapidity range in lab system.
Bool_t fYRangeIsSet
True if rapidity range is set.
Double32_t fThetaMax
Polar angle range in lab system [degree].
void SetKinERange(Double32_t kinEMin, Double32_t kinEMax)
Defines uniform distribution boundaries of ion kinetic energy [GeV].
Bool_t fEtaRangeIsSet
True if eta range is set.
void SetKinESigma(Double32_t kinE, Double32_t sigmaKinE)
Defines Gaussian distribution of ion kinetic energy [GeV].
Int_t fMult
Multiplicity per event.
Double32_t fGausY
Amplitude values of coordinates in Gauss distibution [cm].
void SetKinE(Double32_t kinE)
Defines fixed ion kinetic energy that is recalculated to the momentum according to equation ...
Double32_t fZ
Point vertex coordinates [cm].
Bool_t fPRangeIsSet
True if abs momentum range is set.
Bool_t fThetaRangeIsSet
True if theta range is set.
Double32_t fIonMass
Ion mass + Ion Exitation [GeV].
Bool_t fSigmaThetaIsSet
True if Gauss distribution for theta angle is set.
Int_t fPDGType
Particle type (PDG encoding)
Double32_t fKinE
Kinetic energy [GeV].
Double32_t fSigmaY
Coordinates normal deviation [cm].
Bool_t fSpreadingOnTarget
True if parameters are spreaded on target and reconstructed to beam start position.
virtual ~ERIonGenerator()
Destructor.
Double32_t fSigmaTheta
Theta angle normal deviation [degree].
Bool_t fPointVtxIsSet
True if point vertex is set.
Double32_t fPtMax
Transverse momentum range [GeV].
void SetExcitationEnergy(Double_t eExc)
Defines ion excitation energy of generated FairIon object.
FairIon * fIon
Pointer to the FairIon to be generated.
void SpreadingParameters(void)
Spreads parameters recieved by accessor methods.
Int_t fQ
Electric charge [e].
Bool_t fBoxSigmaIsSet
True if Gauss distribution for coordinates is set.
Bool_t fCosThetaIsSet
True if uniform distribution in cos(theta) is set (default -> not set)
Bool_t fBoxVtxIsSet
True if box vertex is set.
Double32_t fPz
Momentum projection [GeV].
Double32_t fPMax
Momentum range in lab system.
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)
Defines uniform distribution boundaries of ion azimuth angle[degree].
ERIonGenerator()
Default constructor.
Double32_t fY2
Box vertex coords (x1,y1)->(x2,y2)
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
Double32_t fSigmaP
Momentum normal deviation [GeV].
Double32_t fEtaMax
Pseudorapidity range in lab system.
Class for the generation ion.
Bool_t fSigmaPIsSet
True if Gauss distribution for momentum is set.