ATLAS Offline Software
Loading...
Searching...
No Matches
EventCleaningTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5/******************************************************************************
6Name: EventCleaningTool
7
8Author: Julia Gonski
9Created: Nov 2016
10
11Description: Class for selecting events that pass recommended jet cleaning procedure
12******************************************************************************/
13
14// This class header and package headers
18
19// The xAOD jet type
20#include "xAODJet/Jet.h"
22
23// xAOD/ASG includes
27
28
29// STL includes
30#include <iostream>
31#include <cmath>
32#include <cfloat>
33
34// ROOT includes
35#include "TEnv.h"
36
37namespace ECUtils {
38
39//=============================================================================
40// Constructors
41//=============================================================================
43 : asg::AsgTool(name)
44 , m_jetCleaningTool("JetCleaningTool/JetCleaningTool")
45{
46 m_jetCleaningTool.declarePropertyFor(this, "JetCleaningTool");
47}
48
49
50//=============================================================================
51// Destructor
52//=============================================================================
54
55//=============================================================================
56// Initialize
57//=============================================================================
59{
60 if(m_passJvtKey.key() == "" || m_passORKey.key() == ""){
61 ATH_MSG_ERROR( "Tool initialized with unknown decorator names." );
62 return StatusCode::FAILURE;
63 }
64 if (m_cleaningLevel == ""){
65 ATH_MSG_ERROR( "Tool initialized with unknown cleaning level." );
66 return StatusCode::FAILURE;
67 }
68 if(m_jetContainerName == ""){
69 ATH_MSG_ERROR( "Tool initialized with no jet container name." );
70 return StatusCode::FAILURE;
71 }
72
73 //initialize jet cleaning tool
74 ATH_CHECK(m_jetCleaningTool.setProperty("JetContainer", m_jetContainerName ));
75 ATH_CHECK(m_jetCleaningTool.setProperty("CutLevel", m_cleaningLevel ));
76 ATH_CHECK(m_jetCleaningTool.setProperty("UseDecorations", m_useDecorations )); //for AODs we can't use decorations
77 ATH_CHECK(m_jetCleaningTool.retrieve());
78 ATH_MSG_INFO( "Event cleaning tool configured with cut level " << m_cleaningLevel );
79
83
84 ATH_CHECK(m_passJvtKey.initialize());
85 ATH_CHECK(m_passORKey.initialize());
87
88#ifndef XAOD_STANDALONE
90 // The user has promised that this will be produced by the same alg.
91 // Tell the scheduler to ignore it to avoid circular dependencies.
94 }
97 }
98#endif
99
100 return StatusCode::SUCCESS;
101}
102
104{
105 bool pass_pt = 0;
106 bool pass_eta = 0;
107 bool pass_accept = 0;
108 int jvtDecision = 0;
109 int orDecision = 0;
110 bool isThisJetGood = 0;
111 bool isEventAllGood = 1;
112
116
117 for (auto thisJet : *jets){ //loop over decorated jet collection
118 pass_pt = thisJet->pt() > m_pt;
119 pass_eta = fabs(thisJet->eta()) < m_eta;
120 pass_accept = keepJet(*thisJet);
121 jvtDecision = jvtHandle(*thisJet);
122 orDecision = !(orHandle(*thisJet)); //recall, passOR==0 means that the jet is not an overlap and should be kept!
123
124 ATH_MSG_DEBUG("Jet info: pT: " << pass_pt << ", eta: " << pass_eta << ", accept? " << pass_accept << ", jvt: " << jvtDecision << ", or: " << orDecision);
125 if(pass_pt && pass_eta && jvtDecision && orDecision){//only consider jets for cleaning if they pass these requirements.
126 isThisJetGood = pass_accept;
127 isEventAllGood = isEventAllGood && isThisJetGood; //any event with a bad jet is rejected
128 }
129 else isThisJetGood = pass_accept; //if it fails any one of these, it shouldn't be able to kill the whole event, but we still need to know cleaning
130 ATH_MSG_DEBUG("Is jet good? " << isThisJetGood);
131 if(m_decorate) jetCleanHandle(*thisJet) = isThisJetGood;
132 }
133 ATH_MSG_DEBUG("Is event good? " << isEventAllGood);
134 return isEventAllGood;
135}
136
138{
139 return m_jetCleaningTool->keep(jet);
140}
141
142}//ECUtils
143
144
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading a decoration on an object.
Handle class for adding a decoration to an object.
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
SG::WriteDecorHandleKey< xAOD::JetContainer > m_jetCleanKey
EventCleaningTool(const std::string &name="EventCleaningTool")
Create a proper constructor for Athena.
asg::AnaToolHandle< IJetSelector > m_jetCleaningTool
virtual ~EventCleaningTool()
Standard destructor.
SG::ReadDecorHandleKey< xAOD::JetContainer > m_passJvtKey
virtual bool acceptEvent(const xAOD::JetContainer *jets) const override
Declare the interface.
virtual int keepJet(const xAOD::Jet &jet) const override
Gaudi::Property< double > m_pt
Gaudi::Property< bool > m_suppressOutputDeps
Gaudi::Property< std::string > m_prefix
Gaudi::Property< bool > m_useDecorations
Gaudi::Property< std::string > m_jetContainerName
Gaudi::Property< std::string > m_cleaningLevel
virtual StatusCode initialize() override
Initialize method.
Gaudi::Property< bool > m_decorate
Gaudi::Property< double > m_eta
SG::ReadDecorHandleKey< xAOD::JetContainer > m_passORKey
Gaudi::Property< bool > m_suppressInputDeps
Handle class for reading a decoration on an object.
Handle class for adding a decoration to an object.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".