StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
LHAFortran.h
1 // LHAFortran.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 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 // Header file for Fortran Les Houches Accord user process information.
7 // LHAupFortran: derived class with the HEPRUP and HEPEUP Fortran info.
8 // You are expected to create a derived class that supplies the fillHepRup
9 // and fillHepEup methods (and returns true when successful).
10 
11 #ifndef Pythia8_LHAFortran_H
12 #define Pythia8_LHAFortran_H
13 
14 #include "Pythia8/Pythia.h"
15 
16 namespace Pythia8 {
17 
18 //==========================================================================
19 
20 // Give access to the HEPRUP and HEPEUP Fortran commonblocks.
21 
22 #ifdef _WIN32
23  #define heprup_ HEPRUP
24  #define hepeup_ HEPEUP
25 #endif
26 
27 extern "C" {
28 
29  extern struct {
30  int idbmup[2];
31  double ebmup[2];
32  int pdfgup[2], pdfsup[2], idwtup, nprup;
33  double xsecup[100], xerrup[100], xmaxup[100];
34  int lprup[100];
35  } heprup_;
36 
37  extern struct {
38  int nup, idprup;
39  double xwgtup, scalup, aqedup, aqcdup;
40  int idup[500], istup[500], mothup[500][2], icolup[500][2];
41  double pup[500][5], vtimup[500],spinup[500];
42  } hepeup_;
43 
44 }
45 
46 //==========================================================================
47 
48 // A derived class with initialization information from the HEPRUP
49 // Fortran commonblock and event information from the HEPEUP one.
50 
51 class LHAupFortran : public LHAup {
52 
53 public:
54 
55  // Constructor.
56  LHAupFortran() {}
57 
58  // Routine for doing the job of setting initialization info.
59  bool setInit() {
60  // Call the routine that does the job.
61  if (!fillHepRup()) return false;
62  // Store beam and strategy info.
63  setBeamA(heprup_.idbmup[0], heprup_.ebmup[0], heprup_.pdfgup[0],
64  heprup_.pdfsup[0]);
65  setBeamB(heprup_.idbmup[1], heprup_.ebmup[1], heprup_.pdfgup[1],
66  heprup_.pdfsup[1]);
67  setStrategy(heprup_.idwtup);
68  // Store process info. Protect against vanishing cross section.
69  for (int ip = 0; ip < heprup_.nprup; ++ip) {
70  double xsec = max( 1e-10, heprup_.xsecup[ip]);
71  addProcess( heprup_.lprup[ip], xsec, heprup_.xerrup[ip],
72  heprup_.xmaxup[ip] );
73  }
74  // Store the beam energies to calculate x values later.
75  eBeamA = heprup_.ebmup[0];
76  eBeamB = heprup_.ebmup[1];
77  // Done.
78  return true;
79  }
80 
81  // Routine for doing the job of setting info on next event.
82  bool setEvent(int idProcIn = 0) {
83  // In some strategies the type of the next event has been set.
84  hepeup_.idprup = idProcIn;
85  // Call the routine that does the job.
86  if (!fillHepEup()) return false;
87  // Store process info.
88  setProcess(hepeup_.idprup, hepeup_.xwgtup, hepeup_.scalup,
89  hepeup_.aqedup, hepeup_.aqcdup);
90  // Store particle info.
91  for (int ip = 0; ip < hepeup_.nup; ++ip) addParticle(hepeup_.idup[ip],
92  hepeup_.istup[ip], hepeup_.mothup[ip][0], hepeup_.mothup[ip][1],
93  hepeup_.icolup[ip][0], hepeup_.icolup[ip][1], hepeup_.pup[ip][0],
94  hepeup_.pup[ip][1], hepeup_.pup[ip][2], hepeup_.pup[ip][3],
95  hepeup_.pup[ip][4], hepeup_.vtimup[ip], hepeup_.spinup[ip]) ;
96  // Store x values (here E = pup[ip][3]), but note incomplete info.
97  setPdf( hepeup_.idup[0], hepeup_.idup[1], hepeup_.pup[0][3]/eBeamA,
98  hepeup_.pup[1][3]/eBeamB, 0., 0., 0., false);
99  // Done.
100  return true;
101  }
102 
103 protected:
104 
105  // User-written routine that does the intialization and fills heprup.
106  virtual bool fillHepRup() {return false;}
107 
108  // User-written routine that does the event generation and fills hepeup.
109  virtual bool fillHepEup() {return false;}
110 
111 private:
112 
113  // Save beam energies to calculate x values.
114  double eBeamA, eBeamB;
115 
116 };
117 
118 //==========================================================================
119 
120 } // end namespace Pythia8
121 
122 #endif // Pythia8_LHAFortran_H