ATLAS Offline Software
Loading...
Searching...
No Matches
JetTrimming.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "fastjet/PseudoJet.hh"
8#include "fastjet/JetDefinition.hh"
9#include "fastjet/Selector.hh"
11
13
14using namespace JetGrooming;
15
16namespace {
17 // tool implementing the operations to convert fastjet::PseudoJet -> xAOD::Jet
18 const static PseudoJetTranslator s_pjTranslator(false, false); // false => do not save jet areas
19}
20
21//**********************************************************************
22
25
26 // Unfortunately not possible to do this because there is no
27 // declareProperty overload for CheckedProperty in AsgTool
28 //
29 // Enforce upper/lower limits of Gaudi::Properties
30 // m_rclus.verifier().setBounds(0.,10.);
31 // m_ptfrac.verifier().setBounds(0.,1.);
32 if ( m_rclus < 0.0 || m_rclus > 10.0 ) {
33 ATH_MSG_ERROR("Invalid value " << m_rclus << "for RClus. Allowable range is 0-10");
34 return StatusCode::FAILURE;
35 }
37 ATH_MSG_ERROR("Invalid value " << m_ptfrac << "for PtFrac. Allowable range is 0-1");
38 return StatusCode::FAILURE;
39 }
40
41 // Define the trimmer
42 m_trimmer = std::make_unique<fastjet::Filter>(fastjet::JetDefinition(fastjet::kt_algorithm, m_rclus),
43 fastjet::SelectorPtFractionMin(m_ptfrac));
44
45 ATH_MSG_INFO(" Recluster R: " << m_rclus);
46 ATH_MSG_INFO(" pT faction min: " << m_ptfrac);
47
48 return StatusCode::SUCCESS;
49}
50
51
52//**********************************************************************
53
54void JetTrimming::insertGroomedJet(const xAOD::Jet& parentjet, const PseudoJetContainer& inpjcont, xAOD::JetContainer& outcont, PseudoJetVector& trimpjvec) const {
55
56 const static SG::AuxElement::Accessor<const fastjet::PseudoJet*> s_pjAcc("PseudoJet");
57 const static SG::AuxElement::ConstAccessor<const fastjet::PseudoJet*> s_pjConstAcc("PseudoJet");
58
59 // retrieve the PseudoJet from the parent :
60 const fastjet::PseudoJet& parentPJ = *s_pjConstAcc(parentjet);
61
62 // Trim :
63 fastjet::PseudoJet trimmedPJ = m_trimmer->result(parentPJ) ;
64 ATH_MSG_VERBOSE(" Input cluster sequence: " << parentPJ.associated_cluster_sequence());
65 ATH_MSG_VERBOSE(" Trimmed cluster sequence: " << trimmedPJ.associated_cluster_sequence());
66
67 // build the xAOD::Jet from the PseudoJet, and put it in the container
68 xAOD::Jet& jet = s_pjTranslator.translate(trimmedPJ, inpjcont, outcont, parentjet);
69 // The vector is resized externally to match the jet container size,
70 // so just fill the corresponding entry
71 trimpjvec[jet.index()] = trimmedPJ; // save a *copy* of this trimmed PJ
72
73 // decorate with the pointer to the PJ we keep in the evt store.
74 s_pjAcc(jet) = & trimpjvec[jet.index()];
75
76 int nptrim = trimmedPJ.pieces().size();
78 jet.setAttribute<int>(xAOD::JetAttribute::NTrimSubjets, nptrim);
79 // Need to convert from GaudiProperty
80 jet.setAttribute(xAOD::JetAttribute::RClus, float(m_rclus));
81 jet.setAttribute(xAOD::JetAttribute::PtFrac, float(m_ptfrac));
82 ATH_MSG_VERBOSE("Properties after trimming:");
83 ATH_MSG_VERBOSE(" ncon: " << trimmedPJ.constituents().size() << "/"
84 << parentPJ.constituents().size());
85 ATH_MSG_VERBOSE(" nsub: " << nptrim);
86}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
std::vector< fastjet::PseudoJet > PseudoJetVector
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< float > m_ptfrac
Definition JetTrimming.h:48
std::unique_ptr< fastjet::Filter > m_trimmer
Definition JetTrimming.h:44
Gaudi::Property< float > m_rclus
Definition JetTrimming.h:47
StatusCode initialize() override final
Dummy implementation of the initialisation function.
virtual void insertGroomedJet(const xAOD::Jet &, const PseudoJetContainer &, xAOD::JetContainer &, PseudoJetVector &) const override final
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".