Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PrintStat.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PrintStat.cxx,v 1.3 2004/09/11 17:35:43 weber Exp $
00003 //
00004 // A small bit of program to print out some status line for each event
00005 //
00006 // A.Weber@rl.ac.uk
00008 #include "PrintStat.h"
00009 #include <cstdio>
00010 // MINOS includes
00011 #include "MessageService/MsgService.h"     // MSG text output
00012 #include "MinosObjectMap/MomNavigator.h"   // Data access
00013 #include "RawData/RawRecord.h"
00014 #include "RawData/RawDaqSnarlHeader.h"
00015 //#include "JobControl/JobCommand.h"         // JobCommand handling
00016 #include "JobControl/JobCModuleRegistry.h" // JOBMODULE registration macro
00017 #include "Conventions/Munits.h"
00018 #include "Validity/VldContext.h"
00019 #include "TString.h"
00020 
00021 CVSID("$Id: PrintStat.cxx,v 1.3 2004/09/11 17:35:43 weber Exp $");
00022 JOBMODULE(PrintStat,"PrintStat","Analyse Raw Hits\n");
00023 
00024 //......................................................................
00025 
00026 PrintStat::PrintStat() :
00027   fActOutLine(-1)      // event counter
00028 {
00029 //======================================================================
00030 // Set the initial state of your module. The code above initializes the
00031 // variables listed to the values in parentheses. 
00032 //======================================================================
00033 
00034   MSG("Stat",Msg::kDebug) << "Constructing PrintStat.\n";
00035 
00036 }
00037 
00038 //......................................................................
00039 
00040 
00041 PrintStat::~PrintStat()
00042 {
00043 //======================================================================
00044 // This is my destructor, which currently does nothing.
00045 //======================================================================
00046 
00047   MSG("Stat",Msg::kDebug) << "Destructing PrintStat.\n";
00048 
00049 }
00050 
00051 //......................................................................
00052 
00053 void PrintStat::BeginJob()
00054 {
00055 //======================================================================
00056 // This is my destructor, which currently does nothing.
00057 //======================================================================
00058 
00059   MSG("Stat",Msg::kDebug) << "PrintStat::BeginJob starts here.\n";
00060 
00061 }
00062 
00063 //......................................................................
00064 
00065 const Registry& PrintStat::DefaultConfig() const
00066 {
00067 //======================================================================
00068 // Create a registry which holds the default configuration and return it
00069 //======================================================================
00070   static Registry r;
00071 
00072   MSG("Stat",Msg::kDebug) << "PrintStat::DefaultConfig starts here.\n";
00073 
00074   // Set name of config
00075   std::string name = this->GetName();
00076   name += ".config.default";
00077   r.SetName(name.c_str());
00078 
00079   // Set values of config
00080   r.UnLockValues();
00081   r.Set("OutputRate",  10);
00082   r.Set("MaxOutLine", 100000);
00083   r.LockValues();
00084 
00085   return r;
00086 }
00087 
00088 //......................................................................
00089 
00090 void PrintStat::Config(const Registry& r)
00091 {
00092 //======================================================================
00093 // Configure the module given the registry r
00094 // Do all configuration here.
00095 // Beware: this methode may be called several times!
00096 //======================================================================
00097 
00098   int    tmpi;
00099 
00100   if (r.Get("OutputRate", tmpi)) { fOutputRate  = tmpi; }
00101   if (fOutputRate<1) fOutputRate = 1;
00102 
00103   if (r.Get("MaxOutLine", tmpi)) { fMaxOutLine  = tmpi; }
00104 
00105 }
00106 
00107 //......................................................................
00108 
00109 JobCResult PrintStat::Ana(const MomNavigator *mom) 
00110 {
00111 //======================================================================
00112 // Given the object to which the data is attached perform some
00113 // analysis of the data
00114 //======================================================================
00115 
00116   MSG("Stat", Msg::kDebug) << "Starting PrintStat::Ana.\n";
00117 
00118   // Accumulate statistics
00119 
00120   fActOutLine++;
00121   if (fActOutLine%fOutputRate!=0)           return JobCResult::kPassed;
00122   if (fActOutLine/fOutputRate>fMaxOutLine)  return JobCResult::kPassed;
00123 
00124   // find some pointers
00125 
00126   TObject* tobj;
00127   TIter    fragiter = mom->FragmentIter();
00128 
00129   RawRecord*                 rr   = 0;
00130   const RawDaqSnarlHeader*   rdsh = 0;
00131 
00132   // loop over all fragments of mom and get pointers
00133 
00134   while( ( tobj = fragiter.Next() ) ) { 
00135     if( ( rr = dynamic_cast<RawRecord*>(tobj) ) ) {
00136 
00137       MSG("Stat", Msg::kDebug) << "Found Next RawRecord. rr= "
00138                                  << rr << endl;
00139 
00140       if ( !rdsh )  rdsh  = dynamic_cast<const RawDaqSnarlHeader*>
00141                       (rr->GetRawHeader());
00142     } else {
00143       MSG("Stat", Msg::kVerbose) << "Not a RawRecord.\n";
00144 
00145     }  // if rawrec
00146   } // while
00147 
00148 
00149   if ( rdsh ) {
00150 
00151     Int_t        Run   = rdsh->GetRun();
00152     Int_t        Snarl = rdsh->GetSnarl();
00153     VldContext   vldc  = rdsh->GetVldContext();
00154     VldTimeStamp vldts = vldc.GetTimeStamp();
00155 
00156     MSG("Stat",Msg::kInfo) << "===>> " 
00157                            << SimFlag::AsString(vldc.GetSimFlag())
00158                            << " Snarl(" << setw(5) << fActOutLine << "):"
00159                            << " -- run = "    << setw(6) << Run
00160                            << " -- snarl = "  << setw(6) << Snarl
00161                            << " -- time = "   << vldts.AsString("c")
00162                            << " <<===" << endl;
00163   } else {
00164 
00165     MSG("Stat",Msg::kDebug) << "No RawDaqSnarlHeader.";
00166 
00167   }
00168   
00169   return JobCResult::kPassed;
00170 
00171 }
00172 
00173 //......................................................................
00174 
00175 void PrintStat::EndJob() 
00176 {
00177 //======================================================================
00178 // At the end of the job print some stuff out and save the histogram
00179 // to a file
00180 //======================================================================
00181 
00182   MSG("Stat",Msg::kInfo) << "PrintStat: Total Events processed = " 
00183                          << fActOutLine << "\n";
00184 
00185 }
00186 

Generated on Sat Nov 21 22:47:24 2009 for loon by  doxygen 1.3.9.1