source: trunk/MagicSoft/Simulation/Detector/include-MC/MCCphoton.hxx@ 759

Last change on this file since 759 was 735, checked in by magicsol, 24 years ago
The routine to get the size of the class has been changed.
File size: 3.5 KB
Line 
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
17This 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
44const char FLAG_START_OF_RUN[] = "\nSTART---RUN\n";
45const char FLAG_START_OF_EVENT[] = "\nSTART-EVENT\n";
46const char FLAG_END_OF_EVENT[] = "\nEND---EVENT\n";
47const char FLAG_END_OF_RUN[] = "\nEND-----RUN\n";
48const char FLAG_END_OF_FILE[] = "\nEND----FILE\n";
49const char FLAG_END_OF_STDIN[] = "\nEND---STDIN\n";
50
51#define SIZE_OF_FLAGS 13
52#define SIZE_OF_MCCPHOTON 8 /* floats */
53
54// @endcode
55
56// @subsection Class {\em MCCphoton}: Definition
57
58// @code
59
60class MCCphoton {
61
62public:
63 Float_t w; // wavelength [nm/-] +
64 // 1000*(id_generator)
65 Float_t x, y; // position in the camera [cm]
66 Float_t u, v; // director cosines
67 Float_t t; // time since first interaction [ns]
68 // till the camera
69 Float_t h; // height [cm]
70 Float_t phi; // incident angle in the camera [rad]
71
72public:
73 MCCphoton() {} // default constructor
74
75 // overloaded constructor
76 MCCphoton( ifstream &is ) { MCCphoton::read( is ); }
77
78 virtual ~MCCphoton() {} // default destructor
79
80 // reads photon from binary input stream
81 Int_t read ( ifstream &is ) {
82 is.read ( (char *)this, mysize() );
83 return is.gcount();
84 }
85
86 // writes photon to binary output stream
87 Int_t write ( ofstream &os ) {
88 os.write ( (char *)this, mysize() );
89 return 0;
90 }
91
92 // get information about the photon
93 inline Float_t get_wl( void ) { return ( w - 1000.*((int)floor(w/1000.))); }
94 inline Int_t get_particle( void ) {
95 return ( (int)floor(w/1000.) );
96 }
97
98 inline Float_t get_x( void ) { return ( x ); }
99 inline Float_t get_y( void ) { return ( y ); }
100 inline Float_t get_u( void ) { return ( u ); }
101 inline Float_t get_v( void ) { return ( v ); }
102 inline Float_t get_h( void ) { return ( h ); }
103 inline Float_t get_t( void ) { return ( t ); }
104 inline Float_t get_phi( void ) { return ( phi ); }
105
106 inline Float_t get_r( void ) { return ( sqrt( x*x + y*y ) ); }
107 inline Float_t get_w( void ) { return ( sqrt( 1.0 - u*u - v*v ) ); }
108
109 inline void fill(Float_t thew,
110 Float_t thex, Float_t they,
111 Float_t theu, Float_t thev,
112 Float_t theh, Float_t thet,
113 Float_t thephi) {
114 w = thew;
115 x = thex;
116 y = they;
117 u = theu;
118 v = thev;
119 h = theh;
120 t = thet;
121 phi = thephi;
122 }
123
124 int isA( const char * flag ) {
125 return ( (strncmp((char *)this, flag, 8)==0) ? TRUE : FALSE );
126 }
127
128 inline int mysize(void) { return ( SIZE_OF_MCCPHOTON*sizeof(float) ); }
129
130};
131
132// @endcode
133
134#endif // not defined MCCphoton_Class
135
Note: See TracBrowser for help on using the repository browser.