#include "Level3Mods/HelloWorld.hh" // for iterating over objects/banks #ifdef USE_CDFEDM2 #include "Edm/GenericConstHandle.hh" #include "Edm/ConstHandle.hh" #include "StorableBanks/StorableBank.hh" #else #include "Trybos/TRY_Record_Iter_Any.hh" #endif #include #include using std::dec; using std::setw; using std::hex; using std::cout; using std::endl; #include HelloWorld::HelloWorld( const char* const theName, const char* const theDescription ) : AppModule( theName, theDescription ), _frenchSpew("frenchSpew",this,false), _bankDump("bankDump",this,false) { _jobCount = 0; _frenchSpew.addDescription(" \tSay hello in French on every event? (default false)"); commands()->append(&_frenchSpew); _bankDump.addDescription(" \tSay hello in French on every event? (default false)"); commands()->append(&_bankDump); } HelloWorld::~HelloWorld() {} AppResult HelloWorld::beginJob( AbsEvent* aJob ) { std::cout << "HelloWorld::beginJob" << std::endl; return AppResult::OK; } AppResult HelloWorld::beginRun( AbsEvent* aRun ) { _runCount = 0; _l2RunCount = 0; std::cout << "HelloWorld:beginRun" << std::endl; return AppResult::OK; } AppResult HelloWorld::event( AbsEvent* anEvent ) { _runCount++; _jobCount++; if (_runCount >= pow(2., (double) _l2RunCount)) { std::cout << "HelloWorld has processed " << _runCount << " events this run, and a total of " << _jobCount << std::endl; _l2RunCount++; } if (_frenchSpew.value()) { std::cout << "Bonjour, monde (set frenchSpew to false to turn this off)" << std::endl; } if ( _bankDump.value() ) { #ifdef USE_CDFEDM2 for (EventRecord::ConstIterator iter = anEvent->begin(); iter.is_valid(); ++iter) { GenericConstHandle handle(iter); std::string class_name = handle->class_name() ; std::cout << " " << class_name << " (oid " << handle->object_id() ; int index = class_name.find("StorableBank") ; if ( (index >= 0) && (index < class_name.size()) ) { ConstHandle bank_handle(handle) ; std::cout << ": " << bank_handle->bank_name() ; std::cout << ", " << bank_handle->bank_number() ; } std::cout << ")" ; if (!handle->description().empty()) { std::cout << ", " << handle->description(); } std::cout << std::endl; } // End object loop -------------------------- #else TRY_Record_Iter_Any p_bnk(anEvent); std::cout << "Bank List:"; while (p_bnk.is_valid()) { std::cout << (p_bnk++).bank_name() << " "; } std::cout << std::endl; #endif } return AppResult::OK; } AppResult HelloWorld::endRun( AbsEvent* aRun ) { std::cout << "HelloWorld::endRun " << _runCount << " events" << std::endl; return AppResult::OK; } AppResult HelloWorld::endJob( AbsEvent* aJob ) { std::cout << "HelloWorld::endJob " << _jobCount << " events" << std::endl; return AppResult::OK; } AppResult HelloWorld::abortJob( AbsEvent* aJob ) { return AppResult::OK; } AppModule* HelloWorld::clone(const char* cloneName) { return new HelloWorld(cloneName,"this module is a clone of HelloWorld"); }