The Gaudi Framework  master (594c33fa)
Gaudi::Decays::Nodes::CTau Class Reference

#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 More...
 
CTauclone () const override
 MANDATORY: clone method ("virtual constructor") More...
 
bool operator() (const Gaudi::ParticleID &pid) const override
 MANDATORY: the only one essential method. More...
 
std::ostreamfillStream (std::ostream &s) const override
 MANDATORY: the specific printout. More...
 
bool valid () const override
 MANDATORY: check the validity. More...
 
StatusCode validate (const Gaudi::Interfaces::IParticlePropertySvc *svc) const override
 MANDATORY: the proper validation of the node. More...
 
const Gaudi::Interfaces::IParticlePropertySvcppSvc () const
 
double low () const
 get low edge More...
 
double high () const
 get high edge More...
 
StatusCode setService (const Gaudi::Interfaces::IParticlePropertySvc *svc) const
 
MsgStreamprintAcceptedAsTable (MsgStream &s) const
 
- Public Member Functions inherited from Gaudi::Decays::iNode
virtual bool operator! () const
 invalid node? More...
 
virtual std::string toString () const
 the string representation of the node More...
 
virtual ~iNode ()=default
 virtual destructor More...
 

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::IParticlePropertySvcService
 

Private Member Functions

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

Private Attributes

Service m_ppSvc
 the service : More...
 
Gaudi::cxx::SynchronizedValue< KnownPidsm_pids
 
double m_low
 low edge More...
 
double m_high
 high edge More...
 

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 }

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 }

◆ 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  }

◆ clone()

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

◆ 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::Mass, Gaudi::Decays::Nodes::StableCharged, Gaudi::Decays::Nodes::Stable, Gaudi::Decays::Nodes::LongLived_, and Gaudi::Decays::Nodes::ShortLived_.

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 }

◆ 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  }

◆ 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 }

◆ 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 }

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:
Gaudi::Decays::Nodes::CTau::m_pids
Gaudi::cxx::SynchronizedValue< KnownPids > m_pids
Definition: NodesPIDs.h:477
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::Interfaces::IParticlePropertySvc
Definition: IParticlePropertySvc.h:29
Gaudi::Decays::Nodes::CTau::classify
bool classify(Gaudi::ParticleID pid, F &&f) const
Definition: NodesPIDs.h:433
gaudirun.c
c
Definition: gaudirun.py:525
Gaudi::Decays::Nodes::CTau::m_low
double m_low
low edge
Definition: NodesPIDs.h:480
Gaudi::ParticleProperties::printAsTable
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
Definition: ParticleProperty.cpp:319
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:72
ParticleID.pids
pids
Definition: ParticleID.py:70
Gaudi::Decays::Nodes::CTau::setService
StatusCode setService(const Gaudi::Interfaces::IParticlePropertySvc *svc) const
Definition: NodePIDs.cpp:306
Gaudi::Decays::Nodes::CTau::add_
bool add_(Gaudi::ParticleID pid, bool acc) const
Definition: NodePIDs.cpp:295
Gaudi::Decays::Nodes::CTau::CTau
CTau(const double low, const double high, const Gaudi::Interfaces::IParticlePropertySvc *svc=nullptr)
constructor from c-tau range
Definition: NodePIDs.cpp:266
Gaudi::ParticleProperty
Definition: ParticleProperty.h:37
MsgStream
Definition: MsgStream.h:34
Gaudi::Decays::Nodes::CTau::high
double high() const
get high edge
Definition: NodesPIDs.h:427
std::lower_bound
T lower_bound(T... args)
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Gaudi::Interfaces::IParticlePropertySvc::find
virtual const ParticleProperty * find(const std::string &name) const =0
Retrieve an object by name:
Gaudi::ParticleID
Definition: ParticleID.h:43
Gaudi::Decays::Nodes::CTau::m_ppSvc
Service m_ppSvc
the service :
Definition: NodesPIDs.h:468
Gaudi::Decays::Nodes::CTau::m_high
double m_high
high edge
Definition: NodesPIDs.h:482
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
std::binary_search
T binary_search(T... args)
compareOutputFiles.pp
pp
Definition: compareOutputFiles.py:507
Gaudi::Decays::Nodes::CTau::low
double low() const
get low edge
Definition: NodesPIDs.h:425
Gaudi::Decays::Nodes::CTau::ppSvc
const Gaudi::Interfaces::IParticlePropertySvc * ppSvc() const
Definition: NodesPIDs.h:422