29 #include "TGeant3/TGeant3.h" 30 #include "TDatabasePDG.h" 43 const TVector3& poserr,
44 const TVector3& momerr,
51 fCharge=TDatabasePDG::Instance()->GetParticle(
fPdg)->Charge()/3.;
61 TVector3
w=u.Cross(v);
84 fCov[3][3] = poserr.X()*poserr.X() * u.X()*u.X() +
85 poserr.Y()*poserr.Y() * u.Y()*u.Y() +
86 poserr.Z()*poserr.Z() * u.Z()*u.Z();
87 fCov[4][4] = poserr.X()*poserr.X() * v.X()*v.X() +
88 poserr.Y()*poserr.Y() * v.Y()*v.Y() +
89 poserr.Z()*poserr.Z() * v.Z()*v.Z();
91 (mom.X()*mom.X() * momerr.X()*momerr.X()+
92 mom.Y()*mom.Y() * momerr.Y()*momerr.Y()+
93 mom.Z()*mom.Z() * momerr.Z()*momerr.Z());
94 fCov[1][1] = pow((u.X()/pw - w.X()*pu/(pw*pw)),2.)*momerr.X()*momerr.X() +
95 pow((u.Y()/pw - w.Y()*pu/(pw*pw)),2.)*momerr.Y()*momerr.Y() +
96 pow((u.Z()/pw - w.Z()*pu/(pw*pw)),2.)*momerr.Z()*momerr.Z();
97 fCov[2][2] = pow((v.X()/pw - w.X()*pv/(pw*pw)),2.)*momerr.X()*momerr.X() +
98 pow((v.Y()/pw - w.Y()*pv/(pw*pw)),2.)*momerr.Y()*momerr.Y() +
99 pow((v.Z()/pw - w.Z()*pv/(pw*pw)),2.)*momerr.Z()*momerr.Z();
115 TMatrixT<Double_t>& statePred)
117 TMatrixT<Double_t> covPred(6,6);
125 TMatrixT<Double_t>& statePred,
126 TMatrixT<Double_t>& covPred)
129 throw GFException(
"GEANE propagation not possible for p.theta<THETACUT",__LINE__,__FILE__).
setFatal();
132 TGeant3 *gMC3 = (TGeant3*) gMC;
134 throw GFException(
"GeaneTrackRep2: TGeant3 has not been initialized.",__LINE__,__FILE__).
setFatal();
138 TVector3 oto=pl.
getO();TVector3 uto=pl.
getU();TVector3 vto=pl.
getV();
141 TVector3 wfrom=ufrom.Cross(vfrom);;
144 pli[0]=ufrom.X();pli[1]=ufrom.Y();pli[2]=ufrom.Z();pli[3]=vfrom.X();pli[4]=vfrom.Y();pli[5]=vfrom.Z();
147 plf[0]=uto.X();plf[1]=uto.Y();plf[2]=uto.Z();plf[3]=vto.X();plf[4]=vto.Y();plf[5]=vto.Z();plf[6]=oto.X();plf[7]=oto.Y();plf[8]=oto.Z();
154 for(
int i=0; i<5;++i){
155 for(
int j=i;j<5;++j){
156 ein[count++]=
fCov[i][j];
164 gMC3->Eufilp(1, ein, pli, plf);
167 Float_t
x1[3];Float_t
x2[3];Float_t p1[3];Float_t p2[3];
169 x1vect = ofrom +
fState[3][0]*ufrom +
fState[4][0]*vfrom;
187 for(
unsigned int i=0;i<3;++i) {
195 GFException e(
"obsolete exception?: x2[0]<-1.E29",__LINE__,__FILE__);
199 if(fabs(p2[0])==0. && fabs(p2[1])==0. && fabs(p2[2])==0) {
200 GFException e(
"fabs(p2[0])==0. && fabs(p2[1])==0. && fabs(p2[2])==0",__LINE__,__FILE__);
204 double trklength = gMC3->TrackLength();
205 Ertrio_t *ertrio = gMC3->fErtrio;
208 Ertrio1_t *ertrio1 = gMC3->fErtrio1;
209 if(ertrio1->iertr != 0){
210 GFException e(
"GEANE error flag for numerical divergence detected",__LINE__,__FILE__);
218 for(Int_t i=0;i<15;i++) {
219 cov15[i]=ertrio->errout[i];
221 if(i == 0) cov15[i] = cov15[i] * fCharge *
fCharge;
222 if(i > 0 && i < 5) cov15[i] = cov15[i] *
fCharge;
226 for(
int i=0;i<5;++i){
227 for(
int j=i;j<5;++j){
228 covPred[i][j]=cov15[count];
229 if(i!=j)covPred[j][i]=cov15[count];
233 TVector3
d(x2[0]-oto.X(),x2[1]-oto.Y(),x2[2]-oto.Z());
234 statePred[3][0] =
d*uto;
235 statePred[4][0] =
d*vto;
236 TVector3 p2vect(p2[0],p2[1],p2[2]);
237 statePred[0][0] = fCharge/p2vect.Mag();
241 pw = p2vect*(uto.Cross(vto));
244 GFException exc(
"fabs(pw)<1.e-10",__LINE__,__FILE__);
250 statePred[1][0] = pu/fabs(pw);
251 statePred[2][0] = pv/fabs(pw);
255 statePred[1][0] = -1.*pu/fabs(pw);
256 statePred[2][0] = -1.*pv/fabs(pw);
267 GFException exc(
"GEANE propagation not possible for p.theta<THETACUT",__LINE__,__FILE__);
272 TGeant3 *gMC3 = (TGeant3*) gMC;
274 std::cerr <<
"GeaneTrackRep2: TGeant3 has not been initialized. -> abort" 281 nullVec[0]=0.; nullVec[1]=0.; nullVec[2]=0.;
285 gMC3->SetClose(1,posArr,999,nullVec,nullVec,nullVec,nullVec,nullVec,nullVec);
290 for(
int i=0; i<5;++i){
291 for(
int j=i;j<5;++j){
292 ein[count++]=
fCov[i][j];
308 for(
unsigned int i=0;i<3;++i){
309 x2[i]=0.;p2[i]=0.;po1[i]=0.;po2[i]=0.;po3[i]=0.;clen[i]=0.;
313 Float_t maxlen[1] = {(float)(2.*((mypos-pos).Mag()))};
314 gMC3->Eufill(1, ein, maxlen);
327 gMC3->GetClose(po1,po2,po3,clen);
332 if((fabs(clen[0])<1.
E-8 && fabs(clen[1])<1.
E-8) ||
333 fabs(clen[0]-clen[1])<1.
E-8){
338 else if(fabs(clen[1]-clen[2])<1.
E-8){
343 TVector3 result12,result23;
346 if((result12-pos).Mag()<(result23-pos).Mag()){
348 if( (poV2-poca).Mag() > 0.25*(poV1-poV2).Mag() ){
357 if( (poV2-poca).Mag() > 0.25*(poV2-poV3).Mag() ){
450 const TVector3& point2,
453 TVector3& poca_onWire)
456 GFException exc(
"GEANE propagation not possible for p.theta<THETACUT",__LINE__,__FILE__);
461 TGeant3 *gMC3 = (TGeant3*) gMC;
463 std::cerr <<
"GeaneTrackRep2: TGeant3 has not been initialized. -> abort" 470 nullVec[0]=0.; nullVec[1]=0.; nullVec[2]=0.;
473 point1.GetXYZ(w1Arr);
474 point2.GetXYZ(w2Arr);
476 gMC3->SetClose(2,nullVec,999,w1Arr,w2Arr,nullVec,nullVec,nullVec,nullVec);
481 for(
int i=0; i<5;++i){
482 for(
int j=i;j<5;++j){
483 ein[count++]=
fCov[i][j];
499 for(
unsigned int i=0;i<3;++i){
500 x2[i]=0.;p2[i]=0.;po1[i]=0.;po2[i]=0.;po3[i]=0.;clen[i]=0.;
505 TVector3 pointOnWireClosestToMyPos;
506 poca2Line(point1,point2,mypos,pointOnWireClosestToMyPos);
508 Float_t maxlen[1] = {(float)(2.*((mypos-pointOnWireClosestToMyPos).Mag()))};
509 gMC3->Eufill(1, ein, maxlen);
522 gMC3->GetClose(po1,po2,po3,clen);
527 if((fabs(clen[0])<1.
E-8 && fabs(clen[1])<1.
E-8) ||
528 fabs(clen[0]-clen[1])<1.
E-8){
529 pocaLine2Line(poV2,poV3-poV2,point1,point2-point1,poca,poca_onWire);
532 else if(fabs(clen[1]-clen[2])<1.
E-8){
533 pocaLine2Line(poV1,poV2-poV1,point1,point2-point1,poca,poca_onWire);
537 TVector3 result12_1,result12_2,result23_1,result23_2;
538 pocaLine2Line(poV1,poV2-poV1,point1,point2-point1,result12_1,result12_2);
539 pocaLine2Line(poV2,poV3-poV2,point1,point2-point1,result23_1,result23_2);
540 if((result12_1-result12_2).Mag()<(result23_1-result23_2).Mag()){
542 poca_onWire = result12_2;
543 if( (poV2-poca).Mag() > 0.25*(poV1-poV2).Mag() ){
552 poca_onWire = result23_2;
553 if( (poV2-poca).Mag() > 0.25*(poV2-poV3).Mag() ){
568 TVector3 theWire = extr2-extr1;
569 if(theWire.Mag()<1.E-8){
570 GFException exc(
"GeaneTrackRep2::poca2Line(): try to find poca between line and point, but the line is really just a point",__LINE__,__FILE__);
573 double t = 1./(theWire*theWire)*(point*theWire+extr1*extr1-extr1*extr2);
574 result = extr1+t*theWire;
585 GFException exc(
"GeaneTrackRep2::pocaLine2Line(): lines are parallel",__LINE__,__FILE__);
588 double s = 1./(kl*kl-1)*(point2*k-point1*k-(point2*l-point1*l)*kl);
589 double t = (point2*l+s*kl-point1*l);
590 result1 = point1+t*l;
591 result2 = point2+s*k;
599 TMatrixT<Double_t> statePred(
fState);
601 return pl.
getO()+(statePred[3][0]*pl.
getU())+(statePred[4][0]*pl.
getV());
607 TMatrixT<Double_t> statePred(
fState);
612 TVector3 mom = statePred[5][0]*(pl.
getNormal()+statePred[1][0]*pl.
getU()+statePred[2][0]*pl.
getV());
613 mom.SetMag(1./fabs(statePred[0][0]));
619 TMatrixT<Double_t> statePred(
fState);
621 mom = statePred[5][0]*(pl.
getNormal()+statePred[1][0]*pl.
getU()+statePred[2][0]*pl.
getV());
622 mom.SetMag(1./fabs(statePred[0][0]));
623 pos = pl.
getO()+(statePred[3][0]*pl.
getU())+(statePred[4][0]*pl.
getV());
630 std::cerr<<
"insert brain here " << __FILE__ <<
" " << __LINE__
631 <<
" ->abort" <<std::endl;
Float_t x1[n_points_granero]
TVector3 dist(const TVector3 &point) const
unsigned int fDimension
Dimensionality of track representation.
Base Class for genfit track representations. Defines interface for track parameterizations.
TVector3 getNormal() const
TMatrixT< Double_t > fCov
The covariance matrix.
virtual double extrapolate(const GFDetPlane &, TMatrixT< Double_t > &statePred)
returns the tracklength spanned in this extrapolation
void poca2Line(const TVector3 &, const TVector3 &, const TVector3 &, TVector3 &)
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
GFException & setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
void extrapolateToLine(const TVector3 &point1, const TVector3 &point2, TVector3 &poca, TVector3 &normVec, TVector3 &poca_onwire)
This method extrapolates to the point of closest approach to a line.
void extrapolateToPoint(const TVector3 &pos, TVector3 &poca, TVector3 &normVec)
This method is to extrapolate the track to point of closest approach to a point in space...
TMatrixT< Double_t > fState
The vector of track parameters.
virtual void getPosMomCov(const GFDetPlane &pl, TVector3 &pos, TVector3 &mom, TMatrixT< Double_t > &cov)
method which gets position, momentum and 6x6 covariance matrix
void pocaLine2Line(const TVector3 &point1, const TVector3 &line1, const TVector3 &point2, const TVector3 &line2, TVector3 &result1, TVector3 &result2)
Float_t x2[n_points_geant4]
virtual void getPosMom(const GFDetPlane &, TVector3 &pos, TVector3 &mom)
virtual ~GeaneTrackRep2()