CbmRoot
PairAnalysisPairLV.cxx
Go to the documentation of this file.
1 //
3 //
4 // Authors:
5 // Julian Book <Julian.Book@cern.ch>
6 /*
7 
8  PairAnalysisPair class that internally makes use of TLorentzVector.
9 
10 */
11 // //
13 
14 
15 #include <TDatabasePDG.h>
16 
17 #include "CbmL1.h"
18 #include "L1Algo.h"
19 #include "L1Field.h"
20 
21 #include "CbmMCTrack.h"
22 #include "PairAnalysisTrack.h"
23 
24 #include "PairAnalysisPairLV.h"
25 
27 
29  : PairAnalysisPair(), fPairPos(), fPair(), fD1(), fD2() {
30  //
31  // Default Constructor
32  //
33 }
34 
35 //______________________________________________
37  : PairAnalysisPair(pair), fPairPos(), fPair(), fD1(), fD2() {
38  //
39  // Copy Constructor
40  //
42  pair.GetFirstDaughterPid(),
43  pair.GetSecondDaughter(),
44  pair.GetSecondDaughterPid());
45 }
46 
47 //______________________________________________
49  Int_t pid1,
50  PairAnalysisTrack* const particle2,
51  Int_t pid2,
52  Char_t type)
53  : PairAnalysisPair(type), fPairPos(), fPair(), fD1(), fD2() {
54  //
55  // Constructor with tracks
56  //
57  SetTracks(particle1, pid1, particle2, pid2);
58 }
59 
60 //______________________________________________
62  //
63  // Default Destructor
64  //
65 }
66 
67 //______________________________________________
69  Int_t pid1,
70  PairAnalysisTrack* const particle2,
71  Int_t pid2) {
72  //
73  // set TLorentzVector daughters and pair
74  // refParticle1 and 2 are the original tracks. In the case of track rotation
75  // they are needed in the framework
76  //
77 
78  //vvv
79  // TODO: think about moving the pid assignement to PairAnalysisTrack and use it here
80  // BUT what about mixed events or LS-pairs
81  const Double_t mpid1 = TDatabasePDG::Instance()->GetParticle(pid1)->Mass();
82  const Double_t mpid2 = TDatabasePDG::Instance()->GetParticle(pid2)->Mass();
83  const Double_t cpid1 =
84  TDatabasePDG::Instance()->GetParticle(pid1)->Charge() * 3;
85  const Double_t cpid2 =
86  TDatabasePDG::Instance()->GetParticle(pid2)->Charge() * 3;
87 
88  // match charge of track to pid and set mass accordingly
89  fPid1 = pid1;
90  fPid2 = pid2;
91  Double_t m1 = mpid1;
92  Double_t m2 = mpid2;
93  if (particle1->Charge() == cpid2) {
94  m1 = mpid2;
95  fPid1 = pid2;
96  } //TODO: what about 2e-charges
97  if (particle2->Charge() == cpid1) {
98  m2 = mpid1;
99  fPid2 = pid1;
100  }
101 
102  // Calculate Energy per particle by hand
103  Double_t e1 = TMath::Sqrt(m1 * m1 + particle1->Px() * particle1->Px()
104  + particle1->Py() * particle1->Py()
105  + particle1->Pz() * particle1->Pz());
106 
107  Double_t e2 = TMath::Sqrt(m2 * m2 + particle2->Px() * particle2->Px()
108  + particle2->Py() * particle2->Py()
109  + particle2->Pz() * particle2->Pz());
110 
111  fRefD1 = particle1;
112  fRefD2 = particle2;
113  fD1.SetPxPyPzE(particle1->Px(), particle1->Py(), particle1->Pz(), e1);
114  fD2.SetPxPyPzE(particle2->Px(), particle2->Py(), particle2->Pz(), e2);
115  //^^^ this should become obsolete
116 
117  // build pair
118  fPair = (fD1 + fD2);
119  fPairPos = (*particle1->GetPosition() + *particle2->GetPosition());
120  fCharge = (particle1->Charge() * particle2->Charge());
121  fWeight = TMath::Sqrt(particle1->GetWeight() * particle2->GetWeight());
122  // printf("fill pair weight: %.1f * %.1f = %.1f \n",particle1->GetWeight(),particle2->GetWeight(),fWeight);
123 }
124 
125 //______________________________________________
126 void PairAnalysisPairLV::SetMCTracks(const CbmMCTrack* const particle1,
127  const CbmMCTrack* const particle2) {
128  //
129  // build MC pair from TLorentzVector daughters
130  // no references are set
131  //
132  particle1->Get4Momentum(fD1);
133  particle2->Get4Momentum(fD2);
134  fPair = (fD1 + fD2);
135  TLorentzVector fD1Pos(particle1->GetStartX(),
136  particle1->GetStartY(),
137  particle1->GetStartZ(),
138  particle1->GetStartT());
139  TLorentzVector fD2Pos(particle2->GetStartX(),
140  particle2->GetStartY(),
141  particle2->GetStartZ(),
142  particle2->GetStartT());
143  fPairPos = (fD1Pos + fD2Pos);
144 }
145 
146 //______________________________________________
147 // Int_t PairAnalysisPairLV::Charge() const
148 // {
149 // return (dynamic_cast<PairAnalysisTrack*>(fRefD1.GetObject())->Charge() +
150 // dynamic_cast<PairAnalysisTrack*>(fRefD2.GetObject())->Charge());
151 // }
152 
153 //______________________________________________
154 void PairAnalysisPairLV::GetThetaPhiCM(Double_t& thetaHE,
155  Double_t& phiHE,
156  Double_t& thetaCS,
157  Double_t& phiCS) const {
158  //
159  // Calculate theta and phi in helicity and Collins-Soper coordinate frame
160  //
161 
162  TLorentzVector motherMom(fPair);
163  TLorentzVector p1Mom(fD1);
164  TLorentzVector p2Mom(fD2);
166  motherMom, p1Mom, p2Mom, thetaHE, phiHE, thetaCS, phiCS);
167 }
168 
169 
170 //______________________________________________
171 Double_t PairAnalysisPairLV::PsiPair(Double_t /*MagField*/) const {
172  //Following idea to use opening of colinear pairs in magnetic field from e.g. PHENIX
173  //to ID conversions. Adapted from AliTRDv0Info class
174  //TODO: adapt and get magnetic field
175  /* (FU) not used
176  Double_t x, y;//, z;
177  x = fPair.X();
178  y = fPair.Y();
179  // z = fPair.Z();
180 */
181  Double_t m1[3] = {0, 0, 0};
182  Double_t m2[3] = {0, 0, 0};
183 
184  m1[0] = fD1.Px();
185  m1[1] = fD1.Py();
186  m1[2] = fD1.Pz();
187 
188  m2[0] = fD2.Px();
189  m2[1] = fD2.Py();
190  m2[2] = fD2.Pz();
191 
192  Double_t deltat = 1.;
193  //difference of angles of the two daughter tracks with z-axis
194  deltat =
195  TMath::ATan(m2[2] / (TMath::Sqrt(m2[0] * m2[0] + m2[1] * m2[1]) + 1.e-13))
196  - TMath::ATan(m1[2]
197  / (TMath::Sqrt(m1[0] * m1[0] + m1[1] * m1[1]) + 1.e-13));
198 
199  // Double_t radiussum = TMath::Sqrt(x*x + y*y) + 50;//radius to which tracks shall be propagated
200 
201  Double_t mom1Prop[3] = {0., 0., 0.};
202  Double_t mom2Prop[3] = {0., 0., 0.};
203 
204  // TODO: adapt code
205  Double_t fPsiPair = 4.;
206  /*
207  AliExternalTrackParam *d1 = static_cast<AliExternalTrackParam*>(fRefD1.GetObject());
208  AliExternalTrackParam *d2 = static_cast<AliExternalTrackParam*>(fRefD2.GetObject());
209  AliExternalTrackParam nt(*d1), pt(*d2);
210 
211  if(nt.PropagateTo(radiussum,MagField) == 0)//propagate tracks to the outside
212  fPsiPair = -5.;
213  if(pt.PropagateTo(radiussum,MagField) == 0)
214  fPsiPair = -5.;
215  pt.GetPxPyPz(mom1Prop);//Get momentum vectors of tracks after propagation
216  nt.GetPxPyPz(mom2Prop);
217  */
218 
219  // absolute momentum values
220  Double_t pEle =
221  TMath::Sqrt(mom2Prop[0] * mom2Prop[0] + mom2Prop[1] * mom2Prop[1]
222  + mom2Prop[2] * mom2Prop[2]);
223  Double_t pPos =
224  TMath::Sqrt(mom1Prop[0] * mom1Prop[0] + mom1Prop[1] * mom1Prop[1]
225  + mom1Prop[2] * mom1Prop[2]);
226  //scalar product of propagated posit
227  Double_t scalarproduct = mom1Prop[0] * mom2Prop[0] + mom1Prop[1] * mom2Prop[1]
228  + mom1Prop[2] * mom2Prop[2];
229  //Angle between propagated daughter tracks
230  Double_t chipair = TMath::ACos(scalarproduct / (pEle * pPos));
231 
232  fPsiPair = TMath::Abs(TMath::ASin(deltat / chipair));
233 
234  return fPsiPair;
235 }
236 
237 //______________________________________________
239  //
240  // Calculate the Armenteros-Podolanski Alpha
241  //
242  Int_t qD1 =
243  dynamic_cast<PairAnalysisTrack*>(fRefD1.GetObject())->Charge() > 0;
244  TVector3 momNeg = (qD1 < 0 ? fD1.Vect() : fD2.Vect());
245  TVector3 momPos = (qD1 < 0 ? fD2.Vect() : fD1.Vect());
246  TVector3 momTot(Px(), Py(), Pz());
247 
248  Double_t lQlNeg = momNeg.Dot(momTot) / momTot.Mag();
249  Double_t lQlPos = momPos.Dot(momTot) / momTot.Mag();
250 
251  return ((lQlPos - lQlNeg) / (lQlPos + lQlNeg));
252 }
253 
254 //______________________________________________
256  //
257  // Calculate the Armenteros-Podolanski Pt
258  //
259  Int_t qD1 =
260  dynamic_cast<PairAnalysisTrack*>(fRefD1.GetObject())->Charge() > 0;
261  TVector3 momNeg = (qD1 < 0 ? fD1.Vect() : fD2.Vect());
262  TVector3 momTot(Px(), Py(), Pz());
263  return (momNeg.Perp(momTot));
264 }
265 
266 //______________________________________________
267 Double_t PairAnalysisPairLV::PhivPair(Double_t MagField) const {
278  Int_t qD1 = 0;
279  if (fRefD1.GetObject())
280  qD1 = dynamic_cast<PairAnalysisTrack*>(fRefD1.GetObject())->Charge() > 0;
281  // TODO add mc charge (no fRefD1.GetObject())
282  TVector3 p1;
283  TVector3 p2;
284 
285  // L1FieldValue bfield = CbmL1::Instance()->algo->GetvtxFieldValue();
286  // printf("l1 field values: %f %f %f \n",bfield.x[0],bfield.y[0],bfield.z[0]);
287  // if(bfield.y[0]>0){
288  if (MagField < 0) {
289  p1 = (qD1 > 0 ? fD1.Vect() : fD2.Vect());
290  p2 = (qD1 > 0 ? fD2.Vect() : fD1.Vect());
291  } else {
292  p2 = (qD1 > 0 ? fD1.Vect() : fD2.Vect());
293  p1 = (qD1 > 0 ? fD2.Vect() : fD1.Vect());
294  }
295 
296  //unit vector of (pep+pem)
297  TVector3 u = fPair.Vect();
298  u.SetMag(1.); // normalize
299 
300  //vector product of pep X pem (perpendicular to the pair)
301  TVector3 vpm = p1.Cross(p2);
302  vpm.SetMag(1.); // normalize
303 
304  //The third axis defined by vector product (ux,uy,uz)X(vx,vy,vz)
305  // by construction, (wx,wy,wz) must be a unit vector.
306  TVector3 w = u.Cross(vpm);
307 
308  // unit vector in xz-plane (perpendicular to B-field)
309  Double_t ax =
310  u.Pz() / TMath::Sqrt(u.Px() + u.Px() + u.Pz() + u.Pz()); // =sin(alpha_xz)
311  Double_t ay = 0.; // by defintion
312  Double_t az =
313  u.Pz()
314  / TMath::Sqrt(u.Px() + u.Px() + u.Pz() + u.Pz()); // =cos(alpha_xz+180)
315  TVector3 a(ax, ay, az);
316 
317  // measure angle between (wx,wy,wz) and (ax,ay,0). The angle between them
318  // should be small if the pair is conversion
319  // Double_t cosPhiV = w.Px()*ax + w.Py()*ay; // angle btw w and a
320  // Double_t phiv = TMath::ACos(cosPhiV);
321  Double_t phiv = w.Angle(a);
322 
323  return phiv;
324 }
325 
326 //_______________________________________________
328  //
329  // Rotate one of the legs according to the track rotator settings
330  //
331 
332  Double_t rotAngle = rot->GetAngle();
333  Double_t rotCharge = rot->GetCharge();
334 
336  if (!first) return;
337 
338  //Printf("\n before rotation:");
339  //fD1.Print("");
340  //fD2.Print("");
341 
344  && rotCharge == 0)) {
345  if (first->Charge() > 0)
346  fD1.RotateZ(rotAngle);
347  else
348  fD2.RotateZ(rotAngle);
349  }
350 
353  && rotCharge == 1)) {
354  if (first->Charge() > 0)
355  fD1.RotateZ(rotAngle);
356  else
357  fD2.RotateZ(rotAngle);
358  }
359  // Printf("after rotation:");
360  //fD1.Print("");
361  //fD2.Print("");
362 
363  // rebuild pair
364  fPair = (fD1 + fD2);
365 }
PairAnalysisPairLV::SetTracks
void SetTracks(PairAnalysisTrack *const particle1, Int_t pid1, PairAnalysisTrack *const particle2, Int_t pid2)
Definition: PairAnalysisPairLV.cxx:68
PairAnalysisTrackRotator::GetAngle
Double_t GetAngle() const
Definition: PairAnalysisTrackRotator.h:38
PairAnalysisPair::GetFirstDaughterPid
Int_t GetFirstDaughterPid() const
Definition: PairAnalysisPair.h:146
PairAnalysisPairLV::fPair
TLorentzVector fPair
Definition: PairAnalysisPairLV.h:117
CbmMCTrack::GetStartX
Double_t GetStartX() const
Definition: CbmMCTrack.h:75
PairAnalysisPair::GetFirstDaughter
PairAnalysisTrack * GetFirstDaughter() const
Definition: PairAnalysisPair.h:140
L1Algo.h
PairAnalysisTrack::GetWeight
Double_t GetWeight() const
Definition: PairAnalysisTrack.h:110
PairAnalysisPairLV::GetArmAlpha
Double_t GetArmAlpha() const
Definition: PairAnalysisPairLV.cxx:238
PairAnalysisPairLV::PsiPair
Double_t PsiPair(Double_t MagField) const
Definition: PairAnalysisPairLV.cxx:171
L1Field.h
PairAnalysisTrackRotator::kRotatePositive
@ kRotatePositive
Definition: PairAnalysisTrackRotator.h:19
PairAnalysisPair::fWeight
Double_t fWeight
Definition: PairAnalysisPair.h:160
PairAnalysisTrack::Charge
Short_t Charge() const
Definition: PairAnalysisTrack.h:107
PairAnalysisPair::GetThetaPhiCM
virtual void GetThetaPhiCM(Double_t &thetaHE, Double_t &phiHE, Double_t &thetaCS, Double_t &phiCS) const =0
PairAnalysisPair::fRefD1
TRef fRefD1
beam energy
Definition: PairAnalysisPair.h:164
PairAnalysisTrackRotator
Definition: PairAnalysisTrackRotator.h:17
CbmL1.h
PairAnalysisTrack
Definition: PairAnalysisTrack.h:37
PairAnalysisPair
Definition: PairAnalysisPair.h:25
PairAnalysisPairLV::PhivPair
Double_t PhivPair(Double_t MagField) const
Definition: PairAnalysisPairLV.cxx:267
PairAnalysisPairLV::GetThetaPhiCM
void GetThetaPhiCM(Double_t &thetaHE, Double_t &phiHE, Double_t &thetaCS, Double_t &phiCS) const
Definition: PairAnalysisPairLV.cxx:154
PairAnalysisPairLV::fD2
TLorentzVector fD2
Definition: PairAnalysisPairLV.h:119
CbmMCTrack::GetStartZ
Double_t GetStartZ() const
Definition: CbmMCTrack.h:77
PairAnalysisPair::fPid2
Int_t fPid2
Definition: PairAnalysisPair.h:167
PairAnalysisPair::Charge
Short_t Charge() const
Definition: PairAnalysisPair.h:79
PairAnalysisTrackRotator::kRotateBothRandom
@ kRotateBothRandom
Definition: PairAnalysisTrackRotator.h:19
PairAnalysisPair::fCharge
Short_t fCharge
Definition: PairAnalysisPair.h:158
PairAnalysisTrack::Px
Double_t Px() const
Definition: PairAnalysisTrack.h:86
PairAnalysisPairLV.h
PairAnalysisPairLV
Definition: PairAnalysisPairLV.h:25
PairAnalysisPairLV::Px
virtual Double_t Px() const
Definition: PairAnalysisPairLV.h:47
first
bool first
Definition: LKFMinuit.cxx:143
PairAnalysisPairLV::GetArmPt
Double_t GetArmPt() const
Definition: PairAnalysisPairLV.cxx:255
PairAnalysisTrack.h
PairAnalysisTrackRotator::GetRotationType
ERotationType GetRotationType() const
Definition: PairAnalysisTrackRotator.h:34
CbmMCTrack::GetStartY
Double_t GetStartY() const
Definition: CbmMCTrack.h:76
PairAnalysisPair::fPid1
Int_t fPid1
Definition: PairAnalysisPair.h:166
CbmMCTrack.h
PairAnalysisPair::GetSecondDaughterPid
Int_t GetSecondDaughterPid() const
Definition: PairAnalysisPair.h:147
PairAnalysisPair::fRefD2
TRef fRefD2
Definition: PairAnalysisPair.h:165
ClassImp
ClassImp(PairAnalysisPairLV) PairAnalysisPairLV
Definition: PairAnalysisPairLV.cxx:26
PairAnalysisTrackRotator::kRotateNegative
@ kRotateNegative
Definition: PairAnalysisTrackRotator.h:19
CbmMCTrack
Definition: CbmMCTrack.h:34
PairAnalysisPairLV::RotateTrack
virtual void RotateTrack(PairAnalysisTrackRotator *rot)
Definition: PairAnalysisPairLV.cxx:327
PairAnalysisPairLV::fD1
TLorentzVector fD1
Definition: PairAnalysisPairLV.h:118
CbmMCTrack::Get4Momentum
void Get4Momentum(TLorentzVector &momentum) const
Definition: CbmMCTrack.h:177
PairAnalysisPairLV::~PairAnalysisPairLV
virtual ~PairAnalysisPairLV()
Definition: PairAnalysisPairLV.cxx:61
PairAnalysisPairLV::Py
virtual Double_t Py() const
Definition: PairAnalysisPairLV.h:48
PairAnalysisTrackRotator::GetCharge
Double_t GetCharge() const
Definition: PairAnalysisTrackRotator.h:41
PairAnalysisPairLV::fPairPos
TLorentzVector fPairPos
Definition: PairAnalysisPairLV.h:116
PairAnalysisPairLV::Pz
virtual Double_t Pz() const
Definition: PairAnalysisPairLV.h:49
PairAnalysisTrack::Pz
Double_t Pz() const
Definition: PairAnalysisTrack.h:88
PairAnalysisPairLV::PairAnalysisPairLV
PairAnalysisPairLV()
PairAnalysisPair::GetSecondDaughter
PairAnalysisTrack * GetSecondDaughter() const
Definition: PairAnalysisPair.h:143
PairAnalysisTrack::GetPosition
TLorentzVector * GetPosition()
Definition: PairAnalysisTrack.h:67
PairAnalysisPairLV::SetMCTracks
void SetMCTracks(const CbmMCTrack *const particle1, const CbmMCTrack *const particle2)
Definition: PairAnalysisPairLV.cxx:126
PairAnalysisTrack::Py
Double_t Py() const
Definition: PairAnalysisTrack.h:87
CbmMCTrack::GetStartT
Double_t GetStartT() const
Definition: CbmMCTrack.h:78