ATLAS Offline Software
Loading...
Searching...
No Matches
MinBiasScintillatorSDTool Class Reference

#include <MinBiasScintillatorSDTool.h>

Inheritance diagram for MinBiasScintillatorSDTool:
Collaboration diagram for MinBiasScintillatorSDTool:

Public Member Functions

 MinBiasScintillatorSDTool (const std::string &type, const std::string &name, const IInterface *parent)
 ~MinBiasScintillatorSDTool ()=default
virtual StatusCode initialize () override
virtual StatusCode SetupEvent (HitCollectionMap &) override final
 Beginning of an athena event.
virtual StatusCode Gather (HitCollectionMap &) override final
 End of an athena event.
StatusCode initializeSD () override
 Setup an SD in the current thread.

Protected Member Functions

virtual G4VSensitiveDetector * makeSD () const override final
StatusCode assignSD (std::unique_ptr< G4VSensitiveDetector > sd, const std::vector< std::string > &volumes) const
 Assign SD to a list of volumes.
void SetSensitiveDetector (G4LogicalVolume *, G4VSensitiveDetector *) const
 Method stolen from G4VUserDetectorConstruction in G4 10.2.

Protected Attributes

Gaudi::Property< std::vector< std::string > > m_volumeNames {this, "LogicalVolumeNames", {}}
 All the volumes to which this SD is assigned.
Gaudi::Property< std::vector< std::string > > m_outputCollectionNames {this, "OutputCollectionNames", {}}
 Names of all output collections written out by this SD.
Gaudi::Property< bool > m_noVolumes {this, "NoVolumes", false}
 This SensitiveDetector has no volumes associated with it.

Static Private Member Functions

static bool matchStrings (const char *first, const char *second)
 Match two strings with wildcard support.

Private Attributes

MinBiasScintSDOptions m_options
Gaudi::Property< std::vector< double > > m_deltaTHit {this, "DeltaTHit", {0.5 , -75.25 , 75.25 , 5.}}
Gaudi::Property< double > m_timeCut {this, "TimeCut", 350.5}
Gaudi::Property< bool > m_tileTB {this, "TileTB", false}
Gaudi::Property< bool > m_doBirk {this, "DoBirk", true}
Gaudi::Property< double > m_birk1 {this, "Birk1", 0.0130 * CLHEP::g / (CLHEP::MeV * CLHEP::cm2)}
Gaudi::Property< double > m_birk2 {this, "Birk2", 9.6e-6 * CLHEP::g / (CLHEP::MeV * CLHEP::cm2) * CLHEP::g / (CLHEP::MeV * CLHEP::cm2)}
Gaudi::Property< bool > m_doTOFCorrection {this, "DoTOFCorrection", true}

Detailed Description

Definition at line 20 of file MinBiasScintillatorSDTool.h.

Constructor & Destructor Documentation

◆ MinBiasScintillatorSDTool()

MinBiasScintillatorSDTool::MinBiasScintillatorSDTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

◆ ~MinBiasScintillatorSDTool()

MinBiasScintillatorSDTool::~MinBiasScintillatorSDTool ( )
default

Member Function Documentation

◆ assignSD()

StatusCode SensitiveDetectorBase::assignSD ( std::unique_ptr< G4VSensitiveDetector > sd,
const std::vector< std::string > & volumes ) const
protectedinherited

Assign SD to a list of volumes.

This method supports wild card matching

Definition at line 55 of file SensitiveDetectorBase.cxx.

57{
58 // Propagate verbosity setting to the SD
59 if(msgLvl(MSG::VERBOSE)) sd->SetVerboseLevel(10);
60 else if(msgLvl(MSG::DEBUG)) sd->SetVerboseLevel(5);
61
62 // Add the sensitive detector to the SD manager in G4 for SDs,
63 // even if it has no volumes associated to it.
64 auto sdMgr = G4SDManager::GetSDMpointer();
65 auto sdPtr = sd.get();
66 // SDManager is now the SD owner
67 //for later use
68 auto sdName = sd->GetName();
69 sdMgr->AddNewDetector(sd.release());
70
71 if(!volumes.empty()) {
72 bool gotOne = false;
73 auto logicalVolumeStore = G4LogicalVolumeStore::GetInstance();
74 for(const auto& volumeName : volumes) {
75 // Keep track of how many volumes we find with this name string.
76 // We allow for multiple matches.
77 int numFound = 0;
78
79 // Find volumes with this name
80 for(auto* logVol : *logicalVolumeStore) {
81
82 ATH_MSG_VERBOSE("Check whether "<<logVol->GetName()<<" belongs to the set of sensitive detectors "<<volumeName);
83 if( matchStrings( volumeName.data(), logVol->GetName() ) ){
84 ++numFound;
85 SetSensitiveDetector(logVol, sdPtr);
86 }
87
88 }
89 // Warn if no volumes were found
90 if(numFound == 0) {
91 ATH_MSG_WARNING("Volume " << volumeName <<
92 " not found in G4LogicalVolumeStore.");
93 }
94 else {
95 ATH_MSG_VERBOSE("Found " << numFound << " copies of LV " << volumeName <<
96 "; SD " << sdName << " assigned.");
97 gotOne = true;
98 }
99
100 }
101
102 // Abort if we have failed to assign any volume
103 if(!gotOne) {
104 ATH_MSG_ERROR( "Failed to assign *any* volume to SD " << name() <<
105 " and expected at least one. Size of the volume store "<<G4LogicalVolumeStore::GetInstance()->size() );
106 return StatusCode::FAILURE;
107 }
108 }
109
110 return StatusCode::SUCCESS;
111}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
size_t size() const
Number of registered mappings.
static bool matchStrings(const char *first, const char *second)
Match two strings with wildcard support.
void SetSensitiveDetector(G4LogicalVolume *, G4VSensitiveDetector *) const
Method stolen from G4VUserDetectorConstruction in G4 10.2.

