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

In This Package:

DetailsFromRecordSvc.cc
Go to the documentation of this file.
00001 #include "DetailsFromRecordSvc.h"
00002 
00003 #include "FileReadoutFormat/CalibrationParametersRecord.h"
00004 #include "FileReadoutFormat/FileNameStrings.h"
00005 #include "FileReadoutFormat/FileStartRecord.h"
00006 #include "FileReadoutFormat/FileTraits.h"
00007 #include "FileReadoutFormat/RunParametersRecord.h"
00008 
00009 using DybDaq::CalibrationParametersRecord;
00010 using DybDaq::FileNameStrings;
00011 using DybDaq::FileStartRecord;
00012 using DybDaq::FileTraits;
00013 using DybDaq::RunParametersRecord;
00014 using std::vector;
00015 
00016 RunDetailsFromRecord::RunDetailsFromRecord(const RunParametersRecord& record) :
00017   m_record(record) {
00018 }
00019 
00020 RunDetailsFromRecord::~RunDetailsFromRecord() {
00021 }
00022 
00023 unsigned int RunDetailsFromRecord::runNumber() const {
00024   return m_record.runNumber();
00025 }
00026 
00027 const RunParametersRecord& RunDetailsFromRecord::record() const {
00028   return m_record;
00029 }
00030 
00031 const DaqRunDetails::DetectorList& RunDetailsFromRecord::detectors() const {
00032   return *((DetectorList*)0);
00033 }
00034 
00035 FileDetailsFromRecord::FileDetailsFromRecord(const FileStartRecord& record,
00036                                              const FileNameStrings& names) :
00037   m_record(record),
00038   m_names(names) {
00039 }
00040 
00041 FileDetailsFromRecord::~FileDetailsFromRecord() {
00042 }
00043 
00044 unsigned int FileDetailsFromRecord::fileNumber() const {
00045   return m_record.fileNumber();
00046 }
00047 
00048 std::string FileDetailsFromRecord::fileName() const {
00049   return m_names.fileBase() + ".data";
00050 }
00051 
00052 TimeStamp& FileDetailsFromRecord::whenStarted() const {
00053   return *((TimeStamp*)0);
00054 }
00055 
00056 using DayaBay::Detector;
00057 
00058 CalibDetailsFromRecord::CalibDetailsFromRecord(const DybDaq::CalibrationParametersRecord& record) :
00059   m_record(record) {
00060 }
00061 
00062 CalibDetailsFromRecord::~CalibDetailsFromRecord() {
00063 }
00064 
00065 Site::Site_t CalibDetailsFromRecord::convertSite(unsigned int site) const {
00066   if (site == FileTraits::kCalibratingEh1) {
00067     return Site::kDayaBay;
00068   }
00069   if (site == FileTraits::kCalibratingEh2) {
00070     return Site::kLingAo;
00071   }
00072   if (site == FileTraits::kCalibratingEh3) {
00073     return Site::kFar;
00074   }
00075   if (site == FileTraits::kCalibratingSab) {
00076     return Site::kSAB;
00077   }
00078   return Site::kUnknown;
00079 }
00080 
00081 DetectorId::DetectorId_t CalibDetailsFromRecord::convertDetectorId(unsigned int detector) const {
00082   if (detector == FileTraits::kCalibratingAd1) {
00083     return DetectorId::kAD1;
00084   }
00085   if (detector == FileTraits::kCalibratingAd2) {
00086     return DetectorId::kAD2;
00087   }
00088   if (detector == FileTraits::kCalibratingAd3) {
00089     return DetectorId::kAD3;
00090   }
00091   if (detector == FileTraits::kCalibratingAd4) {
00092     return DetectorId::kAD4;
00093   }
00094   return DetectorId::kUnknown;
00095 }
00096 
00097 DayaBay::Calibration::SourceType::SourceType_t CalibDetailsFromRecord::convertSource(unsigned int source) const {
00098   if (source == FileTraits::kLedSource) {
00099     return DayaBay::Calibration::SourceType::kLED;
00100   }
00101   if (source == FileTraits::kAmC_Co60Source) {
00102     return DayaBay::Calibration::SourceType::kAmC_Co60;;
00103   }
00104   if (source == FileTraits::kGe68Source) {
00105     return DayaBay::Calibration::SourceType::kGe68;
00106   }
00107   return DayaBay::Calibration::SourceType::kUnknown;
00108 }
00109 
00110 DetectorId::DetectorId_t CalibDetailsFromRecord::detectorId() const {
00111   return convertDetectorId(m_record.detector());
00112 }
00113 
00114 Detector CalibDetailsFromRecord::adNumber() const {
00115   const unsigned int number = m_record.adNumber();
00116   return Detector(convertSite(number & 0xf0),
00117                   convertDetectorId(number &0x0f));
00118 }
00119 
00120 DayaBay::Calibration::SourceType::SourceType_t CalibDetailsFromRecord::sourceIdA() const {
00121   return convertSource(m_record.sourceA());
00122 }
00123 
00124 int CalibDetailsFromRecord::zPositionA() const {
00125   return m_record.zPositionA();
00126 }
00127 
00128 DayaBay::Calibration::SourceType::SourceType_t CalibDetailsFromRecord::sourceIdB() const {
00129   return convertSource(m_record.sourceB());
00130 }
00131 
00132 int CalibDetailsFromRecord::zPositionB() const {
00133   return m_record.zPositionB();
00134 }
00135 
00136 DayaBay::Calibration::SourceType::SourceType_t CalibDetailsFromRecord::sourceIdC() const {
00137   return convertSource(m_record.sourceC());
00138 }
00139 
00140 
00141 int CalibDetailsFromRecord::zPositionC() const {
00142   return m_record.zPositionC();
00143 }
00144 
00145 int CalibDetailsFromRecord::duration() const {
00146   return m_record.duration();
00147 }
00148 
00149 int CalibDetailsFromRecord::led1() const {
00150   return m_record.led1();
00151 }
00152 
00153 int CalibDetailsFromRecord::led2() const {
00154   return m_record.led2();
00155 }
00156 
00157 int CalibDetailsFromRecord::led1Voltage() const {
00158   return m_record.led1Voltage();
00159 }
00160 
00161 int CalibDetailsFromRecord::led2Voltage() const {
00162   return m_record.led2Voltage();
00163 }
00164 
00165 int CalibDetailsFromRecord::ledFrequency() const {
00166   return m_record.ledFrequency();
00167 }
00168 
00169 int CalibDetailsFromRecord::ledPulseSeparation() const {
00170   return m_record.ledPulseSeparation();
00171 }
00172 
00173 int CalibDetailsFromRecord::ltbMode() const {
00174   return m_record.ltbMode();
00175 }
00176 
00177 int CalibDetailsFromRecord::motorPower() const {
00178   return m_record.motorPower();
00179 }
00180 
00181 int CalibDetailsFromRecord::cameraPower() const {
00182   return m_record.cameraPower();
00183 }
00184 
00185 bool CalibDetailsFromRecord::ledFlashing() const {
00186     return false;
00187 }
00188 
00189 bool CalibDetailsFromRecord::homeA() const {
00190     return false;
00191 }
00192 
00193 bool CalibDetailsFromRecord::homeB() const {
00194     return false;
00195 }
00196 
00197 bool CalibDetailsFromRecord::homeC() const {
00198     return false;
00199 }
00200 
00201 #include "DaqReadoutSvc/IDaqReadoutSvc.h"
00202 
00203 #include "GaudiKernel/GaudiException.h"
00204 
00205 DetailsFromRecordSvc::DetailsFromRecordSvc(const std::string& name,
00206                                          ISvcLocator* svc) :
00207   Service(name,
00208           svc),
00209   m_daqReadoutSvc(0),
00210   m_lastTime(0),
00211   m_lastDate(0),
00212   m_lastFile(0),
00213   m_runDetails(0),
00214   m_fileDetails(0),
00215   m_calibDetails(new vector<CalibDetailsFromRecord*>())
00216 {
00217 }
00218 
00219 DetailsFromRecordSvc::~DetailsFromRecordSvc() {
00220 }
00221 
00222 StatusCode DetailsFromRecordSvc::queryInterface(const InterfaceID& id, 
00223                                                void** interface) {
00224   if (IDaqDetailsSvc::interfaceID().versionMatch(id)) {
00225     // Good enough. Return this object
00226     *interface = dynamic_cast<IDaqDetailsSvc*>(this);
00227     addRef();
00228     return StatusCode::SUCCESS;
00229   }
00230   // Try base class
00231   return Service::queryInterface(id,
00232                                  interface);
00233 }
00234 
00235 StatusCode DetailsFromRecordSvc::initialize() {
00236   StatusCode status = Service::initialize();
00237   if (status.isFailure()) {
00238     throw GaudiException("Could not initialize super class",
00239                          name(),
00240                          status);
00241   }
00242   status = service("DaqReadoutSvc",
00243                    m_daqReadoutSvc);
00244   if (status.isFailure() ) {
00245     return status;
00246   }
00247   return StatusCode::SUCCESS;
00248 }
00249 
00250 StatusCode DetailsFromRecordSvc::finalize() {
00251   const vector<CalibDetailsFromRecord*>::const_iterator finished = m_calibDetails->end();
00252   for (vector<CalibDetailsFromRecord*>::const_iterator calib = m_calibDetails->begin();
00253        finished != calib;
00254        ++calib) {
00255        delete *calib;
00256   }
00257   if (0 != m_fileDetails) {
00258     delete m_fileDetails;
00259   }
00260   if (0 != m_runDetails) {
00261     delete m_runDetails;
00262   }
00263   if( 0 != m_daqReadoutSvc ) {
00264     m_daqReadoutSvc->release();
00265   }
00266   return Service::finalize();
00267 }
00268 
00269 void DetailsFromRecordSvc::flushExpiredDetails() const {
00270   bool recordValid = m_daqReadoutSvc->hasFileStartRecord();
00271   const DybDaq::FileStartRecord& record = m_daqReadoutSvc->fileStartRecord();
00272   if (recordValid && m_lastTime == record.time() && m_lastDate == record.date() && m_lastFile == record.fileNumber()) {
00273       return;
00274   }
00275   const vector<CalibDetailsFromRecord*>::const_iterator finished = m_calibDetails->end();
00276   for (vector<CalibDetailsFromRecord*>::const_iterator calib;
00277        finished != calib;
00278        ++calib) {
00279        delete *calib;
00280   }
00281   m_calibDetails->clear();
00282   if (0 != m_fileDetails) {
00283     delete m_fileDetails;
00284     m_fileDetails = 0;
00285   }
00286   if (0 != m_runDetails) {
00287     delete m_runDetails;
00288     m_runDetails = 0;
00289   }
00290   if (!recordValid) {
00291     return;
00292   }
00293   m_lastTime = record.time();
00294   m_lastDate = record.date();
00295   m_lastFile = record.fileNumber();
00296   if (m_daqReadoutSvc->hasRunParametersRecord()) {
00297     m_runDetails = new RunDetailsFromRecord(m_daqReadoutSvc->runParametersRecord());
00298   }
00299   m_fileDetails = new FileDetailsFromRecord(record,
00300                                             m_daqReadoutSvc->fileNameStrings());
00301   const int finished2 = m_daqReadoutSvc->calibrationParametersRecordCount();
00302   for (int calib = 0;
00303        finished2 != calib;
00304        ++calib) {
00305       m_calibDetails->push_back(new CalibDetailsFromRecord(m_daqReadoutSvc->calibrationParametersRecord(calib)));
00306   }
00307 }
00308 
00309 bool DetailsFromRecordSvc::hasRunDetails(const ServiceMode& /* svcMode */) const {
00310   flushExpiredDetails();
00311   return 0 != m_runDetails;
00312 }
00313 
00314 const DaqRunDetails& DetailsFromRecordSvc::runDetails(const ServiceMode& /* svcMode */) const {
00315   flushExpiredDetails();
00316   return *m_runDetails;
00317 }
00318 
00319 bool DetailsFromRecordSvc::hasFileDetails(const ServiceMode& /* svcMode */) const {
00320   flushExpiredDetails();
00321   return 0 != m_fileDetails;
00322 }
00323 
00324 const DaqFileDetails& DetailsFromRecordSvc::fileDetails(const ServiceMode& /* svcMode */) const {
00325   flushExpiredDetails();
00326   return *m_fileDetails;
00327 }
00328 
00329 int DetailsFromRecordSvc::calibDetailsCount(const ServiceMode& /* svcMode */) const {
00330   flushExpiredDetails();
00331   return m_calibDetails->size();
00332 }
00333 
00334 const DaqCalibDetails& DetailsFromRecordSvc::calibDetails(const int index,
00335                                                           const ServiceMode& /* svcMode */ ) const {
00336   flushExpiredDetails();
00337   return *(m_calibDetails->at(index));
00338 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:15:31 for DaqFormatModules by doxygen 1.7.4