33 #include "TObjArray.h"
34 #include "TGeoTrack.h"
35 #include "TGeoVolume.h"
36 #include "TParticle.h"
37 #include "TGeoManager.h"
38 #include "TRefArray.h"
40 #include "TInterpreter.h"
41 #include "TVirtualMC.h"
42 #include "TDatabasePDG.h"
43 #include "TGeoTrack.h"
44 #include "TGeoVolume.h"
45 #include "TParticle.h"
46 #include "TGeoManager.h"
47 #include "TParticlePDG.h"
48 #include "TMCParticleType.h"
49 #include "THashList.h"
59 TObjArray* ModList,
const char* MatName)
60 :TVirtualMCApplication(name,title),
62 fActiveDetectors(NULL),
71 fPythiaDecayer(kFALSE),
72 fPythiaDecayerConfig(
""),
80 fTrajAccepted(kFALSE),
90 fTrkPos(TLorentzVector(0,0,0,0)),
113 if(obj->InheritsFrom(
"FairDetector")) {
136 :TVirtualMCApplication(),
147 fPythiaDecayer(kFALSE),
148 fPythiaDecayerConfig(
""),
156 fTrajAccepted(kFALSE),
158 fUserDecayConfig(
""),
166 fTrkPos(TLorentzVector(0,0,0,0)),
173 fMCEventHeader(NULL),
212 TString MCName=gMC->GetName();
213 if (MCName ==
"TGeant3" || MCName ==
"TGeant3TGeo") {
215 }
else if(MCName ==
"TGeant4") {
217 }
else if(MCName ==
"TFluka") {
233 gMC->ProcessRun(nofEvents);
263 TObjArray* meshlist = NULL;
269 for(Int_t i=0; i<meshlist->GetEntriesFast(); i++ ) {
271 aMesh->
Scale(1./nprimary);
281 cout << endl << endl;
282 cout <<
"======================================================="
284 cout <<
" Dosimetry histos saving " << endl << endl;
285 cout <<
"======================================================="
287 cout << endl << endl;
289 gDirectory->mkdir(
"Dosimetry");
290 gDirectory->cd(
"Dosimetry");
294 for(Int_t i=0; i<meshlist->GetEntriesFast(); i++ ) {
306 gDirectory->cd(
"..");
392 static Int_t TrackId = 0;
393 if (
fMcVersion ==2 && gMC->GetStack()->GetCurrentTrackNumber() != TrackId ) {
395 TrackId = gMC->GetStack()->GetCurrentTrackNumber();
400 Int_t
id = gMC->CurrentVolID(copyNo);
402 Bool_t InMap =kFALSE;
412 if(copyNo==fCopyNo) {
428 fVolMap.insert(pair<Int_t, FairVolume* >(
id, fNewV));
442 id = gMC->CurrentVolID(copyNo);
447 id = gMC->CurrentVolID(copyNo);
544 TObjArray* fListOfTracks=gGeoManager->GetListOfTracks();
545 fListOfTracks->Delete();
584 TListIter iter(MediaList);
593 if ( gGeoManager && (Med = gGeoManager->GetMedium(medium->GetName())) ) {
601 Double_t ppckov[NK], absco[NK], effic[NK],rindex[NK];
602 for (Int_t i=0; i<NK; i++) {
609 gMC->SetCerenkov(Mid, NK, ppckov,absco, effic, rindex);
614 while((Mod = dynamic_cast<FairModule*>(
fModIter->Next()))) {
626 Int_t NoOfVolumesBefore=0;
628 while((Mod = dynamic_cast<FairModule*>(
fModIter->Next()))) {
629 NoOfVolumesBefore=gGeoManager->GetListOfVolumes()->GetEntriesFast();
632 NoOfVolumes=gGeoManager->GetListOfVolumes()->GetEntriesFast();
633 for (Int_t
n=NoOfVolumesBefore;
n <= NoOfVolumes;
n++) {
643 gGeoManager->CloseGeometry();
644 gMC->SetRootGeometry();
645 gGeoManager->SetPdgName(22,
"gamma");
646 gGeoManager->SetPdgName(211,
"pi+");
647 gGeoManager->SetPdgName(321,
"K+");
648 gGeoManager->SetPdgName(2212,
"proton");
649 gGeoManager->SetPdgName(-211,
"pi-");
650 gGeoManager->SetPdgName(-321,
"K-");
651 gGeoManager->SetPdgName(111,
"pi0");
652 gGeoManager->SetPdgName(310,
"K0");
653 gGeoManager->SetPdgName(130,
"K0");
654 gGeoManager->SetPdgName(2112,
"neutron");
655 gGeoManager->SetPdgName(11,
"e-");
656 gGeoManager->SetPdgName(13,
"mu-");
657 gGeoManager->SetPdgName(-11,
"e+");
658 gGeoManager->SetPdgName(-13,
"mu+");
659 gGeoManager->SetPdgName(3312,
"Xsi");
660 gGeoManager->SetPdgName(3334,
"Omega");
661 gGeoManager->SetPdgName(50000050,
"Ckov");
662 gGeoManager->SetPdgName(-421,
"D0bar");
663 gGeoManager->SetPdgName(421,
"D0");
664 gGeoManager->SetPdgName(-411,
"D-");
665 gGeoManager->SetPdgName(411,
"D+");
666 gGeoManager->SetPdgName(-213,
"rho-");
667 gGeoManager->SetPdgName(213,
"rho+");
668 gGeoManager->SetPdgName(113,
"rho0");
669 gGeoManager->SetPdgName(1000010020,
"Deuteron");
670 gGeoManager->SetPdgName(1000010030,
"Triton");
671 gGeoManager->SetPdgName(1000020030,
"HE3");
672 gGeoManager->SetPdgName(1000020040,
"Alpha");
694 while((detector = dynamic_cast<FairDetector*>(
fActDetIter->Next()))) {
741 TTree* outTree =
new TTree(
"cbmsim",
"/cbmroot", 99);
750 TGeoVolume*
v=gGeoManager->GetVolume(fv->GetName());
756 for(Int_t
k=0;
k<fNs->GetEntriesFast();
k++) {
757 fN=(TGeoNode*)fNs->At(
k);
763 fVolMap.insert(pair<Int_t, FairVolume* >(
id, fNewV));
771 fVolMap.insert(pair<Int_t, FairVolume* >(
id, fNewV));
774 fVolMap.insert(pair<Int_t, FairVolume* >(
id, fv));
801 TDatabasePDG* pdgDatabase = TDatabasePDG::Instance();
804 TIterator* Iter=NewIons->MakeIterator();
808 while((obj=Iter->Next())) {
809 ion=dynamic_cast <
FairIon*> (obj);
818 if ( !pdgDatabase->GetParticle( ionPdg ) ) {
819 gMC->DefineIon(ion->GetName(), ion->
GetZ(), ion->
GetA(), ion->
GetQ(),
823 ion->SetName(pdgDatabase->GetParticle(ionPdg)->GetName());
827 gGeoManager->SetPdgName(pdgDatabase->GetParticle(ion->GetName())->PdgCode(),ion->GetName() );
829 fLogger->
Info(
MESSAGE_ORIGIN,
"Add Ion: %s with PDG %i ", ion->GetName(), pdgDatabase->GetParticle(ion->GetName())->PdgCode());
844 TIterator* Iter=NewIons->MakeIterator();
848 TIterator* parIter=NewPart->MakeIterator();
852 while((obj=parIter->Next())) {
856 cout <<
"Add Particle: " << particle->
GetName() <<
" with PDG " << particle->
GetPDG() <<
"\n"<<
857 particle->
GetName() <<
" // const TString& name \n" <<
858 particle->
GetMCType()<<
" // TMCParticleType mcType \n" <<
859 particle->
GetMass()<<
" // Double_t mass \n" <<
860 particle->
GetCharge()<<
" // Double_t charge \n" <<
862 particle->
GetPType()<<
" // const TString& pType, \n" <<
863 particle->
GetWidth()<<
" // Double_t width \n" <<
864 particle->
GetSpin()<<
" // Int_t iSpin \n" <<
865 particle->
GetiParity()<<
" // Int_t iParity \n" <<
867 particle->
GetIsospin()<<
" // Int_t iIsospin \n" <<
868 particle->
GetIsospinZ()<<
" // Int_t iIsospinZ \n" <<
869 particle->
GetgParity()<<
" // Int_t gParity \n" <<
870 particle->
GetLepton()<<
" // Int_t lepton \n" <<
871 particle->
GetBaryon()<<
" // Int_t baryon \n" <<
872 particle->
IsStable() <<
" // Bool_t stable \n" << endl;
873 gMC->DefineParticle(particle->
GetPDG(),
893 gGeoManager->SetPdgName(particle->
GetPDG(),particle->
GetName() );
905 TString work = getenv(
"VMCWORKDIR");
906 TString work_config=work+
"/gconfig/";
907 TString config_dir= getenv(
"CONFIG_DIR");
908 Bool_t AbsPath=kFALSE;
910 if (!config_dir.EndsWith(
"/")) {
918 decayConfig=
"DecayConfig.C";
927 if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(), decayConfig)) != TString(
"")) {
928 cout <<
"---User path for Configuration (DecayConfig.C) is used : " << config_dir.Data() << endl;
937 cout <<
"External Decay Modes with script \n "<< decayConfig.Data() << endl;
939 Int_t pyt= gROOT->LoadMacro(decayConfig.Data());
941 gInterpreter->ProcessLine(
"DecayConfig()");
949 Userdecay=
"UserDecay.C";
959 if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(), Userdecay)) != TString(
"")) {
960 cout <<
"---User path for Configuration (UserDecay.C) is used : " << config_dir.Data() << endl;
968 cout <<
"User Decay Modes with script \n "<< Userdecay.Data() << endl;
969 Int_t dec= gROOT->LoadMacro(Userdecay.Data());
971 gInterpreter->ProcessLine(
"UserDecayConfig()");
1015 while((Mod = dynamic_cast<FairModule*>(
fModIter->Next()))) {
1076 return 1000000000 + 10*1000*z + 10*a;