All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PartPropSvc Class Reference

#include <src/PartPropSvc.h>

Inheritance diagram for PartPropSvc:
Collaboration diagram for PartPropSvc:

Public Member Functions

virtual StatusCode initialize ()
 Initialization (from CONFIGURED to INITIALIZED). More...
 
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). More...
 
virtual StatusCode finalize ()
 Finalize (from INITIALIZED to CONFIGURED). More...
 
HepPDT::ParticleDataTable * PDT ()
 
void setUnknownParticleHandler (HepPDT::ProcessUnknownID *, const std::string &)
 
 PartPropSvc (const std::string &name, ISvcLocator *svc)
 
virtual ~PartPropSvc ()
 
- Public Member Functions inherited from extends1< Service, IPartPropSvc >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends1 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends1 ()
 Default constructor. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual ~extends1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector
< Property * > & 
getProperties () const
 Get list of properties. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 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<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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
virtual ~CommonMessaging ()
 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...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces3< IService, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
- Public Member Functions inherited from extend_interfaces1< IPartPropSvc >
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IPartPropSvc
 DeclareInterfaceID (IPartPropSvc, 2, 0)
 InterfaceID. More...
 
virtual ~IPartPropSvc ()
 virtual destructor More...
 

Private Member Functions

StatusCode createTable ()
 

Private Attributes

std::vector< std::pair
< std::string, bool(*)(std::istream
&, HepPDT::TableBuilder &)> > 
m_inputs
 
StringProperty m_pdtFiles
 
HepPDT::ProcessUnknownID * m_upid
 
std::string m_upid_name
 
HepPDT::ParticleDataTable * m_pdt
 
bool(*)(std::istream
&, HepPDT::TableBuilder &) 
parseTableType (std::string &)
 
MsgStream m_log
 
bool m_upid_local
 

Additional Inherited Members

- Public Types inherited from extends1< Service, IPartPropSvc >
typedef extends1 base_class
 Typedef to this class. More...
 
typedef extend_interfaces1
< IPartPropSvc
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from Service
typedef
Gaudi::PluginService::Factory
< IService *, const
std::string &, ISvcLocator * > 
Factory
 
- Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging base_class
 
- Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class. More...
 
typedef extend_interfaces3
< IService, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IService, IProperty, IStateful >
typedef mpl::fold< typename
IService::iid::iids::type,
typename mpl::fold< typename
IProperty::iid::iids::type,
typename
IStateful::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type, mpl::insert< mpl::_1,
mpl::_2 > >::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Public Types inherited from extend_interfaces1< IPartPropSvc >
typedef
IPartPropSvc::iid::iids::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level. More...
 
Gaudi::StateMachine::State m_state
 Service state. More...
 
Gaudi::StateMachine::State m_targetState
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::auto_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

Detailed Description

Definition at line 27 of file PartPropSvc.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file PartPropSvc.cpp.

33  : base_class( name, svc ), m_upid(0), m_pdt(0), m_log(msgSvc(), name),
34  m_upid_local(false) {
35 
36  declareProperty( "InputFile", m_pdtFiles="PDGTABLE.MeV");
37 
38 }
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream m_log
Definition: PartPropSvc.h:60
extends1 base_class
Typedef to this class.
Definition: extends.h:12
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:53
bool m_upid_local
Definition: PartPropSvc.h:62
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
HepPDT::ParticleDataTable * m_pdt
Definition: PartPropSvc.h:56
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:211
StringProperty m_pdtFiles
Definition: PartPropSvc.h:52
PartPropSvc::~PartPropSvc ( )
virtual

Definition at line 42 of file PartPropSvc.cpp.

42  {
43 }

Member Function Documentation

StatusCode PartPropSvc::createTable ( )
private

Definition at line 189 of file PartPropSvc.cpp.

