Angular distribution interface: Add user-defined angular distributions


double f_my_function(double *x, double * par)
{
    // (1+x*x)/2
    return (1+x[0]*x[0])/2;
    // It is important that the test fuction does not exceed 1 (but comes close to it)
}


void useAngularDistribution(void) {

    //define the angular function
    //it should not exceed 1!!
    //This can be a parsed TF1 object:
    TF1 *angles1 = new TF1("angles1", "(1+x*x)/2", -1, 1);
    //or a hand-made function:
    TF1 *angles2 = new TF1("angles2", f_my_function, -1, 1, 1);
    //or based on a TGraph:
    const Int_t n = 3;
    Double_t x[n], y[n];
    for (Int_t i=0; i<n; i++) {
	x[i] = i*(1./Double_t(n-1));
	y[i] = (1+x[i]*x[i])/2;
    }
    //another idea:
    y[0]=1.;
    y[1]=0.;
    y[2]=1.;

    TGraph *angles3 = new TGraph(n, x, y);

    PAngularDistribution *ang = new PAngularDistribution("my_angle", "My angular dist");
    ang->Add("q,parent,reference");
    ang->Add("p,daughter");
    ang->Add("NP11+,daughter,primary");

    //uncomment here one version
    //ang->SetAngleFunction(angles1);
    //ang->SetAngleFunction(angles2);
    ang->SetAngleFunction(angles3, kTRUE, kTRUE);
    //ang->SetAngleFunction(angles3,kFALSE,kTRUE);
    //options for TGraph version: useSpline, useSymmetry
    ang->Print();

    makeDistributionManager()->Add(ang);

    PReaction my_reaction (3, "p", "p", "p NP11+ [p pi0]", "angular_distribution", 1, 0, 0, 0);

    makeDistributionManager()->Print();
    my_reaction.Print();
    ang->Draw();
    my_reaction.Loop(10000);
}
 useAngularDistribution.C:1
 useAngularDistribution.C:2
 useAngularDistribution.C:3
 useAngularDistribution.C:4
 useAngularDistribution.C:5
 useAngularDistribution.C:6
 useAngularDistribution.C:7
 useAngularDistribution.C:8
 useAngularDistribution.C:9
 useAngularDistribution.C:10
 useAngularDistribution.C:11
 useAngularDistribution.C:12
 useAngularDistribution.C:13
 useAngularDistribution.C:14
 useAngularDistribution.C:15
 useAngularDistribution.C:16
 useAngularDistribution.C:17
 useAngularDistribution.C:18
 useAngularDistribution.C:19
 useAngularDistribution.C:20
 useAngularDistribution.C:21
 useAngularDistribution.C:22
 useAngularDistribution.C:23
 useAngularDistribution.C:24
 useAngularDistribution.C:25
 useAngularDistribution.C:26
 useAngularDistribution.C:27
 useAngularDistribution.C:28
 useAngularDistribution.C:29
 useAngularDistribution.C:30
 useAngularDistribution.C:31
 useAngularDistribution.C:32
 useAngularDistribution.C:33
 useAngularDistribution.C:34
 useAngularDistribution.C:35
 useAngularDistribution.C:36
 useAngularDistribution.C:37
 useAngularDistribution.C:38
 useAngularDistribution.C:39
 useAngularDistribution.C:40
 useAngularDistribution.C:41
 useAngularDistribution.C:42
 useAngularDistribution.C:43
 useAngularDistribution.C:44
 useAngularDistribution.C:45
 useAngularDistribution.C:46
 useAngularDistribution.C:47
 useAngularDistribution.C:48
 useAngularDistribution.C:49
 useAngularDistribution.C:50
 useAngularDistribution.C:51
 useAngularDistribution.C:52
 useAngularDistribution.C:53
 useAngularDistribution.C:54