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 return StatusCode::SUCCESS;
38}
39
41{
42 ATH_MSG_INFO ("Booking hists " << name() << "...");
43
44 // Physics validation plots are level 10
46 m_oDiTauValidationPlots->setDetailLevel(100);
47 m_oDiTauValidationPlots->initialize();
48 std::vector<HistData> hists = m_oDiTauValidationPlots->retrieveBookedHistograms();
49 ATH_MSG_INFO ("Filling n of hists " << hists.size() << " ");
50 for (const auto& hist : hists) {
51 ATH_CHECK(regHist(hist.first,hist.second,all));
52 }
53
54 return StatusCode::SUCCESS;
55}
56
58{
59 ATH_MSG_DEBUG ("Filling hists " << name() << "...");
60
61 // Retrieve tau container
62 const xAOD::DiTauJetContainer* ditaus = nullptr;
64 ATH_CHECK( evtStore()->retrieve(ditaus, m_DiTauJetContainerName) );
65 } else {
66 ATH_MSG_INFO("Input collection " << m_DiTauJetContainerName << " not found. Skip the monitoring ..");
67 return StatusCode::SUCCESS;
68 }
69
70
71 ATH_MSG_DEBUG("Number of ditaus: " << ditaus->size());
72
73 // Retrieve event info and beamSpotWeight
74 const xAOD::EventInfo* eventInfo = nullptr;
75 ATH_CHECK( evtStore()->retrieve(eventInfo, "EventInfo") );
76
77 float weight = eventInfo->beamSpotWeight();
78
79 // Loop through recoonstructed tau container
80 for (auto ditau : *ditaus) {
81 if ( m_detailLevel < 10 ) continue;
82
83 bool nominal = static_cast<bool>(m_nomiDiTauSel->accept(*ditau));
84
85 // fill histograms for reconstructed taus
86 m_oDiTauValidationPlots->m_oNewCorePlots.fill(*ditau, weight);
87 if(nominal) {
88 m_oDiTauValidationPlots->m_oNewCorePlotsNom.fill(*ditau, weight);
89 }
90
91 // Don't fill truth and fake histograms if we are running on data.
92 if ( !m_isMC ) continue;
93
94 ATH_MSG_DEBUG("Trying to truth-match ditau");
95 m_truthTool->getTruth(*ditau);
96
97 static const SG::ConstAccessor<char> IsTruthMatchedAcc("IsTruthHadronic");
98 if ( (bool)IsTruthMatchedAcc(*ditau) ) {
99 m_oDiTauValidationPlots->m_oNewCorePlotsTrue.fill(*ditau, weight);
100 if(nominal){
101 m_oDiTauValidationPlots->m_oNewCorePlotsNomTrue.fill(*ditau, weight);
102 m_oDiTauValidationPlots->m_oNewResolutionPlotsTrue.fill(*ditau, weight);
103 }
104 } else {
105 m_oDiTauValidationPlots->m_oNewCorePlotsFake.fill(*ditau, weight);
106 if(nominal){
107 m_oDiTauValidationPlots->m_oNewCorePlotsNomFake.fill(*ditau, weight);
108 }
109 }
110 }
111
112 return StatusCode::SUCCESS;
113}
114
116{
117 ATH_MSG_INFO ("Finalising hists " << name() << "...");
118 return StatusCode::SUCCESS;
119}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Helper class to provide constant type-safe access to aux data.
ServiceHandle< StoreGateSvc > & evtStore()
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)
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 fillHistograms()
An inheriting class should either override this function or fillHists().
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
ToolHandle< TauAnalysisTools::IDiTauTruthMatchingTool > m_truthTool
Gaudi::Property< std::string > m_DiTauJetContainerName
PhysValDiTau(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
virtual StatusCode initialize()
Helper class to provide constant type-safe access to aux data.
float beamSpotWeight() const
Weight for beam spot size reweighting.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
EventInfo_v1 EventInfo
Definition of the latest event info version.
DiTauJetContainer_v1 DiTauJetContainer
Definition of the current DiTauJet container version.