CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
DTDDUUnpacker Class Reference

#include <DTDDUUnpacker.h>

Inheritance diagram for DTDDUUnpacker:
DTUnpacker

Public Member Functions

 DTDDUUnpacker (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual void interpretRawData (const unsigned int *index, int datasize, int dduID, edm::ESHandle< DTReadOutMapping > &mapping, std::auto_ptr< DTDigiCollection > &product, std::auto_ptr< DTLocalTriggerCollection > &product2, uint16_t rosList=0)
 
virtual ~DTDDUUnpacker ()
 Destructor. More...
 
- Public Member Functions inherited from DTUnpacker
 DTUnpacker ()
 Constructor. More...
 
virtual ~DTUnpacker ()
 Destructor. More...
 

Private Attributes

DTDataMonitorInterfacedataMonitor
 
const edm::ParameterSet dduPSet
 
bool debug
 
bool localDAQ
 if data are read locally, status words are swapped More...
 
bool performDataIntegrityMonitor
 perform DQM for DDU More...
 
DTROS25Unpackerros25Unpacker
 

Detailed Description

The unpacker for DTs' FED.

Author
M. Zanetti INFN Padova FRC 060906

Definition at line 17 of file DTDDUUnpacker.h.

Constructor & Destructor Documentation

DTDDUUnpacker::DTDDUUnpacker ( const edm::ParameterSet ps)

Constructor.

Definition at line 26 of file DTDDUUnpacker.cc.

References dataMonitor, dduPSet, debug, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), edm::Service< T >::isAvailable(), localDAQ, cppFunctionSkipper::operator, performDataIntegrityMonitor, and ros25Unpacker.

26  : dduPSet(ps) {
27 
28  // the ROS unpacker
30 
31  // parameters
32  localDAQ = dduPSet.getUntrackedParameter<bool>("localDAQ",false);
33  performDataIntegrityMonitor = dduPSet.getUntrackedParameter<bool>("performDataIntegrityMonitor",false);
34  debug = dduPSet.getUntrackedParameter<bool>("debug",false);
35 
36  // enable DQM if Service is available
37  if(performDataIntegrityMonitor) {
40  } else {
41  LogWarning("DTRawToDigi|DTDDUUnpacker") <<
42  "[DTDDUUnpacker] WARNING! Data Integrity Monitoring requested but no DTDataMonitorInterface Service available" << endl;
43  performDataIntegrityMonitor = false;
44  }
45  }
46 
47 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
DTDataMonitorInterface * dataMonitor
Definition: DTDDUUnpacker.h:49
DTROS25Unpacker * ros25Unpacker
Definition: DTDDUUnpacker.h:47
bool isAvailable() const
Definition: Service.h:46
bool localDAQ
if data are read locally, status words are swapped
Definition: DTDDUUnpacker.h:40
const edm::ParameterSet dduPSet
Definition: DTDDUUnpacker.h:37
bool performDataIntegrityMonitor
perform DQM for DDU
Definition: DTDDUUnpacker.h:43
DTDDUUnpacker::~DTDDUUnpacker ( )
virtual

Destructor.

Definition at line 50 of file DTDDUUnpacker.cc.

References ros25Unpacker.

50  {
51  delete ros25Unpacker;
52 }
DTROS25Unpacker * ros25Unpacker
Definition: DTDDUUnpacker.h:47

Member Function Documentation

void DTDDUUnpacker::interpretRawData ( const unsigned int *  index,
int  datasize,
int  dduID,
edm::ESHandle< DTReadOutMapping > &  mapping,
std::auto_ptr< DTDigiCollection > &  product,
std::auto_ptr< DTLocalTriggerCollection > &  product2,
uint16_t  rosList = 0 
)
virtual

Unpacking method. index is the pointer to the beginning of the buffer. datasize is the size of the buffer in bytes

Implements DTUnpacker.

Definition at line 55 of file DTDDUUnpacker.cc.

References DTDDUData::addDDUStatusWord(), DTDDUData::addROSStatusWord(), FEDHeader::bxID(), FEDTrailer::check(), FEDHeader::check(), DTDDUData::checkCRCBit(), gather_cfg::cout, dataMonitor, debug, DTROS25Unpacker::getROSsControlData(), DTROS25Unpacker::interpretRawData(), FEDTrailer::lenght(), localDAQ, FEDHeader::lvl1ID(), performDataIntegrityMonitor, DTDataMonitorInterface::processFED(), ros25Unpacker, and DTDDUSecondStatusWord::rosList().

