Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:24

0001 /*
0002  * GblPoint.h
0003  *
0004  *  Created on: Aug 18, 2011
0005  *      Author: kleinwrt
0006  */
0007 
0008 /** \file
0009  *  GblPoint definition.
0010  *
0011  *  \author Claus Kleinwort, DESY, 2011 (Claus.Kleinwort@desy.de)
0012  *
0013  *  \copyright
0014  *  Copyright (c) 2011 - 2016 Deutsches Elektronen-Synchroton,
0015  *  Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY \n\n
0016  *  This library is free software; you can redistribute it and/or modify
0017  *  it under the terms of the GNU Library General Public License as
0018  *  published by the Free Software Foundation; either version 2 of the
0019  *  License, or (at your option) any later version. \n\n
0020  *  This library is distributed in the hope that it will be useful,
0021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0023  *  GNU Library General Public License for more details. \n\n
0024  *  You should have received a copy of the GNU Library General Public
0025  *  License along with this program (see the file COPYING.LIB for more
0026  *  details); if not, write to the Free Software Foundation, Inc.,
0027  *  675 Mass Ave, Cambridge, MA 02139, USA.
0028  */
0029 
0030 #ifndef GBLPOINT_H_
0031 #define GBLPOINT_H_
0032 
0033 #include<iostream>
0034 #include<vector>
0035 #include<math.h>
0036 #include <stdexcept>
0037 #include "TVectorD.h"
0038 #include "TMatrixD.h"
0039 #include "TMatrixDSym.h"
0040 #include "TMatrixDSymEigen.h"
0041 
0042 #include "Math/SMatrix.h"
0043 #include "Math/SVector.h"
0044 typedef ROOT::Math::SMatrix<double, 2> SMatrix22;
0045 typedef ROOT::Math::SMatrix<double, 2, 3> SMatrix23;
0046 typedef ROOT::Math::SMatrix<double, 2, 5> SMatrix25;
0047 typedef ROOT::Math::SMatrix<double, 2, 7> SMatrix27;
0048 typedef ROOT::Math::SMatrix<double, 3, 2> SMatrix32;
0049 typedef ROOT::Math::SMatrix<double, 3> SMatrix33;
0050 typedef ROOT::Math::SMatrix<double, 5> SMatrix55;
0051 typedef ROOT::Math::SVector<double, 2> SVector2;
0052 typedef ROOT::Math::SVector<double, 5> SVector5;
0053 
0054 namespace gbl {
0055 
0056 /// Point on trajectory
0057 /**
0058  * User supplied point on (initial) trajectory.
0059  *
0060  * Must have jacobian for propagation from previous point. May have:
0061  *
0062  *   -# Measurement (1D - 5D)
0063  *   -# Scatterer (thin, 2D kinks)
0064  *   -# Additional local parameters (with derivatives). Fitted together with track parameters.
0065  *   -# Additional global parameters (with labels and derivatives). Not fitted, only passed
0066  *      on to (binary) file for fitting with Millepede-II.
0067  */
0068 class GblPoint {
0069 public:
0070     explicit GblPoint(const TMatrixD &aJacobian);
0071     explicit GblPoint(const SMatrix55 &aJacobian);
0072     virtual ~GblPoint();
0073     void addMeasurement(const TMatrixD &aProjection, const TVectorD &aResiduals,
0074             const TVectorD &aPrecision, double minPrecision = 0.);
0075     void addMeasurement(const TMatrixD &aProjection, const TVectorD &aResiduals,
0076             const TMatrixDSym &aPrecision, double minPrecision = 0.);
0077     void addMeasurement(const TVectorD &aResiduals, const TVectorD &aPrecision,
0078             double minPrecision = 0.);
0079     void addMeasurement(const TVectorD &aResiduals,
0080             const TMatrixDSym &aPrecision, double minPrecision = 0.);
0081     unsigned int hasMeasurement() const;
0082     void getMeasurement(SMatrix55 &aProjection, SVector5 &aResiduals,
0083             SVector5 &aPrecision) const;
0084     void getMeasTransformation(TMatrixD &aTransformation) const;
0085     void addScatterer(const TVectorD &aResiduals, const TVectorD &aPrecision);
0086     void addScatterer(const TVectorD &aResiduals,
0087             const TMatrixDSym &aPrecision);
0088     bool hasScatterer() const;
0089     void getScatterer(SMatrix22 &aTransformation, SVector2 &aResiduals,
0090             SVector2 &aPrecision) const;
0091     void getScatTransformation(TMatrixD &aTransformation) const;
0092     void addLocals(const TMatrixD &aDerivatives);
0093     unsigned int getNumLocals() const;
0094     const TMatrixD& getLocalDerivatives() const;
0095     void addGlobals(const std::vector<int> &aLabels,
0096             const TMatrixD &aDerivatives);
0097     unsigned int getNumGlobals() const;
0098     std::vector<int> getGlobalLabels() const;
0099     const TMatrixD& getGlobalDerivatives() const;
0100     void setLabel(unsigned int aLabel);
0101     unsigned int getLabel() const;
0102     void setOffset(int anOffset);
0103     int getOffset() const;
0104     const SMatrix55& getP2pJacobian() const;
0105     void addPrevJacobian(const SMatrix55 &aJac);
0106     void addNextJacobian(const SMatrix55 &aJac);
0107     void getDerivatives(int aDirection, SMatrix22 &matW, SMatrix22 &matWJ,
0108             SVector2 &vecWd) const;
0109     void printPoint(unsigned int level = 0) const;
0110 
0111 private:
0112     unsigned int theLabel; ///< Label identifying point
0113     int theOffset; ///< Offset number at point if not negative (else interpolation needed)
0114     SMatrix55 p2pJacobian; ///< Point-to-point jacobian from previous point
0115     SMatrix55 prevJacobian; ///< Jacobian to previous scatterer (or first measurement)
0116     SMatrix55 nextJacobian; ///< Jacobian to next scatterer (or last measurement)
0117     unsigned int measDim; ///< Dimension of measurement (1-5), 0 indicates absence of measurement
0118     SMatrix55 measProjection; ///< Projection from measurement to local system
0119     SVector5 measResiduals; ///< Measurement residuals
0120     SVector5 measPrecision; ///< Measurement precision (diagonal of inverse covariance matrix)
0121     bool transFlag; ///< Transformation exists?
0122     TMatrixD measTransformation; ///< Transformation of diagonalization (of meas. precision matrix)
0123     bool scatFlag; ///< Scatterer present?
0124     SMatrix22 scatTransformation; ///< Transformation of diagonalization (of scat. precision matrix)
0125     SVector2 scatResiduals; ///< Scattering residuals (initial kinks if iterating)
0126     SVector2 scatPrecision; ///< Scattering precision (diagonal of inverse covariance matrix)
0127     TMatrixD localDerivatives; ///< Derivatives of measurement vs additional local (fit) parameters
0128     std::vector<int> globalLabels; ///< Labels of global (MP-II) derivatives
0129     TMatrixD globalDerivatives; ///< Derivatives of measurement vs additional global (MP-II) parameters
0130 };
0131 }
0132 #endif /* GBLPOINT_H_ */