/[PAMELA software]/PamVMC/examples/run_g4_test.C
ViewVC logotype

Diff of /PamVMC/examples/run_g4_test.C

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by nikolas, Thu Feb 19 18:43:13 2009 UTC revision 1.5 by pam-rm2, Fri Jun 12 18:39:15 2009 UTC
# Line 1  Line 1 
1  // $Id: run_g4.C,v 1.0 2007/06/01  void run_g4_test() {
2  //  
3  // Macro for running G4PAM_VMC with Geant4.      TString PAM_VMC=gSystem->Getenv("PAM_VMC");
4  void run_g4_test(const TString& configMacro = "../macro/g4Config.C") {      TString PLAT=gSystem->Getenv("PLATFORM");
5    
6      // Load basic libraries      // Load basic libraries
7      gROOT->LoadMacro("../macro/basiclibs.C");      gROOT->LoadMacro(PAM_VMC+"/macro/basiclibs.C");
8      basiclibs();      basiclibs();
9    
10      // Load PAMELA libs      // Load PAMELA libs
# Line 14  void run_g4_test(const TString& configMa Line 14  void run_g4_test(const TString& configMa
14      gSystem->Load(PAMLIB+"/libPamLevel2.so");      gSystem->Load(PAMLIB+"/libPamLevel2.so");
15            
16      // Load Geant4 libraries      // Load Geant4 libraries
17            gROOT->LoadMacro(PAM_VMC+"/macro/PamG4Libs.C");
     gROOT->LoadMacro("../macro/PamG4Libs.C");  
18      PamG4Libs();      PamG4Libs();
19          
20      // Load this example libraries      // Load application library
21      TString G4WD=gSystem->Getenv("G4WORKDIR");      gSystem->Load(PAM_VMC+"/lib/tgt_"+PLAT+"/libPamVMC_fc");    
22      TString PLAT=gSystem->Getenv("PLATFORM");  
     gSystem->Load(G4WD+"/lib/tgt_"+PLAT+"/libPamVMC_fc");  
       
23      // MC application      // MC application
24      PamVMCApplication* appl      PamVMCApplication* appl
25        = new PamVMCApplication("PAMG4_VMC", "PAMELA GEANT4 VMC application");        = new PamVMCApplication("PAMG4_VMC", "PAMELA GEANT4 VMC application","nik1");
     
     appl->GetPrimaryGenerator()->SetNofPrimaries(1);    
       
       
     // Initialize MC  
     appl->InitMC(configMacro);  
     ((TGeant4*)gMC)->ProcessGeantMacro("../macro/g4config2.in");  
   
 #define EVENTS 5000    
26        
27  #define RMIN 1.0      //verbose level (0-4), 0 means no verbose
28  #define RMAX 2.0      appl->SetVerboseLevel(0);
29    
30        //initialise physycs with specific RunConfiguration, defined in macro
31        appl->InitMC(PAM_VMC+"/config/g4Config.C");
32    
 #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  
33    
34      TRandom3 r(123456);      //additional flags and controls related to G4 core
35      TRandom3 dprx(123);     ((TGeant4*)gMC)->ProcessGeantMacro(PAM_VMC+"/config/g4config2.in");
36      TRandom3 dpry(456);  
37      TRandom3 dprz(321);  
38      TRandom3 drx(132);      //maximum allowed steps per track, default 30000
39      TRandom3 dry(465);      ((TGeant4*)gMC)->SetMaxNStep(50000);
40        
41      for (Int_t i=0; i<EVENTS; i++){      //define particle. Important. Is shold be done before any
42        Double_t rig = r.Uniform(RMIN,RMAX);      //definition of energy or momentum
43        appl->GetPrimaryGenerator()->SetRigidity(rig);      appl->GetPrimaryGenerator()->SetParticle(1000020040);
44    
45        Double_t dpx = dprx.Uniform(-DPX,DPX);      //define direction, theta, phi (radians)
46        Double_t dpy = dpry.Uniform(-DPY,DPY);      appl->GetPrimaryGenerator()->SetDirection(-TMath::Pi()/180.*0.,
47        Double_t dpz = dprz.Uniform(-DPZ,DPZ);                                                TMath::Pi()/90.*0.);
48        appl->GetPrimaryGenerator()->SetDirection(PX+dpx,PY+dpy,-1.0+dpz);  
49              //define total kinetic energy (GeV)
50        Double_t dx = drx.Uniform(-DX,DX);      appl->GetPrimaryGenerator()->SetKinEnergy(8.);
51        Double_t dy = dry.Uniform(-DY,DY);  
52              //define initial position in PAMELA reference system
53        appl->GetPrimaryGenerator()->SetPosition(X0+dx,Y0+dy,Z0);      appl->GetPrimaryGenerator()->SetPosition(2.,2.,120.);
54        appl->RunMC(1);  
55    
56        //run MC in loop and visualize for 1 evnent
57        for (Int_t i=0; i<11; i++){
58         if (i==10) ((TGeant4*)gMC)->ProcessGeantMacro(PAM_VMC+"/config/g4vis.in");
59         appl->RunMC(1);
60      }      }
     
    // Visualization settings  
     // ((TGeant4*)gMC)->ProcessGeantMacro("../macro/g4vis.in");  
       
     // Run MC  
     //  appl->RunMC(1000);  
      appl->FinishRun();  
      // ((TGeant4*)gMC)->StartGeantUI();  
      //  delete appl;  
61    
62    }        //Starting Geant-4 interface if needed
63        //((TGeant4*)gMC)->StartGeantUI();
64    
65        // finish run, write output files
66        appl->FinishRun();
67        delete appl;
68    }  

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.23