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

Private Member Functions

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

Private Attributes

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

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"),
36  {}

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 
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");
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  }

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

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.

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


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
AtlasHitsVector::iterator
CONT::iterator iterator
Definition: AtlasHitsVector.h:42
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
G4UA::HitWrapper::m_config
Config m_config
Definition: HitWrapper.h:38
G4UA::HitWrapper::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: HitWrapper.h:34
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
G4UA::HitWrapper::Config::time
float time
Definition: HitWrapper.h:24
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
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
G4UA::HitWrapper::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: HitWrapper.h:36
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
pix
Definition: PixelMapping.cxx:16
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