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