CbmRoot
Loading...
Searching...
No Matches
CbmKresFunctions.h
Go to the documentation of this file.
1/* Copyright (C) 2017-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Ievgenii Kres, Florian Uhlig [committer] */
4
13#ifndef CBM_KRES_FUNCTIONS
14#define CBM_KRES_FUNCTIONS
15
16#include "CbmGlobalTrack.h"
17#include "CbmMCTrack.h"
18#include "CbmStsKFTrackFitter.h"
19#include "CbmVertex.h"
20
21#include "TLorentzVector.h"
22#include "TMath.h"
23#include "TMatrixTSym.h"
24#include "TVector3.h"
25
26#include "LmvmKinePar.h"
27
28#define M2E 2.6112004954086e-7
29#define M2Pion 0.0194798351452
30
32public:
34 static TVector3 FitToVertex(CbmStsTrack* stsTrack, double x, double y, double z)
35 {
36 CbmVertex* vtx = new CbmVertex();
37 TMatrixFSym* covMat = new TMatrixFSym(3);
38 vtx->SetVertex(x, y, z, 0, 0, 0, *covMat);
40 FairTrackParam neu_track;
41 fitter.FitToVertex(stsTrack, vtx, &neu_track);
42
43 TVector3 momentum;
44
45 neu_track.Momentum(momentum);
46
47 delete vtx;
48 delete covMat;
49
50 return momentum;
51 }
52
54 static double ChiToVertex(CbmStsTrack* stsTrack, double x, double y, double z)
55 {
56 CbmVertex* vtx = new CbmVertex();
57 TMatrixFSym* covMat = new TMatrixFSym(3);
58 vtx->SetVertex(x, y, z, 0, 0, 0, *covMat);
60 FairTrackParam neu_track;
61 fitter.FitToVertex(stsTrack, vtx, &neu_track);
62
63 double chi = fitter.GetChiToVertex(stsTrack, vtx);
64
65 delete vtx;
66 delete covMat;
67
68 return chi;
69 }
70
71
73 static TVector3 FitToVertexAndGetChi(CbmStsTrack* stsTrack, double x, double y, double z, double& chi)
74 {
75 CbmVertex* vtx = new CbmVertex();
76 TMatrixFSym* covMat = new TMatrixFSym(3);
77 vtx->SetVertex(x, y, z, 0, 0, 0, *covMat);
79 FairTrackParam neu_track;
80 fitter.FitToVertex(stsTrack, vtx, &neu_track);
81
82 chi = fitter.GetChiToVertex(stsTrack, vtx);
83
84 TVector3 momentum;
85
86 neu_track.Momentum(momentum);
87
88 delete vtx;
89 delete covMat;
90
91 return momentum;
92 }
93
94 // calculation of invariant mass from 2 tracks using MCtrue momenta
95 static double Invmass_2particles_MC(const CbmMCTrack* mctrack1, const CbmMCTrack* mctrack2)
96 {
97 TLorentzVector lorVec1;
98 mctrack1->Get4Momentum(lorVec1);
99
100 TLorentzVector lorVec2;
101 mctrack2->Get4Momentum(lorVec2);
102
103 TLorentzVector sum;
104 sum = lorVec1 + lorVec2;
105
106 return sum.Mag();
107 }
108
109 // calculation of invariant mass from 2 tracks using reconstructed momenta
110 static double Invmass_2particles_RECO(const TVector3 part1, const TVector3 part2)
111 {
112 Double_t energy1 = TMath::Sqrt(part1.Mag2() + M2E);
113 TLorentzVector lorVec1(part1, energy1);
114
115 Double_t energy2 = TMath::Sqrt(part2.Mag2() + M2E);
116 TLorentzVector lorVec2(part2, energy2);
117
118 TLorentzVector sum;
119 sum = lorVec1 + lorVec2;
120
121 return sum.Mag();
122 }
123
124 // calculation of invariant mass from 4 tracks using MCtrue momenta
125 static double Invmass_4particles_MC(const CbmMCTrack* mctrack1, const CbmMCTrack* mctrack2,
126 const CbmMCTrack* mctrack3, const CbmMCTrack* mctrack4)
127 {
128 TLorentzVector lorVec1;
129 mctrack1->Get4Momentum(lorVec1);
130
131 TLorentzVector lorVec2;
132 mctrack2->Get4Momentum(lorVec2);
133
134 TLorentzVector lorVec3;
135 mctrack3->Get4Momentum(lorVec3);
136
137 TLorentzVector lorVec4;
138 mctrack4->Get4Momentum(lorVec4);
139
140 TLorentzVector sum;
141 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4;
142
143 return sum.Mag();
144 }
145
146 // calculation of invariant mass from 4 tracks using reconstructed momenta
147 static double Invmass_4particles_RECO(const TVector3 part1, const TVector3 part2, const TVector3 part3,
148 const TVector3 part4)
149 {
150 Double_t energy1 = TMath::Sqrt(part1.Mag2() + M2E);
151 TLorentzVector lorVec1(part1, energy1);
152
153 Double_t energy2 = TMath::Sqrt(part2.Mag2() + M2E);
154 TLorentzVector lorVec2(part2, energy2);
155
156 Double_t energy3 = TMath::Sqrt(part3.Mag2() + M2E);
157 TLorentzVector lorVec3(part3, energy3);
158
159 Double_t energy4 = TMath::Sqrt(part4.Mag2() + M2E);
160 TLorentzVector lorVec4(part4, energy4);
161
162 TLorentzVector sum;
163 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4;
164
165 return sum.Mag();
166 }
167
168 // gives amount of daughter particles belonging to current particle -> MCtrue info
169 static int NofDaughters(int motherId, vector<CbmMCTrack*> MC)
170 {
171 int nofDaughters = 0;
172 for (size_t i = 0; i < MC.size(); i++) {
173 int motherId_temp = MC.at(i)->GetMotherId();
174 if (motherId == motherId_temp) nofDaughters++;
175 }
176 return nofDaughters;
177 }
178
179
180 // calculation of many interesting for analysis physics parameters of 2 tracks: Invariant mass, opening angle, rapidity, pt,
181 static LmvmKinePar CalculateKinematicParamsReco(const TVector3 electron1, const TVector3 electron2)
182 {
183 LmvmKinePar params;
184
185 Double_t energyP = TMath::Sqrt(electron1.Mag2() + M2E);
186 TLorentzVector lorVecP(electron1, energyP);
187
188 Double_t energyM = TMath::Sqrt(electron2.Mag2() + M2E);
189 TLorentzVector lorVecM(electron2, energyM);
190
191 TVector3 momPair = electron1 + electron2;
192 Double_t energyPair = energyP + energyM;
193 Double_t ptPair = momPair.Perp();
194 Double_t pzPair = momPair.Pz();
195 Double_t yPair = 0.5 * TMath::Log((energyPair + pzPair) / (energyPair - pzPair));
196 Double_t anglePair = lorVecM.Angle(lorVecP.Vect());
197 Double_t theta = 180. * anglePair / TMath::Pi();
198 Double_t minv = 2. * TMath::Sin(anglePair / 2.) * TMath::Sqrt(electron1.Mag() * electron2.Mag());
199
200 params.fMomentumMag = momPair.Mag();
201 params.fPt = ptPair;
202 params.fRapidity = yPair;
203 params.fMinv = minv;
204 params.fAngle = theta;
205 return params;
206 }
207
208
209 // calculation of many interesting for analysis physics parameters of 4 tracks: Invariant mass, opening angle, rapidity, pt,
210 static LmvmKinePar CalculateKinematicParams_4particles(const TVector3 part1, const TVector3 part2,
211 const TVector3 part3, const TVector3 part4)
212 {
213 LmvmKinePar params;
214
215 Double_t energy1 = TMath::Sqrt(part1.Mag2() + M2E);
216 TLorentzVector lorVec1(part1, energy1);
217
218 Double_t energy2 = TMath::Sqrt(part2.Mag2() + M2E);
219 TLorentzVector lorVec2(part2, energy2);
220
221 Double_t energy3 = TMath::Sqrt(part3.Mag2() + M2E);
222 TLorentzVector lorVec3(part3, energy3);
223
224 Double_t energy4 = TMath::Sqrt(part4.Mag2() + M2E);
225 TLorentzVector lorVec4(part4, energy4);
226
227 TLorentzVector sum;
228 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4;
229
230 TVector3 momPair = part1 + part2 + part3 + part4;
231 Double_t energyPair = energy1 + energy2 + energy3 + energy4;
232 Double_t ptPair = momPair.Perp();
233 Double_t pzPair = momPair.Pz();
234 Double_t yPair = 0.5 * TMath::Log((energyPair + pzPair) / (energyPair - pzPair));
235 Double_t minv = sum.Mag();
236
237 params.fMomentumMag = momPair.Mag();
238 params.fPt = ptPair;
239 params.fRapidity = yPair;
240 params.fMinv = minv;
241 params.fAngle = 0;
242 return params;
243 }
244
245
246 // calculation of opening angle from 2 tracks using reconstructed momenta
247 static Double_t CalculateOpeningAngle_Reco(TVector3 electron1, TVector3 electron2)
248 {
249 Double_t energyP = TMath::Sqrt(electron1.Mag2() + M2E);
250 TLorentzVector lorVecP(electron1, energyP);
251
252 Double_t energyM = TMath::Sqrt(electron2.Mag2() + M2E);
253 TLorentzVector lorVecM(electron2, energyM);
254
255 Double_t anglePair = lorVecM.Angle(lorVecP.Vect());
256 Double_t theta = 180. * anglePair / TMath::Pi();
257
258 return theta;
259 }
260
261
262 // calculation of opening angle from 2 tracks using MCtrue momenta
263 static Double_t CalculateOpeningAngle_MC(CbmMCTrack* mctrack1, CbmMCTrack* mctrack2)
264 {
265 TVector3 electron1;
266 mctrack1->GetMomentum(electron1);
267 Double_t energyP = TMath::Sqrt(electron1.Mag2() + M2E);
268 TLorentzVector lorVecP(electron1, energyP);
269
270 TVector3 electron2;
271 mctrack2->GetMomentum(electron2);
272 Double_t energyM = TMath::Sqrt(electron2.Mag2() + M2E);
273 TLorentzVector lorVecM(electron2, energyM);
274
275 Double_t anglePair = lorVecM.Angle(lorVecP.Vect());
276 Double_t theta = 180. * anglePair / TMath::Pi();
277
278 return theta;
279 }
280
281
282 // calculation of opening angle from 2 photons using reconstructed momenta
283 static Double_t CalculateOpeningAngleBetweenGammas_Reco(TVector3 electron1, TVector3 electron2, TVector3 electron3,
284 TVector3 electron4)
285 {
286 Double_t energy1 = TMath::Sqrt(electron1.Mag2() + M2E);
287 TLorentzVector lorVec1(electron1, energy1);
288
289 Double_t energy2 = TMath::Sqrt(electron2.Mag2() + M2E);
290 TLorentzVector lorVec2(electron2, energy2);
291
292 Double_t energy3 = TMath::Sqrt(electron3.Mag2() + M2E);
293 TLorentzVector lorVec3(electron3, energy3);
294
295 Double_t energy4 = TMath::Sqrt(electron4.Mag2() + M2E);
296 TLorentzVector lorVec4(electron4, energy4);
297
298 TLorentzVector lorPhoton1 = lorVec1 + lorVec2;
299 TLorentzVector lorPhoton2 = lorVec3 + lorVec4;
300
301 Double_t angleBetweenPhotons = lorPhoton1.Angle(lorPhoton2.Vect());
302 Double_t theta = 180. * angleBetweenPhotons / TMath::Pi();
303
304 return theta;
305 }
306
307
308 // calculation of invariant mass of 4 particles using reconstructed value of momenta
309 static double Invmass_2el_2pions_RECO(const TVector3 part1El, const TVector3 part2El, const TVector3 part3Pion,
310 const TVector3 part4Pion)
311 {
312 Double_t energy1 = TMath::Sqrt(part1El.Mag2() + M2E);
313 TLorentzVector lorVec1(part1El, energy1);
314
315 Double_t energy2 = TMath::Sqrt(part2El.Mag2() + M2E);
316 TLorentzVector lorVec2(part2El, energy2);
317
318 Double_t energy3 = TMath::Sqrt(part3Pion.Mag2() + M2Pion);
319 TLorentzVector lorVec3(part3Pion, energy3);
320
321 Double_t energy4 = TMath::Sqrt(part4Pion.Mag2() + M2Pion);
322 TLorentzVector lorVec4(part4Pion, energy4);
323
324 TLorentzVector sum;
325 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4;
326
327 return sum.Mag();
328 }
329
330
331 // calculation of invariant mass of 6 particles using true value of momenta
332 static double Invmass_6particles_MC(const CbmMCTrack* mctrack1, const CbmMCTrack* mctrack2,
333 const CbmMCTrack* mctrack3, const CbmMCTrack* mctrack4,
334 const CbmMCTrack* mctrack5, const CbmMCTrack* mctrack6)
335 {
336 TLorentzVector lorVec1;
337 mctrack1->Get4Momentum(lorVec1);
338
339 TLorentzVector lorVec2;
340 mctrack2->Get4Momentum(lorVec2);
341
342 TLorentzVector lorVec3;
343 mctrack3->Get4Momentum(lorVec3);
344
345 TLorentzVector lorVec4;
346 mctrack4->Get4Momentum(lorVec4);
347
348 TLorentzVector lorVec5;
349 mctrack5->Get4Momentum(lorVec5);
350
351 TLorentzVector lorVec6;
352 mctrack6->Get4Momentum(lorVec6);
353
354 TLorentzVector sum;
355 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4 + lorVec5 + lorVec6;
356
357 return sum.Mag();
358 }
359
360 // calculation of invariant mass of 6 particles using reconstructed value of momenta
361 static double Invmass_4el_2pions_RECO(const TVector3 part1El, const TVector3 part2El, const TVector3 part3El,
362 const TVector3 part4El, const TVector3 part5Pion, const TVector3 part6Pion)
363 {
364 Double_t energy1 = TMath::Sqrt(part1El.Mag2() + M2E);
365 TLorentzVector lorVec1(part1El, energy1);
366
367 Double_t energy2 = TMath::Sqrt(part2El.Mag2() + M2E);
368 TLorentzVector lorVec2(part2El, energy2);
369
370 Double_t energy3 = TMath::Sqrt(part3El.Mag2() + M2E);
371 TLorentzVector lorVec3(part3El, energy3);
372
373 Double_t energy4 = TMath::Sqrt(part4El.Mag2() + M2E);
374 TLorentzVector lorVec4(part4El, energy4);
375
376 Double_t energy5 = TMath::Sqrt(part5Pion.Mag2() + M2Pion);
377 TLorentzVector lorVec5(part5Pion, energy5);
378
379 Double_t energy6 = TMath::Sqrt(part6Pion.Mag2() + M2Pion);
380 TLorentzVector lorVec6(part6Pion, energy6);
381
382 TLorentzVector sum;
383 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4 + lorVec5 + lorVec6;
384
385 return sum.Mag();
386 }
387
388
390 static Double_t CalculateOpeningAngleBetweenPions_Reco(TVector3 electron1, TVector3 electron2)
391 {
392 Double_t energyP = TMath::Sqrt(electron1.Mag2() + M2Pion);
393 TLorentzVector lorVecP(electron1, energyP);
394
395 Double_t energyM = TMath::Sqrt(electron2.Mag2() + M2Pion);
396 TLorentzVector lorVecM(electron2, energyM);
397
398 Double_t anglePair = lorVecM.Angle(lorVecP.Vect());
399 Double_t theta = 180. * anglePair / TMath::Pi();
400
401 return theta;
402 }
403
404
406 static Double_t CalculateOpeningAngleBetweenPions_MC(CbmMCTrack* mctrack1, CbmMCTrack* mctrack2)
407 {
408 TVector3 electron1;
409 mctrack1->GetMomentum(electron1);
410 Double_t energyP = TMath::Sqrt(electron1.Mag2() + M2Pion);
411 TLorentzVector lorVecP(electron1, energyP);
412
413 TVector3 electron2;
414 mctrack2->GetMomentum(electron2);
415 Double_t energyM = TMath::Sqrt(electron2.Mag2() + M2Pion);
416 TLorentzVector lorVecM(electron2, energyM);
417
418 Double_t anglePair = lorVecM.Angle(lorVecP.Vect());
419 Double_t theta = 180. * anglePair / TMath::Pi();
420
421 return theta;
422 }
423
424
425 // calculation of many interesting for analysis physics parameters of 2 leptons and 2 pions: Invariant mass, opening angle, rapidity, pt,
426 static LmvmKinePar CalculateKinematicParams_2el_2pions(const TVector3 part1, const TVector3 part2,
427 const TVector3 part3, const TVector3 part4)
428 {
429 LmvmKinePar params;
430
431 Double_t energy1 = TMath::Sqrt(part1.Mag2() + M2E);
432 TLorentzVector lorVec1(part1, energy1);
433
434 Double_t energy2 = TMath::Sqrt(part2.Mag2() + M2E);
435 TLorentzVector lorVec2(part2, energy2);
436
437 Double_t energy3 = TMath::Sqrt(part3.Mag2() + M2Pion);
438 TLorentzVector lorVec3(part3, energy3);
439
440 Double_t energy4 = TMath::Sqrt(part4.Mag2() + M2Pion);
441 TLorentzVector lorVec4(part4, energy4);
442
443 TLorentzVector sum;
444 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4;
445
446 TVector3 momPair = part1 + part2 + part3 + part4;
447 Double_t energyPair = energy1 + energy2 + energy3 + energy4;
448 Double_t ptPair = momPair.Perp();
449 Double_t pzPair = momPair.Pz();
450 Double_t yPair = 0.5 * TMath::Log((energyPair + pzPair) / (energyPair - pzPair));
451 Double_t minv = sum.Mag();
452
453 params.fMomentumMag = momPair.Mag();
454 params.fPt = ptPair;
455 params.fRapidity = yPair;
456 params.fMinv = minv;
457 params.fAngle = 0;
458 return params;
459 }
460};
461
462#endif
#define M2Pion
#define M2E
static Double_t CalculateOpeningAngleBetweenGammas_Reco(TVector3 electron1, TVector3 electron2, TVector3 electron3, TVector3 electron4)
static TVector3 FitToVertexAndGetChi(CbmStsTrack *stsTrack, double x, double y, double z, double &chi)
static double ChiToVertex(CbmStsTrack *stsTrack, double x, double y, double z)
static LmvmKinePar CalculateKinematicParams_2el_2pions(const TVector3 part1, const TVector3 part2, const TVector3 part3, const TVector3 part4)
static int NofDaughters(int motherId, vector< CbmMCTrack * > MC)
static Double_t CalculateOpeningAngle_Reco(TVector3 electron1, TVector3 electron2)
static double Invmass_2particles_MC(const CbmMCTrack *mctrack1, const CbmMCTrack *mctrack2)
static Double_t CalculateOpeningAngle_MC(CbmMCTrack *mctrack1, CbmMCTrack *mctrack2)
static Double_t CalculateOpeningAngleBetweenPions_MC(CbmMCTrack *mctrack1, CbmMCTrack *mctrack2)
calculate opening angle between two pions using MCtrue momenta
static Double_t CalculateOpeningAngleBetweenPions_Reco(TVector3 electron1, TVector3 electron2)
calculate opening angle between two pions using reconstructed momenta
static LmvmKinePar CalculateKinematicParams_4particles(const TVector3 part1, const TVector3 part2, const TVector3 part3, const TVector3 part4)
static double Invmass_6particles_MC(const CbmMCTrack *mctrack1, const CbmMCTrack *mctrack2, const CbmMCTrack *mctrack3, const CbmMCTrack *mctrack4, const CbmMCTrack *mctrack5, const CbmMCTrack *mctrack6)
static double Invmass_2particles_RECO(const TVector3 part1, const TVector3 part2)
static double Invmass_4particles_MC(const CbmMCTrack *mctrack1, const CbmMCTrack *mctrack2, const CbmMCTrack *mctrack3, const CbmMCTrack *mctrack4)
static TVector3 FitToVertex(CbmStsTrack *stsTrack, double x, double y, double z)
static double Invmass_4particles_RECO(const TVector3 part1, const TVector3 part2, const TVector3 part3, const TVector3 part4)
static double Invmass_4el_2pions_RECO(const TVector3 part1El, const TVector3 part2El, const TVector3 part3El, const TVector3 part4El, const TVector3 part5Pion, const TVector3 part6Pion)
static LmvmKinePar CalculateKinematicParamsReco(const TVector3 electron1, const TVector3 electron2)
static double Invmass_2el_2pions_RECO(const TVector3 part1El, const TVector3 part2El, const TVector3 part3Pion, const TVector3 part4Pion)
void GetMomentum(TVector3 &momentum) const
Definition CbmMCTrack.h:170
void Get4Momentum(TLorentzVector &momentum) const
Definition CbmMCTrack.h:173
Double_t FitToVertex(CbmStsTrack *track, CbmVertex *vtx, FairTrackParam *v_track)
Double_t GetChiToVertex(CbmStsTrack *track, CbmVertex *vtx=nullptr)
void SetVertex(double x, double y, double z, double chi2, int32_t ndf, int32_t nTracks, const TMatrixFSym &covMat)
Double_t fAngle
Definition LmvmKinePar.h:23
Double_t fMinv
Definition LmvmKinePar.h:22
Double_t fPt
Definition LmvmKinePar.h:20
Double_t fMomentumMag
Definition LmvmKinePar.h:19
Double_t fRapidity
Definition LmvmKinePar.h:21