source: trunk/MagicSoft/Simulation/Detector/include-CORSIKA/CORParticle.hxx@ 770

Last change on this file since 770 was 417, checked in by harald, 24 years ago
Added the memberfunction Print() to show some members of a instance of the class.
File size: 3.2 KB
Line 
1/////////////////////////////////////////////////////////////////
2//
3// CORParticle
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 CORParticle.hxx}
15
16/* @text
17This section shows the include file {\tt CORParticle.hxx}
18@endtext */
19
20#ifndef CORParticle_Class
21#define CORParticle_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 <math.h>
38// @endcode
39
40// @subsection Class {\em CORParticle}: Definition
41
42// @code
43class CORParticle {
44
45public:
46 Float_t w; // wavelength/type of particle [nm/-]
47 Float_t x, y; // position [cm]
48 Float_t u, v; // director cosines
49 Float_t t; // time since first interaction [ns]
50 Float_t h; // height [cm]
51
52public:
53 CORParticle() {} // default constructor
54
55 // overloaded constructor
56 CORParticle( ifstream &is ) { CORParticle::read( is ); }
57
58 // overloaded constructor
59 CORParticle(Float_t thew, Float_t thex, Float_t they,
60 Float_t theu, Float_t thev, Float_t thet, Float_t theh)
61 {
62 w = thew;
63 x = thex;
64 y = they;
65 u = theu;
66 v = thev;
67 t = thet;
68 h = theh;
69 }
70
71 virtual ~CORParticle() {} // default destructor
72
73 // reads photon from binary input stream
74 Int_t read ( ifstream &is ) {
75 int n;
76 is.read ( (char *)this, 7 * sizeof( Float_t ) ); //
77 return is.gcount();
78 }
79
80 // writes photon to binary output stream
81 Int_t write ( ofstream &os ) {
82 os.write ( (char *)this, 7 * sizeof( Float_t ) );
83 return 0;
84 }
85
86 // fill information
87 inline void fill(Float_t thew, Float_t thex, Float_t they,
88 Float_t theu, Float_t thev, Float_t thet, Float_t theh)
89 {
90 w = thew;
91 x = thex;
92 y = they;
93 u = theu;
94 v = thev;
95 t = thet;
96 h = theh;
97 }
98
99
100 // print content of one particle
101 inline void print()
102 {
103 cout << " PartId: " << get_particle()
104 << " Pos: " << x << "/" << y
105 << " lam: " << w - 1000.*((int)floor(w/1000.))
106 << " hei: " << h
107 << " tim: " << t
108 << " dir: " << u << "/" << v
109 << endl ;
110 }
111
112 // get information about the photon
113 inline Float_t get_wl( void ) {
114 return ( (w>1.0) ?
115 w - 1000.*((int)floor(w/1000.)) :
116 0.0 );
117 }
118 inline Float_t get_id( void ) { return ( w ); }
119 inline Int_t get_particle( void ) {
120 return ( (int)floor(w/1000.) );
121 }
122 inline Float_t get_x( void ) { return ( x ); }
123 inline Float_t get_y( void ) { return ( y ); }
124 inline Float_t get_u( void ) { return ( u ); }
125 inline Float_t get_v( void ) { return ( v ); }
126 inline Float_t get_h( void ) { return ( h ); }
127 inline Float_t get_t( void ) { return ( t ); }
128
129 inline Float_t get_r( void ) { return ( sqrt( x*x + y*y ) ); }
130 inline Float_t get_w( void ) { return ( sqrt( 1.0 - u*u - v*v ) ); }
131};
132
133// @endcode
134
135#endif // not defined CORParticle_Class
136
Note: See TracBrowser for help on using the repository browser.