Difference between revisions of "DV Plotting XSect"

From New IAC Wiki
Jump to navigation Jump to search
Line 88: Line 88:
 
}
 
}
  
 +
</pre>
 +
 +
A data file is created with the differential cross-section for the scattering angle theta, by increments of 1
 +
<pre>
 +
0  90.000000 0.000017 
 +
4  91.000000 0.000017 
 +
8  92.000000 0.000017 
 +
12  93.000000 0.000017 
 +
16  94.000000 0.000017 
 +
20  95.000000 0.000017 
 +
24  96.000000 0.000017 
 +
28  97.000000 0.000017 
 +
32  98.000000 0.000017 
 +
36  99.000000 0.000018 
 +
40  100.000000 0.000018
 +
44  101.000000 0.000018
 +
48  102.000000 0.000019
 +
52  103.000000 0.000019
 +
56  104.000000 0.000019
 +
60  105.000000 0.000020
 +
64  106.000000 0.000020
 +
68  107.000000 0.000021
 +
72  108.000000 0.000022
 +
76  109.000000 0.000022
 +
80  110.000000 0.000023
 +
84  111.000000 0.000024
 +
88  112.000000 0.000025
 +
92  113.000000 0.000025
 +
96  114.000000 0.000026
 +
100  115.000000 0.000028
 +
104  116.000000 0.000029
 +
108  117.000000 0.000030
 +
112  118.000000 0.000031
 +
116  119.000000 0.000033
 +
120  120.000000 0.000035
 +
124  121.000000 0.000036
 +
128  122.000000 0.000038
 +
132  123.000000 0.000040
 +
136  124.000000 0.000043
 +
140  125.000000 0.000045
 +
144  126.000000 0.000048
 +
148  127.000000 0.000051
 +
152  128.000000 0.000054
 +
156  129.000000 0.000058
 +
160  130.000000 0.000062
 +
164  131.000000 0.000067
 +
168  132.000000 0.000072
 +
172  133.000000 0.000077
 +
176  134.000000 0.000083
 +
180  135.000000 0.000090
 +
184  136.000000 0.000097
 +
188  137.000000 0.000106
 +
192  138.000000 0.000115
 +
196  139.000000 0.000126
 +
200  140.000000 0.000138
 +
204  141.000000 0.000152
 +
208  142.000000 0.000167
 +
212  143.000000 0.000185
 +
216  144.000000 0.000205
 +
220  145.000000 0.000228
 +
224  146.000000 0.000254
 +
228  147.000000 0.000285
 +
232  148.000000 0.000321
 +
236  149.000000 0.000362
 +
240  150.000000 0.000411
 +
244  151.000000 0.000468
 +
248  152.000000 0.000537
 +
252  153.000000 0.000618
 +
256  154.000000 0.000716
 +
260  155.000000 0.000834
 +
264  156.000000 0.000978
 
</pre>
 
</pre>

Revision as of 21:13, 15 April 2016

Creating a program called MollerDiffXSect.c

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
main()
{
float angle,dSigma_dOmega;
double alpha=7.2973525664e-3;
double E_CM=53e6;

                /* using equation from Landau-Lifshitz & Azfar */
                /* units in MeV */
                for(angle=90;angle<=180; angle=angle+.25)
                        {
                        dSigma_dOmega=(alpha*(3+cos(angle*3.14/180)*cos(angle*3.14/180)));
                        dSigma_dOmega=dSigma_dOmega*dSigma_dOmega;

dSigma_dOmega=dSigma_dOmega/(4*E_CM*E_CM*sin(angle*3.14/180)*sin(angle*3.14/180)*sin(angle*3.14/180)*sin(angle*3.14/180));
                        dSigma_dOmega=dSigma_dOmega*1e18;
                        dSigma_dOmega=dSigma_dOmega*.3892e-3;//barns
                        dSigma_dOmega=dSigma_dOmega/1e-6;//micro barns
                        fprintf(stdout," %f\t%f\n", angle, dSigma_dOmega);
                        }

}

