ATLAS Offline Software
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 
7 #include "JetRec/JetSplitter.h"
8 #include <iomanip>
9 #include "fastjet/PseudoJet.hh"
10 #include "fastjet/tools/MassDropTagger.hh"
11 #include "fastjet/tools/Filter.hh"
12 #include "JetEDM/PseudoJetVector.h"
15 #include "JetRec/JetDumper.h"
16 
17 using std::setw;
18 using fastjet::PseudoJet;
19 using fastjet::MassDropTagger;
20 using fastjet::Filter;
22 using fastjet::JetDefinition;
23 using fastjet::SelectorNHardest;
24 using xAOD::JetContainer;
27 
28 //**********************************************************************
29 
30 JetSplitter::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 
44  delete m_pdmp;
45 }
46 
47 //**********************************************************************
48 
50  if ( m_mumax < 0.0 || m_mumax > 1.0 ) {
51  ATH_MSG_ERROR("Invalid value for MuMax: " << m_mumax);
52  return StatusCode::FAILURE;
53  }
54  if ( m_mumax < 0.0 || m_mumax > 1.0 ) {
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 
163 void 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 //**********************************************************************
JetSplitter::JetSplitter
JetSplitter(const std::string &name)
Definition: JetSplitter.cxx:30
JetSplitter::m_nsubjetmax
int m_nsubjetmax
Definition: JetSplitter.h:54
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PseudoJetVector.h
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
JetSplitter::groom
int groom(const xAOD::Jet &jin, const PseudoJetContainer &, xAOD::JetContainer &jout) const
Transform jet.
Definition: JetSplitter.cxx:67
IJetGroomer::pseudojetRetriever
virtual const IJetPseudojetRetriever * pseudojetRetriever() const
Return the pseudojet retriever associated with this tool.
Definition: IJetGroomer.cxx:21
JetDumper.h
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
JetSplitter::m_bld
ToolHandle< IJetFromPseudojet > m_bld
Definition: JetSplitter.h:51
JetSplitter::print
void print() const
Print the state of the tool.
Definition: JetSplitter.cxx:163
PseudoJetContainer
Definition: PseudoJetContainer.h:48
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
JetSplitter::m_pdmp
JetDumper * m_pdmp
Definition: JetSplitter.h:57
covarianceTool.filter
filter
Definition: covarianceTool.py:514
JetSplitter::m_ymin
float m_ymin
Definition: JetSplitter.h:50
JetSplitter::~JetSplitter
~JetSplitter()
Definition: JetSplitter.cxx:43
JetConstituentFiller.h
JetDumper
Tool to dump jets to the log.
Definition: JetDumper.h:55
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
JetSplitter::m_rclus
float m_rclus
Definition: JetSplitter.h:52
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
IConstituentUserInfo.h
JetSplitter::m_mumax
float m_mumax
Definition: JetSplitter.h:49
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::JetTransform::MassDrop
@ MassDrop
Definition: JetContainerInfo.h:117
xAOD::Jet_v1::setAttribute
void setAttribute(const std::string &name, const T &v)
JetSplitter.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
JetSplitter::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: JetSplitter.cxx:49
IJetPseudojetRetriever::pseudojet
virtual const fastjet::PseudoJet * pseudojet(const xAOD::Jet &jet) const =0
Retrieve the pseudojet associate with a jet.
xAOD::JetAlgorithmType::cambridge_algorithm
@ cambridge_algorithm
Definition: JetContainerInfo.h:32
JetDumper::dump_collection
int dump_collection(const TList *pjets, const std::string &objtypename="Unknown") const
Definition: JetDumper.h:369
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
y
#define y
jet::JetConstituentFiller
Definition: JetConstituentFiller.h:27
jet::IConstituentUserInfo
Definition: IConstituentUserInfo.h:26
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
JetSplitter::m_bdrs
bool m_bdrs
Definition: JetSplitter.h:53
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition: JetContainer.h:17
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
python.StandardJetMods.Filter
Filter
Definition: StandardJetMods.py:34
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53