1 |
// $Id: run_g4.C,v 1.0 2007/06/01 |
2 |
// |
3 |
// Macro for running G4PAM_VMC with Geant4. |
4 |
void run_g4(const TString& configMacro = "g4Config.C") { |
5 |
|
6 |
// Load basic libraries |
7 |
gROOT->LoadMacro("./macro/basiclibs.C"); |
8 |
basiclibs(); |
9 |
|
10 |
// Load PAMELA libs |
11 |
TString PAMLIB=gSystem->Getenv("PAM_LIB"); |
12 |
gSystem->Load(PAMLIB+"/libyoda.so"); |
13 |
gSystem->Load(PAMLIB+"/libDarthVader.so"); |
14 |
gSystem->Load(PAMLIB+"/libPamLevel2.so"); |
15 |
|
16 |
// Load Geant4 libraries |
17 |
|
18 |
gROOT->LoadMacro("./macro/PamG4Libs.C"); |
19 |
PamG4Libs(); |
20 |
|
21 |
// Load this example libraries |
22 |
TString G4WD=gSystem->Getenv("G4WORKDIR"); |
23 |
TString PLAT=gSystem->Getenv("PLATFORM"); |
24 |
gSystem->Load(G4WD+"/lib/tgt_"+PLAT+"/libPamVMC_fc"); |
25 |
|
26 |
// MC application |
27 |
PamVMCApplication* appl |
28 |
= new PamVMCApplication("PAMG4_VMC", "PAMELA GEANT4 VMC application"); |
29 |
|
30 |
//appl->GetPrimaryGenerator()->SetNofPrimaries(1); |
31 |
appl->SetVerboseLevel(0); |
32 |
|
33 |
// Macro to run with primary = polarized optical photon |
34 |
//gROOT->LoadMacro("optPhoton.C"); |
35 |
//optPhoton(); |
36 |
|
37 |
// Initialize MC |
38 |
appl->InitMC(configMacro); |
39 |
|
40 |
|
41 |
// Customise Geant4 setting after initialization: |
42 |
// Physics list |
43 |
// gMC->SetCut("CUTGAM", 1.0e-6); |
44 |
// gMC->SetCut("BCUTE", 1.0e-6); |
45 |
// gMC->SetCut("CUTELE", 1.0e-6); |
46 |
// gMC->SetCut("DCUTE", 1.0e-6); |
47 |
// gMC->SetCut("CUTNEU", 1.0e-6); |
48 |
// gMC->SetCut("CUTHAD", 1.0e-6); |
49 |
// gMC->SetCut("CUTMUO", 1.0e-6); |
50 |
// gMC->SetCut("DCUTM", 1.0e-6); |
51 |
// gMC->SetCut("BCUTM", 1.0e-6); |
52 |
// gMC->SetCut("PPCUTM", 1.0e-6); |
53 |
// gMC->SetCut("TOFMAX", 1.0e-3); |
54 |
|
55 |
((TGeant4*)gMC)->ProcessGeantMacro("g4config2.in"); |
56 |
// Visualization settings |
57 |
// ((TGeant4*)gMC)->ProcessGeantMacro("g4vis.in"); |
58 |
appl->GetPrimaryGenerator()->SetParticle(kProton); |
59 |
//appl->GetPrimaryGenerator()->SetDirection(0.,0.); |
60 |
|
61 |
//appl->GetPrimaryGenerator()->SetRigidity(1.0); //GV |
62 |
//appl->GetPrimaryGenerator()->SetPosition(1.,1.,130.); |
63 |
// Run MC |
64 |
for (Int_t i=1; i<10000; i++){ |
65 |
cout<<"Event "<<i<<endl; |
66 |
appl->GetPrimaryGenerator()->GenPosition(-22.4,22.4, -18.5, 18.5, 110.0,110.0); |
67 |
appl->GetPrimaryGenerator()->GenDirection(0.,TMath::Pi()/2.,0.,2*TMath::Pi()); |
68 |
appl->GetPrimaryGenerator()->GenSpe(1.,5.,-2.75); |
69 |
// appl->GetPrimaryGenerator()->Print(); |
70 |
appl->RunMC(1); |
71 |
|
72 |
} |
73 |
appl->FinishRun(); |
74 |
// ((TGeant4*)gMC)->StartGeantUI(); |
75 |
delete appl; |
76 |
|
77 |
} |