Import Geant4 9.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:58:43 +02:00
parent 96c8bcd0af
commit b79225fb37
7544 changed files with 245407 additions and 91099 deletions
@@ -0,0 +1,13 @@
Examples for Pythia-Geant4 interface
------------------------------------
This directory contains examples for using Pythia as Monte Carlo event
generator, interfaced with Geant4, and showing how to implement an external
decayer.
Requirements for external software packages
-------------------------------------------
PYTHIA
Tested version 6.4.18
URL: http://www.thep.lu.se/~torbjorn/Pythia.html
@@ -0,0 +1,39 @@
# $Id: GNUmakefile,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
# --------------------------------------------------------------
# GNUmakefile for examples module
# --------------------------------------------------------------
name := pythia6_decayer
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../../..
endif
.PHONY: all
all: pythia6 lib bin
EXTRALIBS = $(G4TMPDIR)/libPythia6.so
include $(G4INSTALL)/config/binmake.gmk
CCFLAGS += -c
FCFLAGS += -c
visclean:
rm -f g4*.prim g4*.eps g4*.wrl
rm -f .DAWN_*
pythia6: $(G4TMPDIR)/libPythia6.so
$(G4TMPDIR)/libPythia6.so: $(G4TMPDIR)/pythia6.o $(G4TMPDIR)/pythia6_common_address.o
$(FC) -shared -Wl,-soname,libPythia6.so -o $(G4TMPDIR)/libPythia6.so $(G4TMPDIR)/pythia6.o $(G4TMPDIR)/pythia6_common_address.o
$(G4TMPDIR)/pythia6.o:
$(FC) $(FCFLAGS) $(PYTHIA6)/pythia-$(PYTHIA6_VERSION).f -o $(G4TMPDIR)/pythia6.o
$(G4TMPDIR)/pythia6_common_address.o:
$(CC) $(CCFLAGS) src/pythia6_common_address.c -o $(G4TMPDIR)/pythia6_common_address.o
@@ -0,0 +1,19 @@
$Id: History,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
----------------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
examples History file
---------------------
This file should be used by the test developer to briefly summarize all major
modifications introduced in the code and keep track of all tags.
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
03/11/2008 - G.Cosmo (p6decayer-V09-01-00)
--------------------
- First version from original code by I.Hrivnakova.
@@ -0,0 +1,68 @@
$Id: README,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
------------------------------------------------------------
Example of the external decayer implementation with Pythia6
===========================================================
The complete Pythia6 documentation can be found at:
http://home.thep.lu.se/~torbjorn/pythiaaux/recent.html
The Pythia6 external decayer was originally developed within
the AliRoot framework, by Andreas Morsch (CERN).
The dependence on the ALICE software was taken off
by Christian Holm Christensen,
The dependence on the Root framework and the integration in
the Geant4 framework was done by Ivana Hrivnacova (IPN Orsay).
------------------------------------------------------------
The use of the external decayer is demonstrated on the modified
novice N03 example.
The G4Pythia6Decayer class provides the implementation of the
G4VExternalDecayer interface with using Pythia6. In order
to be able to use Pythia6, which is written in FORTRAN,
a C++ interface class Pythia6 is provided. This class
interfaces only the Pythia6 functions relevant to decay.
The G4Pythia6Decayer is instantiated in the ExN03PhysicsList class,
in the ConstructDecay() function.
To demonstrate the decay with external decayer,
the B- meson is defined in ExN03PrimaryGeneratorAction,
as it has no own decay table defined within Geant4.
With Pythia6, it is possible to force a selected decay
type. This selection can be chosen interactively via
the implemented Geant4 UI command:
/pythia6Decayer/forceDecayType decayType
where the available decay types are listed in the EDecayType
enumaration.
The classes Pythia6, G4Pythia6Decayer, G4Pythia6DecayerMessenger
are independent from the example classes and can be reused
in another user application.
Installation:
1. Download the Pythia6 source file from the Pythia6 download site:
http://www.hepforge.org/downloads/pythia6
2. Define the environment variables:
PYTHIA6 the path to pythia-vesrinX.f source code
PYTHIA6_VERSION the pythia version
e.g. If you download pythia-6.4.18.f.gz and unzip it in $HOME,
then you have to set:
export PYTHIA6=$HOME
export PYTHIA6_VERSION="6.4.18"
3. cd $G4INSTALL/example/extended/eventgenerator/pythia/decayer6
make
Execution:
% pythia6_decayer pythia6_decayer.in
@@ -0,0 +1,157 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: DetectorConstruction.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#ifndef DetectorConstruction_h
#define DetectorConstruction_h 1
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
class G4Box;
class G4LogicalVolume;
class G4VPhysicalVolume;
class G4Material;
class G4UniformMagField;
class DetectorMessenger;
// ----------------------------------------------------------------------------
class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
DetectorConstruction();
~DetectorConstruction();
public:
void SetAbsorberMaterial (G4String);
void SetAbsorberThickness(G4double);
void SetGapMaterial (G4String);
void SetGapThickness(G4double);
void SetCalorSizeYZ(G4double);
void SetNbOfLayers (G4int);
void SetMagField(G4double);
G4VPhysicalVolume* Construct();
void UpdateGeometry();
public:
void PrintCalorParameters();
G4double GetWorldSizeX() {return WorldSizeX;};
G4double GetWorldSizeYZ() {return WorldSizeYZ;};
G4double GetCalorThickness() {return CalorThickness;};
G4double GetCalorSizeYZ() {return CalorSizeYZ;};
G4int GetNbOfLayers() {return NbOfLayers;};
G4Material* GetAbsorberMaterial() {return AbsorberMaterial;};
G4double GetAbsorberThickness() {return AbsorberThickness;};
G4Material* GetGapMaterial() {return GapMaterial;};
G4double GetGapThickness() {return GapThickness;};
const G4VPhysicalVolume* GetphysiWorld() {return physiWorld;};
const G4VPhysicalVolume* GetAbsorber() {return physiAbsorber;};
const G4VPhysicalVolume* GetGap() {return physiGap;};
private:
G4Material* AbsorberMaterial;
G4double AbsorberThickness;
G4Material* GapMaterial;
G4double GapThickness;
G4int NbOfLayers;
G4double LayerThickness;
G4double CalorSizeYZ;
G4double CalorThickness;
G4Material* defaultMaterial;
G4double WorldSizeYZ;
G4double WorldSizeX;
G4Box* solidWorld; //pointer to the solid World
G4LogicalVolume* logicWorld; //pointer to the logical World
G4VPhysicalVolume* physiWorld; //pointer to the physical World
G4Box* solidCalor; //pointer to the solid Calor
G4LogicalVolume* logicCalor; //pointer to the logical Calor
G4VPhysicalVolume* physiCalor; //pointer to the physical Calor
G4Box* solidLayer; //pointer to the solid Layer
G4LogicalVolume* logicLayer; //pointer to the logical Layer
G4VPhysicalVolume* physiLayer; //pointer to the physical Layer
G4Box* solidAbsorber; //pointer to the solid Absorber
G4LogicalVolume* logicAbsorber; //pointer to the logical Absorber
G4VPhysicalVolume* physiAbsorber; //pointer to the physical Absorber
G4Box* solidGap; //pointer to the solid Gap
G4LogicalVolume* logicGap; //pointer to the logical Gap
G4VPhysicalVolume* physiGap; //pointer to the physical Gap
G4UniformMagField* magField; //pointer to the magnetic field
DetectorMessenger* detectorMessenger; //pointer to the Messenger
private:
void DefineMaterials();
void ComputeCalorParameters();
G4VPhysicalVolume* ConstructCalorimeter();
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline void DetectorConstruction::ComputeCalorParameters()
{
// Compute derived parameters of the calorimeter
LayerThickness = AbsorberThickness + GapThickness;
CalorThickness = NbOfLayers*LayerThickness;
WorldSizeX = 1.2*CalorThickness; WorldSizeYZ = 1.2*CalorSizeYZ;
}
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,76 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: DetectorMessenger.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#ifndef DetectorMessenger_h
#define DetectorMessenger_h 1
#include "globals.hh"
#include "G4UImessenger.hh"
class DetectorConstruction;
class G4UIdirectory;
class G4UIcmdWithAString;
class G4UIcmdWithAnInteger;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithoutParameter;
// ----------------------------------------------------------------------------
class DetectorMessenger: public G4UImessenger
{
public:
DetectorMessenger(DetectorConstruction* );
~DetectorMessenger();
void SetNewValue(G4UIcommand*, G4String);
private:
DetectorConstruction* Detector;
G4UIdirectory* decDir;
G4UIdirectory* detDir;
G4UIcmdWithAString* AbsMaterCmd;
G4UIcmdWithAString* GapMaterCmd;
G4UIcmdWithADoubleAndUnit* AbsThickCmd;
G4UIcmdWithADoubleAndUnit* GapThickCmd;
G4UIcmdWithADoubleAndUnit* SizeYZCmd;
G4UIcmdWithAnInteger* NbLayersCmd;
G4UIcmdWithADoubleAndUnit* MagFieldCmd;
G4UIcmdWithoutParameter* UpdateCmd;
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,68 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: EDecayType.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// According to EDecayType enum in TPythia6Decayer class in Root:
// http://root.cern.ch/
// see http://root.cern.ch/root/License.html
// ----------------------------------------------------------------------------
#ifndef E_DECAY_TYPE_H
#define E_DECAY_TYPE_H
// Enum of decay mode types
enum EDecayType
{
kSemiElectronic,
kDiElectron,
kSemiMuonic,
kDiMuon,
kBJpsiDiMuon,
kBJpsiDiElectron,
kBPsiPrimeDiMuon,
kBPsiPrimeDiElectron,
kPiToMu,
kKaToMu,
kNoDecay,
kHadronicD,
kOmega,
kPhiKK,
kAll,
kNoDecayHeavy,
kHardMuons,
kBJpsi,
kWToMuon,
kWToCharm,
kWToCharmToMuon,
kZDiMuon,
kMaxDecay
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,75 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: EventAction.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#ifndef EventAction_h
#define EventAction_h 1
#include "G4UserEventAction.hh"
#include "globals.hh"
class RunAction;
class EventActionMessenger;
// ----------------------------------------------------------------------------
class EventAction : public G4UserEventAction
{
public:
EventAction(RunAction*);
~EventAction();
void BeginOfEventAction(const G4Event*);
void EndOfEventAction(const G4Event*);
void AddAbs(G4double de, G4double dl) {EnergyAbs += de; TrackLAbs += dl;}
void AddGap(G4double de, G4double dl) {EnergyGap += de; TrackLGap += dl;}
void SetPrintModulo(G4int val) {printModulo = val;};
private:
RunAction* runAct;
G4double EnergyAbs, EnergyGap;
G4double TrackLAbs, TrackLGap;
G4int printModulo;
EventActionMessenger* eventMessenger;
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,63 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: EventActionMessenger.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#ifndef EventActionMessenger_h
#define EventActionMessenger_h 1
#include "globals.hh"
#include "G4UImessenger.hh"
class EventAction;
class G4UIdirectory;
class G4UIcmdWithAnInteger;
// ----------------------------------------------------------------------------
class EventActionMessenger: public G4UImessenger
{
public:
EventActionMessenger(EventAction*);
~EventActionMessenger();
void SetNewValue(G4UIcommand*, G4String);
private:
EventAction* eventAction;
G4UIdirectory* eventDir;
G4UIcmdWithAnInteger* PrintCmd;
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,100 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: G4Pythia6Decayer.hh,v 1.2 2008/12/18 12:56:36 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// Implements the G4VExtDecayer abstract class using the Pythia6 interface.
//
// According to TPythia6Decayer class in Root:
// http://root.cern.ch/
// see http://root.cern.ch/root/License.html
// ----------------------------------------------------------------------------
#ifndef G4_PYTHIA6_DECAYER_H
#define G4_PYTHIA6_DECAYER_H
#include "G4VExtDecayer.hh"
#include "G4Pythia6DecayerMessenger.hh"
#include "Pythia6.hh"
#include "EDecayType.hh"
#include "globals.hh"
class Pythia6Particle;
class G4Track;
class G4DecayProducts;
// ----------------------------------------------------------------------------
class G4Pythia6Decayer : public G4VExtDecayer
{
public:
G4Pythia6Decayer();
virtual ~G4Pythia6Decayer();
virtual G4DecayProducts* ImportDecayProducts(const G4Track& track);
void ForceDecayType(EDecayType decayType);
void SetVerboseLevel(G4int verboseLevel) { fVerboseLevel = verboseLevel; }
private:
/// Not implemented
G4Pythia6Decayer(const G4Pythia6Decayer& right);
/// Not implemented
G4Pythia6Decayer& operator=(const G4Pythia6Decayer& right);
G4ParticleDefinition*
GetParticleDefinition(const Pythia6Particle* p,G4bool warn = true) const;
G4DynamicParticle* CreateDynamicParticle(const Pythia6Particle* p) const;
G4ThreeVector GetParticlePosition(const Pythia6Particle* particle) const;
G4ThreeVector GetParticleMomentum(const Pythia6Particle* particle) const;
G4int CountProducts(G4int channel, G4int particle);
void ForceParticleDecay(G4int particle, G4int product, G4int mult);
void ForceParticleDecay(G4int particle,
G4int* products, G4int* mult, G4int npart);
void ForceHadronicD();
void ForceOmega();
void ForceDecay(EDecayType decayType);
void Decay(G4int pdg, const CLHEP::HepLorentzVector& p);
G4int ImportParticles(ParticleVector* particles);
static const EDecayType fgkDefaultDecayType; ///< default decay type
G4Pythia6DecayerMessenger fMessenger; ///< command messenger
G4int fVerboseLevel; ///< verbose level
EDecayType fDecayType; ///< selected decay type
ParticleVector* fDecayProductsArray ; ///< array of decay products
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,79 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: G4Pythia6DecayerMessenger.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// Messenger class that defines commands for G4Pythia6Decayer.
//
// Implements command
// - /pythia6Decayer/verbose [level]
// - /pythia6Decayer/forceDecayType [decayType]
// ----------------------------------------------------------------------------
#ifndef G4_PYTHIA6_DECAYER_MESSENGER_H
#define G4_PYTHIA6_DECAYER_MESSENGER_H
#include <G4UImessenger.hh>
#include <globals.hh>
class G4Pythia6Decayer;
class G4UIdirectory;
class G4UIcmdWithAnInteger;
class G4UIcmdWithABool;
// ----------------------------------------------------------------------------
class G4Pythia6DecayerMessenger : public G4UImessenger
{
public:
G4Pythia6DecayerMessenger(G4Pythia6Decayer* pythia6Decayer);
virtual ~G4Pythia6DecayerMessenger();
virtual void SetNewValue(G4UIcommand* command, G4String string);
private:
/// Not implemented
G4Pythia6DecayerMessenger();
/// Not implemented
G4Pythia6DecayerMessenger(const G4Pythia6DecayerMessenger& right);
/// Not implemented
G4Pythia6DecayerMessenger& operator=(const G4Pythia6DecayerMessenger& r);
private:
G4Pythia6Decayer* fPythia6Decayer; ///< associated class
G4UIdirectory* fDirectory; ///< command directory
G4UIcmdWithAnInteger* fVerboseCmd; ///< command: verbose
G4UIcmdWithAnInteger* fDecayTypeCmd; ///< command: forceDEcayeType
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,69 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: PhysicsList.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#ifndef PhysicsList_h
#define PhysicsList_h 1
#include "G4VUserPhysicsList.hh"
#include "globals.hh"
// ----------------------------------------------------------------------------
class PhysicsList: public G4VUserPhysicsList
{
public:
PhysicsList();
~PhysicsList();
// Construct particle and physics
void ConstructParticle();
void ConstructProcess();
void SetCuts();
private:
// these methods Construct particles
void ConstructBosons();
void ConstructLeptons();
void ConstructMesons();
void ConstructBaryons();
// these methods Construct physics processes and register them
void ConstructDecay();
void ConstructEM();
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,69 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: PrimaryGeneratorAction.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#ifndef PrimaryGeneratorAction_h
#define PrimaryGeneratorAction_h 1
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
class G4ParticleGun;
class G4Event;
class DetectorConstruction;
class PrimaryGeneratorMessenger;
// ----------------------------------------------------------------------------
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
PrimaryGeneratorAction(DetectorConstruction*);
~PrimaryGeneratorAction();
void GeneratePrimaries(G4Event*);
void SetRndmFlag(G4String val) { rndmFlag = val;}
private:
G4ParticleGun* particleGun; // pointer a to G4 class
DetectorConstruction* Detector; // pointer to the geometry
PrimaryGeneratorMessenger* gunMessenger; // messenger of this class
G4String rndmFlag; // flag for a rndm impact point
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,63 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: PrimaryGeneratorMessenger.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// ----------------------------------------------------------------------------
#ifndef PrimaryGeneratorMessenger_h
#define PrimaryGeneratorMessenger_h 1
#include "G4UImessenger.hh"
#include "globals.hh"
class PrimaryGeneratorAction;
class G4UIdirectory;
class G4UIcmdWithAString;
// ----------------------------------------------------------------------------
class PrimaryGeneratorMessenger : public G4UImessenger
{
public:
PrimaryGeneratorMessenger(PrimaryGeneratorAction*);
~PrimaryGeneratorMessenger();
void SetNewValue(G4UIcommand*, G4String);
private:
PrimaryGeneratorAction* Action;
G4UIdirectory* gunDir;
G4UIcmdWithAString* RndmCmd;
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,191 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: Pythia6.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// According to TPythia6 class from Root:
// (The TPythia6 class is an interface class to F77 routines in Pythia6 //
// CERNLIB event generators, written by T.Sjostrand.)
// http://root.cern.ch/
// see http://root.cern.ch/root/License.html
//
// The complete Pythia6 documentation can be found at:
// http://home.thep.lu.se/~torbjorn/pythiaaux/recent.html
//
// ----------------------------------------------------------------------------
// ******************************************************************************
// ******************************************************************************
// ** **
// ** **
// ** *......* Welcome to the Lund Monte Carlo! **
// ** *:::!!:::::::::::* **
// ** *::::::!!::::::::::::::* PPP Y Y TTTTT H H III A **
// ** *::::::::!!::::::::::::::::* P P Y Y T H H I A A **
// ** *:::::::::!!:::::::::::::::::* PPP Y T HHHHH I AAAAA **
// ** *:::::::::!!:::::::::::::::::* P Y T H H I A A **
// ** *::::::::!!::::::::::::::::*! P Y T H H III A A **
// ** *::::::!!::::::::::::::* !! **
// ** !! *:::!!:::::::::::* !! This is PYTHIA version 6.418 **
// ** !! !* -><- * !! Last date of change: 9 Jun 2008 **
// ** !! !! !! **
// ** !! !! !! Now is 0 Jan 2000 at 0:00:00 **
// ** !! !! **
// ** !! lh !! Disclaimer: this program comes **
// ** !! !! without any guarantees. Beware **
// ** !! hh !! of errors and use common sense **
// ** !! ll !! when interpreting results. **
// ** !! !! **
// ** !! Copyright T. Sjostrand (2008) **
// ** **
// ** An archive of program versions and documentation is found on the web: **
// ** http://www.thep.lu.se/~torbjorn/Pythia.html **
// ** **
// ** When you cite this program, the official reference is to the 6.4 manual: **
// ** T. Sjostrand, S. Mrenna and P. Skands, JHEP05 (2006) 026 **
// ** (LU TP 06-13, FERMILAB-PUB-06-052-CD-T) [hep-ph/0603175]. **
// ** **
// ** Also remember that the program, to a large extent, represents original **
// ** physics research. Other publications of special relevance to your **
// ** studies may therefore deserve separate mention. **
// ** **
// ** Main author: Torbjorn Sjostrand; Department of Theoretical Physics, **
// ** Lund University, Solvegatan 14A, S-223 62 Lund, Sweden; **
// ** phone: + 46 - 46 - 222 48 16; e-mail: torbjorn@thep.lu.se **
// ** Author: Stephen Mrenna; Computing Division, GDS Group, **
// ** Fermi National Accelerator Laboratory, MS 234, Batavia, IL 60510, USA; **
// ** phone: + 1 - 630 - 840 - 2556; e-mail: mrenna@fnal.gov **
// ** Author: Peter Skands; Theoretical Physics Department, **
// ** Fermi National Accelerator Laboratory, MS 106, Batavia, IL 60510, USA; **
// ** and CERN/PH, CH-1211 Geneva, Switzerland; **
// ** phone: + 41 - 22 - 767 24 59; e-mail: skands@fnal.gov **
// ** **
// ** **
// ******************************************************************************
#ifndef PYTHIA_Pythia6
#define PYTHIA_Pythia6
#include <vector>
int const KNDCAY = 8000; //should be 4000 for pythia61
struct Pyjets_t
{
int N;
int NPAD;
int K[5][4000];
double P[5][4000];
double V[5][4000];
};
struct Pydat1_t
{
int MSTU[200];
double PARU[200];
int MSTJ[200];
double PARJ[200];
};
struct Pydat3_t
{
int MDCY[3][500];
int MDME[2][KNDCAY];
double BRAT[KNDCAY];
int KFDP[5][KNDCAY];
};
struct Pythia6Particle
{
Pythia6Particle(
int ks, int kf, int parent, int firstChild, int lastChild,
float px, float py, float pz, float energy, float mass,
float vx, float vy, float vz, float time, float lifetime)
: fKS(ks), fKF(kf),
fParent(parent), fFirstChild(firstChild), fLastChild(lastChild),
fPx(px), fPy(py), fPz(pz), fEnergy(energy), fMass(mass),
fVx(vx), fVy(vy), fVz(vz), fTime(time), fLifetime(lifetime) {}
int fKS; // status of particle ( LUJETS K[1] )
int fKF; // KF flavour code ( LUJETS K[2] )
int fParent; // parrent's id ( LUJETS K[3] )
int fFirstChild; // id of first child ( LUJETS K[4] )
int fLastChild; // id of last child ( LUJETS K[5] )
float fPx; // X momenta [GeV/c] ( LUJETS P[1] )
float fPy; // Y momenta [GeV/c] ( LUJETS P[2] )
float fPz; // Z momenta [GeV/c] ( LUJETS P[3] )
float fEnergy; // Energy [GeV] ( LUJETS P[4] )
float fMass; // Mass [Gev/c^2] ( LUJETS P[5] )
float fVx; // X vertex [mm] ( LUJETS V[1] )
float fVy; // Y vertex [mm] ( LUJETS V[2] )
float fVz; // Z vertex [mm] ( LUJETS V[3] )
float fTime; // time of procuction [mm/c]( LUJETS V[4] )
float fLifetime; // proper lifetime [mm/c] ( LUJETS V[5] )
};
typedef std::vector<Pythia6Particle*> ParticleVector;
class Pythia6
{
public:
// ****** constructors and destructor
Pythia6();
virtual ~Pythia6();
static Pythia6 *Instance();
// ****** TPYTHIA routines
//
int Pycomp(int kf);
void Py1ent(int line, int kf, double pe, double theta, double phi);
ParticleVector* ImportParticles();
int ImportParticles(ParticleVector* particles, const char* option="");
// ****** /PYDAT1/
//
void SetMSTJ(int i, int m ) { fPydat1->MSTJ[i-1] = m; }
// ****** /PYDAT3/
//
int GetMDCY(int i, int j) { return fPydat3->MDCY[j-1][i-1]; }
int GetKFDP(int i, int j) { return fPydat3->KFDP[j-1][i-1]; }
void SetMDCY(int i, int j, int m) { fPydat3->MDCY[j-1][i-1] = m; }
void SetMDME(int i, int j, int m) { fPydat3->MDME[j-1][i-1] = m; }
private:
static Pythia6* fgInstance;
ParticleVector* fParticles;
Pyjets_t* fPyjets;
Pydat1_t* fPydat1;
Pydat3_t* fPydat3;
};
#endif
@@ -0,0 +1,65 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: RunAction.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// ----------------------------------------------------------------------------
#ifndef RunAction_h
#define RunAction_h 1
#include "G4UserRunAction.hh"
#include "globals.hh"
// ----------------------------------------------------------------------------
class G4Run;
class RunAction : public G4UserRunAction
{
public:
RunAction();
~RunAction();
void BeginOfRunAction(const G4Run*);
void EndOfRunAction(const G4Run*);
void fillPerEvent(G4double, G4double, G4double, G4double);
private:
G4double sumEAbs, sum2EAbs;
G4double sumEGap, sum2EGap;
G4double sumLAbs, sum2LAbs;
G4double sumLGap, sum2LGap;
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,60 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: SteppingAction.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#ifndef SteppingAction_h
#define SteppingAction_h 1
#include "G4UserSteppingAction.hh"
class DetectorConstruction;
class EventAction;
// ----------------------------------------------------------------------------
class SteppingAction : public G4UserSteppingAction
{
public:
SteppingAction(DetectorConstruction*, EventAction*);
~SteppingAction();
void UserSteppingAction(const G4Step*);
private:
DetectorConstruction* detector;
EventAction* eventaction;
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,55 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: SteppingVerbose.hh,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
class SteppingVerbose;
#ifndef SteppingVerbose_h
#define SteppingVerbose_h 1
#include "G4SteppingVerbose.hh"
// ----------------------------------------------------------------------------
class SteppingVerbose : public G4SteppingVerbose
{
public:
SteppingVerbose();
~SteppingVerbose();
void StepInfo();
void TrackingStarted();
};
// ----------------------------------------------------------------------------
#endif
@@ -0,0 +1,138 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: pythia6_decayer.cc,v 1.1 2008/11/03 14:47:54 ivana Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
#include "Randomize.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "SteppingAction.hh"
#include "SteppingVerbose.hh"
#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
#endif
// ----------------------------------------------------------------------------
int main(int argc,char** argv)
{
// Choose the Random engine
//
CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
// User Verbose output class
//
G4VSteppingVerbose::SetInstance(new SteppingVerbose);
// Construct the default run manager
//
G4RunManager * runManager = new G4RunManager;
// Set mandatory initialization classes
//
DetectorConstruction* detector = new DetectorConstruction;
runManager->SetUserInitialization(detector);
//
G4VUserPhysicsList* physics = new PhysicsList;
runManager->SetUserInitialization(physics);
// Set user action classes
//
G4VUserPrimaryGeneratorAction* gen_action =
new PrimaryGeneratorAction(detector);
runManager->SetUserAction(gen_action);
//
RunAction* run_action = new RunAction;
runManager->SetUserAction(run_action);
//
EventAction* event_action = new EventAction(run_action);
runManager->SetUserAction(event_action);
//
G4UserSteppingAction* stepping_action =
new SteppingAction(detector, event_action);
runManager->SetUserAction(stepping_action);
// Initialize G4 kernel
//
runManager->Initialize();
// Get the pointer to the User Interface manager
//
G4UImanager* UI = G4UImanager::GetUIpointer();
if (argc!=1) // batch mode
{
G4String command = "/control/execute ";
G4String fileName = argv[1];
UI->ApplyCommand(command+fileName);
}
else // interactive mode : define visualization UI terminal
{
#ifdef G4VIS_USE
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
#endif
G4UIsession* session = 0;
#if defined(G4UI_USE_TCSH)
session = new G4UIterminal(new G4UItcsh);
#else
session = new G4UIterminal();
#endif
UI->ApplyCommand("/control/execute vis.mac");
session->SessionStart();
delete session;
#ifdef G4VIS_USE
delete visManager;
#endif
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not
// be deleted in the main() program !
delete runManager;
return 0;
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,8 @@
# B- meson with default Pythia6 decay
/tracking/verbose 1
/run/beamOn 1
# B- meson with forced kSemiElectronic Pythia6 decay
/pythia6Decayer/forceDecayType 0
/tracking/verbose 1
/run/beamOn 1
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,448 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: DetectorConstruction.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "G4Material.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4UniformMagField.hh"
#include "G4GeometryManager.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4SolidStore.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4FieldManager.hh"
#include "G4TransportationManager.hh"
#include "G4RunManager.hh"
// ----------------------------------------------------------------------------
DetectorConstruction::DetectorConstruction()
: AbsorberMaterial(0),GapMaterial(0),defaultMaterial(0),
solidWorld(0),logicWorld(0),physiWorld(0),
solidCalor(0),logicCalor(0),physiCalor(0),
solidLayer(0),logicLayer(0),physiLayer(0),
solidAbsorber(0),logicAbsorber(0),physiAbsorber(0),
solidGap (0),logicGap (0),physiGap (0),
magField(0)
{
// default parameter values of the calorimeter
AbsorberThickness = 10.*mm;
GapThickness = 5.*mm;
NbOfLayers = 10;
CalorSizeYZ = 10.*cm;
ComputeCalorParameters();
// materials
DefineMaterials();
SetAbsorberMaterial("Lead");
SetGapMaterial("liquidArgon");
// create commands for interactive definition of the calorimeter
detectorMessenger = new DetectorMessenger(this);
}
// ----------------------------------------------------------------------------
DetectorConstruction::~DetectorConstruction()
{ delete detectorMessenger;}
// ----------------------------------------------------------------------------
G4VPhysicalVolume* DetectorConstruction::Construct()
{
return ConstructCalorimeter();
}
// ----------------------------------------------------------------------------
void DetectorConstruction::DefineMaterials()
{
//This function illustrates the possible ways to define materials
G4String symbol; //a=mass of a mole;
G4double a, z, density; //z=mean number of protons;
G4int iz, n; //iz=number of protons in an isotope;
// n=number of nucleons in an isotope;
G4int ncomponents, natoms;
G4double abundance, fractionmass;
//
// define Elements
//
G4Element* H = new G4Element("Hydrogen",symbol="H", z= 1., a= 1.01*g/mole);
G4Element* C = new G4Element("Carbon" ,symbol="C", z= 6., a= 12.01*g/mole);
G4Element* N = new G4Element("Nitrogen",symbol="N", z= 7., a= 14.01*g/mole);
G4Element* O = new G4Element("Oxygen" ,symbol="O", z= 8., a= 16.00*g/mole);
G4Element* Si = new G4Element("Silicon",symbol="Si", z= 14., a= 28.09*g/mole);
//
// define an Element from isotopes, by relative abundance
//
G4Isotope* U5 = new G4Isotope("U235", iz=92, n=235, a=235.01*g/mole);
G4Isotope* U8 = new G4Isotope("U238", iz=92, n=238, a=238.03*g/mole);
G4Element* U = new G4Element("enriched Uranium",symbol="U",ncomponents=2);
U->AddIsotope(U5, abundance= 90.*perCent);
U->AddIsotope(U8, abundance= 10.*perCent);
//
// define simple materials
//
new G4Material("Aluminium", z=13., a=26.98*g/mole, density=2.700*g/cm3);
new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
new G4Material("Lead" , z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
//
// define a material from elements. case 1: chemical molecule
//
G4Material* H2O =
new G4Material("Water", density= 1.000*g/cm3, ncomponents=2);
H2O->AddElement(H, natoms=2);
H2O->AddElement(O, natoms=1);
// overwrite computed meanExcitationEnergy with ICRU recommended value
H2O->GetIonisation()->SetMeanExcitationEnergy(75.0*eV);
G4Material* Sci =
new G4Material("Scintillator", density= 1.032*g/cm3, ncomponents=2);
Sci->AddElement(C, natoms=9);
Sci->AddElement(H, natoms=10);
G4Material* Myl =
new G4Material("Mylar", density= 1.397*g/cm3, ncomponents=3);
Myl->AddElement(C, natoms=10);
Myl->AddElement(H, natoms= 8);
Myl->AddElement(O, natoms= 4);
G4Material* SiO2 =
new G4Material("quartz",density= 2.200*g/cm3, ncomponents=2);
SiO2->AddElement(Si, natoms=1);
SiO2->AddElement(O , natoms=2);
//
// define a material from elements. case 2: mixture by fractional mass
//
G4Material* Air =
new G4Material("Air" , density= 1.290*mg/cm3, ncomponents=2);
Air->AddElement(N, fractionmass=0.7);
Air->AddElement(O, fractionmass=0.3);
//
// define a material from elements and/or others materials
// (mixture of mixtures)
//
G4Material* Aerog =
new G4Material("Aerogel", density= 0.200*g/cm3, ncomponents=3);
Aerog->AddMaterial(SiO2, fractionmass=62.5*perCent);
Aerog->AddMaterial(H2O , fractionmass=37.4*perCent);
Aerog->AddElement (C , fractionmass= 0.1*perCent);
//
// examples of gas in non STP conditions
//
G4Material* CO2 =
new G4Material("CarbonicGas", density= 27.*mg/cm3, ncomponents=2,
kStateGas, 325.*kelvin, 50.*atmosphere);
CO2->AddElement(C, natoms=1);
CO2->AddElement(O, natoms=2);
G4Material* steam =
new G4Material("WaterSteam", density= 0.3*mg/cm3, ncomponents=1,
kStateGas, 500.*kelvin, 2.*atmosphere);
steam->AddMaterial(H2O, fractionmass=1.);
//
// examples of vacuum
//
G4Material* Vacuum =
new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density,
kStateGas, 2.73*kelvin, 3.e-18*pascal);
G4Material* beam =
new G4Material("Beam", density= 1.e-5*g/cm3, ncomponents=1,
kStateGas, STP_Temperature, 2.e-2*bar);
beam->AddMaterial(Air, fractionmass=1.);
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
//default materials of the World
defaultMaterial = Vacuum;
}
// ----------------------------------------------------------------------------
G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter()
{
// Clean old geometry, if any
//
G4GeometryManager::GetInstance()->OpenGeometry();
G4PhysicalVolumeStore::GetInstance()->Clean();
G4LogicalVolumeStore::GetInstance()->Clean();
G4SolidStore::GetInstance()->Clean();
// complete the Calor parameters definition
ComputeCalorParameters();
//
// World
//
solidWorld = new G4Box("World", //its name
WorldSizeX/2,WorldSizeYZ/2,WorldSizeYZ/2); //its size
logicWorld = new G4LogicalVolume(solidWorld, //its solid
defaultMaterial, //its material
"World"); //its name
physiWorld = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
logicWorld, //its logical volume
"World", //its name
0, //its mother volume
false, //no boolean operation
0); //copy number
//
// Calorimeter
//
solidCalor=0; logicCalor=0; physiCalor=0;
solidLayer=0; logicLayer=0; physiLayer=0;
if (CalorThickness > 0.)
{ solidCalor = new G4Box("Calorimeter", //its name
CalorThickness/2,CalorSizeYZ/2,CalorSizeYZ/2);//size
logicCalor = new G4LogicalVolume(solidCalor, //its solid
defaultMaterial, //its material
"Calorimeter"); //its name
physiCalor = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
logicCalor, //its logical volume
"Calorimeter", //its name
logicWorld, //its mother volume
false, //no boolean operation
0); //copy number
//
// Layer
//
solidLayer = new G4Box("Layer", //its name
LayerThickness/2,CalorSizeYZ/2,CalorSizeYZ/2); //size
logicLayer = new G4LogicalVolume(solidLayer, //its solid
defaultMaterial, //its material
"Layer"); //its name
if (NbOfLayers > 1)
physiLayer = new G4PVReplica("Layer", //its name
logicLayer, //its logical volume
logicCalor, //its mother
kXAxis, //axis of replication
NbOfLayers, //number of replica
LayerThickness); //witdth of replica
else
physiLayer = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
logicLayer, //its logical volume
"Layer", //its name
logicCalor, //its mother volume
false, //no boolean operation
0); //copy number
}
//
// Absorber
//
solidAbsorber=0; logicAbsorber=0; physiAbsorber=0;
if (AbsorberThickness > 0.)
{ solidAbsorber = new G4Box("Absorber", //its name
AbsorberThickness/2,CalorSizeYZ/2,CalorSizeYZ/2);
logicAbsorber = new G4LogicalVolume(solidAbsorber, //its solid
AbsorberMaterial, //its material
AbsorberMaterial->GetName()); //name
physiAbsorber = new G4PVPlacement(0, //no rotation
G4ThreeVector(-GapThickness/2,0.,0.), //its position
logicAbsorber, //its logical volume
AbsorberMaterial->GetName(), //its name
logicLayer, //its mother
false, //no boulean operat
0); //copy number
}
//
// Gap
//
solidGap=0; logicGap=0; physiGap=0;
if (GapThickness > 0.)
{ solidGap = new G4Box("Gap",
GapThickness/2,CalorSizeYZ/2,CalorSizeYZ/2);
logicGap = new G4LogicalVolume(solidGap,
GapMaterial,
GapMaterial->GetName());
physiGap = new G4PVPlacement(0, //no rotation
G4ThreeVector(AbsorberThickness/2,0.,0.), //its position
logicGap, //its logical volume
GapMaterial->GetName(), //its name
logicLayer, //its mother
false, //no boulean operat
0); //copy number
}
PrintCalorParameters();
//
// Visualization attributes
//
logicWorld->SetVisAttributes (G4VisAttributes::Invisible);
G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
simpleBoxVisAtt->SetVisibility(true);
logicCalor->SetVisAttributes(simpleBoxVisAtt);
//
//always return the physical World
//
return physiWorld;
}
// ----------------------------------------------------------------------------
void DetectorConstruction::PrintCalorParameters()
{
G4cout << "\n------------------------------------------------------------"
<< "\n---> The calorimeter is " << NbOfLayers << " layers of: [ "
<< AbsorberThickness/mm << "mm of " << AbsorberMaterial->GetName()
<< " + "
<< GapThickness/mm << "mm of " << GapMaterial->GetName() << " ] "
<< "\n------------------------------------------------------------\n";
}
// ----------------------------------------------------------------------------
void DetectorConstruction::SetAbsorberMaterial(G4String materialChoice)
{
// search the material by its name
G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
if (pttoMaterial) AbsorberMaterial = pttoMaterial;
}
// ----------------------------------------------------------------------------
void DetectorConstruction::SetGapMaterial(G4String materialChoice)
{
// search the material by its name
G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
if (pttoMaterial) GapMaterial = pttoMaterial;
}
// ----------------------------------------------------------------------------
void DetectorConstruction::SetAbsorberThickness(G4double val)
{
// change Absorber thickness and recompute the calorimeter parameters
AbsorberThickness = val;
}
// ----------------------------------------------------------------------------
void DetectorConstruction::SetGapThickness(G4double val)
{
// change Gap thickness and recompute the calorimeter parameters
GapThickness = val;
}
// ----------------------------------------------------------------------------
void DetectorConstruction::SetCalorSizeYZ(G4double val)
{
// change the transverse size and recompute the calorimeter parameters
CalorSizeYZ = val;
}
// ----------------------------------------------------------------------------
void DetectorConstruction::SetNbOfLayers(G4int val)
{
NbOfLayers = val;
}
// ----------------------------------------------------------------------------
void DetectorConstruction::SetMagField(G4double fieldValue)
{
//apply a global uniform magnetic field along Z axis
G4FieldManager* fieldMgr
= G4TransportationManager::GetTransportationManager()->GetFieldManager();
if(magField) delete magField; //delete the existing magn field
if(fieldValue!=0.) // create a new one if non nul
{ magField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
fieldMgr->SetDetectorField(magField);
fieldMgr->CreateChordFinder(magField);
} else {
magField = 0;
fieldMgr->SetDetectorField(magField);
}
}
// ----------------------------------------------------------------------------
void DetectorConstruction::UpdateGeometry()
{
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter());
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,146 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: DetectorMessenger.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
// ----------------------------------------------------------------------------
DetectorMessenger::DetectorMessenger( DetectorConstruction* Det )
: Detector(Det)
{
decDir = new G4UIdirectory("/decayer/");
decDir->SetGuidance("UI commands of this example");
detDir = new G4UIdirectory("/decayer/det/");
detDir->SetGuidance("detector control");
AbsMaterCmd = new G4UIcmdWithAString("/decayer/det/setAbsMat",this);
AbsMaterCmd->SetGuidance("Select Material of the Absorber.");
AbsMaterCmd->SetParameterName("choice",false);
AbsMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
GapMaterCmd = new G4UIcmdWithAString("/decayer/det/setGapMat",this);
GapMaterCmd->SetGuidance("Select Material of the Gap.");
GapMaterCmd->SetParameterName("choice",false);
GapMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
AbsThickCmd = new G4UIcmdWithADoubleAndUnit("/decayer/det/setAbsThick",this);
AbsThickCmd->SetGuidance("Set Thickness of the Absorber");
AbsThickCmd->SetParameterName("Size",false);
AbsThickCmd->SetRange("Size>=0.");
AbsThickCmd->SetUnitCategory("Length");
AbsThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
GapThickCmd = new G4UIcmdWithADoubleAndUnit("/decayer/det/setGapThick",this);
GapThickCmd->SetGuidance("Set Thickness of the Gap");
GapThickCmd->SetParameterName("Size",false);
GapThickCmd->SetRange("Size>=0.");
GapThickCmd->SetUnitCategory("Length");
GapThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
SizeYZCmd = new G4UIcmdWithADoubleAndUnit("/decayer/det/setSizeYZ",this);
SizeYZCmd->SetGuidance("Set tranverse size of the calorimeter");
SizeYZCmd->SetParameterName("Size",false);
SizeYZCmd->SetRange("Size>0.");
SizeYZCmd->SetUnitCategory("Length");
SizeYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
NbLayersCmd = new G4UIcmdWithAnInteger("/decayer/det/setNbOfLayers",this);
NbLayersCmd->SetGuidance("Set number of layers.");
NbLayersCmd->SetParameterName("NbLayers",false);
NbLayersCmd->SetRange("NbLayers>0 && NbLayers<500");
NbLayersCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
UpdateCmd = new G4UIcmdWithoutParameter("/decayer/det/update",this);
UpdateCmd->SetGuidance("Update calorimeter geometry.");
UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
UpdateCmd->SetGuidance("if you changed geometrical value(s).");
UpdateCmd->AvailableForStates(G4State_Idle);
MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/decayer/det/setField",this);
MagFieldCmd->SetGuidance("Define magnetic field.");
MagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
MagFieldCmd->SetParameterName("Bz",false);
MagFieldCmd->SetUnitCategory("Magnetic flux density");
MagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
// ----------------------------------------------------------------------------
DetectorMessenger::~DetectorMessenger()
{
delete NbLayersCmd;
delete AbsMaterCmd; delete GapMaterCmd;
delete AbsThickCmd; delete GapThickCmd;
delete SizeYZCmd; delete UpdateCmd;
delete MagFieldCmd;
delete detDir;
delete decDir;
}
// ----------------------------------------------------------------------------
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == AbsMaterCmd )
{ Detector->SetAbsorberMaterial(newValue);}
if( command == GapMaterCmd )
{ Detector->SetGapMaterial(newValue);}
if( command == AbsThickCmd )
{ Detector->SetAbsorberThickness(AbsThickCmd->GetNewDoubleValue(newValue));}
if( command == GapThickCmd )
{ Detector->SetGapThickness(GapThickCmd->GetNewDoubleValue(newValue));}
if( command == SizeYZCmd )
{ Detector->SetCalorSizeYZ(SizeYZCmd->GetNewDoubleValue(newValue));}
if( command == NbLayersCmd )
{ Detector->SetNbOfLayers(NbLayersCmd->GetNewIntValue(newValue));}
if( command == UpdateCmd )
{ Detector->UpdateGeometry(); }
if( command == MagFieldCmd )
{ Detector->SetMagField(MagFieldCmd->GetNewDoubleValue(newValue));}
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,108 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: EventAction.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#include "EventAction.hh"
#include "RunAction.hh"
#include "EventActionMessenger.hh"
#include "G4Event.hh"
#include "G4TrajectoryContainer.hh"
#include "G4VTrajectory.hh"
#include "G4VVisManager.hh"
#include "G4UnitsTable.hh"
#include "Randomize.hh"
#include <iomanip>
// ----------------------------------------------------------------------------
EventAction::EventAction(RunAction* run)
: runAct(run),printModulo(1),eventMessenger(0)
{
eventMessenger = new EventActionMessenger(this);
}
// ----------------------------------------------------------------------------
EventAction::~EventAction()
{
delete eventMessenger;
}
// ----------------------------------------------------------------------------
void EventAction::BeginOfEventAction(const G4Event* evt)
{
G4int evtNb = evt->GetEventID();
if (evtNb%printModulo == 0)
{
G4cout << "\n---> Begin of event: " << evtNb << G4endl;
CLHEP::HepRandom::showEngineStatus();
}
// initialisation per event
//
EnergyAbs = EnergyGap = 0.;
TrackLAbs = TrackLGap = 0.;
}
// ----------------------------------------------------------------------------
void EventAction::EndOfEventAction(const G4Event* evt)
{
// accumulates statistic
//
runAct->fillPerEvent(EnergyAbs, EnergyGap, TrackLAbs, TrackLGap);
// print per event (modulo n)
//
G4int evtNb = evt->GetEventID();
if (evtNb%printModulo == 0)
{
G4cout << "---> End of event: " << evtNb << G4endl;
G4cout
<< " Absorber: total energy: " << std::setw(7)
<< G4BestUnit(EnergyAbs,"Energy")
<< " total track length: " << std::setw(7)
<< G4BestUnit(TrackLAbs,"Length")
<< G4endl
<< " Gap: total energy: " << std::setw(7)
<< G4BestUnit(EnergyGap,"Energy")
<< " total track length: " << std::setw(7)
<< G4BestUnit(TrackLGap,"Length")
<< G4endl;
}
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,72 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: EventActionMessenger.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#include "EventActionMessenger.hh"
#include "EventAction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "globals.hh"
// ----------------------------------------------------------------------------
EventActionMessenger::EventActionMessenger(EventAction* EvAct)
: eventAction(EvAct)
{
eventDir = new G4UIdirectory("/decayer/event/");
eventDir->SetGuidance("event control");
PrintCmd = new G4UIcmdWithAnInteger("/decayer/event/printModulo",this);
PrintCmd->SetGuidance("Print events modulo n");
PrintCmd->SetParameterName("EventNb",false);
PrintCmd->SetRange("EventNb>0");
}
// ----------------------------------------------------------------------------
EventActionMessenger::~EventActionMessenger()
{
delete PrintCmd;
delete eventDir;
}
// ----------------------------------------------------------------------------
void EventActionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if(command == PrintCmd)
{
eventAction->SetPrintModulo(PrintCmd->GetNewIntValue(newValue));
}
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,610 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: G4Pythia6Decayer.cc,v 1.3 2008/12/18 12:56:38 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// According to TPythia6Decayer class in Root:
// http://root.cern.ch/
// see http://root.cern.ch/root/License.html
// ----------------------------------------------------------------------------
#include "G4Pythia6Decayer.hh"
#include "Pythia6.hh"
#include "G4DynamicParticle.hh"
#include "G4DecayProducts.hh"
#include "G4DecayTable.hh"
#include "G4ParticleTable.hh"
#include "G4DynamicParticle.hh"
#include "G4Track.hh"
#include <CLHEP/Vector/LorentzVector.h>
#include <cmath>
const EDecayType G4Pythia6Decayer::fgkDefaultDecayType = kAll;
//_____________________________________________________________________________
G4Pythia6Decayer::G4Pythia6Decayer()
: G4VExtDecayer("G4Pythia6Decayer"),
fMessenger(this),
fVerboseLevel(0),
fDecayType(fgkDefaultDecayType),
fDecayProductsArray(0)
{
/// Standard constructor
fDecayProductsArray = new ParticleVector();
ForceDecay(fDecayType);
}
//_____________________________________________________________________________
G4Pythia6Decayer::~G4Pythia6Decayer()
{
/// Destructor
delete fDecayProductsArray;
}
//
// private methods
//
//_____________________________________________________________________________
G4ParticleDefinition* G4Pythia6Decayer::
GetParticleDefinition(const Pythia6Particle* particle, G4bool warn) const
{
/// Return G4 particle definition for given TParticle
// get particle definition from G4ParticleTable
G4int pdgEncoding = particle->fKF;
G4ParticleTable* particleTable
= G4ParticleTable::GetParticleTable();
G4ParticleDefinition* particleDefinition = 0;
if (pdgEncoding != 0)
particleDefinition = particleTable->FindParticle(pdgEncoding);
if ( particleDefinition == 0 && warn) {
std::cerr
<< "G4Pythia6Decayer: GetParticleDefinition: " << std::endl
<< "G4ParticleTable::FindParticle() for particle with PDG = "
<< pdgEncoding
<< " failed." << std::endl;
}
return particleDefinition;
}
//_____________________________________________________________________________
G4DynamicParticle*
G4Pythia6Decayer::CreateDynamicParticle(const Pythia6Particle* particle) const
{
/// Create G4DynamicParticle.
// get particle properties
G4ParticleDefinition* particleDefinition
= GetParticleDefinition(particle);
if ( ! particleDefinition ) return 0;
G4ThreeVector momentum = GetParticleMomentum(particle);
// create G4DynamicParticle
G4DynamicParticle* dynamicParticle
= new G4DynamicParticle(particleDefinition, momentum);
return dynamicParticle;
}
//_____________________________________________________________________________
G4ThreeVector G4Pythia6Decayer::GetParticlePosition(
const Pythia6Particle* particle) const
{
/// Return particle vertex position.
G4ThreeVector position
= G4ThreeVector(particle->fVx * cm,
particle->fVy * cm,
particle->fVz * cm);
return position;
}
//_____________________________________________________________________________
G4ThreeVector G4Pythia6Decayer::GetParticleMomentum(
const Pythia6Particle* particle) const
{
/// Return particle momentum.
G4ThreeVector momentum
= G4ThreeVector(particle->fPx * GeV,
particle->fPy * GeV,
particle->fPz * GeV);
return momentum;
}
//______________________________________________________________________________
G4int G4Pythia6Decayer::CountProducts(G4int channel, G4int particle)
{
/// Count number of decay products
G4int np = 0;
for ( G4int i=1; i<=5; i++ )
if ( std::abs(Pythia6::Instance()->GetKFDP(channel,i) ) == particle ) np++;
return np;
}
//______________________________________________________________________________
void
G4Pythia6Decayer::ForceParticleDecay(G4int particle, G4int product, G4int mult)
{
/// Force decay of particle into products with multiplicity mult
Pythia6* pythia6 = Pythia6::Instance();
G4int kc = pythia6->Pycomp(particle);
pythia6->SetMDCY(kc,1,1);
G4int ifirst = pythia6->GetMDCY(kc,2);
G4int ilast = ifirst + pythia6->GetMDCY(kc,3)-1;
//
// Loop over decay channels
for (G4int channel= ifirst; channel <= ilast; channel++) {
if (CountProducts(channel,product) >= mult) {
pythia6->SetMDME(channel,1,1);
} else {
pythia6->SetMDME(channel,1,0);
}
}
}
//______________________________________________________________________________
void G4Pythia6Decayer::ForceParticleDecay(G4int particle, G4int* products,
G4int* mult, G4int npart)
{
/// Force decay of particle into products with multiplicity mult
Pythia6* pythia6 = Pythia6::Instance();
G4int kc = pythia6->Pycomp(particle);
pythia6->SetMDCY(kc,1,1);
G4int ifirst = pythia6->GetMDCY(kc,2);
G4int ilast = ifirst+pythia6->GetMDCY(kc,3)-1;
//
// Loop over decay channels
for (G4int channel = ifirst; channel <= ilast; channel++) {
G4int nprod = 0;
for (G4int i = 0; i < npart; i++)
nprod += (CountProducts(channel, products[i]) >= mult[i]);
if (nprod)
pythia6->SetMDME(channel,1,1);
else {
pythia6->SetMDME(channel,1,0);
}
}
}
//______________________________________________________________________________
void G4Pythia6Decayer::ForceHadronicD()
{
/// Force golden D decay modes
const G4int kNHadrons = 4;
G4int channel;
G4int hadron[kNHadrons] = {411, 421, 431, 4112};
// for D+ -> K0* (-> K- pi+) pi+
G4int iKstar0 = 313;
G4int iKstarbar0 = -313;
G4int iKPlus = 321;
G4int iKMinus = -321;
G4int iPiPlus = 211;
G4int iPiMinus = -211;
G4int products[2] = {iKPlus, iPiMinus}, mult[2] = {1, 1};
ForceParticleDecay(iKstar0, products, mult, 2);
// for Ds -> Phi pi+
G4int iPhi = 333;
ForceParticleDecay(iPhi,iKPlus,2); // Phi->K+K-
G4int decayP1[kNHadrons][3] = {
{iKMinus, iPiPlus, iPiPlus},
{iKMinus, iPiPlus, 0 },
{iKPlus , iKstarbar0, 0 },
{-1 , -1 , -1 }
};
G4int decayP2[kNHadrons][3] = {
{iKstarbar0, iPiPlus, 0 },
{-1 , -1 , -1 },
{iPhi , iPiPlus, 0 },
{-1 , -1 , -1 }
};
Pythia6* pythia6 = Pythia6::Instance();
for ( G4int ihadron = 0; ihadron < kNHadrons; ihadron++ ) {
G4int kc = pythia6->Pycomp(hadron[ihadron]);
pythia6->SetMDCY(kc,1,1);
G4int ifirst = pythia6->GetMDCY(kc,2);
G4int ilast = ifirst + pythia6->GetMDCY(kc,3)-1;
for (channel = ifirst; channel <= ilast; channel++) {
if ((pythia6->GetKFDP(channel,1) == decayP1[ihadron][0] &&
pythia6->GetKFDP(channel,2) == decayP1[ihadron][1] &&
pythia6->GetKFDP(channel,3) == decayP1[ihadron][2] &&
pythia6->GetKFDP(channel,4) == 0) ||
(pythia6->GetKFDP(channel,1) == decayP2[ihadron][0] &&
pythia6->GetKFDP(channel,2) == decayP2[ihadron][1] &&
pythia6->GetKFDP(channel,3) == decayP2[ihadron][2] &&
pythia6->GetKFDP(channel,4) == 0)) {
pythia6->SetMDME(channel,1,1);
} else {
pythia6->SetMDME(channel,1,0);
} // selected channel ?
} // decay channels
} // hadrons
}
//______________________________________________________________________________
void G4Pythia6Decayer::ForceOmega()
{
/// Force Omega -> Lambda K- Decay
Pythia6* pythia6 = Pythia6::Instance();
G4int iLambda0 = 3122;
G4int iKMinus = -321;
G4int kc = pythia6->Pycomp(3334);
pythia6->SetMDCY(kc,1,1);
G4int ifirst = pythia6->GetMDCY(kc,2);
G4int ilast = ifirst + pythia6->GetMDCY(kc,3)-1;
for (G4int channel = ifirst; channel <= ilast; channel++) {
if (pythia6->GetKFDP(channel,1) == iLambda0 &&
pythia6->GetKFDP(channel,2) == iKMinus &&
pythia6->GetKFDP(channel,3) == 0)
pythia6->SetMDME(channel,1,1);
else
pythia6->SetMDME(channel,1,0);
// selected channel ?
} // decay channels
}
//______________________________________________________________________________
void G4Pythia6Decayer::ForceDecay(EDecayType decayType)
{
/// Force a particle decay mode
Pythia6::Instance()->SetMSTJ(21,2);
if ( fDecayType == kNoDecayHeavy ) return;
//
// select mode
G4int products[3];
G4int mult[3];
switch ( decayType ) {
case kHardMuons:
products[0] = 13;
products[1] = 443;
products[2] = 100443;
mult[0] = 1;
mult[1] = 1;
mult[2] = 1;
ForceParticleDecay( 511, products, mult, 3);
ForceParticleDecay( 521, products, mult, 3);
ForceParticleDecay( 531, products, mult, 3);
ForceParticleDecay( 5122, products, mult, 3);
ForceParticleDecay( 5132, products, mult, 3);
ForceParticleDecay( 5232, products, mult, 3);
ForceParticleDecay( 5332, products, mult, 3);
ForceParticleDecay( 100443, 443, 1); // Psi' -> J/Psi X
ForceParticleDecay( 443, 13, 2); // J/Psi -> mu+ mu-
ForceParticleDecay( 411,13,1); // D+/-
ForceParticleDecay( 421,13,1); // D0
ForceParticleDecay( 431,13,1); // D_s
ForceParticleDecay( 4122,13,1); // Lambda_c
ForceParticleDecay( 4132,13,1); // Xsi_c
ForceParticleDecay( 4232,13,1); // Sigma_c
ForceParticleDecay( 4332,13,1); // Omega_c
break;
case kSemiMuonic:
ForceParticleDecay( 411,13,1); // D+/-
ForceParticleDecay( 421,13,1); // D0
ForceParticleDecay( 431,13,1); // D_s
ForceParticleDecay( 4122,13,1); // Lambda_c
ForceParticleDecay( 4132,13,1); // Xsi_c
ForceParticleDecay( 4232,13,1); // Sigma_c
ForceParticleDecay( 4332,13,1); // Omega_c
ForceParticleDecay( 511,13,1); // B0
ForceParticleDecay( 521,13,1); // B+/-
ForceParticleDecay( 531,13,1); // B_s
ForceParticleDecay( 5122,13,1); // Lambda_b
ForceParticleDecay( 5132,13,1); // Xsi_b
ForceParticleDecay( 5232,13,1); // Sigma_b
ForceParticleDecay( 5332,13,1); // Omega_b
break;
case kDiMuon:
ForceParticleDecay( 113,13,2); // rho
ForceParticleDecay( 221,13,2); // eta
ForceParticleDecay( 223,13,2); // omega
ForceParticleDecay( 333,13,2); // phi
ForceParticleDecay( 443,13,2); // J/Psi
ForceParticleDecay(100443,13,2);// Psi'
ForceParticleDecay( 553,13,2); // Upsilon
ForceParticleDecay(100553,13,2);// Upsilon'
ForceParticleDecay(200553,13,2);// Upsilon''
break;
case kSemiElectronic:
ForceParticleDecay( 411,11,1); // D+/-
ForceParticleDecay( 421,11,1); // D0
ForceParticleDecay( 431,11,1); // D_s
ForceParticleDecay( 4122,11,1); // Lambda_c
ForceParticleDecay( 4132,11,1); // Xsi_c
ForceParticleDecay( 4232,11,1); // Sigma_c
ForceParticleDecay( 4332,11,1); // Omega_c
ForceParticleDecay( 511,11,1); // B0
ForceParticleDecay( 521,11,1); // B+/-
ForceParticleDecay( 531,11,1); // B_s
ForceParticleDecay( 5122,11,1); // Lambda_b
ForceParticleDecay( 5132,11,1); // Xsi_b
ForceParticleDecay( 5232,11,1); // Sigma_b
ForceParticleDecay( 5332,11,1); // Omega_b
break;
case kDiElectron:
ForceParticleDecay( 113,11,2); // rho
ForceParticleDecay( 333,11,2); // phi
ForceParticleDecay( 221,11,2); // eta
ForceParticleDecay( 223,11,2); // omega
ForceParticleDecay( 443,11,2); // J/Psi
ForceParticleDecay(100443,11,2);// Psi'
ForceParticleDecay( 553,11,2); // Upsilon
ForceParticleDecay(100553,11,2);// Upsilon'
ForceParticleDecay(200553,11,2);// Upsilon''
break;
case kBJpsiDiMuon:
products[0] = 443;
products[1] = 100443;
mult[0] = 1;
mult[1] = 1;
ForceParticleDecay( 511, products, mult, 2); // B0 -> J/Psi (Psi') X
ForceParticleDecay( 521, products, mult, 2); // B+/- -> J/Psi (Psi') X
ForceParticleDecay( 531, products, mult, 2); // B_s -> J/Psi (Psi') X
ForceParticleDecay( 5122, products, mult, 2); // Lambda_b -> J/Psi (Psi')X
ForceParticleDecay( 100443, 443, 1); // Psi' -> J/Psi X
ForceParticleDecay( 443,13,2); // J/Psi -> mu+ mu-
break;
case kBPsiPrimeDiMuon:
ForceParticleDecay( 511,100443,1); // B0
ForceParticleDecay( 521,100443,1); // B+/-
ForceParticleDecay( 531,100443,1); // B_s
ForceParticleDecay( 5122,100443,1); // Lambda_b
ForceParticleDecay(100443,13,2); // Psi'
break;
case kBJpsiDiElectron:
ForceParticleDecay( 511,443,1); // B0
ForceParticleDecay( 521,443,1); // B+/-
ForceParticleDecay( 531,443,1); // B_s
ForceParticleDecay( 5122,443,1); // Lambda_b
ForceParticleDecay( 443,11,2); // J/Psi
break;
case kBJpsi:
ForceParticleDecay( 511,443,1); // B0
ForceParticleDecay( 521,443,1); // B+/-
ForceParticleDecay( 531,443,1); // B_s
ForceParticleDecay( 5122,443,1); // Lambda_b
break;
case kBPsiPrimeDiElectron:
ForceParticleDecay( 511,100443,1); // B0
ForceParticleDecay( 521,100443,1); // B+/-
ForceParticleDecay( 531,100443,1); // B_s
ForceParticleDecay( 5122,100443,1); // Lambda_b
ForceParticleDecay(100443,11,2); // Psi'
break;
case kPiToMu:
ForceParticleDecay(211,13,1); // pi->mu
break;
case kKaToMu:
ForceParticleDecay(321,13,1); // K->mu
break;
case kWToMuon:
ForceParticleDecay( 24, 13,1); // W -> mu
break;
case kWToCharm:
ForceParticleDecay( 24, 4,1); // W -> c
break;
case kWToCharmToMuon:
ForceParticleDecay( 24, 4,1); // W -> c
ForceParticleDecay( 411,13,1); // D+/- -> mu
ForceParticleDecay( 421,13,1); // D0 -> mu
ForceParticleDecay( 431,13,1); // D_s -> mu
ForceParticleDecay( 4122,13,1); // Lambda_c
ForceParticleDecay( 4132,13,1); // Xsi_c
ForceParticleDecay( 4232,13,1); // Sigma_c
ForceParticleDecay( 4332,13,1); // Omega_c
break;
case kZDiMuon:
ForceParticleDecay( 23, 13,2); // Z -> mu+ mu-
break;
case kHadronicD:
ForceHadronicD();
break;
case kPhiKK:
ForceParticleDecay(333,321,2); // Phi->K+K-
break;
case kOmega:
ForceOmega();
case kAll:
break;
case kNoDecay:
Pythia6::Instance()->SetMSTJ(21,0);
break;
case kNoDecayHeavy: break;
case kMaxDecay: break;
}
}
//______________________________________________________________________________
void G4Pythia6Decayer::Decay(G4int pdg, const CLHEP::HepLorentzVector& p)
{
/// Decay a particle of type IDPART (PDG code) and momentum P.
Pythia6::Instance()->Py1ent(0, pdg, p.e(), p.theta(), p.phi());
}
//______________________________________________________________________________
G4int G4Pythia6Decayer::ImportParticles(ParticleVector* particles)
{
/// Get the decay products into the passed PARTICLES vector
return Pythia6::Instance()->ImportParticles(particles,"All");
}
//
// public methods
//
//_____________________________________________________________________________
G4DecayProducts* G4Pythia6Decayer::ImportDecayProducts(const G4Track& track)
{
/// Import decay products
// get particle momentum
G4ThreeVector momentum = track.GetMomentum();
G4double etot = track.GetDynamicParticle()->GetTotalEnergy();;
CLHEP::HepLorentzVector p;
p[0] = momentum.x() / GeV;
p[1] = momentum.y() / GeV;
p[2] = momentum.z() / GeV;
p[3] = etot / GeV;
// get particle PDG
// ask G4Pythia6Decayer to get PDG encoding
// (in order to get PDG from extended TDatabasePDG
// in case the standard PDG code is not defined)
G4ParticleDefinition* particleDef = track.GetDefinition();
G4int pdgEncoding = particleDef->GetPDGEncoding();
// let Pythia6Decayer decay the particle
// and import the decay products
Decay(pdgEncoding, p);
G4int nofParticles = ImportParticles(fDecayProductsArray);
if ( fVerboseLevel > 1 ) {
G4cout << "nofParticles: " << nofParticles << G4endl;
}
// convert decay products Pythia6Particle type
// to G4DecayProducts
G4DecayProducts* decayProducts
= new G4DecayProducts(*(track.GetDynamicParticle()));
G4int counter = 0;
for (G4int i=0; i<nofParticles; i++) {
// get particle from ParticleVector
Pythia6Particle* particle = (*fDecayProductsArray)[i];
G4int status = particle->fKS;
G4int pdg = particle->fKF;
if ( status>0 && status<11 &&
std::abs(pdg)!=12 && std::abs(pdg)!=14 && std::abs(pdg)!=16 ) {
// pass to tracking final particles only;
// skip neutrinos
if ( fVerboseLevel > 1 ) {
G4cout << " " << i << "th particle PDG: " << pdg << " ";
}
// create G4DynamicParticle
G4DynamicParticle* dynamicParticle
= CreateDynamicParticle(particle);
if (dynamicParticle) {
if ( fVerboseLevel > 1 ) {
G4cout << " G4 particle name: "
<< dynamicParticle->GetDefinition()->GetParticleName()
<< G4endl;
}
// add dynamicParticle to decayProducts
decayProducts->PushProducts(dynamicParticle);
counter++;
}
}
}
if ( fVerboseLevel > 1 ) {
G4cout << "nofParticles for tracking: " << counter << G4endl;
}
return decayProducts;
}
//_____________________________________________________________________________
void G4Pythia6Decayer::ForceDecayType(EDecayType decayType)
{
/// Force a given decay type
// Do nothing if the decay type is not different from current one
if ( decayType == fDecayType ) return;
fDecayType = decayType;
ForceDecay(fDecayType);
}
@@ -0,0 +1,104 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: G4Pythia6DecayerMessenger.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// Messenger class that defines commands for G4Pythia6Decayer.
//
// Implements command
// - /pythia6Decayer/verbose [level]
// - /pythia6Decayer/forceDecayType [decayType]
// ----------------------------------------------------------------------------
#include "G4Pythia6DecayerMessenger.hh"
#include "G4Pythia6Decayer.hh"
#include "EDecayType.hh"
#include <G4UIdirectory.hh>
#include <G4UIcmdWithAnInteger.hh>
#include <sstream>
//_____________________________________________________________________________
G4Pythia6DecayerMessenger::G4Pythia6DecayerMessenger(
G4Pythia6Decayer* pythia6Decayer)
: G4UImessenger(),
fPythia6Decayer(pythia6Decayer),
fDirectory(0),
fVerboseCmd(0),
fDecayTypeCmd(0)
{
/// Standard constructor
fDirectory = new G4UIdirectory("/pythia6Decayer/");
fDirectory->SetGuidance("G4Pythia6Decayer control commands.");
fVerboseCmd = new G4UIcmdWithAnInteger("/pythia6Decayer/verbose", this);
fVerboseCmd->SetGuidance("Set Pythia6Decayer verbose level");
fVerboseCmd->SetParameterName("VerboseLevel", false);
fVerboseCmd->SetRange("VerboseLevel >= 0 && VerboseLevel <= 5");
fVerboseCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle);
fDecayTypeCmd = new G4UIcmdWithAnInteger("/pythia6Decayer/forceDecayType", this);
fDecayTypeCmd->SetGuidance("Force the specified decay type");
fDecayTypeCmd->SetParameterName("DecayType", false);
std::ostringstream os;
os << "DecayType >= " << kSemiElectronic
<< " && DecayType <= " << kMaxDecay;
fDecayTypeCmd->SetRange(os.str().c_str());
fDecayTypeCmd->AvailableForStates(G4State_PreInit,G4State_Init,G4State_Idle);
}
//_____________________________________________________________________________
G4Pythia6DecayerMessenger::~G4Pythia6DecayerMessenger()
{
/// Destructor
delete fDirectory;
delete fVerboseCmd;
delete fDecayTypeCmd;
}
//
// public methods
//
//_____________________________________________________________________________
void G4Pythia6DecayerMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
/// Apply command to the associated object.
if(command == fVerboseCmd) {
fPythia6Decayer
->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue));
}
else if(command == fDecayTypeCmd) {
fPythia6Decayer
->ForceDecayType(EDecayType(fDecayTypeCmd->GetNewIntValue(newValue)));
}
}
@@ -0,0 +1,256 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: PhysicsList.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#include "PhysicsList.hh"
#include "G4ProcessManager.hh"
#include "G4ParticleTypes.hh"
#include "G4Pythia6Decayer.hh"
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4MultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MuIonisation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4hIonisation.hh"
#include "G4Decay.hh"
// ----------------------------------------------------------------------------
PhysicsList::PhysicsList(): G4VUserPhysicsList()
{
defaultCutValue = 1.0*mm;
SetVerboseLevel(1);
}
// ----------------------------------------------------------------------------
PhysicsList::~PhysicsList()
{
}
// ----------------------------------------------------------------------------
void PhysicsList::ConstructParticle()
{
// In this method, static member functions should be called
// for all particles which you want to use.
// This ensures that objects of these particle types will be
// created in the program.
ConstructBosons();
ConstructLeptons();
ConstructMesons();
ConstructBaryons();
}
// ----------------------------------------------------------------------------
void PhysicsList::ConstructBosons()
{
// pseudo-particles
G4Geantino::GeantinoDefinition();
G4ChargedGeantino::ChargedGeantinoDefinition();
// gamma
G4Gamma::GammaDefinition();
// optical photon
G4OpticalPhoton::OpticalPhotonDefinition();
}
// ----------------------------------------------------------------------------
void PhysicsList::ConstructLeptons()
{
// leptons
G4Electron::ElectronDefinition();
G4Positron::PositronDefinition();
G4MuonPlus::MuonPlusDefinition();
G4MuonMinus::MuonMinusDefinition();
G4NeutrinoE::NeutrinoEDefinition();
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
G4NeutrinoMu::NeutrinoMuDefinition();
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
}
// ----------------------------------------------------------------------------
void PhysicsList::ConstructMesons()
{
// mesons
G4PionPlus::PionPlusDefinition();
G4PionMinus::PionMinusDefinition();
G4PionZero::PionZeroDefinition();
G4Eta::EtaDefinition();
G4EtaPrime::EtaPrimeDefinition();
G4KaonPlus::KaonPlusDefinition();
G4KaonMinus::KaonMinusDefinition();
G4KaonZero::KaonZeroDefinition();
G4AntiKaonZero::AntiKaonZeroDefinition();
G4KaonZeroLong::KaonZeroLongDefinition();
G4KaonZeroShort::KaonZeroShortDefinition();
G4BMesonMinus::BMesonMinusDefinition();
G4BMesonPlus::BMesonPlusDefinition();
G4BMesonZero::BMesonZeroDefinition();
}
// ----------------------------------------------------------------------------
void PhysicsList::ConstructBaryons()
{
// barions
G4Proton::ProtonDefinition();
G4AntiProton::AntiProtonDefinition();
G4Neutron::NeutronDefinition();
G4AntiNeutron::AntiNeutronDefinition();
}
// ----------------------------------------------------------------------------
void PhysicsList::ConstructProcess()
{
AddTransportation();
ConstructEM();
ConstructDecay();
}
// ----------------------------------------------------------------------------
void PhysicsList::ConstructEM()
{
theParticleIterator->reset();
while( (*theParticleIterator)() )
{
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
if (particleName == "gamma") {
// gamma
pmanager->AddDiscreteProcess(new G4PhotoElectricEffect);
pmanager->AddDiscreteProcess(new G4ComptonScattering);
pmanager->AddDiscreteProcess(new G4GammaConversion);
} else if (particleName == "e-") {
//electron
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
} else if (particleName == "e+") {
//positron
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,4);
} else if( particleName == "mu+" ||
particleName == "mu-" ) {
//muon
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4MuIonisation, -1, 2,2);
pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3,3);
pmanager->AddProcess(new G4MuPairProduction, -1, 4,4);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4hIonisation, -1, 2,2);
}
}
}
// ----------------------------------------------------------------------------
void PhysicsList::ConstructDecay()
{
// Add Decay Process
G4Decay* theDecayProcess = new G4Decay();
// Create Geant4 external decayer
G4Pythia6Decayer* extDecayer = new G4Pythia6Decayer();
extDecayer->SetVerboseLevel(2);
// The extDecayer is deleted in G4Decay destructor
theDecayProcess->SetExtDecayer(extDecayer);
theParticleIterator->reset();
while( (*theParticleIterator)() )
{
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (theDecayProcess->IsApplicable(*particle))
{
pmanager ->AddProcess(theDecayProcess);
// set ordering for PostStepDoIt and AtRestDoIt
pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
}
}
}
// ----------------------------------------------------------------------------
void PhysicsList::SetCuts()
{
if (verboseLevel >0)
{
G4cout << "PhysicsList::SetCuts:";
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
}
// set cut values for gamma at first and for e- second and next for e+,
// because some processes for e+/e- need cut values for gamma
//
SetCutValue(defaultCutValue, "gamma");
SetCutValue(defaultCutValue, "e-");
SetCutValue(defaultCutValue, "e+");
if (verboseLevel>0) DumpCutValuesTable();
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,96 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: PrimaryGeneratorAction.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#include "PrimaryGeneratorAction.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorMessenger.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "Randomize.hh"
// ----------------------------------------------------------------------------
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* DC)
: Detector(DC), rndmFlag("off")
{
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
//create a messenger for this class
gunMessenger = new PrimaryGeneratorMessenger(this);
// default particle kinematic
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
//G4ParticleDefinition* particle
// = particleTable->FindParticle(particleName="e-");
G4ParticleDefinition* particle
= particleTable->FindParticle(particleName="B-");
particleGun->SetParticleDefinition(particle);
particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
particleGun->SetParticleEnergy(50.*MeV);
G4double position = -0.5*(Detector->GetWorldSizeX());
particleGun->SetParticlePosition(G4ThreeVector(position,0.*cm,0.*cm));
}
// ----------------------------------------------------------------------------
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete particleGun;
delete gunMessenger;
}
// ----------------------------------------------------------------------------
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
//this function is called at the begining of event
//
G4double x0 = -0.5*(Detector->GetWorldSizeX());
G4double y0 = 0.*cm, z0 = 0.*cm;
if (rndmFlag == "on")
{
y0 = (Detector->GetCalorSizeYZ())*(G4UniformRand()-0.5);
z0 = (Detector->GetCalorSizeYZ())*(G4UniformRand()-0.5);
}
particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
particleGun->GeneratePrimaryVertex(anEvent);
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,75 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: PrimaryGeneratorMessenger.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#include "PrimaryGeneratorMessenger.hh"
#include "PrimaryGeneratorAction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
// ----------------------------------------------------------------------------
PrimaryGeneratorMessenger::
PrimaryGeneratorMessenger(PrimaryGeneratorAction* Gun)
: Action(Gun)
{
gunDir = new G4UIdirectory("/decayer/gun/");
gunDir->SetGuidance("PrimaryGenerator control");
RndmCmd = new G4UIcmdWithAString("/decayer/gun/rndm",this);
RndmCmd->SetGuidance("Shoot randomly the incident particle.");
RndmCmd->SetGuidance(" Choice : on(default), off");
RndmCmd->SetParameterName("choice",true);
RndmCmd->SetDefaultValue("on");
RndmCmd->SetCandidates("on off");
RndmCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
// ----------------------------------------------------------------------------
PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
{
delete RndmCmd;
delete gunDir;
}
// ----------------------------------------------------------------------------
void
PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == RndmCmd )
{
Action->SetRndmFlag(newValue);
}
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,265 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: Pythia6.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// According to TPythia6 class from Root:
// (The TPythia6 class is an interface class to F77 routines in Pythia6 //
// CERNLIB event generators, written by T.Sjostrand.)
// http://root.cern.ch/
// see http://root.cern.ch/root/License.html
//
// The complete Pythia6 documentation can be found at:
// http://home.thep.lu.se/~torbjorn/pythiaaux/recent.html
// ----------------------------------------------------------------------------
// ******************************************************************************
// ******************************************************************************
// ** **
// ** **
// ** *......* Welcome to the Lund Monte Carlo! **
// ** *:::!!:::::::::::* **
// ** *::::::!!::::::::::::::* PPP Y Y TTTTT H H III A **
// ** *::::::::!!::::::::::::::::* P P Y Y T H H I A A **
// ** *:::::::::!!:::::::::::::::::* PPP Y T HHHHH I AAAAA **
// ** *:::::::::!!:::::::::::::::::* P Y T H H I A A **
// ** *::::::::!!::::::::::::::::*! P Y T H H III A A **
// ** *::::::!!::::::::::::::* !! **
// ** !! *:::!!:::::::::::* !! This is PYTHIA version 6.418 **
// ** !! !* -><- * !! Last date of change: 9 Jun 2008 **
// ** !! !! !! **
// ** !! !! !! Now is 0 Jan 2000 at 0:00:00 **
// ** !! !! **
// ** !! lh !! Disclaimer: this program comes **
// ** !! !! without any guarantees. Beware **
// ** !! hh !! of errors and use common sense **
// ** !! ll !! when interpreting results. **
// ** !! !! **
// ** !! Copyright T. Sjostrand (2008) **
// ** **
// ** An archive of program versions and documentation is found on the web: **
// ** http://www.thep.lu.se/~torbjorn/Pythia.html **
// ** **
// ** When you cite this program, the official reference is to the 6.4 manual: **
// ** T. Sjostrand, S. Mrenna and P. Skands, JHEP05 (2006) 026 **
// ** (LU TP 06-13, FERMILAB-PUB-06-052-CD-T) [hep-ph/0603175]. **
// ** **
// ** Also remember that the program, to a large extent, represents original **
// ** physics research. Other publications of special relevance to your **
// ** studies may therefore deserve separate mention. **
// ** **
// ** Main author: Torbjorn Sjostrand; Department of Theoretical Physics, **
// ** Lund University, Solvegatan 14A, S-223 62 Lund, Sweden; **
// ** phone: + 46 - 46 - 222 48 16; e-mail: torbjorn@thep.lu.se **
// ** Author: Stephen Mrenna; Computing Division, GDS Group, **
// ** Fermi National Accelerator Laboratory, MS 234, Batavia, IL 60510, USA; **
// ** phone: + 1 - 630 - 840 - 2556; e-mail: mrenna@fnal.gov **
// ** Author: Peter Skands; Theoretical Physics Department, **
// ** Fermi National Accelerator Laboratory, MS 106, Batavia, IL 60510, USA; **
// ** and CERN/PH, CH-1211 Geneva, Switzerland; **
// ** phone: + 41 - 22 - 767 24 59; e-mail: skands@fnal.gov **
// ** **
// ** **
// ******************************************************************************
#include "Pythia6.hh"
#include <iostream>
#ifndef WIN32
# define pycomp pycomp_
# define py1ent py1ent_
# define type_of_call
#else
# define pycomp PYCOMP
# define py1ent PY1ENT
# define type_of_call _stdcall
#endif
extern "C" {
int type_of_call pycomp(int *kf);
void type_of_call py1ent(int&, int&, double&, double&, double&);
void* pythia6_common_address(const char*);
}
Pythia6* Pythia6::fgInstance = 0;
//______________________________________________________________________________
Pythia6* Pythia6::Instance()
{
/// Static access method
if ( ! fgInstance ) fgInstance = new Pythia6();
return fgInstance;
}
//______________________________________________________________________________
Pythia6::Pythia6()
: fParticles(0)
{
/// Pythia6 constructor: creates a vector of Pythia6Particle in which it will store all
/// particles. Note that there may be only one functional Pythia6 object
/// at a time, so it's not use to create more than one instance of it.
// Protect against multiple objects. All access should be via the
// Instance member function.
if ( fgInstance ) {
std::cerr << "There's already an instance of Pythia6" << std::endl;
exit (1);
}
fParticles = new ParticleVector();
// initialize common-blocks
fPyjets = (Pyjets_t*) pythia6_common_address("PYJETS");
fPydat1 = (Pydat1_t*) pythia6_common_address("PYDAT1");
fPydat3 = (Pydat3_t*) pythia6_common_address("PYDAT3");
}
//______________________________________________________________________________
Pythia6::~Pythia6()
{
/// Destroy the object, delete and dispose all Pythia6Particles currently on list.
if ( fParticles ) {
ParticleVector::const_iterator it;
for ( it = fParticles->begin(); it != fParticles->end(); it++ )
delete *it;
delete fParticles;
}
}
//______________________________________________________________________________
int Pythia6::Pycomp(int kf)
{
/// Interface with fortran routine pycomp
return pycomp(&kf);
}
//______________________________________________________________________________
void Pythia6::Py1ent(int ip, int kf, double pe, double theta, double phi)
{
/// Add one entry to the event record, i.e. either a parton or a
/// particle.
///
/// IP: normally line number for the parton/particle. There are two
/// exceptions:
///
/// If IP = 0: line number 1 is used and PYEXEC is called.
/// If IP < 0: line -IP is used, with status code K(-IP,2)=2
/// rather than 1; thus a parton system may be built
/// up by filling all but the last parton of the
/// system with IP < 0.
/// KF: parton/particle flavour code (PDG code)
/// PE: parton/particle energy. If PE is smaller than the mass,
/// the parton/particle is taken to be at rest.
/// THETA:
/// PHI: polar and azimuthal angle for the momentum vector of the
/// parton/particle.
py1ent(ip, kf, pe, theta, phi);
}
//______________________________________________________________________________
int Pythia6::ImportParticles(ParticleVector* particles, const char* option)
{
/// Default primary creation method. It reads the /HEPEVT/ common block which
/// has been filled by the GenerateEvent method. If the event generator does
/// not use the HEPEVT common block, This routine has to be overloaded by
/// the subclasses.
/// The function loops on the generated particles and store them in
/// the TClonesArray pointed by the argument particles.
/// The default action is to store only the stable particles (ISTHEP = 1)
/// This can be demanded explicitly by setting the option = "Final"
/// If the option = "All", all the particles are stored.
if ( particles == 0 ) return 0;
ParticleVector::const_iterator it;
for ( it = particles->begin(); it != particles->end(); it++ )
delete *it;
particles->clear();
int numpart = fPyjets->N;
int nparts=0;
if (!strcmp(option,"") || !strcmp(option,"Final")) {
for (int i = 0; i<numpart; i++) {
if (fPyjets->K[0][i] == 1) {
//
// Use the common block values for the TParticle constructor
//
particles->push_back(
new Pythia6Particle(
fPyjets->K[0][i] ,
fPyjets->K[1][i] ,
fPyjets->K[2][i] ,
fPyjets->K[3][i] ,
fPyjets->K[4][i] ,
fPyjets->P[0][i] ,
fPyjets->P[1][i] ,
fPyjets->P[2][i] ,
fPyjets->P[3][i] ,
fPyjets->P[4][i] ,
fPyjets->V[0][i] ,
fPyjets->V[1][i] ,
fPyjets->V[2][i] ,
fPyjets->V[3][i] ,
fPyjets->V[4][i]));
// if(gDebug) printf("%d %d %d! ",i,fPyjets->K[1][i],numpart);
nparts++;
}
}
}
else if (!strcmp(option,"All")) {
for (int i = 0; i<numpart; i++) {
particles->push_back(
new Pythia6Particle(
fPyjets->K[0][i] ,
fPyjets->K[1][i] ,
fPyjets->K[2][i] ,
fPyjets->K[3][i] ,
fPyjets->K[4][i] ,
fPyjets->P[0][i] ,
fPyjets->P[1][i] ,
fPyjets->P[2][i] ,
fPyjets->P[3][i] ,
fPyjets->P[4][i] ,
fPyjets->V[0][i] ,
fPyjets->V[1][i] ,
fPyjets->V[2][i] ,
fPyjets->V[3][i] ,
fPyjets->V[4][i]));
}
nparts=numpart;
}
return nparts;
}
@@ -0,0 +1,123 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: RunAction.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// ----------------------------------------------------------------------------
#include "RunAction.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
// ----------------------------------------------------------------------------
RunAction::RunAction()
{
}
// ----------------------------------------------------------------------------
RunAction::~RunAction()
{
}
// ----------------------------------------------------------------------------
void RunAction::BeginOfRunAction(const G4Run* aRun)
{
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
// inform the runManager to save random number seed
//
G4RunManager::GetRunManager()->SetRandomNumberStore(true);
// initialize cumulative quantities
//
sumEAbs = sum2EAbs =sumEGap = sum2EGap = 0.;
sumLAbs = sum2LAbs =sumLGap = sum2LGap = 0.;
}
// ----------------------------------------------------------------------------
void RunAction::fillPerEvent(G4double EAbs, G4double EGap,
G4double LAbs, G4double LGap)
{
// accumulate statistic
//
sumEAbs += EAbs; sum2EAbs += EAbs*EAbs;
sumEGap += EGap; sum2EGap += EGap*EGap;
sumLAbs += LAbs; sum2LAbs += LAbs*LAbs;
sumLGap += LGap; sum2LGap += LGap*LGap;
}
// ----------------------------------------------------------------------------
void RunAction::EndOfRunAction(const G4Run* aRun)
{
G4int NbOfEvents = aRun->GetNumberOfEvent();
if (NbOfEvents == 0) return;
// compute statistics: mean and rms
//
sumEAbs /= NbOfEvents; sum2EAbs /= NbOfEvents;
G4double rmsEAbs = sum2EAbs - sumEAbs*sumEAbs;
if (rmsEAbs >0.) rmsEAbs = std::sqrt(rmsEAbs); else rmsEAbs = 0.;
sumEGap /= NbOfEvents; sum2EGap /= NbOfEvents;
G4double rmsEGap = sum2EGap - sumEGap*sumEGap;
if (rmsEGap >0.) rmsEGap = std::sqrt(rmsEGap); else rmsEGap = 0.;
sumLAbs /= NbOfEvents; sum2LAbs /= NbOfEvents;
G4double rmsLAbs = sum2LAbs - sumLAbs*sumLAbs;
if (rmsLAbs >0.) rmsLAbs = std::sqrt(rmsLAbs); else rmsLAbs = 0.;
sumLGap /= NbOfEvents; sum2LGap /= NbOfEvents;
G4double rmsLGap = sum2LGap - sumLGap*sumLGap;
if (rmsLGap >0.) rmsLGap = std::sqrt(rmsLGap); else rmsLGap = 0.;
// print
//
G4cout
<< "\n--------------------End of Run------------------------------\n"
<< "\n mean Energy in Absorber : " << G4BestUnit(sumEAbs,"Energy")
<< " +- " << G4BestUnit(rmsEAbs,"Energy")
<< "\n mean Energy in Gap : " << G4BestUnit(sumEGap,"Energy")
<< " +- " << G4BestUnit(rmsEGap,"Energy")
<< G4endl;
G4cout
<< "\n mean trackLength in Absorber : " << G4BestUnit(sumLAbs,"Length")
<< " +- " << G4BestUnit(rmsLAbs,"Length")
<< "\n mean trackLength in Gap : " << G4BestUnit(sumLGap,"Length")
<< " +- " << G4BestUnit(rmsLGap,"Length")
<< "\n------------------------------------------------------------\n"
<< G4endl;
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,73 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: SteppingAction.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
//
// ----------------------------------------------------------------------------
#include "SteppingAction.hh"
#include "DetectorConstruction.hh"
#include "EventAction.hh"
#include "G4Step.hh"
// ----------------------------------------------------------------------------
SteppingAction::SteppingAction(DetectorConstruction* det, EventAction* evt)
: detector(det), eventaction(evt)
{
}
// ----------------------------------------------------------------------------
SteppingAction::~SteppingAction()
{
}
// ----------------------------------------------------------------------------
void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
// get volume of the current step
G4VPhysicalVolume* volume
= aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume();
// collect energy and track length step by step
G4double edep = aStep->GetTotalEnergyDeposit();
G4double stepl = 0.;
if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.)
{
stepl = aStep->GetStepLength();
}
if (volume == detector->GetAbsorber()) { eventaction->AddAbs(edep,stepl); }
if (volume == detector->GetGap()) { eventaction->AddGap(edep,stepl); }
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,195 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: SteppingVerbose.cc,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// ----------------------------------------------------------------------------
#include "SteppingVerbose.hh"
#include "G4SteppingManager.hh"
#include "G4UnitsTable.hh"
// ----------------------------------------------------------------------------
SteppingVerbose::SteppingVerbose()
{
}
// ----------------------------------------------------------------------------
SteppingVerbose::~SteppingVerbose()
{
}
// ----------------------------------------------------------------------------
void SteppingVerbose::StepInfo()
{
CopyState();
G4int prec = G4cout.precision(3);
if( verboseLevel >= 1 )
{
if( verboseLevel >= 4 ) { VerboseTrack(); }
if( verboseLevel >= 3 )
{
G4cout << G4endl;
G4cout << std::setw( 5) << "#Step#" << " "
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "Volume" << " "
<< std::setw(10) << "Process" << G4endl;
}
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
<< " ";
// if( fStepStatus != fWorldBoundary){
if( fTrack->GetNextVolume() != 0 )
{
G4cout << std::setw(10) << fTrack->GetVolume()->GetName();
}
else
{
G4cout << std::setw(10) << "OutOfWorld";
}
if(fStep->GetPostStepPoint()->GetProcessDefinedStep() != 0)
{
G4cout << " "
<< std::setw(10)
<< fStep->GetPostStepPoint()->GetProcessDefinedStep()
->GetProcessName();
}
else
{
G4cout << " UserLimit";
}
G4cout << G4endl;
if( verboseLevel == 2 )
{
G4int tN2ndariesTot = fN2ndariesAtRestDoIt +
fN2ndariesAlongStepDoIt +
fN2ndariesPostStepDoIt;
if(tN2ndariesTot>0)
{
G4cout << " :----- List of 2ndaries - "
<< "#SpawnInStep=" << std::setw(3) << tN2ndariesTot
<< "(Rest=" << std::setw(2) << fN2ndariesAtRestDoIt
<< ",Along=" << std::setw(2) << fN2ndariesAlongStepDoIt
<< ",Post=" << std::setw(2) << fN2ndariesPostStepDoIt
<< "), "
<< "#SpawnTotal=" << std::setw(3) << (*fSecondary).size()
<< " ---------------"
<< G4endl;
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
lp1<(*fSecondary).size(); lp1++)
{
G4cout << " : "
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().x(),"Length")
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().y(),"Length")
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().z(),"Length")
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
<< std::setw(10)
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName();
G4cout << G4endl;
}
G4cout << " :-----------------------------"
<< "----------------------------------"
<< "-- EndOf2ndaries Info ---------------"
<< G4endl;
}
}
}
G4cout.precision(prec);
}
// ----------------------------------------------------------------------------
void SteppingVerbose::TrackingStarted()
{
CopyState();
G4int prec = G4cout.precision(3);
if( verboseLevel > 0 )
{
G4cout << std::setw( 5) << "Step#" << " "
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "Volume" << " "
<< std::setw(10) << "Process" << G4endl;
G4cout << std::setw( 5) << fTrack->GetCurrentStepNumber() << " "
<< std::setw( 6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw( 6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw( 6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw( 6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
<< " ";
if(fTrack->GetNextVolume())
{
G4cout << std::setw(10) << fTrack->GetVolume()->GetName();
}
else
{
G4cout << "OutOfWorld";
}
G4cout << " initStep" << G4endl;
}
G4cout.precision(prec);
}
// ----------------------------------------------------------------------------
@@ -0,0 +1,65 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: pythia6_common_address.c,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
// According to pythia6_common_address.c provided in Root
// Pythia6 distribution:
// http://root.cern.ch/
// see http://root.cern.ch/root/License.html
// ----------------------------------------------------------------------------
#include <string.h>
// declaration of PYTHIA6 common clocks
#ifndef WIN32
# define pycomp pycomp_
# define py1ent py1ent_
# define pyjets pyjets_
# define pydat1 pydat1_
# define pydat3 pydat3_
# define type_of_call
#else
# define pycomp PYCOMP
# define py1ent PY1ENT
# define pyjets PYJETS
# define pydat1 PYDAT1
# define pydat3 PYDAT3
# define type_of_call _stdcall
#endif
int pyjets[2+5*4000+2*2*5*4000];
int pydat1[200+2*200+200+2*200];
int pydat3[3*500+2*8000+2*8000+5*8000]; /* KNDCAY=8000 */
void *pythia6_common_address(const char* name)
{
if (!strcmp(name,"PYJETS")) return pyjets;
else if (!strcmp(name,"PYDAT1")) return pydat1;
else if (!strcmp(name,"PYDAT3")) return pydat3;
return 0;
}
@@ -0,0 +1,54 @@
# $Id: vis.mac,v 1.1 2008/11/03 11:48:35 gcosmo Exp $
#
# Macro file for the initialization phase
# when running in interactive mode
#
# Sets some default verbose
#
/control/verbose 2
/control/saveHistory
/run/verbose 2
#
# create empty scene
#
/vis/scene/create
#
# Create a scene handler for a specific graphics system
# (Edit the next line(s) to choose another graphic system)
#
# Use this open statement to get an .eps and .prim files
# suitable for viewing in DAWN.
#/vis/open DAWNFILE
#
# Use this open statement instead for OpenGL in immediate mode.
/vis/open OGLIX
#/vis/open RayTracer
#/vis/open OIX
# Output an empty detector
/vis/viewer/set/viewpointThetaPhi 30 30 deg
/vis/viewer/flush
#
# Draw trajectories at end of event, showing trajectory points as
# markers of size 2 pixels
/vis/scene/add/trajectories
/vis/modeling/trajectories/create/drawByCharge
/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true
/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2
# (if too many tracks cause core dump => /tracking/storeTrajectory 0)
#
# To draw gammas only
#/vis/filtering/trajectories/create/particleFilter
#/vis/filtering/trajectories/particleFilter-0/add gamma
#
# To draw charged particles only
#/vis/filtering/trajectories/particleFilter-0/invert true
#
# Many other options available with /vis/modeling and /vis/filtering.
# For example, select colour by particle ID
#/vis/modeling/trajectories/create/drawByParticleID
#/vis/modeling/trajectories/drawByParticleID-0/set e- red
#
/vis/scene/endOfEventAction accumulate
#
# At end of each run, an automatic flush causes graphical output.
#/run/beamOn 1