EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Magnet.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Magnet.cxx
1 
2 //_____________________________________________________________________________
3 //
4 // spectrometer dipole magnet
5 //
6 //_____________________________________________________________________________
7 
8 //local headers
9 #include "Magnet.h"
10 
11 //Geant headers
12 #include <Geant4/G4LogicalVolume.hh>
13 #include <Geant4/G4NistManager.hh>
14 #include <Geant4/G4Box.hh>
15 #include <Geant4/G4SystemOfUnits.hh>
16 #include <Geant4/G4PVPlacement.hh>
17 #include <Geant4/G4FieldManager.hh>
18 #include <Geant4/G4UniformMagField.hh>
19 #include <Geant4/G4VisAttributes.hh>
20 
21 
22 //_____________________________________________________________________________
23 Magnet::Magnet(G4double zpos, G4LogicalVolume *top) {
24 
25  G4Material *mat = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
26 
27  //magnet shape
28  G4double dz = 60.*cm;
29  G4double xysiz = 10*cm;
30 
31  G4String nam = "Magnet";
32  G4Box *mshape = new G4Box(nam, xysiz, xysiz, dz/2.);
33  G4LogicalVolume *mvol = new G4LogicalVolume(mshape, mat, nam);
34 
35  G4VisAttributes *vis = new G4VisAttributes();
36  //vis->SetColor(1, 1, 0); // yellow
37  vis->SetColor(1, 0, 1); // magenta
38  //vis->SetLineWidth(2);
39  mvol->SetVisAttributes(vis);
40 
41  //maginetic field
42  G4UniformMagField *field = new G4UniformMagField(G4ThreeVector(0.5*tesla, 0, 0));
43  G4FieldManager *fman = new G4FieldManager();
44  fman->SetDetectorField(field);
45  fman->CreateChordFinder(field);
46 
47  mvol->SetFieldManager(fman, true);
48 
49  new G4PVPlacement(0, G4ThreeVector(0, 0, zpos-dz/2.), mvol, nam, top, false, 0);
50 
51 }//Magnet
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76