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

Last change on this file since 416 was 406, checked in by harald, 24 years ago
adding the memberfunction print() to show the properties of one particle.
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 << "Id: " << get_particle()
104 << " Pos: " << x << "/" << y
105 << " lam: " << w - 1000.*((int)floor(w/1000.))
106 << " hei: " << h
107 << endl ;
108 }
109
110 // get information about the photon
111 inline Float_t get_wl( void ) {
112 return ( (w>1.0) ?
113 w - 1000.*((int)floor(w/1000.)) :
114 0.0 );
115 }
116 inline Float_t get_id( void ) { return ( w ); }
117 inline Int_t get_particle( void ) {
118 return ( (int)floor(w/1000.) );
119 }
120 inline Float_t get_x( void ) { return ( x ); }
121 inline Float_t get_y( void ) { return ( y ); }
122 inline Float_t get_u( void ) { return ( u ); }
123 inline Float_t get_v( void ) { return ( v ); }
124 inline Float_t get_h( void ) { return ( h ); }
125 inline Float_t get_t( void ) { return ( t ); }
126
127 inline Float_t get_r( void ) { return ( sqrt( x*x + y*y ) ); }
128 inline Float_t get_w( void ) { return ( sqrt( 1.0 - u*u - v*v ) ); }
129};
130
131// @endcode
132
133#endif // not defined CORParticle_Class
134
Note: See TracBrowser for help on using the repository browser.