Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:24:00

0001 #ifndef MACRO_G4ACTSGEOM_C
0002 #define MACRO_G4ACTSGEOM_C
0003 
0004 // GlobalVariables.C has to be first, an empty line afterwards
0005 // protects its position against reshuffling by clang-format
0006 #include <GlobalVariables.C>
0007 
0008 #include <G4_Magnet.C>
0009 #include <G4_TrkrVariables.C>  // for Enable::MVTX_APPLYMISALIGNMENT, INTT_USEG4SURVEYGEOM
0010 
0011 #pragma GCC diagnostic push
0012 #pragma GCC diagnostic ignored "-Wundefined-internal"
0013 #include <trackreco/MakeActsGeometry.h>
0014 #pragma GCC diagnostic pop
0015 
0016 #include <fun4all/Fun4AllServer.h>
0017 
0018 #include <Rtypes.h>  // for R__LOAD_LIBRARY
0019 
0020 R__LOAD_LIBRARY(libg4eval.so)
0021 R__LOAD_LIBRARY(libtrack_reco.so)
0022 R__LOAD_LIBRARY(libtpccalib.so)
0023 
0024 namespace ACTSGEOM
0025 {
0026 
0027   unsigned int mvtxMisalignment = 1;
0028   unsigned int inttMisalignment = 1;
0029   unsigned int tpcMisalignment = 1;
0030   unsigned int tpotMisalignment = 1;
0031 
0032   bool mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0033   bool inttsurvey = Enable::INTT_USEG4SURVEYGEOM;
0034 
0035   void ActsGeomInit()
0036   {
0037     static bool wasCalled = false;
0038     if (wasCalled)
0039     {
0040       return;
0041     }
0042     wasCalled = true;
0043 
0044     if (!Enable::MICROMEGAS)
0045     {
0046       G4MICROMEGAS::n_micromegas_layer = 0;
0047     }
0048     ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0049     MagnetFieldInit();
0050 
0051     // Build the Acts geometry
0052     auto *se = Fun4AllServer::instance();
0053     int verbosity = Enable::VERBOSITY;
0054 
0055     // Geometry must be built before any Acts modules
0056     MakeActsGeometry *geom = new MakeActsGeometry();
0057     geom->set_drift_velocity(G4TPC::tpc_drift_velocity_reco);
0058     geom->set_apply_tpc_tzero_correction(G4TPC::apply_tpc_tzero_correction);  // set true to apply tpc tzero correction
0059     geom->set_tpc_tzero(G4TPC::tpc_tzero_reco);
0060     geom->set_sampa_tzero_bias(G4TPC::sampa_tzero_bias);
0061     std::cout << "G4_ActsGeom: " << std::endl;
0062     std::cout << "     Setting apply_tpc_tzero_correction flag to " << G4TPC::apply_tpc_tzero_correction << std::endl;
0063     std::cout << "     Setting tpc_tzero_reco to " << G4TPC::tpc_tzero_reco << std::endl;
0064     std::cout << "     Setting sampa_tzero_bias to " << G4TPC::sampa_tzero_bias << std::endl;
0065     std::cout << "     Setting tpc_drift_velocity_reco to " << G4TPC::tpc_drift_velocity_reco << std::endl;
0066     geom->Verbosity(verbosity);
0067     for (int i = 0; i < 57; i++)
0068     {
0069       if (i < 3)
0070       {
0071         geom->misalignmentFactor(i, ACTSGEOM::mvtxMisalignment);
0072       }
0073       else if (i < 7)
0074       {
0075         geom->misalignmentFactor(i, ACTSGEOM::inttMisalignment);
0076       }
0077       else if (i < 55)
0078       {
0079         geom->misalignmentFactor(i, ACTSGEOM::tpcMisalignment);
0080       }
0081       else
0082       {
0083         geom->misalignmentFactor(i, ACTSGEOM::tpotMisalignment);
0084       }
0085     }
0086 
0087     geom->loadMagField(G4TRACKING::init_acts_magfield);
0088     geom->setMagField(G4MAGNET::magfield_tracking);
0089     geom->setMagFieldRescale(G4MAGNET::magfield_rescale);
0090     std::cout << "ActsGeomInit: Mvtx apply misalignment? ACTSGEOM::mvtx_applymisalignment=" << ACTSGEOM::mvtx_applymisalignment << std::endl;
0091     geom->set_mvtx_applymisalign(ACTSGEOM::mvtx_applymisalignment);
0092     std::cout << "ActsGeomInit: Use survey geometry? ACTSGEOM::inttsurvey=" << ACTSGEOM::inttsurvey << std::endl;
0093     geom->set_intt_survey(ACTSGEOM::inttsurvey);
0094     se->registerSubsystem(geom);
0095   }
0096 }  // namespace ACTSGEOM
0097 
0098 #endif