Lab #1: Photon counting with a PM tube—statistics of...

12
Lab #1: Photon counting with a PM tube—statistics of light James. R. Graham, UC Berkeley Your report is due 2009, September 15 at 5:59:59PM PDT. 1 Overview 1.1 Schedule This is a two-week lab—9/1 & 9/8. Your lab report is due on 9/15. For “show-and-tell” on 9/8 you should have progressed at least to step 7 (see below). 1.2 Goals Explore the fundamental physical limitations on the detection of light. Investigate how precisely brightness can be specified, and what determines that precision. Ultimately, what are the statistical properties of photons? 1.3 Reading assignments (available on line) Unix tutorial o To master the first lab you will need basic Linux system skills so that you can collect data and manipulate files. Start with §§1.1 & 1.2, IDL tutorial o Read the first IDL tutorial so that you can learn how to use this programming language to compute statistical quantities and make plots. Try to work through all 15 pages. TeX tutorials o We use the TeX/LaTeX document preparation system to create “publication quality” reports. There are several examples—the short example that I created is a good starting point. Download the example and make sure that you can generate the PDF output file. You can then use this example as a template for your first report. If you have time and want to do more inspect the advanced exampled by Tristan Lewis. Skim the first two chapters of Taylor’s book on statistics and errors. 1.4 Key steps You will execute four primary steps in this lab: 1. Collect data from the photometer experiment and use IDL to make a plot of the counts per sample versus time. 2. Plot histograms of sets of samples from the photometer. 3. Compute the mean and standard deviation for your samples and investigate the variability of the count rate. 4. Compare the observed histograms with the theoretical Poisson probability distribution function.

Transcript of Lab #1: Photon counting with a PM tube—statistics of...

Page 1: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

Lab #1:Photon counting with a PM tube—statistics of light

James. R. Graham, UC Berkeley

Your report is due 2009, September 15 at 5:59:59PM PDT.

1 Overview

1.1 ScheduleThis is a two-week lab—9/1 & 9/8. Your lab report is due on 9/15. For “show-and-tell” on 9/8you should have progressed at least to step 7 (see below).

1.2 GoalsExplore the fundamental physical limitations on the detection of light. Investigate how preciselybrightness can be specified, and what determines that precision. Ultimately, what are thestatistical properties of photons?

1.3 Reading assignments (available on line)• Unix tutorial

o To master the first lab you will need basic Linux system skills so that you cancollect data and manipulate files. Start with §§1.1 & 1.2,

• IDL tutorialo Read the first IDL tutorial so that you can learn how to use this programming

language to compute statistical quantities and make plots. Try to work through all15 pages.

• TeX tutorialso We use the TeX/LaTeX document preparation system to create “publication

quality” reports. There are several examples—the short example that I created is agood starting point. Download the example and make sure that you can generatethe PDF output file. You can then use this example as a template for your firstreport. If you have time and want to do more inspect the advanced exampled byTristan Lewis.

• Skim the first two chapters of Taylor’s book on statistics and errors.

1.4 Key stepsYou will execute four primary steps in this lab:

1. Collect data from the photometer experiment and use IDL to make a plot of the countsper sample versus time.

2. Plot histograms of sets of samples from the photometer.3. Compute the mean and standard deviation for your samples and investigate the variability

of the count rate.4. Compare the observed histograms with the theoretical Poisson probability distribution

function.

Page 2: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

2

2 Getting started: collecting data from the photomultipliertube

This lab activity is based on a light detector that can record the arrival of individual photons. Thedetector, known as a photomultiplier PMT, is very sensitive, and must be treated with care.Before you modify anything associated with the PMT make sure that you have read andunderstood the PMT web page:

http://www.ugastro.berkeley.edu/infrared/photon/index.html

