KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVDetectorSignalExpression.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Thu Jun 20 15:36:03 2019
2 //Author: John Frankland,,,
3 
4 #include "KVDetector.h"
6 
8 
9 
10 
19  : KVDetectorSignal(type, det), fFormula(nullptr)
20 {
21  // 'type' will be an alias for this expression
22  //
23  // 'expr' is any mathematically valid expression involving signals which are defined for 'det'
24  //
25  // If no valid signals are contained in the expression, IsValid() returns kFALSE
26  // and the expression should not be used
27 
28  int nsigs = 0;
29  KVString expr = _expr;
30  SetLabel(_expr);
31  TIter it_sig(&det->GetListOfDetectorSignals());
32  KVDetectorSignal* ds;
33  fRaw = kTRUE;
34  while ((ds = (KVDetectorSignal*)it_sig())) {
35  if (expr.Contains(ds->GetName())) {
36  fSignals.push_back(ds);
37  if (!ds->IsRaw()) fRaw = kFALSE;
38  expr.ReplaceAll(ds->GetName(), Form("[%d]", nsigs));
39  ++nsigs;
40  }
41  }
42  if (nsigs) {
43 #if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
44  fFormula = new TFormula(type, expr);
45 #else
46  fFormula.reset(new TFormula(type, expr));
47 #endif
48  fValid = kTRUE;
49  }
50  else
51  fValid = kFALSE;
52 
53  SetTitle(Form("Signal calculated as %s for detector %s", _expr.Data(), det->GetName()));
54 }
55 
56 
57 
63 
65 {
66  // Evaluate the expression using all current values of signals
67  //
68  // Any extra parameters required by any calibrations in the expression can be passed
69  // as a comma-separated list of "param=value" pairs
70 
71  int nsigs = fSignals.size();
72  for (int i = 0; i < nsigs; ++i) {
73  fFormula->SetParameter(i, fSignals[i]->GetValue(params));
74  }
75  return fFormula->Eval(0);
76 }
77 
78 
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char Char_t
const Bool_t kFALSE
double Double_t
const Bool_t kTRUE
int type
char * Form(const char *fmt,...)
Detector output from a mathematical combination of other signals.
Double_t GetValue(const KVNameValueList &params="") const
std::unique_ptr< TFormula > fFormula
std::vector< KVDetectorSignal * > fSignals
Output signal data produced by a detector.
virtual Bool_t IsRaw() const
Base class for detector geometry description, interface to energy-loss calculations.
Definition: KVDetector.h:121
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
virtual const char * GetName() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)