All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ISyst.cxx
Go to the documentation of this file.
2 
5 
6 namespace ana
7 {
8  //----------------------------------------------------------------------
9  ISyst::ISyst(const std::string& shortName,
10  const std::string& latexName,
11  bool applyPenalty,
12  double min,
13  double max)
14  : fShortName(shortName), fLatexName(latexName), fApplyPenalty(applyPenalty), fMin(min), fMax(max)
15  {
17  }
18 
19  //----------------------------------------------------------------------
21  {
22  // Normally ISysts should last for the life of the process, but in case one
23  // is deleted it's best not to leave a dangling pointer in SystRegistry.
25  }
26 
27  //----------------------------------------------------------------------
28  double ISyst::Penalty(double x) const
29  {
30  if(fApplyPenalty){
31  // Regular quadratic penalty term
32  return x*x;
33  }
34  else{
35  // Otherwise, no penalty within range, but still apply one outside
36  if(x >= Min() && x <= Max()) return 0;
37 
38  // Try to direct fit back towards centre of the space. Engineer penalty
39  // to be zero at the limits.
40  const double mean = (Min()+Max())/2;
41  const double rad = (Max()-Min())/2;
42  return util::sqr((x-mean)/rad)-1;
43  }
44  }
45 }
bool fApplyPenalty
Definition: ISyst.h:64
process_name opflash particleana ie x
ISyst(const std::string &shortName, const std::string &latexName, bool applyPenalty=true, double min=-3, double max=+3)
Definition: ISyst.cxx:9
virtual double Max() const
Definition: ISyst.h:42
process_name opflashCryoW ana
virtual double Min() const
Return the min/max value for this syst.
Definition: ISyst.h:41
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
static void UnRegister(const ISyst *s)
static void Register(const ISyst *s)
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
virtual double Penalty(double x) const
Definition: ISyst.cxx:28
virtual ~ISyst()
Definition: ISyst.cxx:20