PYTHIA  8.312
BeamSetup.h
1 // BeamSetup.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2024 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // This file contains a helper class for the setup of beam flavour,
7 // kinematics and PDFs.
8 
9 #ifndef Pythia8_BeamSetup_H
10 #define Pythia8_BeamSetup_H
11 
12 #include "Pythia8/Basics.h"
13 #include "Pythia8/BeamParticle.h"
14 #include "Pythia8/BeamShape.h"
15 #include "Pythia8/HadronLevel.h"
16 #include "Pythia8/Info.h"
17 #include "Pythia8/LesHouches.h"
18 #include "Pythia8/ParticleData.h"
19 #include "Pythia8/PartonDistributions.h"
20 #include "Pythia8/PartonLevel.h"
21 #include "Pythia8/PhysicsBase.h"
22 #include "Pythia8/ProcessLevel.h"
23 #include "Pythia8/PythiaStdlib.h"
24 #include "Pythia8/Settings.h"
25 
26 namespace Pythia8 {
27 
28 //==========================================================================
29 
30 // The BeamSetup class contains a number of routines auxiliary to Pythia
31 // to set up beam flavour, kinematics and PDFs.
32 
33 class BeamSetup : public PhysicsBase {
34 
35 public:
36 
37  // Constructor.
38  BeamSetup() = default;
39 
40  // Possibility to pass in pointers to PDF's.
41  bool setPDFPtr( PDFPtr pdfAPtrIn, PDFPtr pdfBPtrIn,
42  PDFPtr pdfHardAPtrIn = nullptr, PDFPtr pdfHardBPtrIn = nullptr,
43  PDFPtr pdfPomAPtrIn = nullptr, PDFPtr pdfPomBPtrIn = nullptr,
44  PDFPtr pdfGamAPtrIn = nullptr, PDFPtr pdfGamBPtrIn = nullptr,
45  PDFPtr pdfHardGamAPtrIn = nullptr, PDFPtr pdfHardGamBPtrIn = nullptr,
46  PDFPtr pdfUnresAPtrIn = nullptr, PDFPtr pdfUnresBPtrIn = nullptr,
47  PDFPtr pdfUnresGamAPtrIn = nullptr, PDFPtr pdfUnresGamBPtrIn = nullptr,
48  PDFPtr pdfVMDAPtrIn = nullptr, PDFPtr pdfVMDBPtrIn = nullptr);
49  bool setPDFAPtr( PDFPtr pdfAPtrIn );
50  bool setPDFBPtr( PDFPtr pdfBPtrIn );
51 
52  // Set photon fluxes externally. Used with option "PDF:lepton2gammaSet = 2".
53  bool setPhotonFluxPtr( PDFPtr photonFluxAIn, PDFPtr photonFluxBIn) {
54  if ( photonFluxAIn ) pdfGamFluxAPtr = photonFluxAIn;
55  if ( photonFluxBIn ) pdfGamFluxBPtr = photonFluxBIn;
56  return true;}
57 
58  // Possibility to pass in pointer to external LHA-interfaced generator.
59  bool setLHAupPtr( LHAupPtr lhaUpPtrIn) {lhaUpPtr = lhaUpPtrIn;
60  useNewLHA = false; return true;}
61 
62  // For a given particle id, get a particle that represents its properties,
63  // i.e. a particle with the same PDF shape and parameters.
64  int represent(int idIn) const;
65 
66  // Switch to new beam particle identities; for similar hadrons only.
67  bool setBeamIDs( int idAin, int idBin = 0);
68 
69  // Switch beam kinematics.
70  bool setKinematics(double eCMIn);
71  bool setKinematics(double eAIn, double eBIn);
72  bool setKinematics(double pxAIn, double pyAIn, double pzAIn,
73  double pxBIn, double pyBIn, double pzBIn);
74  bool setKinematics(Vec4 pAIn, Vec4 pBIn);
75 
76  // Possibility to pass in pointer for beam shape.
77  bool setBeamShapePtr( BeamShapePtr beamShapePtrIn) {
78  beamShapePtr = beamShapePtrIn; return true;}
79 
80  // Possibility to access the pointer to the BeamShape object.
81  BeamShapePtr getBeamShapePtr() { return beamShapePtr; }
82 
83  // Return a parton density set among list of possibilities.
84  PDFPtr getPDFPtr(int idIn, int sequence = 1, string beam = "A",
85  bool resolved = true);
86 
87  // Return a map of the PDF pointers.
88  map<string, PDFPtr> getPDFPtr();
89 
90  // Set up frame of beams, Les Houches input, and switches for beam handling.
91  bool initFrame();
92 
93  // Initialize kinematics and PDFs of beams.
94  bool initBeams(bool doNonPertIn, StringFlav* flavSelPtr);
95 
96  // Return whether VMD states sampled.
97  bool getVMDsideA() { return doVMDsideA; }
98  bool getVMDsideB() { return doVMDsideB; }
99 
100  // Clear all beams.
101  void clear();
102 
103  // Pick new beam valence flavours (for pi0, eta, K0S, Pomeron, etc.).
104  void newValenceContent();
105 
106  // Recalculate kinematics for each event when beam momentum has a spread.
107  void nextKinematics();
108 
109  // Boost from CM frame to lab frame, or inverse. Set production vertex.
110  void boostAndVertex( Event& process, Event& event, bool toLab,
111  bool setVertex);
112 
113  // Print parton lists for the main beams. For debug mainly.
114  void list() const { beamA.list(); beamB.list(); }
115 
116  // Some data values are kept public so that the Pythia class can access them.
117  bool doLHA = false, useNewLHA = false, skipInit = false,
118  doMomentumSpread = {}, doVertexSpread = {}, doVarEcm = {},
119  allowIDAswitch = {}, hasSwitchedIDs = {}, beamA2gamma = {},
120  beamB2gamma = {};
121  int idA = {}, idB = {}, frameType = {}, boostType = {}, iPDFAsave = {},
122  gammaMode = {};
123  double mA = {}, mB = {}, pxA = {}, pxB = {}, pyA = {}, pyB = {}, pzA = {},
124  pzB = {}, eA = {}, eB = {}, pzAcm = {}, pzBcm = {}, eCM = {},
125  betaZ = {}, gammaZ = {};
126  Vec4 pAinit = {}, pBinit = {}, pAnow = {}, pBnow = {};
127  RotBstMatrix MfromCM = {}, MtoCM = {};
128  LHAupPtr lhaUpPtr = {};
129 
130  // The two incoming beams.
132  BeamParticle beamB = {};
133 
134  // Alternative Pomeron beam-inside-beam.
136  BeamParticle beamPomB = {};
137 
138  // Alternative photon beam-inside-beam.
140  BeamParticle beamGamB = {};
141 
142  // Alternative VMD beam-inside-beam.
144  BeamParticle beamVMDB = {};
145 
146  // Hadron types for rapid switching.
147  vector<int> idAList = { 2212, 211, 311, 221,
148  331, 333, 411, 431, 443, 511, 531, 541, 553, 3212, 3312, 3334,
149  4112, 4312, 4332, 5112, 5312, 5332};
150 
151 protected:
152 
153  void onInitInfoPtr() override {
154  registerSubObject(beamA);
155  registerSubObject(beamB);
156  registerSubObject(beamPomA);
157  registerSubObject(beamPomB);
158  registerSubObject(beamGamA);
159  registerSubObject(beamGamB);
160  registerSubObject(beamVMDA);
161  registerSubObject(beamVMDB);
162  }
163 
164 private:
165 
166  // Initialization data, plus some event-specific.
167  bool doNonPert = {}, doDiffraction = {}, doSoftQCD = {},
168  doHardDiff = {}, doProcessLevel = {}, doPartonVertex = {},
169  doVertexPlane = {}, isUnresolvedA = {}, isUnresolvedB = {},
170  doVMDsideA = {}, doVMDsideB = {}, beamAResGamma = {},
171  beamBResGamma = {}, beamAUnresGamma = {}, beamBUnresGamma = {};
172 
173  // Pointers to the PDFs of beams, with several alternatives.
174  PDFPtr pdfAPtr = {}, pdfBPtr = {}, pdfHardAPtr = {}, pdfHardBPtr = {},
175  pdfPomAPtr = {}, pdfPomBPtr = {}, pdfGamAPtr = {}, pdfGamBPtr = {},
176  pdfHardGamAPtr = {}, pdfHardGamBPtr = {}, pdfUnresAPtr = {},
177  pdfUnresBPtr = {}, pdfUnresGamAPtr = {}, pdfUnresGamBPtr = {},
178  pdfGamFluxAPtr = {}, pdfGamFluxBPtr = {}, pdfVMDAPtr = {},
179  pdfVMDBPtr = {};
180 
181  // Array of PDFs to be used when idA can be changed between events.
182  vector<PDFPtr> pdfASavePtrs = {};
183 
184  // Pointer to BeamShape object for beam momentum and interaction vertex.
185  BeamShapePtr beamShapePtr = {};
186 
187  // Check that beams and beam combination can be handled.
188  bool checkBeams();
189 
190  // Calculate kinematics at initialization.
191  bool initKinematics();
192 
193  // Set up pointers to PDFs.
194  bool initPDFs();
195 
196  // Create an LHAPDF plugin PDF.
197  PDFPtr initLHAPDF(int idIn, string cfg);
198 
199 };
200 
201 //==========================================================================
202 
203 } // end namespace Pythia8
204 
205 #endif // Pythia8_BeamSetup_H
BeamParticle beamVMDA
Alternative VMD beam-inside-beam.
Definition: BeamSetup.h:143
bool setPDFAPtr(PDFPtr pdfAPtrIn)
Routine to pass in pointers to PDF&#39;s. Usage optional.
Definition: BeamSetup.cc:105
Definition: PhysicsBase.h:27
void registerSubObject(PhysicsBase &pb)
Register a sub object that should have its information in sync with this.
Definition: PhysicsBase.cc:56
Definition: BeamSetup.h:33
void newValenceContent()
Pick new beam valence flavours (for pi0, eta, K0S, Pomeron, etc.).
Definition: BeamSetup.cc:617
The Event class holds all info on the generated event.
Definition: Event.h:453
Definition: BeamParticle.h:133
bool setKinematics(double eCMIn)
Switch beam kinematics.
Definition: BeamSetup.cc:258
bool setPhotonFluxPtr(PDFPtr photonFluxAIn, PDFPtr photonFluxBIn)
Set photon fluxes externally. Used with option "PDF:lepton2gammaSet = 2".
Definition: BeamSetup.h:53
void clear()
Clear all beams.
Definition: BeamSetup.cc:602
void onInitInfoPtr() override
Definition: BeamSetup.h:153
BeamSetup()=default
Constructor.
bool setPDFPtr(PDFPtr pdfAPtrIn, PDFPtr pdfBPtrIn, PDFPtr pdfHardAPtrIn=nullptr, PDFPtr pdfHardBPtrIn=nullptr, PDFPtr pdfPomAPtrIn=nullptr, PDFPtr pdfPomBPtrIn=nullptr, PDFPtr pdfGamAPtrIn=nullptr, PDFPtr pdfGamBPtrIn=nullptr, PDFPtr pdfHardGamAPtrIn=nullptr, PDFPtr pdfHardGamBPtrIn=nullptr, PDFPtr pdfUnresAPtrIn=nullptr, PDFPtr pdfUnresBPtrIn=nullptr, PDFPtr pdfUnresGamAPtrIn=nullptr, PDFPtr pdfUnresGamBPtrIn=nullptr, PDFPtr pdfVMDAPtrIn=nullptr, PDFPtr pdfVMDBPtrIn=nullptr)
Possibility to pass in pointers to PDF&#39;s.
Definition: BeamSetup.cc:21
bool initFrame()
Set up frame of beams, Les Houches input, and switches for beam handling.
Definition: BeamSetup.cc:342
BeamParticle beamPomA
Alternative Pomeron beam-inside-beam.
Definition: BeamSetup.h:135
bool doLHA
Some data values are kept public so that the Pythia class can access them.
Definition: BeamSetup.h:117
BeamParticle beamA
The two incoming beams.
Definition: BeamSetup.h:131
map< string, PDFPtr > getPDFPtr()
Return a map of the PDF pointers.
Definition: BeamSetup.cc:1558
BeamParticle beamGamA
Alternative photon beam-inside-beam.
Definition: BeamSetup.h:139
bool setBeamIDs(int idAin, int idBin=0)
Switch to new beam particle identities; for similar hadrons only.
Definition: BeamSetup.cc:180
bool setLHAupPtr(LHAupPtr lhaUpPtrIn)
Possibility to pass in pointer to external LHA-interfaced generator.
Definition: BeamSetup.h:59
void list() const
Print extracted parton list; for debug mainly.
Definition: BeamParticle.cc:1309
bool getVMDsideA()
Return whether VMD states sampled.
Definition: BeamSetup.h:97
void list() const
Print parton lists for the main beams. For debug mainly.
Definition: BeamSetup.h:114
bool initBeams(bool doNonPertIn, StringFlav *flavSelPtr)
Initialize kinematics and PDFs of beams.
Definition: BeamSetup.cc:505
Definition: Basics.h:252
bool setPDFBPtr(PDFPtr pdfBPtrIn)
Routine to pass in pointers to PDF&#39;s. Usage optional.
Definition: BeamSetup.cc:129
int represent(int idIn) const
Definition: BeamSetup.cc:151
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
The StringFlav class is used to select quark and hadron flavours.
Definition: FragmentationFlavZpT.h:84
BeamShapePtr getBeamShapePtr()
Possibility to access the pointer to the BeamShape object.
Definition: BeamSetup.h:81
vector< int > idAList
Hadron types for rapid switching.
Definition: BeamSetup.h:147
void boostAndVertex(Event &process, Event &event, bool toLab, bool setVertex)
Boost from CM frame to lab frame, or inverse. Set production vertex.
Definition: BeamSetup.cc:701
bool setBeamShapePtr(BeamShapePtr beamShapePtrIn)
Possibility to pass in pointer for beam shape.
Definition: BeamSetup.h:77
Definition: Basics.h:32
void nextKinematics()
Recalculate kinematics for each event when beam momentum has a spread.
Definition: BeamSetup.cc:632