CMS 3D CMS Logo

DTDDUUnpacker.cc
Go to the documentation of this file.
1 
13 
14 #include <iostream>
15 
16 using namespace std;
17 using namespace edm;
18 
20  // the ROS unpacker
22 
23  // parameters
24  localDAQ = dduPSet.getUntrackedParameter<bool>("localDAQ",false);
25  debug = dduPSet.getUntrackedParameter<bool>("debug",false);
26 }
27 
29  delete ros25Unpacker;
30 }
31 
32 
33 void DTDDUUnpacker::interpretRawData(const unsigned int* index32, int datasize,
34  int dduID,
36  std::unique_ptr<DTDigiCollection>& detectorProduct,
37  std::unique_ptr<DTLocalTriggerCollection>& triggerProduct,
38  uint16_t rosList) {
39 
40  // Definitions
41  const int wordSize_32 = 4;
42  const int wordSize_64 = 8;
43 
44  int numberOf32Words = datasize/wordSize_32;
45 
46  const unsigned char* index8 = reinterpret_cast<const unsigned char*>(index32);
47 
48 
50  /* D D U d a t a */
52 
53  // DDU header
54  FEDHeader dduHeader(index8);
55  if (dduHeader.check()) {
56  if(debug) cout << "[DTDDUUnpacker] FED Header. BXID: "<<dduHeader.bxID()
57  << " L1ID: "<<dduHeader.lvl1ID() <<endl;
58  } else {
59  LogWarning("DTRawToDigi|DTDDUUnpacker") << "[DTDDUUnpacker] WARNING!, this is not a DDU Header, FED ID: "
60  << dduID << endl;
61  }
62 
63  // DDU trailer
64  // [BITS] stop before FED trailer := 8 bytes
65  FEDTrailer dduTrailer(index8 + datasize - 1*wordSize_64);
66 
67  if (dduTrailer.check()) {
68  if(debug) cout << "[DTDDUUnpacker] FED Trailer. Length of the DT event: "
69  << dduTrailer.fragmentLength() << endl;
70  } else {
71  LogWarning("DTRawToDigi|DTDDUUnpacker") << "[DTDDUUnpacker] WARNING!, this is not a DDU Trailer, FED ID: "
72  << dduID << endl;
73  }
74 
75 
76  // Initialize control data
78  controlData.addDDUHeader(dduHeader);
79  controlData.addDDUTrailer(dduTrailer);
80  // check the CRC set in the FED trailer (FCRC errors)
81  controlData.checkCRCBit(index8 + datasize - 1*wordSize_64);
82 
83  // Check Status Words
84  vector<DTDDUFirstStatusWord> rosStatusWords;
85  // [BITS] 3 words of 8 bytes + "rosId" bytes
86  // In the case we are reading from DMA, the status word are swapped as the ROS data
87  if (localDAQ) {
88  // DDU channels from 1 to 4
89  for (int rosId = 0; rosId < 4; rosId++ ) {
90  int wordIndex8 = numberOf32Words*wordSize_32 - 3*wordSize_64 + wordSize_32 + rosId;
92  }
93  // DDU channels from 5 to 8
94  for (int rosId = 0; rosId < 4; rosId++ ) {
95  int wordIndex8 = numberOf32Words*wordSize_32 - 3*wordSize_64 + rosId;
97  }
98  // DDU channels from 9 to 12
99  for (int rosId = 0; rosId < 4; rosId++ ) {
100  int wordIndex8 = numberOf32Words*wordSize_32 - 2*wordSize_64 + wordSize_32 + rosId;
102  }
103  }
104  else {
105  for (int rosId = 0; rosId < 12; rosId++ ) {
106  int wordIndex8 = numberOf32Words*wordSize_32 - 3*wordSize_64 + rosId;
108  }
109  }
110 
111  int theROSList;
112  // [BITS] 2 words of 8 bytes + 4 bytes (half 64 bit word)
113  // In the case we are reading from DMA, the status word are swapped as the ROS data
114  if (localDAQ) {
115  DTDDUSecondStatusWord dduStatusWord(index32[numberOf32Words - 2*wordSize_64/wordSize_32]);
116  controlData.addDDUStatusWord(dduStatusWord);
117  theROSList = dduStatusWord.rosList();
118  }
119  else {
120  DTDDUSecondStatusWord dduStatusWord(index32[numberOf32Words - 2*wordSize_64/wordSize_32 + 1]);
121  controlData.addDDUStatusWord(dduStatusWord);
122  theROSList = dduStatusWord.rosList();
123  }
124 
125 
127  /* R O S d a t a */
129 
130  // Set the index to start looping on ROS data
131  // [BITS] one 8 bytes word
132  index32 += (wordSize_64)/wordSize_32;
133 
134  // Set the datasize to look only at ROS data
135  // [BITS] header, trailer, 2 status words
136  datasize -= 4*wordSize_64;
137 
138  // unpacking the ROS payload
139  ros25Unpacker->interpretRawData(index32, datasize, dduID, mapping, detectorProduct, triggerProduct, theROSList);
140 
141 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void interpretRawData(const unsigned int *index, int datasize, int dduID, edm::ESHandle< DTReadOutMapping > &mapping, std::unique_ptr< DTDigiCollection > &product, std::unique_ptr< DTLocalTriggerCollection > &product2, uint16_t rosList=0) override
void addDDUStatusWord(const DTDDUSecondStatusWord &word)
void addROSStatusWord(const DTDDUFirstStatusWord &word)
int rosList() const
Definition: DTDDUWords.h:903
bool check() const
Check that the header is OK.
Definition: FEDHeader.cc:72
bool check() const
Check that the trailer is OK.
Definition: FEDTrailer.cc:83
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:17
void interpretRawData(const unsigned int *index, int datasize, int dduID, edm::ESHandle< DTReadOutMapping > &mapping, std::unique_ptr< DTDigiCollection > &product, std::unique_ptr< DTLocalTriggerCollection > &product2, uint16_t rosList=0) override
DTROS25Unpacker * ros25Unpacker
Definition: DTDDUUnpacker.h:55
void addDDUHeader(const FEDHeader &word)
Setters.
void addDDUTrailer(const FEDTrailer &word)
bool localDAQ
if data are read locally, status words are swapped
Definition: DTDDUUnpacker.h:48
const edm::ParameterSet dduPSet
Definition: DTDDUUnpacker.h:45
void checkCRCBit(const unsigned char *trailer)
void clean()
uint16_t bxID() const
The bunch crossing number.
Definition: FEDHeader.cc:27
HLT enums.
~DTDDUUnpacker() override
Destructor.
uint32_t lvl1ID() const
Level-1 event number generated by the TTC system.
Definition: FEDHeader.cc:22
DTDDUUnpacker(const edm::ParameterSet &ps)
Constructor.
DTDDUData controlData
Definition: DTDDUUnpacker.h:57