FairRoot/PandaRoot
Functions
PndGenfitAdapters2.cxx File Reference
#include "PndGenfitAdapters2.h"
#include <iostream>
#include "PndTrack.h"
#include "PndTrackCand.h"
#include "FairTrackParP.h"
#include "AbsTrackRep.h"
#include "DetPlane.h"
#include "Exception.h"
#include "RKTrackRep.h"
#include "SharedPlanePtr.h"
#include "Track.h"
#include "TrackCand.h"
#include <TMatrixD.h>
#include <TMatrixDSym.h>
#include <cmath>

Go to the source code of this file.

Functions

PndTrackCandGenfit2TrackCand2PndTrackCand (const genfit::TrackCand *cand)
 
genfit::TrackCandPndTrackCand2Genfit2TrackCand (PndTrackCand *cand)
 
PndTrackGenfit2Track2PndTrack (const genfit::Track *tr)
 

Function Documentation

PndTrack* Genfit2Track2PndTrack ( const genfit::Track tr)

Definition at line 60 of file PndGenfitAdapters2.cxx.

References genfit::Track::constructTrackCand(), count, Genfit2TrackCand2PndTrackCand(), genfit::StateOnPlane::getAuxInfo(), genfit::Track::getCardinalRep(), genfit::FitStatus::getChi2(), genfit::MeasuredStateOnPlane::getCov(), genfit::Track::getFitStatus(), genfit::Track::getFittedState(), genfit::FitStatus::getNdf(), genfit::StateOnPlane::getPlane(), genfit::StateOnPlane::getState(), i, genfit::FitStatus::isFitConverged(), PndTrack::SetChi2(), PndTrack::SetFlag(), and PndTrack::SetNDF().

Referenced by PndRecoDafFit2::Fit(), and PndRecoKalmanFit2::Fit().

60  {
61 
62  if (dynamic_cast<genfit::RKTrackRep*>(tr->getCardinalRep())==NULL) {
63  std::cerr << " GenfitAbsTrackRep2PndTrack() can currently only handle RKTrackRep" << std::endl;
64  throw;
65  }
66 
67  const TVectorD& firstState = tr->getFittedState().getState();
68  const TVectorD& lastState = tr->getFittedState(-1).getState();
69  const TMatrixDSym& firstCov = tr->getFittedState().getCov();
70  const TMatrixDSym& lastCov = tr->getFittedState(-1).getCov();
71  genfit::SharedPlanePtr firstPlane = tr->getFittedState().getPlane();
72  genfit::SharedPlanePtr lastPlane = tr->getFittedState(-1).getPlane();
73 
74  //make the FairTrackParP for first and last hit
75  double firstCova[15];
76  int count=0;
77  for(int i=0; i<5;++i){
78  for(int j=i;j<5;++j){
79  firstCova[count++]=firstCov(i,j);
80  }
81  }
82  double lastCova[15];
83  count=0;
84  for(int i=0; i<5;++i){
85  for(int j=i;j<5;++j){
86  lastCova[count++]=lastCov(i,j);
87  }
88  }
89 
90  double first_spu = (tr->getFittedState().getAuxInfo())(0);
91  double last_spu = (tr->getFittedState(-1).getAuxInfo())(0);
92 
93  FairTrackParP first(firstState[3],firstState[4],firstState[1],firstState[2],firstState[0],firstCova,firstPlane->getO(),firstPlane->getU(),firstPlane->getV(),first_spu);
94  FairTrackParP last(lastState[3],lastState[4],lastState[1],lastState[2],lastState[0],lastCova,lastPlane->getO(),lastPlane->getU(),lastPlane->getV(),last_spu);
95 
96  //copy the trackCand
97  genfit::TrackCand* genfitCand = tr->constructTrackCand();
98  PndTrackCand* pndCand = Genfit2TrackCand2PndTrackCand(genfitCand);
99  PndTrack* retVal = new PndTrack(first,last,*pndCand);
100  retVal->SetChi2(tr->getFitStatus()->getChi2());
101  retVal->SetNDF(tr->getFitStatus()->getNdf());
102  if (tr->getFitStatus()->isFitConverged()) {
103  retVal->SetFlag(1);
104  }
105  else {
106  retVal->SetFlag(-1);
107  }
108  delete genfitCand;
109  delete pndCand;
110  return retVal;
111 
112 }
Track candidate – seed values and indices.
Definition: TrackCand.h:69
boost::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
Int_t i
Definition: run_full.C:25
double getChi2() const
Get chi^2 of the fit.
Definition: FitStatus.h:118
void SetChi2(Double_t d)
Definition: PndTrack.h:39
const TMatrixDSym & getCov() const
const TVectorD & getAuxInfo() const
Definition: StateOnPlane.h:62
PndTrackCand * Genfit2TrackCand2PndTrackCand(const genfit::TrackCand *cand)
double getNdf() const
Get the degrees of freedom of the fit.
Definition: FitStatus.h:120
bool isFitConverged(bool inAllPoints=true) const
Did the fit converge (in all Points or only partially)?
Definition: FitStatus.h:105
FitStatus * getFitStatus(const AbsTrackRep *rep=NULL) const
Get FitStatus for a AbsTrackRep. Per default, return FitStatus for cardinalRep.
Definition: Track.h:150
AbsTrackRep * getCardinalRep() const
Get cardinal track representation.
Definition: Track.h:141
TrackCand * constructTrackCand() const
Construct a new TrackCand containing the hit IDs of the measurements.
void SetFlag(Int_t i)
Definition: PndTrack.h:38
void SetNDF(Int_t i)
Definition: PndTrack.h:40
int count
const MeasuredStateOnPlane & getFittedState(int id=0, const AbsTrackRep *rep=NULL, bool biased=true) const
Shortcut to get FittedStates.
const TVectorD & getState() const
Definition: StateOnPlane.h:60
const SharedPlanePtr & getPlane() const
Definition: StateOnPlane.h:64
PndTrackCand* Genfit2TrackCand2PndTrackCand ( const genfit::TrackCand cand)

