Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

RawBeamMonBlock Class Reference

#include <RawBeamMonBlock.h>

Inheritance diagram for RawBeamMonBlock:

RawDataBlock List of all members.

Public Member Functions

 RawBeamMonBlock ()
 RawBeamMonBlock (const Int_t *block)
 RawBeamMonBlock (const RawBeamMonBlock &rhs)
virtual ~RawBeamMonBlock ()
RawBeamMonBlockoperator= (const RawBeamMonBlock &rhs)
virtual std::ostream & FormatToOStream (std::ostream &os, Option_t *option="") const
void SetFiltered (bool filtered=true)
std::vector< std::string > GetNames () const
 Return a list of all the device names in this block.
const RawBeamDataoperator[] (std::string device_name) const
int TclkTriggerEvent () const
int TclkTriggerDelay () const

Private Member Functions

void Unpacker () const

Private Attributes

std::map< std::string, RawBeamData * > fDevices
double fEarliest
 no I/O

Constructor & Destructor Documentation

RawBeamMonBlock::RawBeamMonBlock  ) 
 

Definition at line 18 of file RawBeamMonBlock.cxx.

References fDevices, and fEarliest.

00018                                  : RawDataBlock()
00019 {
00020     fEarliest = 0;
00021     fDevices.clear();
00022 }

RawBeamMonBlock::RawBeamMonBlock const Int_t *  block  ) 
 

Definition at line 24 of file RawBeamMonBlock.cxx.

References fDevices, and fEarliest.

00025    : RawDataBlock(block)
00026 {
00027     fEarliest = 0;
00028     fDevices.clear();
00029 }

RawBeamMonBlock::RawBeamMonBlock const RawBeamMonBlock rhs  ) 
 

Definition at line 41 of file RawBeamMonBlock.cxx.

References fDevices, and fEarliest.

00042     : RawDataBlock(rhs)
00043 {
00044     fEarliest = rhs.fEarliest;
00045     fDevices.clear();
00046 }

RawBeamMonBlock::~RawBeamMonBlock  )  [virtual]
 

Definition at line 31 of file RawBeamMonBlock.cxx.

References done(), and fDevices.

00032 {
00033     // delete any RawBeamData objects created!
00034     map<string,RawBeamData*>::iterator it, done = fDevices.end();
00035     for (it = fDevices.begin(); it != done; ++it) {
00036         if (it->second) delete it->second;
00037         it->second = 0;
00038     }
00039 }


Member Function Documentation

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

Reimplemented from RawDataBlock.

Definition at line 129 of file RawBeamMonBlock.cxx.

References fDevices, RawDataBlock::FormatToOStream(), RawBeamData::GetData(), RawBeamData::GetDataLength(), RawBeamData::GetMsecs(), GetNames(), RawBeamData::GetSeconds(), option, and Unpacker().

00130 {
00131     if (0 == fDevices.size()) this->Unpacker();
00132     RawDataBlock::FormatToOStream(os,option);
00133     if (option[0] == 'X') return os;
00134     
00135     vector<string> names = this->GetNames();
00136     os << names.size() << " devices:\n";
00137     
00138     for (size_t ind = 0; ind < names.size(); ++ind) {
00139         string name = names[ind];
00140         const RawBeamData* rbd = (*this)[name];
00141         if (!rbd) {
00142             os << name << " has no data!!!\a\n";
00143             continue;
00144         }
00145         os.precision(20);
00146         os << name << " @ " << rbd->GetSeconds() << "." << rbd->GetMsecs() << endl;
00147         size_t ndata = rbd->GetDataLength();
00148         const double* data = rbd->GetData();
00149         for (size_t ind2 = 0; ind2 < ndata; ++ind2)
00150             os << "\t" << ind2 << ": " << data[ind2] << endl;
00151     }
00152 
00153     return os;
00154 }

std::vector< string > RawBeamMonBlock::GetNames  )  const
 

Return a list of all the device names in this block.

Definition at line 106 of file RawBeamMonBlock.cxx.

References done(), fDevices, and Unpacker().

Referenced by dump(), BmntImp::Fill(), BdntImp::Fill(), and FormatToOStream().

00107 {
00108     if (0 == fDevices.size()) this->Unpacker();
00109 
00110     vector<string> res;
00111     map<string,RawBeamData*>::iterator it, done = fDevices.end();
00112     for (it=fDevices.begin(); it != done; ++it) {
00113         res.push_back(it->first);
00114     }
00115     return res;
00116 }

RawBeamMonBlock & RawBeamMonBlock::operator= const RawBeamMonBlock rhs  ) 
 

Definition at line 48 of file RawBeamMonBlock.cxx.

References fDevices, fEarliest, and RawDataBlock::operator=().

00049 {
00050     if (this == &rhs) return *this;
00051     RawDataBlock::operator=(rhs);
00052     fEarliest = rhs.fEarliest;
00053     fDevices.clear();
00054     return *this;
00055 }

const RawBeamData * RawBeamMonBlock::operator[] std::string  device_name  )  const
 

