CMS 3D CMS Logo

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