VMC Examples Version 6.6
Loading...
Searching...
No Matches
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"
25
26/// \cond CLASSIMP
28 /// \endcond
29
30 //_____________________________________________________________________________
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//_____________________________________________________________________________
44
45//
46// public methods
47//
48
49//_____________________________________________________________________________
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
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}
Definition of the A01LocalMagField class.
Definition of the A01RootDetectorConstruction class.
Definition of a uniform magnetic field within a given region.
The detector construction (via TGeo )
TString fGeometryFileName
The root geometry file name.
Bool_t fUseLocalMagField
Option to use local magnetic field (working only with Geant4 !)