CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Public Attributes
TPNCor Class Reference

#include <TPNCor.h>

Inheritance diagram for TPNCor:

Public Types

enum  VarGain { iGain0, iGain1, iSizeGain }
 
enum  VarParPN { iPar0, iPar1, iPar2, iSizePar }
 

Public Member Functions

double getPNCorrectionFactor (double val0, int gain)
 
 TPNCor (std::string filename)
 
virtual ~TPNCor ()
 

Public Attributes

double corParams [iSizeGain][iSizePar]
 
int isFileOK
 

Detailed Description

Definition at line 7 of file TPNCor.h.

Member Enumeration Documentation

Enumerator
iGain0 
iGain1 
iSizeGain 

Definition at line 22 of file TPNCor.h.

Enumerator
iPar0 
iPar1 
iPar2 
iSizePar 

Definition at line 23 of file TPNCor.h.

Constructor & Destructor Documentation

TPNCor::TPNCor ( std::string  filename)

Definition at line 22 of file TPNCor.cc.

References trackerHits::c, gather_cfg::cout, groupFilesInBlocks::fin, i, j, and run_regression::test.

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 }
int i
Definition: DBlmapReader.cc:9
double corParams[iSizeGain][iSizePar]
Definition: TPNCor.h:28
int j
Definition: DBlmapReader.cc:9
tuple filename
Definition: lut2db_cfg.py:20
int isFileOK
Definition: TPNCor.h:29
tuple cout
Definition: gather_cfg.py:121
TPNCor::~TPNCor ( )
virtual

Definition at line 66 of file TPNCor.cc.

67 {
68 
69 
70 }

Member Function Documentation

double TPNCor::getPNCorrectionFactor ( double  val0,
int  gain 
)

Definition at line 72 of file TPNCor.cc.

References corr, and gather_cfg::cout.

Referenced by EcalLaserAnalyzer2::analyze(), and EcalLaserAnalyzer::analyze().

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 }
double corParams[iSizeGain][iSizePar]
Definition: TPNCor.h:28
JetCorrectorParameters corr
Definition: classes.h:5
int isFileOK
Definition: TPNCor.h:29
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

double TPNCor::corParams[iSizeGain][iSizePar]

Definition at line 28 of file TPNCor.h.

int TPNCor::isFileOK

Definition at line 29 of file TPNCor.h.