Import Geant4 8.2.0 source tree
This commit is contained in:
@@ -0,0 +1,238 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 2006/11/22 14:51:29 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 - DetectorConstruction class
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
DetectorConstruction::DetectorConstruction() :
|
||||
Iron(0), Copper(0), Tungsten(0), Lead(0), Uranium(0), PbWO4(0),
|
||||
Polystyrene(0), LiquidArgon(0),
|
||||
theAbsorberMaterial(0),
|
||||
logicAbsorber(0), physiAbsorber(0) {}
|
||||
|
||||
|
||||
DetectorConstruction::~DetectorConstruction() {}
|
||||
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
{
|
||||
//------------------- materials ------------------------
|
||||
|
||||
G4double a; // atomic mass
|
||||
G4double z; // atomic number
|
||||
G4double density, pressure, temperature, fractionmass;
|
||||
G4String name, symbol;
|
||||
G4int nel, natoms;
|
||||
|
||||
//--- elements
|
||||
|
||||
a = 1.01*g/mole;
|
||||
G4Element* elH = new G4Element(name="Hydrogen", symbol="H2", z=1., a);
|
||||
|
||||
a = 12.01*g/mole;
|
||||
G4Element* elC = new G4Element(name="Carbon", symbol="C", z=6., a);
|
||||
|
||||
a = 14.01*g/mole;
|
||||
G4Element* elN = new G4Element(name="Nitrogen", symbol="N2", z=7., a);
|
||||
|
||||
a = 16.00*g/mole;
|
||||
G4Element* elO = new G4Element(name="Oxygen", symbol="O2", z=8., a);
|
||||
|
||||
a = 183.85*g/mole;
|
||||
G4Element* elW = new G4Element(name="Tungsten", symbol="W", z=74., a);
|
||||
|
||||
a = 207.19*g/mole;
|
||||
G4Element* elPb = new G4Element(name="Lead", symbol="Pb", z=82., a);
|
||||
|
||||
//--- simple materials
|
||||
|
||||
// Iron has a X0 = 1.7585 cm and lambda_I = 16.760 cm.
|
||||
density = 7.87*g/cm3;
|
||||
a = 55.85*g/mole;
|
||||
Iron = new G4Material(name="Iron", z=26., a, density);
|
||||
|
||||
// Copper has a X0 = 1.4353 cm and lambda_I = 15.056 cm.
|
||||
density = 8.96*g/cm3;
|
||||
a = 63.55*g/mole;
|
||||
Copper = new G4Material(name="Copper", z=29., a, density);
|
||||
|
||||
// Tungsten has a X0 = 0.35 cm and lambda_I = 9.5855 cm.
|
||||
density = 19.30*g/cm3;
|
||||
a = 183.85*g/mole;
|
||||
Tungsten = new G4Material(name="Tungsten", z=74., a, density);
|
||||
|
||||
// Lead has a X0 = 0.56120 cm and lambda_I = 17.092 cm.
|
||||
density = 11.35*g/cm3;
|
||||
a = 207.19*g/mole;
|
||||
Lead = new G4Material(name="Lead", z=82., a, density);
|
||||
|
||||
// Uranium has a X0 = 0.31662 cm and lambda_I = 10.501 cm.
|
||||
density = 18.95*g/cm3;
|
||||
a = 238.03*g/mole;
|
||||
Uranium = new G4Material(name="Uranium", z=92., a, density);
|
||||
|
||||
// Liquid Argon has a X0 = 10.971 cm and lambda_I = 65.769 cm.
|
||||
density = 1.4*g/cm3;
|
||||
a = 39.95*g/mole;
|
||||
LiquidArgon = new G4Material(name="LiquidArgon", z=18., a, density);
|
||||
|
||||
//--- mixtures
|
||||
|
||||
density = 1.290*mg/cm3;
|
||||
G4Material* Air = new G4Material(name="Air", density, nel=2);
|
||||
Air->AddElement(elN, 0.7);
|
||||
Air->AddElement(elO, 0.3);
|
||||
|
||||
// 4-May-2006 : We rename "Vacuum" as "G4vacuum" to avoid
|
||||
// problems with Flugg.
|
||||
density = 1.e-5*g/cm3;
|
||||
pressure = 2.e-2*bar;
|
||||
temperature = STP_Temperature; // From PhysicalConstants.h .
|
||||
G4Material* G4vacuum = new G4Material(name="G4vacuum", density, nel=1,
|
||||
kStateGas, temperature, pressure);
|
||||
G4vacuum->AddMaterial(Air, fractionmass=1.);
|
||||
|
||||
// Plastic scintillator tiles (used both in CMS hadron calorimeter
|
||||
// and ATLAS hadron barrel calorimeter):
|
||||
// X0 = 42.4 cm and lambda_I = 79.360 cm.
|
||||
density = 1.032*g/cm3;
|
||||
Polystyrene = new G4Material(name="Polystyrene", density, nel=2);
|
||||
Polystyrene->AddElement(elC, natoms=19);
|
||||
Polystyrene->AddElement(elH, natoms=21);
|
||||
|
||||
// PbWO4 CMS crystals. It has a X0 = 0.89 cm and lambda_I = 22.4 cm.
|
||||
density = 8.28*g/cm3;
|
||||
PbWO4 = new G4Material(name="PbWO4", density, nel=3);
|
||||
PbWO4->AddElement(elPb, natoms=1);
|
||||
PbWO4->AddElement(elW, natoms=1);
|
||||
PbWO4->AddElement(elO, natoms=4);
|
||||
|
||||
//------------------- volumes --------------------------
|
||||
|
||||
// --- experimental hall (world volume)
|
||||
// beam line along z axis
|
||||
|
||||
//***LOOKHERE***
|
||||
const G4double sizeExpHall = 4.0*m; // For normal calorimeter
|
||||
//const G4double sizeExpHall = 10.0*m; // For Scintillator calorimeter
|
||||
|
||||
G4double expHall_x = sizeExpHall / 2.0; // half dimension along x
|
||||
G4double expHall_y = sizeExpHall / 2.0; // half dimension along y
|
||||
G4double expHall_z = sizeExpHall / 2.0; // half dimension along z
|
||||
|
||||
G4Box* experimentalHall_box
|
||||
= new G4Box("expHall_box",expHall_x,expHall_y,expHall_z);
|
||||
|
||||
experimentalHall_log = new G4LogicalVolume(experimentalHall_box, // solid
|
||||
G4vacuum, // material
|
||||
"expHall_log", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0); // user limits
|
||||
|
||||
experimentalHall_phys = new G4PVPlacement(0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"expHall", // name
|
||||
experimentalHall_log, // logical volume
|
||||
0, // mother physical volume
|
||||
false, // boolean operation
|
||||
0); // copy number
|
||||
|
||||
// --- Detector
|
||||
|
||||
//***LOOKHERE***
|
||||
const G4double sizeCalo = 2.0*m; // For normal calorimeter
|
||||
//const G4double sizeCalo = 8.0*m; // For Scintillator calorimeter
|
||||
|
||||
G4double xAbsorber = sizeCalo / 2.0; // half dimension along x
|
||||
G4double yAbsorber = sizeCalo / 2.0; // half dimension along y
|
||||
G4double zAbsorber = sizeCalo / 2.0; // half dimension along z
|
||||
|
||||
G4Box* solidAbsorber = new G4Box("solidAbsorber", xAbsorber, yAbsorber, zAbsorber);
|
||||
|
||||
logicAbsorber = new G4LogicalVolume(solidAbsorber, // solid
|
||||
theAbsorberMaterial, // material
|
||||
"logicAbsorber", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0); // user limits
|
||||
|
||||
physiAbsorber = new G4PVPlacement(0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiAbsorber", // its name
|
||||
logicAbsorber, // logical volume
|
||||
experimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
100); // copy number
|
||||
|
||||
// --- Set default values ***LOOKHERE***
|
||||
theAbsorberMaterial = Iron;
|
||||
//theAbsorberMaterial = Copper;
|
||||
//theAbsorberMaterial = Tungsten;
|
||||
//theAbsorberMaterial = Lead;
|
||||
//theAbsorberMaterial = Uranium;
|
||||
//theAbsorberMaterial = PbWO4;
|
||||
//theAbsorberMaterial = Polystyrene;
|
||||
//theAbsorberMaterial = LiquidArgon;
|
||||
|
||||
logicAbsorber->SetMaterial( theAbsorberMaterial );
|
||||
|
||||
PrintParameters();
|
||||
|
||||
return experimentalHall_phys;
|
||||
}
|
||||
|
||||
|
||||
void DetectorConstruction::PrintParameters()
|
||||
{
|
||||
G4cout << G4endl << G4endl
|
||||
<< " ------ DetectorConstruction::PrintParameters() ------ " << G4endl
|
||||
<< " Absorber Material = ";
|
||||
if ( theAbsorberMaterial ) {
|
||||
G4cout << theAbsorberMaterial->GetName();
|
||||
} else {
|
||||
G4cout << " UNDEFINED ";
|
||||
}
|
||||
G4cout << G4endl << " -------------------------------------------------------- "
|
||||
<< G4endl << G4endl;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: MCTruthConfig.cc,v 1.1 2006/11/22 14:51:29 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 - MCTruthConfig class
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include "MCTruthConfig.hh"
|
||||
|
||||
MCTruthConfig::MCTruthConfig()
|
||||
{}
|
||||
|
||||
MCTruthConfig::~MCTruthConfig()
|
||||
{}
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: MCTruthEventAction.cc,v 1.1 2006/11/22 14:51:29 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 - MCTruthEventAction class
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include "MCTruthEventAction.hh"
|
||||
|
||||
MCTruthEventAction::MCTruthEventAction() : G4UserEventAction()
|
||||
{}
|
||||
|
||||
MCTruthEventAction::~MCTruthEventAction()
|
||||
{}
|
||||
|
||||
void MCTruthEventAction::BeginOfEventAction(const G4Event*)
|
||||
{
|
||||
// instanciating new event
|
||||
MCTruthManager::GetInstance()->NewEvent();
|
||||
}
|
||||
|
||||
void MCTruthEventAction::EndOfEventAction(const G4Event*)
|
||||
{
|
||||
// printing event
|
||||
MCTruthManager::GetInstance()->PrintEvent();
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: MCTruthManager.cc,v 1.2 2006/12/13 15:42:36 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 - MCTruthManager class
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include "MCTruthManager.hh"
|
||||
|
||||
static MCTruthManager* instance = 0;
|
||||
|
||||
MCTruthManager::MCTruthManager() : config(0)
|
||||
{}
|
||||
|
||||
MCTruthManager::~MCTruthManager()
|
||||
{}
|
||||
|
||||
MCTruthManager* MCTruthManager::GetInstance()
|
||||
{
|
||||
if( instance == 0 )
|
||||
{
|
||||
instance = new MCTruthManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
void MCTruthManager::NewEvent()
|
||||
{
|
||||
// first delete the old event
|
||||
delete event;
|
||||
// and now instaciate a new one
|
||||
event = new HepMC::GenEvent();
|
||||
}
|
||||
|
||||
void MCTruthManager::AddParticle(G4LorentzVector& momentum,
|
||||
G4LorentzVector& prodpos,
|
||||
G4LorentzVector& endpos,
|
||||
G4int pdg_id, G4int partID, G4int motherID,
|
||||
G4bool directParent)
|
||||
{
|
||||
// we create a new particle with barcode = partID
|
||||
HepMC::GenParticle* particle = new HepMC::GenParticle(momentum, pdg_id);
|
||||
particle->suggest_barcode(partID);
|
||||
// we initialize the 'segmentations' map
|
||||
// for the moment particle is not 'segmented'
|
||||
segmentations[partID] = 1;
|
||||
|
||||
// we create the GenVertex corresponding to the end point of the track
|
||||
HepMC::GenVertex* endvertex = new HepMC::GenVertex(endpos);
|
||||
|
||||
// barcode of the endvertex = - barcode of the track
|
||||
endvertex->suggest_barcode(-partID);
|
||||
endvertex->add_particle_in(particle);
|
||||
event->add_vertex(endvertex);
|
||||
|
||||
if(motherID) // not a primary
|
||||
{
|
||||
// here we could try to improve speed by searching only through particles which
|
||||
// belong to the given primary tree
|
||||
HepMC::GenParticle* mother = event->barcode_to_particle(motherID);
|
||||
//
|
||||
if(mother)
|
||||
{
|
||||
// we first check whether the mother's end vertex corresponds to the particle's
|
||||
// production vertex
|
||||
HepMC::GenVertex* motherendvtx = mother->end_vertex();
|
||||
G4LorentzVector motherendpos = motherendvtx->position();
|
||||
|
||||
if( motherendpos.x() == prodpos.x() &&
|
||||
motherendpos.y() == prodpos.y() &&
|
||||
motherendpos.z() == prodpos.z() ) // if yes, we attach the particle
|
||||
{
|
||||
motherendvtx->add_particle_out(particle);
|
||||
}
|
||||
else // if not, we check whether the mother is biological or adopted
|
||||
{
|
||||
if(!directParent) // adopted
|
||||
{
|
||||
G4bool found = false;
|
||||
|
||||
// first check if any of the dummy particles
|
||||
// has the end vertex at the right place
|
||||
//
|
||||
for(HepMC::GenVertex::particles_out_const_iterator
|
||||
it=motherendvtx->particles_out_const_begin();
|
||||
it!=motherendvtx->particles_out_const_end();it++)
|
||||
{
|
||||
if((*it)->pdg_id()==-999999)
|
||||
{
|
||||
G4LorentzVector dummypos = (*it)->end_vertex()->position();
|
||||
|
||||
if( dummypos.x() == prodpos.x() &&
|
||||
dummypos.y() == prodpos.y() &&
|
||||
dummypos.z() == prodpos.z() )
|
||||
{
|
||||
(*it)->end_vertex()->add_particle_out(particle);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// and if not, create a dummy particle connecting
|
||||
// to the end vertex of the mother
|
||||
//
|
||||
if(!found)
|
||||
{
|
||||
HepMC::GenVertex* childvtx = new HepMC::GenVertex(prodpos);
|
||||
childvtx->add_particle_out(particle);
|
||||
|
||||
// the dummy vertex gets the barcode -500000
|
||||
// minus the daughter particle barcode
|
||||
//
|
||||
childvtx->suggest_barcode(-500000-partID);
|
||||
event->add_vertex(childvtx);
|
||||
|
||||
HepMC::GenParticle* dummypart =
|
||||
new HepMC::GenParticle(G4LorentzVector(),-999999);
|
||||
|
||||
// the dummy particle gets the barcode 500000
|
||||
// plus the daughter particle barcode
|
||||
//
|
||||
dummypart->suggest_barcode(500000+partID);
|
||||
childvtx->add_particle_in(dummypart);
|
||||
motherendvtx->add_particle_out(dummypart);
|
||||
}
|
||||
}
|
||||
else // biological
|
||||
{
|
||||
// in case mother was already 'split' we need to look for
|
||||
// the right 'segment' to add the new daugther.
|
||||
// We use Time coordinate to locate the place for the new vertex
|
||||
|
||||
G4int number_of_segments = segmentations[motherID];
|
||||
G4int segment = 0;
|
||||
|
||||
// we loop through the segments
|
||||
//
|
||||
while ( !((mother->end_vertex()->position().t()>prodpos.t()) &&
|
||||
(mother->production_vertex()->position().t()<prodpos.t())) )
|
||||
{
|
||||
segment++;
|
||||
if (segment == number_of_segments)
|
||||
G4cerr << "Problem!!!! Time coordinates incompatible!" << G4endl;
|
||||
|
||||
mother = event->barcode_to_particle(segment*10000000 + motherID);
|
||||
}
|
||||
|
||||
// now, we 'split' the appropriate 'segment' of the mother particle
|
||||
// into two particles and create a new vertex
|
||||
//
|
||||
HepMC::GenVertex* childvtx = new HepMC::GenVertex(prodpos);
|
||||
childvtx->add_particle_out(particle);
|
||||
event->add_vertex(childvtx);
|
||||
|
||||
// we first detach the mother from its original vertex
|
||||
//
|
||||
HepMC::GenVertex* orig_mother_end_vtx = mother->end_vertex();
|
||||
orig_mother_end_vtx->remove_particle(mother);
|
||||
|
||||
// and attach it to the new vertex
|
||||
//
|
||||
childvtx->add_particle_in(mother);
|
||||
|
||||
// now we create a new particle representing the mother after
|
||||
// interaction the barcode of the new particle is 10000000 + the
|
||||
// original barcode
|
||||
//
|
||||
HepMC::GenParticle* mothertwo = new HepMC::GenParticle(*mother);
|
||||
mothertwo->suggest_barcode(segmentations[motherID]*10000000
|
||||
+ mother->barcode());
|
||||
|
||||
// we also reset the barcodes of the vertices
|
||||
//
|
||||
orig_mother_end_vtx->suggest_barcode(-segmentations[motherID]
|
||||
*10000000 - mother->barcode());
|
||||
childvtx->suggest_barcode(-mother->barcode());
|
||||
|
||||
// we attach it to the new vertex where interaction took place
|
||||
//
|
||||
childvtx->add_particle_out(mothertwo);
|
||||
|
||||
// and we attach it to the original endvertex
|
||||
//
|
||||
orig_mother_end_vtx->add_particle_in(mothertwo);
|
||||
|
||||
// and finally ... the increase the 'segmentation counter'
|
||||
//
|
||||
segmentations[motherID] = segmentations[motherID]+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
// mother GenParticle is not there for some reason...
|
||||
// if this happens, we need to revise the philosophy...
|
||||
// a solution would be to create HepMC particles
|
||||
// at the begining of each track
|
||||
{
|
||||
G4cerr << "barcode " << motherID << " mother not there! "<< G4endl;
|
||||
}
|
||||
}
|
||||
else // primary
|
||||
{
|
||||
HepMC::GenVertex* primaryvtx = new HepMC::GenVertex(prodpos);
|
||||
primaryvtx->add_particle_out(particle);
|
||||
event->add_vertex(primaryvtx);
|
||||
|
||||
// add id to the list of primaries
|
||||
//
|
||||
primarybarcodes.push_back(partID);
|
||||
}
|
||||
}
|
||||
|
||||
void MCTruthManager::PrintEvent()
|
||||
{
|
||||
event->print();
|
||||
|
||||
// looping over primaries and print the decay tree for each of them
|
||||
//
|
||||
for(std::vector<int>::const_iterator primarybar=primarybarcodes.begin();
|
||||
primarybar!=primarybarcodes.end();primarybar++)
|
||||
{
|
||||
printTree(event->barcode_to_particle(*primarybar), " | ");
|
||||
}
|
||||
}
|
||||
|
||||
void MCTruthManager::printTree(HepMC::GenParticle* particle, G4String offset)
|
||||
{
|
||||
G4cout << offset << "--- barcode: " << particle->barcode() << " pdg: "
|
||||
<< particle->pdg_id() << " energy: " << particle->momentum().e()
|
||||
<< " production vertex: "<< particle->production_vertex()->position()
|
||||
<< G4endl;
|
||||
|
||||
for(HepMC::GenVertex::particles_out_const_iterator
|
||||
it=particle->end_vertex()->particles_out_const_begin();
|
||||
it!=particle->end_vertex()->particles_out_const_end();
|
||||
it++)
|
||||
{
|
||||
G4String deltaoffset = "";
|
||||
|
||||
if( std::fmod((*it)->barcode(),10000000) != std::fmod(particle->barcode(),10000000) )
|
||||
{
|
||||
deltaoffset = " | ";
|
||||
}
|
||||
|
||||
printTree((*it), offset + deltaoffset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: MCTruthTrackInformation.cc,v 1.1 2006/11/22 14:51:30 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 - MCTruthTrackInformation class
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include "MCTruthTrackInformation.hh"
|
||||
|
||||
MCTruthTrackInformation::MCTruthTrackInformation()
|
||||
{
|
||||
directParent = true;
|
||||
}
|
||||
|
||||
MCTruthTrackInformation::~MCTruthTrackInformation()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: MCTruthTrackingAction.cc,v 1.1 2006/11/22 14:51:30 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 - MCTruthTrackingAction class
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "G4Track.hh"
|
||||
#include "G4TrackVector.hh"
|
||||
#include "G4TrackingManager.hh"
|
||||
#include "MCTruthTrackingAction.hh"
|
||||
#include "MCTruthTrackInformation.hh"
|
||||
|
||||
MCTruthTrackingAction::MCTruthTrackingAction()
|
||||
{}
|
||||
|
||||
MCTruthTrackingAction::~MCTruthTrackingAction()
|
||||
{}
|
||||
|
||||
void MCTruthTrackingAction::PreUserTrackingAction(const G4Track* track)
|
||||
{
|
||||
fmom = G4LorentzVector(track->GetMomentum(), track->GetTotalEnergy());
|
||||
|
||||
if(!track->GetUserInformation())
|
||||
{
|
||||
G4VUserTrackInformation* mcinf = new MCTruthTrackInformation;
|
||||
fpTrackingManager->SetUserTrackInformation(mcinf);
|
||||
}
|
||||
}
|
||||
|
||||
void MCTruthTrackingAction::PostUserTrackingAction(const G4Track* track)
|
||||
{
|
||||
|
||||
G4LorentzVector prodpos(track->GetGlobalTime() - track->GetLocalTime(),
|
||||
track->GetVertexPosition());
|
||||
G4LorentzVector endpos(track->GetGlobalTime(), track->GetPosition());
|
||||
|
||||
// here (?) make all different checks to decide whether to store the particle
|
||||
//
|
||||
if (trackToBeStored(track))
|
||||
{
|
||||
MCTruthTrackInformation* mcinf =
|
||||
(MCTruthTrackInformation*) track->GetUserInformation();
|
||||
|
||||
MCTruthManager::GetInstance()->
|
||||
AddParticle(fmom, prodpos, endpos,
|
||||
track->GetDefinition()->GetPDGEncoding(),
|
||||
track->GetTrackID(),
|
||||
track->GetParentID(), mcinf->GetDirectParent());
|
||||
}
|
||||
else
|
||||
{
|
||||
// If track is not to be stored, propagate it's parent ID (stored)
|
||||
// to its secondaries
|
||||
//
|
||||
G4TrackVector* childrens = fpTrackingManager->GimmeSecondaries() ;
|
||||
|
||||
for( unsigned int index = 0 ; index < childrens->size() ; ++index )
|
||||
{
|
||||
G4Track* tr = (*childrens)[index] ;
|
||||
tr->SetParentID( track->GetParentID() );
|
||||
|
||||
// set the flag saying that the direct mother is not stored
|
||||
//
|
||||
MCTruthTrackInformation* mcinf =
|
||||
(MCTruthTrackInformation*) tr->GetUserInformation();
|
||||
if(!mcinf)
|
||||
tr->SetUserInformation(mcinf = new MCTruthTrackInformation);
|
||||
|
||||
mcinf->SetDirectParent(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G4bool MCTruthTrackingAction::trackToBeStored(const G4Track* track)
|
||||
{
|
||||
MCTruthConfig* config = MCTruthManager::GetInstance()->GetConfig();
|
||||
|
||||
// check energy
|
||||
if (fmom.e() > config->GetMinE()) return true;
|
||||
|
||||
// particle type
|
||||
std::vector<G4int> types = config->GetParticleTypes();
|
||||
|
||||
if(std::find( types.begin(), types.end(),
|
||||
track->GetDefinition()->GetPDGEncoding())
|
||||
!= types.end()) return true;
|
||||
|
||||
// creator process
|
||||
|
||||
// etc...
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 2006/11/22 14:51:30 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 - PhysicsList class
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include "globals.hh"
|
||||
#include "PhysicsList.hh"
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
|
||||
PhysicsList::PhysicsList(): G4VUserPhysicsList()
|
||||
{
|
||||
defaultCutValue = 1.0*cm;
|
||||
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();
|
||||
}
|
||||
|
||||
void PhysicsList::ConstructLeptons()
|
||||
{
|
||||
// leptons
|
||||
// e+/-
|
||||
G4Electron::ElectronDefinition();
|
||||
G4Positron::PositronDefinition();
|
||||
// mu+/-
|
||||
G4MuonPlus::MuonPlusDefinition();
|
||||
G4MuonMinus::MuonMinusDefinition();
|
||||
// nu_e
|
||||
G4NeutrinoE::NeutrinoEDefinition();
|
||||
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
|
||||
// nu_mu
|
||||
G4NeutrinoMu::NeutrinoMuDefinition();
|
||||
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
|
||||
}
|
||||
|
||||
void PhysicsList::ConstructMesons()
|
||||
{
|
||||
// mesons
|
||||
// light mesons
|
||||
G4PionPlus::PionPlusDefinition();
|
||||
G4PionMinus::PionMinusDefinition();
|
||||
G4PionZero::PionZeroDefinition();
|
||||
G4Eta::EtaDefinition();
|
||||
G4EtaPrime::EtaPrimeDefinition();
|
||||
G4KaonPlus::KaonPlusDefinition();
|
||||
G4KaonMinus::KaonMinusDefinition();
|
||||
G4KaonZero::KaonZeroDefinition();
|
||||
G4AntiKaonZero::AntiKaonZeroDefinition();
|
||||
G4KaonZeroLong::KaonZeroLongDefinition();
|
||||
G4KaonZeroShort::KaonZeroShortDefinition();
|
||||
}
|
||||
|
||||
void PhysicsList::ConstructBaryons()
|
||||
{
|
||||
// barions
|
||||
G4Proton::ProtonDefinition();
|
||||
G4AntiProton::AntiProtonDefinition();
|
||||
|
||||
G4Neutron::NeutronDefinition();
|
||||
G4AntiNeutron::AntiNeutronDefinition();
|
||||
}
|
||||
|
||||
void PhysicsList::ConstructProcess()
|
||||
{
|
||||
AddTransportation();
|
||||
ConstructEM();
|
||||
ConstructGeneral();
|
||||
}
|
||||
|
||||
#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 "G4StepLimiter.hh"
|
||||
#include "G4UserSpecialCuts.hh"
|
||||
|
||||
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);
|
||||
//step limit
|
||||
pmanager->AddProcess(new G4StepLimiter, -1,-1,3);
|
||||
///pmanager->AddProcess(new G4UserSpecialCuts, -1,-1,4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "G4Decay.hh"
|
||||
void PhysicsList::ConstructGeneral()
|
||||
{
|
||||
// Add Decay Process
|
||||
G4Decay* theDecayProcess = new G4Decay();
|
||||
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()
|
||||
{
|
||||
//G4VUserPhysicsList::SetCutsWithDefault method sets
|
||||
//the default cut value for all particle types
|
||||
//
|
||||
SetCutsWithDefault();
|
||||
|
||||
if (verboseLevel>0) DumpCutValuesTable();
|
||||
}
|
||||
@@ -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: PrimaryGeneratorAction.cc,v 1.1 2006/11/22 14:51:31 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 - PrimaryGeneratorAction class
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction()
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
particleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
// default particle
|
||||
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4ParticleDefinition* particle = particleTable->FindParticle("kaon0S");
|
||||
|
||||
particleGun->SetParticleDefinition(particle);
|
||||
particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
|
||||
particleGun->SetParticleEnergy(3.0*GeV);
|
||||
}
|
||||
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
{
|
||||
delete particleGun;
|
||||
}
|
||||
|
||||
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
G4double position = 0.0;
|
||||
particleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,position));
|
||||
|
||||
particleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
Reference in New Issue
Block a user