ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterLogPos.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#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 m_offset(4.7)
19{
20 declareProperty ("LogPosOffset",m_offset) ;
21}
22
23
25
26 ATH_MSG_DEBUG("Initializing " << name() << endmsg ) ;
27
28 return StatusCode::SUCCESS;
29}
30
31StatusCode CaloClusterLogPos::execute(const EventContext& /*ctx*/,
32 xAOD::CaloCluster* theCluster) const
33{
34
35 if ( msgSvc()->outputLevel(name()) <= MSG::DEBUG ) {
36
37 msg(MSG::DEBUG) << " old cluster eta = " << theCluster->eta()
38 << " phi = " << theCluster->phi() << endmsg;
39
40 // std::vector<double> theEtas;
41 // std::vector<double> thePhis;
42 // theCluster->getEtaInSamples(theEtas);
43 // theCluster->getPhiInSamples(thePhis);
44 // for(int i=0;i<CaloCell_ID::Unknown;i++) {
45 // report << MSG::DEBUG << " old sampling " << i << " eta = " << theEtas[i]
46 // << " phi = " << thePhis[i] << endmsg;
47 //}
48 }
49
50 const double absEClus = fabs(theCluster->e());
51
52 if ( absEClus > 0 ) {
53 const double inv_absEClus = 1. / absEClus;
54 std::vector<double> weightSample(CaloCell_ID::Unknown,0);
55 std::vector<double> etaSample(CaloCell_ID::Unknown,0);
56 std::vector<double> phiSample(CaloCell_ID::Unknown,0);
57
58 double weightAll(0),etaAll(0),phiAll(0);
59
60 xAOD::CaloCluster::cell_iterator itrCell = theCluster->cell_begin();
61 xAOD::CaloCluster::cell_iterator itrCellEnd = theCluster->cell_end();
62 for (;itrCell!=itrCellEnd; ++itrCell) {
63 const CaloCell* thisCell = *itrCell;
64 double weight = itrCell.weight();//theCluster->getCellWeight(itrCell);
65 // Identifier myId = thisCell->ID();
66 int theSample = thisCell->caloDDE()->getSampling();
67 double absE = fabs(weight*thisCell->e());
68
69 if ( absE > 0 ) {
70 double lw = m_offset + log(absE*inv_absEClus);
71 if ( lw > 0 ) {
72
73 ATH_MSG_VERBOSE(" add cell with eta "
74 << thisCell->eta() << " phi " << thisCell->phi()
75 << " energy " << thisCell->e() << " weight " << weight
76 << " sampling " << theSample << " cluster e "
77 << theCluster->e() << " log weight " << lw);
78
79
80 etaAll += thisCell->eta()*lw;
81
82 // first cell decides the sign in order to avoid
83 // overlap problem at phi = -pi == +pi
84 // need to be normalized to the range [-pi,+pi] in the end
85
86 if ( weightAll > 0
87 && phiAll/weightAll < CaloPhiRange::phi_min() + 90*deg
88 && thisCell->phi() > CaloPhiRange::phi_max() - 90*deg)
89 phiAll += (thisCell->phi()-360*deg)*lw;
90 else if ( weightAll > 0
91 && phiAll/weightAll > CaloPhiRange::phi_max() - 90*deg
92 && thisCell->phi() < CaloPhiRange::phi_min() + 90*deg)
93 phiAll += (thisCell->phi()+360*deg)*lw;
94 else
95 phiAll += thisCell->phi()*lw;
96
97 weightAll += lw;
98
99 etaSample[theSample] += thisCell->eta()*lw;
100 if ( weightSample[theSample] > 0
101 && phiSample[theSample]/weightSample[theSample]
103 && thisCell->phi() > CaloPhiRange::phi_max() - 90*deg)
104 phiSample[theSample] += (thisCell->phi()-360*deg)*lw;
105 else if ( weightSample[theSample] > 0
106 && phiSample[theSample]/weightSample[theSample]
108 && thisCell->phi() < CaloPhiRange::phi_min() + 90*deg)
109 phiSample[theSample] += (thisCell->phi()+360*deg)*lw;
110 else
111 phiSample[theSample] += thisCell->phi()*lw;
112 weightSample[theSample] += lw;
113
114 }
115 }
116 }
117
118 if ( weightAll > 0 ) {
119 const double inv_weightAll = 1. / weightAll;
120 theCluster->setEta(etaAll * inv_weightAll);
121 theCluster->setPhi(CaloPhiRange::fix(phiAll * inv_weightAll));
122 }
123
124 // std::vector<double> theEtas(CaloCell_ID::Unknown,0);
125 // std::vector<double> thePhis(CaloCell_ID::Unknown,0);
126 // for (int i=0;i<CaloCell_ID::Unknown;i++) {
127 // if (theCluster->hasSampling(i)) {
128 // theEtas[i]=theCluster->etaSampl(i);
129 // thePhis[i]=theCluster->phiSampl(i);
130 // }
131
132 for(int i=0;i<CaloCell_ID::Unknown;i++) {
134 if ( theCluster->hasSampling(s) && weightSample[i] > 0 ) {
135 float etaSample=theCluster->etaSample(s);
136 float phiSample=theCluster->phiSample(s);
137 etaSample /= weightSample[i];
138 phiSample /= weightSample[i];
139 phiSample = CaloPhiRange::fix(phiSample);
140 theCluster->setEta(s,etaSample);
141 theCluster->setPhi(s,phiSample);
142 }
143 }//end loop over samples
144 }
145
146 if ( msgSvc()->outputLevel(name()) <= MSG::DEBUG ) {
147
148 ATH_MSG_DEBUG(" new cluster eta = " << theCluster->eta()
149 << " phi = " << theCluster->phi());
150
151 // std::vector<double> theEtas;
152 // std::vector<double> thePhis;
153
154 // theCluster->getEtaInSamples(theEtas);
155 // theCluster->getPhiInSamples(thePhis);
156 // for(int i=0;i<CaloCell_ID::Unknown;i++) {
157 // msg(MSG::DEBUG) << " new sampling " << i << " eta = " << theEtas[i]
158 // << " phi = " << thePhis[i] << endmsg;
159 // }
160 }
161
162 return StatusCode::SUCCESS;
163}
164
165
166
#define endmsg
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
CaloPhiRange class declaration.
#define deg
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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
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