~alifson/chiralityflow/trunk

« back to all changes in this revision

Viewing changes to Template/NLO/Source/PDF/pdf_lhapdf6.cc

  • Committer: andrew.lifson at lu
  • Date: 2021-09-01 15:34:39 UTC
  • Revision ID: andrew.lifson@thep.lu.se-20210901153439-7fasjhav4cp4m88r
testing a new repository of a madgraph folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- C++ -*-
 
2
//
 
3
// This file is part of LHAPDF
 
4
// Copyright (C) 2012-2014 The LHAPDF collaboration (see AUTHORS for details)
 
5
//
 
6
#include "LHAPDF/PDF.h"
 
7
#include "LHAPDF/PDFSet.h"
 
8
#include "LHAPDF/PDFIndex.h"
 
9
#include "LHAPDF/Factories.h"
 
10
#include "LHAPDF/Utils.h"
 
11
#include "LHAPDF/Paths.h"
 
12
#include "LHAPDF/Version.h"
 
13
#include "LHAPDF/LHAGlue.h"
 
14
#include <boost/shared_ptr.hpp>
 
15
#include <boost/foreach.hpp>
 
16
#include <boost/algorithm/string.hpp>
 
17
#include <string.h>
 
18
 
 
19
using namespace std;
 
20
 
 
21
 
 
22
// We have to create and initialise some common blocks here for backwards compatibility
 
23
struct w50512 {
 
24
  double qcdl4, qcdl5;
 
25
};
 
26
w50512 w50512_;
 
27
 
 
28
struct w50513 {
 
29
  double xmin, xmax, q2min, q2max;
 
30
};
 
31
w50513 w50513_;
 
32
 
 
33
struct lhapdfr {
 
34
  double qcdlha4, qcdlha5;
 
35
  int nfllha;
 
36
};
 
37
lhapdfr lhapdfr_;
 
38
 
 
39
 
 
40
 
 
41
namespace lhapdf_amc { //< Unnamed namespace to restrict visibility to this file
 
42
 
 
43
  /// @brief PDF object storage here is a smart pointer to ensure deletion of created PDFs
 
44
  ///
 
45
  /// NB. std::auto_ptr cannot be stored in STL containers, hence we use
 
46
  /// boost::shared_ptr. std::unique_ptr is the nature replacement when C++11
 
47
  /// is globally available.
 
48
  typedef boost::shared_ptr<LHAPDF::PDF> PDFPtr;
 
49
 
 
50
  /// @brief A struct for handling the active PDFs for the Fortran interface.
 
51
  ///
 
52
  /// We operate in a string-based way, since maybe there will be sets with names, but no
 
53
  /// index entry in pdfsets.index.
 
54
  ///
 
55
  /// @todo Can we avoid the strings and just work via the LHAPDF ID and factory construction?
 
56
  ///
 
57
  /// Smart pointers are used in the native map used for PDF member storage so
 
58
  /// that they auto-delete if the PDFSetHandler that holds them goes out of
 
59
  /// scope (i.e. is overwritten).
 
60
  struct PDFSetHandler {
 
61
 
 
62
    /// Default constructor
 
63
    PDFSetHandler() : currentmem(0)
 
64
    { } //< It'll be stored in a map so we need one of these...
 
65
 
 
66
    /// Constructor from a PDF set name
 
67
    PDFSetHandler(const string& name)
 
68
      : setname(name)
 
69
    {
 
70
      loadMember(0);
 
71
    }
 
72
 
 
73
    /// Constructor from a PDF set's LHAPDF ID code
 
74
    PDFSetHandler(int lhaid) {
 
75
      pair<string,int> set_mem = LHAPDF::lookupPDF(lhaid);
 
76
      // First check that the lookup was successful, i.e. it was a valid ID for the LHAPDF6 set collection
 
77
      if (set_mem.first.empty() || set_mem.second < 0)
 
78
        throw LHAPDF::UserError("Could not find a valid PDF with LHAPDF ID = " + LHAPDF::to_str(lhaid));
 
79
      // Try to load this PDF (checking that the member number is in the set's range is done in mkPDF, called by loadMember)
 
80
      setname = set_mem.first;
 
81
      loadMember(set_mem.second);
 
82
    }
 
83
 
 
84
    /// @brief Load a new PDF member
 
85
    ///
 
86
    /// If it's already loaded, the existing object will not be reloaded.
 
87
    void loadMember(int mem) {
 
88
      if (mem < 0)
 
89
        throw LHAPDF::UserError("Tried to load a negative PDF member ID: " + LHAPDF::to_str(mem) + " in set " + setname);
 
90
      if (members.find(mem) == members.end())
 
91
        members[mem] = PDFPtr(LHAPDF::mkPDF(setname, mem));
 
92
      currentmem = mem;
 
93
    }
 
94
 
 
95
    /// Actively delete a PDF member to save memory
 
96
    void unloadMember(int mem) {
 
97
      members.erase(mem);
 
98
      const int nextmem = (!members.empty()) ? members.begin()->first : 0;
 
99
      loadMember(nextmem);
 
100
    }
 
101
 
 
102
    /// @brief Get a PDF member
 
103
    ///
 
104
    /// Non-const because it can secretly load the member. Not that constness
 
105
    /// matters in a Fortran interface utility function!
 
106
    const PDFPtr member(int mem) {
 
107
      loadMember(mem);
 
108
      return members.find(mem)->second;
 
109
    }
 
110
 
 
111
    /// Get the currently active PDF member
 
112
    ///
 
113
    /// Non-const because it can secretly load the member. Not that constness
 
114
    /// matters in a Fortran interface utility function!
 
115
    const PDFPtr activemember() {
 
116
      return member(currentmem);
 
117
    }
 
118
 
 
119
    /// The currently active member in this set
 
120
    int currentmem;
 
121
 
 
122
    /// Name of this set
 
123
    string setname;
 
124
 
 
125
    /// Map of pointers to selected member PDFs
 
126
    ///
 
127
    // /// It's mutable so that a "const" member-getting operation can implicitly
 
128
    // /// load a new PDF object. Good idea / bad idea? Disabled for now.
 
129
    // mutable map<int, PDFPtr> members;
 
130
    map<int, PDFPtr> members;
 
131
  };
 
132
 
 
133
 
 
134
  /// Collection of active sets
 
135
  static map<int, PDFSetHandler> ACTIVESETS;
 
136
 
 
137
  /// The currently active set
 
138
  int CURRENTSET = 0;
 
139
 
 
140
}
 
