CMS 3D CMS Logo

Classes | Public Member Functions | Private Types | Private Attributes

sistrip::DetSetVectorFiller< T, dsvIsSparse > Class Template Reference

#include <SiStripDetSetVectorFiller.h>

List of all members.

Classes

struct  ChannelRegistryItem

Public Member Functions

void addItem (const T &item)
std::auto_ptr
< edm::DetSetVector< T > > 
createDetSetVector ()
 DetSetVectorFiller (const size_t registrySize, const size_t dataSize)
void newChannel (const uint32_t key, const uint16_t firstItem=0)
 ~DetSetVectorFiller ()

Private Types

typedef std::vector< TData
typedef std::vector
< ChannelRegistryItem
Registry

Private Attributes

Data data_
Registry registry_

Detailed Description

template<typename T, bool dsvIsSparse>
class sistrip::DetSetVectorFiller< T, dsvIsSparse >

Definition at line 17 of file SiStripDetSetVectorFiller.h.


Member Typedef Documentation

template<typename T , bool dsvIsSparse>
typedef std::vector<T> sistrip::DetSetVectorFiller< T, dsvIsSparse >::Data [private]

Definition at line 39 of file SiStripDetSetVectorFiller.h.

template<typename T , bool dsvIsSparse>
typedef std::vector<ChannelRegistryItem> sistrip::DetSetVectorFiller< T, dsvIsSparse >::Registry [private]

Definition at line 38 of file SiStripDetSetVectorFiller.h.


Constructor & Destructor Documentation

template<typename T , bool dsvIsSparse>
sistrip::DetSetVectorFiller< T, dsvIsSparse >::DetSetVectorFiller ( const size_t  registrySize,
const size_t  dataSize 
) [inline]

Definition at line 45 of file SiStripDetSetVectorFiller.h.

  {
    registry_.reserve(registrySize);
    data_.reserve(dataSize);
  }
template<typename T , bool dsvIsSparse>
sistrip::DetSetVectorFiller< T, dsvIsSparse >::~DetSetVectorFiller ( ) [inline]

Definition at line 51 of file SiStripDetSetVectorFiller.h.

  {}

Member Function Documentation

template<typename T , bool dsvIsSparse>
void sistrip::DetSetVectorFiller< T, dsvIsSparse >::addItem ( const T item) [inline]

Definition at line 59 of file SiStripDetSetVectorFiller.h.

Referenced by sistrip::SpyUnpacker::createDigis(), and sistrip::SpyDigiConverter::mergeModuleChannels().

  {
    data_.push_back(item);
    registry_.back().length++;
  }
template<typename T , bool dsvIsSparse>
std::auto_ptr< edm::DetSetVector< T > > sistrip::DetSetVectorFiller< T, dsvIsSparse >::createDetSetVector ( )

Definition at line 65 of file SiStripDetSetVectorFiller.h.

References filterCSVwithJSON::copy, Exception, and python::multivaluedict::sort().

Referenced by sistrip::SpyUnpacker::createDigis(), and sistrip::SpyDigiConverter::mergeModuleChannels().

  {
    std::sort(registry_.begin(),registry_.end());
    std::vector< edm::DetSet<T> > sorted_and_merged;
    sorted_and_merged.reserve(registry_.size());
    typename Registry::const_iterator iReg = registry_.begin();
    const typename Registry::const_iterator endReg = registry_.end();
    while (iReg != endReg) {
      sorted_and_merged.push_back( edm::DetSet<T>(iReg->key) );
      std::vector<T>& detSetData = sorted_and_merged.back().data;
      typename Registry::const_iterator jReg;
      if (dsvIsSparse) {
        uint16_t length = 0;
        for (jReg = iReg; (jReg != endReg) && (jReg->key == iReg->key); ++jReg) length += jReg->length;
        detSetData.reserve(length);
        for (jReg = iReg; (jReg != endReg) && (jReg->key == iReg->key); ++jReg) {
          detSetData.insert(detSetData.end(), data_.begin()+jReg->startIndex, data_.begin()+jReg->startIndex+jReg->length);
        }
      } else {
        uint16_t detLength = 0;
        uint16_t firstItemOfLastChannel = 0;
        for (jReg = iReg; (jReg != endReg) && (jReg->key == iReg->key); ++jReg) {
          if (!detLength) detLength = jReg->length;
          else if (detLength != jReg->length) throw cms::Exception("DetSetVectorFiller") << "Cannot fill non-sparse DetSet if channels are not unformly sized.";
          firstItemOfLastChannel = jReg->firstItem;
        }
        detSetData.resize(firstItemOfLastChannel+detLength);
        for (jReg = iReg; (jReg != endReg) && (jReg->key == iReg->key); ++jReg) {
          std::copy(data_.begin()+jReg->startIndex, data_.begin()+jReg->startIndex+jReg->length, detSetData.begin()+jReg->firstItem);
        }
      }
      iReg = jReg;
    }
    return typename std::auto_ptr< edm::DetSetVector<T> >( new edm::DetSetVector<T>(sorted_and_merged, true) );
  }
template<typename T , bool dsvIsSparse>
void sistrip::DetSetVectorFiller< T, dsvIsSparse >::newChannel ( const uint32_t  key,
const uint16_t  firstItem = 0 
) [inline]

Definition at line 54 of file SiStripDetSetVectorFiller.h.

Referenced by sistrip::SpyUnpacker::createDigis(), and sistrip::SpyDigiConverter::mergeModuleChannels().

  {
    registry_.push_back( ChannelRegistryItem(key,data_.size(),0,firstItem) );
  }

Member Data Documentation

template<typename T , bool dsvIsSparse>
Data sistrip::DetSetVectorFiller< T, dsvIsSparse >::data_ [private]

Definition at line 42 of file SiStripDetSetVectorFiller.h.

template<typename T , bool dsvIsSparse>
Registry sistrip::DetSetVectorFiller< T, dsvIsSparse >::registry_ [private]

Definition at line 41 of file SiStripDetSetVectorFiller.h.