Geant4  10.01.p02
F04SimpleSolenoid.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: F04SimpleSolenoid.cc 68021 2013-03-13 13:36:07Z gcosmo $
27 //
30 //
31 
32 #include "globals.hh"
33 
34 #include "G4GeometryManager.hh"
35 
36 #include "F04GlobalField.hh"
37 
38 #include "F04SimpleSolenoid.hh"
39 
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41 
43  G4LogicalVolume* lv,
45 {
46  fBfield = Bz;
47  fFringeZ = fz;
48 
49  fFieldLength = 2.*((G4Tubs*)fVolume->GetSolid())->GetZHalfLength()+fFringeZ;
50  fFieldRadius = ((G4Tubs*)fVolume->GetSolid())->GetOuterRadius();
51 }
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56  G4double field[6]) const
57 {
58  G4ThreeVector global(point[0],point[1],point[2]);
60 
61  local = fGlobal2local.TransformPoint(global);
62 
63  if (IsOutside(local)) return;
64 
65  G4ThreeVector B(0.0,0.0,fBfield);
66 
68 
69  field[0] += B[0];
70  field[1] += B[1];
71  field[2] += B[2];
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
77 {
78 // EInside inside = tubs->Inside(local);
79 // return (inside == kOutside);
80  G4double r = std::sqrt(local.x()*local.x()+local.y()*local.y());
81  return (r > fFieldRadius || std::fabs(local.z()) > fFieldLength/2.0);
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
88 // EInside inside = tubs->Inside(local);
89 // return (inside == kInside);
90  G4double r = std::sqrt(local.x()*local.x()+local.y()*local.y());
91  return (r < fFieldRadius && std::fabs(local.z()) < fFieldLength/2.0);
92 }
G4bool IsOutside(G4ThreeVector &local) const
IsOutside() returns true when outside the solenoid.
CLHEP::Hep3Vector G4ThreeVector
G4AffineTransform Inverse() const
Definition of the F04GlobalField class.
Definition: G4Tubs.hh:85
#define local
Definition: adler32.cc:10
F04SimpleSolenoid(G4double, G4double, G4LogicalVolume *, G4ThreeVector)
Default constructor.
G4bool IsWithin(G4ThreeVector &local) const
IsWithin() returns true when inside the solenoid.
bool G4bool
Definition: G4Types.hh:79
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4AffineTransform fGlobal2local
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
Definition of the F04SimpleSolenoid class.
G4LogicalVolume * fVolume
double G4double
Definition: G4Types.hh:76
G4VSolid * GetSolid() const
virtual void AddFieldValue(const G4double point[4], G4double field[6]) const
AddFieldValue() adds the field for this solenoid into field[]. point[] is in global coordinates...