PetersonFragm.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab - June 15, 2004
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13 
14 */
15 //____________________________________________________________________________
16 
17 #include <TROOT.h>
18 
21 
22 using namespace genie;
23 
24 //___________________________________________________________________________
26 FragmentationFunctionI("genie::PetersonFragm")
27 {
28 
29 }
30 //___________________________________________________________________________
32 FragmentationFunctionI("genie::PetersonFragm", config)
33 {
34  this->BuildFunction();
35 }
36 //___________________________________________________________________________
38 {
39  delete fFunc;
40 }
41 //___________________________________________________________________________
42 double PetersonFragm::Value(double z) const
43 {
44 // Evaluate the fragmentation function
45 
46  if(z<0 || z>1) return 0;
47  return fFunc->Eval(z);
48 }
49 //___________________________________________________________________________
50 double PetersonFragm::GenerateZ(void) const
51 {
52 // Return a random number using the fragmentation function as PDF
53 
54  return fFunc->GetRandom();
55 }
56 //___________________________________________________________________________
58 {
59  Algorithm::Configure(config);
60  this->BuildFunction();
61 }
62 //___________________________________________________________________________
64 {
65  Algorithm::Configure(config);
66  this->BuildFunction();
67 }
68 //___________________________________________________________________________
70 {
71  fFunc = new TF1("fFunc",genie::utils::frgmfunc::peterson_func,0,1,2);
72 
73  fFunc->SetParNames("Norm","Epsilon");
74  // stop ROOT from deleting this object of its own volition
75  gROOT->GetListOfFunctions()->Remove(fFunc);
76 
77  double N = -1. ;
78  GetParam( "PetFrag-Norm", N, false ) ;
79 
80  //The xml files says that Epsilon is not optional, while the
81  //orignal behaviour of this function assigned a 0 default value
82  //if the xml file was not providing such a number.
83  // Original behaviour maintained
84  double e = 0. ;
85  GetParam( "PetFrag-Epsilon", e, false ) ;
86 
87  // if the normalization parameter was left negative, explicitly normalize
88  // the fragmentation function
89  if(N<0) {
90  N=1;
91  fFunc->SetParameters(N,e);
92  double I = fFunc->Integral(0,1);
93  assert(I>0);
94  N = 1./I;
95  }
96  fFunc->SetParameters(N,e);
97 }
98 //___________________________________________________________________________
99 
void Configure(const Registry &config)
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
double peterson_func(double *x, double *par)
The Peterson fragmentation function.
Definition: config.py:1
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:70
double Value(double z) const
implement the FragmentationFunctionI interface
z
Definition: test.py:28
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:66
assert(nhit_max >=nhit_nbins)
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
double GenerateZ(void) const
Float_t e
Definition: plot.C:35