00001 00002 // File: TrackCollectionFP420.cc 00003 // Date: 12.2006 00004 // Description: TrackCollectionFP420 for FP420 00005 // Modifications: 00007 #include "DataFormats/FP420Cluster/interface/TrackCollectionFP420.h" 00008 #include <iostream> 00009 #include <algorithm> 00010 using namespace std; 00011 //#define mydigidebug 00012 00013 void TrackCollectionFP420::put(TrackCollectionFP420::Range input, unsigned int stationID) { 00014 // put in RecHits of stationID 00015 00016 // store size of vector before put 00017 TrackCollectionFP420::IndexRange inputRange; 00018 00019 // put in TrackFP420s from input 00020 bool first = true; 00021 00022 // fill input in temporary vector for sorting 00023 std::vector<TrackFP420> temporary; 00024 TrackCollectionFP420::ContainerIterator sort_begin = input.first; 00025 TrackCollectionFP420::ContainerIterator sort_end = input.second; 00026 #ifdef mydigidebug 00027 std::cout <<" !!!!!!!!!!!!!!!! TrackCollectionFP420:: !!!! 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 TrackCollectionFP420::ContainerIterator begin = temporary.begin(); 00039 TrackCollectionFP420::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_[stationID] = inputRange; 00068 00069 } 00070 00071 const TrackCollectionFP420::Range TrackCollectionFP420::get(unsigned int stationID) const { 00072 // get RecHits of stationID 00073 00074 #ifdef mydigidebug 00075 std::cout <<"TrackCollectionFP420::get:stationID= " << stationID << std::endl; 00076 #endif 00077 TrackCollectionFP420::RegistryIterator returnIndex = map_.find(stationID); 00078 TrackCollectionFP420::IndexRange returnIndexRange = returnIndex->second; 00079 #ifdef mydigidebug 00080 std::cout <<"TrackCollectionFP420::get1: returnIndexRange.first= " << returnIndexRange.first << std::endl; 00081 std::cout <<"TrackCollectionFP420::get1: returnIndexRange.second= " << returnIndexRange.second << std::endl; 00082 #endif 00083 00084 TrackCollectionFP420::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 <<"TrackCollectionFP420::get2: container_.size() = " << container_.size() << std::endl; 00093 std::cout <<"TrackCollectionFP420::get2: returnIndexRange.first= " << returnIndexRange.first << std::endl; 00094 std::cout <<"TrackCollectionFP420::get2: returnIndexRange.second= " << returnIndexRange.second << std::endl; 00095 #endif 00096 return returnRange; 00097 } 00098 00099 00100 00101 void TrackCollectionFP420::clear() { 00102 container_.clear(); 00103 } 00104 void TrackCollectionFP420::putclear(TrackCollectionFP420::Range input, unsigned int stationID) { 00105 00106 TrackCollectionFP420::IndexRange inputRange; 00107 00108 std::vector<TrackFP420> temporary; 00109 TrackCollectionFP420::ContainerIterator sort_begin = input.first; 00110 TrackCollectionFP420::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 TrackCollectionFP420::ContainerIterator begin = temporary.begin(); 00118 TrackCollectionFP420::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_[stationID] = inputRange; 00134 } 00135 00136 00137 00138 00139 00140 00141 const std::vector<unsigned int> TrackCollectionFP420::stationIDs() const { 00142 // returns vector of stationIDs in map 00143 00144 #ifdef mydigidebug 00145 std::cout <<"TrackCollectionFP420::stationIDs:start " << std::endl; 00146 #endif 00147 TrackCollectionFP420::RegistryIterator begin = map_.begin(); 00148 TrackCollectionFP420::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 }