7 #include "TClonesArray.h"
9 #include "TLorentzVector.h"
12 #include "TParticle.h"
14 #include "FairPrimaryGenerator.h"
15 #include "FairRunSim.h"
23 #include "G4Version.hh"
27 #include "G4RunManager.hh"
28 #include "G4VUserPhysicsList.hh"
29 #include "G4PhysicalConstants.hh"
30 #include "G4SystemOfUnits.hh"
31 #include "G4Material.hh"
32 #include "G4MaterialCutsCouple.hh"
33 #include "G4ElementVector.hh"
34 #include "Test30Material.hh"
35 #include "Test30Physics.hh"
37 #include "G4ProcessManager.hh"
38 #include "G4VParticleChange.hh"
39 #include "G4ParticleChange.hh"
40 #include "G4HadronCrossSections.hh"
41 #include "G4HadronicProcess.hh"
42 #include "G4ChargeExchangeProcess.hh"
43 #include "G4VCrossSectionDataSet.hh"
44 #include "G4ProtonInelasticCrossSection.hh"
45 #include "G4NeutronInelasticCrossSection.hh"
46 #include "G4HadronInelasticDataSet.hh"
47 #include "G4HadronElasticDataSet.hh"
48 #include "G4IonsShenCrossSection.hh"
49 #include "G4TripathiCrossSection.hh"
50 #include "G4TripathiLightCrossSection.hh"
51 #include "G4HadronElasticDataSet.hh"
52 #include "G4PiNuclearCrossSection.hh"
53 #include "G4IonProtonCrossSection.hh"
55 #include "G4BGGNucleonElasticXS.hh"
56 #include "G4BGGPionElasticXS.hh"
57 #include "G4BGGNucleonInelasticXS.hh"
58 #include "G4BGGPionInelasticXS.hh"
60 #include "G4HadronNucleonXsc.hh"
61 #include "G4VComponentCrossSection.hh"
62 #include "G4ComponentAntiNuclNuclearXS.hh"
64 #include "G4ParticleTable.hh"
65 #include "G4ParticleChange.hh"
66 #include "G4DynamicParticle.hh"
67 #include "G4AntiProton.hh"
68 #include "G4Neutron.hh"
69 #include "G4Proton.hh"
70 #include "G4Electron.hh"
71 #include "G4Positron.hh"
73 #include "G4PionZero.hh"
74 #include "G4PionPlus.hh"
75 #include "G4PionMinus.hh"
78 #include "G4Deuteron.hh"
79 #include "G4Triton.hh"
80 #include "G4IonTable.hh"
81 #include "G4DecayPhysics.hh"
83 #include "G4ForceCondition.hh"
85 #include "G4PVPlacement.hh"
87 #include "G4GRSVolume.hh"
89 #include "G4UnitsTable.hh"
90 #include "G4SystemOfUnits.hh"
92 #include "G4ExcitationHandler.hh"
93 #include "G4PreCompoundModel.hh"
94 #include "G4Evaporation.hh"
96 #include "G4StateManager.hh"
97 #include "G4NistManager.hh"
100 #include "G4Timer.hh"
102 #include "G4ForceCondition.hh"
103 #include "G4TouchableHistory.hh"
105 #include "G4NucleiProperties.hh"
106 #include "G4ProductionCuts.hh"
107 #include "G4ProductionCutsTable.hh"
108 #include "G4ChipsComponentXS.hh"
109 #include "UZHI_diffraction.hh"
116 #include "TClonesArray.h"
118 #include "TStopwatch.h"
119 #include "TParticle.h"
121 #include "TG4RunConfiguration.h"
124 #include "TG4StateManager.h"
125 #include "TG4GeometryManager.h"
126 #include "TG4SDManager.h"
127 #include "TG4PhysicsManager.h"
144 fG4VUserPhysicsList(0),
193 FairGenerator(other),
198 fRsigma(other.fRsigma),
199 fThtMin(other.fThtMin),
201 fG4VUserPhysicsList(0),
205 fpartTable(other.fpartTable),
207 fverbose(other.fverbose),
208 fsaverand(other.fsaverand),
209 fNoElastics(other.fNoElastics),
210 fnamePart(other.fnamePart),
211 fionParticle(other.fionParticle),
213 fenergy(other.fenergy),
214 fsigmae(other.fsigmae),
217 ftargetA(other.ftargetA),
218 fnameMat(other.fnameMat),
220 fnameGen(other.fnameGen),
223 ftheStep(other.ftheStep),
224 fmaterial(other.fmaterial),
225 fxsbgg(other.fxsbgg),
227 faTime(other.faTime),
235 fsigTot(other.fsigTot),
236 fsigEl(other.fsigEl),
237 fsigIn(other.fsigIn),
238 fnpart(other.fnpart),
239 factiveCnt(other.factiveCnt),
243 gTrack(other.gTrack),
260 fG4VUserPhysicsList(0),
311 G4cout <<
"========================================================" << G4endl;
312 G4cout <<
"====== FTF Test Start ========" << G4endl;
313 G4cout <<
"========================================================" << G4endl;
314 G4cout <<
"Input file <" << configfile << G4endl;
317 fin =
new std::ifstream();
318 G4String fname = configfile;
319 fin->open(fname.c_str());
320 if( !
fin->is_open()) {
321 G4cout <<
"Input file <" << fname <<
"> does not exist! Exit" << G4endl;
349 fG4VUserPhysicsList(0),
357 fNoElastics(noelastic),
402 G4cout <<
"========================================================" << G4endl;
403 G4cout <<
"====== FTF Test Start ========" << G4endl;
404 G4cout <<
"========================================================" << G4endl;
405 G4cout <<
"parameters: particle="<<particle<<
", material="<<material<<
", targetA="<<targetA<<
", generator="<<generator<<
", mom="<<mom<<
", seed="<<seed<<
", nonelastic="<<noelastic<<G4endl;
478 G4cout <<
"###### End of PndFtfDirect #####" << G4endl;
496 std::cout<<
"PndFtfDirect::InitZero() $$$$$$$$$$$$$$$$$$$$$$$$$ "<<std::endl;
499 if ( strncmp(FairRunSim::Instance()->GetName(),
"TGeant3",7 ) == 0 ) {
500 std::cout <<
"We use GEANT3 and want to use FtfDirect: loading a Geant4 Manager for FTF now." << std::endl;
544 G4cout.setf( std::ios::scientific, std::ios::floatfield );
556 std::cout<<
"PndFtfDirect::Setup() $$$$$$$$$$$$$$$$$$$$$$$$$ "<<std::endl;
557 cout<<
"INIT FTF Material and Processes"<<endl;
560 fmate =
new Test30Material();
561 G4NistManager::Instance()->SetVerbose(0);
564 fphys =
new Test30Physics();
593 cout<<
"INIT FTF PARTICLES"<<endl;
596 proton = G4Proton::Proton();
597 neutron = G4Neutron::Neutron();
598 pin = G4PionMinus::PionMinus();
599 pip = G4PionPlus::PionPlus();
601 deu = G4Deuteron::DeuteronDefinition();
602 tri = G4Triton::TritonDefinition();
603 he3 = G4He3::He3Definition();
604 alp = G4Alpha::AlphaDefinition();
613 fpartTable = G4ParticleTable::GetParticleTable();
616 G4StateManager* g4State=G4StateManager::GetStateManager();
617 if (! g4State->SetNewState(G4State_Init)) {
618 G4cout <<
"error changing G4state"<< G4endl;;
628 <<
"> is not found out"
632 const G4Element* elm =
fmaterial->GetElement(0);
635 G4ProductionCuts*
cuts =
new G4ProductionCuts();
636 G4MaterialCutsCouple* couple =
new G4MaterialCutsCouple(
fmaterial,cuts);
638 G4ProductionCutsTable*
pkt = G4ProductionCutsTable::GetProductionCutsTable();
639 std::vector<G4double>* vc =
640 const_cast<std::vector<G4double>*
>(pkt->GetEnergyCutsVector(3));
645 G4int A = (G4int)(elm->GetN()+0.5);
646 G4int
Z = (G4int)(elm->GetZ()+0.5);
651 part = (G4ParticleTable::GetParticleTable())->FindParticle(
fnamePart);
659 G4cout <<
" Sorry, No definition for particle" <<
fnamePart
660 <<
" found" << G4endl;
672 std::cout<<
"PndFtfDirect::Setup(): got aprocess: proc = "<<
proc<<
" fphys = "<<
fphys<<std::endl;
675 G4cout <<
"For particle: " <<
part->GetParticleName()
676 <<
" generator " <<
fnameGen <<
" is unavailable"<< G4endl;
679 G4HadronicProcess* extraproc = 0;
681 G4cout<<
"targetA "<<
ftargetA<<G4endl;
685 G4cout <<
"The particle: " <<
part->GetParticleName() << G4endl;
687 G4cout <<
"The material: " <<
fmaterial->GetName()
688 <<
" Z= " << Z <<
" A= " << A<< G4endl;
689 G4cout <<
"The step: " <<
ftheStep/
mm <<
" mm" << G4endl;
690 G4cout <<
"The position: " << (*faPosition)/
mm <<
" mm" << G4endl;
691 G4cout <<
"The direction: " << (*faDirection) << G4endl;
692 G4cout <<
"The time: " <<
faTime/ns <<
" ns" << G4endl;
695 G4cout <<G4endl<<
"energy = " <<
fenergy/MeV <<
" MeV "
696 <<
" RMS(MeV)= " <<
fsigmae/MeV <<
" Plab "<<
fPlab/GeV<<
" GeV/c"<<G4endl;
700 G4double cross_sec = 0.0;
701 G4double cross_secel = 0.0;
702 G4double cross_inel = 0.0;
708 G4VComponentCrossSection* cs =0;
709 cs=
new G4ComponentAntiNuclNuclearXS();
711 cs->BuildPhysicsTable(*
part);
712 cross_sec = cs->GetTotalElementCrossSection(
part,
fenergy, Z, (G4double) A);
713 cross_inel=cs->GetInelasticElementCrossSection(
part,
fenergy, Z, (G4double)A);
714 cross_secel=cs->GetElasticElementCrossSection(
part,
fenergy, Z, (G4double)A);
718 G4VCrossSectionDataSet* cs = 0;
721 cs =
new G4HadronElasticDataSet();
722 }
else if (
fnameGen ==
"chargeex" ||
728 if(
fxsbgg) extraproc->AddDataSet(
new G4BGGNucleonElasticXS(
part));
730 if(
fxsbgg) extraproc->AddDataSet(
new G4BGGPionElasticXS(
part));
734 if(
fxsbgg) cs =
new G4BGGNucleonInelasticXS(
part);
735 else cs =
new G4ProtonInelasticCrossSection();
738 if(
fxsbgg) cs =
new G4BGGNucleonInelasticXS(
part);
739 else cs =
new G4NeutronInelasticCrossSection();
742 if(
fxsbgg) cs =
new G4BGGPionInelasticXS(
part);
743 else cs =
new G4PiNuclearCrossSection();
746 G4double zz = G4double(Z);
747 G4double aa = G4double(A);
750 cs =
new G4TripathiLightCrossSection();
752 G4cout <<
"Using Tripathi Light Cross section for Ions" << G4endl;
759 cs =
new G4TripathiCrossSection();
761 G4cout <<
"Using Tripathi Cross section for Ions" << G4endl;
770 cs =
new G4IonsShenCrossSection();
772 G4cout <<
"Using Shen Cross section for Ions" << G4endl;
774 G4cout <<
"ERROR: no cross section for ion Z= "
775 << zz <<
" A= " << aa << G4endl;
780 cs =
new G4HadronInelasticDataSet();
781 G4cout<<
"Using G4HadronInelasticDataSet()"<<G4endl;
785 extraproc->PreparePhysicsTable(*
part);
786 extraproc->BuildPhysicsTable(*
part);
787 cross_sec = extraproc->GetMicroscopicCrossSection(
dParticle,
791 cs->BuildPhysicsTable(*
part);
792 cross_sec = cs->GetCrossSection(
dParticle, elm);
793 G4cout<<
"Try 1 cross_secel "<<cross_secel/millibarn<<G4endl;
795 cross_sec = (G4HadronCrossSections::Instance())->
796 GetInelasticCrossSection(
dParticle, Z,A);
797 G4cout<<
"Try 2 cross_sec "<<cross_sec/millibarn<<G4endl;
801 cs->BuildPhysicsTable(*
part);
807 G4TouchableHandle fpTouchable(
new G4TouchableHistory());
808 gTrack->SetTouchableHandle(fpTouchable);
817 G4StepPoint *aPoint, *bPoint;
818 aPoint =
new G4StepPoint();
822 aPoint->SetSafety(safety);
823 step->SetPreStepPoint(aPoint);
828 bPoint->SetPosition(bPosition);
829 step->SetPostStepPoint(bPoint);
830 step->SetStepLength(ftheStep);
833 if(!G4StateManager::GetStateManager()->SetNewState(G4State_Idle))
834 G4cout <<
"G4StateManager PROBLEM! " << G4endl;
835 G4RotationMatrix*
rot =
new G4RotationMatrix();
839 rot->rotateY(-theta0);
842 G4cout <<
"Test rotation= " << (*rot)*(*faDirection) << G4endl;
844 G4Timer*
timer =
new G4Timer();
849 G4cout <<
"cross(mb)in= " << cross_sec*1000./barn << G4endl
850 <<
"cross(mb)el= " << cross_secel*1000./barn<<G4endl<<G4endl;
852 cross_inel=cross_sec-cross_secel;
854 cross_sec/=millibarn;
855 cross_secel/=millibarn;
856 cross_inel/=millibarn;
858 G4cout<<
"Element A Z N: "<<A<<
" "<<Z<<
" "<<A-Z<<G4endl;
859 G4cout<<
"Proposed Xs (mb): Tot El In: "
860 <<cross_sec<<
" "<<cross_secel<<
" "<<cross_inel<<G4endl;
864 G4double chipsTot, chipsEl, chipsIn;
866 static G4ChipsComponentXS* _instance =
new G4ChipsComponentXS();
867 G4ChipsComponentXS* CHIPSxsManager = _instance;
869 G4bool CHIPapplic=
true;
872 chipsTot=CHIPSxsManager->GetTotalElementCrossSection(
part,
fenergy,Z,A-Z);
873 chipsEl =CHIPSxsManager->GetElasticElementCrossSection(
part,
fenergy,Z,A-Z);
874 chipsIn =CHIPSxsManager->GetInelasticElementCrossSection(
part,
fenergy,Z,A-Z);
875 chipsTot/=millibarn; chipsEl/=millibarn; chipsIn/=millibarn;
877 G4cout<<
"CHIPS cross sections are used:----------------------"<<G4endl<<
878 "Plab Total Elastic Inelastic" <<G4endl;
879 G4cout<<
" "<<
fPlab/GeV<<
" "<< chipsTot<<
" "<<chipsEl<<
" "<<chipsIn <<G4endl<<G4endl;
888 G4cout<<
"Proposed Xs (mb) are used: Tot El In: "
889 <<cross_sec<<
" "<<cross_secel<<
" "<<cross_inel<<G4endl;
904 if(
fverbose>=1) cout<<
"ProcessEvent() try number "<<tryno<<
" failed, try again..."<<endl;
916 const G4DynamicParticle* sec = 0;
917 G4ParticleDefinition* pd;
919 G4LorentzVector labv, fm;
921 G4VParticleChange* aChange = 0;
923 TLorentzVector V(0,0,0,0);
951 gTrack->SetKineticEnergy(e0);
952 G4double amass =
fphys->GetNucleusMass();
957 G4double mass =
part->GetPDGMass();
961 e0/=
fionA; G4double mass_N=938.*MeV;
962 labv = G4LorentzVector(0.0, 0.0,
std::sqrt(e0*(e0 + 2.*mass_N)),
963 e0 + mass_N + mass_N);
966 labv = G4LorentzVector(0.0, 0.0,
std::sqrt(e0*(e0 + 2.*mass)),
970 G4ThreeVector bst = labv.boostVector();
972 G4LorentzVector labNN(0.0, 0.0,
std::sqrt(e0*(e0 + 2.*mass)),e0 + mass + amass);
973 G4ThreeVector boostNN = labNN.boostVector();
977 G4double
de = aChange->GetLocalEnergyDeposit();
978 G4LorentzVector dee = G4LorentzVector(0.0, 0.0, 0.0, de);
981 G4int
n = aChange->GetNumberOfSecondaries();
986 if(
fverbose>=1) G4cout<<
" Uzhi ------------ N prod. part "<<n<<G4endl;
988 if((
fverbose > 0) && (n < 2)) {G4cout<<
"Multiplicity of produced < 2!!!"<<G4endl;}
989 if(n < 2) {Nfault++; Ntotal--;}
994 const G4DynamicParticle *sec1 = aChange->GetSecondary(0)->GetDynamicParticle();
995 const G4DynamicParticle *sec2 = aChange->GetSecondary(1)->GetDynamicParticle();
996 G4ParticleDefinition *pd1 = sec1->GetDefinition();
997 G4ParticleDefinition *pd2 = sec2->GetDefinition();
998 int id1 = pd1->GetPDGEncoding();
999 int id2 = pd2->GetPDGEncoding();
1001 if(abs(id1)==2212 && abs(id2)==2212)
1004 delete aChange->GetSecondary(0);
1005 delete aChange->GetSecondary(1);
1008 for(G4int
i=0;
i<
n; ++
i)
1010 sec = aChange->GetSecondary(
i)->GetDynamicParticle();
1011 pd = sec->GetDefinition();
1012 G4String pname=pd->GetParticleName();
1014 if(
fverbose>=1) G4cout<<
" Part "<<
i<<
" "<<pname
1015 <<
" "<<sec->Get4Momentum()/GeV
1016 <<sec->Get4Momentum().mag()/GeV<<G4endl;
1018 fm = sec->Get4Momentum();
1020 mom = sec->GetMomentum();
1030 labv += G4LorentzVector(0.0,0.0,0.0,electron_mass_c2);
1038 theta = mom.theta();
1039 if(std::abs(pd->GetBaryonNumber()) < 2)
1041 int id = pd->GetPDGEncoding();
1042 Mom.SetPxPyPzE(px,py,pz,e);
1046 printf(
"- I -: new particle with: %i, %f, %f, %f ...\n",
id, px, py, pz);
1047 primGen->AddTrack(
id, px, py, pz, 0.,0.,0.);
1050 theta=theta*180./
pi;
1057 delete aChange->GetSecondary(
i);
1063 G4cout <<
"We have an inelastic event." << G4endl;
1069 G4cout <<
"We have skipped an elastic event." << G4endl;
1076 G4cout <<
"Energy/Momentum balance= " << labv << G4endl;
1082 G4cout <<
"End event =====================================" <<
fPlab<< G4endl;
1086 if(!flag_good)
return kFALSE;
1117 G4String line, line1;
1125 if(
fverbose > 0) G4cout <<
"Next line " << line << G4endl;
1126 if(line ==
"#particle") {
1129 }
else if(line ==
"#ion") {
1133 }
else if(line ==
"#Plab(GeV/c)") {
1136 }
else if(line ==
"#sigmae(GeV)") {
1139 }
else if(line ==
"#events") {
1141 }
else if(line ==
"#step(mm)") {
1144 }
else if(line ==
"#print") {
1146 }
else if(line ==
"#material") {
1148 }
else if(line ==
"#targetA") {
1150 }
else if(line ==
"#Shen") {
1152 }
else if(line ==
"#noElastics") {
1154 }
else if(line ==
"#generator") {
1157 if (fnameGen ==
"") {
1158 G4cout <<
"Generator name is empty! " << G4endl;
1162 if(fnameGen ==
"elastic" || fnameGen ==
"HElastic" ||
1163 fnameGen ==
"DElastic") {
fNoElastics=
false;
break; }
1164 char*
c = getenv(fnameGen);
1166 G4cout <<
"Generator <" << fnameGen <<
"> is not included in the "
1167 <<
" list SetModels.csh, so is ignored!"
1169 G4cout <<
"Use #run command to overcome this limitation " << G4endl;
1173 if(ss==
"1") {
break; }
1174 }
else if(line ==
"#run") {
1176 }
else if(line ==
"#verbose") {
1178 G4NistManager::Instance()->SetVerbose(fverbose);
1179 }
else if(line ==
"#position(mm)") {
1182 }
else if(line ==
"#direction") {
1188 }
else if(line ==
"#time(ns)") {
1191 }
else if(line ==
"#saverand") {
1193 }
else if(line ==
"#initrand") {
1197 if(
fverbose>0) G4cout <<
"Random Engine restored from file <"
1198 << sss <<
">" << G4endl;
1199 CLHEP::HepRandom::showEngineStatus();
1200 }
else if(line ==
"#xs_ghad") {
1202 }
else if(line ==
"#exit") {
1205 }
else if(line ==
"#GEMEvaporation") {
1206 G4cout<<
"### GEM evaporation is set"<<G4endl;
1208 }
else if(line ==
"#DefGEMEvaporation") {
1209 G4cout<<
"### Combined Default+GEM evaporation is set"<<G4endl;
1211 }
else if(line ==
"#Evaporation") {
1212 G4cout<<
"### Default evaporation is set"<<G4endl;
1214 }
else if(line ==
"#XSoption") {
1217 if (OPTxs< 0 || OPTxs >4 ){
1218 G4cout <<
"### WArning: BAD CROSS SECTION OPTION for PreCompound model "
1219 << OPTxs <<
" ignored" << G4endl;
1224 G4cout<<
" Option for inverse cross sections : OPTxs="<<OPTxs<<G4endl;
1226 }
else if(line ==
"#UseSuperImposedCoulombBarrier") {
1227 G4cout<<
" Coulomb Barrier has been overimposed to ALL inverse cross sections"
1232 }
else if(line ==
"#UseNeverGoBack") {
1233 G4cout<<
" Never Go Back hypothesis has been assumed at preequilibrium"
1236 }
else if(line ==
"#UseSoftCutOff") {
1237 G4cout<<
" Soft Cut Off hypothesis has been assumed at preequilibrium"
1241 }
else if(line ==
"#UseCEMTransitions") {
1242 G4cout<<
" Transition probabilities at preequilibrium based on CEM model"
1246 }
else if(line ==
"#MFenergy(MeV)") {
1249 G4cout<<
" Min energy for multi-fragmentation is set to " << tmin
1250 <<
" MeV" << G4endl;
1252 }
else if(line ==
"#FermiBreakUp") {
1253 G4cout<<
"### Max A and Z energy for fermiBreakUp are set to 17 and 9"
G4ParticleDefinition * anti_He3
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
G4ParticleDefinition * anti_triton
G4ParticleTable * fpartTable
friend F32vec4 sqrt(const F32vec4 &a)
G4RunManager * fG4RunManager
G4ParticleDefinition * part
G4ExcitationHandler * ftheDeExcitation
G4ParticleDefinition * he3
G4ParticleDefinition * anti_neutron
FairPrimaryGenerator * primGen
Bool_t ProcessEvent(FairPrimaryGenerator *primGen)
G4ParticleDefinition * proton
G4ParticleDefinition * pin
G4DynamicParticle * dParticle
G4PreCompoundModel * fthePreCompound
G4VUserPhysicsList * fG4VUserPhysicsList
CLHEP::RanluxEngine * fdefaultEngine
G4ParticleDefinition * alp
G4ParticleDefinition * anti_alpha
G4ParticleDefinition * anti_proton
G4ParticleDefinition * neutron
CLHEP::Hep3Vector * faDirection
G4ParticleDefinition * deu
G4ParticleDefinition * anti_deuteron
G4ParticleDefinition * tri
G4ParticleDefinition * electron
CLHEP::Hep3Vector * faPosition
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
G4ParticleDefinition * pip
G4Evaporation * ftheEvaporation