PYTHIA  8.311
ProcessContainer.h
1 // ProcessContainer.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 the collected machinery of a process.
7 // ProcessContainer: contains information on a particular process.
8 // SetupContainers: administrates the selection/creation of processes.
9 
10 #ifndef Pythia8_ProcessContainer_H
11 #define Pythia8_ProcessContainer_H
12 
13 #include "Pythia8/Basics.h"
14 #include "Pythia8/BeamParticle.h"
15 #include "Pythia8/Event.h"
16 #include "Pythia8/Info.h"
17 #include "Pythia8/ParticleData.h"
18 #include "Pythia8/PartonDistributions.h"
19 #include "Pythia8/PhaseSpace.h"
20 #include "Pythia8/PhysicsBase.h"
21 #include "Pythia8/PythiaStdlib.h"
22 #include "Pythia8/ResonanceDecays.h"
23 #include "Pythia8/Settings.h"
24 #include "Pythia8/SigmaProcess.h"
25 #include "Pythia8/SigmaTotal.h"
26 #include "Pythia8/SigmaOnia.h"
27 #include "Pythia8/StandardModel.h"
28 #include "Pythia8/SusyCouplings.h"
29 #include "Pythia8/SLHAinterface.h"
30 #include "Pythia8/UserHooks.h"
31 
32 namespace Pythia8 {
33 
34 //==========================================================================
35 
36 // The ProcessContainer class combines pointers to matrix element and
37 // phase space generator with general generation info.
38 
39 class ProcessContainer : public PhysicsBase {
40 
41 public:
42 
43  // Constructor.
44  ProcessContainer(SigmaProcessPtr sigmaProcessPtrIn = 0,
45  PhaseSpacePtr phaseSpacePtrIn = 0) :
46  sigmaProcessPtr(sigmaProcessPtrIn),
47  phaseSpacePtr(phaseSpacePtrIn), resDecaysPtr(), gammaKinPtr(),
48  matchInOut(), idRenameBeams(), setLifetime(), setQuarkMass(),
49  setLeptonMass(), idNewM(), mRecalculate(), mNewM(), isLHA(), isNonDiff(),
50  isResolved(), isDiffA(), isDiffB(), isDiffC(), isQCD3body(),
51  allowNegSig(), isSameSave(), increaseMaximum(), canVetoResDecay(),
52  lhaStrat(), lhaStratAbs(), processCode(), useStrictLHEFscales(),
53  isAsymLHA(), betazLHA(), newSigmaMx(), nTry(), nSel(), nAcc(),
54  nTryStat(), sigmaMx(), sigmaSgn(), sigmaSum(), sigma2Sum(), sigmaNeg(),
55  sigmaAvg(), sigmaFin(), deltaFin(), weightNow(), wtAccSum(),
56  beamAhasResGamma(), beamBhasResGamma(), beamHasResGamma(),
57  beamHasGamma(), beamAgammaMode(), beamBgammaMode(), gammaModeEvent(),
58  approximatedGammaFlux(), nTryRequested(), nSelRequested(),
59  nAccRequested(), sigmaTemp(), sigma2Temp(), normVar3() {}
60 
61  // Initialize phase space and counters.
62  bool init(bool isFirst, ResonanceDecays* resDecaysPtrIn,
63  SLHAinterface* slhaInterfacePtr, GammaKinematics* gammaKinPtrIn);
64 
65  // Store or replace Les Houches pointer.
66  void setLHAPtr( LHAupPtr lhaUpPtrIn, ParticleData* particleDataPtrIn = 0,
67  Settings* settingsPtrIn = 0, Rndm* rndmPtrIn = 0)
68  {lhaUpPtr = lhaUpPtrIn; setLifetime = 0;
69  if (settingsPtrIn && rndmPtrIn) {
70  rndmPtr = rndmPtrIn;
71  setLifetime = settingsPtrIn->mode("LesHouches:setLifetime");
72  }
73  if (particleDataPtrIn != 0) particleDataPtr = particleDataPtrIn;
74  if (sigmaProcessPtr != 0) sigmaProcessPtr->setLHAPtr(lhaUpPtr);
75  if (phaseSpacePtr != 0) phaseSpacePtr->setLHAPtr(lhaUpPtr);}
76 
77  // Switch to new beam particle identities; for similar hadrons only.
78  void updateBeamIDs() {phaseSpacePtr->updateBeamIDs();}
79 
80  // Update the CM energy of the event.
81  void newECM(double eCM) {phaseSpacePtr->newECM(eCM);}
82 
83  // Generate a trial event; accepted or not.
84  bool trialProcess();
85 
86  // Pick flavours and colour flow of process.
87  bool constructState();
88 
89  // Give the hard subprocess (with option for a second hard subprocess).
90  bool constructProcess( Event& process, bool isHardest = true);
91 
92  // Give the Les Houches decay chain for external resonance.
93  bool constructDecays( Event& process);
94 
95  // Do resonance decays.
96  bool decayResonances( Event& process);
97 
98  // Accumulate statistics after user veto.
99  void accumulate();
100 
101  // Reset statistics on events generated so far.
102  void reset();
103 
104  // Set whether (photon) beam is resolved or unresolved.
105  // Method propagates the choice of photon process type to beam pointers.
106  void setBeamModes(bool setVMD = false, bool isSampled = true);
107 
108  // Process name and code, and the number of final-state particles.
109  string name() const {return sigmaProcessPtr->name();}
110  int code() const {return sigmaProcessPtr->code();}
111  int nFinal() const {return sigmaProcessPtr->nFinal();}
112  bool isSUSY() const {return sigmaProcessPtr->isSUSY();}
113  bool isNonDiffractive() const {return isNonDiff;}
114  bool isSoftQCD() const {return (code() > 100 && code() < 107);}
115  bool isElastic() const {return (code() == 102);}
116 
117  // Member functions for info on generation process.
118  bool newSigmaMax() const {return newSigmaMx;}
119  double sigmaMax() const {return sigmaMx;}
120  long nTried() const {return nTry;}
121  long nSelected() const {return nSel;}
122  long nAccepted() const {return nAcc;}
123  double weightSum() const {return wtAccSum;}
124  double sigmaSelMC( bool doAccumulate = true)
125  { if (nTry > nTryStat && doAccumulate) sigmaDelta(); return sigmaAvg;}
126  double sigmaMC( bool doAccumulate = true)
127  { if (nTry > nTryStat && doAccumulate) sigmaDelta(); return sigmaFin;}
128  double deltaMC( bool doAccumulate = true)
129  { if (nTry > nTryStat && doAccumulate) sigmaDelta(); return deltaFin;}
130 
131  // New value for switched beam identity or energy (for SoftQCD processes).
132  double sigmaMaxSwitch() {sigmaMx = phaseSpacePtr->sigmaMaxSwitch();
133  return sigmaMx;}
134 
135  // Some kinematics quantities.
136  int id1() const {return sigmaProcessPtr->id(1);}
137  int id2() const {return sigmaProcessPtr->id(2);}
138  double x1() const {return phaseSpacePtr->x1();}
139  double x2() const {return phaseSpacePtr->x2();}
140  double Q2Fac() const {return sigmaProcessPtr->Q2Fac();}
141  double mHat() const {return sqrtpos(phaseSpacePtr->sHat());}
142  double pTHat() const {return phaseSpacePtr->pTHat();}
143 
144  // Tell whether container is for Les Houches events.
145  bool isLHAContainer() const {return isLHA;}
146  int lhaStrategy() const {return lhaStrat;}
147 
148  // Info on Les Houches events.
149  int codeLHASize() const {return codeLHA.size();}
150  int subCodeLHA(int i) const {return codeLHA[i];}
151  long nTriedLHA(int i) const {return nTryLHA[i];}
152  long nSelectedLHA(int i) const {return nSelLHA[i];}
153  long nAcceptedLHA(int i) const {return nAccLHA[i];}
154 
155  // When two hard processes set or get info whether process is matched.
156  void isSame( bool isSameIn) { isSameSave = isSameIn;}
157  bool isSame() const {return isSameSave;}
158 
159 private:
160 
161  // Constants: could only be changed in the code itself.
162  static const int N12SAMPLE, N3SAMPLE;
163 
164  // Pointer to the subprocess matrix element. Mark if external.
165  SigmaProcessPtr sigmaProcessPtr;
166 
167  // Pointer to the phase space generator.
168  PhaseSpacePtr phaseSpacePtr;
169 
170  // Pointer to ResonanceDecays object for sequential resonance decays.
171  ResonanceDecays* resDecaysPtr;
172 
173  // Pointer to LHAup for generating external events.
174  LHAupPtr lhaUpPtr;
175 
176  // Pointer to the phase space generator of photons from leptons.
177  GammaKinematics* gammaKinPtr;
178 
179  // Possibility to modify Les Houches input.
180  bool matchInOut;
181  int idRenameBeams, setLifetime, setQuarkMass, setLeptonMass, idNewM[9];
182  double mRecalculate, mNewM[9];
183 
184  // Info on process.
185  bool isLHA, isNonDiff, isResolved, isDiffA, isDiffB, isDiffC, isQCD3body,
186  allowNegSig, isSameSave, increaseMaximum, canVetoResDecay;
187  int lhaStrat, lhaStratAbs, processCode;
188  bool useStrictLHEFscales;
189 
190  // Boost Les Houches events to CM frame (when originally asymmetric).
191  bool isAsymLHA;
192  double betazLHA;
193 
194  // Statistics on generation process. (Long integers just in case.)
195  bool newSigmaMx;
196  long nTry, nSel, nAcc, nTryStat;
197  double sigmaMx, sigmaSgn, sigmaSum, sigma2Sum, sigmaNeg, sigmaAvg,
198  sigmaFin, deltaFin, weightNow, wtAccSum;
199 
200  // Flags to store whether beam has a (un)resolved photon.
201  bool beamAhasResGamma, beamBhasResGamma, beamHasResGamma, beamHasGamma;
202  int beamAgammaMode, beamBgammaMode, gammaModeEvent;
203 
204  // Use approximated photon flux for process sampling.
205  bool approximatedGammaFlux;
206 
207  // Statistics for Les Houches event classification.
208  vector<int> codeLHA;
209  vector<long> nTryLHA, nSelLHA, nAccLHA;
210 
211  // More fine-grained event counting.
212  long nTryRequested, nSelRequested, nAccRequested;
213 
214  // Temporary summand for handling (weighted) events when vetoes are applied.
215  double sigmaTemp, sigma2Temp, normVar3;
216 
217  // Estimate integrated cross section and its uncertainty.
218  void sigmaDelta();
219 
220 };
221 
222 //==========================================================================
223 
224 // The SetupContainers class turns the list of user-requested processes
225 // into a vector of ProcessContainer objects, each with a process.
226 
228 
229 public:
230 
231  // Constructor.
232  SetupContainers() : nVecA(), nVecB() {}
233 
234  // Initialization assuming all necessary data already read.
235  bool init(vector<ProcessContainer*>& containerPtrs, Info* infoPtr);
236 
237  // Initialization of a second hard process.
238  bool init2(vector<ProcessContainer*>& container2Ptrs, Info* infoPtr);
239 
240 private:
241 
242  // Methods to check that outgoing SUSY particles are allowed ones.
243  void setupIdVecs( Settings& settings);
244  bool allowIdVals( int idCheck1, int idCheck2);
245 
246  // Arrays of allowed outgoing SUSY particles and their lengths.
247  vector<int> idVecA, idVecB;
248  int nVecA, nVecB;
249 
250  // Helper class to setup onia production.
251  SigmaOniaSetup charmonium, bottomonium;
252 
253 };
254 
255 //==========================================================================
256 
257 } // end namespace Pythia8
258 
259 #endif // Pythia8_ProcessContainer_H
ProcessContainer(SigmaProcessPtr sigmaProcessPtrIn=0, PhaseSpacePtr phaseSpacePtrIn=0)
Constructor.
Definition: ProcessContainer.h:44
void accumulate()
Accumulate statistics after user veto.
Definition: ProcessContainer.cc:441
double sigmaMaxSwitch()
New value for switched beam identity or energy (for SoftQCD processes).
Definition: ProcessContainer.h:132
Definition: PhysicsBase.h:27
Definition: Info.h:45
void newECM(double eCM)
Update the CM energy of the event.
Definition: ProcessContainer.h:81
The Event class holds all info on the generated event.
Definition: Event.h:453
bool trialProcess()
Generate a trial event; accepted or not.
Definition: ProcessContainer.cc:259
Definition: ProcessContainer.h:39
Definition: SLHAinterface.h:27
bool constructProcess(Event &process, bool isHardest=true)
Give the hard subprocess (with option for a second hard subprocess).
Definition: ProcessContainer.cc:525
void isSame(bool isSameIn)
When two hard processes set or get info whether process is matched.
Definition: ProcessContainer.h:156
bool init(bool isFirst, ResonanceDecays *resDecaysPtrIn, SLHAinterface *slhaInterfacePtr, GammaKinematics *gammaKinPtrIn)
Initialize phase space and counters.
Definition: ProcessContainer.cc:48
Rndm * rndmPtr
Pointer to the random number generator.
Definition: PhysicsBase.h:93
SetupContainers()
Constructor.
Definition: ProcessContainer.h:232
A helper class used to setup the onia processes.
Definition: SigmaOnia.h:63
int id1() const
Some kinematics quantities.
Definition: ProcessContainer.h:136
ParticleData * particleDataPtr
Pointer to the particle data table.
Definition: PhysicsBase.h:84
bool newSigmaMax() const
Member functions for info on generation process.
Definition: ProcessContainer.h:118
Definition: Basics.h:385
int codeLHASize() const
Info on Les Houches events.
Definition: ProcessContainer.h:149
void setLHAPtr(LHAupPtr lhaUpPtrIn, ParticleData *particleDataPtrIn=0, Settings *settingsPtrIn=0, Rndm *rndmPtrIn=0)
Store or replace Les Houches pointer.
Definition: ProcessContainer.h:66
void reset()
Reset statistics on events generated so far.
Definition: ProcessContainer.cc:1322
Class to sample the virtuality and transverse momentum of emitted photons.
Definition: GammaKinematics.h:23
string name() const
Process name and code, and the number of final-state particles.
Definition: ProcessContainer.h:109
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
void setBeamModes(bool setVMD=false, bool isSampled=true)
Set the photon modes according to the process.
Definition: ProcessContainer.cc:488
Info * infoPtr
Definition: PhysicsBase.h:78
bool decayResonances(Event &process)
Do resonance decays.
Definition: ProcessContainer.cc:1262
Definition: ProcessContainer.h:227
Definition: ResonanceDecays.h:28
bool constructDecays(Event &process)
Give the Les Houches decay chain for external resonance.
Definition: ProcessContainer.cc:1138
This class holds a map of all ParticleDataEntries.
Definition: ParticleData.h:422
void updateBeamIDs()
Switch to new beam particle identities; for similar hadrons only.
Definition: ProcessContainer.h:78
bool constructState()
Pick flavours and colour flow of process.
Definition: ProcessContainer.cc:468
Definition: Settings.h:195
bool isLHAContainer() const
Tell whether container is for Les Houches events.
Definition: ProcessContainer.h:145
double sqrtpos(const double &x)
Avoid problem with negative square root argument (from roundoff).
Definition: PythiaStdlib.h:191