ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterLogPos.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CaloClusterLogPos.h"
8#include "GaudiKernel/MsgStream.h"
9#include <CLHEP/Units/SystemOfUnits.h>
10
11using CLHEP::deg;
12
15 const std::string& name,
16 const IInterface* parent)
17 : CaloClusterProcessor(type, name, parent)
18{
19}
20
21
23
24 ATH_MSG_DEBUG("Initializing " << name() << endmsg ) ;
25
26 return StatusCode::SUCCESS;
27}
28
29StatusCode CaloClusterLogPos::execute(const EventContext& /*ctx*/,
30 xAOD::CaloCluster* theCluster) const
31{
32
33 if ( msgSvc()->outputLevel(name()) <= MSG::DEBUG ) {
34
35 msg(MSG::DEBUG) << " old cluster eta = " << theCluster->eta()
36 << " phi = " << theCluster->phi() << endmsg;
37
38 // std::vector<double> theEtas;
39 // std::vector<double> thePhis;
40 // theCluster->getEtaInSamples(theEtas);
41 // theCluster->getPhiInSamples(thePhis);
42 // for(int i=0;i<CaloCell_ID::Unknown;i++) {
43 // report << MSG::DEBUG << " old sampling " << i << " eta = " << theEtas[i]
44 // << " phi = " << thePhis[i] << endmsg;
45 //}
46 }
47
48 const double absEClus = fabs(theCluster->e());
49
50 if ( absEClus > 0 ) {
51 const double inv_absEClus = 1. / absEClus;
52 std::vector<double> weightSample(CaloCell_ID::Unknown,0);
53 std::vector<double> etaSample(CaloCell_ID::Unknown,0);
54 std::vector<double> phiSample(CaloCell_ID::Unknown,0);
55
56 double weightAll(0),etaAll(0),phiAll(0);
57
58 xAOD::CaloCluster::cell_iterator itrCell = theCluster->cell_begin();
59 xAOD::CaloCluster::cell_iterator itrCellEnd = theCluster->cell_end();
60 for (;itrCell!=itrCellEnd; ++itrCell) {
61 const CaloCell* thisCell = *itrCell;
62 double weight = itrCell.weight();//theCluster->getCellWeight(itrCell);
63 // Identifier myId = thisCell->ID();
64 int theSample = thisCell->caloDDE()->getSampling();
65 double absE = fabs(weight*thisCell->e());
66
67 if ( absE > 0 ) {
68 double lw = m_offset + log(absE*inv_absEClus);
69 if ( lw > 0 ) {
70
71 ATH_MSG_VERBOSE(" add cell with eta "
72 << thisCell->eta() << " phi " << thisCell->phi()
73 << " energy " << thisCell->e() << " weight " << weight
74 << " sampling " << theSample << " cluster e "
75 << theCluster->e() << " log weight " << lw);
76
77
78 etaAll += thisCell->eta()*lw;
79
80 // first cell decides the sign in order to avoid
81 // overlap problem at phi = -pi == +pi
82 // need to be normalized to the range [-pi,+pi] in the end
83
84 if ( weightAll > 0
85 && phiAll/weightAll < CaloPhiRange::phi_min() + 90*deg
86 && thisCell->phi() > CaloPhiRange::phi_max() - 90*deg)
87 phiAll += (thisCell->phi()-360*deg)*lw;
88 else if ( weightAll > 0
89 && phiAll/weightAll > CaloPhiRange::phi_max() - 90*deg
90 && thisCell->phi() < CaloPhiRange::phi_min() + 90*deg)
91 phiAll += (thisCell->phi()+360*deg)*lw;
92 else
93 phiAll += thisCell->phi()*lw;
94
95 weightAll += lw;
96
97 etaSample[theSample] += thisCell->eta()*lw;
98 if ( weightSample[theSample] > 0
99 && phiSample[theSample]/weightSample[theSample]
101 && thisCell->phi() > CaloPhiRange::phi_max() - 90*deg)
102 phiSample[theSample] += (thisCell->phi()-360*deg)*lw;
103 else if ( weightSample[theSample] > 0
104 && phiSample[theSample]/weightSample[theSample]
106 && thisCell->phi() < CaloPhiRange::phi_min() + 90*deg)
107 phiSample[theSample] += (thisCell->phi()+360*deg)*lw;
108 else
109 phiSample[theSample] += thisCell->phi()*lw;
110 weightSample[theSample] += lw;
111
112 }
113 }
114 }
115
116 if ( weightAll > 0 ) {
117 const double inv_weightAll = 1. / weightAll;
118 theCluster->setEta(etaAll * inv_weightAll);
119 theCluster->setPhi(CaloPhiRange::fix(phiAll * inv_weightAll));
120 }
121
122 // std::vector<double> theEtas(CaloCell_ID::Unknown,0);
123 // std::vector<double> thePhis(CaloCell_ID::Unknown,0);
124 // for (int i=0;i<CaloCell_ID::Unknown;i++) {
125 // if (theCluster->hasSampling(i)) {
126 // theEtas[i]=theCluster->etaSampl(i);
127 // thePhis[i]=theCluster->phiSampl(i);
128 // }
129
130 for(int i=0;i<CaloCell_ID::Unknown;i++) {
132 if ( theCluster->hasSampling(s) && weightSample[i] > 0 ) {
133 float etaSample=theCluster->etaSample(s);
134 float phiSample=theCluster->phiSample(s);
135 etaSample /= weightSample[i];
136 phiSample /= weightSample[i];
137 phiSample = CaloPhiRange::fix(phiSample);
138 theCluster->setEta(s,etaSample);
139 theCluster->setPhi(s,phiSample);
140 }
141 }//end loop over samples
142 }
143
144 if ( msgSvc()->outputLevel(name()) <= MSG::DEBUG ) {
145
146 ATH_MSG_DEBUG(" new cluster eta = " << theCluster->eta()
147 << " phi = " << theCluster->phi());
148
149 // std::vector<double> theEtas;
150 // std::vector<double> thePhis;
151
152 // theCluster->getEtaInSamples(theEtas);
153 // theCluster->getPhiInSamples(thePhis);
154 // for(int i=0;i<CaloCell_ID::Unknown;i++) {
155 // msg(MSG::DEBUG) << " new sampling " << i << " eta = " << theEtas[i]
156 // << " phi = " << thePhis[i] << endmsg;
157 // }
158 }
159
160 return StatusCode::SUCCESS;
161}
162
163
164
#define endmsg
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
CaloPhiRange class declaration.
#define deg
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition CaloCell.h:375
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition CaloCell.h:382
CaloClusterLogPos(const std::string &type, const std::string &name, const IInterface *parent)
Standard AlgTool constructor.
StatusCode initialize() override
Gaudi::Property< double > m_offset
StatusCode execute(const EventContext &ctx, xAOD::CaloCluster *theCluster) const override
Execute on a single cluster.
CaloClusterProcessor(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
CaloCell_ID::CaloSample getSampling() const
cell sampling
static double phi_max()
static double fix(double phi)
static double phi_min()
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
float phiSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
virtual double eta() const
The pseudorapidity ( ) of the particle.
CaloClusterCellLink::iterator cell_iterator
Iterator of the underlying CaloClusterCellLink (non-const version)
virtual double e() const
The total energy of the particle.
const_cell_iterator cell_end() const
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
virtual double phi() const
The azimuthal angle ( ) of the particle.
const_cell_iterator cell_begin() const
Iterator of the underlying CaloClusterCellLink (const version)
float etaSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
MsgStream & msg
Definition testRead.cxx:32