// $Id: run_g4.C,v 1.0 2007/06/01 // // Macro for running G4PAM_VMC with Geant4. void PamG4Libs_granular(); #include #include #include #include #include #include #include void run_sim_g4(const TString& configMacro = "g4Config.C", const TString& primfile = "prim.root") { cout<<"PRIMFILE: "<SetBranchAddress("PRIM", &p); PamG4Libs(); // Load this example libraries TString PAM_VMC=gSystem->Getenv("PAM_VMC"); TString PLAT=gSystem->Getenv("PLATFORM"); // MC application TString outname="."; outname+="/"; outname+=primfile; outname.Replace(0,outname.Index("prim_",0),""); outname.Replace(outname.Index(".root",0),5,"_sim"); cout<<"OUTNAME="<InitMC(G4ConfMacro); cout<<"MACRO READED"<SetMaxNStep(50000); Int_t nevents = primtree->GetEntries(); ; //MAIN LOOP Double_t x,y,z,theta,phi,momentum; Int_t pdg; for(Int_t i = 0; iGetEntry(i); x = p->X0; y = p->Y0; z = p->Z0; theta = p->Theta; phi = p->Phi; pdg = p->PDG; momentum = p->P0; cout<<"EVENT: "<GetPrimaryGenerator()->SetParticle(pdg); appl->GetPrimaryGenerator()->SetDirection(theta,phi); appl->GetPrimaryGenerator()->SetMomentum(momentum); appl->GetPrimaryGenerator()->SetPosition(x,y,z); appl->RunMC(1); } appl->FinishRun(); // delete appl; }