Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions
CCalRotationMatrixFactory Class Reference

#include <CCalRotationMatrixFactory.hh>

Public Member Functions

 ~CCalRotationMatrixFactory ()
 
G4RotationMatrixfindMatrix (const G4String &)
 
G4RotationMatrixAddMatrix (const G4String &name, G4double th1, G4double phi1, G4double th2, G4double phi2, G4double th3, G4double phi3)
 

Static Public Member Functions

static CCalRotationMatrixFactorygetInstance ()
 
static CCalRotationMatrixFactorygetInstance (const G4String &rotfile)
 
static void setFileName (const G4String &rotfile)
 

Detailed Description

Definition at line 45 of file CCalRotationMatrixFactory.hh.

Constructor & Destructor Documentation

CCalRotationMatrixFactory::~CCalRotationMatrixFactory ( )

Definition at line 84 of file CCalRotationMatrixFactory.cc.

84  {
86  for(i=theMatrices.begin(); i != theMatrices.end(); ++i) {
87  delete (*i).second;
88  };
89  theMatrices.clear();
90 }
std::map< G4String, G4RotationMatrixPtr, std::less< G4String > >::iterator G4RotationMatrixTableIterator

Member Function Documentation

G4RotationMatrix * CCalRotationMatrixFactory::AddMatrix ( const G4String name,
G4double  th1,
G4double  phi1,
G4double  th2,
G4double  phi2,
G4double  th3,
G4double  phi3 
)

Definition at line 105 of file CCalRotationMatrixFactory.cc.

References python.hepunit::deg, G4cout, G4endl, CLHEP::HepRotation::invert(), and CLHEP::HepRotation::rotateAxes().

Referenced by CCalG4Ecal::constructIn().

111  {
112  G4double sinth1, sinth2, sinth3, costh1, costh2, costh3;
113  G4double sinph1, sinph2, sinph3, cosph1, cosph2, cosph3;
114  G4double TH1 = th1/deg, TH2 = th2/deg, TH3 = th3/deg;
115  G4double PH1 = phi1/deg, PH2 = phi2/deg, PH3 = phi3/deg;
116 
117  if (TH1 == 0.0 || TH1 == 360) {
118  sinth1 = 0.0; costh1 = 1.0;
119  } else if (TH1 == 90.0 || TH1 == -270) {
120  sinth1 = 1.0; costh1 = 0.0;
121  } else if (TH1 == 180.0 || TH1 == -180.0) {
122  sinth1 = 0.0; costh1 = -1.0;
123  } else if (TH1 == 270.0 || TH1 == -90.0) {
124  sinth1 = -1.0; costh1 = 0.0;
125  } else {
126  sinth1 = std::sin(th1); costh1 = std::cos(th1);
127  }
128 
129  if (TH2 == 0.0 || TH2 == 360) {
130  sinth2 = 0.0; costh2 = 1.0;
131  } else if (TH2 == 90.0 || TH2 == -270) {
132  sinth2 = 1.0; costh2 = 0.0;
133  } else if (TH2 == 180.0 || TH2 == -180.0) {
134  sinth2 = 0.0; costh2 = -1.0;
135  } else if (TH2 == 270.0 || TH2 == -90.0) {
136  sinth2 = -1.0; costh2 = 0.0;
137  } else {
138  sinth2 = std::sin(th2); costh2 = std::cos(th2);
139  }
140 
141  if (TH3 == 0.0 || TH3 == 360) {
142  sinth3 = 0.0; costh3 = 1.0;
143  } else if (TH3 == 90.0 || TH2 == -270) {
144  sinth3 = 1.0; costh3 = 0.0;
145  } else if (TH3 == 180.0 || TH3 == -180.0) {
146  sinth3 = 0.0; costh3 = -1.0;
147  } else if (TH3 == 270.0 || TH3 == -90.0) {
148  sinth3 = -1.0; costh3 = 0.0;
149  } else {
150  sinth3 = std::sin(th3); costh3 = std::cos(th3);
151  }
152 
153  if (PH1 == 0.0 || PH1 == 360) {
154  sinph1 = 0.0; cosph1 = 1.0;
155  } else if (PH1 == 90.0 || PH1 == -270) {
156  sinph1 = 1.0; cosph1 = 0.0;
157  } else if (PH1 == 180.0 || PH1 == -180.0) {
158  sinph1 = 0.0; cosph1 = -1.0;
159  } else if (PH1 == 270.0 || PH1 == -90.0) {
160  sinph1 = -1.0; cosph1 = 0.0;
161  } else {
162  sinph1 = std::sin(phi1); cosph1 = std::cos(phi1);
163  }
164 
165  if (PH2 == 0.0 || PH2 == 360) {
166  sinph2 = 0.0; cosph2 = 1.0;
167  } else if (PH2 == 90.0 || PH2 == -270) {
168  sinph2 = 1.0; cosph2 = 0.0;
169  } else if (PH2 == 180.0 || PH2 == -180.0) {
170  sinph2 = 0.0; cosph2 = -1.0;
171  } else if (PH2 == 270.0 || PH2 == -90.0) {
172  sinph2 = -1.0; cosph2 = 0.0;
173  } else {
174  sinph2 = std::sin(phi2); cosph2 = std::cos(phi2);
175  }
176 
177  if (PH3 == 0.0 || PH3 == 360) {
178  sinph3 = 0.0; cosph3 = 1.0;
179  } else if (PH3 == 90.0 || PH3 == -270) {
180  sinph3 = 1.0; cosph3 = 0.0;
181  } else if (PH3 == 180.0 || PH3 == -180.0) {
182  sinph3 = 0.0; cosph3 = -1.0;
183  } else if (PH3 == 270.0 || PH3 == -90.0) {
184  sinph3 = -1.0; cosph3 = 0.0;
185  } else {
186  sinph3 = std::sin(phi3); cosph3 = std::cos(phi3);
187  }
188 
189  //xprime axis coordinates
190  CLHEP::Hep3Vector xprime(sinth1*cosph1,sinth1*sinph1,costh1);
191  //yprime axis coordinates
192  CLHEP::Hep3Vector yprime(sinth2*cosph2,sinth2*sinph2,costh2);
193  //zprime axis coordinates
194  CLHEP::Hep3Vector zprime(sinth3*cosph3,sinth3*sinph3,costh3);
195 
196 #ifdef ddebug
197  G4cout << xprime << '\t'; G4cout << yprime << '\t'; G4cout << zprime << G4endl;
198 #endif
199  G4RotationMatrix *rotMat = new G4RotationMatrix();
200  rotMat->rotateAxes(xprime, yprime, zprime);
201  if (*rotMat == G4RotationMatrix()) {
202  // G4cerr << "WARNING: Matrix " << name << " will not be created as a rotation matrix."
203  // G4cerr << "WARNING: Matrix " << name << " is = identity matrix. It will not be created as a rotation matrix." << G4endl;
204  delete rotMat;
205  rotMat=0;
206  } else {
207  rotMat->invert();
208  theMatrices[name]=rotMat;
209 #ifdef ddebug
210  G4cout << *rotMat << G4endl;
211 #endif
212  }
213 
214  return rotMat;
215 }
CLHEP::HepRotation G4RotationMatrix
HepRotation & rotateAxes(const Hep3Vector &newX, const Hep3Vector &newY, const Hep3Vector &newZ)
Definition: Rotation.cc:105
const XML_Char * name
HepRotation & invert()
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4RotationMatrix * CCalRotationMatrixFactory::findMatrix ( const G4String rot)

