ATLAS Offline Software
Loading...
Searching...
No Matches
G4UA::G4AtlantisDumper Class Reference

#include <G4AtlantisDumper.h>

Inheritance diagram for G4UA::G4AtlantisDumper:
Collaboration diagram for G4UA::G4AtlantisDumper:

Classes

struct  Config

Public Member Functions

 G4AtlantisDumper (const Config &config)
virtual void UserSteppingAction (const G4Step *) override
virtual void EndOfEventAction (const G4Event *) override
virtual void BeginOfEventAction (const G4Event *) override
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Member Functions

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

Private Attributes

Config m_config
ServiceHandle< StoreGateSvcm_evtStore
 Pointer to StoreGate (event store by default)
ServiceHandle< StoreGateSvcm_detStore
 Pointer to StoreGate (detector store by default)
int m_nsteps
std::ofstream * m_file
std::string m_filename
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Definition at line 21 of file G4AtlantisDumper.h.

Constructor & Destructor Documentation

◆ G4AtlantisDumper()

G4UA::G4AtlantisDumper::G4AtlantisDumper ( const Config & config)

Definition at line 24 of file G4AtlantisDumper.cxx.

24 :
25 AthMessaging(Gaudi::svcLocator()->service< IMessageSvc >( "MessageSvc" ),"G4AtlantisDumper"),
26 m_config(config),
27 m_evtStore("StoreGateSvc/StoreGateSvc","G4AtlantisDumper"),
28 m_detStore("StoreGateSvc/DetectorStore","G4AtlantisDumper"),
29 m_nsteps(0),
30 m_file(NULL)
31 {}
AthMessaging()
Default constructor:
ServiceHandle< StoreGateSvc > m_evtStore
Pointer to StoreGate (event store by default)
ServiceHandle< StoreGateSvc > m_detStore
Pointer to StoreGate (detector store by default)

Member Function Documentation

◆ BeginOfEventAction()

void G4UA::G4AtlantisDumper::BeginOfEventAction ( const G4Event * )
overridevirtual

Definition at line 109 of file G4AtlantisDumper.cxx.

110 {
111 m_nsteps = 0;
112
113 SG::ReadHandle<xAOD::EventInfo> evt("EventInfo");
114 if(!evt.isValid()) {
115 ATH_MSG_INFO("G4AtlantisDumper could not get event info!");
116 return;
117 }
118
119 int athevent = evt->eventNumber();
120 int athrun = evt->runNumber();
121 ATH_MSG_INFO("G4AtlantisDumper: Athena run event is "<<athrun<<" "<<athevent);
122 char buf[1000];
123 int length=snprintf(buf, 1000, "G4Atlantis_%d_%d.txt", athrun, athevent);
124 if(999<length) {
125 ATH_MSG_WARNING( "BeginOfEvent:: m_filename string (" << buf << ") was truncated" );
126 }
127 ATH_MSG_INFO( "G4AtlantisDumper: Opening m_file "<<buf);
128 m_file = new std::ofstream();
129 m_file->open(buf);
130 m_filename = buf;
131 }
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
double length(const pvec &v)

◆ EndOfEventAction()

void G4UA::G4AtlantisDumper::EndOfEventAction ( const G4Event * event)
overridevirtual

Definition at line 99 of file G4AtlantisDumper.cxx.

100 {
101 ATH_MSG_INFO( "Goodbye from G4AtlantisDumper, event "<<event->GetEventID());
102 m_file->close();
103 delete m_file;
104
105 ATH_MSG_INFO("G4AtlantisDumper: zipping "<<m_filename);
106 system(("zip -m "+m_filename+".zip "+m_filename).c_str());
107 }

◆ 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 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ 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 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ 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 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ 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_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ 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::G4AtlantisDumper::UserSteppingAction ( const G4Step * aStep)
overridevirtual

Definition at line 33 of file G4AtlantisDumper.cxx.

34 {
35 const G4Track *t=aStep->GetTrack();
36 //if(m_nsteps>40) return;
37 if (!t) return;
38
39 int id=t->GetTrackID();
40 int pid=t->GetParentID();
41
42 int fs=aStep->IsFirstStepInVolume();
43 int ls=aStep->IsLastStepInVolume();
44 int stepn=t->GetCurrentStepNumber();
45
46 const G4TrackVector *sec=aStep->GetSecondary();
47 int nsec=0; if (sec) nsec=sec->size();
48
49 double tedep=aStep->GetTotalEnergyDeposit();
50 double tnedep=aStep->GetNonIonizingEnergyDeposit();
51 double length=aStep->GetStepLength();
52 int pdg=t->GetDefinition()->GetPDGEncoding();
53
54 bool keep=false;
55 if (fs||ls) keep=true;
56 if (tedep>m_config.tedep_cut) keep=true;//default = 0.1 MeV
57 if (length>m_config.length_cut) keep=true;//default = 1.0 mm
58 if (aStep->GetPreStepPoint()->GetMomentum().mag()<m_config.p_cut) keep=false;//default = 10 MeV
59 if (aStep->GetPreStepPoint()->GetKineticEnergy()<m_config.ke_cut) keep=false;//default = 10 MeV
60 if (!keep) return;
61
62 //const G4VPhysicalVolume *v =t->GetVolume();
63 //const G4Material *m =t->GetMaterial();
64
65 const G4VProcess *p =t->GetCreatorProcess();
66 G4String pn="none"; if(p) pn=p->GetProcessName();
67
68 G4ThreeVector pos1=aStep->GetPreStepPoint()->GetPosition();
69 double x1=pos1.x(); double y1=pos1.y(); double z1=pos1.z();
70 double t1=aStep->GetPreStepPoint()->GetGlobalTime();
71 G4ThreeVector pos2=aStep->GetPostStepPoint()->GetPosition();
72 double x2=pos2.x(); double y2=pos2.y(); double z2=pos2.z();
73 double t2=aStep->GetPostStepPoint()->GetGlobalTime();
74 G4ThreeVector p1=aStep->GetPreStepPoint()->GetMomentum();
75 double px1=p1.x(); double py1=p1.y(); double pz1=p1.z();
76 G4ThreeVector p2=aStep->GetPostStepPoint()->GetMomentum();
77 double px2=p2.x(); double py2=p2.y(); double pz2=p2.z();
78 double ke1=aStep->GetPreStepPoint()->GetKineticEnergy();
79 double ke2=aStep->GetPostStepPoint()->GetKineticEnergy();
80 //GetVelocity() //GetBeta() //GetGamma()
81 //GetSensitiveDetector() //GetPolarization()
82 double mass=aStep->GetPreStepPoint()->GetMass();
83 double charge=aStep->GetPreStepPoint()->GetCharge();
84 //GetMagneticMoment()
85
86 (*m_file)<<"ACH_G4Step";
87 (*m_file)<<" "<<m_nsteps; (*m_file)<<" "<<id; (*m_file)<<" "<<pid; (*m_file)<<" "<<(int)fs; (*m_file)<<" "<<(int)ls; (*m_file)<<" "<<stepn;
88 (*m_file)<<" "<<pn; (*m_file)<<" "<<nsec;
89 (*m_file)<<" "<<tedep; (*m_file)<<" "<<tnedep; (*m_file)<<" "<<length; (*m_file)<<" "<<pdg; (*m_file)<<" "<<mass; (*m_file)<<" "<<charge;
90 (*m_file)<<" "<<x1; (*m_file)<<" "<<y1; (*m_file)<<" "<<z1; (*m_file)<<" "<<t1;
91 (*m_file)<<" "<<px1; (*m_file)<<" "<<py1; (*m_file)<<" "<<pz1; (*m_file)<<" "<<ke1;
92 (*m_file)<<" "<<x2; (*m_file)<<" "<<y2; (*m_file)<<" "<<z2; (*m_file)<<" "<<t2;
93 (*m_file)<<" "<<px2; (*m_file)<<" "<<py2; (*m_file)<<" "<<pz2; (*m_file)<<" "<<ke2;
94 (*m_file)<<std::endl;
95
96 ++m_nsteps;
97 }
double charge(const T &p)
Definition AtlasPID.h:997
static Double_t fs
std::vector< ALFA_RawDataContainer_p1 > t2
std::vector< ALFA_RawDataCollection_p1 > t1
ls(path, longls=False)
Definition DiskUtils.py:111

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_config

Config G4UA::G4AtlantisDumper::m_config
private

Definition at line 42 of file G4AtlantisDumper.h.

◆ m_detStore

ServiceHandle<StoreGateSvc> G4UA::G4AtlantisDumper::m_detStore
private

Pointer to StoreGate (detector store by default)

Definition at line 47 of file G4AtlantisDumper.h.

◆ m_evtStore

ServiceHandle<StoreGateSvc> G4UA::G4AtlantisDumper::m_evtStore
private

Pointer to StoreGate (event store by default)

Definition at line 45 of file G4AtlantisDumper.h.

◆ m_file

std::ofstream* G4UA::G4AtlantisDumper::m_file
private

Definition at line 49 of file G4AtlantisDumper.h.

◆ m_filename

std::string G4UA::G4AtlantisDumper::m_filename
private

Definition at line 50 of file G4AtlantisDumper.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ 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_nsteps

int G4UA::G4AtlantisDumper::m_nsteps
private

Definition at line 48 of file G4AtlantisDumper.h.


The documentation for this class was generated from the following files: