The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
Gaudi::ParticleProperties Namespace Reference

Functions

size_t index (const Gaudi::ParticleProperty *property, const Gaudi::Interfaces::IParticlePropertySvc *service)
 helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential identifier
 
size_t index (const Gaudi::ParticleID &pid, const Gaudi::Interfaces::IParticlePropertySvc *service)
 helper utility for mapping of Gaudi::ParticleID object into non-negative integral sequential identifier
 
const Gaudi::ParticlePropertyparticle (const size_t index, const Gaudi::Interfaces::IParticlePropertySvc *service)
 the inverse mapping of the integer sequential number onto Gaudi::ParticleID object
 
const Gaudi::ParticleID particleID (const size_t index, const Gaudi::Interfaces::IParticlePropertySvc *service)
 the inverse mapping of the integer sequential number onto Gaudi::ParticleID object
 
const Gaudi::ParticlePropertybyPythiaID (const int pythia, const Gaudi::Interfaces::IParticlePropertySvc *svc)
 mapping by pythiaID
 
const Gaudi::ParticlePropertybyEvtGenName (const std::string &evtGen, const Gaudi::Interfaces::IParticlePropertySvc *svc)
 mapping by EvtGen-name
 
template<class INPUT, class PREDICATE, class OUTPUT>
OUTPUT get (INPUT first, INPUT last, const PREDICATE &cut, OUTPUT output)
 get all particle properties which satisfy the certain criteria
 
template<class PREDICATE, class OUTPUT>
OUTPUT get (const Gaudi::Interfaces::IParticlePropertySvc *service, const PREDICATE &cut, OUTPUT output)
 get all particle properties which satisfy the certain criteria
 
Gaudi::Interfaces::IParticlePropertySvc::ParticleProperties allProperties (const Gaudi::Interfaces::IParticlePropertySvc *service)
 get all the properties at once
 
