LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GFAbsRecoHit.h
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
20 /* @{ */
21 
22 #ifndef GFABSRECOHIT_H
23 #define GFABSRECOHIT_H
24 
25 #include <iostream>
26 #include <stdexcept> // std::logic_error
27 
28 #include "TMatrixT.h"
29 #include "TObject.h"
30 
32 #include "larreco/Genfit/GFException.h" // PrintROOTobject()
33 #include <cmath>
34 
35 namespace genf {
36  class GFAbsTrackRep;
37 }
38 
76 namespace genf {
77 
78  class GFAbsRecoHit : public TObject {
79  protected:
81  TMatrixT<Double_t> fHitCoord;
82 
84  TMatrixT<Double_t> fHitCov;
85 
86  private:
87  int fNparHit;
88 
89  public:
90  virtual ~GFAbsRecoHit();
91 
98  GFAbsRecoHit(int NparHit);
99 
102  GFAbsRecoHit();
103 
129  virtual TMatrixT<Double_t> getHMatrix(const GFAbsTrackRep* stateVector) = 0;
130  virtual TMatrixT<Double_t> getHMatrix(const GFAbsTrackRep* stateVector,
131  const Double_t&,
132  const Double_t&) = 0;
133 
149  virtual TMatrixT<Double_t> residualVector(const GFAbsTrackRep* stateVector,
150  const TMatrixT<Double_t>& state,
151  const GFDetPlane& d)
152  {
153  std::cout << "GFAbsRecoHit::residualVector(3args) Not correctly Using theta -- multiple "
154  "scattering -- information !!! Fix this if you really want to use getChi2Hit"
155  << std::endl;
156  TMatrixT<Double_t> H = getHMatrix(stateVector);
157  return (getHitCoord(d) - (H * state));
158  }
159 
160  virtual TMatrixT<Double_t> residualVector(const GFAbsTrackRep* stateVector,
161  const TMatrixT<Double_t>& state,
162  const GFDetPlane& d,
163  const GFDetPlane& dPrev,
164  const double& mass)
165  {
166  Double_t dist = (d.getO() - dPrev.getO()).Mag();
167  // Double_t mass = 0.104; // close enough for muons, pions, I think.
168  Double_t mom = fabs(1.0 / state[0][0]);
169  Double_t beta = mom / sqrt(mass * mass + mom * mom);
170  if (std::isnan(dist) || dist < 0.2) dist = 0.2; // don't allow 0s here.
171  if (std::isnan(beta) || beta < 0.04) beta = 0.04;
172 
173  TMatrixT<Double_t> H = getHMatrix(stateVector, beta, dist);
174  return (getHitCoord(d, dPrev) - (H * state));
175  }
176 
180  TMatrixT<Double_t> getRawHitCov() const { return fHitCov; }
181 
185  TMatrixT<Double_t> getRawHitCoord() const { return fHitCoord; }
186 
194  virtual TMatrixT<Double_t> getHitCov(const GFDetPlane&) = 0;
195  virtual TMatrixT<Double_t> getHitCov(const GFDetPlane&,
196  const GFDetPlane&,
197  const TMatrixT<Double_t>&,
198  const Double_t&) = 0;
199 
207  virtual TMatrixT<Double_t> getHitCoord(const GFDetPlane&, const GFDetPlane&) = 0;
208  virtual TMatrixT<Double_t> getHitCoord(const GFDetPlane&) = 0;
209 
224  virtual const GFDetPlane& getDetPlane(GFAbsTrackRep*) = 0;
225 
232  virtual GFAbsRecoHit* clone() = 0;
233 
236  virtual void Print(std::ostream& out = std::cout) const { PrintROOTobject(out, fHitCoord); }
237 
238  virtual const std::string& getPolicyName();
239 
240  int getNparHit() { return fNparHit; }
241 
242  // public:
243  //ClassDef(GFAbsRecoHit,3)
244 
245  private:
246  virtual void Print(Option_t*) const
247  {
248  throw std::logic_error(std::string(__func__) + "::Print(Option_t*) not available");
249  }
250  };
251 } // namespace
252 
253 #endif //FITTER_ABSHIT_H
254 
virtual TMatrixT< Double_t > getHitCoord(const GFDetPlane &, const GFDetPlane &)=0
Get hit coordinates in a specific detector plane.
virtual ~GFAbsRecoHit()
TMatrixT< Double_t > fHitCoord
Vector of raw coordinates of hit.
Definition: GFAbsRecoHit.h:81
virtual const std::string & getPolicyName()
Generic Interface to magnetic fields in GENFIT.
Definition: GFAbsBField.h:34
virtual TMatrixT< Double_t > getHMatrix(const GFAbsTrackRep *stateVector)=0
Get transformation matrix. Transformation between hit coordinates and track representation coordinate...
virtual const GFDetPlane & getDetPlane(GFAbsTrackRep *)=0
Get detector plane for a given track representation.
TMatrixT< Double_t > getRawHitCoord() const
Get raw hit coordinates.
Definition: GFAbsRecoHit.h:185
Base Class for genfit track representations. Defines interface for track parameterizations.
Definition: GFAbsTrackRep.h:81
TVector3 getO() const
Definition: GFDetPlane.h:77
virtual void Print(Option_t *) const
Definition: GFAbsRecoHit.h:246
virtual TMatrixT< Double_t > residualVector(const GFAbsTrackRep *stateVector, const TMatrixT< Double_t > &state, const GFDetPlane &d, const GFDetPlane &dPrev, const double &mass)
Definition: GFAbsRecoHit.h:160
virtual TMatrixT< Double_t > getHitCov(const GFDetPlane &)=0
Get hit covariances in a specific detector plane.
Float_t d
Definition: plot.C:235
virtual void Print(std::ostream &out=std::cout) const
Print raw hit coordinates.
Definition: GFAbsRecoHit.h:236
GFAbsRecoHit()
Default constructor needed for compatibility with ROOT.
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
void PrintROOTobject(std::ostream &, const ROOTOBJ &)
Small utility functions which print some ROOT objects into an output stream.
Definition: GFException.h:127
TMatrixT< Double_t > getRawHitCov() const
Get raw hit covariances.
Definition: GFAbsRecoHit.h:180
virtual TMatrixT< Double_t > residualVector(const GFAbsTrackRep *stateVector, const TMatrixT< Double_t > &state, const GFDetPlane &d)
Calculate residual with respect to a track representation.
Definition: GFAbsRecoHit.h:149
TMatrixT< Double_t > fHitCov
Covariance of raw hit coordinates.
Definition: GFAbsRecoHit.h:84
virtual GFAbsRecoHit * clone()=0
Get clone of this object.