The Gaudi Framework  v29r0 (ff2e7097)
PartPropSvc Class Reference

#include <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
 
 ~PartPropSvc () override=default
 
- 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...
 
 ~extends () override=default
 Virtual destructor. 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...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. 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 >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
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
 
 ~PropertyHolder () override=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, TYPE &value, const std::string &doc="none") const
 
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 Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &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 (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces... >
 ~extend_interfaces () override=default
 Virtual destructor. 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::unique_ptr< 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
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- 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
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
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"}
 
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()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Detailed Description

Definition at line 28 of file PartPropSvc.h.

Member Typedef Documentation

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

Definition at line 45 of file PartPropSvc.h.

Constructor & Destructor Documentation

PartPropSvc::~PartPropSvc ( )
overridedefault

Member Function Documentation

StatusCode PartPropSvc::createTable ( )
private

Definition at line 130 of file PartPropSvc.cpp.

131 {
132 
133  // use a handler for unknown heavy ions
134  if ( !m_upid ) {
135  setUnknownParticleHandler( new HepPDT::HeavyIonUnknownID, "Default Heavy Ion Handler" );
136  m_upid_local = true;
137  }
138 
139  m_pdt.reset( new HepPDT::ParticleDataTable( m_upid_name, m_upid ) );
140 
141  HepPDT::TableBuilder tb( *m_pdt );
142 
143  for ( const auto& itr : m_inputs ) {
144  const auto& f = itr.first;
145  const auto& pF = itr.second;
146 
147  debug() << "Reading PDT file \"" << f << "\"" << endmsg;
148 
149  std::ifstream pdfile{f};
150  // build a table from the file
151  if ( !pF( pdfile, tb ) ) {
152  error() << "Error reading PDT file: \"" << f << "\"" << endmsg;
153  return StatusCode::FAILURE;
154  }
155  }
156 
157  return StatusCode::SUCCESS;
158 }
std::unique_ptr< HepPDT::ParticleDataTable > m_pdt
Definition: PartPropSvc.h:55
std::vector< std::pair< std::string, inputFunPtr > > m_inputs
Definition: PartPropSvc.h:48
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:52
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
bool m_upid_local
Definition: PartPropSvc.h:59
T reset(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
void setUnknownParticleHandler(HepPDT::ProcessUnknownID *, const std::string &) override
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
STL class.
std::string m_upid_name
Definition: PartPropSvc.h:53
StatusCode PartPropSvc::finalize ( )
override

Definition at line 89 of file PartPropSvc.cpp.

90 {
91 
92  m_pdt.reset();
93 
94  if ( m_upid_local && m_upid ) {
95  m_upid_local = false;
96  // This will cause a memory leak, but we can't delete it as the
97  // destructor of HepPDT::processUnknownID is protected.
98  // We need this though to call reinitialize successfully.
99  m_upid = nullptr;
100  }
101 
102  StatusCode status = Service::finalize();
103 
104  if ( status.isSuccess() ) {
105  debug() << "Service finalised successfully" << endmsg;
106  }
107 
108  return status;
109 }
StatusCode finalize() override
Definition: Service.cpp:174
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
std::unique_ptr< HepPDT::ParticleDataTable > m_pdt
Definition: PartPropSvc.h:55
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:52
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
bool m_upid_local
Definition: PartPropSvc.h:59
T reset(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode PartPropSvc::initialize ( )
override

Definition at line 22 of file PartPropSvc.cpp.

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

Definition at line 113 of file PartPropSvc.cpp.

114 {
115  static const auto table = {
116  std::make_pair( "PDG", &HepPDT::addPDGParticles ), std::make_pair( "PYTHIA", &HepPDT::addPythiaParticles ),
117  std::make_pair( "EVTGEN", &HepPDT::addEvtGenParticles ), std::make_pair( "HERWIG", &HepPDT::addHerwigParticles ),
118  std::make_pair( "ISAJET", &HepPDT::addIsajetParticles ), std::make_pair( "QQ", &HepPDT::addQQParticles )};
119  auto i = std::find_if( std::begin( table ), std::end( table ),
120  [&]( const std::pair<const char*, inputFunPtr>& p ) { return typ == p.first; } );
121  if ( i == std::end( table ) ) {
122  error() << "Unknown Particle Data file type: \"" << typ << "\"" << endmsg;
123  throw std::runtime_error( "error parsing particle table type" );
124  }
125  return i->second;
126 }
T end(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
T make_pair(T...args)
T find_if(T...args)
T begin(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
HepPDT::ParticleDataTable * PartPropSvc::PDT ( )
override

Definition at line 162 of file PartPropSvc.cpp.

163 {
164 
165  if ( !m_pdt ) {
166  debug() << "creating ParticleDataTable" << endmsg;
167  if ( createTable().isFailure() ) {
168  fatal() << "Could not create ParticleDataTable" << endmsg;
169  m_pdt.reset( nullptr );
170  }
171  }
172 
173  return m_pdt.get();
174 }
std::unique_ptr< HepPDT::ParticleDataTable > m_pdt
Definition: PartPropSvc.h:55
T reset(T...args)
T get(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
StatusCode createTable()
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void PartPropSvc::setUnknownParticleHandler ( HepPDT::ProcessUnknownID *  puid,
const std::string n 
)
override

Definition at line 178 of file PartPropSvc.cpp.

179 {
180  if ( m_pdt ) {
181  error() << "not setting Unknown Particle Handler \"" << n << "\" as ParticleDataTable already instantiated"
182  << endmsg;
183  return;
184  }
185 
186  debug() << "setting Unknown Particle Handler \"" << n << "\" at " << puid << endmsg;
187 
188  if ( m_upid ) {
189  warning() << "overriding previously selected Unknown Particle Handler \"" << m_upid_name << "\" with \"" << n
190  << "\"" << endmsg;
191  }
192 
193  m_upid = puid;
194  m_upid_name = n;
195 }
std::unique_ptr< HepPDT::ParticleDataTable > m_pdt
Definition: PartPropSvc.h:55
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:52
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
std::string m_upid_name
Definition: PartPropSvc.h:53

Member Data Documentation

PartPropSvc.InputFile

Definition at line 6 of file PartPropSvc.py.

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

Definition at line 48 of file PartPropSvc.h.

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

Definition at line 55 of file PartPropSvc.h.

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

Definition at line 50 of file PartPropSvc.h.

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

Definition at line 52 of file PartPropSvc.h.

bool PartPropSvc::m_upid_local = false
private

Definition at line 59 of file PartPropSvc.h.

std::string PartPropSvc::m_upid_name
private

Definition at line 53 of file PartPropSvc.h.


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