RawConfigFilesBlock Class Reference

#include <RawConfigFilesBlock.h>

Inheritance diagram for RawConfigFilesBlock:
RawDataBlock

List of all members.

Public Member Functions

 RawConfigFilesBlock ()
 RawConfigFilesBlock (const Int_t *block)
 RawConfigFilesBlock (const VldContext &vldc, Int_t run, Short_t subrun, Short_t runtype, const Char_t *text)
virtual ~RawConfigFilesBlock ()
VldTimeStamp GetTime () const
Int_t GetRun () const
Short_t GetSubRun () const
Short_t GetRunType () const
VldContext GetVldContext () const
const Char_t * GetConfigFile () const
std::string GuessFileType () const
virtual std::ostream & FormatToOStream (std::ostream &os, Option_t *option="") const
 RawConfigFilesBlock (const RawConfigFilesBlock &rhs)
RawConfigFilesBlockoperator= (const RawConfigFilesBlock &rhs)

Static Public Member Functions

static void SetDebugFlags (const UInt_t dbgflgs)
static UInt_t GetDebugFlags ()

Protected Attributes

Char_t * fConfigFile

Static Private Attributes

static UInt_t fgDebugFlags = 0
 not written out

Detailed Description

Definition at line 20 of file RawConfigFilesBlock.h.


Constructor & Destructor Documentation

RawConfigFilesBlock::RawConfigFilesBlock (  ) 

Definition at line 42 of file RawConfigFilesBlock.cxx.

00043    : RawDataBlock(), fConfigFile(0)
00044 {
00045    // Default constructor
00046 }

RawConfigFilesBlock::RawConfigFilesBlock ( const Int_t *  block  ) 

Definition at line 49 of file RawConfigFilesBlock.cxx.

00050    : RawDataBlock(block), fConfigFile(0)
00051 {
00052    //  stored block format is:
00053    //---------------------
00054    //  0   # words in block
00055    //  1   checksum
00056    //  2   Block Id
00057    //-----
00058    //  3   run #
00059    //  4   {subrun#| run type}
00060    //  5   time (sec)
00061    //  6   time (nsec)
00062    //  7   comment string (padded to 4 char)
00063 
00064 }

RawConfigFilesBlock::RawConfigFilesBlock ( const VldContext vldc,
Int_t  run,
Short_t  subrun,
Short_t  runtype,
const Char_t *  text 
)

Definition at line 67 of file RawConfigFilesBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, VldContext::GetDetector(), RawBlockProxy::GetMajorId(), VldTimeStamp::GetNanoSec(), VldTimeStamp::GetSec(), VldContext::GetSimFlag(), VldContext::GetTimeStamp(), indx_run, indx_startnsec, indx_startsec, indx_subrun, RawBlockRegistry::Instance(), RawBlockProxy::IsDCS(), RawBlockRegistry::LookUp(), nwords_in_string(), pack_string_in_lel(), rdxsum_fill(), and zzzz_last.

00070    : RawDataBlock(), fConfigFile(0)
00071 {
00072    // Component ctor 
00073 
00074    UInt_t nwdc  = nwords_in_string(comment);
00075    fSize = zzzz_last + nwdc;
00076    if (fRawBlock) delete [] fRawBlock;
00077    fRawBlock = new Int_t [fSize];  
00078 
00079    fRawBlock[0] = fSize;
00080 // fRawBlock[1] = checksum... see below
00081  
00082    RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00083    RawBlockProxy*    rbp = rbr.LookUp("RawConfigFilesBlock");
00084  
00085    Bool_t isDCS   = rbp->IsDCS();
00086    Int_t  majorId = rbp->GetMajorId();
00087    Int_t  minorId = 2;
00088    RawBlockId rbid(majorId,minorId,isDCS,
00089                    vldc.GetDetector(),vldc.GetSimFlag());
00090    fRawBlock[2] = rbid.GetEncoded();
00091  
00092    fRawBlock[indx_run]     = run;
00093    fRawBlock[indx_subrun]  = (subrun&0xffff)<<16 | (runtype&0xffff);
00094    fRawBlock[indx_startsec]     = vldc.GetTimeStamp().GetSec();
00095    fRawBlock[indx_startnsec]    = vldc.GetTimeStamp().GetNanoSec();
00096  
00097    fRawBlock[fSize-1] = 0; // ensure final '\0'
00098    pack_string_in_lel(fRawBlock+zzzz_last,comment);
00099 
00100    // fill checksum
00101    rdxsum_fill((int32_t*)fRawBlock,0);
00102 }

RawConfigFilesBlock::~RawConfigFilesBlock (  )  [virtual]

Definition at line 105 of file RawConfigFilesBlock.cxx.

References fConfigFile.

