--- PamVMC/examples/run_g4_test.C 2009/02/19 17:39:48 1.2 +++ PamVMC/examples/run_g4_test.C 2009/06/12 18:39:15 1.5 @@ -1,10 +1,10 @@ -// $Id: run_g4.C,v 1.0 2007/06/01 -// -// Macro for running G4PAM_VMC with Geant4. -void run_g4_test(const TString& configMacro = "g4Config.C") { +void run_g4_test() { + + TString PAM_VMC=gSystem->Getenv("PAM_VMC"); + TString PLAT=gSystem->Getenv("PLATFORM"); // Load basic libraries - gROOT->LoadMacro("../macro/basiclibs.C"); + gROOT->LoadMacro(PAM_VMC+"/macro/basiclibs.C"); basiclibs(); // Load PAMELA libs @@ -14,76 +14,55 @@ gSystem->Load(PAMLIB+"/libPamLevel2.so"); // Load Geant4 libraries - - gROOT->LoadMacro("../macro/PamG4Libs.C"); + gROOT->LoadMacro(PAM_VMC+"/macro/PamG4Libs.C"); PamG4Libs(); - - // Load this example libraries - TString G4WD=gSystem->Getenv("G4WORKDIR"); - TString PLAT=gSystem->Getenv("PLATFORM"); - gSystem->Load(G4WD+"/lib/tgt_"+PLAT+"/libPamVMC_fc"); - + + // Load application library + gSystem->Load(PAM_VMC+"/lib/tgt_"+PLAT+"/libPamVMC_fc"); + // MC application PamVMCApplication* appl - = new PamVMCApplication("PAMG4_VMC", "PAMELA GEANT4 VMC application"); - - appl->GetPrimaryGenerator()->SetNofPrimaries(1); - - - // Initialize MC - appl->InitMC(configMacro); - ((TGeant4*)gMC)->ProcessGeantMacro("../macro/g4config2.in"); - -#define EVENTS 5000 + = new PamVMCApplication("PAMG4_VMC", "PAMELA GEANT4 VMC application","nik1"); -#define RMIN 1.0 -#define RMAX 2.0 + //verbose level (0-4), 0 means no verbose + appl->SetVerboseLevel(0); + + //initialise physycs with specific RunConfiguration, defined in macro + appl->InitMC(PAM_VMC+"/config/g4Config.C"); -#define X0 0. -#define Y0 0. -#define Z0 110. - -#define DX 10.0 -#define DY 10.0 - -#define PX 0. -#define PY 0. - //#define PEEE -1. - -#define DPX 0.1 -#define DPY 0.1 -#define DPZ 0.1 - TRandom3 r(123456); - TRandom3 dprx(123); - TRandom3 dpry(456); - TRandom3 dprz(321); - TRandom3 drx(132); - TRandom3 dry(465); - - for (Int_t i=0; iGetPrimaryGenerator()->SetRigidity(rig); - - Double_t dpx = dprx.Uniform(-DPX,DPX); - Double_t dpy = dpry.Uniform(-DPY,DPY); - Double_t dpz = dprz.Uniform(-DPZ,DPZ); - appl->GetPrimaryGenerator()->SetDirection(PX+dpx,PY+dpy,-1.0+dpz); - - Double_t dx = drx.Uniform(-DX,DX); - Double_t dy = dry.Uniform(-DY,DY); - - appl->GetPrimaryGenerator()->SetPosition(X0+dx,Y0+dy,Z0); - appl->RunMC(1); + //additional flags and controls related to G4 core + ((TGeant4*)gMC)->ProcessGeantMacro(PAM_VMC+"/config/g4config2.in"); + + + //maximum allowed steps per track, default 30000 + ((TGeant4*)gMC)->SetMaxNStep(50000); + + //define particle. Important. Is shold be done before any + //definition of energy or momentum + appl->GetPrimaryGenerator()->SetParticle(1000020040); + + //define direction, theta, phi (radians) + appl->GetPrimaryGenerator()->SetDirection(-TMath::Pi()/180.*0., + TMath::Pi()/90.*0.); + + //define total kinetic energy (GeV) + appl->GetPrimaryGenerator()->SetKinEnergy(8.); + + //define initial position in PAMELA reference system + appl->GetPrimaryGenerator()->SetPosition(2.,2.,120.); + + + //run MC in loop and visualize for 1 evnent + for (Int_t i=0; i<11; i++){ + if (i==10) ((TGeant4*)gMC)->ProcessGeantMacro(PAM_VMC+"/config/g4vis.in"); + appl->RunMC(1); } - - // Visualization settings - // ((TGeant4*)gMC)->ProcessGeantMacro("../macro/g4vis.in"); - - // Run MC - // appl->RunMC(1000); - appl->FinishRun(); - // ((TGeant4*)gMC)->StartGeantUI(); - // delete appl; - } + //Starting Geant-4 interface if needed + //((TGeant4*)gMC)->StartGeantUI(); + + // finish run, write output files + appl->FinishRun(); + delete appl; +}