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

Last change on this file since 10083 was 5103, checked in by moralejo, 20 years ago
Changes to adapt headers to c++ style.
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>
30#include <iomanip>
31#include <fstream>
32#include <stdlib.h>
33#include <string>
34#include <math.h>
35
36#include "jcmacros.h"
37
38using namespace std;
39
40// const char variables to use in MCCphoton::isA() function
41
42const char FLAG_START_OF_RUN[] = "\nSTART---RUN\n";
43const char FLAG_START_OF_HEADER[] = "RUNH";
44const char FLAG_START_OF_EVENT[] = "\nSTART-EVENT\n";
45const char FLAG_EVENT_HEADER[] = "EVTH";
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_HEADER 8 /* floats */
53#define SIZE_OF_MCCPHOTON 8 /* floats */
54
55// @endcode
56
57// @subsection Class {\em MCCphoton}: Definition
58
59// @code
60
61class MCCphoton {
62private:
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 Int_t read ( FILE *f ) {
87 return fread( &w, mysize(), 1, f );
88 }
89
90 void get_flag(Char_t* c)
91 {
92 memcpy(c, (Char_t*)&w, SIZE_OF_FLAGS);
93 }
94
95 // writes photon to binary output stream
96 Int_t write ( ofstream &os ) {
97 os.write ( (char *)this, mysize() );
98 return 0;
99 }
100
101 // get information about the photon
102 inline Float_t get_wl( void ) { return ( w - 1000.*((int)floor(w/1000.))); }
103
104 inline Int_t get_particle( void ) {
105 return ( (int)floor(w/1000.) );
106 }
107
108
109 inline Float_t get_x( void ) { return ( x ); }
110 inline Float_t get_y( void ) { return ( y ); }
111 inline Float_t get_u( void ) { return ( u ); }
112 inline Float_t get_v( void ) { return ( v ); }
113 inline Float_t get_h( void ) { return ( h ); }
114 inline Float_t get_t( void ) { return ( t ); }
115 inline Float_t get_phi( void ) { return ( phi ); }
116
117
118 inline Float_t get_r( void ) { return ( sqrt( x*x + y*y ) ); }
119 inline Float_t get_w( void ) { return ( sqrt( 1.0 - u*u - v*v ) ); }
120
121 inline void fill(Float_t thew,
122 Float_t thex, Float_t they,
123 Float_t theu, Float_t thev,
124 Float_t theh, Float_t thet,
125 Float_t thephi) {
126 w = thew;
127 x = thex;
128 y = they;
129 u = theu;
130 v = thev;
131 h = theh;
132 t = thet;
133 phi = thephi;
134 }
135
136
137 inline void fill(Char_t* data)
138 {
139 cout << "hola1" << endl;
140 memcpy((Char_t*)(&w), data, mysize());
141 cout << "hola2" << endl;
142 }
143
144
145 int isA( const char * flag ) {
146 return ( (strncmp((char *)this, flag, 8)==0) ? TRUE : FALSE );
147 }
148
149 inline int mysize(void) { return ( SIZE_OF_MCCPHOTON*sizeof(Float_t) ); }
150
151};
152
153// @endcode
154
155#endif // not defined MCCphoton_Class
156
Note: See TracBrowser for help on using the repository browser.