DTRecoConditions

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
#ifndef CondFormats_DTObjects_DTRecoConditions_H
#define CondFormats_DTObjects_DTRecoConditions_H

/** \class DTRecoConditions
 *  DB object for storing per-SL DT reconstruction parameters (ttrig, vdrift, uncertainties), 
 *  possibly with their dependency from external quantities (like position, angle, etc.) 
 *
 *  Dependencies can be specified  with the expression set by setFormula(string), representing:
 *  -a TFormula,  e.g. "[0]+[1]*x", in the most general case;
 *  -special cases like "[0]" = fixed constant, that are implemented without calling TFormula.
 *
 *  \author N. Amapane, G. Cerminara
 */

#include "CondFormats/Serialization/interface/Serializable.h"

#include <map>
#include <vector>
#include <string>
#include <cstdint>
#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
#include <atomic>
#endif

class DTWireId;
class TFormula;

class DTRecoConditions {
public:
  typedef std::map<uint32_t, std::vector<double> >::const_iterator const_iterator;

  /// Constructor
  DTRecoConditions();
  DTRecoConditions(const DTRecoConditions&);
  const DTRecoConditions& operator=(const DTRecoConditions&);

  /// Destructor
  virtual ~DTRecoConditions();

  void setVersion(int version) { theVersion = version; }

  /// Version numer specifying the structure of the payload. See .cc file for details.
  int version() const { return theVersion; }

  /// Get the value correspoding to the given WireId,
  //// using x[] as parameters of the parametrization when relevant
  float get(const DTWireId& wireid, double* x = nullptr) const;

  /// Set the expression representing the formula used for parametrization
  void setFormulaExpr(const std::string& expr) { expression = expr; }

  std::string getFormulaExpr() const { return expression; }

  /// Fill the payload
  void set(const DTWireId& wireid, const std::vector<double>& values);

  /// Access the data
  const_iterator begin() const;
  const_iterator end() const;

private:
  // The formula used for parametrization (transient pointer)
#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
  mutable std::atomic<TFormula*> formula COND_TRANSIENT;
#else
  mutable TFormula* formula COND_TRANSIENT;
#endif

  // Formula evalaution strategy, derived from expression and cached for efficiency reasons
#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
  mutable std::atomic<int> formulaType COND_TRANSIENT;
#else
  mutable int formulaType COND_TRANSIENT;
#endif

  // String with the expression representing the formula used for parametrization
  std::string expression;

  // Actual data
  std::map<uint32_t, std::vector<double> > payload;

  // Versioning
  int theVersion;

  COND_SERIALIZABLE;
};
#endif