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

In This Package:

TESDemoOutput.cpp
Go to the documentation of this file.
00001 #include "src/TESDemoOutput.h"
00002 
00003 #include "Event/RegistrationSequence.h"
00004 #include "Event/TESDemoReadout.h"
00005 
00006 #include "DybKernel/IDybStorageSvc.h"
00007 #include "DybKernel/IArchiveTrimSvc.h"
00008 
00009 using namespace DayaBay;
00010 
00011 TESDemoOutput::TESDemoOutput( const std::string& name, 
00012                               ISvcLocator* pSvcLocator ) :
00013   GaudiAlgorithm(name,
00014                  pSvcLocator),
00015   p_storageSvc(0),
00016   p_trimSvc(0)
00017 {
00018   declareProperty("RegSeqPath",
00019                   m_regSeqPath="/Event/RegistrationSequence",
00020                   "Path, in the TES, where the RegistrationSequnce object is kept");
00021   declareProperty("ReadoutPath",
00022                   m_readoutPath="/Event/TESDemo/Readout",
00023                   "Path from which to retrieve the Readouts");
00024 }
00025 
00026 StatusCode TESDemoOutput::initialize() {
00027   
00028    info() << "in initialize" 
00029           << endreq;
00030    info() << m_regSeqPath 
00031           << endreq;
00032    
00033    StatusCode status = service("DybStorageSvc",
00034                                p_storageSvc);
00035    if (status.isFailure()) {
00036      return Error("Service [DybStorageSvc] not found",
00037                   status);
00038    }
00039 
00040    status = service("ArchiveTrimSvc",
00041                     p_trimSvc);
00042    if (status.isFailure()) {
00043      warning() << "Service [ArchiveTrimSvc] not found, will run output"
00044                << "at the end of each loop"
00045                << endreq;
00046      p_trimSvc = 0;
00047    }
00048 
00049    return StatusCode::SUCCESS;
00050 
00051 }
00052 
00053 StatusCode TESDemoOutput::execute() {
00054 
00055   SmartDataPtr<RegistrationSequence>  regSeq(eventSvc(),
00056                                              m_regSeqPath.value());
00057   if (0 == regSeq) {
00058     return Error("Failed to retrieve RegistrationSequence from Event Store");
00059   }
00060 
00061   regSeq->addRef();
00062   m_regSeqs.push_back(regSeq.ptr());
00063 
00064   TimeStamp now;
00065   if (0 != p_trimSvc) {
00066     SmartDataPtr<const TESDemoReadout>  readout(eventSvc(),
00067                                                 m_readoutPath.value());
00068     if (0 == readout) {
00069       return Error("Failed to retrieve readout from Event Store");
00070     }
00071     now = readout->timeStamp();
00072   }
00073 
00074   bool done = false;
00075   std::deque<RegistrationSequence*>::iterator entry = m_regSeqs.begin();
00076   while (!done &&
00077          m_regSeqs.end() != entry) {
00078     RegistrationSequence* element = *(entry);
00079     if (0 == p_trimSvc ||
00080         (now - TimeStamp(p_trimSvc->window(m_regSeqPath.value()))) > element->latest()) {
00081       p_storageSvc->store(*element);
00082       element->release();
00083       entry = m_regSeqs.erase(entry);
00084     } else {
00085       done = true;
00086     }
00087   }
00088   
00089   return StatusCode::SUCCESS;
00090 }
00091 
00092 StatusCode TESDemoOutput::finalize() {
00093 
00094   info() << "in finalize"
00095          << endreq;
00096 
00097   if (0 != p_storageSvc) {
00098     p_storageSvc->release();
00099   }
00100 
00101   return StatusCode::SUCCESS;
00102 
00103 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:09:00 for TESDemo by doxygen 1.7.4