ATLAS Offline Software
JetQuarkChargeLabelingTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "xAODJet/JetContainer.h"
8 #include "AsgMessaging/Check.h"
11 
12 using namespace std;
13 using namespace xAOD;
14 
16  : AsgTool(name) {
17 }
18 
20 {
21 
22  // Initialize output handles
23  ATH_MSG_DEBUG("Initializing JetQuarkChargeLabelingTool");
24  m_map = m_mapOption.value();
25 
26  return StatusCode::SUCCESS;
27 }
28 
30 {
31 
32  ATH_MSG_VERBOSE("In " << name() << "::decorate()");
33 
34  SG::AuxElement::Accessor<int> hadronAccessorHandle(m_hadronAccessor.value());
35  SG::AuxElement::Accessor<int> partonAccessorHandle(m_partonAccessor.value());
36  SG::AuxElement::Decorator<int> chargeDecoratorHandle(m_chargeDecorator.value());
37 
38  for (const xAOD::Jet* jet: jets) {
39  int final_pdgId = -999 ;
40 
41  //get hadron pdgId and parton label :
42 
43  int hadron_pdgId = hadronAccessorHandle(*jet);
44  int parton_pdgId = partonAccessorHandle(*jet);
45  int negative_pdgId = (-1)*hadron_pdgId;
46 
47  if( hadron_pdgId == 0 ){
48  final_pdgId = parton_pdgId;
49  ATH_MSG_DEBUG("Jet is a light-jet. Associating to the jet the value of the " << m_partonAccessor);
50  }else{
51  if(m_map.count(hadron_pdgId) >0){
52  final_pdgId = m_map.at(hadron_pdgId);
53  ATH_MSG_DEBUG("Found associated hadron. Assigning " << final_pdgId << " to jet");
54  }else if(m_map.count(negative_pdgId) >0 ){
55  final_pdgId = (-1)*m_map.at(negative_pdgId);
56  ATH_MSG_DEBUG("Found associated hadron. Assigning " << final_pdgId << " to jet");
57  }else{
58  ATH_MSG_DEBUG("Couldn't find the hadron with pdgId " << hadron_pdgId << " in current map. Assigning default " << final_pdgId << " to jet" );
59  };
60  };
61 
62  // Decorate the jet with the charge too
63  chargeDecoratorHandle(*jet) = final_pdgId;
64  };
65 
66  return StatusCode::SUCCESS;
67 }
JetQuarkChargeLabelingTool::decorate
StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition: JetQuarkChargeLabelingTool.cxx:29
JetQuarkChargeLabelingTool::initialize
StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: JetQuarkChargeLabelingTool.cxx:19
Check.h
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
JetQuarkChargeLabelingTool::m_map
std::map< int, int > m_map
Definition: JetQuarkChargeLabelingTool.h:37
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
JetQuarkChargeLabelingTool::m_partonAccessor
Gaudi::Property< std::string > m_partonAccessor
Definition: JetQuarkChargeLabelingTool.h:33
ParticleJetLabelCommon.h
JetQuarkChargeLabelingTool::JetQuarkChargeLabelingTool
JetQuarkChargeLabelingTool(const std::string &name)
Constructor.
Definition: JetQuarkChargeLabelingTool.cxx:15
JetQuarkChargeLabelingTool::m_mapOption
Gaudi::Property< std::map< int, int > > m_mapOption
Definition: JetQuarkChargeLabelingTool.h:35
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
JetQuarkChargeLabelingTool::m_chargeDecorator
Gaudi::Property< std::string > m_chargeDecorator
Definition: JetQuarkChargeLabelingTool.h:34
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
WriteDecorHandle.h
Handle class for adding a decoration to an object.
JetQuarkChargeLabelingTool.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
JetContainer.h
ReadDecorHandle.h
Handle class for reading a decoration on an object.
JetQuarkChargeLabelingTool::m_hadronAccessor
Gaudi::Property< std::string > m_hadronAccessor
Definition: JetQuarkChargeLabelingTool.h:32