CMS 3D CMS Logo

DTDDUUnpacker.cc
Go to the documentation of this file.
1 
14 
15 #include <iostream>
16 
17 using namespace std;
18 using namespace edm;
19 
21  // the ROS unpacker
23 
24  // parameters
25  localDAQ = dduPSet.getUntrackedParameter<bool>("localDAQ",false);
26  debug = dduPSet.getUntrackedParameter<bool>("debug",false);
27 }
28 
30  delete ros25Unpacker;
31 }
32 
33 
34 void DTDDUUnpacker::interpretRawData(const unsigned int* index32, int datasize,
35  int dduID,
37  std::unique_ptr<DTDigiCollection>& detectorProduct,
38  std::unique_ptr<DTLocalTriggerCollection>& triggerProduct,
39  uint16_t rosList) {
40 
41  // Definitions
42  const int wordSize_32 = 4;
43  const int wordSize_64 = 8;
44 
45  int numberOf32Words = datasize/wordSize_32;
46 
47  const unsigned char* index8 = reinterpret_cast<const unsigned char*>(index32);
48 
49 
51  /* D D U d a t a */
53 
54  // DDU header
55  FEDHeader dduHeader(index8);
56  if (dduHeader.check()) {
57  if(debug) cout << "[DTDDUUnpacker] FED Header. BXID: "<<dduHeader.bxID()
58  << " L1ID: "<<dduHeader.lvl1ID() <<endl;
59  } else {
60  LogWarning("DTRawToDigi|DTDDUUnpacker") << "[DTDDUUnpacker] WARNING!, this is not a DDU Header, FED ID: "
61  << dduID << endl;
62  }
63 
64  // DDU trailer
65  // [BITS] stop before FED trailer := 8 bytes
66  FEDTrailer dduTrailer(index8 + datasize - 1*wordSize_64);
67 
68  if (dduTrailer.check()) {
69  if(debug) cout << "[DTDDUUnpacker] FED Trailer. Length of the DT event: "
70  << dduTrailer.fragmentLength() << endl;
71  } else {
72  LogWarning("DTRawToDigi|DTDDUUnpacker") << "[DTDDUUnpacker] WARNING!, this is not a DDU Trailer, FED ID: "
73  << dduID << endl;
74  }
75 
76 
77  // Initialize control data
79  controlData.addDDUHeader(dduHeader);
80  controlData.addDDUTrailer(dduTrailer);
81  // check the CRC set in the FED trailer (FCRC errors)
82  controlData.checkCRCBit(index8 + datasize - 1*wordSize_64);
83 
84  // Check Status Words
85  vector<DTDDUFirstStatusWord> rosStatusWords;
86  // [BITS] 3 words of 8 bytes + "rosId" bytes
87  // In the case we are reading from DMA, the status word are swapped as the ROS data
88  if (localDAQ) {
89  // DDU channels from 1 to 4
90  for (int rosId = 0; rosId < 4; rosId++ ) {
91  int wordIndex8 = numberOf32Words*wordSize_32 - 3*wordSize_64 + wordSize_32 + rosId;
93  }
94  // DDU channels from 5 to 8
95  for (int rosId = 0; rosId < 4; rosId++ ) {
96  int wordIndex8 = numberOf32Words*wordSize_32 - 3*wordSize_64 + rosId;
98  }
99  // DDU channels from 9 to 12
100  for (int rosId = 0; rosId < 4; rosId++ ) {
101  int wordIndex8 = numberOf32Words*wordSize_32 - 2*wordSize_64 + wordSize_32 + rosId;
103  }
104  }
105  else {
106  for (int rosId = 0; rosId < 12; rosId++ ) {
107  int wordIndex8 = numberOf32Words*wordSize_32 - 3*wordSize_64 + rosId;
109  }
110  }
111 
112  int theROSList;
113  // [BITS] 2 words of 8 bytes + 4 bytes (half 64 bit word)
114  // In the case we are reading from DMA, the status word are swapped as the ROS data
115  if (localDAQ) {
116  DTDDUSecondStatusWord dduStatusWord(index32[numberOf32Words - 2*wordSize_64/wordSize_32]);
117  controlData.addDDUStatusWord(dduStatusWord);
118  theROSList = dduStatusWord.rosList();
119  }
120  else {
121  DTDDUSecondStatusWord dduStatusWord(index32[numberOf32Words - 2*wordSize_64/wordSize_32 + 1]);
122  controlData.addDDUStatusWord(dduStatusWord);
123  theROSList = dduStatusWord.rosList();
124  }
125 
126 
128  /* R O S d a t a */
130 
131  // Set the index to start looping on ROS data
132  // [BITS] one 8 bytes word
133  index32 += (wordSize_64)/wordSize_32;
134 
135  // Set the datasize to look only at ROS data
136  // [BITS] header, trailer, 2 status words
137  datasize -= 4*wordSize_64;
138 
139  // unpacking the ROS payload
140  ros25Unpacker->interpretRawData(index32, datasize, dduID, mapping, detectorProduct, triggerProduct, theROSList);
141 
142 }
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