CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GflashHadronWrapperProcess Class Reference

#include <GflashHadronWrapperProcess.h>

Inheritance diagram for GflashHadronWrapperProcess:

Public Member Functions

G4String GetName ()
 
 GflashHadronWrapperProcess (G4String processName)
 
G4VParticleChange * PostStepDoIt (const G4Track &track, const G4Step &step) override
 
void Print (const G4Step &astep)
 
 ~GflashHadronWrapperProcess () override
 

Private Attributes

G4VProcess * fProcess
 
G4ProcessVector * fProcessVector
 
G4VParticleChange * particleChange
 
G4ProcessManager * pmanager
 
G4String theProcessName
 

Detailed Description

Definition at line 14 of file GflashHadronWrapperProcess.h.

Constructor & Destructor Documentation

◆ GflashHadronWrapperProcess()

GflashHadronWrapperProcess::GflashHadronWrapperProcess ( G4String  processName)

◆ ~GflashHadronWrapperProcess()

GflashHadronWrapperProcess::~GflashHadronWrapperProcess ( )
override

Definition at line 21 of file GflashHadronWrapperProcess.cc.

21 {}

Member Function Documentation

◆ GetName()

G4String GflashHadronWrapperProcess::GetName ( )
inline

Definition at line 24 of file GflashHadronWrapperProcess.h.

References theProcessName.

◆ PostStepDoIt()

G4VParticleChange * GflashHadronWrapperProcess::PostStepDoIt ( const G4Track &  track,
const G4Step &  step 
)
override

Definition at line 23 of file GflashHadronWrapperProcess.cc.

References fProcess, fProcessVector, particleChange, pmanager, and HLT_2024v11_cff::track.

23  {
24  // process PostStepDoIt for the original process
25 
26  particleChange = pRegProcess->PostStepDoIt(track, step);
27 
28  // specific actions of the wrapper process
29 
30  // update step/track information after PostStep of the original process is
31  // done these steps will be repeated again without additional conflicts even
32  // if the parameterized physics process doesn't take over the original process
33 
34  particleChange->UpdateStepForPostStep(const_cast<G4Step *>(&step));
35 
36  // we may not want to update G4Track during this wrapper process if
37  // G4Track accessors are not used in the G4VFastSimulationModel model
38  // (const_cast<G4Step *> (&step))->UpdateTrack();
39 
40  // update safety after each invocation of PostStepDoIts
41  // G4double safety = std::max(endpointSafety - (endpointSafOrigin -
42  // fPostStepPoint->GetPosition()).mag(),0.);
43  // step.GetPostStepPoint()->SetSafety(safety);
44 
45  // the secondaries from the original process are also created at the wrapper
46  // process, but they must be deleted whether the parameterized physics is
47  // an 'ExclusivelyForced' process or not. Normally the secondaries will be
48  // created after this wrapper process in G4SteppingManager::InvokePSDIP
49 
50  // store the secondaries from ParticleChange to SecondaryList
51 
52  G4TrackVector *fSecondary = (const_cast<G4Step *>(&step))->GetfSecondary();
53  G4int nSecondarySave = fSecondary->size();
54 
55  G4int num2ndaries = particleChange->GetNumberOfSecondaries();
56  G4Track *tempSecondaryTrack;
57 
58  for (G4int DSecLoop = 0; DSecLoop < num2ndaries; DSecLoop++) {
59  tempSecondaryTrack = particleChange->GetSecondary(DSecLoop);
60 
61  // Set the process pointer which created this track
62  tempSecondaryTrack->SetCreatorProcess(pRegProcess);
63 
64  // add secondaries from this wrapper process to the existing list
65  fSecondary->push_back(tempSecondaryTrack);
66 
67  } // end of loop on secondary
68 
69  // Now we can still impose conditions on the secondaries from ModelTrigger,
70  // such as the number of secondaries produced by the original process as well
71  // as those by other continuous processes - for the hadronic inelastic
72  // interaction, it is always true that
73  // particleChange->GetNumberOfSecondaries() > 0
74 
75  // at this stage, updated step information after all processes involved
76  // should be available
77 
78  // Print(step);
79 
80  // call ModelTrigger for the second time - the primary loop of PostStepGPIL
81  // is inside G4SteppingManager::DefinePhysicalStepLength().
82 
83  pmanager = track.GetDefinition()->GetProcessManager();
84 
85  G4double testGPIL = DBL_MAX;
86  G4double fStepLength = 0.0;
87  G4ForceCondition fForceCondition = InActivated;
88 
89  fStepLength = step.GetStepLength();
90 
91  fProcessVector = pmanager->GetPostStepProcessVector(typeDoIt);
92 
93  // keep the current status of track, use fPostponeToNextEvent word for
94  // this particular PostStep GPIL and then restore G4TrackStatus if the
95  // paramterized physics doesn't meet trigger conditions in ModelTrigger
96 
97  const G4TrackStatus keepStatus = track.GetTrackStatus();
98 
99  (const_cast<G4Track *>(&track))->SetTrackStatus(fPostponeToNextEvent);
100  int fpv_entries = fProcessVector->entries();
101  for (G4int ipm = 0; ipm < fpv_entries; ipm++) {
102  fProcess = (*fProcessVector)(ipm);
103 
104  if (fProcess->GetProcessType() == fParameterisation) {
105  // test ModelTrigger via PostStepGPIL
106 
107  testGPIL = fProcess->PostStepGPIL(track, fStepLength, &fForceCondition);
108 
109  // if G4FastSimulationModel:: ModelTrigger is true, then the parameterized
110  // physics process takes over the current process
111 
112  if (fForceCondition == ExclusivelyForced) {
113  // clean up memory for changing the process - counter clean up for
114  // the secondaries created by new G4Track in
115  // G4HadronicProcess::FillTotalResult
116  G4int nsec = particleChange->GetNumberOfSecondaries();
117  for (G4int DSecLoop = 0; DSecLoop < nsec; DSecLoop++) {
118  G4Track *tempSecondaryTrack = particleChange->GetSecondary(DSecLoop);
119  delete tempSecondaryTrack;
120  }
121  particleChange->Clear();
122 
123  // updating G4Step between PostStepGPIL and PostStepDoIt for the
124  // parameterized process may not be necessary, but do it anyway
125 
126  (const_cast<G4Step *>(&step))->SetStepLength(testGPIL);
127  (const_cast<G4Track *>(&track))->SetStepLength(testGPIL);
128 
129  step.GetPostStepPoint()->SetStepStatus(fExclusivelyForcedProc);
130  ;
131  step.GetPostStepPoint()->SetProcessDefinedStep(fProcess);
132  step.GetPostStepPoint()->SetSafety(0.0);
133 
134  // invoke PostStepDoIt: equivalent steps for
135  // G4SteppingManager::InvokePSDIP
136  particleChange = fProcess->PostStepDoIt(track, step);
137 
138  // update PostStepPoint of Step according to ParticleChange
139  particleChange->UpdateStepForPostStep(const_cast<G4Step *>(&step));
140 
141  // update G4Track according to ParticleChange after each PostStepDoIt
142  (const_cast<G4Step *>(&step))->UpdateTrack();
143 
144  // update safety after each invocation of PostStepDoIts - acutally this
145  // is not necessary for the parameterized physics process, but do it
146  // anyway
147  step.GetPostStepPoint()->SetSafety(0.0);
148 
149  // additional nullification
150  (const_cast<G4Track *>(&track))->SetTrackStatus(particleChange->GetTrackStatus());
151  } else {
152  // restore TrackStatus if fForceCondition != ExclusivelyForced
153  (const_cast<G4Track *>(&track))->SetTrackStatus(keepStatus);
154  }
155  // assume that there is one and only one parameterized physics
156  break;
157  }
158  }
159 
160  // remove secondaries of this wrapper process that were added to the secondary
161  // list since they will be added in the normal stepping procedure after
162  // this->PostStepDoIt in G4SteppingManager::InvokePSDIP
163 
164  // move the iterator to the (nSecondarySave+1)th element in the secondary list
165  G4TrackVector::iterator itv = fSecondary->begin();
166  itv += nSecondarySave;
167 
168  // delete next num2ndaries tracks from the secondary list
169  fSecondary->erase(itv, itv + num2ndaries);
170 
171  // end of specific actions of this wrapper process
172 
173  return particleChange;
174 }
step
Definition: StallMonitor.cc:83

