ATLAS Offline Software
ScoringVolumeTrackKiller.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <string>
8 #include <iostream>
9 
10 #include "G4Step.hh"
11 #include "G4TrackVector.hh"
12 
13 #include "GaudiKernel/Bootstrap.h"
14 #include "GaudiKernel/ISvcLocator.h"
15 #include "GaudiKernel/IMessageSvc.h"
16 
17 namespace G4UA
18 {
19 
20  //---------------------------------------------------------------------------
22  : AthMessaging(Gaudi::svcLocator()->service< IMessageSvc >( "MessageSvc" ),
23  "ScoringVolumeTrackKiller")
24  , m_killCount(0)
25  {}
26 
27  //---------------------------------------------------------------------------
29  {
30  ATH_MSG_INFO( m_killCount << " tracks killed in this event " );
31  m_killCount = 0;
32  }
33 
34  //---------------------------------------------------------------------------
36  {
37  G4StepPoint* preStep = aStep->GetPreStepPoint();
38  const G4VTouchable* preTouchable = preStep->GetTouchable();
39  G4StepPoint* postStep = aStep->GetPostStepPoint();
40  const G4VTouchable* postTouchable = postStep->GetTouchable();
41  int preDepth = preTouchable->GetHistoryDepth();
42  int postDepth = postTouchable->GetHistoryDepth();
43 
44  std::string preName;
45  bool preInStation = false;
46  for (int i = 0; i < preDepth+1; i++) {
47  preName = preTouchable->GetVolume(i)->GetName();
48  if (preName.find("station") != std::string::npos ||
49  preName.find("av_") != std::string::npos) {
50 
51  preInStation = true;
52  break;
53  }
54  }
55  std::string postName;
56  bool postOutofStation = true;
57  bool outOfMother = false;
58  for (int i = 0; i < postDepth+1; i++) {
59  if (postTouchable->GetVolume(i) != 0) {
60  postName = postTouchable->GetVolume(i)->GetName();
61  } else {
62  outOfMother = true;
63  break;
64  }
65  if (postName.find("station") != std::string::npos ||
66  postName.find("av_") != std::string::npos) {
67 
68  postOutofStation = false;
69  break;
70  }
71  }
72  if ( (preInStation && postOutofStation) || outOfMother ) {
73  aStep->GetTrack()->SetTrackStatus(fStopAndKill);
74  m_killCount++;
75  }
76  }
77 
78 } // namespace G4UA
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
G4UA::ScoringVolumeTrackKiller::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override
Definition: ScoringVolumeTrackKiller.cxx:28
G4UA
for nSW
Definition: CalibrationDefaultProcessing.h:19
ScoringVolumeTrackKiller.h
G4UA::ScoringVolumeTrackKiller::ScoringVolumeTrackKiller
ScoringVolumeTrackKiller()
Definition: ScoringVolumeTrackKiller.cxx:21
G4UA::ScoringVolumeTrackKiller::m_killCount
unsigned long m_killCount
Definition: ScoringVolumeTrackKiller.h:24
lumiFormat.i
int i
Definition: lumiFormat.py:92
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
G4UA::ScoringVolumeTrackKiller::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override
Definition: ScoringVolumeTrackKiller.cxx:35
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273