Back to home page

sPhenix code displayed by LXR

 
 

    


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   // Make the Server
0010   //////////////////////////////////////////
0011   Fun4AllServer *se = Fun4AllServer::instance();
0012   se->Verbosity(0);
0013 
0014   // PHG4ParticleGenerator generates particle
0015   // distributions in eta/phi/mom range
0016   PHG4ParticleGenerator *gen = new PHG4ParticleGenerator("PGENERATOR");
0017   int uniqueseed = TRandom3(0).GetSeed();
0018   recoConsts *rc = recoConsts::instance();
0019   rc->set_IntFlag("RANDOMSEED", 12345);
0020   //  gen->set_seed(uniqueseed);
0021   //gen->set_name("gamma");
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()); // 0-90 deg
0027   //  se->registerSubsystem(gen);
0028   PHG4ParticleGun *gun = new PHG4ParticleGun();
0029   //  gun->set_name("anti_proton");
0030   gun->set_name("anti_sigma+");
0031   gun->set_vtx(0, 0, 0);
0032   gun->set_mom(10, 0, 0.01);
0033   // gun->AddParticle("geantino",1.7776,-0.4335,0.);
0034   // gun->AddParticle("geantino",1.7709,-0.4598,0.);
0035   // gun->AddParticle("geantino",2.5621,0.60964,0.);
0036   // gun->AddParticle("geantino",1.8121,0.253,0.);
0037   se->registerSubsystem(gun);
0038 
0039 
0040   PHG4Reco* g4Reco = new PHG4Reco();
0041   g4Reco->SetWorldMaterial("G4_Galactic");
0042 //  g4Reco->set_field(1.5); // 1.5 T solenoidal field 
0043 
0044   double calorad[3] = {90.,116.,178.};
0045   PHG4CylinderSubsystem *cyl;
0046   // here is our silicon:
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"); // combine all layers into one node
0055       g4Reco->registerSubsystem( cyl );
0056     }
0057   PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
0058   g4Reco->registerSubsystem(truth);
0059 
0060   se->registerSubsystem( g4Reco );
0061   if (0)
0062     {
0063       // save a comprehensive  evaluation file
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       // finish job - close and save output files
0091       se->End();
0092       std::cout << "All done" << std::endl;
0093 
0094       // cleanup - delete the server and exit
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 }