GAUDI_API std::ostream & printAsTable_ (const std::vector< const Gaudi::ParticleProperty * > &particles, std::ostream &stream, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
 print a list of properties in a form of the table
 
GAUDI_API std::string printAsTable (const std::vector< const Gaudi::ParticleProperty * > &particles, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
 print a list of properties in a form of the table
 
GAUDI_API MsgStreamprintAsTable (const std::vector< const Gaudi::ParticleProperty * > &particles, MsgStream &stream, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
 print a list of properties in a form of the table
 
GAUDI_API std::ostream & printAsTable_ (const std::vector< Gaudi::ParticleID > &particles, std::ostream &stream, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
 print properties in a form of the table
 
template<class C_, class A_>
std::ostream & printAsTable_ (const std::set< Gaudi::ParticleID, C_, A_ > &particles, std::ostream &stream, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
 
GAUDI_API std::string printAsTable (const std::vector< Gaudi::ParticleID > &particles, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
 print properties in a form of the table
 
template<class C_, class A_>
std::string printAsTable (const std::set< Gaudi::ParticleID, C_, A_ > &particles, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
 
GAUDI_API MsgStreamprintAsTable (const std::vector< Gaudi::ParticleID > &particles, MsgStream &stream, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
 print properties in a form of the table
 
template<class C_, class A_>
MsgStreamprintAsTable (const std::set< Gaudi::ParticleID, C_, A_ > &particles, MsgStream &stream, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
 

Function Documentation

◆ allProperties()

get all the properties at once

Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 201 of file IParticlePropertySvc.cpp.

201 {
202 return service ? Gaudi::Interfaces::IParticlePropertySvc::ParticleProperties( service->begin(), service->end() )
203 : Gaudi::Interfaces::IParticlePropertySvc::ParticleProperties();
204}
virtual iterator begin() const =0
get the begin-iterator for the container of particle properties It is assumed that the container is p...
virtual iterator end() const =0
get the end-iterator for the container of particle properties It is assumed that the container is pro...
std::vector< const Gaudi::ParticleProperty * > ParticleProperties
the actual type of (ordered) container of particle properties
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1

◆ byEvtGenName()

const Gaudi::ParticleProperty * Gaudi::ParticleProperties::byEvtGenName ( const std::string & evtGen,
const Gaudi::Interfaces::IParticlePropertySvc * svc )

mapping by EvtGen-name

const std::string& evtGen
const Gaudi::ParticleProperty* pp = byEvtGenName ( pythiaID , svc ) ;
The abstract interface to Particle Property Service.
A trivial class to hold information about a single particle properties.
const Gaudi::ParticleProperty * byEvtGenName(const std::string &evtGen, const Gaudi::Interfaces::IParticlePropertySvc *svc)
mapping by EvtGen-name
Attention
the method is not very efficient and should not be abused
See also
Gaudi::ParticleProperties::particle
Parameters
evtGenthe particle naem in EvtGen-generator
svcpointer to particle property service
Returns
the particle property for the given EvtGen-name
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 180 of file IParticlePropertySvc.cpp.

181 {
182 if ( !svc ) { return nullptr; }
183 // to be more efficient:
184 // 1) try to use the regular name (fast, logarithmic search)
185 const Gaudi::ParticleProperty* pp = svc->find( evtGen );
186 // 2) check the proper evtgen name
187 if ( pp && evtGen == pp->evtGen() ) { return pp; }
188 // 3) use the regular (linear search)
189 auto begin = svc->begin();
190 auto end = svc->end();
191 auto found = std::find_if( begin, end, [&]( const Gaudi::ParticleProperty* pp ) { return pp->evtGen() == evtGen; } );
192 //
193 return found != end ? *found : nullptr;
194}
virtual const ParticleProperty * find(const std::string &name) const =0
Retrieve an object by name:

◆ byPythiaID()

const Gaudi::ParticleProperty * Gaudi::ParticleProperties::byPythiaID ( const int pythia,
const Gaudi::Interfaces::IParticlePropertySvc * svc )

mapping by pythiaID

const int pythiaID = ... ;
const Gaudi::ParticleProeprty* pp = byPythiaID( pythiaID , svc ) ;
const Gaudi::ParticleProperty * byPythiaID(const int pythia, const Gaudi::Interfaces::IParticlePropertySvc *svc)
mapping by pythiaID
Attention
the method is not very efficient and should not be abused
See also
Gaudi::ParticleProperties::particle
Parameters
pythiapythia identifier
svcpointer to particle property service
Returns
the particle property for the given pythia ID
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 144 of file IParticlePropertySvc.cpp.

144 {
145 if ( !svc ) { return nullptr; }
146 // to be efficient
147 // 1) try to use PDG-ID (fast, logarithmic search)
148 const Gaudi::ParticleProperty* pp = svc->find( Gaudi::ParticleID( pythia ) );
149 // 2) check the proper pythia ID
150 if ( pp && pythia == pp->pythiaID() ) { return pp; }
151 // 3) use the regular (linear search)
152 auto begin = svc->begin();
153 auto end = svc->end();
154 auto found =
155 std::find_if( begin, end, [&]( const Gaudi::ParticleProperty* pp ) { return pp->pythiaID() == pythia; } );
156 return found != end ? *found : nullptr;
157}
Holds PDG + LHCb extension particle code, following the PDG particle numbering scheme (pdg....
Definition ParticleID.h:43

◆ get() [1/2]

template<class PREDICATE, class OUTPUT>
OUTPUT Gaudi::ParticleProperties::get ( const Gaudi::Interfaces::IParticlePropertySvc * service,
const PREDICATE & cut,
OUTPUT output )

get all particle properties which satisfy the certain criteria

e.g. select all particles with 'invalid' Pythia ID = 0 :

#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
using namespace boost::lambda ;
// create the output vector:
Vector output ;
// use the function
( svc ,
bind ( &Gaudi::ParticleProperty::pythiaID , _1 ) == 0 , // predicate
std::back_inserter( output ) ) ; // output
int pythiaID() const
Get the Pythia ID.
OUTPUT get(INPUT first, INPUT last, const PREDICATE &cut, OUTPUT output)
get all particle properties which satisfy the certain criteria

or select all particles with 'invalid' EvtGen = "unknown" :

#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
using namespace boost::lambda ;
// create the output vector:
Vector output ;
// use the function
( svc ,
bind ( &Gaudi::ParticleProperty::evtGen , _1 ) == "unknown" , // predicate
std::back_inserter( output ) ) ; // output
const std::string & evtGen() const
Get the EvtGen name.

Select all leptons:

#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
using namespace boost::lambda ;
// create the output vector:
Vector leptons ;
// use the function
( svc ,
std::back_inserter ( leptons ) ) ; // output
bool isLepton() const
Return if the PID is for a lepton.
const Gaudi::ParticleID & particleID() const
get the particle ID
Parameters
firstbegin-iterator of input sequence of particle properties
endend-iterator of input sequence of particle properties
cutthe predicate
outputthe output iterator
Returns
the updated position of output iterator
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 476 of file IParticlePropertySvc.h.

476 {
477 if ( 0 == service ) { return output; }
478 return service->get( cut, output );
479 }
OUTPUT get(const PREDICATE &cut, OUTPUT output) const
get the properties according to some criteria

◆ get() [2/2]

template<class INPUT, class PREDICATE, class OUTPUT>
OUTPUT Gaudi::ParticleProperties::get ( INPUT first,
INPUT last,
const PREDICATE & cut,
OUTPUT output )

get all particle properties which satisfy the certain criteria

e.g. select all particles with 'invalid' Pythia ID = 0 :

#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
using namespace boost::lambda ;
// create the output vector:
Vector output ;
// use the function
( svc->begin() , // begin-sequence
svc->end () , // end-sequence
bind ( &Gaudi::ParticleProperty::pythiaID , _1 ) == 0 , // predicate
std::back_inserter( output ) ) ; // output

or select all particles with 'invalid' EvtGen = "unknown" :

#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
using namespace boost::lambda ;
// create the output vector:
Vector output ;
// use the function
( svc->begin() , // begin-sequence
svc->end () , // end-sequence
bind ( &Gaudi::ParticleProperty::evtGen , _1 ) == "unknown" , // predicate
std::back_inserter( output ) ) ; // output

select leptons:

#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
...
...
using namespace boost::lambda ;
// create the output vector:
Vector leptons ;
// use the function
( svc->begin() , // begin-sequence
svc->end () , // end-sequence
std::back_inserter ( lepton ) ) ; // output

Essentially it is just a missing std::copy_if STL-algorithm

Parameters
firstbegin-iterator of input sequence of particle properties
lastend-iterator of input sequence of particle properties
cutthe predicate
outputthe output iterator
Returns
the updated position of output iterator
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 388 of file IParticlePropertySvc.h.

388 {
389 for ( ; first != last; ++first ) {
390 if ( cut( *first ) ) {
391 *output = *first;
392 ++output;
393 }
394 }
395 return output;
396 }

◆ index() [1/2]

size_t Gaudi::ParticleProperties::index ( const Gaudi::ParticleID & pid,
const Gaudi::Interfaces::IParticlePropertySvc * service )

helper utility for mapping of Gaudi::ParticleID object into non-negative integral sequential identifier

const Gaudi::ParticlePropertySvc* svc = ... ;
const Gaudi::ParticleID& pid = ... ;
size_t index = index ( pid , svc ) ;
if ( !index )
{
// error here: conversion is not possible
}
size_t index(const Gaudi::ParticleProperty *property, const Gaudi::Interfaces::IParticlePropertySvc *service)
helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential id...
This service provides access to particle properties.

This appears to be useful operation, but since it is "pure technical" it does not appear as interface method.

For invalid/missing PID and/or service 0 is returned. The valid result is always satisfy the condition: index <= service->size()

Parameters
pidthe object to be mapped
servicethe service
Returns
the sequential non-negative index
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 67 of file IParticlePropertySvc.cpp.

68 {
69 if ( !service ) { return 0; }
70 const Gaudi::ParticleProperty* pp = service->find( pid );
71 return pp ? Gaudi::ParticleProperties::index( pp, service ) : 0;
72}

◆ index() [2/2]

size_t Gaudi::ParticleProperties::index ( const Gaudi::ParticleProperty * property,
const Gaudi::Interfaces::IParticlePropertySvc * service )

helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential identifier

const Gaudi::ParticlePropertySvc* svc = ... ;
const Gaudi::ParticleProperty* pp = ... ;
size_t index = index ( pp , svc ) ;
if ( !index )
{
// error here: conversion is not possible
}

This appears to be useful operation, but since it is "pure technical" it does not appear as interface method.

For invalid/missing property and/or service 0 is returned. The valid result is always satisfy the condition: index <= service->size()

Parameters
propertythe property to be mapped
servicethe service
Returns
the sequential non-negative index
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 39 of file IParticlePropertySvc.cpp.

40 {
41 if ( !property || !service ) { return 0; }
42
43 auto first = service->begin();
44 auto last = service->end();
45 // start the binary_search
46 static constexpr auto cmp = Gaudi::ParticleProperty::Compare();
47 auto ifind = std::lower_bound( first, last, property, cmp );
48 return last != ifind && !cmp( *ifind, property ) ? ( ifind - first + 1 ) : 0;
49}
The comparison criteria for particle properties.

◆ particle()

const Gaudi::ParticleProperty * Gaudi::ParticleProperties::particle ( const size_t index,
const Gaudi::Interfaces::IParticlePropertySvc * service )

the inverse mapping of the integer sequential number onto Gaudi::ParticleID object

const Gaudi::ParticlePropertySvc* svc = ... ;
const size_t index = ...
const Gaudi::ParticleProperty* pp = particle ( index , svc ) ;
if ( !pp )
{
// error here: conversion is not possible
}
const Gaudi::ParticleProperty * particle(const size_t index, const Gaudi::Interfaces::IParticlePropertySvc *service)
the inverse mapping of the integer sequential number onto Gaudi::ParticleID object

This appears to be useful operation, but since it is "pure technical" it does not appear as interface method.

For invalid/missing PID and/or service NULL is returned.

Parameters
pidthe object to be mapped
servicethe service
Returns
the sequential non-negative index
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 90 of file IParticlePropertySvc.cpp.

90 {
91 if ( 0 == index || !service ) { return nullptr; }
92 // get the iterators from the service
93 auto first = service->begin();
94 auto last = service->end();
95 if ( index > (size_t)std::distance( first, last ) ) { return 0; }
96 std::advance( first, index - 1 );
97 return *first;
98}

◆ particleID()

const Gaudi::ParticleID Gaudi::ParticleProperties::particleID ( const size_t index,
const Gaudi::Interfaces::IParticlePropertySvc * service )

the inverse mapping of the integer sequential number onto Gaudi::ParticleID object

const Gaudi::ParticlePropertySvc* svc = ... ;
const size_t index = ...
const Gaudi::ParticleID pid = particleID ( index , svc ) ;
if ( Gaudi::ParticleID() == pid )
{
// error here: conversion is not possible
}
const Gaudi::ParticleID particleID(const size_t index, const Gaudi::Interfaces::IParticlePropertySvc *service)
the inverse mapping of the integer sequential number onto Gaudi::ParticleID object

This appears to be useful operation, but since it is "pure technical" it does not appear as interface method.

For invalid/missing index and/or service Gaudi::ParticleID() is returned.

Parameters
pidthe object to be mapped
servicethe service
Returns
the sequential non-negative index
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 117 of file IParticlePropertySvc.cpp.

117 {
118 if ( 0 == index || !service ) { return Gaudi::ParticleID(); }
120 return pp ? pp->particleID() : Gaudi::ParticleID();
121}

◆ printAsTable() [1/6]

template<class C_, class A_>
std::string Gaudi::ParticleProperties::printAsTable ( const std::set< Gaudi::ParticleID, C_, A_ > & particles,
const Gaudi::Interfaces::IParticlePropertySvc * service = 0 )
inline

Definition at line 376 of file ParticleProperty.h.

377 {
378 return printAsTable( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), service );
379 }
GAUDI_API std::string printAsTable(const std::vector< const Gaudi::ParticleProperty * > &particles, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
print a list of properties in a form of the table

◆ printAsTable() [2/6]

template<class C_, class A_>
MsgStream & Gaudi::ParticleProperties::printAsTable ( const std::set< Gaudi::ParticleID, C_, A_ > & particles,
MsgStream & stream,
const Gaudi::Interfaces::IParticlePropertySvc * service = 0 )
inline

Definition at line 394 of file ParticleProperty.h.

395 {
396 return printAsTable( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), stream, service );
397 }

◆ printAsTable() [3/6]

std::string Gaudi::ParticleProperties::printAsTable ( const std::vector< const Gaudi::ParticleProperty * > & particles,
const Gaudi::Interfaces::IParticlePropertySvc * service = 0 )

print a list of properties in a form of the table

const std::vector<const Gaudi::ParticleProperty*>& props = ... ;
std::cout << "Properties" << std::endl <<
Gaudi::ParticleProperties::printAsTable ( props , svc ) << std::endl

The utility is easy to use in conjunction with Gaudi::ParticleProperties:;get utilities: e.g. get all leptons from the service and print them as table:

#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
typedef std::vector<const Gaudi::IParticleProperty*> Vector ;
// create the output vector:
Vector leptons ;
// use the function
( svc ,
// create the predicate:
boost::lambda::bind ( &Gaudi::ParticleID::isLepton ,
boost::lambda::bind ( &Gaudi::ParticleProperty::particleID , boost::lambda::_1 ) ) ,
std::back_inserter ( leptons ) ) ; // output
// print the leptons:
std::cout << "LEPTONS"
<< std::endl
<< std::endl ;
See also
Gaudi::ParticleProperty
Gaudi::Interfaces::IParticlePropertySvc
Gaudi::ParticleProperties::get
Parameters
particlesthe list of particle properties
servicethe service to extract global information
Returns
the string output
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 319 of file ParticleProperty.cpp.

320 {
321 std::ostringstream s;
322 printAsTable_( particles, s, service );
323 return s.str();
324}
GAUDI_API std::ostream & printAsTable_(const std::vector< const Gaudi::ParticleProperty * > &particles, std::ostream &stream, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
print a list of properties in a form of the table

◆ printAsTable() [4/6]

MsgStream & Gaudi::ParticleProperties::printAsTable ( const std::vector< const Gaudi::ParticleProperty * > & particles,
MsgStream & stream,
const Gaudi::Interfaces::IParticlePropertySvc * service = 0 )

print a list of properties in a form of the table

const std::vector<const Gaudi::ParticleProperty*>& props = ... ;
MsgStream& log = ... ;
log << endmsg ;
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
Definition of the MsgStream class used to transmit messages.
Definition MsgStream.h:29

The utility is easy to use in conjunction with Gaudi::ParticleProperties:;get utilities: e.g. get all leptons from the service and print them as table:

#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
typedef std::vector<const Gaudi::IParticleProperty*> Vector ;
// create the output vector:
Vector leptons ;
// use the function
( svc ,
// create the predicate:
boost::lambda::bind ( &Gaudi::ParticleID::isLepton ,
boost::lambda::bind ( &Gaudi::ParticleProperty::particleID , boost::lambda::_1 ) ) ,
std::back_inserter ( leptons ) ) ; // output
// print the leptons:
MsgStream& log = ... ;
log << "LEPTONS" << std::endl ;
Gaudi::ParticleProperties::printAsTable ( leptons , log , svc ) ;
log << endmsg ;
See also
Gaudi::ParticleProperty
Gaudi::Interfaces::IParticlePropertySvc
Gaudi::ParticleProperties::get
Parameters
particlesthe list of particle properties
streamthe reference to the output stream
servicethe service to extract global information
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 333 of file ParticleProperty.cpp.

335 {
336 if ( stream.isActive() ) { printAsTable_( particles, stream.stream(), service ); }
337 return stream;
338}

◆ printAsTable() [5/6]

std::string Gaudi::ParticleProperties::printAsTable ( const std::vector< Gaudi::ParticleID > & particles,
const Gaudi::Interfaces::IParticlePropertySvc * service = 0 )

print properties in a form of the table

Parameters
particles(INPUT) list of particles
service(INPUT) pointer to particle property service
Returns
string-representation
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru
Date
2010-01-04

Definition at line 393 of file ParticleProperty.cpp.

394 {
395 std::ostringstream s;
396 printAsTable_( particles, s, service );
397 return s.str();
398}

◆ printAsTable() [6/6]

MsgStream & Gaudi::ParticleProperties::printAsTable ( const std::vector< Gaudi::ParticleID > & particles,
MsgStream & stream,
const Gaudi::Interfaces::IParticlePropertySvc * service = 0 )

print properties in a form of the table

Parameters
particles(INPUT) list of particles
stream(UPDATE) the stream
service(INPUT) pointer to particle property service
Returns
the stream
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru
Date
2010-01-04

Definition at line 381 of file ParticleProperty.cpp.

382 {
383 if ( stream.isActive() ) { printAsTable_( particles, stream.stream(), service ); }
384 return stream;
385}

◆ printAsTable_() [1/3]

template<class C_, class A_>
std::ostream & Gaudi::ParticleProperties::printAsTable_ ( const std::set< Gaudi::ParticleID, C_, A_ > & particles,
std::ostream & stream,
const Gaudi::Interfaces::IParticlePropertySvc * service = 0 )
inline

Definition at line 359 of file ParticleProperty.h.

360 {
361 return printAsTable_( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), stream, service );
362 }

◆ printAsTable_() [2/3]

std::ostream & Gaudi::ParticleProperties::printAsTable_ ( const std::vector< const Gaudi::ParticleProperty * > & particles,
std::ostream & stream,
const Gaudi::Interfaces::IParticlePropertySvc * service = 0 )

print a list of properties in a form of the table

const std::vector<const Gaudi::ParticleProperty*>& props = ... ;
std::cout << "Properties" << std::endl ;
Gaudi::ParticleProperties::printAsTable ( props , std::cout , svc ) ;

The utility is easy to use in conjunction with Gaudi::ParticleProperties:;get utilities: e.g. get all leptons from the service and print them as table:

#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
typedef std::vector<const Gaudi::IParticleProperty*> Vector ;
// create the output vector:
Vector leptons ;
// use the function
( svc ,
// create the predicate:
boost::lambda::bind ( &Gaudi::ParticleID::isLepton ,
boost::lambda::bind ( &Gaudi::ParticleProperty::particleID , boost::lambda::_1 ) ) ,
std::back_inserter ( leptons ) ) ; // output
// print the leptons:
std::cout << "LEPTONS" << std::endl ;
Gaudi::ParticleProperties::printAsTable_ ( leptons , std::cout , svc ) ;
See also
Gaudi::ParticleProperty
Gaudi::Interfaces::IParticlePropertySvc
Gaudi::ParticleProperties::get
Parameters
particlesthe list of particle properties
streamthe reference to the output stream
servicethe service to extract global information
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2008-08-03

Definition at line 173 of file ParticleProperty.cpp.

175 {
176 std::string fmt, hdr;
177 //
178 if ( 0 != service ) {
179 fmt += " | %|-4.4s| "; // index
180 hdr += " | %|-4.4s| "; // index
181 }
182 //
183 fmt += "| %|-18.18s|"; // the name
184 fmt += "| %|12d| "; // PDGID
185 fmt += "| %|=4s| "; // charge
186 fmt += "| %|13.8g|"; // mass
187 fmt += " %|-3s| "; // unit
188 fmt += "| %|13.8g|"; // lifetime/gamma/ctau
189 fmt += " %|-3s| "; // unit
190 fmt += "| %|=10.4g| "; // maxwidth
191 fmt += "| %|=20.20s|"; // evtgen name
192 fmt += " | %|=10d| |"; // pythia ID
193 fmt += " %|=20.20d| |"; // antiparticle
194 //
195 hdr += "| %|=18.18s|"; // the name
196 hdr += "| %|=12.12s| "; // PDGID
197 hdr += "| %|=4.4s| "; // charge
198 hdr += "| %|=18.18s|"; // mass
199 // hdr += "%|=5.5s|" ; // unit
200 hdr += "| %|=18.18s|"; // lifetime/gamma/ctau
201 // hdr += "%|=5.5s|" ; // unit
202 hdr += "| %|=10.10g| "; // maxwidth
203 hdr += "| %|=20.20s|"; // evtgen name
204 hdr += " | %|=10.10s| |"; // pythia ID
205 hdr += " %|=20.20d| |"; // antiparticle
206
207 boost::format header( hdr );
208 header.exceptions( boost::io::all_error_bits ^ ( boost::io::too_many_args_bit | boost::io::too_few_args_bit ) );
209
210 if ( service ) { header % "#"; }
211 header % "Name" % "PdgID" % "Q" % "Mass" % "(c*)Tau/Gamma" % "MaxWidth" % "EvtGen" % "PythiaID" % "Antiparticle";
212
213 const std::string hdrLine = header.str();
214 const std::string dashes = " " + std::string( hdrLine.size() - 1, '-' );
215 stream << dashes << std::endl << hdrLine << std::endl << dashes << std::endl;
216
217 for ( auto ip = particles.begin(); particles.end() != ip; ++ip ) {
218 const Gaudi::ParticleProperty* pp = *ip;
219 if ( 0 == pp ) { continue; }
220 boost::format line( fmt );
221 line.exceptions( boost::io::all_error_bits ^ ( boost::io::too_many_args_bit | boost::io::too_few_args_bit ) );
222 //
223 if ( 0 != service ) {
224 size_t index = Gaudi::ParticleProperties::index( pp, service );
225 if ( 0 == index ) {
226 line % "?";
227 } else {
228 line % index;
229 }
230 }
231 //
232 line % pp->name() // name
233 % pp->particleID().pid(); // PDG-ID
234 //
235#ifdef __INTEL_COMPILER // Disable ICC remark
236# pragma warning( disable : 1572 ) // Floating-point equality and inequality comparisons are unreliable
237# pragma warning( push )
238#endif
239 if ( 0 == pp->charge() ) {
240 line % "0";
241 } else if ( 0.3 == pp->charge() ) {
242 line % "+1/3";
243 } else if ( -0.3 == pp->charge() ) {
244 line % "-1/3";
245 } else if ( 0.7 == pp->charge() ) {
246 line % "+2/3";
247 } else if ( -0.7 == pp->charge() ) {
248 line % "-2/3";
249 } else {
250 line % pp->charge();
251 }
252#ifdef __INTEL_COMPILER // Re-enable ICC remark
253# pragma warning( pop )
254#endif
255 //
256 // mass
257 if ( pp->mass() < 1 * Gaudi::Units::keV ) {
258 line % ( pp->mass() / Gaudi::Units::eV ) % "eV";
259 } else if ( pp->mass() < 1 * Gaudi::Units::MeV ) {
260 line % ( pp->mass() / Gaudi::Units::keV ) % "keV";
261 } else if ( pp->mass() < 1 * Gaudi::Units::GeV ) {
262 line % ( pp->mass() / Gaudi::Units::MeV ) % "MeV";
263 } else if ( pp->mass() < 1 * Gaudi::Units::TeV ) {
264 line % ( pp->mass() / Gaudi::Units::GeV ) % "GeV";
265 } else {
266 line % ( pp->mass() / Gaudi::Units::TeV ) % "TeV";
267 }
268 // lifetime/width/ctau
269 const double ctau = pp->ctau();
270 const double width = pp->width();
271 const double ltime = pp->lifetime();
272 if ( 3600 * Gaudi::Units::second < ltime ) {
273 line % "stable" % "";
274 } else if ( 1 * Gaudi::Units::second < ltime ) {
275 line % ( ltime / Gaudi::Units::second ) % "s";
276 } else if ( 1 * Gaudi::Units::meter < ctau ) {
277 line % ( ctau / Gaudi::Units::meter ) % "m";
278 } else if ( 1 * Gaudi::Units::cm < ctau ) {
279 line % ( ctau / Gaudi::Units::cm ) % "cm";
280 } else if ( 0.5 * Gaudi::Units::mm < ctau ) {
281 line % ( ctau / Gaudi::Units::mm ) % "mm";
282 } else if ( 0.1 * Gaudi::Units::micrometer < ctau ) {
283 line % ( ctau / Gaudi::Units::micrometer ) % "um";
284 } else if ( 1 * Gaudi::Units::GeV < width ) {
285 line % ( width / Gaudi::Units::GeV ) % "GeV";
286 } else if ( 1 * Gaudi::Units::MeV < width ) {
287 line % ( width / Gaudi::Units::MeV ) % "MeV";
288 } else if ( 1 * Gaudi::Units::keV < width ) {
289 line % ( width / Gaudi::Units::keV ) % "keV";
290 } else if ( 1 * Gaudi::Units::eV < width ) {
291 line % ( width / Gaudi::Units::eV ) % "eV";
292 } else {
293 line % ( ltime / Gaudi::Units::ns ) % "ns";
294 }
295 //
296 line % pp->maxWidth() % pp->evtGen() % pp->pythia();
297 //
298 const Gaudi::ParticleProperty* const anti = pp->antiParticle();
299 //
300 if ( 0 == anti ) {
301 line % "-";
302 } else if ( anti == pp ) {
303 line % "self-cc";
304 } else {
305 line % anti->name();
306 }
307 //
308 stream << line << std::endl;
309 }
310 return stream << dashes << std::endl;
311}
const std::string & name() const
Get the particle name.
constexpr double TeV
constexpr double eV
constexpr double micrometer
constexpr double second
constexpr double MeV
constexpr double meter
constexpr double keV
constexpr double mm
constexpr double cm
constexpr double ns
constexpr double GeV
stream
Definition Write.py:32

◆ printAsTable_() [3/3]

std::ostream & Gaudi::ParticleProperties::printAsTable_ ( const std::vector< Gaudi::ParticleID > & particles,
std::ostream & stream,
const Gaudi::Interfaces::IParticlePropertySvc * service = 0 )

print properties in a form of the table

Parameters
particles(INPUT) list of particles
stream(UPDATE) the stream
service(INPUT) pointer to particle property service
Returns
the stream
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru
Date
2010-01-04

Definition at line 358 of file ParticleProperty.cpp.

360 {
361 //
362 if ( 0 == service ) { return Gaudi::Utils::toStream( particles, stream ); }
363
364 // convert list of ParticleIDs to list fo Particle properties:
365 std::vector<const Gaudi::ParticleProperty*> props;
366 for ( std::vector<Gaudi::ParticleID>::const_iterator ipid = particles.begin(); particles.end() != ipid; ++ipid ) {
367 const Gaudi::ParticleProperty* pp = service->find( *ipid );
368 if ( 0 == pp ) { continue; }
369 props.push_back( pp );
370 }
371 return printAsTable_( props, stream, service );
372}
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition ToStream.h:304