00001 #ifndef SourceModule_H 00002 #define SourceModule_H 00003 00004 #include <vector> 00005 #include <string> 00006 #include <inttypes.h> 00007 #include <fstream> 00008 00009 #include "FWCore/Framework/interface/ConfigurableInputSource.h" 00010 #include "DataFormats/FEDRawData/interface/FEDRawData.h" 00011 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" 00012 #include "DataFormats/Provenance/interface/Timestamp.h" 00013 00014 class LmfSource: public edm::ConfigurableInputSource{ 00015 private: 00016 struct IndexRecord{ 00017 uint32_t orbit; 00018 uint32_t filePos; 00019 // bool operator<(const IndexRecord& i) const { return orbit < i.orbit; } 00020 }; 00021 00022 public: 00023 LmfSource(const edm::ParameterSet& pset, 00024 const edm::InputSourceDescription& isd); 00025 virtual ~LmfSource(){} 00026 00027 private: 00030 virtual bool produce(edm::Event &e); 00031 00036 virtual void setRunAndEventInfo(); 00037 00038 bool openFile(int iFile); 00039 00040 bool readFileHeader(); 00041 00048 bool readEventWithinFile(bool doSkip); 00049 00054 std::string toString(edm::TimeValue_t& t) const; 00055 00056 00057 private: 00060 std::vector<std::string> fileNames_; 00061 00064 int iFile_; 00065 00068 FEDRawDataCollection fedColl_; 00069 00072 FEDRawData emptyFedBlock_; 00073 00077 int fedId_; 00078 00081 std::vector<uint32_t> header_; 00082 00083 static unsigned fileHeaderSize; 00084 00087 std::vector<uint32_t> fileHeader_; 00088 00089 00092 static unsigned char minDataFormatVersion_; 00093 00096 static unsigned char maxDataFormatVersion_; 00097 00101 bool filter() const; 00102 00107 bool readEvent(bool doSkip = false); 00108 00113 bool nextEventWithinFile(); 00114 00119 void checkFileNames(); 00120 00124 void readIndexTable(); 00125 00126 uint64_t timeStamp_; 00127 uint32_t lumiBlock_; 00128 uint32_t runNum_; 00129 uint32_t bx_; 00130 uint32_t eventNum_; 00131 uint32_t orbitNum_; 00132 00133 unsigned char dataFormatVers_; 00134 00135 std::ifstream in_; 00136 00139 bool rcRead_; 00140 00141 unsigned preScale_; 00142 00145 uint32_t iEvent_; 00146 00149 uint32_t iEventInFile_; 00150 00151 uint32_t indexTablePos_; 00152 00153 int calibTrig_; 00154 00155 int nFeds_; 00156 00160 std::vector<IndexRecord> indexTable_; 00161 00165 static const unsigned maxEvents_ = 1<<20; 00166 00170 static const unsigned maxEventSize_ = 1<<20; //1MB. (full DCC event is 49kB) 00171 00175 bool orderedRead_; 00176 00180 bool watchFileList_; 00181 00184 std::string fileListName_; 00185 00188 std::string inputDir_; 00189 00192 std::string currentFileName_; 00193 00194 std::ifstream fileList_; 00195 00198 int nSecondsToSleep_; 00199 00202 int verbosity_; 00203 }; 00204 #endif //SourceModule_H not defined 00205