CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

sistrip::DigiToRaw Class Reference

Input: edm::DetSetVector<SiStripDigi>. Output: FEDRawDataCollection. More...

#include <SiStripDigiToRaw.h>

List of all members.

Public Member Functions

void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers)
void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripRawDigi > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers)
 DigiToRaw (FEDReadoutMode, bool use_fed_key)
void fedReadoutMode (FEDReadoutMode mode)
 ~DigiToRaw ()

Private Member Functions

template<class Digi_t >
void createFedBuffers_ (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
uint16_t STRIP (const edm::DetSet< SiStripRawDigi >::const_iterator &it, const edm::DetSet< SiStripRawDigi >::const_iterator &begin) const
uint16_t STRIP (const edm::DetSet< SiStripDigi >::const_iterator &it, const edm::DetSet< SiStripDigi >::const_iterator &begin) const

Private Attributes

FEDBufferGenerator bufferGenerator_
FEDReadoutMode mode_
bool useFedKey_

Detailed Description

Input: edm::DetSetVector<SiStripDigi>. Output: FEDRawDataCollection.

Definition at line 29 of file SiStripDigiToRaw.h.


Constructor & Destructor Documentation

sistrip::DigiToRaw::DigiToRaw ( FEDReadoutMode  mode,
bool  useFedKey 
)

Definition at line 21 of file SiStripDigiToRaw.cc.

References bufferGenerator_, edm::isDebugEnabled(), LogDebug, mode_, and sistrip::FEDBufferGenerator::setReadoutMode().

                                         : 
    mode_(mode),
    useFedKey_(useFedKey),
    bufferGenerator_()
  {
    if ( edm::isDebugEnabled() ) {
      LogDebug("DigiToRaw")
        << "[sistrip::DigiToRaw::DigiToRaw]"
        << " Constructing object...";
    }
    bufferGenerator_.setReadoutMode(mode_);
  }
sistrip::DigiToRaw::~DigiToRaw ( )

Definition at line 37 of file SiStripDigiToRaw.cc.

References edm::isDebugEnabled(), and LogDebug.

                        {
    if ( edm::isDebugEnabled() ) {
      LogDebug("DigiToRaw")
        << "[sistrip::DigiToRaw::~DigiToRaw]"
        << " Destructing object...";
    }
  }

Member Function Documentation

void sistrip::DigiToRaw::createFedBuffers ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< edm::DetSetVector< SiStripDigi > > &  collection,
std::auto_ptr< FEDRawDataCollection > &  buffers 
)

Input: DetSetVector of SiStripDigis. Output: FEDRawDataCollection. Retrieves and iterates through FED buffers, extract FEDRawData from collection and (optionally) dumps raw data to stdout, locates start of FED buffer by identifying DAQ header, creates new Fed9UEvent object using current FEDRawData buffer, dumps FED buffer to stdout, retrieves data from various header fields

Definition at line 54 of file SiStripDigiToRaw.cc.

References runEdmFileComparison::collection, and createFedBuffers_().

Referenced by sistrip::DigiToRawModule::produce().

                                                                                 { 
    createFedBuffers_(event, cabling, collection, buffers, true);
  }
void sistrip::DigiToRaw::createFedBuffers ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< edm::DetSetVector< SiStripRawDigi > > &  digis,
std::auto_ptr< FEDRawDataCollection > &  buffers 
)

Definition at line 61 of file SiStripDigiToRaw.cc.

References runEdmFileComparison::collection, and createFedBuffers_().

                                                                                 { 
    createFedBuffers_(event, cabling, collection, buffers, false);
  }
template<class Digi_t >
void sistrip::DigiToRaw::createFedBuffers_ ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< edm::DetSetVector< Digi_t > > &  digis,
std::auto_ptr< FEDRawDataCollection > &  buffers,
bool  zeroSuppressed 
) [private]

Definition at line 69 of file SiStripDigiToRaw.cc.

References bufferGenerator_, runEdmFileComparison::collection, edm::DetSet< T >::data, alignCSCRings::e, edm::EventID::event(), exception, sistrip::FEDBufferGenerator::generateBuffer(), edm::EventBase::id(), sistrip::invalid32_, sistrip::invalid_, edm::isDebugEnabled(), combine::key, mode_, sistrip::READOUT_MODE_SCOPE, sistrip::FEDBufferGenerator::setL1ID(), STRIP(), strip(), sistrip::STRIPS_PER_FEDCH, useFedKey_, and relativeConstraints::value.

