The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::Decays::Nodes::CTau Class Reference

simple pid-checker for particle lifetime (in c*tau units) More...

#include </builds/gaudi/Gaudi/GaudiPartProp/include/Gaudi/Decays/NodesPIDs.h>

Inheritance diagram for Gaudi::Decays::Nodes::CTau:
Collaboration diagram for Gaudi::Decays::Nodes::CTau:

Classes

struct  KnownPids

Public Member Functions

 CTau (const double low, const double high, const Gaudi::Interfaces::IParticlePropertySvc *svc=nullptr)
 constructor from c-tau range
CTau * clone () const override
 MANDATORY: clone method ("virtual constructor").
bool operator() (const Gaudi::ParticleID &pid) const override
 MANDATORY: the only one essential method.
std::ostream & fillStream (std::ostream &s) const override
 MANDATORY: the specific printout.
bool valid () const override
 MANDATORY: check the validity.
StatusCode validate (const Gaudi::Interfaces::IParticlePropertySvc *svc) const override
 MANDATORY: the proper validation of the node.
const Gaudi::Interfaces::IParticlePropertySvc * ppSvc () const
double low () const
 get low edge
double high () const
 get high edge
StatusCode setService (const Gaudi::Interfaces::IParticlePropertySvc *svc) const
MsgStream & printAcceptedAsTable (MsgStream &s) const
Public Member Functions inherited from Gaudi::Decays::iNode
virtual bool operator! () const
 invalid node?
virtual std::string toString () const
 the string representation of the node
virtual ~iNode ()=default
 virtual destructor

Protected Member Functions

template<typename F, typename = std::is_invocable_r<bool, F, Gaudi::ParticleID>>
bool classify (Gaudi::ParticleID pid, F &&f) const

Private Types

typedef SmartIF< Gaudi::Interfaces::IParticlePropertySvc > Service

Private Member Functions

bool add_ (Gaudi::ParticleID pid, bool acc) const

Private Attributes

Service m_ppSvc
 the service :
Gaudi::cxx::SynchronizedValue< KnownPids > m_pids
double m_low
 low edge
double m_high
 high edge

Detailed Description

simple pid-checker for particle lifetime (in c*tau units)

Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl
Date
2009-05-11

Definition at line 406 of file NodesPIDs.h.

Member Typedef Documentation

◆ Service

Constructor & Destructor Documentation

◆ CTau()

Gaudi::Decays::Nodes::CTau::CTau ( const double low,
const double high,
const Gaudi::Interfaces::IParticlePropertySvc * svc = nullptr )

constructor from c-tau range

Definition at line 266 of file NodePIDs.cpp.

267 : m_low( low ), m_high( high ) {
268 if ( svc ) { m_ppSvc = const_cast<Gaudi::Interfaces::IParticlePropertySvc*>( svc ); }
269}
double low() const
get low edge
Definition NodesPIDs.h:425
double high() const
get high edge
Definition NodesPIDs.h:427
double m_high
high edge
Definition NodesPIDs.h:482
Service m_ppSvc
the service :
Definition NodesPIDs.h:468

Member Function Documentation

◆ add_()

bool Gaudi::Decays::Nodes::CTau::add_ ( Gaudi::ParticleID pid,
bool acc ) const
private

Definition at line 295 of file NodePIDs.cpp.

295 {
296 return m_pids.with_lock(
297 []( KnownPids& pids, Gaudi::ParticleID pid, bool acc ) {
298 auto& c = ( acc ? pids.accepted : pids.rejected );
299 auto ifind = std::lower_bound( c.begin(), c.end(), pid );
300 if ( c.end() == ifind || pid < ( *ifind ) ) { c.insert( ifind, pid ); }
301 return acc;
302 },
303 pid, acc );
304}
Gaudi::cxx::SynchronizedValue< KnownPids > m_pids
Definition NodesPIDs.h:477

◆ classify()

template<typename F, typename = std::is_invocable_r<bool, F, Gaudi::ParticleID>>
bool Gaudi::Decays::Nodes::CTau::classify ( Gaudi::ParticleID pid,
F && f ) const
inlineprotected

Definition at line 433 of file NodesPIDs.h.

433 {
434 enum struct Classification { Accepted = +1, Rejected = -1, Unknown = 0 };
435 auto r = m_pids.with_lock(
436 []( const auto& pids, Gaudi::ParticleID pid ) {
437 return std::binary_search( pids.accepted.begin(), pids.accepted.end(), pid ) ? Classification::Accepted
438 : std::binary_search( pids.rejected.begin(), pids.rejected.end(), pid ) ? Classification::Rejected
439 : Classification::Unknown;
440 },
441 pid );
442 switch ( r ) {
443 case Classification::Accepted:
444 return true;
445 case Classification::Rejected:
446 return false;
447 case Classification::Unknown:
448 return add_( pid, std::invoke( std::forward<F>( f ), pid ) );
449 }
450 __builtin_unreachable();
451 }
bool add_(Gaudi::ParticleID pid, bool acc) const
Definition NodePIDs.cpp:295

◆ clone()

Decays::Nodes::CTau * Gaudi::Decays::Nodes::CTau::clone ( ) const
overridevirtual

MANDATORY: clone method ("virtual constructor").

Implements Gaudi::Decays::iNode.

Reimplemented in Gaudi::Decays::Nodes::Heavy, Gaudi::Decays::Nodes::Light, Gaudi::Decays::Nodes::LongLived_, Gaudi::Decays::Nodes::Mass, Gaudi::Decays::Nodes::ShortLived_, Gaudi::Decays::Nodes::Stable, and Gaudi::Decays::Nodes::StableCharged.

