ATLAS Offline Software
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 
11 using CLHEP::deg;
12 
15  const std::string& name,
16  const IInterface* 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 
31 StatusCode 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]
102  < CaloPhiRange::phi_min() + 90*deg
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]
107  > CaloPhiRange::phi_max() - 90*deg
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 
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
xAOD::CaloCluster_v1::cell_begin
const_cell_iterator cell_begin() const
Iterator of the underlying CaloClusterCellLink (const version)
Definition: CaloCluster_v1.h:812
CaloClusterLogPos.h
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CaloCell::phi
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition: CaloCell.h:359
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
python.LumiCalcWorking.lw
lw
Definition: LumiCalcWorking.py:112
CaloClusterProcessor
Definition: CaloClusterProcessor.h:33
deg
#define deg
Definition: SbPolyhedron.cxx:17
CaloCell::e
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition: CaloCell.h:317
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CaloPhiRange::phi_min
static double phi_min()
Definition: CaloPhiRange.h:49
CaloCell_ID.h
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
CaloClusterLogPos::execute
StatusCode execute(const EventContext &ctx, xAOD::CaloCluster *theCluster) const override
Execute on a single cluster.
Definition: CaloClusterLogPos.cxx:31
xAOD::CaloCluster_v1::etaSample
float etaSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
Definition: CaloCluster_v1.cxx:532
CaloClusterLogPos::initialize
StatusCode initialize() override
Definition: CaloClusterLogPos.cxx:24
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloPhiRange::phi_max
static double phi_max()
Definition: CaloPhiRange.h:52
CaloClusterLogPos::CaloClusterLogPos
CaloClusterLogPos(const std::string &type, const std::string &name, const IInterface *parent)
Standard AlgTool constructor.
Definition: CaloClusterLogPos.cxx:14
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition: CaloCell.h:305
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CaloPhiRange.h
CaloPhiRange class declaration.
xAOD::CaloCluster_v1::phiSample
float phiSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
Definition: CaloCluster_v1.cxx:547
CaloPhiRange::fix
static double fix(double phi)
Definition: CaloPhiRange.cxx:14
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.TrigPSCPythonDbSetup.outputLevel
outputLevel
Definition: TrigPSCPythonDbSetup.py:30
CaloClusterLogPos::m_offset
double m_offset
Definition: CaloClusterLogPos.h:69
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
xAOD::CaloCluster_v1::cell_end
const_cell_iterator cell_end() const
Definition: CaloCluster_v1.h:813
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
xAOD::CaloCluster_v1::setPhi
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
Definition: CaloCluster_v1.cxx:556
xAOD::CaloCluster_v1::setEta
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
Definition: CaloCluster_v1.cxx:541
xAOD::CaloCluster_v1::hasSampling
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
Definition: CaloCluster_v1.h:890
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition: CaloCluster_v1.cxx:265
CaloCell::eta
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition: CaloCell.h:366