// SampleModuleB.cc // // This is part of the principal sample of how to use the ErrorLogger // mechanism in a realistic setting. // // The overall structure assumed is that some programmer(s) provide a // "framework" including the main program, various setups and event-flow // controls, and so forth. Then each group of physicists provide "modules" // (or, in D0 language, "packages") which do steps of physics calculation -- // the framework will pass an event from package to package. // // This sample is composed of five files: // SampleFramework // SampleModule // SampleEvent // SampleModuleB // SampleModuleB contains the physics code written by group A to act // as module B. This has just one .h and one .cc file, // though actual physics code would probably have // files for each indiviedual subroutine. // #include "SampleModuleB.h" SampleModuleB::SampleModuleB ( const std::string & name ) : SampleModule(name) { } void SampleModuleB::invoke ( Event & event ) { // SampleModuleB chooses to rely on each method that actually issues a // message to place the subroutine name in that message. As compared // to setting the ubroutine before each method call, this places more burden // on the issuer of messages, but chews up no time in the bulk of events, // which issue no messages at all. errlog.setSubroutine (""); // In case a user forgets to say @SUB= // The following should never be reached. If it is reached, the check for // highest severity at least ELnextEvent to skip remaining modules is broken. if ( (event.datum%17) == 0 ) { errlog.setSubroutine ("B::invoke"); errlog (ELfatal, "Should have skipped") << "SampleModuleB called when an ELnextEvent error was issued by module A." << "datum =" << event.datum << endmsg; errlog (ELfatal, "Should NEVER get here") << "Processing continued after fatal error!!!" << endmsg; } preliminaryFit(event); int i; for (i=0; i < 10; i++) { refineTracks1(event); refineTracks2(event); refineTracks3(event); } errlog ( ELsuccess, "Module B Finished" ) << "datum =" << event.datum << endmsg; } void SampleModuleB::preliminaryFit ( Event & event ) { // Do something to the event ... event.datum += 13; // Sometimes there is trouble detected at this stage ... if ( (event.datum % 23) == 15 ) { ERRLOG (ELwarning, "Fitting Problem") << "datum =" << event.datum << endmsg; // The coder of this routine decided NOT // to supply a subroutine name when each // error was detected. Instead she used // the ERRLOGF macro to emit file and line info. // 2:4 } if ( (event.datum % 53) == 15 ) { ERRLOG (ELwarning, "Fitting Problem") << "datum =" << event.datum << endmsg; } if ( (event.datum % 67) == 15 ) { ERRLOG (ELwarning, "Fitting Problem") << "datum =" << event.datum << endmsg; } } // preliminaryFit void SampleModuleB::refineTracks1 ( Event & event ) { // Do something to the event ... event.datum += 29; // XXXXXX errlog (ELinfo, "value of datum%201") << "@SUB= refineTracks1" << event.datum%201 << endmsg; // Rarely, we find a problem ... if ( (event.datum % 201) >= 200 ) { errlog (ELerror, "Refinement error") << "@SUB= refineTracks1" << "datum =" << event.datum << endmsg; // $$ 23:1 } } // refineTracks1 void SampleModuleB::refineTracks2 ( Event & event ) { // Do something to the event ... event.datum += 59; // Rarely, we find a problem ... if ( (event.datum % 101) >= 100 ) { errlog (ELerror, "Refinement error") << "@SUB= refineTracks2" << "datum =" << event.datum << endmsg; } } // refineTracks2 void SampleModuleB::refineTracks3 ( Event & event ) { // Do something to the event ... event.datum += 97; // Rarely, we find a problem ... if ( (event.datum % 151) >= 150 ) { errlog (ELabort, "Refinement error") << "@SUB= refineTracks3" << "datum =" << event.datum << endmsg; } // Note that even though WE recommend aborting, the framework chooses to // set the abort threshold higher (at ELfatal) so the job goes on. } // refineTracks3