ATLAS Offline Software
EfficiencyResponseHistos.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 
15 
16 using Athena::Units::GeV;
17 
18 
20  , m_histoDef(this)
21 {
22  declareProperty("HistoDef", m_histoDef, "The list of HistoDefinitionTool defining the histos to be used in this tool");
23  declareProperty("RefContainer", m_refContainerName);
24 }
25 
26 
27 
29  CHECK( m_histoDef.retrieve() );
30  return StatusCode::SUCCESS;
31 }
32 
34  ATH_MSG_INFO(" buildHistos num of histos : "<< m_histoDef.size() );
35 
37 
38  // Histos are defined in jobOptions !
39  // For each histo, ask hbuilder if a corresponding definition exists in the jobOption list.
40  // -> if so a valid histo is returned (and booked)
41  // -> else NULL is returned
42  m_eff1 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR1") );
43  m_eff2 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR2") );
44  m_eff3 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR3") );
45 
46  m_etres = bookHisto( hbuilder.build<TH1F>("erhResponse") );
47  m_etres_eta =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta") );
48  m_etres_pt =bookHisto( hbuilder.build<TProfile>("erhResponseVsPt") );
49 
50  m_etres_noShift = bookHisto( hbuilder.build<TH1F>("erhResponse_noShift") );
51  m_etres_noShift_eta =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_noShift") );
52  m_etres_noShift_pt =bookHisto( hbuilder.build<TProfile>("erhResponseVsPt_noShift") );
53 
54  m_deltaRclosest = bookHisto( hbuilder.build<TH1F>("erhDeltaR") );
55 
56 
57  return 0;
58 }
59 
60 
62 
63  const xAOD::JetContainer* refContainer = nullptr;
64  CHECK( evtStore()->retrieve( refContainer, m_refContainerName), 1 );
66  std::list<const xAOD::Jet*> listJets(cont.begin(), cont.end());
67 
68  for ( const xAOD::Jet* refjet : *refContainer ){
69  double dr2min = 500000;
70 
71  if (listJets.empty() ) break;
72  // find the min match
74  std::list<const xAOD::Jet*>::iterator itmin=listJets.end();
75  for( ; it != listJets.end(); ++it) {
76  double dr2 = jet::JetDistances::deltaR2(*(*it),*refjet);
77  if(dr2 < dr2min) { dr2min = dr2; itmin = it ;}
78  }
79  //cppcheck-suppress derefInvalidIterator
80  const xAOD::Jet* matched = *itmin;
81  listJets.erase(itmin);
82 
83  double dr = sqrt(dr2min);
84  double refPt = refjet->pt() / GeV;
85 
86  m_eff1->Fill(refPt, dr<0.1 ? weight : 0 ); // 0 weight if not matching close enough
87  m_eff2->Fill(refPt, dr<0.2 ? weight : 0 ); // 0 weight if not matching close enough
88  m_eff3->Fill(refPt, dr<0.3 ? weight : 0 ); // 0 weight if not matching close enough
89 
90  m_deltaRclosest->Fill( dr, weight );
91 
92  if( dr < 0.3) {
93  double relDiff = -999;
94  double response = -999;
95  if (refPt > 0.){
96  relDiff = ( matched->pt() / GeV - refPt )/refPt;
97  response = (matched->pt() / GeV)/refPt;
98  }
99  m_etres->Fill( relDiff, weight );
100  m_etres_eta->Fill( refjet->eta(), relDiff, weight);
101  m_etres_pt->Fill( refPt, relDiff, weight);
102 
103  m_etres_noShift->Fill( response, weight );
104  m_etres_noShift_eta->Fill( refjet->eta(), response, weight);
106  }
107 
108  }
109 
110 
111  return 0;
112 }
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:36
EfficiencyResponseHistos::m_refContainerName
std::string m_refContainerName
Definition: EfficiencyResponseHistos.h:29
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
EfficiencyResponseHistos::m_eff3
TProfile * m_eff3
Definition: EfficiencyResponseHistos.h:34
EfficiencyResponseHistos.h
response
MDT_Response response
Definition: MDT_ResponseTest.cxx:28
EfficiencyResponseHistos::m_etres_eta
TProfile * m_etres_eta
Definition: EfficiencyResponseHistos.h:37
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:28
EfficiencyResponseHistos::m_etres_noShift
TH1F * m_etres_noShift
Definition: EfficiencyResponseHistos.h:40
EfficiencyResponseHistos::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: EfficiencyResponseHistos.cxx:28
skel.it
it
Definition: skel.GENtoEVGEN.py:423
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
EfficiencyResponseHistos::m_eff1
TProfile * m_eff1
Definition: EfficiencyResponseHistos.h:32
EfficiencyResponseHistos::m_etres_noShift_eta
TProfile * m_etres_noShift_eta
Definition: EfficiencyResponseHistos.h:41
JetHistoBase
Definition: JetHistoBase.h:27
EfficiencyResponseHistos::m_eff2
TProfile * m_eff2
Definition: EfficiencyResponseHistos.h:33
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
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:42
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:581
EfficiencyResponseHistos::buildHistos
virtual int buildHistos()
Definition: EfficiencyResponseHistos.cxx:33
python.ElectronD3PDObject.matched
matched
Definition: ElectronD3PDObject.py:138
TProfile
Definition: rootspy.cxx:515
Units.h
Wrapper to avoid constant divisions when using units.
EfficiencyResponseHistos::m_etres_pt
TProfile * m_etres_pt
Definition: EfficiencyResponseHistos.h:38
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
TProfile::Fill
int Fill(double, double)
Definition: rootspy.cxx:523
TH1F
Definition: rootspy.cxx:320
EfficiencyResponseHistos::fillHistosFromContainer
virtual int fillHistosFromContainer(const xAOD::JetContainer &cont, float weight)
Definition: EfficiencyResponseHistos.cxx:61
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
EfficiencyResponseHistos::m_deltaRclosest
TH1F * m_deltaRclosest
Definition: EfficiencyResponseHistos.h:44
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
EfficiencyResponseHistos::EfficiencyResponseHistos
EfficiencyResponseHistos(const std::string &t)
Definition: EfficiencyResponseHistos.cxx:19
ToolHandleHistoHelper.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
JetDistances.h