CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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)
 
 ~TPNCor () override
 

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 16 of file TPNCor.h.

Enumerator
iPar0 
iPar1 
iPar2 
iSizePar 

Definition at line 17 of file TPNCor.h.

Constructor & Destructor Documentation

TPNCor::TPNCor ( std::string  filename)

Definition at line 22 of file TPNCor.cc.

References c, gather_cfg::cout, groupFilesInBlocks::fin, mps_fire::i, dqmiolumiharvest::j, and ctpps_dqm_sourceclient-live_cfg::test.

22  {
23  // Initialize
24 
25  isFileOK = 0;
26 
27  for (int i = 0; i < iSizePar; i++) {
28  for (int j = 0; j < iSizeGain; j++) {
29  corParams[j][i] = 0.0;
30  }
31  }
32 
33  // Get values from file
34 
35  FILE *test;
36  test = fopen(filename.c_str(), "r");
37  char c;
38  int gain;
39  double aa, bb, cc;
40  std::ifstream fin;
41 
42  if (test) {
43  fclose(test);
44  fin.open(filename.c_str());
45  while ((c = fin.peek()) != EOF) {
46  fin >> gain >> aa >> bb >> cc;
47 
48  if (gain < iSizeGain) {
49  corParams[gain][0] = aa;
50  corParams[gain][1] = bb;
51  corParams[gain][2] = cc;
52  }
53  }
54  isFileOK = 1;
55  fin.close();
56  } else {
57  cout << " No PN linearity corrections file found, no correction will be applied " << endl;
58  }
59 }
const edm::EventSetup & c
double corParams[iSizeGain][iSizePar]
Definition: TPNCor.h:22
tuple filename
Definition: lut2db_cfg.py:20
int isFileOK
Definition: TPNCor.h:23
tuple cout
Definition: gather_cfg.py:144
TPNCor::~TPNCor ( )
override

Definition at line 62 of file TPNCor.cc.

62 {}

Member Function Documentation

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

Definition at line 64 of file TPNCor.cc.

References alignCSCRings::corr, and gather_cfg::cout.

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

64  {
65  double cor = 0;
66  double corr = 1.0;
67  double pn = val0;
68  double xpn = val0 / 1000.0;
69 
70  if (isFileOK == 0)
71  return 1.0;
72 
73  if (gain > iSizeGain)
74  cout << "Unknown gain, gain has to be lower than " << iSizeGain << endl;
75 
76  if (gain < iSizeGain) {
77  cor = xpn * (corParams[gain][0] + xpn * (corParams[gain][1] + xpn * corParams[gain][2]));
78 
79  if (pn != 0)
80  corr = 1.0 - cor / pn;
81  else
82  corr = 1.0;
83  }
84 
85  return corr;
86 }
double corParams[iSizeGain][iSizePar]
Definition: TPNCor.h:22
int isFileOK
Definition: TPNCor.h:23
tuple cout
Definition: gather_cfg.py:144

Member Data Documentation

double TPNCor::corParams[iSizeGain][iSizePar]

Definition at line 22 of file TPNCor.h.

int TPNCor::isFileOK

Definition at line 23 of file TPNCor.h.