ATLAS Offline Software
Loading...
Searching...
No Matches
CaloLocalHadCoeff Struct Reference

Hold binned correction data for local hadronic calibration procedure. More...

#include <CaloLocalHadCoeff.h>

Collaboration diagram for CaloLocalHadCoeff:

Classes

class  LocalHadArea
 Definition of correction area. More...
class  LocalHadDimension
 Class defines binning for user dimension. More...

Public Types

typedef std::vector< float > LocalHadCoeff
 Correction parameters for one general bin.

Public Member Functions

 CaloLocalHadCoeff ()
 Default constructor.
 CaloLocalHadCoeff (const CaloLocalHadCoeff &other)=default
 Copy constructor.
CaloLocalHadCoeffoperator= (const CaloLocalHadCoeff &other)=default
 CaloLocalHadCoeff (CaloLocalHadCoeff &&) noexcept=default
CaloLocalHadCoeffoperator= (CaloLocalHadCoeff &&) noexcept=default
const std::string & getTitle () const
 return name
void setTitle (const std::string &title)
 set name
int getSizeAreaSet () const
 return number of areas defined for this data set
void addArea (LocalHadArea &theArea)
 add new area
void setArea (const int n_area, const LocalHadArea &theArea)
 replace existing area with another one
const LocalHadAreagetArea (int n_area) const
 return area
const LocalHadAreagetAreaFromBin (int iBin) const
 return area defined for given general iBin
const LocalHadAreagetAreaFromBin (int iBin, int &i_area) const
 return area (and area index) defined for given general iBin
int getSizeCoeffSet () const
 return total number of coefficient sets
void setCoeff (const int iBin, const LocalHadCoeff &theCoeff)
 set new data
const LocalHadCoeffgetCoeff (const int &iBin) const
 get data for given general bin number
const LocalHadCoeffgetCoeff (const int &n_area, std::vector< float > &vars) const
 get data for given area and list of cluster variables
int getBin (const int n_area, std::vector< float > &vars) const
 calculate general bin from vector of input cluster variables
int getBin (const int n_area, std::vector< int > &v_indexes) const
 calculate general bin from known bins in dimensions
int bin2indexes (const int iBin, std::vector< int > &v_dim_indx) const
 expand general bin into vector of bins for defined dimensions
bool isNeighbour (const int iBinx, std::vector< int > &v_indx) const
 are this bins is neighbour to this indexes vector (any of their indexes differ per one ?)
bool isFilled (const int iBin) const
 check if general bin is filled
bool getInterpArrays (const int n_area, const std::vector< int > &dim, std::vector< float > &x, std::vector< double > &xadj, std::vector< unsigned int > &gbin) const
 for interpolation, build the vector of relative x, and global bins for interpolated array for area n_area and list of dimensions (all in case dim is empty)

Private Attributes

std::string m_title
 title of data set
std::vector< LocalHadCoeffm_CoeffSet
 vector of correction coefficients
std::vector< LocalHadAream_AreaSet
 vector of correction areas

Detailed Description

Hold binned correction data for local hadronic calibration procedure.

defines enums and data types of CaloLocalHadCoeff

Author
Gennady Pospelov guenn.nosp@m.adi..nosp@m.pospe.nosp@m.lov@.nosp@m.cern..nosp@m.ch, Pavol Strizenec pavol.nosp@m.@mai.nosp@m.l.cer.nosp@m.n.ch
Date
20-July-2009

This class holds binned correction data in multi-dimensional space for classification, weighting, out-of-cluster or dead material correction tools. Data are holded as vector of floats for each bin defined, thereby that at the end they appear to be vector of vector of float. One data set (one CaloLocalHadCoeff) serve for one correction tool.

Binning definition is done via conception of 'correction areas'. One area has fixed number of dimenensions, fixed way how these dimensions have been binned and fixed number of correction parameters for each bin.

For example, em/had classification tool requires following setup: 3 correction coefficients (em fraction of bin, number of entries in bin, some error in bin) are binned in 4 dimensions: cluster eta, log10(cluster energy), log10(cluster energy density), log10(cluter depth).

