ATLAS Offline Software
JetConeLabeling.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 
7 //#include "ParticleJetTools/IJetTruthMatching.h"
9 //#include "ParticleJetTools/JetQGPartonLabel.h"
10 
11 //#include "JetTagInfo/TruthInfo.h"
12 
13 //#include "ParticleJetTools/FindLeptonTruth.h"
14 //#include "JetTagInfo/SoftLeptonTruthInfo.h"
15 //#include "JetTagInfo/QGPartonTruthInfo.h"
16 //#include "JetTagInfo/SLTrueInfo.h"
17 
18 //#include "ParticleJetTools/FindLeptonTruth.h"
19 namespace Analysis {
20 
21  JetConeLabeling::JetConeLabeling(const std::string& name) :
23  m_jetTruthMatchTool("Analysis::JetQuarkLabel",this)//,
24  //m_LeptonTruthTool("Analysis::LeptonTruthTool")
25  {
26  declareProperty("JetTruthMatchTool", m_jetTruthMatchTool);
27  //declareProperty("JetQGPartonTruthMatchTool", m_jetQGPartonTruthMatchTool);
28  //declareProperty("LeptonTruthTool", m_LeptonTruthTool);
29  }
30 
32  }
33 
35  {
37  if ( !m_jetTruthMatchTool.empty() ) {
38  if ( m_jetTruthMatchTool.retrieve().isFailure() ) {
39  ATH_MSG_FATAL("#BTAG# Failed to retrieve tool " << m_jetTruthMatchTool);
40  return StatusCode::FAILURE;
41  } else {
42  ATH_MSG_DEBUG("#BTAG# Retrieved tool " << m_jetTruthMatchTool);
43  }
44  }
45  // if ( !m_jetQGPartonTruthMatchTool.empty() ) {
46  // if ( m_jetQGPartonTruthMatchTool.retrieve().isFailure() ) {
47  // ATH_MSG_FATAL("#BTAG# Failed to retrieve tool " << m_jetQGPartonTruthMatchTool);
48  // return StatusCode::FAILURE;
49  // } else {
50  // ATH_MSG_DEBUG("#BTAG# Retrieved tool " << m_jetQGPartonTruthMatchTool);
51  // }
52  // }
53 
54  // if ( !m_LeptonTruthTool.empty() ) {
55  // if ( m_LeptonTruthTool.retrieve().isFailure() ) {
56  // ATH_MSG_FATAL("#BTAG# Failed to retrieve tool " << m_LeptonTruthTool);
57  // return StatusCode::FAILURE;
58  // } else {
59  // ATH_MSG_DEBUG("#BTAG# Retrieved tool " << m_LeptonTruthTool);
60  // }
61  // }
62 
63  return StatusCode::SUCCESS;
64  }
65 
67  ATH_MSG_VERBOSE("In " << name() << "::modifyJet()");
68  //JetTruthMatching and setting of the TruthInfo object
69  bool jetIsMatched( true );
70  //const Analysis::TruthInfo* mcinfo = NULL;//jet.tagInfo<Analysis::TruthInfo>("TruthInfo");// AA - need jet input
71 
72  int thisJetTruthLabel = 0;
73  // bool doTruthInfo = !jet.getAttribute("TruthLabelID",thisJetTruthLabel);
74  // TEMPORARY FIX! This will happily rerun the tagging even if it was done already. A proper fix should be made
75  bool doTruthInfo = true;
76  // const Analysis::SoftLeptonTruthInfo* mcslinfo = jet.tagInfo<Analysis::SoftLeptonTruthInfo>("SoftLeptonTruthInfo");
77  // bool doSLTruthInfo = true;
78  // if(mcslinfo) doSLTruthInfo = false;
79 
80  if (!m_jetTruthMatchTool.empty() && doTruthInfo) {
81  //TruthInfo* truthInfo = new TruthInfo("TruthInfo");
83  jetIsMatched = m_jetTruthMatchTool->matchJet( jet, &info );
84  jet.setAttribute("TruthLabelDeltaR_B",info.deltaRMinTo("B"));
85  jet.setAttribute("TruthLabelDeltaR_C",info.deltaRMinTo("C"));
86  jet.setAttribute("TruthLabelDeltaR_T",info.deltaRMinTo("T"));
87  //
88  if ( jetIsMatched ) {
89  thisJetTruthLabel = info.jetLabel;
90  //if(thisJetTruthLabel=="B") {
91  //jet.set_pdgId(PDG::b);// AA - need jet input
92  //if (jql) {
93  // truthInfo->BDecayVertex(jql->BDecVtx());
94  // truthInfo->BHadronPdg(jql->Bpdg());
95  // }
96  //} else if(thisJetTruthLabel=="C") {
97  //jet.set_pdgId(PDG::c);// AA - need jet input
98  //} else if(thisJetTruthLabel=="T") {
99  //jet.set_pdgId(PDG::tau_minus);// AA - need jet input
100  //}
101  }
102  else {
103  thisJetTruthLabel = -1;
104  }
105  jet.setAttribute("ConeTruthLabelID",thisJetTruthLabel);
106  ATH_MSG_VERBOSE("#BTAG# Matching tool result: " << jetIsMatched << " " << thisJetTruthLabel);
107  //std::cout << "AARON result: " << jetIsMatched << " " << thisJetTruthLabel << std::endl;
108  //jet.addInfo(truthInfo); AA - need jet input
109 
110  //
111  // Quick and dirty : if the McEventCollection contains more than one event,
113 
117 /* if (jql) {
118  //std::cout << "AARON in jql" << std::endl;
119  int nMC = jql->NEventInCollection();
120  if (nMC > 1 && jql->EventSelection() == -1) {
121  TruthInfo* truthInfoPU = new TruthInfo("TruthInfoPU");
122  jql->EventSelection(1);
123  bool jetIsMatchedPU = m_jetTruthMatchTool->matchJet( jet );
124  truthInfoPU->deltaRMinTo("B", jql->deltaRMinTo("B"));
125  truthInfoPU->deltaRMinTo("C", jql->deltaRMinTo("C"));
126  truthInfoPU->deltaRMinTo("T", jql->deltaRMinTo("T"));
127  truthInfoPU->setJetTruthLabel(m_jetTruthMatchTool->jetLabel());
128  if (jetIsMatchedPU && m_jetTruthMatchTool->jetLabel() == "B") {
129  truthInfoPU->BDecayVertex(jql->BDecVtx());
130  truthInfoPU->BHadronPdg(jql->Bpdg());
131  }
132  //jet.addInfo(truthInfoPU); AA - need jet input
133  //std::cout << "AARON calling jql->EventSelection(-1)" << std::endl;
134  jql->EventSelection(-1);
135  }
136  }*/
137  }/*
138  //JetQGPartonTruthMatching and setting of the TruthInfo object
139  bool jetIsQGPartonMatched( true );
140  std::string thisJetQGPartonTruthLabel( "N/A" ); /// by default no truth info available
141  const Analysis::QGPartonTruthInfo* QGPartonmcinfo = jet.tagInfo<Analysis::QGPartonTruthInfo>("QGPartonTruthInfo");
142  bool doQGPartonTruthInfo = true;
143  if(QGPartonmcinfo) doQGPartonTruthInfo = false;
144 
145  if (!m_jetQGPartonTruthMatchTool.empty() && doQGPartonTruthInfo) {
146  QGPartonTruthInfo* QGTruthInfo = new QGPartonTruthInfo("QGPartonTruthInfo");
147  ATH_MSG_VERBOSE("#QGTAG# Matching tool available, calling it...");
148  jetIsQGPartonMatched = m_jetQGPartonTruthMatchTool->matchJet( jet );
149  JetQGPartonLabel* jqgpl = dynamic_cast<JetQGPartonLabel*>(&(*m_jetQGPartonTruthMatchTool)); // & gets the pointer out of the ToolHandle to cast it!
150  //
151  if ( jetIsQGPartonMatched ) {
152  thisJetQGPartonTruthLabel = m_jetQGPartonTruthMatchTool->jetLabel();
153  QGTruthInfo->setJetTruthLabel(thisJetQGPartonTruthLabel);
154  if(jqgpl){
155  QGTruthInfo->deltaRToParton( jqgpl->deltaRToParton() );
156  }
157  }
158  ATH_MSG_VERBOSE("#QGTAG# Matching tool result: " << jetIsQGPartonMatched << " " << thisJetQGPartonTruthLabel);
159  jet.addInfo(QGTruthInfo);
160  //
161  // Quick and dirty : if the McEventCollection contains more than one event,
163 
167  if (jqgpl) {
168  int nMC = jqgpl->NEventInCollection();
169  if (nMC > 1 && jqgpl->EventSelection() == -1) {
170  QGPartonTruthInfo* QGTruthInfoPU = new Analysis::QGPartonTruthInfo("QGPartonTruthInfoPU");
171  jqgpl->EventSelection(1);
172  bool jetIsQGPartonMatchedPU = m_jetQGPartonTruthMatchTool->matchJet( jet );
173  if(jetIsQGPartonMatchedPU){
174  QGTruthInfoPU->deltaRToParton(jqgpl->deltaRToParton());
175  QGTruthInfoPU->setJetTruthLabel(m_jetQGPartonTruthMatchTool->jetLabel());
176  jet.addInfo(QGTruthInfoPU);
177  jqgpl->EventSelection(-1);
178  }
179  }
180  }
181  }
182 
183  // Specific truth information for leptons:
184  if (!m_LeptonTruthTool.empty() && doSLTruthInfo) {
185  ATH_MSG_VERBOSE("#BTAG# Lepton truth tool available, calling it...");
186  std::vector<SLTrueInfo> sltinfovec = m_LeptonTruthTool->FindTruth( jet );
187  uint numberOfTrueLeptons = sltinfovec.size();
188  if (numberOfTrueLeptons > 0) {
189  SoftLeptonTruthInfo* sltinfo = new SoftLeptonTruthInfo("SoftLeptonTruthInfo");
190  for (uint i = 0; i < numberOfTrueLeptons; i++) {
191  ATH_MSG_VERBOSE("#BTAG# Adding lepton " << i << " " << sltinfovec[i]);
192  sltinfo->addSLTrueInfo(sltinfovec[i]);
193  }
194  jet.addInfo(sltinfo);
195  }
196  ATH_MSG_VERBOSE("#BTAG# Lepton truth tool result: " << numberOfTrueLeptons);
197  }
198  return StatusCode::SUCCESS;*/
199 
200  return 0;
201  }
202 
203 } // namespace
grepfile.info
info
Definition: grepfile.py:38
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Analysis::IJetTruthMatching::MatchInfo
Definition: IJetTruthMatching.h:43
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
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
Analysis::JetConeLabeling::JetConeLabeling
JetConeLabeling(const std::string &name)
Constructors and destructors.
Definition: JetConeLabeling.cxx:21
Analysis::JetConeLabeling::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: JetConeLabeling.cxx:34
Analysis
The namespace of all packages in PhysicsAnalysis/JetTagging.
Definition: BTaggingCnvAlg.h:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Analysis::JetConeLabeling::~JetConeLabeling
virtual ~JetConeLabeling()
Definition: JetConeLabeling.cxx:31
JetConeLabeling.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
Analysis::JetConeLabeling::modifyJet
virtual int modifyJet(xAOD::Jet &jet) const
Modify a single jet. This is obsolete and set to be removed.
Definition: JetConeLabeling.cxx:66
JetQuarkLabel.h
JetModifierBase
Definition: JetModifierBase.h:22
Analysis::JetConeLabeling::m_jetTruthMatchTool
ToolHandle< IJetTruthMatching > m_jetTruthMatchTool
pointer to the Truth matching tool
Definition: JetConeLabeling.h:32