CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/EventFilter/EcalTBRawToDigi/src/EcalSupervisorDataFormatter.cc

Go to the documentation of this file.
00001 #include "EcalSupervisorDataFormatter.h"
00002 
00003 
00004 #include <iostream>
00005 
00006 EcalSupervisorTBDataFormatter::EcalSupervisorTBDataFormatter () {
00007 }
00008 
00009 void EcalSupervisorTBDataFormatter::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("EcalSupervisorTBDataFormatter") << "EcalSupervisorTBData 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   a = buffer[wordCounter];wordCounter++;
00030   b = (a & 0xfff00000);
00031   b = b >> 20;
00032   tbEventHeader.setBurstNumber(b);
00033   LogDebug("EcalSupervisorTBDataFormatter") << "Burst number:\t" << b;
00034   //Skipping the second word
00035   wordCounter +=1;
00036   a = buffer[wordCounter];wordCounter++;
00037   b = (a& 0x80000000);
00038   b = b >> 31;
00039   tbEventHeader.setSyncError(b & 0x1);
00040   LogDebug("EcalSupervisorTBDataFormatter") << "Sync Error:\t" << b;
00041   a = buffer[wordCounter];wordCounter++;
00042   b = (a& 0xffffff);
00043   tbEventHeader.setRunNumber(b);
00044   LogDebug("EcalSupervisorTBDataFormatter") << "Run Number:\t" << b;
00045   a = buffer[wordCounter];wordCounter++;
00046   b = (a& 0xff);
00047   int version = b;
00048   LogDebug("EcalSupervisorTBDataFormatter") << "Version Number:\t" << b;
00049 
00050   int numberOfMagnetMeasurements = -1;
00051   if (version >= 11)
00052     {
00053       b = (a& 0xff00);
00054       b = b >> 8;
00055       numberOfMagnetMeasurements= b;
00056       tbEventHeader.setNumberOfMagnetMeasurements(b);
00057       LogDebug("EcalSupervisorTBDataFormatter") << "Number Of Magnet Measurements:\t" << b;
00058     }
00059 
00060   a = buffer[wordCounter];wordCounter++;
00061   b = (a& 0xffffffff);
00062   tbEventHeader.setEventNumber(b);
00063   LogDebug("EcalSupervisorTBDataFormatter") << "Event Number:\t" << b;
00064   a = buffer[wordCounter];wordCounter++;
00065   b = (a& 0xffffffff);
00066   tbEventHeader.setBegBurstTimeSec(b);
00067   LogDebug("EcalSupervisorTBDataFormatter") << "BegBurstTimeSec:\t" << b;
00068   a = buffer[wordCounter];wordCounter++;
00069   b = (a& 0xffffffff);
00070   tbEventHeader.setBegBurstTimeMsec(b);
00071   LogDebug("EcalSupervisorTBDataFormatter") << "BegBurstTimeMsec:\t" << b;
00072   a = buffer[wordCounter];wordCounter++;
00073   b = (a& 0xffffffff);
00074   tbEventHeader.setEndBurstTimeSec(b);
00075   LogDebug("EcalSupervisorTBDataFormatter") << "EndBurstTimeSec:\t" << b;
00076   a = buffer[wordCounter];wordCounter++;
00077   b = (a& 0xffffffff);
00078   tbEventHeader.setEndBurstTimeMsec(b);
00079   LogDebug("EcalSupervisorTBDataFormatter") << "EndBurstTimeMsec:\t" << b;
00080   a = buffer[wordCounter];wordCounter++;
00081   b = (a& 0xffffffff);
00082   tbEventHeader.setBegBurstLV1A(b);
00083   LogDebug("EcalSupervisorTBDataFormatter") << "BegBurstLV1A:\t" << b;
00084   a = buffer[wordCounter];wordCounter++;
00085   b = (a& 0xffffffff);
00086   tbEventHeader.setEndBurstLV1A(b);
00087   LogDebug("EcalSupervisorTBDataFormatter") << "EndBurstLV1A:\t" << b;
00088 
00089   if (version >= 11)
00090     {
00091       std::vector<EcalTBEventHeader::magnetsMeasurement_t> magnetMeasurements;
00092       for (int iMagMeas = 0; iMagMeas < numberOfMagnetMeasurements; iMagMeas ++)
00093         { 
00094           LogDebug("EcalSupervisorTBDataFormatter") << "++++++ New Magnet Measurement++++++\t" << (iMagMeas + 1);
00095           EcalTBEventHeader::magnetsMeasurement_t aMeasurement;
00096           wordCounter+=4;
00097           a = buffer[wordCounter];wordCounter++;
00098           b = (a& 0xffffffff);
00099           aMeasurement.magnet6IRead_ampere = b;
00100           LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet6ReadAmpere:\t" << b;
00101           a = buffer[wordCounter];wordCounter++;
00102           b = (a& 0xffffffff);
00103           aMeasurement.magnet6ISet_ampere = b;
00104           LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet6SetAmpere:\t" << b;
00105           a = buffer[wordCounter];wordCounter++;
00106           b = (a& 0xffffffff);
00107           aMeasurement.magnet7IRead_ampere = b;
00108           LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet7ReadAmpere:\t" << b;
00109           a = buffer[wordCounter];wordCounter++;
00110           b = (a& 0xffffffff);
00111           aMeasurement.magnet7ISet_ampere = b;
00112           LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet7SetAmpere:\t" << b;
00113           a = buffer[wordCounter];wordCounter++;
00114           b = (a& 0xffffffff);
00115           aMeasurement.magnet7VMeas_uvolt = b;
00116           LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet7MicroVolt:\t" << b;
00117           a = buffer[wordCounter];wordCounter++;
00118           b = (a& 0xffffffff);
00119           aMeasurement.magnet7IMeas_uampere = b;
00120           LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet7Ampere:\t" << b;
00121           a = buffer[wordCounter];wordCounter++;
00122           b = (a& 0xffffffff);
00123           aMeasurement.magnet6VMeas_uvolt = b;
00124           LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet6MicroVolt:\t" << b;
00125           a = buffer[wordCounter];wordCounter++;
00126           b = (a& 0xffffffff);
00127           aMeasurement.magnet6IMeas_uampere = b;
00128           LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet6Ampere:\t" << b;
00129           magnetMeasurements.push_back(aMeasurement);
00130         }
00131       tbEventHeader.setMagnetMeasurements(magnetMeasurements);
00132     }
00133 }