Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EfficiencyResponseHistos.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 #include "AthenaKernel/Units.h"
10 
11 #include "TH1.h"
12 #include "TH2.h"
13 #include "TProfile.h"
14 #include <cmath>
15 
16 
17 using Athena::Units::GeV;
18 
19 
21  , m_histoDef(this)
22 {
23  declareProperty("HistoDef", m_histoDef, "The list of HistoDefinitionTool defining the histos to be used in this tool");
24  declareProperty("RefContainer", m_refContainerName);
25 }
26 
27 
28 
30  CHECK( m_histoDef.retrieve() );
31  return StatusCode::SUCCESS;
32 }
33 
35  ATH_MSG_INFO(" buildHistos num of histos : "<< m_histoDef.size() );
36 
38 
39  // Histos are defined in jobOptions !
40  // For each histo, ask hbuilder if a corresponding definition exists in the jobOption list.
41  // -> if so a valid histo is returned (and booked)
42  // -> else NULL is returned
43  m_eff1 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR1") );
44  m_eff2 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR2") );
45  m_eff3 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR3") );
46 
47  m_etres = bookHisto( hbuilder.build<TH1F>("erhResponse") );
48  m_etres_eta =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta") );
49  m_etres_pt =bookHisto( hbuilder.build<TProfile>("erhResponseVsPt") );
50 
51  m_etres_noShift = bookHisto( hbuilder.build<TH1F>("erhResponse_noShift") );
52  m_etres_noShift_eta =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_noShift") );
53  m_etres_noShift_pt =bookHisto( hbuilder.build<TProfile>("erhResponseVsPt_noShift") );
54 
55  m_deltaRclosest = bookHisto( hbuilder.build<TH1F>("erhDeltaR") );
56 
57 
58  return 0;
59 }
60 
61 
63 
64  const xAOD::JetContainer* refContainer = nullptr;
65  CHECK( evtStore()->retrieve( refContainer, m_refContainerName), 1 );
67  std::list<const xAOD::Jet*> listJets(cont.begin(), cont.end());
68 
69  for ( const xAOD::Jet* refjet : *refContainer ){
70  double dr2min = 500000;
71 
72  if (listJets.empty() ) break;
73  // find the min match
75  std::list<const xAOD::Jet*>::iterator itmin=listJets.end();
76  for( ; it != listJets.end(); ++it) {
77  double dr2 = xAOD::P4Helpers::deltaR2(*(*it),*refjet,false);
78  if(dr2 < dr2min) { dr2min = dr2; itmin = it ;}
79  }
80  if (itmin == listJets.end()) break;
81  const xAOD::Jet* matched = *itmin;
82  //cppcheck-suppress eraseIteratorOutOfBoundsCond
83  listJets.erase(itmin);
84 
85  double dr = std::sqrt(dr2min);
86  double refPt = refjet->pt() / GeV;
87 
88  m_eff1->Fill(refPt, dr<0.1 ? weight : 0 ); // 0 weight if not matching close enough
89  m_eff2->Fill(refPt, dr<0.2 ? weight : 0 ); // 0 weight if not matching close enough
90  m_eff3->Fill(refPt, dr<0.3 ? weight : 0 ); // 0 weight if not matching close enough
91 
92  m_deltaRclosest->Fill( dr, weight );
93 
94  if( dr < 0.3) {
95  double relDiff = -999;
96  double response = -999;
97  if (refPt > 0.){
98  relDiff = ( matched->pt() / GeV - refPt )/refPt;
99  response = (matched->pt() / GeV)/refPt;
100  }
101  m_etres->Fill( relDiff, weight );
102  m_etres_eta->Fill( refjet->eta(), relDiff, weight);
103  m_etres_pt->Fill( refPt, relDiff, weight);
104 
105  m_etres_noShift->Fill( response, weight );
106  m_etres_noShift_eta->Fill( refjet->eta(), response, weight);
107  m_etres_noShift_pt->Fill( refPt, response, weight);
108  }
109 
110  }
111 
112 
113  return 0;
114 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
EfficiencyResponseHistos::m_etres
TH1F * m_etres
Definition: EfficiencyResponseHistos.h:41
EfficiencyResponseHistos::m_refContainerName
std::string m_refContainerName
Definition: EfficiencyResponseHistos.h:34
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
EfficiencyResponseHistos::m_eff3
TProfile * m_eff3
Definition: EfficiencyResponseHistos.h:39
EfficiencyResponseHistos.h
response
MDT_Response response
Definition: MDT_ResponseTest.cxx:28
EfficiencyResponseHistos::m_etres_eta
TProfile * m_etres_eta
Definition: EfficiencyResponseHistos.h:42
xAODP4Helpers.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
EfficiencyResponseHistos::m_histoDef
ToolHandleArray< HistoDefinitionTool > m_histoDef
Definition: EfficiencyResponseHistos.h:33
EfficiencyResponseHistos::m_etres_noShift
TH1F * m_etres_noShift
Definition: EfficiencyResponseHistos.h:45
EfficiencyResponseHistos::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: EfficiencyResponseHistos.cxx:29
skel.it
it
Definition: skel.GENtoEVGEN.py:407
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::P4Helpers::deltaR2
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Definition: xAODP4Helpers.h:111
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
EfficiencyResponseHistos::m_eff1
TProfile * m_eff1
Definition: EfficiencyResponseHistos.h:37
EfficiencyResponseHistos::m_etres_noShift_eta
TProfile * m_etres_noShift_eta
Definition: EfficiencyResponseHistos.h:46
JetHistoBase
Definition: JetHistoBase.h:27
EfficiencyResponseHistos::m_eff2
TProfile * m_eff2
Definition: EfficiencyResponseHistos.h:38
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
python.TrigEgammaMonitorHelper.TProfile
def TProfile(*args, **kwargs)
Definition: TrigEgammaMonitorHelper.py:81
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EfficiencyResponseHistos::m_etres_noShift_pt
TProfile * m_etres_noShift_pt
Definition: EfficiencyResponseHistos.h:47
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
ToolHandleHistoHelper::HistoRetriever
Definition: ToolHandleHistoHelper.h:26
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
EfficiencyResponseHistos::buildHistos
virtual int buildHistos()
Definition: EfficiencyResponseHistos.cxx:34
python.ElectronD3PDObject.matched
matched
Definition: ElectronD3PDObject.py:138
Units.h
Wrapper to avoid constant divisions when using units.
EfficiencyResponseHistos::m_etres_pt
TProfile * m_etres_pt
Definition: EfficiencyResponseHistos.h:43
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
ToolHandleHistoHelper::HistoRetriever::build
T * build(const std::string &n)
Definition: ToolHandleHistoHelper.h:44
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
EfficiencyResponseHistos::fillHistosFromContainer
virtual int fillHistosFromContainer(const xAOD::JetContainer &cont, float weight)
Definition: EfficiencyResponseHistos.cxx:62
HistoGroupBase::bookHisto
T * bookHisto(T *h, Interval_t ityp=useToolInterval)
register the histo h in this group (if h!=NULL). The histo name is changed if m_prefixedHistoName==tr...
Definition: HistoGroupBase.h:69
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
EfficiencyResponseHistos::m_deltaRclosest
TH1F * m_deltaRclosest
Definition: EfficiencyResponseHistos.h:49
EfficiencyResponseHistos::EfficiencyResponseHistos
EfficiencyResponseHistos(const std::string &t)
Definition: EfficiencyResponseHistos.cxx:20
ToolHandleHistoHelper.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.