Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
12 JetHistoResponseAndEff::JetHistoResponseAndEff( const std::string& type, const std::string & name ,const IInterface* parent):
14  m_refContainerKey("REFCONTAINER")
15 {
16  declareInterface<IJetHistoFiller>(this);
17  declareProperty("RefContainerName",m_refContainerKey);
18 }
19 
20 
23  ATH_MSG_DEBUG(" initialize "<< m_refContainerKey.key());
24  return StatusCode::SUCCESS;
25 }
26 
27 
28 StatusCode 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 
minmax_transformed_element.h
Return the minimum or maximum element from a transformed range.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
xAODP4Helpers.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JetHistoResponseAndEff.h
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
xAOD::P4Helpers::deltaR2
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Definition: xAODP4Helpers.h:111
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
GenericMonitoringTool.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
JetHistoResponseAndEff::m_energyScale
Gaudi::Property< float > m_energyScale
Definition: JetHistoResponseAndEff.h:30
JetHistoResponseAndEff::m_refContainerKey
SG::ReadHandleKey< xAOD::JetContainer > m_refContainerKey
Definition: JetHistoResponseAndEff.h:31
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
AthMonitorAlgorithm::fill
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.
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
JetHistoResponseAndEff::initialize
virtual StatusCode initialize()
Definition: JetHistoResponseAndEff.cxx:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
python.ElectronD3PDObject.matched
matched
Definition: ElectronD3PDObject.py:138
JetMonitoringAlg
Definition: JetMonitoringAlg.h:26
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
JetMonitoringAlg.h
JetHistoResponseAndEff::JetHistoResponseAndEff
JetHistoResponseAndEff(const std::string &type, const std::string &name, const IInterface *parent)
Definition: JetHistoResponseAndEff.cxx:12
JetHistoResponseAndEff::m_group
Gaudi::Property< std::string > m_group
Definition: JetHistoResponseAndEff.h:29
JetHistoResponseAndEff::processJetContainer
virtual StatusCode processJetContainer(const JetMonitoringAlg &parentAlg, const xAOD::JetContainer &jets, const EventContext &ctx) const
Definition: JetHistoResponseAndEff.cxx:28
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
AthAlgTool
Definition: AthAlgTool.h:26
CxxUtils::min_transformed_element
auto min_transformed_element(RANGE &&r, FUNC &&f)
Find the minimum transformed element in a range.
Definition: minmax_transformed_element.h:50