Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
TrackSmearMomentumPercent.cxx
1/*
2 * TrackSmearMomentumPercent.cxx
3 *
4 * Created on: 8 gru 2015
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "TrackSmearMomentumPercent.h"
11
12#include <TLorentzVector.h>
13#include <TMath.h>
14#include <TRandom.h>
15
16#include "Package.h"
17#include "Parameter.h"
18#include "SmearedTrack.h"
19#include "Track.h"
20
21
22namespace Hal {
23 TrackSmearMomentumPercent::TrackSmearMomentumPercent() :
24 TrackSmear(), fPxSmear(0.0), fPySmear(0.0), fPzSmear(0.0), fPtSmear(0.0), fSmearMode(0) {}
25
26 void TrackSmearMomentumPercent::SetMomentumSmear(Double_t pt) {
27 fPtSmear = pt;
28 fPzSmear = 0.0;
29 fPxSmear = 0.0;
30 fPySmear = 0.0;
31 }
32
33 void TrackSmearMomentumPercent::SetMomentumSmear(Double_t pt, Double_t pz) {
34 fPtSmear = pt;
35 fPzSmear = pz;
36 fPxSmear = fPySmear = 0.0;
37 }
38
39 void TrackSmearMomentumPercent::SetMomentumSmear(Double_t px, Double_t py, Double_t pz) {
40 fPtSmear = 0.0;
41 fPxSmear = px;
42 fPySmear = py;
43 fPzSmear = pz;
44 }
45
46 Package* TrackSmearMomentumPercent::Report() const {
47 Package* pack = TrackSmear::Report();
48 Double_t px_smear;
49 Double_t py_smear;
50 if (fSmearMode == 1 || fSmearMode == 2) {
51 px_smear = 0.0;
52 py_smear = 0.0;
53 } else {
54 px_smear = fPxSmear;
55 py_smear = fPySmear;
56 }
57 pack->AddObject(new ParameterDouble("Smear of px (%)", px_smear * 100.0));
58 pack->AddObject(new ParameterDouble("Smear of py (%)", py_smear * 100.0));
59 pack->AddObject(new ParameterDouble("Smear of pz (%)", fPzSmear * 100.0));
60 pack->AddObject(new ParameterDouble("Smear of pt (%)", fPtSmear));
61 return pack;
62 }
63
64 void TrackSmearMomentumPercent::ModifyTrack(SmearedTrack* mod) {
65 Double_t px, py, pz, e;
66 TLorentzVector* true_mom = mod->GetTrueMomentum();
67 px = true_mom->Px();
68 py = true_mom->Py();
69 pz = true_mom->Pz();
70 e = true_mom->E();
71 Double_t m2 = e * e - px * px - py * py - pz * pz;
72 switch (fSmearMode) {
73 case 1: // pt only
74 {
75 px = px * (1. + gRandom->Gaus(0, fPxSmear));
76 py = py * (1. + gRandom->Gaus(0, fPySmear));
77 } break;
78 default: {
79 px = px * (1. + gRandom->Gaus(0, fPxSmear));
80 py = py * (1. + gRandom->Gaus(0, fPySmear));
81 pz = pz * (1. + gRandom->Gaus(0, fPzSmear));
82 } break;
83 }
84 e = TMath::Sqrt(m2 + px * px + py * py + pz * pz);
85 mod->SetMomentum(px, py, pz, e);
86 }
87
88 Task::EInitFlag TrackSmearMomentumPercent::Init() {
89 if (fPtSmear != 0) fSmearMode = 1;
90 if (fPzSmear != 0) fSmearMode = 2;
91 if (fPxSmear != 0) fSmearMode = 3;
92 switch (fSmearMode) {
93 case 1: // pt only
94 {
95 fPxSmear = fPtSmear / TMath::Sqrt(2.0) / 100.0;
96 fPySmear = fPtSmear / TMath::Sqrt(2.0) / 100.0;
97 } break;
98 case 2: // pt and pz
99 {
100 fPxSmear = fPtSmear / TMath::Sqrt(2.0) / 100.0;
101 fPySmear = fPtSmear / TMath::Sqrt(2.0) / 100.0;
102 } break;
103 case 3: {
104 fPxSmear = fPxSmear / 100.0;
105 fPySmear = fPySmear / 100.0;
106 fPzSmear = fPzSmear / 100.0;
107 } break;
108 }
109 return Task::EInitFlag::kSUCCESS;
110 }
111
112 TrackSmearMomentumPercent::TrackSmearMomentumPercent(const TrackSmearMomentumPercent& obj) :
113 TrackSmear(obj),
114 fPxSmear(obj.fPxSmear),
115 fPySmear(obj.fPySmear),
116 fPzSmear(obj.fPzSmear),
117 fPtSmear(obj.fPtSmear),
118 fSmearMode(obj.fSmearMode) {}
119
120 TrackSmearMomentumPercent::~TrackSmearMomentumPercent() {
121 // TODO Auto-generated destructor stub
122 }
123} // namespace Hal
void AddObject(TObject *object)
Definition Package.cxx:209
void SetMomentum(Double_t px, Double_t py, Double_t pz, Double_t e)
Definition Track.h:152