ATLAS Offline Software
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
G4UA::TestBoundariesUserAction Class Reference

#include <TestBoundariesUserAction.h>

Inheritance diagram for G4UA::TestBoundariesUserAction:
Collaboration diagram for G4UA::TestBoundariesUserAction:

Classes

struct  Data
 

Public Member Functions

 TestBoundariesUserAction ()
 
virtual void BeginOfRunAction (const G4Run *) override
 
virtual void EndOfRunAction (const G4Run *) override
 
virtual void UserSteppingAction (const G4Step *) override
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Types

typedef std::map< std::string, int > SMap
 

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

SMap m_sel
 
TFile * m_file {}
 
TTree * m_tree {}
 
struct G4UA::TestBoundariesUserAction::Data m_data
 
std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

Detailed Description

Definition at line 23 of file TestBoundariesUserAction.h.

Member Typedef Documentation

◆ SMap

typedef std::map<std::string,int> G4UA::TestBoundariesUserAction::SMap
private

Definition at line 35 of file TestBoundariesUserAction.h.

Constructor & Destructor Documentation

◆ TestBoundariesUserAction()

G4UA::TestBoundariesUserAction::TestBoundariesUserAction ( )

Definition at line 22 of file TestBoundariesUserAction.cxx.

23  : AthMessaging(Gaudi::svcLocator()->service< IMessageSvc >( "MessageSvc" ),
24  "TestBoundariesUserAction")
25  {
26  }

Member Function Documentation

◆ BeginOfRunAction()

void G4UA::TestBoundariesUserAction::BeginOfRunAction ( const G4Run *  )
overridevirtual

Definition at line 28 of file TestBoundariesUserAction.cxx.

29  {
30  m_file = TFile::Open("points.root","RECREATE");
31  ATH_MSG_INFO("Open file points.root, create tree");
32  m_file->cd();
33  m_tree = new TTree("points","points");
34  m_tree->Branch("x",&m_data.x,"x/F");
35  m_tree->Branch("y",&m_data.y,"y/F");
36  m_tree->Branch("z",&m_data.z,"z/F");
37  m_tree->Branch("volume",&m_data.volume,"volume/I");
38  m_tree->Branch("enter",&m_data.enter,"enter/O");
39  m_tree->Branch("exit",&m_data.exit,"exit/O");
40  m_tree->Branch("leave",&m_data.leave,"leave/O");
41  }

◆ EndOfRunAction()

void G4UA::TestBoundariesUserAction::EndOfRunAction ( const G4Run *  )
overridevirtual

Definition at line 43 of file TestBoundariesUserAction.cxx.