◆ Gather()

virtual StatusCode MinBiasScintillatorSDTool::Gather ( HitCollectionMap & )
finaloverridevirtual

End of an athena event.

Store the output collection in SG at this point. If we are using a WriteHandle, then this can be empty!

Reimplemented from SensitiveDetectorBase.

◆ initialize()

virtual StatusCode MinBiasScintillatorSDTool::initialize ( )
overridevirtual

◆ initializeSD()

StatusCode SensitiveDetectorBase::initializeSD ( )
overrideinherited

Setup an SD in the current thread.

Separate from the AthAlgTool initialize() method because it needs to be called once per worker thread in AthenaMT. Don't confuse this with the G4 SD method Initialize which is called at the beginning of every G4 event.

Definition at line 25 of file SensitiveDetectorBase.cxx.

26{
27 ATH_MSG_VERBOSE( name() << "::initializeSD()" );
28
29 // Sanity check for volume configuration problems.
30 // It would be better to have a more robust solution for this.
31 if(m_volumeNames.empty() != m_noVolumes) {
32 ATH_MSG_ERROR("Initializing SD from " << name() << ", NoVolumes = "
33 << (m_noVolumes? "true" : "false") << ", but LogicalVolumeNames = "
34 << m_volumeNames.value());
35 return StatusCode::FAILURE;
36 }
37
38 // Make the SD stored by this tool
39 auto sd = std::unique_ptr<G4VSensitiveDetector>(makeSD());
40 if(!sd)
41 {
42 ATH_MSG_ERROR("Failed to create SD!");
43 return StatusCode::FAILURE;
44 }
45 // Assign the SD to our list of volumes
46 ATH_CHECK( assignSD( std::move(sd), m_volumeNames.value() ) );
47
48 ATH_MSG_DEBUG( "Initialized and added SD " << name() );
49 return StatusCode::SUCCESS;
50}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
StatusCode assignSD(std::unique_ptr< G4VSensitiveDetector > sd, const std::vector< std::string > &volumes) const
Assign SD to a list of volumes.
Gaudi::Property< std::vector< std::string > > m_volumeNames
All the volumes to which this SD is assigned.
Gaudi::Property< bool > m_noVolumes
This SensitiveDetector has no volumes associated with it.

◆ makeSD()

virtual G4VSensitiveDetector * MinBiasScintillatorSDTool::makeSD ( ) const
finaloverrideprotectedvirtual

◆ matchStrings()

bool SensitiveDetectorBase::matchStrings ( const char * first,
const char * second )
staticprivateinherited

Match two strings with wildcard support.

Compares two strings character by character with optional * wildcard in the first argument

Definition at line 115 of file SensitiveDetectorBase.cxx.

116{
117 // If we reach at the end of both strings, we are done
118 if (*first == '\0' && *second == '\0')
119 return true;
120
121 // If there are consecutive '*' present in the first string
122 // advance to the next character
123 if(*first == '*' && *(first + 1) == '*')
124 return matchStrings(first + 1, second);
125
126 // Make sure that the characters after '*' are present in second string.
127 if (*first == '*' && *(first + 1) != '\0' && *second == '\0')
128 return false;
129
130 // If the current characters of both strings match
131 if (*first == *second)
132 return matchStrings(first + 1, second + 1);
133
134 // If there is *, then there are two possibilities
135 // a) We consider current character of second string
136 // b) We ignore current character of second string.
137 if (*first == '*')
138 return matchStrings(first + 1, second) || matchStrings(first, second + 1);
139 return false;
140}

◆ SetSensitiveDetector()

void SensitiveDetectorBase::SetSensitiveDetector ( G4LogicalVolume * logVol,
G4VSensitiveDetector * aSD ) const
protectedinherited

Method stolen from G4VUserDetectorConstruction in G4 10.2.

Definition at line 142 of file SensitiveDetectorBase.cxx.