141
 
 
142
 
 
143
 
 
144
string lhaglue_get_current_pdf(int nset) {
 
145
  if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
146
    return "NONE";
 
147
  lhapdf_amc::CURRENTSET = nset;
 
148
  return lhapdf_amc::ACTIVESETS[nset].activemember()->set().name() + " (" +
 
149
    LHAPDF::to_str(lhapdf_amc::ACTIVESETS[nset].activemember()->lhapdfID()) + ")";
 
150
}
 
151
 
 
152
 
 
153
 
 
154
extern "C" {
 
155
 
 
156
  // NEW FORTRAN INTERFACE FUNCTIONS
 
157
 
 
158
  /// List of available sets
 
159
  void lhapdf_getversion_(char* s, size_t len) {
 
160
    strncpy(s, LHAPDF_VERSION, len);
 
161
  }
 
162
 
 
163
  /// List of available PDF sets, returned as a space-separated string
 
164
  void lhapdf_getpdfsetlist_(char* s, size_t len) {
 
165
    string liststr;
 
166
    BOOST_FOREACH(const string& setname, LHAPDF::availablePDFSets()) {
 
167
      if (!liststr.empty()) liststr += " ";
 
168
      liststr += setname;
 
169
    }
 
170
    strncpy(s, liststr.c_str(), len);
 
171
  }
 
172
 
 
173
 
 
174
  //////////////////
 
175
 
 
176
  // LHAPDF5 / PDFLIB COMPATIBILITY INTERFACE FUNCTIONS
 
177
 
 
178
 
 
179
  // System-level info
 
180
 
 
181
  /// LHAPDF library version
 
182
  void getlhapdfversion_(char* s, size_t len) {
 
183
    /// @todo Works? Need to check Fortran string return, string macro treatment, etc.
 
184
    strncpy(s, LHAPDF_VERSION, len);
 
185
  }
 
186
 
 
187
 
 
188
  /// Does nothing, only provided for backward compatibility
 
189
  void lhaprint_(int& a) {  }
 
190
 
 
191
 
 
192
  /// Set LHAPDF parameters -- does nothing in LHAPDF6!
 
193
  void setlhaparm_(const char* par, int parlength) {
 
194
    /// @todo Can any Fortran LHAPDF params be usefully mapped?
 
195
  }
 
196
 
 
197
 
 
198
  /// Return a dummy max number of sets (there is no limitation now)
 
199
  void getmaxnumsets_(int& nmax) {
 
200
    nmax = 1000;
 
201
  }
 
202
 
 
203
 
 
204
  /// Set PDF data path
 
205
  void setpdfpath_(const char* s, size_t len) {
 
206
    /// @todo Works? Need to check C-string copying, null termination
 
207
    char s2[1024];
 
208
    s2[len] = '\0';
 
209
    strncpy(s2, s, len);
 
210
    LHAPDF::pathsPrepend(s2);
 
211
  }
 
212
 
 
213
  /// Get PDF data path (colon-separated if there is more than one element)
 
214
  void getdatapath_(char* s, size_t len) {
 
215
    /// @todo Works? Need to check Fortran string return, string macro treatment, etc.
 
216
    string pathstr;
 
217
    BOOST_FOREACH(const string& path, LHAPDF::paths()) {
 
218
      if (!pathstr.empty()) pathstr += ":";
 
219
      pathstr += path;
 
220
    }
 
221
    strncpy(s, pathstr.c_str(), len);
 
222
  }
 
223
 
 
224
 
 
225
  // PDF initialisation and focus-switching
 
226
 
 
227
  /// Load a PDF set
 
228
  ///
 
229
  /// @todo Does this version actually take a *path*? What to do?
 
230
  void initpdfsetm_(const int& nset, const char* setpath, int setpathlength) {
 
231
    // Strip file extension for backward compatibility
 
232
    string fullp = string(setpath, setpathlength);
 
233
    // Remove trailing whitespace
 
234
    fullp.erase( std::remove_if( fullp.begin(), fullp.end(), ::isspace ), fullp.end() );
 
235
    // Use only items after the last /
 
236
    const string pap = LHAPDF::dirname(fullp);
 
237
    const string p = LHAPDF::basename(fullp);
 
238
    // Prepend path to search area
 
239
    LHAPDF::pathsPrepend(pap);
 
240
    // Handle extensions
 
241
    string path = LHAPDF::file_extn(p).empty() ? p : LHAPDF::file_stem(p);
 
242
    /// @note We correct the misnamed CTEQ6L1/CTEQ6ll set name as a backward compatibility special case.
 
243
    if (boost::algorithm::to_lower_copy(path) == "cteq6ll") path = "cteq6l1";
 
244
    // Create the PDF set with index nset
 
245
    // if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
246
    lhapdf_amc::ACTIVESETS[nset] = lhapdf_amc::PDFSetHandler(path); //< @todo Will be wrong if a structured path is given
 
247
    lhapdf_amc::CURRENTSET = nset;
 
248
  }
 
249
  /// Load a PDF set (non-multiset version)
 
250
  void initpdfset_(const char* setpath, int setpathlength) {
 
251
    int nset1 = 1;
 
252
    initpdfsetm_(nset1, setpath, setpathlength);
 
253
  }
 
254
 
 
255
 
 
256
  /// Load a PDF set by name
 
257
  void initpdfsetbynamem_(const int& nset, const char* setname, int setnamelength) {
 
258
    // Truncate input to size setnamelength
 
259
    string p = setname;
 
260
    p.erase(setnamelength, std::string::npos);
 
261
    // Strip file extension for backward compatibility
 
262
    string name = LHAPDF::file_extn(p).empty() ? p : LHAPDF::file_stem(p);
 
263
    // Remove trailing whitespace
 
264
    name.erase( std::remove_if( name.begin(), name.end(), ::isspace ), name.end() );
 
265
    /// @note We correct the misnamed CTEQ6L1/CTEQ6ll set name as a backward compatibility special case.
 
266
    if (boost::algorithm::to_lower_copy(name) == "cteq6ll") name = "cteq6l1";
 
267
    // Create the PDF set with index nset
 
268
    // if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
269
    lhapdf_amc::ACTIVESETS[nset] = lhapdf_amc::PDFSetHandler(name);
 
270
    // Update current set focus
 
271
    lhapdf_amc::CURRENTSET = nset;
 
272
  }
 
273
  /// Load a PDF set by name (non-multiset version)
 
274
  void initpdfsetbyname_(const char* setname, int setnamelength) {
 
275
    int nset1 = 1;
 
276
    initpdfsetbynamem_(nset1, setname, setnamelength);
 
277
  }
 
278
 
 
279
 
 
280
  /// Load a PDF in current set
 
281
  void initpdfm_(const int& nset, const int& nmember) {
 
282
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
283
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
284
    lhapdf_amc::ACTIVESETS[nset].loadMember(nmember);
 
285
    // Update current set focus
 
286
    lhapdf_amc::CURRENTSET = nset;
 
287
  }
 
288
  /// Load a PDF in current set (non-multiset version)
 
289
  void initpdf_(const int& nmember) {
 
290
    int nset1 = 1;
 
291
    initpdfm_(nset1, nmember);
 
292
  }
 
293
 
 
294
 
 
295
  /// Get the current set number (i.e. allocation slot index)
 
296
  void getnset_(int& nset) {
 
297
    nset = lhapdf_amc::CURRENTSET;
 
298
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
299
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
300
  }
 
301
 
 
302
  /// Explicitly set the current set number (i.e. allocation slot index)
 
303
  void setnset_(const int& nset) {
 
304
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
305
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
306
    lhapdf_amc::CURRENTSET = nset;
 
307
  }
 
308
 
 
309
 
 
310
  /// Get the current member number in slot nset
 
311
  void getnmem_(int& nset, int& nmem) {
 
312
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
313
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
314
    nmem = lhapdf_amc::ACTIVESETS[nset].currentmem;
 
315
    // Update current set focus
 
316
    lhapdf_amc::CURRENTSET = nset;
 
317
  }
 
318
 
 
319
  /// Set the current member number in slot nset
 
320
  void setnmem_(const int& nset, const int& nmem) {
 
321
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
322
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" +
 
323
                              LHAPDF::to_str(nset) + " but it is not initialised");
 
324
    lhapdf_amc::ACTIVESETS[nset].loadMember(nmem);
 
325
    // Update current set focus
 
326
    lhapdf_amc::CURRENTSET = nset;
 
327
  }
 
