ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11
13 const std::string& name,
14 const IInterface* parent) :
15 AthAlgTool(type, name, parent)
16{
17 declareInterface<ICaloAffectedTool>(this);
18}
19
20//-----------------------------------------------------------------
21
23
24
25//-------------------------------------------------------------------
26
28 return StatusCode::SUCCESS;
29}
30
31//---------------------------------------------------------
32
33
34bool 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
86bool 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}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::vector< CaloAffectedRegionInfo > CaloAffectedRegionInfoVec
CaloPhiRange class declaration.
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
float get_eta_max() const
get eta max of region
float get_phi_min() const
get phi min of region
int get_layer_max() const
get layer max of region
float get_eta_min() const
get eta min of region
int get_problem() const
get problem type
int get_layer_min() const
get layer min of region
float get_phi_max() const
get phi max of region
virtual StatusCode initialize() override
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
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
CaloAffectedTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual ~CaloAffectedTool()
static double fix(double phi)
Class providing the definition of the 4-vector interface.