<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.3.1"/> <title>LHAPDF C++ wrapper: /examples/CCTest1.cc</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">LHAPDF C++ wrapper  <span id="projectnumber">5.4</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.3.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">/examples/CCTest1.cc</div> </div> </div><!--header--> <div class="contents"> <p>This is an example of a program using the recommended C++ interface to <a class="el" href="namespaceLHAPDF.html" title="Namespace containing all the LHAPDF wrapper functions.">LHAPDF</a>.</p> <div class="fragment"><div class="line"><span class="comment">// Simple test program to test functionality of</span></div> <div class="line"><span class="comment">// the LHAPDF C++ wrapper.</span></div> <div class="line"><span class="comment">// Use this as a template for your program.</span></div> <div class="line"><span class="comment">//</span></div> <div class="line"><span class="comment">// Original author: Stefan Gieseke 2005</span></div> <div class="line"><span class="comment">// Adapted for LHAPDF v5+ by Mike Whalley.</span></div> <div class="line"><span class="comment">// Further updates for >= v5.4 by Andy Buckley.</span></div> <div class="line"></div> <div class="line"><span class="preprocessor">#include "LHAPDF/LHAPDF.h"</span></div> <div class="line"><span class="preprocessor">#include <iterator></span></div> <div class="line"><span class="preprocessor">#include <iostream></span></div> <div class="line"><span class="preprocessor">#include <cstdlib></span></div> <div class="line"><span class="keyword">using namespace </span>std;</div> <div class="line"></div> <div class="line"><span class="comment">// NB. You might want to also have</span></div> <div class="line"><span class="comment">// using namespace LHAPDF;</span></div> <div class="line"><span class="comment">// for convenience.</span></div> <div class="line"></div> <div class="line"></div> <div class="line"><span class="keywordtype">int</span> main() {</div> <div class="line"> <span class="keyword">const</span> <span class="keywordtype">int</span> SUBSET = 0;</div> <div class="line"> <span class="keyword">const</span> <span class="keywordtype">string</span> NAME = <span class="stringliteral">"CT10"</span>;</div> <div class="line"></div> <div class="line"> <a name="a0"></a><a class="code" href="namespaceLHAPDF.html#aa10ba6e937b19cbc9d58ec0f5aaf2564" title="Initialise member in PDF set setid.">LHAPDF::initPDFSet</a>(NAME, LHAPDF::LHGRID, SUBSET);</div> <div class="line"></div> <div class="line"> <span class="keyword">const</span> <span class="keywordtype">double</span> Q = 10.0, mz = 91.2;</div> <div class="line"> cout << <span class="stringliteral">"alphas(mz) = "</span> << <a name="a1"></a><a class="code" href="namespaceLHAPDF.html#a38560c4ffe9c677e332e7b79ee1f430c" title=" used by the current PDF.">LHAPDF::alphasPDF</a>(mz) << endl;</div> <div class="line"> cout << <span class="stringliteral">"qcdlam4 = "</span> << <a name="a2"></a><a class="code" href="namespaceLHAPDF.html#ab93e76e23f624496bf6efe20dcb0871d" title="Value of QCD for member m.">LHAPDF::getLam4</a>(SUBSET) << endl;</div> <div class="line"> cout << <span class="stringliteral">"qcdlam5 = "</span> << <a name="a3"></a><a class="code" href="namespaceLHAPDF.html#a45ac2af896fdc4d28e8e5457a46a68b7" title="Value of QCD for member m.">LHAPDF::getLam5</a>(SUBSET) << endl;</div> <div class="line"> cout << <span class="stringliteral">"orderPDF = "</span> << <a name="a4"></a><a class="code" href="namespaceLHAPDF.html#a18f83a309678f560e5be15a8b51bea5a" title="Get order at which the PDF was fitted.">LHAPDF::getOrderPDF</a>() << endl;</div> <div class="line"> cout << <span class="stringliteral">"xmin = "</span> << <a name="a5"></a><a class="code" href="namespaceLHAPDF.html#a4b68147f30e452ed7bbe300630b46a3f" title="Minimum value considered valid for this set, as specified by the set authors.">LHAPDF::getXmin</a>(SUBSET) << endl;</div> <div class="line"> cout << <span class="stringliteral">"xmax = "</span> << <a name="a6"></a><a class="code" href="namespaceLHAPDF.html#a9674750111bc08eee46291537f5aca71" title="Maximum value considered valid for this set, as specified by the set authors.">LHAPDF::getXmax</a>(SUBSET) << endl;</div> <div class="line"> cout << <span class="stringliteral">"q2min = "</span> << <a name="a7"></a><a class="code" href="namespaceLHAPDF.html#aaf8a27a30e2a01de0456096492804a9e" title="Minimum value considered valid for this set, as specified by the set authors.">LHAPDF::getQ2min</a>(SUBSET) << endl;</div> <div class="line"> cout << <span class="stringliteral">"q2max = "</span> << <a name="a8"></a><a class="code" href="namespaceLHAPDF.html#ad4db3b12b4887db4389adb37987c2c77" title="Maximum value considered valid for this set, as specified by the set authors.">LHAPDF::getQ2max</a>(SUBSET) << endl;</div> <div class="line"> cout << <span class="stringliteral">"orderalfas = "</span> << <a name="a9"></a><a class="code" href="namespaceLHAPDF.html#a550873e5d7fe446d28648e9789d2e54d" title="Perturbative order of parton evolution and respectively.">LHAPDF::getOrderAlphaS</a>() << endl;</div> <div class="line"> cout << <span class="stringliteral">"num flav = "</span> << <a name="a10"></a><a class="code" href="namespaceLHAPDF.html#a06455b0d04084767234687d2157fbaac" title="Number of flavours used in the current PDF set.">LHAPDF::getNf</a>() << endl;</div> <div class="line"> cout << <span class="stringliteral">"name = "</span> << NAME << endl;</div> <div class="line"> cout << <span class="stringliteral">"number = "</span> << <a name="a11"></a><a class="code" href="namespaceLHAPDF.html#a4cfecd0693992eff5c0febc2838ed376" title="Number of members available in the current set.">LHAPDF::numberPDF</a>() << endl;</div> <div class="line"> cout << endl;</div> <div class="line"></div> <div class="line"></div> <div class="line"> <span class="comment">// LHAPDF::extrapolate();</span></div> <div class="line"></div> <div class="line"> <span class="keyword">const</span> <span class="keywordtype">int</span> NUMBER = <a class="code" href="namespaceLHAPDF.html#a4cfecd0693992eff5c0febc2838ed376" title="Number of members available in the current set.">LHAPDF::numberPDF</a>();</div> <div class="line"></div> <div class="line"></div> <div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0; n < NUMBER + 1; ++n) {</div> <div class="line"> cout << <span class="stringliteral">"Set number: "</span> << n << endl;</div> <div class="line"> <a name="a12"></a><a class="code" href="namespaceLHAPDF.html#a8db3179ee46b8fcdb742eba2c00837dd" title="The choice of PDF member out of one distribution.">LHAPDF::initPDF</a>(n);</div> <div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> ix = 1; ix < 11; ++ix) {</div> <div class="line"> <span class="keyword">const</span> <span class="keywordtype">double</span> x = (ix - 0.5) / 10.0;</div> <div class="line"> cout << <span class="stringliteral">"x="</span> << x << <span class="stringliteral">", Q="</span> << Q << <span class="stringliteral">", f=0: "</span> << <a name="a13"></a><a class="code" href="namespaceLHAPDF.html#a1c64cf2da56507d8640034dcdb412b31">LHAPDF::xfx</a>(x, Q, 0) << endl;</div> <div class="line"> }</div> <div class="line"> cout << endl;</div> <div class="line"> }</div> <div class="line"></div> <div class="line"></div> <div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0; n < NUMBER + 1; ++n) {</div> <div class="line"> cout << <span class="stringliteral">"Set number: "</span> << n << endl;</div> <div class="line"> <a class="code" href="namespaceLHAPDF.html#a8db3179ee46b8fcdb742eba2c00837dd" title="The choice of PDF member out of one distribution.">LHAPDF::initPDF</a>(n);</div> <div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> ix = 1; ix < 11; ++ix) {</div> <div class="line"> <span class="keyword">const</span> <span class="keywordtype">double</span> x = (ix - 0.5) / 10.0;</div> <div class="line"> cout << <span class="stringliteral">"x="</span> << x << <span class="stringliteral">", Q="</span> << Q << <span class="stringliteral">": "</span>;</div> <div class="line"> vector<double> result = <a class="code" href="namespaceLHAPDF.html#a1c64cf2da56507d8640034dcdb412b31">LHAPDF::xfx</a>(x, Q);</div> <div class="line"> std::copy(result.begin(), result.end(), ostream_iterator<double>(cout,<span class="stringliteral">"\t"</span>));</div> <div class="line"> cout << endl;</div> <div class="line"> }</div> <div class="line"> cout << endl;</div> <div class="line"> }</div> <div class="line"></div> <div class="line"></div> <div class="line"> cout << string().insert(0, 40, <span class="charliteral">'-'</span>) << endl << endl;</div> <div class="line"> cout << <span class="stringliteral">"Checking LHAPDF with package "</span> << endl;</div> <div class="line"> cout << NAME << <span class="stringliteral">" set number "</span> << SUBSET << <span class="stringliteral">"/"</span> << <a class="code" href="namespaceLHAPDF.html#a4cfecd0693992eff5c0febc2838ed376" title="Number of members available in the current set.">LHAPDF::numberPDF</a>() << endl << endl;</div> <div class="line"> cout << <span class="stringliteral">"LHAPDF::getDescription() gives:"</span> << endl;</div> <div class="line"> <a name="a14"></a><a class="code" href="namespaceLHAPDF.html#a04cf7f990740e452d0fe736947b343ae" title="Prints a brief description of the current PDF set to stdout.">LHAPDF::getDescription</a>();</div> <div class="line"></div> <div class="line"> <span class="keywordflow">return</span> EXIT_SUCCESS;</div> <div class="line">}</div> <div class="line"></div> <div class="line"></div> <div class="line"><span class="preprocessor">#include "FortranWrappers.h"</span></div> <div class="line"><span class="preprocessor">#ifdef FC_DUMMY_MAIN</span></div> <div class="line"><span class="preprocessor"></span><span class="keywordtype">int</span> FC_DUMMY_MAIN() { <span class="keywordflow">return</span> 1; }</div> <div class="line"><span class="preprocessor">#endif</span></div> </div><!-- fragment --> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Thu Nov 21 2013 06:02:29 for LHAPDF C++ wrapper by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.3.1 </small></address> </body> </html>