ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. 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 Member Functions

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

Private Attributes

Config m_config
 
ServiceHandle< StoreGateSvcm_evtStore
 Pointer to StoreGate (event store by default) More...
 
ServiceHandle< StoreGateSvcm_detStore
 Pointer to StoreGate (detector store by default) More...
 
int m_nsteps
 
std::ofstream * m_file
 
std::string m_filename
 
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 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"),
27  m_evtStore("StoreGateSvc/StoreGateSvc","G4AtlantisDumper"),
28  m_detStore("StoreGateSvc/DetectorStore","G4AtlantisDumper"),
29  m_nsteps(0),
30  m_file(NULL)
31  {}

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 
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  }

◆ 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  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::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  }

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.

◆ 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_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:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
G4UA::G4AtlantisDumper::Config::p_cut
double p_cut
Definition: G4AtlantisDumper.h:32
G4UA::G4AtlantisDumper::m_evtStore
ServiceHandle< StoreGateSvc > m_evtStore
Pointer to StoreGate (event store by default)
Definition: G4AtlantisDumper.h:45
G4UA::G4AtlantisDumper::Config::tedep_cut
double tedep_cut
Definition: G4AtlantisDumper.h:30
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
G4UA::G4AtlantisDumper::m_filename
std::string m_filename
Definition: G4AtlantisDumper.h:50
G4UA::G4AtlantisDumper::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Pointer to StoreGate (detector store by default)
Definition: G4AtlantisDumper.h:47
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
G4UA::G4AtlantisDumper::m_config
Config m_config
Definition: G4AtlantisDumper.h:42
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
python.ZdcRecConfig.pn
pn
Definition: ZdcRecConfig.py:524
G4UA::G4AtlantisDumper::Config::ke_cut
double ke_cut
Definition: G4AtlantisDumper.h:33
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
python.DecayParser.buf
buf
print ("=> [%s]"cmd)
Definition: DecayParser.py:27
ReadCalibFromCool.keep
keep
Definition: ReadCalibFromCool.py:85
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
G4UA::G4AtlantisDumper::m_file
std::ofstream * m_file
Definition: G4AtlantisDumper.h:49
G4UA::G4AtlantisDumper::Config::length_cut
double length_cut
Definition: G4AtlantisDumper.h:31
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
charge
double charge(const T &p)
Definition: AtlasPID.h:756
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
Herwig7_QED_EvtGen_ll.fs
dictionary fs
Definition: Herwig7_QED_EvtGen_ll.py:17
python.DiskUtils.ls
def ls(path, longls=False)
Definition: DiskUtils.py:112
G4UA::G4AtlantisDumper::m_nsteps
int m_nsteps
Definition: G4AtlantisDumper.h:48
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
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26