ATLAS Offline Software
QuirkWatcher.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "G4TrackStatus.hh"
6 #include "G4LorentzVector.hh"
7 
8 #include "Quirk.h"
9 #include "InfracolorForce.h"
10 #include "QuirkWatcher.h"
11 
13 
14 QuirkWatcher::QuirkWatcher() : G4VProcess(G4String("QuirkWatcher")) {
15  enableAtRestDoIt = false;
16  enableAlongStepDoIt = false;
17 }
18 
20 
22  const G4Track&, //track
23  G4double, //previousStepSize
24  G4ForceCondition* condition
25 ) {
26  *condition = StronglyForced;
27  return DBL_MAX;
28 }
29 
30 G4VParticleChange* QuirkWatcher::PostStepDoIt(
31  const G4Track& track,
32  const G4Step& //stepData
33 ) {
34  // Get infracolor string
35  auto part_nc ATLAS_THREAD_SAFE = // track should really be non-const in Geant4 interface
36  const_cast<G4ParticleDefinition*>(track.GetParticleDefinition());
37  Quirk* quirkDef = dynamic_cast<Quirk*>(part_nc);
38  if (quirkDef == 0) {
39  G4Exception("QuirkWatcher::PostStepDoIt", "NonQuirk", FatalErrorInArgument, "QuirkWatcher run on non-quirk particle");
40  std::abort();
41  }
42  InfracolorForce& string = quirkDef->GetStringIn();
43 
44  if (track.GetCurrentStepNumber() > 1 && !string.IsSourceInitialized()) {
45  string.Clear();
46  string.GetReactionForce()->Clear();
47  G4Exception(
48  "QuirkWatcher::PostStepDoIt",
49  "QuirkMissingPartner",
50  EventMustBeAborted,
51  "QuirkWatcher: missing partner for quirk"
52  );
53  }
54 
55  // Update track status
56  G4TrackStatus stat = track.GetTrackStatus();
57  if (stat == fStopButAlive) {
58  stat = fAlive;
59  }
60  if (stat == fAlive || stat == fSuspend) {
61  G4bool passControl = !string.HasNextStringVector();
62  //G4bool passControl = !string.HasNextStringVector() || (string.GetSumStrings().t() < string.GetReactionForce()->GetSumStrings().t());
63  if (passControl) {
64  if (string.IsSourceAlive()) {
65  stat = fSuspend;
66  } else {
67  stat = fStopAndKill;
68  }
69  }
70  }
71  if (stat == fStopAndKill || stat == fKillTrackAndSecondaries) {
72  string.TrackKilled();
73  }
74 
75  m_particleChange.Initialize(track);
76  m_particleChange.ProposeTrackStatus(stat);
77  return &m_particleChange;
78 }
Quirk::GetStringIn
const InfracolorForce & GetStringIn() const
Definition: Quirk.h:29
QuirkWatcher::QuirkWatcher
QuirkWatcher()
Definition: QuirkWatcher.cxx:14
LArG4GenerateShowerLib.condition
condition
Definition: LArG4GenerateShowerLib.py:19
QuirkWatcher::m_particleChange
G4VParticleChange m_particleChange
Definition: QuirkWatcher.h:47
QuirkWatcher::PostStepDoIt
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &)
Definition: QuirkWatcher.cxx:30
Quirk.h
Quirk
Definition: Quirk.h:12
InfracolorForce
Definition: InfracolorForce.h:14
QuirkWatcher::PostStepGetPhysicalInteractionLength
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
Definition: QuirkWatcher.cxx:21
InfracolorForce::Clear
void Clear()
Definition: InfracolorForce.cxx:57
beamspotman.stat
stat
Definition: beamspotman.py:266
QuirkWatcher.h
InfracolorForce.h
QuirkWatcher::~QuirkWatcher
virtual ~QuirkWatcher()
Definition: QuirkWatcher.cxx:19
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
checker_macros.h
Define macros for attributes used to control the static checker.