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