/////////////////////////////////////////////////////////////////// // // Base class for classes which create events and pass them through a // block of processors. // // A Producer creates new events and then passes them to the main // block of processors for analysis. Unlike a Processor, a // Producer does not operate upon existing events, but constructs // them in memory, extracting them from various sources like files, the // network, or the void (as good a description of Monte Carlo as // any). // // The event loop is controlled by a Producer, and initiated by // the user in response to a some command. This is why Producer // inherits from G4UImessenger. If you make a new producer // subclass, you will need to create some instances of G4UIcommand in // your constructor so that users can start your producer running in // their macros. See InROOTProducer for an example of this. // (Note that Gsim is a special producer which is wired into // GEANT4's event management loop, so it is unusual in this respect.) // // Another consideration for producers is graceful handling of a // user's Ctrl-C termination request. If a user presses Ctrl-C once, // execution is not interrupted, but a flag is set and can be // retrieved from SignalHandler::IsTermRequested(). This gives // the currently running producer a chance to let the current event // finish and then terminate the event loop. Your implementation of // the event loop should probably look something like this: // // for (Int_t i=0; i < num_events && !SignalHandler::IsTermRequested(); i++) { // // Create/Retrieve the i'th event // mainBlock->DSEvent(ds); // } // // All producers will be constructed once in the main() function and // destroyed at the end of program execution. If you create a new // Producer, be sure to edit main() accordingly. // // Author: Stan Seibert // // REVISION HISTORY: // 2013-12-14 : P G Jones - Added BeginOfRun method. // 2015-05-27 : N Barros - Added calling BeginOfRun for the database. // 2016-11-21 : N Barros - Introduced EndOfRun, as it is needed by some producers // 2017-15-05 : N Barros - Added RATDB default plane lock when the run being initialized // is non-zero or the data being processed is real data. // /////////////////////////////////////////////////////////////////// #ifndef __RAT_Producer__ #define __RAT_Producer__ #include namespace RAT { namespace DS { class Run; } //::DS class ProcBlock; class Producer : public G4UImessenger { public: // Create a new producer with no block. // // It is not allowed to do anything further with this object until // SetMainBlock() is called. Producer() : fMainBlock( NULL ) { } // Create a new producer with a ProcBlock // // Most likely, other Producer objects have a pointer to // theBlock as well, so we do not take ownership of the object. // // block: the main block to execute with events Producer( ProcBlock* const block ) : fMainBlock( block ) { } // Destroy this producer. Does not destroy the main block. virtual ~Producer() { /* Do nothing */ }; // Get a pointer to the main block used by this producer. // // Returns a a pointer to the main block ProcBlock* GetMainBlock() const { return fMainBlock; } // Set the main block used by this producer. // // block: the main block to execute with events void SetMainBlock( ProcBlock* const block ) { fMainBlock = block; } protected: // Called whenever the run changes // // This method initialises all the singletons so MUST be called // before any computation is done i.e. the start of the first run. // // run: run to begin void BeginOfRun( DS::Run& run ); void EndOfRun(DS::Run & run); ProcBlock* fMainBlock; // Run events on this block of processors when created. }; } // namespace RAT #endif