There could be more, than one, correction area defined for one correction tool. For example, dead material correction have 8 different areas defined for different kind of dead material energy depositions (before presamplers, between emec and hec, before FCAL, etc)

Author
Gennady Pospelov guenn.nosp@m.adi..nosp@m.pospe.nosp@m.lov@.nosp@m.cern..nosp@m.ch
Date
18-August-2009

Definition at line 41 of file CaloLocalHadCoeff.h.

Member Typedef Documentation

◆ LocalHadCoeff

typedef std::vector<float> CaloLocalHadCoeff::LocalHadCoeff

Correction parameters for one general bin.

Definition at line 220 of file CaloLocalHadCoeff.h.

Constructor & Destructor Documentation

◆ CaloLocalHadCoeff() [1/3]

CaloLocalHadCoeff::CaloLocalHadCoeff ( )

Default constructor.

Definition at line 162 of file CaloLocalHadCoeff.cxx.

163{
164 static_assert(std::is_nothrow_move_constructible<CaloLocalHadCoeff>::value);
165 static_assert(std::is_nothrow_move_constructible<LocalHadArea>::value);
166 static_assert(std::is_nothrow_move_constructible<LocalHadDimension>::value);
167}

◆ CaloLocalHadCoeff() [2/3]

CaloLocalHadCoeff::CaloLocalHadCoeff ( const CaloLocalHadCoeff & other)
default

Copy constructor.

◆ CaloLocalHadCoeff() [3/3]

CaloLocalHadCoeff::CaloLocalHadCoeff ( CaloLocalHadCoeff && )
defaultnoexcept

Member Function Documentation

◆ addArea()

void CaloLocalHadCoeff::addArea ( LocalHadArea & theArea)

add new area

Definition at line 176 of file CaloLocalHadCoeff.cxx.

177{
178 // calculating offset for coefficients of this area using previous areas defined
179 int offset = 0;
180 for(unsigned int i_area=0; i_area<m_AreaSet.size(); i_area++){
181 offset += m_AreaSet[i_area].getLength();
182 }
183 theArea.setOffset(offset);
184 // adding zero coefficients
186 pars.resize(theArea.getNpars(), 0.0);
187 for(int i_size=0; i_size<theArea.getLength(); i_size++){
188 m_CoeffSet.push_back(pars);
189 }
190 // adding area
191 m_AreaSet.push_back(theArea);
192}
std::vector< float > LocalHadCoeff
Correction parameters for one general bin.
std::vector< LocalHadArea > m_AreaSet
vector of correction areas
std::vector< LocalHadCoeff > m_CoeffSet
vector of correction coefficients

◆ bin2indexes()

int CaloLocalHadCoeff::bin2indexes ( const int iBin,
std::vector< int > & v_dim_indx ) const

expand general bin into vector of bins for defined dimensions

Definition at line 301 of file CaloLocalHadCoeff.cxx.

302{
303 const LocalHadArea *theArea = getAreaFromBin(iBin);
304 v_dim_indx.resize(theArea->getNdim(),0);
305 for(int i_dim=0; i_dim<theArea->getNdim(); i_dim++){
306 int x0 = 0;
307 for(int j=0; j<i_dim; j++){
308 x0 += v_dim_indx[j]*theArea->getDimLoc(j);
309 }
310 v_dim_indx[i_dim] = (iBin-theArea->getOffset()-x0)/theArea->getDimLoc(i_dim);
311 }
312 return 0;
313}
Definition of correction area.
const LocalHadArea * getAreaFromBin(int iBin) const
return area defined for given general iBin

◆ getArea()

const CaloLocalHadCoeff::LocalHadArea * CaloLocalHadCoeff::getArea ( int n_area) const

return area

Definition at line 201 of file CaloLocalHadCoeff.cxx.

202{
203 if(n_area >= 0 && n_area<(int)m_AreaSet.size() ) {
204 return &(m_AreaSet[n_area]);
205 } else {
206 return nullptr;
207 }
208}

◆ getAreaFromBin() [1/2]

