StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ProcessContainer.h
1 // ProcessContainer.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2012 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, 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 "Basics.h"
14 #include "BeamParticle.h"
15 #include "Event.h"
16 #include "Info.h"
17 #include "ParticleData.h"
18 #include "PartonDistributions.h"
19 #include "PhaseSpace.h"
20 #include "PythiaStdlib.h"
21 #include "ResonanceDecays.h"
22 #include "Settings.h"
23 #include "SigmaProcess.h"
24 #include "SigmaTotal.h"
25 #include "StandardModel.h"
26 #include "SusyCouplings.h"
27 #include "SusyLesHouches.h"
28 #include "UserHooks.h"
29 
30 namespace Pythia8 {
31 
32 //==========================================================================
33 
34 // The ProcessContainer class combines pointers to matrix element and
35 // phase space generator with general generation info.
36 
38 
39 public:
40 
41  // Constructor.
42  ProcessContainer(SigmaProcess* sigmaProcessPtrIn = 0,
43  bool externalPtrIn = false) : sigmaProcessPtr(sigmaProcessPtrIn),
44  externalPtr(externalPtrIn), phaseSpacePtr(0) {}
45 
46  // Destructor. Do not destroy external sigmaProcessPtr.
47  ~ProcessContainer() {delete phaseSpacePtr;
48  if (!externalPtr) delete sigmaProcessPtr;}
49 
50  // Initialize phase space and counters.
51  bool init(bool isFirst, Info* infoPtrIn, Settings& settings,
52  ParticleData* particleDataPtrIn, Rndm* rndmPtrIn, BeamParticle* beamAPtr,
53  BeamParticle* beamBPtr, Couplings* couplings, SigmaTotal* sigmaTotPtr,
54  ResonanceDecays* resDecaysPtrIn, SusyLesHouches* slhaPtr,
55  UserHooks* userHooksPtr);
56 
57  // Store or replace Les Houches pointer.
58  void setLHAPtr( LHAup* lhaUpPtrIn) {lhaUpPtr = lhaUpPtrIn;
59  if (sigmaProcessPtr != nullptr) sigmaProcessPtr->setLHAPtr(lhaUpPtr);
60  if (phaseSpacePtr != nullptr) phaseSpacePtr->setLHAPtr(lhaUpPtr);}
61 
62  // Update the CM energy of the event.
63  void newECM(double eCM) {phaseSpacePtr->newECM(eCM);}
64 
65  // Generate a trial event; accepted or not.
66  bool trialProcess();
67 
68  // Give the hard subprocess (with option for a second hard subprocess).
69  bool constructProcess( Event& process, bool isHardest = true);
70 
71  // Do resonance decays.
72  bool decayResonances( Event& process);
73 
74  // Accumulate statistics after user veto.
75  void accumulate() {++nAcc; wtAccSum += weightNow;}
76 
77  // Reset statistics on events generated so far.
78  void reset();
79 
80  // Process name and code, and the number of final-state particles.
81  string name() const {return sigmaProcessPtr->name();}
82  int code() const {return sigmaProcessPtr->code();}
83  int nFinal() const {return sigmaProcessPtr->nFinal();}
84  bool isSUSY() const {return sigmaProcessPtr->isSUSY();}
85 
86  // Member functions for info on generation process.
87  bool newSigmaMax() const {return newSigmaMx;}
88  double sigmaMax() const {return sigmaMx;}
89  long nTried() const {return nTry;}
90  long nSelected() const {return nSel;}
91  long nAccepted() const {return nAcc;}
92  double weightSum() const {return wtAccSum;}
93  double sigmaSelMC() {if (nTry > nTryStat) sigmaDelta(); return sigmaAvg;}
94  double sigmaMC() {if (nTry > nTryStat) sigmaDelta(); return sigmaFin;}
95  double deltaMC() {if (nTry > nTryStat) sigmaDelta(); return deltaFin;}
96 
97  // Some kinematics quantities.
98  int id1() const {return sigmaProcessPtr->id(1);}
99  int id2() const {return sigmaProcessPtr->id(2);}
100  double x1() const {return phaseSpacePtr->x1();}
101  double x2() const {return phaseSpacePtr->x2();}
102  double Q2Fac() const {return sigmaProcessPtr->Q2Fac();}
103  double mHat() const {return sqrtpos(phaseSpacePtr->sHat());}
104  double pTHat() const {return phaseSpacePtr->pTHat();}
105 
106  // Tell whether container is for Les Houches events.
107  bool isLHAContainer() const {return isLHA;}
108  int lhaStrategy() const {return lhaStrat;}
109 
110  // When two hard processes set or get info whether process is matched.
111  void isSame( bool isSameIn) { isSameSave = isSameIn;}
112  bool isSame() const {return isSameSave;}
113 
114 private:
115 
116  // Constants: could only be changed in the code itself.
117  static const int N12SAMPLE, N3SAMPLE;
118 
119  // Pointer to the subprocess matrix element. Mark if external.
120  SigmaProcess* sigmaProcessPtr;
121  bool externalPtr;
122 
123  // Pointer to the phase space generator.
124  PhaseSpace* phaseSpacePtr;
125 
126  // Pointer to various information on the generation.
127  Info* infoPtr;
128 
129  // Pointer to the particle data table.
130  ParticleData* particleDataPtr;
131 
132  // Pointer to the random number generator.
133  Rndm* rndmPtr;
134 
135  // Pointer to ResonanceDecays object for sequential resonance decays.
136  ResonanceDecays* resDecaysPtr;
137 
138  // Pointer to LHAup for generating external events.
139  LHAup* lhaUpPtr;
140 
141  // Info on process.
142  bool isLHA, isMinBias, isResolved, isDiffA, isDiffB, isQCD3body,
143  allowNegSig, hasOctetOnium, isSameSave, increaseMaximum;
144  int lhaStrat, lhaStratAbs;
145 
146  // Statistics on generation process. (Long integers just in case.)
147  bool newSigmaMx;
148  long nTry, nSel, nAcc, nTryStat;
149  double sigmaMx, sigmaSgn, sigmaSum, sigma2Sum, sigmaNeg, sigmaAvg,
150  sigmaFin, deltaFin, weightNow, wtAccSum;
151 
152  // Estimate integrated cross section and its uncertainty.
153  void sigmaDelta();
154 
155 };
156 
157 //==========================================================================
158 
159 // The SetupContainers class turns the list of user-requested processes
160 // into a vector of ProcessContainer objects, each with a process.
161 
163 
164 public:
165 
166  // Constructor.
167  SetupContainers() {}
168 
169  // Initialization assuming all necessary data already read.
170  bool init(vector<ProcessContainer*>& containerPtrs, Settings& settings,
171  ParticleData* particleDataPtr, Couplings* couplings);
172 
173  // Initialization of a second hard process.
174  bool init2(vector<ProcessContainer*>& container2Ptrs, Settings& settings);
175 
176 };
177 
178 //==========================================================================
179 
180 } // end namespace Pythia8
181 
182 #endif // Pythia8_ProcessContainer_H