ATLAS Offline Software
CaloHadDMCoeff.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <iostream>
8 
10 = default;
11 
12 
14 
15 
16 = default;
17 
18 
20 {
21  if (this != &other) {
22  m_DMCoeffSet = other.m_DMCoeffSet;
23  m_DMAreaSet = other.m_DMAreaSet;
24  }
25  return *this;
26 }
27 
28 
29 const CaloHadDMCoeff::HadDMCoeff * CaloHadDMCoeff::getHadDMCoeff(const int & n_area, const float & cls_emfrac, const float & cls_ener, const float & cls_eta) const
30 {
31  int iBin = getBin(n_area, cls_emfrac, cls_ener, cls_eta);
32  return getHadDMCoeff(iBin);
33 }
34 
35 
37 {
38  if(n_area >= 0 && n_area<(int)m_DMAreaSet.size() ) {
39  return &(m_DMAreaSet[n_area]);
40  } else {
41  return nullptr;
42  }
43 }
44 
45 
47 {
48  m_DMCoeffSet.push_back(theData);
49 }
50 
51 
52 void CaloHadDMCoeff::setHadDMCoeff(const int iBin, const HadDMCoeff & theData)
53 {
54  m_DMCoeffSet[iBin] = theData;
55 }
56 
57 
59 {
60  m_DMAreaSet.push_back(theArea);
61 }
62 
63 
64 void CaloHadDMCoeff::setHadDMArea(const int n_area, const HadDMArea & theArea)
65 {
66  m_DMAreaSet[n_area] = theArea;
67 }
68 
69 
70 /* *****************************************************************************
71 get EM fraction bin
72 ***************************************************************************** */
73 int CaloHadDMCoeff::getBinFrac(const int n_area, const float & cls_emfrac) const
74 {
75  const HadDMArea *dmArea = &m_DMAreaSet[n_area];
76  if(cls_emfrac < dmArea->m_MinFrac || cls_emfrac >= dmArea->m_MaxFrac) return -1;
77  int ifrac;
78  int nfrac = dmArea->m_FracBins.size();
79  for (ifrac=0; ifrac<nfrac; ifrac++) {
80  if( cls_emfrac < dmArea->m_FracBins[ifrac] ) break;
81  if( cls_emfrac >= dmArea->m_FracBins[ifrac] && (ifrac == nfrac-1 || cls_emfrac < dmArea->m_FracBins[ifrac+1]) ) break;
82  }
83  return ifrac;
84 }
85 
86 
87 /* *****************************************************************************
88 To get energy bin
89 ***************************************************************************** */
90 int CaloHadDMCoeff::getBinEner(const int n_area, const float & cls_ener) const
91 {
92  const HadDMArea *dmArea = &m_DMAreaSet[n_area];
93  if(cls_ener < dmArea->m_MinEner || cls_ener >= dmArea->m_MaxEner) return (-1);
94  int iener;
95  int nener = (int)dmArea->m_EnerBins.size();
96  for (iener=0; iener<nener; iener++) {
97  if( cls_ener < dmArea->m_EnerBins[iener] ) break;
98  if( cls_ener >= dmArea->m_EnerBins[iener] && (iener == nener-1 || cls_ener < dmArea->m_EnerBins[iener+1]) ) break;
99  }
100  return iener;
101 }
102 
103 
104 /* *****************************************************************************
105 get eta bin
106 ***************************************************************************** */
107 int CaloHadDMCoeff::getBinEta(const int n_area, const float & cls_eta) const
108 {
109  const HadDMArea *dmArea = &m_DMAreaSet[n_area];
110  if(cls_eta < dmArea->m_MinEta || cls_eta >= dmArea->m_MaxEta) return (-1);
111  int neta = (int)dmArea->m_EtaBins.size();
112  int ieta = (int)((cls_eta - dmArea->m_MinEta)/(dmArea->m_MaxEta - dmArea->m_MinEta)*neta);
113  return ieta;
114 }
115 
116 
117 /* *****************************************************************************
118 get common bin
119 ***************************************************************************** */
120 int CaloHadDMCoeff::getBin(const int & n_dm_area, const float & cls_emfrac, const float & cls_ener, const float & cls_eta) const
121 {
122  if(n_dm_area < 0 || n_dm_area >= (int)m_DMAreaSet.size()) {
123  std::cout << " WARNING CaloHadDMCoeff::getBin -> wrong n_area: " << n_dm_area << std::endl;
124  return (-1);
125  }
126  int ifrac = getBinFrac(n_dm_area, cls_emfrac);
127  int iener = getBinEner(n_dm_area, cls_ener);
128  int ieta = getBinEta(n_dm_area, cls_eta);
129  int iBin = getBin(n_dm_area, ifrac, iener, ieta);
130  return iBin;
131 }
132 
133 
134 int CaloHadDMCoeff::getBin(const int & n_dm_area, const int & ifrac, const int & iener, const int & ieta) const
135 {
136  const HadDMArea *dmArea = &m_DMAreaSet[n_dm_area];
137  int iBin = -1;
138  if(ifrac!=-1 && iener !=-1 && ieta!=-1) {
139  iBin = ieta + iener*(int)dmArea->m_EtaBins.size() + ifrac*(int)dmArea->m_EnerBins.size()*(int)dmArea->m_EtaBins.size() + dmArea->m_offset;
140  }
141  return iBin;
142 }
143 
144 
146 {
147 
148  const char *comments={
149  "# Coeffs for Dead Material corrections in CaloClusterLocalCalib algorithm.\n"
150  "# Author: Guennadi Pospelov <pospelov@mppmu.mpg.de>\n"
151  "#\n"
152  "#\n"
153  "# dm_id is_ON dm_title\n"
154  "# nFrac FracMin FracMax\n"
155  "# nEner EnerMin EnerMax\n"
156  "# nEta EtaMin EtaMax\n"
157  "# Npars\n"
158  "# indx ifrac iener ieta frac ener eta pars[]\n"
159  "#\n\n"};
160  fprintf(fout,"%s",comments);
161  int indx = 0;
162  for(int i_zone=0; i_zone < (int)m_DMAreaSet.size(); i_zone++){
163  const HadDMArea *area = &m_DMAreaSet[i_zone];
164  fprintf(fout," %d %d %s\n",area->m_indx, area->m_is_on, area->m_title.data());
165  fprintf(fout,"%2d %6.3f %6.3f\n", (int)area->m_FracBins.size(), area->m_MinFrac, area->m_MaxFrac);
166  fprintf(fout,"%2d %6.3g %6.3g\n", (int)area->m_EnerBins.size(), area->m_MinEner, area->m_MaxEner);
167  fprintf(fout,"%2d %6.3f %6.3f\n", (int)area->m_EtaBins.size(), area->m_MinEta, area->m_MaxEta);
168  fprintf(fout,"%2d\n", area->m_nPars);
169  for(int i_frac=0; i_frac<(int)area->m_FracBins.size(); i_frac++){
170  for(int i_ener=0; i_ener<(int)area->m_EnerBins.size(); i_ener++){
171  for(int i_eta=0; i_eta<(int)area->m_EtaBins.size(); i_eta++){
172  float cls_emfrac = area->m_FracBins[i_frac];
173  float cls_ener = area->m_EnerBins[i_ener];
174  float cls_eta = area->m_EtaBins[i_eta]+0.01;
175  const HadDMCoeff *vv = getHadDMCoeff(i_zone, cls_emfrac, cls_ener, cls_eta);
176  fprintf(fout,"%4d %2d %2d %2d %6.3f %6.3g %6.3f ",
177  indx, i_frac,i_ener, i_eta, area->m_FracBins[i_frac], area->m_EnerBins[i_ener], area->m_EtaBins[i_eta]);
178  for(int i_par=0; i_par<area->m_nPars; i_par++){
179  if(area->m_indx!=10) {
180  fprintf(fout,"%10.4f ",(*vv)[i_par]);
181  } else{
182  fprintf(fout,"%10.7f ",(*vv)[i_par]);
183  }
184  } // i_par
185  indx++;
186  fprintf(fout,"\n");
187  } // i_eta
188  } // i_ener
189  } // i_frac
190  fprintf(fout,"\n");
191  }
192 }
CaloHadDMCoeff::HadDMArea::m_MaxEta
float m_MaxEta
Definition: CaloHadDMCoeff.h:36
CaloHadDMCoeff::m_DMAreaSet
std::vector< HadDMArea > m_DMAreaSet
Definition: CaloHadDMCoeff.h:78
WriteBchToCool.comments
comments
Definition: WriteBchToCool.py:297
CaloHadDMCoeff::addHadDMArea
void addHadDMArea(const HadDMArea &theArea)
Definition: CaloHadDMCoeff.cxx:58
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloHadDMCoeff::getBinFrac
int getBinFrac(const int dm_area, const float &cls_frac) const
Definition: CaloHadDMCoeff.cxx:73
CaloHadDMCoeff::HadDMArea::m_FracBins
std::vector< float > m_FracBins
Definition: CaloHadDMCoeff.h:31
CaloHadDMCoeff::HadDMArea::m_MaxEner
float m_MaxEner
Definition: CaloHadDMCoeff.h:33
CaloHadDMCoeff::getHadDMArea
const HadDMArea * getHadDMArea(int n_area) const
Definition: CaloHadDMCoeff.cxx:36
CaloHadDMCoeff::HadDMCoeff
std::vector< float > HadDMCoeff
Definition: CaloHadDMCoeff.h:44
CaloHadDMCoeff::HadDMArea::m_EnerBins
std::vector< float > m_EnerBins
Definition: CaloHadDMCoeff.h:34
CaloHadDMCoeff::getBinEner
int getBinEner(const int dm_area, const float &cls_ener) const
Definition: CaloHadDMCoeff.cxx:90
CaloHadDMCoeff::HadDMArea::m_MinEta
float m_MinEta
Definition: CaloHadDMCoeff.h:35
CaloHadDMCoeff::m_DMCoeffSet
std::vector< HadDMCoeff > m_DMCoeffSet
Definition: CaloHadDMCoeff.h:77
CaloHadDMCoeff::setHadDMCoeff
void setHadDMCoeff(const int iBin, const HadDMCoeff &theData)
Definition: CaloHadDMCoeff.cxx:52
CaloHadDMCoeff::getHadDMCoeff
const HadDMCoeff * getHadDMCoeff(const int &dm_area, const float &cls_emfrac, const float &cls_ener, const float &cls_eta) const
Definition: CaloHadDMCoeff.cxx:29
CaloHadDMCoeff::addHadDMCoeff
void addHadDMCoeff(const HadDMCoeff &theData)
Definition: CaloHadDMCoeff.cxx:46
CaloHadDMCoeff::HadDMArea::m_offset
int m_offset
Definition: CaloHadDMCoeff.h:39
dqt_zlumi_alleff_HIST.fout
fout
Definition: dqt_zlumi_alleff_HIST.py:59
CaloHadDMCoeff::HadDMArea::m_EtaBins
std::vector< float > m_EtaBins
Definition: CaloHadDMCoeff.h:37
CaloHadDMCoeff::HadDMArea
Definition: CaloHadDMCoeff.h:25
CaloHadDMCoeff::CaloHadDMCoeff
CaloHadDMCoeff()
Default Constructor.
CaloHadDMCoeff::getBinEta
int getBinEta(const int dm_area, const float &cls_eta) const
Definition: CaloHadDMCoeff.cxx:107
CaloHadDMCoeff::operator=
CaloHadDMCoeff & operator=(const CaloHadDMCoeff &other)
Definition: CaloHadDMCoeff.cxx:19
CaloHadDMCoeff::getBin
int getBin(const int &n_dm_area, const float &cls_frac, const float &cls_ener, const float &cls_eta) const
Definition: CaloHadDMCoeff.cxx:120
CaloHadDMCoeff
Definition: CaloHadDMCoeff.h:23
CaloHadDMCoeff::PrintData
void PrintData(FILE *fout=stdout) const
Definition: CaloHadDMCoeff.cxx:145
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
area
double area(double R)
Definition: ConvertStaveServices.cxx:42
CaloHadDMCoeff::setHadDMArea
void setHadDMArea(const int n_area, const HadDMArea &theArea)
Definition: CaloHadDMCoeff.cxx:64
PlotCalibFromCool.vv
vv
Definition: PlotCalibFromCool.py:716
CaloHadDMCoeff::HadDMArea::m_MaxFrac
float m_MaxFrac
Definition: CaloHadDMCoeff.h:30
CaloHadDMCoeff.h