328
 
 
329
 
 
330
 
 
331
  // PDF evolution functions
 
332
 
 
333
  /// Get xf(x) values for common partons from current PDF
 
334
  void evolvepdfm_(const int& nset, const double& x, const double& q, double* fxq) {
 
335
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
336
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
337
    // Evaluate for the 13 LHAPDF5 standard partons (-6..6)
 
338
    for (size_t i = 0; i < 13; ++i) {
 
339
      try {
 
340
        fxq[i] = lhapdf_amc::ACTIVESETS[nset].activemember()->xfxQ(i-6, x, q);
 
341
      } catch (const exception& e) {
 
342
        fxq[i] = 0;
 
343
      }
 
344
    }
 
345
    // Update current set focus
 
346
    lhapdf_amc::CURRENTSET = nset;
 
347
  }
 
348
  /// Get xf(x) values for common partons from current PDF (non-multiset version)
 
349
  void evolvepdf_(const double& x, const double& q, double* fxq) {
 
350
    int nset1 = 1;
 
351
    evolvepdfm_(nset1, x, q, fxq);
 
352
  }
 
353
 
 
354
  // PDF evolution functions
 
355
  // NEW BY MZ to evolve one single parton
 
356
 
 
357
  /// Get xf(x) values for common partons from current PDF
 
358
  void evolvepartm_(const int& nset, const int& ipart, const double& x, const double& q, double& fxq) {
 
359
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
360
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
361
    int ipart_copy; // this is to deal with photons, which are labeled 7 in MG5aMC
 
362
    ipart_copy = ipart;
 
363
    if (ipart==7) ipart_copy = 22;
 
364
    try {
 
365
      fxq = lhapdf_amc::ACTIVESETS[nset].activemember()->xfxQ(ipart_copy, x, q);
 
366
    } catch (const exception& e) {
 
367
      fxq = 0;
 
368
    }
 
369
    // Update current set focus
 
370
    lhapdf_amc::CURRENTSET = nset;
 
371
  }
 
372
  /// Get xf(x) values for common partons from current PDF (non-multiset version)
 
373
  void evolvepart_( const int& ipart, const double& x, const double& q, double& fxq) {
 
374
    int nset1 = 1;
 
375
    evolvepartm_(nset1, ipart, x, q, fxq);
 
376
  }
 
377
 
 
378
 
 
379
  /// Determine if the current PDF has a photon flavour (historically only MRST2004QED)
 
380
  /// @todo Function rather than subroutine?
 
381
  /// @note There is no multiset version. has_photon will respect the current set slot.
 
382
  bool has_photon_() {
 
383
    return lhapdf_amc::ACTIVESETS[lhapdf_amc::CURRENTSET].activemember()->hasFlavor(22);
 
384
  }
 
385
 
 
386
 
 
387
  /// Get xfx values from current PDF, including an extra photon flavour
 
388
  void evolvepdfphotonm_(const int& nset, const double& x, const double& q, double* fxq, double& photonfxq) {
 
389
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
390
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
391
    // First evaluate the "normal" partons
 
392
    evolvepdfm_(nset, x, q, fxq);
 
393
    // Then evaluate the photon flavor (historically only for MRST2004QED)
 
394
    try {
 
395
      photonfxq = lhapdf_amc::ACTIVESETS[nset].activemember()->xfxQ(22, x, q);
 
396
    } catch (const exception& e) {
 
397
      photonfxq = 0;
 
398
    }
 
399
    // Update current set focus
 
400
    lhapdf_amc::CURRENTSET = nset;
 
401
  }
 
402
  /// Get xfx values from current PDF, including an extra photon flavour (non-multiset version)
 
403
  void evolvepdfphoton_(const double& x, const double& q, double* fxq, double& photonfxq) {
 
404
    int nset1 = 1;
 
405
    evolvepdfphotonm_(nset1, x, q, fxq, photonfxq);
 
406
  }
 
407
 
 
408
 
 
409
  /// Get xf(x) values for common partons from a photon PDF
 
410
  void evolvepdfpm_(const int& nset, const double& x, const double& q, const double& p2, const int& ip2, double& fxq) {
 
411
    // Update current set focus
 
412
    lhapdf_amc::CURRENTSET = nset;
 
413
    throw LHAPDF::NotImplementedError("Photon structure functions are not yet supported in LHAPDF6");
 
414
  }
 
415
  /// Get xf(x) values for common partons from a photon PDF (non-multiset version)
 
416
  void evolvepdfp_(const double& x, const double& q, const double& p2, const int& ip2, double& fxq) {
 
417
    int nset1 = 1;
 
418
    evolvepdfpm_(nset1, x, q, p2, ip2, fxq);
 
419
  }
 
420
 
 
421
 
 
422
  // alpha_s evolution
 
423
 
 
424
  /// Get the alpha_s order for the set
 
425
  void getorderasm_(const int& nset, int& oas) {
 
426
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
427
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
428
    // Set equal to the number of members for the requested set
 
429
    oas = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<int>("AlphaS_OrderQCD");
 
430
    // Update current set focus
 
431
    lhapdf_amc::CURRENTSET = nset;
 
432
  }
 
