Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Fun4Pythia8Demo.C
Go to the documentation of this file.
1 #include <iostream>
2 using namespace std;
3 
5  const int nEvents = 1
6  )
7 {
8  const bool use_pythia8 = true; //enable ptyiha8
9  const bool use_gun = false; // enable particle gun
10 
12 
13  if(use_pythia8) {
14  gSystem->Load("libPHPythia8.so");
15 
17 
19  PHPythia8 *pythia8 = new PHPythia8();
20  pythia8->set_config_file("phpythia8_DY.cfg");
21  //pythia8->set_vertex_distribution_width(0,0,10,0)
22  se->registerSubsystem(pythia8);
23 
26  trigger->AddParticles("13,-13");
27  pythia8->register_trigger(trigger);
28 
30  HepMCNodeReader *hr = new HepMCNodeReader();
31  se->registerSubsystem(hr);
32  }
34 
35  // particle gun
36  if(use_gun) {
37  PHG4ParticleGun *gun = new PHG4ParticleGun("PGUN");
38  gun->set_name("proton");
39  gun->set_vtx(0, 0, 0);
40  gun->set_mom(0, 0, 120);
41  se->registerSubsystem(gun);
42  }
43 
44  gSystem->Load("libg4testbench");
45  PHG4Reco *g4Reco = new PHG4Reco();
46  g4Reco->SetWorldSizeX(200);
47  g4Reco->SetWorldSizeY(200);
48  g4Reco->SetWorldSizeZ(200);
49  // shape of our world - it is a tube
50  g4Reco->SetWorldShape("G4BOX");
51  // this is what our world is filled with
52  g4Reco->SetWorldMaterial("G4_Galactic");
53  // Geant4 Physics list to use
54  g4Reco->SetPhysicsList("FTFP_BERT");
55 
57  g4Reco->registerSubsystem(truth);
58 
59  se->registerSubsystem(g4Reco);
60 
63 
64  Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", "DST.root");
66 
67  //Convert DST to human command readable TTree for quick poke around the outputs
68  gSystem->Load("libg4eval");
69  PHG4DSTReader *ana = new PHG4DSTReader(string("DSTReader.root"));
70  ana->set_save_particle(true);
71  ana->set_load_all_particle(false);
72  ana->set_load_active_particle(true);
73  ana->set_save_vertex(true);
74  //ana->AddNode("PHHepMCGenEvent");
75  se->registerSubsystem(ana);
76 
77  //-----------------
78  // Event processing
79  //-----------------
80 
81  se->run(nEvents);
82 
83  //-----
84  // Exit
85  //-----
86 
87  se->End();
88  std::cout << "All done" << std::endl;
89  delete se;
90  gSystem->Exit(0);
91 }
int registerInputManager(Fun4AllInputManager *InManager)
virtual int End()
Runs G4 as a subsystem.
Definition: PHG4Reco.h:38
void set_load_all_particle(bool b)
Definition: PHG4DSTReader.h:73
void AddParticles(std::string particles)
PHG4DSTReader save information from DST to an evaluator, which could include hit. particle...
Definition: PHG4DSTReader.h:39
void SetWorldMaterial(const std::string &s)
Definition: PHG4Reco.h:118
void SetWorldShape(const std::string &s)
Definition: PHG4Reco.h:117
static Fun4AllServer * instance()
Fun4AllServer * se
int Fun4Pythia8Demo(const int nEvents=1)
int registerSubsystem(SubsysReco *subsystem, const std::string &topnodename="TOP")
void set_config_file(const char *cfg_file)
Definition: PHPythia8.h:46
int run(const int nevnts=0, const bool require_nevents=false)
run n events (0 means up to end of file)
int registerOutputManager(Fun4AllOutputManager *manager)
void set_save_vertex(bool b)
Switch for vertex.
Definition: PHG4DSTReader.h:94
void set_save_particle(bool b)
Switch for saving any particles at all.
Definition: PHG4DSTReader.h:87
void ana()
Definition: ana.C:291
void SetWorldSizeX(const double sx)
Definition: PHG4Reco.h:111
void SetPhysicsList(const std::string &s)
Definition: PHG4Reco.h:119
virtual void set_vtx(const double x, const double y, const double z)
void set_load_active_particle(bool b)
load all particle that produced a saved hit
Definition: PHG4DSTReader.h:80
void register_trigger(PHPy8GenTrigger *theTrigger)
set event selection criteria
Definition: PHPythia8.C:303
virtual void set_name(const std::string &particle="proton")
virtual void set_mom(const double x, const double y, const double z)
void registerSubsystem(PHG4Subsystem *subsystem)
register subsystem
Definition: PHG4Reco.h:65
void SetWorldSizeZ(const double sz)
Definition: PHG4Reco.h:113
void SetWorldSizeY(const double sy)
Definition: PHG4Reco.h:112