FairShip
Loading...
Searching...
No Matches
FixedTargetGenerator.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_FIXEDTARGETGENERATOR_H_
6#define SHIPGEN_FIXEDTARGETGENERATOR_H_
7
8#include <utility>
9
10#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
11#include "Generator.h"
12#include "Pythia8/Pythia.h"
13#include "TNtuple.h"
14#include "TROOT.h"
15#include "TTree.h"
16
17namespace Pythia8 {
18class EvtGenDecays;
19}
20
21class FairPrimaryGenerator;
22
24 public:
27
30
32 Bool_t ReadEvent(FairPrimaryGenerator*) override;
33 Bool_t Init(const char* inFile) override { return Init(inFile, 0); };
34
35 Bool_t Init(const char* inFile, int startEvent) override {
36 LOG(warning) << "Init with files not implemented for FixedTargetGenerator. "
37 "Using default Init() instead";
38 return Init();
39 };
41 Bool_t Init() override;
42
43 Bool_t InitForCharmOrBeauty(const TString& fInName, Int_t nev,
44 Double_t npots = 5E13, Int_t nStart = 0);
45
46 void SetMom(Double_t mom) { fMom = mom; };
47 void UseRandom1() {
48 fUseRandom1 = kTRUE;
49 fUseRandom3 = kFALSE;
50 };
51 void UseRandom3() {
52 fUseRandom1 = kFALSE;
53 fUseRandom3 = kTRUE;
54 };
55 void SetTarget(TString s, Double_t x, Double_t y) {
56 targetName = std::move(s);
57 xOff = x;
58 yOff = y;
59 };
60 void SetZoffset(Double_t z) { zOff = z; };
61 void SetXoffset(Double_t x) { xOff = x; };
62 void SetYoffset(Double_t y) { yOff = y; };
63 void SetSmearBeam(Double_t sb) { fsmearBeam = sb; };
64 void SetPaintRadius(Double_t r) { fPaintBeam = r; };
65 void SetTargetCoordinates(Double_t start_z, Double_t end_z) {
66 startZ = start_z;
67 endZ = end_z;
68 targetFromGeometry = true;
69 };
70 void SetBoost(Double_t f) {
71 fBoost = f;
72 } // boost factor for rare di-muon decays
73 void SetG4only() {
74 G4only = true;
75 } // only run Geant4, no pythia primary interaction
76 void SetTauOnly() { tauOnly = true; } // only have Ds decay to tau
77 void SetJpsiMainly() { JpsiMainly = true; } // let all Jpsi decay to mumu
78 void SetOnlyMuons() { OnlyMuons = true; } // only transport muons
79 void SetDrellYan() { DrellYan = true; } // only generate prompt Z0* processes
81 PhotonCollision = true;
82 } // only generate prompt photon processes
83 void WithEvtGen() {
84 withEvtGen = true;
85 } // use EvtGen as external decayer to Pythia, experimental phase, only works
86 // for one Pythia instance
87 void SetChibb(Double_t x) {
88 chibb = x;
89 } // chibb = bbbar over mbias cross section
90 void SetChicc(Double_t x) {
91 chicc = x;
92 } // chicc = ccbar over mbias cross section
93 inline void SetSeed(Double_t seed) { fSeed = seed; }
94 inline void SetHeartBeat(Int_t x) { heartbeat = x; }
95 inline void SetEnergyCut(Float_t emax) {
96 EMax = emax;
97 } // min energy to be copied to Geant4
98 inline void SetDebug(Bool_t x) { Debug = x; }
99 // Pythia8 tune for the primary interaction: "" or "default" (Monash 2013) or
100 // "FTFT" (fixed-target open charm and beauty tune, arXiv:2608.29076)
101 inline void SetPythiaTune(const TString& tune) {
102 fTune = (tune == "default") ? "" : tune;
103 }
104 inline void SetOpt4DP(TNtuple* t) {
105 withNtuple = kTRUE;
106 fNtuple = t;
107 }
108 Double_t GetPotForCharm() { return nrpotspill / wspill; }
109 Pythia8::Pythia* GetPythia() { return fPythiaP; }
110 Pythia8::Pythia* GetPythiaN() { return fPythiaN; }
111
112 private:
113 std::shared_ptr<Pythia8::RndmEngine> fRandomEngine;
114
115 protected:
116 Double_t fMom; // proton momentum
117 Bool_t fUseRandom1; // flag to use TRandom1
118 Bool_t fUseRandom3; // flag to use TRandom3 (default)
120 Double_t pot; // proton-on-target counter, incremented by 0.5 per signal
124 FairLogger* fLogger;
125 Pythia8::Pythia* fPythiaN;
126 Pythia8::Pythia* fPythiaP;
127 Pythia8::EvtGenDecays* evtgenN;
128 Pythia8::EvtGenDecays* evtgenP;
129 Bool_t withNtuple;
130 TNtuple* fNtuple;
132 TString fTune; // Pythia8 tune name, empty for the Pythia8 default
133 Double_t xOff;
134 Double_t yOff;
135 Double_t zOff;
136 Double_t fsmearBeam; // finite beam size
137 Double_t fPaintBeam; // beam painting radius
138 Double_t start[3];
139 Double_t end[3];
140 Double_t bparam;
141 Double_t mparam[10];
142 Double_t startZ;
143 Double_t endZ;
144 Bool_t targetFromGeometry; // flag to indicate coordinates set from geometry
146 TFile* fin;
147 TNtuple* nTree;
150 // input stores the number of heavy-flavour hadrons per event; files without
151 // it hold exactly two per event
152 Bool_t hasHadronCount = kFALSE;
154};
155#endif // SHIPGEN_FIXEDTARGETGENERATOR_H_
Bool_t InitForCharmOrBeauty(const TString &fInName, Int_t nev, Double_t npots=5E13, Int_t nStart=0)
~FixedTargetGenerator() override
Bool_t ReadEvent(FairPrimaryGenerator *) override
void SetTargetCoordinates(Double_t start_z, Double_t end_z)
void SetTarget(TString s, Double_t x, Double_t y)
Pythia8::Pythia * GetPythiaN()
TNtuple * fNtuple
special option for Dark Photon physics studies
void SetXoffset(Double_t x)
Bool_t Init(const char *inFile, int startEvent) override
void SetPythiaTune(const TString &tune)
void SetEnergyCut(Float_t emax)
void SetSmearBeam(Double_t sb)
void SetYoffset(Double_t y)
Bool_t Init(const char *inFile) override
void SetMom(Double_t mom)
void SetZoffset(Double_t z)
Pythia8::Pythia * GetPythia()
Pythia8::EvtGenDecays * evtgenN
void SetPaintRadius(Double_t r)
Pythia8::Pythia * fPythiaN
don't make it persistent, magic ROOT command
Pythia8::EvtGenDecays * evtgenP
void SetSeed(Double_t seed)
std::shared_ptr< Pythia8::RndmEngine > fRandomEngine
virtual Bool_t Init(const char *, int)=0