433
  /// Get the alpha_s order for the set (non-multiset version)
 
434
  void getorderas_(int& oas) {
 
435
    int nset1 = 1;
 
436
    getorderasm_(nset1, oas);
 
437
  }
 
438
 
 
439
 
 
440
  /// Get the alpha_s(Q) value for set nset
 
441
  double alphaspdfm_(const int& nset, const double& Q){
 
442
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
443
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
444
    return lhapdf_amc::ACTIVESETS[nset].activemember()->alphasQ(Q);
 
445
    // Update current set focus
 
446
    lhapdf_amc::CURRENTSET = nset;
 
447
  }
 
448
  /// Get the alpha_s(Q) value for the set (non-multiset version)
 
449
  double alphaspdf_(const double& Q){
 
450
    int nset1 = 1;
 
451
    return alphaspdfm_(nset1, Q);
 
452
  }
 
453
 
 
454
 
 
455
  // Metadata functions
 
456
 
 
457
  /// Get the number of error members in the set (with special treatment for single member sets)
 
458
  void numberpdfm_(const int& nset, int& numpdf) {
 
459
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
460
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
461
    // Set equal to the number of members  for the requested set
 
462
    numpdf=  lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<int>("NumMembers");
 
463
    // Reproduce old LHAPDF v5 behaviour, i.e. subtract 1 if more than 1 member set
 
464
    if (numpdf > 1) numpdf -= 1;
 
465
    // Update current set focus
 
466
    lhapdf_amc::CURRENTSET = nset;
 
467
  }
 
468
  /// Get the number of error members in the set (non-multiset version)
 
469
  void numberpdf_(int& numpdf) {
 
470
    int nset1 = 1;
 
471
    numberpdfm_(nset1, numpdf);
 
472
  }
 
473
 
 
474
 
 
475
  /// Get the max number of active flavours
 
476
  void getnfm_(const int& nset, int& nf) {
 
477
    //nf = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<int>("AlphaS_NumFlavors");
 
478
    nf = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<int>("NumFlavors");
 
479
    // Update current set focus
 
480
    lhapdf_amc::CURRENTSET = nset;
 
481
  }
 
482
  /// Get the max number of active flavours (non-multiset version)
 
483
  void getnf_(int& nf) {
 
484
    int nset1 = 1;
 
485
    getnfm_(nset1, nf);
 
486
  }
 
487
 
 
488
 
 
489
  /// Get nf'th quark mass
 
490
  void getqmassm_(const int& nset, const int& nf, double& mass) {
 
491
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
492
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
493
    if      (nf*nf ==  1) mass = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("MDown");
 
494
    else if (nf*nf ==  4) mass = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("MUp");
 
495
    else if (nf*nf ==  9) mass = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("MStrange");
 
496
    else if (nf*nf == 16) mass = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("MCharm");
 
497
    else if (nf*nf == 25) mass = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("MBottom");
 
498
    else if (nf*nf == 36) mass = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("MTop");
 
499
    else throw LHAPDF::UserError("Trying to get quark mass for invalid quark ID #" + LHAPDF::to_str(nf));
 
500
    // Update current set focus
 
501
    lhapdf_amc::CURRENTSET = nset;
 
502
  }
 
503
  /// Get nf'th quark mass (non-multiset version)
 
504
  void getqmass_(const int& nf, double& mass) {
 
505
    int nset1 = 1;
 
506
    getqmassm_(nset1, nf, mass);
 
507
  }
 
508
 
 
509
 
 
510
  /// Get the nf'th quark threshold
 
511
  void getthresholdm_(const int& nset, const int& nf, double& Q) {
 
512
    try {
 
513
      if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
514
        throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
515
      if      (nf*nf ==  1) Q = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("ThresholdDown");
 
516
      else if (nf*nf ==  4) Q = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("ThresholdUp");
 
517
      else if (nf*nf ==  9) Q = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("ThresholdStrange");
 
518
      else if (nf*nf == 16) Q = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("ThresholdCharm");
 
519
      else if (nf*nf == 25) Q = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("ThresholdBottom");
 
520
      else if (nf*nf == 36) Q = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("ThresholdTop");
 
521
      //else throw LHAPDF::UserError("Trying to get quark threshold for invalid quark ID #" + LHAPDF::to_str(nf));
 
522
    } catch (...) {
 
523
      getqmassm_(nset, nf, Q);
 
524
    }
 
525
    // Update current set focus
 
526
    lhapdf_amc::CURRENTSET = nset;
 
527
  }
 
528
  /// Get the nf'th quark threshold
 
529
  void getthreshold_(const int& nf, double& Q) {
 
530
    int nset1 = 1;
 
531
    getthresholdm_(nset1, nf, Q);
 
532
  }
 
533
 
 
534
 
 
535
  /// Print PDF set's description to stdout
 
536
  void getdescm_(const int& nset) {
 
537
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
538
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
539
    cout << lhapdf_amc::ACTIVESETS[nset].activemember()->description() << endl;
 
540
    // Update current set focus
 
541
    lhapdf_amc::CURRENTSET = nset;
 
542
  }
 
543
  void getdesc_() {
 
544
    int nset1 = 1;
 
545
    getdescm_(nset1);
 
546
  }
 
547
 
 
548
 
 
549
  void getxminm_(const int& nset, const int& nmem, double& xmin) {
 
550
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
551
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
552
    const int activemem = lhapdf_amc::ACTIVESETS[nset].currentmem;
 
553
    lhapdf_amc::ACTIVESETS[nset].loadMember(nmem);
 
554
    xmin = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("XMin");
 
555
    lhapdf_amc::ACTIVESETS[nset].loadMember(activemem);
 
556
    // Update current set focus
 
557
    lhapdf_amc::CURRENTSET = nset;
 
558
  }
 
559
  void getxmin_(const int& nmem, double& xmin) {
 
560
    int nset1 = 1;
 
561
    getxminm_(nset1, nmem, xmin);
 
562
  }
 
563
 
 
564
 
 
565
  void getxmaxm_(const int& nset, const int& nmem, double& xmax) {
 
566
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
567
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
568
    const int activemem = lhapdf_amc::ACTIVESETS[nset].currentmem;
 
569
    lhapdf_amc::ACTIVESETS[nset].loadMember(nmem);
 
570
    xmax = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("XMax");
 
571
    lhapdf_amc::ACTIVESETS[nset].loadMember(activemem);
 
572
    // Update current set focus
 
573
    lhapdf_amc::CURRENTSET = nset;
 
574
  }
 
575
  void getxmax_(const int& nmem, double& xmax) {
 
576
    int nset1 = 1;
 
577
    getxmaxm_(nset1, nmem, xmax);
 
578
  }
 
