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) 2014 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 "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/PythiaStdlib.h"
21 #include "Pythia8/ResonanceDecays.h"
22 #include "Pythia8/Settings.h"
23 #include "Pythia8/SigmaProcess.h"
24 #include "Pythia8/SigmaTotal.h"
25 #include "Pythia8/SigmaOnia.h"
26 #include "Pythia8/StandardModel.h"
27 #include "Pythia8/SusyCouplings.h"
28 #include "Pythia8/SLHAinterface.h"
29 #include "Pythia8/UserHooks.h"
30 
31 namespace Pythia8 {
32 
33 //==========================================================================
34 
35 // The ProcessContainer class combines pointers to matrix element and
36 // phase space generator with general generation info.
37 
38 class ProcessContainer {
39 
40 public:
41 
42  // Constructor.
43  ProcessContainer(SigmaProcess* sigmaProcessPtrIn = 0,
44  bool externalPtrIn = false) : sigmaProcessPtr(sigmaProcessPtrIn),
45  externalPtr(externalPtrIn), phaseSpacePtr(0) {}
46 
47  // Destructor. Do not destroy external sigmaProcessPtr.
48  ~ProcessContainer() {delete phaseSpacePtr;
49  if (!externalPtr) delete sigmaProcessPtr;}
50 
51  // Initialize phase space and counters.
52  bool init(bool isFirst, Info* infoPtrIn, Settings& settings,
53  ParticleData* particleDataPtrIn, Rndm* rndmPtrIn, BeamParticle* beamAPtr,
54  BeamParticle* beamBPtr, Couplings* couplings, SigmaTotal* sigmaTotPtr,
55  ResonanceDecays* resDecaysPtrIn, SLHAinterface* slhaInterfacePtr,
56  UserHooks* userHooksPtr);
57 
58  // Store or replace Les Houches pointer.
59  void setLHAPtr( LHAup* lhaUpPtrIn, ParticleData* particleDataPtrIn = 0)
60  {lhaUpPtr = lhaUpPtrIn;
61  if (particleDataPtrIn != 0) particleDataPtr = particleDataPtrIn;
62  if (sigmaProcessPtr != 0) sigmaProcessPtr->setLHAPtr(lhaUpPtr);
63  if (phaseSpacePtr != 0) phaseSpacePtr->setLHAPtr(lhaUpPtr);}
64 
65  // Update the CM energy of the event.
66  void newECM(double eCM) {phaseSpacePtr->newECM(eCM);}
67 
68  // Generate a trial event; accepted or not.
69  bool trialProcess();
70 
71  // Pick flavours and colour flow of process.
72  bool constructState();
73 
74  // Give the hard subprocess (with option for a second hard subprocess).
75  bool constructProcess( Event& process, bool isHardest = true);
76 
77  // Give the Les Houches decay chain for external resonance.
78  bool constructDecays( Event& process);
79 
80  // Do resonance decays.
81  bool decayResonances( Event& process);
82 
83  // Accumulate statistics after user veto.
84  void accumulate();
85 
86  // Reset statistics on events generated so far.
87  void reset();
88 
89  // Process name and code, and the number of final-state particles.
90  string name() const {return sigmaProcessPtr->name();}
91  int code() const {return sigmaProcessPtr->code();}
92  int nFinal() const {return sigmaProcessPtr->nFinal();}
93  bool isSUSY() const {return sigmaProcessPtr->isSUSY();}
94 
95  // Member functions for info on generation process.
96  bool newSigmaMax() const {return newSigmaMx;}
97  double sigmaMax() const {return sigmaMx;}
98  long nTried() const {return nTry;}
99  long nSelected() const {return nSel;}
100  long nAccepted() const {return nAcc;}
101  double weightSum() const {return wtAccSum;}
102  double sigmaSelMC() {if (nTry > nTryStat) sigmaDelta(); return sigmaAvg;}
103  double sigmaMC() {if (nTry > nTryStat) sigmaDelta(); return sigmaFin;}
104  double deltaMC() {if (nTry > nTryStat) sigmaDelta(); return deltaFin;}
105 
106  // Some kinematics quantities.
107  int id1() const {return sigmaProcessPtr->id(1);}
108  int id2() const {return sigmaProcessPtr->id(2);}
109  double x1() const {return phaseSpacePtr->x1();}
110  double x2() const {return phaseSpacePtr->x2();}
111  double Q2Fac() const {return sigmaProcessPtr->Q2Fac();}
112  double mHat() const {return sqrtpos(phaseSpacePtr->sHat());}
113  double pTHat() const {return phaseSpacePtr->pTHat();}
114 
115  // Tell whether container is for Les Houches events.
116  bool isLHAContainer() const {return isLHA;}
117  int lhaStrategy() const {return lhaStrat;}
118 
119  // Info on Les Houches events.
120  int codeLHASize() const {return codeLHA.size();}
121  int subCodeLHA(int i) const {return codeLHA[i];}
122  long nTriedLHA(int i) const {return nTryLHA[i];}
123  long nSelectedLHA(int i) const {return nSelLHA[i];}
124  long nAcceptedLHA(int i) const {return nAccLHA[i];}
125 
126  // When two hard processes set or get info whether process is matched.
127  void isSame( bool isSameIn) { isSameSave = isSameIn;}
128  bool isSame() const {return isSameSave;}
129 
130 private:
131 
132  // Constants: could only be changed in the code itself.
133  static const int N12SAMPLE, N3SAMPLE;
134 
135  // Pointer to the subprocess matrix element. Mark if external.
136  SigmaProcess* sigmaProcessPtr;
137  bool externalPtr;
138 
139  // Pointer to the phase space generator.
140  PhaseSpace* phaseSpacePtr;
141 
142  // Pointer to various information on the generation.
143  Info* infoPtr;
144 
145  // Pointer to the particle data table.
146  ParticleData* particleDataPtr;
147 
148  // Pointer to the random number generator.
149  Rndm* rndmPtr;
150 
151  // Pointer to ResonanceDecays object for sequential resonance decays.
152  ResonanceDecays* resDecaysPtr;
153 
154  // Pointer to userHooks object for user interaction with program.
155  UserHooks* userHooksPtr;
156 
157  // Pointer to LHAup for generating external events.
158  LHAup* lhaUpPtr;
159 
160  // Possibility to modify Les Houches input.
161  int idRenameBeams, setLifetime;
162 
163  // Info on process.
164  bool isLHA, isNonDiff, isResolved, isDiffA, isDiffB, isDiffC, isQCD3body,
165  allowNegSig, isSameSave, increaseMaximum, canVetoResDecay;
166  int lhaStrat, lhaStratAbs;
167 
168  // Statistics on generation process. (Long integers just in case.)
169  bool newSigmaMx;
170  long nTry, nSel, nAcc, nTryStat;
171  double sigmaMx, sigmaSgn, sigmaSum, sigma2Sum, sigmaNeg, sigmaAvg,
172  sigmaFin, deltaFin, weightNow, wtAccSum;
173 
174  // Statistics for Les Houches event classification.
175  vector<int> codeLHA;
176  vector<long> nTryLHA, nSelLHA, nAccLHA;
177 
178  // Estimate integrated cross section and its uncertainty.
179  void sigmaDelta();
180 
181 };
182 
183 //==========================================================================
184 
185 // The SetupContainers class turns the list of user-requested processes
186 // into a vector of ProcessContainer objects, each with a process.
187 
188 class SetupContainers {
189 
190 public:
191 
192  // Constructor.
193  SetupContainers() {}
194 
195  // Initialization assuming all necessary data already read.
196  bool init(vector<ProcessContainer*>& containerPtrs, Info* infoPtr,
197  Settings& settings, ParticleData* particleDataPtr, Couplings* couplings);
198 
199  // Initialization of a second hard process.
200  bool init2(vector<ProcessContainer*>& container2Ptrs, Settings& settings);
201 
202 private:
203 
204  // Methods to check that outgoing SUSY particles are allowed ones.
205  void setupIdVecs( Settings& settings);
206  bool allowIdVals( int idCheck1, int idCheck2);
207 
208  // Arrays of allowed outgoing SUSY particles and their lengths.
209  vector<int> idVecA, idVecB;
210  int nVecA, nVecB;
211 
212  // Helper class to setup onia production.
213  SigmaOniaSetup charmonium, bottomonium;
214 
215 };
216 
217 //==========================================================================
218 
219 } // end namespace Pythia8
220 
221 #endif // Pythia8_ProcessContainer_H
Definition: AgUStep.h:26