| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
PartPropSvc Class Reference

`#include <src/PartPropSvc.h>`

Inheritance diagram for PartPropSvc:
[legend]
Collaboration diagram for PartPropSvc:
[legend]

## Public Member Functions
| PartPropSvc (const std::string &name, ISvcLocator *svc)
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::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () 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...
StatusCode | setProperty (const Property &p) override
StatusCode | setProperty (const std::string &s) override
StatusCode | setProperty (const std::string &n, const std::string &v) override
StatusCode | getProperty (Property *p) const override
const Property & | getProperty (const std::string &name) const override
StatusCode | getProperty (const std::string &n, std::string &v) const override
const std::vector< Property * > & | getProperties () const override
bool | hasProperty (const std::string &name) const override
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value 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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties. More...
template<class T >
StatusCode | declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Private tool. More...
template<class T >
StatusCode | declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Public 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 CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () 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...

## 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
StringProperty | m_pdtFiles
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 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 CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
IntegerProperty | m_outputLevel = MSG::NIL
| Service output level. More...
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. 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 48 of file PartPropSvc.h.

## Constructor & Destructor Documentation

PartPropSvc::PartPropSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc
| ) |  |

Definition at line 25 of file PartPropSvc.cpp.

26 : base_class( name_, svc )
27 {
28 declareProperty( "InputFile", m_pdtFiles="PDGTABLE.MeV");
29 }
extends< Service, IPartPropSvc >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
Service::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
PartPropSvc::m_pdtFiles
StringProperty m_pdtFiles
Definition: PartPropSvc.h:53

PartPropSvc::~PartPropSvc | ( |  | ) |
| override default

## Member Function Documentation

StatusCode PartPropSvc::createTable | ( |  | ) |
| private

Definition at line 155 of file PartPropSvc.cpp.

