FiltTriggerPrescale Class Reference
[Filtration]

Prescale snarls based on trigger bits. More...

#include <FiltTriggerPrescale.h>

Inheritance diagram for FiltTriggerPrescale:
JobCModule

List of all members.

Public Member Functions

 FiltTriggerPrescale ()
JobCResult Ana (const MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)
void Report ()
void EndJob ()

Private Attributes

UInt_t fN [32]
UInt_t fM [32]
UInt_t fRecordSets
UInt_t fSnarls
UInt_t fSnarlsPassed
UInt_t fNoSnarlRecSets
UInt_t fTrigSeen [32]
UInt_t fTrigPass [32]

Detailed Description

Prescale snarls based on trigger bits.

Author:
(last to touch it)
Author
rhatcher
Version:
Revision
1.1
Date:
Date
2005/06/02 05:51:40

Contact: R. Hatcher <rhatcher@fnal.gov>

Created on: Tue May 31 17:02:36 2005

Author: R. Hatcher 2005.05.31

Id
FiltTriggerPrescale.h,v 1.1 2005/06/02 05:51:40 rhatcher Exp

Definition at line 33 of file FiltTriggerPrescale.h.


Constructor & Destructor Documentation

FiltTriggerPrescale::FiltTriggerPrescale (  ) 

Definition at line 37 of file FiltTriggerPrescale.cxx.

References fM, fN, fNoSnarlRecSets, fRecordSets, fSnarls, fSnarlsPassed, fTrigPass, and fTrigSeen.

00038 {
00039     fRecordSets = fSnarls = fSnarlsPassed = fNoSnarlRecSets = 0;
00040     for (int i=0; i<32; ++i) {
00041         fN[i] = fM[i] = fTrigSeen[i] = fTrigPass[i] = 0;
00042     }
00043 }


Member Function Documentation

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

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 184 of file FiltTriggerPrescale.cxx.

References bfld::AsString(), fM, fN, fNoSnarlRecSets, Form(), MomNavigator::FragmentIter(), fRecordSets, fSnarls, fSnarlsPassed, fTrigPass, fTrigSeen, VldContext::GetDetector(), RecMinos::GetHeader(), JobCModule::GetName(), RawDaqHeader::GetRun(), RawDaqSnarlHeader::GetSnarl(), RawDaqHeader::GetSubRun(), RawDaqSnarlHeader::GetTrigSrc(), RecMinosHdr::GetVldContext(), Msg::kDebug, JobCResult::kFailed, JobCResult::kPassed, Msg::kSynopsis, Msg::kWarning, and MSG.

00185 {
00186 
00187   JobCResult result = JobCResult::kFailed;
00188   int snarlsInRecSet = 0;
00189 
00190   // count record sets that have been processed
00191   fRecordSets++;
00192   
00193   TObject* recObj = 0;
00194   TIter recItr = mom->FragmentIter();
00195   while ( ( recObj = recItr.Next() ) ) {
00196     RawRecord* rawrec = dynamic_cast<RawRecord*>(recObj);
00197     if (!rawrec) continue;  // skip things in mom that aren't RawRecords
00198 
00199     // look for the DaqSnarl records
00200     
00201     const RawDaqSnarlHeader* snarlHdr = 
00202       dynamic_cast<const RawDaqSnarlHeader*>(rawrec->GetHeader());
00203 
00204     if ( snarlHdr ) {
00205       fSnarls++;
00206       snarlsInRecSet++;  // count # of snarls in recset
00207       bool passSnarl = false;
00208 
00209       int snarlNum  = snarlHdr->GetSnarl();
00210       int trigSrc   = snarlHdr->GetTrigSrc();
00211       const VldContext& vldc = snarlHdr->GetVldContext();
00212       std::string detName =  Detector::AsString(vldc.GetDetector());
00213 
00214       for (int ibit=0; ibit<32; ++ibit) {
00215           UInt_t oneBit = 1 << ibit;
00216           if ( oneBit & trigSrc ) {
00217               fTrigSeen[ibit]++;
00218               bool passBit = false;
00219               if ( fM[ibit] > 0 ) {
00220                   UInt_t modSnarlNum = snarlNum%fM[ibit];
00221                   if ( modSnarlNum < fN[ibit] ) passBit = true;
00222               }
00223 
00224               RawTriggerCodes::TrigBits_t tbit = 
00225                   static_cast<RawTriggerCodes::TrigBits_t>(oneBit);
00226               std::string trigName = RawTriggerCodes::AsString(tbit);
00227               MSG("Filt",Msg::kDebug )
00228                   << " " << detName
00229                   << " Run " << snarlHdr->GetRun() 
00230                   << " Snarl " << snarlNum
00231                   << " had TrigBit \"" << trigName << "\""
00232                   << " : "
00233                   << (passBit?"Passed":"Failed")
00234                   << endl;
00235 
00236               if ( passBit ) {
00237                   passSnarl = true;
00238                   fTrigPass[ibit]++;
00239               }
00240           }
00241       }
00242       if ( passSnarl ) {
00243           fSnarlsPassed++;
00244           result = JobCResult::kPassed;
00245       }
00246 
00247       MSG("Filt",Msg::kSynopsis )
00248           << " " << detName
00249           << " Run " << snarlHdr->GetRun() 
00250           << " SubRun " << snarlHdr->GetSubRun()
00251           << " Snarl " << snarlNum
00252           << " TrigSrc " << Form("0x%08x",trigSrc)
00253           << " : "
00254           << (passSnarl?"Passed":"Failed")
00255           << endl;
00256 
00257     } // snarl header
00258   }
00259 
00260 // pass record sets that contain no DaqSnarl
00261   if ( snarlsInRecSet == 0 ) {
00262       fNoSnarlRecSets++;
00263       MSG("Filt",Msg::kSynopsis )
00264           << GetName() 
00265           << " RecordSet contained no DaqSnarl "
00266           << endl;
00267       return JobCResult::kPassed;
00268   }
00269   if ( snarlsInRecSet > 1 ) {
00270       MSG("Filt",Msg::kWarning )
00271           << GetName() 
00272           << " RecordSet contained more than one DaqSnarl "
00273           << endl;
00274   }
00275   return result;
00276 }

