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

Last change on this file since 5078 was 5078, checked in by moralejo, 20 years ago
Updated in CVS after some time...
File size: 3.8 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#include "TROOT.h"
27#include "TObject.h"
28
29#include <iostream.h>
30#include <iomanip.h>
31#include <fstream.h>
32#include <stdlib.h>
33#include <string.h>
34#include <math.h>
35
36#include "jcmacros.h"
37
38// const char variables to use in MCCphoton::isA() function
39
40const char FLAG_START_OF_RUN[] = "\nSTART---RUN\n";
41const char FLAG_START_OF_HEADER[] = "RUNH";
42const char FLAG_START_OF_EVENT[] = "\nSTART-EVENT\n";
43const char FLAG_EVENT_HEADER[] = "EVTH";
44const char FLAG_END_OF_EVENT[] = "\nEND---EVENT\n";
45const char FLAG_END_OF_RUN[] = "\nEND-----RUN\n";
46const char FLAG_END_OF_FILE[] = "\nEND----FILE\n";
47const char FLAG_END_OF_STDIN[] = "\nEND---STDIN\n";
48
49#define SIZE_OF_FLAGS 13
50#define SIZE_OF_HEADER 8 /* floats */
51#define SIZE_OF_MCCPHOTON 8 /* floats */
52
53// @endcode
54
55// @subsection Class {\em MCCphoton}: Definition
56
57// @code
58
59class MCCphoton {
60private:
61 Float_t w; // wavelength [nm/-] +
62 // 1000*(id_generator)
63 Float_t x, y; // position in the camera [cm]
64 Float_t u, v; // director cosines
65 Float_t t; // time since first interaction [ns]
66 // till the camera
67 Float_t h; // height [cm]
68 Float_t phi; // incident angle in the camera [rad]
69
70public:
71 MCCphoton() {} // default constructor
72
73 // overloaded constructor
74 MCCphoton( ifstream &is ) { MCCphoton::read( is ); }
75
76 virtual ~MCCphoton() {} // default destructor
77
78 // reads photon from binary input stream
79 Int_t read ( ifstream &is ) {
80 is.read ( (char *)this, mysize() );
81 return is.gcount();
82 }
83
84 Int_t read ( FILE *f ) {
85 return fread( &w, mysize(), 1, f );
86 }
87
88 void get_flag(Char_t* c)
89 {
90 memcpy(c, (Char_t*)&w, SIZE_OF_FLAGS);
91 }
92
93 // writes photon to binary output stream
94 Int_t write ( ofstream &os ) {
95 os.write ( (char *)this, mysize() );
96 return 0;
97 }
98
99 // get information about the photon
100 inline Float_t get_wl( void ) { return ( w - 1000.*((int)floor(w/1000.))); }
101
102 inline Int_t get_particle( void ) {
103 return ( (int)floor(w/1000.) );
104 }
105
106
107 inline Float_t get_x( void ) { return ( x ); }
108 inline Float_t get_y( void ) { return ( y ); }
109 inline Float_t get_u( void ) { return ( u ); }
110 inline Float_t get_v( void ) { return ( v ); }
111 inline Float_t get_h( void ) { return ( h ); }
112 inline Float_t get_t( void ) { return ( t ); }
113 inline Float_t get_phi( void ) { return ( phi ); }
114
115
116 inline Float_t get_r( void ) { return ( sqrt( x*x + y*y ) ); }
117 inline Float_t get_w( void ) { return ( sqrt( 1.0 - u*u - v*v ) ); }
118
119 inline void fill(Float_t thew,
120 Float_t thex, Float_t they,
121 Float_t theu, Float_t thev,
122 Float_t theh, Float_t thet,
123 Float_t thephi) {
124 w = thew;
125 x = thex;
126 y = they;
127 u = theu;
128 v = thev;
129 h = theh;
130 t = thet;
131 phi = thephi;
132 }
133
134
135 inline void fill(Char_t* data)
136 {
137 cout << "hola1" << endl;
138 memcpy((Char_t*)(&w), data, mysize());
139 cout << "hola2" << endl;
140 }
141
142
143 int isA( const char * flag ) {
144 return ( (strncmp((char *)this, flag, 8)==0) ? TRUE : FALSE );
145 }
146
147 inline int mysize(void) { return ( SIZE_OF_MCCPHOTON*sizeof(Float_t) ); }
148
149};
150
151// @endcode
152
153#endif // not defined MCCphoton_Class
154
Note: See TracBrowser for help on using the repository browser.