Public Member Functions | Private Member Functions | Private Attributes | List of all members
G3Node Class Reference

#include <G3Node.h>

Inheritance diagram for G3Node:

Public Member Functions

 G3Node ()
 
 G3Node (const char *name, const char *title, const char *shapename, Double_t x=0, Double_t y=0, Double_t z=0, const char *matrixname="", Option_t *option="")
 
 G3Node (const char *name, const char *title, TShape *shape, Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0, Option_t *option="")
 
 G3Node (const G3Node &node, G3Node *parent)
 
virtual ~G3Node ()
 
virtual void SetDivision (Int_t ndiv, Int_t axis, Float_t start, Float_t step)
 
virtual void ExpandDivisions ()
 
virtual Int_t Axis () const
 
virtual Int_t Ndiv () const
 
virtual Float_t Step () const
 
virtual Float_t StartC () const
 
virtual void AddSons (TList *list)
 
virtual void AddSon (G3Node *node)
 

Private Member Functions

G3Nodeoperator= (const G3Node &)
 

Private Attributes

Int_t fAxis
 
Int_t fNDivision
 
Float_t fStep
 
Float_t fStartC
 

Detailed Description

Definition at line 9 of file G3Node.h.

Constructor & Destructor Documentation

G3Node::G3Node ( )
inline

Definition at line 12 of file G3Node.h.

12 {}
G3Node::G3Node ( const char *  name,
const char *  title,
const char *  shapename,
Double_t  x = 0,
Double_t  y = 0,
Double_t  z = 0,
const char *  matrixname = "",
Option_t *  option = "" 
)
G3Node::G3Node ( const char *  name,
const char *  title,
TShape *  shape,
Double_t  x = 0,
Double_t  y = 0,
Double_t  z = 0,
TRotMatrix *  matrix = 0,
Option_t *  option = "" 
)

Definition at line 66 of file G3Node.cxx.

68  :
69  TNode(name, title, shape, x, y, z, matrix, option)
70 {
71  fNDivision = -1;
72  fAxis = 0;
73  fStartC = 0.;
74  fStep = 0.;
75 }
Int_t fNDivision
Definition: G3Node.h:37
double y
double z
Float_t fStartC
Definition: G3Node.h:39
Float_t fStep
Definition: G3Node.h:38
Int_t fAxis
Definition: G3Node.h:36
list x
Definition: train.py:276
G3Node::G3Node ( const G3Node node,
G3Node parent 
)

Definition at line 401 of file G3Node.cxx.

402 {
403  fNDivision = node.Ndiv();
404  fAxis = node.Axis();
405  fStartC = node.StartC();
406  fStep = node.Step();
407  fName = node.GetName();
408  fTitle = node.GetTitle();
409  fX = node.GetX();
410  fY = node.GetY();
411  fZ = node.GetZ();
412  fMatrix = node.GetMatrix();
413  fNodes = 0;
414  fParent = parent;
415 
416 
417  if (fNDivision > 0) {
418  fShape = new TShape(*node.GetShape());
419  } else {
420  fShape = (TShape*) node.GetShape()->Clone();
421  }
422 
423 
424 // fShape = (TShape*) shape->Clone();
425 /*
426  char tmp[4];
427  strcpy(tmp, shape->ClassName());
428 
429  if (strcmp(tmp, "TTUBE")==0)
430  fShape = (TTUBE*)shape->Clone();
431  else if (strcmp(tmp, "TBRIK")==0)
432  fShape = (TBRIK*)shape->Clone();
433  else if (strcmp(tmp, "TCONE")==0)
434  fShape = (TCONE*)shape->Clone();
435  else if (strcmp(tmp, "TCONS")==0)
436  fShape = (TCONS*)shape->Clone();
437  else if (strcmp(tmp, "TTUBS")==0)
438  fShape = (TTUBS*)shape->Clone();
439  else if (strcmp(tmp, "TTRAP")==0)
440  fShape = (TTRAP*)shape->Clone();
441  else if (strcmp(tmp, "TTRD1")==0)
442  fShape = (TTRD1*)shape->Clone();
443  else if (strcmp(tmp, "TTRD2")==0)
444  fShape = (TTRD2*)shape->Clone();
445  else if (strcmp(tmp, "TSPHE")==0)
446  fShape = (TSPHE*)shape->Clone();
447  else if (strcmp(tmp, "TPGON")==0)
448  fShape = (TPGON*)shape->Clone();
449  else if (strcmp(tmp, "TPCON")==0)
450  fShape = (TPCON*)shape->Clone();
451 */
452 }
Int_t fNDivision
Definition: G3Node.h:37
virtual Int_t Ndiv() const
Definition: G3Node.h:27
virtual Float_t StartC() const
Definition: G3Node.h:29
virtual Float_t Step() const
Definition: G3Node.h:28
Float_t fStartC
Definition: G3Node.h:39
Float_t fStep
Definition: G3Node.h:38
virtual Int_t Axis() const
Definition: G3Node.h:26
Int_t fAxis
Definition: G3Node.h:36
virtual G3Node::~G3Node ( )
inlinevirtual

