Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:46:02

0001 #include "TH2F.h"
0002 #include <string>
0003 #include <cmath>
0004 
0005 inline int countEmptyRows(std::vector<float>& vec) {
0006   int cnt = 0;
0007   for (std::vector<float>::const_iterator it = vec.begin(); it != vec.end(); it++)
0008     if ((*it) == 0.0f)
0009       cnt++;
0010 
0011   return cnt;
0012 }
0013 
0014 inline void fillFunctionParamsValues(
0015     TH2F*& align, std::vector<float>& m_params, std::string title, int& gridRows, int& NbColumns) {
0016   const int maxInCol = 25;
0017   int NbRows = 0;
0018 
0019   NbRows = m_params.size() - countEmptyRows(m_params);
0020 
0021   gridRows = (NbRows <= maxInCol) ? NbRows : maxInCol;
0022   NbColumns = ceil(1.0 * NbRows / maxInCol) + 1;
0023 
0024   //char *y = new char[text[s].length() + 1];
0025   //std::strcpy(y, text[s].c_str());
0026 
0027   align = new TH2F(title.c_str(), "Ecal Function Parameters", NbColumns, 0, NbColumns, gridRows, 0, gridRows);
0028 
0029   double row = gridRows - 0.5;
0030   double column = 1.5;
0031   int cnt = 0;
0032 
0033   for (int i = 0; i < gridRows; i++) {
0034     align->Fill(0.5, gridRows - i - 0.5, i + 1);
0035   }
0036 
0037   for (std::vector<float>::const_iterator it = m_params.begin(); it != m_params.end(); it++) {
0038     if ((*it) == 0.0f)
0039       continue;
0040     align->Fill(column, row, *it);
0041 
0042     cnt++;
0043     column = floor(1.0 * cnt / maxInCol) + 1.5;
0044     row = (row == 0.5 ? (gridRows - 0.5) : row - 1);
0045   }
0046 }