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