CMS 3D CMS Logo

PTStatistics.cc
Go to the documentation of this file.
2 
3 #include <sstream>
4 #include <numeric>
5 #include <iostream>
6 //-----------------------------------------------------------------------------
7 // PTStatistics
8 //-----------------------------------------------------------------------------
9 static std::vector<long double> initializeRates() {
10  std::vector<long double> rates(RPCpg::ptBins_s, 0);
11  //std::cout << "Initilizing rates" << std::endl;
12 
13  // Note bin=0 is empty during generation
14  // bin=0 is used only when calculating efficiencies (for storing muons,that werent found)
15  for (unsigned int i = 1; i < rates.size(); ++i) {
16  long double low = RPCpg::pts[i];
17  long double high = RPCpg::pts[i + 1];
18  long double rt = RPCpg::rate(low) - RPCpg::rate(high);
19 
20  /* std::cout << "PtCode " << i
21  << " " << low
22  << " " << high
23  << " " << rt
24  << std::endl;*/
25  rates[i] = rt;
26  }
27  return rates;
28 }
29 
30 const std::vector<long double> PTStatistics::m_rates = initializeRates();
31 
33 
34 void PTStatistics::update(PTStatistics& otherPtStats) {
35  for (unsigned int i = 0; i < this->size(); ++i) {
36  //this->at(i)+=otherPtStats.at(i);
37  (*this)[i] += otherPtStats[i];
38  }
39 }
41  std::stringstream ss;
42  ss << "PTStats:";
43  for (unsigned int i = 0; i < this->size(); ++i) {
44  ss << " " << (*this)[i];
45  }
46 
47  return ss.str();
48 }
49 
50 long double PTStatistics::eff(int ptCut) { // ptCut=0 -> total rate
51  //int eqOrAbovePtCut = 0;
52  //for(unsigned int i=ptCut;i<this->size();++i) eqOrAbovePtCut += this->at(i);
53  // return double(eqOrAbovePtCut)/this->sum();
54  return double(sum(ptCut)) / this->sum();
55 }
56 
57 long int PTStatistics::sum(const int& ptCut) const {
58  //inline int PTStatistics::sum(const int & ptCut) const{
59  //return std::accumulate(this->begin(),this->end(),0);
60  long int eqOrAbovePtCut = 0;
61  unsigned int size = this->size();
62  //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += this->at(i);
63  for (unsigned int i = ptCut; i < size; ++i)
64  eqOrAbovePtCut += (*this)[i];
65  return eqOrAbovePtCut;
66 }
67 
68 //inline int PTStatistics::sum() const{
69 long int PTStatistics::sum() const {
70  //return std::accumulate(this->begin(),this->end(),0);
71  long int eqOrAbovePtCut = 0;
72  //unsigned int size = this->size();
73  //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += this->at(i);
74  //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += (*this)[i];
75  PTStatistics::const_iterator it = this->begin();
76  PTStatistics::const_iterator itend = this->end();
77  for (; it != itend; ++it)
78  eqOrAbovePtCut += *it;
79 
80  return eqOrAbovePtCut;
81 }
82 
83 long double PTStatistics::sumR(const int& ptCut) const {
84  //return std::accumulate(this->begin(),this->end(),0);
85  long double eqOrAbovePtCut = 0;
86  unsigned int size = this->size();
87  //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += this->at(i);
88  for (unsigned int i = ptCut; i < size; ++i)
89  eqOrAbovePtCut += (*this)[i] * m_rates[i];
90  return eqOrAbovePtCut;
91 }
92 
93 long double PTStatistics::sumR() const {
94  //return std::accumulate(this->begin(),this->end(),0);
95  long double eqOrAbovePtCut = 0;
96  //unsigned int size = this->size();
97  //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += this->at(i);
98  //for(unsigned int i=ptCut;i<size;++i) eqOrAbovePtCut += (*this)[i];
99  //PTStatistics::const_iterator it = this->begin();
100  //PTStatistics::const_iterator itend = this->end();
101  //PtCode 0 - muons not found
102  unsigned int size = this->size();
103  for (unsigned int i = 1; i < size; ++i)
104  eqOrAbovePtCut += (*this)[i] * m_rates[i];
105  //for(;it!=itend;++it) eqOrAbovePtCut += *it*m_rates[i];
106 
107  return eqOrAbovePtCut;
108 }
mps_fire.i
i
Definition: mps_fire.py:428
PTStatistics::m_rates
static const std::vector< long double > m_rates
Definition: PTStatistics.h:22
PTStatistics::toString
std::string toString()
Definition: PTStatistics.cc:40
assign
void assign(const std::vector< float > &vec, float &a, float &b, float &c, float &d)
Definition: PileupJetIdAlgo.cc:139
hcal_runs.rt
rt
Definition: hcal_runs.py:76
RPCpg::rate
double rate(double x)
Definition: Constants.cc:3
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
mps_fire.end
end
Definition: mps_fire.py:242
PTStatistics::update
void update(PTStatistics &otherPtStats)
Definition: PTStatistics.cc:34
jetfilter_cfi.ptCut
ptCut
Definition: jetfilter_cfi.py:6
PTStatistics::sumR
long double sumR() const
Definition: PTStatistics.cc:93
PTStatistics::PTStatistics
PTStatistics()
Definition: PTStatistics.cc:32
PTStatistics::eff
long double eff(int ptCut)
Definition: PTStatistics.cc:50
PTStatistics::sum
long int sum() const
Definition: PTStatistics.cc:69
RPCpg::pts
static const double pts[33]
Definition: Constants.h:30
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
RPCpg::ptBins_s
const unsigned int ptBins_s
Definition: Constants.h:28
initializeRates
static std::vector< long double > initializeRates()
Definition: PTStatistics.cc:9
PTStatistics
Definition: PTStatistics.h:10
PTStatistics.h
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443