DemoDataReject Class Reference

#include <DemoDataReject.h>

Inheritance diagram for DemoDataReject:
JobCModule

List of all members.

Public Member Functions

 DemoDataReject ()
 ~DemoDataReject ()
JobCResult Ana (const MomNavigator *mom)
void Config (const Registry &r)
const RegistryDefaultConfig () const
void Help ()
void HandleCommand (JobCommand *cmd)

Private Member Functions

JobCResult FilterRawRecord (const RawRecord *rawrec) const

Private Attributes

std::set< Short_t > fRunTypeReject
short fPedReject
short fSparsReject
short fCommonReject
short fVetoShieldReject

Detailed Description

Definition at line 15 of file DemoDataReject.h.


Constructor & Destructor Documentation

DemoDataReject::DemoDataReject (  ) 

Definition at line 85 of file DemoDataReject.cxx.

DemoDataReject::~DemoDataReject (  ) 

Definition at line 94 of file DemoDataReject.cxx.

00094 {}


Member Function Documentation

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

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 98 of file DemoDataReject.cxx.

References JobCResult::Failed(), FilterRawRecord(), and JobCResult::kPassed.

00099 {
00100    JobCResult result = JobCResult::kPassed;
00101    
00102    // Get any and all raw records attached to the data record pointed 
00103    // to by "mom".  The dynamic cast from TObject is ugly but necessary
00104    TObject   *tobj   = 0;
00105    TIter reciter = const_cast<MomNavigator*>(mom)->FragmentIter();
00106    while ( (tobj = reciter() ) ) {
00107       RawRecord *rawrec = dynamic_cast<RawRecord *>(tobj);
00108       result = FilterRawRecord(rawrec);
00109       if (result.Failed()) return result;
00110    }
00111 
00112    // other potential tests
00113 
00114    return result;
00115 }

void DemoDataReject::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 142 of file DemoDataReject.cxx.

References fCommonReject, fPedReject, fSparsReject, fVetoShieldReject, and Registry::Get().

00143 {
00144 //======================================================================
00145 // Configure the module using the registry r
00146 //======================================================================
00147   int  tmpi;
00148 
00149   if (r.Get("PedReject",tmpi))        fPedReject = tmpi;
00150   if (r.Get("SparsReject",tmpi))      fSparsReject = tmpi;
00151   if (r.Get("CommonReject",tmpi))     fCommonReject = tmpi;
00152   if (r.Get("VetoShieldReject",tmpi)) fVetoShieldReject = tmpi;
00153 
00154 }

const Registry & DemoDataReject::DefaultConfig ( void   )  const [virtual]

Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like:

const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; }

Reimplemented from JobCModule.

Definition at line 119 of file DemoDataReject.cxx.

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

00120 {
00121 //======================================================================
00122 // The default configuration for this module
00123 //======================================================================
00124   static Registry r;
00125   
00126   std::string name = this->GetName();
00127   name += ".config.default";
00128   r.SetName(name.c_str());
00129   
00130   r.UnLockValues();
00131   r.Set("PedReject",        kIgnoreTest);
00132   r.Set("SparseReject",     kIgnoreTest);
00133   r.Set("CommonReject",     kIgnoreTest);
00134   r.Set("VetoShieldReject", kIgnoreTest);
00135   r.LockValues();
00136 
00137   return r;
00138 }

JobCResult DemoDataReject::FilterRawRecord ( const RawRecord rawrec  )  const [private]

Definition at line 214 of file DemoDataReject.cxx.

References fCommonReject, fPedReject, fRunTypeReject, fSparsReject, fVetoShieldReject, RawDigitDataBlock::GetNCommonModeCrates(), RawDigitDataBlock::GetNPedModeCrates(), RawDigitDataBlock::GetNSparsModeCrates(), RawDigitDataBlock::GetNumberOfCrates(), RawRecord::GetRawBlockIter(), RawRecord::GetRawHeader(), RawDaqHeader::GetRunType(), header, JobCResult::kFailed, kIgnoreTest, Msg::kInfo, JobCResult::kPassed, MSG, RejectHelper::reject_it(), and RejectHelper::reject_veto().

Referenced by Ana().

00215 {
00216 
00217    JobCResult result = JobCResult::kPassed;
00218 
00219    // test if the run type is in the disallowed set
00220    const RawDaqHeader* header = 
00221       dynamic_cast<const RawDaqHeader*>(rawrec->GetRawHeader());
00222    if (header) {
00223       Short_t rt = header->GetRunType();
00224       if (fRunTypeReject.end() != fRunTypeReject.find(rt))
00225          return JobCResult::kFailed;
00226    }
00227    else {
00228       MSG("Demo",Msg::kInfo)
00229          << "RawRecord lacked RawDaqHeader: "
00230          << *(rawrec->GetRawHeader())
00231          << endl;
00232    }
00233 
00234    // test if the wrong modes were in play in RawDigitDataBlock
00235    TIter itr = rawrec->GetRawBlockIter();
00236    RawDataBlock* rdb = 0;
00237    // The dynamic cast from TObject is ugly but necessary
00238    // Careful! the itr() advances the iterator as a side effect!
00239    while ((rdb = dynamic_cast<RawDataBlock*>(itr()))) {
00240       RawDigitDataBlock *rddb = dynamic_cast<RawDigitDataBlock*>(rdb);
00241       if (rddb) {
00242          Short_t ncrates = rddb->GetNumberOfCrates();
00243          Short_t nped    = rddb->GetNPedModeCrates();
00244          Short_t nspars  = rddb->GetNSparsModeCrates();
00245          Short_t ncommon = rddb->GetNCommonModeCrates();
00246 
00247          using namespace RejectHelper;
00248          if (reject_it(fPedReject,nped,ncrates)) 
00249             return JobCResult::kFailed;
00250          if (reject_it(fSparsReject,nspars,ncrates)) 
00251             return JobCResult::kFailed;
00252          if (reject_it(fCommonReject,ncommon,ncrates)) 
00253             return JobCResult::kFailed;
00254 
00255          if ( fVetoShieldReject != kIgnoreTest &&
00256               reject_veto(fVetoShieldReject,rddb) ) return JobCResult::kFailed;
00257       }
00258   }
00259 
00260   return result;
00261 }

