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

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