const CaloLocalHadCoeff::LocalHadArea * CaloLocalHadCoeff::getAreaFromBin ( int iBin) const

return area defined for given general iBin

Definition at line 211 of file CaloLocalHadCoeff.cxx.

212{
213 int i_area = 0;
214 int narea = m_AreaSet.size();
215 for(i_area=0; i_area<narea; i_area++) {
216 if( iBin < m_AreaSet[i_area].getOffset() ) break;
217 if( iBin >= m_AreaSet[i_area].getOffset()
218 && (i_area == narea-1 || iBin < m_AreaSet[i_area+1].getOffset()) ) break;
219 }
220 return &(m_AreaSet[i_area]);
221}
void getOffset(boost::tokenizer< boost::char_separator< char > >::iterator &token, uint32_t &offset)

◆ getAreaFromBin() [2/2]

const CaloLocalHadCoeff::LocalHadArea * CaloLocalHadCoeff::getAreaFromBin ( int iBin,
int & i_area ) const

return area (and area index) defined for given general iBin

Definition at line 224 of file CaloLocalHadCoeff.cxx.

225{
226 i_area = 0;
227 int narea = m_AreaSet.size();
228 for(i_area=0; i_area<narea; i_area++) {
229 if( iBin < m_AreaSet[i_area].getOffset() ) break;
230 if( iBin >= m_AreaSet[i_area].getOffset()
231 && (i_area == narea-1 || iBin < m_AreaSet[i_area+1].getOffset()) ) break;
232 }
233 return &(m_AreaSet[i_area]);
234}

◆ getBin() [1/2]

int CaloLocalHadCoeff::getBin ( const int n_area,
std::vector< float > & vars ) const

calculate general bin from vector of input cluster variables

Definition at line 273 of file CaloLocalHadCoeff.cxx.

274{
275 const LocalHadArea *area = &m_AreaSet[n_area];
276 // loop over dimensions
277 int iBin = area->getOffset();
278 for(int i_dim=0; i_dim<area->getNdim(); i_dim++){
279 int i_bin_dim = area->getDimension(i_dim)->getBin( vars[i_dim] );
280 if(i_bin_dim < 0) return -1;
281 iBin += i_bin_dim*area->getDimLoc(i_dim);
282 }
283 return iBin;
284}
double area(double R)

◆ getBin() [2/2]

int CaloLocalHadCoeff::getBin ( const int n_area,
std::vector< int > & v_indexes ) const

calculate general bin from known bins in dimensions

Definition at line 288 of file CaloLocalHadCoeff.cxx.

289{
290 const LocalHadArea *area = &m_AreaSet[n_area];
291 // loop over dimensions
292 int iBin = area->getOffset();
293 for(int i_dim=0; i_dim<area->getNdim(); i_dim++){
294 if(v_indexes[i_dim] < 0) return -1;
295 iBin += v_indexes[i_dim]*area->getDimLoc(i_dim);
296 }
297 return iBin;
298}

◆ getCoeff() [1/2]

const CaloLocalHadCoeff::LocalHadCoeff * CaloLocalHadCoeff::getCoeff ( const int & iBin) const

get data for given general bin number

Definition at line 249 of file CaloLocalHadCoeff.cxx.

250{
251 if ( iBin >= 0 && iBin < (int)m_CoeffSet.size() ) {
252 return (& m_CoeffSet[iBin]);
253 }else{
254 return nullptr;
255 }
256}

◆ getCoeff() [2/2]

const CaloLocalHadCoeff::LocalHadCoeff * CaloLocalHadCoeff::getCoeff ( const int & n_area,
std::vector< float > & vars ) const

get data for given area and list of cluster variables

Definition at line 259 of file CaloLocalHadCoeff.cxx.

260{
261 int iBin = getBin(n_area, vars);
262 return getCoeff(iBin);
263}
const LocalHadCoeff * getCoeff(const int &iBin) const
get data for given general bin number
int getBin(const int n_area, std::vector< float > &vars) const
calculate general bin from vector of input cluster variables

◆ getInterpArrays()

