Skip to content
Snippets Groups Projects
Commit aa44f9c1 authored by Kristian Zarebski's avatar Kristian Zarebski
Browse files

Modified TestEm6 for Gamma2DiMuon Conversion

parent 6bb63cee
No related branches found
No related tags found
No related merge requests found
Showing
with 1793 additions and 0 deletions
gaudi_subdir(G4GammaToDiLeptonConversionTest v1r0)
gaudi_depends_on_subdirs(Geant4/G4config)
gaudi_depends_on_subdirs(LHCbG4PhysLists)
find_package(CLHEP REQUIRED)
include_directories(SYSTEM ${CMAKE_INSTALL_PREFIX}/include ${CLHEP_INCLUDE_DIRS})
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
set(Geant4_LIBRARIES
-lG4analysis
-lG4physicslists
-lG4intercoms
-lG4global
-lG4run
-lG4tracking
-lG4track
-lG4event
-lG4processes
-lG4particles
-lG4geometry
-lG4materials
-lG4graphics_reps)
gaudi_add_executable(G4GammaToDiLeptonConversionTest
G4GammaToDiLeptonConversionTest.cc src/*.cc
INCLUDE_DIRS include CLHEP
LINK_LIBRARIES ${Geant4_LIBRARIES} CLHEP)
add_dependencies(G4GammaToDiLeptonConversionTest Geant4)
gaudi_install_scripts()
// BASED ON TESTEM6 BY THE GEANT4 COLLABORATION
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/TestEm6.cc
/// \brief Main program of the electromagnetic/TestEm6 example
//
// $Id: TestEm6.cc 83428 2014-08-21 15:46:01Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "Geant4/G4RunManager.hh"
#include "Geant4/G4UImanager.hh"
#include "Geant4/Randomize.hh"
#include "Geant4/G4GammaConversionToMuons.hh"
#include "Geant4/G4ProcessTable.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "SteppingVerbose.hh"
#include "PhysicsList.hh"
#include "RunAction.hh"
#include "SteppingAction.hh"
#include "StackingAction.hh"
#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
#endif
#ifdef G4UI_USE
#include "G4UIExecutive.hh"
#endif
G4double energy = 1000; //in GeV
G4int nEvts = 100;
G4double thickness = 0.3; //in mm
G4String physList = "FTFP_BERT";
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc,char** argv) {
for(int i{0}; i<argc; ++i)
{
if(G4String(argv[i]) == "--nevts")
{
++i;
nEvts = G4int(atoi(argv[i]));
++i;
}
if(G4String(argv[i]) == "--energy")
{
++i;
energy = G4double(atof(argv[i]));
++i;
}
if(G4String(argv[i]) == "--thickness")
{
++i;
thickness = G4double(atof(argv[i]));
++i;
}
}
//choose the Random engine
CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
//my Verbose output class
G4VSteppingVerbose::SetInstance(new SteppingVerbose);
//Construct the default run manager
G4RunManager * runManager = new G4RunManager;
//Set Physics List
runManager->SetUserInitialization(new PhysicsList);
//set mandatory initialization classes
DetectorConstruction* det;
runManager->SetUserInitialization(det = new DetectorConstruction(thickness));
runManager->SetUserAction(new PrimaryGeneratorAction(det, energy, nEvts));
//set user action classes
RunAction* RunAct;
runManager->SetUserAction(RunAct = new RunAction(det, energy, thickness, nEvts));
runManager->SetUserAction(new SteppingAction(RunAct));
runManager->SetUserAction(new StackingAction);
//get the pointer to the User Interface manager
G4UImanager* UI = G4UImanager::GetUIpointer();
// Initialize Run Manager
UI->ApplyCommand("/run/initialize");
// Increase Gamma2MuMu XSec to 1000x
UI->ApplyCommand("/testem/phys/SetGammaToMuPairFac 1000");
//Start Simulation
UI->ApplyCommand("/run/beamOn");
//job termination
delete runManager;
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
# $Id: GNUmakefile 66241 2012-12-13 18:34:42Z gunter $
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := TestEm6
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../../..
endif
.PHONY: all
all: lib bin
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/binmake.gmk
histclean:
rm -f $(G4WORKDIR)/tmp/$(G4SYSTEM)/$(G4TARGET)/RunAction.o
rm -f $(G4WORKDIR)/tmp/$(G4SYSTEM)/$(G4TARGET)/SteppingAction.o
visclean:
rm -f g4*.prim g4*.eps g4*.wrl
rm -f .DAWN_*
$Id: History 100285 2016-10-17 08:42:54Z gcosmo $
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
TestEm6 History file
--------------------
This file should be used by the G4 example coordinator to briefly
summarize all major modifications introduced in the code and keep
track of all tags.
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
14-10-16 G.Folger (testem6-V10-02-02)
- remove direct use of theParticleIterator, use GetParticleTableIterator().
fix required by clang39 on Linux and MAC
04-07-16 I. Hrivnacova (testem6-V10-02-01)
- Fixes for Doxygen documentation
10-12-15 V.Ivant (testem6-V10-02-00)
- H.Burkhardt fixed root macro allowing to work both with root5 and 6
28-10-15 D.Sawkey (testem6-V10-01-00)
- update physics description in READMEs
- add more standard EM physics builders
30-07-14 V.Ivant (testem6-V10-00-02)
- Naruhiro Chikuma have updated PhysicsList, DetectorConstruction,
and RunAction; bug fix
03-07-14 mma (testem6-V10-00-01)
- replace /testem/event/printModulo by /run/printProgress
08-06-14 mma (testem6-V10-00-00)
- suppress EventAction and its messenger
18-09-13 V.Ivant (testem6-V09-06-04)
- fixed tag format
17-09-13 V.Ivant (testem6-V09-05-04)
- TestEm6.in - added cross section factor to gamma->mu+mu- process
05-09-13 mma (testem6-V09-06-03)
- PhysicsList: restore G4GammaConversionToMuons
19-06-13 mma (testem6-V09-06-02)
- SteppingVerbose: use G4Step::GetSecondaryInCurrentStep()
07-06-13 mma (testem6-V09-06-01)
- Cosmetic in SteppingAction.
13-02-13 I.Hrivnacova (testem6-V09-06-00)
- Applied coding guidelines (virtual keyword, data members initialization)
12-10-12 V.Ivant (testem6-V09-05-03)
- Migration to the updated analysis tool and inplicit units
11-10-12 mma (testem6-V09-05-02)
- coding conventions: virtual
06-04-12 mma (testem6-V09-05-01)
- all classes : apply G4 coding conventions
11-03-12 mma (testem6-V09-05-00)
- RunAction.hh and .cc : migrate to new g4tools histogramming system
Do not need aida anymore, nor G4ANALYSIS_USE
08-11-11 mma (testem6-V09-04-00)
- modify SteppingVerbose for OutOfWorld
09-11-10 I.Hrivnacova (testem6-V09-03-05)
- Fixed compilation error on gcc-4.5.1.
09-11-10 M.Asai (testem6-V09-03-04)
- Fix AIDA file option.
06-06-10 J.Perl (testem6-V09-03-03)
- Remove unused variable in EventAction
03-06-10 J.Perl (testem6-V09-03-02)
- Updated vis usage
21-05-10 mma (testem6-V09-03-01)
- TestEm6.cc : introduction of G4UIExecutive
31-03-10 V.Ivant (testem6-V09-03-00)
- Remove obsolete MSC from comments line
27-11-09 V.Ivant (testem6-V09-02-01)
- H.Burkhardt add StackingAction allowing remove secondary particles;
cleanup PhysicsList for 9.3.
13-05-09 V.Ivant (testem6-V09-02-00)
- Increased upper limit of energy in the tables to 1000 TeV
18-09-08 mma (testem6-V09-01-02)
- RunAction : change default histogram format (root)
12-06-08 mma (testem6-V09-01-01)
- Remove AIDA from GNUmakefile
06-05-08 mma (testem6-V09-01-00)
- README : update Aida informations
20-10-06 mma (testem6-V08-01-00)
- GNUmakefile : LOADLIBS
24-05-06 mma (testem6-V08-00-01)
- register G4StepLimiter in PhysicsList
16-02-06 mma (testem6-V08-00-00)
- add command /testem/phys/SetAnnihiToHadronFac
06-12-05 Gabriele Cosmo
- Trivial changes for support of CLHEP-2.0.X series.
29-11-05 V.Ivant (testem6-V07-01-02)
- Add GenericIon to the PhysicsList
23-11-05 V.Ivant (testem6-V07-01-01)
- extend test to mu+mu- and pi+pi- pair creation processes and G4hhIonisation
in order to test all processes of the subdirectory
22-11-05 mma (testem6-V07-01-00)
- update README for OpenScientist
01-06-05 mma (testem6-V07-00-01)
- RunAction : option "noErrors" for hbook files;
3rd May 2005 John Allison (examples-V07-00-03)
- Replaced vis manager with G4VisExecutive.
02-03-05 mma (testem6-V07-00-00)
- RunAction : put a protection for the creation of analysis factory;
02 Dec 04: V.Ivant (testem6-V06-02-01)
- Migration to cmath
27-09-04 mma (testem6-V06-02-00)
- define correctly all UI subdirectories.
- modifs in RunAction for hbook,root,XML (Jaida)
31-03-04 mma (testem6-V06-01-00)
- remove direct interface with root
15-03-04 mma (testem6-V06-00-00)
- example of histograms with ROOT: USE_ROOT
25-11-03 V.Ivanchenko (testem6-V05-02-02)
- Fix geometry (G.Cosmo)
13-11-03 John Allison
- Removed OPACS from Vis Manager.
24-10-03 mma (testem6-V05-02-01)
- PhysListEmStandard: AddProcess(Bremsstrahlung,-1,3,3) ..etc..
10-10-03 mma (testem6-V05-02-00)
- NOHIST replaced by ANALYSIS_USE
- cosmetic in material definitions
- SetMaterial() in constructor. all macros updated for /run/initialize
10-06-03 mma (testem6-V05-01-00)
- proper deletion of old geometry in case of update
- fixe compilation warning
01-04-03 mma (testem6-V05-00-02)
- PVPlacement in logical mother even for the world
20-02-03 V.Ivant (testem6-V05-00-01)
- Migration to cut per region
12-02-03 mma (testem6-V05-00-00)
- DetectorConstruction: change volume name
30-01-03 hbu
- PhysicsList: implementation of (e+,e-) annihilation to (mu+,mu-)
- macros run11.mac and run12.mac
12-12-02 mma (testem6-V04-01-00)
- migration to aida 3.0
- UI directory /testem/
05-06-02 mma (testem6-V04-00-01)
- old histograming package clhep/hist replaced by AIDA 2.2/anaphe
23-05-02 mma (testem6-V04-00-00)
- creation
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/DetectorConstruction.hh
/// \brief Definition of the DetectorConstruction class
//
// $Id: DetectorConstruction.hh 83428 2014-08-21 15:46:01Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef DetectorConstruction_h
#define DetectorConstruction_h 1
#include "Geant4/G4VUserDetectorConstruction.hh"
#include "Geant4/globals.hh"
class G4LogicalVolume;
class G4Material;
class G4UniformMagField;
class G4UserLimits;
class DetectorMessenger;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
DetectorConstruction(G4float);
~DetectorConstruction();
public:
virtual G4VPhysicalVolume* Construct();
void SetBoxDepth (G4double);
void SetSizeXY (G4double);
void SetMaterial (const G4String&);
void SetMagField (G4double);
void SetMaxStepSize (G4double);
void UpdateGeometry();
public:
const
G4VPhysicalVolume* GetWorld() {return fP_Box;};
G4double GetXYSize() {return fBoxXY;};
G4double GetBoxDepth() {return fBoxDepth;};
G4Material* GetMaterial() {return fMaterial;};
void PrintParameters();
private:
G4VPhysicalVolume* fP_Box;
G4LogicalVolume* fL_Box;
G4double fBoxDepth;
G4double fBoxXY;
G4Material* fMaterial;
G4UniformMagField* fMagField;
G4UserLimits* fUserLimits;
DetectorMessenger* fDetectorMessenger;
private:
void DefineMaterials();
G4VPhysicalVolume* ConstructVolumes();
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/DetectorMessenger.hh
/// \brief Definition of the DetectorMessenger class
//
// $Id: DetectorMessenger.hh 66241 2012-12-13 18:34:42Z gunter $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef DetectorMessenger_h
#define DetectorMessenger_h 1
#include "Geant4/globals.hh"
#include "Geant4/G4UImessenger.hh"
class DetectorConstruction;
class G4UIdirectory;
class G4UIcmdWithAString;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithoutParameter;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class DetectorMessenger: public G4UImessenger
{
public:
DetectorMessenger(DetectorConstruction* );
~DetectorMessenger();
virtual void SetNewValue(G4UIcommand*, G4String);
private:
DetectorConstruction* fDetector;
G4UIdirectory* fTestemDir;
G4UIdirectory* fDetDir;
G4UIcmdWithAString* fMaterCmd;
G4UIcmdWithADoubleAndUnit* fSizeCmd;
G4UIcmdWithADoubleAndUnit* fMagFieldCmd;
G4UIcmdWithADoubleAndUnit* fMaxStepCmd;
G4UIcmdWithoutParameter* fUpdateCmd;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/PhysicsList.hh
/// \brief Definition of the PhysicsList class
//
// $Id: PhysicsList.hh 83428 2014-08-21 15:46:01Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef PhysicsList_h
#define PhysicsList_h 1
#include "Geant4/G4VModularPhysicsList.hh"
#include "Geant4/globals.hh"
#include "Geant4/G4EmConfigurator.hh"
class G4VPhysicsConstructor;
class StepMax;
class PhysicsListMessenger;
class G4GammaConversionToMuons;
class G4GammaConversion;
class G4AnnihiToMuPair;
class G4eeToHadrons;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class PhysicsList: public G4VModularPhysicsList
{
public:
PhysicsList();
virtual ~PhysicsList();
// Construct particles
virtual void ConstructParticle();
virtual void ConstructProcess();
void AddPhysicsList(const G4String& name);
void ConstructHighEnergy();
void AddStepMax();
// Construct processes and register them
void SetGammaToMuPairFac(G4double);
void SetAnnihiToMuPairFac(G4double);
void SetAnnihiToHadronFac(G4double);
private:
G4VPhysicsConstructor* fEmPhysicsList;
G4VPhysicsConstructor* fDecayPhysicsList;
G4String fEmName;
StepMax* fStepMaxProcess;
PhysicsListMessenger* fMes;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/PhysicsListMessenger.hh
/// \brief Definition of the PhysicsListMessenger class
//
// $Id: PhysicsListMessenger.hh 83428 2014-08-21 15:46:01Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef PhysicsListMessenger_h
#define PhysicsListMessenger_h 1
#include "Geant4/globals.hh"
#include "Geant4/G4UImessenger.hh"
class PhysicsList;
class G4UIdirectory;
class G4UIcmdWithADouble;
class G4UIcmdWithAString;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class PhysicsListMessenger: public G4UImessenger
{
public:
PhysicsListMessenger(PhysicsList*);
~PhysicsListMessenger();
virtual void SetNewValue(G4UIcommand*, G4String);
private:
PhysicsList* fPhysList;
G4UIdirectory* fPhysDir;
G4UIcmdWithADouble* fGammaToMuPairFacCmd;
G4UIcmdWithADouble* fGammaToEPairFacCmd;
G4UIcmdWithADouble* fAnnihiToMuPairFacCmd;
G4UIcmdWithADouble* fAnnihiToHadronFacCmd;
G4UIcmdWithAString* fListCmd;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/PrimaryGeneratorAction.hh
/// \brief Definition of the PrimaryGeneratorAction class
//
// $Id: PrimaryGeneratorAction.hh 66241 2012-12-13 18:34:42Z gunter $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef PrimaryGeneratorAction_h
#define PrimaryGeneratorAction_h 1
#include "Geant4/G4VUserPrimaryGeneratorAction.hh"
#include "Geant4/globals.hh"
class G4ParticleGun;
class G4Event;
class DetectorConstruction;
class PrimaryGeneratorMessenger;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
PrimaryGeneratorAction(DetectorConstruction*, G4double, G4int);
~PrimaryGeneratorAction();
public:
void SetRndmBeam(G4double val) {fRndmBeam = val;}
virtual void GeneratePrimaries(G4Event*);
private:
G4ParticleGun* fParticleGun;
DetectorConstruction* fDetector;
G4double fRndmBeam;
PrimaryGeneratorMessenger* fGunMessenger;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/PrimaryGeneratorMessenger.hh
/// \brief Definition of the PrimaryGeneratorMessenger class
//
// $Id: PrimaryGeneratorMessenger.hh 66241 2012-12-13 18:34:42Z gunter $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef PrimaryGeneratorMessenger_h
#define PrimaryGeneratorMessenger_h 1
#include "Geant4/G4UImessenger.hh"
#include "Geant4/globals.hh"
class PrimaryGeneratorAction;
class G4UIdirectory;
class G4UIcmdWithADouble;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class PrimaryGeneratorMessenger: public G4UImessenger
{
public:
PrimaryGeneratorMessenger(PrimaryGeneratorAction*);
~PrimaryGeneratorMessenger();
virtual void SetNewValue(G4UIcommand*, G4String);
private:
PrimaryGeneratorAction* fAction;
G4UIdirectory* fGunDir;
G4UIcmdWithADouble* fRndmCmd;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/ProcessesCount.hh
/// \brief Definition of the ProcessesCount class
//
// $Id: ProcessesCount.hh 66241 2012-12-13 18:34:42Z gunter $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef ProcessesCount_HH
#define ProcessesCount_HH
#include "Geant4/globals.hh"
#include <vector>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class OneProcessCount
{
public:
OneProcessCount(G4String name) {fName=name; fCounter=0;};
~OneProcessCount() {};
public:
G4String GetName() {return fName;};
G4int GetCounter() {return fCounter;};
void Count() {fCounter++;};
private:
G4String fName; // process name
G4int fCounter; // process counter
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
typedef std::vector<OneProcessCount*> ProcessesCount;
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/RunAction.hh
/// \brief Definition of the RunAction class
//
// $Id: RunAction.hh 83428 2014-08-21 15:46:01Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef RunAction_h
#define RunAction_h 1
#include "Geant4/G4UserRunAction.hh"
#include "ProcessesCount.hh"
#include "Geant4/globals.hh"
#include "Geant4/G4ParticleDefinition.hh"
#include "DetectorConstruction.hh"
#include "Geant4/g4root.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class G4Run;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class RunAction : public G4UserRunAction
{
public:
RunAction(DetectorConstruction*, G4double, G4double, G4int);
~RunAction();
public:
virtual void BeginOfRunAction(const G4Run*);
virtual void EndOfRunAction(const G4Run*);
void CountProcesses(G4String);
private:
DetectorConstruction* fDetector;
ProcessesCount* fProcCounter;
G4AnalysisManager* fAnalysis;
G4Material* fMat;
G4double fMinE;
G4double fMaxE;
G4int fnBin;
G4String fileName;
G4int fNtColId[3];
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/StackingAction.hh
/// \brief Definition of the StackingAction class
//
// $Id: StackingAction.hh 66241 2012-12-13 18:34:42Z gunter $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef StackingAction_h
#define StackingAction_h 1
#include "Geant4/G4UserStackingAction.hh"
#include "Geant4/globals.hh"
class G4Track;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class StackingAction : public G4UserStackingAction
{
public:
StackingAction();
~StackingAction();
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* );
};
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/StepMax.hh
/// \brief Definition of the StepMax class
//
// $Id: StepMax.hh 66241 2012-12-13 18:34:42Z gunter $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef StepMax_h
#define StepMax_h 1
#include "Geant4/globals.hh"
#include "Geant4/G4VDiscreteProcess.hh"
#include "Geant4/G4ParticleDefinition.hh"
#include "Geant4/G4Step.hh"
class StepMaxMessenger;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class StepMax : public G4VDiscreteProcess
{
public:
StepMax(const G4String& processName = "UserMaxStep");
~StepMax();
void SetMaxStep(G4double);
inline G4double GetMaxStep() { return fMaxChargedStep; };
virtual G4bool IsApplicable(const G4ParticleDefinition&);
virtual G4double
PostStepGetPhysicalInteractionLength(const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition);
virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&);
virtual G4double
GetMeanFreePath(const G4Track&, G4double, G4ForceCondition*);
private:
G4double fMaxChargedStep;
G4double fProposedStep;
StepMaxMessenger* fMessenger;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/StepMaxMessenger.hh
/// \brief Definition of the StepMaxMessenger class
//
// $Id: StepMaxMessenger.hh 67268 2013-02-13 11:38:40Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef StepMaxMessenger_h
#define StepMaxMessenger_h 1
#include "Geant4/globals.hh"
#include "Geant4/G4UImessenger.hh"
class StepMax;
class G4UIcmdWithADoubleAndUnit;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class StepMaxMessenger: public G4UImessenger
{
public:
StepMaxMessenger(StepMax*);
~StepMaxMessenger();
virtual void SetNewValue(G4UIcommand*, G4String);
private:
StepMax* fStepMax;
G4UIcmdWithADoubleAndUnit* fStepMaxCmd;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/SteppingAction.hh
/// \brief Definition of the SteppingAction class
//
// $Id: SteppingAction.hh 66241 2012-12-13 18:34:42Z gunter $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef SteppingAction_h
#define SteppingAction_h 1
#include "Geant4/G4UserSteppingAction.hh"
#include "Geant4/globals.hh"
class RunAction;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class SteppingAction : public G4UserSteppingAction
{
public:
SteppingAction(RunAction*);
~SteppingAction();
virtual void UserSteppingAction(const G4Step*);
private:
RunAction* fRunAction;
G4double fMuonMass;
G4double fEMass;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/include/SteppingVerbose.hh
/// \brief Definition of the SteppingVerbose class
//
//
// $Id: SteppingVerbose.hh 98272 2016-07-04 17:56:04Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef SteppingVerbose_h
#define SteppingVerbose_h 1
#include "Geant4/G4SteppingVerbose.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class SteppingVerbose : public G4SteppingVerbose {
public:
SteppingVerbose();
~SteppingVerbose();
virtual void TrackingStarted();
virtual void StepInfo();
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
import subprocess
import argparse
from math import log10
import logging
logging.basicConfig()
_logger = logging.getLogger("GAMMA2DILEPTONPROD")
_logger.setLevel("INFO")
parser = argparse.ArgumentParser("DILEPTONPROD")
parser.add_argument("--nevts", default=10000, help="Number of Events")
parser.add_argument("--energies", default="[1000]", help="Energies List")
parser.add_argument("--thickness", default="[0.3]", help="List of thicknesses")
parser.add_argument("--debug", default=False, action="store_true", help="Debug Mode")
args = parser.parse_args()
if args.debug:
_logger.setLevel("DEBUG")
def get_list(argument):
import re
elements = re.findall(r'[\d|\.]+', argument)
return elements
energies = get_list(args.energies)
thickness = get_list(args.thickness)
try:
assert int(args.nevts) > 0
except AssertionError:
_logger.error("Number of Events Must be a Positive Integer")
exit(0)
except TypeError:
_logger.error("Invalid Input for Number of Events")
exit(0)
for energy in energies:
for t in thickness:
_logger.info("%s\n\nRunning Gamma->l+ l- with options:\n\n\tNEvents :\t%s\n\tEnergy :\t%s GeV\n\tThickness :\t%s mm\n",
'='*40, args.nevts, energy, t)
_logger.info('='*40)
subprocess.check_call("G4GammaToDiLeptonConversionTest.exe --nevts {} --energy {} --thickness {}".format(args.nevts, energy, t), shell=True)
_logger.info("Creating Single Combined Plots ROOT File...")
import ROOT
_output = ROOT.TFile.Open("G4GammaToDiLeptonConversionTest.root", "NEW")
_histo_dim_dict = {'DiElectron' : {'Hist' : {'InvMass' : (100, 0, 100),
'ThetaPlus' : (100, 0, 0.02),
'ThetaMinus' : (100, 0, 0.02),
'EFrac' : (100,0,1)},
'Symbol' : 'e'},
'DiMuon' : {'Hist' : {'InvMass' : (150, 250, 550),
'ThetaPlus' : (100, 0, 0.07),
'ThetaMinus' : (100, 0, 0.07),
'EFrac' : (100,0,1)},
'Symbol' : '#mu' } }
for energy in energies:
for t in thickness:
_logger.debug("Opening file '%s'", "TestEM6_Al_{}mm_{}GeV_{}.root".format(t, energy, args.nevts))
_tmp = ROOT.TFile.Open("TestEM6_Al_{}mm_{}GeV_{}.root".format(t, energy, args.nevts))
for particle in _histo_dim_dict.keys():
_logger.debug("Attempting to retrieve TTree '%s'", particle)
_tree = _tmp.Get(particle)
assert _tree.GetEntries() > 0, "No Entries Found!"
hist_mm = ROOT.TH1F("{}_InvMass_{}GeV_{}mm_Al".format(particle, energy, t),
"{} Invariant Mass from {}GeV Photons in {}mm of Aluminium".format(particle, energy, t),
*_histo_dim_dict[particle]['Hist']['InvMass'])
hist_mm.GetXaxis().SetTitle("M_{%s}/MeV" % '{s}{s}'.format(s=_histo_dim_dict[particle]['Symbol']))
hist_tp = ROOT.TH1F("{}_AnglePlus_{}GeV_{}mm_Al".format(particle, energy, t),
"#gamma-{} Angle for {}GeV Photons in {}mm of Aluminium".format(_histo_dim_dict[particle]['Symbol']+'^{+}', energy, t),
*_histo_dim_dict[particle]['Hist']['ThetaPlus'])
hist_tp.GetXaxis().SetTitle("#theta(p_{%s}, p_{%s})" % ('#gamma', _histo_dim_dict[particle]['Symbol']+'^{+}'))
hist_tm = ROOT.TH1F("{}_AngleMinus_{}GeV_{}mm_Al".format(particle, energy, t),
"#gamma-{} Angle for {}GeV Photons in {}mm of Aluminium".format(_histo_dim_dict[particle]['Symbol']+'^{+}', energy, t),
*_histo_dim_dict[particle]['Hist']['ThetaMinus'])
hist_tm.GetXaxis().SetTitle("#theta(p_{%s}, p_{%s})" % ('#gamma', _histo_dim_dict[particle]['Symbol']+'^{-}'))
hist_efp = ROOT.TH1F("{}_EnergyFrac_Plus_{}GeV_{}mm_Al".format(particle, energy, t),
"Energy Fraction of {} for {}GeV Photons in {}mm of Aluminium".format(_histo_dim_dict[particle]['Symbol']+'^{+}', energy, t),
*_histo_dim_dict[particle]['Hist']['EFrac'])
hist_efp.GetXaxis().SetTitle("E_{%s}/E_{%s}" % (_histo_dim_dict[particle]['Symbol']+'^{+}', "#gamma"))
hist_efm = ROOT.TH1F("{}_EnergyFrac_Minus_{}GeV_{}mm_Al".format(particle, energy, t),
"Energy Fraction of {} for {}GeV Photons in {}mm of Aluminium".format(_histo_dim_dict[particle]['Symbol']+'^{-}', energy, t),
*_histo_dim_dict[particle]['Hist']['EFrac'])
hist_efm.GetXaxis().SetTitle("E_{%s}/E_{%s}" % (_histo_dim_dict[particle]['Symbol']+'^{-}', "#gamma"))
for event in _tree: # ROOT broke when using Draw(hist >> hist_tmp(i,j,k)) method
hist_mm.Fill(getattr(event, '{}_InvMass'.format(particle)))
hist_tp.Fill(getattr(event, '{}_ThetaPlus'.format(particle)))
hist_tm.Fill(getattr(event, '{}_ThetaMinus'.format(particle)))
hist_efp.Fill(getattr(event, '{}_EnergyFracPlus'.format(particle)))
hist_efm.Fill(getattr(event, '{}_EnergyFracMinus'.format(particle)))
_output.cd()
hist_mm.Write()
hist_tp.Write()
hist_tm.Write()
hist_efp.Write()
hist_efm.Write()
hist_mm.Delete()
hist_tp.Delete()
hist_tm.Delete()
hist_efp.Delete()
hist_efm.Delete()
_tmp.Close()
_output.Write()
_output.Close()
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/src/DetectorConstruction.cc
/// \brief Implementation of the DetectorConstruction class
//
// $Id: DetectorConstruction.cc 83428 2014-08-21 15:46:01Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "Geant4/G4NistManager.hh"
#include "Geant4/G4RunManager.hh"
#include "Geant4/G4Material.hh"
#include "Geant4/G4Box.hh"
#include "Geant4/G4LogicalVolume.hh"
#include "Geant4/G4PVPlacement.hh"
#include "Geant4/G4UniformMagField.hh"
#include "Geant4/G4UserLimits.hh"
#include "Geant4/G4GeometryManager.hh"
#include "Geant4/G4PhysicalVolumeStore.hh"
#include "Geant4/G4LogicalVolumeStore.hh"
#include "Geant4/G4SolidStore.hh"
#include "Geant4/G4UnitsTable.hh"
#include "Geant4/G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction(G4float thickness)
:G4VUserDetectorConstruction(),
fP_Box(0), fL_Box(0), fBoxXY(10*m), fBoxDepth(thickness*mm), fMaterial(0), fMagField(0),
fUserLimits(0), fDetectorMessenger(0)
{
DefineMaterials();
SetMaterial("Aluminium");
// create UserLimits
fUserLimits = new G4UserLimits();
// create commands for interactive definition of the detector
fDetectorMessenger = new DetectorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{ delete fDetectorMessenger;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::Construct()
{
return ConstructVolumes();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::DefineMaterials()
{
G4double a, z, density;
new G4Material("Aluminium", z= 13., a= 26.98*g/mole, density= 2.700*g/cm3);
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
{
G4GeometryManager::GetInstance()->OpenGeometry();
G4PhysicalVolumeStore::GetInstance()->Clean();
G4LogicalVolumeStore::GetInstance()->Clean();
G4SolidStore::GetInstance()->Clean();
G4Box*
sBox = new G4Box("Container", //its name
fBoxXY/2.,fBoxXY*2.,fBoxDepth/2.); //its dimensions
fL_Box = new G4LogicalVolume(sBox, //its shape
fMaterial, //its material
fMaterial->GetName()); //its name
fL_Box->SetUserLimits(fUserLimits);
fP_Box = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fL_Box, //its logical volume
fMaterial->GetName(), //its name
0, //its mother volume
false, //no boolean operation
0); //copy number
PrintParameters();
//
//always return the root volume
//
return fP_Box;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::PrintParameters()
{
G4cout << "\n The Box is " << G4BestUnit(fBoxDepth,"Length")
<< " of " << fMaterial->GetName() << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetMaterial(const G4String& name)
{
G4cout << "###SetMaterial" << G4endl;
// get the pointer to the existing material
G4Material* mat = G4Material::GetMaterial(name, false);
// create the material by its name
if(!mat) { mat = G4NistManager::Instance()->FindOrBuildMaterial(name); }
if (mat && mat != fMaterial) {
G4cout << "### New target material: " << mat->GetName() << G4endl;
fMaterial = mat;
if(fL_Box) {
fL_Box->SetMaterial(mat);
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetSizeXY(G4double value)
{
fBoxXY = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetBoxDepth(G4double value)
{
fBoxDepth = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "Geant4/G4FieldManager.hh"
#include "Geant4/G4TransportationManager.hh"
void DetectorConstruction::SetMagField(G4double fieldValue)
{
//apply a global uniform magnetic field along Z axis
G4FieldManager* fieldMgr
= G4TransportationManager::GetTransportationManager()->GetFieldManager();
if (fMagField) delete fMagField; //delete the existing magn field
if (fieldValue!=0.) // create a new one if non nul
{
fMagField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
fieldMgr->SetDetectorField(fMagField);
fieldMgr->CreateChordFinder(fMagField);
}
else
{
fMagField = 0;
fieldMgr->SetDetectorField(fMagField);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetMaxStepSize(G4double val)
{
// set the maximum allowed step size
//
if (val <= DBL_MIN)
{ G4cout << "\n --->warning from SetMaxStepSize: maxStep "
<< val << " out of range. Command refused" << G4endl;
return;
}
fUserLimits->SetMaxAllowedStep(val);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "Geant4/G4RunManager.hh"
void DetectorConstruction::UpdateGeometry()
{
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm6/src/DetectorMessenger.cc
/// \brief Implementation of the DetectorMessenger class
//
// $Id: DetectorMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "Geant4/G4UIdirectory.hh"
#include "Geant4/G4UIcmdWithAString.hh"
#include "Geant4/G4UIcmdWithADoubleAndUnit.hh"
#include "Geant4/G4UIcmdWithoutParameter.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:G4UImessenger(),fDetector(Det),
fTestemDir(0),
fDetDir(0),
fMaterCmd(0),
fSizeCmd(0),
fMagFieldCmd(0),
fMaxStepCmd(0),
fUpdateCmd(0)
{
fTestemDir = new G4UIdirectory("/testem/");
fTestemDir->SetGuidance(" detector control.");
fDetDir = new G4UIdirectory("/testem/det/");
fDetDir->SetGuidance("detector construction commands");
fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
fMaterCmd->SetGuidance("Select material of the box.");
fMaterCmd->SetParameterName("choice",false);
fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSize",this);
fSizeCmd->SetGuidance("Set size of the box");
fSizeCmd->SetParameterName("Size",false);
fSizeCmd->SetRange("Size>0.");
fSizeCmd->SetUnitCategory("Length");
fSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
fMagFieldCmd->SetGuidance("Define magnetic field.");
fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
fMagFieldCmd->SetParameterName("Bz",false);
fMagFieldCmd->SetUnitCategory("Magnetic flux density");
fMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
fUpdateCmd->SetGuidance("Update calorimeter geometry.");
fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
fUpdateCmd->AvailableForStates(G4State_Idle);
fMaxStepCmd = new G4UIcmdWithADoubleAndUnit("/testem/tracking/stepMax",this);
fMaxStepCmd->SetGuidance("Set max allowed step size");
fMaxStepCmd->SetParameterName("Size",false);
fMaxStepCmd->SetRange("Size>0.");
fMaxStepCmd->SetUnitCategory("Length");
fMaxStepCmd->AvailableForStates(G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::~DetectorMessenger()
{
delete fMaterCmd;
delete fSizeCmd;
delete fMagFieldCmd;
delete fUpdateCmd;
delete fMaxStepCmd;
delete fDetDir;
delete fTestemDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == fMaterCmd )
{ fDetector->SetMaterial(newValue);}
if( command == fSizeCmd )
{ fDetector->SetBoxDepth(fSizeCmd->GetNewDoubleValue(newValue));}
if( command == fMagFieldCmd )
{ fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
if( command == fUpdateCmd )
{ fDetector->UpdateGeometry(); }
if( command == fMaxStepCmd )
{ fDetector->SetMaxStepSize(fMaxStepCmd->GetNewDoubleValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment