ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11#include "TH1.h"
12#include "TH2.h"
13#include "TProfile.h"
14#include <cmath>
15
16
17using 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
74 std::list<const xAOD::Jet*>::iterator it=listJets.begin();
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}
#define ATH_MSG_INFO(x)
#define CHECK(...)
Evaluate an expression and check for errors.
MDT_Response response
Wrapper to avoid constant divisions when using units.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
ToolHandleArray< HistoDefinitionTool > m_histoDef
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
EfficiencyResponseHistos(const std::string &t)
virtual int fillHistosFromContainer(const xAOD::JetContainer &cont, float weight)
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...
JetHistoBase(const std::string &t)
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".