CMS 3D CMS Logo

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

#include <MatacqDataFormatter.h>

Public Member Functions

void interpretRawData (const FEDRawData &data, EcalMatacqDigiCollection &matacqDigiCollection)
 
 MatacqTBDataFormatter ()
 
virtual ~MatacqTBDataFormatter ()
 

Private Member Functions

void printData (std::ostream &out, const MatacqTBRawEvent &event) const
 

Detailed Description

Definition at line 14 of file MatacqDataFormatter.h.

Constructor & Destructor Documentation

MatacqTBDataFormatter::MatacqTBDataFormatter ( )
inline

Definition at line 16 of file MatacqDataFormatter.h.

16 {};
virtual MatacqTBDataFormatter::~MatacqTBDataFormatter ( )
inlinevirtual

Definition at line 17 of file MatacqDataFormatter.h.

References LogDebug.

17  {
18  LogDebug("EcalTBRawToDigi") << "@SUB=MatacqTBDataFormatter"
19  << "\n";
20  };
#define LogDebug(id)

Member Function Documentation

void MatacqTBDataFormatter::interpretRawData ( const FEDRawData data,
EcalMatacqDigiCollection matacqDigiCollection 
)

Callback method for decoding raw data

Parameters
dataraw data
matacqDigiCollection[out] digi collection object to fill with the decoded data

Definition at line 16 of file MatacqDataFormatter.cc.

References edm::SortedCollection< T, SORT >::back(), filterCSVwithJSON::copy, gather_cfg::cout, FEDRawData::data(), relativeConstraints::empty, mps_fire::i, SiStripPI::max, hgc_digi::nSamples, printData(), edm::SortedCollection< T, SORT >::push_back(), FEDRawData::size(), and relval_steps::version.

Referenced by EcalDCCTBUnpackingModule::produce(), and EcalDCCTB07UnpackingModule::produce().

16  {
17 #if MATACQ_DEBUG
18  std::cout << "****************************************************************\n";
19  std::cout << "********************** MATACQ decoder **************************\n";
20  std::cout << "****************************************************************\n";
21  std::cout << "FEDRawData: \n";
22  char oldPad = std::cout.fill('0');
23  for (int i = 0; i < max(100, (int)data.size()); ++i) {
24  std::cout << std::hex << std::setw(2) << (int)(data.data()[i]) << ((i + 1) % 8 ? " " : "\n");
25  }
26  std::cout.fill(oldPad);
27  std::cout << "======================================================================\n";
28 #endif //MATACQ_DEBUG defined
29 
30  MatacqTBRawEvent matacq(data.data(), data.size());
31 
32 #if MATACQ_DEBUG
33  printData(std::cout, matacq);
34 #endif //MATACQ_DEBUG defined
35 
36  const double ns = 1.e-9; //ns->s
37  const double ps = 1.e-12; //ps->s
38  double ts = ns / matacq.getFreqGHz();
39  double tTrig = matacq.getTTrigPs() < .5 * std::numeric_limits<int>::max() ? ps * matacq.getTTrigPs() : 999.;
40  int version = matacq.getMatacqDataFormatVersion();
41 
42  std::vector<int16_t> samples;
43  //FIXME: the interpretRawData method should fill an EcalMatacqDigiCollection
44  //instead of an EcalMatacqDigi because Matacq channels are several.
45  //In the meamtime copy only the first channel appearing in data:
46  const std::vector<MatacqTBRawEvent::ChannelData>& chData = matacq.getChannelData();
47  for (unsigned iCh = 0; iCh < chData.size(); ++iCh) {
48  //copy time samples into a vector:
49  samples.resize(chData[iCh].nSamples);
50  copy(chData[iCh].samples, chData[iCh].samples + chData[iCh].nSamples, samples.begin());
51  int chId = chData[iCh].chId;
52  std::vector<int16_t> empty;
53  EcalMatacqDigi matacqDigi(empty, chId, ts, version, tTrig);
54  matacqDigiCollection.push_back(matacqDigi);
55  matacqDigiCollection.back().swap(samples); //swap is more efficient than a copy
56  }
57 }
void printData(std::ostream &out, const MatacqTBRawEvent &event) const
void push_back(T const &t)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
constexpr size_t nSamples
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
tuple cout
Definition: gather_cfg.py:144
const_reference back() const
void MatacqTBDataFormatter::printData ( std::ostream &  out,
const MatacqTBRawEvent event 
) const
private

Definition at line 59 of file MatacqDataFormatter.cc.

References gpuClustering::adc, gather_cfg::cout, TauDecayModes::dec, MatacqTBRawEvent::getBxId(), MatacqTBRawEvent::getChannelCount(), MatacqTBRawEvent::getChannelData(), MatacqTBRawEvent::getDccErrors(), MatacqTBRawEvent::getDccLen(), MatacqTBRawEvent::getEventId(), MatacqTBRawEvent::getFedId(), MatacqTBRawEvent::getFov(), MatacqTBRawEvent::getFreqGHz(), MatacqTBRawEvent::getMatacqDataFormatVersion(), MatacqTBRawEvent::getRunNum(), MatacqTBRawEvent::getStatus(), MatacqTBRawEvent::getTimeStamp(), MatacqTBRawEvent::getTriggerType(), and mps_fire::i.

Referenced by interpretRawData().

59  {
60  std::cout << "FED id: " << std::hex << "0x" << matacq.getFedId() << std::dec << "\n";
61  std::cout << "Event id (lv1): " << std::hex << "0x" << matacq.getEventId() << std::dec << "\n";
62  std::cout << "FOV: " << std::hex << "0x" << matacq.getFov() << std::dec << "\n";
63  std::cout << "BX id: " << std::hex << "0x" << matacq.getBxId() << std::dec << "\n";
64  std::cout << "Trigger type: " << std::hex << "0x" << matacq.getTriggerType() << std::dec << "\n";
65  std::cout << "DCC Length: " << matacq.getDccLen() << "\n";
66  std::cout << "Run number: " << matacq.getRunNum() << "\n";
67  std::cout << "Field 'DCC errors': " << std::hex << "0x" << matacq.getDccErrors() << std::dec << "\n";
68 
69  if (matacq.getStatus()) {
70  std::cout << "Error in matacq data. Errot code: " << std::hex << "0x" << matacq.getStatus() << std::dec << "\n";
71  }
72 
73  std::cout << "MATACQ data format version: " << matacq.getMatacqDataFormatVersion() << "\n";
74  std::cout << "Sampling frequency: " << matacq.getFreqGHz() << " GHz\n";
75  std::cout << "MATACQ channel count: " << matacq.getChannelCount() << "\n";
76  time_t timeStamp = matacq.getTimeStamp();
77  std::cout << "Data acquired on : " << ctime(&timeStamp);
78 
79  const std::vector<MatacqTBRawEvent::ChannelData>& channels = matacq.getChannelData();
80  for (unsigned i = 0; i < channels.size(); ++i) {
81  std::cout << "-------------------------------------- Channel " << channels[i].chId << ": " << std::setw(4)
82  << channels[i].nSamples << " samples --------------------------------------\n";
83 
84  for (int iSample = 0; iSample < channels[i].nSamples; ++iSample) {
85  MatacqTBRawEvent::int16le_t adc = (channels[i].samples)[iSample];
86  std::cout << std::setw(4) << adc << ((iSample % 20 == 19) ? "\n" : " ");
87  }
88  }
89  std::cout << "=================================================="
90  "==================================================\n\n";
91 }
tuple cout
Definition: gather_cfg.py:144
uint16_t *__restrict__ uint16_t const *__restrict__ adc