ATLAS Offline Software
ERatio.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "ERatio.h"
6 
7 #include "GaudiKernel/StatusCode.h"
8 #include <sstream>
9 #include <limits>
10 
11 namespace GlobalSim {
12  ERatio::ERatio(const std::string & name,
13  double minDeltaE,
14  double maxERCut) :
15  m_name{name}, m_minDeltaE{minDeltaE}, m_maxERCut{maxERCut} {
16  }
17 
20 
21  result = false;
22 
23  std::size_t maxCellInd = nbhd.maxCellIndex();
24  auto p_peakE = nbhd.phi_center().at(maxCellInd).m_e;
25 
26  for (const auto& ps : {nbhd.phi_center(),
27  nbhd.phi_low(),
28  nbhd.phi_high()}) {
29 
30  double s_peakE = secondaryPeakEnergy_forw(ps, maxCellInd);
31 
32  result = eratioCut(p_peakE, s_peakE);
33  if (result) {break;}
34 
35  s_peakE = secondaryPeakEnergy_back(ps, maxCellInd);
36 
37  result = eratioCut(p_peakE, s_peakE);
38 
39  if (result) {break;}
40  }
41 
42  return StatusCode::SUCCESS;
43  }
44 
45 
47  std::size_t maxCellInd) {
48 
49  /*
50  * Look for a secondary peak in the direction of increasing eta
51  * starting at the eta location of the maximum energy strip.
52  */
53 
54  constexpr double maxStripE{std::numeric_limits<double>::max()};
55  double peakE{0.};
56 
57  // eratio needs at least three elements
58  auto sz = phi_str.size();
59  if (sz < 3 or maxCellInd > sz) {return peakE;}
60 
61  bool valley =
62  phi_str.at(maxCellInd+1).m_e < maxStripE - m_minDeltaE;
63 
64  for(auto iter = std::begin(phi_str)+maxCellInd+2;
65  iter != std::end(phi_str);
66  ++iter){
67 
68  if(!valley) {
69  valley = iter->m_e < ((iter-1)->m_e) - m_minDeltaE;
70  }
71 
72  if(valley) {
73  auto c_cellE = iter->m_e;
74  auto p_cellE = (iter-1)->m_e;
75  if(c_cellE > p_cellE + m_minDeltaE) {
76  peakE = std::max(peakE, c_cellE);
77  }
78  }
79 
80  }
81  return peakE;
82  }
83 
84 
86  std::size_t maxCellInd) {
87 
88 
89  /*
90  * Look for a secondary peak in the direction of decreasing eta
91  * starting at the eta location of the maximum energy strip.
92  */
93 
94 
95  constexpr double maxStripE{std::numeric_limits<double>::max()};
96  double peakE{0.};
97 
98  // eratio needs at least three elements
99  auto sz = maxCellInd;
100  if (sz < 2) {return peakE;}
101 
102  bool valley =
103  phi_str.at(maxCellInd-1).m_e < maxStripE - m_minDeltaE;
104 
105 
106  // calculate offset to point to 2 less than phi_str[maxCellInd]
107  std::size_t start = phi_str.size() - maxCellInd + 1;
108  for(auto iter = std::rbegin(phi_str)+start;
109  iter != std::rend(phi_str);
110  ++iter){
111 
112  if(!valley) {
113  valley = iter->m_e < ((iter-1)->m_e) - m_minDeltaE;
114  continue;
115  }
116 
117  auto c_cellE = iter->m_e;
118  auto p_cellE = (iter-1)->m_e;
119  if(c_cellE > p_cellE + m_minDeltaE) {
120  peakE = std::max(peakE, c_cellE);
121  }
122 
123  }
124  return peakE;
125  }
126 
127 
128  bool ERatio::eratioCut(double p_peakE, double s_peakE) {
129 
130  if (p_peakE <= 0 or s_peakE <= 0) {return false;}
131 
132  return std::max(p_peakE, s_peakE)/std::min(p_peakE, s_peakE) < m_maxERCut;
133 
134  }
135 
136  std::string ERatio::toString() const{
137  std::stringstream ss;
138  ss << "ERatio. "
139  << " name: " << m_name
140  << " minimum strip E difference to be significant " << m_minDeltaE
141  << " upper ERatio limit for pi0 candidate " << m_maxERCut
142  << '\n';
143 
144  return ss.str();
145  }
146 }
147 
148 std::ostream& operator<< (std::ostream& os, const GlobalSim::ERatio& er) {
149  os << er.toString();
150  return os;
151 }
152 
153 
GlobalSim::ERatio::toString
std::string toString() const
Definition: ERatio.cxx:136
fitman.sz
sz
Definition: fitman.py:527
get_generator_info.result
result
Definition: get_generator_info.py:21
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
GlobalSim::LArStripNeighborhood::phi_center
const StripDataVector & phi_center() const
Definition: LArStripNeighborhood.h:40
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
GlobalSim::ERatio::m_maxERCut
double m_maxERCut
Definition: ERatio.h:43
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
GlobalSim::ERatio::secondaryPeakEnergy_back
double secondaryPeakEnergy_back(const StripDataVector &, std::size_t)
Definition: ERatio.cxx:85
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
GlobalSim
AlgTool to obtain a selection of eFex RoIs read in from the event store.
Definition: dump.h:8
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
GlobalSim::LArStripNeighborhood::maxCellIndex
std::size_t maxCellIndex() const
Definition: LArStripNeighborhood.h:43
ERatio.h
operator<<
std::ostream & operator<<(std::ostream &os, const GlobalSim::ERatio &er)
Definition: ERatio.cxx:148
GlobalSim::ERatio::secondaryPeakEnergy_forw
double secondaryPeakEnergy_forw(const StripDataVector &, std::size_t)
Definition: ERatio.cxx:46
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
GlobalSim::LArStripNeighborhood::phi_low
const StripDataVector & phi_low() const
Definition: LArStripNeighborhood.h:39
GlobalSim::ERatio::run
StatusCode run(const LArStripNeighborhood &in, bool &result)
Definition: ERatio.cxx:19
GlobalSim::ERatio::ERatio
ERatio(const std::string &name, double thresh=50., double maxERCut=2.5)
Definition: ERatio.cxx:12
GlobalSim::ERatio
Definition: ERatio.h:25
GlobalSim::ERatio::m_name
std::string m_name
Definition: ERatio.h:41
GlobalSim::LArStripNeighborhood::phi_high
const StripDataVector & phi_high() const
Definition: LArStripNeighborhood.h:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
GlobalSim::ERatio::m_minDeltaE
double m_minDeltaE
Definition: ERatio.h:42
GlobalSim::LArStripNeighborhood
Definition: LArStripNeighborhood.h:28
GlobalSim::StripDataVector
std::vector< StripData > StripDataVector
Definition: LArStripNeighborhood.h:24
GlobalSim::ERatio::eratioCut
bool eratioCut(double p_peakE, double s_peakE)
Definition: ERatio.cxx:128