The Gaudi Framework  v36r13 (995e4364)
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 * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service
More...
 
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
More...
 
StatusCode sysStart () override
 Initialize Service
More...
 
StatusCode sysStop () override
 Initialize Service
More...
 
StatusCode sysFinalize () override
 Finalize Service
More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor
More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator
More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
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, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
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. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
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. More...
 
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. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
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) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

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::stringm_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 = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- 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 = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 Standard Destructor
More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
Gaudi::Property< bool > m_auditInit { this, "AuditServices", false, "[[deprecated]] unused" }
 
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
More...
 

Detailed Description

Definition at line 38 of file PartPropSvc.h.

Member Typedef Documentation

◆ inputFunPtr

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

Definition at line 51 of file PartPropSvc.h.

Member Function Documentation

◆ createTable()

StatusCode PartPropSvc::createTable ( )
private

Definition at line 135 of file PartPropSvc.cpp.

135  {
136 
137  // use a handler for unknown heavy ions
138  if ( !m_upid ) {
139  setUnknownParticleHandler( new HepPDT::HeavyIonUnknownID, "Default Heavy Ion Handler" );
140  m_upid_local = true;
141  }
142 
143  m_pdt.emplace( m_upid_name, m_upid );
144 
145  HepPDT::TableBuilder tb( *m_pdt );
146 
147  for ( const auto& itr : m_inputs ) {
148  const auto& f = itr.first;
149  const auto& pF = itr.second;
150 
151  debug() << "Reading PDT file \"" << f << "\"" << endmsg;
152 
153  std::ifstream pdfile{ f };
154  // build a table from the file
155  if ( !pF( pdfile, tb ) ) {
156  error() << "Error reading PDT file: \"" << f << "\"" << endmsg;
157  return StatusCode::FAILURE;
158  }
159  }
160 
161  return StatusCode::SUCCESS;
162 }

◆ finalize()

StatusCode PartPropSvc::finalize ( )
override

Definition at line 98 of file PartPropSvc.cpp.

98  {
99 
100  m_pdt.reset();
101 
102  if ( m_upid_local && m_upid ) {
103  m_upid_local = false;
104  // This will cause a memory leak, but we can't delete it as the
105  // destructor of HepPDT::processUnknownID is protected.
106  // We need this though to call reinitialize successfully.
107  m_upid = nullptr;
108  }
109 
110  StatusCode status = Service::finalize();
111 
112  if ( status.isSuccess() ) { debug() << "Service finalised successfully" << endmsg; }
113 
114  return status;
115 }

◆ initialize()

StatusCode PartPropSvc::initialize ( )
override

Definition at line 32 of file PartPropSvc.cpp.

32  {
33 
35 
36  if ( status.isFailure() ) {
37  error() << "Could not initialize main svc" << endmsg;
38  return StatusCode::FAILURE;
39  }
40 
42 
43  typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
44  boost::char_separator<char> sep( ", " );
45  boost::char_separator<char> sep_eq( "=" );
46 
47  tokenizer tokens( key, sep );
48  for ( auto it = tokens.begin(); it != tokens.end(); ++it ) {
49 
50  tokenizer tok2( *it, sep_eq );
51  int nToks( std::distance( tok2.begin(), tok2.end() ) );
52 
53  auto it2 = tok2.begin();
54  const std::string fname = *it2;
56  if ( nToks == 1 ) {
57  info() << "No table format type specified for \"" << fname << "\". Assuming PDG" << endmsg;
58  fmt = "PDG";
59  } else {
60  ++it2;
61  fmt = *it2;
62  }
63 
64  // see if input file exists in $DATAPATH
65  std::string rfile = System::PathResolver::find_file( fname, "DATAPATH" );
66  if ( rfile.empty() ) {
67  error() << "Could not find PDT file: \"" << fname << "\" in $DATAPATH" << endmsg;
68  return StatusCode::FAILURE;
69  }
70 
71  // is the file readable?
72  std::ifstream pdfile{ rfile };
73  if ( !pdfile ) {
74  error() << "Could not open PDT file: \"" << rfile << "\"" << endmsg;
75  return StatusCode::FAILURE;
76  }
77 
78  std::string FMT = boost::algorithm::to_upper_copy( fmt );
79 
80  inputFunPtr pF = nullptr;
81  try {
82  pF = parseTableType( FMT );
83  } catch ( ... ) {
84  error() << "Could not determine Particle Property table type: \"" << FMT << "\" for file \"" << fname << "\""
85  << endmsg;
86  return StatusCode::FAILURE;
87  }
88 
89  debug() << "Adding PDT file \"" << rfile << "\" type " << FMT << endmsg;
90 
91  m_inputs.emplace_back( rfile, pF );
92  }
93 
94  return status;
95 }

