|
|
|||
File indexing completed on 2025-12-15 10:14:15
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 #pragma once 0012 0013 #include <Gaudi/ParticleID.h> 0014 #include <GaudiKernel/Kernel.h> 0015 #include <GaudiKernel/PhysicalConstants.h> 0016 #include <cmath> 0017 #include <functional> 0018 #include <iosfwd> 0019 #include <limits> 0020 #include <set> 0021 #include <string> 0022 #include <vector> 0023 0024 namespace Gaudi { 0025 namespace Interfaces { 0026 class IParticlePropertySvc; 0027 } 0028 0029 /** @class ParticleProperty ParticleProperty.h Gaudi/ParticleProperty.h 0030 * 0031 * A trivial class to hold information about a single particle properties. 0032 * All particle properties are accessible through accessor functions 0033 * 0034 * @author Iain Last,G.Corti 0035 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0036 */ 0037 class GAUDI_API ParticleProperty final { 0038 public: 0039 /** @struct Compare 0040 * The comparison criteria for particle properties 0041 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0042 * @date 2008-10-14 0043 */ 0044 struct Compare { 0045 inline bool operator()( const ParticleProperty* p1, const ParticleProperty* p2 ) const { 0046 return p1 == p2 ? false : 0 == p1 ? true : 0 == p2 ? false : ( *p1 < *p2 ); 0047 } 0048 }; 0049 0050 /** full constructor, from all data (except the antiparticle ) 0051 * @param name the name for the particle 0052 * @param pid the PID for the particle 0053 * @param charge the charge of the particle 0054 * @param mass the nominal mass of the particle 0055 * @param tlife the nominal lifetime of the particle 0056 * @param maxWidth the maximal width of the particle (used in generator) 0057 * @param evtgen the name of particle in EvtGen program 0058 * @param pythia the ID for the particle used in Pythia generator 0059 */ 0060 ParticleProperty( const std::string& name, const Gaudi::ParticleID& pid, const double charge, const double mass, 0061 const double tlife, const double maxWidth, const std::string& evtgen, const int pythia ); 0062 /** a bit simplified constructor, from all data (except the antiparticle ) 0063 * 0064 * - "evtGenName" is set from the regular "name" 0065 * - pythiaID is set from the regular PID 0066 * 0067 * @param name the name for the particle 0068 * @param pid the PID for the particle 0069 * @param charge the charge of the particle 0070 * @param mass the nominal mass of the particle 0071 * @param tlife the nominal lifetime of the particle 0072 * @param maxWidth the maximal width of the particle (used in generator) 0073 */ 0074 ParticleProperty( const std::string& name, const Gaudi::ParticleID& pid, const double charge, const double mass, 0075 const double tlife, const double maxWidth ); 0076 0077 /// Get the particle name. 0078 const std::string& particle() const { return m_name; } 0079 /// Get the particle name. 0080 const std::string& name() const { return m_name; } 0081 /// get the particle ID 0082 const Gaudi::ParticleID& particleID() const { return m_pid; } 0083 /// get the particle ID 0084 const Gaudi::ParticleID& pdgID() const { return m_pid; } 0085 /// get the particle ID 0086 const Gaudi::ParticleID& pid() const { return m_pid; } 0087 /// Get the particle charge. 0088 double charge() const { return m_charge; } 0089 /// Get the particle mass. 0090 double mass() const { return m_mass; } 0091 /// Get the particle lifetime. 0092 double lifetime() const { return m_tlife; } 0093 /// Get the particle lifetime. 0094 double lifeTime() const { return m_tlife; } 0095 /// Get the particle proper lifetime in c*tau units 0096 double ctau() const { return Gaudi::Units::c_light * lifeTime(); } 0097 /// Get the particle natural width 0098 double width() const { 0099 return std::abs( ctau() ) < std::numeric_limits<double>::epsilon() ? 0.0 : Gaudi::Units::hbarc / ctau(); 0100 } 0101 /// Get the max width deviation 0102 double maxWidth() const { return m_maxWidth; } // max-width 0103 /// get the pointer to the anti-particle 0104 const Gaudi::ParticleProperty* antiParticle() const { return anti(); } 0105 /// get the pointer to the anti-particle 0106 const Gaudi::ParticleProperty* anti() const { return m_anti; } 0107 0108 /// self-charge conjugated? 0109 bool selfcc() const { return m_anti == this; } 0110 0111 /// Three times the charge (in positron charge units) 0112 int threeCharge() const { return m_pid.threeCharge(); } 0113 0114 /** set the pointer to the antiparticle 0115 * @attention it is the only one "setter" 0116 * @param p pointer to anti-particle 0117 */ 0118 void setAntiParticle( const ParticleProperty* p ); 0119 0120 /// Get the EvtGen name 0121 const std::string& evtGenName() const { return m_evtgen; } 0122 /// Get the EvtGen name 0123 const std::string& evtGen() const { return m_evtgen; } 0124 /// Get the Pythia ID 0125 int pythiaID() const { return m_pythia; } 0126 /// Get the Pythia ID 0127 int pythia() const { return m_pythia; } 0128 0129 /// comparison/ordering operator ( "strict-less-by-PID&Name" ) 0130 friend bool operator<( const ParticleProperty& lhs, const ParticleProperty& rhs ) { 0131 return std::tie( lhs.m_pid, lhs.m_name ) < std::tie( rhs.m_pid, rhs.m_name ); 0132 } 0133 0134 /// implicit conversion to ParticleID class 0135 operator const Gaudi::ParticleID&() const { return m_pid; } 0136 0137 /** the standard (a'la Gaudi) printout of the object 0138 * @param s reference to the output stream 0139 * @return reference to the output stream 0140 */ 0141 std::ostream& fillStream( std::ostream& s ) const; 0142 /// simple method for conversion into the string 0143 std::string toString() const; 0144 0145 private: 0146 /// the name for the particle 0147 std::string m_name; 0148 /// the PID for the particle 0149 Gaudi::ParticleID m_pid; 0150 /// the charge for the particle 0151 double m_charge; 0152 /// the nominal mass for the particle 0153 double m_mass; 0154 /// the nominal proper lifetime for the particle 0155 double m_tlife; 0156 /// The maximum width deviation 0157 double m_maxWidth; 0158 /// the name of the particle for EvtGen program 0159 std::string m_evtgen; 0160 /// the ID for the particle used in Pythia generator 0161 int m_pythia; 0162 /// the pointer to the anti-particle 0163 const Gaudi::ParticleProperty* m_anti; 0164 }; 0165 } // namespace Gaudi 0166 0167 /** standard output operator to the stream 0168 * @param stream the stream 0169 * @param pp the particle property object 0170 * @return the stream 0171 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0172 * @date 2008-08-03 0173 */ 0174 std::ostream& operator<<( std::ostream& stream, const Gaudi::ParticleProperty& pp ); 0175 0176 class MsgStream; 0177 namespace Gaudi { 0178 namespace ParticleProperties { 0179 /** print a list of properties in a form of the table 0180 * 0181 * @code 0182 * 0183 * Gaudi::Interfaces::IParticlePropertySvc* svc = ... ; 0184 * 0185 * const std::vector<const Gaudi::ParticleProperty*>& props = ... ; 0186 * 0187 * std::cout << "Properties" << std::endl ; 0188 * Gaudi::ParticleProperties::printAsTable ( props , std::cout , svc ) ; 0189 * 0190 * @endcode 0191 * 0192 * The utility is easy to use in conjunction with 0193 * Gaudi::ParticleProperties:;get utilities: 0194 * e.g. get all leptons from the service and print them as table: 0195 * 0196 * @code 0197 * 0198 * #include "boost/lambda/lambda.hpp" 0199 * #include "boost/lambda/bind.hpp" 0200 * 0201 * typedef std::vector<const Gaudi::IParticleProperty*> Vector ; 0202 * const Gaudi::Interfaces::IParticlePropertySvc* svc = ... ; 0203 * 0204 * // create the output vector: 0205 * Vector leptons ; 0206 * // use the function 0207 * Gaudi::ParticleProperties::get 0208 * ( svc , 0209 * // create the predicate: 0210 * boost::lambda::bind ( &Gaudi::ParticleID::isLepton , 0211 * boost::lambda::bind ( &Gaudi::ParticleProperty::particleID , boost::lambda::_1 ) ) , 0212 * std::back_inserter ( leptons ) ) ; // output 0213 * 0214 * // print the leptons: 0215 * std::cout << "LEPTONS" << std::endl ; 0216 * Gaudi::ParticleProperties::printAsTable_ ( leptons , std::cout , svc ) ; 0217 * 0218 * @endcode 0219 * 0220 * @see Gaudi::ParticleProperty 0221 * @see Gaudi::Interfaces::IParticlePropertySvc 0222 * @see Gaudi::ParticleProperties::get 0223 * @param particles the list of particle properties 0224 * @param stream the reference to the output stream 0225 * @param service the service to extract global information 0226 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0227 * @date 2008-08-03 0228 */ 0229 GAUDI_API 0230 std::ostream& printAsTable_( const std::vector<const Gaudi::ParticleProperty*>& particles, std::ostream& stream, 0231 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ); 0232 0233 /** print a list of properties in a form of the table 0234 * 0235 * @code 0236 * 0237 * Gaudi::Interfaces::IParticlePropertySvc* svc = ... ; 0238 * 0239 * const std::vector<const Gaudi::ParticleProperty*>& props = ... ; 0240 * 0241 * std::cout << "Properties" << std::endl << 0242 * Gaudi::ParticleProperties::printAsTable ( props , svc ) << std::endl 0243 * 0244 * @endcode 0245 * 0246 * The utility is easy to use in conjunction with 0247 * Gaudi::ParticleProperties:;get utilities: 0248 * e.g. get all leptons from the service and print them as table: 0249 * 0250 * @code 0251 * 0252 * #include "boost/lambda/lambda.hpp" 0253 * #include "boost/lambda/bind.hpp" 0254 * 0255 * typedef std::vector<const Gaudi::IParticleProperty*> Vector ; 0256 * const Gaudi::Interfaces::IParticlePropertySvc* svc = ... ; 0257 * 0258 * // create the output vector: 0259 * Vector leptons ; 0260 * // use the function 0261 * Gaudi::ParticleProperties::get 0262 * ( svc , 0263 * // create the predicate: 0264 * boost::lambda::bind ( &Gaudi::ParticleID::isLepton , 0265 * boost::lambda::bind ( &Gaudi::ParticleProperty::particleID , boost::lambda::_1 ) ) , 0266 * std::back_inserter ( leptons ) ) ; // output 0267 * 0268 * // print the leptons: 0269 * std::cout << "LEPTONS" 0270 * << std::endl 0271 * Gaudi::ParticleProperties::printAsTable ( leptons , svc ) 0272 * << std::endl ; 0273 * 0274 * @endcode 0275 * 0276 * @see Gaudi::ParticleProperty 0277 * @see Gaudi::Interfaces::IParticlePropertySvc 0278 * @see Gaudi::ParticleProperties::get 0279 * @param particles the list of particle properties 0280 * @param service the service to extract global information 0281 * @return the string output 0282 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0283 * @date 2008-08-03 0284 */ 0285 GAUDI_API 0286 std::string printAsTable( const std::vector<const Gaudi::ParticleProperty*>& particles, 0287 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ); 0288 0289 /** print a list of properties in a form of the table 0290 * 0291 * @code 0292 * 0293 * Gaudi::Interfaces::IParticlePropertySvc* svc = ... ; 0294 * 0295 * const std::vector<const Gaudi::ParticleProperty*>& props = ... ; 0296 * 0297 * MsgStream& log = ... ; 0298 * Gaudi::ParticleProperties::printAsTable ( props , log , svc ) ; 0299 * log << endmsg ; 0300 * 0301 * @endcode 0302 * 0303 * The utility is easy to use in conjunction with 0304 * Gaudi::ParticleProperties:;get utilities: 0305 * e.g. get all leptons from the service and print them as table: 0306 * 0307 * @code 0308 * 0309 * #include "boost/lambda/lambda.hpp" 0310 * #include "boost/lambda/bind.hpp" 0311 * 0312 * typedef std::vector<const Gaudi::IParticleProperty*> Vector ; 0313 * const Gaudi::Interfaces::IParticlePropertySvc* svc = ... ; 0314 * 0315 * // create the output vector: 0316 * Vector leptons ; 0317 * // use the function 0318 * Gaudi::ParticleProperties::get 0319 * ( svc , 0320 * // create the predicate: 0321 * boost::lambda::bind ( &Gaudi::ParticleID::isLepton , 0322 * boost::lambda::bind ( &Gaudi::ParticleProperty::particleID , boost::lambda::_1 ) ) , 0323 * std::back_inserter ( leptons ) ) ; // output 0324 * 0325 * // print the leptons: 0326 * MsgStream& log = ... ; 0327 * log << "LEPTONS" << std::endl ; 0328 * Gaudi::ParticleProperties::printAsTable ( leptons , log , svc ) ; 0329 * log << endmsg ; 0330 * 0331 * @endcode 0332 * 0333 * @see Gaudi::ParticleProperty 0334 * @see Gaudi::Interfaces::IParticlePropertySvc 0335 * @see Gaudi::ParticleProperties::get 0336 * @param particles the list of particle properties 0337 * @param stream the reference to the output stream 0338 * @param service the service to extract global information 0339 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0340 * @date 2008-08-03 0341 */ 0342 GAUDI_API 0343 MsgStream& printAsTable( const std::vector<const Gaudi::ParticleProperty*>& particles, MsgStream& stream, 0344 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ); 0345 0346 /** print properties in a form of the table 0347 * @param particles (INPUT) list of particles 0348 * @param stream (UPDATE) the stream 0349 * @param service (INPUT) pointer to particle property service 0350 * @return the stream 0351 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 0352 * @date 2010-01-04 0353 */ 0354 GAUDI_API 0355 std::ostream& printAsTable_( const std::vector<Gaudi::ParticleID>& particles, std::ostream& stream, 0356 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ); 0357 0358 template <class C_, class A_> 0359 inline std::ostream& printAsTable_( const std::set<Gaudi::ParticleID, C_, A_>& particles, std::ostream& stream, 0360 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ) { 0361 return printAsTable_( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), stream, service ); 0362 } 0363 0364 /** print properties in a form of the table 0365 * @param particles (INPUT) list of particles 0366 * @param service (INPUT) pointer to particle property service 0367 * @return string-representation 0368 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 0369 * @date 2010-01-04 0370 */ 0371 GAUDI_API 0372 std::string printAsTable( const std::vector<Gaudi::ParticleID>& particles, 0373 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ); 0374 0375 template <class C_, class A_> 0376 inline std::string printAsTable( const std::set<Gaudi::ParticleID, C_, A_>& particles, 0377 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ) { 0378 return printAsTable( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), service ); 0379 } 0380 0381 /** print properties in a form of the table 0382 * @param particles (INPUT) list of particles 0383 * @param stream (UPDATE) the stream 0384 * @param service (INPUT) pointer to particle property service 0385 * @return the stream 0386 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 0387 * @date 2010-01-04 0388 */ 0389 GAUDI_API 0390 MsgStream& printAsTable( const std::vector<Gaudi::ParticleID>& particles, MsgStream& stream, 0391 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ); 0392 0393 template <class C_, class A_> 0394 inline MsgStream& printAsTable( const std::set<Gaudi::ParticleID, C_, A_>& particles, MsgStream& stream, 0395 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ) { 0396 return printAsTable( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), stream, service ); 0397 } 0398 } // namespace ParticleProperties 0399 } // namespace Gaudi 0400 namespace Gaudi { 0401 namespace Utils { 0402 /** print a list of particle properties as formatted table 0403 * @see Gaudi::ParticleProperty 0404 * @param particles the list of particle properties 0405 * @param stream the reference to the output stream 0406 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0407 * @date 2008-08-03 0408 */ 0409 GAUDI_API 0410 std::ostream& toStream( const std::vector<const Gaudi::ParticleProperty*>& particles, std::ostream& stream ); 0411 } // namespace Utils 0412 } // namespace Gaudi 0413 namespace std { 0414 GAUDI_API 0415 const Gaudi::ParticleProperty* abs( const Gaudi::ParticleProperty* p ); 0416 } // namespace std
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|