Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:22:08

0001 #ifndef MACRO_FUN4ALLG4CYLINDER_C
0002 #define MACRO_FUN4ALLG4CYLINDER_C
0003 
0004 #include <fun4all/SubsysReco.h>
0005 #include <fun4all/Fun4AllServer.h>
0006 #include <fun4all/Fun4AllInputManager.h>
0007 #include <fun4all/Fun4AllDstOutputManager.h>
0008 #include <fun4all/Fun4AllOutputManager.h>
0009 #include <fun4all/Fun4AllDummyInputManager.h>
0010 #include <g4detectors/PHG4CylinderSubsystem.h>
0011 #include <g4eval/PHG4DSTReader.h>
0012 #include <g4main/PHG4ParticleGenerator.h>
0013 #include <g4main/PHG4Reco.h>
0014 #include <g4main/PHG4TruthSubsystem.h>
0015 #include <phool/recoConsts.h>
0016 
0017 R__LOAD_LIBRARY(libg4eval.so)
0018 R__LOAD_LIBRARY(libfun4all.so)
0019 R__LOAD_LIBRARY(libg4testbench.so)
0020 R__LOAD_LIBRARY(libg4detectors.so)
0021 
0022 int Fun4All_G4_Cylinder(const int nEvents = 10, const char * outfile = nullptr)
0023 {
0024 
0025   ///////////////////////////////////////////
0026   // Make the Server
0027   //////////////////////////////////////////
0028   Fun4AllServer *se = Fun4AllServer::instance();
0029   se->Verbosity(0);
0030 
0031   recoConsts *rc = recoConsts::instance();
0032 //  rc->set_IntFlag("RANDOMSEED", 12345); // if you want to use a fixed seed
0033   // PHG4ParticleGenerator generates particle
0034   // distributions in eta/phi/mom range
0035   PHG4ParticleGenerator *gen = new PHG4ParticleGenerator("PGENERATOR");
0036   //gen->set_name("gamma");
0037   gen->set_name("e+");
0038   gen->set_vtx(0, 0, 0);
0039   gen->set_eta_range(-0.05, +0.05);
0040   gen->set_mom_range(0.4, 10.0);
0041   gen->set_phi_range(0., 90. / 180.*TMath::Pi()); // 0-90 deg
0042   se->registerSubsystem(gen);
0043 
0044   PHG4Reco* g4Reco = new PHG4Reco();
0045   g4Reco->set_field(1.4); // 1.5 T solenoidal field 
0046 
0047 
0048   double si_thickness[6] = {0.02, 0.02, 0.0625, 0.032, 0.032, 0.032};
0049   double svxrad[6] = {2.71, 4.63, 11.765, 25.46, 41.38, 63.66};
0050   double length[6] = {20., 20., 36., -1., - 1., - 1.}; // -1 use eta coverage to determine length
0051   PHG4CylinderSubsystem *cyl;
0052   // here is our silicon:
0053    for (int ilayer = 0; ilayer < 6; ilayer++)
0054     {
0055       cyl = new PHG4CylinderSubsystem("SVTX", ilayer);
0056       cyl->set_double_param("radius",svxrad[ilayer]);
0057       cyl->set_string_param("material","G4_Si");
0058       cyl->set_double_param("thickness",si_thickness[ilayer]);
0059       cyl->SetActive();
0060       cyl->SuperDetector("SVTX");
0061       if (length[ilayer] > 0)
0062         {
0063           cyl->set_double_param("length",length[ilayer]);
0064         }
0065       g4Reco->registerSubsystem( cyl );
0066     }
0067   se->registerSubsystem( g4Reco );
0068 
0069   if (outfile)
0070     {
0071       Fun4AllOutputManager *out = new Fun4AllDstOutputManager("DSTOUT",outfile);
0072       se->registerOutputManager(out);
0073     }
0074   Fun4AllInputManager *in = new Fun4AllDummyInputManager( "JADE");
0075   se->registerInputManager( in );
0076 
0077 
0078   if (nEvents > 0)
0079     {
0080       se->run(nEvents);
0081       // finish job - close and save output files
0082       se->End();
0083       std::cout << "All done" << std::endl;
0084 
0085       // cleanup - delete the server and exit
0086       delete se;
0087       gSystem->Exit(0);
0088     }
0089   return 0;
0090 }
0091 
0092 PHG4ParticleGenerator *get_gen(const char *name="PGENERATOR")
0093 {
0094   Fun4AllServer *se = Fun4AllServer::instance();
0095   PHG4ParticleGenerator *pgun = (PHG4ParticleGenerator *) se->getSubsysReco(name);
0096   return pgun;
0097 }
0098 
0099 #endif