1 |
|
|
2 |
// $Id: run_g4.C,v 1.0 2007/06/01 |
// $Id: run_g4.C,v 1.0 2007/06/01 |
3 |
// |
// |
4 |
// Macro for running G4PAM_VMC with Geant4. |
// Macro for running G4PAM_VMC with Geant4. |
5 |
void run_g4_testTRK(const TString& configMacro = "g4Config.C") { |
void run_g4_testTRK(TString outfilename="/gpfs/wizard/flight/analysis/cecilia/trieste/pamVMC/pamtest", |
6 |
|
UInt_t seed = 0, const TString& configMacro = "g4Config.C") { |
7 |
|
|
8 |
|
if (seed == 0) { // set random seed |
9 |
|
TRandom3 *r = new TRandom3(0); |
10 |
|
seed = r->GetSeed(); |
11 |
|
} |
12 |
|
|
13 |
// Load basic libraries |
// Load basic libraries |
14 |
gROOT->LoadMacro("./macro/basiclibs.C"); |
gROOT->LoadMacro("./macro/basiclibs.C"); |
32 |
|
|
33 |
// MC application |
// MC application |
34 |
PamVMCApplication* appl |
PamVMCApplication* appl |
35 |
= new PamVMCApplication("PAMG4_VMC", "PAMELA GEANT4 VMC application"); |
= new PamVMCApplication("PAMG4_VMC", "PAMELA GEANT4 VMC application", outfilename.Data(), seed); |
36 |
|
|
37 |
|
|
38 |
//appl->GetPrimaryGenerator()->SetNofPrimaries(1); |
//appl->GetPrimaryGenerator()->SetNofPrimaries(1); |
39 |
appl->SetVerboseLevel(0); |
appl->SetVerboseLevel(0); |
40 |
|
|
43 |
//optPhoton(); |
//optPhoton(); |
44 |
appl->SetVerboseLevel(2); |
appl->SetVerboseLevel(2); |
45 |
// Initialize MC |
// Initialize MC |
46 |
appl->InitMC(configMacro); |
appl->InitMC(configMacro, outfilename.Data(), seed); |
47 |
|
|
48 |
|
// Cecilia: set seed for random generator |
49 |
|
TRandom3 *rndgen = new TRandom3(seed); |
50 |
|
((TGeant4*)gMC)->SetRandom(rndgen); |
51 |
|
// Write seed in a txt file |
52 |
|
TString seedfname = outfilename; |
53 |
|
seedfname.Append("Seed.txt"); |
54 |
|
cout<<" FILENAME "<<seedfname.Data()<<endl; |
55 |
|
FILE *seedfile = fopen(seedfname.Data(),"w"); |
56 |
|
fprintf(seedfile,"%d\n",rndgen->GetSeed() ); |
57 |
|
fclose(seedfile); |
58 |
|
|
59 |
|
cout<<"SEED "<<rndgen->GetSeed()<<endl; |
60 |
|
|
61 |
|
|
62 |
// Customise Geant4 setting after initialization: |
// Customise Geant4 setting after initialization: |
63 |
// Physics list |
// Physics list |
75 |
|
|
76 |
((TGeant4*)gMC)->ProcessGeantMacro("g4config2.in"); |
((TGeant4*)gMC)->ProcessGeantMacro("g4config2.in"); |
77 |
// Visualization settings |
// Visualization settings |
78 |
((TGeant4*)gMC)->ProcessGeantMacro("g4vis.in"); |
//((TGeant4*)gMC)->ProcessGeantMacro("g4vis.in"); |
79 |
|
|
80 |
((TGeant4*)gMC)->SetMaxNStep(50000); |
((TGeant4*)gMC)->SetMaxNStep(50000); |
81 |
//appl->GetPrimaryGenerator()->SetParticle(1000060120); |
//appl->GetPrimaryGenerator()->SetParticle(1000060120); |
82 |
appl->GetPrimaryGenerator()->SetParticle(kElectron); |
appl->GetPrimaryGenerator()->SetParticle(kElectron); |
83 |
//appl->GetPrimaryGenerator()->SetDirection(0.,0.); |
//appl->GetPrimaryGenerator()->SetDirection(0.,0.); |
84 |
//appl->GetPrimaryGenerator()->SetKinEnergy(10.); |
//appl->GetPrimaryGenerator()->SetKinEnergy(10.); |
85 |
//appl->GetPrimaryGenerator()->SetRigidity(1.0); //GV |
//appl->GetPrimaryGenerator()->SetRigidity(1.0); //GV |
86 |
//appl->GetPrimaryGenerator()->SetPosition(1.,1.,130.); |
//appl->GetPrimaryGenerator()->SetPosition(1.,1.,130.); |
87 |
|
|
88 |
// Run MC |
// Run MC |
89 |
for (Int_t i=0; i<3; i++){ |
for (Int_t i=0; i<2; i++){ |
90 |
cout<<"Event "<<i<<endl; |
cout<<"in Loop: Event nr."<<i<<" --<<--<<--<<--<<--<<--<<--"<<endl; |
91 |
appl->GetPrimaryGenerator()->SetKinEnergy(10.); |
// ritabrata 04.03.2009 |
92 |
if (i==0) appl->GetPrimaryGenerator()->SetKinEnergy(0.01); |
//appl->GetPrimaryGenerator()->SetKinEnergy(0.1); |
93 |
appl->GetPrimaryGenerator()->GenSphDist(120.); |
//if (i==0) appl->GetPrimaryGenerator()->SetKinEnergy(0.01); |
94 |
//appl->GetPrimaryGenerator()->GenSphDist(120.,0.,90.,0.,360.); |
//appl->GetPrimaryGenerator()->GenSphDist(120.); |
95 |
// appl->GetPrimaryGenerator()->GenPosition(-22.4,22.4, -18.5, 18.5, 110.0,110.0); |
// endritabrata |
96 |
//appl->GetPrimaryGenerator()->GenDirection(0.,TMath::Pi()/2.,0.,2*TMath::Pi()); |
|
97 |
//appl->GetPrimaryGenerator()->GenSpe(1.,5.,-2.75); |
// cecilia |
98 |
// appl->GetPrimaryGenerator()->Print(); |
appl->GetPrimaryGenerator()->GenSphPhiThe(-25,25., -25.,25., 108.0,108.0); |
99 |
// if (i==9) ((TGeant4*)gMC)->ProcessGeantMacro("g4vis.in"); |
appl->GetPrimaryGenerator()->GenSpe(5.,30.,-3.3); |
100 |
|
|
101 |
appl->RunMC(1); |
appl->RunMC(1); |
102 |
|
|
103 |
} |
} |