ATLAS Offline Software
CaloAffectedTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "xAODBase/IParticle.h"
10 
11 
13  const std::string& name,
14  const IInterface* parent) :
16 {
17  declareInterface<ICaloAffectedTool>(this);
18 }
19 
20 //-----------------------------------------------------------------
21 
23 
24 
25 //-------------------------------------------------------------------
26 
28  return StatusCode::SUCCESS;
29 }
30 
31 //---------------------------------------------------------
32 
33 
34 bool CaloAffectedTool::isAffected(const xAOD::IParticle *p, const CaloAffectedRegionInfoVec *vAff, float deta, float dphi, int layer_min, int layer_max, int problemType) const
35 {
36 
37  if(!vAff) return false;
38 
39  static const float epsilon=1e-6;
40 
41  //std::cout << " in isAffected " << p->eta() << " " << p->phi() << std::endl;
42 
43  std::vector<CaloAffectedRegionInfo>::const_iterator reg1 = vAff->begin();
44  std::vector<CaloAffectedRegionInfo>::const_iterator reg2 = vAff->end();
45  for (;reg1 != reg2; ++reg1) {
46  const CaloAffectedRegionInfo* region = &(*reg1);
47 
48  int problem=region->get_problem();
49  //std::cout << " problem,problemType " << problem << " " << problemType << std::endl;
50  if (problemType>=0 && (problem != problemType)) continue;
51 
52  int layermin=region->get_layer_min();
53  int layermax=region->get_layer_max();
54  //std::cout << " layermin, layermax " << layermin << " " << layermax << std::endl;
55  if ((layer_max>=layer_min) && (layermax < layer_min || layermin > layer_max)) continue;
56 
57 
58  float etamin=region->get_eta_min();
59  float etamax=region->get_eta_max();
60  float eta = p->eta();
61  //std::cout << " eta region " << etamin << " " << etamax << std::endl;
62  if ((eta+deta)<etamin || (eta-deta)>etamax) continue;
63 
64  float phimin=region->get_phi_min();
65  float phimax=region->get_phi_max();
66  float phi = p->phi();
67  //std::cout << " phi region " << phimin << " " << phimax << std::endl;
68  float phi2 = CaloPhiRange::fix(phi+dphi+epsilon);
69  float phi1 = CaloPhiRange::fix(phi-dphi-epsilon);
70 
71  if ((phimax >= phimin) && (phi2 >= phi1) && (phi2<phimin || phi1>phimax)) continue;
72  if ((phimax >= phimin) && (phi2 <= phi1) && (phi1>phimax && phi2<phimin)) continue;
73  if ((phimax <= phimin) && (phi2 >= phi1) && (phi1>phimax && phi2<phimin)) continue;
74 
75  //std::cout << " in region " << std::endl;
76 
77  return true;
78 
79  }
80 
81  return false;
82 
83 }
84 //-------------------------------------------------
85 
86 bool CaloAffectedTool::listAffected(const xAOD::IParticle*p, const CaloAffectedRegionInfoVec *vAff, std::vector<int>& layer_list, std::vector<int>& problem_list, float deta, float dphi, int problemType) const
87 {
88 
89  if(!vAff) return false;
90 
91  bool found = false;
92 
93  static const float epsilon=1e-6;
94 
95  layer_list.clear();
96  problem_list.clear();
97 
98 
99  std::vector<CaloAffectedRegionInfo>::const_iterator reg1 = vAff->begin();
100  std::vector<CaloAffectedRegionInfo>::const_iterator reg2 = vAff->end();
101  for (;reg1 != reg2; ++reg1) {
102  const CaloAffectedRegionInfo* region = &(*reg1);
103 
104  int problem=region->get_problem();
105  if (problemType>=0 && (problem != problemType)) continue;
106 
107  int layermin=region->get_layer_min();
108  int layermax=region->get_layer_max();
109 
110  float etamin=region->get_eta_min();
111  float etamax=region->get_eta_max();
112  float eta = p->eta();
113  if ((eta+deta)<etamin || (eta-deta)>etamax) continue;
114 
115  float phimin=region->get_phi_min();
116  float phimax=region->get_phi_max();
117  float phi = p->phi();
118  float phi2 = CaloPhiRange::fix(phi+dphi+epsilon);
119  float phi1 = CaloPhiRange::fix(phi-dphi-epsilon);
120 
121  if ((phimax >= phimin) && (phi2 >= phi1) && (phi2<phimin || phi1>phimax)) continue;
122  if ((phimax >= phimin) && (phi2 <= phi1) && (phi1>phimax && phi2<phimin)) continue;
123  if ((phimax <= phimin) && (phi2 >= phi1) && (phi1>phimax && phi2<phimin)) continue;
124 
125  found = true;
126 
127  for (int ilayer=layermin;ilayer<=layermax;ilayer++) {
128  layer_list.push_back(ilayer);
129  problem_list.push_back(problem);
130  }
131 
132 
133  }
134 
135  return found;
136 
137 }
CaloAffectedRegionInfoVec.h
CaloAffectedTool::CaloAffectedTool
CaloAffectedTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CaloAffectedTool.cxx:12
CaloAffectedRegionInfoVec
std::vector< CaloAffectedRegionInfo > CaloAffectedRegionInfoVec
Definition: CaloAffectedRegionInfoVec.h:11
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CaloAffectedRegionInfo
Definition: CaloAffectedRegionInfo.h:16
IParticle.h
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
CaloAffectedRegionInfo::get_phi_min
float get_phi_min() const
get phi min of region
Definition: CaloAffectedRegionInfo.cxx:36
CaloAffectedTool::initialize
virtual StatusCode initialize() override
Definition: CaloAffectedTool.cxx:27
CaloAffectedRegionInfo::get_eta_max
float get_eta_max() const
get eta max of region
Definition: CaloAffectedRegionInfo.cxx:32
CaloAffectedTool.h
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
CaloAffectedRegionInfo::get_eta_min
float get_eta_min() const
get eta min of region
Definition: CaloAffectedRegionInfo.cxx:28
CaloAffectedRegionInfo::get_layer_max
int get_layer_max() const
get layer max of region
Definition: CaloAffectedRegionInfo.cxx:52
CaloAffectedRegionInfo::get_problem
int get_problem() const
get problem type
Definition: CaloAffectedRegionInfo.cxx:44
CaloAffectedTool::~CaloAffectedTool
virtual ~CaloAffectedTool()
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CaloAffectedTool::listAffected
virtual bool listAffected(const xAOD::IParticle *p, const CaloAffectedRegionInfoVec *vAff, std::vector< int > &layer_list, std::vector< int > &problem_list, float deta=0, float dphi=0, int problemType=-1) const override
Definition: CaloAffectedTool.cxx:86
CaloPhiRange.h
CaloPhiRange class declaration.
CaloAffectedRegionInfo::get_phi_max
float get_phi_max() const
get phi max of region
Definition: CaloAffectedRegionInfo.cxx:40
CaloPhiRange::fix
static double fix(double phi)
Definition: CaloPhiRange.cxx:14
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloAffectedTool::isAffected
virtual bool isAffected(const xAOD::IParticle *p, const CaloAffectedRegionInfoVec *vAff, float deta=0., float dphi=0., int layer_min=0, int layer_max=-1, int problemType=-1) const override
Definition: CaloAffectedTool.cxx:34
CaloAffectedRegionInfo::get_layer_min
int get_layer_min() const
get layer min of region
Definition: CaloAffectedRegionInfo.cxx:48
AthAlgTool
Definition: AthAlgTool.h:26
LArCellBinning.etamin
etamin
Definition: LArCellBinning.py:137