ATLAS Offline Software
Loading...
Searching...
No Matches
TrigTauCaloRoiUpdater.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "GaudiKernel/MsgStream.h"
8#include "GaudiKernel/IToolSvc.h"
9#include "GaudiKernel/StatusCode.h"
10
12#include "CxxUtils/phihelper.h"
13
14#include "TLorentzVector.h"
15
16
17TrigTauCaloRoiUpdater::TrigTauCaloRoiUpdater(const std::string & name, ISvcLocator* pSvcLocator)
18 : AthReentrantAlgorithm(name, pSvcLocator)
19{
20
21}
22
23
25{
26 ATH_MSG_DEBUG("Initializing " << name());
27 ATH_MSG_DEBUG("dRForCenter: " << m_dRForCenter);
28
29 ATH_MSG_DEBUG("Initialising HandleKeys");
30 ATH_CHECK(m_roIInputKey.initialize());
31 ATH_CHECK(m_clustersKey.initialize());
32 ATH_CHECK(m_roIOutputKey.initialize());
33
34 return StatusCode::SUCCESS;
35}
36
37
38StatusCode TrigTauCaloRoiUpdater::execute(const EventContext& ctx) const
39{
40 ATH_MSG_DEBUG("Running " << name());
41
42 //---------------------------------------------------------------
43 // Prepare I/O
44 //---------------------------------------------------------------
45
46 // Prepare output RoI container
47 std::unique_ptr<TrigRoiDescriptorCollection> roiCollection = std::make_unique<TrigRoiDescriptorCollection>();
49 ATH_CHECK(outputRoIHandle.record(std::move(roiCollection)));
50
51
52 // Retrieve input RoI descriptor
54 ATH_MSG_DEBUG("Size of roisHandle: " << roisHandle->size());
55 const TrigRoiDescriptor* roiDescriptor = roisHandle->at(0); // We only have one RoI in the handle
56
57
58 // Fill local variables for RoI reference position
59 float eta = roiDescriptor->eta();
60 float phi = roiDescriptor->phi();
61
62 const float dEta = (roiDescriptor->etaPlus() - roiDescriptor->etaMinus()) / 2;
63 const float dPhi = CxxUtils::deltaPhi(roiDescriptor->phiPlus(), roiDescriptor->phiMinus()) / 2;
64
65 ATH_MSG_DEBUG("RoI ID: " << roiDescriptor->roiId() << ", eta: " << eta << ", phi: " << phi);
66
67
68
69 //---------------------------------------------------------------
70 // Find detector tau axis
71 //---------------------------------------------------------------
72
73 // Retrieve Input CaloClusterContainer
75 ATH_CHECK(CCContainerHandle.isValid());
76 const xAOD::CaloClusterContainer *RoICaloClusterContainer = CCContainerHandle.get();
77
78 if(!RoICaloClusterContainer) {
79 ATH_MSG_ERROR("No CaloCluster container found");
80 return StatusCode::FAILURE;
81 }
82
83 ATH_MSG_DEBUG("Size of vector CaloCluster container is: " << RoICaloClusterContainer->size());
84
85 // store all good roicaloccluster in a vector
86 std::vector<TLorentzVector> cls_vec;
87
88 // We first need to get the barycenter of the LCTopo jet, including all clusters
89 TLorentzVector tau_barycenter;
90 for(const xAOD::CaloCluster* cluster : *RoICaloClusterContainer) {
91 // Skip clusters with negative energy
92 if(cluster->e() < 0) continue;
93
94 tau_barycenter += cluster->p4();
95 cls_vec.push_back(cluster->p4());
96 }
97
98 // Determine the LCTopo jet pT at the detector axis
99 TLorentzVector tau_detector_axis;
100 for (const auto& clsP4 : cls_vec) {
101
102 // Skip clusters further than a maximum Delta R
103 if(tau_barycenter.DeltaR(clsP4) > m_dRForCenter) continue;
104
105 tau_detector_axis += clsP4;
106 }
107
108
109
110 //---------------------------------------------------------------
111 // Update the RoI
112 //---------------------------------------------------------------
113
114 // Only update the roi if tau_detector_axis.Pt() > 0, i.e. if the calo cluster sum makes sense
115 if(tau_detector_axis.Pt() > 0) {
116 eta = tau_detector_axis.Eta();
117 phi = tau_detector_axis.Phi();
118 }
119
120 // Create the new RoI
121 outputRoIHandle->push_back(std::make_unique<TrigRoiDescriptor>(
122 roiDescriptor->roiWord(), roiDescriptor->l1Id(), roiDescriptor->roiId(),
123 eta, eta-dEta, eta+dEta,
125 roiDescriptor->zed(), roiDescriptor->zedMinus(), roiDescriptor->zedPlus()
126 ));
127
128
129 ATH_MSG_DEBUG("Input RoI: " << *roiDescriptor);
130 ATH_MSG_DEBUG("Output RoI: " << *outputRoIHandle->back());
131
132 return StatusCode::SUCCESS;
133}
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.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual double etaMinus() const override final
gets eta at zMinus
virtual double etaPlus() const override final
gets eta at zedPlus
virtual double zed() const override final
virtual double phi() const override final
Methods to retrieve data members.
virtual double phiMinus() const override final
gets phiMinus
virtual double zedPlus() const override final
z at the most forward end of the RoI
virtual double zedMinus() const override final
z at the most backward end of the RoI
virtual double eta() const override final
virtual double phiPlus() const override final
gets phiPlus
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
virtual unsigned int roiWord() const override final
virtual unsigned int roiId() const override final
these quantities probably don't need to be used any more
virtual unsigned int l1Id() const override final
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode initialize() override
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roIInputKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_clustersKey
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roIOutputKey
TrigTauCaloRoiUpdater(const std::string &, ISvcLocator *)
Gaudi::Property< float > m_dRForCenter
constexpr T deltaPhi(T phiA, T phiB)
Return difference phiA - phiB in range [-pi, pi].
Definition phihelper.h:64
constexpr T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition phihelper.h:31
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Helper for azimuthal angle calculations.