44  {
45  ATH_MSG_INFO("Writing file points.root");
46  m_file->cd();
47  m_tree->Write();
48  m_file->Close();
49  delete m_file;
50  m_file=nullptr;
51  m_tree=nullptr;
52  }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40 {
42  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152 {
153  if (!m_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level  lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29 {
30  m_lvl = lvl;
31 }

◆ UserSteppingAction()

void G4UA::TestBoundariesUserAction::UserSteppingAction ( const G4Step *  aStep)
overridevirtual

Definition at line 54 of file TestBoundariesUserAction.cxx.

55  {
56  G4StepPoint* preStep = aStep->GetPreStepPoint();
57  G4StepPoint* postStep = aStep->GetPostStepPoint();
58 
59  if (!preStep || !postStep) {
60  ATH_MSG_ERROR("TestBoundariesUserAction Error something missing");
61  return;
62  }
63 
64  const G4TouchableHistory* preTH = dynamic_cast<const G4TouchableHistory*>(preStep->GetTouchable());
65  const G4TouchableHistory* postTH = dynamic_cast<const G4TouchableHistory*>(postStep->GetTouchable());
66  G4LogicalVolume* preLV = preStep->GetPhysicalVolume()->GetLogicalVolume();
67 
68  if (preTH) {
69  int preN=preTH->GetHistoryDepth();
70  if (preN>0) preLV = preTH->GetVolume(preN-1)->GetLogicalVolume();
71  }
72 
73  G4LogicalVolume* postLV{};
74  if (postStep->GetPhysicalVolume())
75  postLV = postStep->GetPhysicalVolume()->GetLogicalVolume();
76  if (postTH) {
77  int postN = postTH->GetHistoryDepth();
78  if (postN>0) postLV = postTH->GetVolume(postN-1)->GetLogicalVolume();
79  }
80 
81  if (postLV!=preLV) {
82  const G4ThreeVector& pos = aStep->GetPostStepPoint()->GetPosition();
83  m_data.Set(pos.x(),pos.y(),pos.z(),0);
84  if (preLV) {
85  const std::string& preStepPointName = preLV->GetName();
86  SMap::const_iterator it = m_sel.find(preStepPointName);
87  if (it!=m_sel.end()) {
88  m_data.volume = it->second;
89  m_data.Reset();
90  m_data.exit = true;
91  if (m_tree) m_tree->Fill();
92  }
93  }
94  if (postLV) {
95  SMap::const_iterator it = m_sel.find( postLV->GetName() );
96  if (it!=m_sel.end()) {
97  m_data.volume = it->second;
98  m_data.Reset();
99  m_data.enter = true;
100  if (m_tree) m_tree->Fill();
101  }
102  }
103  else {
104  m_data.volume = 0;
105  m_data.Reset();
106  m_data.leave = true;
107  if (m_tree) m_tree->Fill();
108  }
109  }
110  }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_data

struct G4UA::TestBoundariesUserAction::Data G4UA::TestBoundariesUserAction::m_data
private

◆ m_file

TFile* G4UA::TestBoundariesUserAction::m_file {}
private

Definition at line 38 of file TestBoundariesUserAction.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_sel

SMap G4UA::TestBoundariesUserAction::m_sel
private

Definition at line 36 of file TestBoundariesUserAction.h.

◆ m_tree

TTree* G4UA::TestBoundariesUserAction::m_tree {}
private

Definition at line 39 of file TestBoundariesUserAction.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
G4UA::TestBoundariesUserAction::Data::Reset
void Reset()
Reset the data.
Definition: TestBoundariesUserAction.h:53
G4UA::TestBoundariesUserAction::m_tree
TTree * m_tree
Definition: TestBoundariesUserAction.h:39
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
skel.it
it
Definition: skel.GENtoEVGEN.py:423
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
G4UA::TestBoundariesUserAction::Data::x
Float_t x
Definition: TestBoundariesUserAction.h:43
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
G4UA::TestBoundariesUserAction::Data::leave
Bool_t leave
Definition: TestBoundariesUserAction.h:47
G4UA::TestBoundariesUserAction::Data::enter
Bool_t enter
Definition: TestBoundariesUserAction.h:45
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
G4UA::TestBoundariesUserAction::m_data
struct G4UA::TestBoundariesUserAction::Data m_data
G4UA::TestBoundariesUserAction::m_sel
SMap m_sel
Definition: TestBoundariesUserAction.h:36
G4UA::TestBoundariesUserAction::Data::y
Float_t y
Definition: TestBoundariesUserAction.h:43
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
G4UA::TestBoundariesUserAction::Data::z
Float_t z
Definition: TestBoundariesUserAction.h:43
G4UA::TestBoundariesUserAction::Data::Set
void Set(Float_t _x, Float_t _y, Float_t _z, Int_t _vol)
Set the data.
Definition: TestBoundariesUserAction.h:58
G4UA::TestBoundariesUserAction::Data::exit
Bool_t exit
Definition: TestBoundariesUserAction.h:46
G4UA::TestBoundariesUserAction::m_file
TFile * m_file
Definition: TestBoundariesUserAction.h:38
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
G4UA::TestBoundariesUserAction::Data::volume
Int_t volume
Definition: TestBoundariesUserAction.h:44
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132