CMS 3D CMS Logo

Functions
EcalFunctionParametersUtils.h File Reference
#include "TH2F.h"
#include <string>
#include <cmath>

Go to the source code of this file.

Functions

int countEmptyRows (std::vector< float > &vec)
 
void fillFunctionParamsValues (TH2F *&align, std::vector< float > &m_params, std::string title, int &gridRows, int &NbColumns)
 

Function Documentation

◆ countEmptyRows()

int countEmptyRows ( std::vector< float > &  vec)

Definition at line 5 of file EcalFunctionParametersUtils.h.

5  {
6  int cnt = 0;
7  for (std::vector<float>::const_iterator it = vec.begin(); it != vec.end(); it++)
8  if ((*it) == 0.0f)
9  cnt++;
10 
11  return cnt;
12 }

Referenced by fillFunctionParamsValues().

◆ fillFunctionParamsValues()

void fillFunctionParamsValues ( TH2F *&  align,
std::vector< float > &  m_params,
std::string  title,
int &  gridRows,
int &  NbColumns 
)

Definition at line 14 of file EcalFunctionParametersUtils.h.

15  {
16  const int maxInCol = 25;
17  int NbRows = 0;
18 
19  NbRows = m_params.size() - countEmptyRows(m_params);
20 
21  gridRows = (NbRows <= maxInCol) ? NbRows : maxInCol;
22  NbColumns = ceil(1.0 * NbRows / maxInCol) + 1;
23 
24  //char *y = new char[text[s].length() + 1];
25  //std::strcpy(y, text[s].c_str());
26 
27  align = new TH2F(title.c_str(), "Ecal Function Parameters", NbColumns, 0, NbColumns, gridRows, 0, gridRows);
28 
29  double row = gridRows - 0.5;
30  double column = 1.5;
31  int cnt = 0;
32 
33  for (int i = 0; i < gridRows; i++) {
34  align->Fill(0.5, gridRows - i - 0.5, i + 1);
35  }
36 
37  for (std::vector<float>::const_iterator it = m_params.begin(); it != m_params.end(); it++) {
38  if ((*it) == 0.0f)
39  continue;
40  align->Fill(column, row, *it);
41 
42  cnt++;
43  column = floor(1.0 * cnt / maxInCol) + 1.5;
44  row = (row == 0.5 ? (gridRows - 0.5) : row - 1);
45  }
46 }

References reco::ceil(), countEmptyRows(), mps_fire::i, and runGCPTkAlMap::title.

runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
align
Definition: AlignableIndexer.h:30
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
countEmptyRows
int countEmptyRows(std::vector< float > &vec)
Definition: EcalFunctionParametersUtils.h:5