Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
volume.h
Go to the documentation of this file.
1#ifndef VOLUME_H
2#define VOLUME_H
3#include <iostream>
4#include <vector>
5
9
10/*
11The main definitions related to volume.
12
13Copyright (c) 2000 Igor B. Smirnov
14
15The file can be used, copied, modified, and distributed
16according to the terms of GNU Lesser General Public License version 2.1
17as published by the Free Software Foundation,
18and provided that the above copyright notice, this permission notice,
19and notices about any modifications of the original text
20appear in all copies and in supporting documentation.
21The file is provided "as is" without express or implied warranty.
22*/
23
24namespace Heed {
25
26class gparticle;
27class manip_absvol;
28class volume;
29class absvol;
30
31/// Service class (array of manip_absvol).
33 public:
34 /// Constructor
36 /// List of volumes
37 std::vector<PassivePtr<manip_absvol> > eid;
38 /// Get last address of manipulator
40 return eid.empty() ? NULL : eid.back().get();
41 }
42 /// Get last address of volume
43 absvol* G_lavol() const;
44
45 friend int operator==(manip_absvol_treeid& tid1, manip_absvol_treeid& tid2);
46 friend int operator!=(manip_absvol_treeid& tid1, manip_absvol_treeid& tid2);
47 // The following two functions change reference frame of any object
48 // derivative from absref
49 void down_absref(absref* f);
50 void up_absref(absref* f);
51
52 // The following returns 1 if registered and 0 otherwise
53 // Registered means that the route includes this manip_absvol,
54 // not necessary the last volume.
57 void print(std::ostream& file, int l) const;
58};
59
60int operator==(manip_absvol_treeid& tid1, manip_absvol_treeid& tid2);
62 if (tid1 == tid2) return 0;
63 return 1;
64}
65
66/// Abstract base class for volumes.
67/// The functions accept and return parameters expressed in the internal
68/// coordinate system inherent to this volume.
69/// For interface with external system please use manip_absvol.
70class absvol : virtual public absref, public RegPassivePtr {
71 // public RegPassivePtr is not necessary for general package
72 // but may be useful in applications
73 public:
76
77 /// Destructor
78 virtual ~absvol() {}
79
80 /// Check if a point is inside the volume.
81 /// If two volumes are adjacent, it may happen that a point belongs to both.
82 /// To avoid this confusion the parameter dir is used.
83 /// If dir == (0, 0, 0), and the point is exactly on the border,
84 /// the behaviour is in general not specified.
85 /// If dir != (0, 0, 0), and the point is on the border with precision prec,
86 /// the exiting volume is ignored.
87 virtual int check_point_inside(const point& fpt, const vec& dir) const = 0;
88
89 /// Return 1 if point in this volume.
90 /// It starts from embraced manipulators, if any
91 /// If there are embraced volumes, it add some to namvol,
92 /// otherwise it does not add namvol==0.
93 /// The embraced volumes should not cross each other,
94 /// since this function can return only one chain.
95 /// But the borders can coincide with precision given to embraced volumes.
96 /// If the point is on the border, it is considered inside volume only if
97 /// dir is directed inside it.
98 /// Also algorithm of volume is effective if it interrupts
99 /// checking after first volume found.
100 virtual int find_embed_vol(const point& fpt, const vec& dir,
101 manip_absvol_treeid* atid) const;
102
103 /// range considering this volume, all embracing volumes
104 /// sb=0 range restricted by precision reasons.
105 /// sb=1 crossing border of this volume
106 /// sb=2 crossing border of embraced volume
107 /// s_ext=1 inside, and to check all embraced volumes
108 /// s_ext=0 outside
109 /// checks only one level in deep. It is assumed that
110 /// from current volume the particle can pass either outside or
111 /// to one of embracing volumes.
112 /// In the last case *faeid is filled by its id.
113 /// Otherwise *faeid is filled by NULL.
114 virtual int range(trajestep& fts, int s_ext, int& sb,
115 PassivePtr<manip_absvol>& faeid) const;
116
117 /// Find cross with current volume ignoring embraced ones.
118 /// s_ext=1 exit, now point is inside, but embraced volumes are ingnored.
119 /// s_ext=0 enter, now point is outside
120 virtual int range_ext(trajestep& fts, int s_ext) const = 0;
121
122 virtual void income(gparticle*) {}
123 virtual void chname(char* nm) const { strcpy(nm, "absvol"); }
124 virtual void print(std::ostream& file, int l) const;
125 virtual absvol* copy() const;
126 virtual std::vector<manip_absvol*> Gamanip_embed() const;
127};
128
129/*
130class absref_transmit_2fixsyscoor : public absref_transmit {
131 public:
132 fixsyscoor* asys1;
133 fixsyscoor* asys2;
134 virtual absref* get_other(int n) {
135 if (n == 0) return asys1;
136 if (n == 1) return asys2;
137 mcerr << "absref_transmit_2fixsyscoor::get_other: should never happen\n";
138 spexit(mcerr);
139 return NULL; // to quiet compiler
140 }
141 absref_transmit_2fixsyscoor(void) : absref_transmit() { ; }
142 absref_transmit_2fixsyscoor(fixsyscoor* fasys1, fixsyscoor* fasys2)
143 : absref_transmit(), asys1(fasys1), asys2(fasys2) {
144 qaref_other = 2;
145 }
146 macro_copy_total(absref_transmit_2fixsyscoor);
147 virtual ~absref_transmit_2fixsyscoor() { ; }
148};
149
150class absref_transmit_fixsyscoor : public absref_transmit {
151 public:
152 std::vector<fixsyscoor>* asys;
153 virtual absref* get_other(int n) { return &((*asys)[n]); }
154 absref_transmit_fixsyscoor(void) : absref_transmit() { ; }
155 absref_transmit_fixsyscoor(std::vector<fixsyscoor>* fasys)
156 : absref_transmit(), asys(fasys) {
157 qaref_other = asys->size();
158 }
159 macro_copy_total(absref_transmit_fixsyscoor);
160 virtual ~absref_transmit_fixsyscoor() { ; }
161};
162
163class absref_transmit_absvol : public absref_transmit {
164 public:
165 std::vector<ActivePtr<absvol> >* avol;
166 virtual absref* get_other(int n) { return (*avol)[n].get(); }
167 absref_transmit_absvol(void) : absref_transmit() { ; }
168 absref_transmit_absvol(std::vector<ActivePtr<absvol> >* favol)
169 : absref_transmit(), avol(favol) {
170 qaref_other = avol->size();
171 }
172 macro_copy_total(absref_transmit_absvol);
173 virtual ~absref_transmit_absvol() { ; }
174};
175*/
176
177/// Abstract base classs for volume "manipulators".
178class manip_absvol : virtual public absref, public RegPassivePtr {
179 public:
180 /// Get the volume.
181 virtual absvol* Gavol() const = 0;
182 /// Get the coordinate system.
183 virtual const abssyscoor* Gasc() const {
184 // Return NULL if it is the same system
185 return NULL;
186 }
187 virtual int m_check_point_inside(const point& fpt, const vec& dir) const;
188 virtual int m_find_embed_vol(const point& fpt, const vec& fdir,
189 manip_absvol_treeid* atid) const;
190 // Do the appropriate manipulations with atid and calls avol->find_embed_vol
191
192 // The two following functions changes syscoor if necessary and
193 // calls similar named functions of absvol
194 virtual int m_range(trajestep& fts, int s_ext, int& sb,
195 PassivePtr<manip_absvol>& faeid) const;
196 virtual int m_range_ext(trajestep& fts, int s_ext) const;
197 // s_ext=1 inside, but embraced volumes are ingnored.
198 // s_ext=0 outside
199
200 // The following two functions change reference frame of any object
201 inline void down_absref(absref* f) const {
202 const abssyscoor* asc = Gasc();
203 if (asc) f->down(asc);
204 }
205 inline void up_absref(absref* f) const {
206 const abssyscoor* asc = Gasc();
207 if (asc) f->up(asc);
208 }
209 void m_chname(char* nm) const;
210 virtual void m_print(std::ostream& file, int l) const;
211 virtual manip_absvol* copy() const;
212 virtual ~manip_absvol() {}
213};
214
215// ********* sh_manip_absvol *********
217 protected:
219
220 public:
221 virtual const abssyscoor* Gasc() const;
222 void Psc(const fixsyscoor& fcsys) { csys = fcsys; }
223
224 protected:
225 virtual void get_components(ActivePtr<absref_transmit>& aref_tran);
227
228 public:
232 sh_manip_absvol(const abssyscoor& f);
233 sh_manip_absvol(const point& fc, const basis& fbas, const std::string& fname);
234 virtual ~sh_manip_absvol() {}
235
236 virtual void m_chname(char* nm) const;
237 virtual void m_print(std::ostream& file, int l) const;
238 virtual sh_manip_absvol* copy() const;
239};
240
241/*
242class absref_transmit_2manip : public absref_transmit {
243 public:
244 ActivePtr<manip_absvol>* amvol1;
245 ActivePtr<manip_absvol>* amvol2;
246 virtual absref* get_other(int n) {
247 absref* vol = 0;
248 if (n == 0) vol = amvol1->get();
249 if (n == 1) vol = amvol2->get();
250 mcerr << "absref_transmit_2manip::get_other: should never happen\n";
251 spexit(mcerr);
252 return vol;
253 }
254 absref_transmit_2manip(void) : absref_transmit() { ; }
255 absref_transmit_2manip(ActivePtr<manip_absvol>* famvol1,
256 ActivePtr<manip_absvol>* famvol2)
257 : absref_transmit(), amvol1(famvol1), amvol2(famvol2) {
258 qaref_other = 2;
259 }
260 macro_copy_total(absref_transmit_2manip);
261 virtual ~absref_transmit_2manip() { ; }
262};
263
264class absref_transmit_manip : public absref_transmit {
265 public:
266 std::vector<ActivePtr<manip_absvol> >* amvol;
267 virtual absref* get_other(int n) { return (*amvol)[n].get(); }
268 absref_transmit_manip(void) : absref_transmit() { ; }
269 absref_transmit_manip(std::vector<ActivePtr<manip_absvol> >* famvol)
270 : absref_transmit(), amvol(famvol) {
271 qaref_other = amvol->size();
272 }
273 macro_copy_total(absref_transmit_manip);
274 virtual ~absref_transmit_manip() { ; }
275};
276*/
277
278}
279
280#endif
Active pointer or automatic container or controlling pointer.
Definition: AbsPtr.h:199
virtual void up(const abssyscoor *fasc)
Convert numbering representation of objects to new system.
Definition: vec.cpp:48
virtual void down(const abssyscoor *fasc)
Convert numbering representation of object to basical system of fasc.
Definition: vec.cpp:43
virtual void print(std::ostream &file, int l) const
Definition: volume.cpp:118
virtual int range(trajestep &fts, int s_ext, int &sb, PassivePtr< manip_absvol > &faeid) const
Definition: volume.cpp:98
virtual int find_embed_vol(const point &fpt, const vec &dir, manip_absvol_treeid *atid) const
Definition: volume.cpp:79
virtual ~absvol()
Destructor.
Definition: volume.h:78
virtual absvol * copy() const
Definition: volume.cpp:146
virtual void income(gparticle *)
Definition: volume.h:122
virtual int range_ext(trajestep &fts, int s_ext) const =0
bool s_sensitive
Definition: volume.h:75
vfloat prec
Definition: volume.h:74
virtual int check_point_inside(const point &fpt, const vec &dir) const =0
virtual std::vector< manip_absvol * > Gamanip_embed() const
Definition: volume.cpp:75
virtual void chname(char *nm) const
Definition: volume.h:123
Basis.
Definition: vec.h:319
Service class (array of manip_absvol).
Definition: volume.h:32
int check_absvol_registered(absvol *avol)
Definition: volume.cpp:37
void down_absref(absref *f)
Definition: volume.cpp:21
void print(std::ostream &file, int l) const
Definition: volume.cpp:56
void up_absref(absref *f)
Definition: volume.cpp:26
friend int operator!=(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.h:61
int check_manip_absvol_registered(manip_absvol *amvol)
Definition: volume.cpp:31
std::vector< PassivePtr< manip_absvol > > eid
List of volumes.
Definition: volume.h:37
friend int operator==(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.cpp:43
absvol * G_lavol() const
Get last address of volume.
Definition: volume.cpp:17
manip_absvol_treeid()
Constructor.
Definition: volume.h:35
manip_absvol * G_lamvol() const
Get last address of manipulator.
Definition: volume.h:39
Abstract base classs for volume "manipulators".
Definition: volume.h:178
virtual int m_check_point_inside(const point &fpt, const vec &dir) const
Definition: volume.cpp:153
virtual manip_absvol * copy() const
Definition: volume.cpp:250
void up_absref(absref *f) const
Definition: volume.h:205
virtual ~manip_absvol()
Definition: volume.h:212
virtual absvol * Gavol() const =0
Get the volume.
void m_chname(char *nm) const
Definition: volume.cpp:222
virtual const abssyscoor * Gasc() const
Get the coordinate system.
Definition: volume.h:183
virtual int m_range_ext(trajestep &fts, int s_ext) const
Definition: volume.cpp:210
void down_absref(absref *f) const
Definition: volume.h:201
virtual int m_range(trajestep &fts, int s_ext, int &sb, PassivePtr< manip_absvol > &faeid) const
Definition: volume.cpp:196
virtual int m_find_embed_vol(const point &fpt, const vec &fdir, manip_absvol_treeid *atid) const
Definition: volume.cpp:167
virtual void m_print(std::ostream &file, int l) const
Definition: volume.cpp:227
Point.
Definition: vec.h:374
fixsyscoor csys
Definition: volume.h:218
virtual void m_print(std::ostream &file, int l) const
Definition: volume.cpp:286
absref * aref_ptr[1]
Definition: volume.h:226
virtual const abssyscoor * Gasc() const
Get the coordinate system.
Definition: volume.cpp:262
void Psc(const fixsyscoor &fcsys)
Definition: volume.h:222
virtual ~sh_manip_absvol()
Definition: volume.h:234
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
Definition: volume.cpp:257
virtual sh_manip_absvol * copy() const
Definition: volume.cpp:280
virtual void m_chname(char *nm) const
Definition: volume.cpp:275
Definition: vec.h:186
Definition: BGMesh.cpp:5
int operator!=(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.h:61
int operator==(const circumf &f1, const circumf &f2)
Definition: circumf.cpp:34
double vfloat
Definition: vfloat.h:16