The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
PartPropSvc Class Reference

#include </builds/gaudi/Gaudi/PartPropSvc/src/PartPropSvc.h>

Inheritance diagram for PartPropSvc:
Collaboration diagram for PartPropSvc:

Public Member Functions

StatusCode initialize () override
 
StatusCode finalize () override
 
HepPDT::ParticleDataTable * PDT () override
 
void setUnknownParticleHandler (HepPDT::ProcessUnknownID *, const std::string &) override
 
- Public Member Functions inherited from extends< Service, IPartPropSvc >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from Service
const std::string & name () const override
 Retrieve name of the service.
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service.
 
StatusCode sysStart () override
 Initialize Service.
 
StatusCode sysStop () override
 Initialize Service.
 
StatusCode sysFinalize () override
 Finalize Service.
 
StatusCode sysReinitialize () override
 Re-initialize the Service.
 
StatusCode sysRestart () override
 Re-initialize the Service.
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator.
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool.
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T>
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Public Attributes

 InputFile
 

Private Types

using inputFunPtr = bool ( * )( std::istream&, HepPDT::TableBuilder& )
 

Private Member Functions

StatusCode createTable ()
 
inputFunPtr parseTableType (const std::string &)
 

Private Attributes

std::vector< std::pair< std::string, inputFunPtr > > m_inputs
 
Gaudi::Property< std::string > m_pdtFiles { this, "InputFile", "PDGTABLE.MeV" }
 
HepPDT::ProcessUnknownID * m_upid = nullptr
 
std::string m_upid_name
 
std::optional< HepPDT::ParticleDataTable > m_pdt
 
bool m_upid_local = false
 

Additional Inherited Members

- Public Types inherited from extends< Service, IPartPropSvc >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory<IService*( const std::string&, ISvcLocator* )>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 
- Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 
int outputLevel () const
 get the Service's output level
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools
 
Gaudi::Property< bool > m_auditorInitialize { this, "AuditInitialize", false, "trigger auditor on initialize()" }
 
Gaudi::Property< bool > m_auditorStart { this, "AuditStart", false, "trigger auditor on start()" }
 
Gaudi::Property< bool > m_auditorStop { this, "AuditStop", false, "trigger auditor on stop()" }
 
Gaudi::Property< bool > m_auditorFinalize { this, "AuditFinalize", false, "trigger auditor on finalize()" }
 
Gaudi::Property< bool > m_auditorReinitialize { this, "AuditReinitialize", false, "trigger auditor on reinitialize()" }
 
Gaudi::Property< bool > m_auditorRestart { this, "AuditRestart", false, "trigger auditor on restart()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service.
 

Detailed Description

Definition at line 37 of file PartPropSvc.h.

Member Typedef Documentation

◆ inputFunPtr

using PartPropSvc::inputFunPtr = bool ( * )( std::istream&, HepPDT::TableBuilder& )
private

Definition at line 50 of file PartPropSvc.h.

Member Function Documentation

◆ createTable()

StatusCode PartPropSvc::createTable ( )
private

Definition at line 129 of file PartPropSvc.cpp.

129 {
130
131 // use a handler for unknown heavy ions
132 if ( !m_upid ) {
133 setUnknownParticleHandler( new HepPDT::HeavyIonUnknownID, "Default Heavy Ion Handler" );
134 m_upid_local = true;
135 }
136
137 m_pdt.emplace( m_upid_name, m_upid );
138
139 HepPDT::TableBuilder tb( *m_pdt );
140
141 for ( const auto& itr : m_inputs ) {
142 const auto& f = itr.first;
143 const auto& pF = itr.second;
144
145 debug() << "Reading PDT file \"" << f << "\"" << endmsg;
146
147 std::ifstream pdfile{ f };
148 // build a table from the file
149 if ( !pF( pdfile, tb ) ) {
150 error() << "Error reading PDT file: \"" << f << "\"" << endmsg;
151 return StatusCode::FAILURE;
152 }
153 }
154
155 return StatusCode::SUCCESS;
156}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
HepPDT::ProcessUnknownID * m_upid
Definition PartPropSvc.h:57
bool m_upid_local
Definition PartPropSvc.h:64
void setUnknownParticleHandler(HepPDT::ProcessUnknownID *, const std::string &) override
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ finalize()

StatusCode PartPropSvc::finalize ( )
override

Definition at line 92 of file PartPropSvc.cpp.

92 {
93
94 m_pdt.reset();
95
96 if ( m_upid_local && m_upid ) {
97 m_upid_local = false;
98 // This will cause a memory leak, but we can't delete it as the
99 // destructor of HepPDT::processUnknownID is protected.
100 // We need this though to call reinitialize successfully.
101 m_upid = nullptr;
102 }
103
104 StatusCode status = Service::finalize();
105
106 if ( status.isSuccess() ) { debug() << "Service finalised successfully" << endmsg; }
107
108 return status;
109}
std::optional< HepPDT::ParticleDataTable > m_pdt
Definition PartPropSvc.h:60
StatusCode finalize() override
Definition Service.cpp:223
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isSuccess() const
Definition StatusCode.h:314

◆ initialize()

StatusCode PartPropSvc::initialize ( )
override

Definition at line 26 of file PartPropSvc.cpp.

26 {
27
29
30 if ( status.isFailure() ) {
31 error() << "Could not initialize main svc" << endmsg;
33 }
34
35 std::string key = m_pdtFiles.value();
36
37 typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
38 boost::char_separator<char> sep( ", " );
39 boost::char_separator<char> sep_eq( "=" );
40
41 tokenizer tokens( key, sep );
42 for ( auto it = tokens.begin(); it != tokens.end(); ++it ) {
43
44 tokenizer tok2( *it, sep_eq );
45 int nToks( std::distance( tok2.begin(), tok2.end() ) );
46
47 auto it2 = tok2.begin();
48 const std::string fname = *it2;
49 std::string fmt;
50 if ( nToks == 1 ) {
51 info() << "No table format type specified for \"" << fname << "\". Assuming PDG" << endmsg;
52 fmt = "PDG";
53 } else {
54 ++it2;
55 fmt = *it2;
56 }
57
58 // see if input file exists in $DATAPATH
59 std::string rfile = System::PathResolver::find_file( fname, "DATAPATH" );
60 if ( rfile.empty() ) {
61 error() << "Could not find PDT file: \"" << fname << "\" in $DATAPATH" << endmsg;
63 }
64
65 // is the file readable?
66 std::ifstream pdfile{ rfile };
67 if ( !pdfile ) {
68 error() << "Could not open PDT file: \"" << rfile << "\"" << endmsg;
70 }
71
72 std::string FMT = boost::algorithm::to_upper_copy( fmt );
73
74 inputFunPtr pF = nullptr;
75 try {
76 pF = parseTableType( FMT );
77 } catch ( ... ) {
78 error() << "Could not determine Particle Property table type: \"" << FMT << "\" for file \"" << fname << "\""
79 << endmsg;
81 }
82
83 debug() << "Adding PDT file \"" << rfile << "\" type " << FMT << endmsg;
84
85 m_inputs.emplace_back( rfile, pF );
86 }
87
88 return status;
89}
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
const ValueType & value() const
Definition Property.h:229
inputFunPtr parseTableType(const std::string &)
std::vector< std::pair< std::string, inputFunPtr > > m_inputs
Definition PartPropSvc.h:53
bool(*)(std::istream &, HepPDT::TableBuilder &) inputFunPtr
Definition PartPropSvc.h:50
StatusCode initialize() override
Definition Service.cpp:118
bool isFailure() const
Definition StatusCode.h:129
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)