155 {
156
157 // use a handler for unknown heavy ions
158 if ( !m_upid ) {
159 setUnknownParticleHandler(new HepPDT::HeavyIonUnknownID,
160 "Default Heavy Ion Handler");
161 m_upid_local = true;
162 }
163
164 m_pdt.reset( new HepPDT::ParticleDataTable(m_upid_name, m_upid) );
165
166 HepPDT::TableBuilder tb( *m_pdt );
167
168 for (const auto& itr : m_inputs ) {
169 const auto& f = itr.first;
170 const auto& pF = itr.second;
171
172 debug() << "Reading PDT file \"" << f << "\""
173 << endmsg;
174
175 std::ifstream pdfile{ f };
176 // build a table from the file
177 if ( ! pF(pdfile,tb) ) {
178 error() << "Error reading PDT file: \"" << f
179 << "\"" << endmsg;
180 return StatusCode::FAILURE;
181 }
182
183 }
184
185 return StatusCode::SUCCESS;
186
187 }
PartPropSvc::m_pdt
std::unique_ptr< HepPDT::ParticleDataTable > m_pdt
Definition: PartPropSvc.h:57
PartPropSvc::m_upid
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:54
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
PartPropSvc::m_upid_local
bool m_upid_local
Definition: PartPropSvc.h:61
std::unique_ptr::reset
T reset(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
PartPropSvc::m_inputs
std::vector< std::pair< std::string, inputFunPtr > > m_inputs
Definition: PartPropSvc.h:51
PartPropSvc::setUnknownParticleHandler
void setUnknownParticleHandler(HepPDT::ProcessUnknownID *, const std::string &) override
Definition: PartPropSvc.cpp:208
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::ifstream
STL class.
PartPropSvc::m_upid_name
std::string m_upid_name
Definition: PartPropSvc.h:55

StatusCode PartPropSvc::finalize | ( |  | ) |
| override

Definition at line 109 of file PartPropSvc.cpp.

109 {
110
111 m_pdt.reset();
112
113 if (m_upid_local && m_upid ) {
114 m_upid_local = false;
115 // This will cause a memory leak, but we can't delete it as the
116 // destructor of HepPDT::processUnknownID is protected.
117 // We need this though to call reinitialize successfully.
118 m_upid = nullptr;
119 }
120
121 StatusCode status = Service::finalize();
122
123 if ( status.isSuccess() ) {
124 debug() << "Service finalised successfully" << endmsg;
125 }
126
127 return status;
128 }
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:193
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
PartPropSvc::m_pdt
std::unique_ptr< HepPDT::ParticleDataTable > m_pdt
Definition: PartPropSvc.h:57
PartPropSvc::m_upid
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:54
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
PartPropSvc::m_upid_local
bool m_upid_local
Definition: PartPropSvc.h:61
std::unique_ptr::reset
T reset(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode PartPropSvc::initialize | ( |  | ) |
| override

Definition at line 34 of file PartPropSvc.cpp.

34 {
35
36 StatusCode status = Service::initialize();
37
38 if ( status.isFailure() ) {
39 error() << "Could not initialize main svc" << endmsg;
40 return StatusCode::FAILURE;
41 }
42
43
44 std::string key = m_pdtFiles.value();
45
46 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
47 boost::char_separator<char> sep(", ");
48 boost::char_separator<char> sep_eq("=");
49
50 tokenizer tokens(key, sep);
51 for (auto it = tokens.begin(); it != tokens.end(); ++it) {
52
53 tokenizer tok2(*it, sep_eq);
54 int nToks(distance(tok2.begin(), tok2.end()));
55
56 auto it2 = tok2.begin();
57 const std::string fname = *it2;
58 std::string fmt;
59 if (nToks == 1) {
60 info() << "No table format type specified for \"" << fname
61 << "\". Assuming PDG" << endmsg;
62 fmt = "PDG";
63 } else {
64 ++it2;
65 fmt = *it2;
66 }
67
68 // see if input file exists in $DATAPATH
69 std::string rfile = System::PathResolver::find_file(fname,"DATAPATH");
70 if (rfile.empty()) {
71 error() << "Could not find PDT file: \"" << fname
72 << "\" in $DATAPATH" << endmsg;
73 return StatusCode::FAILURE;
74 }
75
76 // is the file readable?
77 std::ifstream pdfile{ rfile };
78 if (!pdfile) {
79 error() << "Could not open PDT file: \"" << rfile
80 << "\"" << endmsg;
81 return StatusCode::FAILURE;
82 }
83
84 std::string FMT = boost::algorithm::to_upper_copy(fmt);
85
86 inputFunPtr pF = nullptr;
87 try {
88 pF = parseTableType(FMT);
89 } catch (...) {
90 error()
91 << "Could not determine Particle Property table type: \""
92 << FMT << "\" for file \"" << fname << "\"" << endmsg;
93 return StatusCode::FAILURE;
94 }
95
96 debug() << "Adding PDT file \"" << rfile << "\" type "
97 << FMT << endmsg;
98
99 m_inputs.emplace_back( rfile, pF );
100
101 }
102
103
104 return status;
105 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:68
std::string::empty
T empty(T...args)
std::distance
T distance(T...args)
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
PartPropSvc::parseTableType
inputFunPtr parseTableType(const std::string &)
Definition: PartPropSvc.cpp:133
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
PartPropSvc::inputFunPtr
bool(*)(std::istream &, HepPDT::TableBuilder &) inputFunPtr
Definition: PartPropSvc.h:48
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:126
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
PartPropSvc::m_inputs
std::vector< std::pair< std::string, inputFunPtr > > m_inputs
Definition: PartPropSvc.h:51
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::ifstream
STL class.
PartPropSvc::m_pdtFiles
StringProperty m_pdtFiles
Definition: PartPropSvc.h:53
std::vector::emplace_back
T emplace_back(T...args)

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

Definition at line 133 of file PartPropSvc.cpp.

134 {
135 static const auto table = { std::make_pair( "PDG" , &HepPDT::addPDGParticles ),
136 std::make_pair( "PYTHIA" , &HepPDT::addPythiaParticles ),
137 std::make_pair( "EVTGEN" , &HepPDT::addEvtGenParticles ),
138 std::make_pair( "HERWIG" , &HepPDT::addHerwigParticles ),
139 std::make_pair( "ISAJET" , &HepPDT::addIsajetParticles ),
140 std::make_pair( "QQ" , &HepPDT::addQQParticles ) };
141 auto i = std::find_if( std::begin(table), std::end(table),
142 [&](const std::pair<const char*,inputFunPtr>& p)
143 { return typ == p.first; } );
144 if ( i == std::end(table) ) {
145 error() << "Unknown Particle Data file type: \""
146 << typ << "\"" << endmsg;
147 throw std::runtime_error("error parsing particle table type");
148 }
149 return i->second;
150 }
std::end
T end(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
std::runtime_error
STL class.
std::make_pair
T make_pair(T...args)
std::pair
std::find_if
T find_if(T...args)
std::begin
T begin(T...args)
ana.i
list i
Definition: ana.py:128
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 192 of file PartPropSvc.cpp.

192 {
193
194 if (!m_pdt ) {
195 debug() << "creating ParticleDataTable" << endmsg;
196 if (createTable().isFailure()) {
197 fatal() << "Could not create ParticleDataTable" << endmsg;
198 m_pdt.reset(nullptr);
199 }
200 }
201
202 return m_pdt.get();
203 }
PartPropSvc::m_pdt
std::unique_ptr< HepPDT::ParticleDataTable > m_pdt
Definition: PartPropSvc.h:57
std::unique_ptr::reset
T reset(T...args)
std::unique_ptr::get
T get(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
PartPropSvc::createTable
StatusCode createTable()
Definition: PartPropSvc.cpp:155
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:112
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 208 of file PartPropSvc.cpp.

209 {
210 if (m_pdt) {
211 error() << "not setting Unknown Particle Handler \"" << n
212 << "\" as ParticleDataTable already instantiated" << endmsg;
213 return;
214 }
215
216 debug() << "setting Unknown Particle Handler \"" << n
217 << "\" at " << puid << endmsg;
218
219 if (m_upid) {
220 warning()
221 << "overriding previously selected Unknown Particle Handler \""
222 << m_upid_name << "\" with \"" << n << "\"" << endmsg;
223 }
224
225 m_upid = puid;
226 m_upid_name = n;
227
228 }
PartPropSvc::m_pdt
std::unique_ptr< HepPDT::ParticleDataTable > m_pdt
Definition: PartPropSvc.h:57
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
PartPropSvc::m_upid
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:54
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:121
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
PartPropSvc::m_upid_name
std::string m_upid_name
Definition: PartPropSvc.h:55

## Member Data Documentation

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

Definition at line 51 of file PartPropSvc.h.

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

Definition at line 57 of file PartPropSvc.h.

StringProperty PartPropSvc::m_pdtFiles
| private

Definition at line 53 of file PartPropSvc.h.

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

Definition at line 54 of file PartPropSvc.h.

bool PartPropSvc::m_upid_local = false
| private

Definition at line 61 of file PartPropSvc.h.

std::string PartPropSvc::m_upid_name
| private

Definition at line 55 of file PartPropSvc.h.

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

- PartPropSvc/src/PartPropSvc.h
- PartPropSvc/src/PartPropSvc.cpp