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

#include <ZDC_G4CalibSD.h>

Inheritance diagram for ZDC_G4CalibSD:
Collaboration diagram for ZDC_G4CalibSD:

Public Member Functions

 ZDC_G4CalibSD (const G4String &a_name, const G4String &hitCollectionName, bool doPID=false)
 
virtual ~ZDC_G4CalibSD ()
 
 ZDC_G4CalibSD (const ZDC_G4CalibSD &)=delete
 
ZDC_G4CalibSDoperator= (const ZDC_G4CalibSD &)=delete
 
G4bool ProcessHits (G4Step *a_step, G4TouchableHistory *) override
 
G4bool SpecialHit (G4Step *a_step, const std::vector< G4double > &a_energies)
 
void EndOfAthenaEvent ()
 

Protected Member Functions

G4bool SimpleHit (const Identifier &id, const std::vector< double > &energies)
 

Private Member Functions

 FRIEND_TEST (ZDC_G4CalibSDtest, ProcessHits)
 
 FRIEND_TEST (ZDC_G4CalibSDtest, EndOfAthenaEvent)
 
 FRIEND_TEST (ZDC_G4CalibSDtest, SpecialHit)
 
 FRIEND_TEST (ZDC_G4CalibSDtest, SimpleHit)
 

Private Attributes

SG::WriteHandle< CaloCalibrationHitContainerm_HitColl
 
std::map< uint32_t, CaloCalibrationHit * > m_hitMap
 
std::vector< G4double > m_energies
 
G4int m_numberInvalidHits
 
G4bool m_doPID
 
Identifier m_id
 
CaloG4::SimulationEnergiesm_simulationEnergies
 
ZDC_EscapedEnergyProcessingm_zdc_eep = nullptr
 

Detailed Description

Definition at line 23 of file ZDC_G4CalibSD.h.

Constructor & Destructor Documentation

◆ ZDC_G4CalibSD() [1/2]

ZDC_G4CalibSD::ZDC_G4CalibSD ( const G4String &  a_name,
const G4String &  hitCollectionName,
bool  doPID = false 
)

Definition at line 14 of file ZDC_G4CalibSD.cxx.

15  : G4VSensitiveDetector(a_name), m_HitColl(hitCollectionName), m_numberInvalidHits(0), m_doPID(doPID)
16 {
18 }

◆ ~ZDC_G4CalibSD()

ZDC_G4CalibSD::~ZDC_G4CalibSD ( )
virtual

Definition at line 20 of file ZDC_G4CalibSD.cxx.

21 {
22  if (verboseLevel > 5 && m_numberInvalidHits > 0)
23  {
24  G4cout << "Destructor: Sensitive Detector <" << SensitiveDetectorName << "> had " << m_numberInvalidHits
25  << " G4Step energy deposits outside the region determined by its Calculator." << G4endl;
26  }
27  delete m_simulationEnergies;
28 }

◆ ZDC_G4CalibSD() [2/2]

ZDC_G4CalibSD::ZDC_G4CalibSD ( const ZDC_G4CalibSD )
delete

Member Function Documentation

◆ EndOfAthenaEvent()

void ZDC_G4CalibSD::EndOfAthenaEvent ( )

Definition at line 125 of file ZDC_G4CalibSD.cxx.

126 {
127 
128  //Move the hits from the hit set to the hit container
129  if (!m_HitColl.isValid())
130  m_HitColl = std::make_unique<CaloCalibrationHitContainer>(m_HitColl.name());
131 
132  // Loop through the hits...
133  for (auto hit : m_hitMap)
134  {
135  m_HitColl->push_back(hit.second);
136  } // End of loop over hits
137 
138  // Clean up
139  m_hitMap.clear();
140 }

◆ FRIEND_TEST() [1/4]

ZDC_G4CalibSD::FRIEND_TEST ( ZDC_G4CalibSDtest  ,
EndOfAthenaEvent   
)
private

◆ FRIEND_TEST() [2/4]

ZDC_G4CalibSD::FRIEND_TEST ( ZDC_G4CalibSDtest  ,
ProcessHits   
)
private

◆ FRIEND_TEST() [3/4]

