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
mps_fire.i
i
Definition: mps_fire.py:355
stat_RMS
double stat_RMS(const CONT &cont)
Definition: simple_stat.h:23
generateEDF.cont
cont
load Luminosity info ##
Definition: generateEDF.py:629
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
N
#define N
Definition: blowfish.cc:9
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
combinedConstraintHelpers::sum2
void sum2(T &x, T y)
Definition: CombinedKinematicConstraintT.h:74
stat_mean
double stat_mean(const CONT &cont)
Definition: simple_stat.h:13