CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/CalibCalorimetry/EcalLaserAnalyzer/src/TPN.cc

Go to the documentation of this file.
00001 /* 
00002  *  \class TPN
00003  *
00004  *  $Date: 2012/02/09 10:08:10 $
00005  *  \author: Julie Malcles - CEA/Saclay
00006  */
00007 
00008 #include <CalibCalorimetry/EcalLaserAnalyzer/interface/TMom.h>
00009 #include <CalibCalorimetry/EcalLaserAnalyzer/interface/TPN.h>
00010 #include <CalibCalorimetry/EcalLaserAnalyzer/interface/TMarkov.h>
00011 #include <TMath.h>
00012 
00013 using namespace std;
00014 
00015 //ClassImp(TPN)
00016 
00017 
00018 // Default Constructor...
00019 TPN::TPN(int iPN)
00020 {
00021   init();
00022   _nPN=iPN;
00023 }
00024 
00025 
00026 // Destructor
00027 TPN::~TPN()
00028 {
00029 }
00030 
00031 void TPN::init()
00032 {
00033 
00034   for(int j=0;j<nOutVar;j++){
00035     cuts[0][j]=0.0;
00036     cuts[1][j]=10.0e9;
00037     mom[j]=new TMom();
00038   }
00039 }
00040 
00041 void TPN::addEntry(double pn, double pn0, double pn1)
00042 {
00043 
00044   double val[nOutVar];
00045  
00046   if(_nPN==0) val[iPN]=pn0;
00047   else val[iPN]=pn1;
00048 
00049   if(pn!=0) val[iPNoPN]=val[iPN]/pn;
00050   else val[iPNoPN]=0;
00051 
00052   if(pn0!=0) val[iPNoPN0]=val[iPN]/pn0;
00053   else val[iPNoPN0]=0;
00054 
00055   if(pn1!=0) val[iPNoPN1]=val[iPN]/pn1;
00056   else val[iPNoPN1]=0;
00057   
00058   for(int ivar=0;ivar<nOutVar;ivar++){
00059     mom[ivar]->addEntry(val[ivar]);
00060   }
00061   
00062 }
00063   
00064 void  TPN::setCut(int ivar, double mean, double sig){
00065 
00066   cuts[0][ivar]=mean-2.0*sig;
00067   cuts[1][ivar]=mean+2.0*sig;
00068   if(cuts[0][ivar]<0)cuts[0][ivar]=0.0 ;
00069 
00070   mom[ivar]->setCut(cuts[0][ivar],cuts[1][ivar]);
00071 }
00072 
00073 void  TPN::setPNCut(double mean, double sig){setCut(TPN::iPN,mean,sig);}
00074 void  TPN::setPNoPNCut(double mean, double sig){setCut(TPN::iPNoPN,mean,sig);}
00075 void  TPN::setPNoPN0Cut(double mean, double sig){setCut(TPN::iPNoPN0,mean,sig);}
00076 void  TPN::setPNoPN1Cut(double mean, double sig){setCut(TPN::iPNoPN1,mean,sig);}
00077 
00078 
00079 std::vector<double> TPN::get(int ivar){ 
00080   
00081   std::vector<double> res;
00082   
00083   if(ivar<nOutVar){
00084     
00085     res.push_back(mom[ivar]->getMean());
00086     res.push_back(mom[ivar]->getRMS());
00087     res.push_back(mom[ivar]->getM3());
00088     res.push_back(mom[ivar]->getNevt());
00089     res.push_back(mom[ivar]->getMin());
00090     res.push_back(mom[ivar]->getMax());
00091   }
00092   
00093   return res;
00094   
00095 }
00096 
00097 std::vector<double>   TPN::getPN(){vector <double> x= get(TPN::iPN); return x;}
00098 std::vector<double>   TPN::getPNoPN(){vector <double> x= get(TPN::iPNoPN); return x;}
00099 std::vector<double>   TPN::getPNoPN0(){vector <double> x= get(TPN::iPNoPN0); return x;}
00100 std::vector<double>   TPN::getPNoPN1(){vector <double> x= get(TPN::iPNoPN1); return x;}
00101