CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BackgroundFunction.cc
Go to the documentation of this file.
2 
4 {
5  iterationNum_ = 0;
6  parArray_ = 0;
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 == 10 ) {
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  // TODO: fix the lower and upper limits of the function
58  backgroundFunctionVec_.push_back( backgroundFunctionService( functionNum, 0., 200. ) );
59  }
60  // Take the parameters for the current iteration
61  if ( (lineInt != std::string::npos) ) {
62  size_t subStr1 = line.find("value");
63  std::stringstream paramStr;
64  double param = 0;
65  // Even if all the rest of the line is taken, the following
66  // convertion to a double will stop at the end of the first number.
67  paramStr << line.substr(subStr1+5);
68  paramStr >> param;
69 // // Fill the last vector of parameters, which corresponds to this iteration.
70 // parVecVec_.back().push_back(param);
71  parVecVec_.push_back(param);
72  // std::cout << "param = " << param << std::endl;
73 
74  // This is to extract parameter errors
75  // size_t subStr2 = line.find("+-");
76  // std::stringstream parErrorStr;
77  // double parError = 0;
78  // parErrorStr << line.substr(subStr2+1);
79  // parErrorStr >> parError;
80  // parameterErrors.push_back(parError);
81  // std::cout << "parError = " << parError << std::endl;
82  }
83  }
84 
86 }
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
tuple iteration
Definition: align_cfg.py:5
std::vector< backgroundFunctionBase * > backgroundFunctionVec_
std::vector< int > functionId_
Definition: BaseFunction.h:46
void readParameters(TString fileName)
Parser of the parameters file.
backgroundFunctionBase ** backgroundFunction_
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:196
double ** parArray_
Definition: BaseFunction.h:50