00106 {
00107    // dtor
00108    if (fConfigFile) {
00109       delete [] fConfigFile;
00110       fConfigFile = 0;
00111    }
00112 }

RawConfigFilesBlock::RawConfigFilesBlock ( const RawConfigFilesBlock rhs  )  [inline]

Definition at line 49 of file RawConfigFilesBlock.h.

00050      : RawDataBlock(rhs), fConfigFile(0) { ; }


Member Function Documentation

std::ostream & RawConfigFilesBlock::FormatToOStream ( std::ostream &  os,
Option_t *  option = "" 
) const [virtual]

Reimplemented from RawDataBlock.

Definition at line 251 of file RawConfigFilesBlock.cxx.

References VldTimeStamp::AsString(), GetConfigFile(), GetRun(), GetRunType(), GetSubRun(), GetTime(), and GuessFileType().

00253 {
00254    RawDataBlock::FormatToOStream(os,option);
00255    if (option[0] == 'X') return os;
00256    
00257    // additional block specific formatted output is done here
00258 
00259    os << "Time " << GetTime().AsString("c") << endl;
00260    os << " Run " << GetRun()
00261       << " SubRun " << GetSubRun()
00262       << " RunType " << GetRunType() << endl;
00263    os << " GuessFileType: '" << GuessFileType() << "'" << endl;
00264    const Char_t* cfg = GetConfigFile();
00265    const Char_t* linestart = " | ";
00266    os << linestart;
00267    while (*cfg != '\0') {
00268       os << *cfg;
00269       if (*cfg == '\n' && *(cfg+1) != '\0') os << linestart;
00270       ++cfg;
00271    }
00272    os << endl;
00273 
00274    return os;
00275 }

const Char_t * RawConfigFilesBlock::GetConfigFile (  )  const

Definition at line 174 of file RawConfigFilesBlock.cxx.

References fConfigFile, RawDataBlock::fRawBlock, RawDataBlock::fSize, unpack_lel_to_string(), and zzzz_last.

Referenced by FormatToOStream(), GuessFileType(), DbuDaqFileModule::HandleConfigFilesBlock(), FillFarRunQuality::ProcessBlock(), and FillNearRunQuality::ProcessBlock().

00175 {
00176    // return the run config string
00177 
00178    if (!fConfigFile) {
00179 
00180       Int_t*       insitu = fRawBlock+zzzz_last;
00181 
00182       UInt_t nwd = (fRawBlock+fSize) - insitu;
00183       fConfigFile = unpack_lel_to_string(insitu,nwd);
00184 
00185       // replace non-printable, non-newline characters with blanks
00186       // leave final null (which should be there ... but make sure it is).
00187       int nchar = nwd*sizeof(Int_t)/sizeof(Char_t) - 1;
00188       fConfigFile[nchar] = '\0';
00189       for (int i=0; i<nchar; ++i) {
00190         Char_t c = fConfigFile[i];
00191         if ( !isprint(c) && '\n'!=c ) fConfigFile[i] = ' ';
00192       }
00193 
00194    }
00195    return fConfigFile;
00196 }

static UInt_t RawConfigFilesBlock::GetDebugFlags (  )  [inline, static]

Definition at line 46 of file RawConfigFilesBlock.h.

References fgDebugFlags.

00046 { return fgDebugFlags; }

Int_t RawConfigFilesBlock::GetRun ( void   )  const

Definition at line 137 of file RawConfigFilesBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, indx_run, and zzzz_last.

Referenced by FormatToOStream().

00138 {
00139    // get the run number
00140 
00141    if ( fSize >= zzzz_last ) return fRawBlock[indx_run];
00142    return -1;
00143 }

Short_t RawConfigFilesBlock::GetRunType (  )  const

Definition at line 156 of file RawConfigFilesBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, indx_runtype, and zzzz_last.

Referenced by FormatToOStream().

00157 {
00158    // get the run type
00159 
00160    if ( fSize >= zzzz_last ) 
00161       return fRawBlock[indx_runtype]&0xffff;
00162    return -1;
00163 }

Short_t RawConfigFilesBlock::GetSubRun (  )  const

Definition at line 146 of file RawConfigFilesBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, indx_subrun, and zzzz_last.

Referenced by FormatToOStream().

00147 {
00148    // get the subrun number
00149 
00150    if ( fSize >= zzzz_last ) 
00151       return (fRawBlock[indx_subrun]>>16)&0xffff;
00152    return -1;
00153 }

VldTimeStamp RawConfigFilesBlock::GetTime ( void   )  const

Definition at line 126 of file RawConfigFilesBlock.cxx.

References RawDataBlock::fRawBlock, RawDataBlock::fSize, indx_startnsec, indx_startsec, and zzzz_last.

