Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:06

0001 /**
0002 QEvt_Lifecycle_Test.cc
0003 =========================
0004 
0005 ~/o/qudarap/tests/QEvt_Lifecycle_Test.sh
0006 
0007 
0008 **/
0009 
0010 #include <csignal>
0011 #include "OPTICKS_LOG.hh"
0012 #include "ssys.h"
0013 #include "SEventConfig.hh"
0014 #include "SEvt.hh"
0015 #include "QEvt.hh"
0016 
0017 struct QEvt_Lifecycle_Test
0018 {
0019     static int EventLoop();
0020 };
0021 
0022 /**
0023 QEvt_Lifecycle_Test::EventLoop
0024 -------------------------------------
0025 
0026 Comments are from an input photon centric viewpoint
0027 as those are useful for debugging.
0028 
0029 **/
0030 
0031 int QEvt_Lifecycle_Test::EventLoop()
0032 {
0033     SEvt* sev = SEvt::Create_EGPU() ;
0034     // instanciation may load input_photons if configured
0035     assert( sev );
0036 
0037     sev->setFramePlaceholder();
0038     // calls SEvt::setFrame which
0039     // for non-placeholder frame might transform the input photons
0040     // using the frame transform
0041 
0042 
0043 
0044     QEvt* event = new QEvt ; // grabs SEvt::EGPU
0045 
0046     int num_event = SEventConfig::NumEvent() ;
0047     std::cout << " num_event " << num_event << std::endl ;
0048 
0049     for(int i = 0 ; i < num_event ; i++)
0050     {
0051         //std::cout << i << std::endl ;
0052         // follow pattern of QSim::simulate
0053 
0054         int eventID = i ;
0055 
0056         sev->beginOfEvent(eventID);
0057         // SEvt::beginOfEvent calls SEvt::setFrameGenstep which creates
0058         // the input photon genstep and calls SEvt::addGenstep
0059 
0060         NP* igs = sev->makeGenstepArrayFromVector();
0061         int rc = event->setGenstepUpload_NP(igs);
0062         assert( rc == 0 );
0063         if(rc!=0) std::raise(SIGINT);
0064 
0065         // IN REALITY THE LAUNCH WOULD BE HERE
0066         // propagating the photons, changing GPU side buffers
0067 
0068 
0069         sev->endOfEvent(eventID);
0070     }
0071     return 0 ;
0072 }
0073 
0074 int main(int argc, char** argv)
0075 {
0076     OPTICKS_LOG(argc, argv);
0077 
0078     /**
0079     HMM: might expect that using the lower level ssys::setenvvar
0080     would allow a setting that can be overriden from the script
0081     QEvt_Lifecycle_Test.sh : but that dont work for
0082     OPTICKS_INPUT_PHOTON as the SEventConfig statics run before the main does.
0083 
0084     Override from script  does work for GEOM because that is used as a plain envvar
0085     **/
0086 
0087     bool overwrite = false ;
0088     //ssys::setenvvar("OPTICKS_INPUT_PHOTON", "RainXZ_Z230_10k_f8.npy", overwrite );
0089     SEventConfig::SetInputPhoton("RainXZ_Z230_10k_f8.npy");
0090 
0091     ssys::setenvvar("GEOM", "TEST_CC", overwrite );
0092 
0093     return QEvt_Lifecycle_Test::EventLoop() ;
0094 }