ATLAS Offline Software
Loading...
Searching...
No Matches
JetHistoResponseAndEff.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7
11
12JetHistoResponseAndEff::JetHistoResponseAndEff( const std::string& type, const std::string & name ,const IInterface* parent):
13 AthAlgTool( type, name, parent ),
14 m_refContainerKey("REFCONTAINER")
15{
16 declareInterface<IJetHistoFiller>(this);
17 declareProperty("RefContainerName",m_refContainerKey);
18}
19
20
22 ATH_CHECK( m_refContainerKey.initialize() );
23 ATH_MSG_DEBUG(" initialize "<< m_refContainerKey.key());
24 return StatusCode::SUCCESS;
25}
26
27
28StatusCode JetHistoResponseAndEff::processJetContainer(const JetMonitoringAlg& parentAlg, const xAOD::JetContainer & jets, const EventContext& ctx ) const {
29 if(jets.empty()) return StatusCode::SUCCESS;
30
31 // retrieve the reference jet container (typically : truth jets)
33 if (! refJets.isValid() ) {
34 ATH_MSG_ERROR("evtStore() does not contain jet Collection with name "<< m_refContainerKey.key());
35 return StatusCode::FAILURE;
36 }
37
38
39 // declare the variables to be monitored by the framework
40 Monitored::Scalar<float> refPt("refPt");
41 Monitored::Scalar<float> refEta("refEta");
42 Monitored::Scalar<float> relDiff("relDiff");
43 Monitored::Scalar<float> closestDr("closestDr");
44 Monitored::Scalar<bool> passDr1("passDr1");
45 Monitored::Scalar<bool> passDr2("passDr2");
46 Monitored::Scalar<bool> passDr3("passDr3");
47
48
49 std::vector<const xAOD::Jet*> listJets(jets.begin(), jets.end());
50
51 for ( const xAOD::Jet* refjet : *refJets ){
52 if (listJets.empty() ) break;
53 auto dr2 = [&] (const xAOD::Jet* j)
54 { return xAOD::P4Helpers::deltaR2(*j, *refjet); };
55 auto [dr2min, itmin] = CxxUtils::min_transformed_element (listJets, dr2);
56
57 // calculate efficiency and response from matched jet
58 const xAOD::Jet* matched = *itmin;
59
60 // Move the matched entry to the end of the vector and pop it off.
61 auto itend = listJets.end()-1;
62 if (itmin != itend) {
63 std::iter_swap (itmin, itend);
64 }
65 listJets.pop_back();
66
67 double dr = sqrt(dr2min);
68 refPt = refjet->pt() * m_energyScale;
69 closestDr = dr;
70
71 // Set flag passDrX if (reco,truth) jets are closer than deltaR=0.X
72 passDr1 = dr<0.1;
73 passDr2 = dr<0.2;
74 passDr3 = dr<0.3;
75 // using these flags, the framework will fill 3 TEfficiency to draw ( efficiency_at_drX vs pT) (see also configuration) :
76 parentAlg.fill(m_group, refPt , passDr1, passDr2, passDr3 , closestDr);
77
78 if( dr < 0.3) {
79 if (refPt > 0.) relDiff = ( matched->pt()* m_energyScale - refPt )/refPt;
80 else relDiff = -999;
81 refEta = refjet->eta();
82 parentAlg.fill(m_group, refPt , refEta, relDiff );
83 }
84
85 }
86
87 return StatusCode::SUCCESS;
88}
89
90
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Gaudi::Property< float > m_energyScale
virtual StatusCode processJetContainer(const JetMonitoringAlg &parentAlg, const xAOD::JetContainer &jets, const EventContext &ctx) const
SG::ReadHandleKey< xAOD::JetContainer > m_refContainerKey
Gaudi::Property< std::string > m_group
virtual StatusCode initialize()
JetHistoResponseAndEff(const std::string &type, const std::string &name, const IInterface *parent)
A monitoring algorithm in charge of filling histogram for a JetContainer.
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
Return the minimum or maximum element from a transformed range.
auto min_transformed_element(RANGE &&r, FUNC &&f)
Find the minimum transformed element in a range.
void iter_swap(typename DataModel_detail::iterator< DV > a, typename DataModel_detail::iterator< DV > b)
Specialization of iter_swap for DataVector/DataList.
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".