/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

ReadoutTriggerDataPkg.cc
Go to the documentation of this file.
00001 #include "Event/ReadoutTriggerDataPkg.h"
00002 #include "Event/ReadoutTriggerDataFrame.h"
00003 #include <ostream>
00004 
00005 DayaBay::ReadoutTriggerDataPkg::~ReadoutTriggerDataPkg(){
00006     TriggerFrameCollection::iterator it=m_frames.begin();
00007     for ( ; it!=m_frames.end(); it++ ) {
00008         if (*it && (*it)->package()==this ) delete *it;
00009     }
00010     m_frames.clear();
00011 }
00012 
00013 std::ostream& DayaBay::ReadoutTriggerDataPkg::fillStream(std::ostream& s) const
00014 {
00015     s << "Begin ReadoutTriggerDataPkg\n"
00016       << "\tDet: " << m_detector.detName() << "\n"
00017       << "\tReadout: " << m_readout << "\n"
00018       << "\tTrigger Number: " << m_trigNumber << "\n"
00019       << "\tNumber Sub Triggers: " << m_numSubTriggers << "\n"
00020       << "\tStatus: " << m_boardStatus << "\n"
00021       << "\tLocal SN: " << m_localSN << "\n"
00022       << "\tFrames"<< std::endl;
00023     TriggerFrameCollection::const_iterator it, done = m_frames.end();
00024     for (it=m_frames.begin(); it != done; ++it) {
00025       s << **it << std::endl;
00026     }
00027     s << "End ReadoutTriggerDataPkg" << std::endl;
00028     return s;
00029 }
00030 
00031 void DayaBay::ReadoutTriggerDataPkg::addFrame(DayaBay::ReadoutTriggerDataFrame* tdf)
00032 {
00033     tdf->setPackage(this);
00034     m_frames.push_back(tdf);
00035     m_numSubTriggers=m_frames.size();
00036 }
00037 
00038 DayaBay::ReadoutTriggerDataPkg::ReadoutTriggerDataPkg(const DayaBay::ReadoutTriggerDataPkg& rh)
00039 {
00041     m_readout=0;
00043     m_frames.clear();
00044 
00045     std::vector<DayaBay::ReadoutTriggerDataFrame*> frames = rh.frames();
00046     std::vector<DayaBay::ReadoutTriggerDataFrame*>::iterator it, done=frames.end();
00047 
00048     if ( !rh.detector().isRPC() ) { // PMT frames
00049         for (it = frames.begin(); it != done; ++it) {
00050             DayaBay::ReadoutTriggerDataFrame *nf = new DayaBay::ReadoutTriggerDataFrame(**it);
00051             nf->setPackage(this);
00052             this->addFrame(nf);
00053         }
00054     } else { // need to deal with RPC frames separately
00055         for (it = frames.begin(); it != done; ++it) {
00056             DayaBay::ReadoutRpcTriggerDataFrame* rpcframe =
00057                 dynamic_cast<DayaBay::ReadoutRpcTriggerDataFrame*>(*it);
00058             // FIXME: should put some check on whether we realy get RPC frame
00059             // and handle propery the situation when we don't
00060             DayaBay::ReadoutTriggerDataFrame *nf = new DayaBay::ReadoutRpcTriggerDataFrame(*rpcframe);
00061             nf->setPackage(this);
00062             this->addFrame(nf);
00063         }
00064     }
00065 
00066     m_detector=rh.detector();
00067     m_trigNumber=rh.trigNumber();
00070     m_boardStatus=rh.boardStatus();
00071     m_localSN=rh.localSN();
00072 
00073 }
00074 
00075 DayaBay::ReadoutTriggerDataPkg& DayaBay::ReadoutTriggerDataPkg::operator=(const DayaBay::ReadoutTriggerDataPkg& rh)
00076 {
00077     if (this == &rh) return *this;
00078 
00079     std::vector<DayaBay::ReadoutTriggerDataFrame*> frames = rh.frames();
00080     std::vector<DayaBay::ReadoutTriggerDataFrame*> newframes;
00081 
00082     std::vector<DayaBay::ReadoutTriggerDataFrame*>::iterator it, done=frames.end();
00083 
00084     for (it = frames.begin(); it != done; ++it) {
00085         DayaBay::ReadoutTriggerDataFrame *nf = new DayaBay::ReadoutTriggerDataFrame(**it);
00086         nf->setPackage(this);
00087         this->addFrame(nf);
00088     }
00089     //this->setFrames(newframes);
00090     //this->setFrames(newframes);
00093     m_readout=0;
00094     m_detector=rh.detector();
00095     m_trigNumber=rh.trigNumber();
00098     m_boardStatus=rh.boardStatus();
00099     m_localSN=rh.localSN();
00100 
00101     return *this;
00102 }
00103 
00104 DayaBay::DaqLtb* DayaBay::ReadoutTriggerDataPkg::daqLtb() const {
00105     DaqLtb* result = new DaqLtb(m_trigNumber,
00106                                 // TODO: Fix this!
00107                                 0, //int rawTriggerTotal,
00108                                 m_boardStatus,
00109                                 m_detector);
00110     const TriggerFrameCollection::const_iterator finished = m_frames.end();
00111     for (TriggerFrameCollection::const_iterator frame = m_frames.begin();
00112          finished != frame;
00113          ++frame) {
00114         result->addFrame((*frame)->daqLtbFrame(m_detector));
00115     }
00116     return result;
00117 }
00118 
00119 
00120 DayaBay::DaqRtm* DayaBay::ReadoutTriggerDataPkg::daqRtm() const {
00121     if (!m_detector.isRPC()) {
00122         std::cerr<<"ERROR: ReadoutTriggerDataPkg::daqRtm(): Called for non-RPC detector."<<std::endl;
00123         return 0;
00124     }
00125     if (m_frames.size() == 0) {
00126         std::cerr<<"ERROR: ReadoutTriggerDataPkg::daqRtm(): Data package contains no frames, expected exactly 1."<<std::endl;
00127         return 0;
00128     }
00129     if (m_frames.size() != 1) {
00130         std::cerr<<"ERROR: ReadoutTriggerDataPkg::daqRtm(): Data package contains more than 1 frame, which is not expected for RPCs."<<std::endl;
00131         return 0;
00132     }
00133 
00134     const DayaBay::ReadoutTriggerDataFrame* trgframe = *(m_frames.begin());
00135     if (!trgframe) {
00136         std::cerr<<"ERROR: ReadoutTriggerDataPkg::daqRtm(): Zero pointer to frame found in the package."<<std::endl;
00137         return 0;
00138     }
00139     const DayaBay::ReadoutRpcTriggerDataFrame* rpctrgframe = trgframe->asRpcFrame();
00140     if (!rpctrgframe) {
00141         std::cerr<<"ERROR: ReadoutTriggerDataPkg::daqRtm(): The frame found in the package cannot be retrieved as an RPC trigger frame."<<std::endl;
00142         return 0;
00143     }
00144     return rpctrgframe->daqRtm(m_detector);
00145 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:01:16 for ReadoutEvent by doxygen 1.7.4