FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairYPtGenerator.cxx
Go to the documentation of this file.
1 /*
2  * FairYPtGenerator.cxx
3  *
4  * Created on: 6 mar 2020
5  * Author: Daniel Wielanek
6  * E-mail: daniel.wielanek@gmail.com
7  * Warsaw University of Technology, Faculty of Physics
8  */
9 #include "FairYPtGenerator.h"
10 
11 #include "FairLogger.h"
12 #include "FairPrimaryGenerator.h"
13 
14 #include <TDatabasePDG.h>
15 #include <TLorentzVector.h>
16 #include <TParticlePDG.h>
17 #include <TRandom.h>
18 
21  , fYPt()
22 {}
23 
25  : FairBaseMCGenerator(base)
26 {
27  base.fYPt.Copy(this->fYPt);
28  fYPt.SetDirectory(nullptr);
29 }
30 
32 {
33  if (&rhs == this)
34  return *this;
36  rhs.fYPt.Copy(fYPt);
37  fYPt.SetDirectory(nullptr);
38  return *this;
39 }
40 
41 void FairYPtGenerator::SetYPt(const TH2D &yPt)
42 {
43  yPt.Copy(fYPt);
44  fYPt.SetDirectory(nullptr);
45 }
46 
48 {
49  if (FairBaseMCGenerator::Init() == kFALSE)
50  return kFALSE;
51  fYPt.ResetStats();
52  for (int i = 1; i <= fYPt.GetNbinsX(); i++) {
53  for (int j = 1; j < fYPt.GetNbinsY(); j++) {
54  if (fYPt.GetBinContent(i, j) < 0) {
55  LOG(fatal) << "FairYPtGenerator negative entries !";
56  }
57  }
58  }
59  if (fYPt.GetEntries() == 0) {
60  LOG(fatal) << "FairYPtGenerator lack entries !";
61  }
62  return kTRUE;
63 }
64 
66 {
67  Double_t pt, y;
69  for (int i = 0; i < GetMultiplicity(); i++) {
70  GetYPt(y, pt);
71  Double_t e = TMath::Sqrt(pt * pt + GetMass2());
72  Double_t phi = gRandom->Uniform(-TMath::Pi(), TMath::Pi());
73  Double_t pz = TMath::Sign(e * 0.5, y) * TMath::Exp(-y) * (TMath::Exp(2.0 * y) - 1.0);
74  Double_t px = pt * TMath::Cos(phi);
75  Double_t py = pt * TMath::Sin(phi);
76  LOG(debug) << "FairYPtGenerator: " << Form("PDG %i p=(%.2f, %.2f, %.2f) GeV,", GetPDGType(), px, py, pz);
77  primGen->AddTrack(GetPDGType(), px, py, pz, fX, fY, fZ);
78  }
79  return kTRUE;
80 }
81 
83 
84 void FairYPtGenerator::GetYPt(Double_t &y, Double_t &pt) { fYPt.GetRandom2(y, pt); }
85 
virtual Bool_t Init()
void SetYPt(const TH2D &yPt)
virtual FairGenerator * CloneGenerator() const
Int_t GetPDGType() const
void GetYPt(Double_t &y, Double_t &pt)
FairBaseMCGenerator & operator=(const FairBaseMCGenerator &rhs)=default
virtual void AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t pz, Double_t vx, Double_t vy, Double_t vz, Int_t parent=-1, Bool_t wanttracking=true, Double_t e=-9e9, Double_t tof=0., Double_t weight=0., TMCProcess proc=kPPrimary)
virtual void GenerateEventParameters()
virtual ~FairYPtGenerator()
Double_t GetMass2() const
Int_t GetMultiplicity() const
FairYPtGenerator & operator=(const FairYPtGenerator &rhs)
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)