Referenced by createFedBuffers().

                                                          {
    try {
      
      //set the L1ID to use in the buffers
      bufferGenerator_.setL1ID(0xFFFFFF & event.id().event());
      
      const std::vector<uint16_t>& fed_ids = cabling->feds();
      std::vector<uint16_t>::const_iterator ifed;
      
      for ( ifed = fed_ids.begin(); ifed != fed_ids.end(); ifed++ ) {
        
        const std::vector<FedChannelConnection>& conns = cabling->connections(*ifed);
        std::vector<FedChannelConnection>::const_iterator iconn = conns.begin();
        
        FEDStripData fedData(zeroSuppressed);
        
        for ( ; iconn != conns.end(); iconn++ ) {
          
          // Determine FED key from cabling
          uint32_t fed_key = ( ( iconn->fedId() & sistrip::invalid_ ) << 16 ) | ( iconn->fedCh() & sistrip::invalid_ );
        
          // Determine whether DetId or FED key should be used to index digi containers
          uint32_t key = ( useFedKey_ || mode_ == READOUT_MODE_SCOPE ) ? fed_key : iconn->detId();
          
          // Check key is non-zero and valid
          if ( !key || ( key == sistrip::invalid32_ ) ) { continue; }

          // Determine APV pair number (needed only when using DetId)
          uint16_t ipair = ( useFedKey_ || mode_ == READOUT_MODE_SCOPE ) ? 0 : iconn->apvPairNumber();
          
          FEDStripData::ChannelData& chanData = fedData[iconn->fedCh()];

          // Find digis for DetID in collection
          typename std::vector< edm::DetSet<Digi_t> >::const_iterator digis = collection->find( key );
          if (digis == collection->end()) { continue; } 

          typename edm::DetSet<Digi_t>::const_iterator idigi, digis_begin(digis->data.begin());
          for ( idigi = digis_begin; idigi != digis->data.end(); idigi++ ) {
            
            if ( STRIP(idigi, digis_begin) < ipair*256 ||
                 STRIP(idigi, digis_begin) > ipair*256+255 ) { continue; }
            const unsigned short strip = STRIP(idigi, digis_begin) % 256;

            if ( strip >= STRIPS_PER_FEDCH ) {
              if ( edm::isDebugEnabled() ) {
                std::stringstream ss;
                ss << "[sistrip::DigiToRaw::createFedBuffers]"
                   << " strip >= strips_per_fedCh";
                edm::LogWarning("DigiToRaw") << ss.str();
              }
              continue;
            }
          
            // check if value already exists
            if ( edm::isDebugEnabled() ) {
              const uint16_t value = 0;//chanData[strip];
              if ( value && value != (*idigi).adc() ) {
                std::stringstream ss; 
                ss << "[sistrip::DigiToRaw::createFedBuffers]" 
                   << " Incompatible ADC values in buffer!"
                   << "  FedId/FedCh: " << *ifed << "/" << iconn->fedCh()
                   << "  DetStrip: " << STRIP(idigi, digis_begin)
                   << "  FedChStrip: " << strip
                   << "  AdcValue: " << (*idigi).adc()
                   << "  RawData[" << strip << "]: " << value;
                edm::LogWarning("DigiToRaw") << ss.str();
              }
            }

            // Add digi to buffer
            chanData[strip] = (*idigi).adc();

          }
          // if ((*idigi).strip() >= (ipair+1)*256) break;
        }

        //create the buffer
        FEDRawData& fedrawdata = buffers->FEDData( *ifed );
        bufferGenerator_.generateBuffer(&fedrawdata,fedData,*ifed);
        
       }
    }
    catch (const std::exception& e) {
      if ( edm::isDebugEnabled() ) {
        edm::LogWarning("DigiToRaw") 
          << "DigiToRaw::createFedBuffers] " 
          << "Exception caught : " << e.what();
      }
    }
  
  }
void sistrip::DigiToRaw::fedReadoutMode ( FEDReadoutMode  mode) [inline]

Definition at line 45 of file SiStripDigiToRaw.h.

References mode, and mode_.

{ mode_ = mode; }
uint16_t sistrip::DigiToRaw::STRIP ( const edm::DetSet< SiStripRawDigi >::const_iterator &  it,
const edm::DetSet< SiStripRawDigi >::const_iterator &  begin 
) const [inline, private]

Definition at line 166 of file SiStripDigiToRaw.cc.

References begin.

{return it-begin;}
uint16_t sistrip::DigiToRaw::STRIP ( const edm::DetSet< SiStripDigi >::const_iterator &  it,
const edm::DetSet< SiStripDigi >::const_iterator &  begin 
) const [inline, private]

Definition at line 165 of file SiStripDigiToRaw.cc.

Referenced by createFedBuffers_().

{return it->strip();}

Member Data Documentation

Definition at line 60 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), and DigiToRaw().

Definition at line 58 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), DigiToRaw(), and fedReadoutMode().

Definition at line 59 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().