#include <CaloLCCoeffHelper.h>
Definition at line 15 of file CaloLCCoeffHelper.h.
◆ CaloLCCoeffHelper()
CaloLCCoeffHelper::CaloLCCoeffHelper |
( |
| ) |
|
|
default |
◆ ~CaloLCCoeffHelper()
CaloLCCoeffHelper::~CaloLCCoeffHelper |
( |
| ) |
|
|
virtualdefault |
◆ getAreaFromName()
Definition at line 39 of file CaloLCCoeffHelper.cxx.
41 for(
int i_area=0; i_area<
coeff->getSizeAreaSet(); i_area++) {
42 if(sname ==
coeff->getArea(i_area)->getTitle()) {
44 return coeff->getArea(i_area);
47 std::cout <<
"CaloLCCoeffHelper::getAreaFromName() -> Error! No such area '" << sname <<
"'" << std::endl;
◆ getDimensionId()
Definition at line 32 of file CaloLCCoeffHelper.h.
34 if(dimensionName ==
"DIMC_SIDE") {
36 }
else if(dimensionName ==
"DIMC_ETA") {
38 }
else if(dimensionName ==
"DIMC_PHI") {
40 }
else if(dimensionName ==
"DIMC_ENER") {
42 }
else if(dimensionName ==
"DIMC_EDENS") {
44 }
else if(dimensionName ==
"DIMC_LAMBDA") {
47 }
else if(dimensionName ==
"DIMW_SIDE") {
49 }
else if(dimensionName ==
"DIMW_ETA") {
51 }
else if(dimensionName ==
"DIMW_PHI") {
53 }
else if(dimensionName ==
"DIMW_ENER") {
55 }
else if(dimensionName ==
"DIMW_EDENS") {
58 }
else if(dimensionName ==
"DIMO_SIDE") {
60 }
else if(dimensionName ==
"DIMO_PHI") {
62 }
else if(dimensionName ==
"DIMO_ENER") {
64 }
else if(dimensionName ==
"DIMO_ETA") {
66 }
else if(dimensionName ==
"DIMO_LAMBDA") {
69 }
else if(dimensionName ==
"DIMD_EMFRAC") {
71 }
else if(dimensionName ==
"DIMD_SIDE") {
73 }
else if(dimensionName ==
"DIMD_ETA") {
75 }
else if(dimensionName ==
"DIMD_PHI") {
77 }
else if(dimensionName ==
"DIMD_ENER") {
79 }
else if(dimensionName ==
"DIMD_LAMBDA") {
◆ InitDataFromFile()
Definition at line 56 of file CaloLCCoeffHelper.cxx.
58 std::optional<CaloLocalHadCoeff>
data=std::make_optional<CaloLocalHadCoeff>();
63 std::cout <<
"CaloLCCoeffHelper::InitDataFromFile - Reading file '" <<
filename <<
"'." << std::endl;
67 std::cout <<
"CaloLCCoeffHelper::InitDataFromFile - Can't open file '" <<
filename <<
"'." << std::endl;
72 std::istringstream ist;
73 while(
fin.getline(cLine,
sizeof(cLine)-1)) {
74 if( strlen(cLine)==0 || cLine[0] ==
'#' || cLine[0] ==
'\n')
continue;
78 ist.clear(); ist.str(sLine);
79 std::string sdummy, area_title;
80 int area_indx(0), area_type(0), area_npars(0);
81 if( !(ist >> sdummy >> area_indx >> area_title >> area_type >> area_npars) ) {
82 std::cout <<
"CaloLCCoeffHelper::initDataFromFile() -> Error! Could not parse line '" << cLine <<
"' at p1." << std::endl;
89 while(
fin.getline(cLine,
sizeof(cLine)-1)){
90 if( cLine[0] ==
'#')
continue;
92 if(sLine.find(
"break") != std::string::npos) {
97 std::cout <<
"CaloLCCoeffHelper::initDataFromFile() ->Error! Could not parse line '" << sLine <<
"' at p2a." << std::endl;
100 theArea.addDimension(*
dim);
102 data->addArea(theArea);
105 for(
int i_len=0; i_len<theArea.getLength(); i_len++){
106 if(!
fin.getline(cLine,
sizeof(cLine)-1)) {
107 std::cout <<
"panic " << std::endl;
111 ist.clear(); ist.str(sLine);
113 if( !(ist >> idummy) ) {
114 std::cout <<
"CaloLCCoeffHelper::initDataFromFile() -> Warning! Area " << theArea.getTitle() <<
" doesn't have parameters." << std::endl;
117 if(idummy != theArea.getOffset()+i_len){
118 std::cout <<
"CaloLCCoeffHelper::initDataFromFile() ->Error! Could not parse line '" << cLine <<
"' at p3." << std::endl;
121 for(
int j=0; j<theArea.getNdim(); j++) {
122 if(!(ist >> idummy)) {
123 std::cout <<
"CaloLCCoeffHelper::initDataFromFile() -> panic!" << std::endl;
128 pars.resize(theArea.getNpars(),0.0);
129 for(
int j=0; j<theArea.getNpars(); j++) {
130 if( !(ist >>
pars[j]) ) {
131 std::cout <<
"CaloLCCoeffHelper::initDataFromFile() ->Error! Could not parse line '" << cLine <<
"' at p4." << std::endl;
132 std::cout <<
" dmArea.m_title" << theArea.getTitle() << std::endl;
136 data->setCoeff(theArea.getOffset()+i_len,
pars);
◆ Interpolate()
Definition at line 230 of file CaloLCCoeffHelper.cxx.
235 if( n_area >= (
unsigned int)
data->getSizeAreaSet())
return false;
237 if(!
data->isFilled(
data->getBin(n_area,
x))) {
244 std::cout <<
"CaloLCCoeffHelper::Interpolate() -> Error! Empty vector of dimensions to interpolate trough." << std::endl;
246 }
else if ( (
int)
dim.size() >
area->getNdim()){
247 std::cout <<
"CaloLCCoeffHelper::Interpolate() -> Error! Vector of dimensions to interpolate exceed defined in area." << std::endl;
249 }
else ndim=
dim.size();
250 unsigned int ncorners = (1<<ndim);
252 std::vector<double > vXadj(ndim);
253 std::vector<unsigned int > vgbins(ncorners);
254 std::vector<double > vWeights(ncorners);
255 std::vector<int> ebindx;
259 switch (
area->getType()) {
261 nip =
data->getCoeff(
area->getOffset()+1)->size();
265 nip =
data->getCoeff(
area->getOffset()+1)->size();
268 for(
unsigned int ip=0;
ip<nip; ++
ip) {
269 bool isa =
data->getInterpArrays(n_area,
dim,
x,vXadj,vgbins);
271 std::cout<<
"No arrays for x: ";
272 for(
unsigned int l=0;
l<
x.size(); ++
l) std::cout<<
x[
l]<<
" ";
273 std::cout<<std::endl;
276 for(
unsigned int i_len=0; i_len<ncorners; ++i_len){
278 if(
data->isFilled(vgbins[i_len])) {
280 data->getCoeff(vgbins[i_len]);
283 vWeights[i_len] = (*lpars)[0] + (*lpars)[1]*
pow(xfit,(*lpars)[2]);
285 vWeights[i_len] = (*lpars)[
ip];
291 vWeights[i_len] = 0.;
292 unsigned int icount = 0;
293 data->bin2indexes(vgbins[i_len],ebindx);
296 for(
unsigned int blen=0; blen<ncorners; ++blen){
297 if(blen == i_len)
continue;
298 if(!
data->isFilled(vgbins[blen])){
299 data->bin2indexes(vgbins[i_len],
bx);
304 if(
data->isNeighbour(vgbins[blen], ebindx)) {
306 data->getCoeff(vgbins[blen]);
308 vWeights[i_len] = (*lpars)[0] + (*lpars)[1]*
pow(xfit,(*lpars)[2]);
310 vWeights[i_len] += (*lpars)[
ip];
317 vWeights[i_len] /= icount;
328 std::cout<<
"Not implemented yet for this Area type !!!"<<std::endl;
◆ parse_dim()
Definition at line 341 of file CaloLCCoeffHelper.cxx.
343 std::optional<CaloLocalHadCoeff::LocalHadDimension>
dim{std::nullopt};
344 std::istringstream ist(sLine.c_str());
346 std::string dim_title;
348 int dim_nbins(0), dim_type(0);
349 float dim_xmax(0), dim_xmin(0);
351 if( !(ist >> dim_title >> dim_nbins >> dim_xmin >> dim_xmax >> stype) ){
352 std::cout <<
"CaloHadDMCoeffHelper::parse_dim() -> Error! Could not parse line '" << sLine <<
"' at p1." << std::endl;
359 else if (dim_nbins > 10000)
362 if(stype.find(
"flat") != std::string::npos) {
364 dim.emplace(dim_title.c_str(), dim_type, dim_nbins, dim_xmin, dim_xmax);
365 }
else if(stype.find(
"hand") != std::string::npos) {
367 std::vector<float> x_bins;
369 for(
int i=0;
i<dim_nbins+1;
i++) {
371 std::cout <<
"CaloHadDMCoeffHelper::parse_dim() -> Error! Could not parse line '" << sLine <<
"' at p2." << std::endl;
377 dim.emplace(dim_title.c_str(), dim_type, x_bins);
379 std::cout <<
"CaloHadDMCoeffHelper::parse_dim() -> Error! Could not parse line '" << sLine <<
"' at p3." << std::endl;
◆ PrintData() [1/2]
◆ PrintData() [2/2]
void CaloLCCoeffHelper::PrintData |
( |
CaloLocalHadCoeff * |
m_data, |
|
|
std::ostream & |
fout |
|
) |
| |
|
static |
Definition at line 162 of file CaloLCCoeffHelper.cxx.
164 boost::io::ios_base_all_saver ifs (
fout);
167 "# Coefficients for local hadronic calibration .\n\n"
173 for(
int i_area=0; i_area <
data->getSizeAreaSet(); i_area++){
175 fout <<
"area " << i_area <<
" " <<
area->getTitle() <<
" " <<
area->getType() <<
" " <<
area->getNpars() << std::endl;
176 for(
int i_dim=0; i_dim<
area->getNdim(); i_dim++){
179 "%-6s %2d %6.3f %12.3f ",
dim->getTitle().c_str(),
dim->getNbins(),
dim->getXmin(),
dim->getXmax() );
180 std::string sline(
line);
195 fout <<
"break" << std::endl;
198 for(
int i_data=0; i_data<
area->getLength(); i_data++) {
199 int indx =
area->getOffset() + i_data;
202 std::cout <<
"CaloLCCoeffHelper::PrintData() -> Error! Wrong bin number" << std::endl;
205 fout << std::setw(5) << indx <<
" ";
206 std::vector<int > v_dim_indexes;
207 data->bin2indexes(indx, v_dim_indexes);
208 for(
unsigned int i_dim=0; i_dim<v_dim_indexes.size(); i_dim++){
209 fout << std::setw(4) << v_dim_indexes[i_dim] <<
" ";
212 for(
unsigned int i_par=0; i_par<(*pars).size(); i_par++) {
213 fout << std::fixed << std::setprecision(6) << std::setw(12) << (*pars)[i_par] <<
" ";
The documentation for this class was generated from the following files: