ATLAS Offline Software
Loading...
Searching...
No Matches
JetSplitter.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// JetSplitter.cxx
6
8#include <iomanip>
9#include "fastjet/PseudoJet.hh"
10#include "fastjet/tools/MassDropTagger.hh"
11#include "fastjet/tools/Filter.hh"
15#include "JetRec/JetDumper.h"
16
17using std::setw;
18using fastjet::PseudoJet;
19using fastjet::MassDropTagger;
20using fastjet::Filter;
21using fastjet::cambridge_algorithm;
22using fastjet::JetDefinition;
23using fastjet::SelectorNHardest;
27
28//**********************************************************************
29
30JetSplitter::JetSplitter(const std::string& name)
31 : AsgTool(name), m_bld("",this),
32 m_pdmp(new JetDumper(name+"Dumper")) {
33 declareProperty("MuMax", m_mumax =1.0);
34 declareProperty("YMin", m_ymin =0.0);
35 declareProperty("RClus", m_rclus =0.3);
36 declareProperty("BDRS", m_bdrs =false);
37 declareProperty("NSubjetMax", m_nsubjetmax =3);
38 declareProperty("JetBuilder", m_bld);
39}
40
41//**********************************************************************
42
46
47//**********************************************************************
48
51 ATH_MSG_ERROR("Invalid value for MuMax: " << m_mumax);
52 return StatusCode::FAILURE;
53 }
55 ATH_MSG_ERROR("Invalid value for YMin: " << m_ymin);
56 return StatusCode::FAILURE;
57 }
58 if ( m_bld.empty() ) {
59 ATH_MSG_ERROR("Unable to retrieve jet builder.");
60 return StatusCode::FAILURE;
61 }
62 return StatusCode::SUCCESS;
63}
64
65//**********************************************************************
66
68 const PseudoJetContainer& pjContainer,
69 xAOD::JetContainer& jets) const {
70 MassDropTagger mdtagger(m_mumax, m_ymin);
71 if ( pseudojetRetriever() == nullptr ) {
72 ATH_MSG_WARNING("Pseudojet retriever is null.");
73 return 1;
74 }
75 const PseudoJet* ppjin = pseudojetRetriever()->pseudojet(jin);
76 if ( ppjin == nullptr ) {
77 ATH_MSG_WARNING("Jet does not have a pseudojet.");
78 return 1;
79 }
80 ATH_MSG_VERBOSE("Input pseudojet pT: " << ppjin->pt());
81 ATH_MSG_VERBOSE("Input pseudojet has area: " << ppjin->has_area());
82 int nconin = ppjin->constituents().size();
83 PseudoJet pjfilt = mdtagger(*ppjin);
84 if ( pjfilt == 0 ) {
85 ATH_MSG_DEBUG("Jet rejected by splitter.");
86 return 1;
87 }
88 ATH_MSG_DEBUG("Jet accepted by splitter.");
89 PseudoJet parent1 = pjfilt.pieces()[0];
90 PseudoJet parent2 = pjfilt.pieces()[1];
91 int npfilt = pjfilt.pieces().size();
92 double drfilt = parent1.delta_R(parent2);
93 double mufilt = pjfilt.structure_of<MassDropTagger>().mu();
94 double yfilt = pjfilt.structure_of<MassDropTagger>().y();
95 ATH_MSG_DEBUG("Properties after filtering:");
96 ATH_MSG_DEBUG(" pT: " << pjfilt.pt());
97 ATH_MSG_DEBUG(" has A: " << pjfilt.has_area());
98 ATH_MSG_DEBUG(" ncon: " << pjfilt.constituents().size() << "/" << nconin);
99 ATH_MSG_DEBUG(" nsub: " << npfilt);
100 ATH_MSG_DEBUG(" DR12: " << drfilt);
101 ATH_MSG_DEBUG(" mu: " << mufilt);
102 ATH_MSG_DEBUG(" y: " << yfilt);
103 if ( msgLvl(MSG::VERBOSE) ) {
104 std::vector<PseudoJet> cons = pjfilt.constituents();
105 m_pdmp->dump_collection(&cons, "Jet");
106 }
107
108 // Recluster.
109 double rclus = m_rclus;
110 if ( m_bdrs ) {
111 double rbdrs = 0.5*drfilt;
112 if ( rbdrs < rclus ) rclus = rbdrs;
113 }
114 Filter filter(JetDefinition(cambridge_algorithm, rclus),
115 SelectorNHardest(m_nsubjetmax));
116 PseudoJet pjclus = filter(pjfilt);
117 ATH_MSG_DEBUG("Properties after reclustering:");
118 ATH_MSG_DEBUG(" pT: " << pjclus.pt());
119 ATH_MSG_DEBUG(" has A: " << pjclus.has_area());
120 ATH_MSG_VERBOSE(" Input cluster sequence: " << ppjin->associated_cluster_sequence());
121 ATH_MSG_VERBOSE(" Filtered cluster sequence: " << pjfilt.associated_cluster_sequence());
122 ATH_MSG_VERBOSE(" Reclustered cluster sequence: " << pjclus.associated_cluster_sequence());
123 int npclus = pjclus.pieces().size();
124 double drclus = 0.0;
125 double muclus = 0.0;
126 double yclus = 0.0;
127 if ( npclus > 1 ) {
128 PseudoJet parent1 = pjclus.pieces()[0];
129 PseudoJet parent2 = pjclus.pieces()[1];
130 drclus= parent1.delta_R(parent2);
131 }
132 ATH_MSG_DEBUG("Properties after reclustering:");
133 ATH_MSG_DEBUG(" ncon: " << pjclus.constituents().size() << "/"
134 << pjfilt.constituents().size() << "/" << nconin);
135 ATH_MSG_DEBUG(" nsub: " << npclus);
136 ATH_MSG_DEBUG(" DR12: " << drclus);
137 ATH_MSG_DEBUG(" mu: " << muclus);
138 ATH_MSG_DEBUG(" y: " << yclus);
139
140 // Add jet to collection.
141 xAOD::Jet* pjet = m_bld->add(pjclus, pjContainer, jets, &jin);
142 if ( pjet == nullptr ) {
143 ATH_MSG_ERROR("Unable to add jet to container");
144 } else {
145 ATH_MSG_DEBUG("Added jet to container.");
146 pjet->setAttribute<int>("TransformType", xAOD::JetTransform::MassDrop);
147 pjet->setAttribute<float>("MuMax", m_mumax);
148 pjet->setAttribute<float>("YMin", m_ymin);
149 pjet->setAttribute<float>("RClus", m_rclus);
150 //this has to be a char, because by default bools are converted to chars in perstification. Thus if we run this tool on an exiting collection in a POOL file the type is char.
151 pjet->setAttribute<char>("BDRS", m_bdrs);
152 pjet->setAttribute<int>("NSubjetMax", m_nsubjetmax);
153 pjet->setAttribute<float>("DRFilt", drfilt);
154 pjet->setAttribute<float>("MuFilt", mufilt);
155 pjet->setAttribute<float>("YFilt", yfilt);
156 pjet->setAttribute<int>("NSubjet", npclus);
157 }
158 return 0;
159}
160
161//**********************************************************************
162
163void JetSplitter::print() const {
164 ATH_MSG_INFO(" mu max: " << m_mumax);
165 ATH_MSG_INFO(" y min: " << m_ymin);
166 ATH_MSG_INFO(" Recluster R: " << m_rclus);
167 ATH_MSG_INFO(" Use BDRS: " << m_bdrs);
168 ATH_MSG_INFO(" # subjets: " << m_nsubjetmax);
169 ATH_MSG_INFO(" Jet builder: " << m_bld.name());
170}
171
172//**********************************************************************
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define y
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
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.
Tool to dump jets to the log.
Definition JetDumper.h:55
float m_mumax
Definition JetSplitter.h:49
int groom(const xAOD::Jet &jin, const PseudoJetContainer &, xAOD::JetContainer &jout) const
Transform jet.
float m_rclus
Definition JetSplitter.h:52
void print() const
Print the state of the tool.
StatusCode initialize()
Dummy implementation of the initialisation function.
JetDumper * m_pdmp
Definition JetSplitter.h:57
ToolHandle< IJetFromPseudojet > m_bld
Definition JetSplitter.h:51
JetSplitter(const std::string &name)
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".