/* University College London Dept of Physics Course in OO 3C59 | all rights reserved 2000 | | Utility: The Photomultiplier class | | This class represents a photomultiplier used in the compton scattering | experiment. | It contains the concept of a finite front window and detectes | whether Particles thrown at it would enter and be detected. | | For such detected particles it simulates the PMT energy resolution of | 80 kev and adds the detected energy to a running average fo all particles which | have entered it so far. | | Author: P.Clarke */ import java.util.* ; // Define the class public class PhotoMultiplier { // Attributes fo detector private double m_centralAngle ; // Position of centre in degrees private double m_lolim ; // lower angular acceptance private double m_hilim ; // higher angular acceptance private double m_resolution ; // Energy resolution of this detector in keV // Needed to accumulate average energy. private int m_numberDetectedParticles ; private double m_totalEnergy ; // Needed to generate gaussian random numbers Random m_generator ; //To assimilate Photon attributes in the case of a detected particle private void assimilate( Photon p ) { //First increment the number of detected particles m_numberDetectedParticles++ ; //Now smear the energy using the Gaussian class double detectedEnergy ; detectedEnergy = p.energy() + ( m_generator.nextGaussian() * m_resolution ); //Now add this smeared energy to the total m_totalEnergy += detectedEnergy ; } //--------------- //Constructor taking: // center = angle setting of centre of detector // dist = distance of entrance window of PMT from centre of experiment // window = widthe of entrance window // res = energy resolution of detector public PhotoMultiplier( double centre, double dist, double window, double res ) { //Set the central position of the PMT m_centralAngle = centre ; //Set the acceptance angles double halfAngle = ( Math.atan( window/2.0/dist ) ) * 180.0 / Math.PI ; m_lolim = m_centralAngle - halfAngle; m_hilim = m_centralAngle + halfAngle ; //Set the resolution m_resolution = res ; // statistic counters m_totalEnergy = 0.; m_numberDetectedParticles = 0; // create random object m_generator = new Random() ; } //----------------------- // Method to fire a Photon into the detector public void tryit( Photon p ) { //Does the supplied particle fall within this range if( (p.angle() > m_lolim) && (p.angle() < m_hilim) ) { //Great - it is accepted. To keep the code simple I delegate the operations //to do with adding this particle to the totals to a private method this.assimilate( p ) ; } } //------------------- // Method to return number of particles detected so far public int numberAccepted( ) { return m_numberDetectedParticles ; } //----------------------------- // Method to return average energy of detected particles public double averageEnergy( ) { double average ; if( m_numberDetectedParticles > 0 ) { average = m_totalEnergy / (double) m_numberDetectedParticles ; } else { average = 0. ; } return average ; } //--------------------- // Method to return central angle double angle( ) { return m_centralAngle ; } }