ATLAS Offline Software
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 
14 namespace 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 
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;
54  ATH_MSG_DEBUG("retrieved photons");
55  const xAOD::ElectronContainer* els = 0;
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  //
66  xAOD::MuonContainer::const_iterator mu_end = muons->end();
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
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
FSR::FsrCandidate::Et
double Et
Definition: IFsrPhotonTool.h:36
FSR
Definition: FsrPhotonTool.h:23
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FSR::FsrCandidate::container
std::string container
Definition: IFsrPhotonTool.h:33
FSR::ToolTester::execute
virtual StatusCode execute()
Function executing the algorithm.
Definition: PhysicsAnalysis/AnalysisCommon/FsrUtils/src/ToolTester.cxx:43
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
FSR::FsrCandidate::deltaR
double deltaR
Definition: IFsrPhotonTool.h:35
FSR::ToolTester::ToolTester
ToolTester(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
Definition: PhysicsAnalysis/AnalysisCommon/FsrUtils/src/ToolTester.cxx:16
FSR::ToolTester::m_sgPhotonKey
std::string m_sgPhotonKey
Definition: PhysicsAnalysis/AnalysisCommon/FsrUtils/src/ToolTester.h:40
FSR::ToolTester::initialize
virtual StatusCode initialize()
Function initialising the algorithm.
Definition: PhysicsAnalysis/AnalysisCommon/FsrUtils/src/ToolTester.cxx:28
FSR::FsrCandidate::f1
double f1
Definition: IFsrPhotonTool.h:37
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ElectronContainer.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
FSR::ToolTester::m_fsrTool
ToolHandle< IFsrPhotonTool > m_fsrTool
Connection to the fsr tool.
Definition: PhysicsAnalysis/AnalysisCommon/FsrUtils/src/ToolTester.h:44
FSR::ToolTester::m_sgElectronKey
std::string m_sgElectronKey
Definition: PhysicsAnalysis/AnalysisCommon/FsrUtils/src/ToolTester.h:41
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FSR::FsrCandidate::phIso
double phIso
Definition: IFsrPhotonTool.h:40
FSR::ToolTester::m_candidate
FsrCandidate m_candidate
Definition: PhysicsAnalysis/AnalysisCommon/FsrUtils/src/ToolTester.h:46
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
FSR::FsrCandidate::particle
const xAOD::IParticle * particle
Definition: IFsrPhotonTool.h:34
ToolTester.h
xAOD::Electron_v1
Definition: Electron_v1.h:34
MuonContainer.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
FSR::FsrCandidate::type
FsrType type
Definition: IFsrPhotonTool.h:41
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
xAOD::Photon_v1
Definition: Photon_v1.h:37
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
FSR::FsrCandidate::phi
double phi
Definition: IFsrPhotonTool.h:39
FSR::FsrCandidate::eta
double eta
Definition: IFsrPhotonTool.h:38
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
PhotonContainer.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
FSR::ToolTester::m_sgMuonKey
std::string m_sgMuonKey
StoreGate keys for the muon, photon and electron containers to investigate.
Definition: PhysicsAnalysis/AnalysisCommon/FsrUtils/src/ToolTester.h:39