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

Annotation of /trieste/pamVMC/run_g4_GP_Chain.C

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Wed Mar 4 12:51:03 2009 UTC (15 years, 9 months ago) by pamelats
Branch point for: MAIN, pamVMC
File MIME type: text/plain
Initial revision

1 pamelats 1.1 // $Id: run_g4.C,v 1.0 2007/06/01
2     //
3     // Macro for running G4PAM_VMC with Geant4.
4     void run_g4_GP_Chain(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    
32    
33     // Initialize MC
34     appl->InitMC(configMacro);
35     ((TGeant4*)gMC)->ProcessGeantMacro("g4config2.in");
36    
37     //START READING INPUT FILE
38    
39     Int_t Ipa;
40     Float_t X0, Y0, Z0, Theta, Phi, P0;
41    
42     TChain * h20 = new TChain("h20");
43    
44     //TString Filename = "ele_5-6_n2.Beam.root";
45    
46     TString HOME=gSystem->Getenv("HOME");
47    
48     TSystemDirectory *readdir=new TSystemDirectory("readdir",HOME+"/RES");
49    
50     // TList * list = readdir->GetListOfFiles();
51    
52     h20->Add(HOME+"/RES/ele_r1_5-6.Beam.root");
53     h20->Add(HOME+"/RES/ele_r2_5-6.Beam.root");
54     h20->Add(HOME+"/RES/ele_r3_5-6.Beam.root");
55     // h20->Add(HOME+"/RES/ele_n4_5-6.Beam.root");
56     //if (list->FindObject(Filename) ){
57     // cout<< Filename<<" found..."<<endl;
58     // TFile* inpf = new TFile(HOME+"/RES/"+Filename);
59    
60     //h20 = (Te*)inpf->Get("h20");
61     if (h20->GetBranch("Ipa")){
62     h20->SetBranchAddress("Ipa",&Ipa);
63     h20->SetBranchStatus("Ipa",1);
64     }
65     if (h20->GetBranch("X0")){
66     h20->SetBranchAddress("X0",&X0);
67     h20->SetBranchStatus("X0",1);
68     }
69     if (h20->GetBranch("Y0")){
70     h20->SetBranchAddress("Y0",&Y0);
71     h20->SetBranchStatus("Y0",1);
72     }
73     if (h20->GetBranch("Z0")){
74     h20->SetBranchAddress("Z0",&Z0);
75     h20->SetBranchStatus("Z0",1);
76     }
77     if (h20->GetBranch("P0")){
78     h20->SetBranchAddress("P0",&P0);
79     h20->SetBranchStatus("P0",1);
80     }
81     if (h20->GetBranch("Theta")){
82     h20->SetBranchAddress("Theta",&Theta);
83     h20->SetBranchStatus("Theta",1);
84     }
85     if (h20->GetBranch("Phi")){
86     h20->SetBranchAddress("Phi",&Phi);
87     h20->SetBranchStatus("Phi",1);
88     }
89    
90    
91     Int_t nevents = (Int_t)h20->GetEntries();
92    
93     // nevents = 200;
94     cout<<"PROCESS "<<nevents<<" EVENTS"<<endl;
95    
96     TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(kElectron); //correct
97     Double_t mass = particlePDG->Mass();
98     Double_t PX, PY, PZ;
99     for (Int_t i=0; i<nevents; i++){
100     h20->GetEntry(i);
101     appl->GetPrimaryGenerator()->SetKinEnergy(sqrt(P0*P0+mass*mass)-mass);
102     cout<<"EKIN "<<appl->GetPrimaryGenerator()->GetKinEnergy()<<" GeV"<<endl;
103     //cout<<"RIG "<<appl->GetPrimaryGenerator()->GetRigidity()<<" GV"<<endl;
104     PX=P0*sin(Theta)*cos(Phi);
105     PY=P0*sin(Theta)*sin(Phi);
106     PZ=-P0*cos(Theta);
107     cout<<"(PX0,PY0,PZ0)="<<PX<<","<<PY<<","<<PZ<<endl;
108     appl->GetPrimaryGenerator()->SetDirection(PX,PY,PZ);
109     cout<<"(X0,Y0,Z0)"<<X0<<","<<Y0<<","<<Z0<<endl;
110     appl->GetPrimaryGenerator()->SetPosition(X0,Y0,Z0);
111    
112    
113     appl->RunMC(1);
114    
115     }
116    
117    
118     // Visualization settings
119     // ((TGeant4*)gMC)->ProcessGeantMacro("g4vis.in");
120     // inpf.cd();
121     // delete inpf;
122     // Run MC
123     // appl->RunMC(1000);
124     appl->FinishRun();
125     // ((TGeant4*)gMC)->StartGeantUI();
126     // delete appl;
127    
128     }

  ViewVC Help
Powered by ViewVC 1.1.23