CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TPNCor.cc
Go to the documentation of this file.
1 /*
2  * \class TPNCor
3  *
4  * $Date: 2012/02/09 10:08:10 $
5  * \author: Julie Malcles - CEA/Saclay
6  */
7 
10 #include <sstream>
11 #include <iostream>
12 #include <iomanip>
13 #include <fstream>
14 
15 #include "math.h"
16 
17 using namespace std;
18 //using namespace edm;
19 
20 //ClassImp(TPNCor)
21 
22 // Constructor...
24 {
25 
26  // Initialize
27 
28  isFileOK=0;
29 
30  for(int i=0;i<iSizePar;i++){
31  for(int j=0;j<iSizeGain;j++){
32  corParams[j][i] = 0.0 ;
33  }
34  }
35 
36  // Get values from file
37 
38  FILE *test;
39  test = fopen(filename.c_str(),"r");
40  char c;
41  int gain;
42  double aa, bb, cc;
43  ifstream fin;
44 
45  if( test ) {
46  fclose( test );
47  fin.open(filename.c_str());
48  while( (c=fin.peek()) != EOF )
49  {
50  fin >> gain>> aa >> bb >> cc;
51 
52  if(gain<iSizeGain){
53  corParams[gain][0]=aa;
54  corParams[gain][1]=bb;
55  corParams[gain][2]=cc;
56  }
57  }
58  isFileOK=1;
59  fin.close();
60  }else {
61  cout <<" No PN linearity corrections file found, no correction will be applied "<< endl;
62  }
63 
64 }
65 
66 // Destructor
68 {
69 
70 
71 }
72 
73 double TPNCor::getPNCorrectionFactor( double val0 , int gain )
74 {
75 
76  double cor=0;
77  double corr=1.0;
78  double pn=val0;
79  double xpn=val0/1000.0;
80 
81  if( isFileOK==0) return 1.0;
82 
83  if( gain> iSizeGain ) cout << "Unknown gain, gain has to be lower than "<<iSizeGain << endl;
84 
85  if( gain< iSizeGain ) {
86 
87  cor=xpn*(corParams[gain][0] +xpn*(corParams[gain][1]+xpn*corParams[gain][2]));
88 
89  if(pn!=0) corr = 1.0 - cor/pn;
90  else corr=1.0;
91  }
92 
93  return corr;
94 }
int i
Definition: DBlmapReader.cc:9
double getPNCorrectionFactor(double val0, int gain)
Definition: TPNCor.cc:73
virtual ~TPNCor()
Definition: TPNCor.cc:67
int j
Definition: DBlmapReader.cc:9
JetCorrectorParameters corr
Definition: classes.h:9
TPNCor(std::string filename)
Definition: TPNCor.cc:23
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121