#include <MicrorocXDaqReader.hh>
Inheritance diagram for MicrorocXDaqReader:
Public Member Functions | |
MicrorocXDaqReader (Run &aRun, std::string aFilefullPath, ui32 lastEventId, bool forceAnalog, std::set< unsigned int > *=NULL) | |
~MicrorocXDaqReader () | |
int | getNextEvent (Event &eventToFill) |
int | getAnalogData (Event &event) |
unsigned int | getSpecificData (const unsigned int nBytes) |
Static Public Member Functions | |
static const char * | type (const int subtype=0) |
Private Member Functions | |
void | localReset () |
Private Attributes | |
std::list< unsigned char > | rawdataList |
std::list< unsigned char >::const_iterator | itRawdata |
IO::LCReader * | lcReader |
bool | firstEvent |
Definition at line 36 of file MicrorocXDaqReader.hh.
MicrorocXDaqReader::MicrorocXDaqReader | ( | Run & | aRun, | |
std::string | aFilefullPath, | |||
ui32 | lastEventId, | |||
bool | forceAnalog, | |||
std::set< unsigned int > * | = NULL | |||
) |
MicrorocXDaqReader::~MicrorocXDaqReader | ( | ) |
static const char* MicrorocXDaqReader::type | ( | const int | subtype = 0 |
) | [inline, static] |
Reimplemented from MicrorocMergeReader.
Definition at line 40 of file MicrorocXDaqReader.hh.
Referenced by main().
00040 { return XDAQMR; };
int MicrorocXDaqReader::getNextEvent | ( | Event & | eventToFill | ) | [virtual] |
Implements MicrorocMergeReader.
Definition at line 99 of file MicrorocXDaqReader.cpp.
00100 { 00101 Level(0); 00102 ui16 dataFormat = run.getDataFormat(); 00103 00104 if (dataFormat == 0) { 00105 // first read of the file 00106 bcIdDifAbsOrgMap.clear(); 00107 // read file header 00108 dataFormat = 12; 00109 run.setDataFormat(dataFormat); 00110 00111 return NEW_CONFIG; 00112 } // end dataFormat == 0 00113 00114 // loops until a non-empty event has been found 00115 bool eventFound = false; 00116 while (! eventFound) 00117 { 00118 LCEvent* lcioEvt(0) ; 00119 lcioEvt = lcReader->readNextEvent() ; 00120 if ( lcioEvt == NULL ) // EOF reach 00121 { 00122 return LAST_FILE_EVENT; 00123 } 00124 00125 00126 // There is one more LCEvent 00127 //LCTOOLS::dumpEvent( lcioEvt ) ; 00128 if ( ! slowControlSet ) 00129 { 00130 // Read Slow control from database 00131 if ( event.getRun().getId() == 0 ) 00132 { // try to find run Id in lcioEvt 00133 run.setId(lcioEvt->getRunNumber()); 00134 FILE_LOG(logINFO) << "Set run Id from lcioEvent information[" << run.getId() << "]" << endl; 00135 } 00136 00137 00138 globalTime = (i64) ( lcioEvt->getTimeStamp()*1000 ); 00139 00140 run.setDaqSoftware(0); 00141 run.setCccFirmware(0); 00142 00143 IlcConfDb *ilcconf = IlcConfDb::getInstance(); 00144 if ( ilcconf != NULL ) 00145 { 00146 MicrorocSCReader scReader(run); 00147 scReader.parseSCFromDb(*ilcconf); 00148 slowControlSet = true; 00149 00150 00151 // Set dif Asu1Id and Asu2Id from XML as there is no available information in SlowControl 00152 Detector &det = run.getDetector(); 00153 const ChamberMap_t& chambers= det.getChambers(); 00154 for (ChamberMap_t::const_iterator chamberIt = chambers.begin(); chamberIt != chambers.end(); ++chamberIt) 00155 { 00156 Chamber& chamber = *(chamberIt->second); 00157 const DifMap_t& difs = chamber.getDifs(); 00158 for (DifMap_t::const_iterator difIt = difs.begin(); difIt != difs.end(); ++difIt) 00159 { 00160 Dif& dif = *(difIt->second); 00161 ui16 asuIndex = 1; 00162 const BoardMap_t& boards = dif.getBoards(); 00163 for (BoardMap_t::const_iterator boardIt = boards.begin(); boardIt != boards.end(); ++boardIt) 00164 { 00165 Board& board = *(boardIt->second); 00166 if ( asuIndex == 1 ) 00167 { 00168 dif.setAsu1Id(board.getId()); 00169 asuIndex++; 00170 FILE_LOG(logDEBUG) << "Set difid[" << dif.getId() << "] Asu1Id to[" << dif.getAsu1Id() << "]" << endl; 00171 } 00172 else if ( asuIndex == 2 ) 00173 { 00174 dif.setAsu2Id(board.getId()); 00175 FILE_LOG(logDEBUG) << "Set difid[" << dif.getId() << "] Asu2Id to[" << dif.getAsu2Id() << "]" << endl; 00176 } 00177 } 00178 } 00179 } 00180 00181 } 00182 00183 } 00184 if ( firstEvent ) 00185 { 00186 FILE_LOG(logINFO) << "firstEvent skip" << endl; 00187 firstEvent = false; 00188 // skip first event because of its corruption ??? 00189 } 00190 else if ( skipNbEvent != 0 && debugEventId < skipNbEvent) 00191 { 00192 debugEventId++; 00193 FILE_LOG(logINFO) << "skip event " << debugEventId << "\r" << flush; 00194 } 00195 else if ( skipNbEvent == debugEventId ) 00196 { 00197 FILE_LOG(logINFO) << skipNbEvent << " event(s) have been skipped" << debugEventId << endl; 00198 debugEventId++; 00199 } 00200 00201 else 00202 { 00203 // vnames to store lcioEvt collections name 00204 std::vector<std::string >* vnames; 00205 try 00206 { 00207 vnames= (std::vector<std::string >*)lcioEvt->getCollectionNames(); 00208 for ( vector<std::string >::iterator it = vnames->begin(); it!= vnames->end(); it++) 00209 { 00210 if ((*it).compare("RU_XDAQ")==0) 00211 { 00212 EVENT::LCCollection* col= lcioEvt->getCollection(*it); 00213 00214 for (int difRawDataIndex=0;difRawDataIndex<col->getNumberOfElements(); difRawDataIndex++) 00215 { 00216 IMPL::LCGenericObjectImpl* go= (IMPL::LCGenericObjectImpl*) col->getElementAt(difRawDataIndex); 00217 int rusize =go->getNInt(); 00218 if ( rusize == 56 ) continue; // skip first RU_XDAQ si tsille est 56 int 00219 00220 int shift=-1; 00221 ui16 nbInt = go->getNInt(); 00222 00223 00224 unsigned int buf[go->getNInt()]; 00225 00226 for (int k=0; k < (go->getNInt() );k++) { buf[k] = go->getIntVal(k); } 00227 // skip first NBBYTETOSKIP ( 94 ) bytes 00228 // then fill rawdataList with unsigned char 00229 unsigned char* bufChar = ( unsigned char* ) &(buf); 00230 ui16 rapport = (ui16) (sizeof(unsigned int ) / sizeof ( unsigned char) ); 00231 00232 rawdataList.clear(); 00233 for ( ui32 j = NBBYTETOSKIP ; j < go->getNInt()*rapport ; j++ ) 00234 { 00235 rawdataList.push_back(*(bufChar+j)); 00236 // sleep(1); 00237 } 00238 //cout << endl; 00239 00240 itRawdata = rawdataList.begin(); 00241 00242 MicrorocMergeReader::decodeData(event); 00243 00244 } // end for data for dif 00245 eventFound = true ; 00246 //event.setId(++lastEventId); 00247 } // ed if collection = XU_XDAQ 00248 } // end for collection in event 00249 } 00250 catch (IOException& e) 00251 { 00252 std::cout << e.what() << std::endl ; 00253 std::string s=e.what();s+=__PRETTY_FUNCTION__; 00254 exit(-1); 00255 } 00256 catch (...) 00257 { 00258 std::cout<<" unknow io exeption "<<std::endl; 00259 exit(-1); 00260 } 00261 /*DEBUG */ unsigned int globalHeader = 0XB0; 00262 } // end else not first event 00263 00264 00265 }// end while event not found 00266 00267 if ( event.getChannelHitSize() > 0 ) 00268 { 00269 event.setId(++lastEventId); 00270 return EVENT_CORRECT; 00271 } 00272 else 00273 { 00274 return EVENT_ERROR; 00275 } 00276 00277 00278 00279 00280 00281 return 0; 00282 }
int MicrorocXDaqReader::getAnalogData | ( | Event & | event | ) |
unsigned int MicrorocXDaqReader::getSpecificData | ( | const unsigned int | nBytes | ) | [virtual] |
Implements MicrorocMergeReader.
Definition at line 285 of file MicrorocXDaqReader.cpp.
00286 { 00287 unsigned int result = 0; 00288 00289 fileError = 0; 00290 for (unsigned int byte = 0; byte < nBytes; ++byte) 00291 { 00292 unsigned int data = *itRawdata; 00293 itRawdata++; 00294 if ( computeCrc ) 00295 { 00296 // if ( data != 0xc4 && data != 0xd4 ) 00297 { 00298 crc->compute(data) ; 00299 } 00300 } 00301 result = (result << 8) + data; 00302 } 00303 00304 putData(result, nBytes); 00305 00306 return result; 00307 }
void MicrorocXDaqReader::localReset | ( | ) | [private] |
Reimplemented from MicrorocMergeReader.
Definition at line 87 of file MicrorocXDaqReader.cpp.
00088 { 00089 rawdataList.clear(); 00090 }
std::list<unsigned char> MicrorocXDaqReader::rawdataList [private] |
Definition at line 58 of file MicrorocXDaqReader.hh.
Referenced by getNextEvent(), and localReset().
std::list<unsigned char>::const_iterator MicrorocXDaqReader::itRawdata [private] |
Definition at line 59 of file MicrorocXDaqReader.hh.
Referenced by getNextEvent(), and getSpecificData().
IO::LCReader* MicrorocXDaqReader::lcReader [private] |
Definition at line 61 of file MicrorocXDaqReader.hh.
Referenced by getNextEvent(), and ~MicrorocXDaqReader().
bool MicrorocXDaqReader::firstEvent [private] |