Referenced by FormatToOStream(), and GetVldContext().

00127 {
00128    // get the trigger time
00129 
00130    if ( fSize >= zzzz_last )
00131       return VldTimeStamp(fRawBlock[indx_startsec],fRawBlock[indx_startnsec]);
00132  
00133    return VldTimeStamp((time_t)0,(Int_t)0);
00134 }

VldContext RawConfigFilesBlock::GetVldContext (  )  const

Definition at line 166 of file RawConfigFilesBlock.cxx.

References RawDataBlock::GetBlockId(), RawBlockId::GetDetector(), RawBlockId::GetSimFlag(), and GetTime().

00167 {
00168    // build validity context
00169    RawBlockId rbid = GetBlockId();
00170    return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetTime());
00171 }

std::string RawConfigFilesBlock::GuessFileType (  )  const

Definition at line 199 of file RawConfigFilesBlock.cxx.

References GetConfigFile().

Referenced by FormatToOStream(), and DbuDaqFileModule::HandleConfigFilesBlock().

00200 {
00201    // guess the type of config file this might be
00202    // current version don't have this in any explicit form
00203 
00204   const Char_t* haystack = GetConfigFile();
00205   
00206   // newer blocks actually are tagged as to what file they are
00207   const Char_t* starttag = "<config name=\"";
00208   const Char_t* beginname = strstr(haystack,starttag);
00209   if (beginname) {
00210       beginname += strlen(starttag);  // move to after the opening double-quote
00211       const Char_t* endquote = strstr(beginname,"\""); // closing double-quotes
00212       if (endquote) {
00213           std::string configName = "";
00214           for (const Char_t* iptr = beginname; iptr<endquote; ++iptr)
00215               configName += *iptr;
00216           return configName;
00217       }
00218   }
00219 
00220   // didn't find the new indicator of the config name
00221   // resort to guessing ... bleh!
00222 
00223   // strstr returns 0 if substring is not found
00224   
00225   // these are empirically determined correlations between the
00226   // actual file type and some string uniquely found in them
00227   // NOTE: angerous because the files are subject to change, new ones
00228   // may need to be added.
00229 
00230   if (strstr(haystack,"dcp.config file"))             return "dcp.config";
00231   if (strstr(haystack,"vaClockPeriod"))               return "varc.config";
00232   if (strstr(haystack,"VME Access ModuleId"))         return "master.config";
00233   if (strstr(haystack,"Trigger Processor Config"))    return "tp.config";
00234   if (strstr(haystack,"config file for LI control"))  return "li.config";
00235   if (strstr(haystack,"<branches>"))                  return "daq.config";
00236   if (strstr(haystack,"ropConfig"))                   return "rop.config";
00237   if (strstr(haystack,"<timemaster>"))                return "tpc.config";
00238   if (strstr(haystack,"pvicBrpNode"))                 return "pvic.config";
00239   if (strstr(haystack,"planemap>"))                   return "detector.config";
00240   if (strstr(haystack,"brpHost"))                     return "brp.config";
00241   if (strstr(haystack,"<Pedestal>"))                  return "runType.config";
00242   if (strstr(haystack,"<runstats>"))                  return "runtimes.config";
00243   if (strstr(haystack,"<fileConfig>"))                return "dcp.config";
00244   if (strstr(haystack,"<startTimes>"))                return "liStartTimes.config";
00245 
00246   return "undetermined.config";
00247   
00248 }

RawConfigFilesBlock & RawConfigFilesBlock::operator= ( const RawConfigFilesBlock rhs  ) 

Reimplemented from RawDataBlock.

Definition at line 115 of file RawConfigFilesBlock.cxx.

References fConfigFile.

00116 {
00117    // deep copy assignment 
00118   if (this != &rhs) {
00119     RawDataBlock::operator=(rhs);
00120     if (fConfigFile) { delete [] fConfigFile; fConfigFile = 0; }
00121   }
00122   return *this;
00123 }

static void RawConfigFilesBlock::SetDebugFlags ( const UInt_t  dbgflgs  )  [inline, static]

Definition at line 45 of file RawConfigFilesBlock.h.

References fgDebugFlags.

00045 {fgDebugFlags=dbgflgs;}


Member Data Documentation

Char_t* RawConfigFilesBlock::fConfigFile [mutable, protected]

Definition at line 56 of file RawConfigFilesBlock.h.

Referenced by GetConfigFile(), operator=(), and ~RawConfigFilesBlock().

UInt_t RawConfigFilesBlock::fgDebugFlags = 0 [static, private]

not written out

Definition at line 61 of file RawConfigFilesBlock.h.

Referenced by GetDebugFlags(), and SetDebugFlags().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1