ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
12using namespace std;
13using namespace xAOD;
14
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}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading a decoration on an object.
Handle class for adding a decoration to an object.
Gaudi::Property< std::string > m_chargeDecorator
Gaudi::Property< std::string > m_partonAccessor
StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< std::string > m_hadronAccessor
Gaudi::Property< std::map< int, int > > m_mapOption
JetQuarkChargeLabelingTool(const std::string &name)
Constructor.
StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
SG::Decorator< T, ALLOC > Decorator
Definition AuxElement.h:575
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
STL namespace.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".