ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
GlobalSim::Egamma1BaselineAlgTool Class Reference

#include <Egamma1BaselineAlgTool.h>

Inheritance diagram for GlobalSim::Egamma1BaselineAlgTool:
Collaboration diagram for GlobalSim::Egamma1BaselineAlgTool:

Public Member Functions

 Egamma1BaselineAlgTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~Egamma1BaselineAlgTool ()=default
 
StatusCode initialize () override
 
virtual StatusCode run (const EventContext &ctx) const override
 
virtual std::string toString () const override
 

Private Member Functions

std::vector< double > combine_phi (const LArStripNeighborhood *) const
 
ap_int< 16 > secondPeakSearch (const std::vector< ap_int< 16 >> &input, const ap_int< 16 > peak, const int startCell, const int endCell, const ap_int< 16 > noiseMargin) const
 

Private Attributes

Gaudi::Property< bool > m_enableDump
 
SG::ReadHandleKey< LArStripNeighborhoodContainerm_nbhdContainerReadKey
 
SG::WriteHandleKey< std::vector< float > > m_eRatioKey
 
SG::WriteHandleKey< std::vector< float > > m_eRatioSimpleKey
 

Static Private Attributes

static constexpr int s_required_phi_len = 17
 
static constexpr int s_combination_len = 51
 

Detailed Description

Definition at line 25 of file Egamma1BaselineAlgTool.h.

Constructor & Destructor Documentation

◆ Egamma1BaselineAlgTool()

GlobalSim::Egamma1BaselineAlgTool::Egamma1BaselineAlgTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 13 of file Egamma1BaselineAlgTool.cxx.

15  :
16  base_class(type, name, parent){
17  }

◆ ~Egamma1BaselineAlgTool()

virtual GlobalSim::Egamma1BaselineAlgTool::~Egamma1BaselineAlgTool ( )
virtualdefault

Member Function Documentation

◆ combine_phi()

std::vector< double > GlobalSim::Egamma1BaselineAlgTool::combine_phi ( const LArStripNeighborhood nbhd) const
private

Definition at line 162 of file Egamma1BaselineAlgTool.cxx.

162  {
163  auto result = std::vector<double>();
164 
165  const auto& phi_low = nbhd->phi_low();
166  //if (phi_low.size() != s_required_phi_len) {return result;}
167 
168  const auto& phi_center = nbhd->phi_center();
169  //if (phi_center.size() != s_required_phi_len) {return result;}
170 
171  const auto& phi_high = nbhd->phi_high();
172  //if (phi_high.size() != s_required_phi_len) {return result;}
173 
174  result.reserve(s_combination_len);
175 
176  //Make a big vector as the VHDL does. Not strictly necessary, could just use the nbhd.
177  std::transform(std::begin(phi_high), std::end(phi_high), std::back_inserter(result), [](const auto& high) {
178  return high.m_e;
179  });
180  std::transform(std::begin(phi_center), std::end(phi_center), std::back_inserter(result), [](const auto& center) {
181  return center.m_e;
182  });
183  std::transform(std::begin(phi_low), std::end(phi_low), std::back_inserter(result), [](const auto& low) {
184  return low.m_e;
185  });
186 
187  return result;
188  }

◆ initialize()

StatusCode GlobalSim::Egamma1BaselineAlgTool::initialize ( )
override

Definition at line 19 of file Egamma1BaselineAlgTool.cxx.

19  {
20 
21  CHECK(m_nbhdContainerReadKey.initialize());
24 
25  return StatusCode::SUCCESS;
26  }

◆ run()

StatusCode GlobalSim::Egamma1BaselineAlgTool::run ( const EventContext &  ctx) const
overridevirtual

Definition at line 29 of file Egamma1BaselineAlgTool.cxx.

