1 #ifndef EventFilter_SiStripRawToDigi_SiStripDetSetVectorFiller_H
2 #define EventFilter_SiStripRawToDigi_SiStripDetSetVectorFiller_H
17 template <
typename T,
bool dsvIsSparse>
23 void newChannel(
const uint32_t
key,
const uint16_t firstItem = 0);
30 const uint32_t theStartIndex,
31 const uint16_t theLength,
32 const uint16_t theFirstItem)
35 return ((this->key != other.
key) ? (this->key < other.
key) : (this->firstItem < other.
firstItem));
42 typedef std::vector<ChannelRegistryItem>
Registry;
43 typedef std::vector<T>
Data;
49 template <
typename T,
bool dsvIsSparse>
51 registry_.reserve(registrySize);
52 data_.reserve(dataSize);
55 template <
typename T,
bool dsvIsSparse>
58 template <
typename T,
bool dsvIsSparse>
63 template <
typename T,
bool dsvIsSparse>
65 data_.push_back(item);
66 registry_.back().length++;
69 template <
typename T,
bool dsvIsSparse>
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) {
78 std::vector<T>& detSetData = sorted_and_merged.back().data;
79 typename Registry::const_iterator jReg;
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) {
87 detSetData.end(), data_.begin() + jReg->startIndex, data_.begin() + jReg->startIndex + jReg->length);
90 uint16_t detLength = 0;
91 uint16_t firstItemOfLastChannel = 0;
92 for (jReg = iReg; (jReg != endReg) && (jReg->key == iReg->key); ++jReg) {
94 detLength = jReg->length;
95 else if (detLength != jReg->length)
97 <<
"Cannot fill non-sparse DetSet if channels are not unformly sized.";
98 firstItemOfLastChannel = jReg->firstItem;
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);
109 return typename std::unique_ptr<edm::DetSetVector<T> >(
new edm::DetSetVector<T>(sorted_and_merged,
true));
116 #endif // EventFilter_SiStripRawToDigi_SiStripDetSetVectorFiller_H
void newChannel(const uint32_t key, const uint16_t firstItem=0)
DetSetVectorFiller(const size_t registrySize, const size_t dataSize)
DetSetVectorFiller< SiStripDigi, true > ZSDigiDetSetVectorFiller
std::unique_ptr< edm::DetSetVector< T > > createDetSetVector()
tuple key
prepare the HTCondor submission files and eventually submit them
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
DetSetVectorFiller< SiStripRawDigi, false > RawDigiDetSetVectorFiller
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 ...