FairRoot/PandaRoot
PndEmcXtal.cxx
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // File and Version Information:
3 // $Id:$
4 //
5 // Description:
6 // Class PndEmcXtal
7 //
8 // Software developed for the BaBar Detector at the SLAC B-Factory.
9 // Adapted for the PANDA experiment at GSI
10 //
11 // Author List:
12 // Gautier Hamel de Monchenault - CEN Saclay & Lawrence Berkeley Lab
13 // Stephen J. Gowdy University of Edinburgh
14 // Dima Melnichuk - adaption for PANDA
15 //
16 // Copyright Information:
17 // Copyright (C) 1996 Lawrence Berkeley Laboratory
18 // Copyright (C) 1996 CEA - Centre d'Etude de Saclay
19 // Copyright (C) 1997 University of Edinburgh
20 //------------------------------------------------------------------------
21 #include "TObject.h"
22 #include "PndEmcXtal.h"
23 #include "PndEmcTwoCoordIndex.h"
24 #include "TGeoArb8.h"
25 #include "TVector3.h"
26 #include "TRotation.h"
27 #include "TGeoMatrix.h"
28 #include "TMath.h"
29 
30 //#include <vector>
31 #include <iostream>
32 #include <fstream>
33 #include <iomanip>
34 
35 using namespace std;
36 
37 //----------------
38 // Constructors --
39 //----------------
41  fTCIIndex(new PndEmcTwoCoordIndex()),
42  fLength(0),
43  fTrap(TGeoTrap()),
44  fRotation(TGeoRotation()),
45  fCentre(0,0,0),
46  fFrontCentre(0,0,0),
47  fNormalToFrontFace(0,0,0),
48  fAxis(0,0,0)
49 {
50 }
51 PndEmcXtal::PndEmcXtal(const PndEmcTwoCoordIndex *id, const TGeoTrap &trap, const TVector3 &pos, const TGeoRotation &rot):
52  fTCIIndex(id),
53  fLength(0),
54  fTrap(trap),
55  fRotation(rot),
56  fCentre(pos),
57  fFrontCentre(0,0,0),
58  fNormalToFrontFace(0,0,0),
59  fAxis(0,0,0)
60 {
61  // calculate length of the crystal
62  fLength=trap.GetDz()*2;
63 
64  // Obtain vector to trapezoid front face center.
65 
66  Double_t tx = TMath::Tan(trap.GetTheta() * TMath::DegToRad())
67  * TMath::Cos(trap.GetPhi() * TMath::DegToRad());
68  Double_t ty = TMath::Tan(trap.GetTheta() * TMath::DegToRad())
69  * TMath::Sin(trap.GetPhi() * TMath::DegToRad());
70 
71  Double_t axis[3] = { trap.GetDz() * tx, trap.GetDz() * ty, trap.GetDz() };
72  Double_t axis_rotated[3]; rot.LocalToMaster(axis, axis_rotated);
73  TVector3 axis_vector(axis_rotated);
74 
75  // Obtain unitary vector normal to trapezoid front face.
76 
77  Double_t normal[3] = { 0.0, 0.0, 1.0 };
78  Double_t normal_rotated[3]; rot.LocalToMaster(normal, normal_rotated);
79  TVector3 normal_vector(normal_rotated);
80 
81  if (pos.Dot(axis_vector) < 0.0) {
82  //cout << "Crystal orientation in module " << id->Index() / 100000000
83  // << " +dz" << endl;
84 
85  fFrontCentre = pos + axis_vector;
86  fNormalToFrontFace = -1.0 * normal_vector;
87  fAxis = -1.0 * axis_vector.Unit();
88  } else {
89  //cout << "Crystal orientation in module " << id->Index() / 100000000
90  // << " -dz" << endl;
91 
92  fFrontCentre = pos - axis_vector;
93  fNormalToFrontFace = +1.0 * normal_vector;
94  fAxis = +1.0 * axis_vector.Unit();
95  }
96 }
97 
98 //--------------
99 // Destructor --
100 //--------------
101 
103 {
104 }
105 
106 
107 // ----------------------------------------
108 // -- Public Function Member Definitions --
109 // ----------------------------------------
110 
111 bool
112 PndEmcXtal::operator==( const PndEmcXtal& compare ) const
113 {
114  bool answer = false;
115 
116  if ( *fTCIIndex == *compare.fTCIIndex ) answer=true;
117 
118  return answer;
119 }
120 
121 bool
122 PndEmcXtal::operator<( const PndEmcXtal& compare ) const
123 {
124  bool answer = false;
125 
126  if ( *fTCIIndex < *compare.fTCIIndex ) answer=true;
127  else if ( *fTCIIndex == *compare.fTCIIndex && fLength < compare.fLength) answer=true;
128 
129  return answer;
130 }
131 
132 const PndEmcTwoCoordIndex*
134 {
135  return fTCIIndex;
136 }
137 
138 const TVector3&
140 {
141  return fCentre;
142 }
143 
144 const TVector3&
146 {
147  return fFrontCentre;
148 }
149 
150 const TVector3&
152 {
153  return fNormalToFrontFace;
154 }
155 
156 const TVector3&
158 {
159  return fAxis;
160 }
161 
162 const TGeoTrap&
164 {
165  return fTrap;
166 }
167 
168 const TGeoRotation&
170 {
171  return fRotation;
172 }
173 
174 double
176 {
177  return fNormalToFrontFace.Theta()-fCentre.Theta();
178 }
179 
TVector3 pos
TVector3 fAxis
Definition: PndEmcXtal.h:71
const TGeoTrap & geometry() const
Definition: PndEmcXtal.cxx:163
TVector3 fCentre
Definition: PndEmcXtal.h:68
const PndEmcTwoCoordIndex * myIndex() const
Definition: PndEmcXtal.cxx:133
static T Sin(const T &x)
Definition: PndCAMath.h:42
const TVector3 & frontCentre() const
Definition: PndEmcXtal.cxx:145
represents coordinates of one crystal
Definition: PndEmcXtal.h:36
float Tan(float x)
Definition: PndCAMath.h:165
stores crystal index coordinates (x,y) or (theta,phi)
const PndEmcTwoCoordIndex * fTCIIndex
Definition: PndEmcXtal.h:64
double fLength
Definition: PndEmcXtal.h:65
static T Cos(const T &x)
Definition: PndCAMath.h:43
virtual bool operator<(const PndEmcXtal &compare) const
Definition: PndEmcXtal.cxx:122
const TVector3 & axisVector() const
Definition: PndEmcXtal.cxx:157
double npAngle() const
Definition: PndEmcXtal.cxx:175
const TVector3 & normalToFrontFace() const
Definition: PndEmcXtal.cxx:151
const TGeoTrap fTrap
Definition: PndEmcXtal.h:66
Double_t
virtual ~PndEmcXtal()
Definition: PndEmcXtal.cxx:102
axis
Definition: PndRadMapPlane.h:9
const TGeoRotation & rotation() const
Definition: PndEmcXtal.cxx:169
TVector3 fNormalToFrontFace
Definition: PndEmcXtal.h:70
ClassImp(PndAnaContFact)
TGeoRotation rot
const TVector3 & centre() const
Definition: PndEmcXtal.cxx:139
TVector3 fFrontCentre
Definition: PndEmcXtal.h:69
const TGeoRotation fRotation
Definition: PndEmcXtal.h:67
virtual bool operator==(const PndEmcXtal &compare) const
Definition: PndEmcXtal.cxx:112