The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
PartPropExa.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#include "PartPropExa.h"
15
16#include <HepPDT/ParticleDataTable.hh>
17
18#include <sstream>
19
20// Static Factory declaration
21
23
24/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25
27
28 if ( m_pps.retrieve().isFailure() ) {
29 error() << "Could not get PartPropSvc" << endmsg;
30 return StatusCode::FAILURE;
31 }
32
33 m_pps->setUnknownParticleHandler( new HepPDT::TestUnknownID, "My Unknwon PID Test" );
34
35 info() << "this should cause a warning: " << endmsg;
36 m_pps->setUnknownParticleHandler( new HepPDT::TestUnknownID, "Second Unknwon PID Test" );
37
38 HepPDT::ParticleDataTable* pdt = m_pps->PDT();
39
40 m_pps->setUnknownParticleHandler( new HepPDT::TestUnknownID, "Third Unknwon PID Test" );
41
42 std::ostringstream ost;
43 pdt->writeParticleData( ost );
44
45 info() << ost.str() << endmsg;
46
48}
49
50/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
51
53
54/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
55
56namespace HepPDT {
57
58 CommonParticleData* TestUnknownID::processUnknownID( ParticleID key, const ParticleDataTable& pdt ) {
59
60 std::cout << "TestUnknownID: " << key.PDTname() << std::endl;
61
62 CommonParticleData* cpd = nullptr;
63 if ( key.isNucleus() ) {
64
65 // have to create a TempParticleData with all properties first
66 TempParticleData tpd( key );
67 // calculate approximate mass
68 // WARNING: any calls to particle() from here MUST reference
69 // a ParticleData which is already in the table
70 // This convention is enforced.
71 const ParticleData* proton = pdt.particle( 2212 );
72 if ( proton ) {
73 double protonMass = proton->mass();
74 tpd.tempMass = Measurement( key.A() * protonMass, 0. );
75 // now create CommonParticleData
76 cpd = new CommonParticleData( tpd );
77 }
78 }
79 return cpd;
80 }
81} // namespace HepPDT
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
CommonParticleData * processUnknownID(ParticleID, const ParticleDataTable &pdt) override
StatusCode initialize() override
ServiceHandle< IPartPropSvc > m_pps
Definition PartPropExa.h:36
StatusCode execute() override
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99