CbmRoot
CbmAnaJpsiUtils.h
Go to the documentation of this file.
1 
2 #ifndef CBM_ANA_JPSI_UTILS_H
3 #define CBM_ANA_JPSI_UTILS_H
4 
5 #include "CbmAnaJpsiCandidate.h"
6 
7 #include "CbmKFVertex.h"
8 #include "CbmL1PFFitter.h"
9 #include "CbmMCTrack.h"
10 #include "CbmStsTrack.h"
11 #include "L1Field.h"
12 
13 #include "TDatabasePDG.h"
14 #include "TMCProcess.h"
15 #include "TClonesArray.h"
16 
17 #include <vector>
18 
20 public:
21  /*
22  * Calculates and set track parameters to CbmAnaJpsiCandidate.
23  * The following parameters are set: fChi2sts, fChi2Prim, fPosition, fMomentum, fMass, fCharge, fEnergy, fRapidity
24  */
26  CbmStsTrack* stsTrack,
27  CbmKFVertex& kfVertex) {
28  CbmL1PFFitter fPFFitter;
29  std::vector<CbmStsTrack> stsTracks;
30  stsTracks.resize(1);
31  stsTracks[0] = *stsTrack;
32  std::vector<L1FieldRegion> vField;
33  std::vector<float> chiPrim;
34  fPFFitter.GetChiToVertex(stsTracks, vField, chiPrim, kfVertex, 3e6);
35  cand->fChi2sts = stsTracks[0].GetChiSq() / stsTracks[0].GetNDF();
36  cand->fChi2Prim = chiPrim[0];
37 
38  const FairTrackParam* vtxTrack = stsTracks[0].GetParamFirst();
39 
40  vtxTrack->Position(cand->fPosition);
41  vtxTrack->Momentum(cand->fMomentum);
42 
43  cand->fMass = TDatabasePDG::Instance()->GetParticle(11)->Mass();
44  cand->fCharge = (vtxTrack->GetQp() > 0) ? 1 : -1;
45  cand->fEnergy = sqrt(cand->fMomentum.Mag2() + cand->fMass * cand->fMass);
46  cand->fRapidity = 0.5
47  * TMath::Log((cand->fEnergy + cand->fMomentum.Z())
48  / (cand->fEnergy - cand->fMomentum.Z()));
49  }
50 
51  /*
52  * \brief Return true if MC track is signal primary electron.
53  */
54  static Bool_t IsMcSignalElectron(CbmMCTrack* mctrack) {
55  if (mctrack == NULL) return false;
56  Int_t pdg = TMath::Abs(mctrack->GetPdgCode());
57  if (mctrack->GetGeantProcessId() == kPPrimary && pdg == 11) return true;
58  return false;
59  }
60 
61  /*
62  * \brief Return true if MC track is electron from gamma conversion.
63  */
64  static Bool_t IsMcGammaElectron(CbmMCTrack* mctrack, TClonesArray* mcTracks) {
65  if (mctrack == NULL) return false;
66  Int_t pdg = TMath::Abs(mctrack->GetPdgCode());
67  if (pdg != 11) return false;
68  Int_t motherId = mctrack->GetMotherId();
69  if (motherId < 0) {
70  return false;
71  } else {
72  CbmMCTrack* mct1 = static_cast<CbmMCTrack*>(mcTracks->At(motherId));
73  Int_t motherPdg = mct1->GetPdgCode();
74  if (mct1 != NULL && motherPdg == 22 && pdg == 11) { return true; }
75  }
76  return false;
77  }
78 
79  /*
80  * \brief Return true if MC track is electron from Pi0 dalitz decay.
81  */
82  static Bool_t IsMcPi0Electron(CbmMCTrack* mctrack, TClonesArray* mcTracks) {
83  if (mctrack == NULL) return false;
84  Int_t pdg = TMath::Abs(mctrack->GetPdgCode());
85  if (pdg != 11) return false;
86  Int_t motherId = mctrack->GetMotherId();
87  if (motherId < 0) {
88  return false;
89  } else {
90  CbmMCTrack* mct1 = static_cast<CbmMCTrack*>(mcTracks->At(motherId));
91  Int_t motherPdg = mct1->GetPdgCode();
92  if (mct1 != NULL && motherPdg == 111 && pdg == 11) { return true; }
93  }
94  return false;
95  }
96 };
97 
98 #endif
CbmMCTrack::GetMotherId
Int_t GetMotherId() const
Definition: CbmMCTrack.h:71
CbmAnaJpsiUtils::CalculateAndSetTrackParamsToCandidate
static void CalculateAndSetTrackParamsToCandidate(CbmAnaJpsiCandidate *cand, CbmStsTrack *stsTrack, CbmKFVertex &kfVertex)
Definition: CbmAnaJpsiUtils.h:25
CbmAnaJpsiUtils
Definition: CbmAnaJpsiUtils.h:19
L1Field.h
CbmL1PFFitter
Definition: CbmL1PFFitter.h:31
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
CbmAnaJpsiCandidate::fEnergy
Double_t fEnergy
Definition: CbmAnaJpsiCandidate.h:53
CbmAnaJpsiUtils::IsMcGammaElectron
static Bool_t IsMcGammaElectron(CbmMCTrack *mctrack, TClonesArray *mcTracks)
Definition: CbmAnaJpsiUtils.h:64
CbmMCTrack::GetPdgCode
Int_t GetPdgCode() const
Definition: CbmMCTrack.h:70
CbmAnaJpsiCandidate
Definition: CbmAnaJpsiCandidate.h:8
CbmStsTrack.h
Data class for STS tracks.
CbmL1PFFitter::GetChiToVertex
void GetChiToVertex(std::vector< CbmStsTrack > &Tracks, std::vector< L1FieldRegion > &field, std::vector< float > &chiToVtx, CbmKFVertex &primVtx, float chiPrim=-1)
Definition: CbmL1PFFitter.cxx:403
mcTracks
static vector< vector< QAMCTrack > > mcTracks
Definition: CbmTofHitFinderTBQA.cxx:112
CbmL1PFFitter.h
CbmMCTrack::GetGeantProcessId
UInt_t GetGeantProcessId() const
Definition: CbmMCTrack.h:69
CbmAnaJpsiCandidate::fRapidity
Double_t fRapidity
Definition: CbmAnaJpsiCandidate.h:54
CbmAnaJpsiCandidate::fMomentum
TVector3 fMomentum
Definition: CbmAnaJpsiCandidate.h:51
CbmAnaJpsiCandidate::fChi2Prim
Double_t fChi2Prim
Definition: CbmAnaJpsiCandidate.h:56
CbmMCTrack.h
CbmAnaJpsiCandidate::fCharge
Int_t fCharge
Definition: CbmAnaJpsiCandidate.h:55
CbmMCTrack
Definition: CbmMCTrack.h:34
CbmAnaJpsiCandidate::fMass
Double_t fMass
Definition: CbmAnaJpsiCandidate.h:52
CbmAnaJpsiUtils::IsMcSignalElectron
static Bool_t IsMcSignalElectron(CbmMCTrack *mctrack)
Definition: CbmAnaJpsiUtils.h:54
CbmAnaJpsiCandidate.h
CbmAnaJpsiCandidate::fPosition
TVector3 fPosition
Definition: CbmAnaJpsiCandidate.h:50
CbmStsTrack
Definition: CbmStsTrack.h:37
CbmAnaJpsiUtils::IsMcPi0Electron
static Bool_t IsMcPi0Electron(CbmMCTrack *mctrack, TClonesArray *mcTracks)
Definition: CbmAnaJpsiUtils.h:82
CbmKFVertex.h
CbmKFVertex
Definition: CbmKFVertex.h:6
CbmAnaJpsiCandidate::fChi2sts
Double_t fChi2sts
Definition: CbmAnaJpsiCandidate.h:57