Garfield++ v1r0
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>
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
24class gparticle;
25class manip_absvol;
26class volume;
27#define pqamvol 10
28
29class manip_absvol;
30class absvol;
31
32// Two little service classes
33// (1) Address of volume and index in embracing volume.
35 public:
36 // Constructor
37 manip_absvol_eid(void);
38 // Address of volume
40 // Index of this volume in array
41 int nembed;
42 void print(std::ostream& file, int l) const;
43};
44// (2) Array of manip_absvol_eid classes
46 public:
47 // Constructor
48 manip_absvol_treeid(void) : qeid(0) { ; }
49 // Number of volumes
50 int qeid;
51 // List of volumes
53 // Get last address of manip_absvol_eid
54 const manip_absvol_eid* G_laeid() const {
55 return qeid > 0 ? &eid[qeid - 1] : 0;
56 }
57 // Get last address of manipulator
59 return qeid > 0 ? eid[qeid - 1].amvol.get() : 0;
60 }
61 // Get last address of volume
62 absvol* G_lavol() const;
63
64 friend int operator==(manip_absvol_treeid& tid1, manip_absvol_treeid& tid2);
65 friend int operator!=(manip_absvol_treeid& tid1, manip_absvol_treeid& tid2);
66 // The following two functions change reference frame of any object
67 // derivative from absref
68 void down_absref(absref* f);
69 void up_absref(absref* f);
70
71 // The following returns 1 if registered and 0 otherwise
72 // Registered means that the route includes this manip_absvol,
73 // not necessary the last volume.
76 void print(std::ostream& file, int l) const;
77};
78
81 if (tid1 == tid2) return 0;
82 return 1;
83}
84
85// ******** absvol *******
86// Class abstract volume: the principal volume features
87// Actual shapes should be derived.
88// The functions accept and return parameters expressed in the internal
89// coordinate system inherent to this volume.
90// For interface with external system please use manip_absvol.
91class absvol : virtual public absref, public RegPassivePtr {
92 // public RegPassivePtr is not necessary for general package
93 // but may be useful in applications
94 public:
96 // Destructor
97 virtual ~absvol() {}
98 virtual int check_point_inside(const point& fpt, const vec& dir) const = 0;
99 // If two volumes are exactly adjusted, it may happens that the point
100 // belongs to both volumes, to their borders. To avoid this confusion
101 // the parameter dir is applied.
102 // If dir == dv0, and point is exactly on the border,
103 // generally behaviour is not specified.
104 // If dir != dv0, and point is on the border with precision prec,
105 // the exiting volume is ignored.
106
107 virtual int find_embed_vol(const point& fpt, const vec& dir,
108 manip_absvol_treeid* atid) const;
109 // It starts from embraced manipulators, if any
110 // If point in this volume, it returns 1.
111 // If there are embraced volumes, it add some to namvol,
112 // otherwise it does not add namvol==0.
113 // The embraced volumes should not cross each other,
114 // since this function can return only one chain.
115 // But the borders can coincide with precision given to embraced volumes.
116 // If the point is on the border, it is considered inside volume only if
117 // dir is directed inside it.
118 // Also algorithm of volume is effective if it interrupts
119 // checking after first volume found.
120
121 virtual int range(trajestep& fts, int s_ext, int& sb,
122 manip_absvol_eid* faeid) const;
123 // range considering this volume, all embracing volumes
124 // sb=0 range restricted by precision reasons.
125 // sb=1 crossing border of this volume
126 // sb=2 crossing border of embraced volume
127 // s_ext=1 inside, and to check all embraced volumes
128 // s_ext=0 outside
129 // checks only one level in deep. It is assumed that
130 // from current volume the particle can pass either outside or
131 // to one of embracing volumes.
132 // In the last case *faeid is filled by its id.
133 // Otherwise *faeid is filled by
134 // faeid->amvol = NULL; and faeid->nembed = -1;
135
136 // Find cross with current volume ignoring embraced ones
137 virtual int range_ext(trajestep& fts, int s_ext) const = 0;
138 // s_ext=1 exit, now point is inside, but embraced volumes are ingnored.
139 // s_ext=0 enter, now point is outside
140
142 virtual void income(gparticle*) {}
143 virtual void chname(char* nm) const { strcpy(nm, "absvol"); }
144 virtual void print(std::ostream& file, int l) const;
145 virtual DynLinArr<manip_absvol*> Gamanip_embed(void) const;
146};
147
148class absref_transmit_2fixsyscoor : public absref_transmit {
149 public:
152 virtual absref* get_other(int n) {
153 if (n == 0) return asys1;
154 if (n == 1) return asys2;
155 mcerr << "absref_transmit_2fixsyscoor::get_other: should never happen\n";
156 spexit(mcerr);
157 return NULL; // to quiet compiler
158 }
159 absref_transmit_2fixsyscoor(void) : absref_transmit() { ; }
161 : absref_transmit(), asys1(fasys1), asys2(fasys2) {
162 qaref_other = 2;
163 }
166};
167
168class absref_transmit_fixsyscoor : public absref_transmit {
169 public:
171 virtual absref* get_other(int n) { return &((*asys)[n]); }
172 absref_transmit_fixsyscoor(void) : absref_transmit() { ; }
174 : absref_transmit(), asys(fasys) {
175 qaref_other = asys->get_qel();
176 }
179};
180
181class absref_transmit_absvol : public absref_transmit {
182 public:
184 virtual absref* get_other(int n) { return (*avol)[n].get(); }
185 absref_transmit_absvol(void) : absref_transmit() { ; }
186 absref_transmit_absvol(DynLinArr<ActivePtr<absvol> >* favol)
187 : absref_transmit(), avol(favol) {
188 qaref_other = avol->get_qel();
189 }
192};
193
194// ********* manip_absvol *********
195class manip_absvol : virtual public absref, public RegPassivePtr {
196 public:
197 virtual absvol* Gavol(void) const = 0;
198 virtual const abssyscoor* Gasc(void) const {
199 // Return NULL if it is the same system
200 return NULL;
201 }
202 virtual int m_check_point_inside(const point& fpt, const vec& dir) const;
203 virtual int m_find_embed_vol(const point& fpt, const vec& fdir,
204 manip_absvol_treeid* atid) const;
205 // Do the appropriate manipulations with atid and calls avol->find_embed_vol
206
207 // The two following functions changes syscoor if necessary and
208 // calls similar named functions of absvol
209 virtual int m_range(trajestep& fts, int s_ext, int& sb,
210 manip_absvol_eid* faeid) const;
211 virtual int m_range_ext(trajestep& fts, int s_ext) const;
212 // s_ext=1 inside, but embraced volumes are ingnored.
213 // s_ext=0 outside
214
215 // The following two functions change reference frame of any object
216 inline void down_absref(absref* f) const {
217 const abssyscoor* asc = Gasc();
218 if (asc != NULL) f->down(asc);
219 }
220 inline void up_absref(absref* f) const {
221 const abssyscoor* asc = Gasc();
222 if (asc != NULL) f->up(asc);
223 }
224 void m_chname(char* nm) const;
225 virtual void m_print(std::ostream& file, int l) const;
227 virtual ~manip_absvol() { ; }
228};
229
230// ********* sh_manip_absvol *********
232 protected:
234
235 public:
236 virtual const abssyscoor* Gasc(void) const;
237 void Psc(const fixsyscoor& fcsys) { csys = fcsys; }
238
239 protected:
240 virtual void get_components(ActivePtr<absref_transmit>& aref_tran);
242
243 public:
244 sh_manip_absvol(void);
247 sh_manip_absvol(const abssyscoor& f);
248 sh_manip_absvol(const point& fc, const basis& fbas, const String& fname);
249 virtual ~sh_manip_absvol() { ; }
250
251 virtual void m_chname(char* nm) const;
252 virtual void m_print(std::ostream& file, int l) const;
253
255};
256
257class absref_transmit_2manip : public absref_transmit {
258 public:
259 ActivePtr<manip_absvol>* amvol1;
260 ActivePtr<manip_absvol>* amvol2;
261 virtual absref* get_other(int n) {
262 absref* vol = 0;
263 if (n == 0) vol = amvol1->get();
264 if (n == 1) vol = amvol2->get();
265 mcerr << "absref_transmit_2manip::get_other: should never happen\n";
266 spexit(mcerr);
267 return vol;
268 }
269 absref_transmit_2manip(void) : absref_transmit() { ; }
270 absref_transmit_2manip(ActivePtr<manip_absvol>* famvol1,
271 ActivePtr<manip_absvol>* famvol2)
272 : absref_transmit(), amvol1(famvol1), amvol2(famvol2) {
273 qaref_other = 2;
274 }
277};
278
279class absref_transmit_manip : public absref_transmit {
280 public:
282 virtual absref* get_other(int n) { return (*amvol)[n].get(); }
283 absref_transmit_manip(void) : absref_transmit() { ; }
284 absref_transmit_manip(DynLinArr<ActivePtr<manip_absvol> >* famvol)
285 : absref_transmit(), amvol(famvol) {
286 qaref_other = amvol->get_qel();
287 }
290};
291
292// *************************************
293
294#endif
#define spexit(stream)
Definition: FunNameStack.h:536
std::string String
Definition: String.h:75
long get_qel(void) const
Definition: AbsArr.h:420
virtual ~absref_transmit_2fixsyscoor()
Definition: volume.h:165
absref_transmit_2fixsyscoor(fixsyscoor *fasys1, fixsyscoor *fasys2)
Definition: volume.h:160
virtual absref * get_other(int n)
Definition: volume.h:152
macro_copy_total(absref_transmit_2fixsyscoor)
virtual absref * get_other(int n)
Definition: volume.h:261
ActivePtr< manip_absvol > * amvol1
Definition: volume.h:259
macro_copy_total(absref_transmit_2manip)
virtual ~absref_transmit_2manip()
Definition: volume.h:276
ActivePtr< manip_absvol > * amvol2
Definition: volume.h:260
absref_transmit_2manip(ActivePtr< manip_absvol > *famvol1, ActivePtr< manip_absvol > *famvol2)
Definition: volume.h:270
absref_transmit_2manip(void)
Definition: volume.h:269
DynLinArr< ActivePtr< absvol > > * avol
Definition: volume.h:183
absref_transmit_absvol(DynLinArr< ActivePtr< absvol > > *favol)
Definition: volume.h:186
virtual absref * get_other(int n)
Definition: volume.h:184
macro_copy_total(absref_transmit_absvol)
absref_transmit_absvol(void)
Definition: volume.h:185
virtual ~absref_transmit_absvol()
Definition: volume.h:191
macro_copy_total(absref_transmit_fixsyscoor)
DynLinArr< fixsyscoor > * asys
Definition: volume.h:170
virtual absref * get_other(int n)
Definition: volume.h:171
absref_transmit_fixsyscoor(void)
Definition: volume.h:172
absref_transmit_fixsyscoor(DynLinArr< fixsyscoor > *fasys)
Definition: volume.h:173
virtual ~absref_transmit_fixsyscoor()
Definition: volume.h:178
macro_copy_total(absref_transmit_manip)
absref_transmit_manip(DynLinArr< ActivePtr< manip_absvol > > *famvol)
Definition: volume.h:284
absref_transmit_manip(void)
Definition: volume.h:283
virtual ~absref_transmit_manip()
Definition: volume.h:289
virtual absref * get_other(int n)
Definition: volume.h:282
DynLinArr< ActivePtr< manip_absvol > > * amvol
Definition: volume.h:281
Definition: vec.h:134
virtual void up(const abssyscoor *fasc)
Definition: vec.cpp:55
virtual void down(const abssyscoor *fasc)
Definition: vec.cpp:50
Definition: volume.h:91
virtual void income(gparticle *)
Definition: volume.h:142
virtual int find_embed_vol(const point &fpt, const vec &dir, manip_absvol_treeid *atid) const
Definition: volume.cpp:92
virtual int range_ext(trajestep &fts, int s_ext) const =0
macro_copy_header(absvol)
virtual int check_point_inside(const point &fpt, const vec &dir) const =0
virtual DynLinArr< manip_absvol * > Gamanip_embed(void) const
Definition: volume.cpp:88
vfloat prec
Definition: volume.h:95
virtual int range(trajestep &fts, int s_ext, int &sb, manip_absvol_eid *faeid) const
Definition: volume.cpp:118
virtual void chname(char *nm) const
Definition: volume.h:143
virtual void print(std::ostream &file, int l) const
Definition: volume.cpp:144
virtual ~absvol()
Definition: volume.h:97
Definition: vec.h:397
PassivePtr< manip_absvol > amvol
Definition: volume.h:39
void print(std::ostream &file, int l) const
Definition: volume.cpp:20
manip_absvol_eid(void)
Definition: volume.cpp:15
int check_manip_absvol_registered(manip_absvol *amvol)
Definition: volume.cpp:42
const manip_absvol_eid * G_laeid() const
Definition: volume.h:54
manip_absvol_eid eid[pqamvol]
Definition: volume.h:52
void print(std::ostream &file, int l) const
Definition: volume.cpp:70
friend int operator!=(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.h:80
void down_absref(absref *f)
Definition: volume.cpp:32
friend int operator==(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.cpp:56
manip_absvol * G_lamvol() const
Definition: volume.h:58
void up_absref(absref *f)
Definition: volume.cpp:37
absvol * G_lavol() const
Definition: volume.cpp:28
manip_absvol_treeid(void)
Definition: volume.h:48
int check_absvol_registered(absvol *avol)
Definition: volume.cpp:49
void down_absref(absref *f) const
Definition: volume.h:216
virtual const abssyscoor * Gasc(void) const
Definition: volume.h:198
void up_absref(absref *f) const
Definition: volume.h:220
virtual int m_range_ext(trajestep &fts, int s_ext) const
void m_chname(char *nm) const
macro_copy_header(manip_absvol)
virtual int m_check_point_inside(const point &fpt, const vec &dir) const
virtual absvol * Gavol(void) const =0
virtual int m_range(trajestep &fts, int s_ext, int &sb, manip_absvol_eid *faeid) const
virtual void m_print(std::ostream &file, int l) const
virtual ~manip_absvol()
Definition: volume.h:227
virtual int m_find_embed_vol(const point &fpt, const vec &fdir, manip_absvol_treeid *atid) const
Definition: vec.h:477
virtual const abssyscoor * Gasc(void) const
Definition: volume.cpp:279
virtual ~sh_manip_absvol()
Definition: volume.h:249
void Psc(const fixsyscoor &fcsys)
Definition: volume.h:237
absref * aref_ptr[1]
Definition: volume.h:241
virtual void m_chname(char *nm) const
Definition: volume.cpp:292
fixsyscoor csys
Definition: volume.h:233
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
macro_copy_header(sh_manip_absvol)
sh_manip_absvol(void)
Definition: volume.cpp:281
virtual void m_print(std::ostream &file, int l) const
Definition: vec.h:248
#define mcerr
Definition: prstream.h:135
double vfloat
Definition: vfloat.h:15
int operator!=(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.h:80
#define pqamvol
Definition: volume.h:27
int operator==(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.cpp:56