RawRecCounts Class Reference
[DataUtil]

Characterize a RawData file. More...

#include <RawRecCounts.h>

Inheritance diagram for RawRecCounts:

JobCModule List of all members.

Public Member Functions

 RawRecCounts ()
 ~RawRecCounts ()
void EndJob ()
 Handle job status changes.
JobCResult Ana (const MomNavigator *mom)
 Analysis and Reconstruction methods.
const RegistryDefaultConfig () const
 Module configuration.
void Config (const Registry &r)
void Report ()
 User interface methods.

Private Member Functions

void ClearStatus ()
void ProcessBlocksInRecord (const RawRecord *rawrec)
void CountRawBlockTypes (const RawDataBlock *rdb)

Private Attributes

VldContext fFirstVldc
VldContext fLastVldc
VldContext fFirstSnarlVldc
VldContext fLastSnarlVldc
Int_t fNumRecords
Int_t fNumRecSets
Int_t fFirstSnarl
Int_t fLastSnarl
std::map< std::string, int > fRawBlockCounts
Int_t fRunningStatus
std::string fCurrentFile
Int_t fFileRootVersion

Detailed Description

Characterize a RawData file.

A simple job module for characterizing a RawData file including giving the first and last VldContext (and those of snarls). It should give sensible output when presented with Daq, Dcs or Beam files.

Author:
(last to touch it)
Author
rhatcher
Version:
Revision
1.3
Date:
Date
2005/07/05 20:07:15
Contact: rhatcher@bnl.gov

Created on: 2005/02/08 21:05:02

Id
RawRecCounts.h,v 1.3 2005/07/05 20:07:15 rhatcher Exp

Definition at line 41 of file RawRecCounts.h.


Constructor & Destructor Documentation

RawRecCounts::RawRecCounts (  ) 

Definition at line 40 of file RawRecCounts.cxx.

References ClearStatus().

00041   : fFirstVldc(defaultVldContext),      fLastVldc(defaultVldContext), 
00042     fFirstSnarlVldc(defaultVldContext), fLastSnarlVldc(defaultVldContext),
00043     fNumRecords(0), fNumRecSets(0), fFirstSnarl(-1), fLastSnarl(-1),
00044     // initialize classes for drawing, writing
00045     fRunningStatus(0), fFileRootVersion(0)
00046 {
00047 //======================================================================
00048 // JobModule ctor
00049 //======================================================================
00050   ClearStatus();
00051 }

RawRecCounts::~RawRecCounts (  ) 

Definition at line 55 of file RawRecCounts.cxx.

00056 {
00057 //======================================================================
00058 // JobModule dtor
00059 //======================================================================
00060 }


Member Function Documentation

JobCResult RawRecCounts::Ana ( const MomNavigator mom  )  [virtual]

Analysis and Reconstruction methods.

Reimplemented from JobCModule.

Definition at line 76 of file RawRecCounts.cxx.

References ClearStatus(), defaultVldContext, fCurrentFile, fFileRootVersion, fFirstSnarl, fFirstSnarlVldc, fFirstVldc, fLastSnarl, fLastSnarlVldc, fLastVldc, fNumRecords, fNumRecSets, MomNavigator::FragmentIter(), fRunningStatus, Registry::Get(), RawRecord::GetRawHeader(), RawDaqSnarlHeader::GetSnarl(), RecMinos::GetTempTags(), RecMinosHdr::GetVldContext(), gSystem(), Msg::kInfo, JobCResult::kPassed, MSG, ProcessBlocksInRecord(), and Report().

