CMS 3D CMS Logo

Public Member Functions | Private Member Functions

MatacqDataFormatter Class Reference

#include <MatacqDataFormatter.h>

List of all members.

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.

{};

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().

                                                                                                             {
#if MATACQ_DEBUG
  cout << "****************************************************************\n";
  cout << "********************** MATACQ decoder **************************\n";
  cout << "****************************************************************\n";
  cout << "FEDRawData: \n";
  char oldPad = cout.fill('0');
  for(int i=0; i < max(100, (int)data.size()); ++i){
    cout << hex << setw(2) << (int)(data.data()[i])
         << ((i+1)%8?" ":"\n") ;
  }
  cout.fill(oldPad);
  cout << "======================================================================\n";
#endif //MATACQ_DEBUG defined
  interpretRawData(MatacqRawEvent(data.data(), data.size()),
                   matacqDigiCollection);  
}
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(), ExpressReco_HICollisions_FallBack::samples, matplotRender::t, EcalMatacqDigi::timeStamp(), EcalMatacqDigi::triggerType(), EcalMatacqDigi::trigRec(), EcalMatacqDigi::vernier(), and AlCaRecoCosmics_cfg::version.

                                                                                                                  {
#if MATACQ_DEBUG
  printData(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*numeric_limits<int>::max()?
    ps*matacq.getTTrigPs():999.;
  int version = matacq.getMatacqDataFormatVersion();
  
  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 vector<MatacqRawEvent::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;
    vector<int16_t> empty;
    EcalMatacqDigi matacqDigi(empty, chId, ts, version, tTrig);
#if (defined(ECAL_MATACQ_DIGI_VERS) && (ECAL_MATACQ_DIGI_VERS >= 2))
    matacqDigi.bxId(matacq.getBxId());
    matacqDigi.l1a(matacq.getEventId());
    matacqDigi.triggerType(matacq.getTriggerType());
    matacqDigi.orbitId(matacq.getOrbitId());
    matacqDigi.trigRec(matacq.getTrigRec());
    matacqDigi.postTrig(matacq.getPostTrig());
    matacqDigi.vernier(matacq.getVernier());
    matacqDigi.delayA(matacq.getDelayA());
    matacqDigi.emtcDelay(matacq.getEmtcDelay());
    matacqDigi.emtcPhase(matacq.getEmtcPhase());
    matacqDigi.attenuation_dB(matacq.getAttenuation_dB());
    matacqDigi.laserPower(matacq.getLaserPower());
    timeval t;
    matacq.getTimeStamp(t);
    matacqDigi.timeStamp(t);    
#endif //matacq digi version >=2
    matacqDigiCollection.push_back(matacqDigi);
    matacqDigiCollection.back().swap(samples); //swap is more efficient than a copy
  }
}
void MatacqDataFormatter::printData ( std::ostream &  out,
const MatacqRawEvent event 
) const [private]