1 #ifndef EventFilter_SiStripRawToDigi_SiStripDetSetVectorFiller_H
2 #define EventFilter_SiStripRawToDigi_SiStripDetSetVectorFiller_H
5 #include "boost/cstdint.hpp"
23 void newChannel(
const uint32_t
key,
const uint16_t firstItem = 0);
29 ChannelRegistryItem(
const uint32_t theKey,
const uint32_t theStartIndex,
const uint16_t theLength,
const uint16_t theFirstItem)
32 {
return ( (this->key != other.
key) ? (this->key < other.
key) : (this->firstItem < other.
firstItem) ); }
38 typedef std::vector<ChannelRegistryItem>
Registry;
39 typedef std::vector<T>
Data;
47 registry_.reserve(registrySize);
48 data_.reserve(dataSize);
61 data_.push_back(item);
62 registry_.back().length++;
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) {
74 std::vector<T>& detSetData = sorted_and_merged.back().data;
75 typename Registry::const_iterator jReg;
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);
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;
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);
98 return typename std::auto_ptr< edm::DetSetVector<T> >(
new edm::DetSetVector<T>(sorted_and_merged,
true) );
105 #endif // EventFilter_SiStripRawToDigi_SiStripDetSetVectorFiller_H
DetSetVectorFiller< SiStripDigi, true > ZSDigiDetSetVectorFiller
void newChannel(const uint32_t key, const uint16_t firstItem=0)
DetSetVectorFiller(const size_t registrySize, const size_t dataSize)
DetSetVectorFiller< SiStripRawDigi, false > RawDigiDetSetVectorFiller
std::auto_ptr< edm::DetSetVector< T > > createDetSetVector()
void addItem(const T &item)
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
std::vector< ChannelRegistryItem > Registry
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
bool operator<(const ChannelRegistryItem &other) const
ChannelRegistryItem(const uint32_t theKey, const uint32_t theStartIndex, const uint16_t theLength, const uint16_t theFirstItem)
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...