Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hep.aida.*;
- import java.util.Random;
- import hep.aida.*;
- import java.io.*;
- import java.util.*;
- public class photons
- {
- static StringTokenizer st;
- public static void main(String[] args) throws IOException
- {
- Integer np = 53;
- Double lambda[] = new Double[53];
- Double delta[] = new Double[52];
- Double probability[] = new Double[53];
- // Create factories
- IAnalysisFactory analysisFactory = IAnalysisFactory.create();
- ITreeFactory treeFactory = analysisFactory.createTreeFactory();
- ITree tree = treeFactory.create();
- IPlotter plotter = analysisFactory.createPlotterFactory().create("Fit.java Plot");
- IHistogramFactory histogramFactory = analysisFactory.createHistogramFactory(tree);
- IFunctionFactory functionFactory = analysisFactory.createFunctionFactory(tree);
- IFitFactory fitFactory = analysisFactory.createFitFactory();
- IDataPointSetFactory dpsf = analysisFactory.createDataPointSetFactory(tree);
- IDataPointSet dataPointSet = dpsf.create("dataPointSet","Showing relation between wavelength and photomultiplier efficiency",2);
- // create data point set ; still empty
- try {
- BufferedReader in = new BufferedReader(new FileReader("C:\\Users\\Dawnimus\\Desktop\\data\\xp3422.txt")); // read input file
- int i= 0;
- while ( true ){
- String line = in.readLine(); // copy full line to string
- if (line==null) break; // abort loop if line is empty
- System.out.println( line );
- st = new StringTokenizer(line); // break line into tokens
- Double x = Double.parseDouble(st.nextToken());
- Double y = Double.parseDouble(st.nextToken()) * (0.34 / 89.400); // convert into quantum efficiency
- System.out.println("(x,y) "+ x + " " + y );
- lambda[i] = x;
- probability[i] = y;
- if (i > 0){ delta[i-1] = lambda[i] - lambda[i-1];};
- IDataPoint dp = dataPointSet.addPoint(); // add one data point to set
- dp.coordinate(0).setValue(x);
- dp.coordinate(1).setValue(y);
- dp.coordinate(1).setErrorPlus(0.0);
- dp.coordinate(1).setErrorMinus(0.0);
- i++;
- }
- }
- catch (IOException e){System.out.println( e ); }
- Double alpha = 1.0 / 137.0 ;
- Double dNdz = 0. ;
- Double a=0. ;
- Double twopi = 8. * Math.atan(1.0);
- Double deg2rad = 360. / twopi;
- Double theta = 50.0 * deg2rad;
- for (int i = 0; i < np - 1; i++ ) {
- a = alpha * Math.pow(Math.sin(theta),2) * twopi * Math.pow(lambda[i],-2) * delta[i] * 1e+9 ;
- dNdz = dNdz + a * probability[i] ;
- }
- System.out.println("dNdz [1/m] : " + dNdz );
- plotter.region(0).plot(dataPointSet); // request plot
- plotter.show(); // show plot
- tree.close();
- }
- }
- \end{lstlisting}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement