ATLAS Offline Software
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"
14 #include "JetEDM/PseudoJetVector.h"
15 
16 #include "fastjet/ClusterSequence.hh"
17 #include "fastjet/contrib/RecursiveSymmetryCutBase.hh"
18 #include "fastjet/contrib/ModifiedMassDropTagger.hh"
19 
20 using std::setw;
21 using fastjet::PseudoJet;
22 using fastjet::contrib::RecursiveSymmetryCutBase;
23 using xAOD::JetContainer;
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 //**********************************************************************
JetModifiedMassDrop::vector_z
@ vector_z
Definition: JetModifiedMassDrop.h:41
JetModifiedMassDrop::larger_m
@ larger_m
choose the subjet with larger mass (deprecated)
Definition: JetModifiedMassDrop.h:49
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
JetModifiedMassDrop::m_mu
float m_mu
Definition: JetModifiedMassDrop.h:73
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PseudoJetVector.h
JetModifiedMassDrop::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: JetModifiedMassDrop.cxx:45
IJetGroomer::pseudojetRetriever
virtual const IJetPseudojetRetriever * pseudojetRetriever() const
Return the pseudojet retriever associated with this tool.
Definition: IJetGroomer.cxx:21
PseudoJetContainer
Definition: PseudoJetContainer.h:48
JetModifiedMassDrop::scalar_z
@ scalar_z
Definition: JetModifiedMassDrop.h:40
JetModifiedMassDrop::m_filtR
double m_filtR
Definition: JetModifiedMassDrop.h:75
JetModifiedMassDrop::m_doFilt
bool m_doFilt
Definition: JetModifiedMassDrop.h:74
JetModifiedMassDrop::m_filtNSub
int m_filtNSub
Definition: JetModifiedMassDrop.h:76
covarianceTool.filter
filter
Definition: covarianceTool.py:514
JetModifiedMassDrop::m_zcut
float m_zcut
Definition: JetModifiedMassDrop.h:72
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
JetModifiedMassDrop::y
@ y
Definition: JetModifiedMassDrop.h:42
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
JetModifiedMassDrop::m_bld
ToolHandle< IJetFromPseudojet > m_bld
Definition: JetModifiedMassDrop.h:83
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::Jet_v1::setAttribute
void setAttribute(const std::string &name, const T &v)
min
#define min(a, b)
Definition: cfImp.cxx:40
JetModifiedMassDrop::groom
virtual int groom(const xAOD::Jet &jin, const PseudoJetContainer &, xAOD::JetContainer &jout) const override
Transform jet.
Definition: JetModifiedMassDrop.cxx:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
IJetPseudojetRetriever::pseudojet
virtual const fastjet::PseudoJet * pseudojet(const xAOD::Jet &jet) const =0
Retrieve the pseudojet associate with a jet.
JetModifiedMassDrop::larger_mt
@ larger_mt
choose the subjet with larger
Definition: JetModifiedMassDrop.h:48
JetModifiedMassDrop::larger_pt
@ larger_pt
choose the subjet with larger
Definition: JetModifiedMassDrop.h:47
JetModifiedMassDrop::~JetModifiedMassDrop
~JetModifiedMassDrop()
JetModifiedMassDrop::m_recursion
int m_recursion
Definition: JetModifiedMassDrop.h:81
JetModifiedMassDrop::print
virtual void print() const override
Print the state of the tool.
Definition: JetModifiedMassDrop.cxx:139
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
JetModifiedMassDrop.h
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition: JetContainer.h:17
python.StandardJetMods.Filter
Filter
Definition: StandardJetMods.py:34
JetModifiedMassDrop::m_sym
int m_sym
Definition: JetModifiedMassDrop.h:79
JetModifiedMassDrop::JetModifiedMassDrop
JetModifiedMassDrop(const std::string &name)
Definition: JetModifiedMassDrop.cxx:27