29  {
30  ATH_MSG_DEBUG("run()");
31 
32 
33  // read in LArStrip neighborhoods from the event store
34  // there is one neighborhood per EFex RoI
35  auto in =
37  ctx);
38  CHECK(in.isValid());
39 
40  ATH_MSG_DEBUG("read in " << (*in).size() << " neighborhoods");
41 
42  ap_int<16> peak = 0;
43  ap_int<16> secondMax = 0;
44 
46  CHECK(h_eRatio.record(std::make_unique<std::vector<float> >()));
48  CHECK(h_eRatioSimple.record(std::make_unique<std::vector<float> >()));
49 
50  for (const auto& nbhd : *in) {
51  auto c_phi = combine_phi(nbhd);
52  if (msgLevel() <= MSG::DEBUG) {
53  std::stringstream ss;
54  ss << "Baseline input: ";
55  for (const auto& i : c_phi) {ss << i << ' ';}
56  ATH_MSG_DEBUG(ss.str());
57  }
58  //if (c_phi.empty()) {continue;} // corner case: not all phi have len 17
59  auto input = digitizer::digitize16(c_phi);
60  //Do want to ap_int them?
61  //ap_int<10>* c_input = &input[0]; // vector->array
62 
63  if (msgLevel() <= MSG::DEBUG) {
64  std::stringstream ss;
65  ss << "Baseline input: ";
66  for (const auto& i : input) {ss << i << ' ';}
67  ATH_MSG_DEBUG(ss.str());
68  }
69 
70  //Central peak is easy, it's column 9 in the middle row, i.e. entry 25.
71  peak = input.at(25);
72  ATH_MSG_DEBUG("Peak " << peak);
73 
74  //Find the 6 secondary peaks, lets do it like the VHDL
75  //holder of the current second peak (we will have 6)
76  std::vector<ap_int<16>> secondPeak;
77  secondPeak.resize(6);
78 
79  //Noise Margin: This should be 2sigma... set to 1 for now...
80  int noiseMargin = 1;
81  //Route one: <<< middle row, 24 down to 17
82  secondPeak[0] = secondPeakSearch(input, peak, 24, 17, noiseMargin);
83  //Route two: middle row >>>, 26 up to 33
84  secondPeak[1] = secondPeakSearch(input, peak, 26, 33, noiseMargin);
85  //Route three: <<< top row, 8 down to 0
86  secondPeak[2] = secondPeakSearch(input, peak, 8, 0, noiseMargin);
87  //Route four: top row >>>, 8 up to 16
88  secondPeak[3] = secondPeakSearch(input, peak, 8, 16, noiseMargin);
89  //Route five: <<< bottom row, 42 down to 34
90  secondPeak[4] = secondPeakSearch(input, peak, 42, 34, noiseMargin);
91  //Route five: bottom row >>>, 42 up to 50
92  secondPeak[5] = secondPeakSearch(input, peak, 42, 50, noiseMargin);
93 
94  auto result = std::max_element(secondPeak.begin(), secondPeak.end());
95  ATH_MSG_DEBUG("Max element found at index "
96  << std::distance(secondPeak.begin(), result)
97  << " has value " << *result);
98  //tidy up.
99  secondMax = *result;
100  ATH_MSG_DEBUG("Peak " << peak << " second " << secondMax);
101 
102  //I am not confident on waht div_gen_0 does. So I am casting to floats for now.
103  if(peak > 0 || secondMax > 0){
104  auto eRatio = static_cast< float >(peak - secondMax)/static_cast< float >(peak + secondMax);
105  h_eRatio->push_back(eRatio);
106  ATH_MSG_DEBUG("eRatio (p-sp/p+sp) is " << eRatio);
107 
108  auto eRatioSimple = static_cast< float >(secondMax)/static_cast< float >(peak);
109  h_eRatioSimple->push_back(eRatioSimple);
110  ATH_MSG_DEBUG("eRatio (sp/p) is " << eRatio);
111  }
112 
113  }
114 
115  return StatusCode::SUCCESS;
116  }

◆ secondPeakSearch()

ap_int< 16 > GlobalSim::Egamma1BaselineAlgTool::secondPeakSearch ( const std::vector< ap_int< 16 >> &  input,
const ap_int< 16 >  peak,
const int  startCell,
const int  endCell,
const ap_int< 16 >  noiseMargin 
) const
private

Definition at line 118 of file Egamma1BaselineAlgTool.cxx.

122  {
123  //First set a series of counters to "descending" = 0
124  int ascending = 0;
125 
126  //Setup holder of the last energy we checked... which starts at the peak...
127  ap_int<16> lastEnergy = peak;
128  ap_int<16> secondPeak = 0;
129 
130  //There must be a better way to do this?
131  int direction = 0;
132  if(startCell > endCell) {
133  direction =-1;
134  } else {
135  direction =1;
136  }
137 
138  //Route 1: go down in the middlle row
139  for (auto itr = input.begin() + startCell; itr != input.begin() + endCell + direction; itr+=direction){
140  //Going down hill... until we are not...
141  ATH_MSG_DEBUG("Input is " << *itr << " last energy is " << lastEnergy);
142  if(ascending==0 && *itr>lastEnergy && *itr-lastEnergy > noiseMargin){
143  ATH_MSG_DEBUG("We are going up now " << *itr << " is more then " << lastEnergy);
144  ascending=1;
145  lastEnergy=*itr;
146  //Now check if we are at the peak as we are going uphill
147  } else if(ascending==1 && lastEnergy>*itr && lastEnergy-*itr > noiseMargin){
148  ATH_MSG_DEBUG("We are past the top " << *itr << " is less than " << lastEnergy);
149  if(secondPeak<*itr) secondPeak = lastEnergy;
150  ATH_MSG_DEBUG("The peak was " << secondPeak);
151  //I think we can break here... don't need to find a third peak
152  break;
153  } else {
154  lastEnergy=*itr;
155  }
156  }
157 
158  return secondPeak;
159  }

