00001 00009 #include "DataFormats/LaserAlignment/interface/LASBeamProfileFitCollection.h" 00010 00011 // put in LASBeamProfileFit of detID 00012 void LASBeamProfileFitCollection::put(Range input, unsigned int detID) 00013 { 00014 // store size of vector before put 00015 IndexRange inputRange; 00016 00017 // put in LASBeamProfileFit from input 00018 bool first = true; 00019 00020 // iterators over input 00021 LASBeamProfileFitCollection::ContainerIterator begin = input.first; 00022 LASBeamProfileFitCollection::ContainerIterator end = input.second; 00023 00024 for ( ; begin != end; ++begin) 00025 { 00026 container_.push_back(*begin); 00027 if (first) 00028 { 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 // get LASBeamProfileFit of detID 00040 const LASBeamProfileFitCollection::Range LASBeamProfileFitCollection::get(unsigned int detID) const 00041 { 00042 LASBeamProfileFitCollection::IndexRange returnIndexRange = map_[detID]; 00043 00044 LASBeamProfileFitCollection::Range returnRange; 00045 returnRange.first = container_.begin() + returnIndexRange.first; 00046 returnRange.second = container_.begin() + returnIndexRange.second; 00047 00048 return returnRange; 00049 } 00050 00051 // returns vector of detIDs in the map 00052 const std::vector<unsigned int> LASBeamProfileFitCollection::detIDs() const 00053 { 00054 LASBeamProfileFitCollection::RegistryIterator begin = map_.begin(); 00055 LASBeamProfileFitCollection::RegistryIterator end = map_.end(); 00056 00057 std::vector<unsigned int> output; 00058 00059 for ( ; begin != end; ++begin) 00060 { 00061 output.push_back(begin->first); 00062 } 00063 00064 return output; 00065 } 00066 00067 // appends LASBeamProfileFits to the vector of the given detID 00068 void LASBeamProfileFitCollection::add(unsigned int& det_id, std::vector<LASBeamProfileFit>& beamProfileFit) 00069 { 00070 fitMap_[det_id].reserve( fitMap_[det_id].size() + beamProfileFit.size() ); 00071 00072 if ( fitMap_[det_id].empty() ) 00073 { 00074 fitMap_[det_id] = beamProfileFit; 00075 } 00076 else 00077 { 00078 copy( beamProfileFit.begin(), beamProfileFit.end(), back_inserter(fitMap_[det_id]) ); 00079 } 00080 } 00081 00082 // returns (by reference) the LASBeamProfileFit for a given DetId 00083 void LASBeamProfileFitCollection::beamProfileFit(unsigned int& det_id, std::vector<LASBeamProfileFit>& beamProfileFit) const 00084 { 00085 if ( fitMap_.find(det_id) != fitMap_.end() ) 00086 { 00087 beamProfileFit = fitMap_[det_id]; 00088 } 00089 else 00090 { 00091 beamProfileFit = std::vector<LASBeamProfileFit>(); 00092 } 00093 } 00094 00095 // returns (by reference) vector of DetIds with a LASBeamProfileFit 00096 void LASBeamProfileFitCollection::detIDs(std::vector<unsigned int>& det_ids) const 00097 { 00098 det_ids.clear(); 00099 det_ids.reserve(static_cast<unsigned int>(fitMap_.size())); 00100 00101 LASBeamProfileFitContainer::const_iterator iter; 00102 for (iter = fitMap_.begin(); iter != fitMap_.end(); iter++) 00103 { 00104 det_ids.push_back( iter->first ); 00105 } 00106 } 00107 00108 // returns the size of the collection 00109 int LASBeamProfileFitCollection::size() const 00110 { 00111 return map_.size(); 00112 }