Creating a Makefile with contents:

CC = gcc
DiffXSect: MollerDiffXSect.o
        $(CC) $(CFLAGS) MollerDiffXSect.o  -lm -o DiffXSect
MollerDiffXSect.o: MollerDiffXSect.c
        $(CC)  $(CFLAGS) -c MollerDiffXSect.c


The program can be run with the commands:

make DiffXSect
./DiffXSect >DiffXSect.dat

This creates a data file with the scattering angle theta and the corresponding theoretical Moller differential cross-section for said angle. A c++ macro can be written to input this into root

void MollerDiffXSect2Root()
{
    struct evt_t
        {
                Int_t event;
                Float_t Angle, dSigma_dOmega;
        };
  ifstream in;
  in.open("DiffXSect.dat");
  evt_t evt;
  Int_t nlines=0;

  int count=0;
  TFile *f = new TFile("DiffXSect.root","RECREATE");

  TTree *tree = new TTree("DiffXSect","Moller Diff Xsect");

  TH1F *Th=new TH1F("Theory","Theoretical Differential Cross Section",360,90,180);

  tree->Branch("evt",&evt.event,"event/F:Angle/F:dSigma_dOmega");
  while(in.good())
        {
                evt.event=nlines;
                in >> evt.Angle >> evt.dSigma_dOmega;
                        if(nlines==count)
                        {
                                printf( " %d  %f %f\n",evt.event, evt.Angle, evt.dSigma_dOmega);
                                count=count+4;
                        }
                 nlines++;
                tree->Fill();
                Th->Fill(evt.Angle,evt.dSigma_dOmega);
}
 tree->Print();
 tree->Write();
 f->Write();
 in.close();
 delete tree;
 delete f;
}

A data file is created with the differential cross-section for the scattering angle theta, by increments of 1

0  90.000000 0.000017   
 4  91.000000 0.000017   
 8  92.000000 0.000017   
 12  93.000000 0.000017  
 16  94.000000 0.000017  
 20  95.000000 0.000017  
 24  96.000000 0.000017  
 28  97.000000 0.000017  
 32  98.000000 0.000017  
 36  99.000000 0.000018  
 40  100.000000 0.000018 
 44  101.000000 0.000018
 48  102.000000 0.000019
 52  103.000000 0.000019
 56  104.000000 0.000019
 60  105.000000 0.000020
 64  106.000000 0.000020
 68  107.000000 0.000021
 72  108.000000 0.000022
 76  109.000000 0.000022
 80  110.000000 0.000023
 84  111.000000 0.000024
 88  112.000000 0.000025
 92  113.000000 0.000025
 96  114.000000 0.000026
 100  115.000000 0.000028
 104  116.000000 0.000029
 108  117.000000 0.000030
 112  118.000000 0.000031
 116  119.000000 0.000033
 120  120.000000 0.000035
 124  121.000000 0.000036
 128  122.000000 0.000038
 132  123.000000 0.000040
 136  124.000000 0.000043
 140  125.000000 0.000045
 144  126.000000 0.000048
 148  127.000000 0.000051
 152  128.000000 0.000054
 156  129.000000 0.000058
 160  130.000000 0.000062
 164  131.000000 0.000067
 168  132.000000 0.000072
 172  133.000000 0.000077
 176  134.000000 0.000083
 180  135.000000 0.000090
 184  136.000000 0.000097
 188  137.000000 0.000106
 192  138.000000 0.000115
 196  139.000000 0.000126
 200  140.000000 0.000138
 204  141.000000 0.000152
 208  142.000000 0.000167
 212  143.000000 0.000185
 216  144.000000 0.000205
 220  145.000000 0.000228
 224  146.000000 0.000254
 228  147.000000 0.000285
 232  148.000000 0.000321
 236  149.000000 0.000362
 240  150.000000 0.000411
 244  151.000000 0.000468
 248  152.000000 0.000537
 252  153.000000 0.000618
 256  154.000000 0.000716
 260  155.000000 0.000834
 264  156.000000 0.000978