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 15 of file MatacqDataFormatter.h.

Constructor & Destructor Documentation

MatacqTBDataFormatter::MatacqTBDataFormatter ( )
inline

Definition at line 17 of file MatacqDataFormatter.h.

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

Definition at line 18 of file MatacqDataFormatter.h.

References LogDebug.

18 {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 19 of file MatacqDataFormatter.cc.

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

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

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

Referenced by interpretRawData().

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