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

#include <G4HitFilter.h>

Inheritance diagram for G4UA::G4HitFilter:
Collaboration diagram for G4UA::G4HitFilter:

Classes

struct  Config
 
struct  Report
 

Public Member Functions

 G4HitFilter (const Config &config)
 Constructor. More...
 
const ReportgetReport () const
 
virtual void EndOfEventAction (const G4Event *) override
 
virtual void BeginOfRunAction (const G4Run *) 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

enum  hitCntainerTypes {
  CALOCALIB, CSC, LAR, LUCID,
  MDT, RPC, SI, TGC,
  TILE, TRT
}
 

Private Member Functions

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

Private Attributes

Config m_config
 
Report m_report
 
std::vector< std::pair< int, std::string > > m_hitContainers
 A list of (hitContainerTypes, volumeName) pairs, filled in BeginOfRunAction. More...
 
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 22 of file G4HitFilter.h.

Member Enumeration Documentation

◆ hitCntainerTypes

Enumerator
CALOCALIB 
CSC 
LAR 
LUCID 
MDT 
RPC 
SI 
TGC 
TILE 
TRT 

Definition at line 54 of file G4HitFilter.h.

54  {
55  CALOCALIB,
56  CSC,
57  LAR,
58  LUCID,
59  MDT,
60  RPC,
61  SI,
62  TGC,
63  TILE,
64  TRT };

Constructor & Destructor Documentation

◆ G4HitFilter()

G4UA::G4HitFilter::G4HitFilter ( const Config config)

Constructor.

Definition at line 32 of file G4HitFilter.cxx.

33  : AthMessaging(Gaudi::svcLocator()->service< IMessageSvc >( "MessageSvc" ),
34  "G4HitFilter"),
36  {}

Member Function Documentation

◆ BeginOfRunAction()

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

Definition at line 39 of file G4HitFilter.cxx.

40  {
41  if(m_config.volumenames.size()==0){
42  ATH_MSG_ERROR("No hit containers declared");
43  }
44 
45  int hitType = 999;
46 
47  for(const auto& vol: m_config.volumenames){
48  if(vol == "BCMHits") hitType = SI;
49  else if(vol == "BLMHits") hitType = SI;
50  else if(vol == "CSC_Hits") hitType = CSC;
51  else if(vol == "LArCalibrationHitActive") hitType = CALOCALIB;
52  else if(vol == "LArCalibrationHitDeadMaterial") hitType = CALOCALIB;
53  else if(vol == "LArCalibrationHitInactive") hitType = CALOCALIB;
54  else if(vol == "LArHitEMB") hitType = LAR;
55  else if(vol == "LArHitEMEC") hitType = LAR;
56  else if(vol == "LArHitFCAL") hitType = LAR;
57  else if(vol == "LArHitHEC") hitType = LAR;
58  else if(vol == "LucidSimHitsVector") hitType = LUCID;
59  else if(vol == "MBTSHits") hitType = TILE;
60  else if(vol == "MDT_Hits") hitType = MDT;
61  else if(vol == "PixelHits") hitType = SI;
62  else if(vol == "RPC_Hits") hitType = RPC;
63  else if(vol == "SCT_Hits") hitType = SI;
64  else if(vol == "TGC_Hits") hitType = TGC;
65  else if(vol == "TRTUncompressedHits") hitType = TRT;
66  else if(vol == "TileHitVec") hitType = TILE;
67 
68  if(hitType == 999){
69  ATH_MSG_ERROR("unknown hit tipe" << vol);
70  }
71 
72  m_hitContainers.push_back( std::make_pair(hitType,vol) );
73  }
74  }

◆ EndOfEventAction()

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

Definition at line 77 of file G4HitFilter.cxx.