Return encapsulated data for one device block. Return 0 on failed device_name lookup. Ownership of the returned RawBeamData is not transfered and is deleted when this is.

Definition at line 118 of file RawBeamMonBlock.cxx.

References fDevices, and Unpacker().

00119 {
00120     if (0 == fDevices.size()) this->Unpacker();
00121 
00122     map<string,RawBeamData*>::iterator it = fDevices.find(device_name);
00123     if (it == fDevices.end()) return 0;
00124 
00125     return it->second;
00126 }

void RawBeamMonBlock::SetFiltered bool  filtered = true  ) 
 

By default not all device data in the data block will be accessible. The default is to filter "bad" device data. Normally, this filter does nothing, but in rare cases the Beam Data Process server was given multiple duplicate spills. When this occurs some of the duplicate spills are corrupted by subsequent spill data. The filter will remove access to any devices with timestamps more than 1.0 second from the earliest time stamp. See also BeamDataUtil/BDUniquify to help cut out the duplicate spills. Calling this method with the default argument sets the filter (done by default). Reversed turns off filtering

Definition at line 58 of file RawBeamMonBlock.cxx.

References fDevices, and fEarliest.

00059 {
00060     fEarliest = filter ? 0 : -1;
00061     fDevices.clear();
00062 }

int RawBeamMonBlock::TclkTriggerDelay  )  const
 

Return the delay from the above event, in msec, that the ACNET readout was triggered

Definition at line 161 of file RawBeamMonBlock.cxx.

Referenced by BDEarliest::CalculateEarliest(), BmntImp::Fill(), BdntImp::Fill(), BDSwicPeds::IsPedSpill(), and BeamMonDbuModule::Process().

00162 {
00163     return fRawBlock[pld_indx_clbk_delay];
00164 }

int RawBeamMonBlock::TclkTriggerEvent  )  const
 

Return the TCLK event used to trigger this block of ACNET readout

Definition at line 156 of file RawBeamMonBlock.cxx.

Referenced by BeamMonSwicPedsDbuModule::Ana(), BmntImp::Fill(), fill_bdtest(), PedStudy::OneFile(), and BeamMonDbuModule::Process().

00157 {
00158     return fRawBlock[pld_indx_clbk_event];
00159 }

void RawBeamMonBlock::Unpacker  )  const [private]
 

Definition at line 64 of file RawBeamMonBlock.cxx.

References done(), fDevices, fEarliest, RawBeamData::GetMsecs(), RawBeamData::GetName(), RawBeamData::GetSeconds(), and pld_nvalues_offset.

Referenced by FormatToOStream(), GetNames(), and operator[]().

00065 {
00066     const int* end = fRawBlock + fRawBlock[pld_indx_size];
00067     const int ndevs_tot = fRawBlock[pld_indx_num_devices];
00068 
00069     int ndevs = 0;
00070 
00071     for (int* data = fRawBlock+pld_indx_data_start;
00072          data < end;
00073          data += pld_nvalues_offset + data[pld_nvalues_offset] + 1, ++ndevs) {
00074         
00075         RawBeamData* rbd = new RawBeamData(data);
00076 
00077         if (fEarliest >= 0) {
00078             double t = rbd->GetSeconds() + rbd->GetMsecs()/1000.0;
00079             if (fEarliest < 1 || (t > 1 && t < fEarliest)) fEarliest = t;
00080         }
00081         
00082         string name = rbd->GetName();
00083         fDevices[name] = rbd;
00084     }
00085     assert (ndevs == ndevs_tot);
00086 
00087     if (fEarliest < 0) return;
00088 
00089     // Implement filter - this doesn't touch the underlying data, just
00090     // how it is mapped.
00091     map<string,RawBeamData*> newmap;
00092     map<string,RawBeamData*>::iterator it, done = fDevices.end();
00093     for (it = fDevices.begin(); it != done; ++it) {
00094         double t = it->second->GetSeconds() + it->second->GetMsecs()/1000.0;
00095         if (t - fEarliest > 1.0) {
00096             delete it->second;
00097             it->second = 0;
00098         }
00099         else newmap[it->first] = it->second;
00100     }
00101 
00102     fDevices.clear();
00103     fDevices = newmap;
00104 }


Member Data Documentation

std::map<std::string,RawBeamData*> RawBeamMonBlock::fDevices [mutable, private]
 

Definition at line 91 of file RawBeamMonBlock.h.

Referenced by FormatToOStream(), GetNames(), operator=(), operator[](), RawBeamMonBlock(), SetFiltered(), Unpacker(), and ~RawBeamMonBlock().

double RawBeamMonBlock::fEarliest [mutable, private]
 

no I/O

Definition at line 92 of file RawBeamMonBlock.h.

Referenced by operator=(), RawBeamMonBlock(), SetFiltered(), and Unpacker().


The documentation for this class was generated from the following files:
Generated on Fri Jul 3 23:43:58 2009 for loon by  doxygen 1.3.9.1