CMS 3D CMS Logo

SiStripClusterCollection.cc

Go to the documentation of this file.
00001 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
00002 #include <iostream>
00003 
00004 void SiStripClusterCollection::put(SiStripClusterCollection::Range input, unsigned int detID) {
00005   // put in RecHits of detID
00006   if (input.first == input.second) return ;
00007 
00008   // store size of vector before put
00009   SiStripClusterCollection::IndexRange inputRange;
00010   
00011   // put in SiStripClusters from input
00012   bool first = true;
00013   
00014   // fill input in temporary vector for sorting
00015   std::vector<SiStripCluster> temporary;
00016   SiStripClusterCollection::ContainerIterator sort_begin = input.first;
00017   SiStripClusterCollection::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   SiStripClusterCollection::ContainerIterator begin = temporary.begin();
00025   SiStripClusterCollection::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 SiStripClusterCollection::Range SiStripClusterCollection::get(unsigned int detID) const {
00041   // get RecHits of detID
00042 
00043   SiStripClusterCollection::RegistryIterator returnIndex = map_.find(detID);
00044 
00045   if (returnIndex == map_.end()){
00046     return Range (container_.end(), container_.end());
00047   }
00048 
00049   SiStripClusterCollection::IndexRange returnIndexRange = returnIndex->second;
00050 
00051   SiStripClusterCollection::Range returnRange;
00052   returnRange.first  = container_.begin()+returnIndexRange.first;
00053   returnRange.second = container_.begin()+returnIndexRange.second+1;
00054 
00055   return returnRange;
00056 }
00057 
00058 const std::vector<unsigned int> SiStripClusterCollection::detIDs() const {
00059   // returns vector of detIDs in map
00060 
00061   SiStripClusterCollection::RegistryIterator begin = map_.begin();
00062   SiStripClusterCollection::RegistryIterator end   = map_.end();
00063 
00064   std::vector<unsigned int> output;
00065 
00066   for (; begin != end; ++begin) {
00067     output.push_back(begin->first);
00068   }
00069 
00070   return output;
00071 
00072 }

Generated on Tue Jun 9 17:31:44 2009 for CMSSW by  doxygen 1.5.4