00077 {
00078 //======================================================================
00079 // JobCModule analysis hook
00080 //======================================================================
00081 
00082   fNumRecSets++;
00083   if (fRunningStatus>0 && fNumRecSets%fRunningStatus == 0)
00084     MSG("DataUtil",Msg::kInfo)
00085       << "\r processed " << fNumRecSets << " record sets\r" << flush;
00086 
00087   TObject *tobj = 0;
00088   TIter reciter = mom->FragmentIter();
00089   while ( ( tobj = reciter() ) ) {
00090     RawRecord *rawrec  = dynamic_cast<RawRecord*>(tobj);
00091     if (!rawrec) continue;
00092 
00093     // check for new file
00094     const Registry& registry = rawrec->GetTempTags();
00095     const char* tmpfile = 0;
00096     registry.Get("file",tmpfile);
00097     // we only want the basename
00098     const char* basename = gSystem->BaseName(tmpfile);
00099     std::string thisfile = basename;
00100     if ( thisfile != fCurrentFile ) {
00101       if ( fCurrentFile != "" ) Report();
00102       ClearStatus();
00103       fCurrentFile = thisfile;
00104 
00105       // find the TFile for this new filename
00106       TSeqCollection* listOfFiles = gROOT->GetListOfFiles();
00107       TIter fileItr(listOfFiles);
00108       TFile* afile = 0;
00109       std::string currentBaseName = gSystem->BaseName(fCurrentFile.c_str());
00110       
00111       while ( ( afile = (TFile*)fileItr.Next() ) ) {
00112         std::string fname = afile->GetName();
00113         std::string fbasename = gSystem->BaseName(fname.c_str());
00114 
00115         if ( currentBaseName == fbasename ) {  // test without any path info
00116           fFileRootVersion = afile->GetVersion();
00117         }
00118       }
00119     }  // new file
00120 
00121     // process the record
00122     fNumRecords++;
00123 
00124     const RawHeader *rawhead = rawrec->GetRawHeader();
00125     const RawDaqSnarlHeader *rawdaqsnarlhead =
00126                          dynamic_cast<const RawDaqSnarlHeader*>(rawhead);
00127 
00128     if (fFirstVldc == defaultVldContext)
00129         fFirstVldc = rawhead->GetVldContext();
00130     fLastVldc = rawhead->GetVldContext();
00131 
00132     if (rawdaqsnarlhead) {
00133       if (fFirstSnarlVldc == defaultVldContext) {
00134           fFirstSnarlVldc = rawdaqsnarlhead->GetVldContext();
00135           fFirstSnarl     = rawdaqsnarlhead->GetSnarl();
00136       }
00137       fLastSnarlVldc = rawhead->GetVldContext();
00138       fLastSnarl = rawdaqsnarlhead->GetSnarl();
00139     }
00140 
00141     ProcessBlocksInRecord(rawrec);
00142 
00143   }  // loop over records
00144 
00145   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00146 }

void RawRecCounts::ClearStatus (  )  [private]

Definition at line 149 of file RawRecCounts.cxx.

References defaultVldContext, fFirstSnarl, fFirstSnarlVldc, fFirstVldc, fLastSnarl, fLastSnarlVldc, fLastVldc, fNumRecords, and fNumRecSets.

Referenced by Ana(), and RawRecCounts().

00150 {
00151 //======================================================================
00152 // clear all the current counts
00153 //======================================================================
00154   fFirstVldc      = defaultVldContext;
00155   fLastVldc       = defaultVldContext; 
00156   fFirstSnarlVldc = defaultVldContext;
00157   fLastSnarlVldc  = defaultVldContext;
00158   
00159   fNumRecords     =  0;
00160   fNumRecSets     =  0;
00161   fFirstSnarl     = -1;
00162   fLastSnarl      = -1;
00163 }

void RawRecCounts::Config ( const Registry r  )  [virtual]

Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables.

Reimplemented from JobCModule.

Definition at line 219 of file RawRecCounts.cxx.

References fRunningStatus, and Registry::Get().

00220 {
00221 //======================================================================
00222 // Configure the module given the Registry r
00223 //======================================================================
00224   int    tmpi;
00225   if (r.Get("RunningStatus",tmpi)) { fRunningStatus = tmpi; }
00226 }

void RawRecCounts::CountRawBlockTypes ( const RawDataBlock rdb  )  [private]

Definition at line 182 of file RawRecCounts.cxx.

References fRawBlockCounts.

Referenced by ProcessBlocksInRecord().

00183 {
00184 //======================================================================
00185 // Accumulate count of RawDataBlock types
00186 //======================================================================
00187 
00188   string name = rdb->GetName();
00189   if ( fRawBlockCounts.find(name) == fRawBlockCounts.end() )
00190     fRawBlockCounts[name] = 0;
00191   fRawBlockCounts[name] += 1;
00192 
00193 }

const Registry & RawRecCounts::DefaultConfig (  )  const [virtual]

Module configuration.

Reimplemented from JobCModule.

Definition at line 197 of file RawRecCounts.cxx.

References JobCModule::GetName(), Registry::LockValues(), Registry::Set(), and Registry::UnLockValues().

00198 {
00199 //======================================================================
00200 // Supply the default configuration for the module
00201 //======================================================================
00202   static Registry r; // Default configuration for module
00203 
00204   // Set name of config
00205   std::string name = this->GetName();
00206   name += ".config.default";
00207   r.SetName(name.c_str());
00208 
00209   // Set values in configuration
00210   r.UnLockValues();
00211   r.Set("RunningStatus", 0); 
00212   r.LockValues();
00213 
00214   return r;
00215 }

void RawRecCounts::EndJob (  )  [virtual]

Handle job status changes.

Reimplemented from JobCModule.

Definition at line 64 of file RawRecCounts.cxx.

References Report().

00065 {
00066 //======================================================================
00067 // JobModule EndJob
00068 //======================================================================
00069 
00070   Report();
00071 
00072 }

void RawRecCounts::ProcessBlocksInRecord ( const RawRecord rawrec  )  [private]

Definition at line 167 of file RawRecCounts.cxx.

References CountRawBlockTypes(), and RawRecord::GetRawBlockIter().

Referenced by Ana().

