FarTimingFidFinder Class Reference
[DataUtil]

A class to provide look-up services on the FarTimingFid table. More...

#include <FarTimingFidFinder.h>

List of all members.

Classes

struct  Cleaner

Public Member Functions

virtual ~FarTimingFidFinder ()
Int_t GetFarTimingFid (const VldContext &vldc, Int_t crate=2)
 Return "Desired Stuff" w/ various interfaces.
Int_t GetFarTimingFid (const VldTimeStamp &vts, Int_t crate=2)
Int_t GetFarTimingFid (time_t sec, Int_t crate=2)
void Print (std::string option="") const
 Print the entire FarTimingFid table.
DbiResultPtr< FarTimingFid > & GetDbiResultSet ()
 Access to DbiResultSet.

Static Public Member Functions

static FarTimingFidFinderInstance (Dbi::Task task=Dbi::kDefaultTask)
 Singleton access.

Private Member Functions

 FarTimingFidFinder ()
 signal unset
void UpdateTask (Dbi::Task task=Dbi::kDefaultTask)
void RefreshQuery (const VldContext &vldc)

Private Attributes

VldContext fVldContext
 Cache recent query.
VldRange fVldRange
 validity range of current query
DbiResultPtr< FarTimingFidfFarTimingFidTable
 Access to entire FarTimingFid table.
std::map< time_t, int > crate2map
 Unpacked info ... map provides a sorting.
std::map< time_t, int > crate4map

Static Private Attributes

static FarTimingFidFinderfgInstance = 0
static Dbi::Task fgTask = 0xDEADDEAD
 allow alternative versions

Detailed Description

A class to provide look-up services on the FarTimingFid table.

Author:
(last to touch it)
Author
rhatcher
Version:
Revision
1.1
Date:
Date
2013/12/18 23:57:14

Contact: rhatcher@fnal.gov

Definition at line 15 of file FarTimingFidFinder.h.


Constructor & Destructor Documentation

virtual FarTimingFidFinder::~FarTimingFidFinder (  )  [inline, virtual]

Definition at line 37 of file FarTimingFidFinder.h.

00037 {}

FarTimingFidFinder::FarTimingFidFinder (  )  [private]

signal unset

Definition at line 20 of file FarTimingFidFinder.cxx.

Referenced by Instance().

00021 { 
00022   // ctor
00023 }


Member Function Documentation

DbiResultPtr<FarTimingFid>& FarTimingFidFinder::GetDbiResultSet (  )  [inline]

Access to DbiResultSet.

Definition at line 48 of file FarTimingFidFinder.h.

References fFarTimingFidTable.

00048 { return fFarTimingFidTable; }

Int_t FarTimingFidFinder::GetFarTimingFid ( time_t  sec,
Int_t  crate = 2 
)

Definition at line 80 of file FarTimingFidFinder.cxx.

References GetFarTimingFid().

00082 {
00083   VldTimeStamp vts(sec,0);
00084   return GetFarTimingFid(vts,crate);
00085 }

Int_t FarTimingFidFinder::GetFarTimingFid ( const VldTimeStamp vts,
Int_t  crate = 2 
)

Definition at line 87 of file FarTimingFidFinder.cxx.

References GetFarTimingFid(), SimFlag::kData, and Detector::kFar.

00089 {
00090   VldContext vldc(Detector::kFar,SimFlag::kData,vts);
00091   return GetFarTimingFid(vldc,crate);
00092 }

Int_t FarTimingFidFinder::GetFarTimingFid ( const VldContext vldc,
Int_t  crate = 2 
)

Return "Desired Stuff" w/ various interfaces.

Definition at line 94 of file FarTimingFidFinder.cxx.

References crate2map, crate4map, fVldRange, VldTimeStamp::GetSec(), VldContext::GetTimeStamp(), VldRange::IsCompatible(), Msg::kError, MSG, and RefreshQuery().

Referenced by NuExtraction::ExtractTimingFiducial(), and GetFarTimingFid().

00096 {
00097 
00098   if ( ! fVldRange.IsCompatible(vldc) ) {
00099     // current data doesn't cover this requested period
00100     // update our internal state
00101     RefreshQuery(vldc);
00102   }
00103 
00104   // so rummage around 
00105 
00106   // ... not so pretty at the moment for the crate 2 vs. 4 handling
00107   std::map<time_t,int>* crateNmap = 0;
00108   if      ( crate == 2 ) { crateNmap = &crate2map; }
00109   else if ( crate == 4 ) { crateNmap = &crate4map; }
00110   else {
00111     MSG("FarTimingFidFinder",Msg::kError) 
00112       << "FarTimingFidFinder only supports crates 2 and 4"
00113       << std::endl;
00114     return -9999;
00115   }
00116 
00117   time_t desired_sec = vldc.GetTimeStamp().GetSec();
00118 
00119   // have a map ... iterate until we see an entry w/ time beyond our 
00120   // desired second and then take the previous value
00121   int prev_fidval = -99999;
00122   std::map<time_t,int>::const_iterator itr    = crateNmap->begin();
00123   std::map<time_t,int>::const_iterator itrEnd = crateNmap->end();
00124   for ( ; itr != itrEnd; ++itr ) {
00125     time_t fid_sec = itr->first;
00126     int    fid_val = itr->second;
00127     if ( fid_sec > desired_sec ) {
00128       // gone too far ... want previous value
00129       break;
00130     }
00131     prev_fidval = fid_val;
00132   }
00133   return prev_fidval;
00134 }

