ATLAS Offline Software
Loading...
Searching...
No Matches
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
15class ISvcLocator;
16
17
18TrigEgammaFastPhotonReAlgo::TrigEgammaFastPhotonReAlgo(const std::string & name, ISvcLocator* pSvcLocator)
19 : AthReentrantAlgorithm(name, pSvcLocator)
20{
21}
22
23
25{
26
27 ATH_CHECK( m_roiCollectionKey.initialize() );
29 ATH_CHECK( m_outputPhotonsKey.initialize() );
30 return StatusCode::SUCCESS;
31}
32
33
34StatusCode 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}
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
virtual double phi() const override final
Methods to retrieve data members.
virtual double eta() const override final
SG::ReadHandleKey< xAOD::TrigEMClusterContainer > m_TrigEMClusterContainerKey
TrigEgammaFastPhotonReAlgo(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
SG::WriteHandleKey< xAOD::TrigPhotonContainer > m_outputPhotonsKey
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode initialize() override
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
virtual unsigned int roiId() const override final
these quantities probably don't need to be used any more
float et() const
get Et (calibrated)
float eta() const
get Eta (calibrated)
float phi() const
get Phi (calibrated)
const TrigEMCluster * emCluster() const
The associated EM cluster, as a simple pointer.
virtual double eta() const
The pseudorapidity ( ) of the particle.
uint32_t roiWord() const
Get the RoI word that seeded the reconstruction of this object.
float etHad() const
Documentation to be added.
void init(uint32_t roi, float dphi, float deta, const EMClusterLink_t &clLink)
Initialisation function, setting most properties of the object.
float rcore() const
Documentation to be added.
float eratio() const
Documentation to be added.
virtual double phi() const
The azimuthal angle ( ) of the particle.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
TrigPhoton_v1 TrigPhoton
Declare the latest version of TrigPhoton.
TrigEMCluster_v1 TrigEMCluster
Define the latest version of the trigger EM cluster class.
setTeId setLumiBlock roiId