(Note ugastro web pages accessed within 705 are referenced as http://aquarius, so this link wouldbe typed as http://aquarius/infrared/photon/index.html.)

Do not expose the PMT to direct room light! Do not expose to light so that the count rate is > 1Mhz (one million counts per second.) To figure the count rate multiply the counts per sample bythe sample rate e.g., 1000 counts per sample when the sample rate is 1 kHz corresponds to a1,000,000 counts per second or 1 MHz.

The first step is to acquire a time sequence of digitized data and save the data as a file. Log intoone of the Linux workstations. Make a new folder or sub-directory (using mkdir) for yourproject

% mkdir lab1% cd lab1

(Note: commands that you type are shown in Courier font. A % indicates the Unixprompt—do not type an extra %.) Now type the following at the Unix prompt (cut and paste fromthis PDF document to make sure that you don’t have any typos):

% echo counter nsamples=100 rate=1000 fname=c.100.1000.dat | sendpc

This cryptic command takes 100 samples of data from the photo-multiplier tube at a rate of 1000Hz, and puts the data in a file called c.100.1000.dat. A cartoon of the photon counting process isshown in Figure 1.

Page 3: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

3

time

Δt

Sample nSample n+1 Sample n+2

Figure 1: A cartoon of the samples generated by the counter. The bin width is constant, and for each intervalof time, Δt = 1/rate, counts (smiley faces) from the photon detector are accumulated. In this example thesequence of counts is 3, 1, 2, 4. Only four samples from a longer sequence are illustrated.

You should get a message indicating success. Since you asked for 100 samples, this file shouldcontain 100 lines. Figure out for this example how long is the counter active for? What would theanswer be if you had chosen:

nsamples=1000 rate=100 ?

A rate of 1000 Hz means that for each sample the computer accumulates counts from the PMTfor 1/1000 of a second (1 ms). Typically, at this rate you should get a handful of counts persample. Play around with the sample rate and convince yourself that the length of the sample isinversely proportional to the sample rate. If the rate is significantly higher or lower than this thenask an instructor for help.

The maximum sample rate is 5000 Hz. Note that not all sample rates are supported by thehardware. If you ask for a counter rate that is not supported then the counter program willchoose the closest one available—you need to be aware of this if the results of your experimentdepend on the exact value of the sample rate. Read about this on the Lab 1 web page.

The predominant failure mode of this experiment occurs when the program on the PC attached tothe counter fails. When this crashes the sendpc command does not return valid data. If yoususpect that there is a problem ask the instructor or TA for help.

3 Reading dataThe next challenge is to read in the data file into IDL. View your file by asking the computer toprint out the contents of the file, e.g.,

% cat c.100.1000.dat

3923253642

Page 4: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

4

333938…

Notice that the file comprises a single column of numbers—each number corresponds to thenumber of counts in one sample interval. There is a handy IDL program that reads a file intocomputer memory and labels it with an IDL variable name, in this example the variable is calledmydata:

IDL> readcol, 'c.100.1000.dat', mydata

Notice that the file name must be enclosed in single quotes. IDL names between single quotesare called strings.

4 Plotting dataWhen you have the data in an IDL variable you examine it by typing

IDL> print, mydata

IDL will tell you what type of entity mydata is by typing

IDL> help, mydata

or you can plot it using the IDL command

IDL> plot, mydata

To make a useful graph you need to plot your data as a function of time. Label the x- (i.e., time)and y-axes (counts). Make sure that your labels include units. A plot title is also helpful and canbe used to denote the sample rate. Invoke IDL help by typing a question mark at the IDLcommand line. Look up PLOT in the index and figure out how to add a title and axes to yourplot.

In addition to the ugastro IDL tutorials some useful on-line resources are

http://idlastro.gsfc.nasa.gov/idl_html_help/home.html

http://www.dfanning.com/

To make your life easier we have provided a handy IDL function that calls that sendpcprogram for you so that you do not have to do so much typing. Here’s an example:

Page 5: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

5

IDL> t = savephotons(nsamples=100, rate=100)Please wait, Acquiring DataData saved in file: photon.100.100.txt

Note that savephotons makes up the file name for you if you do not specify it. This programis what is known as a function in IDL, i.e. a routine with arguments (the values of nsamplesand rate) and a return value. In this case the return value, t, lets you know if the programworked.

IDL> print,t 1IDL>

Our homegrown IDL code for savephotons can be found in

/home/global/ay121/idl/pc/savephotons.pro

Take a look at the program and see if you can figure out what is does. A set of IDL instructionto collect some data and plot them would be:

IDL> t = savephotons(nsamples=100, rate=100)Please wait, Acquiring DataData saved in file: photon.100.100.txtIDL> readcol,'photon.100.100.txt',data% READCOL: Format keyword not supplied - All columns assumedfloating point% READCOL: 100 valid lines readIDL> plot,dataIDL>

5 Statistics—making a histogramFirst, be sure to review and understand what a histogram is (see Taylor’s book).

Calculate the mean and standard deviation of the count rate for a set of data collected usingsavephotons. The IDL function total will turn out to be very useful for computingstatistical quantities. Be sure to look up total in the IDL help.

Bin the data and make a histogram of the counts. Binning means sorting the data into uniquecategories, and counting the number of occurrences of those categories. Use my exampleprogram in the statistics hand out to help you solve this programming problem.

Page 6: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

6

Does the histogram plot that that you have made really reflect that data that you collected?Carefully compare the list of counts in the data file and the plot. Do a “reality check” on a dataset where you can rapidly compute the histogram with pencil and paper1.

Once you can plot histograms with confidence, repeat the experiment, say, six times andcompare the results of your experiments. Does the histogram change? Do you always get thesame mean count rate? Become adept at inspecting the histogram plot and guessing what themean and standard deviations are. Calculate the mean and standard deviation of the six countrates you just measured. Be sure to use a unique file name for each sequence of data, becauseyou may want to go back and look at your data files again. If you do not change the name the filewill be overwritten.

To examine the data in IDL it will be helpful to understand how to use "for" loops. A quick andsophisticated way to approach repetitive tasks involves writing the entire sequence of dataacquisition in IDL using for loops.

The simplest IDL for loop can be executed at the command line. Try this:

IDL> for i=0,4 do print,i 0 1 2 3 4IDL>

Suppose we want to take a sequence of data sets where the rate increased by steps of a factor oftwo, then the following would be useful:

IDL> for i=0,4 do print,2^i 1 2 4 8 16IDL>

1 This is perhaps the most important programming lesson here. Always test your program on a problem where youknow the answer. For example test your histogram program with x =[0,0,0,1,1,1] andx=[0,1,2,3,4,5,6].

Page 7: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

7

If you need multiple instructions “within” the loop, then you need to write a little program.Create a new file with emacs called test.pro by cutting and pasting the following:

; Testing savephotons with a for loop. Each time savephotons is called; a unique file name is used. Written by JRG 8/25/2008;mynsamp = 100 ; Define the number of samplesmyrate = 1000 ; Define the sample rate (in Hz)nrep = 4 ; Define the number of repitions

for i=0,nrep-1 do begin

; construct the file name

myfilename = 'test_' + $ string(i,format='(i03)') + '_' + $ string(mynsamp,format='(i03)') + '_' + $ string(myrate,format='(i04)') + '.dat'

; get the data

t = savephotons(nsamp=mynsamp, rate = myrate, file = myfilename)

; print out some useful information print,'i= ',i,' file = ',myfilename,' status = ',t print,'----------------------------------'

endforend

Note that the semicolon is a comment character—everything after a “;” is ignored. To executethis program in IDL, all you need to do is type

IDL> .run test% Compiled module: $MAIN$.Please wait, Acquiring DataData saved in file: test_000_100_1000.dati= 0 file = test_000_100_1000.dat status = 1----------------------------------Please wait, Acquiring DataData saved in file: test_001_100_1000.dati= 1 file = test_001_100_1000.dat status = 1----------------------------------Please wait, Acquiring DataData saved in file: test_002_100_1000.dati= 2 file = test_002_100_1000.dat status = 1----------------------------------Please wait, Acquiring DataData saved in file: test_003_100_1000.dati= 3 file = test_003_100_1000.dat status = 1----------------------------------IDL>

Page 8: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

8

Notice that the file name is printed out, and each time that savephotons is invoked the newfile name is used. After the program completes get a listing of the folder to see what files werecreated:

% ls -l

The -l part tells the computer to give you more or “long” information about the files. If you areplotting multiple sequences of data investigate what happens when you set the IDL plottingvariable

IDL> !p.multi = [0,2,3]

What does this do? To get back to normal plotting set

IDL> !p.multi=0

Now repeat with a bigger sample of data, e.g., increase the number of samples by a factor of 4,but keep the sample rate the same as before. Again, take six sets of data and repeat the exerciseof calculating the mean and standard deviation for each longer set of data. Calculate the meansand standard deviations of the six count rates you just measured. What do you notice about themean count rate and the standard deviation for these sequences?

6 Mean and standard deviation

Let's try and get to the root of these variations. First, let’s explore the relation between the meannumber of counts and the standard deviation.

Take a sequence of data with increasingly long sample times (progressively slower sample rates.)For this part of the experiment you need to know that the shortest sample is 200 µs (5000 Hz)and that the duration of the sample can only increase in 100 µs increments. Thus the allowablerates are 10000 Hz/n, where is an integer n = 2, 3, 4… A handy aspect of savephotons is thatyou can call it with the argument dt, which is the sample duration in ms (=1000 µs), so that

IDL> t = savephotons(nsamples=100, dt=0.2)IDL> t = savephotons(nsamples=100, dt=0.3)IDL> t = savephotons(nsamples=100, dt=0.4)

are all valid data requests.

Calculate the mean count for each sequence and also the standard deviation. Suppose xbar ands are the means and standard deviations, use the command

IDL> plot, xbar, s^2

Page 9: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

9

to make a plot of the mean versus the variance (the standard deviation squared). Now over plot aline representing x=y. What does this tell you about the relation between mean and variance forcounting (Poisson) statistics?

7 The Poisson distributionPlot a histogram for one of your sequences with a small count rate, e.g, 2-4 counts per sampleand lots of samples, e.g., 1000. Calculate the mean count rate and compare the resultanthistogram with the theoretical Poisson probability distribution,

P x;µ( ) = µ x

x!exp −µ( ) , (1)

where µ is the mean. Use IDL's OPLOT function to compare your data and the prediction. Thinkabout that… How do you compare a histogram, which represents a measured counts with atheoretical distribution!? The Poisson distribution gives a probability. You have measuredcounts. Explain how to choose the correct scaling factor (or normalization) to compare themeasured and theoretical distributions. Can you use a theoretical probability to predict counts orcan you express your measured counts as a probability?

Does the Poisson distribution provide a good description of the data? Now arrange so that thecounts per sample is increased (be careful that the count rate does not exceed 1 MHz.) Aim forseveral hundred counts per sample. Plot the histogram again. What has happened to the shape ofthe histogram—is it qualitatively different? Calculate the mean and standard deviation and over-plot the corresponding Gaussian probability distribution,

P x;µ,σ( ) = 1σ 2π

exp −12

x − µσ

⎛⎝⎜

⎞⎠⎟2⎡

⎣⎢⎢

⎦⎥⎥

. (2)

Is a Gaussian curve a good approximation to the Poisson distribution? Under what conditions isthe Gaussian probability distribution a good approximation?

Some notes regarding Poisson fluctuations and blackbody radiation are included in theAppendix.

8 Standard deviation of the meanThe more events you count the more accurately you can measure the number of counts persample (i.e., the count rate). To illustrate the effect take ten sets of data with a given number ofsamples, say 16. Choose a fixed sample rate, say, 1 kHz.

For each of these ten sets calculate the mean. Due to statistical variations the ten means will bedifferent, so also calculate the mean of the means (MOM) and the standard deviation of themeans (SDOM). The MOM is the best estimate of the counts per sample and the SDOM is ameasure of how precisely we know the average counts per sample.

Page 10: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

10

How does the SDOM vary with the number of samples in the individual sequences? Intuitionsuggests that if we have more samples in each of our ten measurements the SDOM will besmaller. To quantify this effect repeat with 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 etc.samples per sequence. Don't vary the sample rate, and be sure that no one changes the LEDbrightness while you are collecting your data!

For each sample size consider the ten data sets and calculate the mean of the means (MOM) andthe standard deviation of the means (SDOM). Plot the MOM and the SDOM as a function of thenumber of samples. Describe how the MOM and SDOM vary as the sample size increases.Based on your knowledge of Poisson statistics and error propagation predict the SDOM giventhe measured mean count per sample and the sample size. Use the IDL OPLOT function tocompare your prediction with the data. If I want to improve the accuracy of a measurement of themean by a factor of two, by what factor do I need to increase the number of samples?

• How accurate is your best estimate of the count rate, i.e., how accurate is the MOM?• Is it possible to construct a light source for the photometer experiment that would not

show variations in the count rate?

Write up your lab report describing each of the above exercises. Show your results by includingIDL plots in your report.

Page 11: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

11

9 Appendix: Photon noise & Poisson statisticsWhy do photons exhibit Poisson fluctuations? Is the detection of photons really governed by thePoisson probability distribution? Consider the number of photons, n, in a cavity at temperatureT, and frequency v. As photons are emitted and absorbed by the walls the number of photons inthe cavity will change. Boltzmann’s law gives the probability that a state with energy E = nhvoccurs, where n may take on any value 0, 1, 2, 3, …

P(n) = 1Uexp −nhν kT( ), (3)

where h is Planck’s constant, and k is Boltzmann’s constant. The normalization U is found fromthe condition that the probability must sum to unity

U = exp −nhν kT( )n=0

∑ . (4)

The quantity U is sometimes called the partition function. The average energy at frequency v is

E =1U

En=0

∑ P(n)

=1U

nhν exp −nhν kT( )n=0

=hν

exp hν kT( ) −1.

(5)

We can use this result to compute the energy density of photons. Photons are spin zero particles,and therefore unlike half-integer spin particles like electrons can congregate in a cell of phasespace. The number of phase cells per unit volume for photons with momenta p to p + dp is

dn = 2 4π p2

h3dp =

8πν 2

c3dν , (6)

where the factor of two accounts for the two polarization states. Thus, the energy density ofblackbody radiation at frequency v to v + dv is

ρνdν = E dn =8πν 2

c3hν

exp hν kT( ) −1dν , (7)

which is the famous Planck formula. The mean number of photons is

n =1U

nn=0

∑ P(n) = 1exp hν kT( ) −1 , (8)

Page 12: Lab #1: Photon counting with a PM tube—statistics of lightugastro.berkeley.edu/infrared09/photon/Lab1.pdf · 2 2 Getting started: collecting data from the photomultiplier tube This

12

and

n2 =1U

n2n=0

∑ P(n) =exp hν kT( ) +1exp hν kT( ) −1⎡⎣ ⎤⎦

2 . (9)

Hence, the variance, which is 〈n2〉 - 〈n〉2 is

σ 2 =exp hν kT( )

exp hν kT( ) −1⎡⎣ ⎤⎦2 , (10)

or by substituting for 〈n〉 we see that the variance is proportional to 〈n〉

σ 2 = n1

1− exp −hν kT( ) , (11)

times a correction factor. Often the correction factor is very close to unity. Figure 2 shows thecorrection factor an incandescent lamp (3300 K) at wavelength between 0.1 and 100 µm. In theUV and visible we have to a very good approximation σ2 = 〈n〉, i.e., the fluctuations are Poisson.However, at infrared and radio wavelengths the Poisson approximation is not useful.

Figure 2: The Boson correction factor 1/[1-exp(-hv/kT)] from Eq. (11) versus wavelength for a temperaturetypical of a tungsten filament lamp. At UV and visible wavelengths the correction factor is close to unity andblackbody radiation shows Poisson fluctuations.