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

In This Package:

SaveB4TrimAesSvc.cpp
Go to the documentation of this file.
00001 
00002 #include "SaveB4TrimAesSvc.h"
00003 #include "GaudiKernel/MsgStream.h"
00004 #include "GaudiKernel/IDataManagerSvc.h"
00005 #include "GaudiKernel/DataSvc.h"
00006 #include "DataUtilities/DybArchiveList.h"
00007 #include "Event/RegistrationSequence.h"
00008 
00009 SaveB4TrimAesSvc::SaveB4TrimAesSvc(const std::string& name,
00010                                  ISvcLocator* svc) : 
00011   Service(name,svc)
00012 {
00013 }
00014 
00015 StatusCode SaveB4TrimAesSvc::queryInterface(const InterfaceID& id,
00016                                             void** interface) 
00017 {
00018   MsgStream log(msgSvc(), name());
00019 
00020   if (ISaveB4TrimAesSvc::interfaceID().versionMatch(id)) {
00021     // If good enough match return this object.
00022     *interface = (ISaveB4TrimAesSvc*)this;
00023     addRef();
00024     // log<<MSG::DEBUG<<"match"<<endreq;
00025   } else {
00026     // Interface is not directly available: try out a base class.
00027     // log<<MSG::DEBUG<<"no match"<<endreq;
00028     return Service::queryInterface(id,interface);
00029   }
00030 
00031   return StatusCode::SUCCESS;
00032 }
00033 
00034 StatusCode SaveB4TrimAesSvc::initialize() 
00035 {
00036   return Service::initialize();
00037 }
00038 
00039 StatusCode SaveB4TrimAesSvc::finalize() 
00040 {
00041   return Service::finalize();
00042 }
00043 
00044 StatusCode SaveB4TrimAesSvc::store(const std::string& regSeqLocation,
00045                                    IDybStorageSvc*  dybStorageSvc,
00046                                    IDataManagerSvc* aes,
00047                                    IArchiveTrimSvc* archiveTrimSvc,
00048                                    const TimeStamp& now)
00049 {
00050   MsgStream log(msgSvc(), name());
00051 
00052   // get window for RegistrationSequence
00053   double window = archiveTrimSvc->window(regSeqLocation);
00054 
00055   // Threshold
00056   TimeStamp thres = now;
00057   thres.Add(-1.0 * window);
00058 
00059   // Get DataObject
00060   DataObject* pObj=0;
00061   //log<<MSG::DEBUG<<regSeqLocation<<endreq;
00062   //log<<MSG::DEBUG<<aes<<endreq;
00063 
00064   // Cast to pAes
00065   DataSvc* pAes=0;
00066   try{
00067     pAes=dynamic_cast<DataSvc*>(aes);
00068   }
00069   catch(...) {
00070     log<<MSG::ERROR<<"Failed to AES"<<endreq;
00071     return StatusCode::FAILURE;
00072   }
00073 
00074   StatusCode sc = pAes->retrieveObject(regSeqLocation,pObj);
00075   if(sc.isFailure()) {
00076     log<<MSG::ERROR<<"Failed to get data object"<<endreq;
00077     return StatusCode::FAILURE;
00078   }
00079   // Get RegSeqList
00080   DybArchiveList* pRegSeqList=0;
00081   try{
00082     pRegSeqList=dynamic_cast<DybArchiveList*>(pObj);
00083   }
00084   catch (...) {
00085     log<<MSG::ERROR<<"Failed to get DybArchiveList"<<endreq;
00086     return StatusCode::FAILURE;
00087   }
00088 
00089 
00090   // Traverse AES /Event/RegistrationSequence
00091   DybArchiveList::reverse_iterator iter;
00092   DayaBay::RegistrationSequence* pRS=0;
00093   
00094   for(iter=pRegSeqList->rbegin();iter!=pRegSeqList->rend();++iter) {
00095     
00096     pObj=*iter;
00097     try{
00098       pRS=dynamic_cast<DayaBay::RegistrationSequence*>(pObj);
00099     }
00100     catch (...) {
00101       log<<MSG::ERROR<<"Failed to get RegistrationSequence"<<endreq;
00102       return StatusCode::FAILURE;
00103     }
00104 
00105     // This must be consistent with TrimmingAgent
00106     if(pRS->earliest()<=thres) {
00107       // time to save
00108       sc = dybStorageSvc->store(*pRS);
00109     }
00110     else {
00111     }
00112   }
00113 
00114   return StatusCode::SUCCESS;
00115 }
00116 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:09:08 for DybEventMgr by doxygen 1.7.4