MicrorocMergeReader Class Reference

#include <MicrorocMergeReader.hh>

Inheritance diagram for MicrorocMergeReader:

Inheritance graph
[legend]
Collaboration diagram for MicrorocMergeReader:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MicrorocMergeReader (Run &aRun, FILE *aFile, ui32 lastEventId, bool forceAnalog, std::set< unsigned int > *=NULL)
 ~MicrorocMergeReader ()
virtual int getNextEvent (Event &eventToFill)=0

Static Public Member Functions

static const char * type (const int subtype=0)

Protected Member Functions

void localReset (void)
int getAcqData (Event &event, bool temperatureFill=false)
virtual unsigned int getSpecificData (const unsigned int nBytes)=0
int decodeData (Event &event)
int getScData (void)

Protected Attributes

bool slowControlSet
ui32 hexTemperatureAsu1
ui32 hexTemperatureAsu2
ui16 hexTemperatureDif
bool forceAnalog
std::set< unsigned int > * difList
std::map< ui16, std::map<
ui16, ui16 > > 
analogData
ui16 nbChipPerLine
bool analogDataActivate
bool analogDataActivatedLine [NBLINE]
ui32 debugEventId

Detailed Description

CLASS DATAREADER //

Definition at line 28 of file MicrorocMergeReader.hh.


Constructor & Destructor Documentation

MicrorocMergeReader::MicrorocMergeReader ( Run aRun,
FILE *  aFile,
ui32  lastEventId,
bool  forceAnalog,
std::set< unsigned int > *  = NULL 
)

MicrorocMergeReader::~MicrorocMergeReader (  ) 

Definition at line 67 of file MicrorocMergeReader.cpp.

00068 {
00069   FILE_LOG(logDEBUG1)<< "----MicrorocMergeReader destructor"<< endl;
00070 }


Member Function Documentation

static const char* MicrorocMergeReader::type ( const int  subtype = 0  )  [static]

Reimplemented from MicrorocReader.

Reimplemented in MicrorocLabviewReader, and MicrorocXDaqReader.

virtual int MicrorocMergeReader::getNextEvent ( Event eventToFill  )  [pure virtual]

Implements MicrorocReader.

Implemented in MicrorocLabviewReader, and MicrorocXDaqReader.

void MicrorocMergeReader::localReset ( void   )  [protected]

Reimplemented in MicrorocXDaqReader.

Definition at line 74 of file MicrorocMergeReader.cpp.

00075 {
00076   reset(); // appel MicrorocReader::reset();
00077   slowControlSet = false;
00078   hexTemperatureAsu1 = 0;
00079   hexTemperatureAsu2 = 0;
00080   hexTemperatureDif = 0;
00081 
00082 }

int MicrorocMergeReader::getAcqData ( Event event,
bool  temperatureFill = false 
) [protected]

Definition at line 122 of file MicrorocMergeReader.cpp.

Referenced by decodeData().

00123 {
00124 
00125   ui32 nbanalogHit = 0;
00126   unsigned int nbHits = 0;
00127 
00128   display(+1);
00129 
00130 
00131   this->setComputeCrcFlag(true);
00132   //FILE_LOG(logDEBUG) << "MicrorocLabviewReader crc adr[" <<  crc << "]" << endl;
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   // reset the data for the block
00148   //  bcId_AbsOrg = -1;
00149   bcId_Abs = 0; // max. 48 bits
00150   bcId_Dif = 0;
00151   // the following data is repeated one time for each Dif which has sent data
00152   difId = getSpecificData(1);
00153 
00154   difTriggerCounter = getSpecificData(4);
00155   informationCounter = getSpecificData(4);  // trigger counter version >= 4
00156   globalTriggerCounter = getSpecificData(4);
00157 
00158   ui64 bcIdHigh = getSpecificData(2);
00159   ui64 bcIdLow = getSpecificData(4);
00160   bcId_Abs = (bcIdHigh << 32) + bcIdLow;
00161   //FILE_LOG(logDEBUG) << "bcId_Abs[" << hex << bcId_Abs <<  endl;
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; //bit 3 (4eme ligne,)  bit 2 (3eme ligne)  bit 1 (2eme ligne)  bit 0 (1ere ligne)
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   Pour les temperature des ASU
00190 1) j'enleve les 16 bits de poids fort (bit31 a bit16). Le bit 15 signifie alors le bit de signe
00191     C'est a dire qu'il faut que tu mette(bit15 à bit0) dans un integer signé à 16 bits.
00192 
00193 2) il faut supprimer les 3  bits de poids faible (bit2 à bit0). moi, je l'ai fait par une division entiere par 8 (pour garder le signe). Autrement, si tu préfères, tu pourrais faire une décalage de 3 bits des (bits14 à bits0)
00194 
00195 3) il faut diviser le chiffre restant par 16 pour avoir le résultat en degré Celsius.
00196 Cyril.
00197 
00198 4/ Pour les nouvelles sonde ( bit 31 == 1 ) il faut encore diviser le resultat par 2
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 Pour la temperature de la Dif
00212 Vlsb est une constante = 20
00213 (ca veut dire qu'un lsb de l'adc de la DIF vaut 20mV)
00214 
00215 Nadc = les 8 bits que tu recois
00216 
00217 Temperature = la conversion en degré Celsius
00218 ================================================
00219 
00220 float V_adc ;
00221 float  V_lm20 ;
00222 
00223 conversion ADC 
00224 V_adc = ( Nadc * Vlsb ) ;
00225 
00226 ampli gain 33K/10K avec point milieu à 1,5V 
00227 V_lm20 = ( (6450 - V_adc) / 3.3 ) ;
00228 
00229 calcul du premier ordre du lm20 pour T entre -30°C et 100°C 
00230 Temperature = (  (V_lm20 - 1860.5) / (-11.77)  ) ;
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   // the bcTime in milliseconds
00244   i64 bcTime = ((bcId_Abs - bcId_AbsOrg) * bcPeriod) / 1000;
00245   // the reading time in milliseconds
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   // end of global header
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         // any error case - try next chamber
00272         continue;
00273       }
00274 
00275       // the DIF has been found in a chamber. Process all data and continue
00276       difFound = true;
00277       break;
00278     } // for
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       // seek for first data frame header (0xB4)
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       //computeCrc = false;
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 ) // LINE 1
00349         {
00350           ui16 nbChips = getSpecificData(1);
00351           FILE_LOG(logDEBUG)  << endl << " Line " << lineNum << " nb Chip[" << dec <<  nbChips << "]"  << endl;
00352 
00353           // Le SlowControl permet de savoir si il y a 1 ou 2 ASU de connectes a la Dif. Si il n'y a qu'un ASU
00354           // alors  ASUID 1 ou ASUID 2 = 0 dans le slowcontrol
00355           // Dans le cas ou il y a les deux ASU connectes a la Dif, c'est le ASU le plus eloigne ( col ==  ? ) de la Dif qui parle 
00356           // en 1er
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);   // board / row /column
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; // Seul les 2 dernier bits correspondent a  adc_slab_value
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               } // end for iChannel
00397               this->analogData[chip.getId()] = channelsValues;
00398             }
00399           } // end for iChip
00400         } // end if usedLine
00401         else {
00402           iLine--;
00403         }
00404         lineNum++;
00405      } // end for iLine
00406      //computeCrc = true;
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           // When analog is anable, all channel of all chip enable for analogic respond
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()  ) // No difid filter or difId in difList
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     } // end if delimiter 0xC4
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 (; ; )  // Read in chip memory for different BCId_HIT. 
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           // dummy null bytes
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         // Test du bit de suppression de donnée
00487         bool supress = (chipId & 0x80) >> 7;   // bit de poinds fort
00488         FILE_LOG(logINFO) << "suppress[" << supress << "]"  << endl;
00489         if ( supress )
00490         {
00491           chipId = chipId & 0x7F ; // supression du bit de poinds fort
00492 
00493           ui16 supressInfo = getSpecificData(1);
00494           FILE_LOG(logDEBUG) << hex << "supressInfo[0x" << supressInfo << "]" << endl;
00495 
00496           ui16 nbDiffer = supressInfo & 0x3F ; // bits de 0 a 5
00497           ui16 supressType = supressInfo & 0xC0 ; // bit 6 et 7 
00498           FILE_LOG(logDEBUG) << dec << "nbDiffer[" << nbDiffer << "]" << endl;
00499           FILE_LOG(logDEBUG) << dec << "type de suppression(00,01,10 ou 11) [" << supressType << "]" << endl;
00500 
00501 
00502           set<ui16> channels;
00503           for ( int index = 0; index < 64; index ++ )
00504           {
00505             channels.insert(index);
00506           }
00507   
00508           for ( int index = 0; index < nbDiffer ; index++ )
00509           {
00510             //  information pour les channel hits non suprimmer
00511             ui16 channelInfo = getSpecificData(2);
00512             FILE_LOG(logDEBUG) << hex << "channel info not deleted[0x" << channelInfo << "]" << endl;
00513             ui16 channelId = channelInfo & 0xfc;
00514             FILE_LOG(logDEBUG) << dec << "channel id not deleted[0x" << channelId << "]" << endl;
00515             ui16 level = channelInfo & 0x03;
00516             FILE_LOG(logDEBUG) << dec << "channel level not deleted[0x" << level << "]" << endl;
00517             channels.erase(channelId);
00518             nbHits += newHit(event, detector, level, 0, channelId, chipId, difId,orderInChipMemory);
00519           }
00520           // On cree un hit sur tous les autres channels dont les donnees ont ete suprime
00521           set<ui16>::const_iterator myIterator; 
00522           for(myIterator = channels.begin(); myIterator != channels.end(); myIterator++)
00523           {
00524             FILE_LOG(logDEBUG) << *myIterator << endl;    
00525             ui16 channelId = *myIterator;
00526             FILE_LOG(logDEBUG) << dec << "new hit for channel Id not deleted[" << channelId << "]" << endl;
00527             nbHits += newHit(event, detector, supressType, 0, channelId, chipId, difId,orderInChipMemory);
00528           }
00529 
00530 
00531         
00532         }
00533         else 
00534         {
00535         }
00536 */
00537         //{
00538           // bcId from hardroc chip is counted as Gray code
00539           // event time in milliseconds
00540           eventTime = readTime + (((bcId_Dif - bcId_Hit) * bcPeriod) / 1000);
00541 
00542           // not on first line and bcId OK : get and check data
00543           if (difFound)
00544           {
00545             for (int chNum = 48; chNum >= 0; chNum -= 16)  // read data ( 128) for different channel Id with same BCID_HIT
00546             {
00547               unsigned int data4 = getSpecificData(4); // lit 4 bytes => 8 char => 16 canaux
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                 // sur les 16 canaux, recupere les donnees canal par canal
00566                 int trigger = (data4 >> ((15 - index) * 2)) & 0x03; // 2 bits
00567                 //FILE_LOG(logDEBUG) << "trigger[" << trigger << "]"  << endl;
00568                 // store new event data if any
00569                 if (trigger)  // on elimine tous les hits dans la valeur est 0 
00570                 {
00571                   FILE_LOG(logDEBUG) << "difId[" << difId << "]"  << endl;
00572                   if ( difList == NULL || difList->find(difId) != difList->end()  ) // No difid filter or difId in difList
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               } // for (index)
00586             } // End digital data. for (chNum)
00587           }
00588         //} // end else not date supress activate
00589         display();
00590       } // for(;;)
00591     }  // end if delimiter = 0xB4
00592   } // for (;;)
00593   display(-1);
00594 
00595  // CREATE EVENT for current Run
00596 
00597   event.setTimeStamp(globalTime + ((bcId_AbsOrg /1000000 * bcPeriod) )  );  // globalTime -> millisecond and bcId_AbsOrg * bcPeriod -> nano second
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 } // END  int MicrorocMergeReader::getAcqData(Event& event, bool temperatureFill)