579
 
 
580
 
 
581
  void getq2minm_(const int& nset, const int& nmem, double& q2min) {
 
582
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
583
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
584
    const int activemem = lhapdf_amc::ACTIVESETS[nset].currentmem;
 
585
    lhapdf_amc::ACTIVESETS[nset].loadMember(nmem);
 
586
    q2min = LHAPDF::sqr(lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("QMin"));
 
587
    lhapdf_amc::ACTIVESETS[nset].loadMember(activemem);
 
588
    // Update current set focus
 
589
    lhapdf_amc::CURRENTSET = nset;
 
590
  }
 
591
  void getq2min_(const int& nmem, double& q2min) {
 
592
    int nset1 = 1;
 
593
    getq2minm_(nset1, nmem, q2min);
 
594
  }
 
595
 
 
596
 
 
597
  void getq2maxm_(const int& nset, const int& nmem, double& q2max) {
 
598
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
599
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
600
    const int activemem = lhapdf_amc::ACTIVESETS[nset].currentmem;
 
601
    lhapdf_amc::ACTIVESETS[nset].loadMember(nmem);
 
602
    q2max = LHAPDF::sqr(lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("QMax"));
 
603
    lhapdf_amc::ACTIVESETS[nset].loadMember(activemem);
 
604
    // Update current set focus
 
605
    lhapdf_amc::CURRENTSET = nset;
 
606
  }
 
607
  void getq2max_(const int& nmem, double& q2max) {
 
608
    int nset1 = 1;
 
609
    getq2maxm_(nset1, nmem, q2max);
 
610
  }
 
611
 
 
612
 
 
613
  void getminmaxm_(const int& nset, const int& nmem, double& xmin, double& xmax, double& q2min, double& q2max) {
 
614
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
615
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
616
    const int activemem = lhapdf_amc::ACTIVESETS[nset].currentmem;
 
617
    lhapdf_amc::ACTIVESETS[nset].loadMember(nmem);
 
618
    xmin = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("XMin");
 
619
    xmax = lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("XMax");
 
620
    q2min = LHAPDF::sqr(lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("QMin"));
 
621
    q2max = LHAPDF::sqr(lhapdf_amc::ACTIVESETS[nset].activemember()->info().get_entry_as<double>("QMax"));
 
622
    lhapdf_amc::ACTIVESETS[nset].loadMember(activemem);
 
623
    // Update current set focus
 
624
    lhapdf_amc::CURRENTSET = nset;
 
625
  }
 
626
  void getminmax_(const int& nmem, double& xmin, double& xmax, double& q2min, double& q2max) {
 
627
    int nset1 = 1;
 
628
     getminmaxm_(nset1, nmem, xmin, xmax, q2min, q2max);
 
629
   }
 
630
 
 
631
 
 
632
 
 
633
  /// Backwards compatibility functions for LHAPDF5 calculations of
 
634
  /// PDF uncertainties and PDF correlations (G. Watt, March 2014).
 
635
 
 
636
  // subroutine GetPDFUncTypeM(nset,lMonteCarlo,lSymmetric)
 
637
  void getpdfunctypem_(const int& nset, int& lmontecarlo, int& lsymmetric) {
 
638
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
639
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
640
    const string errorType = lhapdf_amc::ACTIVESETS[nset].activemember()->set().errorType();
 
641
    if (errorType == "replicas") { // Monte Carlo PDF sets
 
642
      lmontecarlo = 1;
 
643
      lsymmetric = 1;
 
644
    } else if (errorType == "symmhessian") { // symmetric eigenvector PDF sets
 
645
      lmontecarlo = 0;
 
646
      lsymmetric = 1;
 
647
    } else { // default: assume asymmetric Hessian eigenvector PDF sets
 
648
      lmontecarlo = 0;
 
649
      lsymmetric = 0;
 
650
    }
 
651
    // Update current set focus
 
652
    lhapdf_amc::CURRENTSET = nset;
 
653
  }
 
654
  // subroutine GetPDFUncType(lMonteCarlo,lSymmetric)
 
655
  void getpdfunctype_(int& lmontecarlo, int& lsymmetric) {
 
656
    int nset1 = 1;
 
657
    getpdfunctypem_(nset1, lmontecarlo, lsymmetric);
 
658
  }
 
659
 
 
660
 
 
661
  // subroutine GetPDFuncertaintyM(nset,values,central,errplus,errminus,errsym)
 
662
  void getpdfuncertaintym_(const int& nset, const double* values, double& central, double& errplus, double& errminus, double& errsymm) {
 
663
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
664
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
665
    const size_t nmem = lhapdf_amc::ACTIVESETS[nset].activemember()->set().size()-1;
 
666
    const vector<double> vecvalues(values, values + nmem + 1);
 
667
    LHAPDF::PDFUncertainty err = lhapdf_amc::ACTIVESETS[nset].activemember()->set().uncertainty(vecvalues, -1);
 
668
    central = err.central;
 
669
    errplus = err.errplus;
 
670
    errminus = err.errminus;
 
671
    errsymm = err.errsymm;
 
672
    // Update current set focus
 
673
    lhapdf_amc::CURRENTSET = nset;
 
674
  }
 
675
  // subroutine GetPDFuncertainty(values,central,errplus,errminus,errsym)
 
676
  void getpdfuncertainty_(const double* values, double& central, double& errplus, double& errminus, double& errsymm) {
 
677
    int nset1 = 1;
 
678
    getpdfuncertaintym_(nset1, values, central, errplus, errminus, errsymm);
 
679
  }
 
680
 
 
681
 
 
682
  // subroutine GetPDFcorrelationM(nset,valuesA,valuesB,correlation)
 
683
  void getpdfcorrelationm_(const int& nset, const double* valuesA, const double* valuesB, double& correlation) {
 
684
    if (lhapdf_amc::ACTIVESETS.find(nset) == lhapdf_amc::ACTIVESETS.end())
 
685
      throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
686
    const size_t nmem = lhapdf_amc::ACTIVESETS[nset].activemember()->set().size()-1;
 
687
    const vector<double> vecvaluesA(valuesA, valuesA + nmem + 1);
 
688
    const vector<double> vecvaluesB(valuesB, valuesB + nmem + 1);
 
689
    correlation = lhapdf_amc::ACTIVESETS[nset].activemember()->set().correlation(vecvaluesA,vecvaluesB);
 
690
    // Update current set focus
 
691
    lhapdf_amc::CURRENTSET = nset;
 
692
  }
 
693
  // subroutine GetPDFcorrelation(valuesA,valuesB,correlation)
 
694
  void getpdfcorrelation_(const double* valuesA, const double* valuesB, double& correlation) {
 
695
    int nset1 = 1;
 
696
    getpdfcorrelationm_(nset1, valuesA, valuesB, correlation);
 
697
  }
 
