7 #include "GaudiKernel/IDataProviderSvc.h"
8 #include "GaudiKernel/INTupleSvc.h"
9 #include "GaudiKernel/NTuple.h"
10 #include "GaudiKernel/SmartDataPtr.h"
11 #include "GaudiKernel/Bootstrap.h"
12 #include "GaudiKernel/ISvcLocator.h"
13 #include "GaudiKernel/IMessageSvc.h"
18 #include "G4StepPoint.hh"
19 #include "G4VProcess.hh"
27 AthMessaging(
Gaudi::svcLocator()->service<IMessageSvc>(
"MessageSvc"),
"StepHistogram"),
29 m_initialKineticEnergyOfStep(),
38 G4Track *tr = aStep->GetTrack();
41 G4StepPoint *PreStepPoint = aStep->GetPreStepPoint();
44 G4StepPoint *PostStepPoint = aStep->GetPostStepPoint();
47 double stepKinetic = PreStepPoint->GetKineticEnergy();
50 double postStepKinetic = PostStepPoint->GetKineticEnergy();
53 const G4ThreeVector& myPos = PreStepPoint->GetPosition();
57 if (!(tr->GetDefinition()->GetParticleType() ==
"nucleus"))
61 G4String volumeName = PreStepPoint->GetPhysicalVolume()->GetName();
65 G4String materialName = PreStepPoint->GetMaterial()->GetName();
69 G4String processName = PostStepPoint->GetProcessDefinedStep() ?
70 PostStepPoint->GetProcessDefinedStep()->GetProcessName() :
"Unknown";
73 const std::vector<const G4Track*>* secondaries = aStep->GetSecondaryInCurrentStep();
77 float DepositedE = aStep->GetTotalEnergyDeposit();
79 2000, -20000, 20000, 1000, 0, 5000, myPos.getZ(), myPos.perp(), 1.);
81 2000, -20000, 20000, 1000, 0, 5000, myPos.getZ(), myPos.perp(), 1.);
83 2000, -20000, 20000, 1000, 0, 5000, myPos.getZ(), myPos.perp(), 1.);
85 2000, -20000, 20000, 1000, 0, 5000, myPos.getZ(), myPos.perp(), DepositedE);
87 2000, -20000, 20000, 1000, 0, 5000, myPos.getZ(), myPos.perp(), DepositedE);
92 1000, -12, 4, log10(aStep->GetStepLength()), 1.);
94 1000, -12, 4, log10(aStep->GetStepLength()), 1.);
96 1000, -12, 4, log10(aStep->GetStepLength()), 1.);
100 200, -10, 10, myPos.eta(), 1.);
102 200, -10, 10, myPos.eta(), 1.);
104 200, -10, 10, myPos.eta(), 1.);
108 1000, -9, 7, log10(stepKinetic), 1.);
110 1000, -9, 7, log10(stepKinetic), 1.);
112 1000, -9, 7, log10(stepKinetic), 1.);
114 1000, -9, 7, log10(stepKinetic), 1.);
118 1000, -9, 7, log10(postStepKinetic), 1.);
120 1000, -9, 7, log10(postStepKinetic), 1.);
122 1000, -9, 7, log10(postStepKinetic), 1.);
124 1000, -9, 7, log10(postStepKinetic), 1.);
128 1000, -11, 3, log10(aStep->GetTotalEnergyDeposit()), 1.);
130 1000, -11, 3, log10(aStep->GetTotalEnergyDeposit()), 1.);
132 1000, -11, 3, log10(aStep->GetTotalEnergyDeposit()), 1.);
136 1000, -11, 1, log10(aStep->GetNonIonizingEnergyDeposit()), 1.);
138 1000, -11, 1, log10(aStep->GetNonIonizingEnergyDeposit()), 1.);
140 1000, -11, 1, log10(aStep->GetNonIonizingEnergyDeposit()), 1.);
143 for (
const auto &
track : *secondaries) {
146 1000, -7, 5, log10(
track->GetKineticEnergy()), 1.);
148 1000, -7, 5, log10(
track->GetKineticEnergy()), 1.);
150 1000, -7, 5, log10(
track->GetKineticEnergy()), 1.);
159 if (tr->GetCurrentStepNumber()==1) {
183 if ( tr->GetTrackStatus() == 2 ) {
185 if (not (tr->GetTrackID() ==
m_trackID)) {
186 ATH_MSG_ERROR(
"Track ID changed between the assumed first step and the last.");
190 int nSteps = tr->GetCurrentStepNumber() + 1;
192 10000, 0.5, 10000.5,
nSteps, 1.);
194 10000, 0.5, 10000.5,
nSteps, 1.);
196 10000, 0.5, 10000.5,
nSteps, 1.);
198 10000, 0.5, 10000.5,
nSteps, 1.);
210 1000, -9, 7, log10(tr->GetTrackLength()), 1.);
212 1000, -9, 7, log10(tr->GetTrackLength()), 1.);
214 1000, -9, 7, log10(tr->GetTrackLength()), 1.);
216 1000, -9, 7, log10(tr->GetTrackLength()), 1.);
222 int nbinsx,
double xmin,
double xmax,
223 int nbinsy,
double ymin,
double ymax,
224 double valuex,
double valuey,
double weight)
226 const auto& [pStringMapPair, inserted] = hMapMap.try_emplace(vol,
HistoMap_t());
230 std::ostringstream stringStream;
241 const auto& [pStringMapPair, inserted] = hMapMap.try_emplace(vol,
HistoMap_t());
245 std::ostringstream stringStream;
256 const auto& [pStringMapPair, inserted] = hMapMap.try_emplace(vol,
HistoMap_t());
260 std::ostringstream stringStream;
268 for (
auto const& [g4String, histoMap] : refMap){
269 const auto& [pStringMapPair, inserted] = selfMap.try_emplace(g4String, histoMap);
272 for (
auto const& hm : histoMap){
275 target.emplace(hm.first, hm.second);
279 target[hm.first]->Add(hm.second);
287 mergeMaps(histoMapMap_vol_stepSize,
rep.histoMapMap_vol_stepSize);
288 mergeMaps(histoMapMap_vol_stepKineticEnergy,
rep.histoMapMap_vol_stepKineticEnergy);
289 mergeMaps(histoMapMap_vol_postStepKineticEnergy,
rep.histoMapMap_vol_postStepKineticEnergy);
290 mergeMaps(histoMapMap_vol_stepPseudorapidity,
rep.histoMapMap_vol_stepPseudorapidity);
291 mergeMaps(histoMapMap_vol_stepEnergyDeposit,
rep.histoMapMap_vol_stepEnergyDeposit);
292 mergeMaps(histoMapMap_vol_stepEnergyNonIonDeposit,
rep.histoMapMap_vol_stepEnergyNonIonDeposit);
293 mergeMaps(histoMapMap_vol_stepSecondaryKinetic,
rep.histoMapMap_vol_stepSecondaryKinetic);
295 mergeMaps(histoMapMap_mat_stepSize,
rep.histoMapMap_mat_stepSize);
296 mergeMaps(histoMapMap_mat_stepKineticEnergy,
rep.histoMapMap_mat_stepKineticEnergy);
297 mergeMaps(histoMapMap_mat_postStepKineticEnergy,
rep.histoMapMap_mat_postStepKineticEnergy);
298 mergeMaps(histoMapMap_mat_stepPseudorapidity,
rep.histoMapMap_mat_stepPseudorapidity);
299 mergeMaps(histoMapMap_mat_stepEnergyDeposit,
rep.histoMapMap_mat_stepEnergyDeposit);
300 mergeMaps(histoMapMap_mat_stepEnergyNonIonDeposit,
rep.histoMapMap_mat_stepEnergyNonIonDeposit);
301 mergeMaps(histoMapMap_mat_stepSecondaryKinetic,
rep.histoMapMap_mat_stepSecondaryKinetic);
303 mergeMaps(histoMapMap_prc_stepSize,
rep.histoMapMap_prc_stepSize);
304 mergeMaps(histoMapMap_prc_stepKineticEnergy,
rep.histoMapMap_prc_stepKineticEnergy);
305 mergeMaps(histoMapMap_prc_postStepKineticEnergy,
rep.histoMapMap_prc_postStepKineticEnergy);
306 mergeMaps(histoMapMap_prc_stepPseudorapidity,
rep.histoMapMap_prc_stepPseudorapidity);
307 mergeMaps(histoMapMap_prc_stepEnergyDeposit,
rep.histoMapMap_prc_stepEnergyDeposit);
308 mergeMaps(histoMapMap_prc_stepEnergyNonIonDeposit,
rep.histoMapMap_prc_stepEnergyNonIonDeposit);
309 mergeMaps(histoMapMap_prc_stepSecondaryKinetic,
rep.histoMapMap_prc_stepSecondaryKinetic);
311 mergeMaps(histoMapMap_numberOfSteps,
rep.histoMapMap_numberOfSteps);
312 mergeMaps(histoMapMap_vol_numberOfSteps,
rep.histoMapMap_vol_numberOfSteps);
313 mergeMaps(histoMapMap_mat_numberOfSteps,
rep.histoMapMap_mat_numberOfSteps);
314 mergeMaps(histoMapMap_prc_numberOfSteps,
rep.histoMapMap_prc_numberOfSteps);
315 mergeMaps(histoMapMap_numberOfStepsPerInitialE,
rep.histoMapMap_numberOfStepsPerInitialE);
316 mergeMaps(histoMapMap_vol_numberOfStepsPerInitialE,
rep.histoMapMap_vol_numberOfStepsPerInitialE);
317 mergeMaps(histoMapMap_mat_numberOfStepsPerInitialE,
rep.histoMapMap_mat_numberOfStepsPerInitialE);
318 mergeMaps(histoMapMap_prc_numberOfStepsPerInitialE,
rep.histoMapMap_prc_numberOfStepsPerInitialE);
319 mergeMaps(histoMapMap_trackLengthPerInitialE,
rep.histoMapMap_trackLengthPerInitialE);
320 mergeMaps(histoMapMap_vol_trackLengthPerInitialE,
rep.histoMapMap_vol_trackLengthPerInitialE);
321 mergeMaps(histoMapMap_mat_trackLengthPerInitialE,
rep.histoMapMap_mat_trackLengthPerInitialE);
322 mergeMaps(histoMapMap_prc_trackLengthPerInitialE,
rep.histoMapMap_prc_trackLengthPerInitialE);
323 mergeMaps(histoMapMap_InitialE,
rep.histoMapMap_InitialE);
324 mergeMaps(histoMapMap_vol_InitialE,
rep.histoMapMap_vol_InitialE);
325 mergeMaps(histoMapMap_mat_InitialE,
rep.histoMapMap_mat_InitialE);
326 mergeMaps(histoMapMap_prc_InitialE,
rep.histoMapMap_prc_InitialE);
327 mergeMaps(histoMapMap_stepKinetic,
rep.histoMapMap_stepKinetic);
328 mergeMaps(histoMapMap_postStepKinetic,
rep.histoMapMap_postStepKinetic);
330 mergeMaps(histoMapMap2D_vol_RZ,
rep.histoMapMap2D_vol_RZ);
331 mergeMaps(histoMapMap2D_mat_RZ,
rep.histoMapMap2D_mat_RZ);
332 mergeMaps(histoMapMap2D_prc_RZ,
rep.histoMapMap2D_prc_RZ);
333 mergeMaps(histoMapMap2D_vol_RZ_E,
rep.histoMapMap2D_vol_RZ_E);
334 mergeMaps(histoMapMap2D_mat_RZ_E,
rep.histoMapMap2D_mat_RZ_E);