Geant4  10.01
F04ElementField.cc
Go to the documentation of this file.
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 // $Id: F04ElementField.cc 78551 2014-01-07 09:45:08Z gcosmo $
27 //
30 //
31 
32 #include "F04ElementField.hh"
33 
34 #include "F04GlobalField.hh"
35 
36 #include "G4SystemOfUnits.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39 
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
45 {
46  fCenter = c;
47 
48  fMinX = fMinY = fMinZ = -DBL_MAX;
49  fMaxX = fMaxY = fMaxZ = DBL_MAX;
50 
52 
53  fColor = "1,1,1";
54 
55  fUserLimits = new G4UserLimits();
56 
57  fVolume = lv;
59 
60  fMaxStep = 1*mm;
61 
63 
67 // fUserLimits->SetUserMinRange(1*mm);
68 
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 {
76  G4Navigator* theNavigator =
78  GetNavigatorForTracking();
79 
80  if (!fNavigator) {
81  fNavigator = new G4Navigator();
82  if ( theNavigator->GetWorldVolume() )
83  fNavigator->SetWorldVolume(theNavigator->GetWorldVolume());
84  }
85 
87 
89  CreateTouchableHistoryHandle();
90 
91  G4int depth = touchable->GetHistoryDepth();
92  for (G4int i = 0; i<depth; ++i) {
93  if(touchable->GetVolume()->GetLogicalVolume() == fVolume)break;
94  touchable->MoveUpHistory();
95  }
96 
97  // set fGlobal2local transform
98  fGlobal2local = touchable->GetHistory()->GetTopTransform();
99 
100  // set global bounding box
101  G4double local[4], global[4];
102 
103  G4ThreeVector globalPosition;
104  local[3] = 0.0;
105  for (int i=0; i<2; ++i) {
106  local[0] = (i==0 ? -1.0 : 1.0) * GetWidth()/2.;
107  for (int j=0; j<2; ++j) {
108  local[1] = (j==0 ? -1.0 : 1.0) * GetHeight()/2.;
109  for (int k=0; k<2; ++k) {
110  local[2] = (k==0 ? -1.0 : 1.0) * GetLength()/2.;
111  G4ThreeVector localPosition(local[0],local[1],local[2]);
112  globalPosition =
113  fGlobal2local.Inverse().TransformPoint(localPosition);
114  global[0] = globalPosition.x();
115  global[1] = globalPosition.y();
116  global[2] = globalPosition.z();
117  SetGlobalPoint(global);
118  }
119  }
120  }
121 }
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
124 
126 {
127  G4VisAttributes* p = NULL;
128  if(color.size() > 0 &&
129  (isdigit(color.c_str()[0]) || color.c_str()[0] == '.')) {
130  G4double red=0.0, green=0.0, blue=0.0;
131  if (sscanf(color.c_str(),"%lf,%lf,%lf",&red,&green,&blue) == 3) {
132  p = new G4VisAttributes(true,G4Color(red,green,blue));
133  } else {
134  G4cout << " Invalid color " << color << G4endl;
135  }
136  }
137 
139  p->SetDaughtersInvisible(false);
140 
141  return p;
142 }
static const double MeV
Definition: G4SIunits.hh:193
virtual void SetMaxAllowedStep(G4double ustepMax)
Definition: test07.cc:36
CLHEP::Hep3Vector G4ThreeVector
void SetGlobalPoint(const G4double point[4])
SetGlobalPoint() ensures that the point is within the global bounding box of this ElementField's glob...
G4AffineTransform Inverse() const
Definition of the F04GlobalField class.
F04ElementField(const G4ThreeVector, G4LogicalVolume *)
Constructor.
void SetUserLimits(G4UserLimits *pULimits)
virtual void SetUserMinEkine(G4double uekinMin)
static G4VisAttributes * GetVisAttribute(G4String color)
GetVisAttribute() returns the appropriate G4VisAttributes.
Definition of the F04ElementField class.
#define local
Definition: adler32.cc:10
#define G4ThreadLocal
Definition: tls.hh:84
Definition: test07.cc:36
int G4int
Definition: G4Types.hh:78
G4UserLimits * fUserLimits
virtual G4double GetLength()=0
G4ThreeVector fCenter
virtual void SetUserMaxTrackLength(G4double utrakMax)
static const double ms
Definition: G4SIunits.hh:151
static F04GlobalField * GetObject()
virtual G4double GetWidth()=0
G4GLOB_DLL std::ostream G4cout
G4Colour G4Color
Definition: G4Color.hh:42
static G4TransportationManager * GetTransportationManager()
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
virtual G4double GetHeight()=0
G4AffineTransform fGlobal2local
void SetWorldVolume(G4VPhysicalVolume *pWorld)
static const G4VisAttributes Invisible
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
Definition: G4Navigator.cc:122
#define G4endl
Definition: G4ios.hh:61
static const double m
Definition: G4SIunits.hh:110
G4LogicalVolume * fVolume
double G4double
Definition: G4Types.hh:76
void Construct()
the actual implementation constructs the F04ElementField
#define DBL_MAX
Definition: templates.hh:83
static G4ThreadLocal G4Navigator * fNavigator
static const double mm
Definition: G4SIunits.hh:102
void SetDaughtersInvisible(G4bool)
G4VPhysicalVolume * GetWorldVolume() const
void AddElementField(F04ElementField *f)
AddElementField() adds the ElementField object for a single element to the global field...
virtual void SetUserMaxTime(G4double utimeMax)
void SetVisAttributes(const G4VisAttributes *pVA)