ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtMCTrack.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 // -------------------------------------------------------------------------
10 // ----- AtMCTrack source file -----
11 // ----- M. Al-Turany June 2014 -----
12 // ----- This is a light weight particle class that is saved to disk
13 // ----- instead of saveing the TParticle class
14 // ----- IT is also used for filtring the stack
15 // -------------------------------------------------------------------------
16 
17 #include "AtMCTrack.h"
18 
19 #include <FairLogger.h>
20 
21 #include <Rtypes.h>
22 #include <TDatabasePDG.h> // for TDatabasePDG
23 #include <TMath.h>
24 #include <TObject.h>
25 #include <TParticle.h> // for TParticle
26 #include <TParticlePDG.h> // for TParticlePDG
27 
28 #include <memory>
29 
30 // ----- Default constructor -------------------------------------------
32  : TObject(), fPdgCode(0), fMotherId(-1), fPx(0.), fPy(0.), fPz(0.), fStartX(0.), fStartY(0.), fStartZ(0.),
33  fStartT(0.), fNPoints(0)
34 {
35 }
36 // -------------------------------------------------------------------------
37 
38 // ----- Standard constructor ------------------------------------------
39 AtMCTrack::AtMCTrack(Int_t pdgCode, Int_t motherId, Double_t px, Double_t py, Double_t pz, Double_t x, Double_t y,
40  Double_t z, Double_t t, Int_t nPoints = 0)
41  : TObject(), fPdgCode(pdgCode), fMotherId(motherId), fPx(px), fPy(py), fPz(pz), fStartX(x), fStartY(y), fStartZ(z),
42  fStartT(t), fNPoints(nPoints)
43 {
44 }
45 // -------------------------------------------------------------------------
46 
47 // ----- Copy constructor ----------------------------------------------
48 AtMCTrack::AtMCTrack(const AtMCTrack &track)
49 
50  = default;
51 // -------------------------------------------------------------------------
52 
53 // ----- Constructor from TParticle ------------------------------------
54 AtMCTrack::AtMCTrack(TParticle *part)
55  : TObject(), fPdgCode(part->GetPdgCode()), fMotherId(part->GetMother(0)), fPx(part->Px()), fPy(part->Py()),
56  fPz(part->Pz()), fStartX(part->Vx()), fStartY(part->Vy()), fStartZ(part->Vz()), fStartT(part->T() * 1e09),
57  fNPoints(0)
58 {
59 }
60 // -------------------------------------------------------------------------
61 
62 // ----- Destructor ----------------------------------------------------
63 AtMCTrack::~AtMCTrack() = default;
64 // -------------------------------------------------------------------------
65 
66 // ----- Public method Print -------------------------------------------
67 void AtMCTrack::Print(Int_t trackId) const
68 {
69  LOG(DEBUG) << "Track " << trackId << ", mother : " << fMotherId << ", Type " << fPdgCode << ", momentum (" << fPx
70  << ", " << fPy << ", " << fPz << ") GeV";
71  /* LOG(DEBUG2) << " Ref " << GetNPoints(kREF)
72  << ", TutDet " << GetNPoints(kTutDet)
73  << ", Rutherford " << GetNPoints(kFairRutherford)
74  ;
75  */
76 }
77 // -------------------------------------------------------------------------
78 
79 // ----- Public method GetMass -----------------------------------------
80 Double_t AtMCTrack::GetMass() const
81 {
82  if (TDatabasePDG::Instance()) {
83  TParticlePDG *particle = TDatabasePDG::Instance()->GetParticle(fPdgCode);
84  if (particle) {
85  return particle->Mass();
86  } else {
87  return 0.;
88  }
89  }
90  return 0.;
91 }
92 // -------------------------------------------------------------------------
93 
94 // ----- Public method GetRapidity -------------------------------------
95 Double_t AtMCTrack::GetRapidity() const
96 {
97  Double_t e = GetEnergy();
98  Double_t y = 0.5 * TMath::Log((e + fPz) / (e - fPz));
99  return y;
100 }
101 // -------------------------------------------------------------------------
102 
ClassImp
ClassImp(AtFindVertex)
AtMCTrack::AtMCTrack
AtMCTrack()
Definition: AtMCTrack.cxx:31
y
const double * y
Definition: lmcurve.cxx:20
AtMCTrack::~AtMCTrack
virtual ~AtMCTrack()
AtMCTrack::GetMass
Double_t GetMass() const
Definition: AtMCTrack.cxx:80
AtMCTrack
Definition: AtMCTrack.h:34
AtMCTrack::GetEnergy
Double_t GetEnergy() const
Definition: AtMCTrack.h:113
AtMCTrack::GetRapidity
Double_t GetRapidity() const
Definition: AtMCTrack.cxx:95
AtMCTrack::Print
void Print(Int_t iTrack=0) const
Definition: AtMCTrack.cxx:67
AtMCTrack.h