PetersonFragm.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7  University of Liverpool & STFC Rutherford Appleton Laboratory
8 */
9 //____________________________________________________________________________
10 
11 #include <TROOT.h>
12 
15 
16 using namespace genie;
17 
18 //___________________________________________________________________________
20 FragmentationFunctionI("genie::PetersonFragm")
21 {
22 
23 }
24 //___________________________________________________________________________
26 FragmentationFunctionI("genie::PetersonFragm", config)
27 {
28  this->BuildFunction();
29 }
30 //___________________________________________________________________________
32 {
33  delete fFunc;
34 }
35 //___________________________________________________________________________
36 double PetersonFragm::Value(double z) const
37 {
38 // Evaluate the fragmentation function
39 
40  if(z<0 || z>1) return 0;
41  return fFunc->Eval(z);
42 }
43 //___________________________________________________________________________
44 double PetersonFragm::GenerateZ(void) const
45 {
46 // Return a random number using the fragmentation function as PDF
47 
48  return fFunc->GetRandom();
49 }
50 //___________________________________________________________________________
52 {
53  Algorithm::Configure(config);
54  this->BuildFunction();
55 }
56 //___________________________________________________________________________
58 {
59  Algorithm::Configure(config);
60  this->BuildFunction();
61 }
62 //___________________________________________________________________________
64 {
65  fFunc = new TF1("fFunc",genie::utils::frgmfunc::peterson_func,0,1,2);
66 
67  fFunc->SetParNames("Norm","Epsilon");
68  // stop ROOT from deleting this object of its own volition
69  gROOT->GetListOfFunctions()->Remove(fFunc);
70 
71  double N = -1. ;
72  GetParam( "PetFrag-Norm", N, false ) ;
73 
74  //The xml files says that Epsilon is not optional, while the
75  //orignal behaviour of this function assigned a 0 default value
76  //if the xml file was not providing such a number.
77  // Original behaviour maintained
78  double e = 0. ;
79  GetParam( "PetFrag-Epsilon", e, false ) ;
80 
81  // if the normalization parameter was left negative, explicitly normalize
82  // the fragmentation function
83  if(N<0) {
84  N=1;
85  fFunc->SetParameters(N,e);
86  double I = fFunc->Integral(0,1);
87  assert(I>0);
88  N = 1./I;
89  }
90  fFunc->SetParameters(N,e);
91 }
92 //___________________________________________________________________________
void Configure(const Registry &config)
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
double peterson_func(double *x, double *par)
The Peterson fragmentation function.
const double e
static Config * config
Definition: config.cpp:1054
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
double Value(double z) const
implement the FragmentationFunctionI interface
Pure abstract base class. Defines the FragmentationFunctionI interface to be implemented by any algor...
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
double GenerateZ(void) const