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 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 {LogDebug("EcalTBRawToDigi") << "@SUB=MatacqTBDataFormatter" << "\n"; };
#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 18 of file MatacqDataFormatter.cc.

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

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

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

Definition at line 64 of file MatacqDataFormatter.cc.

References ecalMGPA::adc(), gather_cfg::cout, 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 i.

Referenced by interpretRawData().

64  {
65  std::cout << "FED id: " << std::hex << "0x" << matacq.getFedId() << std::dec << "\n";
66  std::cout << "Event id (lv1): "
67  << std::hex << "0x" << matacq.getEventId() << std::dec << "\n";
68  std::cout << "FOV: " << std::hex << "0x" << matacq.getFov() << std::dec << "\n";
69  std::cout << "BX id: " << std::hex << "0x" << matacq.getBxId() << std::dec << "\n";
70  std::cout << "Trigger type: "
71  << std::hex << "0x" << matacq.getTriggerType() << std::dec << "\n";
72  std::cout << "DCC Length: " << matacq.getDccLen() << "\n";
73  std::cout << "Run number: " << matacq.getRunNum() << "\n";
74  std::cout << "Field 'DCC errors': "
75  << std::hex << "0x" << matacq.getDccErrors() << std::dec << "\n";
76 
77  if(matacq.getStatus()){
78  std::cout << "Error in matacq data. Errot code: "
79  << std::hex << "0x" << matacq.getStatus() << std::dec << "\n";
80  }
81 
82  std::cout << "MATACQ data format version: " << matacq.getMatacqDataFormatVersion()
83  << "\n";
84  std::cout << "Sampling frequency: " << matacq.getFreqGHz() << " GHz\n";
85  std::cout << "MATACQ channel count: " << matacq.getChannelCount() << "\n";
86  time_t timeStamp = matacq.getTimeStamp();
87  std::cout << "Data acquired on : " << ctime(&timeStamp);
88 
89  const std::vector<MatacqTBRawEvent::ChannelData>& channels = matacq.getChannelData();
90  for(unsigned i=0; i< channels.size(); ++i){
91  std::cout << "-------------------------------------- Channel "
92  << channels[i].chId
93  << ": " << std::setw(4) << channels[i].nSamples
94  << " samples --------------------------------------\n";
95 
96  for(int iSample = 0; iSample<channels[i].nSamples; ++iSample){
97  MatacqTBRawEvent::int16le_t adc = (channels[i].samples)[iSample];
98  std::cout << std::setw(4) << adc
99  << ((iSample%20==19)?"\n":" ");
100  }
101  }
102  std::cout << "=================================================="
103  "==================================================\n\n";
104 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:121