CMS 3D CMS Logo

simple_stat.h
Go to the documentation of this file.
1 #ifndef TrackingTools_DetLayers_simple_stat_h
2 #define TrackingTools_DetLayers_simple_stat_h
3 
4 #include <algorithm>
5 #include <numeric>
6 #include <cmath>
7 
12 template <class CONT>
13 double stat_mean(const CONT& cont) {
14  double sum = accumulate(cont.begin(), cont.end(), 0.);
15  return sum / cont.size();
16 }
17 
22 template <class CONT>
23 double stat_RMS(const CONT& cont) {
24  typename CONT::const_iterator i;
25 
26  int N = cont.size();
27  if (N > 1) {
28  double sum = 0., sum2 = 0.;
29  for (i = cont.begin(); i != cont.end(); i++) {
30  sum += *i;
31  sum2 += (*i) * (*i);
32  }
33  return sqrt(std::max(0., (sum2 - sum * sum / N) / (N - 1)));
34  } else
35  return 0.;
36 }
37 
38 #endif // TrackingTools_DetLayers_simple_stat_h
double stat_mean(const CONT &cont)
Definition: simple_stat.h:13
T sqrt(T t)
Definition: SSEVec.h:19
double stat_RMS(const CONT &cont)
Definition: simple_stat.h:23
#define N
Definition: blowfish.cc:9
cont
load Luminosity info ##
Definition: generateEDF.py:628