Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // Fun4All_HepMCReadTest.C
0002 // Minimal validation: read a HepMC2 ASCII file through the standard sPHENIX
0003 // input manager and dump the PHHepMCGenEventMap node it fills.
0004 // Usage:  root -b -q 'Fun4All_HepMCReadTest.C("oo200_hepmc2.hepmc", 10)'
0005 
0006 #include <TSystem.h>
0007 #include <fun4all/Fun4AllInputManager.h>
0008 #include <fun4all/Fun4AllServer.h>
0009 #include <nodedump/Dumper.h>
0010 #include <phhepmc/Fun4AllHepMCInputManager.h>
0011 
0012 R__LOAD_LIBRARY(libfun4all.so)
0013 R__LOAD_LIBRARY(libphhepmc.so)
0014 R__LOAD_LIBRARY(libphnodedump.so)
0015 
0016 void Fun4All_HepMCReadTest(                                                                                                           //
0017     const std::string &infile = "/sphenix/user/hjheng/sPHENIXRepo/generator_OO200GeV/Pythia_Angantyr/pythia8317/examples/test.hepmc", //
0018     const int nEvents = 10                                                                                                            //
0019 )
0020 {
0021     Fun4AllServer *se = Fun4AllServer::instance();
0022     se->Verbosity(INT_MAX);
0023 
0024     // Same construction as the official G4_Input.C. The manager itself creates
0025     // the PHHepMCGenEventMap node and inserts one PHHepMCGenEvent per event.
0026     Fun4AllHepMCInputManager *in = new Fun4AllHepMCInputManager("HEPMCin");
0027     in->Verbosity(2); // set to 4 to print every parsed HepMC event in full
0028     in->AddFile(infile);
0029     se->registerInputManager(in);
0030 
0031     // Zero-custom-code content check: the standard NodeDump module, restricted
0032     // to the one node we care about. Writes one dump file per event to OutDir.
0033     Dumper *dumper = new Dumper("HEPMCDUMP");
0034     dumper->Select("PHHepMCGenEventMap");
0035     dumper->SetOutDir(".");
0036     se->registerSubsystem(dumper);
0037 
0038     se->run(nEvents);
0039     se->End();
0040     delete se;
0041 
0042     std::cout << "Fun4All_HepMCReadTest: done." << std::endl;
0043 
0044     gSystem->Exit(0);
0045 }