Example for a 2-body scattering with total and differential cross sections


{

    //Add a model for the reaction "g+p -> p+eta":
    PScatterCrossSection * model = new PScatterCrossSection("mymodel","My cross section");
    model->Add("g,grandparent,beam");
    model->Add("p,grandparent,target");
    model->Add("q,parent");
    model->Add("p,daughter");
    model->Add("eta,daughter,primary");

    //Define the range of the c.m. sampling:
    model->SetRange(1.4,2.0); 

    //Now start to fill the helper histogram
    //The axis *can* be like in the PScatterCrossSection model (see below)
    //but this is not to be required. You can use the batch equations 
    //to make a conversion
    TH1F *distribution = new TH1F("distribution", "Angular distribution", 10, -1 , 1 );
    distribution->SetBinContent(1,20.);
    distribution->SetBinContent(2,16.);
    distribution->SetBinContent(3,11.);
    distribution->SetBinContent(4,8.);
    distribution->SetBinContent(5,5.);
    distribution->SetBinContent(6,4.);
    distribution->SetBinContent(7,3.);
    distribution->SetBinContent(8,2.5);
    distribution->SetBinContent(9,2.);
    distribution->SetBinContent(10,1.);
    
    //Now add the histogram to the model class, and define an equation
    //Input:  _x is cos(theta), _y is the c.m. energy
    //Output: _f: cross section
    model->AddHistogram(distribution,"value = Eval(_x); _f = _y * value");
    //This equation only a placeholder. If the histogram has a
    //different axis, it is possible to convert the axis, e.g.: 
    //
    //my_x = f(_x); value = Eval(my_x); 
    //
    //with f() as any user-defined function which is possible (see
    //script manual for details). A TH2 can also be used, in this case
    //one should the 2-dimensional version of Eval(x,y)
    //
    //The function can also be staged:
    //model->AddHistogram(distribution,"value = Eval(_x);");
    //model->AddEquation(" _f = _y * value");
    //produces the same result as above
    //
    //The function _f can be folded with the beam profile. But one has
    //to keep in mind that the beam profile must be converted into a
    //function based on the c.m. energy (e.g. by calculating the T_lab
    //based on q)
    //
    //The following example demonstate this. Let's say that a
    //histogram "profile" contains the beam profile and the x-axis is
    //T_lab. Therefore, one has to do a small calculation like:
    //
    //model->AddEquation("t_lab = (_y*_y - g.mass*g.mass - p.mass*p.mass)/(2*p.mass*p.mass) - g.mass;");
    //model->AddHistogram(profile,"_f = _f * Eval(t_lab);");
    //(the gamma mass "g.mass" is only added for completeness)
    //
    //if one would like to use an analytic function instead of a
    //histogram is also possible. 


    //Add the model to the manager:
    makeDistributionManager()->Add(model);
    
    
    PReaction my_reaction("_P1 = 2.2","g","p","p eta [dilepton [e+ e-] g]");
    TH2F * histo2 = new TH2F ("histo2","c.m. vs cos_theta",100,1.0,3.0,20,-1,1);
    my_reaction.Do(histo2,"_x = [g+p]->M(); myeta = [eta]; myeta->Boost([g+p]); _y = myeta->CosTheta()");
    my_reaction.Print();


    my_reaction.Loop(100000);


}
 plugin_cross_section_example.C:1
 plugin_cross_section_example.C:2
 plugin_cross_section_example.C:3
 plugin_cross_section_example.C:4
 plugin_cross_section_example.C:5
 plugin_cross_section_example.C:6
 plugin_cross_section_example.C:7
 plugin_cross_section_example.C:8
 plugin_cross_section_example.C:9
 plugin_cross_section_example.C:10
 plugin_cross_section_example.C:11
 plugin_cross_section_example.C:12
 plugin_cross_section_example.C:13
 plugin_cross_section_example.C:14
 plugin_cross_section_example.C:15
 plugin_cross_section_example.C:16
 plugin_cross_section_example.C:17
 plugin_cross_section_example.C:18
 plugin_cross_section_example.C:19
 plugin_cross_section_example.C:20
 plugin_cross_section_example.C:21
 plugin_cross_section_example.C:22
 plugin_cross_section_example.C:23
 plugin_cross_section_example.C:24
 plugin_cross_section_example.C:25
 plugin_cross_section_example.C:26
 plugin_cross_section_example.C:27
 plugin_cross_section_example.C:28
 plugin_cross_section_example.C:29
 plugin_cross_section_example.C:30
 plugin_cross_section_example.C:31
 plugin_cross_section_example.C:32
 plugin_cross_section_example.C:33
 plugin_cross_section_example.C:34
 plugin_cross_section_example.C:35
 plugin_cross_section_example.C:36
 plugin_cross_section_example.C:37
 plugin_cross_section_example.C:38
 plugin_cross_section_example.C:39
 plugin_cross_section_example.C:40
 plugin_cross_section_example.C:41
 plugin_cross_section_example.C:42
 plugin_cross_section_example.C:43
 plugin_cross_section_example.C:44
 plugin_cross_section_example.C:45
 plugin_cross_section_example.C:46
 plugin_cross_section_example.C:47
 plugin_cross_section_example.C:48
 plugin_cross_section_example.C:49
 plugin_cross_section_example.C:50
 plugin_cross_section_example.C:51
 plugin_cross_section_example.C:52
 plugin_cross_section_example.C:53
 plugin_cross_section_example.C:54
 plugin_cross_section_example.C:55
 plugin_cross_section_example.C:56
 plugin_cross_section_example.C:57
 plugin_cross_section_example.C:58
 plugin_cross_section_example.C:59
 plugin_cross_section_example.C:60
 plugin_cross_section_example.C:61
 plugin_cross_section_example.C:62
 plugin_cross_section_example.C:63
 plugin_cross_section_example.C:64
 plugin_cross_section_example.C:65
 plugin_cross_section_example.C:66
 plugin_cross_section_example.C:67
 plugin_cross_section_example.C:68
 plugin_cross_section_example.C:69
 plugin_cross_section_example.C:70
 plugin_cross_section_example.C:71
 plugin_cross_section_example.C:72
 plugin_cross_section_example.C:73
 plugin_cross_section_example.C:74
 plugin_cross_section_example.C:75
 plugin_cross_section_example.C:76
 plugin_cross_section_example.C:77
 plugin_cross_section_example.C:78
 plugin_cross_section_example.C:79
 plugin_cross_section_example.C:80