Go to the documentation of this file.00001 #ifndef OPERATORS_H_
00002 #define OPERATORS_H_
00003 #include "TH1F.h"
00004 #include <iostream>
00005 #include <vector>
00006 #include <map>
00007
00016
00017
00018
00019 template <class T> std::pair<T, T> operator+(const std::pair<T, T>& one, const std::pair<T, T>& two) {
00020 std::pair<T, T> r(one.first + two.first, one.second + two.second);
00021 return r;
00022 }
00023
00024
00025
00026
00027 template <class T> std::pair<T, T> operator-(const std::pair<T, T>& one, const std::pair<T, T>& two) {
00028 std::pair<T, T> r(one.first - two.first, one.second - two.second);
00029 return r;
00030 }
00031
00032
00033
00034
00035 template <class T> std::ostream& operator<<(std::ostream& s, const std::pair<T, T>& aT) {
00036 s << "(" << aT.first << ", " << aT.second << ")";
00037 return s;
00038 }
00039
00040
00041
00042
00043 template <class K, class V> void valueVector(const std::map<K, V>& extract, std::vector<V>& output) {
00044 for(typename std::map<K, V>::const_iterator cit = extract.begin(); cit != extract.end(); ++cit) {
00045 output.push_back((*cit).second);
00046 }
00047 }
00048
00049
00050
00051
00052 template <class K, class V> void keyVector(const std::map<K, V>& extract, std::vector<K>& output) {
00053 for(typename std::map<K, V>::const_iterator cit = extract.begin(); cit != extract.end(); ++cit) {
00054 output.push_back((*cit).first);
00055 }
00056 }
00057
00058 #endif