00168 {
00169 //======================================================================
00170 // Loop over raw blocks in the record
00171 //======================================================================
00172 
00173   TIter rbitr = rawrec->GetRawBlockIter();
00174   const RawDataBlock* rdb = 0;
00175   while ( ( rdb = dynamic_cast<const RawDataBlock*>(rbitr()) ) ) {
00176     CountRawBlockTypes(rdb);
00177   } // loop over raw blocks
00178 }

void RawRecCounts::Report (  )  [virtual]

User interface methods.

Reimplemented from JobCModule.

Definition at line 230 of file RawRecCounts.cxx.

References fCurrentFile, fFileRootVersion, fFirstSnarl, fFirstSnarlVldc, fFirstVldc, fLastSnarl, fLastSnarlVldc, fLastVldc, fNumRecords, fNumRecSets, Form(), fRawBlockCounts, Msg::kInfo, and MSG.

Referenced by Ana(), and EndJob().

00231 {
00232 //======================================================================
00233 // Print the JobCModule's status
00234 //======================================================================
00235 
00236   int rvi = fFileRootVersion;
00237   int rvmajor = rvi/10000;
00238   int rvminor = rvi/100 - 100*rvmajor;
00239   int rvtiny  = rvi%100;
00240   string rootVersionString = Form("v%02d-%02d-%02d",rvmajor,rvminor,rvtiny);
00241 
00242   MSG("DataUtil",Msg::kInfo) 
00243     << endl << endl
00244     << "RawRecCounts Report: " << fCurrentFile << endl
00245     << "       root version: " << rootVersionString
00246     << endl << endl;
00247 
00248   MSG("DataUtil",Msg::kInfo) 
00249     << "  VldContexts: " << endl
00250     << "  First:       " << fFirstVldc << endl
00251     << "  First Snarl: " << fFirstSnarlVldc 
00252     << " # " << setw(10) << fFirstSnarl << endl
00253     << "  Last:        " << fLastVldc << endl
00254     << "  Last  Snarl: " << fLastSnarlVldc 
00255     << " # " << setw(10) << fLastSnarl << endl
00256     << "  in " << fNumRecords << " records of "
00257     << fNumRecSets << " record sets " << endl
00258     << endl;
00259 
00260   std::map<std::string,int>::iterator mitr = fRawBlockCounts.begin();
00261   for ( ; mitr != fRawBlockCounts.end(); mitr++) {
00262     MSG("DataUtil",Msg::kInfo)
00263       << "  " << setw(30) << left << (*mitr).first << " " 
00264       << setw(10) << right << (*mitr).second
00265       << resetiosflags(ios::adjustfield) // undo "right"
00266       << endl;
00267   }
00268 
00269   MSG("DataUtil",Msg::kInfo) 
00270     << endl
00271     << "RawRecCounts done"
00272     << endl << endl;
00273 
00274 }


Member Data Documentation

std::string RawRecCounts::fCurrentFile [private]

Definition at line 84 of file RawRecCounts.h.

Referenced by Ana(), and Report().

Int_t RawRecCounts::fFileRootVersion [private]

Definition at line 85 of file RawRecCounts.h.

Referenced by Ana(), and Report().

Int_t RawRecCounts::fFirstSnarl [private]

Definition at line 77 of file RawRecCounts.h.

Referenced by Ana(), ClearStatus(), and Report().

VldContext RawRecCounts::fFirstSnarlVldc [private]

Definition at line 72 of file RawRecCounts.h.

Referenced by Ana(), ClearStatus(), and Report().

VldContext RawRecCounts::fFirstVldc [private]

Definition at line 70 of file RawRecCounts.h.

Referenced by Ana(), ClearStatus(), and Report().

Int_t RawRecCounts::fLastSnarl [private]

Definition at line 78 of file RawRecCounts.h.

Referenced by Ana(), ClearStatus(), and Report().

VldContext RawRecCounts::fLastSnarlVldc [private]

Definition at line 73 of file RawRecCounts.h.

Referenced by Ana(), ClearStatus(), and Report().

VldContext RawRecCounts::fLastVldc [private]

Definition at line 71 of file RawRecCounts.h.

Referenced by Ana(), ClearStatus(), and Report().

Int_t RawRecCounts::fNumRecords [private]

Definition at line 75 of file RawRecCounts.h.

Referenced by Ana(), ClearStatus(), and Report().

Int_t RawRecCounts::fNumRecSets [private]

Definition at line 76 of file RawRecCounts.h.

Referenced by Ana(), ClearStatus(), and Report().

std::map<std::string,int> RawRecCounts::fRawBlockCounts [private]

Definition at line 80 of file RawRecCounts.h.

Referenced by CountRawBlockTypes(), and Report().

Int_t RawRecCounts::fRunningStatus [private]

Definition at line 83 of file RawRecCounts.h.

Referenced by Ana(), and Config().


The documentation for this class was generated from the following files:
Generated on Mon Jun 17 22:03:12 2013 for loon by  doxygen 1.4.7