Go to the documentation of this file.00001 #ifndef CondCore_EcalPlugins_plugins_EcalPyWrapperFunctions_H
00002 #define CondCore_EcalPlugins_plugins_EcalPyWrapperFunctions_H
00003
00004 #include <sstream>
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 template <class T>
00018 class EcalPyWrapperHelper{
00019 public:
00020 static const unsigned int MEAN = 0;
00021 static const unsigned int STATUS = 1;
00022
00023 EcalPyWrapperHelper(unsigned int totalValues, unsigned int status = 0, std::string names = "-Means: "):total_values(totalValues), status(status), names(names){}
00024
00025 std::string printBarrelsEndcaps( const std::vector<T> & barrelItems, const std::vector<T> & endcapItems) {
00026 std::stringstream ss;
00027
00028
00029 type_vValues barrelsVec = getValues(barrelItems);
00030 unsigned int barrelsTotal = barrelItems.size();
00031 ss << std::endl << "---Barrels. Total: " << barrelsTotal << std::endl;
00032 switch (status){
00033 case (MEAN) : ss << names << std::endl; break;
00034 case (STATUS): ss << "-With errors: " << std::endl; break;
00035 default : break;
00036 }
00037 ss << printValues(barrelsVec, barrelsTotal);
00038
00039
00040 type_vValues endcapVec = getValues(endcapItems);
00041 unsigned int endcapTotal = endcapItems.size();
00042 ss << std::endl << "---Endcaps. Total: " << endcapTotal << std::endl;
00043 switch (status){
00044 case (MEAN) : ss << names << std::endl; break;
00045 case (STATUS): ss << "-With errors: " << std::endl; break;
00046 default : break;
00047 }
00048 ss << printValues(endcapVec, endcapTotal);
00049
00050 return ss.str();
00051 }
00052 protected:
00053 unsigned int total_values;
00054 unsigned int status;
00055 std::string names;
00056 typedef std::vector<std::pair< std::string, float> > type_vValues;
00057
00058
00059 virtual type_vValues getValues( const std::vector<T> & vItems) = 0;
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 private:
00095 std::string printValues(const type_vValues & vValues, const unsigned int & total) {
00096 std::stringstream ss;
00097
00098 for (type_vValues::const_iterator iVal = vValues.begin(); iVal != vValues.end(); ++iVal){
00099 switch (status){
00100 case (MEAN) : ss << iVal->first << ": " << ((iVal->second)/total) << std::endl; break;
00101 case (STATUS): if (iVal->second != 0) {ss << iVal->first << ": " << ((iVal->second)) << std::endl; break;} else {break; }
00102 default : break;
00103 }
00104
00105 }
00106 return ss.str();
00107 }
00108
00109 };
00110 #endif