Definition at line 24 of file PndGenfitAdapters2.cxx.

References PndTrackCand::AddHit(), genfit::TrackCand::getHit(), genfit::TrackCand::getMcTrackId(), genfit::TrackCand::getNHits(), i, nhits, and PndTrackCand::setMcTrackId().

Referenced by Genfit2Track2PndTrack().

25 {
26  // Utility to convert from genfit TrackCand to PndTrackCand.
27  // Since PndTrackCand does not store any seed value, those componets
28  // will not be present in the final object.
29 
30  PndTrackCand* retVal = new PndTrackCand();
31  const unsigned nhits = cand->getNHits();
32  int detId,hitId;
33  double rho;
34  for(unsigned int i=0;i<nhits;++i){
35  cand->getHit(i,detId,hitId,rho);//
36  retVal->AddHit(detId,hitId,rho);//
37  }
38 
39  retVal->setMcTrackId(cand->getMcTrackId());
40  return retVal;
41 }
TrackCandHit * getHit(int i) const
Int_t i
Definition: run_full.C:25
void setMcTrackId(int i)
Definition: PndTrackCand.h:72
void AddHit(UInt_t detId, UInt_t hitId, Double_t rho)
unsigned int getNHits() const
Definition: TrackCand.h:103
int getMcTrackId() const
Get the MCT track id, for MC simulations - default value = -1.
Definition: TrackCand.h:119
genfit::TrackCand* PndTrackCand2Genfit2TrackCand ( PndTrackCand cand)

Definition at line 43 of file PndGenfitAdapters2.cxx.

References genfit::TrackCand::addHit(), PndTrackCandHit::GetDetId(), PndTrackCandHit::GetHitId(), PndTrackCand::getMcTrackId(), PndTrackCand::GetNHits(), PndTrackCandHit::GetRho(), PndTrackCand::GetSortedHit(), i, nhits, and genfit::TrackCand::setMcTrackId().

Referenced by PndRecoDafFit2::Fit(), and PndRecoKalmanFit2::Fit().

44 {
45  // Utility to convert from PndTrackCand to genfit TrackCand.
46  // PndTrackCand does not store any Seed, then to create a proper TrackCand you need
47  // to fill the seed afterwards taking the values from the PndTrack
48 
49  genfit::TrackCand* retVal = new genfit::TrackCand();
50  unsigned int nhits = cand->GetNHits();
51  for(unsigned int i=0;i<nhits;++i){
52  PndTrackCandHit candHit = cand->GetSortedHit(i);
53  retVal->addHit(candHit.GetDetId(),candHit.GetHitId(),i,candHit.GetRho());
54  }
55 
56  retVal->setMcTrackId(cand->getMcTrackId());
57  return retVal;
58 }
Track candidate – seed values and indices.
Definition: TrackCand.h:69
int getMcTrackId() const
Definition: PndTrackCand.h:60
Int_t i
Definition: run_full.C:25
void addHit(int detId, int hitId, int planeId=-1, double sortingParameter=0)
PndTrackCandHit GetSortedHit(UInt_t i)
Definition: PndTrackCand.h:54
Double_t GetRho() const
UInt_t GetNHits() const
Definition: PndTrackCand.h:59
Int_t GetHitId() const
void setMcTrackId(int i)
Set the MCT track id, for MC simulations.
Definition: TrackCand.h:151
Int_t GetDetId() const