FairShip
Loading...
Searching...
No Matches
HNLPythia8Generator.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5#ifndef SHIPGEN_HNLPYTHIA8GENERATOR_H_
6#define SHIPGEN_HNLPYTHIA8GENERATOR_H_
7
8#include <memory>
9
10#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
11#include "Generator.h"
12#include "Pythia8/Pythia.h"
13#include "TFile.h"
14#include "TROOT.h"
15#include "TRandom1.h"
16#include "TRandom3.h"
17#include "TString.h"
18#include "TTree.h"
19
20class FairPrimaryGenerator;
21
22class PyTr1Rng : public Pythia8::RndmEngine {
23 public:
24 PyTr1Rng() : rng(std::make_unique<TRandom1>(gRandom->GetSeed())) {}
25 ~PyTr1Rng() override = default;
26
27 Double_t flat() override { return rng->Rndm(); };
28
29 private:
30 std::unique_ptr<TRandom1> rng;
31};
32
33class PyTr3Rng : public Pythia8::RndmEngine {
34 public:
35 PyTr3Rng() : rng(std::make_unique<TRandom3>(gRandom->GetSeed())) {}
36 ~PyTr3Rng() override = default;
37
38 Double_t flat() override { return rng->Rndm(); };
39
40 private:
41 std::unique_ptr<TRandom3> rng;
42};
43
45 public:
48
50 ~HNLPythia8Generator() override;
51
53 Bool_t ReadEvent(FairPrimaryGenerator*) override;
54 void SetParameters(char*);
55 using TObject::Print;
56 void Print() { fPythia->settings.listAll(); };
57 void List(int id) { fPythia->particleData.list(id); };
58
60
61 Bool_t Init(const char* inFile) override { return Init(inFile, 0); };
62
63 Bool_t Init(const char* inFile, int startEvent) override {
64 LOG(warning) << "Init with files not implemented for HNLPythia8Generator. "
65 "Using default Init() instead";
66 return Init();
67 };
68 Bool_t Init() override;
69
70 void SetMom(Double_t mom) { fMom = mom; };
71 void SetId(Double_t id) { fId = id; };
72 void SetHNLId(Int_t id) { fHNL = id; };
73 void SetLmin(Double_t z) { fLmin = z * 10; }; // Conversion from cm to mm
74 void SetLmax(Double_t z) { fLmax = z * 10; }; // Conversion from cm to mm
75 void SetSmearBeam(Double_t sb) {
76 fsmearBeam = sb * 10;
77 }; // Conversion from cm to mm
78 void SetPaintRadius(Double_t r) {
79 fPaintBeam = r * 10;
80 }; // Conversion from cm to mm
81 void SetfFDs(Double_t z) { fFDs = z; };
82 void UseRandom1() {
83 fUseRandom1 = kTRUE;
84 fUseRandom3 = kFALSE;
85 };
86 void UseRandom3() {
87 fUseRandom1 = kFALSE;
88 fUseRandom3 = kTRUE;
89 };
90
91 void UseDeepCopy() { fDeepCopy = kTRUE; };
92 Int_t nrOfRetries() { return fnRetries; };
93 Pythia8::Pythia* getPythiaInstance() { return fPythia; };
94 Pythia8::Pythia* fPythia;
95 private:
96 std::shared_ptr<Pythia8::RndmEngine> fRandomEngine;
97
98 protected:
99 Double_t fMom; // proton momentum
100 Int_t fHNL; // HNL ID
101 Int_t fId; // target type
102 Bool_t fUseRandom1{kFALSE}; // flag to use TRandom1
103 Bool_t fUseRandom3{kTRUE}; // flag to use TRandom3 (default)
104 Double_t fLmin; // min decay length along the HNL flight direction (mm)
105 Double_t fLmax; // max decay length along the HNL flight direction (mm)
106 Int_t fnRetries; // retries: no HNL produced
107 Double_t fctau; // Pythia nominal proper lifetime tau0 = proper decay
108 // length c*tau (mm)
109 Double_t fFDs; // correction for Pythia6 to match measured Ds production
110 Double_t fsmearBeam; // finite beam size
111 Double_t fPaintBeam; // beam painting radius
112 TFile* fInputFile;
113 TTree* fTree;
115 Float_t hpx[1], hpy[1], hpz[1], hE[1], hM[1], mpx[1], mpy[1], mpz[1], mE[1],
116 hid[1], mid[1];
117 Bool_t fDeepCopy; // not used
118 FairLogger* fLogger;
119};
120
121#endif // SHIPGEN_HNLPYTHIA8GENERATOR_H_
void SetSmearBeam(Double_t sb)
void SetId(Double_t id)
void SetLmin(Double_t z)
TTree * fTree
pointer to a file
Bool_t Init(const char *inFile, int startEvent) override
void SetLmax(Double_t z)
void SetPaintRadius(Double_t r)
Bool_t ReadEvent(FairPrimaryGenerator *) override
void SetMom(Double_t mom)
std::shared_ptr< Pythia8::RndmEngine > fRandomEngine
Pythia8::Pythia * getPythiaInstance()
Pythia8::Pythia * fPythia
void SetfFDs(Double_t z)
Bool_t Init(const char *inFile) override
~PyTr1Rng() override=default
Double_t flat() override
std::unique_ptr< TRandom1 > rng
Double_t flat() override
~PyTr3Rng() override=default
std::unique_ptr< TRandom3 > rng
virtual Bool_t Init(const char *, int)=0