ATLAS Offline Software
TauAnalysisToolsExampleAthena.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // EDM include(s):
8 
9 // Local include(s):
11 
12 using namespace TauAnalysisTools;
13 
14 TauAnalysisToolsExampleAthena::TauAnalysisToolsExampleAthena( const std::string& name, ISvcLocator* svcLoc )
15  : AthAlgorithm( name, svcLoc )
16 {
17 }
18 
20 {
21  // Greet the user:
22  ATH_MSG_INFO( "Initialising" );
23  ATH_MSG_DEBUG( "TauJets SGKey = " << m_sgKey_TauJets );
25  ATH_MSG_DEBUG( "TauJets_MuonRM SGKey = " << m_sgKey_TauJets_MuonRM );
26  }
27  ATH_MSG_DEBUG( "TauSelectionTool = " << m_selTool );
28  ATH_MSG_DEBUG( "TauSmearingTool = " << m_smearTool );
29  ATH_MSG_DEBUG( "TauEfficiencyTool = " << m_effTool );
30 
31  // Retrieve the tools:
32  ATH_CHECK( m_selTool.retrieve() );
33  ATH_CHECK( m_smearTool.retrieve() );
34  ATH_CHECK( m_effTool.retrieve() );
35 
36  // Return gracefully:
37  return StatusCode::SUCCESS;
38 }
39 
41 {
42  // Retrieve the taus:
43  std::vector<const xAOD::TauJet*> taus_to_calibrate;
44  const xAOD::TauJetContainer* taus_std = 0;
45  ATH_CHECK( evtStore()->retrieve( taus_std, m_sgKey_TauJets ) );
46  ATH_MSG_INFO( "Number of taus: " << taus_std->size() );
47  const xAOD::TauJetContainer* taus_muonRM = 0;
49  ATH_CHECK( evtStore()->retrieve( taus_muonRM, m_sgKey_TauJets_MuonRM ) );
50  ATH_MSG_INFO( "Number of muon removal taus: " << taus_muonRM->size() );
51  taus_to_calibrate = TauAnalysisTools::combineTauJetsWithMuonRM(taus_std, taus_muonRM);
52  }
53  else {
54  for (const xAOD::TauJet* tau : *taus_std){
55  taus_to_calibrate.push_back(tau);
56  }
57  }
58  // Loop over them:
59  for(const xAOD::TauJet* tau_uncali : taus_to_calibrate)
60  {
61  ATH_MSG_DEBUG( " current tau: eta = " << tau_uncali->eta()
62  << ", phi = " << tau_uncali->phi()
63  << ", pt = " << tau_uncali->pt() );
64 
65  // Select "good" taus:
66  if( ! m_selTool->accept( *tau_uncali ) ) continue;
67 
68  // Print some info about the selected tau:
69  ATH_MSG_INFO( " Selected tau: eta = " << tau_uncali->eta()
70  << ", phi = " << tau_uncali->phi()
71  << ", pt = " << tau_uncali->pt() );
72 
73  // copy constant objects to non-constant
74  xAOD::TauJet* tau = 0;
75  tau = new xAOD::TauJet();
76  tau->makePrivateStore( *tau_uncali );
77 
78  ATH_CHECK (m_effTool->applyEfficiencyScaleFactor(*tau));
79 
80  static const SG::ConstAccessor<double> accTauScaleFactorJetID ("TauScaleFactorJetID");
81  ATH_MSG_INFO( " sf = " << accTauScaleFactorJetID (*tau) );
82 
83  ATH_CHECK (m_smearTool->applyCorrection(*tau));
84  ATH_MSG_INFO( "Unsmeared tau pt " << tau->pt() << " Smeared tau pt: " << tau->p4().Pt());
85  }
86 
87  // Return gracefully:
88  return StatusCode::SUCCESS;
89 }
TauAnalysisTools::TauAnalysisToolsExampleAthena::initialize
virtual StatusCode initialize()
Function initialising the algorithm.
Definition: TauAnalysisToolsExampleAthena.cxx:19
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TauAnalysisTools
Definition: TruthCollectionMakerTau.h:16
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TauAnalysisTools::TauAnalysisToolsExampleAthena::execute
virtual StatusCode execute()
Function executing the algorithm.
Definition: TauAnalysisToolsExampleAthena.cxx:40
TauAnalysisTools::TauAnalysisToolsExampleAthena::m_sgKey_TauJets
Gaudi::Property< std::string > m_sgKey_TauJets
StoreGate key for the tau container to investigate.
Definition: TauAnalysisToolsExampleAthena.h:38
SG::ConstAccessor< double >
TauAnalysisTools::TauAnalysisToolsExampleAthena::m_smearTool
ToolHandle< ITauSmearingTool > m_smearTool
Connection to the smearing tool.
Definition: TauAnalysisToolsExampleAthena.h:48
xAOD::TauJet_v3::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
TauAnalysisToolsExampleAthena.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
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TauJet
TauJet_v3 TauJet
Definition of the current "tau version".
Definition: Event/xAOD/xAODTau/xAODTau/TauJet.h:17
TauJetContainer.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
AthAlgorithm
Definition: AthAlgorithm.h:47
TauAnalysisTools::TauAnalysisToolsExampleAthena::m_selTool
ToolHandle< ITauSelectionTool > m_selTool
Connection to the selection tool.
Definition: TauAnalysisToolsExampleAthena.h:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
TauAnalysisTools::TauAnalysisToolsExampleAthena::m_sgKey_TauJets_MuonRM
Gaudi::Property< std::string > m_sgKey_TauJets_MuonRM
Special StoreGate key for the muon-removed taus.
Definition: TauAnalysisToolsExampleAthena.h:42
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
xAOD::TauJet_v3::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: TauJet_v3.cxx:96
TauAnalysisTools::TauAnalysisToolsExampleAthena::m_effTool
ToolHandle< ITauEfficiencyCorrectionsTool > m_effTool
Connection to the efficiency correction tool.
Definition: TauAnalysisToolsExampleAthena.h:50
TauAnalysisTools::TauAnalysisToolsExampleAthena::m_useMuonRemovalTaus
Gaudi::Property< bool > m_useMuonRemovalTaus
Definition: TauAnalysisToolsExampleAthena.h:43
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
TauAnalysisTools::TauAnalysisToolsExampleAthena::TauAnalysisToolsExampleAthena
TauAnalysisToolsExampleAthena(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
Definition: TauAnalysisToolsExampleAthena.cxx:14
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TauAnalysisTools::combineTauJetsWithMuonRM
std::vector< const xAOD::TauJet * > combineTauJetsWithMuonRM(const xAOD::TauJetContainer *taus_std, const xAOD::TauJetContainer *taus_muonRM)
combine the standard taujets container with the muon removal container
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:542