◆ parseTableType()

PartPropSvc::inputFunPtr PartPropSvc::parseTableType ( const std::string & typ)
private

Definition at line 113 of file PartPropSvc.cpp.

113 {
114 static const auto table = {
115 std::make_pair( "PDG", &HepPDT::addPDGParticles ), std::make_pair( "PYTHIA", &HepPDT::addPythiaParticles ),
116 std::make_pair( "EVTGEN", &HepPDT::addEvtGenParticles ), std::make_pair( "HERWIG", &HepPDT::addHerwigParticles ),
117 std::make_pair( "ISAJET", &HepPDT::addIsajetParticles ), std::make_pair( "QQ", &HepPDT::addQQParticles ) };
118 auto i = std::find_if( std::begin( table ), std::end( table ),
119 [&]( const std::pair<const char*, inputFunPtr>& p ) { return typ == p.first; } );
120 if ( i == std::end( table ) ) {
121 error() << "Unknown Particle Data file type: \"" << typ << "\"" << endmsg;
122 throw std::runtime_error( "error parsing particle table type" );
123 }
124 return i->second;
125}

◆ PDT()

HepPDT::ParticleDataTable * PartPropSvc::PDT ( )
override

Definition at line 160 of file PartPropSvc.cpp.

160 {
161
162 if ( !m_pdt ) {
163 debug() << "creating ParticleDataTable" << endmsg;
164 if ( createTable().isFailure() ) {
165 fatal() << "Could not create ParticleDataTable" << endmsg;
166 m_pdt.reset();
167 }
168 }
169
170 return m_pdt ? &m_pdt.value() : nullptr;
171}
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
StatusCode createTable()

◆ setUnknownParticleHandler()

void PartPropSvc::setUnknownParticleHandler ( HepPDT::ProcessUnknownID * puid,
const std::string & n )
override

Definition at line 175 of file PartPropSvc.cpp.

175 {
176 if ( m_pdt ) {
177 error() << "not setting Unknown Particle Handler \"" << n << "\" as ParticleDataTable already instantiated"
178 << endmsg;
179 return;
180 }
181
182 debug() << "setting Unknown Particle Handler \"" << n << "\" at " << puid << endmsg;
183
184 if ( m_upid ) {
185 warning() << "overriding previously selected Unknown Particle Handler \"" << m_upid_name << "\" with \"" << n
186 << "\"" << endmsg;
187 }
188
189 m_upid = puid;
190 m_upid_name = n;
191}
std::string m_upid_name
Definition PartPropSvc.h:58

Member Data Documentation

◆ InputFile

PartPropSvc.InputFile

Definition at line 17 of file PartPropSvc.py.

◆ m_inputs

std::vector<std::pair<std::string, inputFunPtr> > PartPropSvc::m_inputs
private

Definition at line 53 of file PartPropSvc.h.

◆ m_pdt

std::optional<HepPDT::ParticleDataTable> PartPropSvc::m_pdt
private

Definition at line 60 of file PartPropSvc.h.

◆ m_pdtFiles

Gaudi::Property<std::string> PartPropSvc::m_pdtFiles { this, "InputFile", "PDGTABLE.MeV" }
private

Definition at line 55 of file PartPropSvc.h.

55{ this, "InputFile", "PDGTABLE.MeV" };

◆ m_upid

HepPDT::ProcessUnknownID* PartPropSvc::m_upid = nullptr
private

Definition at line 57 of file PartPropSvc.h.

◆ m_upid_local

bool PartPropSvc::m_upid_local = false
private

Definition at line 64 of file PartPropSvc.h.

◆ m_upid_name

std::string PartPropSvc::m_upid_name
private

Definition at line 58 of file PartPropSvc.h.


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