CMS 3D CMS Logo

EcalSupervisorDataFormatter.cc
Go to the documentation of this file.
2 
3 #include <iostream>
4 
6 
8  const unsigned long* buffer = reinterpret_cast<const unsigned long*>(fedData.data());
9  int fedLenght = fedData.size(); // in Bytes
10 
11  // check ultimate fed size and strip off fed-header and -trailer
12  if (fedLenght < (nWordsPerEvent * 4)) {
13  edm::LogError("EcalSupervisorTBDataFormatter")
14  << "EcalSupervisorTBData has size " << fedLenght << " Bytes as opposed to expected " << (nWordsPerEvent * 4)
15  << ". Returning.";
16  return;
17  }
18 
19  unsigned long a = 1; // used to extract an 8 Bytes word from fed
20  unsigned long b = 1; // used to manipulate the 8 Bytes word and get what needed
21 
22  int wordCounter = 0;
23  a = buffer[wordCounter];
24  wordCounter++;
25  b = (a & 0xfff00000);
26  b = b >> 20;
27  tbEventHeader.setBurstNumber(b);
28  LogDebug("EcalSupervisorTBDataFormatter") << "Burst number:\t" << b;
29  //Skipping the second word
30  wordCounter += 1;
31  a = buffer[wordCounter];
32  wordCounter++;
33  b = (a & 0x80000000);
34  b = b >> 31;
35  tbEventHeader.setSyncError(b & 0x1);
36  LogDebug("EcalSupervisorTBDataFormatter") << "Sync Error:\t" << b;
37  a = buffer[wordCounter];
38  wordCounter++;
39  b = (a & 0xffffff);
40  tbEventHeader.setRunNumber(b);
41  LogDebug("EcalSupervisorTBDataFormatter") << "Run Number:\t" << b;
42  a = buffer[wordCounter];
43  wordCounter++;
44  b = (a & 0xff);
45  int version = b;
46  LogDebug("EcalSupervisorTBDataFormatter") << "Version Number:\t" << b;
47 
48  int numberOfMagnetMeasurements = -1;
49  if (version >= 11) {
50  b = (a & 0xff00);
51  b = b >> 8;
52  numberOfMagnetMeasurements = b;
53  tbEventHeader.setNumberOfMagnetMeasurements(b);
54  LogDebug("EcalSupervisorTBDataFormatter") << "Number Of Magnet Measurements:\t" << b;
55  }
56 
57  a = buffer[wordCounter];
58  wordCounter++;
59  b = (a & 0xffffffff);
60  tbEventHeader.setEventNumber(b);
61  LogDebug("EcalSupervisorTBDataFormatter") << "Event Number:\t" << b;
62  a = buffer[wordCounter];
63  wordCounter++;
64  b = (a & 0xffffffff);
65  tbEventHeader.setBegBurstTimeSec(b);
66  LogDebug("EcalSupervisorTBDataFormatter") << "BegBurstTimeSec:\t" << b;
67  a = buffer[wordCounter];
68  wordCounter++;
69  b = (a & 0xffffffff);
70  tbEventHeader.setBegBurstTimeMsec(b);
71  LogDebug("EcalSupervisorTBDataFormatter") << "BegBurstTimeMsec:\t" << b;
72  a = buffer[wordCounter];
73  wordCounter++;
74  b = (a & 0xffffffff);
75  tbEventHeader.setEndBurstTimeSec(b);
76  LogDebug("EcalSupervisorTBDataFormatter") << "EndBurstTimeSec:\t" << b;
77  a = buffer[wordCounter];
78  wordCounter++;
79  b = (a & 0xffffffff);
80  tbEventHeader.setEndBurstTimeMsec(b);
81  LogDebug("EcalSupervisorTBDataFormatter") << "EndBurstTimeMsec:\t" << b;
82  a = buffer[wordCounter];
83  wordCounter++;
84  b = (a & 0xffffffff);
85  tbEventHeader.setBegBurstLV1A(b);
86  LogDebug("EcalSupervisorTBDataFormatter") << "BegBurstLV1A:\t" << b;
87  a = buffer[wordCounter];
88  wordCounter++;
89  b = (a & 0xffffffff);
90  tbEventHeader.setEndBurstLV1A(b);
91  LogDebug("EcalSupervisorTBDataFormatter") << "EndBurstLV1A:\t" << b;
92 
93  if (version >= 11) {
94  std::vector<EcalTBEventHeader::magnetsMeasurement_t> magnetMeasurements;
95  for (int iMagMeas = 0; iMagMeas < numberOfMagnetMeasurements; iMagMeas++) {
96  LogDebug("EcalSupervisorTBDataFormatter") << "++++++ New Magnet Measurement++++++\t" << (iMagMeas + 1);
98  wordCounter += 4;
99  a = buffer[wordCounter];
100  wordCounter++;
101  b = (a & 0xffffffff);
102  aMeasurement.magnet6IRead_ampere = b;
103  LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet6ReadAmpere:\t" << b;
104  a = buffer[wordCounter];
105  wordCounter++;
106  b = (a & 0xffffffff);
107  aMeasurement.magnet6ISet_ampere = b;
108  LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet6SetAmpere:\t" << b;
109  a = buffer[wordCounter];
110  wordCounter++;
111  b = (a & 0xffffffff);
112  aMeasurement.magnet7IRead_ampere = b;
113  LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet7ReadAmpere:\t" << b;
114  a = buffer[wordCounter];
115  wordCounter++;
116  b = (a & 0xffffffff);
117  aMeasurement.magnet7ISet_ampere = b;
118  LogDebug("EcalSupervisorTBDataFormatter") << "NominalMagnet7SetAmpere:\t" << b;
119  a = buffer[wordCounter];
120  wordCounter++;
121  b = (a & 0xffffffff);
122  aMeasurement.magnet7VMeas_uvolt = b;
123  LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet7MicroVolt:\t" << b;
124  a = buffer[wordCounter];
125  wordCounter++;
126  b = (a & 0xffffffff);
127  aMeasurement.magnet7IMeas_uampere = b;
128  LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet7Ampere:\t" << b;
129  a = buffer[wordCounter];
130  wordCounter++;
131  b = (a & 0xffffffff);
132  aMeasurement.magnet6VMeas_uvolt = b;
133  LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet6MicroVolt:\t" << b;
134  a = buffer[wordCounter];
135  wordCounter++;
136  b = (a & 0xffffffff);
137  aMeasurement.magnet6IMeas_uampere = b;
138  LogDebug("EcalSupervisorTBDataFormatter") << "MeasuredMagnet6Ampere:\t" << b;
139  magnetMeasurements.push_back(aMeasurement);
140  }
141  tbEventHeader.setMagnetMeasurements(magnetMeasurements);
142  }
143 }
#define LogDebug(id)
void setBegBurstLV1A(const int &begBurstLV1A)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
void setEventNumber(const int &eventNumber)
void setBegBurstTimeMsec(const int &begBurstTimeMsec)
void setMagnetMeasurements(const std::vector< magnetsMeasurement_t > &magnetMeasurements)
void setRunNumber(const int &runNumber)
void setBurstNumber(const short &burstNumber)
void interpretRawData(const FEDRawData &data, EcalTBEventHeader &tbEventHeader)
double b
Definition: hdecay.h:118
void setNumberOfMagnetMeasurements(const int &numberOfMagnetMeasurements)
void setEndBurstLV1A(const int &endBurstLV1A)
void setEndBurstTimeSec(const int &endBurstTimeSec)
double a
Definition: hdecay.h:119
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
void setBegBurstTimeSec(const int &begBurstTimeSec)
void setEndBurstTimeMsec(const int &endBurstTimeMsec)
void setSyncError(const bool &syncError)