Go to the documentation of this file.00001 #include "Validation/MuonRPCGeometry/interface/PTStatistics.h"
00002
00003 #include <sstream>
00004 #include <numeric>
00005 #include <iostream>
00006
00007
00008
00009 bool PTStatistics::rateInitilized = false;
00010 std::vector<long double> PTStatistics::m_rates = std::vector<long double>(RPCpg::ptBins_s,0);
00011
00012 PTStatistics::PTStatistics(){
00013 this->assign(RPCpg::ptBins_s,0);
00014
00015 if(!rateInitilized){
00016
00017 rateInitilized = true;
00018 m_rates.assign(RPCpg::ptBins_s,0);
00019
00020
00021
00022 for (unsigned int i = 1;i < this->m_rates.size(); ++i ){
00023
00024 long double low = RPCpg::pts[i];
00025 long double high = RPCpg::pts[i+1];
00026 long double rt = RPCpg::rate(low)-RPCpg::rate(high);
00027
00028
00029
00030
00031
00032
00033 this->m_rates.at(i) = rt;
00034 }
00035
00036 }
00037
00038 }
00039
00040 void PTStatistics::update(PTStatistics & otherPtStats){
00041
00042 for (unsigned int i=0; i<this->size();++i){
00043
00044 (*this)[i]+=otherPtStats[i];
00045 }
00046
00047
00048 }
00049 std::string PTStatistics::toString(){
00050
00051 std::stringstream ss;
00052 ss << "PTStats:";
00053 for (unsigned int i=0; i<this->size();++i){
00054 ss << " " << this->at(i);
00055 }
00056
00057 return ss.str();
00058 }
00059
00060 long double PTStatistics::eff(int ptCut){
00061
00062
00063
00064 return double(sum(ptCut))/this->sum();
00065 }
00066
00067
00068 long int PTStatistics::sum(const int & ptCut) const{
00069
00070
00071 long int eqOrAbovePtCut = 0;
00072 unsigned int size = this->size();
00073
00074 for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += (*this)[i];
00075 return eqOrAbovePtCut;
00076 }
00077
00078
00079 long int PTStatistics::sum() const{
00080
00081 long int eqOrAbovePtCut = 0;
00082
00083
00084
00085 PTStatistics::const_iterator it = this->begin();
00086 PTStatistics::const_iterator itend = this->end();
00087 for(;it!=itend;++it) eqOrAbovePtCut += *it;
00088
00089 return eqOrAbovePtCut;
00090 }
00091
00092 long double PTStatistics::sumR(const int & ptCut) const{
00093
00094 long double eqOrAbovePtCut = 0;
00095 unsigned int size = this->size();
00096
00097 for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += (*this)[i]*m_rates[i];
00098 return eqOrAbovePtCut;
00099 }
00100
00101 long double PTStatistics::sumR() const{
00102
00103 long double eqOrAbovePtCut = 0;
00104
00105
00106
00107
00108
00109
00110 unsigned int size = this->size();
00111 for(unsigned int i=1;i<size;++i) eqOrAbovePtCut += (*this)[i]*m_rates[i];
00112
00113
00114 return eqOrAbovePtCut;
00115 }
00116