ATLAS Offline Software
Loading...
Searching...
No Matches
JetModifiedMassDrop.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// JetModifiedMassDrop.cxx
6
8#include <iomanip>
9#include <algorithm>
10#include "fastjet/PseudoJet.hh"
11#include "fastjet/JetDefinition.hh"
12#include "fastjet/Selector.hh"
13#include "fastjet/tools/Filter.hh"
15
16#include "fastjet/ClusterSequence.hh"
17#include "fastjet/contrib/RecursiveSymmetryCutBase.hh"
18#include "fastjet/contrib/ModifiedMassDropTagger.hh"
19
20using std::setw;
21using fastjet::PseudoJet;
22using fastjet::contrib::RecursiveSymmetryCutBase;
24
25//**********************************************************************
26
28 : AsgTool(name), m_bld("",this) {
29 declareProperty("ZCut", m_zcut = 0.1);
30 declareProperty("SymmetryMeasure", m_sym = scalar_z);
31 declareProperty("MassDrop", m_mu = std::numeric_limits<double>::infinity() );
32 declareProperty("RecursionChoice", m_recursion = larger_pt);
33 declareProperty("doFilter", m_doFilt = true);
34 declareProperty("FilterNsubjets", m_filtNSub = 3);
35 declareProperty("FilterR", m_filtR = 0.3);
36 declareProperty("JetBuilder", m_bld);
37}
38
39//**********************************************************************
40
42
43//**********************************************************************
44
46 if ( m_zcut < 0.0 || m_zcut > 10.0 ) {
47 ATH_MSG_ERROR("Invalid value for ZCut " << m_zcut);
48 return StatusCode::FAILURE;
49 }
50 if ( m_mu < 0.0 ) {
51 ATH_MSG_ERROR("Invalid value for MassDrop " << m_mu);
52 }
53 if ( m_sym != y && m_sym != scalar_z && m_sym != vector_z ) {
54 ATH_MSG_ERROR("Invalid value for SymmetryMeasure " << m_sym);
55 return StatusCode::FAILURE;
56 }
58 ATH_MSG_ERROR("Invalid value for RecursionChoice " << m_recursion);
59 return StatusCode::FAILURE;
60 }
61 if ( m_bld.empty() ) {
62 ATH_MSG_ERROR("Unable to retrieve jet builder.");
63 return StatusCode::FAILURE;
64 }
65
66 return StatusCode::SUCCESS;
67}
68
69//**********************************************************************
70
72 const PseudoJetContainer& pjContainer,
73 xAOD::JetContainer& jets) const {
74 if ( pseudojetRetriever() == nullptr ) {
75 ATH_MSG_WARNING("Pseudojet retriever is null.");
76 return 1;
77 }
78 const PseudoJet* ppjin = pseudojetRetriever()->pseudojet(jin);
79 if ( ppjin == nullptr ) {
80 ATH_MSG_WARNING("Jet does not have a pseudojet.");
81 return 1;
82 }
83
85 //configure modified mass drop tagger tool
86 //http://fastjet.hepforge.org/svn/contrib/contribs/RecursiveTools/tags/1.0.0/ModifiedMassDropTagger.hh
88
89 // Could do this casting in the call to the ModifiedMassDropTagger constructor, doing it here for readability
90 RecursiveSymmetryCutBase::SymmetryMeasure sym = static_cast<RecursiveSymmetryCutBase::SymmetryMeasure>(m_sym);
91 RecursiveSymmetryCutBase::RecursionChoice recursion = static_cast<RecursiveSymmetryCutBase::RecursionChoice>(m_recursion);
92
93 //create the modified mass drop tagger, apply it to the input pseudojet
94 fastjet::contrib::ModifiedMassDropTagger MMDT(m_zcut,sym,m_mu,recursion);
95 // Use grooming mode to avoid getting empty pseudojets
96 MMDT.set_grooming_mode();
97 PseudoJet pjMMDT = MMDT(*ppjin);
98
99 bool didMMDT = pjMMDT.has_structure_of<fastjet::contrib::ModifiedMassDropTagger>();
100
101 // then filter the jet (useful for studies at moderate pt) if requested and if grooming succeeded
102 // with a dynamic Rfilt choice (as in arXiv:0802.2470)
103 PseudoJet filtpjMMDT = pjMMDT;
104 double Rfilt = m_filtR;
105 if ( m_doFilt && didMMDT ) {
106 Rfilt = std::min(m_filtR, pjMMDT.structure_of<fastjet::contrib::ModifiedMassDropTagger>().delta_R()*0.5);
107 fastjet::Filter filter(Rfilt, fastjet::SelectorNHardest(m_filtNSub));
108 filtpjMMDT = filter(pjMMDT);
109 }
110
111 int npMMDT = filtpjMMDT.pieces().size();
112 xAOD::Jet* pjet = m_bld->add(filtpjMMDT, pjContainer, jets, &jin);
113 if ( pjet == nullptr ) {
114 ATH_MSG_ERROR("Unable to add jet to container");
115 return 1;
116 }
117 //pjet->SetAttribute<int>("TransformType", xAOD::JetTransform::MMDT); // Possibly not needed
118 pjet->setAttribute("didMMDT", didMMDT);
119 pjet->setAttribute("ZCut", m_zcut);
120 pjet->setAttribute("mMDTSymmetryMeasure", m_sym);
121 pjet->setAttribute("mMDTRecursionChoice", m_recursion);
122 pjet->setAttribute("mMDTMu", m_mu);
123 pjet->setAttribute("FilterNSubjects", m_filtNSub);
124 pjet->setAttribute("FilterR", Rfilt);
125 pjet->setAttribute<int>("NmMDTSubjets", npMMDT);
126
127 ATH_MSG_DEBUG("Properties after softdrop:");
128 ATH_MSG_DEBUG(" ncon: " << pjMMDT.constituents().size() << "/"
129 << ppjin->constituents().size());
130 ATH_MSG_DEBUG(" nsub: " << npMMDT);
131
132 ATH_MSG_DEBUG("Added jet to container.");
133
134 return 0;
135}
136
137//**********************************************************************
138
140 //ATH_MSG_INFO(" Angular fraction min: " << m_zcut);
141 //ATH_MSG_INFO(" Angular exponent: " << m_beta);
142 ATH_MSG_INFO(" Jet builder: " << m_bld.name());
143}
144
145//**********************************************************************
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual const IJetPseudojetRetriever * pseudojetRetriever() const
Return the pseudojet retriever associated with this tool.
virtual const fastjet::PseudoJet * pseudojet(const xAOD::Jet &jet) const =0
Retrieve the pseudojet associate with a jet.
virtual void print() const override
Print the state of the tool.
JetModifiedMassDrop(const std::string &name)
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
@ larger_pt
choose the subjet with larger
@ larger_mt
choose the subjet with larger
@ larger_m
choose the subjet with larger mass (deprecated)
virtual int groom(const xAOD::Jet &jin, const PseudoJetContainer &, xAOD::JetContainer &jout) const override
Transform jet.
ToolHandle< IJetFromPseudojet > m_bld
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
void setAttribute(const std::string &name, const T &v)
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".