Definition at line 22 of file G3Node.h.

22 {}

Member Function Documentation

void G3Node::AddSon ( G3Node node)
virtual

Definition at line 454 of file G3Node.cxx.

455 {
456  fNodes->Add(node);
457 }
void G3Node::AddSons ( TList *  list)
virtual

Definition at line 384 of file G3Node.cxx.

385 {
386  if (!list) return;
387  if (!fNodes) fNodes = new TList();
388 
389  TIter next(list);
390  G3Node* node;
391 
392  while((node = (G3Node*)next())) {
393  G3Node* newNode = new G3Node(*node, this);
394  fNodes->Add(newNode);
395  newNode->SetParent(this);
396  newNode->AddSons(node->GetListOfNodes());
397  }
398 }
G3Node()
Definition: G3Node.h:12
virtual void AddSons(TList *list)
Definition: G3Node.cxx:384
Definition: G3Node.h:9
virtual Int_t G3Node::Axis ( ) const
inlinevirtual

Definition at line 26 of file G3Node.h.

26 {return fAxis;}
Int_t fAxis
Definition: G3Node.h:36
void G3Node::ExpandDivisions ( )
virtual

Definition at line 85 of file G3Node.cxx.

86 {
87  Int_t i;
88  char vName[20];
89  char nName[20];
90 
91  char tmp[4];
92  G3Node* node;
93  TShape* parent = fParent->GetShape();
94  TShape* newsh;
95 
96  strcpy(tmp, parent->GetTitle());
97  Int_t ndiv = fNDivision;
98 
99 // TUBE
100 
101  if (strcmp(tmp, "TUBE")==0) {
102  TTUBE * shape = (TTUBE*) parent;
103 
104  Float_t dZ = shape->GetDz();
105  Float_t rMin = shape->GetRmin();
106  Float_t rMax = shape->GetRmax();
107 
108  if (fAxis == 1) {
109 // radial-division
110  Float_t dr = (rMax-rMin)/Float_t(fNDivision);
111  Float_t r1, r2;
112  for (i=0; i<ndiv; i++) {
113  r1 = rMin+Float_t(i)*dr;
114  r2 = r1+dr;
115  sprintf(vName, "%sD%d", fShape->GetName(), i);
116  sprintf(nName, "%sD%d", GetName(), i);
117  newsh = new TTUBE(vName, "TUBE", "void", r1, r2, dZ);
118  fParent->cd();
119  node = new G3Node(nName,"", newsh, 0., 0., 0.);
120  node->AddSons(fNodes);
121  cd();
122  }
123 
124  } else if (fAxis == 2) {
125 // phi-division
126  Float_t dPhi = 360./Float_t(fNDivision);
127  Float_t phi1, phi2;
128  for (i=0; i<ndiv; i++) {
129  phi1 = Float_t(i)*dPhi;
130  phi2 = phi1+dPhi;
131  sprintf(vName, "%sD%d", fShape->GetName(), i);
132  sprintf(nName, "%sD%d", GetName(), i);
133  newsh = new TTUBS(vName, "TUBS", "void", rMin, rMax, dZ, phi1, phi2);
134  fParent->cd();
135  node = new G3Node(nName, "", newsh, 0., 0., 0.);
136  node->AddSons(fNodes);
137  cd();
138  }
139  } else {
140 // z-division
141  Float_t delZ = dZ/Float_t(fNDivision);
142  for (i=0; i<ndiv; i++) {
143  sprintf(vName, "%sD%d", fShape->GetName(), i);
144  sprintf(nName, "%sD%d", GetName(), i);
145  newsh = new TTUBE(vName, "TUBE", "void", rMin, rMax, delZ);
146  fParent->cd();
147  Float_t zpos = -dZ+delZ*(2.*Float_t(i)+1.);
148  node = new G3Node(nName, "",newsh, 0., 0., zpos);
149  node->AddSons(fNodes);
150  cd();
151  }
152  }
153 //
154 // TUBS
155 //
156  } else if (strcmp(tmp, "TUBS")==0) {
157  TTUBS * shape = (TTUBS*) parent;
158  Float_t dZ = shape->GetDz();
159  Float_t rMin = shape->GetRmin();
160  Float_t rMax = shape->GetRmax();
161  Float_t phi1 = shape->GetPhi1();
162  Float_t phi2 = shape->GetPhi2();
163 
164  if (fAxis == 1) {
165 // radial-division
166  Float_t dr = (rMax-rMin)/Float_t(fNDivision);
167  Float_t r1, r2;
168  Int_t ndiv = fNDivision;
169  for (i=0; i<ndiv; i++) {
170  r1 = rMin+Float_t(i)*dr;
171  r2 = r1+dr;
172  sprintf(vName, "%sD%d", fShape->GetName(), i);
173  sprintf(nName, "%sD%d", GetName(), i);
174  newsh = new TTUBS(vName, "TUBS", "void", r1, r2, dZ, phi1, phi2);
175  fParent->cd();
176  node = new G3Node(nName,"", newsh, 0., 0., 0.);
177  node->AddSons(fNodes);
178  cd();
179  }
180 
181  } else if (fAxis == 2) {
182 // phi-division
183  Float_t dPhi = (phi2-phi1)/Float_t(fNDivision);
184  Float_t nphi1, nphi2;
185 
186  for (i=0; i<fNDivision; i++) {
187  nphi1 = phi1+Float_t(i)*dPhi;
188  nphi2 = nphi1+dPhi;
189  sprintf(vName, "%sD%d", fShape->GetName(), i);
190  sprintf(nName, "%sD%d", GetName(), i);
191 
192  newsh = new TTUBS(vName, "TUBS", "void", rMin, rMax, dZ, nphi1, nphi2);
193  fParent->cd();
194  node = new G3Node(nName, "", newsh, 0., 0., 0.);
195  node->AddSons(fNodes);
196  cd();
197  }
198  } else {
199 // z-division
200  Float_t delZ = dZ/Float_t(fNDivision);
201  for (i=0; i<ndiv; i++) {
202  sprintf(vName, "%sD%d", fShape->GetName(), i);
203  sprintf(nName, "%sD%d", GetName(), i);
204  newsh = new TTUBS(vName, "TUBS", "void", rMin, rMax, delZ, phi1, phi2);
205  fParent->cd();
206  Float_t zpos = -dZ+delZ*(2.*Float_t(i)+1.);
207  node = new G3Node(nName, "",newsh, 0., 0., zpos);
208  node->AddSons(fNodes);
209  cd();
210  }
211  }
212 
213  } else if (strcmp(tmp, "CONE")==0) {
214  TCONE * shape = (TCONE*) parent;
215 
216  Float_t dZ = shape->GetDz();
217  Float_t rMin1 = shape->GetRmin();
218  Float_t rMax1 = shape->GetRmax();
219  Float_t rMin2 = shape->GetRmin2();
220  Float_t rMax2 = shape->GetRmax2();
221 
222  if (fAxis == 1) {
223 // radial-division
224  Float_t dr1 = (rMax1-rMin1)/Float_t(fNDivision);
225  Float_t dr2 = (rMax2-rMin2)/Float_t(fNDivision);
226  Float_t r11, r12, r21, r22;
227  for (i=0; i<ndiv; i++) {
228  r11 = rMin1+Float_t(i)*dr1;
229  r12 = r11+dr1;
230  r21 = rMin2+Float_t(i)*dr2;
231  r22 = r21+dr2;
232 
233  sprintf(vName, "%sD%d", fShape->GetName(), i);
234  sprintf(nName, "%sD%d", GetName(), i);
235  newsh = new TCONE(vName, "CONE", "void", dZ, r11, r12, r21, r22);
236  fParent->cd();
237  node = new G3Node(nName,"", newsh, 0., 0., 0.);
238  node->AddSons(fNodes);
239  cd();
240  }
241  } else if (fAxis == 2) {
242 // phi-division
243  Float_t dPhi = 360./Float_t(fNDivision);
244  Float_t phi1, phi2;
245  for (i=0; i<ndiv; i++) {
246  phi1 = Float_t(i)*dPhi;
247  phi2 = phi1+dPhi;
248  sprintf(vName, "%sD%d", fShape->GetName(), i);
249  sprintf(nName, "%sD%d", GetName(), i);
250  newsh = new TCONS(vName, "CONS", "void", dZ, rMin1, rMax1,
251  rMin2, rMax2, phi1, phi2);
252  fParent->cd();
253  node = new G3Node(nName, "",newsh, 0., 0., 0.);
254  node->AddSons(fNodes);
255  cd();
256  }
257  } else {
258 // z-division
259  Float_t delZ = dZ/Float_t(fNDivision);
260  for (i=0; i<ndiv; i++) {
261  sprintf(vName, "%sD%d", fShape->GetName(), i);
262  sprintf(nName, "%sD%d", GetName(), i);
263  newsh = new TCONE(vName, "CONE", "void", delZ, rMin1, rMax1, rMin2, rMax2);
264  fParent->cd();
265  Float_t zpos = -dZ+delZ*(2.*Float_t(i)+1.);
266  node = new G3Node(nName, "",newsh, 0., 0., zpos);
267  node->AddSons(fNodes);
268  cd();
269  }
270  }
271 
272  } else if (strcmp(tmp, "CONS")==0) {
273  TCONS * shape = (TCONS*) parent;
274  Float_t dZ = shape->GetDz();
275  Float_t rMin1 = shape->GetRmin();
276  Float_t rMax1 = shape->GetRmax();
277  Float_t rMin2 = shape->GetRmin2();
278  Float_t rMax2 = shape->GetRmax2();
279  Float_t phi1 = shape->GetPhi1();
280  Float_t phi2 = shape->GetPhi2();
281  if (fAxis == 1) {
282 // radial-division
283  Float_t dr1 = (rMax1-rMin1)/Float_t(fNDivision);
284  Float_t dr2 = (rMax2-rMin2)/Float_t(fNDivision);
285  Float_t r11, r12, r21, r22;
286  for (i=0; i<ndiv; i++) {
287  r11 = rMin1+Float_t(i)*dr1;
288  r12 = r11+dr1;
289  r21 = rMin2+Float_t(i)*dr2;
290  r22 = r21+dr2;
291 
292  sprintf(vName, "%sD%d", fShape->GetName(), i);
293  sprintf(nName, "%sD%d", GetName(), i);
294  newsh = new TCONS(vName, "CONS", "void", dZ, r11, r12, r21, r22, phi1, phi2);
295  fParent->cd();
296  node = new G3Node(nName,"", newsh, 0., 0., 0.);
297  node->AddSons(fNodes);
298  cd();
299  }
300 
301  } else if (fAxis == 2) {
302 // phi-division
303  Float_t dPhi = (phi2-phi1)/Float_t(fNDivision);
304  Float_t nphi1, nphi2;
305 
306  for (i=0; i<fNDivision; i++) {
307  nphi1 = phi1+Float_t(i)*dPhi;
308  nphi2 = nphi1+dPhi;
309  sprintf(vName, "%sD%d", fShape->GetName(), i);
310  sprintf(nName, "%sD%d", GetName(), i);
311 
312  newsh = new TCONS(vName, "CONS", "void", dZ, rMin1, rMax1, rMin2, rMax2, nphi1, nphi2);
313  fParent->cd();
314  node = new G3Node(nName, "", newsh, 0., 0., 0.);
315  node->AddSons(fNodes);
316  cd();
317  }
318  } else {
319 // z-division
320  Float_t delZ = dZ/Float_t(fNDivision);
321  for (i=0; i<ndiv; i++) {
322  sprintf(vName, "%sD%d", fShape->GetName(), i);
323  sprintf(nName, "%sD%d", GetName(), i);
324  newsh = new TCONS(vName, "CONS", "void", delZ, rMin1, rMax1, rMin2, rMax2, phi1, phi2);
325  fParent->cd();
326  Float_t zpos = -dZ+delZ*(2.*Float_t(i)+1.);
327  node = new G3Node(nName,"",newsh, 0., 0., zpos);
328  node->AddSons(fNodes);
329  cd();
330  }
331  }
332  } else if (strcmp(tmp, "BRIK")==0) {
333 //
334 // BRIK
335 //
336  TBRIK * shape = (TBRIK*) parent;
337  Float_t dX = shape->GetDx();
338  Float_t dY = shape->GetDy();
339  Float_t dZ = shape->GetDz();
340 
341  if (fAxis == 1) {
342 // division in x
343  Float_t delX = dX/Float_t(fNDivision);
344  for (i=0; i<ndiv; i++) {
345  sprintf(vName, "%sD%d", fShape->GetName(), i);
346  sprintf(nName, "%sD%d", GetName(), i);
347  newsh = new TBRIK(vName, "BRIK", "void", delX, dY, dZ);
348  fParent->cd();
349  Float_t xpos = -dX+delX*(2.*Float_t(i)+1.);
350  node = new G3Node(nName,"",newsh, xpos, 0., 0.);
351  node->AddSons(fNodes);
352  cd();
353  }
354  } else if (fAxis == 2) {
355 // division in y
356  Float_t delY = dY/Float_t(fNDivision);
357  for (i=0; i<ndiv; i++) {
358  sprintf(vName, "%sD%d", fShape->GetName(), i);
359  sprintf(nName, "%sD%d", GetName(), i);
360  newsh = new TBRIK(vName, "BRIK", "void", dX, delY, dZ);
361  fParent->cd();
362  Float_t ypos = -dY+delY*(2.*Float_t(i)+1.);
363  node = new G3Node(nName,"",newsh, 0., ypos, 0.);
364  node->AddSons(fNodes);
365  cd();
366  }
367  } else {
368 // division in z
369  Float_t delZ = dZ/Float_t(fNDivision);
370  for (i=0; i<ndiv; i++) {
371  sprintf(vName, "%sD%d", fShape->GetName(), i);
372  sprintf(nName, "%sD%d", GetName(), i);
373  newsh = new TBRIK(vName, "BRIK", "void", dX, dY, delZ);
374  fParent->cd();
375  Float_t zpos = -dZ+delZ*(2.*Float_t(i)+1.);
376  node = new G3Node(nName,"",newsh, 0., 0., zpos);
377  node->AddSons(fNodes);
378  cd();
379  }
380  }
381  }
382 }
Int_t fNDivision
Definition: G3Node.h:37
G3Node()
Definition: G3Node.h:12
virtual void AddSons(TList *list)
Definition: G3Node.cxx:384
Definition: G3Node.h:9
Int_t fAxis
Definition: G3Node.h:36
virtual Int_t G3Node::Ndiv ( ) const
inlinevirtual

