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 #include "EventInfo/EventInfo.h"
15 #include <vector>
16 
17 PhysValDiTau::PhysValDiTau(const std::string& type,
18  const std::string& name,
19  const IInterface* 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;
63  if(evtStore()->contains<xAOD::DiTauJetContainer>(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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
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:115
PhysValDiTau::PhysValDiTau
PhysValDiTau(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition: PhysValDiTau.cxx:17
DiTauJetContainer.h
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:46
PhysValDiTau::initialize
virtual StatusCode initialize()
Definition: PhysValDiTau.cxx:25
ManagedMonitorToolBase::initialize
virtual StatusCode initialize()
Definition: ManagedMonitorToolBase.cxx:616
PhysValDiTau::m_oDiTauValidationPlots
std::unique_ptr< DiTauValidationPlots > m_oDiTauValidationPlots
Definition: PhysValDiTau.h:49
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:795
PhysValDiTau.h
PhysValDiTau::m_isMC
Gaudi::Property< bool > m_isMC
Definition: PhysValDiTau.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
PhysValDiTau::m_nomiDiTauSel
ToolHandle< TauAnalysisTools::IDiTauSelectionTool > m_nomiDiTauSel
Definition: PhysValDiTau.h:45
PhysValDiTau::m_DiTauJetContainerName
Gaudi::Property< std::string > m_DiTauJetContainerName
Definition: PhysValDiTau.h:42
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
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:40
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
PhysValDiTau::fillHistograms
virtual StatusCode fillHistograms()
An inheriting class should either override this function or fillHists().
Definition: PhysValDiTau.cxx:57