78  {
79  unsigned int counter = 0;
80 
81  m_report.ntot++;
82 
83  for(const auto& hitCont : m_hitContainers) {
84 
85  if(hitCont.first == CALOCALIB) {
87  if(! cont.isValid()) continue;
88  counter += cont->size();
89  }
90  else if(hitCont.first == CSC) {
91  SG::ReadHandle<CSCSimHitCollection> cont(hitCont.second);
92  if(! cont.isValid()) continue;
93  counter += cont->size();
94  }
95  else if(hitCont.first == LAR) {
96  SG::ReadHandle<LArHitContainer> cont(hitCont.second);
97  if(! cont.isValid()) continue;
98  counter += cont->size();
99  }
100  else if(hitCont.first == LUCID) {
101  SG::ReadHandle<LUCID_SimHitCollection> cont(hitCont.second);
102  if(! cont.isValid()) continue;
103  counter += cont->size();
104  }
105  else if(hitCont.first == MDT) {
106  SG::ReadHandle<MDTSimHitCollection> cont(hitCont.second);
107  if(! cont.isValid()) continue;
108  counter += cont->size();
109  }
110  else if(hitCont.first == RPC) {
111  SG::ReadHandle<RPCSimHitCollection> cont(hitCont.second);
112  if(! cont.isValid()) continue;
113  counter += cont->size();
114  }
115  else if(hitCont.first == SI) {
116  SG::ReadHandle<SiHitCollection> cont(hitCont.second);
117  if(! cont.isValid()) continue;
118  counter += cont->size();
119  }
120  else if(hitCont.first == TGC) {
121  SG::ReadHandle<TGCSimHitCollection> cont(hitCont.second);
122  if(! cont.isValid()) continue;
123  counter += cont->size();
124  }
125  else if(hitCont.first == TILE) {
126  SG::ReadHandle<TileHitVector> cont(hitCont.second);
127  if(! cont.isValid()) continue;
128  counter += cont->size();
129  }
130  else if(hitCont.first == TRT) {
132  if(! cont.isValid()) continue;
133  counter += cont->size();
134  }
135  else {
136  continue;
137  }
138 
139  // Require at least one hit from one selected detector volume.
140  if(counter>0) break;
141  }
142 
143  if (counter==0){
144  ATH_MSG_INFO("G4HitFilter: failing the event");
145  G4RunManager::GetRunManager()->AbortEvent();
146  }
147  else {
148  ATH_MSG_INFO("G4HitFilter: passing the event");
149  m_report.npass++;
150  }
151  }

◆ getReport()

const Report& G4UA::G4HitFilter::getReport ( ) const
inline

Definition at line 46 of file G4HitFilter.h.

47  { return m_report; }

◆ 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::G4HitFilter::m_config
private

Definition at line 66 of file G4HitFilter.h.

◆ m_hitContainers

std::vector< std::pair<int,std::string> > G4UA::G4HitFilter::m_hitContainers
private

A list of (hitContainerTypes, volumeName) pairs, filled in BeginOfRunAction.

Definition at line 71 of file G4HitFilter.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_report

Report G4UA::G4HitFilter::m_report
private

Definition at line 67 of file G4HitFilter.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
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
G4UA::G4HitFilter::Report::npass
int npass
Definition: G4HitFilter.h:39
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
G4UA::G4HitFilter::m_config
Config m_config
Definition: G4HitFilter.h:66
G4UA::G4HitFilter::MDT
@ MDT
Definition: G4HitFilter.h:59
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
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
G4UA::G4HitFilter::LAR
@ LAR
Definition: G4HitFilter.h:57
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
G4UA::G4HitFilter::TILE
@ TILE
Definition: G4HitFilter.h:63
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TRT
Definition: HitInfo.h:33
TGC
Definition: TgcBase.h:6
G4UA::G4HitFilter::SI
@ SI
Definition: G4HitFilter.h:61
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
G4UA::G4HitFilter::RPC
@ RPC
Definition: G4HitFilter.h:60
G4UA::G4HitFilter::TGC
@ TGC
Definition: G4HitFilter.h:62
G4UA::G4HitFilter::CALOCALIB
@ CALOCALIB
Definition: G4HitFilter.h:55
G4UA::G4HitFilter::CSC
@ CSC
Definition: G4HitFilter.h:56
G4UA::G4HitFilter::m_report
Report m_report
Definition: G4HitFilter.h:67
G4UA::G4HitFilter::Report::ntot
int ntot
Definition: G4HitFilter.h:38
G4UA::G4HitFilter::Config::volumenames
std::vector< std::string > volumenames
Definition: G4HitFilter.h:30
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
G4UA::G4HitFilter::TRT
@ TRT
Definition: G4HitFilter.h:64
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
test_pyathena.counter
counter
Definition: test_pyathena.py:15
G4UA::G4HitFilter::m_hitContainers
std::vector< std::pair< int, std::string > > m_hitContainers
A list of (hitContainerTypes, volumeName) pairs, filled in BeginOfRunAction.
Definition: G4HitFilter.h:71
G4UA::G4HitFilter::LUCID
@ LUCID
Definition: G4HitFilter.h:58