00001 00010 #ifndef DATALOADERALG_H 00011 #define DATALOADERALG_H 00012 00013 00014 #include "DybAlg/DybAlgorithm.h" 00015 #include "Event/ReadoutHeader.h" 00016 #include "Conventions/Site.h" 00017 #include "Conventions/DetectorId.h" 00018 #include "Conventions/Electronics.h" 00019 #include "Conventions/Trigger.h" 00020 00021 #include <vector> 00022 #include <string> 00023 00024 namespace DayaBay { 00025 class RawEvent; 00026 class LocalTriggerData; 00027 class RawDataReader; 00028 class Detector; 00029 class ReadoutPmtCrate; 00030 } 00031 00032 class DataLoaderAlg : public DybAlgorithm<DayaBay::ReadoutHeader> 00033 { 00034 00035 public: 00036 00037 DataLoaderAlg(const std::string& name, ISvcLocator* pSvcLocator); 00038 virtual ~DataLoaderAlg(); 00039 00040 virtual StatusCode initialize(); 00041 virtual StatusCode execute(); 00042 virtual StatusCode finalize(); 00043 00044 private: 00045 StatusCode openNextFile(); 00046 StatusCode readNextEvent(DayaBay::RawEvent*& nextEvent); 00047 StatusCode loadEventData(DayaBay::RawEvent* event, 00048 DayaBay::ReadoutHeader* readoutHeader); 00049 StatusCode findTriggerTime(DayaBay::RawEvent* event, 00050 TimeStamp& triggerTime); 00051 Site::Site_t convertSite(unsigned int daqSiteId); 00052 DetectorId::DetectorId_t convertDetector(unsigned int daqDetectorId); 00053 int convertConnector(unsigned int daqChannelId); 00054 int convertBoard(unsigned int daqSlotId); 00055 DayaBay::Trigger::TriggerType_t convertTriggerType( 00056 DayaBay::LocalTriggerData* ltbData, 00057 const DayaBay::Detector* detector); 00058 TimeStamp convertTriggerTime(DayaBay::LocalTriggerData* ltbData); 00059 DayaBay::FeeGain::FeeGain_t convertAdcRange(unsigned int daqAdcRange); 00060 StatusCode unpackEvent(DayaBay::RawEvent* event, 00061 DayaBay::Readout* readout); 00062 StatusCode unpackLtbModule(DayaBay::RawModule* module, 00063 DayaBay::Readout* readout); 00064 StatusCode unpackFeeModule(DayaBay::RawModule* module, 00065 DayaBay::ReadoutPmtCrate* readout); 00066 00067 private: 00068 00069 // Property InputFiles - List of input files 00070 std::vector<std::string> m_inputFiles; 00071 // Property UsePacked - Load packed data 00072 bool m_usePacked; 00073 // Property UseUnpacked - Load unpacked data 00074 bool m_useUnpacked; 00075 00076 // Handle to data reader 00077 DayaBay::RawDataReader* m_reader; 00078 // Current file index 00079 unsigned int m_fileIndex; 00080 // State variables to fix lack of 'year' in UTC-formatted trigger time 00081 unsigned int m_fileYear; 00082 unsigned int m_fileMonth; 00083 unsigned int m_fileDay; 00084 unsigned int m_utcDay; 00085 }; 00086 00087 #endif // DATALOADERALG_H