Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- class Main2
- {
- static BufferedReader keyboard = new BufferedReader (new InputStreamReader(System.in));
- static PrintWriter screen = new PrintWriter (System.out,true);
- public static void main (String [] args) throws FileNotFoundException, IOException, NullPointerException
- {
- BufferedReader reader = new BufferedReader(new FileReader("Combined4mu.csv"));
- List<String> lines = new ArrayList<>();
- String line = null;
- String [] event = new String [20]; //Array to hold elements of each event line
- screen.println("Please enter the name of the file");
- String name = keyboard.readLine();
- String filename = name+".csv";
- FileWriter file1 = new FileWriter(filename);
- PrintWriter outputFile = new PrintWriter(file1);
- screen.println("\nPlease enter the Density in gcm^-3");
- double rho = new Double (keyboard.readLine()).doubleValue();
- screen.println("\nPlease enter the Atomic Mass in u");
- double A = new Double (keyboard.readLine()).doubleValue();
- screen.println("\nPlease enter the Proton Number");
- int Z = Integer.parseInt(keyboard.readLine());
- screen.println("\nPlease enter the Thickness of the Solenoid in cm");
- double t = new Double (keyboard.readLine());
- screen.println("\nPlease enter the Number of Detectors");
- int det = Integer.parseInt(keyboard.readLine());
- screen.println("\nPlease enter the Resolution of the Detectors in Microns");
- double res = new Double (keyboard.readLine()).doubleValue()*0.000001;
- screen.println("\nWhat would you like to do? \n1)Export Muon Positions \n2)Export Invariant Mass \nPlease enter number");
- int ans = Integer.parseInt(keyboard.readLine());
- double [] position=new double [3];
- double [][] Hit = new double [det][2];
- double [] linestats = new double [2];
- double [] xarray = new double [det];
- double [] yarray = new double [det];
- double xback;
- double yback;
- int j=0;
- double [] E = new double [4];
- double [] px = new double [4];
- double [] py = new double [4];
- double [] pz = new double [4];
- screen.println("\n\nLoading.... please wait");
- while ((line = reader.readLine()) != null) //event loop
- {
- lines.add(line);
- String delimiter = ",";
- event = line.split(",");
- for (int q = 0; q<=3; q++) //muon number loop
- {
- PolarConvert PolarConst = new PolarConvert( event[5*q+1], event[5*q+2], event[5*q+3], event[5*q+4]);
- IronTrack IronConst = new IronTrack(PolarConst.pT(),PolarConst.delta(),PolarConst.bigPhi(),PolarConst.q(),rho,A,Z);
- double exitX = PolarConst.exitX();
- double exitY = PolarConst.exitY();
- for (int r=0;r<=2;r++) //loop to fill position array
- {
- position[r] = IronConst.newPos(exitX,exitY)[r];
- }
- for (int d=0;d<=(det-1);d++) //detector loop
- {
- for (int s=0;s<=1;s++)
- {
- Hit[d][s]=IronConst.detector(position[0],position[1],position[2],(d*0.1+2.3),res)[s];
- }
- xarray[d]=Hit[d][0];
- yarray[d]=Hit[d][1];
- }
- JLineFit JLConst = new JLineFit (xarray,yarray,det);
- linestats[0] = JLConst.getJLine()[0]; //grad
- linestats[1] = JLConst.getJLine()[1]; //intercept
- BacktoB BackConst = new BacktoB (linestats[0], linestats[1], 1.2, xarray[0], yarray [0]);
- xback = BackConst.getcoordinates()[0];
- yback = BackConst.getcoordinates()[1];
- ReversePC RevConst = new ReversePC (xback,yback,linestats[0],PolarConst.pZ());//,PolarConst.delta());
- E[q]=RevConst.getE();
- px[q]=RevConst.back_px();
- py[q]=RevConst.back_py();
- pz[q]=PolarConst.pZ();
- if (ans < 2)
- {
- outputFile.println(Hit[0][0]+","+Hit[0][1]+","+Hit[1][0]+","+Hit[1][1]+","+Hit[2][0]+","+Hit[2][1]+","+xback+","+yback);
- }
- //screen.println(RevConst.back_pT());
- //outputFile.println(RevConst.back_pT()+","+PolarConst.pT());
- }
- INVMASS MassConst = new INVMASS (E,px,py,pz);
- if (ans > 1)
- {
- outputFile.println(MassConst.getMASS());
- }
- }
- j++;
- outputFile.close();
- screen.println("\n\nFinished,"+name+" is ready to view");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement