CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/EventFilter/EcalTBRawToDigi/src/TableDataFormatter.cc

Go to the documentation of this file.
00001 #include "TableDataFormatter.h"
00002 
00003 
00004 #include <iostream>
00005 
00006 TableDataFormatter::TableDataFormatter () {
00007 }
00008 
00009 void TableDataFormatter::interpretRawData( const FEDRawData & fedData, 
00010                                            EcalTBEventHeader& tbEventHeader)
00011 {
00012   const unsigned long * buffer = ( reinterpret_cast<unsigned long*>(const_cast<unsigned char*> ( fedData.data())));
00013   int fedLenght                        = fedData.size(); // in Bytes
00014   
00015   // check ultimate fed size and strip off fed-header and -trailer
00016   if (fedLenght != (nWordsPerEvent *4) )
00017     {
00018       edm::LogError("TableDataFormatter") << "TableData has size "  <<  fedLenght
00019                                        <<" Bytes as opposed to expected " 
00020                                        << (nWordsPerEvent *4)
00021                                      << ". Returning.";
00022       return;
00023     }
00024 
00025   unsigned long a=1; // used to extract an 8 Bytes word from fed 
00026   unsigned long b=1; // used to manipulate the 8 Bytes word and get what needed
00027 
00028   int wordCounter =0;
00029   wordCounter +=4;
00030 
00031   a = buffer[wordCounter];wordCounter++;
00032   b = (a& 0xffffffff);
00033   tbEventHeader.setThetaTableIndex(b);
00034   LogDebug("TableDataFormatter") << "Table theta position:\t" << b;
00035   a = buffer[wordCounter];wordCounter++;
00036   b = (a& 0xffffffff);
00037   tbEventHeader.setPhiTableIndex(b);
00038   LogDebug("TableDataFormatter") << "Table phi position:\t" << b;
00039   a = buffer[wordCounter];wordCounter++;
00040   b = (a& 0xffff);
00041   tbEventHeader.setCrystalInBeam(EBDetId(1,b,EBDetId::SMCRYSTALMODE));
00042   LogDebug("TableDataFormatter") << "Actual Current crystal in beam:\t" << b;
00043   b = (a& 0xffff0000);
00044   b = b >> 16;
00045   tbEventHeader.setNominalCrystalInBeam(EBDetId(1,b,EBDetId::SMCRYSTALMODE));
00046   LogDebug("TableDataFormatter") << "Nominal Current crystal in beam:\t" << b;
00047   a = buffer[wordCounter];wordCounter++;
00048   b = (a& 0xffff);
00049   tbEventHeader.setNextCrystalInBeam(EBDetId(1,b,EBDetId::SMCRYSTALMODE));
00050   LogDebug("TableDataFormatter") << "Next crystal in beam:\t" << b;
00051   b = (a& 0x00010000); //Table is moving at the begin of the spill
00052   b = b >> 16;
00053   tbEventHeader.setTableIsMovingAtBegSpill(b & 0x1);
00054   LogDebug("TableDataFormatter") << "Table is moving at begin of the spill:\t" << b;
00055 }