The Gaudi Framework
master (bb4415cc)
Toggle main menu visibility
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
"
12
#include <
GaudiKernel/IPartPropSvc.h
>
13
#include <
GaudiKernel/ISvcLocator.h
>
14
#include <
GaudiKernel/MsgStream.h
>
15
16
#include <HepPDT/ParticleDataTable.hh>
17
18
#include <sstream>
19
20
// Static Factory declaration
21
22
DECLARE_COMPONENT
(
PartPropExa
)
23
24
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25
26
StatusCode
PartPropExa
::
initialize
() {
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
47
return
StatusCode::SUCCESS
;
48
}
49
50
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
51
52
StatusCode
PartPropExa::execute
() {
return
StatusCode::SUCCESS
; }
53
54
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
55
56
namespace
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
IPartPropSvc.h
ISvcLocator.h
MsgStream.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
PartPropExa.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:115
HepPDT::TestUnknownID
Definition
PartPropExa.h:40
HepPDT::TestUnknownID::processUnknownID
CommonParticleData * processUnknownID(ParticleID, const ParticleDataTable &pdt) override
Definition
PartPropExa.cpp:58
PartPropExa
Definition
PartPropExa.h:28
PartPropExa::initialize
StatusCode initialize() override
Definition
PartPropExa.cpp:26
PartPropExa::m_pps
ServiceHandle< IPartPropSvc > m_pps
Definition
PartPropExa.h:36
PartPropExa::execute
StatusCode execute() override
Definition
PartPropExa.cpp:52
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
HepPDT
Definition
IPartPropSvc.h:16
ParticleID
Definition
ParticleID.py:1
GaudiTestSuite
src
PartProp
PartPropExa.cpp
Generated on
for The Gaudi Framework by
1.17.0