ATLAS Offline Software
RCJetMC.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 /**************************************************************
6  //
7  // Created: 19 January 2016
8  // Last Updated: 22 February 2016
9  //
10  // Daniel Marley
11  // demarley@umich.edu
12  // University of Michigan, Ann Arbor, MI
13  //
14  // File for initializing and making re-clustered jets.
15  //
16  ***************************************************************/
17 #include "TopEvent/RCJet.h"
18 
20 #include "AsgTools/AsgTool.h"
22 
23 #include "xAODJet/JetContainer.h"
26 #include "xAODCore/ShallowCopy.h"
29 
30 #include "fastjet/ClusterSequence.hh"
31 #include <fastjet/contrib/EnergyCorrelator.hh>
32 #include <fastjet/contrib/Nsubjettiness.hh>
37 
38 RCJet::RCJet(const std::string& name) :
39  asg::AsgTool(name),
40  m_name(name),
41  m_config(nullptr),
42  m_ptcut(0.),
43  m_etamax(0.),
44  m_inputJetPtMin(0.),
45  m_inputJetEtaMax(999.),
46  m_trim(0.),
47  m_radius(0.),
48  m_minradius(0.),
49  m_massscale(0.),
50  m_useJSS(false),
51  m_useAdditionalJSS(false),
52  m_egamma("EG_"),
53  m_jetsyst("JET_"),
54  m_muonsyst("MUON_"),
55  m_tracksyst("TRK_"),
56  m_InJetContainerBase("AntiKt4EMTopoJets_RC"),
57  m_OutJetContainerBase("AntiKtRCJets"),
58  m_InputJetContainer("AntiKt4EMTopoJets_RC"),
59  m_OutputJetContainer("AntiKtRCJets"),
60  m_loose_hashValue(2),
61  m_jet_def_rebuild(nullptr),
62  m_nSub1_beta1(nullptr),
63  m_nSub2_beta1(nullptr),
64  m_nSub3_beta1(nullptr),
65  m_ECF1(nullptr),
66  m_ECF2(nullptr),
67  m_ECF3(nullptr),
68  m_split12(nullptr),
69  m_split23(nullptr),
70  m_qw(nullptr),
71  m_gECF332(nullptr),
72  m_gECF461(nullptr),
73  m_gECF322(nullptr),
74  m_gECF331(nullptr),
75  m_gECF422(nullptr),
76  m_gECF441(nullptr),
77  m_gECF212(nullptr),
78  m_gECF321(nullptr),
79  m_gECF311(nullptr),
80  m_unique_syst(false) {
81  declareProperty("config", m_config);
82  declareProperty("VarRCjets", m_VarRCjets = false);
83  declareProperty("VarRCjets_rho", m_VarRCjets_rho = "");
84  declareProperty("VarRCjets_mass_scale", m_VarRCjets_mass_scale = "");
85 }
86 
88 
89 
91  /* Initialize the re-clustered jets */
92  ATH_MSG_INFO(" Initializing Re-clustered jets ");
93 
94  // load the necessary parameters from the Dynamic Keys in the config file
96 
98  if (m_VarRCjets) {
99  m_ptcut = std::stof(configSettings->value("VarRCJetPt")); // 100 GeV
100  m_etamax = std::stof(configSettings->value("VarRCJetEta")); // 2.5
101  m_trim = std::stof(configSettings->value("VarRCJetTrim")); // 0.05 (5% jet pT)
102  m_radius = std::stof(configSettings->value("VarRCJetMaxRadius")); // 1.2 (min=0.4)
103  m_minradius = 0.4; // 0.4 default (until we have smaller jets!)
104  std::string original_rho(m_VarRCjets_rho);
105  std::replace(original_rho.begin(), original_rho.end(), '_', '.');
106  float rho = std::stof(original_rho);
107  float m_scale = mass_scales.at(m_VarRCjets_mass_scale);
108  m_massscale = rho * m_scale * 1e-3; // e.g., 2*m_top; in [GeV]!
109 
110  m_useJSS = m_config->useVarRCJetSubstructure();
111  m_useAdditionalJSS = m_config->useVarRCJetAdditionalSubstructure();
112  } else {
113  m_ptcut = std::stof(configSettings->value("RCJetPt")); // for initialize [GeV] & passSelection
114  m_etamax = std::stof(configSettings->value("RCJetEta")); // for passSelection
115  m_trim = std::stof(configSettings->value("RCJetTrim")); // for initialize
116  m_radius = std::stof(configSettings->value("RCJetRadius")); // for initialize
117  m_minradius = -1.0;
118  m_massscale = -1.0;
119  m_useJSS = m_config->useRCJetSubstructure();
120  m_useAdditionalJSS = m_config->useRCJetAdditionalSubstructure();
121  }
122 
123  m_inputJetPtMin = std::stof(configSettings->value("RCInputJetPtMin"));
124  m_inputJetEtaMax = std::stof(configSettings->value("RCInputJetEtaMax"));
125 
126 
127  if (m_useJSS || m_useAdditionalJSS) {
128  ATH_MSG_INFO("Calculating RCJet Substructure");
129 
130  // Setup a bunch of FastJet stuff
131  //define the type of jets you will build (http://fastjet.fr/repo/doxygen-3.0.3/classfastjet_1_1JetDefinition.html)
132  m_jet_def_rebuild = std::make_shared<fastjet::JetDefinition>(fastjet::antikt_algorithm, 1.0, fastjet::E_scheme,
133  fastjet::Best);
134  }
135  if (m_useJSS) {
136  //Substructure tool definitions
137  m_nSub1_beta1 = std::make_shared<fastjet::contrib::Nsubjettiness>(1,
138  fastjet::contrib::OnePass_WTA_KT_Axes(),
139  fastjet::contrib::UnnormalizedMeasure(1.0));
140  m_nSub2_beta1 = std::make_shared<fastjet::contrib::Nsubjettiness>(2,
141  fastjet::contrib::OnePass_WTA_KT_Axes(),
142  fastjet::contrib::UnnormalizedMeasure(1.0));
143  m_nSub3_beta1 = std::make_shared<fastjet::contrib::Nsubjettiness>(3,
144  fastjet::contrib::OnePass_WTA_KT_Axes(),
145  fastjet::contrib::UnnormalizedMeasure(1.0));
146 
147 
148  m_split12 = std::make_shared<JetSubStructureUtils::KtSplittingScale>(1);
149  m_split23 = std::make_shared<JetSubStructureUtils::KtSplittingScale>(2);
150 
151  m_qw = std::make_shared<JetSubStructureUtils::Qw>();
152 
153  m_ECF1 = std::make_shared<fastjet::contrib::EnergyCorrelator>(1, 1.0, fastjet::contrib::EnergyCorrelator::pt_R);
154  m_ECF2 = std::make_shared<fastjet::contrib::EnergyCorrelator>(2, 1.0, fastjet::contrib::EnergyCorrelator::pt_R);
155  m_ECF3 = std::make_shared<fastjet::contrib::EnergyCorrelator>(3, 1.0, fastjet::contrib::EnergyCorrelator::pt_R);
156 
157  }
158  if (m_useAdditionalJSS) {
159 
160  m_gECF332 = std::make_shared<JetSubStructureUtils::EnergyCorrelatorGeneralized>(3, 3, 2,
161  JetSubStructureUtils::EnergyCorrelator::pt_R);
162  m_gECF461 = std::make_shared<JetSubStructureUtils::EnergyCorrelatorGeneralized>(6, 4, 1,
163  JetSubStructureUtils::EnergyCorrelator::pt_R);
164  m_gECF322 = std::make_shared<JetSubStructureUtils::EnergyCorrelatorGeneralized>(2, 3, 2,
165  JetSubStructureUtils::EnergyCorrelator::pt_R);
166  m_gECF331 = std::make_shared<JetSubStructureUtils::EnergyCorrelatorGeneralized>(3, 3, 1,
167  JetSubStructureUtils::EnergyCorrelator::pt_R);
168  m_gECF422 = std::make_shared<JetSubStructureUtils::EnergyCorrelatorGeneralized>(2, 4, 2,
169  JetSubStructureUtils::EnergyCorrelator::pt_R);
170  m_gECF441 = std::make_shared<JetSubStructureUtils::EnergyCorrelatorGeneralized>(4, 4, 1,
171  JetSubStructureUtils::EnergyCorrelator::pt_R);
172  m_gECF212 = std::make_shared<JetSubStructureUtils::EnergyCorrelatorGeneralized>(1, 2, 2,
173  JetSubStructureUtils::EnergyCorrelator::pt_R);
174  m_gECF321 = std::make_shared<JetSubStructureUtils::EnergyCorrelatorGeneralized>(2, 3, 1,
175  JetSubStructureUtils::EnergyCorrelator::pt_R);
176  m_gECF311 = std::make_shared<JetSubStructureUtils::EnergyCorrelatorGeneralized>(1, 3, 1,
177  JetSubStructureUtils::EnergyCorrelator::pt_R);
178  }
179 
180 
181 
182  for (auto treeName : *m_config->systAllTTreeNames()) {
183  // only make a new tool if it is the nominal systematic or one that could affect small-r jets (el, mu, jet)
184  std::string hash_name("");
185 
186  if (isUniqueSyst(treeName.second)) {
187  if (treeName.second.compare("nominal") != 0) hash_name = treeName.second; // no extra strings for nominal (so all
188  // other non-unique systs have same name
189  // as nominal)
190 
193 
194  // build a jet re-clustering tool for each case
195  std::shared_ptr<JetReclusteringTool> tool(new JetReclusteringTool(treeName.second + m_name));
196  top::check(tool->setProperty("InputJetContainer",
197  m_InputJetContainer), "Failed inputjetcontainer initialize reclustering tool");
198  top::check(tool->setProperty("OutputJetContainer",
199  m_OutputJetContainer), "Failed outputjetcontainer initialize reclustering tool");
200  top::check(tool->setProperty("ReclusterRadius",
201  m_radius), "Failed re-clustering radius initialize reclustering tool");
202  top::check(tool->setProperty("RCJetPtMin", m_ptcut * 1e-3), "Failed ptmin [GeV] initialize reclustering tool");
203  top::check(tool->setProperty("InputJetPtMin", m_inputJetPtMin * 1e-3), "Failed InputJetPtMin [GeV] initialize reclustering tool");
204  top::check(tool->setProperty("TrimPtFrac", m_trim), "Failed pT fraction initialize reclustering tool");
205  top::check(tool->setProperty("VariableRMinRadius",
206  m_minradius), "Failed VarRC min radius initialize reclustering tool");
207  top::check(tool->setProperty("VariableRMassScale",
208  m_massscale), "Failed VarRC mass scale initialize reclustering tool");
209  top::check(tool->initialize(), "Failed to initialize reclustering tool");
210 
211  m_jetReclusteringTool.insert({treeName.first, tool}); // insert the re-clustering tool into map
212  // this stores a tool for each systematic based on hash
213  // value
214 
215  // map of container names to access in event saver
218 
219  // make a re-clustering tool for 'loose' events, too.
220  if (m_config->doLooseEvents()) {
221  std::shared_ptr<JetReclusteringTool> tool_loose(new JetReclusteringTool(treeName.second + m_name + "_Loose"));
222  top::check(tool_loose->setProperty("InputJetContainer",
223  m_InputJetContainer + "_Loose"),
224  "Failed inputjetcontainer reclustering tool");
225  top::check(tool_loose->setProperty("OutputJetContainer",
226  m_OutputJetContainer + "_Loose"),
227  "Failed outputjetcontainer loose initialize reclustering tool");
228  top::check(tool_loose->setProperty("ReclusterRadius",
229  m_radius), "Failed re-clustering radius initialize reclustering tool");
230  top::check(tool_loose->setProperty("RCJetPtMin", m_ptcut * 1e-3), "Failed ptmin [GeV] reclustering tool");
231  top::check(tool->setProperty("InputJetPtMin", m_inputJetPtMin * 1e-3), "Failed InputJetPtMin [GeV] initialize reclustering tool");
232  top::check(tool_loose->setProperty("TrimPtFrac", m_trim), "Failed pT fraction initialize reclustering tool");
233  top::check(tool_loose->setProperty("VariableRMinRadius",
234  m_minradius), "Failed VarRC min radius initialize reclustering tool");
235  top::check(tool_loose->setProperty("VariableRMassScale",
236  m_massscale), "Failed VarRC mass scale initialize reclustering tool");
237  top::check(tool_loose->initialize(), "Failed to initialize reclustering tool");
238 
239  m_jetReclusteringTool.insert({m_loose_hashValue* treeName.first, tool_loose}); // making up a number as index
240  // for the loose event
241  // map of container names to access in event saver
244  } // end if loose
245  } // end if unique syst
246  else {
249 
250  // map of container names to access in event saver
251  if (m_config->doLooseEvents()) {
254  } else {
257  }
258  }
259 
260  } // end for loop over systematics
261 
262  ATH_MSG_INFO(" Re-clustered jets initialized ");
263 
264  return StatusCode::SUCCESS;
265 } // end initialize()
266 
268  /*
269  Make the jet container (if necessary) and execute the re-clustering tool
270  https://svnweb.cern.ch/trac/atlasoff/browser/PhysicsAnalysis/TopPhys/xAOD/TopEvent/trunk/Root/TopEventMaker.cxx#L31
271  */
272  m_InputJetContainer = inputContainerName(event.m_hashValue, event.m_isLoose);
273  m_OutputJetContainer = rcjetContainerName(event.m_hashValue, event.m_isLoose);
274 
275 
276  // -- Save the jet container to the TStore (only if it doesn't already exist!)
277  // -- Then, we can access it with the re-clustering tool further down
278  if (!evtStore()->contains<xAOD::JetContainer>(m_InputJetContainer)) {
279  // Save the nominal container once, and each jet systematic container once
280  // Make the new jet container (only do this if we have to!)
281  // 22 Feb 2016:
282  // Code significantly shortened to make this container
283  // thanks to email exchange between Davide Gerbaudo & Attila Krasznahorkay
284  auto rcJetInputs = std::make_unique< ConstDataVector< xAOD::JetContainer >>(SG::VIEW_ELEMENTS);
285  for(const xAOD::Jet* jet : event.m_jets) {
286  if(jet->pt() < m_inputJetPtMin || std::abs(jet->eta()) > m_inputJetEtaMax) continue;
287  rcJetInputs->push_back(jet);
288  }
289  top::check(evtStore()->tds()->record(std::move(rcJetInputs), m_InputJetContainer),
290  "Failed to put jets in TStore for re-clustering");
291  } // end if jet container exists
292 
293  // --- EXECUTE --- //
294  // only execute if the jet container doesn't exist
295  // (do not re-make the 'nominal' jet container over & over again!)
296  if (!evtStore()->contains<xAOD::JetContainer>(m_OutputJetContainer)) {
297  int hash_factor = (event.m_isLoose) ? m_loose_hashValue : 1;
298 
299  // tools only exist for unique systematics & nominal (save time/space)!
300  m_tool_iterator tool_iter = m_jetReclusteringTool.find(hash_factor * event.m_hashValue);
301 
302  // if this is a unique systematic or nominal, execute from the tool; else execute nominal
303  if (tool_iter != m_jetReclusteringTool.end()) tool_iter->second->execute();
304  else m_jetReclusteringTool.at(hash_factor * m_config->nominalHashValue())->execute();
305 
306  xAOD::JetContainer* myJets(nullptr);
307  top::check(evtStore()->retrieve(myJets, m_OutputJetContainer), "Failed to retrieve RC JetContainer");
308  for (auto rcjet : *myJets) {
309  rcjet->auxdecor<bool>("PassedSelection") = passSelection(*rcjet);
310  }
311 
312  if (m_useJSS || m_useAdditionalJSS) {
313  static const SG::AuxElement::ConstAccessor<bool> passedSelection("PassedSelection");
314 
315  for (auto rcjet : *myJets) {
316  if (!passedSelection(*rcjet)) continue; // Calculate JSS only if passed object selection
317 
318  // get the subjets and clusters of the rcjets
319 
320  std::vector<fastjet::PseudoJet> clusters;
321 
322 
323  if (m_config->sgKeyJetsTDS(hash_factor * m_config->nominalHashValue(),
324  false).find("AntiKt4EMTopoJets") != std::string::npos) {
325  getEMTopoClusters(clusters,rcjet); // use subjet constituents
326  }
327  else if (m_config->sgKeyJetsTDS(hash_factor * m_config->nominalHashValue(),
328  false).find("AntiKt4EMPFlowJets") != std::string::npos) {
329  getPflowConstituent(clusters, rcjet, event); // use ghost-matched tracks
330  }
331  else getLCTopoClusters(clusters, rcjet); // // use LCTOPO CLUSTERS matched to subjet
332 
333  if (m_config->sgKeyJetsTDS(hash_factor * m_config->nominalHashValue(),
334  false).find("AntiKt4EMPFlowJets") == std::string::npos) {
335  // In case of AntiKt4EMPFlowJets the tracks could be removed by the pile-up cuts
336  top::check(
337  !clusters.empty(),
338  "RCJet::execute(const top::Event& event): Failed to get vector of clusters! Unable to calculate RC jets substructure variables!\n Aborting!");
339  }
340 
341  if (clusters.size() != 0) {
342  // Now rebuild the large jet from the small jet constituents aka the original clusters
344  std::vector<fastjet::PseudoJet> my_pjets = fastjet::sorted_by_pt(clust_seq_rebuild.inclusive_jets(0.0));
345 
346 
347  fastjet::PseudoJet correctedJet;
348  correctedJet = my_pjets[0];
349  //Sometimes fastjet splits the jet into two, so need to correct for that!!
350  if (my_pjets.size() > 1) correctedJet += my_pjets[1];
351 
352  if (m_useJSS) {
353  // Now finally we can calculate some substructure!
354  double tau32 = -1, tau21 = -1;
355 
356  double tau1 = m_nSub1_beta1->result(correctedJet);
357  double tau2 = m_nSub2_beta1->result(correctedJet);
358  double tau3 = m_nSub3_beta1->result(correctedJet);
359 
360  if (std::abs(tau1) > 1e-8) tau21 = tau2 / tau1;
361  else tau21 = -999.0;
362  if (std::abs(tau2) > 1e-8) tau32 = tau3 / tau2;
363  else tau32 = -999.0;
364 
365 
366 
367  double split12 = m_split12->result(correctedJet);
368  double split23 = m_split23->result(correctedJet);
369  double qw = m_qw->result(correctedJet);
370 
371  double D2 = -1;
372 
373  double vECF1 = m_ECF1->result(correctedJet);
374  double vECF2 = m_ECF2->result(correctedJet);
375  double vECF3 = m_ECF3->result(correctedJet);
376  if (std::abs(vECF2) > 1e-8) D2 = vECF3 * vECF1* vECF1* vECF1 / (vECF2 * vECF2 * vECF2);
377  else D2 = -999.0;
378 
379 
380  // now attach the results to the original jet
381  rcjet->auxdecor<float>("Tau32_clstr") = tau32;
382  rcjet->auxdecor<float>("Tau21_clstr") = tau21;
383 
384  // lets also write out the components so we can play with them later
385  rcjet->auxdecor<float>("Tau3_clstr") = tau3;
386  rcjet->auxdecor<float>("Tau2_clstr") = tau2;
387  rcjet->auxdecor<float>("Tau1_clstr") = tau1;
388 
389  rcjet->auxdecor<float>("d12_clstr") = split12;
390  rcjet->auxdecor<float>("d23_clstr") = split23;
391  rcjet->auxdecor<float>("Qw_clstr") = qw;
392 
393  rcjet->auxdecor<float>("nconstituent_clstr") = clusters.size();
394 
395  rcjet->auxdecor<float>("ECF1_clstr") = vECF1;
396  rcjet->auxdecor<float>("ECF2_clstr") = vECF2;
397  rcjet->auxdecor<float>("ECF3_clstr") = vECF3;
398  rcjet->auxdecor<float>("D2_clstr") = D2;
399 
400  } // end of if useJSS
401 
402  if (m_useAdditionalJSS) {
403 
404  // MlB's t/H discriminators
405  // E = (a*n) / (b*m)
406  // for an ECFG_X_Y_Z, a=Y, n=Z -> dimenionless variable
407  double gECF332 = m_gECF332->result(correctedJet);
408  double gECF461 = m_gECF461->result(correctedJet);
409  double gECF322 = m_gECF322->result(correctedJet);
410  double gECF331 = m_gECF331->result(correctedJet);
411  double gECF422 = m_gECF422->result(correctedJet);
412  double gECF441 = m_gECF441->result(correctedJet);
413  double gECF212 = m_gECF212->result(correctedJet);
414  double gECF321 = m_gECF321->result(correctedJet);
415  double gECF311 = m_gECF311->result(correctedJet);
416 
417  double L1 = -999.0, L2 = -999.0, L3 = -999.0, L4 = -999.0, L5 = -999.0;
418  if (std::abs(gECF212) > 1e-12) {
419  L1 = gECF321 / gECF212;
420  L2 = gECF331 / sqrt(gECF212*gECF212*gECF212);
421  }
422  if (std::abs(gECF331) > 1e-12) {
423  L3 = gECF311 / pow(gECF331,1./3.);
424  L4 = gECF322 / pow(gECF331,4./3.);
425  }
426  if (std::abs(gECF441) > 1e-12) {
427  L5 = gECF422/gECF441;
428  }
429 
430  rcjet->auxdecor<float>("gECF332_clstr") = gECF332;
431  rcjet->auxdecor<float>("gECF461_clstr") = gECF461;
432  rcjet->auxdecor<float>("gECF322_clstr") = gECF322;
433  rcjet->auxdecor<float>("gECF331_clstr") = gECF331;
434  rcjet->auxdecor<float>("gECF422_clstr") = gECF422;
435  rcjet->auxdecor<float>("gECF441_clstr") = gECF441;
436  rcjet->auxdecor<float>("gECF212_clstr") = gECF212;
437  rcjet->auxdecor<float>("gECF321_clstr") = gECF321;
438  rcjet->auxdecor<float>("gECF311_clstr") = gECF311;
439  rcjet->auxdecor<float>("L1_clstr") = L1;
440  rcjet->auxdecor<float>("L2_clstr") = L2;
441  rcjet->auxdecor<float>("L3_clstr") = L3;
442  rcjet->auxdecor<float>("L4_clstr") = L4;
443  rcjet->auxdecor<float>("L5_clstr") = L5;
444  // lets also store the rebuilt jet incase we need it later
445  rcjet->auxdecor<float>("RRCJet_pt") = correctedJet.pt();
446  rcjet->auxdecor<float>("RRCJet_eta") = correctedJet.eta();
447  rcjet->auxdecor<float>("RRCJet_phi") = correctedJet.phi();
448  rcjet->auxdecor<float>("RRCJet_e") = correctedJet.e();
449  }// end of if useAdditional JSS
450  }
451  }// end of rcjet loop
452  }//m_useJSS || m_useAdditionalJSS
453  } //if (!evtStore()->contains<xAOD::JetContainer>(m_OutputJetContainer))
454 
455 
456 
457 
458 
459 
460 
461 
462 
463  return StatusCode::SUCCESS;
464 } // end execute()
465 
467  m_jetReclusteringTool.clear();
468 
469  return StatusCode::SUCCESS;
470 }
471 
472 bool RCJet::isUniqueSyst(const std::string syst_name) {
473  /*
474  Check if the given systematic (besides nominal) needs a unique container
475  Keep this in one function so it easier to update than having multiple checks everywhere.
476  Only need jet containers for EGamma, Muon, Jet and Nominal systematics
477  */
478 
479  bool isSmallRJetSys = (syst_name.find(m_jetsyst) != std::string::npos);
480 
481  // Systematic branches for small-R and large-R jets both contain "JET_" string. We want to recluster only if they
482  // correspond to small-R jets.
483  if ((syst_name.find("_R10_") != std::string::npos) ||
484  (syst_name.find("_CombMass_") != std::string::npos) ||
485  (syst_name.find("_LargeR_") != std::string::npos) ||
486  (syst_name.find("_MassRes_") != std::string::npos) ||
487  (syst_name.find("_SigSF_") != std::string::npos) ||
488  (syst_name.find("_BGSF_") != std::string::npos) ) isSmallRJetSys = false;
489 
490  m_unique_syst = (syst_name.find(m_egamma) == 0 ||
491  syst_name.find(m_muonsyst) == 0 ||
492  isSmallRJetSys ||
493  syst_name.find(m_tracksyst) == 0 ||
494  syst_name.compare("nominal") == 0);
495 
496  return m_unique_syst;
497 }
498 
499 std::string RCJet::inputContainerName(std::size_t hash_value, bool isLooseEvent) {
500  /* Return the name of the input container */
501  std::string this_container_name("");
502  if (isLooseEvent) hash_value *= m_loose_hashValue; // loose events have a slightly different hash value to keep track
503  // of
504 
506 
507  if (iter != m_inputContainerNames.end()) this_container_name = iter->second;
508  else this_container_name = m_InJetContainerBase;
509 
510  return this_container_name;
511 }
512 
513 std::string RCJet::rcjetContainerName(std::size_t hash_value, bool isLooseEvent) {
514  /* Return the name of the rcjet container for a given systematic */
515  std::string this_container_name("");
516  if (isLooseEvent) hash_value *= m_loose_hashValue; // loose events have a slightly different hash value
517 
519 
520  if (iter != m_outputContainerNames.end()) this_container_name = iter->second;
521  else this_container_name = m_OutJetContainerBase;
522 
523  return this_container_name;
524 }
525 
526 bool RCJet::passSelection(const xAOD::Jet& jet) const {
527  /*
528  Check if the re-clustered jet passes selection.
529  Right now, this only does something for |eta| because
530  pT is taken care of in the re-clustering tool. When
531  small-r jet mass is available (calibrated+uncertainties),
532  we can cut on that.
533  */
534  // [pT] calibrated to >~ 22 GeV (23 Jan 2016)
535  if (jet.pt() < m_ptcut) return false;
536 
537  // [|eta|] calibrated < 2.5
538  if (std::abs(jet.eta()) > m_etamax) return false;
539 
540  // small-r jet mass not calibrated and no uncertainties
541 
542  return true;
543 }
544 
545 void RCJet::getEMTopoClusters(std::vector<fastjet::PseudoJet>& clusters, const xAOD::Jet* rcjet) {
546  clusters.clear();
547 
548  for (auto subjet : rcjet->getConstituents()) {
549  const xAOD::Jet* subjet_raw = static_cast<const xAOD::Jet*>(subjet->rawConstituent());
550 
551  // Make sure we don't try to access jets that have had the clusters thinned
552  bool hasConstituents = true;
553  auto links = subjet_raw->constituentLinks();
554  for (auto link : links) {
555  if (!link.isValid()) {
557  "Some of the RC Jet Constituents have been thinned - will not be included in RCJet JSS calculation");
558  hasConstituents = false;
559  break;
560  }
561  }
562  if (!hasConstituents) {
563  continue;
564  }
565 
566  for (auto clus_itr : subjet_raw->getConstituents()) {
567  if (clus_itr->e() > 0) {
568  TLorentzVector temp_p4;
569 
570  double sf = 1.0;
571  temp_p4.SetPtEtaPhiM(clus_itr->pt() * sf, clus_itr->eta(), clus_itr->phi(), clus_itr->m());
572 
573  clusters.push_back(fastjet::PseudoJet(temp_p4.Px(), temp_p4.Py(), temp_p4.Pz(), temp_p4.E()));
574  }
575  }
576  }
577 }
578 
579 void RCJet::getLCTopoClusters(std::vector<fastjet::PseudoJet>& clusters, const xAOD::Jet* rcjet) {
580  //LCTOPO CLUSTERS
581  clusters.clear();
582 
583  // get the clusters (directly we so can try using the LCTopo clusters)
584  const xAOD::CaloClusterContainer* myClusters(nullptr);
585  top::check(evtStore()->retrieve(myClusters, "CaloCalTopoClusters"), "Failed to retrieve CaloCalTopoClusters");
586 
587 
588 
589  for (auto cluster : *myClusters) {
590  for (auto subjet : rcjet->getConstituents()) {
591  const xAOD::Jet* subjet_raw = static_cast<const xAOD::Jet*>(subjet->rawConstituent());
592 
593  float dR = subjet_raw->p4().DeltaR(cluster->p4());
594  if (dR < 0.4) {
595  TLorentzVector temp_p4;
596  temp_p4.SetPtEtaPhiE(cluster->pt((xAOD::CaloCluster_v1::State(1))),
597  cluster->eta((xAOD::CaloCluster_v1::State(1))),
598  cluster->phi((xAOD::CaloCluster_v1::State(1))),
599  cluster->e((xAOD::CaloCluster_v1::State(1))));
600  clusters.push_back(fastjet::PseudoJet(temp_p4.Px(), temp_p4.Py(), temp_p4.Pz(), temp_p4.E()));
601  break;
602  }
603  }
604  }
605 }
606 
607 void RCJet::getPflowConstituent(std::vector<fastjet::PseudoJet>& clusters, const xAOD::Jet* rcjet,
608  const top::Event& event) {
609  // At the moment the proper constituent of the PFlows aren't available in TOPQ1 and there is no strategy to provide
610  // uncertainty on that consequently
611  // at the moment just the tracks ghost matched to the PFLow objects are considered to define the substructure (under
612  // suggestion of the JSS group).
613  // As a consiquence all the neutral component of the jet is missing from the substructure, this choice is consistently
614  // copied at particle level
615 
616  clusters.clear();
617  std::vector<const xAOD::TrackParticle*> jetTracks;
618 
619 
620  for (auto subjet : rcjet->getConstituents()) {
621  const xAOD::Jet* subjet_raw = static_cast<const xAOD::Jet*>(subjet->rawConstituent());
622 
623  if(subjet->pt() < m_config->jetPtGhostTracks() || std::abs(subjet->eta()) > m_config->jetEtaGhostTracks()) continue;
624 
625 
626  jetTracks.clear();
627 
628  jetTracks = subjet_raw->getAssociatedObjects<xAOD::TrackParticle>(m_config->decoKeyJetGhostTrack(event.m_hashValue));
629  bool haveJetTracks = jetTracks.size() != 0;
630 
631  if (haveJetTracks) {
632 
633  for ( const xAOD::TrackParticle* jet: jetTracks ){
634  TLorentzVector temp_p4;
635 
636  if (jet != nullptr) {
637 
638  // Select on track quality, pt, eta and match to vertex
639  if(jet->auxdataConst< char >("passPreORSelection") != 1){
640  continue;
641  }
642 
643  temp_p4.SetPtEtaPhiE(jet->pt(), jet->eta(), jet->phi(), jet->e());
644  clusters.emplace_back(fastjet::PseudoJet(temp_p4.Px(), temp_p4.Py(), temp_p4.Pz(), temp_p4.E()));
645 
646  }
647  }
648  } else {
650  "RCJET::No remaining tracks associated to the PFlow jet");
651  }
652  }
653 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ShallowCopy.h
RCJet::m_gECF331
std::shared_ptr< JetSubStructureUtils::EnergyCorrelatorGeneralized > m_gECF331
Definition: RCJet.h:133
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
RCJet::m_ECF2
std::shared_ptr< fastjet::contrib::EnergyCorrelator > m_ECF2
Definition: RCJet.h:125
RCJet::m_qw
std::shared_ptr< JetSubStructureUtils::Qw > m_qw
Definition: RCJet.h:129
RCJet::m_split12
std::shared_ptr< JetSubStructureUtils::KtSplittingScale > m_split12
Definition: RCJet.h:127
RCJet::isUniqueSyst
bool isUniqueSyst(std::string syst_name)
Definition: RCJetMC.cxx:472
top::ConfigurationSettings::value
const std::string & value(const std::string &key) const
The user wants to know the value for the specified key.
Definition: ConfigurationSettings.cxx:970
RCJet::m_tracksyst
std::string m_tracksyst
Definition: RCJet.h:111
Trk::L2
@ L2
Definition: AlignModuleList.h:32
FlavorTagDiscriminants::hbb_key::subjet
const std::string subjet
Definition: HbbConstants.h:18
RCJet::m_name
std::string m_name
Definition: RCJet.h:91
KtSplittingScale.h
RCJet::m_gECF461
std::shared_ptr< JetSubStructureUtils::EnergyCorrelatorGeneralized > m_gECF461
Definition: RCJet.h:131
RCJet::getPflowConstituent
void getPflowConstituent(std::vector< fastjet::PseudoJet > &clusters, const xAOD::Jet *rcjet, const top::Event &event)
Definition: RCJetMC.cxx:607
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
RCJet::m_InputJetContainer
std::string m_InputJetContainer
Definition: RCJet.h:115
RCJet::m_loose_hashValue
int m_loose_hashValue
Definition: RCJet.h:117
RCJet::m_useAdditionalJSS
bool m_useAdditionalJSS
Definition: RCJet.h:106
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
RCJet::m_minradius
float m_minradius
Definition: RCJet.h:103
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
RCJet::~RCJet
~RCJet()
Definition: RCJetMC.cxx:87
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
xAOD::CaloCluster_v1::State
State
enum of possible signal states.
Definition: CaloCluster_v1.h:304
RCJet::m_jet_def_rebuild
std::shared_ptr< fastjet::JetDefinition > m_jet_def_rebuild
Definition: RCJet.h:120
asg
Definition: DataHandleTestTool.h:28
RCJet::m_inputContainerNames
std::map< std::size_t, std::string > m_inputContainerNames
Definition: RCJet.h:143
Trk::L1
@ L1
Definition: AlignModuleList.h:32
RCJet::m_gECF441
std::shared_ptr< JetSubStructureUtils::EnergyCorrelatorGeneralized > m_gECF441
Definition: RCJet.h:135
JetReclusteringTool
Definition: JetReclusteringTool.h:33
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
RCJet::m_VarRCjets_rho
std::string m_VarRCjets_rho
Definition: RCJet.h:95
RCJet::m_ECF1
std::shared_ptr< fastjet::contrib::EnergyCorrelator > m_ECF1
Definition: RCJet.h:124
xAOD::Jet_v1::getConstituents
JetConstituentVector getConstituents() const
Return a vector of consituents. The object behaves like vector<const IParticle*>. See JetConstituentV...
Definition: Jet_v1.cxx:147
RCJet::m_muonsyst
std::string m_muonsyst
Definition: RCJet.h:110
RCJet::inputContainerName
std::string inputContainerName(std::size_t hash_value, bool isLooseEvent)
Definition: RCJetMC.cxx:499
RCJet::m_useJSS
bool m_useJSS
Definition: RCJet.h:105
RCJet::m_inputJetPtMin
float m_inputJetPtMin
Definition: RCJet.h:99
RCJet::RCJet
RCJet(const std::string &name)
Definition: RCJetMC.cxx:38
RCJet::getLCTopoClusters
void getLCTopoClusters(std::vector< fastjet::PseudoJet > &clusters, const xAOD::Jet *rcjet)
Definition: RCJetMC.cxx:579
RCJet::m_tool_iterator
std::unordered_map< std::size_t, std::shared_ptr< JetReclusteringTool > >::iterator m_tool_iterator
Definition: RCJet.h:156
xAOD::Jet_v1::getAssociatedObjects
std::vector< const T * > getAssociatedObjects(const std::string &name) const
get associated objects as a vector<object> this compact form throws an exception if the object is not...
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
RCJet::getEMTopoClusters
void getEMTopoClusters(std::vector< fastjet::PseudoJet > &clusters, const xAOD::Jet *rcjet)
Definition: RCJetMC.cxx:545
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
RCJet::finalize
StatusCode finalize()
Definition: RCJetMC.cxx:466
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
jet::ClusterSequence
fastjet::ClusterSequence ClusterSequence
Definition: ClusterSequence.h:21
Trk::L3
@ L3
Definition: AlignModuleList.h:32
RCJet::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: RCJetMC.cxx:90
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DMTest::links
links
Definition: CLinks_v1.cxx:22
RCJet::m_gECF332
std::shared_ptr< JetSubStructureUtils::EnergyCorrelatorGeneralized > m_gECF332
Definition: RCJet.h:130
top::ConfigurationSettings::get
static ConfigurationSettings * get(bool reset=false)
Design patterns 101.
Definition: ConfigurationSettings.cxx:714
RCJet::rcjetContainerName
std::string rcjetContainerName(std::size_t hash_value, bool isLooseEvent)
Definition: RCJetMC.cxx:513
RCJet::mass_scales
std::map< std::string, float > mass_scales
Definition: RCJet.h:146
dumpFileToPlots.treeName
string treeName
Definition: dumpFileToPlots.py:20
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
RCJet::m_VarRCjets
bool m_VarRCjets
Definition: RCJet.h:94
RCJet::m_gECF212
std::shared_ptr< JetSubStructureUtils::EnergyCorrelatorGeneralized > m_gECF212
Definition: RCJet.h:136
RCJet::m_gECF311
std::shared_ptr< JetSubStructureUtils::EnergyCorrelatorGeneralized > m_gECF311
Definition: RCJet.h:138
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
RCJet::passSelection
bool passSelection(const xAOD::Jet &jet) const
Definition: RCJetMC.cxx:526
RCJet::m_gECF322
std::shared_ptr< JetSubStructureUtils::EnergyCorrelatorGeneralized > m_gECF322
Definition: RCJet.h:132
RCJet::execute
StatusCode execute(const top::Event &event)
Definition: RCJetMC.cxx:267
RCJet::m_VarRCjets_mass_scale
std::string m_VarRCjets_mass_scale
Definition: RCJet.h:96
xAOD::Jet_v1::constituentLinks
const std::vector< ElementLink< IParticleContainer > > & constituentLinks() const
Direct access to constituents. WARNING expert use only.
Definition: Jet_v1.cxx:162
RCJet::m_gECF321
std::shared_ptr< JetSubStructureUtils::EnergyCorrelatorGeneralized > m_gECF321
Definition: RCJet.h:137
RCJet::m_OutJetContainerBase
std::string m_OutJetContainerBase
Definition: RCJet.h:114
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
RCJet::m_gECF422
std::shared_ptr< JetSubStructureUtils::EnergyCorrelatorGeneralized > m_gECF422
Definition: RCJet.h:134
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
RCJet::m_config
std::shared_ptr< top::TopConfig > m_config
Definition: RCJet.h:93
RCJet::m_inputJetEtaMax
float m_inputJetEtaMax
Definition: RCJet.h:100
TopConfig.h
RCJet::m_iterator
std::map< std::size_t, std::string >::iterator m_iterator
Definition: RCJet.h:142
EventInfo.h
python.StandardJetMods.qw
qw
Definition: StandardJetMods.py:268
xAOD::JetAlgorithmType::antikt_algorithm
@ antikt_algorithm
Definition: JetContainerInfo.h:33
RCJet::m_OutputJetContainer
std::string m_OutputJetContainer
Definition: RCJet.h:116
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
xAOD::Jet_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: Jet_v1.cxx:71
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
EnergyCorrelatorGeneralized.h
RCJet::m_nSub1_beta1
std::shared_ptr< fastjet::contrib::Nsubjettiness > m_nSub1_beta1
Definition: RCJet.h:121
JetContainer.h
RCJet::m_egamma
std::string m_egamma
Definition: RCJet.h:108
RCJet::m_jetsyst
std::string m_jetsyst
Definition: RCJet.h:109
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
RCJet::m_radius
float m_radius
Definition: RCJet.h:102
RCJet::m_massscale
float m_massscale
Definition: RCJet.h:104
Qw.h
RCJet::m_unique_syst
bool m_unique_syst
Definition: RCJet.h:140
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
RCJet::m_etamax
float m_etamax
Definition: RCJet.h:98
RCJet::m_trim
float m_trim
Definition: RCJet.h:101
JetAuxContainer.h
RCJet::m_nSub2_beta1
std::shared_ptr< fastjet::contrib::Nsubjettiness > m_nSub2_beta1
Definition: RCJet.h:122
IParticleHelpers.h
top::Event
Very simple class to hold event data after reading from a file.
Definition: Event.h:49
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
RCJet::m_ECF3
std::shared_ptr< fastjet::contrib::EnergyCorrelator > m_ECF3
Definition: RCJet.h:126
RCJet::m_nSub3_beta1
std::shared_ptr< fastjet::contrib::Nsubjettiness > m_nSub3_beta1
Definition: RCJet.h:123
AsgTool.h
EnergyCorrelator.h
top::ConfigurationSettings
Hold the configuration information for the whole run.
Definition: ConfigurationSettings.h:21
RCJet::m_outputContainerNames
std::map< std::size_t, std::string > m_outputContainerNames
Definition: RCJet.h:144
RCJet.h
fitman.rho
rho
Definition: fitman.py:532
RCJet::m_jetReclusteringTool
std::unordered_map< std::size_t, std::shared_ptr< JetReclusteringTool > > m_jetReclusteringTool
Definition: RCJet.h:155
RCJet::m_split23
std::shared_ptr< JetSubStructureUtils::KtSplittingScale > m_split23
Definition: RCJet.h:128
RCJet::m_InJetContainerBase
std::string m_InJetContainerBase
Definition: RCJet.h:113
SystematicsUtil.h
RCJet::m_ptcut
float m_ptcut
Definition: RCJet.h:97
CP::hash_value
std::size_t hash_value(const SystematicSet &)
Hash function specifically for boost::hash.
Definition: SystematicSet.cxx:321