ATLAS Offline Software
Loading...
Searching...
No Matches
EgammaReHadEnFex.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5// ********************************************************************
6//
7// NAME: EgammaReHadEnFex.cxx
8// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloEgamma
9//
10// AUTHOR: M.P. Casado
11//
12// REFERENCES: Based on Trigger/TrigT2CaloEgamma/T2EmHadAlgorithm.cxx
13//
14// ********************************************************************
15
16#include "EgammaReHadEnFex.h"
17#include "CaloGeoHelpers/CaloSampling.h"
19#include <math.h>
20
21EgammaReHadEnFex::EgammaReHadEnFex(const std::string& type, const std::string& name,
22 const IInterface* parent) :
23 IReAlgToolCalo(type, name, parent)
24{}
25
26StatusCode EgammaReHadEnFex::execute(xAOD::TrigEMCluster& rtrigEmCluster, const IRoiDescriptor& roi,
27 const CaloDetDescrElement*& /*caloDDE*/,
28 const EventContext& context) const
29{
30 double deta = 0.; // eta difference current cell - seed
31 double dphi = 0.; // phi difference current cell - seed
32
34
35 double energyEta = rtrigEmCluster.eta();
36 double energyPhi = rtrigEmCluster.phi();
37 rtrigEmCluster.setEhad1(0.);
38
39 // Dump eta-phi strip ranges into arrays
40 // Define variables here so that their scope covers both the Tile and HEC loops
41 // Use arrays of length 3 since there is no samp 0 in the HAD calorimeters
42 // this avoids wasting memory but makes the code slightly less clear
43
44 int ncells = 0;
45
46 for (unsigned int sampling = 0; sampling < 3; sampling++) {
47
49 ATH_CHECK( m_dataSvc->loadCollections(context, roi, TTHEC, sampling, sel) );
50
51 for (const LArCell* larcell : sel) {
52
53 ncells++;
54 double etaCell = larcell->eta();
55 double phiCell = larcell->phi();
56 double energyCell = larcell->energy();
57
58 // find position of current cell w.r.t. seed
59 deta = std::abs(etaCell - energyEta);
60 dphi = std::abs(phiCell - energyPhi);
61 if (dphi > M_PI) dphi = 2. * M_PI - dphi; // wrap (pi - 2pi)->(-pi - 0)
62 // hadronic measurements: energy sum in 0.1*0.1
63 if (deta <= 0.12 && dphi <= 0.12) {
64 // samp = CaloSampling::getSampling(*larcell);
65 samp = larcell->caloDDE()->getSampling();
66 rtrigEmCluster.setEnergy(samp, rtrigEmCluster.energy(samp) + energyCell);
67 rtrigEmCluster.setRawEnergy(samp, rtrigEmCluster.rawEnergy(samp) + energyCell);
68 if (CaloSampling::HEC0 == samp) {
69 rtrigEmCluster.setEhad1(rtrigEmCluster.ehad1() + energyCell);
70 }
71 }
72
73 } // end of loop over cells
74
75 } // End sampling loop
76
77 // Next TILECAL
78
79 std::vector<const TileCell*> seltile;
80 ATH_CHECK( m_dataSvc->loadCollections(context, roi, seltile) );
81
82 for (const TileCell* tilecell : seltile) { // loop over cells
83
84 ncells++;
85 double etaCell = tilecell->eta();
86 double phiCell = tilecell->phi();
87 double energyCell = tilecell->energy();
88
89 // find position of current cell w.r.t. seed
90 deta = std::abs(etaCell - energyEta);
91 dphi = std::abs(phiCell - energyPhi);
92 if (dphi > M_PI) dphi = 2. * M_PI - dphi; // wrap (pi - 2pi)->(-pi - 0)
93 // hadronic measurements: energy sum in 0.1*0.1
94 if (deta <= 0.12 && dphi <= 0.12) {
95 // samp = CaloSampling::getSampling(*tilecell);
96 samp = tilecell->caloDDE()->getSampling();
97 rtrigEmCluster.setEnergy(samp, rtrigEmCluster.energy(samp) + energyCell);
98 rtrigEmCluster.setRawEnergy(samp, rtrigEmCluster.rawEnergy(samp) + energyCell);
99 if ((CaloSampling::TileBar0 == samp) || (CaloSampling::TileExt0 == samp) ||
100 (CaloSampling::TileGap1 == samp) || (CaloSampling::TileGap2 == samp)) {
101 rtrigEmCluster.setEhad1(rtrigEmCluster.ehad1() + energyCell);
102 }
103 }
104
105 } // end of loop over cells
106
107 rtrigEmCluster.setNCells(ncells + rtrigEmCluster.nCells());
108
109 return StatusCode::SUCCESS;
110}
#define M_PI
#define ATH_CHECK
Evaluate an expression and check for errors.
@ TTHEC
Definition RegSelEnums.h:29
This class groups all DetDescr information related to a CaloCell.
virtual StatusCode execute(xAOD::TrigEMCluster &rtrigEmCluster, const IRoiDescriptor &roi, const CaloDetDescrElement *&caloDDE, const EventContext &context) const override
execute feature extraction for the EM Calorimeter second layer
EgammaReHadEnFex(const std::string &type, const std::string &name, const IInterface *parent)
IReAlgToolCalo(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
ServiceHandle< ITrigCaloDataAccessSvc > m_dataSvc
Describes the API of the Region of Ineterest geometry.
Data object for LAr calorimeter readout cell.
Definition LArCell.h:53
void setNCells(int)
set number of cells used from RoI
float rawEnergy() const
get Raw Energy (no calibration)
int nCells() const
get number of cells used from RoI
void setRawEnergy(float)
set Raw Energy (no calibration)
void setEhad1(float)
set hadronic Energy (first hadronic layer)
float eta() const
get Eta (calibrated)
void setEnergy(float energy)
set Energy (calibrated)
float phi() const
get Phi (calibrated)
float ehad1() const
get hadronic Energy (first hadronic layer)
float energy() const
get Energy (calibrated)
TrigEMCluster_v1 TrigEMCluster
Define the latest version of the trigger EM cluster class.