ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalSim::eRatioAlgTool_UCL Class Reference

#include <eRatioAlgTool_UCL.h>

Inheritance diagram for GlobalSim::eRatioAlgTool_UCL:
Collaboration diagram for GlobalSim::eRatioAlgTool_UCL:

Public Member Functions

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

Private Member Functions

std::vector< double > combine_phi (const IOBitwise::eEmNbhoodTOB *) 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< IOBitwise::eEmNbhoodTOBContainerm_nbhdTOBContainerReadKey
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 29 of file eRatioAlgTool_UCL.h.

Constructor & Destructor Documentation

◆ eRatioAlgTool_UCL()

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

Definition at line 16 of file eRatioAlgTool_UCL.cxx.

18 :
19 base_class(type, name, parent){
20 }

◆ ~eRatioAlgTool_UCL()

virtual GlobalSim::eRatioAlgTool_UCL::~eRatioAlgTool_UCL ( )
virtualdefault

Member Function Documentation

◆ combine_phi()

std::vector< double > GlobalSim::eRatioAlgTool_UCL::combine_phi ( const IOBitwise::eEmNbhoodTOB * nbhdTOB) const
private

Definition at line 170 of file eRatioAlgTool_UCL.cxx.

170 {
171 auto result = std::vector<double>();
172
173 const auto& phi_low = nbhdTOB->Neighbourhood().phi_low();
174 //if (phi_low.size() != s_required_phi_len) {return result;}
175
176 const auto& phi_center = nbhdTOB->Neighbourhood().phi_center();
177 //if (phi_center.size() != s_required_phi_len) {return result;}
178
179 const auto& phi_high = nbhdTOB->Neighbourhood().phi_high();
180 //if (phi_high.size() != s_required_phi_len) {return result;}
181
182 result.reserve(s_combination_len);
183
184 //Make a big vector as the VHDL does. Not strictly necessary, could just use the nbhd.
185 std::transform(std::begin(phi_high), std::end(phi_high), std::back_inserter(result), [](const auto& high) {
186 return high.m_e;
187 });
188 std::transform(std::begin(phi_center), std::end(phi_center), std::back_inserter(result), [](const auto& center) {
189 return center.m_e;
190 });
191 std::transform(std::begin(phi_low), std::end(phi_low), std::back_inserter(result), [](const auto& low) {
192 return low.m_e;
193 });
194
195 return result;
196 }
static constexpr int s_combination_len

◆ initialize()

StatusCode GlobalSim::eRatioAlgTool_UCL::initialize ( )
override

Definition at line 22 of file eRatioAlgTool_UCL.cxx.

22 {
23
24 CHECK(m_nbhdTOBContainerReadKey.initialize());
25 CHECK(m_eRatioKey.initialize());
26 CHECK(m_eRatioSimpleKey.initialize());
27
28 return StatusCode::SUCCESS;
29 }
#define CHECK(...)
Evaluate an expression and check for errors.
SG::ReadHandleKey< IOBitwise::eEmNbhoodTOBContainer > m_nbhdTOBContainerReadKey
SG::WriteHandleKey< std::vector< float > > m_eRatioKey
SG::WriteHandleKey< std::vector< float > > m_eRatioSimpleKey

◆ run()

StatusCode GlobalSim::eRatioAlgTool_UCL::run ( const std::unique_ptr< IDataCollector > & dc,
const EventContext & ctx ) const
overridevirtual

Definition at line 32 of file eRatioAlgTool_UCL.cxx.

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

◆ secondPeakSearch()

ap_int< 16 > GlobalSim::eRatioAlgTool_UCL::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 126 of file eRatioAlgTool_UCL.cxx.

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

◆ toString()

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

Definition at line 198 of file eRatioAlgTool_UCL.cxx.

198 {
199
200 std::stringstream ss;
201 ss << "eRatioAlgTool_UCL. name: " << name() << '\n'
203 << '\n';
204 return ss.str();
205 }

Member Data Documentation

◆ m_enableDump

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

Definition at line 48 of file eRatioAlgTool_UCL.h.

48 {this,
49 "enableDump",
50 {false},
51 "flag to enable dumps"};

◆ m_eRatioKey

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

Definition at line 62 of file eRatioAlgTool_UCL.h.

62 {
63 this,
64 "eRatioKey",
65 "eRatio"};

◆ m_eRatioSimpleKey

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

Definition at line 68 of file eRatioAlgTool_UCL.h.

68 {
69 this,
70 "eRatioSimpleKey",
71 "eRatioSimple"};

◆ m_nbhdTOBContainerReadKey

SG::ReadHandleKey<IOBitwise::eEmNbhoodTOBContainer> GlobalSim::eRatioAlgTool_UCL::m_nbhdTOBContainerReadKey
private
Initial value:
{
this,
"LArNeighborhoodTOBContainerReadKey",
"stripNeighborhoodTOBContainer",
"key to read inLArNeighborhoodTOBsReadKeys"}

Definition at line 55 of file eRatioAlgTool_UCL.h.

55 {
56 this,
57 "LArNeighborhoodTOBContainerReadKey",
58 "stripNeighborhoodTOBContainer",
59 "key to read inLArNeighborhoodTOBsReadKeys"};

◆ s_combination_len

int GlobalSim::eRatioAlgTool_UCL::s_combination_len = 51
inlinestaticconstexprprivate

Definition at line 85 of file eRatioAlgTool_UCL.h.

◆ s_required_phi_len

int GlobalSim::eRatioAlgTool_UCL::s_required_phi_len = 17
inlinestaticconstexprprivate

Definition at line 81 of file eRatioAlgTool_UCL.h.


The documentation for this class was generated from the following files: