#include "Level3Mods/Level3Recorder.hh" #include "Framework/APPFramework.hh" #include "Framework/AppStreamsOutputModule.hh" #include #include using std::cout; using std::endl; // // WARNING.... this module assumes there is an active output module // which inherits from AppStreamsOutputModule. It will die a horrible // death when attempting to access streams() if this is not true! // Level3Recorder::Level3Recorder( const char* const theName, const char* const theDescription ) : AppModule( theName, theDescription ), _theLevel3Accountant(NULL), _noLevel3Accountant("noLevel3Accountant",this,true), _noLevel3CpuMonitor("noLevel3CpuMonitor",this,false), _enableOldTL3("enableOldTL3",this,false), _enableNewTL3("enableNewTL3",this,true) { _noLevel3Accountant.addDescription(" \tDon't use a Level-3 Accountant; do nothing in this model (default TRUE -- n.b., this means DEFAULT IS TO DO NOTHING)"); _noLevel3CpuMonitor.addDescription(" \tDon't let the Level-3 Accountant Monitor CPU time (default false)"); _enableOldTL3.addDescription(" \tEnable testing of new TL3 objects (default false)"); _enableNewTL3.addDescription(" \tEnable testing of new TL3 objects (default true)"); commands()->append(&_noLevel3Accountant); commands()->append(&_noLevel3CpuMonitor); commands()->append(&_enableOldTL3); commands()->append(&_enableNewTL3); } Level3Recorder::~Level3Recorder() {} AppResult Level3Recorder::beginRun( AbsEvent* aRun ) { if ( !_noLevel3Accountant.value() ) { _theLevel3Accountant = new Level3Accountant(_enableOldTL3.value(), _enableNewTL3.value(), !_noLevel3CpuMonitor.value(), _verbose.value()); // output module only knows streams() AppStreamsOutputModule* theOM = (AppStreamsOutputModule*) framework()->theOutputModule(); _theLevel3Accountant->createLedger(framework(), theOM->streams(), aRun); } return AppResult::OK; } AppResult Level3Recorder::endRun( AbsEvent* aRun ) { if (_theLevel3Accountant != NULL) delete _theLevel3Accountant; return AppResult::OK; } AppResult Level3Recorder::event( AbsEvent* anEvent ) { if ( !_noLevel3Accountant.value() ) { // output module only knows streams() AppStreamsOutputModule* theOM = (AppStreamsOutputModule*) framework()->theOutputModule(); _theLevel3Accountant->countBeans(framework(), theOM->streams(), anEvent); } return AppResult::OK; } AppModule* Level3Recorder::clone(const char* cloneName) { return new Level3Recorder(cloneName,"this module is a clone of Level3Recorder"); }