GN_Data.cc

Go to the documentation of this file.
00001 //! \file
00002 //!
00003 //! Source file for the GN_Data class.
00004 //!
00005 //! Defines the GN_Data class and the member routines which
00006 //! are used in collecting the information for an event.
00007 //!
00008 //! \author D.K. Hasell
00009 //! \version 1.0
00010 //! \date 2010-10-31
00011 //!
00012 //! \ingroup detector
00013 
00014 // Include the Data header file.
00015 
00016 #include "GN_Data.h"
00017 
00018 // Include the required GEANT header files.
00019 
00020 #include "CLHEP/Units/PhysicalConstants.h"
00021 
00022 // Include the STL header files referenced in this file.
00023 
00024 #include <vector>
00025 
00026 // Include the C++ header files referenced in this file.
00027 
00028 #include <cmath>
00029 
00030 // Use the STD namespace.
00031 
00032 using namespace std;
00033 
00034 // MCData class 
00035 
00036 ClassImp( GN_Data )
00037 
00038 // Constructor.
00039 
00040 GN_Data::GN_Data() {}
00041 
00042 // Destructor.
00043 
00044 GN_Data::~GN_Data() {}
00045 
00046 // Member functions.
00047 
00048 // Routine to clear the event vectors.
00049 
00050 void GN_Data::Reset() {
00051 
00052    nGN = 0;
00053 
00054    id.clear();
00055    q.clear();
00056    tr.clear();
00057 
00058    x.clear();
00059    y.clear();
00060    z.clear();
00061 
00062    px.clear();
00063    py.clear();
00064    pz.clear();
00065 
00066 }
00067 
00068 // Function to calculate the total momentum for a given particle.
00069 
00070 double GN_Data::P( int i ) {
00071    return sqrt( px[i] * px[i] + py[i] * py[i] + pz[i] * pz[i] );
00072 }
00073 
00074 // Function to calculate the polar angle for a given particle.
00075 
00076 double GN_Data::Theta( int i ) {
00077    return acos( pz[i] / P(i) );
00078 }
00079 
00080 // Function to calculate the azimuthal angle for a given particle.
00081 
00082 double GN_Data::Phi( int i ) {
00083    double ph = atan2( py[i], px[i] );
00084    return ( ph > -CLHEP::halfpi ) ? ph : ph + CLHEP::twopi;
00085 }
00086