void FiltTriggerPrescale::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 91 of file FiltTriggerPrescale.cxx.

References bfld::AsString(), fM, fN, Registry::Get(), and VHS::ToString().

00092 {
00093 //======================================================================
00094 // Configure the module given the registry r
00095 //======================================================================
00096 //  char   tmpb;
00097 //  double tmpd;
00098     int    tmpn, tmpm;
00099 
00100   for (int ibit=0; ibit<32; ++ibit) {
00101       UInt_t oneBit = 1 << ibit;
00102       RawTriggerCodes::TrigBits_t tbit = 
00103           static_cast<RawTriggerCodes::TrigBits_t>(oneBit);
00104       std::string trigName = RawTriggerCodes::AsString(tbit);
00105 
00106       // handle unnamed trigger bits
00107       if ( trigName.find("TrigBit") == 0 || trigName.find("0x") == 0 ) {
00108           trigName = "TrigBit" + UtilString::ToString(ibit);
00109       }
00110       
00111       std::string nName = trigName + "_N";
00112       std::string mName = trigName + "_M";
00113       if (r.Get(nName.c_str(),tmpn)) { fN[ibit] = tmpn; }
00114       if (r.Get(mName.c_str(),tmpm)) { fM[ibit] = tmpm; }
00115   }
00116 
00117 }

const Registry & FiltTriggerPrescale::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 47 of file FiltTriggerPrescale.cxx.

References bfld::AsString(), JobCModule::GetName(), Registry::LockValues(), Registry::Set(), VHS::ToString(), and Registry::UnLockValues().

00048 {
00049 //======================================================================
00050 // Create a registry which holds the default configuration and return it
00051 //======================================================================
00052   static Registry r;
00053 
00054   // Set name of config
00055   std::string name = this->GetName();
00056   name += ".config.default";
00057   r.SetName(name.c_str());
00058 
00059   // Set values of config
00060   r.UnLockValues();
00061 
00062   for (int ibit=0; ibit<32; ++ibit) {
00063       UInt_t oneBit = 1 << ibit;
00064       RawTriggerCodes::TrigBits_t tbit = 
00065           static_cast<RawTriggerCodes::TrigBits_t>(oneBit);
00066       std::string trigName = RawTriggerCodes::AsString(tbit);
00067       int defaultN = 1;
00068       int defaultM = 1;
00069 
00070       // handle unnamed trigger bits (default for this is "ignore")
00071       // but allow users to configure with "TrigBit<n>" naming
00072       if ( trigName.find("TrigBit") == 0 || trigName.find("0x") == 0 ) {
00073           trigName = "TrigBit" + UtilString::ToString(ibit);
00074           defaultN = 0;
00075           defaultM = 0;
00076       }
00077 
00078       std::string nName = trigName + "_N";
00079       std::string mName = trigName + "_M";
00080       r.Set(nName.c_str(),defaultN);
00081       r.Set(mName.c_str(),defaultM);
00082   }
00083 
00084   r.LockValues();
00085 
00086   return r;
00087 }

