ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
HIEventShapeIndex Class Reference

#include <HIEventShapeIndex.h>

Collaboration diagram for HIEventShapeIndex:

Classes

struct  range_index_t
 

Public Member Functions

 HIEventShapeIndex ()
 
 ~HIEventShapeIndex ()
 
unsigned int setBinning (const TH2 *h2, bool asMask)
 
unsigned int setBinning (HI::BinningScheme scheme)
 
void initializeEventShapeContainer (std::unique_ptr< xAOD::HIEventShapeContainer > &shape_container, unsigned int num_harmonics) const
 
unsigned int getIndex (float eta, int layer) const
 
unsigned int getIndexFromBin (unsigned int ebin, int layer) const
 
unsigned int getEtaBin (float eta, int layer) const
 
unsigned int getNumBins () const
 
xAOD::HIEventShapegetShape (float eta, int layer, xAOD::HIEventShapeContainer *shape_container) const
 
const xAOD::HIEventShapegetShape (float eta, int layer, const xAOD::HIEventShapeContainer *shape_container) const
 
xAOD::HIEventShapegetShape (float eta, int layer, std::unique_ptr< xAOD::HIEventShapeContainer > &shape_container) const
 
std::string print () const
 

Private Member Functions

unsigned int getIndex_Internal (float eta, int layer, bool etaIndex) const
 
std::map< int, std::vector< range_index_t > >::const_iterator getLayer (int layer) const
 
float roundToTenth (float d) const
 

Private Attributes

std::map< int, std::vector< range_index_t > > m_edges
 
unsigned int m_size
 

Detailed Description

Definition at line 16 of file HIEventShapeIndex.h.

Constructor & Destructor Documentation

◆ HIEventShapeIndex()

HIEventShapeIndex::HIEventShapeIndex ( )

Definition at line 14 of file HIEventShapeIndex.cxx.

14  : m_size(0)
15 {
16 }

◆ ~HIEventShapeIndex()

HIEventShapeIndex::~HIEventShapeIndex ( )

Definition at line 18 of file HIEventShapeIndex.cxx.

19 {
20 }

Member Function Documentation

◆ getEtaBin()

unsigned int HIEventShapeIndex::getEtaBin ( float  eta,
int  layer 
) const

Definition at line 150 of file HIEventShapeIndex.cxx.

151 {
152  return getIndex_Internal(eta,layer,true);
153 }

◆ getIndex()

unsigned int HIEventShapeIndex::getIndex ( float  eta,
int  layer 
) const

Definition at line 145 of file HIEventShapeIndex.cxx.

146 {
147  return getIndex_Internal(eta,layer,false);
148 }

◆ getIndex_Internal()

unsigned int HIEventShapeIndex::getIndex_Internal ( float  eta,
int  layer,
bool  etaIndex 
) const
private

Definition at line 110 of file HIEventShapeIndex.cxx.

111 {
112  auto mItr=getLayer(layer);
113  const std::vector<range_index_t>& vec=mItr->second;
114  unsigned int vsize=vec.size();
115 
116  if(vsize==0)
117  {
118  std::cerr << "Layer " << layer << " has no range in calorimeter" << std::endl;
119  throw std::range_error("Bad binning request");
120  return 0;
121  }
122 
123  float eta_c=eta;
124  if(m_edges.size()>1)
125  {
126  float abs_eta=std::abs(eta);
129 
130  if(abs_eta < rmin) eta_c=rmin+std::copysign(1e-2,eta);
131  else if(abs_eta > rmax) eta_c=rmax-std::copysign(1e-2,eta);
132  }
133 
134  unsigned int pIndex=0;
135  for(; pIndex < vsize-1; pIndex++)
136  {
137  const range_index_t& p=vec.at(pIndex);
138  if(p(eta_c)) break;
139  }
140 
141  return (etaIndex) ? pIndex : vec.at(pIndex).index;
142 }

◆ getIndexFromBin()

unsigned int HIEventShapeIndex::getIndexFromBin ( unsigned int  ebin,
int  layer 
) const

Definition at line 105 of file HIEventShapeIndex.cxx.

