File indexing completed on 2025-08-05 08:11:05
0001 int Fun4All_G4_Calos(const int nEvents = 10, const char * outfile = NULL)
0002 {
0003
0004 gSystem->Load("libfun4all");
0005 gSystem->Load("libg4detectors.so");
0006 gSystem->Load("libg4testbench.so");
0007
0008
0009
0010
0011 Fun4AllServer *se = Fun4AllServer::instance();
0012 se->Verbosity(0);
0013
0014
0015
0016 PHG4ParticleGenerator *gen = new PHG4ParticleGenerator("PGENERATOR");
0017 int uniqueseed = TRandom3(0).GetSeed();
0018 recoConsts *rc = recoConsts::instance();
0019 rc->set_IntFlag("RANDOMSEED", 12345);
0020
0021
0022 gen->set_name("proton");
0023 gen->set_vtx(0, 0, 0);
0024 gen->set_eta_range(-0.05, +0.05);
0025 gen->set_mom_range(0.4, 10.0);
0026 gen->set_phi_range(0., 90. / 180.*TMath::Pi());
0027
0028 PHG4ParticleGun *gun = new PHG4ParticleGun();
0029
0030 gun->set_name("anti_sigma+");
0031 gun->set_vtx(0, 0, 0);
0032 gun->set_mom(10, 0, 0.01);
0033
0034
0035
0036
0037 se->registerSubsystem(gun);
0038
0039
0040 PHG4Reco* g4Reco = new PHG4Reco();
0041 g4Reco->SetWorldMaterial("G4_Galactic");
0042
0043
0044 double calorad[3] = {90.,116.,178.};
0045 PHG4CylinderSubsystem *cyl;
0046
0047 for (int ilayer = 0; ilayer < 3; ilayer++)
0048 {
0049 cyl = new PHG4CylinderSubsystem("CALO", ilayer);
0050 cyl->set_double_param("radius",calorad[ilayer]);
0051 cyl->set_string_param("material","G4_Galactic");
0052 cyl->set_double_param("thickness",0.001);
0053 cyl->SetActive();
0054 cyl->SuperDetector("CALO");
0055 g4Reco->registerSubsystem( cyl );
0056 }
0057 PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
0058 g4Reco->registerSubsystem(truth);
0059
0060 se->registerSubsystem( g4Reco );
0061 if (0)
0062 {
0063
0064 PHG4DSTReader* ana = new PHG4DSTReader(
0065 string(outfile) + string("_DSTReader.root"));
0066 ana->set_save_particle(true);
0067 ana->set_load_all_particle(false);
0068 ana->set_load_active_particle(true);
0069 ana->set_save_vertex(true);
0070 if (nEvents > 0 && nEvents < 2)
0071 {
0072 ana->Verbosity(2);
0073 }
0074 ana->AddNode("box_0");
0075 se->registerSubsystem(ana);
0076 }
0077
0078 if (outfile)
0079 {
0080 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT",outfile);
0081 se->registerOutputManager(out);
0082 }
0083 Fun4AllInputManager *in = new Fun4AllDummyInputManager( "JADE");
0084 se->registerInputManager( in );
0085
0086
0087 if (nEvents > 0)
0088 {
0089 se->run(nEvents);
0090
0091 se->End();
0092 std::cout << "All done" << std::endl;
0093
0094
0095 delete se;
0096 gSystem->Exit(0);
0097 }
0098
0099 }
0100
0101 PHG4ParticleGenerator *get_gen(const char *name="PGENERATOR")
0102 {
0103 Fun4AllServer *se = Fun4AllServer::instance();
0104 PHG4ParticleGenerator *pgun = (PHG4ParticleGenerator *) se->getSubsysReco(name);
0105 return pgun;
0106 }