CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Attributes
sistrip::DetSetVectorFiller< T, dsvIsSparse > Class Template Reference

#include <SiStripDetSetVectorFiller.h>

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.

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

Definition at line 51 of file SiStripDetSetVectorFiller.h.

52  {}

Member Function Documentation

template<typename T , bool dsvIsSparse>
void sistrip::DetSetVectorFiller< T, dsvIsSparse >::addItem ( const T item)
inline
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, edm::hlt::Exception, and python.multivaluedict::sort().

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

66  {
67  std::sort(registry_.begin(),registry_.end());
68  std::vector< edm::DetSet<T> > sorted_and_merged;
69  sorted_and_merged.reserve(registry_.size());
70  typename Registry::const_iterator iReg = registry_.begin();
71  const typename Registry::const_iterator endReg = registry_.end();
72  while (iReg != endReg) {
73  sorted_and_merged.push_back( edm::DetSet<T>(iReg->key) );
74  std::vector<T>& detSetData = sorted_and_merged.back().data;
75  typename Registry::const_iterator jReg;
76  if (dsvIsSparse) {
77  uint16_t length = 0;
78  for (jReg = iReg; (jReg != endReg) && (jReg->key == iReg->key); ++jReg) length += jReg->length;
79  detSetData.reserve(length);
80  for (jReg = iReg; (jReg != endReg) && (jReg->key == iReg->key); ++jReg) {
81  detSetData.insert(detSetData.end(), data_.begin()+jReg->startIndex, data_.begin()+jReg->startIndex+jReg->length);
82  }
83  } else {
84  uint16_t detLength = 0;
85  uint16_t firstItemOfLastChannel = 0;
86  for (jReg = iReg; (jReg != endReg) && (jReg->key == iReg->key); ++jReg) {
87  if (!detLength) detLength = jReg->length;
88  else if (detLength != jReg->length) throw cms::Exception("DetSetVectorFiller") << "Cannot fill non-sparse DetSet if channels are not unformly sized.";
89  firstItemOfLastChannel = jReg->firstItem;
90  }
91  detSetData.resize(firstItemOfLastChannel+detLength);
92  for (jReg = iReg; (jReg != endReg) && (jReg->key == iReg->key); ++jReg) {
93  std::copy(data_.begin()+jReg->startIndex, data_.begin()+jReg->startIndex+jReg->length, detSetData.begin()+jReg->firstItem);
94  }
95  }
96  iReg = jReg;
97  }
98  return typename std::auto_ptr< edm::DetSetVector<T> >( new edm::DetSetVector<T>(sorted_and_merged, true) );
99  }
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().

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

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.