ATLAS Offline Software
Loading...
Searching...
No Matches
JetGroomer.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#include "JetRec/JetGroomer.h"
6
8#include "fastjet/PseudoJet.hh"
10
12
13using namespace JetGrooming;
14
15
17
18 ATH_MSG_DEBUG("Initializing...");
19
20 if(m_inputJetContainer.empty()){
21 ATH_MSG_ERROR("Jet grooming requested with no input ungroomed jets");
22 return StatusCode::FAILURE;
23 } else if(m_inputPseudoJets.empty()){
24 ATH_MSG_ERROR("Jet grooming requested with no input pseudojets");
25 return StatusCode::FAILURE;
26 }
27 else{
28 if(!m_finalPseudoJets.empty()){
29 ATH_MSG_WARNING("A non-empty value was found for the FinalPseudoJets WriteHandleKey -- this will be ignored!");
30 }
31
32 ATH_CHECK(m_inputJetContainer.initialize());
33 ATH_CHECK(m_inputPseudoJets.initialize());
34 m_finalPseudoJets = name() + "FinalPJ";
35 ATH_CHECK(m_finalPseudoJets.initialize());
36 }
37
38 return StatusCode::SUCCESS;
39}
40
41
42// Common operations for any jet groomer
43std::pair<std::unique_ptr<xAOD::JetContainer>,std::unique_ptr<SG::IAuxStore> > JetGroomer::getJets() const {
44 // Return this in case of any problems
45 auto nullreturn = std::make_pair(std::unique_ptr<xAOD::JetContainer>(nullptr), std::unique_ptr<SG::IAuxStore>(nullptr));
46
47 // -----------------------
48 // retrieve input
50 if(!jetContHandle.isValid()) {
51 ATH_MSG_ERROR("No valid JetContainer with key "<< m_inputJetContainer.key());
52 return nullreturn;
53 }
54
56 if(!pjContHandle.isValid()) {
57 ATH_MSG_ERROR("No valid PseudoJetContainer with key "<< m_inputPseudoJets.key());
58 return nullreturn;
59 }
60
61 // Build the container to be returned
62 // Avoid memory leaks with unique_ptr
63 auto groomedJets = std::make_unique<xAOD::JetContainer>();
64 auto auxCont = std::make_unique<xAOD::JetAuxContainer>();
65 groomedJets->setStore(auxCont.get());
66
67 // -----------------------
68 // Build a new pointer to a PseudoJetVector containing the final groomed PseudoJets
69 // This allows us to own the vector of PseudoJet which we will put in the evt store.
70 // Thus the contained PseudoJet will be kept frozen there and we can safely use pointer to them from the xAOD::Jet objects
71 auto groomPJVector = std::make_unique<PseudoJetVector>( );
72 groomPJVector->resize( jetContHandle->size() );
73
74 // loop over input jets
75 for (const xAOD::Jet* parentJet: *jetContHandle){
76 // Child will create a groomed jet and insert it into the output container
77 this->insertGroomedJet(*parentJet, *pjContHandle, *groomedJets, *groomPJVector);
78 }
79
80 // -------------------------------------
81 // record final PseudoJetVector
83 if(!pjVectorHandle.record(std::move(groomPJVector))){
84 ATH_MSG_ERROR("Can't record PseudoJetVector under key "<< m_finalPseudoJets);
85 return nullreturn;
86 }
87
88 return std::make_pair(std::move(groomedJets),std::move(auxCont));
89}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
SG::ReadHandleKey< PseudoJetContainer > m_inputPseudoJets
This is the input to the parent JetContainer. It is needed in order to re-assign the ghost constituen...
Definition JetGroomer.h:58
virtual void insertGroomedJet(const xAOD::Jet &, const PseudoJetContainer &, xAOD::JetContainer &, PseudoJetVector &) const =0
virtual std::pair< std::unique_ptr< xAOD::JetContainer >, std::unique_ptr< SG::IAuxStore > > getJets() const override final
Method to build the collection and return it to the caller.
SG::WriteHandleKey< PseudoJetVector > m_finalPseudoJets
Definition JetGroomer.h:60
SG::ReadHandleKey< xAOD::JetContainer > m_inputJetContainer
Handle Input JetContainer (this contains the parent ungroomed jets to be trimmed)
Definition JetGroomer.h:55
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".