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

void RawRecCounts::ClearStatus (  )  [private]

Definition at line 150 of file RawRecCounts.cxx.

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

Referenced by Ana(), and RawRecCounts().

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

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 220 of file RawRecCounts.cxx.

References fRunningStatus, and Registry::Get().

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

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

Definition at line 183 of file RawRecCounts.cxx.

References fRawBlockCounts.

Referenced by ProcessBlocksInRecord().

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

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

Module configuration.

Reimplemented from JobCModule.

Definition at line 198 of file RawRecCounts.cxx.

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

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

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 168 of file RawRecCounts.cxx.

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

Referenced by Ana().

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

void RawRecCounts::Report (  )  [virtual]

User interface methods.

Reimplemented from JobCModule.

Definition at line 231 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().

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


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 Fri Oct 10 22:46:24 2014 for loon by  doxygen 1.4.7