Definition at line 271 of file NodePIDs.cpp.

271{ return new CTau( *this ); }
CTau(const double low, const double high, const Gaudi::Interfaces::IParticlePropertySvc *svc=nullptr)
constructor from c-tau range
Definition NodePIDs.cpp:266

◆ fillStream()

std::ostream & Gaudi::Decays::Nodes::CTau::fillStream ( std::ostream & s) const
overridevirtual

MANDATORY: the specific printout.

Implements Gaudi::Decays::iNode.

Reimplemented in Gaudi::Decays::Nodes::Heavy, Gaudi::Decays::Nodes::Light, Gaudi::Decays::Nodes::LongLived_, Gaudi::Decays::Nodes::Mass, Gaudi::Decays::Nodes::ShortLived_, Gaudi::Decays::Nodes::Stable, and Gaudi::Decays::Nodes::StableCharged.

Definition at line 273 of file NodePIDs.cpp.

273 {
274 return s << " CTau(" << low() << "," << high() << ") ";
275}

◆ high()

double Gaudi::Decays::Nodes::CTau::high ( ) const
inline

get high edge

Definition at line 427 of file NodesPIDs.h.

427{ return m_high; }

◆ low()

double Gaudi::Decays::Nodes::CTau::low ( ) const
inline

get low edge

Definition at line 425 of file NodesPIDs.h.

425{ return m_low; }

◆ operator()()

bool Gaudi::Decays::Nodes::CTau::operator() ( const Gaudi::ParticleID & pid) const
overridevirtual

MANDATORY: the only one essential method.

Implements Gaudi::Decays::iNode.

Reimplemented in Gaudi::Decays::Nodes::Mass, and Gaudi::Decays::Nodes::StableCharged.

Definition at line 283 of file NodePIDs.cpp.

283 {
284 return classify( pid, [&]( Gaudi::ParticleID id ) {
285 // invalid node
286 if ( !ppSvc() ) { return false; } // REJECT for invalid service
287 // use the service
288 const Gaudi::ParticleProperty* pp = ppSvc()->find( id );
289 if ( !pp ) { return false; } // REJECT for invalid dparticle
290 // final decision: check ctau range
291 const auto ctau = pp->ctau();
292 return low() <= ctau && ctau <= high();
293 } );
294}
const Gaudi::Interfaces::IParticlePropertySvc * ppSvc() const
Definition NodesPIDs.h:422
bool classify(Gaudi::ParticleID pid, F &&f) const
Definition NodesPIDs.h:433
virtual const ParticleProperty * find(const std::string &name) const =0
Retrieve an object by name:

◆ ppSvc()

const Gaudi::Interfaces::IParticlePropertySvc * Gaudi::Decays::Nodes::CTau::ppSvc ( ) const
inline

Definition at line 422 of file NodesPIDs.h.

422{ return m_ppSvc; }

◆ printAcceptedAsTable()

MsgStream & Gaudi::Decays::Nodes::CTau::printAcceptedAsTable ( MsgStream & s) const
inline

Definition at line 457 of file NodesPIDs.h.

457 {
458 return m_pids.with_lock(
459 [&]( const KnownPids& pids, MsgStream& s, auto const& ppSvc ) -> decltype( auto ) {
461 },
462 s, m_ppSvc );
463 }
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

◆ setService()

StatusCode Gaudi::Decays::Nodes::CTau::setService ( const Gaudi::Interfaces::IParticlePropertySvc * svc) const

Definition at line 306 of file NodePIDs.cpp.

306 {
307 // if service is substituted, clear the cache
308 if ( m_ppSvc != svc ) {
309 m_pids.with_lock( []( KnownPids& pids ) {
310 pids.accepted.clear();
311 pids.rejected.clear();
312 } );
313 }
314 //
315 if ( svc ) {
316 m_ppSvc = const_cast<Gaudi::Interfaces::IParticlePropertySvc*>( svc );
317 } else {
318 m_ppSvc = nullptr;
319 }
320 //
322}
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ valid()

bool Gaudi::Decays::Nodes::CTau::valid ( ) const
overridevirtual

MANDATORY: check the validity.

Implements Gaudi::Decays::iNode.

Definition at line 277 of file NodePIDs.cpp.

277{ return m_ppSvc.isValid(); }

◆ validate()

StatusCode Gaudi::Decays::Nodes::CTau::validate ( const Gaudi::Interfaces::IParticlePropertySvc * svc) const
overridevirtual

MANDATORY: the proper validation of the node.

Implements Gaudi::Decays::iNode.

Definition at line 279 of file NodePIDs.cpp.

279 {
280 return setService( svc );
281}
StatusCode setService(const Gaudi::Interfaces::IParticlePropertySvc *svc) const
Definition NodePIDs.cpp:306

Member Data Documentation

◆ m_high

double Gaudi::Decays::Nodes::CTau::m_high
private

high edge

Definition at line 482 of file NodesPIDs.h.

◆ m_low

double Gaudi::Decays::Nodes::CTau::m_low
private

low edge

Definition at line 480 of file NodesPIDs.h.

◆ m_pids

Gaudi::cxx::SynchronizedValue<KnownPids> Gaudi::Decays::Nodes::CTau::m_pids
mutableprivate

Definition at line 477 of file NodesPIDs.h.

◆ m_ppSvc

Service Gaudi::Decays::Nodes::CTau::m_ppSvc
mutableprivate

the service :

Definition at line 468 of file NodesPIDs.h.


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