ATLAS Offline Software
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 
13 // STL includes
14 #include <vector>
15 
16 // FrameWork includes
17 #include "GaudiKernel/IToolSvc.h"
18 #include "xAODJet/JetContainer.h"
22 
23 
24 PhysValDiTau::PhysValDiTau(const std::string& type,
25  const std::string& name,
26  const IInterface* parent) :
28 {
29 }
30 
31 
33 {
34  ATH_MSG_INFO ("Initializing " << name() << "...");
36 
37  // selections are configured in PhysicsValidation job options
38  ATH_CHECK(m_nomiDiTauSel.retrieve());
39 
40  if ( m_isMC ) {
41  ATH_CHECK(m_truthTool.retrieve());
42  }
43 
44  return StatusCode::SUCCESS;
45 }
46 
48 {
49  ATH_MSG_INFO ("Booking hists " << name() << "...");
50 
51  // Physics validation plots are level 10
53  m_oDiTauValidationPlots->setDetailLevel(100);
54  m_oDiTauValidationPlots->initialize();
55  std::vector<HistData> hists = m_oDiTauValidationPlots->retrieveBookedHistograms();
56  ATH_MSG_INFO ("Filling n of hists " << hists.size() << " ");
57  for (const auto& hist : hists) {
58  ATH_CHECK(regHist(hist.first,hist.second,all));
59  }
60 
61  return StatusCode::SUCCESS;
62 }
63 
65 {
66  ATH_MSG_DEBUG ("Filling hists " << name() << "...");
67 
68  // Retrieve tau container
69  const xAOD::DiTauJetContainer* ditaus = nullptr;
70  if(evtStore()->contains<xAOD::DiTauJetContainer>(m_DiTauJetContainerName)){
72  } else {
73  ATH_MSG_INFO("Input collection " << m_DiTauJetContainerName << " not found. Skip the monitoring ..");
74  return StatusCode::SUCCESS;
75  }
76 
77 
78  ATH_MSG_DEBUG("Number of ditaus: " << ditaus->size());
79 
80  // Retrieve event info and beamSpotWeight
81  const xAOD::EventInfo* eventInfo = nullptr;
82  ATH_CHECK( evtStore()->retrieve(eventInfo, "EventInfo") );
83 
84  float weight = eventInfo->beamSpotWeight();
85 
86  // Loop through recoonstructed tau container
87  for (auto ditau : *ditaus) {
88  if ( m_detailLevel < 10 ) continue;
89 
90  bool nominal = static_cast<bool>(m_nomiDiTauSel->accept(*ditau));
91 
92  // fill histograms for reconstructed taus
93  m_oDiTauValidationPlots->m_oNewCorePlots.fill(*ditau, weight);
94  if(nominal) {
95  m_oDiTauValidationPlots->m_oNewCorePlotsNom.fill(*ditau, weight);
96  }
97 
98  // Don't fill truth and fake histograms if we are running on data.
99  if ( !m_isMC ) continue;
100 
101  ATH_MSG_DEBUG("Trying to truth-match ditau");
102  m_truthTool->getTruth(*ditau);
103 
104  static const SG::ConstAccessor<char> IsTruthMatchedAcc("IsTruthHadronic");
105  if ( (bool)IsTruthMatchedAcc(*ditau) ) {
106  m_oDiTauValidationPlots->m_oNewCorePlotsTrue.fill(*ditau, weight);
107  if(nominal){
108  m_oDiTauValidationPlots->m_oNewCorePlotsNomTrue.fill(*ditau, weight);
109  m_oDiTauValidationPlots->m_oNewResolutionPlotsTrue.fill(*ditau, weight);
110  }
111  } else {
112  m_oDiTauValidationPlots->m_oNewCorePlotsFake.fill(*ditau, weight);
113  if(nominal){
114  m_oDiTauValidationPlots->m_oNewCorePlotsNomFake.fill(*ditau, weight);
115  }
116  }
117  }
118 
119  return StatusCode::SUCCESS;
120 }
121 
123 {
124  ATH_MSG_INFO ("Finalising hists " << name() << "...");
125  return StatusCode::SUCCESS;
126 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AthCheckMacros.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:73
plotmaker.hist
hist
Definition: plotmaker.py:148
PhysValDiTau::procHistograms
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
Definition: PhysValDiTau.cxx:122
PhysValDiTau::PhysValDiTau
PhysValDiTau(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition: PhysValDiTau.cxx:24
SG::ConstAccessor< char >
DiTauValidationPlots
Definition: DiTauValidationPlots.h:12
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
PhysValDiTau::m_truthTool
ToolHandle< TauAnalysisTools::IDiTauTruthMatchingTool > m_truthTool
Definition: PhysValDiTau.h:51
PhysValDiTau::initialize
virtual StatusCode initialize()
Definition: PhysValDiTau.cxx:32
ManagedMonitorToolBase::initialize
virtual StatusCode initialize()
Definition: ManagedMonitorToolBase.cxx:616
PhysValDiTau::m_oDiTauValidationPlots
std::unique_ptr< DiTauValidationPlots > m_oDiTauValidationPlots
Definition: PhysValDiTau.h:54
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MakeTH3DFromTH2Ds.hists
hists
Definition: MakeTH3DFromTH2Ds.py:72
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
PhysValDiTau.h
PhysValDiTau::m_isMC
Gaudi::Property< bool > m_isMC
Definition: PhysValDiTau.h:48
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
PhysValDiTau::m_nomiDiTauSel
ToolHandle< TauAnalysisTools::IDiTauSelectionTool > m_nomiDiTauSel
Definition: PhysValDiTau.h:50
PhysValDiTau::m_DiTauJetContainerName
Gaudi::Property< std::string > m_DiTauJetContainerName
Definition: PhysValDiTau.h:47
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
JetContainer.h
ManagedMonitorToolBase::all
@ all
Definition: ManagedMonitorToolBase.h:115
PhysValDiTau::bookHistograms
virtual StatusCode bookHistograms()
An inheriting class should either override this function or bookHists().
Definition: PhysValDiTau.cxx:47
ManagedMonitorToolBase::m_detailLevel
unsigned int m_detailLevel
Definition: ManagedMonitorToolBase.h:836
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::EventInfo_v1::beamSpotWeight
float beamSpotWeight() const
Weight for beam spot size reweighting.
Definition: EventInfo_v1.cxx:970
ManagedMonitorToolBase::regHist
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 ...
Definition: ManagedMonitorToolBase.cxx:1344
HepMCHelpers.h
PhysValDiTau::fillHistograms
virtual StatusCode fillHistograms()
An inheriting class should either override this function or fillHists().
Definition: PhysValDiTau.cxx:64