Pluto v6.3.0
Loading...
Searching...
No Matches
cross_section_example.C
Go to the documentation of this file.
1//TITLE Example for a 2-body scattering with total and differential cross sections
2
3{
4
5 //Add a model for the reaction "g+p -> p+eta":
6 PScatterCrossSection * model = new PScatterCrossSection("mymodel","My cross section");
7 model->Add("g,grandparent,beam");
8 model->Add("p,grandparent,target");
9 model->Add("q,parent");
10 model->Add("p,daughter");
11 model->Add("eta,daughter,primary");
12
13 //Define the range of the c.m. sampling:
14 model->SetRange(1.4,2.0);
15
16 //Now start to fill the helper histogram
17 //The axis *can* be like in the PScatterCrossSection model (see below)
18 //but this is not to be required. You can use the batch equations
19 //to make a conversion
20 TH1F *distribution = new TH1F("distribution", "Angular distribution", 10, -1 , 1 );
21 distribution->SetBinContent(1,20.);
22 distribution->SetBinContent(2,16.);
23 distribution->SetBinContent(3,11.);
24 distribution->SetBinContent(4,8.);
25 distribution->SetBinContent(5,5.);
26 distribution->SetBinContent(6,4.);
27 distribution->SetBinContent(7,3.);
28 distribution->SetBinContent(8,2.5);
29 distribution->SetBinContent(9,2.);
30 distribution->SetBinContent(10,1.);
31
32 //Now add the histogram to the model class, and define an equation
33 //Input: _x is cos(theta), _y is the c.m. energy
34 //Output: _f: cross section
35 model->AddHistogram(distribution,"value = Eval(_x); _f = _y * value");
36 //This equation only a placeholder. If the histogram has a
37 //different axis, it is possible to convert the axis, e.g.:
38 //
39 //my_x = f(_x); value = Eval(my_x);
40 //
41 //with f() as any user-defined function which is possible (see
42 //script manual for details). A TH2 can also be used, in this case
43 //one should the 2-dimensional version of Eval(x,y)
44 //
45 //The function can also be staged:
46 //model->AddHistogram(distribution,"value = Eval(_x);");
47 //model->AddEquation(" _f = _y * value");
48 //produces the same result as above
49 //
50 //The function _f can be folded with the beam profile. But one has
51 //to keep in mind that the beam profile must be converted into a
52 //function based on the c.m. energy (e.g. by calculating the T_lab
53 //based on q)
54 //
55 //The following example demonstate this. Let's say that a
56 //histogram "profile" contains the beam profile and the x-axis is
57 //T_lab. Therefore, one has to do a small calculation like:
58 //
59 //model->AddEquation("t_lab = (_y*_y - g.mass*g.mass - p.mass*p.mass)/(2*p.mass*p.mass) - g.mass;");
60 //model->AddHistogram(profile,"_f = _f * Eval(t_lab);");
61 //(the gamma mass "g.mass" is only added for completeness)
62 //
63 //if one would like to use an analytic function instead of a
64 //histogram is also possible.
65
66
67 //Add the model to the manager:
69
70
71 PReaction my_reaction("_P1 = 2.2","g","p","p eta [dilepton [e+ e-] g]");
72 TH2F * histo2 = new TH2F ("histo2","c.m. vs cos_theta",100,1.0,3.0,20,-1,1);
73 my_reaction.Do(histo2,"_x = [g+p]->M(); myeta = [eta]; myeta->Boost([g+p]); _y = myeta->CosTheta()");
74 my_reaction.Print();
75
76
77 my_reaction.Loop(100000);
78
79
80}
Int_t Add(const Char_t *opt)
void SetRange(Double_t mymin, Double_t mymax)
Bool_t AddHistogram(TH2 *histo, char *command)
PReaction my_reaction("_P1 = 2.2","g","p","p eta [dilepton [e+ e-] g]")
TH1F * distribution
makeDistributionManager() -> Add(model)
PReaction my_reaction("3.5","p","7Li","p (n) phi [K+ K-] (6Li)","delme")
TH2F * histo2