ATLAS Offline Software
Loading...
Searching...
No Matches
PhysValDiTau.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// PhysValDdiTau.cxx
6// Implementation file for class PhysValDiTau
7// Author: S.Binet<binet@cern.ch>
8// Author: A.DeMaria<antonio.de.maria@cern.ch>
9
10// PhysVal includes
11#include "PhysValDiTau.h"
12#include "EventInfo/EventInfo.h"
15#include <vector>
16
17PhysValDiTau::PhysValDiTau(const std::string& type,
18 const std::string& name,
19 const IInterface* parent) :
20 ManagedMonitorToolBase(type, name, parent)
21{
22}
23
24
26{
27 ATH_MSG_INFO ("Initializing " << name() << "...");
29
30 // selections are configured in PhysicsValidation job options
31 ATH_CHECK(m_nomiDiTauSel.retrieve());
32
33 if ( m_isMC ) {
34 ATH_CHECK(m_truthTool.retrieve());
35 }
36
37 ATH_CHECK(m_ditauContainerKey.initialize());
38
40 ATH_CHECK( m_IsTruthHadronicKey.initialize());
41
42 return StatusCode::SUCCESS;
43}
44
46{
47 ATH_MSG_INFO ("Booking hists " << name() << "...");
48
49 // Physics validation plots are level 10
51 m_oDiTauValidationPlots->setDetailLevel(100);
52 m_oDiTauValidationPlots->initialize();
53 std::vector<HistData> hists = m_oDiTauValidationPlots->retrieveBookedHistograms();
54 ATH_MSG_INFO ("Filling n of hists " << hists.size() << " ");
55 for (const auto& hist : hists) {
56 ATH_CHECK(regHist(hist.first,hist.second,all));
57 }
58
59 return StatusCode::SUCCESS;
60}
61
62StatusCode PhysValDiTau::fillHistograms(const EventContext& ctx)
63{
64 ATH_MSG_DEBUG ("Filling hists " << name() << "...");
65
66 // Retrieve tau container
68 if (!ditauJetsReadHandle.isValid()) {
69 ATH_MSG_ERROR ("Could not retrieve DiTauJetContainer with key " << ditauJetsReadHandle.key());
70 return StatusCode::FAILURE;
71 }
72 const xAOD::DiTauJetContainer* ditaus = ditauJetsReadHandle.cptr();
73
74 ATH_MSG_DEBUG("Number of ditaus: " << ditaus->size());
75
76 // Retrieve event info and beamSpotWeight
77 SG::ReadHandle<xAOD::EventInfo> eventInfoReadHandle("EventInfo", ctx);
78 const xAOD::EventInfo* eventInfo = eventInfoReadHandle.cptr();
79
80 float weight = eventInfo->beamSpotWeight();
81
82 // Loop through recoonstructed tau container
83 for (auto ditau : *ditaus) {
84 if ( m_detailLevel < 10 ) continue;
85
86 bool nominal = static_cast<bool>(m_nomiDiTauSel->accept(*ditau));
87
88 // fill histograms for reconstructed taus
89 m_oDiTauValidationPlots->m_oNewCorePlots.fill(*ditau, weight);
90 if(nominal) {
91 m_oDiTauValidationPlots->m_oNewCorePlotsNom.fill(*ditau, weight);
92 }
93
94 // Don't fill truth and fake histograms if we are running on data.
95 if ( !m_isMC ) continue;
96
97 ATH_MSG_DEBUG("Trying to truth-match ditau");
98 m_truthTool->getTruth(*ditau);
99
101 if ( (bool) isTruthHadronic(*ditau) ) {
102 m_oDiTauValidationPlots->m_oNewCorePlotsTrue.fill(*ditau, weight);
103 if(nominal){
104 m_oDiTauValidationPlots->m_oNewCorePlotsNomTrue.fill(*ditau, weight);
105 m_oDiTauValidationPlots->m_oNewResolutionPlotsTrue.fill(*ditau, weight);
106 }
107 } else {
108 m_oDiTauValidationPlots->m_oNewCorePlotsFake.fill(*ditau, weight);
109 if(nominal){
110 m_oDiTauValidationPlots->m_oNewCorePlotsNomFake.fill(*ditau, weight);
111 }
112 }
113 }
114
115 return StatusCode::SUCCESS;
116}
117
119{
120 ATH_MSG_INFO ("Finalising hists " << name() << "...");
121 return StatusCode::SUCCESS;
122}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Helper class to provide constant type-safe access to aux data.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual StatusCode regHist(TH1 *h, const std::string &system, Interval_t interval, MgmtAttr_t histo_mgmt=ATTRIB_MANAGED, const std::string &chain="", const std::string &merge="")
Registers a TH1 (including TH2, TH3, and TProfile) to be included in the output stream using logical ...
ManagedMonitorToolBase(const std::string &type, const std::string &name, const IInterface *parent)
SG::ReadHandleKey< xAOD::DiTauJetContainer > m_ditauContainerKey
SG::ReadDecorHandleKey< xAOD::DiTauJetContainer > m_IsTruthHadronicKey
virtual StatusCode bookHistograms()
An inheriting class should either override this function or bookHists().
ToolHandle< TauAnalysisTools::IDiTauSelectionTool > m_nomiDiTauSel
std::unique_ptr< DiTauValidationPlots > m_oDiTauValidationPlots
Gaudi::Property< bool > m_isMC
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
ToolHandle< TauAnalysisTools::IDiTauTruthMatchingTool > m_truthTool
PhysValDiTau(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
virtual StatusCode fillHistograms(const EventContext &ctx)
An inheriting class should either override this function or fillHists().
virtual StatusCode initialize()
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
float beamSpotWeight() const
Weight for beam spot size reweighting.
EventInfo_v1 EventInfo
Definition of the latest event info version.
DiTauJetContainer_v1 DiTauJetContainer
Definition of the current DiTauJet container version.