FairRoot/PandaRoot
Test30VSecondaryGenerator.cxx
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // -------------------------------------------------------------
28 // GEANT 4 class
29 //
30 // ---------- Test30VSecondaryGenerator -------
31 // by Vladimir Ivanchenko, 12 March 2002
32 //
33 // Modified:
34 //
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
37 
38 #include "Test30VSecondaryGenerator.hh"
39 #include "G4SystemOfUnits.hh"
40 #include "G4Track.hh"
41 #include "G4ParticleTable.hh"
42 #include "G4IonTable.hh"
43 #include "G4ParticleDefinition.hh"
44 #include "G4HadronicInteraction.hh"
45 #include "G4ElementVector.hh"
46 #include "G4Material.hh"
47 #include "G4NucleiProperties.hh"
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50 
51 Test30VSecondaryGenerator::Test30VSecondaryGenerator(
52  G4HadronicInteraction* hadi, const G4Material* mat):
53  hInteraction(hadi),
54  material(mat),
55  targetA(0)
56 {
57  elm = material->GetElement(0);
58  targetZ = G4lrint(elm->GetZ());
59  G4cout << "New generator for material " << material->GetName()
60  << " Nelm= " << material->GetNumberOfElements()
61  << " Nmat= " << material->GetNumberOfMaterials()
62  << " Target element: " << elm->GetName()
63  << G4endl;
64  generatorName = "";
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
68 
69 Test30VSecondaryGenerator::~Test30VSecondaryGenerator()
70 {}
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
73 
74 void Test30VSecondaryGenerator::SetA(G4int A)
75 {
76  targetA = A;
77  G4cout << "Nucleus with A= " << targetA << " Z= " << targetZ
78  << " A(amu)= " << elm->GetN();
79  if(targetA < targetZ) {
80  targetA = 0;
81  G4cout << " Natural abundances";
82  } else {
83  G4double mass = G4NucleiProperties::GetNuclearMass(targetA, targetZ);
84  G4cout << "Mass from G4NucleiProperties(GeV)= " << mass/GeV << G4endl;
85  }
86  G4cout << G4endl;
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
90 
91 G4double Test30VSecondaryGenerator::GetMass()
92 {
93  G4int A = targetA;
94  if(0 == targetA) {
95  A = G4lrint(elm->GetAtomicMassAmu());
96  G4IsotopeVector* isoVector = elm->GetIsotopeVector();
97  G4int nIsoPerElement = elm->GetNumberOfIsotopes();
98  A = (*isoVector)[0]->GetN();
99  if(nIsoPerElement > 1) {
100  G4double* abundVector = elm->GetRelativeAbundanceVector();
101  G4double y = G4UniformRand();
102  for(G4int j=0; j<nIsoPerElement; ++j) {
103  y -= abundVector[j];
104  if(y <= 0.0) {
105  A = (*isoVector)[j]->GetN();
106  break;
107  }
108  }
109  }
110  }
111  targetNucleus.SetParameters(A, targetZ);
112  G4double mass = G4NucleiProperties::GetNuclearMass(A, targetZ);
113  return mass;
114 }
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
117 
118 G4HadFinalState* Test30VSecondaryGenerator::Secondaries(const G4Track& track)
119 {
120  G4HadFinalState *result1 = 0;
121  G4HadProjectile thePro(track);
122  if (hInteraction) {
123 
124  result1 = hInteraction->ApplyYourself(thePro, targetNucleus);
125  result1->SetTrafoToLab(thePro.GetTrafoToLab());
126  }
127  return result1;
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
PndRiemannTrack track
Definition: RiemannTest.C:33
Double_t y