CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DataFormats/FP420Cluster/src/RecoCollectionFP420.cc

Go to the documentation of this file.
00001 
00002 // File: RecoCollectionFP420.cc
00003 // Date: 11.2007
00004 // Description: RecoCollectionFP420 for FP420
00005 // Modifications: 
00007 #include "DataFormats/FP420Cluster/interface/RecoCollectionFP420.h"
00008 #include <algorithm>
00009 #include <iostream>
00010 using namespace std;
00011 //#define mydigidebug
00012 
00013 void RecoCollectionFP420::put(RecoCollectionFP420::Range input, unsigned int stationID) {
00014   // put in RecHits of stationID
00015 
00016   // store size of vector before put
00017   RecoCollectionFP420::IndexRange inputRange;
00018   
00019   // put in RecoFP420s from input
00020   bool first = true;
00021   
00022   // fill input in temporary vector for sorting
00023   std::vector<RecoFP420> temporary;
00024   RecoCollectionFP420::ContainerIterator sort_begin = input.first;
00025   RecoCollectionFP420::ContainerIterator sort_end = input.second;
00026 #ifdef mydigidebug
00027    std::cout <<"   !!!!!!!!!!!!!!!!    RecoCollectionFP420:: !!!!  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   RecoCollectionFP420::ContainerIterator begin = temporary.begin();
00039   RecoCollectionFP420::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 
00058 //  inputRange.second = container_.size()-1;
00059 //  //inputRange.second = container_.size();
00060 
00061 #ifdef mydigidebug
00062    std::cout <<"put: container_.size() = " << container_.size() << std::endl;
00063    std::cout <<"put:  inputRange.first = " << inputRange.first << std::endl;
00064    std::cout <<"put:  inputRange.second = " << inputRange.second << std::endl;
00065 #endif
00066   
00067   // fill map
00068   map_[stationID] = inputRange;
00069 
00070 }
00071 
00072 const RecoCollectionFP420::Range RecoCollectionFP420::get(unsigned int stationID) const {
00073   // get RecHits of stationID
00074 
00075 #ifdef mydigidebug
00076 std::cout <<"RecoCollectionFP420::get:stationID= " << stationID << std::endl;
00077 #endif
00078   RecoCollectionFP420::RegistryIterator returnIndex = map_.find(stationID);
00079   RecoCollectionFP420::IndexRange returnIndexRange = returnIndex->second;
00080 #ifdef mydigidebug
00081    std::cout <<"RecoCollectionFP420::get1: returnIndexRange.first= " << returnIndexRange.first << std::endl;
00082    std::cout <<"RecoCollectionFP420::get1: returnIndexRange.second= " << returnIndexRange.second << std::endl;
00083 #endif
00084 
00085   RecoCollectionFP420::Range returnRange;
00086   returnRange.first  = container_.begin()+returnIndexRange.first;
00087   if(returnIndexRange.second != 0 ) {
00088     returnRange.second = container_.begin()+returnIndexRange.second+1;
00089   }else{
00090     returnRange.second = container_.begin()+returnIndexRange.second;
00091   }
00092 #ifdef mydigidebug
00093    std::cout <<"RecoCollectionFP420::get2: container_.size() = " << container_.size() << std::endl;
00094    std::cout <<"RecoCollectionFP420::get2: returnIndexRange.first= " << returnIndexRange.first << std::endl;
00095    std::cout <<"RecoCollectionFP420::get2: returnIndexRange.second= " << returnIndexRange.second << std::endl;
00096 #endif
00097   return returnRange;
00098 }
00099 
00100 
00101 
00102 void RecoCollectionFP420::clear() {
00103 container_.clear();
00104 }
00105 void RecoCollectionFP420::putclear(RecoCollectionFP420::Range input, unsigned int stationID) {
00106 
00107   RecoCollectionFP420::IndexRange inputRange;
00108   
00109   std::vector<RecoFP420> temporary;
00110   RecoCollectionFP420::ContainerIterator sort_begin = input.first;
00111   RecoCollectionFP420::ContainerIterator sort_end = input.second;
00112   for ( ;sort_begin != sort_end; ++sort_begin ) {
00113     temporary.push_back(*sort_begin);
00114   }
00115   std::sort(temporary.begin(),temporary.end());
00116 
00117   //    temporary.clear();
00118   RecoCollectionFP420::ContainerIterator begin = temporary.begin();
00119   RecoCollectionFP420::ContainerIterator end = temporary.end();
00120   for ( ;begin != end; ++begin ) {
00121     container_.push_back(*begin);
00122   }
00123   //container_.clear();
00124           inputRange.first = container_.size()-container_.size();
00125           inputRange.second = container_.size()-container_.size();
00126 
00127 #ifdef mydigidebug
00128    std::cout <<"putclear: container_.size() = " << container_.size() << std::endl;
00129    std::cout <<"putclear:  inputRange.first = " << inputRange.first << std::endl;
00130    std::cout <<"putclear:  inputRange.second = " << inputRange.second << std::endl;
00131 #endif
00132 
00133 
00134           map_[stationID] = inputRange;
00135 }
00136 
00137 
00138 
00139 
00140 
00141 
00142 const std::vector<unsigned int> RecoCollectionFP420::stationIDs() const {
00143   // returns vector of stationIDs in map
00144 
00145 #ifdef mydigidebug
00146 std::cout <<"RecoCollectionFP420::stationIDs:start " << std::endl;
00147 #endif
00148   RecoCollectionFP420::RegistryIterator begin = map_.begin();
00149   RecoCollectionFP420::RegistryIterator end   = map_.end();
00150 
00151   std::vector<unsigned int> output;
00152 
00153   for (; begin != end; ++begin) {
00154     output.push_back(begin->first);
00155   }
00156 
00157   return output;
00158 
00159 }