CMS 3D CMS Logo

CaloValidationStatistics.cc
Go to the documentation of this file.
3 #include <cmath>
4 #include <iostream>
5 
6 CaloValidationStatistics::CaloValidationStatistics(std::string name, float expectedMean, float expectedRMS)
7 : name_(name),
8  expectedMean_(expectedMean),
9  expectedRMS_(expectedRMS),
10  sum_(0.),
11  sumOfSquares_(0.),
12  weightedSum_(0.),
13  sumOfWeights_(0.),
14  n_(0)
15 {
16 }
17 
18 
20 {
21  edm::LogInfo("CaloValidationStatistics") << *this;
22 }
23 
25  sum_ += value;
26  sumOfSquares_ += (value*value);
27  weightedSum_ += value*weight;
29  ++n_;
30 }
31 
32 
34  return sum_/n_;
35 }
36 
37 
39  float numerator = n_ * sumOfSquares_ - sum_*sum_;
40  int denominator = n_ * (n_-1);
41  return std::sqrt(numerator/denominator);
42 }
43 
44 
46  return weightedSum_ / sumOfWeights_;
47 }
48 
49 
50 std::ostream& operator<<(std::ostream & os,const CaloValidationStatistics & stat) {
51  os << "OVAL " << stat.name() << " entries:" << stat.nEntries();
52  if(stat.nEntries() > 0) {
53  os << " Mean: " << stat.mean()
54  << " (expect " << stat.expectedMean() << ")";
55  }
56  if(stat.nEntries() > 1) {
57  os << " RMS: " << stat.RMS()
58  << " (expect " << stat.expectedRMS() << ")";
59  }
60  return os;
61 }
62 
63 
numerator
Definition: cuy.py:483
Definition: weight.py:1
std::ostream & operator<<(std::ostream &os, const CaloValidationStatistics &stat)
T sqrt(T t)
Definition: SSEVec.h:18
~CaloValidationStatistics()
prints to LogInfo upon destruction
Definition: value.py:1
denominator
Definition: cuy.py:484
void addEntry(float value, float weight=1.)
CaloValidationStatistics(std::string name, float expectedMean, float expectedRMS)