void FiltTriggerPrescale::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 177 of file FiltTriggerPrescale.cxx.

References Report().

00178 {
00179     Report();
00180 }

void FiltTriggerPrescale::Report (  )  [virtual]

Implement to spew end of running report

Reimplemented from JobCModule.

Definition at line 121 of file FiltTriggerPrescale.cxx.

References bfld::AsString(), fM, fN, fNoSnarlRecSets, fRecordSets, fSnarls, fSnarlsPassed, fTrigPass, fTrigSeen, Msg::kInfo, Munits::m, MSG, and n.

Referenced by EndJob().

00122 {
00123   MSG("Filt",Msg::kInfo) 
00124     << "Report For FiltTriggerPrescale Module:" << endl;
00125 
00126   //Registry &r = GetConfig();
00127   //r.Print();
00128 
00129   MSG("Filt",Msg::kInfo) 
00130       << " Processed " << fRecordSets << " record-sets "
00131       << "(" << fNoSnarlRecSets << " without snarls)." << endl;
00132 
00133   MSG("Filt",Msg::kInfo) 
00134       << "  bit#  triggerName      passed/    seen                 N/   M" 
00135       << endl;
00136   for ( int ibit=0; ibit<32; ++ibit) {
00137       UInt_t nPass = fTrigPass[ibit];
00138       UInt_t mSeen = fTrigSeen[ibit];
00139       UInt_t n     = fN[ibit];
00140       UInt_t m     = fM[ibit];
00141       if ( nPass == 0 && mSeen == 0 && n == 0 && m == 0 ) continue;
00142 
00143       UInt_t oneBit = 1 << ibit;
00144       RawTriggerCodes::TrigBits_t tbit = 
00145           static_cast<RawTriggerCodes::TrigBits_t>(oneBit);
00146       std::string trigName = RawTriggerCodes::AsString(tbit);
00147 
00148       double passFrac = (mSeen>0) ? (double)nPass/(double)mSeen : -1;
00149       double targFrac = (m    >0) ? (double)n    /(double)m     : -1;
00150 
00151       MSG("Filt",Msg::kInfo)
00152           << "  [" << setw(2) << right << ibit << left << "]  "
00153           << setw(12) << trigName << "  "
00154           << right
00155           << " " << setw(8) << nPass << "/" << setw(8) << mSeen
00156           << " (" << setw(10) << passFrac << ")"
00157           << " " << setw(4) << n     << "/" << setw(4) << m
00158           << " (" << setw(10) << targFrac << ")"
00159           << left
00160           << endl;
00161   }
00162   double totPassFrac = 
00163       (fSnarls>0) ? (double)fSnarlsPassed/(double)fSnarls : -1;
00164   MSG("Filt",Msg::kInfo)
00165       << "        "
00166       << setw(12) << "-all triggers-" 
00167       << right
00168       << " " << setw(8) << fSnarlsPassed << "/" << setw(8) << fSnarls
00169       << " (" << setw(10) << totPassFrac << ")"
00170       << endl;
00171 
00172   MSG("Filt",Msg::kInfo) << endl;
00173 }


Member Data Documentation

UInt_t FiltTriggerPrescale::fM[32] [private]

Definition at line 49 of file FiltTriggerPrescale.h.

Referenced by Ana(), Config(), FiltTriggerPrescale(), and Report().

UInt_t FiltTriggerPrescale::fN[32] [private]

Definition at line 48 of file FiltTriggerPrescale.h.

Referenced by Ana(), Config(), FiltTriggerPrescale(), and Report().

Definition at line 55 of file FiltTriggerPrescale.h.

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

Definition at line 52 of file FiltTriggerPrescale.h.

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

UInt_t FiltTriggerPrescale::fSnarls [private]

Definition at line 53 of file FiltTriggerPrescale.h.

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

Definition at line 54 of file FiltTriggerPrescale.h.

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

UInt_t FiltTriggerPrescale::fTrigPass[32] [private]

Definition at line 57 of file FiltTriggerPrescale.h.

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

UInt_t FiltTriggerPrescale::fTrigSeen[32] [private]

Definition at line 56 of file FiltTriggerPrescale.h.

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


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1