Pull out not recently seen RawBeamMonBlocks from Mom. More...
#include <BDUniquify.h>
Public Types | |
typedef std::pair< const RawBeamMonHeaderBlock *, const RawBeamMonBlock * > | BlockPair |
Public Member Functions | |
BDUniquify (size_t qsize=10) | |
std::vector< BlockPair > | GetUniqueBlocks (const MomNavigator &mom) |
bool | IsUnique (const VldTimeStamp &vts, int event, int delay) |
void | AddTimeStamp (const VldTimeStamp &vts, int event, int delay) |
Private Attributes | |
std::map< int, std::deque < VldTimeStamp > > | fPastSpills |
size_t | fSize |
Pull out not recently seen RawBeamMonBlocks from Mom.
Unfortunately there was a period of time where multiple callbacks were set in the bdp-server. This resulted in almost two weeks of data taking where there will be multiple spills in mom when the data is read back. This class tries to clean things up as best as possible. It does this by remembering the last N VldTimeStamps and returning only those RawBeamMonBlocks that have VldTimeStamps that are not near any of the last ones.
Contact: bv@bnl.gov
Created on: Mon Nov 7 10:28:11 2005
Definition at line 45 of file BDUniquify.h.
typedef std::pair<const RawBeamMonHeaderBlock*,const RawBeamMonBlock*> BDUniquify::BlockPair |
Definition at line 52 of file BDUniquify.h.
BDUniquify::BDUniquify | ( | size_t | qsize = 10 |
) |
Definition at line 18 of file BDUniquify.cxx.
00019 : fSize(qsize) 00020 { 00021 }
void BDUniquify::AddTimeStamp | ( | const VldTimeStamp & | vts, | |
int | event, | |||
int | delay | |||
) |
Definition at line 109 of file BDUniquify.cxx.
References fPastSpills, and fSize.
Referenced by GetUniqueBlocks().
00110 { 00111 int key = ( event<<24 ) + delay; 00112 deque<VldTimeStamp>& vtsl = fPastSpills[key]; 00113 vtsl.push_front(vts); 00114 while (vtsl.size() > fSize) vtsl.pop_back(); 00115 }
vector< BDUniquify::BlockPair > BDUniquify::GetUniqueBlocks | ( | const MomNavigator & | mom | ) |
Definition at line 55 of file BDUniquify.cxx.
References AddTimeStamp(), block_pair_less(), done(), MomNavigator::FragmentIter(), RawRecord::GetRawBlockIter(), BDEarliest::GetTimestamps(), IsUnique(), it, and BDEarliest::SetSpill().
Referenced by BeamMonSwicPedsDbuModule::Ana(), BDUniquifyTestModule::Ana(), BeamMonDbuModule::Ana(), BDataQualityModule::Ana(), and BDTestDataModule::Reco().
00056 { 00057 static BDEarliest earliest; 00058 00059 list<BDUniquify::BlockPair> res; 00060 00061 // Loop through all RawRecords in mom: 00062 TObject* tobj=0; 00063 TIter fragiter = mom.FragmentIter(); 00064 while( ( tobj = fragiter.Next() ) ) { 00065 const RawRecord* rawrec = dynamic_cast<const RawRecord*>(tobj); 00066 if (!rawrec) continue; 00067 00068 BlockPair p; 00069 00070 00071 TIter blockiter = rawrec->GetRawBlockIter(); 00072 while( ( tobj = blockiter.Next() ) ) { 00073 if (!p.first) 00074 p.first = dynamic_cast<const RawBeamMonHeaderBlock*>(tobj); 00075 if (!p.second) 00076 p.second = dynamic_cast<const RawBeamMonBlock*>(tobj); 00077 } 00078 00079 if (!p.first || !p.second) continue; 00080 00081 earliest.SetSpill(*p.first,*p.second); 00082 double dae=0,vme=0; 00083 earliest.GetTimestamps(dae, vme); 00084 if (dae<1 && vme<1) continue; 00085 00086 res.push_back(p); 00087 } 00088 00089 // Sort so any duplicates with more devices are added first 00090 res.sort(block_pair_less); 00091 00092 vector<BDUniquify::BlockPair> ret; 00093 list<BDUniquify::BlockPair>::iterator it, done = res.end(); 00094 for (it=res.begin(); it != done; ++it) { 00095 BDUniquify::BlockPair p = *it; 00096 VldTimeStamp vts = p.first->GetTimeStamp(); 00097 int event = p.second->TclkTriggerEvent(); 00098 int delay = p.second->TclkTriggerDelay(); 00099 if (! this->IsUnique(vts, event, delay)) continue; 00100 00101 this->AddTimeStamp(vts,event,delay); 00102 ret.push_back(p); 00103 } 00104 00105 return ret; 00106 00107 }
bool BDUniquify::IsUnique | ( | const VldTimeStamp & | vts, | |
int | event, | |||
int | delay | |||
) |
Definition at line 117 of file BDUniquify.cxx.
References fPastSpills, and it.
Referenced by GetUniqueBlocks().
00118 { 00119 int key = ( event<<24 ) + delay; 00120 map<int,deque<VldTimeStamp> >::iterator it = fPastSpills.find(key); 00121 00122 if (it == fPastSpills.end()) return true; 00123 00124 deque<VldTimeStamp> &vtsl = it->second; 00125 00126 size_t siz = vtsl.size(); 00127 for (size_t ind=0; ind<siz; ++ind) { 00128 if (fabs(vtsl[ind]-vts) < 0.5) return false; 00129 } 00130 00131 return true; 00132 }
std::map<int,std::deque<VldTimeStamp> > BDUniquify::fPastSpills [private] |
Definition at line 46 of file BDUniquify.h.
Referenced by AddTimeStamp(), and IsUnique().
size_t BDUniquify::fSize [private] |
Definition at line 47 of file BDUniquify.h.
Referenced by AddTimeStamp().