106 {
107  return getLayer(layer)->second.at(ebin).index;
108 }

◆ getLayer()

std::map< int, std::vector< HIEventShapeIndex::range_index_t > >::const_iterator HIEventShapeIndex::getLayer ( int  layer) const
private

Definition at line 193 of file HIEventShapeIndex.cxx.

194 {
195  auto mItr=m_edges.find(layer);
196 
197  if(mItr==m_edges.end())
198  {
199  //ATH_MSG_ERROR("Layer " << layer << " has no binning specification");
200  std::cerr << "Layer " << layer << " has no binning specification" << std::endl;
201  throw std::range_error("Bad binning request");
202  }
203  return mItr;
204 }

◆ getNumBins()

unsigned int HIEventShapeIndex::getNumBins ( ) const
inline

Definition at line 37 of file HIEventShapeIndex.h.

37 {return m_size;};

◆ getShape() [1/3]

const xAOD::HIEventShape * HIEventShapeIndex::getShape ( float  eta,
int  layer,
const xAOD::HIEventShapeContainer shape_container 
) const

Definition at line 169 of file HIEventShapeIndex.cxx.

170 {
171  if(shape_container==nullptr)
172  {
173  //ATH_MSG_WARNING("No default HIEventShapeContainer to query. Returning nullptr_t.");
174  return nullptr;
175  }
176  unsigned int bin=getIndex(eta,layer);
177  //correct for round-off errors in cell eta values, just need to make sure they end up in the right bin
178  if( bin >= shape_container->size() ) bin=getIndex(eta-std::copysign(1e-2,eta),layer);
179 
180  return shape_container->at(bin);
181 }

◆ getShape() [2/3]

xAOD::HIEventShape * HIEventShapeIndex::getShape ( float  eta,
int  layer,
std::unique_ptr< xAOD::HIEventShapeContainer > &  shape_container 
) const

Definition at line 184 of file HIEventShapeIndex.cxx.

185 {
186  unsigned int bin=getIndex(eta,layer);
187  //correct for round-off errors in cell eta values, just need to make sure they end up in the right bin
188  if( bin >= shape_container->size() ) bin=getIndex(eta-std::copysign(1e-2,eta),layer);
189 
190  return shape_container->at(bin);
191 }

◆ getShape() [3/3]

xAOD::HIEventShape * HIEventShapeIndex::getShape ( float  eta,
int  layer,
xAOD::HIEventShapeContainer shape_container 
) const

Definition at line 155 of file HIEventShapeIndex.cxx.

156 {
157  if(shape_container==nullptr)
158  {
159  //ATH_MSG_WARNING("No default HIEventShapeContainer to query. Returning nullptr_t.");
160  return nullptr;
161  }
162  unsigned int bin=getIndex(eta,layer);
163  //correct for round-off errors in cell eta values, just need to make sure they end up in the right bin
164  if( bin >= shape_container->size() ) bin=getIndex(eta-std::copysign(1e-2,eta),layer);
165 
166  return shape_container->at(bin);
167 }

◆ initializeEventShapeContainer()

void HIEventShapeIndex::initializeEventShapeContainer ( std::unique_ptr< xAOD::HIEventShapeContainer > &  shape_container,
unsigned int  num_harmonics 
) const

Definition at line 206 of file HIEventShapeIndex.cxx.

207 {
208  if(getNumBins()==0)
209  {
210  //ATH_MSG_WARNING("Cannot initialize HIEventShapeContainer. Index has not been initialized.");
211  return;
212 
213  }
214  bool isEmpty=(shape_container->size()==0);
215  if(isEmpty) shape_container->resize(getNumBins());
216  else if(shape_container->size()!=getNumBins())
217  {
218  //ATH_MSG_WARNING("Cannot initialize HIEventShapeContainer. Number of elements incompatible w/ requested binning.");
219  return;
220 
221  }
222 
223  for(const auto& pp : m_edges)
224  {
225  for(auto ri : pp.second)
226  {
228  if(isEmpty)
229  {
231  //shape_container->push_back(slice);
232  shape_container->operator[](ri.index)=slice;
233  }
234  else slice=shape_container->at(ri.index);
235 
236  slice->setEtaMin(ri.eta_min);
237  slice->setEtaMax(ri.eta_max);
238  slice->setLayer(pp.first);
239  slice->etCos().assign(num_harmonics,0);
240  slice->etSin().assign(num_harmonics,0);
241  }
242  }
243 }

