Import Geant4 9.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:16:48 +02:00
parent 75c7fd177d
commit a8e9364cea
6592 changed files with 84274 additions and 69292 deletions
@@ -0,0 +1,30 @@
# $Id: GNUmakefile,v 1.1 2007/05/28 08:31:53 gcosmo Exp $
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := errprop
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
.PHONY: all
all: lib bin
ifdef G4ANALYSIS_USE
CPPFLAGS += -DG4ANALYSIS_USE
endif
include $(G4INSTALL)/config/architecture.gmk
ifdef G4ANALYSIS_USE
# for the aida-config command see the README file
CPPFLAGS += `aida-config --include`
LOADLIBS += `aida-config --lib`
endif
include $(G4INSTALL)/config/binmake.gmk
@@ -0,0 +1,23 @@
$Id: History,v 1.2 2007/05/28 13:24:26 arce Exp $
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
May 28, 2007 G.Cosmo
- Created.
May 28, 2007 P.Arce
- First version
+33
View File
@@ -0,0 +1,33 @@
This is an example illustrating the use of the error propagation utility.
A G4ErrorFreeTrajState is created to simulate a muon track of 20 GeV along the X axis. Then the track is propagated until the target is reached.
The geometry is a simplified typical HEP detector:
An air beamline ( BEAM )
An air central detector ( CDET )
A copper calorimeter, divided in four ( ECAL )
An aluminium calorimeter, divided in ten ( HCAL )
An air muon detector ( MUON )
It is inmersed in a magnetic field along the Z axis with default value -1 kilogauss. This value can be changed with the command "/exerror/setField.
The type of target can be chosen with the enviromental variable G4ERROR_TARGET:
PLANE_SURFACE : use a G4ErrorPlaneSurfaceTarget perpendicular to X at (2241. mm, 0, 0)
CYL_SURFACE : use a G4ErrorCylSurfaceTarget parallel to Z of radius 2220 mm
VOLUME : use a G4ErrorGeomVolumeTarget with volume name "MUON"
TRKLEN : use a G4ErrorTrackLengthTarget with track length 2230 mm
The user may also choose if the propagation is done forwards (the natural way, loosing energy) or backwards (in opposite direction, gaining energy), with the enviromental variable G4ERROR_MODE:
FORWARDS : propagate in the forward direction
BACKWARDS : propagate in the backward direction
There are also two modes of propagation, that can be chosen with the enviromental variable G4ERROR_PROP
UNTIL_TARGET : propagate until target, all steps in one go
STEP_BY_STEP propagate until target, returning control to the user at each step
@@ -0,0 +1,232 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// ------------------------------------------------------------
// GEANT 4 example main
// ------------------------------------------------------------
//
// History:
// - Created: P. Arce May 2007
//
#include "ExErrorDetectorConstruction.hh"
#include "G4SteppingVerbose.hh"
#include "G4ErrorPropagator.hh"
#include "G4ErrorPropagatorData.hh"
#include "G4ErrorPropagatorManager.hh"
#include "G4ErrorPlaneSurfaceTarget.hh"
#include "G4ErrorCylSurfaceTarget.hh"
#include "G4ErrorGeomVolumeTarget.hh"
#include "G4ErrorTrackLengthTarget.hh"
#include "G4ErrorFreeTrajState.hh"
#include "G4UImanager.hh"
void Initialize();
G4ErrorTarget* BuildTarget( G4int iTarget );
void ProcessEvent( G4int iProp, uint nEv );
void Finalize();
G4ErrorTarget* theTarget;
G4ErrorMode theG4ErrorMode;
//-------------------------------------------------------------
int main()
{
Initialize();
//----- Choose propagation mode
// 0: propagate until target, all steps in one go
// 1: propagate until target, returning control to the user at each step
G4int iProp = 0;
char* prop = getenv("G4ERROR_PROP");
if( prop ) {
if( G4String(prop) == G4String("UNTIL_TARGET") ){
iProp = 0;
} else if ( G4String(prop) == G4String("STEP_BY_STEP") ) {
iProp = 1;
} else {
G4Exception("exG4eReco","Fatal error in Argument",FatalErrorInArgument,G4String("Variable G4ERROR_PROP = " + G4String(prop) + " It must be: UNTIL_TARGET or STEP_BY_STEP").c_str());
}
} else {
G4Exception("exG4eReco","Fatal error in Argument",JustWarning,"Variable G4ERROR_PROP not defined, taking it = UNTIL_TARGET");
}
uint nEvents = 3;
for( uint ii = 0; ii < nEvents; ii++ ){
ProcessEvent( iProp, ii );
}
Finalize();
}
//-------------------------------------------------------------
void Initialize()
{
G4VSteppingVerbose::SetInstance(new G4SteppingVerbose);
// Initialize the GEANT4e manager
G4ErrorPropagatorManager* g4emgr = G4ErrorPropagatorManager::GetErrorPropagatorManager();
G4ErrorPropagatorData* g4edata = G4ErrorPropagatorData::GetErrorPropagatorData();
g4emgr->SetUserInitialization(new ExErrorDetectorConstruction);
G4UImanager::GetUIpointer()->ApplyCommand("/exerror/setField -10. kilogauss");
g4emgr->InitGeant4e();
G4UImanager::GetUIpointer()->ApplyCommand("/control/verbose 1");
G4UImanager::GetUIpointer()->ApplyCommand("/tracking/verbose 1");
G4UImanager::GetUIpointer()->ApplyCommand("/geant4e/limits/stepLength 100 mm");
//----- Choose target type:
// 1: PlaneSurfaceTarget
// 2: CylSurfaceTarget
// 3: GeomVolumeTarget
// 4: TrackLengthTarget
G4int iTarget = 1;
char* target = getenv("G4ERROR_TARGET");
if( target ) {
if( G4String(target) == G4String("PLANE_SURFACE") ) {
iTarget = 1;
}else if( G4String(target) == G4String("CYL_SURFACE") ) {
iTarget = 2;
}else if( G4String(target) == G4String("VOLUME") ) {
iTarget = 3;
}else if( G4String(target) == G4String("TRKLEN") ) {
iTarget = 4;
}else {
G4Exception("exG4eReco","Fatal error in Argument",FatalErrorInArgument,G4String("Variable G4ERROR_TARGET = " + G4String(target) + " It must be: PLANE_SURFACE, CYL_SURFACE, VOLUME, TRKLEN").c_str());
}
} else {
G4Exception("exG4eReco","Fatal error in Argument",JustWarning,"Variable G4ERROR_TARGET not defined, taking it = PLANE_SURFACE");
}
theTarget = BuildTarget( iTarget );
g4edata->SetTarget( theTarget );
theG4ErrorMode = G4ErrorMode_PropBackwards;
char* mode = getenv("G4ERROR_MODE");
if( mode ) {
if( G4String(mode) == G4String("FORWARDS") ) {
theG4ErrorMode = G4ErrorMode_PropForwards;
} else if( G4String(mode) == G4String("BACKWARDS") ) {
theG4ErrorMode = G4ErrorMode_PropBackwards;
} else {
G4Exception("exG4eReco","Fatal error in Argument",FatalErrorInArgument,G4String("Variable G4ERROR_MODE = " + G4String(mode) + " It must be: FORWARDS or BACKWARDS").c_str());
}
} else {
G4Exception("exG4eReco","Fatal error in Argument",JustWarning,"Variable G4ERROR_MODE not defined, taking it = BACKWARDS");
}
}
void ProcessEvent( G4int iProp, uint )
{
// Set the starting trajectory.
G4ThreeVector xv3( 0, 0, 0 );
G4ThreeVector pv3( 20.0*GeV, 0.0, 0.0 );
G4ErrorTrajErr error( 5, 0 );
G4ErrorFreeTrajState* theG4ErrorTrajState = new G4ErrorFreeTrajState( "mu-", xv3, pv3, error );
G4ErrorPropagatorManager* g4emgr = G4ErrorPropagatorManager::GetErrorPropagatorManager();
int ierr = 0;
G4Point3D surfPos(224.*cm,0.,0.);
G4Normal3D surfNorm(1.,0.,0.);
//- G4ErrorTarget* theG4ErrorTarget = new G4ErrorPlaneSurfaceTarget(surfNorm, surfPos );
if( iProp == 0){
// Propagate until G4ErrorTarget is found all in one go
ierr = g4emgr->Propagate( theG4ErrorTrajState, theTarget, theG4ErrorMode );
} else if( iProp == 1){
// Propagate until G4ErrorTarget is reached step by step
g4emgr->InitTrackPropagation();
// G4Track* aTrack = G4EventManager::GetEventManager()->GetTrackingManager()->GetTrack();
bool moreEvt = TRUE;
while( moreEvt ){
ierr = g4emgr->PropagateOneStep( theG4ErrorTrajState, theG4ErrorMode );
//---- Check if target is reached
if( g4emgr->GetPropagator()->CheckIfLastStep( theG4ErrorTrajState->GetG4Track() )) {
g4emgr->GetPropagator()->InvokePostUserTrackingAction( theG4ErrorTrajState->GetG4Track() );
moreEvt = 0;
G4cout << "STEP_BY_STEP propagation: Last Step " << G4endl;
}
}
}
G4cout << " $$$ PROPAGATION ENDED " << G4endl;
// extract current state info
G4Point3D posEnd = theG4ErrorTrajState->GetPosition();
G4Normal3D momEnd = theG4ErrorTrajState->GetMomentum();
G4ErrorTrajErr errorEnd = theG4ErrorTrajState->GetError();
G4cout << " Position: " << posEnd << G4endl
<< " Momentum: " << momEnd << G4endl
<< " Error: " << errorEnd << G4endl;
}
//-------------------------------------------------------------
G4ErrorTarget* BuildTarget( G4int iTarget )
{
G4ErrorTarget* target = 0;
if( iTarget == 1 ) {
G4Point3D surfPos(221.*cm,0.,0.);
G4Normal3D surfNorm(1.,0.,0.);
target = new G4ErrorPlaneSurfaceTarget(surfNorm, surfPos );
}else if( iTarget == 2 ) {
G4double radius = 222*cm;
target = new G4ErrorCylSurfaceTarget(radius);
}else if( iTarget == 3 ) {
target = new G4ErrorGeomVolumeTarget("MUON");
}else if( iTarget == 4 ) {
target = new G4ErrorTrackLengthTarget(223.*cm);
}else {
G4Exception("exG4eReco::BuildTarget. Target type has to be between 1 and 4");
}
return target;
}
//-------------------------------------------------------------
void Finalize()
{
G4ErrorPropagatorManager::GetErrorPropagatorManager()->CloseGeometry();
}
@@ -0,0 +1,91 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// ------------------------------------------------------------
// GEANT 4 class header file
// ------------------------------------------------------------
//
// Class Description:
//
// Creates a simplified typical HEP detector:
// An air beamline ( BEAM )
// An air central detector ( CDET )
// A copper calorimeter, divided in four ( ECAL )
// An aluminium calorimeter, divided in ten ( HCAL )
// An air muon detector ( MUON )
//
// History:
// - Created: P. Arce May 2007
//
#ifndef ExErrorDetectorConstruction_hh
#define ExErrorDetectorConstruction_hh 1
#include "globals.hh"
#include "G4VUserDetectorConstruction.hh"
#include "ExErrorMagneticField.hh"
class G4Box;
class G4LogicalVolume;
class G4VPhysicalVolume;
class G4Material;
class ExErrorDetectorMessenger;
class G4UserLimits;
//------------------------------------------------------------------------
class ExErrorDetectorConstruction : public G4VUserDetectorConstruction
{
public:
ExErrorDetectorConstruction();
~ExErrorDetectorConstruction();
G4VPhysicalVolume* Construct();
void SetMagField(G4double);
private:
G4double xBEAM;
G4double xCDET;
G4double xECAL;
G4double xSOLN;
G4double xHCAL;
G4double xMUON;
G4double ndivECAL;
G4double ndivHCAL;
G4double yzLength;
G4double xHalfWorldLength;
G4UserLimits* userLimits;
ExErrorMagneticField* fpMagField; // pointer to the magnetic field
ExErrorDetectorMessenger* detectorMessenger; // pointer to the Messenger
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -0,0 +1,66 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// ------------------------------------------------------------
// GEANT 4 class header file
// ------------------------------------------------------------
//
// Class Description:
//
// Defines a G4UIcommand to set the value of the constant field
//
// History:
// - Created: P. Arce, May 2007
//
#ifndef ExErrorDetectorMessenger_hh
#define ExErrorDetectorMessenger_hh 1
#include "globals.hh"
#include "G4UImessenger.hh"
class ExErrorDetectorConstruction;
class G4UIdirectory;
class G4UIcmdWithAString;
class G4UIcmdWithADoubleAndUnit;
//------------------------------------------------------------------------
class ExErrorDetectorMessenger: public G4UImessenger
{
public:
ExErrorDetectorMessenger(ExErrorDetectorConstruction*);
~ExErrorDetectorMessenger();
void SetNewValue(G4UIcommand*, G4String);
private:
ExErrorDetectorConstruction* myDetector;
G4UIdirectory* mydetDir;
G4UIcmdWithADoubleAndUnit* FieldCmd;
};
#endif
@@ -0,0 +1,66 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// ------------------------------------------------------------
// GEANT 4 class header file
// ------------------------------------------------------------
//
// Class Description:
//
// A uniform 1 kilogauss field along the Z axis
//
// History:
// - Created: P. Arce May 2007
//
#ifndef ExErrorMagneticField_H
#define ExErrorMagneticField_H
#include "G4UniformMagField.hh"
class G4FieldManager;
//------------------------------------------------------------------------
class ExErrorMagneticField: public G4UniformMagField
{
public:
ExErrorMagneticField(G4ThreeVector); // The value of the field
ExErrorMagneticField(); // A zero field
~ExErrorMagneticField();
//Set the field (0,0,fieldValue)
void SetFieldValue(G4double fieldValue);
void SetFieldValue(G4ThreeVector fieldVector);
G4ThreeVector GetConstantFieldValue();
protected:
// Find the global Field Manager
G4FieldManager* GetGlobalFieldManager(); // static
};
#endif
@@ -0,0 +1,254 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
#include "ExErrorDetectorConstruction.hh"
#include "ExErrorDetectorMessenger.hh"
#include "ExErrorMagneticField.hh"
#include "G4Material.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4UserLimits.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4ios.hh"
//-------------------------------------------------------------
ExErrorDetectorConstruction::ExErrorDetectorConstruction()
: xBEAM(5.*cm), xCDET(20.*cm), xECAL(40.*cm), xSOLN(10.*cm), xHCAL(100.*cm),
xMUON(50.*cm), ndivECAL(40./10.), ndivHCAL(100./10.), yzLength(50.*cm),
xHalfWorldLength(xBEAM + xCDET + xECAL + xSOLN + xHCAL + xMUON)
{
// create UserLimits
userLimits = new G4UserLimits();
fpMagField = new ExErrorMagneticField(G4ThreeVector(0.*kilogauss,0.*kilogauss,-1.*kilogauss));
detectorMessenger = new ExErrorDetectorMessenger(this);
}
//-------------------------------------------------------------
ExErrorDetectorConstruction::~ExErrorDetectorConstruction()
{
delete fpMagField;
delete detectorMessenger;
}
//-------------------------------------------------------------
G4VPhysicalVolume* ExErrorDetectorConstruction::Construct()
{
//--------- Material definition ---------
G4double a, iz, z, density;
G4String name, symbol;
G4int nel;
//Vacuum
/* a = 1.*g/mole;
density = 1.E-9*g/cm3;
G4Material* Vacuum = new G4Material(name="Vacuum", z=1., a, density);
*/
//Air
a = 14.01*g/mole;
G4Element* elN = new G4Element(name="Nitrogen", symbol="N", iz=7., a);
a = 16.00*g/mole;
G4Element* elO = new G4Element(name="Oxigen", symbol="O", iz=8., a);
density = 1.205*mg/cm3;
G4Material* Air = new G4Material(name="Air", density, nel=2);
Air->AddElement(elN, .7);
Air->AddElement(elO, .3);
//Al
a = 26.98*g/mole;
density = 2.7*g/cm3;
G4Material* Al = new G4Material(name="Al", z=13., a, density);
//Fe
a = 55.85*g/mole;
density = 7.87*g/cm3;
G4Material* Fe = new G4Material(name="Fe", z=26., a, density);
//Cu
a = 63.54*g/mole;
density = 8.96*g/cm3;
G4Material* Cu = new G4Material(name="Cu", z=29., a, density);
// Print all the materials defined.
//
G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
//--------- Sizes of the principal geometrical components (solids) --------- (half lengths)
//double xBEAM = 5.*2.*cm;
//double xCDET = 90.*cm;
//double xECAL = 40.*cm;
//double xSOLN = 10.*cm;
//double xHCAL = 100.*cm;
//double xMUON = 50.*cm;
//double ndivECAL = 10;
//double ndivHCAL = 10;
//double yzLength = 100.*cm;
// double xWorldLength= xBEAM + xCDET + xECAL + xSOLN + xHCAL + xMUON;
//--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
//------------------------------
// World
//------------------------------
//- G4double HalfWorldLength = xWorldLength;
G4cout << " HalfWorldLength " << xHalfWorldLength << G4endl;
G4Box* solidWorld= new G4Box("world",xHalfWorldLength,yzLength,yzLength);
G4LogicalVolume* logicWorld= new G4LogicalVolume( solidWorld, Air, "World", 0, 0, 0);
// Must place the World Physical volume unrotated at (0,0,0).
//
G4VPhysicalVolume* physiWorld = new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
"World", // its name
logicWorld, // its logical volume
0, // its mother volume
false, // no boolean operations
0); // no field specific to volum
//------------------------------
// BEAM
//------------------------------
G4Box* solidBEAM = new G4Box("BEAM",xBEAM,yzLength,yzLength);
G4LogicalVolume* logicBEAM = new G4LogicalVolume(solidBEAM,Air,"BEAM",0,0,0);
G4ThreeVector positionBEAM = G4ThreeVector(0.,0.,0.);
//G4VPhysicalVolume* physiBEAM =
new G4PVPlacement(0, // no rotation
positionBEAM, // at (x,y,z)
"BEAM", // its name
logicBEAM, // its logical volume
physiWorld, // its mother volume
false, // no boolean operations
0); // no particular field
//------------------------------
// CDET (Central DETector)
//------------------------------
G4ThreeVector positionCdet = G4ThreeVector(xBEAM + xCDET/2.,0.,0.);
G4Box* solidCDET = new G4Box("CDET",xCDET/2.,yzLength,yzLength);
G4LogicalVolume* logicCDET = new G4LogicalVolume(solidCDET,Air,"Cdet",0,0,0);
// G4VPhysicalVolume* physiCDET =
new G4PVPlacement(0, // no rotation
positionCdet, // at (x,y,z)
"CDET", // its name
logicCDET, // its logical volume
physiWorld, // its mother volume
false, // no boolean operations
0); // no particular field
//------------------------------
// ECAL
//------------------------------
G4ThreeVector positionECAL = G4ThreeVector(xBEAM + xCDET + xECAL/2., 0., 0.);
G4Box* solidECAL = new G4Box("ECAL",xECAL/2.,yzLength,yzLength);
G4LogicalVolume* logicECAL = new G4LogicalVolume(solidECAL,Cu,"ECAL",0,0,0);
G4VPhysicalVolume* physiECAL = new G4PVPlacement(0, // no rotation
positionECAL, // at (x,y,z)
"ECAL", // its name
logicECAL, // its logical volume
physiWorld, // its mother volume
false, // no boolean operations
0); // no particular field
//--------- Divide it
G4Box* solidECALdiv = new G4Box("ECAL",xECAL/2./ndivECAL,yzLength,yzLength);
G4LogicalVolume* logicECALdiv = new G4LogicalVolume(solidECALdiv,Cu,"ECALdiv",0,0,0);
new G4PVReplica("DVEC", logicECALdiv, physiECAL,
kXAxis, G4int(ndivECAL), xECAL/ndivECAL);
//------------------------------
// SOLN
//------------------------------
G4ThreeVector positionSOLN = G4ThreeVector(xBEAM + xCDET + xECAL + xSOLN/2., 0., 0.);
G4Box* solidSOLN = new G4Box("SOLN",xSOLN/2.,yzLength,yzLength);
G4LogicalVolume* logicSOLN = new G4LogicalVolume(solidSOLN,Al,"SOLN",0,0,0);
new G4PVPlacement(0, // no rotation
positionSOLN, // at (x,y,z)
"SOLN", // its name
logicSOLN, // its logical volume
physiWorld, // its mother volume
false, // no boolean operations
0); // no particular field
//------------------------------
// HCAL
//------------------------------
G4ThreeVector positionHCAL = G4ThreeVector(xBEAM + xCDET + xECAL + xSOLN + xHCAL/2., 0., 0.);
G4Box* solidHCAL = new G4Box("HCAL",xHCAL/2.,yzLength,yzLength);
G4LogicalVolume* logicHCAL = new G4LogicalVolume(solidHCAL,Fe,"HCAL",0,0,0);
G4VPhysicalVolume* physiHCAL = new G4PVPlacement(0, // no rotation
positionHCAL, // at (x,y,z)
"HCAL", // its name
logicHCAL, // its logical volume
physiWorld, // its mother volume
false, // no boolean operations
0); // no particular field
//--------- Divide it
G4Box* solidHCALdiv = new G4Box("HCAL",xHCAL/2./ndivHCAL,yzLength,yzLength);
G4LogicalVolume* logicHCALdiv = new G4LogicalVolume(solidHCALdiv,Fe,"HCALdiv",0,0,0);
new G4PVReplica("DVEH", logicHCALdiv, physiHCAL,
kXAxis, G4int(ndivHCAL), xHCAL/ndivHCAL);
//------------------------------
// MUON
//------------------------------
G4ThreeVector positionMUON = G4ThreeVector(xBEAM + xCDET + xECAL + xSOLN + xHCAL + xMUON/2., 0., 0.);
G4Box* solidMUON = new G4Box("MUON",xMUON/2.,yzLength,yzLength);
G4LogicalVolume* logicMUON = new G4LogicalVolume(solidMUON,Air,"MUON",0,0,0);
new G4PVPlacement(0, // no rotation
positionMUON, // at (x,y,z)
"MUON", // its name
logicMUON, // its logical volume
physiWorld, // its mother volume
false, // no boolean operations
0); // no particular field
G4VisAttributes* worldVisAtt = new G4VisAttributes(0);
logicWorld->SetVisAttributes( worldVisAtt);
return physiWorld;
}
//-------------------------------------------------------------
void ExErrorDetectorConstruction::SetMagField(G4double fieldValue)
{
fpMagField->SetFieldValue(fieldValue);
}
@@ -0,0 +1,70 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
#include "ExErrorDetectorMessenger.hh"
#include "ExErrorDetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "globals.hh"
//-------------------------------------------------------------
ExErrorDetectorMessenger::ExErrorDetectorMessenger(ExErrorDetectorConstruction* myDet)
:myDetector(myDet)
{
mydetDir = new G4UIdirectory("/exerror/");
mydetDir->SetGuidance("ExError control.");
FieldCmd = new G4UIcmdWithADoubleAndUnit("/exerror/setField",this);
FieldCmd->SetGuidance("Define magnetic field.");
FieldCmd->SetGuidance("Magnetic field will be in Z direction.");
FieldCmd->SetParameterName("Bz",false);
FieldCmd->SetDefaultUnit("tesla");
FieldCmd->SetUnitCategory("Magnetic flux density");
FieldCmd->AvailableForStates(G4State_PreInit,G4State_Init,G4State_Idle);
}
//-------------------------------------------------------------
ExErrorDetectorMessenger::~ExErrorDetectorMessenger()
{
delete FieldCmd;
delete mydetDir;
}
//-------------------------------------------------------------
void ExErrorDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == FieldCmd ) {
myDetector->SetMagField(FieldCmd->GetNewDoubleValue(newValue));
}
}
@@ -0,0 +1,87 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
#include "ExErrorMagneticField.hh"
#include "G4FieldManager.hh"
#include "G4TransportationManager.hh"
//-------------------------------------------------------------
ExErrorMagneticField::ExErrorMagneticField()
: G4UniformMagField(G4ThreeVector())
{
GetGlobalFieldManager()->SetDetectorField(this);
GetGlobalFieldManager()->CreateChordFinder(this);
}
//-------------------------------------------------------------
ExErrorMagneticField::ExErrorMagneticField(G4ThreeVector fieldVector)
: G4UniformMagField(fieldVector)
{
GetGlobalFieldManager()->SetDetectorField(this);
GetGlobalFieldManager()->CreateChordFinder(this);
}
//-------------------------------------------------------------
void ExErrorMagneticField::SetFieldValue(G4double fieldValue)
{
G4UniformMagField::SetFieldValue(G4ThreeVector(0,0,fieldValue));
}
//-------------------------------------------------------------
void ExErrorMagneticField::SetFieldValue(G4ThreeVector fieldVector)
{
// Find the Field Manager for the global field
G4FieldManager* fieldMgr= GetGlobalFieldManager();
if(fieldVector!=G4ThreeVector(0.,0.,0.))
{
G4UniformMagField::SetFieldValue(fieldVector);
fieldMgr->SetDetectorField(this);
} else {
// If the new field's value is Zero, then it is best to
// insure that it is not used for propagation.
G4MagneticField* magField = NULL;
fieldMgr->SetDetectorField(magField);
}
}
//-------------------------------------------------------------
ExErrorMagneticField::~ExErrorMagneticField()
{
}
//-------------------------------------------------------------
G4FieldManager* ExErrorMagneticField::GetGlobalFieldManager()
{
return G4TransportationManager::GetTransportationManager()->GetFieldManager();
}