Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-08-31 08:14:22

0001 #ifndef MACRO_FUN4ALL_G4_SPHENIX_HEPMC_C
0002 #define MACRO_FUN4ALL_G4_SPHENIX_HEPMC_C
0003 
0004 #include <GlobalVariables.C>
0005 
0006 #include "G4Setup_sPHENIX.C"
0007 
0008 #include <G4_Global.C>
0009 #include <G4_Input.C>
0010 #include <G4_Mbd.C>
0011 
0012 #include "./G4_TrkrSimulation.C"
0013 #include <Trkr_Clustering.C>
0014 #include <Trkr_LaserClustering.C>
0015 #include <Trkr_Reco.C>
0016 #include <Trkr_RecoInit.C>
0017 
0018 #include <ffamodules/CDBInterface.h>
0019 #include <ffamodules/FlagHandler.h>
0020 #include <ffamodules/HeadReco.h>
0021 #include <ffamodules/SyncReco.h>
0022 
0023 #include <fun4all/Fun4AllDstOutputManager.h>
0024 #include <fun4all/Fun4AllServer.h>
0025 
0026 #include <phool/PHRandomSeed.h>
0027 #include <phool/recoConsts.h>
0028 
0029 #include <trackreco/PHTruthVertexing.h>
0030 
0031 #include <vertexcompare/VertexCompare.h>
0032 
0033 #include <Rtypes.h>
0034 #include <TSystem.h>
0035 
0036 #include <iostream>
0037 #include <string>
0038 
0039 R__LOAD_LIBRARY(libfun4all.so)
0040 R__LOAD_LIBRARY(libffamodules.so)
0041 R__LOAD_LIBRARY(libg4eval.so)
0042 R__LOAD_LIBRARY(libVertexCompare.so)
0043 
0044 /**
0045  * Full sPHENIX simulation and standard reconstruction from a HepMC2 file.
0046  *
0047  * Chain:
0048  *   HepMC2
0049  *     -> PHHepMCGenEventMap
0050  *     -> HepMCNodeReader
0051  *     -> Geant4 detector simulation
0052  *     -> standard detector digitization
0053  *     -> standard clustering
0054  *     -> standard tracking reconstruction
0055  *     -> global vertex reconstruction
0056  *     -> VertexCompare analysis ntuple
0057  *     -> unfiltered DST
0058  *
0059  * Example:
0060  *
0061  * root -b -q \
0062  * 'Fun4All_G4_sPHENIX_HepMC.C(
0063  *    10,
0064  *    "oo200_hepmc2.hepmc",
0065  *    "DST_OO200_Angantyr.root",
0066  *    "VertexCompare_OO200_Angantyr.root",
0067  *    0,
0068  *    0,
0069  *    false)'
0070  */
0071 int Fun4All_G4_sPHENIX_HepMC(                                                                                                                                       //
0072     const int nEvents = 5,                                                                                                                                          //
0073     const std::string &inputFile = "/sphenix/tg/tg01/hf/hjheng/ppg-dNdEta-OOpp/generator/pythia_angantyr/Gaussian/hepmc/oo200gev_angantyr_Gaussian_00000000.hepmc", //
0074     const std::string &dstOutputFile = "DST_OO200_Angantyr_test.root",                                                                                              //
0075     const std::string &analysisOutputFile = "VertexCompare_OO200_Angantyr_test.root",                                                                               //
0076     const int process = 0,                                                                                                                                          //
0077     const int skip = 0,                                                                                                                                             //
0078     const bool inputIsList = false                                                                                                                                  //
0079 )
0080 {
0081     Fun4AllServer *se = Fun4AllServer::instance();
0082     se->Verbosity(0);
0083 
0084     PHRandomSeed::Verbosity(1);
0085     CDBInterface::instance()->Verbosity(1);
0086 
0087     recoConsts *rc = recoConsts::instance();
0088 
0089     Enable::CDB = true;
0090     rc->set_StringFlag("CDB_GLOBALTAG", CDB::global_tag);
0091     rc->set_uint64Flag("TIMESTAMP", CDB::timestamp);
0092     rc->set_IntFlag("RUNNUMBER", 1);
0093     rc->set_IntFlag("RANDOMSEED", process + 12345);
0094 
0095     // --------------------------------------------------------------------------
0096     // HepMC input
0097     // --------------------------------------------------------------------------
0098     Input::VERBOSITY = 0;
0099 
0100     Input::HEPMC = true;
0101     Input::READHITS = false;
0102     Input::EMBED = false;
0103     Input::PILEUPRATE = 0.0;
0104 
0105     // Use the central sPHENIX O+O beam and collision-vertex configuration
0106     Input::BEAM_CONFIGURATION = Input::OO_COLLISION;
0107 
0108     INPUTHEPMC::filename.clear();
0109     INPUTHEPMC::listfile.clear();
0110 
0111     if (inputIsList)
0112     {
0113         INPUTHEPMC::listfile = inputFile;
0114     }
0115     else
0116     {
0117         INPUTHEPMC::filename = inputFile;
0118     }
0119 
0120     // Do not apply generator-specific afterburners to the Angantyr record
0121     INPUTHEPMC::HIJINGFLIP = false;
0122     INPUTHEPMC::FLOW = false;
0123     INPUTHEPMC::FERMIMOTION = false;
0124     INPUTHEPMC::REACTIONPLANERAND = false;
0125     INPUTHEPMC::HEPMC_STRANGENESS_FRACTION = -1.0;
0126 
0127     // Creates Fun4AllHepMCInputManager
0128     InputInit();
0129 
0130     // Apply the standard O+O beam crossing and collision-vertex distribution
0131     Input::ApplysPHENIXBeamParameter(INPUTMANAGER::HepMCInputManager);
0132 
0133     // Registers HepMCNodeReader, which copies particles from HepMC to Geant4
0134     InputRegister();
0135 
0136     // Standard event and run headers for generator input
0137     SyncReco *sync = new SyncReco();
0138     se->registerSubsystem(sync);
0139 
0140     HeadReco *head = new HeadReco();
0141     se->registerSubsystem(head);
0142 
0143     FlagHandler *flag = new FlagHandler();
0144     se->registerSubsystem(flag);
0145 
0146     // --------------------------------------------------------------------------
0147     // Detector configuration
0148     // --------------------------------------------------------------------------
0149     Enable::MBD = true;
0150     Enable::MBDRECO = true;
0151     Enable::MBDFAKE = false;
0152 
0153     Enable::PIPE = true;
0154     Enable::PIPE_ABSORBER = true;
0155 
0156     Enable::MVTX = true;
0157     Enable::INTT = true;
0158     Enable::TPC = true;
0159     Enable::MICROMEGAS = true;
0160 
0161     Enable::BEAMLINE = true;
0162 
0163     // Standard detector hit reconstruction.
0164     Enable::MVTX_CELL = true;
0165     Enable::INTT_CELL = true;
0166     Enable::TPC_CELL = true;
0167     Enable::MICROMEGAS_CELL = true;
0168 
0169     // Standard clustering.
0170     Enable::MVTX_CLUSTER = true;
0171     Enable::INTT_CLUSTER = true;
0172     Enable::TPC_CLUSTER = true;
0173     Enable::MICROMEGAS_CLUSTER = true;
0174 
0175     // Standard full tracking and global reconstruction.
0176     Enable::TRACKING_TRACK = true;
0177     Enable::GLOBAL_RECO = true;
0178 
0179     // This sample contains one in-time O+O collision per HepMC event.
0180     TRACKING::streaming_mode = false;
0181 
0182     // --------------------------------------------------------------------------
0183     // Geant4 detector simulation
0184     // --------------------------------------------------------------------------
0185     G4Init();
0186     G4Setup();
0187 
0188     // --------------------------------------------------------------------------
0189     // Standard detector reconstruction
0190     // --------------------------------------------------------------------------
0191     if (Enable::MBD && Enable::MBDRECO)
0192     {
0193         Mbd_Reco();
0194     }
0195 
0196     if (Enable::MVTX_CELL)
0197     {
0198         Mvtx_Cells();
0199     }
0200 
0201     if (Enable::INTT_CELL)
0202     {
0203         Intt_Cells();
0204     }
0205 
0206     if (Enable::TPC_CELL)
0207     {
0208         TPC_Cells();
0209     }
0210 
0211     if (Enable::MICROMEGAS_CELL)
0212     {
0213         Micromegas_Cells();
0214     }
0215 
0216     if (Enable::TRACKING_TRACK)
0217     {
0218         TrackingInit();
0219     }
0220 
0221     if (Enable::MVTX_CLUSTER)
0222     {
0223         Mvtx_Clustering();
0224     }
0225 
0226     if (Enable::INTT_CLUSTER)
0227     {
0228         Intt_Clustering();
0229     }
0230 
0231     if (Enable::TPC_CLUSTER)
0232     {
0233         if (G4TPC::ENABLE_DIRECT_LASER_HITS || G4TPC::ENABLE_CENTRAL_MEMBRANE_HITS)
0234         {
0235             TPC_LaserClustering();
0236         }
0237         else
0238         {
0239             TPC_Clustering();
0240         }
0241     }
0242 
0243     if (Enable::MICROMEGAS_CLUSTER)
0244     {
0245         Micromegas_Clustering();
0246     }
0247 
0248     if (Enable::TRACKING_TRACK)
0249     {
0250         // Central sPHENIX tracking wrapper:
0251         // silicon seeding, TPC seeding, matching, track fitting, cleaning,
0252         // track vertexing, and track propagation.
0253         Tracking_Reco();
0254     }
0255 
0256     if (Enable::GLOBAL_RECO)
0257     {
0258         Global_Reco();
0259     }
0260 
0261     // Truth vertex map used by the simulation analysis.
0262     PHTruthVertexing *truthVertexing = new PHTruthVertexing();
0263     truthVertexing->associate_tracks(false);
0264     se->registerSubsystem(truthVertexing);
0265 
0266     // --------------------------------------------------------------------------
0267     // User analysis module
0268     // --------------------------------------------------------------------------
0269     VertexCompareVerbosity::fillSilconSeed = 0;
0270     VertexCompareVerbosity::fillCluster = 0;
0271     VertexCompareVerbosity::fillTruthParticle = 0;
0272 
0273     VertexCompare *compare = new VertexCompare();
0274     compare->IsSimulation();
0275     compare->doTrackOutput();
0276     compare->doTpcSeedOutput();
0277     compare->setOutputName(analysisOutputFile.c_str());
0278     se->registerSubsystem(compare);
0279 
0280     // --------------------------------------------------------------------------
0281     // Input manager and DST output
0282     // --------------------------------------------------------------------------
0283     InputManagers();
0284 
0285     Fun4AllDstOutputManager *dstOutput = new Fun4AllDstOutputManager("DSTOUT", dstOutputFile);
0286     se->registerOutputManager(dstOutput);
0287 
0288     // --------------------------------------------------------------------------
0289     // Event processing
0290     // --------------------------------------------------------------------------
0291     if (nEvents < 0)
0292     {
0293         return 0;
0294     }
0295 
0296     se->skip(skip);
0297     se->run(nEvents);
0298 
0299     CDBInterface::instance()->Print();
0300 
0301     se->End();
0302     se->PrintTimer();
0303 
0304     std::cout << "Fun4All_G4_sPHENIX_HepMC completed." << std::endl;
0305     std::cout << "DST:      " << dstOutputFile << std::endl;
0306     std::cout << "Analysis: " << analysisOutputFile << std::endl;
0307 
0308     delete se;
0309 
0310     gSystem->Exit(0);
0311     return 0;
0312 }
0313 
0314 #endif