ATLAS Offline Software
TrigEgammaFastPhotonReAlgo.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /**************************************************************************
6  ** Original Author: B.Safarzadeh
7  **************************************************************************/
8 
13 
14 
15 class ISvcLocator;
16 
17 
18 TrigEgammaFastPhotonReAlgo::TrigEgammaFastPhotonReAlgo(const std::string & name, ISvcLocator* pSvcLocator)
19  : AthReentrantAlgorithm(name, pSvcLocator)
20 {
21 }
22 
23 
25 {
26 
28  ATH_CHECK( m_TrigEMClusterContainerKey.initialize() );
29  ATH_CHECK( m_outputPhotonsKey.initialize() );
30  return StatusCode::SUCCESS;
31 }
32 
33 
34 StatusCode TrigEgammaFastPhotonReAlgo::execute( const EventContext& ctx ) const
35 
36 {
37  using namespace xAOD;
38  auto trigPhotoColl = SG::makeHandle (m_outputPhotonsKey, ctx);
39  ATH_CHECK( trigPhotoColl.record (std::make_unique<xAOD::TrigPhotonContainer>(),
40  std::make_unique<xAOD::TrigEMClusterAuxContainer>()) );
41 
42  ATH_MSG_DEBUG( "Made WriteHandle " << m_outputPhotonsKey );
43 
44  auto roiCollection = SG::makeHandle(m_roiCollectionKey, ctx);
45  if (roiCollection->size()==0) {
46  ATH_MSG_DEBUG(" RoI collection size = 0");
47  return StatusCode::SUCCESS;
48  }
49 
50  const TrigRoiDescriptor* roiDescriptor = *(roiCollection->begin());
51 
52  ATH_MSG_DEBUG(" RoI ID = " << (roiDescriptor)->roiId() << ": Eta = " << (roiDescriptor)->eta()
53  << ", Phi = " << (roiDescriptor)->phi());
54 
55 
56  double etaRef = roiDescriptor->eta();
57  double phiRef = roiDescriptor->phi();
58  // correct phi the to right range (probably not needed anymore)
59  if ( fabs(phiRef) > M_PI ) phiRef -= 2*M_PI; // correct phi if outside range
60 
61 
62  // retrieve TrigEMCluster ElementLink from the TriggerElement
63  auto clusContainer = SG::makeHandle (m_TrigEMClusterContainerKey, ctx);
64 
65 
66  //JTB Should only be 1 cluster in each RoI
67 
68  const xAOD::TrigEMCluster *elink_cluster=(*clusContainer->begin());
70 
71 
72  // retrieve the TrigEMCluster from the ElementLink
73  const xAOD::TrigEMCluster* pClus = elink_cluster;
74 
75  if(pClus == 0){
76  ATH_MSG_ERROR("Failed to retieve TrigEMCluster from the ElementLink");
77  return StatusCode::SUCCESS; //HLT::MISSING_FEATURE;
78  }
79 
80  float dEta = pClus->eta() - etaRef;
81  // Deal with angle diferences greater than Pi
82  float dPhi = fabs(pClus->phi() - phiRef);
83  dPhi = (dPhi < M_PI ? dPhi : 2*M_PI - dPhi );
84  ATH_MSG_DEBUG("TrigPhoton will be built with: dEta=" << dEta
85  << " and dPhi= " << dPhi);
86 
87  // create TrigPhoton from TrigEMCluster
88  xAOD::TrigPhoton* p_trigPhoton = new xAOD::TrigPhoton();
89  // push TrigPhoton into TrigPhotonContainer
90  trigPhotoColl->push_back(p_trigPhoton);
91  p_trigPhoton->init( roiDescriptor->roiId(), dPhi, dEta, EClus);
92 
93 
94  ATH_MSG_DEBUG("REGTEST: TrigPhotonContainer has " << trigPhotoColl->size()<< " element");
95  if (!trigPhotoColl->empty()) {
96  xAOD::TrigPhoton* p_tp = trigPhotoColl->front();
97  ATH_MSG_DEBUG("REGTEST: TrigPhoton: RoI=" << p_tp->roiWord()
98  << "; eta=" << p_tp->eta()
99  << "; phi=" << p_tp->phi()
100  << "; Et=" << p_tp->emCluster()->et()
101  << "; Had Et=" << p_tp->etHad()
102  << "; EnergyRatio=" << p_tp->eratio()
103  << "; rCore=" << p_tp->rcore());
104  }
105  return StatusCode::SUCCESS;
106 
107 }
TrigEgammaFastPhotonReAlgo::m_TrigEMClusterContainerKey
SG::ReadHandleKey< xAOD::TrigEMClusterContainer > m_TrigEMClusterContainerKey
Definition: TrigEgammaFastPhotonReAlgo.h:41
xAOD::TrigEMCluster_v1::eta
float eta() const
get Eta (calibrated)
xAOD::TrigPhoton_v1::init
void init(uint32_t roi, float dphi, float deta, const EMClusterLink_t &clLink)
Initialisation function, setting most properties of the object.
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
xAOD::TrigPhoton_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: TrigPhoton_v1.h:52
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::TrigPhoton_v1::roiWord
uint32_t roiWord() const
Get the RoI word that seeded the reconstruction of this object.
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::TrigPhoton_v1::eratio
float eratio() const
Documentation to be added.
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
TrigEgammaFastPhotonReAlgo::TrigEgammaFastPhotonReAlgo
TrigEgammaFastPhotonReAlgo(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigEgammaFastPhotonReAlgo.cxx:18
xAOD::TrigPhoton_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: TrigPhoton_v1.h:50
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TrigEgammaFastPhotonReAlgo::m_roiCollectionKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
Definition: TrigEgammaFastPhotonReAlgo.h:36
xAOD::TrigEMCluster_v1::phi
float phi() const
get Phi (calibrated)
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigEMClusterAuxContainer.h
xAOD::TrigPhoton
TrigPhoton_v1 TrigPhoton
Declare the latest version of TrigPhoton.
Definition: Event/xAOD/xAODTrigEgamma/xAODTrigEgamma/TrigPhoton.h:16
TrigEgammaFastPhotonReAlgo::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: TrigEgammaFastPhotonReAlgo.cxx:34
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:538
xAOD::roiId
setTeId setLumiBlock roiId
Definition: L2StandAloneMuon_v1.cxx:331
TrigEgammaFastPhotonReAlgo::m_outputPhotonsKey
SG::WriteHandleKey< xAOD::TrigPhotonContainer > m_outputPhotonsKey
Definition: TrigEgammaFastPhotonReAlgo.h:46
TrigPhotonContainer.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
xAOD::TrigPhoton_v1
Class describing a photon reconstructed in the HLT.
Definition: TrigPhoton_v1.h:38
TrigEgammaFastPhotonReAlgo::initialize
virtual StatusCode initialize() override
Definition: TrigEgammaFastPhotonReAlgo.cxx:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::TrigPhoton_v1::etHad
float etHad() const
Documentation to be added.
TrigRoiDescriptor::roiId
virtual unsigned int roiId() const override final
these quantities probably don't need to be used any more
Definition: TrigRoiDescriptor.h:133
TrigEMClusterContainer.h
RoiDescriptor::phi
virtual double phi() const override final
Methods to retrieve data members.
Definition: RoiDescriptor.h:100
xAOD::TrigPhoton_v1::rcore
float rcore() const
Documentation to be added.
RoiDescriptor::eta
virtual double eta() const override final
Definition: RoiDescriptor.h:101
xAOD::TrigEMCluster_v1::et
float et() const
get Et (calibrated)
xAOD::TrigPhoton_v1::emCluster
const TrigEMCluster * emCluster() const
The associated EM cluster, as a simple pointer.
Definition: TrigPhoton_v1.cxx:133
TrigEgammaFastPhotonReAlgo.h
xAOD::TrigEMCluster_v1
Description of a trigger EM cluster.
Definition: TrigEMCluster_v1.h:28
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:527