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

ValidateRawChecksums.cxx

Go to the documentation of this file.
00001 
00002 // $Id: ValidateRawChecksums.cxx,v 1.3 2004/09/02 21:03:46 rhatcher Exp $
00004 #include "DataUtil/ValidateRawChecksums.h"
00005 
00006 #include "RawData/RawRecord.h"
00007 #include "RawData/RawDataBlock.h"
00008 #include "JobControl/JobCModuleRegistry.h"
00009 #include "MinosObjectMap/MomNavigator.h"
00010 #include "MessageService/MsgService.h"
00011 //#include "Util/UtilString.h"
00012 
00013 CVSID("$Id: ValidateRawChecksums.cxx,v 1.3 2004/09/02 21:03:46 rhatcher Exp $");
00014 JOBMODULE(ValidateRawChecksums, 
00015           "ValidateRawChecksums", "Filter for bad raw block xsums.");
00016 
00017 //......................................................................
00018 
00019 ValidateRawChecksums::ValidateRawChecksums()
00020   : fDumpLevel(1)
00021   , fMaxDumps(-1)
00022   , fRawBlockList("")
00023 {}
00024 
00025 //......................................................................
00026 
00027 ValidateRawChecksums::~ValidateRawChecksums() {}
00028 
00029 //......................................................................
00030   
00031 JobCResult ValidateRawChecksums::Ana(const MomNavigator* mom)
00032 {
00033    JobCResult result = JobCResult::kPassed;
00034 
00035    // Get any and all raw records attached to the data record pointed 
00036    // to by "mom".  The dynamic cast from TObject is ugly but necessary
00037    TObject   *tobj   = 0;
00038    TIter reciter = const_cast<MomNavigator*>(mom)->FragmentIter();
00039    while ( (tobj = reciter() ) ) {
00040       RawRecord *rawrec = dynamic_cast<RawRecord *>(tobj);
00041       JobCResult one_res = FilterRawRecord(rawrec);
00042       if (one_res.Failed()) result.SetFailed();
00043    }
00044 
00045    return result;
00046 }
00047 
00048 //......................................................................
00049 
00050 const Registry& ValidateRawChecksums::DefaultConfig() const 
00051 {
00052 //======================================================================
00053 // The default configuration for this module
00054 //======================================================================
00055   static Registry r;
00056   
00057   std::string name = this->GetName();
00058   name += ".config.default";
00059   r.SetName(name.c_str());
00060   
00061   r.UnLockValues();
00062   r.Set("DumpLevel",        1);
00063   r.Set("MaxDumps",        -1);   // no limit
00064   r.Set("RawBlockList",     "");
00065   r.LockValues();
00066 
00067   return r;
00068 }
00069 
00070 //......................................................................
00071 
00072 void ValidateRawChecksums::Config(const Registry& r) 
00073 {
00074 //======================================================================
00075 // Configure the module using the registry r
00076 //======================================================================
00077   int  tmpi;
00078   const char* tmpcs = 0;
00079 
00080   if (r.Get("DumpLevel",tmpi))        fDumpLevel    = tmpi;
00081   if (r.Get("MaxDumps", tmpi))        fMaxDumps     = tmpi;
00082   if (r.Get("RawBlockList",tmpcs))    fRawBlockList = tmpcs;
00083 
00084 }
00085 
00086 //......................................................................
00087 
00088 JobCResult ValidateRawChecksums::FilterRawRecord(const RawRecord* rawrec)
00089 {
00090 //======================================================================
00091 // For this raw record object check if all th
00092 //======================================================================
00093    JobCResult result = JobCResult::kPassed;
00094 
00095    bool checklist = (fRawBlockList != "");
00096 
00097    TIter itr = rawrec->GetRawBlockIter();
00098    RawDataBlock* rdb = 0;
00099    // the dynamic cast from TObject is ugly but necessary
00100    // Careful! the itr() advances the iterator as a side effect!
00101    while (( rdb = dynamic_cast<RawDataBlock*>(itr()))) {
00102      bool testit = true;
00103      if (checklist) {
00104        std::string blkname = rdb->GetName();
00105        if (fRawBlockList.find(blkname) == string::npos) testit = false;
00106      }
00107      if (testit) {
00108        bool mismatch = rdb->TestChecksum();
00109        if (mismatch) {
00110          result = JobCResult::kFailed; // set final result for record
00111          if ( fDumpLevel > 0 && fMaxDumps != 0 ) {
00112            MSG("Validate",Msg::kInfo)
00113              << "RawRecord contained raw block \""
00114              << rdb->GetName() 
00115              << "\" which failed checksum test." << endl;
00116            --fMaxDumps;
00117            switch (fDumpLevel) {
00118            case 3:  rdb->FormatToOStream(cout,"x"); break; 
00119            case 2:  rdb->FormatToOStream(cout,"");  break; 
00120            default:
00121              // no additional info printed
00122              break;
00123            }
00124          }
00125        }
00126      }
00127    }
00128 
00129   return result;
00130 }
00131 

Generated on Mon Feb 15 11:07:50 2010 for loon by  doxygen 1.3.9.1