ATLAS Offline Software
ViewCreatorJetSuperROITool.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "AthViews/ViewHelper.h"
7 #include "CxxUtils/phihelper.h"
9 
10 #include "xAODJet/JetContainer.h"
12 
14  const std::string& name,
15  const IInterface* parent)
16  : base_class(type, name, parent)
17 {}
18 
19 
22 
23  return StatusCode::SUCCESS;
24 }
25 
26 
28  const EventContext& ctx ) const {
29 
30  // ===================================================================================== //
31  // ===================================================================================== //
32  // Create output RoI collection
33 
35  // ===================================================================================== //
36 
37  // Only expect one object in container
38  if(decisions.size()!=1) {
39  ATH_MSG_ERROR("Did not find exactly one decision object in decision container containing " << decisions.size() << " decisions");
40  return StatusCode::FAILURE;
41  }
42  TrigCompositeUtils::Decision* outputDecision = decisions[0];
43 
44  // Link name should probably be configurable
45  const TrigCompositeUtils::LinkInfo< xAOD::JetContainer> leadingjetlink = TrigCompositeUtils::findLink< xAOD::JetContainer >(outputDecision, "LeadingPreselJet", TrigDefs::lastFeatureOfType);
46  if(!leadingjetlink.link.isValid()) {
47  ATH_MSG_ERROR("Received invalid jet link from decision object! " << leadingjetlink.link);
48  return StatusCode::FAILURE;
49  }
50 
51  const xAOD::JetContainer* jetCont = static_cast<const xAOD::JetContainer*>((*leadingjetlink.link)->container());
52  ATH_MSG_DEBUG("Found " << jetCont->size() << " presel jets linked from decision object.");
53 
54  // This is needed to merge the RoIs from each jet
55  std::unique_ptr<TrigRoiDescriptor> superRoI = std::make_unique<TrigRoiDescriptor>();
56 
63  superRoI->setComposite(true);
64  superRoI->manageConstituents(false);
65 
66  for(const xAOD::Jet* jet : *jetCont) {
67  if(jet->pt()>m_jetMinPt && std::abs(jet->eta())<m_jetMaxAbsEta) {
68  double jetEta{jet->eta()}, jetPhi{jet->phi()};
69 
70  ATH_MSG_DEBUG("JET -- pt=" << jet->pt() <<
71  " eta=" << jet->eta() <<
72  " phi=" << jet->phi() );
73 
74  // create ROIs
75  ATH_MSG_DEBUG("Adding RoI to RoI container");
76  ATH_MSG_DEBUG( " ** Imposing Z constraint while building RoI" );
77  double etaMinus = jetEta - m_roiEtaWidth;
78  double etaPlus = jetEta + m_roiEtaWidth;
79 
80  double phiMinus = CxxUtils::wrapToPi( jetPhi - m_roiPhiWidth );
81  double phiPlus = CxxUtils::wrapToPi( jetPhi + m_roiPhiWidth );
82 
83 
84  if ( m_roiZWidth > 0 ) {
85  // Should retrieve beamspot offset from somewhere
86  double zMinus = -1. * m_roiZWidth;
87  double zPlus = m_roiZWidth;
88 
91  superRoI->push_back( new TrigRoiDescriptor( jetEta, etaMinus, etaPlus,
92  jetPhi, phiMinus, phiPlus,
93  0.,zMinus,zPlus ) );
94  }
95  else {
96  superRoI->push_back( new TrigRoiDescriptor( jetEta, etaMinus, etaPlus,
97  jetPhi, phiMinus, phiPlus ) );
98  }
99 
100 
104  superRoI->manageConstituents(true);
105  }
106  }
107 
108  roisWriteHandle->push_back(superRoI.release());
110  outputDecision->setObjectLink( TrigCompositeUtils::roiString(), roiEL );
111 
112  ATH_MSG_DEBUG("PRINTING DECISION");
113  ATH_MSG_DEBUG( *outputDecision );
114 
115  return StatusCode::SUCCESS;
116 }
TrigCompositeUtils::LinkInfo::link
ElementLink< T > link
Link to the feature.
Definition: LinkInfo.h:61
CxxUtils::wrapToPi
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition: phihelper.h:24
ViewHelper.h
ViewCreatorJetSuperROITool::m_roiEtaWidth
Gaudi::Property< double > m_roiEtaWidth
Definition: ViewCreatorJetSuperROITool.h:57
ViewCreatorJetSuperROITool::attachROILinks
virtual StatusCode attachROILinks(TrigCompositeUtils::DecisionContainer &decisions, const EventContext &ctx) const override
Tool interface method.
Definition: ViewCreatorJetSuperROITool.cxx:27
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
RoiDescriptor::push_back
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
Definition: RoiDescriptor.h:157
ViewCreatorJetSuperROITool::m_jetMinPt
Gaudi::Property< double > m_jetMinPt
Definition: ViewCreatorJetSuperROITool.h:50
xAOD::TrigComposite_v1::setObjectLink
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
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
ViewCreatorJetSuperROITool::m_roiZWidth
Gaudi::Property< double > m_roiZWidth
Definition: ViewCreatorJetSuperROITool.h:64
ViewCreatorJetSuperROITool::m_jetMaxAbsEta
Gaudi::Property< double > m_jetMaxAbsEta
Definition: ViewCreatorJetSuperROITool.h:54
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ViewCreatorJetSuperROITool.h
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TrigCompositeUtils::createAndStoreNoAux
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Creates and right away records the Container CONT with the key.
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:101
ViewCreatorJetSuperROITool::ViewCreatorJetSuperROITool
ViewCreatorJetSuperROITool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ViewCreatorJetSuperROITool.cxx:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
phihelper.h
Helper for azimuthal angle calculations.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
SG::WriteHandle< TrigRoiDescriptorCollection >
TrigCompositeUtils::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:28
ViewCreatorJetSuperROITool::m_roisWriteHandleKey
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
Definition: ViewCreatorJetSuperROITool.h:44
JetContainer.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ViewCreatorJetSuperROITool::initialize
virtual StatusCode initialize() override
Definition: ViewCreatorJetSuperROITool.cxx:20
JetAuxContainer.h
RoiDescriptor::setComposite
void setComposite(bool b=true)
Definition: RoiDescriptor.h:138
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:876
TrigRoiDescriptor
Athena::TPCnvVers::Current TrigRoiDescriptor
Definition: TrigSteeringEventTPCnv.cxx:68
RoiDescriptor::manageConstituents
bool manageConstituents() const
always manage constituents ???
Definition: RoiDescriptor.h:141
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
ViewCreatorJetSuperROITool::m_roiPhiWidth
Gaudi::Property< double > m_roiPhiWidth
Definition: ViewCreatorJetSuperROITool.h:60
TrigRoiDescriptorCollection.h