ZDC_G4CalibSD::FRIEND_TEST ( ZDC_G4CalibSDtest  ,
SimpleHit   
)
private

◆ FRIEND_TEST() [4/4]

ZDC_G4CalibSD::FRIEND_TEST ( ZDC_G4CalibSDtest  ,
SpecialHit   
)
private

◆ operator=()

ZDC_G4CalibSD& ZDC_G4CalibSD::operator= ( const ZDC_G4CalibSD )
delete

◆ ProcessHits()

G4bool ZDC_G4CalibSD::ProcessHits ( G4Step *  a_step,
G4TouchableHistory *   
)
override

Definition at line 30 of file ZDC_G4CalibSD.cxx.

31 {
32  // If there's no energy, there's no hit. (Aside: Isn't this energy
33  // the same as the energy from the calculator? Not necessarily.
34  // The calculator may include detector effects such as
35  // charge-collection which are not modeled by Geant4.)
36  if (a_step->GetTotalEnergyDeposit() == 0.)
37  return false;
38 
39  // Convert the G4Step into (eta,phi,sampling).
40  // Check that hit was valid. (It might be invalid if, for example,
41  // it occurred outside the sensitive region. If such a thing
42  // happens, it means that the geometry definitions in the
43  // detector-construction routine and the calculator do not agree.)
44 
45  m_energies.clear();
46  // classify different types of deposits (0: EM, 1: Non-EM, 2: Invisible, 3: Escaped)
47 
49 
50  // identifier needed to specify particular volme we're in. Used in HitCollection to make sure we don't have double hits
51  Identifier id;
52  id = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo();
53 
54  // build calibHit. check if we've had a hit in this cell already. if we havent add it to the set of cells. If we have add energies to existing energies. ie can't distinguish b/w different hits in single cell so must integrate all this information
55  return SimpleHit (id, m_energies );
56 }

◆ SimpleHit()

G4bool ZDC_G4CalibSD::SimpleHit ( const Identifier id,
const std::vector< double > &  energies 
)
protected

Definition at line 59 of file ZDC_G4CalibSD.cxx.

60 {
61 
62  // retreive particle ID
63  int particleID = HepMC::UNDEFINED_ID;
64  int particleUID = HepMC::UNDEFINED_ID;
65  if( m_doPID ) {
66  AtlasG4EventUserInfo * atlasG4EvtUserInfo = dynamic_cast<AtlasG4EventUserInfo*>(G4RunManager::GetRunManager()->GetCurrentEvent()->GetUserInformation());
67  if (atlasG4EvtUserInfo) {
68  particleID = HepMC::barcode(atlasG4EvtUserInfo->GetCurrentPrimaryGenParticle()); // FIXME Barcode-based
69  particleUID = HepMC::uniqueID(atlasG4EvtUserInfo->GetCurrentPrimaryGenParticle());
70  }
71  }
72 
73 
74  // Reject cases where invisible energy calculation produced values
75  // of order 10e-12 instead of 0 due to rounding errors in that
76  // calculation, or general cases where the energy deposits are
77  // trivially small.
78  if (energies[0] + energies[1] + energies[3] < 0.001 * CLHEP::eV && std::abs(energies[2]) < 0.001 * CLHEP::eV)
79  {
80  return true;
81  }
82 
83  // Build the hit.
85  energies[0],
86  energies[1],
87  energies[2],
88  energies[3],
89  particleID,
90  particleUID);
91 
92  //Get the hash for this volume to keep track of hits
93  uint32_t hash = id.get_identifier32().get_compact();
94 
96 
97  if(it == m_hitMap.end()){
98  //This is a new hit, insert it
99  m_hitMap.insert(std::pair<uint32_t,CaloCalibrationHit*>(hash,hit));
100  }else{
101  //Add this hit to the existing one for this volume
102  it->second->Add(hit);
103  delete hit;
104  }
105 
106  return true;
107 }

◆ SpecialHit()

G4bool ZDC_G4CalibSD::SpecialHit ( G4Step *  a_step,
const std::vector< G4double > &  a_energies 
)

Definition at line 115 of file ZDC_G4CalibSD.cxx.

