Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_G4_Calos.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_G4_Calos.C
1 int Fun4All_G4_Calos(const int nEvents = 10, const char * outfile = NULL)
2 {
3 
4  gSystem->Load("libfun4all");
5  gSystem->Load("libg4detectors.so");
6  gSystem->Load("libg4testbench.so");
7 
9  // Make the Server
12  se->Verbosity(0);
13 
14  // PHG4ParticleGenerator generates particle
15  // distributions in eta/phi/mom range
16  PHG4ParticleGenerator *gen = new PHG4ParticleGenerator("PGENERATOR");
17  int uniqueseed = TRandom3(0).GetSeed();
19  rc->set_IntFlag("RANDOMSEED", 12345);
20  // gen->set_seed(uniqueseed);
21  //gen->set_name("gamma");
22  gen->set_name("proton");
23  gen->set_vtx(0, 0, 0);
24  gen->set_eta_range(-0.05, +0.05);
25  gen->set_mom_range(0.4, 10.0);
26  gen->set_phi_range(0., 90. / 180.*TMath::Pi()); // 0-90 deg
27  // se->registerSubsystem(gen);
28  PHG4ParticleGun *gun = new PHG4ParticleGun();
29  // gun->set_name("anti_proton");
30  gun->set_name("anti_sigma+");
31  gun->set_vtx(0, 0, 0);
32  gun->set_mom(10, 0, 0.01);
33  // gun->AddParticle("geantino",1.7776,-0.4335,0.);
34  // gun->AddParticle("geantino",1.7709,-0.4598,0.);
35  // gun->AddParticle("geantino",2.5621,0.60964,0.);
36  // gun->AddParticle("geantino",1.8121,0.253,0.);
37  se->registerSubsystem(gun);
38 
39 
40  PHG4Reco* g4Reco = new PHG4Reco();
41  g4Reco->SetWorldMaterial("G4_Galactic");
42 // g4Reco->set_field(1.5); // 1.5 T solenoidal field
43 
44  double calorad[3] = {90.,116.,178.};
46  // here is our silicon:
47  for (int ilayer = 0; ilayer < 3; ilayer++)
48  {
49  cyl = new PHG4CylinderSubsystem("CALO", ilayer);
50  cyl->set_double_param("radius",calorad[ilayer]);
51  cyl->set_string_param("material","G4_Galactic");
52  cyl->set_double_param("thickness",0.001);
53  cyl->SetActive();
54  cyl->SuperDetector("CALO"); // combine all layers into one node
55  g4Reco->registerSubsystem( cyl );
56  }
58  g4Reco->registerSubsystem(truth);
59 
60  se->registerSubsystem( g4Reco );
61  if (0)
62  {
63  // save a comprehensive evaluation file
64  PHG4DSTReader* ana = new PHG4DSTReader(
65  string(outfile) + string("_DSTReader.root"));
66  ana->set_save_particle(true);
67  ana->set_load_all_particle(false);
68  ana->set_load_active_particle(true);
69  ana->set_save_vertex(true);
70  if (nEvents > 0 && nEvents < 2)
71  {
72  ana->Verbosity(2);
73  }
74  ana->AddNode("box_0");
75  se->registerSubsystem(ana);
76  }
77 
78  if (outfile)
79  {
81  se->registerOutputManager(out);
82  }
84  se->registerInputManager( in );
85 
86 
87  if (nEvents > 0)
88  {
89  se->run(nEvents);
90  // finish job - close and save output files
91  se->End();
92  std::cout << "All done" << std::endl;
93 
94  // cleanup - delete the server and exit
95  delete se;
96  gSystem->Exit(0);
97  }
98 
99 }
100 
101 PHG4ParticleGenerator *get_gen(const char *name="PGENERATOR")
102 {
105  return pgun;
106 }