Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:12

0001 #include "DataFormats/SiPixelDigi/interface/PixelDigiCollection.h"
0002 #include <iostream>
0003 #include <algorithm>
0004 
0005 void PixelDigiCollection::put(Range input, unsigned int detID) {
0006   // put in Digis of detID
0007 
0008   // store size of vector before put
0009   IndexRange inputRange;
0010 
0011   // put in PixelDigis from input
0012   bool first = true;
0013 
0014   // fill input in temporary vector for sorting
0015   std::vector<PixelDigi> temporary;
0016   PixelDigiCollection::ContainerIterator sort_begin = input.first;
0017   PixelDigiCollection::ContainerIterator sort_end = input.second;
0018   for (; sort_begin != sort_end; ++sort_begin) {
0019     temporary.push_back(*sort_begin);
0020   }
0021   std::sort(temporary.begin(), temporary.end());
0022 
0023   // iterators over input
0024   PixelDigiCollection::ContainerIterator begin = temporary.begin();
0025   PixelDigiCollection::ContainerIterator end = temporary.end();
0026   for (; begin != end; ++begin) {
0027     container_.push_back(*begin);
0028     if (first) {
0029       inputRange.first = container_.size() - 1;
0030       first = false;
0031     }
0032   }
0033   inputRange.second = container_.size() - 1;
0034 
0035   // fill map
0036   map_[detID] = inputRange;
0037 }
0038 
0039 const PixelDigiCollection::Range PixelDigiCollection::get(unsigned int detID) const {
0040   // get Digis of detID
0041 
0042   auto found = map_.find(detID);
0043   PixelDigiCollection::IndexRange returnIndexRange{};
0044   if (found != map_.end()) {
0045     returnIndexRange = found->second;
0046   }
0047 
0048   PixelDigiCollection::Range returnRange;
0049   returnRange.first = container_.begin() + returnIndexRange.first;
0050   returnRange.second = container_.begin() + returnIndexRange.second + 1;
0051 
0052   return returnRange;
0053 }
0054 
0055 const std::vector<unsigned int> PixelDigiCollection::detIDs() const {
0056   // returns vector of detIDs in map
0057 
0058   PixelDigiCollection::RegistryIterator begin = map_.begin();
0059   PixelDigiCollection::RegistryIterator end = map_.end();
0060 
0061   std::vector<unsigned int> output;
0062 
0063   for (; begin != end; ++begin) {
0064     output.push_back(begin->first);
0065   }
0066 
0067   return output;
0068 }