ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sTGCSensitiveDetector Class Reference

#include <sTGCSensitiveDetector.h>

Inheritance diagram for sTGCSensitiveDetector:
Collaboration diagram for sTGCSensitiveDetector:

Public Member Functions

 sTGCSensitiveDetector (const std::string &name, const std::string &hitCollectionName, unsigned baseDepth)
 construction/destruction More...
 
 ~sTGCSensitiveDetector ()=default
 
void Initialize (G4HCofThisEvent *HCE) override final
 member functions More...
 
G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *ROhist) override final
 
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

 FRIEND_TEST (sTGCSensitiveDetectortest, Initialize)
 
 FRIEND_TEST (sTGCSensitiveDetectortest, ProcessHits)
 
void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

SG::WriteHandle< sTGCSimHitCollectionm_sTGCSimHitCollection
 
const sTgcHitIdHelperm_muonHelper {sTgcHitIdHelper::GetHelper()}
 
unsigned m_baseDepth {0}
 basic depth to travel along the G4 history. 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 17 of file sTGCSensitiveDetector.h.

Constructor & Destructor Documentation

◆ sTGCSensitiveDetector()

sTGCSensitiveDetector::sTGCSensitiveDetector ( const std::string &  name,
const std::string &  hitCollectionName,
unsigned  baseDepth 
)

construction/destruction

Definition at line 18 of file sTGCSensitiveDetector.cxx.

20  :
21  G4VSensitiveDetector( name ),
23  m_sTGCSimHitCollection( hitCollectionName ),
24  m_baseDepth{baseDepth} {}

◆ ~sTGCSensitiveDetector()

sTGCSensitiveDetector::~sTGCSensitiveDetector ( )
default

Member Function Documentation

◆ FRIEND_TEST() [1/2]

sTGCSensitiveDetector::FRIEND_TEST ( sTGCSensitiveDetectortest  ,
Initialize   
)
private

◆ FRIEND_TEST() [2/2]

sTGCSensitiveDetector::FRIEND_TEST ( sTGCSensitiveDetectortest  ,
ProcessHits   
)
private

◆ Initialize()

void sTGCSensitiveDetector::Initialize ( G4HCofThisEvent *  HCE)
finaloverride

member functions

Definition at line 27 of file sTGCSensitiveDetector.cxx.

28 {
29  if (!m_sTGCSimHitCollection.isValid()) m_sTGCSimHitCollection = std::make_unique<sTGCSimHitCollection>();
30 }

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

◆ ProcessHits()

G4bool sTGCSensitiveDetector::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROhist 
)
finaloverride

Definition at line 32 of file sTGCSensitiveDetector.cxx.

