VMC Examples
Version 6.8
Toggle main menu visibility
Loading...
Searching...
No Matches
examples
A01
src
A01RootDetectorConstruction.cxx
Go to the documentation of this file.
1
//------------------------------------------------
2
// The Virtual Monte Carlo examples
3
// Copyright (C) 2007 - 2014 Ivana Hrivnacova
4
// All rights reserved.
5
//
6
// For the licensing terms see geant4_vmc/LICENSE.
7
// Contact: root-vmc@cern.ch
8
//-------------------------------------------------
9
10
/// \file A01RootDetectorConstruction.cxx
11
/// \brief Implementation of the A01RootDetectorConstruction class
12
///
13
/// Geant4 ExampleA01 adapted to Virtual Monte Carlo \n
14
///
15
/// \date 12/05/2012
16
/// \author I. Hrivnacova; IPN, Orsay
17
18
#include <Riostream.h>
19
#include <TGeoManager.h>
20
#include <TList.h>
21
#include <TVirtualMC.h>
22
23
#include "
A01LocalMagField.h
"
24
#include "
A01RootDetectorConstruction.h
"
25
26
/// \cond CLASSIMP
27
ClassImp(
A01RootDetectorConstruction
)
28
/// \endcond
29
30
//_____________________________________________________________________________
31
A01RootDetectorConstruction
::
A01RootDetectorConstruction
(
32
const TString& geometryFileName)
33
:
TObject
(),
fGeometryFileName
(geometryFileName),
fUseLocalMagField
(false)
34
{
35
/// Standard constuctor
36
/// \param geometryFileName The root geometry file name
37
}
38
39
//_____________________________________________________________________________
40
A01RootDetectorConstruction::~A01RootDetectorConstruction
()
41
{
42
/// Destructor
43
}
44
45
//
46
// public methods
47
//
48
49
//_____________________________________________________________________________
50
void
A01RootDetectorConstruction::ConstructGeometry
()
51
{
52
/// Contruct volumes using TGeo modeller
53
54
TGeoManager::Import(
fGeometryFileName
.Data());
55
56
// Update media parameters (needed for Geant3)
57
TList* media = gGeoManager->GetListOfMedia();
58
TIter next(media);
59
while
(
TObject
* obj = next()) {
60
TGeoMedium* medium = (TGeoMedium*)obj;
61
medium->SetParam(1, 2);
// ifield - User defined magnetic field
62
medium->SetParam(2, 10);
// fieldm - Maximum field value (in kiloGauss)
63
medium->SetParam(6, .001);
// epsil - Tracking precision
64
}
65
66
// Create local magnetic field
67
if
(
fUseLocalMagField
) {
68
// Constant magnetic field (in kiloGauss)
69
// field value: 1.0*tesla (= 10.0 kiloGauss) in y
70
TVirtualMagField
* magField =
new
A01LocalMagField
(0, 10.0, 0);
71
72
// set the field to "magneticLogical" volume
73
TGeoVolume* magneticVolume = gGeoManager->FindVolumeFast(
"magneticLogical"
);
74
if
(magneticVolume) {
75
magneticVolume->SetField(magField);
76
}
77
else
{
78
std::cerr <<
"The Tube volume was not found in geometry."
<< std::endl;
79
std::cerr <<
"Local magnetic field has not been set."
<< std::endl;
80
delete
magField;
81
}
82
}
83
// notify VMC about Root geometry
84
gMC->SetRootGeometry();
85
}
A01LocalMagField.h
Definition of the A01LocalMagField class.
A01RootDetectorConstruction.h
Definition of the A01RootDetectorConstruction class.
A01LocalMagField
Definition of a uniform magnetic field within a given region.
Definition
A01LocalMagField.h:30
A01RootDetectorConstruction
The detector construction (via TGeo ).
Definition
A01RootDetectorConstruction.h:30
A01RootDetectorConstruction::ConstructGeometry
void ConstructGeometry()
Definition
A01RootDetectorConstruction.cxx:50
A01RootDetectorConstruction::~A01RootDetectorConstruction
virtual ~A01RootDetectorConstruction()
Definition
A01RootDetectorConstruction.cxx:40
A01RootDetectorConstruction::A01RootDetectorConstruction
A01RootDetectorConstruction(const TString &geometryFileName)
Definition
A01RootDetectorConstruction.cxx:31
A01RootDetectorConstruction::fGeometryFileName
TString fGeometryFileName
The root geometry file name.
Definition
A01RootDetectorConstruction.h:43
A01RootDetectorConstruction::fUseLocalMagField
Bool_t fUseLocalMagField
Option to use local magnetic field (working only with Geant4 !).
Definition
A01RootDetectorConstruction.h:46
TObject
TVirtualMagField
Generated on
for VMC Examples by
1.17.0