Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/CTPPSDigi/interface/CTPPSPixelDigiCollection.h"
0002 
0003 #include <algorithm>
0004 
0005 void CTPPSPixelDigiCollection::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   /// fill input in temporary vector for sorting
0012   std::vector<CTPPSPixelDigi> temporary;
0013 
0014   auto sort_begin = input.first;
0015   auto sort_end = input.second;
0016 
0017   temporary.insert(std::end(temporary), sort_begin, sort_end);
0018 
0019   std::sort(temporary.begin(), temporary.end());
0020 
0021   inputRange.first = container_.size();
0022   container_.insert(std::end(container_), std::begin(temporary), std::end(temporary));
0023   inputRange.second = container_.size() - 1;
0024 
0025   /// fill map
0026   map_[detID] = inputRange;
0027 }
0028 
0029 const CTPPSPixelDigiCollection::Range CTPPSPixelDigiCollection::get(unsigned int detID) const {
0030   /// get Digis of detID
0031 
0032   auto found = map_.find(detID);
0033   CTPPSPixelDigiCollection::IndexRange returnIndexRange{};
0034   if (found != map_.end()) {
0035     returnIndexRange = found->second;
0036   }
0037 
0038   CTPPSPixelDigiCollection::Range returnRange;
0039   returnRange.first = container_.begin() + returnIndexRange.first;
0040   returnRange.second = container_.begin() + returnIndexRange.second + 1;
0041 
0042   return returnRange;
0043 }
0044 
0045 const std::vector<unsigned int> CTPPSPixelDigiCollection::detIDs() const {
0046   /// returns vector of detIDs in map
0047 
0048   auto begin = map_.begin();
0049   auto end = map_.end();
0050 
0051   std::vector<unsigned int> output;
0052   output.reserve(12);
0053 
0054   for (; begin != end; ++begin) {
0055     output.push_back(begin->first);
0056   }
0057 
0058   return output;
0059 }