FarTimingFidFinder & FarTimingFidFinder::Instance ( Dbi::Task  task = Dbi::kDefaultTask  )  [static]

Singleton access.

Definition at line 68 of file FarTimingFidFinder.cxx.

References FarTimingFidFinder(), fgInstance, UpdateTask(), and FarTimingFidFinder::Cleaner::UseMe().

Referenced by NuExtraction::ExtractTimingFiducial().

00069 {
00070   static Cleaner cleaner;  // cleaner dtor calls FarTimingFidFinder dtor
00071   if ( ! fgInstance ) {
00072     fgInstance = new FarTimingFidFinder();
00073     cleaner.UseMe();
00074   }
00075   fgInstance->UpdateTask(task);
00076   return *fgInstance;
00077 }

void FarTimingFidFinder::Print ( std::string  option = ""  )  const

Print the entire FarTimingFid table.

void FarTimingFidFinder::RefreshQuery ( const VldContext vldc  )  [private]

Definition at line 37 of file FarTimingFidFinder.cxx.

References crate2map, crate4map, fFarTimingFidTable, fgTask, fVldContext, fVldRange, FarTimingFid::GetCrate(), FarTimingFid::GetFidValue(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRow(), FarTimingFid::GetSec(), DbiResultPtr< T >::GetValidityRec(), DbiValidityRec::GetVldRange(), Msg::kError, MSG, and DbiResultPtr< T >::NewQuery().

Referenced by GetFarTimingFid(), and UpdateTask().

00038 {
00039   fVldContext = vldc;
00040   fFarTimingFidTable.NewQuery(fVldContext,fgTask);
00041 
00042   // made the query, now extract the validity range
00043   const DbiValidityRec* dbivldrecptr = fFarTimingFidTable.GetValidityRec();
00044   fVldRange = dbivldrecptr->GetVldRange();
00045 
00046   // now extract the data into our internal format
00047   // don't count on rows coming back ordered
00048   size_t nrows = fFarTimingFidTable.GetNumRows();
00049   for ( size_t irow=0; irow < nrows; ++irow ) {
00050     const FarTimingFid* fid = fFarTimingFidTable.GetRow(irow);
00051     int    crate  = fid->GetCrate();
00052     time_t sec    = fid->GetSec();
00053     int    fidval = fid->GetFidValue();
00054     if      ( crate == 2 ) { crate2map[sec] = fidval; }
00055     else if ( crate == 4 ) { crate4map[sec] = fidval; }
00056     else {
00057       MSG("FarTimingFidFinder",Msg::kError)
00058         << "FarTimingFidFinder only supports crates 2 and 4, "
00059         << "got " << crate << " from the DB"
00060         << std::endl;
00061     }
00062 
00063   }
00064 }

void FarTimingFidFinder::UpdateTask ( Dbi::Task  task = Dbi::kDefaultTask  )  [private]

Definition at line 26 of file FarTimingFidFinder.cxx.

References fgTask, fVldContext, and RefreshQuery().

Referenced by Instance().

00027 {
00028   if ( task != fgTask ) {
00029     // task # has changed, need to reprime the pump
00030     fgTask = task;
00031     // Refresh query of FarTimingFid table.
00032     RefreshQuery(fVldContext);
00033   }
00034 }


Member Data Documentation

std::map<time_t,int> FarTimingFidFinder::crate2map [private]

Unpacked info ... map provides a sorting.

Definition at line 67 of file FarTimingFidFinder.h.

Referenced by GetFarTimingFid(), and RefreshQuery().

std::map<time_t,int> FarTimingFidFinder::crate4map [private]

Definition at line 68 of file FarTimingFidFinder.h.

Referenced by GetFarTimingFid(), and RefreshQuery().

Access to entire FarTimingFid table.

Definition at line 64 of file FarTimingFidFinder.h.

Referenced by GetDbiResultSet(), and RefreshQuery().

Definition at line 56 of file FarTimingFidFinder.h.

Referenced by Instance(), and FarTimingFidFinder::Cleaner::~Cleaner().

Dbi::Task FarTimingFidFinder::fgTask = 0xDEADDEAD [static, private]

allow alternative versions

Definition at line 57 of file FarTimingFidFinder.h.

Referenced by RefreshQuery(), and UpdateTask().

Cache recent query.

some default for if UpdateTask

Definition at line 60 of file FarTimingFidFinder.h.

Referenced by RefreshQuery(), and UpdateTask().

validity range of current query

Definition at line 61 of file FarTimingFidFinder.h.

Referenced by GetFarTimingFid(), and RefreshQuery().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1