ATLAS Offline Software
JetReclusteringTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "AsgMessaging/Check.h"
7 
15 
16 #include <sstream>
17 
18 #ifdef ROOTCORE // The macro for RootCore needs these (provides a way of getting around missing dictionaries)
19 #include "JetRec/JetFilterTool.h"
20 #include "JetRec/JetRecTool.h"
21 #include "JetRec/PseudoJetGetter.h"
23 #include "JetRec/JetFinder.h"
24 #include "JetRec/JetTrimmer.h"
35 #endif
36 
38  AsgTool(name),
39  m_jetFilterTool("JetFilterTool/JetFilterTool_" + this->name()),
40  m_inputJetFilterTool("JetRecTool/JetRec_InputJetFilterTool_" + this->name()),
41  m_pseudoJetGetterTool("PseudoJetGetter/PseudoJetGetterTool_" + this->name()),
42  m_jetFromPseudoJetTool("JetFromPseudojet/JetFromPseudoJetTool_" + this->name()),
43  m_jetFinderTool("JetFinder/JetFinderTool_" + this->name()),
44  m_reclusterJetTool("JetRecTool/JetRec_JetReclusterTool_" + this->name()),
45  m_trimJetTool("JetRecTool/JetRec_JetTrimTool_" + this->name()),
46  m_effectiveRTool("EffectiveRTool/EffectiveRTool"),
47  m_jetTrimmingTool("JetTrimmer/JetTrimmerTool_" + this->name()),
48  m_jetTrimmingTool_JPJR("JetPseudojetRetriever/JetRec_JetTrimTool_JPJR_" + this->name()),
49  m_jetChargeTool("JetChargeTool/JetChargeTool_" + this->name()),
50  m_jetPullTool("JetPullTool/JetPullTool_" + this->name()),
51  m_energyCorrelatorTool("EnergyCorrelatorTool/EnergyCorrelatorTool_" + this->name()),
52  m_energyCorrelatorRatiosTool("EnergyCorrelatorRatiosTool/EnergyCorrelatorRatiosTool_" + this->name()),
53  m_ktSplittingScaleTool("KTSplittingScaleTool/KTSplittingScaleTool_" + this->name()),
54  m_dipolarityTool("DipolarityTool/DipolarityTool_" + this->name()),
55  m_centerOfMassShapesTool("CenterOfMassShapesTool/CenterOfMassShapesTool_" + this->name()),
56  m_nSubjettinessTool("NSubjettinessTool/NSubjettinessTool_" + this->name())
57 {
58 
59 
60  declareProperty("InputJetContainer", m_inputJetContainer = "");
61  declareProperty("OutputJetContainer", m_outputJetContainer = "");
62  declareProperty("ReclusterRadius", m_radius = 1.0);
63  declareProperty("ReclusterAlgorithm", m_rc_alg = "AntiKt");
64  declareProperty("VariableRMinRadius", m_varR_minR =-1.0);
65  declareProperty("VariableRMassScale", m_varR_mass =-1.0);
66  declareProperty("InputJetPtMin", m_ptMin_input = 25.0);
67  declareProperty("RCJetPtMin", m_ptMin_rc = 50.0);
68  declareProperty("RCJetPtFrac", m_ptFrac = 0.05);
69  declareProperty("RCJetSubjetRadius", m_subjet_radius = 0.2);
70  declareProperty("DoArea", m_doArea = false);
71  declareProperty("AreaAttributes", m_areaAttributes = "ActiveArea ActiveArea4vec");
72 
73 }
74 
76  if(m_isInitialized){
77  ATH_MSG_WARNING(m_APP_NAME << " already initialized.");
78  return StatusCode::FAILURE;
79  }
80  ATH_MSG_INFO(m_APP_NAME << " initializing");
81  ATH_MSG_INFO( "Name is " << name());
82 
83 
84  ATH_MSG_INFO( "... with containers:" );
85  ATH_MSG_INFO( "\tInputJetContainer: " << m_inputJetContainer );
86  ATH_MSG_INFO( "\tOutputJetContainer: " << m_outputJetContainer );
87 
88  // set to true, we're calling it now
89  m_isInitialized = true;
90 
91  // set up some stuff to use within the initialize()
92  ToolHandleArray<IJetModifier> modArray;
93  ToolHandleArray<IPseudoJetGetter> getterArray;
94 
95  // this is for intermediate output containers used between tools
96  std::string filteredInputJetContainer(m_inputJetContainer);
97  if(m_ptMin_input > 0) filteredInputJetContainer = "Filtered_"+name();
98  std::string filteredInputPseudoJetsContainer = "PseudoJets_"+name();
99  std::string reclusteredJetsContainer = "ReclusteredJets_"+name();
100 
101  if(m_ptMin_input > 0){
102  ATH_MSG_INFO( "Input Jet Filtering" );
103  ATH_MSG_INFO( "\tPtMin: " << m_ptMin_input*1.e3 << " GeV" );
104  /* initialize input jet filtering */
105  // - create a tool that will filter jets
108  ASG_CHECK(m_jetFilterTool.setProperty("OutputLevel", msg().level() ) );
110  modArray.clear();
111  modArray.push_back(m_jetFilterTool.getHandle() );
112  ATH_CHECK(modArray.retrieve() );
113 
114  // - create the master tool to filter the input jets
117  ASG_CHECK(m_inputJetFilterTool.setProperty("OutputContainer", filteredInputJetContainer));
118  ASG_CHECK(m_inputJetFilterTool.setProperty("JetModifiers", modArray));
119  /* note: we cannot use shallow copies since we are removing elements from a
120  * container, we need a deep copy as linking will break */
121  ASG_CHECK(m_inputJetFilterTool.setProperty("ShallowCopy", false));
122  ASG_CHECK(m_inputJetFilterTool.setProperty("OutputLevel", msg().level() ) );
124  }
125 
126  // only compute area if ptFrac = 0.0 and m_areaAttributes is specified
127  float ghostArea(0.0);
128  std::vector<std::string> areaAttributes;
129  if(m_doArea){
130  ATH_MSG_INFO( "Ghost Area Calculations:" );
131  ATH_MSG_INFO( "\tAreaAttributes: " << m_areaAttributes );
132  ghostArea = 0.01;
133  // split up the m_areaAttributes string specifying which attributes to record
134  std::string token;
135  std::istringstream ss(m_areaAttributes);
136  while(std::getline(ss, token, ' '))
137  areaAttributes.push_back(token);
138  }
139  /* initialize jet reclustering */
140  // - create a PseudoJet builder.
141  ATH_MSG_INFO( "PseudoJet Builder initializing..." );
142  m_pseudoJetGetterTool.setType ("PseudoJetGetter");
143  ASG_CHECK(m_pseudoJetGetterTool.setProperty("InputContainer", filteredInputJetContainer));
144  ASG_CHECK(m_pseudoJetGetterTool.setProperty("OutputContainer", filteredInputPseudoJetsContainer));
145  ASG_CHECK(m_pseudoJetGetterTool.setProperty("Label", "LCTopo"));
146  ASG_CHECK(m_pseudoJetGetterTool.setProperty("SkipNegativeEnergy", true));
147  ASG_CHECK(m_pseudoJetGetterTool.setProperty("GhostScale", 0.0));
148  ASG_CHECK(m_pseudoJetGetterTool.setProperty("OutputLevel", msg().level() ) );
150  getterArray.push_back(m_pseudoJetGetterTool.getHandle());
151  ATH_CHECK(getterArray.retrieve() );
152  // - create a Jet builder
153  ATH_MSG_INFO( "Jet Builder initializing..." );
154  m_jetFromPseudoJetTool.setType ("JetFromPseudojet");
155  ASG_CHECK(m_jetFromPseudoJetTool.setProperty("Attributes", areaAttributes));
156  ASG_CHECK(m_jetFromPseudoJetTool.setProperty("OutputLevel", msg().level() ) );
158  // - create a ClusterSequence Tool
159  ATH_MSG_INFO( "Cluster Sequencer initializing..." );
160  m_jetFinderTool.setType ("JetFinder");
161  ASG_CHECK(m_jetFinderTool.setProperty("JetAlgorithm", m_rc_alg));
163  ASG_CHECK(m_jetFinderTool.setProperty("VariableRMinRadius", m_varR_minR));
164  ASG_CHECK(m_jetFinderTool.setProperty("VariableRMassScale", m_varR_mass*1.e3));
166  // set ghost area, ignore if trimming is being applied to reclustered jets
167  ASG_CHECK(m_jetFinderTool.setProperty("GhostArea", ghostArea));
168  ASG_CHECK(m_jetFinderTool.setProperty("RandomOption", 1));
170  ASG_CHECK(m_jetFinderTool.setProperty("OutputLevel", msg().level() ) );
172  // - create list of modifiers.
173  modArray.clear();
174  // we need to calculate effectiveR before trimming, if we are doing variableR
175  m_effectiveRTool.setType ("EffectiveRTool");
177  modArray.push_back(m_effectiveRTool.getHandle() );
178  ATH_CHECK(modArray.retrieve() );
179  // - create our master reclustering tool
180  ATH_MSG_INFO( "Jet Reclusterer initializing..." );
181  m_reclusterJetTool.setType ("JetRecTool");
182  ASG_CHECK(m_reclusterJetTool.setProperty("OutputContainer", reclusteredJetsContainer));
183  ASG_CHECK(m_reclusterJetTool.setProperty("PseudoJetGetters", getterArray));
185  ASG_CHECK(m_reclusterJetTool.setProperty("JetModifiers", modArray));
186  ASG_CHECK(m_reclusterJetTool.setProperty("OutputLevel", msg().level() ) );
188 
189  // clear modArray again
190  modArray.clear();
191  // then trim the reclustered jets
192  ATH_MSG_INFO( "Jet Trimmer initializing..." );
193  ATH_MSG_INFO( "\tPtFrac: " << m_ptFrac );
194  ATH_MSG_INFO( "\tRClus: " << m_subjet_radius );
195  m_jetTrimmingTool.setType ("JetTrimmer");
199  ASG_CHECK(m_jetTrimmingTool.setProperty("OutputLevel", msg().level() ) );
201 
202  // because of changes to JetRec, can't rely on them making this tool for us anymore
203  ATH_MSG_INFO( "JetPseudojetRetriever initializing for Jet Trimmer..." );
204  m_jetTrimmingTool_JPJR.setType ("JetPseudojetRetriever");
206 
207  // and then apply all other modifiers based on the trimmed reclustered jets
208  ATH_MSG_INFO( "\t... and queuing up various jet modifiers..." );
209 
210  m_jetChargeTool.setType ("JetChargeTool");
212  modArray.push_back(m_jetChargeTool.getHandle() );
213 
214  m_jetPullTool.setType ("JetPullTool");
216  modArray.push_back(m_jetPullTool.getHandle() );
217 
218  m_energyCorrelatorTool.setType ("EnergyCorrelatorTool");
220  modArray.push_back(m_energyCorrelatorTool.getHandle() );
221 
222  m_energyCorrelatorRatiosTool.setType ("EnergyCorrelatorRatiosTool");
224  modArray.push_back(m_energyCorrelatorRatiosTool.getHandle() );
225 
226  m_ktSplittingScaleTool.setType ("KTSplittingScaleTool");
228  modArray.push_back(m_ktSplittingScaleTool.getHandle() );
229 
230  m_dipolarityTool.setType ("DipolarityTool");
232  modArray.push_back(m_dipolarityTool.getHandle() );
233 
234  m_centerOfMassShapesTool.setType ("CenterOfMassShapesTool");
236  modArray.push_back(m_centerOfMassShapesTool.getHandle() );
237 
238  m_nSubjettinessTool.setType ("NSubjettinessTool");
240  modArray.push_back(m_nSubjettinessTool.getHandle() );
241  ATH_CHECK(modArray.retrieve() );
242  // finish up the rest of the tool
243 
244  m_trimJetTool.setType ("JetRecTool");
245  ASG_CHECK(m_trimJetTool.setProperty("InputContainer", reclusteredJetsContainer));
247  ASG_CHECK(m_trimJetTool.setProperty("JetModifiers", modArray));
250  ASG_CHECK(m_trimJetTool.setProperty("OutputLevel", msg().level() ) );
252 
253  return StatusCode::SUCCESS;
254 }
255 
257  int retCode = 0;
258  if(m_ptMin_input > 0) {
259  if ( (retCode = m_inputJetFilterTool->execute() ) != 0) {
260  ATH_MSG_ERROR( "Failure in inputJetFilterTool with return code: " << retCode );
261  return retCode;
262  }
263  }
264  if ( (retCode = m_reclusterJetTool->execute() ) != 0) {
265  ATH_MSG_ERROR( "Failure in reclusterJetTool with return code: " << retCode );
266  return retCode;
267  }
268  if ( (retCode = m_trimJetTool->execute() ) != 0) {
269  ATH_MSG_ERROR( "Failure in trimJetTool with return code: " << retCode );
270  return retCode;
271  }
272  return 0;
273 }
274 
276  ATH_MSG_INFO("Properties for " << m_APP_NAME << "(" << name() << ")");
277  ATH_MSG_INFO(" InputJetContainer: " << m_inputJetContainer );
278  ATH_MSG_INFO(" OutputJetContainer: " << m_outputJetContainer );
279  ATH_MSG_INFO(" Radius: " << m_radius );
280  ATH_MSG_INFO(" ReclusteringAlgorithm: " << m_rc_alg << " (" << m_rc_alg << ")" );
281  ATH_MSG_INFO(" VariableRMinRadius: " << m_varR_minR );
282  ATH_MSG_INFO(" VariableRMassScale: " << m_varR_mass << " GeV" );
283  ATH_MSG_INFO(" InputJetPtCut: " << m_ptMin_input << " GeV" );
284  ATH_MSG_INFO(" ReclusteredJetPtCut: " << m_ptMin_rc << " GeV" );
285  ATH_MSG_INFO(" ReclusteredJetPtFrac: " << m_ptFrac );
286  ATH_MSG_INFO(" ReclusteredJetSubjetR: " << m_subjet_radius );
287 
288  if(m_isInitialized){
291  m_trimJetTool->print();
292  } else {
293  ATH_MSG_INFO(m_APP_NAME << " has not been initialized yet");
294  }
295 
296  }
JetFinder.h
JetPullTool.h
ASG_CHECK
#define ASG_CHECK(...)
Helper macro for checking the status code returned by a function call.
Definition: Check.h:39
asg::IAsgTool::print
virtual void print() const =0
Print the state of the tool.
Check.h
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
JetReclusteringTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: JetReclusteringTool.cxx:75
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
JetReclusteringTool::m_ptFrac
float m_ptFrac
Definition: JetReclusteringTool.h:71
asg::AnaToolHandle::retrieve
StatusCode retrieve()
initialize the tool
JetReclusteringTool::m_nSubjettinessTool
asg::AnaToolHandle< IJetModifier > m_nSubjettinessTool
Definition: JetReclusteringTool.h:103
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JetFilterTool
Definition: JetFilterTool.h:21
JetRecTool
Definition: JetRecTool.h:71
IJetPseudojetRetriever.h
JetReclusteringTool::m_doArea
bool m_doArea
Definition: JetReclusteringTool.h:74
JetReclusteringTool::m_jetChargeTool
asg::AnaToolHandle< IJetModifier > m_jetChargeTool
Definition: JetReclusteringTool.h:96
JetReclusteringTool::m_centerOfMassShapesTool
asg::AnaToolHandle< IJetModifier > m_centerOfMassShapesTool
Definition: JetReclusteringTool.h:102
JetReclusteringTool.h
JetReclusteringTool::m_energyCorrelatorTool
asg::AnaToolHandle< IJetModifier > m_energyCorrelatorTool
Definition: JetReclusteringTool.h:98
JetReclusteringTool::m_jetPullTool
asg::AnaToolHandle< IJetModifier > m_jetPullTool
Definition: JetReclusteringTool.h:97
PseudoJetGetter.h
IJetFinder.h
ASG_MAKE_ANA_TOOL
#define ASG_MAKE_ANA_TOOL(handle, type)
create the tool in the given tool handle
Definition: AnaToolHandle.h:690
asg::AnaToolHandle::setProperty
StatusCode setProperty(const std::string &property, const T2 &value)
set the given property of the tool.
IJetFromPseudojet.h
IJetModifier.h
JetReclusteringTool::m_subjet_radius
float m_subjet_radius
Definition: JetReclusteringTool.h:72
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
EnergyCorrelatorTool.h
JetReclusteringTool::m_reclusterJetTool
asg::AnaToolHandle< IJetExecuteTool > m_reclusterJetTool
Definition: JetReclusteringTool.h:86
JetReclusteringTool::m_isInitialized
bool m_isInitialized
Definition: JetReclusteringTool.h:78
JetReclusteringTool::m_ptMin_input
float m_ptMin_input
Definition: JetReclusteringTool.h:67
IPseudoJetGetter.h
IJetGroomer.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
IJetExecuteTool.h
JetPseudojetRetriever.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
JetReclusteringTool::m_varR_minR
float m_varR_minR
Definition: JetReclusteringTool.h:62
JetReclusteringTool::m_trimJetTool
asg::AnaToolHandle< IJetExecuteTool > m_trimJetTool
Definition: JetReclusteringTool.h:87
JetReclusteringTool::m_dipolarityTool
asg::AnaToolHandle< IJetModifier > m_dipolarityTool
Definition: JetReclusteringTool.h:101
JetReclusteringTool::m_inputJetFilterTool
asg::AnaToolHandle< IJetExecuteTool > m_inputJetFilterTool
Definition: JetReclusteringTool.h:81
JetReclusteringTool::print
virtual void print() const override
Print the state of the tool.
Definition: JetReclusteringTool.cxx:275
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
JetReclusteringTool::m_jetFromPseudoJetTool
asg::AnaToolHandle< IJetFromPseudojet > m_jetFromPseudoJetTool
Definition: JetReclusteringTool.h:84
JetReclusteringTool::m_jetFilterTool
asg::AnaToolHandle< IJetModifier > m_jetFilterTool
Definition: JetReclusteringTool.h:80
JetRecTool.h
KTSplittingScaleTool.h
JetReclusteringTool::m_rc_alg
std::string m_rc_alg
Definition: JetReclusteringTool.h:59
JetReclusteringTool::JetReclusteringTool
JetReclusteringTool(const std::string &myname)
Definition: JetReclusteringTool.cxx:37
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
JetReclusteringTool::m_ptMin_rc
float m_ptMin_rc
Definition: JetReclusteringTool.h:69
EffectiveRTool.h
JetReclusteringTool::m_radius
float m_radius
Definition: JetReclusteringTool.h:57
JetReclusteringTool::m_areaAttributes
std::string m_areaAttributes
Definition: JetReclusteringTool.h:75
JetChargeTool.h
JetReclusteringTool::m_energyCorrelatorRatiosTool
asg::AnaToolHandle< IJetModifier > m_energyCorrelatorRatiosTool
Definition: JetReclusteringTool.h:99
JetReclusteringTool::execute
virtual int execute() const override
Method to be called for each event.
Definition: JetReclusteringTool.cxx:256
asg::AnaToolHandle::getHandle
const ToolHandle< T > & getHandle() const noexcept
the tool handle we wrap
IJetExecuteTool::execute
virtual int execute() const =0
Method to be called for each event.
JetReclusteringTool::m_varR_mass
float m_varR_mass
Definition: JetReclusteringTool.h:64
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
JetReclusteringTool::m_inputJetContainer
std::string m_inputJetContainer
Definition: JetReclusteringTool.h:53
DipolarityTool.h
JetReclusteringTool::m_jetTrimmingTool_JPJR
asg::AnaToolHandle< IJetPseudojetRetriever > m_jetTrimmingTool_JPJR
Definition: JetReclusteringTool.h:94
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
asg::AnaToolHandle::setType
void setType(std::string val_type) noexcept
set the value of type
JetReclusteringTool::m_jetFinderTool
asg::AnaToolHandle< IJetFinder > m_jetFinderTool
Definition: JetReclusteringTool.h:85
JetReclusteringTool::m_pseudoJetGetterTool
asg::AnaToolHandle< IPseudoJetGetter > m_pseudoJetGetterTool
Definition: JetReclusteringTool.h:83
JetTrimmer.h
JetFromPseudojet.h
JetFilterTool.h
JetReclusteringTool::m_outputJetContainer
std::string m_outputJetContainer
Definition: JetReclusteringTool.h:55
JetReclusteringTool::m_ktSplittingScaleTool
asg::AnaToolHandle< IJetModifier > m_ktSplittingScaleTool
Definition: JetReclusteringTool.h:100
JetReclusteringTool::m_effectiveRTool
asg::AnaToolHandle< IJetModifier > m_effectiveRTool
Definition: JetReclusteringTool.h:90
JetReclusteringTool::m_jetTrimmingTool
asg::AnaToolHandle< IJetGroomer > m_jetTrimmingTool
Definition: JetReclusteringTool.h:92
JetReclusteringTool::m_APP_NAME
std::string m_APP_NAME
Definition: JetReclusteringTool.h:49
CenterOfMassShapesTool.h
NSubjettinessTool.h
EnergyCorrelatorRatiosTool.h