CMS 3D CMS Logo

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::MatacqDataFormatter ( )
inline

Definition at line 18 of file MatacqDataFormatter.h.

18 {}

Member Function Documentation

◆ interpretRawData() [1/2]

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

References gather_cfg::cout, data, mps_fire::i, createfilelist::int, and WZElectronSkims53X_cff::max.

Referenced by MatacqProducer::addMatacqData().

18  {
19 #if MATACQ_DEBUG
20  cout << "****************************************************************\n";
21  cout << "********************** MATACQ decoder **************************\n";
22  cout << "****************************************************************\n";
23  cout << "FEDRawData: \n";
24  char oldPad = cout.fill('0');
25  for (int i = 0; i < max(100, (int)data.size()); ++i) {
26  cout << hex << setw(2) << (int)(data.data()[i]) << ((i + 1) % 8 ? " " : "\n");
27  }
28  cout.fill(oldPad);
29  cout << "======================================================================\n";
30 #endif //MATACQ_DEBUG defined
31  interpretRawData(MatacqRawEvent(data.data(), data.size()), matacqDigiCollection);
32 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
void interpretRawData(const FEDRawData &data, EcalMatacqDigiCollection &matacqDigiCollection)

◆ interpretRawData() [2/2]

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 34 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(), WZElectronSkims53X_cff::max, PresampleTask_cfi::nSamples, EcalMatacqDigi::orbitId(), EcalMatacqDigi::postTrig(), edm::SortedCollection< T, SORT >::push_back(), EgammaValidation_cff::samples, submitPVValidationJobs::t, EcalMatacqDigi::timeStamp(), EcalMatacqDigi::triggerType(), EcalMatacqDigi::trigRec(), dttriganalyzer_cfi::tTrig, EcalMatacqDigi::vernier(), and relval_steps::version.

35  {
36 #if MATACQ_DEBUG
37  printData(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 * numeric_limits<int>::max() ? ps * matacq.getTTrigPs() : 999.;
44  int version = matacq.getMatacqDataFormatVersion();
45 
46  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 vector<MatacqRawEvent::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, samples.begin());
55  int chId = chData[iCh].chId;
56  vector<int16_t> empty;
57  EcalMatacqDigi matacqDigi(empty, chId, ts, version, tTrig);
58 #if (defined(ECAL_MATACQ_DIGI_VERS) && (ECAL_MATACQ_DIGI_VERS >= 2))
59  matacqDigi.bxId(matacq.getBxId());
60  matacqDigi.l1a(matacq.getEventId());
61  matacqDigi.triggerType(matacq.getTriggerType());
62  matacqDigi.orbitId(matacq.getOrbitId());
63  matacqDigi.trigRec(matacq.getTrigRec());
64  matacqDigi.postTrig(matacq.getPostTrig());
65  matacqDigi.vernier(matacq.getVernier());
66  matacqDigi.delayA(matacq.getDelayA());
67  matacqDigi.emtcDelay(matacq.getEmtcDelay());
68  matacqDigi.emtcPhase(matacq.getEmtcPhase());
69  matacqDigi.attenuation_dB(matacq.getAttenuation_dB());
70  matacqDigi.laserPower(matacq.getLaserPower());
71  timeval t;
72  matacq.getTimeStamp(t);
73  matacqDigi.timeStamp(t);
74 #endif //matacq digi version >=2
75  matacqDigiCollection.push_back(matacqDigi);
76  matacqDigiCollection.back().swap(samples); //swap is more efficient than a copy
77  }
78 }
void push_back(T const &t)
void printData(std::ostream &out, const MatacqRawEvent &event) const
const_reference back() const

◆ printData()

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

Definition at line 80 of file MatacqDataFormatter.cc.

References gpuClustering::adc, ewkTauDQM_cfi::channels, gather_cfg::cout, TauDecayModes::dec, 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 mps_fire::i.

80  {
81  cout << "FED id: " << hex << "0x" << matacq.getFedId() << dec << "\n";
82  cout << "Event id (lv1): " << hex << "0x" << matacq.getEventId() << dec << "\n";
83  cout << "FOV: " << hex << "0x" << matacq.getFov() << dec << "\n";
84  cout << "BX id: " << hex << "0x" << matacq.getBxId() << dec << "\n";
85  cout << "Trigger type: " << hex << "0x" << matacq.getTriggerType() << dec << "\n";
86  cout << "DCC Length: " << matacq.getDccLen() << "\n";
87  cout << "Run number: " << matacq.getRunNum() << "\n";
88  cout << "Field 'DCC errors': " << hex << "0x" << matacq.getDccErrors() << dec << "\n";
89 
90  if (matacq.getStatus()) {
91  cout << "Error in matacq data. Errot code: " << hex << "0x" << matacq.getStatus() << dec << "\n";
92  }
93 
94  cout << "MATACQ data format version: " << matacq.getMatacqDataFormatVersion() << "\n";
95  cout << "Sampling frequency: " << matacq.getFreqGHz() << " GHz\n";
96  cout << "MATACQ channel count: " << matacq.getChannelCount() << "\n";
97  time_t timeStamp = matacq.getTimeStamp();
98  cout << "Data acquired on : " << ctime(&timeStamp);
99 
100  const vector<MatacqRawEvent::ChannelData>& channels = matacq.getChannelData();
101  for (unsigned i = 0; i < channels.size(); ++i) {
102  cout << "-------------------------------------- Channel " << channels[i].chId << ": " << setw(4)
103  << channels[i].nSamples << " samples --------------------------------------\n";
104 
105  for (int iSample = 0; iSample < channels[i].nSamples; ++iSample) {
106  MatacqRawEvent::int16le_t adc = (channels[i].samples)[iSample];
107  cout << setw(4) << adc << ((iSample % 20 == 19) ? "\n" : " ");
108  }
109  }
110  cout << "=================================================="
111  "==================================================\n\n";
112 }
uint16_t *__restrict__ uint16_t const *__restrict__ adc