◆ parseTableType()

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

Definition at line 119 of file PartPropSvc.cpp.

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

◆ PDT()

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

Definition at line 166 of file PartPropSvc.cpp.

166  {
167 
168  if ( !m_pdt ) {
169  debug() << "creating ParticleDataTable" << endmsg;
170  if ( createTable().isFailure() ) {
171  fatal() << "Could not create ParticleDataTable" << endmsg;
172  m_pdt.reset();
173  }
174  }
175 
176  return m_pdt ? &m_pdt.value() : nullptr;
177 }

◆ setUnknownParticleHandler()

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

Definition at line 181 of file PartPropSvc.cpp.

181  {
182  if ( m_pdt ) {
183  error() << "not setting Unknown Particle Handler \"" << n << "\" as ParticleDataTable already instantiated"
184  << endmsg;
185  return;
186  }
187 
188  debug() << "setting Unknown Particle Handler \"" << n << "\" at " << puid << endmsg;
189 
190  if ( m_upid ) {
191  warning() << "overriding previously selected Unknown Particle Handler \"" << m_upid_name << "\" with \"" << n
192  << "\"" << endmsg;
193  }
194 
195  m_upid = puid;
196  m_upid_name = n;
197 }

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 54 of file PartPropSvc.h.

◆ m_pdt

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

Definition at line 61 of file PartPropSvc.h.

◆ m_pdtFiles

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

Definition at line 56 of file PartPropSvc.h.

◆ m_upid

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

Definition at line 58 of file PartPropSvc.h.

◆ m_upid_local

bool PartPropSvc::m_upid_local = false
private

Definition at line 65 of file PartPropSvc.h.

◆ m_upid_name

std::string PartPropSvc::m_upid_name
private

Definition at line 59 of file PartPropSvc.h.


The documentation for this class was generated from the following files:
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
std::string
STL class.
PartPropSvc::parseTableType
inputFunPtr parseTableType(const std::string &)
Definition: PartPropSvc.cpp:119
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
std::pair
PartPropSvc::m_inputs
std::vector< std::pair< std::string, inputFunPtr > > m_inputs
Definition: PartPropSvc.h:54
PartPropSvc::m_upid_name
std::string m_upid_name
Definition: PartPropSvc.h:59
std::find_if
T find_if(T... args)
std::distance
T distance(T... args)
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:222
PartPropSvc::m_upid
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:58
StatusCode
Definition: StatusCode.h:65
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:239
PartPropSvc::m_pdtFiles
Gaudi::Property< std::string > m_pdtFiles
Definition: PartPropSvc.h:56
std::runtime_error
STL class.
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:235
PartPropSvc::createTable
StatusCode createTable()
Definition: PartPropSvc.cpp:135
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
std::vector::emplace_back
T emplace_back(T... args)
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
System::PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cpp:118
std::begin
T begin(T... args)
PartPropSvc::setUnknownParticleHandler
void setUnknownParticleHandler(HepPDT::ProcessUnknownID *, const std::string &) override
Definition: PartPropSvc.cpp:181
fmt
Definition: MessageSvcSink.cpp:25
PartPropSvc::m_upid_local
bool m_upid_local
Definition: PartPropSvc.h:65
std::string::empty
T empty(T... args)
PartPropSvc::inputFunPtr
bool(*)(std::istream &, HepPDT::TableBuilder &) inputFunPtr
Definition: PartPropSvc.h:51
std::make_pair
T make_pair(T... args)
std::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
PartPropSvc::m_pdt
std::optional< HepPDT::ParticleDataTable > m_pdt
Definition: PartPropSvc.h:61
ProduceConsume.key
key
Definition: ProduceConsume.py:81
std::ifstream
STL class.