CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/FP420Cluster/src/ClusterCollectionFP420.cc

Go to the documentation of this file.
00001 
00002 // File: ClusterCollectionFP420.cc
00003 // Date: 12.2006
00004 // Description: ClusterCollectionFP420 for FP420
00005 // Modifications: 
00007 #include "DataFormats/FP420Cluster/interface/ClusterCollectionFP420.h"
00008 #include <iostream>
00009 #include <algorithm>
00010 using namespace std;
00011 //#define mydigidebug
00012 
00013 void ClusterCollectionFP420::put(ClusterCollectionFP420::Range input, unsigned int detID) {
00014   // put in RecHits of detID
00015 
00016   // store size of vector before put
00017   ClusterCollectionFP420::IndexRange inputRange;
00018   
00019   // put in ClusterFP420s from input
00020   bool first = true;
00021   
00022   // fill input in temporary vector for sorting
00023   std::vector<ClusterFP420> temporary;
00024   ClusterCollectionFP420::ContainerIterator sort_begin = input.first;
00025   ClusterCollectionFP420::ContainerIterator sort_end = input.second;
00026 #ifdef mydigidebug
00027    std::cout <<"   !!!!!!!!!!!!!!!!    ClusterCollectionFP420:: !!!!  put !!!!           start " << std::endl;
00028 #endif
00029   for ( ;sort_begin != sort_end; ++sort_begin ) {
00030 #ifdef mydigidebug
00031    std::cout <<"put: temporary.push_back " << std::endl;
00032 #endif
00033     temporary.push_back(*sort_begin);
00034   }
00035   std::sort(temporary.begin(),temporary.end());
00036 
00037   // iterators over input
00038   ClusterCollectionFP420::ContainerIterator begin = temporary.begin();
00039   ClusterCollectionFP420::ContainerIterator end = temporary.end();
00040   for ( ;begin != end; ++begin ) {
00041     container_.push_back(*begin);
00042     if ( first ) {
00043           inputRange.first = container_.size()-1;
00044  //     inputRange.first = container_.size();
00045       first = false;
00046     }
00047   }
00048 
00049   // since we start from 0, then the last element will be size-1
00050   if(container_.size() != 0) {
00051     inputRange.second = container_.size()-1;
00052   }
00053   else {
00054     inputRange.first = container_.size();
00055     inputRange.second = container_.size();
00056   }
00057   //inputRange.second = container_.size()-1;
00059 
00060 #ifdef mydigidebug
00061    std::cout <<"put: container_.size() = " << container_.size() << std::endl;
00062    std::cout <<"put:  inputRange.first = " << inputRange.first << std::endl;
00063    std::cout <<"put:  inputRange.second = " << inputRange.second << std::endl;
00064 #endif
00065   
00066   // fill map
00067   map_[detID] = inputRange;
00068 
00069 }
00070 
00071 const ClusterCollectionFP420::Range ClusterCollectionFP420::get(unsigned int detID) const {
00072   // get RecHits of detID
00073 
00074 #ifdef mydigidebug
00075 std::cout <<"ClusterCollectionFP420::get:detID= " << detID << std::endl;
00076 #endif
00077   ClusterCollectionFP420::RegistryIterator returnIndex = map_.find(detID);
00078   ClusterCollectionFP420::IndexRange returnIndexRange = returnIndex->second;
00079 #ifdef mydigidebug
00080    std::cout <<"ClusterCollectionFP420::get1: returnIndexRange.first= " << returnIndexRange.first << std::endl;
00081    std::cout <<"ClusterCollectionFP420::get1: returnIndexRange.second= " << returnIndexRange.second << std::endl;
00082 #endif
00083 
00084   ClusterCollectionFP420::Range returnRange;
00085   returnRange.first  = container_.begin()+returnIndexRange.first;
00086   if(returnIndexRange.second != 0 ) {
00087     returnRange.second = container_.begin()+returnIndexRange.second+1;
00088   }else{
00089     returnRange.second = container_.begin()+returnIndexRange.second;
00090   }
00091 #ifdef mydigidebug
00092    std::cout <<"ClusterCollectionFP420::get2: container_.size() = " << container_.size() << std::endl;
00093    std::cout <<"ClusterCollectionFP420::get2: returnIndexRange.first= " << returnIndexRange.first << std::endl;
00094    std::cout <<"ClusterCollectionFP420::get2: returnIndexRange.second= " << returnIndexRange.second << std::endl;
00095 #endif
00096   return returnRange;
00097 }
00098 
00099 
00100 
00101 void ClusterCollectionFP420::clear() {
00102 container_.clear();
00103 }
00104 void ClusterCollectionFP420::putclear(ClusterCollectionFP420::Range input, unsigned int detID) {
00105 
00106   ClusterCollectionFP420::IndexRange inputRange;
00107   
00108   std::vector<ClusterFP420> temporary;
00109   ClusterCollectionFP420::ContainerIterator sort_begin = input.first;
00110   ClusterCollectionFP420::ContainerIterator sort_end = input.second;
00111   for ( ;sort_begin != sort_end; ++sort_begin ) {
00112     temporary.push_back(*sort_begin);
00113   }
00114   std::sort(temporary.begin(),temporary.end());
00115 
00116   //    temporary.clear();
00117   ClusterCollectionFP420::ContainerIterator begin = temporary.begin();
00118   ClusterCollectionFP420::ContainerIterator end = temporary.end();
00119   for ( ;begin != end; ++begin ) {
00120     container_.push_back(*begin);
00121   }
00122   //container_.clear();
00123           inputRange.first = container_.size()-container_.size();
00124           inputRange.second = container_.size()-container_.size();
00125 
00126 #ifdef mydigidebug
00127    std::cout <<"putclear: container_.size() = " << container_.size() << std::endl;
00128    std::cout <<"putclear:  inputRange.first = " << inputRange.first << std::endl;
00129    std::cout <<"putclear:  inputRange.second = " << inputRange.second << std::endl;
00130 #endif
00131 
00132 
00133           map_[detID] = inputRange;
00134 }
00135 
00136 
00137 
00138 
00139 
00140 
00141 const std::vector<unsigned int> ClusterCollectionFP420::detIDs() const {
00142   // returns vector of detIDs in map
00143 
00144 #ifdef mydigidebug
00145 std::cout <<"ClusterCollectionFP420::detIDs:start " << std::endl;
00146 #endif
00147   ClusterCollectionFP420::RegistryIterator begin = map_.begin();
00148   ClusterCollectionFP420::RegistryIterator end   = map_.end();
00149 
00150   std::vector<unsigned int> output;
00151 
00152   for (; begin != end; ++begin) {
00153     output.push_back(begin->first);
00154   }
00155 
00156   return output;
00157 
00158 }