// -*- mode: c++ -*- // // $Id: BrModule.h,v 1.3 2001/12/14 15:31:49 cholm Exp $ // $Author: cholm $ // $Date: 2001/12/14 15:31:49 $ // $Copyright: (C) 2001 BRAHMS Collaboration // // // BrModule // // BRAHMS Analysis Module Class // // Author : Flemming Videbaek // Created: 27/12/97 // Version: 1.0 // #ifndef BRAT_BrModule #define BRAT_BrModule #ifndef ROOT_TError #include "TError.h" #endif #ifndef ROOT_TNamed #include "TNamed.h" #endif #ifndef ROOT_TList #include "TList.h" #endif #ifndef ROOT_TStopwatch #include "TStopwatch.h" #endif #ifndef BRAT_BrEventNode #include "BrEventNode.h" #endif class BrModule : public TNamed { public: // State and Status types enum EBrModuleState { kSetup = 1, // At creation/setup time kInit, // At Init time kBegin, // At Begin time kEvent, // At Event time kEnd, // At End time kFinish // At Finish time }; enum EBrModuleStatus { kOk = ::kWarning - 100, // Module is doing fine kStop = ::kWarning + 100, // Module wants pipeline stoped kFailure = ::kError + 100, // Module failed kAbort = ::kError + 200 // Module failed miserably }; enum { kShowFailures = 3, // Show all failures kShowStop = 10, // Show all stop conditions }; private: // Level for amount of debug information // output during execution of the module entries // The application programmer should use the // member functions DebugLevel() for decision to // output information Int_t fDebugLevel; //! Debug level mutable Int_t fVerbose; //! Option flag //Statistics TStopwatch fTimer; //! Timer for stats Double_t fCpuTime; //! Culminative CPU time spend Int_t fEventCalled; //! Counter times Event is called. mutable Int_t fStopCount; //! Counter for Stop Output mutable Int_t fFailureCount; //! Counter for Failure Output Int_t fStopLimit; //! Limit for Stop Count Int_t fFailureLimit; //! Limit for Failure Count // Histograms and required tables TList* fHistograms; //! Histogram list TList* fRequiredTableList; //! List of needed tables (not used) protected: // State and status of module mutable EBrModuleState fState; //! What state is the module in mutable Int_t fStatus; //! How fares the module // Histogram flags Bool_t fHistOn; //! Histogramming enabled Bool_t fHistBooked; //! Histogrammed Booked virtual void SetState(EBrModuleState state) { fState = state; } virtual void SetStatus(Int_t status) { fStatus = status; } public: BrModule(); BrModule(const Char_t *name, const Char_t *title); virtual ~BrModule(); virtual void Init() { SetState(kInit); } // Called once per job virtual void Begin() { SetState(kBegin); } // Called once per run virtual void Event(); // Called once per event virtual void Event(BrEventNode* inev, BrEventNode *outev); virtual void End() { SetState(kEnd); } // Called once per run virtual void Finish(){ SetState(kFinish); } // Called once per job // Histograms virtual void Book(); void DisableHistograms(); void EnableHistograms(); Bool_t HistOn() const {return fHistOn;} Bool_t HistBooked() const {return fHistBooked;} void SetHistOn() {fHistOn=kTRUE;} void SetHistOff(){fHistOn=kFALSE;} void SetHistBooked(){fHistBooked=kTRUE;} virtual void DefineHistograms(){}; TList* HistogramList() const {return fHistograms;} // Required tables (not used) virtual void AddRequiredTable(TObject *tablename); virtual TList* GetRequiredTableList() {return fRequiredTableList;} void SetRequiredData(Char_t* name); // Statistics virtual void EventStatisticsStart(); //To be called by asp virtual void EventStatisticsEnd(); //To be called by asp virtual void ListEventStatistics(); //To be called by asp // Error, State and Status handling void Stop(const Char_t* location, const char *msgfmt, ...) const; void Failure(const Char_t* location, const char *msgfmt, ...) const; void Abort(const Char_t* location, const char *msgfmt, ...) const; void Info(Int_t lvl, const Char_t* location, const char *msgfmt, ...) const; void Debug(Int_t lvl, const Char_t* location, const char *msgfmt, ...) const; virtual void SetStopLimit(Int_t limit=10) { fStopLimit = limit; } virtual void SetFailureLimit(Int_t limit=10) { fFailureLimit = limit; } virtual Int_t GetStopLimit() const { return fStopLimit; } virtual Int_t GetFailureLimit() const { return fFailureLimit; } virtual Int_t GetStopCount() const { return fStopCount; } virtual Int_t GetFailureCount() const { return fFailureCount; } virtual void Reset() { SetStatus(kOk); } const EBrModuleState GetState() const { return fState; } const Int_t GetStatus() const { return fStatus; } // Information and debug virtual void SetDebugLevel(const Int_t level){ fDebugLevel=level; } Int_t DebugLevel(){return fDebugLevel;} //Debuglevel value virtual void SetVerbose(const Int_t verbose) { fVerbose = verbose;} Int_t Verbose() { return fVerbose; } virtual void Print(Option_t* option="DB"); virtual void Print(Option_t* option="DB") const; ClassDef(BrModule,0) // BRAHMS Module definitions }; #endif // $Log: BrModule.h,v $ // Revision 1.3 2001/12/14 15:31:49 cholm // Removed the Info(void) method, since it's been obsolted by Print(Option_t*) // for while now. Instead I've added the methods // Info(Int_t,const Char_t*, const Char_t*, ...) // Debug(Int_t,const Char_t*, const Char_t*, ...) // for printing information and debug messages to stderr. // // Revision 1.2 2001/06/22 11:12:52 cholm // Decremented version to 0 - not persistenet class // // Revision 1.1.1.1 2001/06/21 14:55:04 hagel // Initial revision of brat2 // // Revision 1.26 2001/06/16 17:40:34 videbaek // Added a ModuleManager. This class will contain a complete list // of all module constructed in a session, and may be useful to // keep track of parameters etc. // The usage is complete transparent. If one has no intention of // using it all activity is in the constructor of any BrModule, that is it. // At present the manager only has one useful method Print that in turns // call the Print method for all Modules. // // Revision 1.25 2001/05/31 01:39:13 cholm // Fix to verbose levels kShowFailres < kShowStop // // Revision 1.24 2001/04/19 15:01:54 cholm // Init, Begin, End, Finish sets setate // // Revision 1.23 2001/03/12 18:46:21 cholm // Fixed a few mistakes. Added a hack to histogram module, to make // sure it's file is closed as the very last thing in Finish. // // Revision 1.22 2001/03/07 12:15:26 cholm // * Defined standard BrModule methods in BrIOModule. // * Add the (simple) class BrHistIOModule. // * BrAppOptionManager and BrAppOption classes changed to not use // BrExceptions. // * Added the method Int_t BrMainModule::Main() to do EVERYTHING. // * Made the method BrModule::Info() const obsolete in favour of // BrModule::Print(Option_t* option="B") const. Impact on other classes. // // Revision 1.21 2001/01/30 23:56:49 cholm // Added method Reset to reset status to kOk. // // Revision 1.20 2001/01/22 19:57:28 cholm // Corrected const-ness of BrAppOption::Compare for old ROOT versions. // Fixed BrModule::Streamer to work with new ROOT. Changed the avaliable // module status values to kStop, kFailure, kAbort, and updated // BrModuleContainer and BrModule accordingly. Also renamed BrIOModule::fStatus // to BrIOModule::fIOStatus. // // Revision 1.19 2001/01/19 16:35:59 cholm // Updated BrAppOption for const'ness of compare. // Added state and status information to BrModule. A container may inspect // these react accordingly, for example by aborting the processing of the // current event, sequnce, run, job, etc. // // Revision 1.18 2000/11/23 01:30:25 brahmlib // Changed name/title types to const Char_t* instead of Char_t* in CTOR. // // Revision 1.17 2000/09/26 20:23:01 cholm // * Cleaned up BrModule // * Made BrModuleContainer a BrModule // * Added the class BrMainModule (singleton) for complex structuring of // modules in any application using BrModules // // Revision 1.16 2000/06/04 21:38:11 videbaek // Changed the BrModule class to have the warning and error counters being // mutable; thus can be used in a const method Warning and Error. // This should fix the problem reported by S.Sanders when compiling on LinuxPPC // and should be sound enough for application. // // Revision 1.15 2000/06/03 18:17:03 videbaek // Changed inheritance of BrIOModule. Added utility to BrDataObject.. See Update message for more info // // Revision 1.14 2000/05/17 10:36:11 ouerdane // see top of file // // Revision 1.13 2000/05/01 17:49:07 videbaek // Add Finish method // // Revision 1.12 1999/04/21 14:47:40 videbaek // Added Methods SetHistOn() .. see comments // // Revision 1.11 1999/04/09 19:36:25 videbaek // Clean up code; add ListStatistics to container class // // Revision 1.10 1999/02/25 15:01:30 videbaek // Add a memeber function Warning at the BrModule level. This has a buildin limit counter // such that Warning will not go on for all events. // The code is copied for the TObject::Warning. // // Revision 1.9 1999/01/21 23:23:20 hagel // 1. Changed convention for checking includes. Current convention is: // BRAT_Br...... eg BRAT_BrModule ala ROOT. // 2. Added CVS logs to .h files that didnt have them. // 3. Moved checking of include definition to first line for easier reading // 4. Put checks before all includes in the include files as per BRAT specifications // 5. Added BrGeantHeader to Geant Makefile // 6. All changes have been checked to compile on NT ala Cygnus // // Revision 1.8 1999/01/15 15:32:14 videbaek // Updates to volume files. // Added member histon to BrModule, and member function HistOn(). // Added BrMath as standard math library. // // Revision 1.7 1998/12/21 20:17:59 videbaek // Added magnet volumes. Additional features for Modules. // // Revision 1.6 1998/09/08 15:21:15 alv // Deleted {} after Book to have a declaration. The definition is in BrModule.cxx // // Revision 1.5 1998/08/28 20:00:50 videbaek // Added Book and DefineHistograms // // Revision 1.4 1998/04/06 21:11:48 videbaek // Clean up and additions for Win95