ATLAS Offline Software
Loading...
Searching...
No Matches
EFexEMEnergyWeightedClusterTool.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
9
11
12LVL1::EFexEMEnergyWeightedClusterTool::EFexEMEnergyWeightedClusterTool(const std::string& type, const std::string& name, const IInterface* parent)
13 : AthAlgTool(type, name, parent)
14{}
15
16
17void
18LVL1::EFexEMEnergyWeightedClusterTool::findCellsAbove(const CaloConstCellContainer* scells, const float& Thr, std::vector<const CaloCell*>& out) const
19{
20 out.clear();
21 for(auto scell : *scells) {
22 if ( scell->et() < Thr ) continue;
23 out.push_back(scell);
24 }
25}
26
27
28void
29LVL1::EFexEMEnergyWeightedClusterTool::findCellsAbove_EMB2_EMEC2(const CaloConstCellContainer* scells, const float& Thr, std::vector<const CaloCell*>& out) const
30{
31 out.clear();
32 for(auto scell : *scells) {
33 if ( scell->et() < Thr ) continue;
34 if ( scell->caloDDE()->getSampling()==2 || scell->caloDDE()->getSampling()==6 ) {
35 out.push_back(scell);
36 }
37 }
38}
39
40
41void
42LVL1::EFexEMEnergyWeightedClusterTool::findCellsAround(const CaloConstCellContainer* scells, const CaloCell* cell, std::vector<const CaloCell*>& out,
43 const float detaSize, const float dphiSize) const
44{
45 out.clear();
46 if ( !cell ) return;
47 float etacell = cell->eta();
48 float phicell = cell->phi();
49 for(auto scell : *scells) {
50 if ( std::abs( scell->eta() - etacell) > detaSize ) continue;
51 float dphi = std::abs( scell->phi() - phicell);
52 dphi = std::abs( M_PI - dphi );
53 dphi = std::abs( M_PI - dphi );
54 if ( std::abs( dphi ) > dphiSize ) continue;
55 out.push_back(scell);
56 }
57}
58
59
60void
61LVL1::EFexEMEnergyWeightedClusterTool::findCellsAround(const CaloConstCellContainer* scells, const float etacell, const float phicell,
62 std::vector<const CaloCell*>& out, const float detaSize, const float dphiSize) const
63{
64 out.clear();
65 for(auto scell : *scells) {
66 if ( std::abs( scell->eta() - etacell) > detaSize ) continue;
67 float dphi = std::abs( scell->phi() - phicell);
68 dphi = std::abs( M_PI - dphi );
69 dphi = std::abs( M_PI - dphi );
70 if ( std::abs( dphi ) > dphiSize ) continue;
71 out.push_back(scell);
72 }
73}
74
75
76void
77LVL1::EFexEMEnergyWeightedClusterTool::findTTsAround(const xAOD::TriggerTowerContainer* scells, const float etacell, const float phicell,
78 std::vector<const xAOD::TriggerTower*>& out) const
79{
80 out.clear();
81 for(auto scell : *scells) {
82 if ( std::abs( scell->eta() - etacell) > m_detaTT ) continue;
83 float dphi = std::abs( scell->phi() - phicell);
84 dphi = std::abs( M_PI - dphi );
85 dphi = std::abs( M_PI - dphi );
86 if ( std::abs( dphi ) > m_dphiTT ) continue;
87 out.push_back(scell);
88 }
89}
90
91
92bool
93LVL1::EFexEMEnergyWeightedClusterTool::isCellEmMaximum(const std::vector<const CaloCell*>& scells, const CaloCell* cell) const
94{
95 if ( !cell ) return false;
96 int samp = cell->caloDDE()->getSampling();
97 if ( (samp >= 8) && (samp!=21) ) return false; // include FCAL0 EM
98 float cellpt = 1.0001*cell->et(); //make sure you don't get thecell itself
99 for(auto scell : scells){
100 int samp1 = scell->caloDDE()->getSampling();
101 if ( ( samp1 >= 8 ) && (samp1!=21) ) continue;
102 if ( scell->ID() == cell->ID() ) continue;
103 if ( scell->et() > cellpt ) return false;
104 }
105 return true;
106}
107
108
109float
110LVL1::EFexEMEnergyWeightedClusterTool::sumEmCells(const std::vector<const CaloCell*>& scells) const
111{
112 float totalSum = 0.0;
113 for(auto scell : scells) {
114 int samp1 = scell->caloDDE()->getSampling();
115 if ( (samp1<8) || (samp1==21) ) totalSum+= scell->energy();
116 }
117 return totalSum;
118}
119
120
121float
122LVL1::EFexEMEnergyWeightedClusterTool::sumEmCells2nd(const std::vector<const CaloCell*>& scells) const
123{
124 float totalSum = 0.0;
125 for(auto scell : scells) {
126 if ( (scell->caloDDE()->getSampling()==2) ||(scell->caloDDE()->getSampling()==6) ) {
127 totalSum+= scell->energy();
128 }
129 }
130 return totalSum;
131}
132
133
134float
135LVL1::EFexEMEnergyWeightedClusterTool::sumHadCells(const std::vector<const CaloCell*>& scells) const
136{
137 float totalSum = 0.0;
138 for(auto scell : scells){
139 if ( (scell->caloDDE()->getSampling() <8) || ( scell->caloDDE()->getSampling()>=22) ) continue;
140 //totalSum+= (scell->et())*TMath::CosH(scell->eta());
141 totalSum+= (scell->energy());
142 }
143 return totalSum;
144}
145
146
147float
148LVL1::EFexEMEnergyWeightedClusterTool::sumHadTTs(const std::vector<const xAOD::TriggerTower*>& scells) const
149{
150 float totalSum = 0.0;
151 for(auto scell : scells){
152 if ( std::abs( scell->eta() ) > 1.5 ) continue;
153 if ( scell->sampling() == 0 ) continue;
154 totalSum+= (scell->pt())*TMath::CosH(scell->eta());
155 }
156 return totalSum * 1e3; // express in MeV
157}
158
159
160void
161LVL1::EFexEMEnergyWeightedClusterTool::findCluster(const std::vector<const CaloCell*>& scells, float &etaCluster, float &phiCluster) const
162{
163 etaCluster=0.0;
164 phiCluster=0.0;
165 double etaClusterD=0.0;
166 double phiClusterD=0.0;
167 double energyCluster=0.0;
168 bool cross_phi_bound=false;
169 int last_sign=0;
170 for(auto scell : scells){
171 if ( std::abs( scell->phi() ) < 2.7 ) continue;
172 int layer = scell->caloDDE()->getSampling();
173 if ( ( layer != 2 ) && ( layer != 6 ) ) continue;
174 int cell_sign = ( scell->phi() >=0 ? 1 : -1 );
175 if ( ( last_sign!=0 ) && ( last_sign != cell_sign ) ) cross_phi_bound = true;
176 last_sign = cell_sign;
177 }
178 for(auto scell : scells){
179 int layer = scell->caloDDE()->getSampling();
180 if ( ( layer != 2 ) && ( layer != 6 ) ) continue;
181 double scelleta = scell->eta();
182 double scellphi = scell->phi();
183 double scellet = scell->et();
184 etaClusterD+= (scellet * scelleta);
185 if (cross_phi_bound && scellphi < 0 ) scellphi += 2 * M_PI;
186 phiClusterD+= (scellet * scellphi);
187 energyCluster+= (scellet) ;
188 }
189 if ( energyCluster > 0.1 ) {
190 etaClusterD/=energyCluster;
191 phiClusterD/=energyCluster;
192 etaCluster = (float)etaClusterD;
193 phiCluster = (float)phiClusterD;
194 if ( phiCluster > M_PI ) phiCluster-=2*M_PI;
195 } else {
196 etaCluster=-999.0;
197 phiCluster=-999.0;
198 }
199}
#define M_PI
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
CaloCellContainer that can accept const cell pointers.
bool isCellEmMaximum(const std::vector< const CaloCell * > &scells, const CaloCell *cell) const
checks if a give (seed) cell is the highest in a vector of cells.
float sumEmCells(const std::vector< const CaloCell * > &scells) const
sum all cells from the vector that are in the EM calorimeter part
float sumHadTTs(const std::vector< const xAOD::TriggerTower * > &scells) const
sum all TTs from the vector that are in the HAD calorimeter part, but only for |eta|<1....
void findCellsAround(const CaloConstCellContainer *, const CaloCell *cell, std::vector< const CaloCell * > &out, const float deta, const float dphi) const
void findCluster(const std::vector< const CaloCell * > &scells, float &etaCluster, float &phiCluster) const
detect central cluster position
void findCellsAbove(const CaloConstCellContainer *, const float &thr, std::vector< const CaloCell * > &out) const
const float m_dphiTT
dphi for the cluster to TT definition
float sumEmCells2nd(const std::vector< const CaloCell * > &scells) const
sum all cells from the vector that are in the EM calorimeter part (only 2nd layer)
float sumHadCells(const std::vector< const CaloCell * > &scells) const
sum all cells from the vector that are in the HAD calorimeter part
EFexEMEnergyWeightedClusterTool(const std::string &type, const std::string &name, const IInterface *parent)
Name : EFexEMEnergyWeightedClusterTool.cxx PACKAGE : Trigger/TrigT1/TrigT1CaloFexPerf AUTHOR : Denis ...
void findCellsAbove_EMB2_EMEC2(const CaloConstCellContainer *, const float &thr, std::vector< const CaloCell * > &out) const
void findTTsAround(const xAOD::TriggerTowerContainer *, const float eta, const float phi, std::vector< const xAOD::TriggerTower * > &out) const
finds TTs around a seed cell.
TriggerTowerContainer_v2 TriggerTowerContainer
Define the latest version of the TriggerTower container.