CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GeneratorInput.h
Go to the documentation of this file.
1 // GeneratorInput.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 // Primary Author: Richard Corke
7 // Secondary Author: Stephen Mrenna
8 // This file provides the following classes:
9 // AlpgenPar: a class for parsing ALPGEN parameter files
10 // and reading back out the values
11 // LHAupAlpgen: an LHAup derived class for reading in ALPGEN
12 // format event files
13 // AlpgenHooks: a UserHooks derived class for providing
14 // 'Alpgen:*' user options
15 // MadgraphPar: a class for parsing MadGraph parameter files
16 // and reading back out the values
17 // Example usage is shown in main32.cc, and further details
18 // can be found in the 'Jet Matching Style' manual page.
19 // Minor changes were made by the secondary author for integration
20 // with Madgraph-style matching, and Madgraph input was added.
21 
22 #ifndef Pythia8_GeneratorInput_H
23 #define Pythia8_GeneratorInput_H
24 
25 // Includes and namespace
26 #include "Pythia8/Pythia.h"
27 
28 //==========================================================================
29 
30 // AlpgenPar: Class to parse ALPGEN parameter files and make them
31 // available through a simple interface
32 
33 class AlpgenPar {
34 
35 public:
36 
37  // Constructor
38  AlpgenPar(Pythia8::Info *infoPtrIn = NULL) : infoPtr(infoPtrIn) {}
39 
40  // Parse as incoming ALPGEN parameter file (passed as string)
41  bool parse(const string paramStr);
42 
43  // Parse an incoming parameter line
44  void extractRunParam(string line);
45 
46  // Check if a parameter exists
47  bool haveParam(const string &paramIn) {
48  return (params.find(paramIn) == params.end()) ? false : true; }
49 
50  // Get a parameter as a double or integer.
51  // Caller should have already checked existance of the parameter.
52  double getParam(const string &paramIn) {
53  return (haveParam(paramIn)) ? params[paramIn] : 0.; }
54  int getParamAsInt(const string &paramIn) {
55  return (haveParam(paramIn)) ? int(params[paramIn]) : 0.; }
56 
57  // Print parameters read from the '.par' file
58  void printParams();
59 
60 private:
61 
62  // Warn if a parameter is going to be overwriten
63  void warnParamOverwrite(const string &paramIn, double val);
64 
65  // Simple string trimmer
66  static string trim(string s);
67 
68  // Storage for parameters
69  map<string,double> params;
70 
71  // Info pointer if provided
72  Pythia8::Info* infoPtr;
73 
74  // Constants
75  static const double ZEROTHRESHOLD;
76 
77 };
78 
79 //==========================================================================
80 
81 // LHAupAlpgen: LHAup derived class for reading in ALPGEN format
82 // event files.
83 
84 class LHAupAlpgen : public Pythia8::LHAup {
85 
86 public:
87 
88  // Constructor and destructor.
89  LHAupAlpgen(const char *baseFNin, Pythia8::Info *infoPtrIn = NULL);
90  ~LHAupAlpgen() { closeFile(isUnw, ifsUnw); }
91 
92  // Override fileFound routine from LHAup.
93  bool fileFound() { return (isUnw != NULL); }
94 
95  // Override setInit/setEvent routines from LHAup.
96  bool setInit();
97  bool setEvent(int, double);
98 
99  // Print list of particles; mainly intended for debugging
100  void printParticles();
101 
102 private:
103 
104  // Add resonances to incoming event.
105  bool addResonances();
106 
107  // Rescale momenta to remove any imbalances.
108  bool rescaleMomenta();
109 
110  // Class variables
111  string baseFN, parFN, unwFN; // Incoming filenames
112  AlpgenPar alpgenPar; // Parameter database
113  int lprup; // Process code
114  double ebmupA, ebmupB; // Beam energies
115  int ihvy1, ihvy2; // Heavy flavours for certain processes
116  double mb; // Bottom mass
117  ifstream ifsUnw; // Input file stream for 'unw' file
118  istream* isUnw; // Input stream for 'unw' file
119  vector<Pythia8::LHAParticle> myParticles; // Local storage for particles
120 
121  // Constants
122  static const bool LHADEBUG, LHADEBUGRESCALE;
124  INCOMINGMIN;
125 
126 };
127 
128 //==========================================================================
129 
130 // AlpgenHooks: provides Alpgen file reading options.
131 // Note that it is defined with virtual inheritance, so that it can
132 // be combined with other UserHooks classes, see e.g. main32.cc.
133 
134 class AlpgenHooks : virtual public Pythia8::UserHooks {
135 
136 public:
137 
138  // Constructor and destructor
139  AlpgenHooks(Pythia8::Pythia &pythia);
140  ~AlpgenHooks() { if (LHAagPtr) delete LHAagPtr; }
141 
142  // Override initAfterBeams routine from UserHooks
143  bool initAfterBeams();
144 
145 private:
146 
147  // LHAupAlpgen pointer
149 
150 };
151 
152 //==========================================================================
153 
154 // MadgraphPar: Class to parse the Madgraph header parameters and
155 // make them available through a simple interface
156 
157 class MadgraphPar {
158 
159 public:
160 
161  // Constructor
162  MadgraphPar(Pythia8::Info *infoPtrIn = NULL) : infoPtr(infoPtrIn) {}
163 
164  // Parse an incoming Madgraph parameter file string
165  bool parse(const string paramStr);
166 
167  // Parse an incoming parameter line
168  void extractRunParam(string line);
169 
170  // Check if a parameter exists
171  bool haveParam(const string &paramIn) {
172  return (params.find(paramIn) == params.end()) ? false : true; }
173 
174  // Get a parameter as a double or integer.
175  // Caller should have already checked existance of the parameter.
176  double getParam(const string &paramIn) {
177  return (haveParam(paramIn)) ? params[paramIn] : 0.; }
178  int getParamAsInt(const string &paramIn) {
179  return (haveParam(paramIn)) ? int(params[paramIn]) : 0.; }
180 
181  // Print parameters read from the '.par' file
182  void printParams();
183 
184 private:
185 
186  // Warn if a parameter is going to be overwriten
187  void warnParamOverwrite(const string &paramIn, double val);
188 
189  // Simple string trimmer
190  static string trim(string s);
191 
192  // Storage for parameters
193  map<string,double> params;
194 
195  // Info pointer if provided
196  Pythia8::Info *infoPtr;
197 
198  // Constants
199  static const double ZEROTHRESHOLD;
200 
201 };
202 #endif // Pythia8_GeneratorInput_H
static const double PTWARNTHRESHOLD
int getParamAsInt(const string &paramIn)
AlpgenPar alpgenPar
void warnParamOverwrite(const string &paramIn, double val)
LHAupAlpgen * LHAagPtr
void printParticles()
void printParams()
bool haveParam(const string &paramIn)
bool fileFound()
bool initAfterBeams()
Pythia8::Info * infoPtr
#define NULL
Definition: scimark2.h:8
istream * isUnw
LHAupAlpgen(const char *baseFNin, Pythia8::Info *infoPtrIn=NULL)
void printParams()
vector< Pythia8::LHAParticle > myParticles
map< string, double > params
static const bool LHADEBUGRESCALE
double getParam(const string &paramIn)
bool rescaleMomenta()
map< string, double > params
AlpgenPar(Pythia8::Info *infoPtrIn=NULL)
bool parse(const string paramStr)
static string trim(string s)
MadgraphPar(Pythia8::Info *infoPtrIn=NULL)
double getParam(const string &paramIn)
static const double ZEROTHRESHOLD
void warnParamOverwrite(const string &paramIn, double val)
static const double ZEROTHRESHOLD
static string trim(string s)
Pythia8::Info * infoPtr
bool haveParam(const string &paramIn)
bool addResonances()
ifstream ifsUnw
void extractRunParam(string line)
static const double EWARNTHRESHOLD
static const bool LHADEBUG
bool setEvent(int, double)
static const double ZEROTHRESHOLD
static const double INCOMINGMIN
AlpgenHooks(Pythia8::Pythia &pythia)
void extractRunParam(string line)
bool parse(const string paramStr)
int getParamAsInt(const string &paramIn)