30 inline Double_t f2(
const Double_t x,
33 return TMath::Gaus(y, 0.0, x, kTRUE);
44 inline Double_t g2(
const Double_t x,
47 return TMath::Gaus(y, 0.0, x, kTRUE) * -y/x;
58 inline Double_t G2(
const Double_t x,
61 return 0.5 * (1.0 + TMath::Erf(sqrt(0.5)*y/x));
67 typedef typename function_type::transformer_type transformer_type;
68 typedef typename function_type::result_type result_type;
74 struct JTransformer_t :
75 public transformer_type
77 typedef typename transformer_type::clone_type clone_type;
78 typedef typename transformer_type::argument_type argument_type;
79 typedef typename transformer_type::const_array_type const_array_type;
89 virtual argument_type putXn(const_array_type& buffer,
const argument_type xn)
const
91 return xn * buffer[0];
102 virtual argument_type getXn(const_array_type& buffer,
const argument_type xn)
const
104 return xn / buffer[0];
114 virtual double getWeight(const_array_type& buffer)
const
149 virtual clone_type clone()
const
151 return new JTransformer_t(*
this);
163 int main(
int argc,
char **argv)
175 JParser<> zap(
"Example program to test transformable function.");
184 catch(
const exception &error) {
185 FATAL(error.what() << endl);
188 if (numberOfEvents <= 0) {
189 FATAL(
"No events." << endl);
193 const double xmin = 0.1;
194 const double xmax = 1.0;
195 const double dx = (xmax - xmin) / 3;
199 for (
double x = xmin; x < xmax + 0.5*dx; x += dx) {
201 const double ymin = -5.0 * xmax;
202 const double ymax = +5.0 * xmax;
203 const double dy = (ymax - ymin) / (numberOfBins - 1);
205 for (
double y = ymin; y < ymax + 0.5*dy; y += dy) {
210 h2.setExceptionHandler(
new typename function_type::JDefaultResult(
JMATH::zero));
213 h2.transform(JTransformer_t());
225 const double ymin = -5.0 * xmax;
226 const double ymax = +5.0 * xmax;
228 for (
int i = 0; i != numberOfEvents; ++i) {
230 const double x = gRandom->Uniform(xmin, xmax);
231 const double y = gRandom->Uniform(ymin, ymax);
235 const result_type value = h2(x,y);
237 const double f = f2(x,y);
238 const double fp = g2(x,y);
239 const double v = G2(x,y);
241 Q[0].put(value.f - f);
242 Q[1].put(value.fp - fp);
243 Q[2].put(value.v - v);
245 catch(
const std::exception& error) {}
252 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
253 cout <<
" " << setw(10) << Q[i].getTitle();
258 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
259 cout <<
" " <<
SCIENTIFIC(10,2) << Q[i].getMean();
264 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
265 cout <<
" " <<
SCIENTIFIC(10,2) << Q[i].getSTDev();
Utility class to parse command line options.
Interface for binary output.
static const JZero zero
Function object to assign zero value.
Various implementations of functional maps.
std::istream & read(std::istream &in, JContainer_t< TString, JAllocator_t > &object, const JBool< false > &option)
Auxiliary method for reading if TString does not exist.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Interface for binary input.
General purpose messaging.
Utility class to parse command line options.
Auxiliary data structure for floating point format specification.
int main(int argc, char *argv[])