CbmRoot
Loading...
Searching...
No Matches
CbmFlesHistosTools.cxx
Go to the documentation of this file.
1/* Copyright (C) 2020 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer], Florian Uhlig */
4
6
7#include <cmath>
8//#include <vector>
9
10std::vector<double> GenerateLogBinArray(uint32_t uNbDecadesLog, uint32_t uNbStepsDecade, uint32_t uNbSubStepsInStep,
11 uint32_t& uNbBinsLog, int32_t iStartExp, bool bAddZeroStart)
12{
18 uNbBinsLog = uNbStepsDecade + uNbStepsDecade * uNbSubStepsInStep * uNbDecadesLog;
19
21 uint32_t uArrayLength = uNbBinsLog + 1;
22 double dBinsLog[uArrayLength];
24 for (uint32_t uSubU = 0; uSubU < uNbStepsDecade; uSubU++) {
25 dBinsLog[uSubU] = std::pow(10, iStartExp - 1) * (1 + uSubU);
26 }
27
29 double dSubstepSize = 1.0 / uNbSubStepsInStep;
30 for (uint32_t uDecade = 0; uDecade < uNbDecadesLog; uDecade++) {
31 double dBase = std::pow(10, iStartExp + static_cast<int32_t>(uDecade));
32 uint32_t uDecadeIdx = uNbStepsDecade + uDecade * uNbStepsDecade * uNbSubStepsInStep;
33 for (uint32_t uStep = 0; uStep < uNbStepsDecade; uStep++) {
34 uint32_t uStepIdx = uDecadeIdx + uStep * uNbSubStepsInStep;
35 for (uint32_t uSubStep = 0; uSubStep < uNbSubStepsInStep; uSubStep++) {
36 dBinsLog[uStepIdx + uSubStep] = dBase * (1 + uStep) + dBase * dSubstepSize * uSubStep;
37 } // for( uint32_t uSubStep = 0; uSubStep < uNbSubStepsInStep; uSubStep++ )
38 } // for( uint32_t uStep = 0; uStep < uNbStepsDecade; uStep++ )
39 } // for( uint32_t uDecade = 0; uDecade < uNbDecadesLog; uDecade ++)
40 dBinsLog[uNbBinsLog] = std::pow(10, iStartExp + uNbDecadesLog);
41
43 std::vector<double> dBinsLogVect;
44
46 if (bAddZeroStart) {
47 uNbBinsLog++;
48 dBinsLogVect.push_back(0);
49 }
50
51 for (uint32_t i = 0; i < uArrayLength; ++i) {
52 dBinsLogVect.push_back(dBinsLog[i]);
53 } // for( uint32_t i = 0; i < uArrayLength; ++i )
54
55 return dBinsLogVect;
56}
std::vector< double > GenerateLogBinArray(uint32_t uNbDecadesLog, uint32_t uNbStepsDecade, uint32_t uNbSubStepsInStep, uint32_t &uNbBinsLog, int32_t iStartExp, bool bAddZeroStart)