CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DataFormats/SiStripCluster/src/SiStripClusterCollection.cc

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