EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairGeoVolume.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairGeoVolume.cxx
1 //*-- AUTHOR : Ilse Koenig
2 //*-- Modified : 27/05/99
3 
5 // FairGeoVolume
6 //
7 // Class to hold the basic geometry properties of a volume
8 // Each volume has a name, a pointer to a reference volume and
9 // a lab transformation.
10 // The reference volume defines the shape, the mother, the size
11 // and the transformation relative to the mother volume which
12 // is either the cave (for modules) or the detector (for the
13 // inner parts).
14 // As an example:
15 // The Mdc modules built at GSI (plane 1 type) are all identical
16 // independent where the sit in the cave. This module type has a
17 // fixed coordinate system. The first layers in all these modules
18 // are identical and they have the same position in the module
19 // coordinate system.
20 //
22 #include "FairGeoVolume.h"
23 
24 #include <iostream>
25 
26 using std::cout;
27 using std::endl;
28 
30 
32  : TNamed(r),
33  shape(""),
34  mother(""),
35  points(NULL),
37  fLabTransform(FairGeoTransform()),
38  fMedium(0),
39  nPoints(0),
40  fHadFormat(0),
41  fgMCid(0)
42 {
43  // copy constructor
44  // fName=r.GetName();
45  setVolumePar(r);
46 }
47 
49 {
50  // copies all volume parameters except the name
51  shape=r.getShape();
52  mother=r.getMother();
53  Int_t n=r.getNumPoints();
54  createPoints(n);
55  for (Int_t i=0; i<nPoints; i++) { setPoint(i,*(r.getPoint(i))); }
57 }
58 
59 void FairGeoVolume::createPoints(const Int_t n)
60 {
61  // Creates n Points (objects of class FairGeoVector).
62  // If the array exists already and the size is different from n it is
63  // deleted and recreated with the new size n.
64  // If n==0 the points are deleted.
65  if (n!=nPoints) {
66  nPoints=n;
67  if (n>0) {
68  if (points!=0) {
69  points->Delete();
70  delete points;
71  }
72  points=new TObjArray(n);
73  for(Int_t i=0; i<n; i++) { points->AddAt(new FairGeoVector(),i); }
74  } else {
75  if (points) { points->Delete(); }
76  delete points;
77  points=0;
78  }
79  }
80 }
81 
82 void FairGeoVolume::setPoint(const Int_t n,const Double_t x,
83  const Double_t y,const Double_t z)
84 {
85  // set the 3 values of the point with index n
86  if (points && n<nPoints) {
88  v->setX(x);
89  v->setY(y);
90  v->setZ(z);
91  }
92 }
93 
94 void FairGeoVolume::setPoint(const Int_t n,const FairGeoVector& p)
95 {
96  // sets point with index n by copying the 3 components of point p
97  if (points && n<nPoints) {
98  FairGeoVector& v=*((FairGeoVector*)points->At(n));
99  v=p;
100  }
101 }
102 
104 {
105  // clears the volume
106  // deletes the points
107  shape="";
108  mother="";
109  if (points) { points->Delete(); }
110  delete points;
111  points=0;
112  nPoints=0;
113  transform.clear();
114 }
115 
117 {
118  // prints all parameters of a volume
119  cout<<"Volume: " <<((const char*)fName)<<" Shape: "<<((const char*)shape)<<" Mother: "
120  <<((const char*)mother)<<'\n';
121  cout << "Points definition " << endl;
122  if (points) {
123  for (Int_t i=0; i<nPoints; i++) {
124  cout<<(*((FairGeoVector*)points->At(i)));
125  }
126  }
127  cout << "Lab Transform " << endl;
129  cout<<'\n';
130 }
131 
132 Double_t FairGeoVolume::getVolParameter( Int_t nPoint, Int_t pos )
133 {
134  FairGeoVector* vec = (FairGeoVector*) points->At( nPoint );
135  if ( vec ) { return vec->getValues( pos ); }
136  else { return -1; }
137 }
138 
139 
141 {
142  if (points) {
143  points->Delete();
144  delete points;
145  points=0;
146  }
147 }
148