/[PAMELA software]/trieste/pamVMC/run_g4_testTRK.C
ViewVC logotype

Annotation of /trieste/pamVMC/run_g4_testTRK.C

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Tue Mar 24 14:18:54 2009 UTC (15 years, 11 months ago) by pizzolot
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +24 -14 lines
File MIME type: text/plain
setting of random seed; new distribution for primary generation

1 pizzolot 1.2
2 pamelats 1.1 // $Id: run_g4.C,v 1.0 2007/06/01
3     //
4     // Macro for running G4PAM_VMC with Geant4.
5 pizzolot 1.3 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 pamelats 1.1
13     // Load basic libraries
14     gROOT->LoadMacro("./macro/basiclibs.C");
15     basiclibs();
16    
17     // Load PAMELA libs
18     TString PAMLIB=gSystem->Getenv("PAM_LIB");
19     gSystem->Load(PAMLIB+"/libyoda.so");
20     gSystem->Load(PAMLIB+"/libDarthVader.so");
21     gSystem->Load(PAMLIB+"/libPamLevel2.so");
22    
23     // Load Geant4 libraries
24    
25     gROOT->LoadMacro("./macro/PamG4Libs.C");
26     PamG4Libs();
27    
28     // Load this example libraries
29     TString G4WD=gSystem->Getenv("G4WORKDIR");
30     TString PLAT=gSystem->Getenv("PLATFORM");
31     gSystem->Load(G4WD+"/lib/tgt_"+PLAT+"/libPamVMC_fc");
32    
33     // MC application
34     PamVMCApplication* appl
35 pizzolot 1.3 = new PamVMCApplication("PAMG4_VMC", "PAMELA GEANT4 VMC application", outfilename.Data(), seed);
36 pamelats 1.1
37 pizzolot 1.2
38 pamelats 1.1 //appl->GetPrimaryGenerator()->SetNofPrimaries(1);
39     appl->SetVerboseLevel(0);
40    
41     // Macro to run with primary = polarized optical photon
42     //gROOT->LoadMacro("optPhoton.C");
43     //optPhoton();
44     appl->SetVerboseLevel(2);
45     // Initialize MC
46 pizzolot 1.3 appl->InitMC(configMacro, outfilename.Data(), seed);
47 pamelats 1.1
48 pizzolot 1.2 // Cecilia: set seed for random generator
49 pizzolot 1.3 TRandom3 *rndgen = new TRandom3(seed);
50 pizzolot 1.2 ((TGeant4*)gMC)->SetRandom(rndgen);
51 pizzolot 1.3 // 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 pizzolot 1.2
61    
62 pamelats 1.1 // Customise Geant4 setting after initialization:
63     // Physics list
64     // gMC->SetCut("CUTGAM", 1.0e-6);
65     // gMC->SetCut("BCUTE", 1.0e-6);
66     // gMC->SetCut("CUTELE", 1.0e-6);
67     // gMC->SetCut("DCUTE", 1.0e-6);
68     // gMC->SetCut("CUTNEU", 1.0e-6);
69     // gMC->SetCut("CUTHAD", 1.0e-6);
70     // gMC->SetCut("CUTMUO", 1.0e-6);
71     // gMC->SetCut("DCUTM", 1.0e-6);
72     // gMC->SetCut("BCUTM", 1.0e-6);
73     // gMC->SetCut("PPCUTM", 1.0e-6);
74     // gMC->SetCut("TOFMAX", 1.0e-3);
75    
76     ((TGeant4*)gMC)->ProcessGeantMacro("g4config2.in");
77     // Visualization settings
78 pizzolot 1.3 //((TGeant4*)gMC)->ProcessGeantMacro("g4vis.in");
79 pamelats 1.1
80     ((TGeant4*)gMC)->SetMaxNStep(50000);
81     //appl->GetPrimaryGenerator()->SetParticle(1000060120);
82     appl->GetPrimaryGenerator()->SetParticle(kElectron);
83     //appl->GetPrimaryGenerator()->SetDirection(0.,0.);
84 pizzolot 1.3 //appl->GetPrimaryGenerator()->SetKinEnergy(10.);
85 pamelats 1.1 //appl->GetPrimaryGenerator()->SetRigidity(1.0); //GV
86     //appl->GetPrimaryGenerator()->SetPosition(1.,1.,130.);
87 pizzolot 1.2
88 pamelats 1.1 // Run MC
89 pizzolot 1.2 for (Int_t i=0; i<2; i++){
90     cout<<"in Loop: Event nr."<<i<<" --<<--<<--<<--<<--<<--<<--"<<endl;
91     // ritabrata 04.03.2009
92     //appl->GetPrimaryGenerator()->SetKinEnergy(0.1);
93     //if (i==0) appl->GetPrimaryGenerator()->SetKinEnergy(0.01);
94     //appl->GetPrimaryGenerator()->GenSphDist(120.);
95     // endritabrata
96    
97     // cecilia
98 pizzolot 1.3 appl->GetPrimaryGenerator()->GenSphPhiThe(-25,25., -25.,25., 108.0,108.0);
99     appl->GetPrimaryGenerator()->GenSpe(5.,30.,-3.3);
100    
101 pamelats 1.1 appl->RunMC(1);
102    
103     }
104    
105     appl->FinishRun();
106     // ((TGeant4*)gMC)->StartGeantUI();
107     delete appl;
108    
109     }

  ViewVC Help
Powered by ViewVC 1.1.23