FairRoot/PandaRoot
GFDafHit.cxx
Go to the documentation of this file.
1 /* Copyright 2011, Technische Universitaet Muenchen,
2 Authors: Karl Bicker
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  */
19 
20 #include<GFDafHit.h>
21 
22 GFDafHit::GFDafHit(std::vector<GFAbsRecoHit*> HitsInPlane) {
23 
24  fRawHits = HitsInPlane;
25  fWeights.assign(fRawHits.size(),1.);
26  fBlow = 1;
27  fHitCovUpd = false;
28  fHitCoordUpd = false;
29 
30 }
31 
32 GFAbsRecoHit* GFDafHit::getHit(unsigned int ihit) {
33 
34  return fRawHits.at(ihit);
35 
36 }
37 
38 void GFDafHit::setBlowUp(double blow_up) {
39 
40  fBlow = blow_up;
41  fHitCovUpd = false;
42  fHitCoordUpd = false;
43 
44 }
45 
46 void GFDafHit::setWeights(std::vector<double> weights) {
47 
48  fWeights = weights;
49  fHitCovUpd = false;
50  fHitCoordUpd = false;
51 
52 }
53 
55 
56  return fRawHits.at(0)->getDetPlane(rep);
57 
58 }
59 
60 TMatrixT<double> GFDafHit::getHitCoord(const GFDetPlane& pl) {
61 
62  if(fHitCoordUpd && fPl == pl) return fHitCoord;
63 
64  if(fRawHits.size() == 1) {
65 
66  if(fHitCoord.GetNrows() ==0) fHitCoord.ResizeTo(fRawHits.at(0)->getHitCoord(pl));
67  fHitCoord = fRawHits.at(0)->getHitCoord(pl);
68 
69  } else {
70 
71  if(fHitCovUpd != true || fPl != pl) getHitCov(pl);
73  for(unsigned int i=0;i<fRawHits.size();i++) {
74 
75  fHitCoord += fWeights.at(i) * fCovInvs.at(i) * fRawHits.at(i)->getHitCoord(pl);
76 
77  }
78 
80  }
81 
82  fPl = pl;
83  fHitCoordUpd = true;
84  return fHitCoord;
85 
86 }
87 
88 TMatrixT<double> GFDafHit::getHitCov(const GFDetPlane& pl) {
89 
90  if(fHitCovUpd && fPl == pl) return fHitCov;
91 
92  if(fHitCov.GetNrows() == 0) {
93  fHitCov.ResizeTo(fRawHits.at(0)->getHitCov(pl));
94  fHitCoord.ResizeTo(fRawHits.at(0)->getHitCoord(pl));
95  }
96 
97  if(fRawHits.size() == 1) {
98 
99  if(((1/fWeights.at(0)) * fBlow) < pow(10,10)) {
100  fHitCov = (1 / fWeights.at(0)) * fBlow * fRawHits.at(0)->getHitCov(pl);
101  } else {
102  fHitCov = pow(10,10) * fRawHits.at(0)->getHitCov(pl);
103  }
104 
105  } else {
106 
107  fHitCov -= fHitCov;
108  fCovInvs.clear();
109 
110  for(unsigned int i=0;i<fRawHits.size();i++) {
111 
112  TMatrixT<double> CovInv;
113  GFTools::invertMatrix((fBlow * fRawHits.at(i)->getHitCov(pl)), CovInv);
114  fCovInvs.push_back(CovInv);
115  fHitCov += fWeights.at(i) * CovInv;
116  }
117 
118  TMatrixT<double> HitCovTemp(fHitCov);
119  GFTools::invertMatrix(HitCovTemp, fHitCov);
120 
121  }
122 
123  fPl = pl;
124  fHitCovUpd = true;
125  return fHitCov;
126 
127 }
128 
129 TMatrixT<double> GFDafHit::getHMatrix(const GFAbsTrackRep* rep) {
130 
131  return fRawHits.at(0)->getHMatrix(rep);
132 
133 }
134 
136 
137  GFDafHit* retval = new GFDafHit(fRawHits);
138  retval->setWeights(fWeights);
139  retval->setBlowUp(fBlow);
140  return retval;
141 
142 }
143 
144 const std::string& GFDafHit::getPolicyName(){
145 
146  return fRawHits.at(0)->getPolicyName();
147 
148 }
149 
TMatrixT< double > getHitCov(const GFDetPlane &pl)
Get the hit covariance.
Definition: GFDafHit.cxx:88
Base Class for genfit track representations. Defines interface for track parameterizations.
Definition: GFAbsTrackRep.h:80
TMatrixT< double > getHMatrix(const GFAbsTrackRep *rep)
Get the H matrix.
Definition: GFDafHit.cxx:129
bool fHitCovUpd
Definition: GFDafHit.h:135
GFDafHit * clone()
Get clone of this object.
Definition: GFDafHit.cxx:135
Int_t i
Definition: run_full.C:25
Detector plane genfit geometry class.
Definition: GFDetPlane.h:59
TMatrixT< double > fHitCoord
Vector of raw coordinates of hit.
Definition: GFAbsRecoHit.h:76
void setWeights(std::vector< double > weights)
Set the weights.
Definition: GFDafHit.cxx:46
GFAbsRecoHit * getHit(unsigned int ihit)
Get at hit from the GFDafHit.
Definition: GFDafHit.cxx:32
GFDetPlane fPl
Definition: GFDafHit.h:136
std::vector< double > fWeights
Definition: GFDafHit.h:140
Wrapper class for use with GFDaf.
Definition: GFDafHit.h:40
void setBlowUp(double blow_up)
Set the blow up factor for the covariance matrices.
Definition: GFDafHit.cxx:38
void invertMatrix(const TMatrixT< double > &mat, TMatrixT< double > &inv)
Invert a matrix, throwing GFException when inversion fails.
Definition: GFTools.cxx:334
const std::string & getPolicyName()
Get the name of the hit policy.
Definition: GFDafHit.cxx:144
double fBlow
Definition: GFDafHit.h:137
bool fHitCoordUpd
Definition: GFDafHit.h:135
Base Class for representing a Hit in GENFIT.
Definition: GFAbsRecoHit.h:73
const GFDetPlane & getDetPlane(GFAbsTrackRep *rep)
Get the detector plane.
Definition: GFDafHit.cxx:54
std::vector< GFAbsRecoHit * > fRawHits
Definition: GFDafHit.h:139
GFDafHit()
Definition: GFDafHit.h:43
ClassImp(PndAnaContFact)
std::vector< TMatrixT< double > > fCovInvs
Definition: GFDafHit.h:138
TMatrixT< double > getHitCoord(const GFDetPlane &pl)
Get the hit coordinates.
Definition: GFDafHit.cxx:60
TMatrixT< double > fHitCov
Covariance of raw hit coordinates.
Definition: GFAbsRecoHit.h:79