The Gaudi Framework  master (37c0b60a)
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"
14 #include <GaudiKernel/MsgStream.h>
15 
16 #include <HepPDT/ParticleDataTable.hh>
17 
18 #include <sstream>
19 
20 // Static Factory declaration
21 
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 
43  pdt->writeParticleData( ost );
44 
45  info() << ost.str() << endmsg;
46 
47  return StatusCode::SUCCESS;
48 }
49 
50 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
51 
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
PartPropExa::execute
StatusCode execute() override
Definition: PartPropExa.cpp:52
ParticleID
Definition: ParticleID.py:1
PartPropExa.h
HepPDT::TestUnknownID::processUnknownID
CommonParticleData * processUnknownID(ParticleID, const ParticleDataTable &pdt) override
Definition: PartPropExa.cpp:58
HepPDT
Definition: IPartPropSvc.h:18
StatusCode
Definition: StatusCode.h:65
std::cout
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
std::ostringstream
STL class.
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
std::endl
T endl(T... args)
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
HepPDT::TestUnknownID
Definition: PartPropExa.h:41
IPartPropSvc.h
std::ostringstream::str
T str(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
PartPropExa
Definition: PartPropExa.h:29
ISvcLocator.h
ProduceConsume.key
key
Definition: ProduceConsume.py:84
MsgStream.h