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