00001 #include "DataFormats/SiPixelDigi/interface/PixelDigiCollection.h" 00002 #include <iostream> 00003 #include <algorithm> 00004 00005 void PixelDigiCollection::put(Range input, unsigned int detID) { 00006 // put in Digis of detID 00007 00008 // store size of vector before put 00009 IndexRange inputRange; 00010 00011 // put in PixelDigis from input 00012 bool first = true; 00013 00014 // fill input in temporary vector for sorting 00015 std::vector<PixelDigi> temporary; 00016 PixelDigiCollection::ContainerIterator sort_begin = input.first; 00017 PixelDigiCollection::ContainerIterator sort_end = input.second; 00018 for ( ;sort_begin != sort_end; ++sort_begin ) { 00019 temporary.push_back(*sort_begin); 00020 } 00021 std::sort(temporary.begin(),temporary.end()); 00022 00023 // iterators over input 00024 PixelDigiCollection::ContainerIterator begin = temporary.begin(); 00025 PixelDigiCollection::ContainerIterator end = temporary.end(); 00026 for ( ;begin != end; ++begin ) { 00027 container_.push_back(*begin); 00028 if ( first ) { 00029 inputRange.first = container_.size()-1; 00030 first = false; 00031 } 00032 } 00033 inputRange.second = container_.size()-1; 00034 00035 // fill map 00036 map_[detID] = inputRange; 00037 00038 } 00039 00040 const PixelDigiCollection::Range PixelDigiCollection::get(unsigned int detID) const { 00041 // get Digis of detID 00042 00043 PixelDigiCollection::IndexRange returnIndexRange = map_[detID]; 00044 00045 PixelDigiCollection::Range returnRange; 00046 returnRange.first = container_.begin()+returnIndexRange.first; 00047 returnRange.second = container_.begin()+returnIndexRange.second+1; 00048 00049 return returnRange; 00050 } 00051 00052 const std::vector<unsigned int> PixelDigiCollection::detIDs() const { 00053 // returns vector of detIDs in map 00054 00055 PixelDigiCollection::RegistryIterator begin = map_.begin(); 00056 PixelDigiCollection::RegistryIterator end = map_.end(); 00057 00058 std::vector<unsigned int> output; 00059 00060 for (; begin != end; ++begin) { 00061 output.push_back(begin->first); 00062 } 00063 00064 return output; 00065 00066 }