| 1 | /////////////////////////////////////////////////////////////////
|
|---|
| 2 | //
|
|---|
| 3 | // MCCphoton
|
|---|
| 4 | //
|
|---|
| 5 | // Created: Tue Apr 28 16:43:30 1998
|
|---|
| 6 | // Author: Jose Carlos Gonzales
|
|---|
| 7 | // Purpose: Base class for Particles/Cherenkov photons
|
|---|
| 8 | // Notes:
|
|---|
| 9 | //
|
|---|
| 10 | /////////////////////////////////////////////////////////////////
|
|---|
| 11 |
|
|---|
| 12 | // @T \newpage
|
|---|
| 13 |
|
|---|
| 14 | // @section Source code of {\tt MCCphoton.hxx}
|
|---|
| 15 |
|
|---|
| 16 | /* @text
|
|---|
| 17 | This section shows the include file {\tt MCCphoton.hxx}
|
|---|
| 18 | @endtext */
|
|---|
| 19 |
|
|---|
| 20 | #ifndef MCCphoton_Class
|
|---|
| 21 | #define MCCphoton_Class
|
|---|
| 22 |
|
|---|
| 23 | // @subsection Include files
|
|---|
| 24 |
|
|---|
| 25 | // @code
|
|---|
| 26 | #ifdef __ROOT__
|
|---|
| 27 | #include "TROOT.h"
|
|---|
| 28 | #include "TObject.h"
|
|---|
| 29 | #else // not __ROOT__
|
|---|
| 30 | #include "Rtypes.h"
|
|---|
| 31 | #endif
|
|---|
| 32 |
|
|---|
| 33 | #include <iostream.h>
|
|---|
| 34 | #include <iomanip.h>
|
|---|
| 35 | #include <fstream.h>
|
|---|
| 36 | #include <stdlib.h>
|
|---|
| 37 | #include <string.h>
|
|---|
| 38 | #include <math.h>
|
|---|
| 39 |
|
|---|
| 40 | #include "jcmacros.h"
|
|---|
| 41 |
|
|---|
| 42 | // const char variables to use in MCCphoton::isA() function
|
|---|
| 43 |
|
|---|
| 44 | const char FLAG_START_OF_RUN[] = "\nSTART---RUN\n";
|
|---|
| 45 | const char FLAG_START_OF_EVENT[] = "\nSTART-EVENT\n";
|
|---|
| 46 | const char FLAG_END_OF_EVENT[] = "\nEND---EVENT\n";
|
|---|
| 47 | const char FLAG_END_OF_RUN[] = "\nEND-----RUN\n";
|
|---|
| 48 | const char FLAG_END_OF_FILE[] = "\nEND----FILE\n";
|
|---|
| 49 | const char FLAG_END_OF_STDIN[] = "\nEND---STDIN\n";
|
|---|
| 50 |
|
|---|
| 51 | #define SIZE_OF_FLAGS 13
|
|---|
| 52 |
|
|---|
| 53 | // @endcode
|
|---|
| 54 |
|
|---|
| 55 | // @subsection Class {\em MCCphoton}: Definition
|
|---|
| 56 |
|
|---|
| 57 | // @code
|
|---|
| 58 |
|
|---|
| 59 | class MCCphoton {
|
|---|
| 60 |
|
|---|
| 61 | public:
|
|---|
| 62 | Float_t w; // wavelength [nm/-] +
|
|---|
| 63 | // 1000*(id_generator)
|
|---|
| 64 | Float_t x, y; // position in the camera [cm]
|
|---|
| 65 | Float_t u, v; // director cosines
|
|---|
| 66 | Float_t t; // time since first interaction [ns]
|
|---|
| 67 | // till the camera
|
|---|
| 68 | Float_t h; // height [cm]
|
|---|
| 69 | Float_t phi; // incident angle in the camera [rad]
|
|---|
| 70 |
|
|---|
| 71 | public:
|
|---|
| 72 | MCCphoton() {} // default constructor
|
|---|
| 73 |
|
|---|
| 74 | // overloaded constructor
|
|---|
| 75 | MCCphoton( ifstream &is ) { MCCphoton::read( is ); }
|
|---|
| 76 |
|
|---|
| 77 | virtual ~MCCphoton() {} // default destructor
|
|---|
| 78 |
|
|---|
| 79 | // reads photon from binary input stream
|
|---|
| 80 | Int_t read ( ifstream &is ) {
|
|---|
| 81 | is.read ( (char *)this, mysize() );
|
|---|
| 82 | return is.gcount();
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | // writes photon to binary output stream
|
|---|
| 86 | Int_t write ( ofstream &os ) {
|
|---|
| 87 | os.write ( (char *)this, mysize() );
|
|---|
| 88 | return 0;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | // get information about the photon
|
|---|
| 92 | inline Float_t get_wl( void ) { return ( w - 1000.*((int)floor(w/1000.))); }
|
|---|
| 93 | inline Int_t get_particle( void ) {
|
|---|
| 94 | return ( (int)floor(w/1000.) );
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | inline Float_t get_x( void ) { return ( x ); }
|
|---|
| 98 | inline Float_t get_y( void ) { return ( y ); }
|
|---|
| 99 | inline Float_t get_u( void ) { return ( u ); }
|
|---|
| 100 | inline Float_t get_v( void ) { return ( v ); }
|
|---|
| 101 | inline Float_t get_h( void ) { return ( h ); }
|
|---|
| 102 | inline Float_t get_t( void ) { return ( t ); }
|
|---|
| 103 | inline Float_t get_phi( void ) { return ( phi ); }
|
|---|
| 104 |
|
|---|
| 105 | inline Float_t get_r( void ) { return ( sqrt( x*x + y*y ) ); }
|
|---|
| 106 | inline Float_t get_w( void ) { return ( sqrt( 1.0 - u*u - v*v ) ); }
|
|---|
| 107 |
|
|---|
| 108 | inline void fill(Float_t thew,
|
|---|
| 109 | Float_t thex, Float_t they,
|
|---|
| 110 | Float_t theu, Float_t thev,
|
|---|
| 111 | Float_t theh, Float_t thet,
|
|---|
| 112 | Float_t thephi) {
|
|---|
| 113 | w = thew;
|
|---|
| 114 | x = thex;
|
|---|
| 115 | y = they;
|
|---|
| 116 | u = theu;
|
|---|
| 117 | v = thev;
|
|---|
| 118 | h = theh;
|
|---|
| 119 | t = thet;
|
|---|
| 120 | phi = thephi;
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | int isA( const char * flag ) {
|
|---|
| 124 | return ( (strncmp((char *)this, flag, 8)==0) ? TRUE : FALSE );
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | inline int mysize(void) { return ( sizeof(*this) ); }
|
|---|
| 128 |
|
|---|
| 129 | };
|
|---|
| 130 |
|
|---|
| 131 | // @endcode
|
|---|
| 132 |
|
|---|
| 133 | #endif // not defined MCCphoton_Class
|
|---|
| 134 |
|
|---|