CMS 3D CMS Logo

Public Member Functions | Private Member Functions

MatacqTBDataFormatter Class Reference

#include <MatacqDataFormatter.h>

List of all members.

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.

{};
virtual MatacqTBDataFormatter::~MatacqTBDataFormatter ( ) [inline, virtual]

Definition at line 18 of file MatacqDataFormatter.h.

References LogDebug.

{LogDebug("EcalTBRawToDigi") << "@SUB=MatacqTBDataFormatter" << "\n"; };

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 EcalDCCTB07UnpackingModule::produce(), and EcalDCCTBUnpackingModule::produce().

                                                                                                                     {
#if MATACQ_DEBUG
  std::cout << "****************************************************************\n";
  std::cout << "********************** MATACQ decoder **************************\n";
  std::cout << "****************************************************************\n";
  std::cout << "FEDRawData: \n";
  char oldPad = std::cout.fill('0');
  for(int i=0; i < max(100, (int)data.size()); ++i){
    std::cout << std::hex << std::setw(2) << (int)(data.data()[i])
         << ((i+1)%8?" ":"\n") ;
  }
  std::cout.fill(oldPad);
  std::cout << "======================================================================\n";
#endif //MATACQ_DEBUG defined
  
  MatacqTBRawEvent matacq(data.data(), data.size());

#if MATACQ_DEBUG
  printData(std::cout, matacq);
#endif //MATACQ_DEBUG defined

  const double ns = 1.e-9; //ns->s
  const double ps = 1.e-12;//ps->s
  double ts = ns/matacq.getFreqGHz();
  double tTrig = matacq.getTTrigPs()<.5*std::numeric_limits<int>::max()?
    ps*matacq.getTTrigPs():999.;
  int version = matacq.getMatacqDataFormatVersion();
  
  std::vector<int16_t> samples;
  //FIXME: the interpretRawData method should fill an EcalMatacqDigiCollection
  //instead of an EcalMatacqDigi because Matacq channels are several.
  //In the meamtime copy only the first channel appearing in data:
  const std::vector<MatacqTBRawEvent::ChannelData>& chData = matacq.getChannelData();
  for(unsigned iCh=0; iCh < chData.size(); ++iCh){
    //copy time samples into a vector:
    samples.resize(chData[iCh].nSamples);
    copy(chData[iCh].samples, chData[iCh].samples+chData[iCh].nSamples,
         samples.begin());
    int chId = chData[iCh].chId;
    std::vector<int16_t> empty;
    EcalMatacqDigi matacqDigi(empty, chId, ts, version, tTrig);
    matacqDigiCollection.push_back(matacqDigi);
    matacqDigiCollection.back().swap(samples); //swap is more efficient than a copy
  }
}
void MatacqTBDataFormatter::printData ( std::ostream &  out,
const MatacqTBRawEvent 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().

Referenced by interpretRawData().

                                                                                   {
  cout << "FED id: " << hex << "0x" << matacq.getFedId() << dec << "\n";
  cout << "Event id (lv1): " 
       << hex << "0x" << matacq.getEventId() << dec << "\n";
  cout << "FOV: " << hex << "0x" << matacq.getFov() << dec << "\n";
  cout << "BX id: " << hex << "0x" << matacq.getBxId() << dec << "\n";
  cout << "Trigger type: " 
       << hex << "0x" << matacq.getTriggerType() << dec << "\n";
  cout << "DCC Length: " << matacq.getDccLen() << "\n";
  cout << "Run number: " << matacq.getRunNum() << "\n";
  cout << "Field 'DCC errors': " 
       << hex << "0x" << matacq.getDccErrors() << dec << "\n";
  
  if(matacq.getStatus()){
    cout << "Error in matacq data. Errot code: "
         << hex << "0x" << matacq.getStatus() << dec << "\n";
  }
  
  cout << "MATACQ data format version: " << matacq.getMatacqDataFormatVersion()
       << "\n";
  cout << "Sampling frequency: " << matacq.getFreqGHz() << " GHz\n";
  cout << "MATACQ channel count: " << matacq.getChannelCount() << "\n";
  time_t timeStamp = matacq.getTimeStamp();
  cout << "Data acquired on : " << ctime(&timeStamp);

  const vector<MatacqRawEvent::ChannelData>& channels = matacq.getChannelData();
  for(unsigned i=0; i< channels.size(); ++i){
    cout << "-------------------------------------- Channel "
         << channels[i].chId
         << ": " << setw(4) << channels[i].nSamples
         << " samples --------------------------------------\n";
    
    for(int iSample = 0; iSample<channels[i].nSamples; ++iSample){
      MatacqRawEvent::int16le_t adc = (channels[i].samples)[iSample];
      cout << setw(4) << adc
           << ((iSample%20==19)?"\n":" ");
    }
  }
  cout << "=================================================="
    "==================================================\n\n";   
}