33 {
34  G4Track* currentTrack = aStep->GetTrack();
35  int charge=currentTrack->GetDefinition()->GetPDGCharge();
36 
37  bool geantinoHit = (currentTrack->GetDefinition()==G4Geantino::GeantinoDefinition()) ||
38  (currentTrack->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition());
39 
40  if (!charge && (!geantinoHit)) return false;
41  // G4cout << "\t\t sTGCSD: Hit in a sensitive layer!!!!! " << G4endl;
42  G4StepPoint* postStep=aStep->GetPostStepPoint();
43  const G4Step* post_Step=aStep->GetTrack()->GetStep();
44 
45  Amg::Vector3D position = Amg::Hep3VectorToEigen(postStep->GetPosition());
46 
47  G4StepPoint* preStep = aStep->GetPreStepPoint();
48  Amg::Vector3D preposition = Amg::Hep3VectorToEigen(preStep->GetPosition());
49 
50  int pdgCode=currentTrack->GetDefinition()->GetPDGEncoding();
51 
52  float globalTime=postStep->GetGlobalTime();
53 
54  Amg::Vector3D direction= Amg::Hep3VectorToEigen( postStep->GetMomentumDirection() );
55  float depositEnergy=post_Step->GetTotalEnergyDeposit();
56 
57  if (depositEnergy<0.0001 && (!geantinoHit)) return false;
58 
59  const G4TouchableHistory* touchHist = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
60 
61  // int iDepth=touchHist->GetHistoryDepth();
62  // G4cout << "\t\t\t\t Touchable history dump "<<G4endl;
63  int nLayer=touchHist->GetVolume(m_baseDepth)->GetCopyNo();
64  std::string chName=touchHist->GetVolume(1+m_baseDepth)->GetLogicalVolume()->GetName();
65  //G4cout << "sTGCSensitiveDetector name: "<<chName<<G4endl;
66  std::string subType=chName.substr(chName.find('-')+1);
67  //G4cout << "\t\t sType: "<<subType);
68  if (subType[0]!='T'&&subType[0]!='Q' ) ATH_MSG_WARNING(" something is wrong, this is no sTGC! "<<chName<<", "<<Amg::toString(preposition));
69  int iRing = std::atoi(&subType[2]) -1;
70  ATH_MSG_VERBOSE("Volume name: "<<chName<<", nLayer: "<<nLayer<<", subType: "<<subType<<", iRing: "<<iRing);
71 
72  // identifiers have eta naming 0-2, eta encoded in subtype is 1-3
73  // double phiDiff=2*M_PI;
74 
75  G4ThreeVector posH=postStep->GetPosition(); //posH is equivalent to position - eigen not used to avoid additional dependence on EventPrimitives
76  if (subType[1]=='L') posH.rotateZ(M_PI/8.);
77  double phiHit=posH.phi();
78  if(phiHit<=0) phiHit+=2.*M_PI;
79  int iPhi=1+int(phiHit/(M_PI/4.));
80  iPhi*=2;
81  if (subType[1]=='L') iPhi-=1;
82 
83  int iSide=1;
84  if (position.z()<0) iSide=-1;
85 
86  int mLayer=0;
87  if (subType[1]=='S')
88  {
89  if (subType[3]=='C') mLayer=1;
90  else if (subType[3]=='P') mLayer=2;
91  }
92  else if (subType[1]=='L')
93  {
94  if (subType[3]=='P') mLayer=1;
95  else if (subType[3]=='C') mLayer=2;
96  }
97 
98  if (mLayer != 1 && mLayer !=2) G4cout << " something is wrong - multilayer index is " << mLayer << G4endl;
99 
100  int sTgcId = m_muonHelper->BuildsTgcHitId(subType, iPhi, iRing, mLayer,nLayer, iSide);
101  TrackHelper trHelp(aStep->GetTrack());
102  m_sTGCSimHitCollection->Emplace(sTgcId,globalTime,position,pdgCode,direction,depositEnergy,
103  trHelp.GenerateParticleLink(),
104  preStep->GetKineticEnergy(),preposition);
105 
106  return true;
107 }

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

unsigned sTGCSensitiveDetector::m_baseDepth {0}
private

basic depth to travel along the G4 history.

For jobs run with the legacy geometry database, it's zero. Otherwise, in the new sqlite workflow it's 1

Definition at line 39 of file sTGCSensitiveDetector.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_muonHelper

const sTgcHitIdHelper* sTGCSensitiveDetector::m_muonHelper {sTgcHitIdHelper::GetHelper()}
private

Definition at line 36 of file sTGCSensitiveDetector.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_sTGCSimHitCollection

SG::WriteHandle<sTGCSimHitCollection> sTGCSensitiveDetector::m_sTGCSimHitCollection
private

Definition at line 35 of file sTGCSensitiveDetector.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
M_PI
#define M_PI
Definition: ActiveFraction.h:11
sTGCSensitiveDetector::m_muonHelper
const sTgcHitIdHelper * m_muonHelper
Definition: sTGCSensitiveDetector.h:36
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
Amg::Hep3VectorToEigen
Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector &CLHEPvector)
Converts a CLHEP-based CLHEP::Hep3Vector into an Eigen-based Amg::Vector3D.
Definition: CLHEPtoEigenConverter.h:137
sTgcHitIdHelper::BuildsTgcHitId
int BuildsTgcHitId(const std::string &, const int, const int, const int, const int, const int) const
Definition: sTgcHitIdHelper.cxx:89
TrackHelper
Definition: TrackHelper.h:14
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
sTGCSensitiveDetector::m_baseDepth
unsigned m_baseDepth
basic depth to travel along the G4 history.
Definition: sTGCSensitiveDetector.h:39
Muon::MuonStationIndex::chName
const std::string & chName(ChIndex index)
convert ChIndex into a string
Definition: MuonStationIndex.cxx:119
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
charge
double charge(const T &p)
Definition: AtlasPID.h:986
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:47
sTGCSensitiveDetector::m_sTGCSimHitCollection
SG::WriteHandle< sTGCSimHitCollection > m_sTGCSimHitCollection
Definition: sTGCSensitiveDetector.h:35
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
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
python.SystemOfUnits.ms
float ms
Definition: SystemOfUnits.py:148