698
 
 
699
 
 
700
  ///////////////////////////////////////
 
701
 
 
702
 
 
703
  /// REALLY OLD PDFLIB COMPATILITY FUNCTIONS
 
704
 
 
705
  /// PDFLIB initialisation function
 
706
  void pdfset_(const char* par, const double* value, int parlength) {
 
707
 
 
708
    // Identify the calling program (yuck!)
 
709
    string my_par(par);
 
710
    if (my_par.find("NPTYPE") != string::npos) {
 
711
      cout << "==== LHAPDF6 USING PYTHIA-TYPE LHAGLUE INTERFACE ====" << endl;
 
712
      // Take PDF ID from value[2]
 
713
      lhapdf_amc::ACTIVESETS[1] = lhapdf_amc::PDFSetHandler(value[2]+1000*value[1]);
 
714
    } else if (my_par.find("HWLHAPDF") != string::npos) {
 
715
      cout << "==== LHAPDF6 USING HERWIG-TYPE LHAGLUE INTERFACE ====" << endl;
 
716
      // Take PDF ID from value[0]
 
717
      lhapdf_amc::ACTIVESETS[1] = lhapdf_amc::PDFSetHandler(value[0]);
 
718
    } else if (my_par.find("DEFAULT") != string::npos) {
 
719
      cout << "==== LHAPDF6 USING DEFAULT-TYPE LHAGLUE INTERFACE ====" << endl;
 
720
      // Take PDF ID from value[0]
 
721
      lhapdf_amc::ACTIVESETS[1] = lhapdf_amc::PDFSetHandler(value[0]);
 
722
    } else {
 
723
      cout << "==== LHAPDF6 USING PDFLIB-TYPE LHAGLUE INTERFACE ====" << endl;
 
724
      // Take PDF ID from value[2]
 
725
      lhapdf_amc::ACTIVESETS[1] = lhapdf_amc::PDFSetHandler(value[2]+1000*value[1]);
 
726
    }
 
727
 
 
728
    lhapdf_amc::CURRENTSET = 1;
 
729
 
 
730
    // Extract parameters for common blocks (with sensible fallback values)
 
731
    lhapdf_amc::PDFPtr pdf = lhapdf_amc::ACTIVESETS[1].activemember();
 
732
    w50513_.xmin = pdf->info().get_entry_as<double>("XMin", 0.0);
 
733
    w50513_.xmax = pdf->info().get_entry_as<double>("XMax", 1.0);
 
734
    w50513_.q2min = LHAPDF::sqr(pdf->info().get_entry_as<double>("QMin", 1.0));
 
735
    w50513_.q2max = LHAPDF::sqr(pdf->info().get_entry_as<double>("QMax", 1.0e5));
 
736
    w50512_.qcdl4 = pdf->info().get_entry_as<double>("AlphaS_Lambda4", 0.0);
 
737
    w50512_.qcdl5 = pdf->info().get_entry_as<double>("AlphaS_Lambda5", 0.0);
 
738
    lhapdfr_.qcdlha4 = pdf->info().get_entry_as<double>("AlphaS_Lambda4", 0.0);
 
739
    lhapdfr_.qcdlha5 = pdf->info().get_entry_as<double>("AlphaS_Lambda5", 0.0);
 
740
    lhapdfr_.nfllha = 4;
 
741
    // Activate legacy/compatibility LHAPDF5-type behaviour re. broken Lambda values
 
742
    if (pdf->info().get_entry_as<bool>("Pythia6LambdaV5Compat", true)) {
 
743
      w50512_.qcdl4 = 0.192;
 
744
      w50512_.qcdl5 = 0.192;
 
745
      lhapdfr_.qcdlha4 = 0.192;
 
746
      lhapdfr_.qcdlha5 = 0.192;
 
747
    }
 
748
  }
 
749
 
 
750
  /// PDFLIB nucleon structure function querying
 
751
  void structm_(const double& x, const double& q,
 
752
                double& upv, double& dnv, double& usea, double& dsea,
 
753
                double& str, double& chm, double& bot, double& top, double& glu) {
 
754
    lhapdf_amc::CURRENTSET = 1;
 
755
    /// Fill (partial) parton return variables
 
756
    lhapdf_amc::PDFPtr pdf = lhapdf_amc::ACTIVESETS[1].activemember();
 
757
    dsea = pdf->xfxQ(-1, x, q);
 
758
    usea = pdf->xfxQ(-2, x, q);
 
759
    dnv = pdf->xfxQ(1, x, q) - dsea;
 
760
    upv = pdf->xfxQ(2, x, q) - usea;
 
761
    str = pdf->xfxQ(3, x, q);
 
762
    chm = (pdf->hasFlavor(4)) ? pdf->xfxQ(4, x, q) : 0;
 
763
    bot = (pdf->hasFlavor(5)) ? pdf->xfxQ(5, x, q) : 0;
 
764
    top = (pdf->hasFlavor(6)) ? pdf->xfxQ(6, x, q) : 0;
 
765
    glu = pdf->xfxQ(21, x, q);
 
766
  }
 
767
 
 
768
  /// PDFLIB photon structure function querying
 
769
  void structp_(const double& x, const double& q2, const double& p2, const double& ip2,
 
770
                double& upv, double& dnv, double& usea, double& dsea,
 
771
                double& str, double& chm, double& bot, double& top, double& glu) {
 
772
    throw LHAPDF::NotImplementedError("Photon structure functions are not yet supported");
 
773
  }
 
774
 
 
775
  /// PDFLIB statistics on PDF under/overflows
 
776
  void pdfsta_() {
 
777
    /// @note Can't do anything...
 
778
  }
 
779
 
 
780
 
 
781
}
 
782
 
 
783
 
 
784
// LHAPDF namespace C++ compatibility code
 
785
#ifdef ENABLE_LHAGLUE_CXX
 
786
 
 
787
 
 
788
void LHAPDF::setVerbosity(LHAPDF::Verbosity noiselevel) {
 
789
  LHAPDF::setVerbosity((int) noiselevel);
 
790
}
 
791
 
 
792
void LHAPDF::setPDFPath(const string& path) {
 
793
  pathsPrepend(path);
 
794
}
 
795
 
 
796
string LHAPDF::pdfsetsPath() {
 
797
  return paths()[0];
 
798
}
 
799
 
 
800
int LHAPDF::numberPDF() {
 
801
  int nmem;
 
802
  numberpdf_(nmem);
 
803
  return nmem;
 
804
}
 
805
int LHAPDF::numberPDF(int nset) {
 
806
  int nmem;
 
807
  numberpdfm_(nset,nmem);
 
808
  return nmem;
 
809
}
 
