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