◆ print()

std::string HIEventShapeIndex::print ( ) const

Definition at line 246 of file HIEventShapeIndex.cxx.

247 {
248  std::stringstream ss;
249  ss.precision(3);
250  for(const auto& pp : m_edges)
251  {
252  for(auto ri : pp.second)
253  {
254  ss << std::setw(10) << pp.first
255  << std::setw(10) << ri.eta_min
256  << std::setw(10) << ri.eta_max
257  << std::setw(10) << ri.index
258  << std::endl;
259  }
260  }
261  return ss.str();
262 }

◆ roundToTenth()

float HIEventShapeIndex::roundToTenth ( float  d) const
inlineprivate

Definition at line 66 of file HIEventShapeIndex.h.

66 {return std::floor(d)+std::floor((d-std::floor(d))*10.0+0.5)/10.0;};

◆ setBinning() [1/2]

unsigned int HIEventShapeIndex::setBinning ( const TH2 *  h2,
bool  asMask 
)

Definition at line 23 of file HIEventShapeIndex.cxx.

24 {
25  if(h2==nullptr)
26  {
27  //ATH_MSG_ERROR("Bad histogram pointer");
28  return 0;
29  }
30 
31  unsigned int count=0;
32  std::set<unsigned int> used_indices;
33  for(int ybin=1; ybin<h2->GetNbinsY(); ybin++)
34  {
35  auto mItr=m_edges.emplace_hint(m_edges.end(),ybin-1,std::vector<range_index_t>());
36  for(int xbin=1; xbin<h2->GetNbinsX(); xbin++)
37  {
38  if(h2->GetBinContent(xbin,ybin) < 0) continue;
39  unsigned int v=h2->GetBinContent(xbin,ybin);
40 
41  if(asMask) v=count;
42  else
43  {
44  auto sItr=used_indices.find(v);
45  if(sItr==used_indices.end()) used_indices.insert(v);
46  else
47  {
48  //ATH_MSG_ERROR("Could not set binning. initialization histogram has duplicate indices " << v);
49  //m_edges.clear();
50  //return 0;
51  continue;
52  }
53  }
54  mItr->second.push_back(range_index_t(h2->GetXaxis()->GetBinLowEdge(xbin),h2->GetXaxis()->GetBinUpEdge(xbin),v));
55  count++;
56  }
57  }
58  m_size=count;
59  return count;
60 }

◆ setBinning() [2/2]

unsigned int HIEventShapeIndex::setBinning ( HI::BinningScheme  scheme)

Definition at line 62 of file HIEventShapeIndex.cxx.

63 {
64  unsigned int index=0;
66  {
67  for(unsigned int layer=0; layer < static_cast<int>(HI::TowerBins::numLayers()); layer++)
68  {
69  auto mItr=m_edges.emplace_hint(m_edges.end(),layer,std::vector<range_index_t>(HI::TowerBins::numEtaBins(),range_index_t()));
70  for(unsigned int eb=0; eb<HI::TowerBins::numEtaBins(); eb++,index++)
71  {
72 
73  mItr->second[eb].eta_min=HI::TowerBins::getBinLowEdgeEta(eb);
74  mItr->second[eb].eta_max=HI::TowerBins::getBinUpEdgeEta(eb);
75  mItr->second[eb].index=index;
76  }
77  }
78  }
80  {
81  float deta=HI::TowerBins::getBinSizeEta();
82  for(int layer=0; layer < static_cast<int>(HI::TowerBins::numLayers()); layer++)
83  {
86  unsigned int num_eta_bins= static_cast<unsigned int>(std::round(std::abs((emax-emin)/deta)));
87  auto mItr=m_edges.emplace_hint(m_edges.end(),layer,std::vector<range_index_t>(2*num_eta_bins,range_index_t()));
88  for(unsigned int k=0; k<num_eta_bins; k++)
89  {
90  mItr->second[k].eta_min=roundToTenth(-emax+k*deta);
91  mItr->second[k].eta_max=roundToTenth(-emax+k*deta+deta);
92  mItr->second[k].index=roundToTenth(k+index);
93  mItr->second[k+num_eta_bins].eta_min=roundToTenth(emin+k*deta);
94  mItr->second[k+num_eta_bins].eta_max=roundToTenth(emin+k*deta+deta);
95  mItr->second[k+num_eta_bins].index=roundToTenth(k+num_eta_bins+index);
96  }
97  index+=2*num_eta_bins;
98  }
99  }
100  m_size=index;
101  return index;
102 
103 }