void DemoDataReject::HandleCommand ( JobCommand command  )  [virtual]

Implement to handle a JobCommand

Reimplemented from JobCModule.

Definition at line 157 of file DemoDataReject.cxx.

References UtilString::cmp_nocase(), fCommonReject, fPedReject, fRunTypeReject, fSparsReject, fVetoShieldReject, JobCommand::HaveOpt(), kIgnoreTest, Msg::kInfo, kRejectIfAllOff, kRejectIfAllOn, kRejectIfAnyOff, kRejectIfAnyOn, Msg::kWarning, MSG, JobCommand::PopCmd(), JobCommand::PopIntOpt(), and JobCommand::PopOpt().

00158 {
00159 
00160    using namespace RejectHelper;
00161    const char* c = cmd->PopCmd();
00162    if (c) {
00163       string sc(c);
00164       if (sc == "RunType") {
00165          while (cmd->HaveOpt()) fRunTypeReject.insert(cmd->PopIntOpt());
00166       }
00167       else  if (sc == "Mode") {
00168          const char* opt = cmd->PopOpt();
00169          string sopt(opt);
00170          Short_t *which = 0;
00171          if      (sopt.find("Ped")   !=string::npos) which = &fPedReject;
00172          else if (sopt.find("Ped")   !=string::npos) which = &fPedReject;
00173          else if (sopt.find("Spars") !=string::npos) which = &fSparsReject;
00174          else if (sopt.find("spars") !=string::npos) which = &fSparsReject;
00175          else if (sopt.find("Common")!=string::npos) which = &fCommonReject;
00176          else if (sopt.find("common")!=string::npos) which = &fCommonReject;
00177          else if (sopt.find("Veto")  !=string::npos) which = &fVetoShieldReject;
00178          else if (sopt.find("veto")  !=string::npos) which = &fVetoShieldReject;
00179          else {
00180             which = 0;
00181             MSG("Demo",Msg::kWarning) 
00182                << "No DataReject/Mode available for mode '" << opt << "'." 
00183                << "  Try one of Ped, Spars, Common, VetoShield." << endl
00184                << endl;
00185          }
00186          if (which) {
00187             const char* tst = cmd->PopOpt();
00188             string stst(tst);
00189             using namespace UtilString;
00190             if      (!cmp_nocase(stst,"ignore")) *which = kIgnoreTest;
00191             else if (!cmp_nocase(stst,"alloff")) *which = kRejectIfAllOff;
00192             else if (!cmp_nocase(stst,"anyoff")) *which = kRejectIfAnyOff;
00193             else if (!cmp_nocase(stst,"off"))    *which = kRejectIfAnyOff;
00194             else if (!cmp_nocase(stst,"on"))     *which = kRejectIfAnyOn;
00195             else if (!cmp_nocase(stst,"anyon"))  *which = kRejectIfAnyOn;
00196             else if (!cmp_nocase(stst,"allon"))  *which = kRejectIfAllOn;
00197             else {
00198                MSG("Demo",Msg::kWarning) 
00199                   << "No DataReject/Mode setting \"" << stst
00200                   << "\", should be one of on, off, ignore." << endl;
00201                *which = kIgnoreTest;
00202             }
00203          }
00204       }
00205    }
00206    else {
00207       MSG("Demo",Msg::kInfo) 
00208          << "Valid DataReject commands are RunType, Mode" << endl;
00209    }
00210 }

void DemoDataReject::Help (  )  [virtual]

Implement to spew some useful help to cout

Reimplemented from JobCModule.

Definition at line 265 of file DemoDataReject.cxx.

References JobCModule::GetName(), Msg::kInfo, MSG, and n.

00266 {
00267   const char* n = this->GetName();
00268 
00269   MSG("Demo",Msg::kInfo)
00270      << "Help for module " << n << endl
00271      << endl
00272      << "  A filter to remove undesired data configurations" << endl
00273      << "  commands:" << endl
00274      << endl
00275      << "  /" << n << "/RunType [ival [ival ...]]" << endl
00276      << endl
00277      << "  /" << n << "/Mode <mode> <toggle> ..." << endl
00278      << "     where <mode> is one of Ped, Spars, Common " <<endl
00279      << "     and   <toggle> is: " << endl
00280      << "                AllOff, [Any]Off, [Any]On, AllOn " << endl
00281      << "                or Ignore (which skips the test) " << endl
00282      << endl
00283      << endl;
00284 
00285 }


Member Data Documentation

Definition at line 37 of file DemoDataReject.h.

Referenced by Config(), FilterRawRecord(), and HandleCommand().

short DemoDataReject::fPedReject [private]

Definition at line 35 of file DemoDataReject.h.

Referenced by Config(), FilterRawRecord(), and HandleCommand().

std::set<Short_t> DemoDataReject::fRunTypeReject [private]

Definition at line 33 of file DemoDataReject.h.

Referenced by FilterRawRecord(), and HandleCommand().

Definition at line 36 of file DemoDataReject.h.

Referenced by Config(), FilterRawRecord(), and HandleCommand().

Definition at line 38 of file DemoDataReject.h.

Referenced by Config(), FilterRawRecord(), and HandleCommand().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1