CMS 3D CMS Logo

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

◆ VarGain

Enumerator
iGain0 
iGain1 
iSizeGain 

Definition at line 16 of file TPNCor.h.

◆ VarParPN

Enumerator
iPar0 
iPar1 
iPar2 
iSizePar 

Definition at line 17 of file TPNCor.h.

Constructor & Destructor Documentation

◆ TPNCor()

TPNCor::TPNCor ( std::string  filename)

Definition at line 21 of file TPNCor.cc.

References gpuPixelDoublets::cc, gather_cfg::cout, corrVsCorr::filename, groupFilesInBlocks::fin, PedestalClient_cfi::gain, mps_fire::i, dqmiolumiharvest::j, and ctpps_dqm_sourceclient-live_cfg::test.

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

◆ ~TPNCor()

TPNCor::~TPNCor ( )
override

Definition at line 60 of file TPNCor.cc.

60 {}

Member Function Documentation

◆ getPNCorrectionFactor()

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

Definition at line 62 of file TPNCor.cc.

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

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

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

Member Data Documentation

◆ corParams

double TPNCor::corParams[iSizeGain][iSizePar]

Definition at line 22 of file TPNCor.h.

◆ isFileOK

int TPNCor::isFileOK

Definition at line 23 of file TPNCor.h.