Belle II Software development
G4MonopolePhysics.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9// modified from GEANT4 exoticphysics/monopole/*
10
11#include <simulation/monopoles/G4MonopolePhysics.h>
12#include <simulation/monopoles/G4mplIonisation.h>
13#include <simulation/monopoles/G4Monopole.h>
14#include <simulation/monopoles/G4MonopoleTransportation.h>
15#include <framework/logging/Logger.h>
16
17#include <TDatabasePDG.h>
18
19#include <G4ProcessManager.hh>
20#include <G4StepLimiter.hh>
21#include <G4hIonisation.hh>
22#include <G4PhysicsListHelper.hh>
23#include <G4BuilderType.hh>
24#include <CLHEP/Units/SystemOfUnits.h>
25#include <cmath>
26
27using namespace std;
28using namespace Belle2;
29using namespace Belle2::Monopoles;
30using namespace CLHEP;
31
33 : G4VPhysicsConstructor("Monopole physics"),
34 fMagCharge(magneticCharge), //in units of the positron charge
35 fMpl(0), fApl(0)
36{
37 //No way to store magnetic charge in TDatabasePDG,
38 //so part of the information (e, m, code, etc.) should be stored before generation
39 //and other part (g) passed to the simulation setup
40 const auto monopoleInPDG = TDatabasePDG::Instance()->GetParticle(c_monopolePDGCode);
41 const auto antiMonopoleInPDG = TDatabasePDG::Instance()->GetParticle(-c_monopolePDGCode);
42 if (!monopoleInPDG || !antiMonopoleInPDG) {
43 B2FATAL("Monopole physics was requested, but the monopole parameters"
44 "were not registered in local PDG database under PID code " << c_monopolePDGCode);
45 }
46 fElCharge = monopoleInPDG->Charge() / 3.0; //TParticlePDG returns in units of |e|/3
47 fMonopoleMass = antiMonopoleInPDG->Mass() * GeV;
48 SetPhysicsType(bUnknown);
49}
50
52{
53}
54
56{
57 fMpl = new G4Monopole("monopole", fMonopoleMass, fMagCharge, fElCharge, c_monopolePDGCode);
58//NOTE careful not to use same name or encoding, this will lead to G4exception
59 fApl = new G4Monopole("anti-monopole", fMonopoleMass, -fMagCharge, -fElCharge, -c_monopolePDGCode);
60}
61
62
64{
65 if (verboseLevel > 0) {
66 G4cout << "G4MonopolePhysics::ConstructProcess" << G4endl;
67 }
68
69 G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
70 G4ProcessManager* pmanager[2] = {fMpl->GetProcessManager(), fApl->GetProcessManager()};
71
72 // defined monopole parameters and binning
73
74 G4double magn = fMpl->MagneticCharge();
75 G4double elec = fMpl->GetPDGCharge();
76 G4double emin = fMonopoleMass / 20000.;
77 if (emin < keV) { emin = keV; }
78 G4double emax = std::max(10.*TeV, fMonopoleMass * 100);
79 G4int nbin = G4lrint(10 * std::log10(emax / emin));
80
81 // dedicated trasporation
82 if (magn != 0.0) {
83 pmanager[0]->RemoveProcess(0);
84 pmanager[0]->AddProcess(new G4MonopoleTransportation(fMpl), -1, 0, 0);
85 pmanager[1]->RemoveProcess(0);
86 pmanager[1]->AddProcess(new G4MonopoleTransportation(fApl), -1, 0, 0);
87//
88// commented out the following 3 lines,
89// to supress a cppcheck [duplicateCondition] warning for the if condition
90// }
91//
92// if (magn != 0.0) {
93 G4double chg = sqrt(magn * magn + elec * elec);//TODO properly combine electric and magnetic ionisation
94 G4mplIonisation* mplioni = new G4mplIonisation(chg);
95 mplioni->SetDEDXBinning(nbin);
96 mplioni->SetMinKinEnergy(emin);
97 mplioni->SetMaxKinEnergy(emax);
98 ph->RegisterProcess(mplioni, fMpl);
99 ph->RegisterProcess(mplioni, fApl);
100 }
101 if (elec != 0.0 && magn == 0.0) {
102 G4hIonisation* hhioni = new G4hIonisation();
103 hhioni->SetDEDXBinning(nbin);
104 hhioni->SetMinKinEnergy(emin);
105 hhioni->SetMaxKinEnergy(emax);
106 ph->RegisterProcess(hhioni, fMpl);
107 ph->RegisterProcess(hhioni, fApl);
108 }
109 ph->RegisterProcess(new G4StepLimiter(), fMpl);
110 ph->RegisterProcess(new G4StepLimiter(), fApl);
111}
G4Monopole * fMpl
Pointer to the monopole definition in GEANT4.
virtual void ConstructProcess()
This method will be invoked in the Construct() method.
G4double fElCharge
Electric charge in case of dyon.
G4double fMagCharge
Magnetic charge of the monopole, in e+ units.
G4double fMonopoleMass
Mass of the monopole.
virtual void ConstructParticle()
Adds monopole and anti-monopole to GEANT4 with a pdg of +/-99666 and parameters taken from current cl...
G4Monopole * fApl
Pointer to the anti-monopole definition in GEANT4.
G4MonopolePhysics(double magneticCharge=1.0)
Constructor.
Concrete class that does the geometrical transport.
A class to hold monopole description as a particle.
Definition: G4Monopole.h:33
G4double MagneticCharge() const
Returns magnetic charge of the monopole.
Definition: G4Monopole.cc:47
Monopole ionisation class.
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.
STL namespace.