Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:35:56

0001 #ifndef DataFormats_PatCandidates_interface_ParametrizationHelper_h
0002 #define DataFormats_PatCandidates_interface_ParametrizationHelper_h
0003 
0004 #include "DataFormats/PatCandidates/interface/CandKinResolution.h"
0005 #include <string>
0006 
0007 namespace pat {
0008   namespace helper {
0009     namespace ParametrizationHelper {
0010 
0011       /// Returns the number of free parameters in a parametrization (3 or 4)
0012       inline uint32_t dimension(pat::CandKinResolution::Parametrization parametrization) {
0013         return (static_cast<uint32_t>(parametrization) & 0x0F);
0014       }
0015 
0016       /// Convert a name into a parametrization code
0017       pat::CandKinResolution::Parametrization fromString(const std::string &name);
0018 
0019       /// Convert a number into a string
0020       const char *name(pat::CandKinResolution::Parametrization param);
0021 
0022       /// Given a choice of coordinate frame, a vector of coordinates and a reference 4-vector, produce a new 4 vector with the specified parameters.
0023       /// The new 4-vector is not guaranteed to satisfy the constraints of these parametrization if the initial 4-vector does not satisfy them.
0024       /// In the future this method will throw an exception if you go in an unphysical point of the coordinate system (e.g. E^2 < P^2)
0025       math::PtEtaPhiMLorentzVector polarP4fromParameters(pat::CandKinResolution::Parametrization parametrization,
0026                                                          const AlgebraicVector4 &parameters,
0027                                                          const math::PtEtaPhiMLorentzVector &initialP4);
0028 
0029       /// Given a choice of coordinate frame, a vector of coordinates and a reference 4-vector, produce a new 4 vector with the specified parameters.
0030       /// The new 4-vector is not guaranteed to satisfy the constraints of these parametrization if the initial 4-vector does not satisfy them.
0031       /// In the future this method will throw an exception if you go in an unphysical point of the coordinate system (e.g. E^2 < P^2)
0032       math::XYZTLorentzVector p4fromParameters(pat::CandKinResolution::Parametrization parametrization,
0033                                                const AlgebraicVector4 &parameters,
0034                                                const math::XYZTLorentzVector &initialP4);
0035 
0036       /// Returns a vector of coordinates values given a coordinate frame and a 4-vector.
0037       AlgebraicVector4 parametersFromP4(pat::CandKinResolution::Parametrization parametrization,
0038                                         const math::XYZTLorentzVector &p4);
0039 
0040       /// Returns a vector of coordinates values given a coordinate frame and a 4-vector.
0041       AlgebraicVector4 parametersFromP4(pat::CandKinResolution::Parametrization parametrization,
0042                                         const math::PtEtaPhiMLorentzVector &p4);
0043 
0044       /// Set the values of the parameters for a given 4-momentum
0045       void setParametersFromP4(pat::CandKinResolution::Parametrization parametrization,
0046                                AlgebraicVector4 &pars,
0047                                const math::XYZTLorentzVector &p4);
0048 
0049       /// Set the values of the parameters for a given 4-momentum
0050       void setParametersFromP4(pat::CandKinResolution::Parametrization parametrization,
0051                                AlgebraicVector4 &pars,
0052                                const math::PtEtaPhiMLorentzVector &p4);
0053 
0054       /// For internal use only, so we provide only the interface. Use the 'setParametersFromP4'.
0055       template <typename T>
0056       void setParametersFromAnyVector(pat::CandKinResolution::Parametrization parametrization,
0057                                       AlgebraicVector4 &pars,
0058                                       const T &p4);
0059 
0060       /// Expresses the difference between two 4-momentum vectors as a shift in coordinates in a given frame.
0061       /** Basically, if you do:
0062      *  <code>
0063      *      pars = parametersFromP4(param, simp4);
0064      *      diff = diffToParameters(param, simP4, recP4);
0065      *  </code>
0066      *  then up to roundoff errors
0067      *  <code>recP4  == p4fromParameters(param, pars+diff, simP4);</code>
0068      */
0069       AlgebraicVector4 diffToParameters(pat::CandKinResolution::Parametrization parametrization,
0070                                         const math::XYZTLorentzVector &p4ini,
0071                                         const math::XYZTLorentzVector &p4fin);
0072 
0073       /// Expresses the difference between two 4-momentum vectors as a shift in coordinates in a given frame.
0074       /** Basically, if you do:
0075      *  <code>
0076      *      pars = parametersFromP4(param, simp4);
0077      *      diff = diffToParameters(param, simP4, recP4);
0078      *  </code>
0079      *  then up to roundoff errors
0080      *  <code>recP4  == p4fromParameters(param, pars+diff, simP4);</code>
0081      */
0082       AlgebraicVector4 diffToParameters(pat::CandKinResolution::Parametrization parametrization,
0083                                         const math::PtEtaPhiMLorentzVector &p4ini,
0084                                         const math::PtEtaPhiMLorentzVector &p4fin);
0085 
0086       /// Is this parametrization usable only with massless objects?
0087       bool isAlwaysMassless(pat::CandKinResolution::Parametrization parametrization);
0088 
0089       /// Is this parametrization usable only with massive objects?
0090       bool isAlwaysMassive(pat::CandKinResolution::Parametrization parametrization);
0091 
0092       /// If this parametrization has a mass constraint (including the 'isAlwaysMassless' case)
0093       bool isMassConstrained(pat::CandKinResolution::Parametrization parametrization);
0094 
0095       /// If this value of the parameters is meaningful in this parametrization.
0096       /// It can be used e.g. when doing random smearing to check you're still within the physical region
0097       /// This DOES check inequalities (e.g. E >= P, M >= 0, theta in [0,PI], ..)
0098       /// This DOES NOT check strict equalities (e.g. M == 0)
0099       /// This DOES NOT check that your parameters comply with your constraints (e.g. fixed mass constraint)
0100       bool isPhysical(pat::CandKinResolution::Parametrization parametrization,
0101                       const AlgebraicVector4 &v4,
0102                       const math::PtEtaPhiMLorentzVector &initialP4);
0103     }  // namespace ParametrizationHelper
0104   }  // namespace helper
0105 }  // namespace pat
0106 
0107 #endif