60  {
61 
62  // Definitions
63  const int wordSize_32 = 4;
64  const int wordSize_64 = 8;
65 
66  int numberOf32Words = datasize/wordSize_32;
67 
68  const unsigned char* index8 = reinterpret_cast<const unsigned char*>(index32);
69 
70 
72  /* D D U d a t a */
74 
75  // DDU header
76  FEDHeader dduHeader(index8);
77  if (dduHeader.check()) {
78  if(debug) cout << "[DTDDUUnpacker] FED Header. BXID: "<<dduHeader.bxID()
79  << " L1ID: "<<dduHeader.lvl1ID() <<endl;
80  } else {
81  LogWarning("DTRawToDigi|DTDDUUnpacker") << "[DTDDUUnpacker] WARNING!, this is not a DDU Header, FED ID: "
82  << dduID << endl;
83  }
84 
85  // DDU trailer
86  // [BITS] stop before FED trailer := 8 bytes
87  FEDTrailer dduTrailer(index8 + datasize - 1*wordSize_64);
88 
89  if (dduTrailer.check()) {
90  if(debug) cout << "[DTDDUUnpacker] FED Trailer. Lenght of the DT event: "
91  << dduTrailer.lenght() << endl;
92  } else {
93  LogWarning("DTRawToDigi|DTDDUUnpacker") << "[DTDDUUnpacker] WARNING!, this is not a DDU Trailer, FED ID: "
94  << dduID << endl;
95  }
96 
97 
98  // Control DDU data
99  DTDDUData controlData(dduHeader,dduTrailer);
100  // check the CRC set in the FED trailer (FCRC errors)
101  controlData.checkCRCBit(index8 + datasize - 1*wordSize_64);
102 
103  // Check Status Words
104  vector<DTDDUFirstStatusWord> rosStatusWords;
105  // [BITS] 3 words of 8 bytes + "rosId" bytes
106  // In the case we are reading from DMA, the status word are swapped as the ROS data
107  if (localDAQ) {
108  // DDU channels from 1 to 4
109  for (int rosId = 0; rosId < 4; rosId++ ) {
110  int wordIndex8 = numberOf32Words*wordSize_32 - 3*wordSize_64 + wordSize_32 + rosId;
111  controlData.addROSStatusWord(DTDDUFirstStatusWord(index8[wordIndex8]));
112  }
113  // DDU channels from 5 to 8
114  for (int rosId = 0; rosId < 4; rosId++ ) {
115  int wordIndex8 = numberOf32Words*wordSize_32 - 3*wordSize_64 + rosId;
116  controlData.addROSStatusWord(DTDDUFirstStatusWord(index8[wordIndex8]));
117  }
118  // DDU channels from 9 to 12
119  for (int rosId = 0; rosId < 4; rosId++ ) {
120  int wordIndex8 = numberOf32Words*wordSize_32 - 2*wordSize_64 + wordSize_32 + rosId;
121  controlData.addROSStatusWord(DTDDUFirstStatusWord(index8[wordIndex8]));
122  }
123  }
124  else {
125  for (int rosId = 0; rosId < 12; rosId++ ) {
126  int wordIndex8 = numberOf32Words*wordSize_32 - 3*wordSize_64 + rosId;
127  controlData.addROSStatusWord(DTDDUFirstStatusWord(index8[wordIndex8]));
128  }
129  }
130 
131  int theROSList;
132  // [BITS] 2 words of 8 bytes + 4 bytes (half 64 bit word)
133  // In the case we are reading from DMA, the status word are swapped as the ROS data
134  if (localDAQ) {
135  DTDDUSecondStatusWord dduStatusWord(index32[numberOf32Words - 2*wordSize_64/wordSize_32]);
136  controlData.addDDUStatusWord(dduStatusWord);
137  theROSList = dduStatusWord.rosList();
138  }
139  else {
140  DTDDUSecondStatusWord dduStatusWord(index32[numberOf32Words - 2*wordSize_64/wordSize_32 + 1]);
141  controlData.addDDUStatusWord(dduStatusWord);
142  theROSList = dduStatusWord.rosList();
143  }
144 
145 
147  /* R O S d a t a */
149 
150  // Set the index to start looping on ROS data
151  // [BITS] one 8 bytes word
152  index32 += (wordSize_64)/wordSize_32;
153 
154  // Set the datasize to look only at ROS data
155  // [BITS] header, trailer, 2 status words
156  datasize -= 4*wordSize_64;
157 
158  // unpacking the ROS payload
159  ros25Unpacker->interpretRawData(index32, datasize, dduID, mapping, detectorProduct, triggerProduct, theROSList);
160 
161  // Perform DQM if requested
163  dataMonitor->processFED(controlData, ros25Unpacker->getROSsControlData(),dduID);
164 
165 }
DTDataMonitorInterface * dataMonitor
Definition: DTDDUUnpacker.h:49
virtual void interpretRawData(const unsigned int *index, int datasize, int dduID, edm::ESHandle< DTReadOutMapping > &mapping, std::auto_ptr< DTDigiCollection > &product, std::auto_ptr< DTLocalTriggerCollection > &product2, uint16_t rosList=0)
DTROS25Unpacker * ros25Unpacker
Definition: DTDDUUnpacker.h:47
virtual void processFED(DTDDUData &dduData, const std::vector< DTROS25Data > &rosData, int ddu)=0
bool localDAQ
if data are read locally, status words are swapped
Definition: DTDDUUnpacker.h:40
bool performDataIntegrityMonitor
perform DQM for DDU
Definition: DTDDUUnpacker.h:43
tuple cout
Definition: gather_cfg.py:121
const std::vector< DTROS25Data > & getROSsControlData() const

Member Data Documentation

DTDataMonitorInterface* DTDDUUnpacker::dataMonitor
private

Definition at line 49 of file DTDDUUnpacker.h.

Referenced by DTDDUUnpacker(), and interpretRawData().

const edm::ParameterSet DTDDUUnpacker::dduPSet
private

Definition at line 37 of file DTDDUUnpacker.h.

Referenced by DTDDUUnpacker().

bool DTDDUUnpacker::debug
private
bool DTDDUUnpacker::localDAQ
private

if data are read locally, status words are swapped

Definition at line 40 of file DTDDUUnpacker.h.

Referenced by DTDDUUnpacker(), and interpretRawData().

bool DTDDUUnpacker::performDataIntegrityMonitor
private

perform DQM for DDU

Definition at line 43 of file DTDDUUnpacker.h.

Referenced by DTDDUUnpacker(), and interpretRawData().

DTROS25Unpacker* DTDDUUnpacker::ros25Unpacker
private

Definition at line 47 of file DTDDUUnpacker.h.

Referenced by DTDDUUnpacker(), interpretRawData(), and ~DTDDUUnpacker().