ATLAS Offline Software
Loading...
Searching...
No Matches
DRConeAssociationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id$
12
13// STL include(s):
14#include <cmath>
15
20#include "GaudiKernel/SystemOfUnits.h"
21
22
23using Gaudi::Units::MeV;
24
25
26namespace D3PD {
27
28
36 (const std::string& type,
37 const std::string& name,
38 const IInterface* parent)
39 : Base (type, name, parent),
40 m_getter (this),
41 m_p (0)
42{
43 declareProperty ("Getter", m_getter,
44 "ICollectionGetterTool instance defining "
45 "the target collection");
46 declareProperty ("DRCut", m_drcut = 999,
47 "DR cut for the association");
48}
49
50
55{
56 // Retrieve the getter tool and configure it, saying that we want
57 // to get @c INavigable4Momentum objects from it.
58 CHECK( m_getter.retrieve() );
59 CHECK( m_getter->configureD3PD<INavigable4Momentum>() );
60 return Base::initialize();
61}
62
63
69{
70 m_p = &p;
71 CHECK( m_getter->reset() );
72 return StatusCode::SUCCESS;
73}
74
75
82{
83 // Protect against null 4-momenta --- they'll crash deltaR.
84 if (m_p->p() < 1e-3*MeV) {
85 m_p = 0;
86 return 0;
87 }
88 // Protect against infinite eta. It appears in some circumstances.
89 if( std::isinf( m_p->eta() ) ) {
90 m_p = 0;
91 return 0;
92 }
93
94 while ( const INavigable4Momentum* obj =
96 {
97 if (obj->p() < 1e-3*MeV) continue;
98 if( std::isinf( obj->eta() ) ) continue;
99 float dr = static_cast<float> (P4Helpers::deltaR (*m_p, *obj));
100 if (dr < m_drcut)
101 return obj;
102 }
103 m_p = 0;
104 return 0;
105}
106
107
108} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Associate all particles within a DR cut.
ToolHandle< ICollectionGetterTool > m_getter
Property: The getter for the target collection.
virtual StatusCode initialize()
Standard Gaudi initialize method.
const INavigable4Momentum * m_p
The input object.
virtual const INavigable4Momentum * next()
Return a pointer to the next element in the association.
DRConeAssociationTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
virtual StatusCode reset(const INavigable4Momentum &p)
Start the iteration for a new association.
MultiAssociationTool< INavigable4Momentum > Base
Block filler tool for noisy FEB information.
double deltaR(const I4Momentum &p4, double eta, double phi)
from 1 I4Momentum
Definition P4Helpers.h:209