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
MatacqDataFormatter Class Reference

#include <MatacqDataFormatter.h>

Public Member Functions

void interpretRawData (const FEDRawData &data, EcalMatacqDigiCollection &matacqDigiCollection)
 
void interpretRawData (const MatacqRawEvent &data, EcalMatacqDigiCollection &matacqDigiCollection)
 
 MatacqDataFormatter ()
 

Private Member Functions

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

Detailed Description

Class to interpret ECAL MATACQ raw data and produce the MATACQ digis. This class is used by the MatacqProducer module.

Author
: Ph. Gras (CEA/Saclay)

Definition at line 16 of file MatacqDataFormatter.h.

Constructor & Destructor Documentation

MatacqDataFormatter::MatacqDataFormatter ( )
inline

Definition at line 18 of file MatacqDataFormatter.h.

18 {};

Member Function Documentation

void MatacqDataFormatter::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 20 of file MatacqDataFormatter.cc.

References gather_cfg::cout, FEDRawData::data(), i, max(), and FEDRawData::size().

Referenced by MatacqProducer::addMatacqData().

20  {
21 #if MATACQ_DEBUG
22  cout << "****************************************************************\n";
23  cout << "********************** MATACQ decoder **************************\n";
24  cout << "****************************************************************\n";
25  cout << "FEDRawData: \n";
26  char oldPad = cout.fill('0');
27  for(int i=0; i < max(100, (int)data.size()); ++i){
28  cout << hex << setw(2) << (int)(data.data()[i])
29  << ((i+1)%8?" ":"\n") ;
30  }
31  cout.fill(oldPad);
32  cout << "======================================================================\n";
33 #endif //MATACQ_DEBUG defined
34  interpretRawData(MatacqRawEvent(data.data(), data.size()),
35  matacqDigiCollection);
36 }
int i
Definition: DBlmapReader.cc:9
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
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:28
void interpretRawData(const FEDRawData &data, EcalMatacqDigiCollection &matacqDigiCollection)
tuple cout
Definition: gather_cfg.py:121
void MatacqDataFormatter::interpretRawData ( const MatacqRawEvent 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 39 of file MatacqDataFormatter.cc.

References EcalMatacqDigi::attenuation_dB(), edm::SortedCollection< T, SORT >::back(), EcalMatacqDigi::bxId(), filterCSVwithJSON::copy, gather_cfg::cout, EcalMatacqDigi::delayA(), relativeConstraints::empty, EcalMatacqDigi::emtcDelay(), EcalMatacqDigi::emtcPhase(), MatacqRawEvent::getAttenuation_dB(), MatacqRawEvent::getBxId(), MatacqRawEvent::getChannelData(), MatacqRawEvent::getDelayA(), MatacqRawEvent::getEmtcDelay(), MatacqRawEvent::getEmtcPhase(), MatacqRawEvent::getEventId(), MatacqRawEvent::getFreqGHz(), MatacqRawEvent::getLaserPower(), MatacqRawEvent::getMatacqDataFormatVersion(), MatacqRawEvent::getOrbitId(), MatacqRawEvent::getPostTrig(), MatacqRawEvent::getTimeStamp(), MatacqRawEvent::getTriggerType(), MatacqRawEvent::getTrigRec(), MatacqRawEvent::getTTrigPs(), MatacqRawEvent::getVernier(), EcalMatacqDigi::l1a(), EcalMatacqDigi::laserPower(), max(), EcalMatacqDigi::orbitId(), EcalMatacqDigi::postTrig(), edm::SortedCollection< T, SORT >::push_back(), lumiQTWidget::t, EcalMatacqDigi::timeStamp(), EcalMatacqDigi::triggerType(), EcalMatacqDigi::trigRec(), EcalMatacqDigi::vernier(), and BeamSplash_cfg::version.

39  {
40 #if MATACQ_DEBUG
41  printData(cout, matacq);
42 #endif //MATACQ_DEBUG defined
43 
44  const double ns = 1.e-9; //ns->s
45  const double ps = 1.e-12;//ps->s
46  double ts = ns/matacq.getFreqGHz();
47  double tTrig = matacq.getTTrigPs()<.5*numeric_limits<int>::max()?
48  ps*matacq.getTTrigPs():999.;
49  int version = matacq.getMatacqDataFormatVersion();
50 
51  vector<int16_t> samples;
52  //FIXME: the interpretRawData method should fill an EcalMatacqDigiCollection
53  //instead of an EcalMatacqDigi because Matacq channels are several.
54  //In the meamtime copy only the first channel appearing in data:
55  const vector<MatacqRawEvent::ChannelData>& chData = matacq.getChannelData();
56  for(unsigned iCh=0; iCh < chData.size(); ++iCh){
57  //copy time samples into a vector:
58  samples.resize(chData[iCh].nSamples);
59  copy(chData[iCh].samples, chData[iCh].samples+chData[iCh].nSamples,
60  samples.begin());
61  int chId = chData[iCh].chId;
62  vector<int16_t> empty;
63  EcalMatacqDigi matacqDigi(empty, chId, ts, version, tTrig);
64 #if (defined(ECAL_MATACQ_DIGI_VERS) && (ECAL_MATACQ_DIGI_VERS >= 2))
65  matacqDigi.bxId(matacq.getBxId());
66  matacqDigi.l1a(matacq.getEventId());
67  matacqDigi.triggerType(matacq.getTriggerType());
68  matacqDigi.orbitId(matacq.getOrbitId());
69  matacqDigi.trigRec(matacq.getTrigRec());
70  matacqDigi.postTrig(matacq.getPostTrig());
71  matacqDigi.vernier(matacq.getVernier());
72  matacqDigi.delayA(matacq.getDelayA());
73  matacqDigi.emtcDelay(matacq.getEmtcDelay());
74  matacqDigi.emtcPhase(matacq.getEmtcPhase());
75  matacqDigi.attenuation_dB(matacq.getAttenuation_dB());
76  matacqDigi.laserPower(matacq.getLaserPower());
77  timeval t;
78  matacq.getTimeStamp(t);
79  matacqDigi.timeStamp(t);
80 #endif //matacq digi version >=2
81  matacqDigiCollection.push_back(matacqDigi);
82  matacqDigiCollection.back().swap(samples); //swap is more efficient than a copy
83  }
84 }
void push_back(T const &t)
const T & max(const T &a, const T &b)
void printData(std::ostream &out, const MatacqRawEvent &event) const
tuple cout
Definition: gather_cfg.py:121
const_reference back() const
void MatacqDataFormatter::printData ( std::ostream &  out,
const MatacqRawEvent event 
) const
private

Definition at line 86 of file MatacqDataFormatter.cc.

References ecalMGPA::adc(), gather_cfg::cout, MatacqRawEvent::getBxId(), MatacqRawEvent::getChannelCount(), MatacqRawEvent::getChannelData(), MatacqRawEvent::getDccErrors(), MatacqRawEvent::getDccLen(), MatacqRawEvent::getEventId(), MatacqRawEvent::getFedId(), MatacqRawEvent::getFov(), MatacqRawEvent::getFreqGHz(), MatacqRawEvent::getMatacqDataFormatVersion(), MatacqRawEvent::getRunNum(), MatacqRawEvent::getStatus(), MatacqRawEvent::getTimeStamp(), MatacqRawEvent::getTriggerType(), and i.

86  {
87  cout << "FED id: " << hex << "0x" << matacq.getFedId() << dec << "\n";
88  cout << "Event id (lv1): "
89  << hex << "0x" << matacq.getEventId() << dec << "\n";
90  cout << "FOV: " << hex << "0x" << matacq.getFov() << dec << "\n";
91  cout << "BX id: " << hex << "0x" << matacq.getBxId() << dec << "\n";
92  cout << "Trigger type: "
93  << hex << "0x" << matacq.getTriggerType() << dec << "\n";
94  cout << "DCC Length: " << matacq.getDccLen() << "\n";
95  cout << "Run number: " << matacq.getRunNum() << "\n";
96  cout << "Field 'DCC errors': "
97  << hex << "0x" << matacq.getDccErrors() << dec << "\n";
98 
99  if(matacq.getStatus()){
100  cout << "Error in matacq data. Errot code: "
101  << hex << "0x" << matacq.getStatus() << dec << "\n";
102  }
103 
104  cout << "MATACQ data format version: " << matacq.getMatacqDataFormatVersion()
105  << "\n";
106  cout << "Sampling frequency: " << matacq.getFreqGHz() << " GHz\n";
107  cout << "MATACQ channel count: " << matacq.getChannelCount() << "\n";
108  time_t timeStamp = matacq.getTimeStamp();
109  cout << "Data acquired on : " << ctime(&timeStamp);
110 
111  const vector<MatacqRawEvent::ChannelData>& channels = matacq.getChannelData();
112  for(unsigned i=0; i< channels.size(); ++i){
113  cout << "-------------------------------------- Channel "
114  << channels[i].chId
115  << ": " << setw(4) << channels[i].nSamples
116  << " samples --------------------------------------\n";
117 
118  for(int iSample = 0; iSample<channels[i].nSamples; ++iSample){
119  MatacqRawEvent::int16le_t adc = (channels[i].samples)[iSample];
120  cout << setw(4) << adc
121  << ((iSample%20==19)?"\n":" ");
122  }
123  }
124  cout << "=================================================="
125  "==================================================\n\n";
126 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:121