CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GSUtilities.h
Go to the documentation of this file.
1 #ifndef GSUtilities_h
2 #define GSUtilities_h
3 
8 class GSUtilities {
9 public:
11  GSUtilities(const unsigned nComp, const float* weights, const float* parameters, const float* errors)
12  : theNComp(nComp), theWeights(nullptr), theParameters(nullptr), theErrors(nullptr) {
13  if (theNComp) {
14  theWeights = new float[theNComp];
15  theParameters = new float[theNComp];
16  theErrors = new float[theNComp];
17  }
18  const float* wPtr1(weights);
19  const float* pPtr1(parameters);
20  const float* ePtr1(errors);
21  float* wPtr2(theWeights);
22  float* pPtr2(theParameters);
23  float* ePtr2(theErrors);
24  for (unsigned i = 0; i < theNComp; i++) {
25  *(wPtr2++) = weights ? *(wPtr1++) : 1.;
26  *(pPtr2++) = *(pPtr1++);
27  *(ePtr2++) = *(ePtr1++);
28  }
29  }
31  delete[] theWeights;
32  delete[] theParameters;
33  delete[] theErrors;
34  }
38  float quantile(const float) const;
40  float mode() const;
42  double pdf(const double&) const;
44  double cdf(const double&) const;
46  double dpdf1(const double&) const;
48  double dpdf2(const double&) const;
49 
51  double combinedMean() const;
52  // mean value of errors
53  double errorCombinedMean() const;
54  // error for the highest weight
55  float errorHighestWeight() const;
56  // max weight component - chiara
57  float maxWeight() const;
58  // mode error + some utilities functions
59  float errorMode();
60  float getMax(float);
61  float getMin(float);
62 
63 private:
65  double gauss(const double&, const double&, const double&) const;
67  double gaussInt(const double&, const double&, const double&) const;
71  double findMode(const double) const;
72 
73 private:
74  unsigned theNComp;
75  float* theWeights;
76  float* theParameters;
77  float* theErrors;
78 };
79 #endif
float mode() const
mode
Definition: GSUtilities.cc:83
float getMax(float)
Definition: GSUtilities.cc:262
float quantile(const float) const
Definition: GSUtilities.cc:11
double errorCombinedMean() const
Definition: GSUtilities.cc:197
double cdf(const double &) const
value of integral(pdf)
Definition: GSUtilities.cc:147
double findMode(const double) const
Definition: GSUtilities.cc:113
unsigned theNComp
Definition: GSUtilities.h:74
double gaussInt(const double &, const double &, const double &) const
integrated value of gaussian distribution
Definition: GSUtilities.cc:183
GSUtilities(const unsigned nComp, const float *weights, const float *parameters, const float *errors)
constructor from arrays of weights, parameters and standard deviations
Definition: GSUtilities.h:11
float * theErrors
Definition: GSUtilities.h:77
float errorMode()
Definition: GSUtilities.cc:219
float * theWeights
Definition: GSUtilities.h:75
double pdf(const double &) const
value of the pdf
Definition: GSUtilities.cc:140
double dpdf2(const double &) const
second derivative of pdf
Definition: GSUtilities.cc:163
float errorHighestWeight() const
Definition: GSUtilities.cc:71
float getMin(float)
Definition: GSUtilities.cc:248
float * theParameters
Definition: GSUtilities.h:76
double combinedMean() const
mean value of combined state
Definition: GSUtilities.cc:187
float maxWeight() const
Definition: GSUtilities.cc:205
double dpdf1(const double &) const
first derivative of pdf
Definition: GSUtilities.cc:154
double gauss(const double &, const double &, const double &) const
value of gaussian distribution
Definition: GSUtilities.cc:172