◆ Print()

void GflashHadronWrapperProcess::Print ( const G4Step &  astep)

Definition at line 176 of file GflashHadronWrapperProcess.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::G4cout, and particleChange.

176  {
177  G4cout << " GflashHadronWrapperProcess ProcessName, PreStepPosition, preStepPoint KE, PostStepPoint KE, DeltaEnergy "
178  "Nsec \n "
179  << step.GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() << " "
180  << step.GetPostStepPoint()->GetPosition() << " " << step.GetPreStepPoint()->GetKineticEnergy() / CLHEP::GeV
181  << " " << step.GetPostStepPoint()->GetKineticEnergy() / CLHEP::GeV << " " << step.GetDeltaEnergy() / CLHEP::GeV
182  << " " << particleChange->GetNumberOfSecondaries() << G4endl;
183 }
step
Definition: StallMonitor.cc:83

Member Data Documentation

◆ fProcess

G4VProcess* GflashHadronWrapperProcess::fProcess
private

Definition at line 34 of file GflashHadronWrapperProcess.h.

Referenced by PostStepDoIt().

◆ fProcessVector

G4ProcessVector* GflashHadronWrapperProcess::fProcessVector
private

Definition at line 33 of file GflashHadronWrapperProcess.h.

Referenced by PostStepDoIt().

◆ particleChange

G4VParticleChange* GflashHadronWrapperProcess::particleChange
private

Definition at line 31 of file GflashHadronWrapperProcess.h.

Referenced by PostStepDoIt(), and Print().

◆ pmanager

G4ProcessManager* GflashHadronWrapperProcess::pmanager
private

Definition at line 32 of file GflashHadronWrapperProcess.h.

Referenced by PostStepDoIt().

◆ theProcessName

G4String GflashHadronWrapperProcess::theProcessName
private

Definition at line 29 of file GflashHadronWrapperProcess.h.

Referenced by GetName(), and GflashHadronWrapperProcess().