12 #include "TVirtualMC.h" 13 #include "TLorentzVector.h" 14 #include "TMCProcess.h" 15 #include "TGeoManager.h" 16 #include "TGeoVolume.h" 20 #include "FairRunSim.h" 21 #include "FairLogger.h" 24 #include "ERMCEventHeader.h" 27 ERDecay::ERDecay(TString name)
29 fInteractionVolumeName(
""),
30 fNuclearInteractionLength(0.),
32 fNormalizingProbability(0.),
33 fIsInterationPointFound(kFALSE)
35 fRnd1 =
new TRandom3();
36 fRnd2 =
new TRandom3();
37 fRnd =
new TRandom3();
43 void ERDecay::SetInputIon(Int_t A, Int_t Z, Int_t Q){
44 FairRunSim* run = FairRunSim::Instance();
45 fInputIonName = fName + TString(
"_InputIon");
46 FairIon* ion =
new FairIon(fInputIonName,A,Z,Q);
50 void ERDecay::SetUniformPos(Double_t a, Double_t b){
56 void ERDecay::SetExponentialPos(Double_t start, Double_t tau){
58 fExponentialStart = start;
59 fExponentialTau = tau;
62 void ERDecay::BeginEvent(){
63 fDecayFinish = kFALSE;
65 fDecayPosZ = fRnd->Uniform(fUniformA, fUniformB);
68 fDecayPosZ = fExponentialStart + fRnd->Exp(fExponentialTau);
72 void ERDecay::FinishEvent(){
75 Bool_t ERDecay::Init(){
76 if (fInputIonName ==
""){
77 LOG(FATAL) <<
"Input ion not defined!" << FairLogger::endl;
81 fInputIonPDG = TDatabasePDG::Instance()->GetParticle(fInputIonName);
82 if ( ! fInputIonPDG ) {
83 LOG(FATAL) <<
"Input ion not found in pdg database!" << FairLogger::endl;
90 void ERDecay::AddParticleToStack(Int_t pdg, TLorentzVector pos, TLorentzVector state){
92 gMC->GetStack()->PushTrack(1,gMC->GetStack()->GetCurrentTrackNumber(), pdg,
93 state.Px(),state.Py(),state.Pz(),state.E(),
94 pos.X(), pos.Y(), pos.Z(),
95 gMC->TrackTime(), 0., 0., 0.,
96 kPDecay, newTrackNb, fInputIonPDG->Mass(),0);
97 LOG(DEBUG) <<
"ERDecay: Added output particle with ID = " << newTrackNb <<
" PDG = " << pdg
98 <<
"; pos=(" << pos.X() <<
"," << pos.Y() <<
"," << pos.Z()
99 <<
"); mom=(" << state.Px() <<
"," << state.Py() <<
"," << state.Pz() <<
")" << FairLogger::endl;
103 fNormalizingProbability = 1 - TMath::Exp(-pathLength / fNuclearInteractionLength);
106 void ERDecay::CalculateTargetParameters() {
107 LOG(DEBUG) <<
"ERDecay: calculated parameters " << FairLogger::endl;
108 if (fInteractionVolumeName !=
"") {
109 TGeoVolume* vol = gGeoManager->FindVolumeFast(fInteractionVolumeName);
110 TGeoBBox* shape = (TGeoBBox*)vol->GetShape();
111 Double_t boundX = 2 * shape->GetDX();
112 Double_t boundY = 2 * shape->GetDY();
113 Double_t boundZ = 2 * shape->GetDZ();
114 LOG(DEBUG) <<
"ERDecay: bounding box x = " << boundX
115 <<
"; y = " << boundY
116 <<
"; z = " << boundZ << FairLogger::endl;
123 if (!fIsInterationPointFound) {
124 gGeoManager->FindNextBoundary();
125 Double_t distToNextBoundary = gGeoManager->GetStep();
126 LOG(DEBUG) <<
"[ERDecay::FindInteractionPoint] distance to a next boundary " 127 << distToNextBoundary << FairLogger::endl;
128 Double_t interactionProbNextBound = 1 - TMath::Exp(-distToNextBoundary /
129 fNuclearInteractionLength);
130 Double_t interactProbability = interactionProbNextBound / fNormalizingProbability;
131 if (interactProbability > 1) {
132 LOG(ERROR) <<
"[ERDecay::FindInteractionPoint] interaction probability " 133 <<
"in current direction more then 1, " 134 <<
"incorrect normalizing respect to maximum path length in an interaction volume" 137 LOG(DEBUG) <<
"[ERDecay::FindInteractionPoint] interaction probability in current direction " 138 << interactProbability
139 <<
"; normalizing probability is " << fNormalizingProbability << FairLogger::endl;
140 if (fRnd1->Uniform(0, 1) > interactProbability) {
141 LOG(DEBUG) <<
"Interaction hasn't happened with defined Interaction length and max path length" 145 fDistanceToInteractPoint = -TMath::Log(1 - fRnd2->Uniform(0, interactionProbNextBound))
146 * fNuclearInteractionLength;
147 LOG(DEBUG) <<
"[ERDecay::FindInteractionPoint] distance to an interaction point " 148 <<
"in current direction " << fDistanceToInteractPoint << FairLogger::endl;
149 fIsInterationPointFound = kTRUE;
void SetMaxPathLength(Double_t pathLength)
Defines maximum path length for particles in the volume that is defined in SetInteractionVolumeName()...
Bool_t FindInteractionPoint()