!!Maybe a treatment on not-found case needed.

Definition at line 92 of file CCalRotationMatrixFactory.cc.

Referenced by CCalG4Ecal::constructIn().

92  {
93  G4RotationMatrix* retrot=0;
94  //Rotation :NULL is no rotation so a null pointer is returned
95  if (rot != ":NULL") {
96  //retrot untouched if rot not found!!!
97  G4RotationMatrixTableIterator it = theMatrices.find(rot);
98  if (it != theMatrices.end())
99  retrot = (*it).second;
100  }
101 
102  return retrot; //!!!Maybe a treatment on not-found case needed.
103 }
std::map< G4String, G4RotationMatrixPtr, std::less< G4String > >::iterator G4RotationMatrixTableIterator
CCalRotationMatrixFactory * CCalRotationMatrixFactory::getInstance ( )
static

Definition at line 60 of file CCalRotationMatrixFactory.cc.

References G4cerr, and G4endl.

Referenced by CCalDetectorConstruction::Construct(), CCalG4Ecal::constructIn(), and getInstance().

60  {
61  if (file=="") {
62  G4cerr << "ERROR: You haven't defined which file to use for materials in "
63  << "CCalRotationMatrixFactory::getInstance(G4String)" << G4endl;
64  return 0;
65  }
66 
67  if (instance==0) {
68  instance = new CCalRotationMatrixFactory;
69  return instance;
70  }
71  else
72  return instance;
73 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
CCalRotationMatrixFactory * CCalRotationMatrixFactory::getInstance ( const G4String rotfile)
static

Definition at line 46 of file CCalRotationMatrixFactory.cc.

References G4cerr, G4endl, and getInstance().

46  {
47  if (rotfile=="" || rotfile==file)
48  return getInstance();
49  else if (file="") {
50  file=rotfile;
51  return getInstance();
52  } else {
53  G4cerr << "ERROR: Trying to get Rotation Matrices from " << rotfile
54  << " when previously were retrieved from " << file <<"." << G4endl;
55  return 0;
56  }
57 }
static CCalRotationMatrixFactory * getInstance()
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
void CCalRotationMatrixFactory::setFileName ( const G4String rotfile)
static

Definition at line 75 of file CCalRotationMatrixFactory.cc.

References G4cerr, and G4endl.

75  {
76  if (rotfile!=file && file!="") {
77  G4cerr << "ERROR: Trying to change Rotation Matrices file name to "
78  << rotfile << "." << G4endl;
79  G4cerr << " Using previous file: " << file << G4endl;
80  }
81  file=rotfile;
82 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

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