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)
Id:
MatacqDataFormatter.h,v 1.1 2009/02/25 14:44:25 pgras Exp
Id:
MatacqDataFormatter.h,v 1.5 2007/10/20 10:58:01 franzoni Exp

Definition at line 17 of file MatacqDataFormatter.h.

Constructor & Destructor Documentation

MatacqDataFormatter::MatacqDataFormatter ( )
inline

Definition at line 19 of file MatacqDataFormatter.h.

19 {};

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

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

Referenced by MatacqProducer::addMatacqData().

21  {
22 #if MATACQ_DEBUG
23  cout << "****************************************************************\n";
24  cout << "********************** MATACQ decoder **************************\n";
25  cout << "****************************************************************\n";
26  cout << "FEDRawData: \n";
27  char oldPad = cout.fill('0');
28  for(int i=0; i < max(100, (int)data.size()); ++i){
29  cout << hex << setw(2) << (int)(data.data()[i])
30  << ((i+1)%8?" ":"\n") ;
31  }
32  cout.fill(oldPad);
33  cout << "======================================================================\n";
34 #endif //MATACQ_DEBUG defined
35  interpretRawData(MatacqRawEvent(data.data(), data.size()),
36  matacqDigiCollection);
37 }
int i
Definition: DBlmapReader.cc:9
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
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 40 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.

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

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