ATLAS Offline Software
Loading...
Searching...
No Matches
PhysicsAnalysis/AnalysisCommon/FsrUtils/src/ToolTester.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
9
10// Local include(s):
11#include "ToolTester.h"
12#include "TLorentzVector.h"
13
14namespace FSR {
15
16 ToolTester::ToolTester( const std::string& name, ISvcLocator* svcLoc )
17 : AthAlgorithm( name, svcLoc ),
18 m_fsrTool( "FSR::FsrPhotonTool/FsrPhotonTool", this) {
19 //m_ntsvc("THistSvc/THistSvc", name),
20 //m_hist (0){
21
22 declareProperty( "SGMuonKey", m_sgMuonKey = "Muons" );
23 declareProperty( "SGPhotonKey", m_sgPhotonKey = "Photons" );
24 declareProperty( "SGElectronKey", m_sgElectronKey = "Electrons" );
25 declareProperty( "FsrPhotonTool", m_fsrTool );
26 }
27
29
30 // Greet the user:
31 ATH_MSG_INFO( "SGMuonKey = " << m_sgMuonKey );
32 ATH_MSG_INFO( "SGPhotonKey = " << m_sgPhotonKey );
33 ATH_MSG_INFO( "SGElectronKey = " << m_sgElectronKey );
34 ATH_MSG_INFO( "FsrPhotonTool = " << m_fsrTool );
35
36 // Retrieve the tools:
37 ATH_CHECK( m_fsrTool.retrieve() );
38
39 // Return gracefully:
40 return StatusCode::SUCCESS;
41 }
42
43 StatusCode ToolTester::execute() {
44
45 // Retrieve the muons:
46 const xAOD::MuonContainer* muons = 0;
47 ATH_CHECK( evtStore()->retrieve( muons, m_sgMuonKey ) );
48
49 ATH_MSG_INFO( "Number of muons: " << muons->size() );
50
51 // Retrieve photons and electrons
52 xAOD::PhotonContainer* phs = 0;
53 ATH_CHECK( evtStore()->retrieve( phs, m_sgPhotonKey ) );
54 ATH_MSG_DEBUG("retrieved photons");
55 const xAOD::ElectronContainer* els = 0;
56 ATH_CHECK( evtStore()->retrieve( els, m_sgElectronKey ) );
57 ATH_MSG_DEBUG("retrieved electrons");
58
59 std::vector<const xAOD::Muon*> selectedMuons;
60 double tmp_energy = -999.;
61 double fsr_energy = 0.;
62 TLorentzVector fsr_tlv;
63 // Loop over them:
64 //
67 for( ; mu_itr != mu_end; ++mu_itr ) {
68
69
70 if ( m_fsrTool->getFsrPhoton(*mu_itr, m_candidate, phs, els) == CP::CorrectionCode::Ok){
71 ATH_MSG_INFO( " FSR m_candidate found !!!!!!!! ");
72 ATH_MSG_INFO( " container = " << m_candidate.container
73 //const xAOD::IParticle* particle;
74 << " deltaR = " << m_candidate.deltaR
75 << " Et = " << m_candidate.Et
76 <<" f1 = " << m_candidate.f1
77 <<" eta = " << m_candidate.eta
78 <<" phi = " << m_candidate.phi
79 <<" phIso = "<< m_candidate.phIso
80 <<" fsrtype = " << m_candidate.type
81 );
82 }
83
84 if (m_candidate.container == "photon" ) {
85 if(const xAOD::Photon* photon = dynamic_cast<const xAOD::Photon*>(m_candidate.particle)){
86 fsr_energy = photon->e();
87 }else{
88 ATH_MSG_WARNING( "Could not cast to Photon " );
89 }
90 } else if (m_candidate.container == "electron" ) {
91 if(const xAOD::Electron* electron = dynamic_cast<const xAOD::Electron*>(m_candidate.particle)){
92 fsr_energy = electron->e();
93 }else{
94 ATH_MSG_WARNING( "Could not cast to Electron " );
95 }
96 } else{
97 ATH_MSG_INFO( " FSR candidate particle is unknown " );
98 }
99 if ( fsr_energy > tmp_energy ) {
100 tmp_energy = fsr_energy;
101 fsr_tlv.SetPtEtaPhiE(m_candidate.Et, m_candidate.eta, m_candidate.phi, fsr_energy);
102 }
103
104 }
105
106 // Return gracefully:
107 return StatusCode::SUCCESS;
108 }
109
110
111} // namespace FSR
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
@ Ok
The correction was done successfully.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
ToolHandle< IFsrPhotonTool > m_fsrTool
Connection to the fsr tool.
virtual StatusCode initialize()
Function initialising the algorithm.
virtual StatusCode execute()
Function executing the algorithm.
ToolTester(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
std::string m_sgMuonKey
StoreGate keys for the muon, photon and electron containers to investigate.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Photon_v1 Photon
Definition of the current "egamma version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Electron_v1 Electron
Definition of the current "egamma version".