810
 
 
811
void LHAPDF::initPDF( int memset) {
 
812
  int nset1 = 1;
 
813
  initpdfm_(nset1, memset);
 
814
}
 
815
void LHAPDF::initPDF(int nset, int memset) {
 
816
  initpdfm_(nset, memset);
 
817
}
 
818
 
 
819
 
 
820
double LHAPDF::xfx(double x, double Q, int fl) {
 
821
  vector<double> r(13);
 
822
  evolvepdf_(x, Q, &r[0]);
 
823
  return r[fl+6];
 
824
}
 
825
double LHAPDF::xfx(int nset, double x, double Q, int fl) {
 
826
  vector<double> r(13);
 
827
  evolvepdfm_(nset, x, Q, &r[0]);
 
828
  return r[fl+6];
 
829
}
 
830
 
 
831
vector<double> LHAPDF::xfx(double x, double Q) {
 
832
  vector<double> r(13);
 
833
  evolvepdf_(x, Q, &r[0]);
 
834
  return r;
 
835
}
 
836
vector<double> LHAPDF::xfx(int nset, double x, double Q) {
 
837
  vector<double> r(13);
 
838
  evolvepdfm_(nset, x, Q, &r[0]);
 
839
  return r;
 
840
}
 
841
 
 
842
void LHAPDF::xfx(double x, double Q, double* results) {
 
843
  evolvepdf_(x, Q, results);
 
844
}
 
845
void LHAPDF::xfx(int nset, double x, double Q, double* results) {
 
846
  evolvepdfm_(nset, x, Q, results);
 
847
}
 
848
 
 
849
 
 
850
vector<double> LHAPDF::xfxphoton(double x, double Q) {
 
851
  vector<double> r(13);
 
852
  double mphoton;
 
853
  evolvepdfphoton_(x, Q, &r[0], mphoton);
 
854
  r.push_back(mphoton);
 
855
  return r;
 
856
}
 
857
vector<double> LHAPDF::xfxphoton(int nset, double x, double Q) {
 
858
  vector<double> r(13);
 
859
  double mphoton;
 
860
  evolvepdfphotonm_(nset, x, Q, &r[0], mphoton);
 
861
  r.push_back(mphoton);
 
862
  return r;
 
863
}
 
864
 
 
865
void LHAPDF::xfxphoton(double x, double Q, double* results) {
 
866
  evolvepdfphoton_(x, Q, results, results[13]);
 
867
}
 
868
void LHAPDF::xfxphoton(int nset, double x, double Q, double* results) {
 
869
  evolvepdfphotonm_(nset, x, Q, results, results[13]);
 
870
}
 
871
 
 
872
double LHAPDF::xfxphoton(double x, double Q, int fl) {
 
873
  vector<double> r(13);
 
874
  double mphoton;
 
875
  evolvepdfphoton_(x, Q, &r[0], mphoton);
 
876
  if (fl == 7) return mphoton;
 
877
  return r[fl+6];
 
878
}
 
879
double LHAPDF::xfxphoton(int nset, double x, double Q, int fl) {
 
880
  vector<double> r(13);
 
881
  double mphoton;
 
882
  evolvepdfphotonm_(nset, x, Q, &r[0], mphoton);
 
883
  if ( fl == 7 ) return mphoton;
 
884
  return r[fl+6];
 
885
}
 
886
 
 
887
 
 
888
void LHAPDF::initPDFSet(const string& filename, int nmem) {
 
889
  initPDFSet(1,filename, nmem);
 
890
}
 
891
 
 
892
void LHAPDF::initPDFSet(int nset, const string& filename, int nmem) {
 
893
  initPDFSetByName(nset,filename);
 
894
  ACTIVESETS[nset].loadMember(nmem);
 
895
  CURRENTSET = nset;
 
896
}
 
897
 
 
898
 
 
899
void LHAPDF::initPDFSet(const string& filename, SetType type ,int nmem) {
 
900
  // silently ignore type
 
901
  initPDFSet(1,filename, nmem);
 
902
}
 
903
 
 
904
void LHAPDF::initPDFSet(int nset, const string& filename, SetType type ,int nmem) {
 
905
  // silently ignore type
 
906
  initPDFSetByName(nset,filename);
 
907
  ACTIVESETS[nset].loadMember(nmem);
 
908
  CURRENTSET = nset;
 
909
}
 
910
 
 
911
void LHAPDF::initPDFSet(int nset, int setid, int nmem) {
 
912
  ACTIVESETS[nset] = PDFSetHandler(setid); //
 
913
  CURRENTSET = nset;
 
914
}
 
915
 
 
916
void LHAPDF::initPDFSet(int setid, int nmem) {
 
917
  initPDFSet(1,setid,nmem);
 
918
}
 
919
 
 
920
#define SIZE 999
 
921
void LHAPDF::initPDFSetByName(const string& filename) {
 
922
  std::cout << "initPDFSetByName: " << filename << std::endl;
 
923
  char cfilename[SIZE+1];
 
924
  strncpy(cfilename, filename.c_str(), SIZE);
 
925
  initpdfsetbyname_(cfilename, filename.length());
 
926
}
 
927
 
 
928
void LHAPDF::initPDFSetByName(int nset, const string& filename) {
 
929
  char cfilename[SIZE+1];
 
930
  strncpy(cfilename, filename.c_str(), SIZE);
 
931
  initpdfsetbynamem_(nset, cfilename, filename.length());
 
932
}
 
933
 
 
934
void LHAPDF::initPDFSetByName(const string& filename, SetType type) {
 
935
  //silently ignore type
 
936
  std::cout << "initPDFSetByName: " << filename << std::endl;
 
937
  char cfilename[SIZE+1];
 
938
  strncpy(cfilename, filename.c_str(), SIZE);
 
939
  initpdfsetbyname_(cfilename, filename.length());
 
940
}
 
941
 
 
942
void LHAPDF::initPDFSetByName(int nset, const string& filename, SetType type) {
 
943
  //silently ignore type
 
944
  char cfilename[SIZE+1];
 
945
  strncpy(cfilename, filename.c_str(), SIZE);
 
946
  initpdfsetbynamem_(nset, cfilename, filename.length());
 
947
}
 
948
 
 
949
 
 
950
void LHAPDF::getDescription() {
 
951
  getDescription(1);
 
952
}
 
953
 
 
954
void LHAPDF::getDescription(int nset) {
 
955
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
956
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
957
  cout << ACTIVESETS[nset].activemember()->set().description() << endl;
 
958
}
 
959
 
 
960
 
 
961
double LHAPDF::alphasPDF(double Q) {
 
962
  return LHAPDF::alphasPDF(1, Q) ;
 
963
}
 
