ATLAS Offline Software
Loading...
Searching...
No Matches
QuirkPhysicsTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// class header
6#include "QuirkPhysicsTool.h"
7
8// package headers
9#include "Quirk.h"
10#include "InfracolorForce.h"
11#include "QuirkTransportation.h"
12#include "QuirkWatcher.h"
13#include "QuirkStackingAction.h"
14#include "DebugSteppingAction.h"
15
16// Geant4 headers
17#include "globals.hh"
18#include "G4ProcessManager.hh"
19#include "G4RunManager.hh"
20#include "G4EventManager.hh"
21#include "G4hMultipleScattering.hh"
22#include "G4hIonisation.hh"
23#include "G4hBremsstrahlung.hh"
24#include "G4hPairProduction.hh"
25
26// STL headers
27#include <G4VPhysicsConstructor.hh>
28#include <fstream>
29#include <iostream>
30#include <memory>
31
32//-----------------------------------------------------------------------------
33// Implementation file for class : QuirksPhysicsTool
34//
35// 15-05-2015 : Edoardo Farina
36//-----------------------------------------------------------------------------
37#include "G4Version.hh"
38#if G4VERSION_NUMBER > 1029
39#define PARTICLEITERATOR (this->GetParticleIterator())
40#elif G4VERSION_NUMBER > 1009
41#define PARTICLEITERATOR aParticleIterator
42#else
43#define PARTICLEITERATOR theParticleIterator
44#endif
45
46//=============================================================================
47// Standard constructor, initializes variables
48//=============================================================================
50 const std::string& nam,const IInterface* parent )
51 : base_class ( type, nam , parent )
52{
53 m_physicsOptionType = G4AtlasPhysicsOption::Type::BSMPhysics;
54 std::ifstream f;
55 f.open("quirks_setup.txt");
56 f >> m_mass; m_mass *= CLHEP::MeV;
57 f >> m_charge; m_charge *= CLHEP::eplus;
58 f >> m_pdgid;
59 f >> m_stringForce; m_stringForce *= CLHEP::MeV/CLHEP::mm;
61 f >> m_maxBoost;
62 f >> m_maxMergeT; m_maxMergeT *= CLHEP::mm;
63 f >> m_maxMergeMag; m_maxMergeMag *= CLHEP::mm;
64 f >> m_enableDebug;
65 if (m_enableDebug) {
66 f >> m_debugStep; m_debugStep *= CLHEP::mm;
67 f >> m_numDebugSteps;
68 }
69 f.close();
70}
71
72//=============================================================================
73// Destructor
74//=============================================================================
75
80
81//=============================================================================
82// Initialize
83//=============================================================================
85{
86 ATH_MSG_DEBUG("QuirksPhysicsTool initialize( )");
87 return StatusCode::SUCCESS;
88}
89
90auto QuirksPhysicsTool::GetPhysicsOption() -> UPPhysicsConstructor {
91 return std::make_unique<QuirksPhysicsTool::PhysicsConstructor>(
92 name(), this->msgLevel(), m_mass, m_charge, m_pdgid, m_stringForce,
94}
95
97 ATH_MSG_DEBUG("ConstructParticle for the Quirks being run");
98
99 Quirk* q1 = new Quirk(
100 /*name*/ "quirk+", m_mass, /*width*/ 0.0, +m_charge,
101 /*2*spin*/ 1, /*parity*/ 0, /*C-conjugation*/ 0,
102 /*2*Isospin*/ 0, /*2*Isospin3*/ 0, /*G-parity*/ 0,
103 /*type*/ "lepton", /*lepton number*/ +1, /*baryon number*/ 0, +m_pdgid,
104 /*stable*/ true, /*lifetime*/ -1.0, /*decay table*/ 0,
105 /*shortlived*/ false
106 );
107 new Quirk(
108 /*name*/ "quirk-", m_mass, /*width*/ 0.0, -m_charge,
109 /*2*spin*/ 1, /*parity*/ 0, /*C-conjugation*/ 0,
110 /*2*Isospin*/ 0, /*2*Isospin3*/ 0, /*G-parity*/ 0,
111 /*type*/ "lepton", /*lepton number*/ -1, /*baryon number*/ 0, -m_pdgid,
112 /*stable*/ true, /*lifetime*/ -1.0, /*decay table*/ 0,
113 /*shortlived*/ false
114 );
115
116 InfracolorForce& s = q1->GetStringIn();
117 s.SetStringForce(m_stringForce);
118 s.SetFirstStringLength(m_firstStringLength);
119 s.SetMaxBoost(m_maxBoost);
120 s.SetMaxMergeT(m_maxMergeT);
121 s.SetMaxMergeMag(m_maxMergeMag);
122}
123
125 ATH_MSG_DEBUG(" ConstructProcess for Quirks being run");
126 PARTICLEITERATOR->reset();
127 while( (*PARTICLEITERATOR)() ){
128 G4ParticleDefinition* particle = PARTICLEITERATOR->value();
129 if (dynamic_cast<Quirk*>(particle) != 0) {
130 G4ProcessManager* pmanager = particle->GetProcessManager();
131 //G4cout << "# processes = " << pmanager->GetProcessListLength() << G4endl;
132 //for (int i = 0; i < pmanager->GetProcessList()->size(); i++) {
133 // G4cout << "process i: " << (*pmanager->GetProcessList())[i]->GetProcessName() << G4endl;
134 //}
135 while (pmanager->GetProcessListLength() != 0) pmanager->RemoveProcess(0);
136 G4VProcess* aTransportation = new QuirkTransportation;
137 pmanager->AddProcess(aTransportation);
138 pmanager->SetProcessOrderingToFirst(aTransportation, idxAlongStep);
139 pmanager->SetProcessOrderingToFirst(aTransportation, idxPostStep);
140 pmanager->AddProcess(new G4hMultipleScattering,-1, 1, 1);
141 pmanager->AddProcess(new G4hIonisation, -1, 2, 2);
142 pmanager->AddProcess(new G4hBremsstrahlung, -1, 3, 3);
143 pmanager->AddProcess(new G4hPairProduction, -1, 4, 4);
144 //pmanager->AddProcess(new TestProcess, -1, 1, 1);
145 pmanager->AddProcess(new QuirkWatcher, -1,-1, 5);
146 //G4cout << "# processes = " << pmanager->GetProcessListLength() << G4endl;
147 //for (int i = 0; i < pmanager->GetProcessList()->size(); i++) {
148 // G4cout << "process i: " << (*pmanager->GetProcessList())[i]->GetProcessName() << G4endl;
149 //}
150 }
151 }
152 G4RunManager* runManager = G4RunManager::GetRunManager();
153 runManager->SetNumberOfAdditionalWaitingStacks(1);
154 G4UserStackingAction* defaultStackingAction = G4EventManager::GetEventManager()->GetUserStackingAction();
155 ATH_MSG_WARNING("This tool is interfering with the normal G4Atlas workflow, by forcing a differentcustom StackingAction instead of the default one. This is acceptable only as a temporary solution, and should be fixed asap.");
156 runManager->SetUserAction(new QuirkStackingAction(defaultStackingAction));
157
158 // ADS this must be done on the python side
159 //f (m_enableDebug) {
160 // DebugSteppingAction* debugger = new DebugSteppingAction(m_debugStep, m_numDebugSteps);
161 //#//f QUIRKS_STANDALONE
162 // runManager->SetUserAction(debugger);
163 //#//
164 // FADS::FadsSteppingAction::GetSteppingAction()->RegisterAction(debugger);
165 //#//f
166 //
167}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define PARTICLEITERATOR
Definition Quirk.h:12
const InfracolorForce & GetStringIn() const
Definition Quirk.h:29
virtual StatusCode initialize() override final
Initialize method.
virtual UPPhysicsConstructor GetPhysicsOption() override final
QuirksPhysicsTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
virtual ~QuirksPhysicsTool()
Destructor.