◆ toString()

std::string GlobalSim::Egamma1BaselineAlgTool::toString ( ) const
overridevirtual

Definition at line 190 of file Egamma1BaselineAlgTool.cxx.

190  {
191 
192  std::stringstream ss;
193  ss << "Egamma1BaselineAlgTool. name: " << name() << '\n'
194  << m_nbhdContainerReadKey << '\n'
195  << '\n';
196  return ss.str();
197  }

Member Data Documentation

◆ m_enableDump

Gaudi::Property<bool> GlobalSim::Egamma1BaselineAlgTool::m_enableDump
private
Initial value:
{this,
"enableDump",
{false},
"flag to enable dumps"}

Definition at line 44 of file Egamma1BaselineAlgTool.h.

◆ m_eRatioKey

SG::WriteHandleKey<std::vector<float> > GlobalSim::Egamma1BaselineAlgTool::m_eRatioKey
private
Initial value:
{
this,
"eRatioKey",
"eRatio"}

Definition at line 58 of file Egamma1BaselineAlgTool.h.

◆ m_eRatioSimpleKey

SG::WriteHandleKey<std::vector<float> > GlobalSim::Egamma1BaselineAlgTool::m_eRatioSimpleKey
private
Initial value:
{
this,
"eRatioSimpleKey",
"eRatioSimple"}

Definition at line 64 of file Egamma1BaselineAlgTool.h.

◆ m_nbhdContainerReadKey

SG::ReadHandleKey<LArStripNeighborhoodContainer> GlobalSim::Egamma1BaselineAlgTool::m_nbhdContainerReadKey
private
Initial value:
{
this,
"LArNeighborhoodContainerReadKey",
"stripNeighborhoodContainer",
"key to read inLArNeighborhoodReadKeys"}

Definition at line 51 of file Egamma1BaselineAlgTool.h.

◆ s_combination_len

constexpr int GlobalSim::Egamma1BaselineAlgTool::s_combination_len = 51
inlinestaticconstexprprivate

Definition at line 81 of file Egamma1BaselineAlgTool.h.

◆ s_required_phi_len

constexpr int GlobalSim::Egamma1BaselineAlgTool::s_required_phi_len = 17
inlinestaticconstexprprivate

Definition at line 77 of file Egamma1BaselineAlgTool.h.


The documentation for this class was generated from the following files:
get_generator_info.result
result
Definition: get_generator_info.py:21
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
GlobalSim::Egamma1BaselineAlgTool::m_eRatioKey
SG::WriteHandleKey< std::vector< float > > m_eRatioKey
Definition: Egamma1BaselineAlgTool.h:58
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
GlobalSim::digitizer::digitize16
static std::vector< ap_int< 16 > > digitize16(const std::vector< double > &v)
Definition: Digitizer.h:42
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
lumiFormat.i
int i
Definition: lumiFormat.py:85
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
test_pyathena.parent
parent
Definition: test_pyathena.py:15
GlobalSim::Egamma1BaselineAlgTool::m_eRatioSimpleKey
SG::WriteHandleKey< std::vector< float > > m_eRatioSimpleKey
Definition: Egamma1BaselineAlgTool.h:64
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
GlobalSim::Egamma1BaselineAlgTool::m_nbhdContainerReadKey
SG::ReadHandleKey< LArStripNeighborhoodContainer > m_nbhdContainerReadKey
Definition: Egamma1BaselineAlgTool.h:51
python.TriggerAPI.TriggerAPISession.ascending
ascending
Definition: TriggerAPISession.py:435
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
GlobalSim::Egamma1BaselineAlgTool::secondPeakSearch
ap_int< 16 > secondPeakSearch(const std::vector< ap_int< 16 >> &input, const ap_int< 16 > peak, const int startCell, const int endCell, const ap_int< 16 > noiseMargin) const
Definition: Egamma1BaselineAlgTool.cxx:118
DEBUG
#define DEBUG
Definition: page_access.h:11
GlobalSim::Egamma1BaselineAlgTool::s_combination_len
static constexpr int s_combination_len
Definition: Egamma1BaselineAlgTool.h:81
GlobalSim::Egamma1BaselineAlgTool::combine_phi
std::vector< double > combine_phi(const LArStripNeighborhood *) const
Definition: Egamma1BaselineAlgTool.cxx:162
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54