117 {
118  // If we can't get the identifier, something is wrong.
119  Identifier id;
120  id = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo();
121 
122  return SimpleHit(id, a_energies);
123 }

Member Data Documentation

◆ m_doPID

G4bool ZDC_G4CalibSD::m_doPID
private

Definition at line 60 of file ZDC_G4CalibSD.h.

◆ m_energies

std::vector<G4double> ZDC_G4CalibSD::m_energies
private

Definition at line 55 of file ZDC_G4CalibSD.h.

◆ m_HitColl

SG::WriteHandle<CaloCalibrationHitContainer> ZDC_G4CalibSD::m_HitColl
private

Definition at line 53 of file ZDC_G4CalibSD.h.

◆ m_hitMap

std::map< uint32_t, CaloCalibrationHit* > ZDC_G4CalibSD::m_hitMap
private

Definition at line 54 of file ZDC_G4CalibSD.h.

◆ m_id

Identifier ZDC_G4CalibSD::m_id
private

Definition at line 61 of file ZDC_G4CalibSD.h.

◆ m_numberInvalidHits

G4int ZDC_G4CalibSD::m_numberInvalidHits
private

Definition at line 58 of file ZDC_G4CalibSD.h.

◆ m_simulationEnergies

CaloG4::SimulationEnergies* ZDC_G4CalibSD::m_simulationEnergies
private

Definition at line 62 of file ZDC_G4CalibSD.h.

◆ m_zdc_eep

ZDC_EscapedEnergyProcessing* ZDC_G4CalibSD::m_zdc_eep = nullptr
private

Definition at line 63 of file ZDC_G4CalibSD.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
CaloG4::SimulationEnergies::Energies
void Energies(const G4Step *, std::vector< G4double > &) const
The simple method to call from a calibration calculator: Examine the G4Step and return the energies r...
AtlasG4EventUserInfo
This class is attached to G4Event objects as UserInformation. It holds a pointer to the HepMC::GenEve...
Definition: AtlasG4EventUserInfo.h:21
ZDC_G4CalibSD::SimpleHit
G4bool SimpleHit(const Identifier &id, const std::vector< double > &energies)
Definition: ZDC_G4CalibSD.cxx:59
ZDC_G4CalibSD::m_HitColl
SG::WriteHandle< CaloCalibrationHitContainer > m_HitColl
Definition: ZDC_G4CalibSD.h:53
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
CaloG4::SimulationEnergies
Definition: SimulationEnergies.h:47
skel.it
it
Definition: skel.GENtoEVGEN.py:396
ZDC_G4CalibSD::m_numberInvalidHits
G4int m_numberInvalidHits
Definition: ZDC_G4CalibSD.h:58
ZDC_G4CalibSD::m_hitMap
std::map< uint32_t, CaloCalibrationHit * > m_hitMap
Definition: ZDC_G4CalibSD.h:54
AthenaHitsVector::push_back
void push_back(T *t)
Definition: AthenaHitsVector.h:153
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
HepMC::uniqueID
int uniqueID(const T &p)
Definition: MagicNumbers.h:109
HepMC::UNDEFINED_ID
constexpr int UNDEFINED_ID
Definition: MagicNumbers.h:55
ZDC_G4CalibSD::m_simulationEnergies
CaloG4::SimulationEnergies * m_simulationEnergies
Definition: ZDC_G4CalibSD.h:62
CaloCalibrationHit
Class to store calorimeter calibration hit.
Definition: CaloCalibrationHit.h:23
ZDC_G4CalibSD::m_doPID
G4bool m_doPID
Definition: ZDC_G4CalibSD.h:60
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
python.SystemOfUnits.eV
int eV
Definition: SystemOfUnits.py:155
AtlasG4EventUserInfo::GetCurrentPrimaryGenParticle
HepMC::ConstGenParticlePtr GetCurrentPrimaryGenParticle() const
return a pointer to the HepMC::GenParticle used to create the current G4PrimaryParticle.
Definition: AtlasG4EventUserInfo.h:44
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
ZDC_G4CalibSD::m_energies
std::vector< G4double > m_energies
Definition: ZDC_G4CalibSD.h:55
Identifier
Definition: IdentifierFieldParser.cxx:14