virtual unsigned int MicrorocMergeReader::getSpecificData ( const unsigned int  nBytes  )  [protected, pure virtual]

Implemented in MicrorocLabviewReader, and MicrorocXDaqReader.

Referenced by decodeData(), and getAcqData().

int MicrorocMergeReader::decodeData ( Event event  )  [protected]

Definition at line 85 of file MicrorocMergeReader.cpp.

Referenced by MicrorocXDaqReader::getNextEvent(), and MicrorocLabviewReader::getNextEvent().

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                 // slow control data
00100                 getScData();
00101               }
00102               else if (globalHeader == 0xB0) {
00103                 // acquisition data
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                 // acquisition data
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 }

int MicrorocMergeReader::getScData ( void   )  [protected, virtual]

Implements MicrorocReader.

Definition at line 613 of file MicrorocMergeReader.cpp.

Referenced by decodeData().

00613                                    {
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   // DIF ID ( 8 bits )
00625   difId=getData(1); // in case of dataFormat = 7 Difid is not in data file
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     // ASU ID 1 ( 16 bits)
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     // ASU ID 2 ( 16 bits)
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)  // ASU dans la boite test
00666   {
00667     ui32 asuId1 = getData(2);
00668     ui32 asuId2 = getData(2);
00669 
00670     if ( asuId1 != 0 )
00671     {
00672       dif.setAsu1Id(asuId1);  // ASU loin de la dif
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     // set all chip to byppassed = True.
00684     // then each chip prensent in Slow control will by set to bypassed = False 
00685     dif.setChipByPassed(true);
00686 
00687 
00688   // nb ASIC ( 8 bits)
00689     ui16 nbAsic = getData(1);
00690     display(+1);
00691     FILE_LOG(logDEBUG) << "--- nb Asic[" << nbAsic << "] ---" << endl;
00692 
00693     
00694   // Size SC ASIC ( 8 bits)
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 } // MicrorocMergeReader.getScData


Member Data Documentation

bool MicrorocMergeReader::slowControlSet [protected]

Definition at line 45 of file MicrorocMergeReader.hh.

Referenced by MicrorocXDaqReader::getNextEvent(), and localReset().

ui32 MicrorocMergeReader::hexTemperatureAsu1 [protected]

Definition at line 47 of file MicrorocMergeReader.hh.

Referenced by getAcqData(), and localReset().

ui32 MicrorocMergeReader::hexTemperatureAsu2 [protected]

Definition at line 48 of file MicrorocMergeReader.hh.

Referenced by getAcqData(), and localReset().

ui16 MicrorocMergeReader::hexTemperatureDif [protected]

Definition at line 49 of file MicrorocMergeReader.hh.

Referenced by getAcqData(), and localReset().

bool MicrorocMergeReader::forceAnalog [protected]

Definition at line 51 of file MicrorocMergeReader.hh.

Referenced by getAcqData().

std::set<unsigned int>* MicrorocMergeReader::difList [protected]

Definition at line 52 of file MicrorocMergeReader.hh.

Referenced by getAcqData().

std::map<ui16,std::map<ui16,ui16> > MicrorocMergeReader::analogData [protected]

Definition at line 53 of file MicrorocMergeReader.hh.

Referenced by decodeData(), and getAcqData().

ui16 MicrorocMergeReader::nbChipPerLine [protected]

Definition at line 54 of file MicrorocMergeReader.hh.

bool MicrorocMergeReader::analogDataActivate [protected]

Definition at line 55 of file MicrorocMergeReader.hh.

Referenced by getAcqData().

bool MicrorocMergeReader::analogDataActivatedLine[NBLINE] [protected]

Definition at line 56 of file MicrorocMergeReader.hh.

ui32 MicrorocMergeReader::debugEventId [protected]

Definition at line 57 of file MicrorocMergeReader.hh.

Referenced by MicrorocXDaqReader::getNextEvent(), and MicrorocLabviewReader::getNextEvent().


The documentation for this class was generated from the following files:
Generated on Mon Jan 7 13:18:45 2013 for MicromegasFramework by  doxygen 1.4.7