CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTRecoConditions.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author N. Amapane, G. Cerminara
5  */
6 
10 #include <iostream>
11 #include <algorithm>
12 
13 #include <TFormula.h>
14 
15 using std::string;
16 using std::map;
17 using std::vector;
18 using std::cout;
19 using std::endl;
20 
21 
23  formula(0),
24  formulaType(0),
25  expression("[0]")
26 {}
27 
29  delete formula;
30 }
31 
32 
33 float DTRecoConditions::get(const DTWireId& wireid, double* x) const {
34 
35  map<uint32_t, vector<double> >::const_iterator slIt = payload.find(wireid.superlayerId().rawId());
36  if(slIt == payload.end()) {
37  throw cms::Exception("InvalidInput") << "The SLId: " << wireid.superlayerId() << " is not in the paylaod map";
38  }
39  const vector<double>& par = slIt->second;
40 
41  // Initialize if this is the first call
42  if (formulaType==0) {
43  if (expression=="[0]") {
44  formulaType = 1;
45  } else if (expression=="par[step]") {
46  formulaType = 2;
47  } else {
48  formulaType = 99;
49  formula = new TFormula("DTExpr",expression.c_str());
50  }
51  }
52 
53  if (formulaType==1 || par.size()==1) {
54  // Return value is simply a constant. Assume this is the case also if only one parameter exists.
55  return par[0];
56  } else if (formulaType==2) {
57  // Special case: par[i] represents the value for step i
58  return par[unsigned (x[0])];
59  } else {
60  // Use the formula corresponding to expression.
61  return formula->EvalPar(x,par.data());
62  }
63 }
64 
65 
66 void DTRecoConditions::set(const DTWireId& wireid, const std::vector<double>& values) {
67  payload[wireid.superlayerId()] = values;
68 }
69 
70 
72  return payload.begin();
73 }
74 
76  return payload.end();
77 }
const_iterator end() const
void set(const DTWireId &wireid, const std::vector< double > &values)
Fill the payload.
std::map< uint32_t, std::vector< double > > payload
std::map< uint32_t, std::vector< double > >::const_iterator const_iterator
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
float get(const DTWireId &wireid, double *x=0) const
Get the value correspoding to the given WireId, / using x[] as parameters of the parametrization wh...
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
DTRecoConditions()
Constructor.
const_iterator begin() const
Access the data.
virtual ~DTRecoConditions()
Destructor.
std::string expression
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10