FairRoot/PandaRoot
PndPidMvdInfo.cxx
Go to the documentation of this file.
1 #include "PndDetectorList.h"
2 #include "PndPidCorrelator.h"
3 #include "PndPidCandidate.h"
4 #include "PndTrack.h"
5 #include "PndTrackID.h"
6 #include "PndSdsHit.h"
7 
8 #include "FairTrackParH.h"
9 #include "FairMCApplication.h"
10 #include "FairRunAna.h"
11 #include "FairRootManager.h"
12 #include "FairRuntimeDb.h"
13 
14 #include "TObjArray.h"
15 #include "TVector3.h"
16 #include "TGeoMatrix.h"
17 #include "TGeoBBox.h"
18 #include "TGeoManager.h"
19 
20 #include <cmath>
21 
22 #include "PndPidCorrelator.h"
23 //_________________________________________________________________
25 {
26  Float_t mvdELoss = 0.; // total energy lost in MVD;
27  Float_t mvdPath = 0.; // total thickness crossed in MVD
28  Int_t mvdCounts = 0;
29  Float_t SensorThickness=0;
30  PndTrackCand trackCand = track->GetTrackCand();
31  FairTrackParP par = track->GetParamFirst();
32  Int_t ierr = 0;
33  FairTrackParH *helix = new FairTrackParH(&par, ierr); // This will be used for propagation
34 
35  for (size_t ii=0; ii<trackCand.GetNHits(); ii++)
36  {
37  PndSdsHit *mvdHit = NULL;
38  PndTrackCandHit candHit = trackCand.GetSortedHit(ii);
39  if (fMixMode==kFALSE)
40  if ( (candHit.GetDetId()!=FairRootManager::Instance()->GetBranchId("MVDHitsPixel")) && (candHit.GetDetId()!=FairRootManager::Instance()->GetBranchId("MVDHitsStrip")) ) continue;
41  if (fMixMode==kTRUE)
42  if ( (candHit.GetDetId()!=FairRootManager::Instance()->GetBranchId("MVDHitsPixelMix")) && (candHit.GetDetId()!=FairRootManager::Instance()->GetBranchId("MVDHitsStripMix")) ) continue;
43 
44  if ( (candHit.GetDetId()==FairRootManager::Instance()->GetBranchId("MVDHitsPixel") && !fMixMode) ||
45  (candHit.GetDetId()==FairRootManager::Instance()->GetBranchId("MVDHitsPixelMix") && fMixMode) )
46  mvdHit = (PndSdsHit*)fMvdHitsPixel->At(candHit.GetHitId());
47  if ( (candHit.GetDetId()==FairRootManager::Instance()->GetBranchId("MVDHitsStrip") && !fMixMode) ||
48  (candHit.GetDetId()==FairRootManager::Instance()->GetBranchId("MVDHitsStripMix") && fMixMode))
49  mvdHit = (PndSdsHit*)fMvdHitsStrip->At(candHit.GetHitId());
50  if (mvdHit==0) continue;
51  TVector3 mvdPos;
52  mvdHit->Position(mvdPos);
53  mvdCounts++;
54  if (fFast) continue;
55  TVector3 SensorDim=fGeoH->GetSensorDimensionsShortId(mvdHit->GetSensorID());//sensor dimension
56  SensorThickness = SensorDim.Z();
57 
58  TGeoHMatrix *matrix = fGeoH->GetMatrixPath(fGeoH->GetPath(mvdHit->GetSensorID()));
59  const Double_t *rotM = matrix->GetRotationMatrix();
60  TVector3 zaxis(rotM[2], rotM[5], rotM[8]); // Z axis in the detector frame
61  TVector3 momentum(0., 0., 0.);
62 
63  Double_t cos = 0.;
64  if (ii==0) // If the MVD hit is the first, no need of propagation
65  {
66  cos = TMath::Cos(helix->GetMomentum().Angle(zaxis));
67  }
68  else
69  {
70  if (fGeanePro)
71  {
72  fGeanePropagator->SetPoint(mvdPos);
73  fGeanePropagator->PropagateToPCA(1, 1);
74  FairTrackParH *fRes= new FairTrackParH();
75  Bool_t rc = fGeanePropagator->Propagate(helix, fRes, fPidHyp*pidCand->GetCharge()); // First propagation at module
76  if (rc)
77  {
78  cos = TMath::Cos(fRes->GetMomentum().Angle(zaxis));
79  helix = fRes; //updates of helix params to propagate from the pervious hit to the next one
80  }
81  else
82  {
83  cos = 0.;
84  }
85  }
86  } // end of "if (ii==0) else"
87 
88  Float_t thickness = 0.; //projection of the momentum on the zaxis of the detector frame
89 
90  if (fabs(cos)<0.000001)
91  {
92  std::cout << "-W- PndPidCorrelator::GetMvdInfo: Track perpendicular to MVD strip/pixel! Not added to MVD eloss" << std::endl;
93  }
94  else
95  {
96  thickness = SensorThickness*2./fabs(cos);
97  mvdELoss += mvdHit->GetEloss();
98  mvdPath += thickness;
99  fMvdHitCount++;
100  }
101  if (fVerbose>1) std::cout << mvdHit->GetSensorID() << "\t" << mvdHit->GetEloss() << "\t" << thickness << std::endl;
102  }
103 
104  if (mvdPath>0.) pidCand->SetMvdDEDX(mvdELoss/mvdPath);
105  pidCand->SetMvdHits(mvdCounts);
106 
107  return kTRUE;
108 }
109 
int fVerbose
Definition: poormantracks.C:24
Int_t GetCharge() const
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
TGeoHMatrix * GetMatrixPath(TString path)
Bool_t GetMvdInfo(PndTrack *track, PndPidCandidate *pid)
PndTrackCandHit GetSortedHit(UInt_t i)
Definition: PndTrackCand.h:54
Double_t par[3]
void SetMvdHits(Int_t val)
Double_t GetEloss() const
Definition: PndSdsHit.h:97
Double_t thickness
static T Cos(const T &x)
Definition: PndCAMath.h:43
TString GetPath(Int_t shortID)
for a given shortID the path is returned
TVector3 GetSensorDimensionsShortId(Int_t shortId)
PndTrackCand GetTrackCand()
Definition: PndTrack.h:47
Double_t
TClonesArray * fMvdHitsPixel
PndSdsHit TCA for strip.
PndMCTrack * track
Definition: anaLmdCluster.C:89
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
FairGeanePro * fGeanePropagator
Refitter for MDT tracks.
TClonesArray * fMvdHitsStrip
PndTrack TCA for MDT refit.
UInt_t GetNHits() const
Definition: PndTrackCand.h:59
ClassImp(PndAnaContFact)
Int_t GetSensorID() const
Definition: PndSdsHit.h:90
Int_t GetHitId() const
PndGeoHandling * fGeoH
Int_t GetDetId() const
FairTrackParP GetParamFirst()
Definition: PndTrack.h:49
void SetMvdDEDX(Double_t val)