bool CaloLocalHadCoeff::getInterpArrays ( const int n_area,
const std::vector< int > & dim,
std::vector< float > & x,
std::vector< double > & xadj,
std::vector< unsigned int > & gbin ) const

for interpolation, build the vector of relative x, and global bins for interpolated array for area n_area and list of dimensions (all in case dim is empty)

Definition at line 317 of file CaloLocalHadCoeff.cxx.

318 {
319 // sanity check
320 if(n_area<0 || n_area >= (int)m_AreaSet.size()) return false;
321 const LocalHadArea *area=&(m_AreaSet[n_area]);
322 if(dim.empty()) {
323 std::cout << "CaloLocalHadCoeff::getInterpArrays() -> Error! Empty dimension list" << std::endl;
324 return false;
325 }else if( (int)dim.size() > area->getNdim()) {
326 std::cout << "CaloLocalHadCoeff::getInterpArrays() -> Error! Vector of dimensions to interpolate exceed defined in area." << std::endl;
327 return false;
328 }
329 int ndim = dim.size();
330
331 if((int)x.size()!= area->getNdim()) {
332 std::cout<<"CaloLocalHadCoeff::getInterpArrays() -> Error! Wrong size of phase space point !!!"<<std::endl;
333 return false;
334 }
335
336 xadj.resize(ndim);
337 unsigned int ncorners = (1<<ndim);
338 gbin.resize(ncorners);
339
340 float xa;
341 int ibin, i;
342 unsigned int i_len;
343 std::vector<int> vTmp;
344 std::vector<int> vIdx(area->getNdim());
345 std::vector<std::vector<int> > vpW;
346 for(i=0; i<ndim; i++){
347 ibin = (area->getDimension(dim[i]))->getBinAdjusted(x[dim[i]],xa);
348 //if(xadj<0) printf("%d x:%6.3f xadj:%6.3f ibin:%d ibin+1:%d \n",i, x[i], xadj, ibin, ibin+1);
349 xadj[i] = xa;
350 vTmp.clear();
351 vTmp.push_back(ibin);
352 if(ibin< (area->getDimension(dim[i]))->getNbins()-1) vTmp.push_back(ibin+1);
353 else vTmp.push_back(ibin);
354 vpW.push_back(vTmp);
355 }
356 // fill the vIdx for dimensions we are not interpolating over
357 for(i=0; i<area->getNdim(); ++i){
358 if(std::find(dim.begin(),dim.end(),i) != dim.end()) continue;
359 vIdx[i] = area->getDimension(i)->getBin(x[i]);
360 }
361
362 // now find the global bin for all corners
363 //vTmp.clear();
364 //vTmp.resize(ndim);
365 for(i_len=0; i_len<ncorners; ++i_len){
366 for( i=0; i<ndim; i++){
367 //std::cout<<"Sec. idx: "<<int(i_len/int(pow(2,i)))%int(pow(2,i))<<std::endl;
368 if(i==0) vIdx[dim[i]] = vpW[i][i_len%2];
369 else vIdx[dim[i]] = vpW[i][int(i_len/int(pow(2,i)))%int(pow(2,i))];
370 //if(i==2) std::cout<< vTmp[i] <<" ";
371 //std::cout<< vTmp[i] <<" ";
372 }
373 // std::cout<<std::endl;
374 ibin = getBin(n_area,vIdx);
375 gbin[i_len] = ibin;
376 }
377 return true;
378}
#define x
constexpr int pow(int base, int exp) noexcept

◆ getSizeAreaSet()

int CaloLocalHadCoeff::getSizeAreaSet ( ) const
inline

return number of areas defined for this data set

Definition at line 248 of file CaloLocalHadCoeff.h.

248{ return (int)m_AreaSet.size(); }

◆ getSizeCoeffSet()

int CaloLocalHadCoeff::getSizeCoeffSet ( ) const
inline

return total number of coefficient sets

Definition at line 269 of file CaloLocalHadCoeff.h.

269{ return (int)m_CoeffSet.size(); }

◆ getTitle()

const std::string & CaloLocalHadCoeff::getTitle ( ) const
inline

return name

Definition at line 239 of file CaloLocalHadCoeff.h.

