Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:45:23

0001 #include "EcalSupervisorDataFormatter.h"
0002 
0003 #include <iostream>
0004 
0005 EcalSupervisorTBDataFormatter::EcalSupervisorTBDataFormatter() {}
0006 
0007 void EcalSupervisorTBDataFormatter::interpretRawData(const FEDRawData& fedData, EcalTBEventHeader& tbEventHeader) {
0008   const unsigned long* buffer = reinterpret_cast<const unsigned long*>(fedData.data());
0009   int fedLenght = fedData.size();  // in Bytes
0010 
0011   // check ultimate fed size and strip off fed-header and -trailer
0012   if (fedLenght < (nWordsPerEvent * 4)) {
0013     edm::LogError("EcalSupervisorTBDataFormatter")
0014         << "EcalSupervisorTBData has size " << fedLenght << " Bytes as opposed to expected " << (nWordsPerEvent * 4)
0015         << ". Returning.";
0016     return;
0017   }
0018 
0019   unsigned long a = 1;  // used to extract an 8 Bytes word from fed
0020   unsigned long b = 1;  // used to manipulate the 8 Bytes word and get what needed
0021 
0022   int wordCounter = 0;
0023   a = buffer[wordCounter];
0024   wordCounter++;
0025   b = (a & 0xfff00000);
0026   b = b >> 20;
0027   tbEventHeader.setBurstNumber(b);
0028   LogDebug("EcalSupervisorTBDataFormatter") << "Burst number:\t" << b;
0029   //Skipping the second word
0030   wordCounter += 1;
0031   a = buffer[wordCounter];
0032   wordCounter++;
0033   b = (a & 0x80000000);
0034   b = b >> 31;
0035   tbEventHeader.setSyncError(b & 0x1);
0036   LogDebug("EcalSupervisorTBDataFormatter") << "Sync Error:\t" << b;
0037   a = buffer[wordCounter];
0038   wordCounter++;
0039   b = (a & 0xffffff);
0040   tbEventHeader.setRunNumber(b);
0041   LogDebug("EcalSupervisorTBDataFormatter") << "Run Number:\t" << b;
0042   a = buffer[wordCounter];
0043   wordCounter++;
0044   b = (a & 0xff);
0045   int version = b;
0046   LogDebug("EcalSupervisorTBDataFormatter") << "Version Number:\t" << b;
0047 
0048   int numberOfMagnetMeasurements = -1;
0049   if (version >= 11) {
0050     b = (a & 0xff00);
0051     b = b >> 8;
0052     numberOfMagnetMeasurements = b;
0053     tbEventHeader.setNumberOfMagnetMeasurements(b);
0054     LogDebug("EcalSupervisorTBDataFormatter") << "Number Of Magnet Measurements:\t" << b;
0055   }
0056 
0057   a = buffer[wordCounter];
0058   wordCounter++;
0059   b = (a & 0xffffffff);
0060   tbEventHeader.setEventNumber(b);
0061   LogDebug("EcalSupervisorTBDataFormatter") << "Event Number:\t" << b;
0062   a = buffer[wordCounter];
0063   wordCounter++;
0064   b = (a & 0xffffffff);
0065   tbEventHeader.setBegBurstTimeSec(b);
0066   LogDebug("EcalSupervisorTBDataFormatter") << "BegBurstTimeSec:\t" << b;
0067   a = buffer[wordCounter];
0068   wordCounter++;
0069   b = (a & 0xffffffff);
0070   tbEventHeader.setBegBurstTimeMsec(b);
0071   LogDebug("EcalSupervisorTBDataFormatter") << "BegBurstTimeMsec:\t" << b;
0072   a = buffer[wordCounter];
0073   wordCounter++;
0074   b = (a & 0xffffffff);
0075   tbEventHeader.setEndBurstTimeSec(b);
0076   LogDebug("EcalSupervisorTBDataFormatter") << "EndBurstTimeSec:\t" << b;
0077   a = buffer[wordCounter];
0078   wordCounter++;
0079   b = (a & 0xffffffff);
0080   tbEventHeader.setEndBurstTimeMsec(b);
0081   LogDebug("EcalSupervisorTBDataFormatter") << "EndBurstTimeMsec:\t" << b;
0082   a = buffer[wordCounter];
0083   wordCounter++;
0084   b = (a & 0xffffffff);
0085   tbEventHeader.setBegBurstLV1A(b);
0086   LogDebug("EcalSupervisorTBDataFormatter") << "BegBurstLV1A:\t" << b;
0087   a = buffer[wordCounter];
0088   wordCounter++;
0089   b = (a & 0xffffffff);
0090   tbEventHeader.setEndBurstLV1A(b);
0091   LogDebug("EcalSupervisorTBDataFormatter") << "EndBurstLV1A:\t" << b;
0092 
0093   if (version >= 11) {
0094     std::vector<EcalTBEventHeader::magnetsMeasurement_t> magnetMeasurements;
0095     for (int iMagMeas = 0; iMagMeas < numberOfMagnetMeasurements; iMagMeas++) {
0096       LogDebug("EcalSupervisorTBDataFormatter") << "++++++ New Magnet Measurement++++++\t" << (iMagMeas + 1);
0097       EcalTBEventHeader::magnetsMeasurement_t aMeasurement;
0098       wordCounter += 4;
0099       a = buffer[wordCounter];
0100       wordCounter++;
0101       b = (a & 0xffffffff);
0102       aMeasurement.magnet6IRead_ampere = b;
0103       LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet6ReadAmpere:\t" << b;
0104       a = buffer[wordCounter];
0105       wordCounter++;
0106       b = (a & 0xffffffff);
0107       aMeasurement.magnet6ISet_ampere = b;
0108       LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet6SetAmpere:\t" << b;
0109       a = buffer[wordCounter];
0110       wordCounter++;
0111       b = (a & 0xffffffff);
0112       aMeasurement.magnet7IRead_ampere = b;
0113       LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet7ReadAmpere:\t" << b;
0114       a = buffer[wordCounter];
0115       wordCounter++;
0116       b = (a & 0xffffffff);
0117       aMeasurement.magnet7ISet_ampere = b;
0118       LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet7SetAmpere:\t" << b;
0119       a = buffer[wordCounter];
0120       wordCounter++;
0121       b = (a & 0xffffffff);
0122       aMeasurement.magnet7VMeas_uvolt = b;
0123       LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet7MicroVolt:\t" << b;
0124       a = buffer[wordCounter];
0125       wordCounter++;
0126       b = (a & 0xffffffff);
0127       aMeasurement.magnet7IMeas_uampere = b;
0128       LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet7Ampere:\t" << b;
0129       a = buffer[wordCounter];
0130       wordCounter++;
0131       b = (a & 0xffffffff);
0132       aMeasurement.magnet6VMeas_uvolt = b;
0133       LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet6MicroVolt:\t" << b;
0134       a = buffer[wordCounter];
0135       wordCounter++;
0136       b = (a & 0xffffffff);
0137       aMeasurement.magnet6IMeas_uampere = b;
0138       LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet6Ampere:\t" << b;
0139       magnetMeasurements.push_back(aMeasurement);
0140     }
0141     tbEventHeader.setMagnetMeasurements(magnetMeasurements);
0142   }
0143 }