Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Fitting 3D lines to a cylinder The images showing the preview of the given files You have access to a file containing 10 events. The

Fitting 3D lines to a cylinder

image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribed

The images showing the preview of the given files

image text in transcribedimage text in transcribed

You have access to a file containing 10 events. The format is defined below. Each event contains data corresponding to two lines. Each line originates from simulated electron, each starting at the x=0 plane from the same point, one emitted to the left, i.e. negative x-coordinates, one to the right, with positive coordinates. Coordinates are given in millimetres. The file arrives in compressed form. You can read it as given using np.loadtxt(filename, delimiter=',') . The column entries (and type) are - Event number (int, starting at value 1) - Line number (int, starting at value 1) - Wire x-coordinate (float) - Wire y-coordinate (float) - Wire z-coordinate (float) - Radius (float) - Radius error (float) - Wire z-coordinate error (float) An example event is shown in the figure below. For your own figure, note that the matplotlib.pyplot library has a pyplot. Circle((x, y), radius, fill=False, lw=2) function that can be added as a 'patch' to a figure. Devt The formula describing the distance of a line to a cylinder is D=(xpx0)ur where u is the unit direction vector of the line and x0 is a point on the line. This assumes the line is not parallel to the y-z plane like in this exercise. The residuals between model and data also come with a weighting factor, made from the data errors, r and z according to W=[(zuz)2+(zuy)2+(ruz)2+(zux)2+(ruy)2+(rux)2]1 where ux,y,z represents the three components of the unit vector. Project: Write an application that 1. reads the data and 2. fits lines to all events, 3. counts and returns the number of successful fits, 4. stores your results in a file with the format given below and finally 5. plots the first event following the plot format from the example picture above. The given code in the cell should be incorporated into your solution since its function names will be used in the tests. The runfit(infile, outfile) data files will be supplied for the project for your own testing. One contains 10 events in the right data format and one contains truth information (as human readable file) for checking your own code. The model solution fits all 10 events correctly. Hint: The data in the file has been created with an intercept in the z-coordinate at 0.0 in order to stabilize the fits a little and simplify your task. Note that you should not take that insight as a fixed parameter (would lead to a reduction of marks) but as a reassurance to test your attempts relatively easily. The assessment data file also has the creation intercept set at z=0 for all events. Hint 2: The errors on the intercept in z and the slope in the x - z plane are likely to be big, occasionally. Not to worry, this reflects the large error on the coordinate which can induce a broad minimum and hence big errors. This observation simply is in the nature of the data. Output format for fit results: - Event number (int, starting at 1) - Line number (int, starting at value 1) - intercept in y (float) - error on intercept in y (float) - slope in xy plane (float) - error on slope in x-y plane (float) - intercept in z (float) - error on intercept in z (float) - slope in xz plane (float) - error on slope in xz plane (float) On storing results: it is important that every line in every event has a result, even for failed hits in order to enable the comparison for your assessment. A failed fit should therefore store a result as datastore. append ((evtnr, linenr, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0)) with evtnr the event number (int) and linenr the line number (int). tendata - Notepad File Edit Format View Help \# event counter, line counter, wirex, wirey, wirez, radius, radius error, z-error tentruth - Notepad File Edit Format View Help \# intercepty, interceptz, slopexy, slopexz 356.749503,0.000000,1.289205,0.835110 356.749503,0.000000,2.767934,0.569496 44.218841,0.000000,4.157547,0.415716 44.218841,0.000000,2.904457,1.372122 525.940812,0.000000,0.309688,0.410017 525.940812,0.000000,1.114542,1.494825 812.937349,0.000000,0.471576,2.041709 812.937349,0.000000,0.727205,2.137225 660.206719,0.000000,1.743949,1.694747 660.206719,0.000000,1.477933,0.158218 25.750842,0.000000,1.231083,0.612854 25.750842,0.000000,0.115341,1.345622 412.747306,0.000000,0.340800,0.582351 412.747306,0.000000,5.281985,0.060729 463.466952,0.000000,0.872751,0.781760 463.466952,0.000000,2.999518,0.476997 109.005950,0.000000,0.906118,1.347475 109.005950,0.000000,5.339613,0.399403 420.008123,0.000000,4.676006,0.957135 420.008123,0.000000,0.513084,0.199957

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions