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

NEEDS DOCUMENTATION. More...

#include <HitWrapper.h>

Inheritance diagram for G4UA::HitWrapper:
Collaboration diagram for G4UA::HitWrapper:

Classes

struct  Config

Public Member Functions

 HitWrapper (const Config &config)
virtual void EndOfEventAction (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 Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

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

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
Config m_config
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

NEEDS DOCUMENTATION.

Definition at line 18 of file HitWrapper.h.

Member Typedef Documentation

◆ StoreGateSvc_t

Definition at line 32 of file HitWrapper.h.

Constructor & Destructor Documentation

◆ HitWrapper()

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

Definition at line 30 of file HitWrapper.cxx.

31 : AthMessaging(Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc"),
32 "HitWrapper"),
33 m_evtStore("StoreGateSvc/StoreGateSvc","HitWrapper"),
34 m_detStore("StoreGateSvc/DetectorStore","HitWrapper"),
35 m_config(config)
36 {}
AthMessaging()
Default constructor:
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition HitWrapper.h:36
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition HitWrapper.h:34

Member Function Documentation

◆ EndOfEventAction()

void G4UA::HitWrapper::EndOfEventAction ( const G4Event * )
overridevirtual

for nSW

for nSW

Definition at line 39 of file HitWrapper.cxx.

40 {
41
42 SG::WriteHandle<CSCSimHitCollection> csc("CSC_Hits");
43 SG::WriteHandle<MDTSimHitCollection> mdt("MDT_Hits");
44 SG::WriteHandle<TGCSimHitCollection> tgc("TGC_Hits");
45 SG::WriteHandle<RPCSimHitCollection> rpc("RPC_Hits");
47 SG::WriteHandle<MMSimHitCollection> mmhits("MM_Hits");
48 SG::WriteHandle<sTGCSimHitCollection> stgc("sTGC_Hits");
49
50 if (!csc.isValid() ) ATH_MSG_WARNING( " HitWrapper could not access csc hit collection" );
51 else {
52 // std::cout << "Working on a collection of size " << cscC->size() << std::endl;
53 //CSCSimHitCollection * csc = const_cast< CSCSimHitCollection * > (&(*cscC));
54 for (CSCSimHitCollection::iterator hit=csc->begin();hit!=csc->end();++hit){
55 //std::cout << "Wrapping CSC hit with time " << (*hit).globalTime() << std::endl;
56 (*hit).setGlobalTime( fmod( (*hit).globalTime() , m_config.time ) );
57 }
58 }
59
60 if ( ! mdt.isValid() ) ATH_MSG_WARNING( " HitWrapper could not access mdt hit collection" );
61 else {
62 // std::cout << "Working on a collection of size " << mdtC->size() << std::endl;
63 //MDTSimHitCollection * mdt = const_cast< MDTSimHitCollection * > (&(*mdtC));
64 for (MDTSimHitCollection::iterator hit=mdt->begin();hit!=mdt->end();++hit){
65 //std::cout << "Wrapping MDT hit with time " << (*hit).globalTime() << std::endl;
66 (*hit).setGlobalTime( fmod( (*hit).globalTime() , m_config.time ) );
67 }
68 }
69
70 if (! rpc.isValid() ) ATH_MSG_WARNING( " HitWrapper could not access rpc hit collection" );
71 else {
72 // std::cout << "Working on a collection of size " << rpcC->size() << std::endl;
73 //RPCSimHitCollection * rpc = const_cast< RPCSimHitCollection * > (&(*rpcC));
74 for (RPCSimHitCollection::iterator hit=rpc->begin();hit!=rpc->end();++hit){
75 //std::cout << "Wrapping RPC hit with time " << (*hit).globalTime() << std::endl;
76 (*hit).setGlobalTime( fmod( (*hit).globalTime() , m_config.time ) );
77 }
78 }
79
80
81 if (! tgc.isValid() ) ATH_MSG_WARNING( " HitWrapper could not access tgc hit collection" );
82 else {
83 // std::cout << "Working on a collection of size " << tgcC->size() << std::endl;
84 //TGCSimHitCollection * tgc = const_cast< TGCSimHitCollection * > (&(*tgcC));
85 for (TGCSimHitCollection::iterator hit=tgc->begin();hit!=tgc->end();++hit){
86 //std::cout << "Wrapping TGC hit with time " << (*hit).globalTime() << std::endl;
87 (*hit).setGlobalTime( fmod( (*hit).globalTime() , m_config.time ) );
88 }
89 }
90
91
93 if (! mmhits.isValid() ) ATH_MSG_WARNING( " HitWrapper could not access Micromegas hit collection" );
94 else {
95 // std::cout << "Working on a collection of size " << nswC->size() << std::endl;
96 //GenericMuonSimHitCollection *mm = const_cast< GenericMuonSimHitCollection * > (&(*mmC));
97 for (MMSimHitCollection::iterator hit=mmhits->begin();hit!=mmhits->end();++hit){
98 //std::cout << "Wrapping GenericMuon hit with time " << (*hit).globalTime() << std::endl;
99 (*hit).setGlobalTime( fmod( (*hit).globalTime() , m_config.time ) );
100 }
101 }
102
103 if (! stgc.isValid() ) ATH_MSG_WARNING( " HitWrapper could not access sTGC hit collection" );
104 else {
105 // std::cout << "Working on a collection of size " << nswC->size() << std::endl;
106 //GenericMuonSimHitCollection *stgc = const_cast< GenericMuonSimHitCollection * > (&(*stgcC));
107 for (sTGCSimHitCollection::iterator hit=stgc->begin();hit!=stgc->end();++hit){
108 //std::cout << "Wrapping GenericMuon hit with time " << (*hit).globalTime() << std::endl;
109 (*hit).setGlobalTime( fmod( (*hit).globalTime() , m_config.time ) );
110 }
111 }
112
113 // Handle the inner detector next
114 SG::WriteHandle<TRTUncompressedHitCollection> trt("TRTUncompressedHits");
115 SG::WriteHandle<SiHitCollection> pix("PixelHits");
116 SG::WriteHandle<SiHitCollection> sct("SCT_Hits");
117
118 if (! trt.isValid() ) ATH_MSG_WARNING( " HitWrapper could not access trt hit collection" );
119 else {
120 //TRTUncompressedHitCollection * trt = const_cast< TRTUncompressedHitCollection * > (&*trtC);
121 for (TRTUncompressedHitCollection::iterator hit=trt->begin();hit!=trt->end();++hit){
122 //std::cout << "Wrapping TRT hit with time " << (*hit).globalTime() << std::endl;
123 (*hit).SetGlobalTime( std::fmod( (*hit).GetGlobalTime() , m_config.time ) );
124 }
125 }
126
127 if (! pix.isValid()) ATH_MSG_WARNING( " HitWrapper could not access pix hit collection" );
128 else {
129 //SiHitCollection * pix = const_cast<SiHitCollection *> (&*pixC);
130 for (SiHitCollection::iterator hit=pix->begin();hit!=pix->end();++hit){
131 //std::cout << "Wrapping Pix hit with time " << (*hit).meanTime() << std::endl;
132 (*hit).setMeanTime( fmod( (*hit).meanTime() , m_config.time ) );
133 }
134 }
135
136 if (! sct.isValid() ) ATH_MSG_WARNING( " HitWrapper could not access sct hit collection" );
137 else {
138 //SiHitCollection * sct = const_cast<SiHitCollection *> (&*sctC);
139 for (SiHitCollection::iterator hit=sct->begin();hit!=sct->end();++hit){
140 //std::cout << "Wrapping SCT hit with time " << (*hit).meanTime() << std::endl;
141 (*hit).setMeanTime( fmod( (*hit).meanTime() , m_config.time ) );
142 }
143 }
144
145 }
#define ATH_MSG_WARNING(x)

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

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::HitWrapper::m_config
private

Definition at line 38 of file HitWrapper.h.

◆ m_detStore

StoreGateSvc_t G4UA::HitWrapper::m_detStore
private

Pointer to StoreGate (detector store by default)

Definition at line 36 of file HitWrapper.h.

◆ m_evtStore

StoreGateSvc_t G4UA::HitWrapper::m_evtStore
private

Pointer to StoreGate (event store by default)

Definition at line 34 of file HitWrapper.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.


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