File indexing completed on 2024-04-06 12:32:55
0001 #include "Validation/MuonRPCGeometry/interface/PTStatistics.h"
0002
0003 #include <sstream>
0004 #include <numeric>
0005 #include <iostream>
0006
0007
0008
0009 static std::vector<long double> initializeRates() {
0010 std::vector<long double> rates(RPCpg::ptBins_s, 0);
0011
0012
0013
0014
0015 for (unsigned int i = 1; i < rates.size(); ++i) {
0016 long double low = RPCpg::pts[i];
0017 long double high = RPCpg::pts[i + 1];
0018 long double rt = RPCpg::rate(low) - RPCpg::rate(high);
0019
0020
0021
0022
0023
0024
0025 rates[i] = rt;
0026 }
0027 return rates;
0028 }
0029
0030 const std::vector<long double> PTStatistics::m_rates = initializeRates();
0031
0032 PTStatistics::PTStatistics() { this->assign(RPCpg::ptBins_s, 0); }
0033
0034 void PTStatistics::update(PTStatistics& otherPtStats) {
0035 for (unsigned int i = 0; i < this->size(); ++i) {
0036
0037 (*this)[i] += otherPtStats[i];
0038 }
0039 }
0040 std::string PTStatistics::toString() {
0041 std::stringstream ss;
0042 ss << "PTStats:";
0043 for (unsigned int i = 0; i < this->size(); ++i) {
0044 ss << " " << (*this)[i];
0045 }
0046
0047 return ss.str();
0048 }
0049
0050 long double PTStatistics::eff(int ptCut) {
0051
0052
0053
0054 return double(sum(ptCut)) / this->sum();
0055 }
0056
0057 long int PTStatistics::sum(const int& ptCut) const {
0058
0059
0060 long int eqOrAbovePtCut = 0;
0061 unsigned int size = this->size();
0062
0063 for (unsigned int i = ptCut; i < size; ++i)
0064 eqOrAbovePtCut += (*this)[i];
0065 return eqOrAbovePtCut;
0066 }
0067
0068
0069 long int PTStatistics::sum() const {
0070
0071 long int eqOrAbovePtCut = 0;
0072
0073
0074
0075 PTStatistics::const_iterator it = this->begin();
0076 PTStatistics::const_iterator itend = this->end();
0077 for (; it != itend; ++it)
0078 eqOrAbovePtCut += *it;
0079
0080 return eqOrAbovePtCut;
0081 }
0082
0083 long double PTStatistics::sumR(const int& ptCut) const {
0084
0085 long double eqOrAbovePtCut = 0;
0086 unsigned int size = this->size();
0087
0088 for (unsigned int i = ptCut; i < size; ++i)
0089 eqOrAbovePtCut += (*this)[i] * m_rates[i];
0090 return eqOrAbovePtCut;
0091 }
0092
0093 long double PTStatistics::sumR() const {
0094
0095 long double eqOrAbovePtCut = 0;
0096
0097
0098
0099
0100
0101
0102 unsigned int size = this->size();
0103 for (unsigned int i = 1; i < size; ++i)
0104 eqOrAbovePtCut += (*this)[i] * m_rates[i];
0105
0106
0107 return eqOrAbovePtCut;
0108 }