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 <iostream>
29 #include <fstream>
30 
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;
58  f >> m_pdgid;
61  f >> m_maxBoost;
64  f >> m_enableDebug;
65  if (m_enableDebug) {
67  f >> m_numDebugSteps;
68  }
69  f.close();
70 }
71 
72 //=============================================================================
73 // Destructor
74 //=============================================================================
75 
77 {
78 
79 }
80 
81 //=============================================================================
82 // Initialize
83 //=============================================================================
85 {
86  ATH_MSG_DEBUG("QuirksPhysicsTool initialize( )");
87  this->SetPhysicsName(name());
88  return StatusCode::SUCCESS;
89 }
90 
91 
93 {
94  return this;
95 }
96 
98 {
99  ATH_MSG_DEBUG("ConstructParticle for the Quirks being run");
100 
101  Quirk* q1 = new Quirk(
102  /*name*/ "quirk+", m_mass, /*width*/ 0.0, +m_charge,
103  /*2*spin*/ 1, /*parity*/ 0, /*C-conjugation*/ 0,
104  /*2*Isospin*/ 0, /*2*Isospin3*/ 0, /*G-parity*/ 0,
105  /*type*/ "lepton", /*lepton number*/ +1, /*baryon number*/ 0, +m_pdgid,
106  /*stable*/ true, /*lifetime*/ -1.0, /*decay table*/ 0,
107  /*shortlived*/ false
108  );
109  new Quirk(
110  /*name*/ "quirk-", m_mass, /*width*/ 0.0, -m_charge,
111  /*2*spin*/ 1, /*parity*/ 0, /*C-conjugation*/ 0,
112  /*2*Isospin*/ 0, /*2*Isospin3*/ 0, /*G-parity*/ 0,
113  /*type*/ "lepton", /*lepton number*/ -1, /*baryon number*/ 0, -m_pdgid,
114  /*stable*/ true, /*lifetime*/ -1.0, /*decay table*/ 0,
115  /*shortlived*/ false
116  );
117 
118  InfracolorForce& s = q1->GetStringIn();
119  s.SetStringForce(m_stringForce);
120  s.SetFirstStringLength(m_firstStringLength);
121  s.SetMaxBoost(m_maxBoost);
122  s.SetMaxMergeT(m_maxMergeT);
123  s.SetMaxMergeMag(m_maxMergeMag);
124 }
125 
127 {
128  ATH_MSG_DEBUG(" ConstructProcess for Quirks being run");
129  PARTICLEITERATOR->reset();
130  while( (*PARTICLEITERATOR)() ){
131  G4ParticleDefinition* particle = PARTICLEITERATOR->value();
132  if (dynamic_cast<Quirk*>(particle) != 0) {
133  G4ProcessManager* pmanager = particle->GetProcessManager();
134  //G4cout << "# processes = " << pmanager->GetProcessListLength() << G4endl;
135  //for (int i = 0; i < pmanager->GetProcessList()->size(); i++) {
136  // G4cout << "process i: " << (*pmanager->GetProcessList())[i]->GetProcessName() << G4endl;
137  //}
138  while (pmanager->GetProcessListLength() != 0) pmanager->RemoveProcess(0);
139  G4VProcess* aTransportation = new QuirkTransportation;
140  pmanager->AddProcess(aTransportation);
141  pmanager->SetProcessOrderingToFirst(aTransportation, idxAlongStep);
142  pmanager->SetProcessOrderingToFirst(aTransportation, idxPostStep);
143  pmanager->AddProcess(new G4hMultipleScattering,-1, 1, 1);
144  pmanager->AddProcess(new G4hIonisation, -1, 2, 2);
145  pmanager->AddProcess(new G4hBremsstrahlung, -1, 3, 3);
146  pmanager->AddProcess(new G4hPairProduction, -1, 4, 4);
147  //pmanager->AddProcess(new TestProcess, -1, 1, 1);
148  pmanager->AddProcess(new QuirkWatcher, -1,-1, 5);
149  //G4cout << "# processes = " << pmanager->GetProcessListLength() << G4endl;
150  //for (int i = 0; i < pmanager->GetProcessList()->size(); i++) {
151  // G4cout << "process i: " << (*pmanager->GetProcessList())[i]->GetProcessName() << G4endl;
152  //}
153  }
154  }
155  G4RunManager* runManager = G4RunManager::GetRunManager();
156  runManager->SetNumberOfAdditionalWaitingStacks(1);
157  G4UserStackingAction* defaultStackingAction = G4EventManager::GetEventManager()->GetUserStackingAction();
158  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.");
159  runManager->SetUserAction(new QuirkStackingAction(defaultStackingAction));
160 
161  // ADS this must be done on the python side
162  //f (m_enableDebug) {
163  // DebugSteppingAction* debugger = new DebugSteppingAction(m_debugStep, m_numDebugSteps);
164  //#//f QUIRKS_STANDALONE
165  // runManager->SetUserAction(debugger);
166  //#//
167  // FADS::FadsSteppingAction::GetSteppingAction()->RegisterAction(debugger);
168  //#//f
169  //
170 }
PARTICLEITERATOR
#define PARTICLEITERATOR
Definition: QuirkPhysicsTool.cxx:43
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
QuirkTransportation
Definition: QuirkTransportation.h:60
QuirkTransportation.h
QuirksPhysicsTool::m_pdgid
G4int m_pdgid
Definition: QuirkPhysicsTool.h:39
python.SystemOfUnits.MeV
int MeV
Definition: SystemOfUnits.py:154
QuirksPhysicsTool::m_numDebugSteps
G4int m_numDebugSteps
Definition: QuirkPhysicsTool.h:47
QuirkPhysicsTool.h
Quirk::GetStringIn
const InfracolorForce & GetStringIn() const
Definition: Quirk.h:29
QuirksPhysicsTool::m_debugStep
G4double m_debugStep
Definition: QuirkPhysicsTool.h:46
QuirkWatcher
Definition: QuirkWatcher.h:11
QuirksPhysicsTool
Definition: QuirkPhysicsTool.h:20
QuirksPhysicsTool::m_firstStringLength
G4double m_firstStringLength
Definition: QuirkPhysicsTool.h:41
QuirksPhysicsTool::initialize
virtual StatusCode initialize() override final
Initialize method.
Definition: QuirkPhysicsTool.cxx:84
QuirksPhysicsTool::ConstructProcess
virtual void ConstructProcess() override final
Definition: QuirkPhysicsTool.cxx:126
QuirkStackingAction.h
QuirksPhysicsTool::ConstructParticle
virtual void ConstructParticle() override final
Definition: QuirkPhysicsTool.cxx:97
QuirksPhysicsTool::m_maxMergeT
G4double m_maxMergeT
Definition: QuirkPhysicsTool.h:43
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
QuirksPhysicsTool::m_enableDebug
G4int m_enableDebug
Definition: QuirkPhysicsTool.h:45
hist_file_dump.f
f
Definition: hist_file_dump.py:135
QuirksPhysicsTool::m_charge
G4double m_charge
Definition: QuirkPhysicsTool.h:38
QuirkWatcher.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
InfracolorForce.h
QuirksPhysicsTool::m_mass
G4double m_mass
Definition: QuirkPhysicsTool.h:37
QuirksPhysicsTool::QuirksPhysicsTool
QuirksPhysicsTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: QuirkPhysicsTool.cxx:49
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
QuirksPhysicsTool::m_stringForce
G4double m_stringForce
Definition: QuirkPhysicsTool.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
QuirksPhysicsTool::m_maxMergeMag
G4double m_maxMergeMag
Definition: QuirkPhysicsTool.h:44
QuirkStackingAction
Definition: QuirkStackingAction.h:11
python.SystemOfUnits.eplus
int eplus
Definition: SystemOfUnits.py:137
QuirksPhysicsTool::m_maxBoost
G4double m_maxBoost
Definition: QuirkPhysicsTool.h:42
G4AtlasPhysicsOption::BSMPhysics
@ BSMPhysics
Definition: IPhysicsOptionTool.h:22
QuirksPhysicsTool::~QuirksPhysicsTool
virtual ~QuirksPhysicsTool()
Destructor.
Definition: QuirkPhysicsTool.cxx:76
QuirksPhysicsTool::GetPhysicsOption
virtual QuirksPhysicsTool * GetPhysicsOption() override final
Definition: QuirkPhysicsTool.cxx:92