ATLAS Offline Software
Loading...
Searching...
No Matches
DeltaRRoIComboHypoTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include <algorithm>
8#include <cmath>
9
10using namespace TrigCompositeUtils;
11
13 const std::string& name,
14 const IInterface* parent)
15 : ComboHypoToolBase(type, name, parent)
16{ }
17
18
20 ATH_MSG_DEBUG("DR threshold set to " << m_DRcut );
21 return StatusCode::SUCCESS;
22}
23
24
25
26bool DeltaRRoIComboHypoTool::executeAlg(const std::vector<Combo::LegDecision>& combination,
27 const EventContext& /*ctx*/) const
28{
29 //retrieve the rois
30 std::vector<ElementLink<TrigRoiDescriptorCollection>> selected_rois;
31
32 // Expecting to only run over chains with two legs and one Decision Object required on each leg
33 // So should always have two objects from which to check DeltaR
34 if(combination.size() != 2){
36 "Expecting to combine exactly two Decision Objects, but instead found "
37 << combination.size() << ". Will throw a runtime error");
38 throw std::runtime_error(
39 "Expecting to combine exactly two Decision Objects, but instead found " +
40 std::to_string(combination.size()));
41 }
42
43 for (const auto& el: combination){
44 const auto EL= el.second;
45 const auto dec= (*EL);
47 selected_rois.push_back(roiLink);
48 }
49
50 auto roiLink1=selected_rois[0];
51 auto roiLink2=selected_rois[1];
52 // calucalte DeltaR
53 float Dr = deltaR((*roiLink1)->eta(), (*roiLink2)->eta(), (*roiLink1)->phi(), (*roiLink2)->phi());
54 ATH_MSG_DEBUG("Found two RoIs with eta/phi " << (*roiLink1)->eta() <<"/"<<(*roiLink1)->phi() <<" and "<< (*roiLink2)->eta()<<"/"<<(*roiLink2)->phi() <<" with Dr="<<Dr);
55
56 // apply the cut
57 bool pass=true;
58 if (Dr > m_DRcut) pass=false;
59
60 if (pass)
61 ATH_MSG_DEBUG( " RoIs within DR<"<<m_DRcut<<". This seleciton passed! ");
62
63 return pass;
64}
65
66
67double DeltaRRoIComboHypoTool::deltaR(double eta1, double eta2, double phi1, double phi2) const {
68 double dPhi=std::remainder( phi1 - phi2, 2*M_PI );
69 double dEta=std::fabs(eta1-eta2);
70 return std::sqrt(dEta*dEta + dPhi*dPhi);
71}
72
#define M_PI
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
ComboHypoToolBase(const std::string &type, const std::string &name, const IInterface *parent)
DeltaRRoIComboHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
double deltaR(double eta1, double eta2, double phi1, double phi2) const
virtual StatusCode initialize() override
bool executeAlg(const std::vector< Combo::LegDecision > &combination, const EventContext &ctx) const override
Only a dummy implementation exists in ComboHypoToolBase.
Gaudi::Property< float > m_DRcut
This module defines the arguments passed from the BATCH driver to the BATCH worker.
LinkInfo< T > findLink(const Decision *start, const std::string &linkName, const bool suppressMultipleLinksWarning=false)
Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision obj...
const std::string & initialRoIString()