Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:46:47

0001 #ifndef CondFormats_DTObjects_DTRecoConditions_H
0002 #define CondFormats_DTObjects_DTRecoConditions_H
0003 
0004 /** \class DTRecoConditions
0005  *  DB object for storing per-SL DT reconstruction parameters (ttrig, vdrift, uncertainties), 
0006  *  possibly with their dependency from external quantities (like position, angle, etc.) 
0007  *
0008  *  Dependencies can be specified  with the expression set by setFormula(string), representing:
0009  *  -a TFormula,  e.g. "[0]+[1]*x", in the most general case;
0010  *  -special cases like "[0]" = fixed constant, that are implemented without calling TFormula.
0011  *
0012  *  \author N. Amapane, G. Cerminara
0013  */
0014 
0015 #include "CondFormats/Serialization/interface/Serializable.h"
0016 
0017 #include <map>
0018 #include <vector>
0019 #include <string>
0020 #include <cstdint>
0021 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0022 #include <atomic>
0023 #endif
0024 
0025 class DTWireId;
0026 class TFormula;
0027 
0028 class DTRecoConditions {
0029 public:
0030   typedef std::map<uint32_t, std::vector<double> >::const_iterator const_iterator;
0031 
0032   /// Constructor
0033   DTRecoConditions();
0034   DTRecoConditions(const DTRecoConditions&);
0035   const DTRecoConditions& operator=(const DTRecoConditions&);
0036 
0037   /// Destructor
0038   virtual ~DTRecoConditions();
0039 
0040   void setVersion(int version) { theVersion = version; }
0041 
0042   /// Version numer specifying the structure of the payload. See .cc file for details.
0043   int version() const { return theVersion; }
0044 
0045   /// Get the value correspoding to the given WireId,
0046   //// using x[] as parameters of the parametrization when relevant
0047   float get(const DTWireId& wireid, double* x = nullptr) const;
0048 
0049   /// Set the expression representing the formula used for parametrization
0050   void setFormulaExpr(const std::string& expr) { expression = expr; }
0051 
0052   std::string getFormulaExpr() const { return expression; }
0053 
0054   /// Fill the payload
0055   void set(const DTWireId& wireid, const std::vector<double>& values);
0056 
0057   /// Access the data
0058   const_iterator begin() const;
0059   const_iterator end() const;
0060 
0061 private:
0062   // The formula used for parametrization (transient pointer)
0063 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0064   mutable std::atomic<TFormula*> formula COND_TRANSIENT;
0065 #else
0066   mutable TFormula* formula COND_TRANSIENT;
0067 #endif
0068 
0069   // Formula evalaution strategy, derived from expression and cached for efficiency reasons
0070 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0071   mutable std::atomic<int> formulaType COND_TRANSIENT;
0072 #else
0073   mutable int formulaType COND_TRANSIENT;
0074 #endif
0075 
0076   // String with the expression representing the formula used for parametrization
0077   std::string expression;
0078 
0079   // Actual data
0080   std::map<uint32_t, std::vector<double> > payload;
0081 
0082   // Versioning
0083   int theVersion;
0084 
0085   COND_SERIALIZABLE;
0086 };
0087 #endif