ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F04ElementField.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file F04ElementField.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
29 //
30 
31 #include "F04ElementField.hh"
32 
33 #include "F04GlobalField.hh"
34 
35 #include "G4SystemOfUnits.hh"
36 
37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
38 
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
44 {
45  fCenter = c;
46 
47  fMinX = fMinY = fMinZ = -DBL_MAX;
48  fMaxX = fMaxY = fMaxZ = DBL_MAX;
49 
51 
52  fColor = "1,1,1";
53 
54  fUserLimits = new G4UserLimits();
55 
56  fVolume = lv;
58 
59  fMaxStep = 1*mm;
60 
62 
66 // fUserLimits->SetUserMinRange(1*mm);
67 
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74 {
75  G4Navigator* theNavigator =
77  GetNavigatorForTracking();
78 
79  if (!fNavigator) {
80  fNavigator = new G4Navigator();
81  if ( theNavigator->GetWorldVolume() )
82  fNavigator->SetWorldVolume(theNavigator->GetWorldVolume());
83  }
84 
86 
88  CreateTouchableHistoryHandle();
89 
90  G4int depth = touchable->GetHistoryDepth();
91  for (G4int i = 0; i<depth; ++i) {
92  if(touchable->GetVolume()->GetLogicalVolume() == fVolume)break;
93  touchable->MoveUpHistory();
94  }
95 
96  // set fGlobal2local transform
97  fGlobal2local = touchable->GetHistory()->GetTopTransform();
98 
99  // set global bounding box
100  G4double local[4], global[4];
101 
102  G4ThreeVector globalPosition;
103  local[3] = 0.0;
104  for (int i=0; i<2; ++i) {
105  local[0] = (i==0 ? -1.0 : 1.0) * GetWidth()/2.;
106  for (int j=0; j<2; ++j) {
107  local[1] = (j==0 ? -1.0 : 1.0) * GetHeight()/2.;
108  for (int k=0; k<2; ++k) {
109  local[2] = (k==0 ? -1.0 : 1.0) * GetLength()/2.;
110  G4ThreeVector localPosition(local[0],local[1],local[2]);
111  globalPosition =
112  fGlobal2local.Inverse().TransformPoint(localPosition);
113  global[0] = globalPosition.x();
114  global[1] = globalPosition.y();
115  global[2] = globalPosition.z();
116  SetGlobalPoint(global);
117  }
118  }
119  }
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
125 {
126  G4VisAttributes* p = NULL;
127  if(color.size() > 0 &&
128  (isdigit(color.c_str()[0]) || color.c_str()[0] == '.')) {
129  G4double red=0.0, green=0.0, blue=0.0;
130  if (sscanf(color.c_str(),"%lf,%lf,%lf",&red,&green,&blue) == 3) {
131  p = new G4VisAttributes(true,G4Color(red,green,blue));
132  } else {
133  G4cout << " Invalid color " << color << G4endl;
134  }
135  }
136 
138  p->SetDaughtersInvisible(false);
139 
140  return p;
141 }