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,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;
}