00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdio.h>
00024 #include <errno.h>
00025
00026 #include "mTypes.h"
00027
00028 #include "parser/MicrorocMergeReader.hh"
00029 #include "parser/AcquisitionParser.hh"
00030 #include "parser/MicrorocSCReader.hh"
00031
00032 #include "event/Event.hh"
00033
00034 #include "geometry/Chamber.hh"
00035 #include "geometry/Board.hh"
00036 #include "geometry/Dif.hh"
00037 #include "geometry/MicrorocChip.hh"
00038 #include "geometry/Detector.hh"
00039
00040 #include "tools/Toolbox.hh"
00041 #include "tools/SteerDesc.hh"
00042 #include "tools/Log.hh"
00043 #include "tools/MicroException.hh"
00044
00045 #include <iostream>
00046 #include <iomanip>
00047
00048 using namespace std;
00049
00050
00051 MicrorocMergeReader::MicrorocMergeReader(Run& aRun, FILE *aFile, ui32 lastEventId, bool _forceAnalog, set<unsigned int>*_difList) : MicrorocReader(aRun, aFile, lastEventId), slowControlSet(false), difList(_difList) , hexTemperatureAsu1(0), hexTemperatureAsu2(0), hexTemperatureDif(0), nbChipPerLine(0), analogDataActivate(false), forceAnalog(_forceAnalog), debugEventId(0)
00052
00053 {
00054 FILE_LOG(logDEBUG1) << "--MicrorocMergeReader constructor()"<< endl;
00055 FILE_LOG(logDEBUG) << "MicrorocMergeReader Constructeur crc adr[" << crc << "]" << endl;
00056
00057 for ( ui16 line = 0 ; line < NBLINE ; line++)
00058 {
00059 analogDataActivatedLine[line] = false;
00060 }
00061
00062
00063 localReset();
00064 }
00065
00066
00067 MicrorocMergeReader::~MicrorocMergeReader()
00068 {
00069 FILE_LOG(logDEBUG1)<< "----MicrorocMergeReader destructor"<< endl;
00070 }
00071
00072
00073
00074 void MicrorocMergeReader::localReset()
00075 {
00076 reset();
00077 slowControlSet = false;
00078 hexTemperatureAsu1 = 0;
00079 hexTemperatureAsu2 = 0;
00080 hexTemperatureDif = 0;
00081
00082 }
00083
00084
00085 int MicrorocMergeReader::decodeData(Event& event)
00086 {
00087 unsigned int globalHeader = getSpecificData(1);
00088 if (fileError == EOF)
00089 {
00090 FILE_LOG(logDEBUG) << " END OF DATA FILE" << endl;
00091 reset();
00092 return(LAST_FILE_EVENT);
00093 }
00094
00095 FILE_LOG(logDEBUG) << "Header: [0x"<< hex << globalHeader << "]" << endl;
00096
00097
00098 if (globalHeader == 0xB1) {
00099
00100 getScData();
00101 }
00102 else if (globalHeader == 0xB0) {
00103
00104 this->analogData.clear();
00105 FILE_LOG(logDEBUG) << " 0xB0 found " << hex << globalHeader << dec << endl;
00106 getAcqData(event);
00107 return true;
00108 }
00109 else if (globalHeader == 0xBB) {
00110
00111 FILE_LOG(logDEBUG) << "TEMPERATURE FILL 0xBB found " << hex << globalHeader << dec << endl;
00112 getAcqData(event,true);
00113 return true;
00114 }
00115 else {
00116 FILE_LOG(logERROR) << " parsing file error. global header error : " << hex << globalHeader << dec << endl;
00117 event.setValidFlag(GLOBAL_HEADER_ERROR,false);
00118 }
00119 }
00120
00121
00122 int MicrorocMergeReader::getAcqData(Event& event, bool temperatureFill)
00123 {
00124
00125 ui32 nbanalogHit = 0;
00126 unsigned int nbHits = 0;
00127
00128 display(+1);
00129
00130
00131 this->setComputeCrcFlag(true);
00132
00133
00134 if ( temperatureFill )
00135 {
00136 FILE_LOG(logDEBUG) << " global header BB found" << endl;
00137 FILE_LOG(logDEBUG) << "crc->compute(0xBB)[ "<< crc <<"]" << endl;
00138 crc->compute(0xBB);
00139 }
00140 else
00141 {
00142 FILE_LOG(logDEBUG) << " global header B0 found" << endl;
00143 FILE_LOG(logDEBUG) << "crc->compute(0xB0)[ "<< crc <<"]" << endl;
00144 crc->compute(0xB0);
00145 }
00146
00147
00148
00149 bcId_Abs = 0;
00150 bcId_Dif = 0;
00151
00152 difId = getSpecificData(1);
00153
00154 difTriggerCounter = getSpecificData(4);
00155 informationCounter = getSpecificData(4);
00156 globalTriggerCounter = getSpecificData(4);
00157
00158 ui64 bcIdHigh = getSpecificData(2);
00159 ui64 bcIdLow = getSpecificData(4);
00160 bcId_Abs = (bcIdHigh << 32) + bcIdLow;
00161
00162
00163 bcId_Dif = getSpecificData(3);
00164
00165 bcId_AbsOrg = getbcIdAbsOrg(difId, bcId_Abs);
00166 display();
00167
00168 ui16 lineInfo = getSpecificData(1);
00169 display();
00170 FILE_LOG(logDEBUG) << " lineInfo[0x" <<hex << lineInfo << "]" << endl;
00171 ui16 nbLine = (lineInfo & 0xF0 ) >> 4;
00172 FILE_LOG(logDEBUG) << " nbline[0x" <<hex << nbLine << "]" << endl;
00173 ui16 usedLine = lineInfo & 0x0F;
00174 FILE_LOG(logDEBUG) << " usedLine[0x" <<hex << usedLine << "]" << endl;
00175
00176
00177 if ( temperatureFill )
00178 {
00179 hexTemperatureAsu1 = getSpecificData(4);
00180 display();
00181 FILE_LOG(logDEBUG) << " hexTemperatureAsu1[0x" <<hex << hexTemperatureAsu1 << "]" << endl;
00182 hexTemperatureAsu2 = getSpecificData(4);
00183 display();
00184 FILE_LOG(logDEBUG) << " hexTemperatureAsu2[0x" <<hex << hexTemperatureAsu2 << "]" << endl;
00185 hexTemperatureDif = getSpecificData(1) & 0xFF;
00186 display();
00187 FILE_LOG(logDEBUG) << " hexTemperatureDif[0x" <<hex << hexTemperatureDif << "]" << endl;
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 i16 hex16tempAsu1 = hexTemperatureAsu1 & 0x7FFF;
00201 float tempAsu1 = (float) ((hex16tempAsu1 / 16 ) / 8 );
00202 if (( hexTemperatureAsu1 & 0x8000) == 0x8000) { tempAsu1 = tempAsu1 / 2 ; }
00203 FILE_LOG(logDEBUG) << " TemperatureAsu1[" <<dec << tempAsu1 << "]" << endl;
00204
00205 i16 hex16tempAsu2 = hexTemperatureAsu2 & 0x7FFF;
00206 float tempAsu2 = (float) ((hex16tempAsu2 / 16 ) / 8 );
00207 if ( ( hexTemperatureAsu2 & 0x8000 ) == 0x8000) { tempAsu2 = tempAsu2 / 2 ; }
00208 FILE_LOG(logDEBUG) << " TemperatureAsu2[" <<dec << tempAsu2 << "]" << endl;
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 float Vlsb = 20.0;
00233 float V_adc = hexTemperatureDif * Vlsb;
00234 float V_lm20 = ( (6450. - V_adc) / 3.3 ) ;
00235 float tempDif = (V_lm20 - 1860.5) / (-11.77);
00236
00237 FILE_LOG(logDEBUG) << " TemperatureDif[" <<dec << tempAsu2 << "]" << endl;
00238
00239 event.setTemperature(difId, tempAsu1, tempAsu2 , tempDif);
00240
00241 }
00242
00243
00244 i64 bcTime = ((bcId_Abs - bcId_AbsOrg) * bcPeriod) / 1000;
00245
00246 i64 readTime = globalTime + bcTime;
00247
00248 FILE_LOG(logDEBUG) << " START EVENT ------------- time " << readTime << " ms" << endl;
00249 FILE_LOG(logDEBUG) << " bc time " << bcTime << " ms" << endl;
00250 FILE_LOG(logDEBUG) << " DIF Id 0x" << hex << (int)difId << dec << endl;
00251 FILE_LOG(logDEBUG) << " DIF trigger counter " << difTriggerCounter << endl;
00252 FILE_LOG(logDEBUG) << " Information counter " << informationCounter << endl;
00253 FILE_LOG(logDEBUG) << " total trigger counter " << globalTriggerCounter << endl;
00254 FILE_LOG(logDEBUG) << " absolute bcId " << bcId_Abs - bcId_AbsOrg << endl;
00255 FILE_LOG(logDEBUG) << " nb line " << dec <<nbLine << endl;
00256 FILE_LOG(logDEBUG) << " used line " << hex << usedLine << dec <<endl;
00257 event.setDifTriggerCounter(difTriggerCounter);
00258 event.setGlobalTriggerCounter(globalTriggerCounter);
00259 Detector &detector = run.getDetector();
00260
00261
00262
00263 bool difFound = false;
00264 { const ChamberMap_t &chambers = detector.getChambers();
00265 for (ChamberMap_t::const_iterator it = chambers.begin(); it != chambers.end(); ++it) {
00266 try {
00267 Chamber& chamber = *(it->second);
00268 const BoardMap_t& boards = chamber.getBoardsByDifId(difId);
00269 }
00270 catch (...) {
00271
00272 continue;
00273 }
00274
00275
00276 difFound = true;
00277 break;
00278 }
00279 if (detector.getMonitoringId() == difId)
00280 {
00281 difFound = true;
00282 }
00283 if (!difFound) {
00284 FILE_LOG(logERROR) << " No dif found with Id 0x" << hex << difId << ", " << dec << difId << " " <<endl;
00285 event.setValidFlag(BAD_DIF_ID,false);
00286
00287 }
00288 }
00289
00290 for (bool finish = false; !finish; ) {
00291 int delimiter = 0;
00292
00293 display();
00294 for (; delimiter != 0xA0 && delimiter != 0xB4 && delimiter != 0xC4; ) {
00295
00296 delimiter = getSpecificData(1);
00297 FILE_LOG(logDEBUG) << " delimiter[0x" <<hex << delimiter << "] " << endl;
00298 if (fileError == EOF) {
00299 delimiter = 0;
00300 break;
00301 }
00302 if (delimiter == 0xA3)
00303 {
00304 FILE_LOG(logERROR) << " frame trailer A3 found -- should not" << endl;
00305 event.setValidFlag(FRAME_HEADER_ERROR,false);
00306 }
00307 }
00308 if (delimiter == 0x00) {
00309 FILE_LOG(logERROR) << " end of file -- should not" << endl;
00310 event.setValidFlag(END_OF_FILE_ERROR,false);
00311 break;
00312 }
00313 if (delimiter == 0xA0)
00314 {
00315 FILE_LOG(logDEBUG) << " frame trailer A0 found" << endl;
00316 this->setComputeCrcFlag(false);
00317 unsigned short CRC_check = getSpecificData(2);
00318 FILE_LOG(logDEBUG) << hex << " Compute CRC[" << crc->getCrc() << "]" << endl;
00319 FILE_LOG(logDEBUG) << hex << " Received CRC[" << CRC_check << "]" << endl;
00320 if ( CRC_check != crc->getCrc() )
00321 {
00322 FILE_LOG(logERROR) << " CRC Error for event id " << lastEventId
00323 << " Compute CRC[" << crc->getCrc()
00324 << "] Received CRC[" << CRC_check << "]" << endl ;
00325 event.setCrcIsCorrect(false);
00326 event.setValidFlag(CRC_ERROR,false);
00327 }
00328 display(-1);
00329 FILE_LOG(logDEBUG) << " global trailer A0 found" << endl;
00330 break;
00331 }
00332 if (delimiter == 0xC4)
00333 {
00334
00335 Dif& dif = run.getDetector().getDifById(difId);
00336 FILE_LOG(logDEBUG) << "analog dif[" << difId << "] " << endl;
00337
00338 analogDataActivate = true;
00339 ui16 lineNum = 1;
00340 ui16 nbChipByBoard = dif.getBoards().begin()->second->getNbColumns();
00341 ui16 nbBoard = dif.getBoards().size();
00342 FILE_LOG(logDEBUG) << "nbBoard[" << nbBoard << "]" <<endl;
00343 FILE_LOG(logDEBUG) << "nbChipByBoard[" << nbChipByBoard << "]" <<endl;
00344
00345 for ( ui16 iLine = 0 ; iLine < nbLine ; iLine++)
00346 {
00347 FILE_LOG(logDEBUG) << "usedLine[" << usedLine << "] lineNum[" << lineNum << "]" << "usedLine & lineNum[" << (usedLine & lineNum) << "]" << endl;
00348 if ( usedLine & lineNum )
00349 {
00350 ui16 nbChips = getSpecificData(1);
00351 FILE_LOG(logDEBUG) << endl << " Line " << lineNum << " nb Chip[" << dec << nbChips << "]" << endl;
00352
00353
00354
00355
00356
00357
00358 ui16 uniqBoard = 99;
00359 ui16 nbChipForLoop = 12;
00360 FILE_LOG(logDEBUG) << "-------- ASU 1 Id[0x" <<hex << dif.getAsu1Id() << "]" << endl;
00361 FILE_LOG(logDEBUG) << "-------- ASU 2 Id[0x" <<hex << dif.getAsu2Id() << "]" << endl;
00362 if ( dif.getAsu1Id() == 0 && dif.getAsu2Id() == 0)
00363 {
00364 FILE_LOG(logERROR)<< "SlowControl Error dif.getAsu1Id()==0 AND dif.getAsu1Id() ==0 " << endl;
00365 exit(0);
00366 }
00367
00368 else if ( dif.getAsu1Id() == 0) { uniqBoard = 1; nbChipForLoop = 6; }
00369 else if ( dif.getAsu2Id() == 0) { uniqBoard = 0; nbChipForLoop = 6; }
00370 FILE_LOG(logDEBUG)<< "uniqBoard[" << uniqBoard << "] nbChipForLoop[" << nbChipForLoop << "]" << endl;
00371
00372 for ( i32 col = nbChipForLoop -1 ; col >= 0; col--)
00373 {
00374
00375 FILE_LOG(logDEBUG)<< "col[" << col << "]" << endl;
00376 ui16 board = col / nbChipByBoard;
00377 if ( uniqBoard == 0 ) { board = 0; }
00378 else if ( uniqBoard == 1 ) { board = 1; }
00379 FILE_LOG(logDEBUG)<< "board[" << board << "]" << endl;
00380
00381
00382 FILE_LOG(logDEBUG)<< dec << "board [" << board << "] line[" << lineNum-1 << "] col[" << col << "]" << endl;
00383 Chip& chip = dif.getChipByRowCol(board, lineNum-1,col % 6);
00384 FILE_LOG(logDEBUG)<< "chip id[" << chip.getId() << "]" << endl;
00385 if( chip.getBypassed() == false )
00386 {
00387 FILE_LOG(logDEBUG)<< dec << "not bypassed chip Id[" << chip.getId() << "]" << endl;
00388 map<ui16,ui16> channelsValues;
00389 for ( ui16 iChannel = 0 ; iChannel < 64 ; iChannel++)
00390 {
00391 ui16 foo = getSpecificData(2);
00392 foo = foo & 0x0fff;
00393 channelsValues[iChannel] = foo;
00394 FILE_LOG(logDEBUG) << "difId["<< dif.getId() << "] ,chipId["<< chip.getId() <<"] analogData line["<< line <<
00395 "], col number["<< col << "] , channel[" << iChannel << "]= [0x" << hex <<foo << "]" << dec << endl;
00396 }
00397 this->analogData[chip.getId()] = channelsValues;
00398 }
00399 }
00400 }
00401 else {
00402 iLine--;
00403 }
00404 lineNum++;
00405 }
00406
00407 if ( forceAnalog )
00408 {
00409 for ( map<ui16,map<ui16,ui16> >::iterator iterAnal = analogData.begin(); iterAnal!= analogData.end(); iterAnal++)
00410 {
00411 map<ui16,ui16>& byChip = iterAnal->second;
00412 ui16 chipId = iterAnal->first;
00413
00414 for ( std::map<ui16,ui16>::iterator iterChip = byChip.begin(); iterChip != byChip.end();iterChip++)
00415 {
00416 ui16 analogValue = iterChip->second;
00417 ui16 channelId = iterChip->first;
00418 if ( difList == NULL || difList->find(difId) != difList->end() )
00419 {
00420 nbHits += newHit(event, detector, 0, analogValue,channelId , chipId, difId);
00421 nbanalogHit++;
00422 }
00423 }
00424 }
00425 }
00426 ui16 header = getSpecificData(1);
00427 display(1);
00428 if ( header != 0xd4 )
00429 {
00430 FILE_LOG(logERROR) << "Frame header 0xd4 not found" << endl;
00431 }
00432 else
00433 {
00434 FILE_LOG(logDEBUG) << "Frame header 0xd4 found" << endl;
00435 }
00436
00437 }
00438
00439 if (delimiter == 0xB4)
00440 {
00441 display(+1);
00442 FILE_LOG(logDEBUG) << " frame header B4 found" << endl;
00443
00444
00445
00446 int chipId = -1;
00447 ui16 orderInChipMemory = 0;
00448 for (; ; )
00449 {
00450 chipId = getSpecificData(1);
00451 FILE_LOG(logDEBUG) << "8 bits read[" << chipId << "] [0x" << hex << chipId << "]" << dec << endl;
00452
00453 if (fileError == EOF) {
00454 finish = true;
00455 FILE_LOG(logINFO) << " end of file found -- should not" << endl;
00456 break;
00457 }
00458 if (chipId == 0x00) {
00459
00460 continue;
00461 }
00462 else if (chipId == 0xA3) {
00463 display(-1);
00464 FILE_LOG(logDEBUG) << " frame trailer A3 found" << endl;
00465 break;
00466 }
00467 else if (chipId == 0xA0) {
00468 finish = true;
00469 display(-1);
00470 break;
00471 }
00472 else if (chipId == 0xC3) {
00473 display(-1);
00474 FILE_LOG(logERROR) << " frame trailer C3 found - error occured during data transfer" << endl;
00475 event.setValidFlag(TRAILER_C3_FOUND,false);
00476 break;
00477 }
00478
00479
00480 bcId_Hit = grayToBinary(getSpecificData(3));
00481 FILE_LOG(logDEBUG) << dec << "bcId_Hit[" << bcId_Hit << "]" << endl;
00482
00483 orderInChipMemory++;
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540 eventTime = readTime + (((bcId_Dif - bcId_Hit) * bcPeriod) / 1000);
00541
00542
00543 if (difFound)
00544 {
00545 for (int chNum = 48; chNum >= 0; chNum -= 16)
00546 {
00547 unsigned int data4 = getSpecificData(4);
00548 if ( data4 == 0xffffffff )
00549 {
00550 event.setValidFlag(ONLY_FFFF);
00551 FILE_LOG(logDEBUG) << "event.setValidFlag(ONLY_FFFF)" << endl;
00552 }
00553 else if ( data4 == 0xaaaaaaaa )
00554 {
00555 event.setValidFlag(ONLY_AAAA);
00556 FILE_LOG(logDEBUG) << "event.setValidFlag(ONLY_AAAA)" << endl;
00557 }
00558 else if ( data4 == 0x55555555 )
00559 {
00560 event.setValidFlag(ONLY_5555);
00561 FILE_LOG(logDEBUG) << "event.setValidFlag(ONLY_5555)" << endl;
00562 }
00563 for (int index = 0; index < 16; index++)
00564 {
00565
00566 int trigger = (data4 >> ((15 - index) * 2)) & 0x03;
00567
00568
00569 if (trigger)
00570 {
00571 FILE_LOG(logDEBUG) << "difId[" << difId << "]" << endl;
00572 if ( difList == NULL || difList->find(difId) != difList->end() )
00573 {
00574 if ( analogDataActivate && orderInChipMemory == 1 )
00575 {
00576 i16 analogValue = analogData[chipId][index + chNum];
00577 nbHits += newHit(event, detector, trigger, analogValue, index + chNum, chipId, difId,orderInChipMemory);
00578 }
00579 else
00580 {
00581 nbHits += newHit(event, detector, trigger, 0, index + chNum, chipId, difId,orderInChipMemory);
00582 }
00583 }
00584 }
00585 }
00586 }
00587 }
00588
00589 display();
00590 }
00591 }
00592 }
00593 display(-1);
00594
00595
00596
00597 event.setTimeStamp(globalTime + ((bcId_AbsOrg /1000000 * bcPeriod) ) );
00598 FILE_LOG(logDEBUG) << "Dif[" << dec << difId << "] Number of created hit for event EVENT " << lastEventId << ", " << nbHits << " total hits, within " << nbanalogHit << " analogic hits" << endl;
00599
00600
00601
00602 if (SkippedBcId) {
00603 FILE_LOG(logWARNING) << " skipped " << SkippedBcId << " data because of bad bcId" << endl;
00604 SkippedBcId = 0;
00605 }
00606
00607 return(nbHits);
00608
00609
00610 }
00611
00612
00613 int MicrorocMergeReader::getScData() {
00614
00615 display(+1);
00616
00617
00618
00619 ui16 dataFormat = run.getDataFormat();
00620 FILE_LOG(logDEBUG) << " Slow Control data format[" << dec << dataFormat << "]" << endl;
00621 if ( dataFormat == 15 || dataFormat == 14 )
00622 {
00623
00624
00625 difId=getData(1);
00626 FILE_LOG(logINFO) << " Slow Control dif Id[" << dec << difId << "]" << endl;
00627 try {
00628 Dif& dif = run.getDetector().getDifById(difId);
00629
00630 if ( dif.getBoards().size() == 2 )
00631 {
00632
00633
00634 dif.setAsu1Id(getData(2));
00635 FILE_LOG(logDEBUG) << "-------- ASU 1 Id[0x" <<hex << dif.getAsu1Id() << "]" << endl;
00636 display(+1);
00637 if ( dif.getAsu1Id() != 0)
00638 {
00639 if ( dif.getBoardByCol(0).getId() != dif.getAsu1Id() )
00640 {
00641 FILE_LOG(logERROR) << "Error data say ASU id = "<< dif.getAsu1Id() << " for ASU close to DIF ( left side ) while XML say ASU id = "
00642 << dif.getBoardByCol(0).getId() << endl;
00643 FILE_LOG(logERROR) << "Please consider modifying XML file" << endl;
00644 exit(-1);
00645 }
00646 }
00647
00648
00649
00650 dif.setAsu2Id(getData(2));
00651 FILE_LOG(logDEBUG) << "-------- ASU 2 Id[0x" <<hex << dif.getAsu2Id() << "]" << endl;
00652 display(+1);
00653 if ( dif.getAsu2Id() != 0)
00654 {
00655 if ( dif.getBoardByCol(1).getId() != dif.getAsu2Id() )
00656 {
00657 FILE_LOG(logERROR) << "Error data say ASU id = "<< dif.getAsu2Id() << " for ASU far away to DIF ( right side ) while XML say ASU id = "
00658 << dif.getBoardByCol(1).getId() << endl;
00659 FILE_LOG(logERROR) << "Please consider modifying XML file" << endl;
00660 exit(-1);
00661 }
00662 }
00663 }
00664
00665 else if (dif.getBoards().size() == 1)
00666 {
00667 ui32 asuId1 = getData(2);
00668 ui32 asuId2 = getData(2);
00669
00670 if ( asuId1 != 0 )
00671 {
00672 dif.setAsu1Id(asuId1);
00673 }
00674 else
00675 {
00676 dif.setAsu1Id(asuId2);
00677 }
00678 FILE_LOG(logDEBUG) << "-------- ASU 1 Id[0x" <<hex << dif.getAsu1Id() << "]" << endl;
00679 }
00680
00681
00682
00683
00684
00685 dif.setChipByPassed(true);
00686
00687
00688
00689 ui16 nbAsic = getData(1);
00690 display(+1);
00691 FILE_LOG(logDEBUG) << "--- nb Asic[" << nbAsic << "] ---" << endl;
00692
00693
00694
00695 ui16 scsize = getData(1);
00696 display(+1);
00697 FILE_LOG(logDEBUG) << "--- sc size 74 or 109[" << dec << scsize << "] ---" << endl;
00698
00699
00700 for ( ui32 index = 0 ; index < nbAsic; index++)
00701 {
00702 const unsigned char *buf = initGetBits(scsize, false);
00703 vector<int> sc;
00704 for ( ui16 i = 0 ; i<scsize ; i++ )
00705 {
00706 ui16 scAsic = getBits(8) ;
00707 sc.push_back(scAsic);
00708 }
00709 MicrorocSCReader scReader(run,sc,difId);
00710 scReader.parseSC(difId);
00711 FILE_LOG(logDEBUG) << "Finish SC for asic [" <<dec << index <<"]" << endl;
00712 }
00713 finishGetBits();
00714 int foo = getData(1);
00715 FILE_LOG(logDEBUG) << "Header[" <<hex << foo <<"]" << endl;
00716 if ( foo != 0xa1)
00717 {
00718 FILE_LOG(logERROR) << " Header A1 not found" << endl;
00719 exit (-1);
00720 }
00721 FILE_LOG(logDEBUG) << "Header A1 found" << endl;
00722 FILE_LOG(logINFO) << "SlowControl read successfully" << endl;
00723 }
00724 catch (MicroException &e) {
00725 FILE_LOG(logERROR) << "Slow control error" << endl;
00726 ui16 foo2 = 0xff;
00727 while ( foo2 != 0xb0 && foo2 !=0 && fileError != EOF)
00728 {
00729 ui16 foo = getData(1);
00730 while ( foo != 0xa1 )
00731 {
00732 foo = getData(1);
00733 FILE_LOG(logDEBUG) << "-- Wait foo 0xa1[" << hex << foo << "]" << endl;
00734 }
00735 foo2 = getData(1);
00736 FILE_LOG(logDEBUG) << "-- Wait foo 0xb0[" << hex << foo << "]" << endl;
00737
00738 }
00739 }
00740 }
00741 else
00742 {
00743 FILE_LOG(logERROR) << " Slow Control format " << dec << dataFormat << " is not implemeted" << endl;
00744 ui16 foo2 = 0xff;
00745 while ( foo2 != 0xb0 && foo2 !=0 && fileError != EOF)
00746 {
00747 ui16 foo = getData(1);
00748 while ( foo != 0xa1 )
00749 {
00750 foo = getData(1);
00751 FILE_LOG(logDEBUG) << "-- Wait foo 0xa1[" << hex << foo << "]" << endl;
00752 }
00753 foo2 = getData(1);
00754 FILE_LOG(logDEBUG) << "-- Wait foo 0xb0[" << hex << foo << "]" << endl;
00755
00756 }
00757 }
00758
00759 return true;
00760 }
00761
00762