239{return m_title;}
std::string m_title
title of data set

◆ isFilled()

bool CaloLocalHadCoeff::isFilled ( const int iBin) const

check if general bin is filled

Definition at line 97 of file CaloLocalHadCoeff.cxx.

98{
99 if( bin<0 || bin >= (int)m_CoeffSet.size() ) {
100 return false;
101 }
102 switch(getAreaFromBin(bin)->getType()) {
105 return m_CoeffSet[bin][ient] != 0;
106 }
108 return m_CoeffSet[bin][CaloLocalHadDefs::BIN_P0] != 0 ||
109
111
113 }
115 bool bf=false;
116 for(unsigned int i=0; i<m_CoeffSet[bin].size(); ++i) if(m_CoeffSet[bin][i] != 0) bf=true;
117 return bf;
118 }
119 default:{
120 std::cout<<"CaloLocalHadCoeff::isFilled() -> Error! Unknown area typ: "<<getAreaFromBin(bin)->getType()<<" in isFilled !!"<<std::endl;
121 return false;
122 }
123 }
124 // should not come here, but syntax need it:
125 return false;
126}
unsigned int getType() const
return area type
T getType(const char *cStr)
Return Ringer enumeration of type T identifying string type:

◆ isNeighbour()

bool CaloLocalHadCoeff::isNeighbour ( const int iBinx,
std::vector< int > & v_indx ) const

are this bins is neighbour to this indexes vector (any of their indexes differ per one ?)

Definition at line 80 of file CaloLocalHadCoeff.cxx.

80 {
81 // Sanity check
82 if(iBinx < 0 || iBinx >= (int) m_CoeffSet.size()) return false;
83 if((int)v_indx.size() != getAreaFromBin(iBinx)->getNdim()) {
84 std::cout<<"CaloLocalHadCoeff::LocalHadDimension::getBinAdjusted() -> Error! Wrong indexes vector size in isNeighbour: "<< v_indx.size()<<std::endl;
85 return false;
86 }
87 std::vector<int> xidx;
88 bin2indexes(iBinx, xidx);
89 for(unsigned int i=0; i<xidx.size(); ++i) {
90 if(abs(v_indx[i]-xidx[i]) == 1) return true;
91 }
92 return false;
93}
int bin2indexes(const int iBin, std::vector< int > &v_dim_indx) const
expand general bin into vector of bins for defined dimensions

◆ operator=() [1/2]

CaloLocalHadCoeff & CaloLocalHadCoeff::operator= ( CaloLocalHadCoeff && )
defaultnoexcept

◆ operator=() [2/2]

CaloLocalHadCoeff & CaloLocalHadCoeff::operator= ( const CaloLocalHadCoeff & other)
default

◆ setArea()

void CaloLocalHadCoeff::setArea ( const int n_area,
const LocalHadArea & theArea )

replace existing area with another one

Definition at line 195 of file CaloLocalHadCoeff.cxx.

196{
197 m_AreaSet[n_area] = theArea;
198}

◆ setCoeff()

void CaloLocalHadCoeff::setCoeff ( const int iBin,
const LocalHadCoeff & theCoeff )

set new data

Definition at line 243 of file CaloLocalHadCoeff.cxx.

244{
245 m_CoeffSet[iBin] = theCoeff;
246}

◆ setTitle()

void CaloLocalHadCoeff::setTitle ( const std::string & title)
inline

set name

Definition at line 242 of file CaloLocalHadCoeff.h.

Member Data Documentation

◆ m_AreaSet

std::vector<LocalHadArea> CaloLocalHadCoeff::m_AreaSet
private

vector of correction areas

Definition at line 312 of file CaloLocalHadCoeff.h.

◆ m_CoeffSet

std::vector<LocalHadCoeff> CaloLocalHadCoeff::m_CoeffSet
private

vector of correction coefficients

Definition at line 309 of file CaloLocalHadCoeff.h.

◆ m_title

std::string CaloLocalHadCoeff::m_title
private

title of data set

Definition at line 306 of file CaloLocalHadCoeff.h.


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