CbmRoot
NicaCbmMCTrack.cxx
Go to the documentation of this file.
1 /*
2  * NicaCbmMCTrack.cxx
3  *
4  * Created on: 20 wrz 2018
5  * Author: Daniel Wielanek
6  * E-mail: daniel.wielanek@gmail.com
7  * Warsaw University of Technology, Faculty of Physics
8  */
9 #include "NicaCbmMCTrack.h"
10 
11 #include <FairLogger.h>
12 
14 
15 void NicaCbmMCTrack::Update(CbmMCTrack* mc, Double_t charge) {
16  GetMomentum()->SetPxPyPzE(
17  mc->GetPx(), mc->GetPy(), mc->GetPz(), mc->GetEnergy());
18  SetMotherIndex(mc->GetMotherId());
19  if (GetMotherIndex() > -1) {
20  SetPrimary(kFALSE);
21  } else {
22  SetPrimary(kTRUE);
23  }
24  SetStatus(0);
25  SetCharge(charge);
26  SetPdg(mc->GetPdgCode());
27  GetStartPosition()->SetXYZT(
28  mc->GetStartX(), mc->GetStartY(), mc->GetStartZ(), mc->GetStartT());
38 }
39 
41 
42 void NicaCbmMCTrack::SetNPoints(ECbmModuleId iDet, Int_t nPoints) {
43  switch (iDet) {
44  case ECbmModuleId::kRef: {
45  if (nPoints < 0)
46  nPoints = 0;
47  else if (nPoints > 1)
48  nPoints = 1;
49  fNPoints = (fNPoints & (~1)) | nPoints;
50  } break;
51  case ECbmModuleId::kMvd: {
52  if (nPoints < 0)
53  nPoints = 0;
54  else if (nPoints > 7)
55  nPoints = 7;
56  fNPoints = (fNPoints & (~(7 << 1))) | (nPoints << 1);
57  } break;
58  case ECbmModuleId::kSts: {
59  if (nPoints < 0)
60  nPoints = 0;
61  else if (nPoints > 31)
62  nPoints = 31;
63  fNPoints = (fNPoints & (~(31 << 4))) | (nPoints << 4);
64  } break;
65  case ECbmModuleId::kRich: {
66  if (nPoints < 0)
67  nPoints = 0;
68  else if (nPoints > 1)
69  nPoints = 1;
70  fNPoints = (fNPoints & (~(1 << 9))) | (nPoints << 9);
71  } break;
72  case ECbmModuleId::kMuch: {
73  if (nPoints < 0)
74  nPoints = 0;
75  else if (nPoints > 31)
76  nPoints = 31;
77  fNPoints = (fNPoints & (~(31 << 10))) | (nPoints << 10);
78  } break;
79  case ECbmModuleId::kTrd: {
80  if (nPoints < 0)
81  nPoints = 0;
82  else if (nPoints > 31)
83  nPoints = 31;
84  fNPoints = (fNPoints & (~(31 << 15))) | (nPoints << 15);
85  } break;
86  case ECbmModuleId::kTof: {
87  if (nPoints < 0)
88  nPoints = 0;
89  else if (nPoints > 15)
90  nPoints = 15;
91  fNPoints = (fNPoints & (~(15 << 20))) | (nPoints << 20);
92  } break;
93  case ECbmModuleId::kEcal: {
94  if (nPoints < 0)
95  nPoints = 0;
96  else if (nPoints > 1)
97  nPoints = 1;
98  fNPoints = (fNPoints & (~(1 << 24))) | (nPoints << 24);
99  } break;
100  case ECbmModuleId::kPsd: {
101  if (nPoints < 0)
102  nPoints = 0;
103  else if (nPoints > 1)
104  nPoints = 1;
105  fNPoints = (fNPoints & (~(1 << 25))) | (nPoints << 25);
106  } break;
107  default: {
108  LOG(warn) << "Call NicaCbmMCTrack::SetNPoints with unsupported system";
109  }
110  }
111 }
112 
114  switch (detId) {
115  case ECbmModuleId::kRef: return (fNPoints & 1); break;
116  case ECbmModuleId::kMvd: {
117  return ((fNPoints & (7 << 1)) >> 1);
118  } break;
119  case ECbmModuleId::kSts: {
120  return ((fNPoints & (31 << 4)) >> 4);
121  } break;
122  case ECbmModuleId::kRich: {
123  return ((fNPoints & (1 << 9)) >> 9);
124  } break;
125  case ECbmModuleId::kMuch: {
126  return ((fNPoints & (31 << 10)) >> 10);
127  } break;
128  case ECbmModuleId::kTrd: {
129  return ((fNPoints & (31 << 15)) >> 15);
130  } break;
131  case ECbmModuleId::kTof: {
132  return ((fNPoints & (15 << 20)) >> 20);
133  } break;
134  case ECbmModuleId::kEcal: {
135  return ((fNPoints & (1 << 24)) >> 24);
136  } break;
137  case ECbmModuleId::kPsd: {
138  return ((fNPoints & (1 << 25)) >> 25);
139  } break;
140  default: return 0; break;
141  }
142 }
143 
144 void NicaCbmMCTrack::CopyData(NicaTrack* other) {
145  NicaMCTrack::CopyData(other);
146  this->fNPoints = ((NicaCbmMCTrack*) other)->fNPoints;
147 }
NicaCbmMCTrack
Definition: NicaCbmMCTrack.h:15
CbmMCTrack::GetMotherId
Int_t GetMotherId() const
Definition: CbmMCTrack.h:71
CbmMCTrack::GetStartX
Double_t GetStartX() const
Definition: CbmMCTrack.h:75
NicaCbmMCTrack::~NicaCbmMCTrack
virtual ~NicaCbmMCTrack()
Definition: NicaCbmMCTrack.cxx:40
CbmMCTrack::GetPdgCode
Int_t GetPdgCode() const
Definition: CbmMCTrack.h:70
ECbmModuleId::kMvd
@ kMvd
Micro-Vertex Detector.
ECbmModuleId
ECbmModuleId
Definition: CbmDefs.h:33
CbmMCTrack::GetPx
Double_t GetPx() const
Definition: CbmMCTrack.h:72
CbmMCTrack::GetPy
Double_t GetPy() const
Definition: CbmMCTrack.h:73
ECbmModuleId::kTof
@ kTof
Time-of-flight Detector.
CbmMCTrack::GetStartZ
Double_t GetStartZ() const
Definition: CbmMCTrack.h:77
CbmMCTrack::GetNPoints
Int_t GetNPoints(ECbmModuleId detId) const
Definition: CbmMCTrack.cxx:186
NicaCbmMCTrack::fNPoints
Int_t fNPoints
Definition: NicaCbmMCTrack.h:16
NicaCbmMCTrack.h
ECbmModuleId::kRich
@ kRich
Ring-Imaging Cherenkov Detector.
ECbmModuleId::kRef
@ kRef
Reference plane.
NicaCbmMCTrack::SetNPoints
void SetNPoints(ECbmModuleId iDet, Int_t np)
Definition: NicaCbmMCTrack.cxx:42
ECbmModuleId::kTrd
@ kTrd
Transition Radiation Detector.
CbmMCTrack::GetStartY
Double_t GetStartY() const
Definition: CbmMCTrack.h:76
CbmMCTrack
Definition: CbmMCTrack.h:34
NicaCbmMCTrack::CopyData
virtual void CopyData(NicaTrack *other)
Definition: NicaCbmMCTrack.cxx:144
NicaCbmMCTrack::GetNPoints
Int_t GetNPoints(ECbmModuleId detId) const
Definition: NicaCbmMCTrack.cxx:113
NicaCbmMCTrack::NicaCbmMCTrack
NicaCbmMCTrack()
Definition: NicaCbmMCTrack.cxx:13
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
ECbmModuleId::kPsd
@ kPsd
Projectile spectator detector.
CbmMCTrack::GetEnergy
Double_t GetEnergy() const
Definition: CbmMCTrack.h:165
NicaCbmMCTrack::Update
virtual void Update(CbmMCTrack *mc, Double_t charge)
Definition: NicaCbmMCTrack.cxx:15
ECbmModuleId::kEcal
@ kEcal
EM-Calorimeter.
ECbmModuleId::kSts
@ kSts
Silicon Tracking System.
CbmMCTrack::GetPz
Double_t GetPz() const
Definition: CbmMCTrack.h:74
CbmMCTrack::GetStartT
Double_t GetStartT() const
Definition: CbmMCTrack.h:78