MuonAnalysis
MomentumScaleCalibration
src
BackgroundFunction.cc
Go to the documentation of this file.
1
#include "
MuonAnalysis/MomentumScaleCalibration/interface/BackgroundFunction.h
"
2
3
void
BackgroundFunction::readParameters
(TString
fileName
) {
4
iterationNum_
= 0;
5
parArray_
=
nullptr
;
6
// std::vector<double> parameterErrors;
7
8
// Read the parameters file
9
std::ifstream parametersFile(
fileName
.Data());
10
std::string
line
;
11
12
std::string
iteration
(
"Iteration "
);
13
// Loop on the file lines
14
while
(parametersFile) {
15
getline(parametersFile,
line
);
16
size_t
lineInt =
line
.find(
"value"
);
17
18
// if( line.find(iteration) != std::string::npos ) {
19
size_t
iterationSubStr =
line
.find(
iteration
);
20
21
// Take the iteration number
22
if
(iterationSubStr != std::string::npos) {
23
int
functionNum = 0;
24
// This can be used when dealing with multiple iterations
25
26
// std::cout << "line = " << line << std::endl;
27
std::stringstream sLine(
line
);
28
std::string
num
;
29
int
wordCounter = 0;
30
// Warning: this strongly depends on the parameters file structure.
31
while
(sLine >>
num
) {
32
++wordCounter;
33
// std::cout << "num["<<wordCounter<<"] = " << num << std::endl;
34
if
(wordCounter == 10) {
35
std::stringstream
in
(
num
);
36
in
>> functionNum;
37
}
38
if
(wordCounter == 13) {
39
std::stringstream
in
(
num
);
40
in
>>
iterationNum_
;
41
}
42
}
43
// std::cout << "iteration number = " << iterationNum_ << std::endl;
44
// std::cout << "scale function number = " << scaleFunctionNum << std::endl;
45
46
// // Create a new vector to hold the parameters for this iteration
47
// std::vector<double> parVec;
48
// parVecVec_.push_back(parVec);
49
50
// Set the scaleFunction
51
// scaleFunction_ = scaleFunctionArrayForVec[scaleFunctionNum];
52
// scaleFunction_ = scaleFunctionArray[scaleFunctionNum];
53
functionId_
.push_back(functionNum);
54
// scaleFunctionVec_.push_back( scaleFunctionArray[scaleFunctionNum] );
55
// TODO: fix the lower and upper limits of the function
56
backgroundFunctionVec_
.push_back(
backgroundFunctionService
(functionNum, 0., 200.));
57
}
58
// Take the parameters for the current iteration
59
if
((lineInt != std::string::npos)) {
60
size_t
subStr1 =
line
.find(
"value"
);
61
std::stringstream paramStr;
62
double
param = 0;
63
// Even if all the rest of the line is taken, the following
64
// convertion to a double will stop at the end of the first number.
65
paramStr <<
line
.substr(subStr1 + 5);
66
paramStr >> param;
67
// // Fill the last vector of parameters, which corresponds to this iteration.
68
// parVecVec_.back().push_back(param);
69
parVecVec_
.push_back(param);
70
// std::cout << "param = " << param << std::endl;
71
72
// This is to extract parameter errors
73
// size_t subStr2 = line.find("+-");
74
// std::stringstream parErrorStr;
75
// double parError = 0;
76
// parErrorStr << line.substr(subStr2+1);
77
// parErrorStr >> parError;
78
// parameterErrors.push_back(parError);
79
// std::cout << "parError = " << parError << std::endl;
80
}
81
}
82
83
convertToArrays
(
backgroundFunction_
,
backgroundFunctionVec_
);
84
}
BaseFunction::convertToArrays
void convertToArrays(T **&function_, const std::vector< T * > &functionVec_)
Convert vectors to arrays for faster random access. The first pointer is replaced,...
Definition:
BaseFunction.h:48
BackgroundFunction::backgroundFunction_
backgroundFunctionBase ** backgroundFunction_
Definition:
BackgroundFunction.h:71
MillePedeFileConverter_cfg.fileName
fileName
Definition:
MillePedeFileConverter_cfg.py:32
BackgroundFunction::readParameters
void readParameters(TString fileName)
Parser of the parameters file.
Definition:
BackgroundFunction.cc:3
BaseFunction::parVecVec_
std::vector< double > parVecVec_
Definition:
BaseFunction.h:39
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
BaseFunction::parArray_
double ** parArray_
Definition:
BaseFunction.h:42
backgroundFunctionService
backgroundFunctionBase * backgroundFunctionService(const int identifier, const double &lowerLimit, const double &upperLimit)
Service to build the background functor corresponding to the passed identifier.
Definition:
Functions.cc:114
recoMuon::in
Definition:
RecoMuonEnumerators.h:6
EgammaValidation_cff.num
num
Definition:
EgammaValidation_cff.py:34
BackgroundFunction::backgroundFunctionVec_
std::vector< backgroundFunctionBase * > backgroundFunctionVec_
Definition:
BackgroundFunction.h:72
BaseFunction::iterationNum_
int iterationNum_
Definition:
BaseFunction.h:44
BaseFunction::functionId_
std::vector< int > functionId_
Definition:
BaseFunction.h:38
mps_splice.line
line
Definition:
mps_splice.py:76
align_cfg.iteration
iteration
Definition:
align_cfg.py:5
BackgroundFunction.h
Generated for CMSSW Reference Manual by
1.8.16