CMS 3D CMS Logo

Public Types | Public Member Functions | Public Attributes

TPNCor Class Reference

#include <TPNCor.h>

List of all members.

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 23 of file TPNCor.cc.

References trackerHits::c, gather_cfg::cout, i, and j.

{

  // Initialize

  isFileOK=0;

  for(int i=0;i<iSizePar;i++){
    for(int j=0;j<iSizeGain;j++){
      corParams[j][i] = 0.0   ;
    }
  }
  
  // Get values from file
  
  FILE *test;
  test = fopen(filename.c_str(),"r");
  char c;
  int gain;
  double aa, bb, cc;
  ifstream fin;
  
  if( test ) {
    fclose( test );
    fin.open(filename.c_str());
    while( (c=fin.peek()) != EOF )
      {
        fin >> gain>> aa >> bb >> cc;
        
        if(gain<iSizeGain){
          corParams[gain][0]=aa;
          corParams[gain][1]=bb;
          corParams[gain][2]=cc;
        }
      }
    isFileOK=1;
    fin.close();
  }else {
    cout <<" No PN linearity corrections file found, no correction will be applied "<< endl;
  }

}
TPNCor::~TPNCor ( ) [virtual]

Definition at line 67 of file TPNCor.cc.

{ 

  
}

Member Function Documentation

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

Definition at line 73 of file TPNCor.cc.

References corr, and gather_cfg::cout.

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

{
  
  double cor=0;
  double corr=1.0;
  double pn=val0;
  double xpn=val0/1000.0;

  if( isFileOK==0) return 1.0;

  if( gain> iSizeGain ) cout << "Unknown gain, gain has to be lower than "<<iSizeGain << endl;
  
  if( gain< iSizeGain ) {
    
    cor=xpn*(corParams[gain][0] +xpn*(corParams[gain][1]+xpn*corParams[gain][2]));
    
    if(pn!=0) corr = 1.0 - cor/pn;
    else corr=1.0;
  } 
  
  return corr;
}

Member Data Documentation

double TPNCor::corParams[iSizeGain][iSizePar]

Definition at line 28 of file TPNCor.h.

Definition at line 29 of file TPNCor.h.