964
 
 
965
double LHAPDF::alphasPDF(int nset, double Q) {
 
966
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
967
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
968
  CURRENTSET = nset;
 
969
  // return alphaS for the requested set
 
970
  return ACTIVESETS[nset].activemember()->alphasQ(Q);
 
971
}
 
972
 
 
973
 
 
974
bool LHAPDF::hasPhoton(){
 
975
  return has_photon_();
 
976
}
 
977
 
 
978
 
 
979
int LHAPDF::getOrderAlphaS() {
 
980
  return LHAPDF::getOrderAlphaS(1) ;
 
981
}
 
982
 
 
983
int LHAPDF::getOrderAlphaS(int nset) {
 
984
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
985
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
986
  CURRENTSET = nset;
 
987
  // return alphaS Order for the requested set
 
988
  return ACTIVESETS[nset].activemember()->info().get_entry_as<int>("AlphaS_OrderQCD", -1);
 
989
}
 
990
 
 
991
 
 
992
int LHAPDF::getOrderPDF() {
 
993
  return LHAPDF::getOrderPDF(1) ;
 
994
}
 
995
 
 
996
int LHAPDF::getOrderPDF(int nset) {
 
997
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
998
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
999
  CURRENTSET = nset;
 
1000
  // return PDF order for the requested set
 
1001
  return ACTIVESETS[nset].activemember()->info().get_entry_as<int>("OrderQCD", -1);
 
1002
}
 
1003
 
 
1004
 
 
1005
double LHAPDF::getLam4(int nmem) {
 
1006
  return LHAPDF::getLam4(1, nmem) ;
 
1007
}
 
1008
 
 
1009
double LHAPDF::getLam4(int nset, int nmem) {
 
1010
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
1011
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
1012
  CURRENTSET = nset;
 
1013
  ACTIVESETS[nset].loadMember(nmem);
 
1014
  return ACTIVESETS[nset].activemember()->info().get_entry_as<double>("AlphaS_Lambda4", -1.0);
 
1015
}
 
1016
 
 
1017
 
 
1018
double LHAPDF::getLam5(int nmem) {
 
1019
  return LHAPDF::getLam5(1, nmem) ;
 
1020
}
 
1021
 
 
1022
double LHAPDF::getLam5(int nset, int nmem) {
 
1023
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
1024
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
1025
  CURRENTSET = nset;
 
1026
  ACTIVESETS[nset].loadMember(nmem);
 
1027
  return ACTIVESETS[nset].activemember()->info().get_entry_as<double>("AlphaS_Lambda5", -1.0);
 
1028
}
 
1029
 
 
1030
 
 
1031
int LHAPDF::getNf() {
 
1032
  return LHAPDF::getNf(1) ;
 
1033
}
 
1034
 
 
1035
int LHAPDF::getNf(int nset) {
 
1036
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
1037
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
1038
  CURRENTSET = nset;
 
1039
  // return alphaS Order for the requested set
 
1040
  return ACTIVESETS[nset].activemember()->info().get_entry_as<int>("NumFlavors");
 
1041
}
 
1042
 
 
1043
 
 
1044
double LHAPDF::getXmin(int nmem) {
 
1045
  return LHAPDF::getXmin(1, nmem) ;
 
1046
}
 
1047
 
 
1048
double LHAPDF::getXmin(int nset, int nmem) {
 
1049
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
1050
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
1051
  CURRENTSET = nset;
 
1052
  // return alphaS Order for the requested set
 
1053
  ACTIVESETS[nset].loadMember(nmem);
 
1054
  return ACTIVESETS[nset].activemember()->info().get_entry_as<double>("XMin");
 
1055
}
 
1056
 
 
1057
double LHAPDF::getXmax(int nmem) {
 
1058
  return LHAPDF::getXmax(1, nmem) ;
 
1059
}
 
1060
 
 
1061
double LHAPDF::getXmax(int nset, int nmem) {
 
1062
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
1063
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
1064
  CURRENTSET = nset;
 
1065
  // return alphaS Order for the requested set
 
1066
  ACTIVESETS[nset].loadMember(nmem);
 
1067
  return ACTIVESETS[nset].activemember()->info().get_entry_as<double>("XMax");
 
1068
}
 
1069
 
 
1070
double LHAPDF::getQ2min(int nmem) {
 
1071
  return LHAPDF::getQ2min(1, nmem) ;
 
1072
}
 
1073
 
 
1074
double LHAPDF::getQ2min(int nset, int nmem) {
 
1075
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
1076
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
1077
  CURRENTSET = nset;
 
1078
  // return alphaS Order for the requested set
 
1079
  ACTIVESETS[nset].loadMember(nmem);
 
1080
  return pow(ACTIVESETS[nset].activemember()->info().get_entry_as<double>("QMin"),2);
 
1081
}
 
1082
 
 
1083
double LHAPDF::getQ2max(int nmem) {
 
1084
  return LHAPDF::getQ2max(1,nmem) ;
 
1085
}
 
1086
 
 
1087
double LHAPDF::getQ2max(int nset, int nmem) {
 
1088
  if (ACTIVESETS.find(nset) == ACTIVESETS.end())
 
1089
    throw LHAPDF::UserError("Trying to use LHAGLUE set #" + LHAPDF::to_str(nset) + " but it is not initialised");
 
1090
  CURRENTSET = nset;
 
1091
  // return alphaS Order for the requested set
 
1092
  ACTIVESETS[nset].loadMember(nmem);
 
1093
  return pow(ACTIVESETS[nset].activemember()->info().get_entry_as<double>("QMax"),2);
 
1094
}
 
1095
 
 
1096
double LHAPDF::getQMass(int nf) {
 
1097
  return LHAPDF::getQMass(1, nf) ;
 
1098
}
 
1099
 
 
1100
double LHAPDF::getQMass(int nset, int nf) {
 
1101
  double mass;
 
1102
  getqmassm_(nset, nf, mass);
 
1103
  return mass;
 
1104
}
 
1105
 
 
1106
double LHAPDF::getThreshold(int nf) {
 
1107
  return LHAPDF::getThreshold(1, nf) ;
 
1108
}
 
1109
 
 
1110
double LHAPDF::getThreshold(int nset, int nf) {
 
1111
  double thres;
 
1112
  getthresholdm_(nset, nf, thres);
 
1113
  return thres;
 
1114
}
 
1115
 
 
1116
void LHAPDF::usePDFMember(int member) {
 
1117
  initpdf_(member);
 
1118
}
 
1119
 
 
1120
void LHAPDF::usePDFMember(int nset, int member) {
 
1121
  initpdfm_(nset, member);
 
1122
}
 
1123
 
 
1124
#endif // ENABLE_LHAGLUE_CXX