Definition at line 27 of file G3Node.h.

27 {return fNDivision;}
Int_t fNDivision
Definition: G3Node.h:37
G3Node& G3Node::operator= ( const G3Node )
inlineprivate

Definition at line 41 of file G3Node.h.

41 {return *this;}
void G3Node::SetDivision ( Int_t  ndiv,
Int_t  axis,
Float_t  start,
Float_t  step 
)
virtual

Definition at line 77 of file G3Node.cxx.

78 {
79  fNDivision = ndiv;
80  fAxis = axis;
81  fStartC = start;
82  fStep = step;
83 }
Int_t fNDivision
Definition: G3Node.h:37
Float_t fStartC
Definition: G3Node.h:39
Float_t fStep
Definition: G3Node.h:38
start
Definition: test.py:4
Int_t fAxis
Definition: G3Node.h:36
virtual Float_t G3Node::StartC ( ) const
inlinevirtual

Definition at line 29 of file G3Node.h.

29 {return fStartC;}
Float_t fStartC
Definition: G3Node.h:39
virtual Float_t G3Node::Step ( void  ) const
inlinevirtual

Definition at line 28 of file G3Node.h.

28 {return fStep;}
Float_t fStep
Definition: G3Node.h:38

Member Data Documentation

Int_t G3Node::fAxis
private

Definition at line 36 of file G3Node.h.

Int_t G3Node::fNDivision
private

Definition at line 37 of file G3Node.h.

Float_t G3Node::fStartC
private

Definition at line 39 of file G3Node.h.

Float_t G3Node::fStep
private

Definition at line 38 of file G3Node.h.


The documentation for this class was generated from the following files: