ATLAS Offline Software
DeltaRRoIComboHypoTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <algorithm>
8 #include <cmath>
9 
10 using namespace TrigCompositeUtils;
11 
13  const std::string& name,
14  const IInterface* parent)
16 { }
17 
18 
20  ATH_MSG_DEBUG("DR threshold set to " << m_DRcut );
21  return StatusCode::SUCCESS;
22 }
23 
24 
25 
26 bool DeltaRRoIComboHypoTool::executeAlg(const std::vector<Combo::LegDecision>& combination) const
27 {
28  //retrieve the rois
29  std::vector<ElementLink<TrigRoiDescriptorCollection>> selected_rois;
30 
31  // Expecting to only run over chains with two legs and one Decision Object required on each leg
32  // So should always have two objects from which to check DeltaR
33  if(combination.size() != 2){
35  "Expecting to combine exactly two Decision Objects, but instead found "
36  << combination.size() << ". Will throw a runtime error");
37  throw std::runtime_error(
38  "Expecting to combine exactly two Decision Objects, but instead found " +
39  std::to_string(combination.size()));
40  }
41 
42  for (const auto& el: combination){
43  const auto EL= el.second;
44  const auto dec= (*EL);
45  const auto roiLink = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>( dec, initialRoIString() ).link;
46  selected_rois.push_back(roiLink);
47  }
48 
49  auto roiLink1=selected_rois[0];
50  auto roiLink2=selected_rois[1];
51  // calucalte DeltaR
52  float Dr = deltaR((*roiLink1)->eta(), (*roiLink2)->eta(), (*roiLink1)->phi(), (*roiLink2)->phi());
53  ATH_MSG_DEBUG("Found two RoIs with eta/phi " << (*roiLink1)->eta() <<"/"<<(*roiLink1)->phi() <<" and "<< (*roiLink2)->eta()<<"/"<<(*roiLink2)->phi() <<" with Dr="<<Dr);
54 
55  // apply the cut
56  bool pass=true;
57  if (Dr > m_DRcut) pass=false;
58 
59  if (pass)
60  ATH_MSG_DEBUG( " RoIs within DR<"<<m_DRcut<<". This seleciton passed! ");
61 
62  return pass;
63 }
64 
65 
66 double DeltaRRoIComboHypoTool::deltaR(double eta1, double eta2, double phi1, double phi2) const {
67  double dPhi=std::remainder( phi1 - phi2, 2*M_PI );
68  double dEta=std::fabs(eta1-eta2);
69  return std::sqrt(dEta*dEta + dPhi*dPhi);
70 }
71 
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
DeltaRRoIComboHypoTool.h
DeltaRRoIComboHypoTool::DeltaRRoIComboHypoTool
DeltaRRoIComboHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: DeltaRRoIComboHypoTool.cxx:12
DeltaRRoIComboHypoTool::deltaR
double deltaR(double eta1, double eta2, double phi1, double phi2) const
Definition: DeltaRRoIComboHypoTool.cxx:66
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
ComboHypoToolBase
Base class for tools which cut on properties of multi-object or multi-leg chains. User should derive ...
Definition: ComboHypoToolBase.h:26
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigCompositeUtils::initialRoIString
const std::string & initialRoIString()
Definition: TrigCompositeUtilsRoot.cxx:870
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
TauGNNUtils::Variables::Track::dPhi
bool dPhi(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:530
test_pyathena.parent
parent
Definition: test_pyathena.py:15
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
DeltaRRoIComboHypoTool::executeAlg
bool executeAlg(const std::vector< Combo::LegDecision > &combination) const override
Only a dummy implementation exists in ComboHypoToolBase.
Definition: DeltaRRoIComboHypoTool.cxx:26
Dr
double Dr
Definition: LArDetectorConstructionTBEC.cxx:55
remainder
std::vector< std::string > remainder(const std::vector< std::string > &v1, const std::vector< std::string > &v2)
list of entries in a vector that are not in another
Definition: compareFlatTrees.cxx:44
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
DeltaRRoIComboHypoTool::m_DRcut
Gaudi::Property< float > m_DRcut
Definition: DeltaRRoIComboHypoTool.h:31
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:525
TrigRoiDescriptorCollection.h
DeltaRRoIComboHypoTool::initialize
virtual StatusCode initialize() override
Definition: DeltaRRoIComboHypoTool.cxx:19