CMS 3D CMS Logo

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::unique_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< ChannelRegistryItemRegistry
 

Private Attributes

Data data_
 
Registry registry_
 

Detailed Description

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

Definition at line 18 of file SiStripDetSetVectorFiller.h.

Member Typedef Documentation

◆ Data

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

Definition at line 43 of file SiStripDetSetVectorFiller.h.

◆ Registry

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

Definition at line 42 of file SiStripDetSetVectorFiller.h.

Constructor & Destructor Documentation

◆ DetSetVectorFiller()

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

Definition at line 50 of file SiStripDetSetVectorFiller.h.

50  {
51  registry_.reserve(registrySize);
52  data_.reserve(dataSize);
53  }

◆ ~DetSetVectorFiller()

template<typename T , bool dsvIsSparse>
sistrip::DetSetVectorFiller< T, dsvIsSparse >::~DetSetVectorFiller ( )
inline

Definition at line 56 of file SiStripDetSetVectorFiller.h.

56 {}

Member Function Documentation

◆ addItem()

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

◆ createDetSetVector()

template<typename T , bool dsvIsSparse>
std::unique_ptr< edm::DetSetVector< T > > sistrip::DetSetVectorFiller< T, dsvIsSparse >::createDetSetVector ( )

Definition at line 70 of file SiStripDetSetVectorFiller.h.

References filterCSVwithJSON::copy, Exception, and jetUpdater_cfi::sort.

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

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

◆ newChannel()

template<typename T , bool dsvIsSparse>
void sistrip::DetSetVectorFiller< T, dsvIsSparse >::newChannel ( const uint32_t  key,
const uint16_t  firstItem = 0 
)
inline

Definition at line 59 of file SiStripDetSetVectorFiller.h.

References crabWrapper::key.

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

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

Member Data Documentation

◆ data_

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

Definition at line 46 of file SiStripDetSetVectorFiller.h.

◆ registry_

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

Definition at line 45 of file SiStripDetSetVectorFiller.h.