Member Data Documentation

◆ m_edges

std::map<int,std::vector<range_index_t> > HIEventShapeIndex::m_edges
private

Definition at line 59 of file HIEventShapeIndex.h.

◆ m_size

unsigned int HIEventShapeIndex::m_size
private

Definition at line 61 of file HIEventShapeIndex.h.


The documentation for this class was generated from the following files:
HI::TOWER
@ TOWER
Definition: HIEventDefs.h:16
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
index
Definition: index.py:1
hist_file_dump.d
d
Definition: hist_file_dump.py:137
HICaloRange::getRangeMax
float getRangeMax(int layer) const
Definition: HICaloRange.h:20
HIEventShapeIndex::roundToTenth
float roundToTenth(float d) const
Definition: HIEventShapeIndex.h:66
HICaloRange::getRangeMin
float getRangeMin(int layer) const
Definition: HICaloRange.h:19
HICaloRange::getRange
static const HICaloRange & getRange()
Definition: HICaloRange.cxx:13
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
bin
Definition: BinsDiffFromStripMedian.h:43
xAOD::HIEventShape
HIEventShape_v2 HIEventShape
Definition of the latest event info version.
Definition: HIEventShape.h:16
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
HI::TowerBins::getBinLowEdgeEta
float getBinLowEdgeEta(unsigned int eb)
Definition: HIEventDefs.h:38
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
HIEventShapeIndex::getLayer
std::map< int, std::vector< range_index_t > >::const_iterator getLayer(int layer) const
Definition: HIEventShapeIndex.cxx:193
xAOD::HIEventShape_v2
Interface class for the HI reconstruction EDM.
Definition: HIEventShape_v2.h:31
HI::TowerBins::getBinUpEdgeEta
float getBinUpEdgeEta(unsigned int eb)
Definition: HIEventDefs.h:39
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
perfmonmt-refit.slice
slice
Definition: perfmonmt-refit.py:52
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
HIEventShapeIndex::getNumBins
unsigned int getNumBins() const
Definition: HIEventShapeIndex.h:37
HI::COMPACT
@ COMPACT
Definition: HIEventDefs.h:16
JetTagCalibConfig.scheme
scheme
Definition: JetTagCalibConfig.py:16
HIEventShapeIndex::getIndex_Internal
unsigned int getIndex_Internal(float eta, int layer, bool etaIndex) const
Definition: HIEventShapeIndex.cxx:110
HI::TowerBins::numEtaBins
constexpr unsigned int numEtaBins()
Definition: HIEventDefs.h:19
DataVector::resize
void resize(size_type sz)
Resizes the collection to the specified number of elements.
HI::TowerBins::getBinSizeEta
constexpr float getBinSizeEta()
Definition: HIEventDefs.h:31
HIEventShapeIndex::m_size
unsigned int m_size
Definition: HIEventShapeIndex.h:61
HI::TowerBins::numLayers
constexpr unsigned int numLayers()
Definition: HIEventDefs.h:23
HIEventShapeIndex::getIndex
unsigned int getIndex(float eta, int layer) const
Definition: HIEventShapeIndex.cxx:145
python.PyAthena.v
v
Definition: PyAthena.py:154
DeMoScan.index
string index
Definition: DeMoScan.py:364
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
HIEventShapeIndex::m_edges
std::map< int, std::vector< range_index_t > > m_edges
Definition: HIEventShapeIndex.h:59
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
fitman.k
k
Definition: fitman.py:528