189  {
190 
191  // use a handler for unknown heavy ions
192  if ( m_upid == 0 ) {
193  setUnknownParticleHandler(new HepPDT::HeavyIonUnknownID,
194  "Default Heavy Ion Handler");
195  m_upid_local = true;
196  }
197 
198  m_pdt = new HepPDT::ParticleDataTable(m_upid_name, m_upid);
199 
200  HepPDT::TableBuilder tb( *m_pdt );
201 
202  std::vector< std::pair<std::string,
203  bool(*) (std::istream&,HepPDT::TableBuilder&)> >::const_iterator itr;
204  for (itr = m_inputs.begin(); itr != m_inputs.end(); ++itr) {
205  string f = itr->first;
206  bool (*pF) (std::istream&,HepPDT::TableBuilder&) = itr->second;
207 
208  m_log << MSG::DEBUG << "Reading PDT file \"" << f << "\""
209  << endmsg;
210 
211  std::ifstream pdfile( f.c_str() );
212  // build a table from the file
213  if ( ! pF(pdfile,tb) ) {
214  m_log << MSG::ERROR << "Error reading PDT file: \"" << f
215  << "\"" << endmsg;
216  return StatusCode::FAILURE;
217  }
218 
219  }
220 
221  return StatusCode::SUCCESS;
222 
223 }
struct GAUDI_API vector
Parametrisation class for vector-like implementation.
MsgStream m_log
Definition: PartPropSvc.h:60
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:53
bool m_upid_local
Definition: PartPropSvc.h:62
HepPDT::ParticleDataTable * m_pdt
Definition: PartPropSvc.h:56
void setUnknownParticleHandler(HepPDT::ProcessUnknownID *, const std::string &)
std::vector< std::pair< std::string, bool(*)(std::istream &, HepPDT::TableBuilder &)> > m_inputs
Definition: PartPropSvc.h:50
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::string m_upid_name
Definition: PartPropSvc.h:54
StatusCode PartPropSvc::finalize ( )
virtual

Finalize (from INITIALIZED to CONFIGURED).

Reimplemented from Service.

Definition at line 131 of file PartPropSvc.cpp.

131  {
132 
133  if (m_pdt != 0) {
134  delete m_pdt;
135  m_pdt = 0;
136  }
137 
138  if (m_upid_local && m_upid != 0) {
139  m_upid_local = false;
140  // This will cause a memory leak, but we can't delete it as the
141  // destructor of HepPDT::processUnknownID is protected.
142  // We need this though to call reinitialize successfully.
143  m_upid = 0;
144  }
145 
146  MsgStream m_log( msgSvc(), name() );
147  StatusCode status = Service::finalize();
148 
149  if ( status.isSuccess() )
150  m_log << MSG::DEBUG << "Service finalised successfully" << endmsg;
151 
152  return status;
153 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
MsgStream m_log
Definition: PartPropSvc.h:60
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:53
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
bool m_upid_local
Definition: PartPropSvc.h:62
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
HepPDT::ParticleDataTable * m_pdt
Definition: PartPropSvc.h:56
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
Definition: Service.cpp:199
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode PartPropSvc::initialize ( )
virtual

Initialization (from CONFIGURED to INITIALIZED).

Reimplemented from Service.

Definition at line 48 of file PartPropSvc.cpp.

48  {
49 
52 
53  if ( status.isFailure() ) {
54  m_log << MSG::ERROR << "Could not initialize main svc" << endmsg;
55  return StatusCode::FAILURE;
56  }
57 
58 
59  std::string key = m_pdtFiles.value();
60 
61  Tokenizer tok(true);
62 
63  tok.analyse( key, " ", "", "", "=", "", "");
64 
65  for ( Tokenizer::Items::iterator i = tok.items().begin();
66  i != tok.items().end(); i++) {
67  const std::string& fname = (*i).tag();
68 
69  // see if input file exists in $DATAPATH
70  std::string rfile = System::PathResolver::find_file(fname,"DATAPATH");
71  if (rfile == "") {
72  m_log << MSG::ERROR << "Could not find PDT file: \"" << fname
73  << "\" in $DATAPATH" << endmsg;
74  return StatusCode::FAILURE;
75  }
76 
77 
78  // is the file readable?
79  std::ifstream pdfile( rfile.c_str() );
80  if (!pdfile) {
81  m_log << MSG::ERROR << "Could not open PDT file: \"" << rfile
82  << "\"" << endmsg;
83  return StatusCode::FAILURE;
84  }
85 
86  std::string val,VAL;
87  val = (*i).value();
88  VAL = val;
89  toupper(VAL);
90 
91  // default: no type specified, assume PDG
92  if (val == fname) {
93  m_log << MSG::INFO << "No table format type specified for \"" << fname
94  << "\". Assuming PDG" << endmsg;
95  VAL = "PDG";
96  }
97 
98  bool (*pF) (std::istream &,
99  HepPDT::TableBuilder &);
100  try {
101  pF = parseTableType(VAL);
102  } catch (...) {
103  m_log << MSG::ERROR
104  << "Could not determine Particle Property table type: \""
105  << val << "\" for file \"" << fname << "\"" << endmsg;
106  return StatusCode::FAILURE;
107  }
108 
109  m_log << MSG::DEBUG << "Adding PDT file \"" << rfile << "\" type "
110  << VAL << endmsg;
111 
112  m_inputs.push_back( make_pair( rfile, pF ) );
113 
114  }
115 
116 
117  return status;
118 }
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:243
MsgStream m_log
Definition: PartPropSvc.h:60
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
void toupper(std::string &s)
Definition: PartPropSvc.cpp:24
STL Include files.
Definition: Tokenizer.h:24
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
const TYPE & value() const
explicit conversion
Definition: Property.h:355
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: Service.cpp:74
bool(*)(std::istream &, HepPDT::TableBuilder &) parseTableType(std::string &)
Definition: PartPropSvc.h:58
void setLevel(int level)
Update outputlevel.
Definition: MsgStream.h:106
std::vector< std::pair< std::string, bool(*)(std::istream &, HepPDT::TableBuilder &)> > m_inputs
Definition: PartPropSvc.h:50
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StringProperty m_pdtFiles
Definition: PartPropSvc.h:52
HepPDT::ParticleDataTable * PartPropSvc::PDT ( )
virtual

Implements IPartPropSvc.

Definition at line 228 of file PartPropSvc.cpp.

228  {
229 
230  if (m_pdt == 0) {
231  m_log << MSG::DEBUG << "creating ParticleDataTable" << endmsg;
232  if (createTable().isFailure()) {
233  m_log << MSG::FATAL << "Could not create ParticleDataTable" << endmsg;
234  m_pdt = 0;
235  }
236  }
237 
238  return m_pdt;
239 }
MsgStream m_log
Definition: PartPropSvc.h:60
HepPDT::ParticleDataTable * m_pdt
Definition: PartPropSvc.h:56
StatusCode createTable()
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode PartPropSvc::reinitialize ( )
virtual

Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).

Reimplemented from Service.

Definition at line 122 of file PartPropSvc.cpp.

122  {
123 
124  return StatusCode::SUCCESS;
125 
126 }
void PartPropSvc::setUnknownParticleHandler ( HepPDT::ProcessUnknownID *  puid,
const std::string &  n 
)
virtual

Implements IPartPropSvc.

Definition at line 244 of file PartPropSvc.cpp.

245  {
246  if (m_pdt != 0) {
247  m_log << MSG::ERROR << "not setting Unknown Particle Handler \"" << n
248  << "\" as ParticleDataTable already instantiated" << endmsg;
249  return;
250  }
251 
252  m_log << MSG::DEBUG << "setting Unknown Particle Handler \"" << n
253  << "\" at " << puid << endmsg;
254 
255  if (m_upid != 0) {
257  << "overriding previously selected Unknown Particle Handler \""
258  << m_upid_name << "\" with \"" << n << "\"" << endmsg;
259  }
260 
261  m_upid = puid;
262  m_upid_name = n;
263 
264 }
MsgStream m_log
Definition: PartPropSvc.h:60
HepPDT::ProcessUnknownID * m_upid
Definition: PartPropSvc.h:53
HepPDT::ParticleDataTable * m_pdt
Definition: PartPropSvc.h:56
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::string m_upid_name
Definition: PartPropSvc.h:54

Member Data Documentation

std::vector< std::pair<std::string, bool(*) (std::istream&,HepPDT::TableBuilder&)> > PartPropSvc::m_inputs
private

Definition at line 50 of file PartPropSvc.h.

MsgStream PartPropSvc::m_log
mutableprivate

Definition at line 60 of file PartPropSvc.h.

HepPDT::ParticleDataTable* PartPropSvc::m_pdt
private

Definition at line 56 of file PartPropSvc.h.

StringProperty PartPropSvc::m_pdtFiles
private

Definition at line 52 of file PartPropSvc.h.

HepPDT::ProcessUnknownID* PartPropSvc::m_upid
private

Definition at line 53 of file PartPropSvc.h.

bool PartPropSvc::m_upid_local
private

Definition at line 62 of file PartPropSvc.h.

std::string PartPropSvc::m_upid_name
private

Definition at line 54 of file PartPropSvc.h.

bool(*)(std::istream&, HepPDT::TableBuilder&) PartPropSvc::parseTableType(std::string &)
private

Definition at line 58 of file PartPropSvc.h.


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