#include <IORawData/EcalTBInputService/src/EcalTBDaqFileReader.h>
Public Member Functions | |
bool | checkEndOfFile () const |
EcalTBDaqFileReader () | |
Constructor. | |
bool | fillDaqEventData () |
const EcalTBDaqFile * | getDaqFile () const |
int | getEventLength () const |
int | getEventNumber () const |
const FedDataPair & | getFedData () const |
int | getFedId () const |
int | getRunNumber () const |
void | initialize (const std::string &filename, bool isBinary) |
bool | isInitialized () |
void | setInitialized (bool value) |
virtual | ~EcalTBDaqFileReader () |
Destructor. | |
Protected Attributes | |
bool | initialized_ |
bool | isBinary_ |
Private Member Functions | |
void | setFEDHeader () |
Private Attributes | |
FedDataPair | cachedData_ |
vector< int > | headValues_ |
EcalTBDaqFile * | inputFile_ |
Definition at line 22 of file EcalTBDaqFileReader.h.
EcalTBDaqFileReader::EcalTBDaqFileReader | ( | ) |
Constructor.
Definition at line 18 of file EcalTBDaqFileReader.cc.
References cachedData_, FedDataPair::fedData, FedDataPair::len, and LogDebug.
00018 : initialized_(false), inputFile_(0) { 00019 LogDebug("EcalTBInputService") << "@SUB=EcalTBDaqFileReader"; 00020 00021 // Reset cachedData_ 00022 cachedData_.len=0; 00023 cachedData_.fedData=0; 00024 00025 }
EcalTBDaqFileReader::~EcalTBDaqFileReader | ( | ) | [virtual] |
Destructor.
Definition at line 27 of file EcalTBDaqFileReader.cc.
References cachedData_, EcalTBDaqFile::close(), FedDataPair::fedData, inputFile_, FedDataPair::len, and LogDebug.
00027 { 00028 00029 LogDebug("EcalTBInputService") << "@SUB=EcalTBDaqFileReader"; 00030 00031 if(inputFile_) { 00032 inputFile_->close(); 00033 delete inputFile_; 00034 inputFile_=0; 00035 } 00036 00037 //Cleaning the event 00038 if (cachedData_.len > 0) { 00039 delete[] cachedData_.fedData; 00040 cachedData_.len = 0; 00041 } 00042 00043 }
bool EcalTBDaqFileReader::checkEndOfFile | ( | ) | const |
Definition at line 174 of file EcalTBDaqFileReader.cc.
References EcalTBDaqFile::checkEndOfFile(), and inputFile_.
Referenced by DAQEcalTBInputService::setRunAndEventInfo().
00175 { 00176 return inputFile_->checkEndOfFile(); 00177 }
bool EcalTBDaqFileReader::fillDaqEventData | ( | ) |
Definition at line 80 of file EcalTBDaqFileReader.cc.
References cachedData_, EcalTBDaqFile::checkEndOfFile(), FedDataPair::fedData, EcalTBDaqFile::getEventData(), getFedId(), i, inputFile_, FedDataPair::len, and setFEDHeader().
Referenced by DAQEcalTBInputService::setRunAndEventInfo().
00080 { 00081 // cout<< "EcalTBDaqFileReader::fillDaqEventData() beginning " << endl; 00082 const int MAXFEDID = 1024; 00083 00084 //Cleaning the event before filling 00085 if (cachedData_.len > 0) { 00086 delete[] cachedData_.fedData; 00087 cachedData_.len = 0; 00088 } 00089 00090 pair<int,int> fedInfo; //int =FED id, int = event data length 00091 try 00092 { 00093 00094 //checkEndOfEvent()replaced by tru + getEventTrailer(); 00095 00096 if( inputFile_->checkEndOfFile() ) throw 1; 00097 00098 // FedDataPair is struct: event lenght + pointer to beginning of event 00099 if (!inputFile_->getEventData(cachedData_)) 00100 throw 2; 00101 // extracting header information from event 00102 setFEDHeader(); 00103 00104 fedInfo.first=getFedId(); 00105 fedInfo.second = cachedData_.len; 00106 00107 // cout << " fillDaqEventData Fed Id " << fedInfo.first << " getEventLength() " 00108 // << getEventLength() << " run " << getRunNumber() << " Ev " 00109 // << getEventNumber() << endl; 00110 00111 00112 // EventID ev( getRunNumber(), getEventNumber() ); 00113 // cID=ev; 00114 00115 if(fedInfo.first<0) 00116 { 00117 LogError("EcalTBInputService") << "@SUB=EcalTBDaqFileReader::addFEDRawData" << "negative FED Id. Adding no data"; 00118 throw 2; 00119 } 00120 else if (fedInfo.first>MAXFEDID) 00121 { 00122 LogError("EcalTBInputService") << "@SUB=EcalTBDaqFileReader::addFEDRawData" << "FED Id(" << fedInfo.first << ") greater than maximum allowed (" << MAXFEDID << "). Adding no data"; 00123 throw 3; 00124 } 00125 return true; 00126 } 00127 catch(int i) 00128 { 00129 if (i==1) 00130 { 00131 LogInfo("EcalTBInputService") << "@SUB=EcalTBDaqFileReader::fillDaqEventData" << "END OF FILE REACHED. No information read for the requested event"; 00132 return false; 00133 } 00134 else 00135 { 00136 LogError("EcalTBInputService") << "@SUB=EcalTBDaqFileReader::fillDaqEventData" << "unkown exception"; 00137 return false; 00138 } 00139 } 00140 }
const EcalTBDaqFile* EcalTBDaqFileReader::getDaqFile | ( | ) | const [inline] |
Definition at line 43 of file EcalTBDaqFileReader.h.
References inputFile_.
00043 { return inputFile_; }
int EcalTBDaqFileReader::getEventLength | ( | ) | const [inline] |
Definition at line 58 of file EcalTBDaqFileReader.h.
References headValues_.
00058 {return headValues_[2];}
int EcalTBDaqFileReader::getEventNumber | ( | ) | const [inline] |
Definition at line 55 of file EcalTBDaqFileReader.h.
References headValues_.
Referenced by DAQEcalTBInputService::produce(), and DAQEcalTBInputService::setRunAndEventInfo().
00055 {return headValues_[1];}
const FedDataPair& EcalTBDaqFileReader::getFedData | ( | ) | const [inline] |
Definition at line 49 of file EcalTBDaqFileReader.h.
References cachedData_.
Referenced by DAQEcalTBInputService::produce().
00049 { return cachedData_;}
int EcalTBDaqFileReader::getFedId | ( | ) | const [inline] |
Definition at line 52 of file EcalTBDaqFileReader.h.
References headValues_.
Referenced by fillDaqEventData(), and DAQEcalTBInputService::produce().
00052 {return headValues_[0];}
int EcalTBDaqFileReader::getRunNumber | ( | ) | const [inline] |
Definition at line 61 of file EcalTBDaqFileReader.h.
References headValues_.
Referenced by DAQEcalTBInputService::produce(), and DAQEcalTBInputService::setRunAndEventInfo().
00061 {return headValues_[3];}
Referenced by DAQEcalTBInputService::setRunAndEventInfo().
bool EcalTBDaqFileReader::isInitialized | ( | ) |
Definition at line 47 of file EcalTBDaqFileReader.cc.
References initialized_.
Referenced by DAQEcalTBInputService::setRunAndEventInfo().
00047 { 00048 00049 return initialized_; 00050 00051 }
void EcalTBDaqFileReader::setFEDHeader | ( | ) | [private] |
Definition at line 142 of file EcalTBDaqFileReader.cc.
References cachedData_, FedDataPair::fedData, headValues_, and i.
Referenced by fillDaqEventData().
00142 { 00143 00144 // cout<<"getting FED Header "<< endl; 00145 int headsize=16; 00146 headValues_.clear(); 00147 00148 unsigned long* buf = reinterpret_cast<unsigned long*>(cachedData_.fedData); 00149 // int val=0; 00150 00151 for ( int i=0; i< headsize/4; ++i) { 00152 // cout << i << " " << hex << buf << dec << endl ; 00153 00154 if ( i==0) { 00155 headValues_.push_back((*buf>>8)&0xFFF); // DCC id 00156 00157 } else if ( i==1) { 00158 headValues_.push_back( (*buf)&0xFFFFFF); // Lv1 number 00159 // cout << " LV1 " << ((*buf)&0xFFFFFF) << endl; 00160 } else if ( i==2) { 00161 headValues_.push_back( ((*buf)&0xFFFFFF)*8 ); // Event length 00162 // cout << " Event length " << ((*buf)&0xFFFFFF)*8 << endl; 00163 } else if ( i==3) { 00164 // int runN= (*buf)&0xFFFFFF; 00165 // cout << " runN " << runN << endl; 00166 headValues_.push_back( (*buf)&0xFFFFFF); // Run NUmber 00167 00168 } 00169 buf+=1; 00170 } 00171 00172 }
Definition at line 45 of file EcalTBDaqFileReader.cc.
References initialized_.
00045 {initialized_=value;}
FedDataPair EcalTBDaqFileReader::cachedData_ [private] |
Definition at line 76 of file EcalTBDaqFileReader.h.
Referenced by EcalTBDaqFileReader(), fillDaqEventData(), getFedData(), setFEDHeader(), and ~EcalTBDaqFileReader().
vector<int> EcalTBDaqFileReader::headValues_ [private] |
Definition at line 75 of file EcalTBDaqFileReader.h.
Referenced by getEventLength(), getEventNumber(), getFedId(), getRunNumber(), and setFEDHeader().
bool EcalTBDaqFileReader::initialized_ [protected] |
Definition at line 65 of file EcalTBDaqFileReader.h.
Referenced by isInitialized(), and setInitialized().
EcalTBDaqFile* EcalTBDaqFileReader::inputFile_ [private] |
Definition at line 73 of file EcalTBDaqFileReader.h.
Referenced by checkEndOfFile(), fillDaqEventData(), getDaqFile(), and ~EcalTBDaqFileReader().
bool EcalTBDaqFileReader::isBinary_ [protected] |
Definition at line 66 of file EcalTBDaqFileReader.h.