144{
145 // New Logic: allow for "multiple" SDs being attached to a single LV.
146 // To do that we use a special proxy SD called G4MultiSensitiveDetector
147
148 // Get existing SD if already set and check if it is of the special type
149 G4VSensitiveDetector* originalSD = logVol->GetSensitiveDetector();
150 if ( originalSD == nullptr )
151 {
152 logVol->SetSensitiveDetector(aSD);
153 }
154 else
155 {
156 G4MultiSensitiveDetector* msd = dynamic_cast<G4MultiSensitiveDetector*>(originalSD);
157 if ( msd != nullptr )
158 {
159 msd->AddSD(aSD);
160 }
161 else
162 {
163 // Construct a unique name using the volume address
164 std::stringstream ss;
166 const G4String msdname = "/MultiSD_" + logVol->GetName() + ss.str();
167 msd = new G4MultiSensitiveDetector(std::move(msdname));
168 // We need to register the proxy to have correct handling of IDs
169 G4SDManager::GetSDMpointer()->AddNewDetector(msd);
170 msd->AddSD(originalSD);
171 msd->AddSD(aSD);
172 logVol->SetSensitiveDetector(msd);
173 }
174 }
175}
static Double_t ss

◆ SetupEvent()

virtual StatusCode MinBiasScintillatorSDTool::SetupEvent ( HitCollectionMap & )
finaloverridevirtual

Beginning of an athena event.

This is where collection initialization should happen. If we are using a WriteHandle, then this could be empty.

Reimplemented from SensitiveDetectorBase.

Member Data Documentation

◆ m_birk1

Gaudi::Property<double> MinBiasScintillatorSDTool::m_birk1 {this, "Birk1", 0.0130 * CLHEP::g / (CLHEP::MeV * CLHEP::cm2)}
private

Definition at line 41 of file MinBiasScintillatorSDTool.h.

41{this, "Birk1", 0.0130 * CLHEP::g / (CLHEP::MeV * CLHEP::cm2)};

◆ m_birk2

Gaudi::Property<double> MinBiasScintillatorSDTool::m_birk2 {this, "Birk2", 9.6e-6 * CLHEP::g / (CLHEP::MeV * CLHEP::cm2) * CLHEP::g / (CLHEP::MeV * CLHEP::cm2)}
private

Definition at line 42 of file MinBiasScintillatorSDTool.h.

42{this, "Birk2", 9.6e-6 * CLHEP::g / (CLHEP::MeV * CLHEP::cm2) * CLHEP::g / (CLHEP::MeV * CLHEP::cm2)};

◆ m_deltaTHit

Gaudi::Property<std::vector<double> > MinBiasScintillatorSDTool::m_deltaTHit {this, "DeltaTHit", {0.5 , -75.25 , 75.25 , 5.}}
private

Definition at line 37 of file MinBiasScintillatorSDTool.h.

37{this, "DeltaTHit", {0.5 , -75.25 , 75.25 , 5.}};

◆ m_doBirk

Gaudi::Property<bool> MinBiasScintillatorSDTool::m_doBirk {this, "DoBirk", true}
private

Definition at line 40 of file MinBiasScintillatorSDTool.h.

40{this, "DoBirk", true};

◆ m_doTOFCorrection

Gaudi::Property<bool> MinBiasScintillatorSDTool::m_doTOFCorrection {this, "DoTOFCorrection", true}
private

Definition at line 43 of file MinBiasScintillatorSDTool.h.

43{this, "DoTOFCorrection", true};

◆ m_noVolumes

Gaudi::Property<bool> SensitiveDetectorBase::m_noVolumes {this, "NoVolumes", false}
protectedinherited

This SensitiveDetector has no volumes associated with it.

Definition at line 83 of file SensitiveDetectorBase.h.

83{this, "NoVolumes", false};

◆ m_options

MinBiasScintSDOptions MinBiasScintillatorSDTool::m_options
private

Definition at line 35 of file MinBiasScintillatorSDTool.h.

◆ m_outputCollectionNames

Gaudi::Property<std::vector<std::string> > SensitiveDetectorBase::m_outputCollectionNames {this, "OutputCollectionNames", {}}
protectedinherited

Names of all output collections written out by this SD.

Definition at line 80 of file SensitiveDetectorBase.h.

80{this, "OutputCollectionNames", {}};

◆ m_tileTB

Gaudi::Property<bool> MinBiasScintillatorSDTool::m_tileTB {this, "TileTB", false}
private

Definition at line 39 of file MinBiasScintillatorSDTool.h.

39{this, "TileTB", false};

◆ m_timeCut

Gaudi::Property<double> MinBiasScintillatorSDTool::m_timeCut {this, "TimeCut", 350.5}
private

Definition at line 38 of file MinBiasScintillatorSDTool.h.

38{this, "TimeCut", 350.5};

◆ m_volumeNames

Gaudi::Property<std::vector<std::string> > SensitiveDetectorBase::m_volumeNames {this, "LogicalVolumeNames", {}}
protectedinherited

All the volumes to which this SD is assigned.

Definition at line 78 of file SensitiveDetectorBase.h.

78{this, "LogicalVolumeNames", {}};

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