Advertisement
roninkoi

Photomultiplier tube Monte Carlo

Feb 27th, 2021
1,530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import numpy as np
  2.  
  3. # Monte Carlo simulation of a
  4. # photomultiplier tube.
  5. # Input: number of samples n, number of
  6. # dynodes dynum and mean of Poisson
  7. # distribution nu.
  8. # Output: array of numbers of electrons
  9. def pmtmc(n, dynum, nu):
  10.     ens = np.zeros(n) # numbers of electrons
  11.    
  12.     for i in range(n): # get n samples
  13.         en = 1 # initial photoelectron
  14.         for j in range(dynum): # iterate over dynodes
  15.             en0 = en # electrons impacting this dynode
  16.             en = 0
  17.             for k in range(en0): # iterate over electrons
  18.                 en += np.random.poisson(nu) # new electrons Poissonian
  19.         ens[i] = en
  20.  
  21.     return ens
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement