Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:52

0001 /* 
0002  *  \class TPN
0003  *
0004  *  \author: Julie Malcles - CEA/Saclay
0005  */
0006 
0007 #include <CalibCalorimetry/EcalLaserAnalyzer/interface/TMom.h>
0008 #include <CalibCalorimetry/EcalLaserAnalyzer/interface/TPN.h>
0009 #include <CalibCalorimetry/EcalLaserAnalyzer/interface/TMarkov.h>
0010 #include <TMath.h>
0011 
0012 using namespace std;
0013 
0014 //ClassImp(TPN)
0015 
0016 // Default Constructor...
0017 TPN::TPN(int iPN) {
0018   init();
0019   _nPN = iPN;
0020 }
0021 
0022 // Destructor
0023 TPN::~TPN() {}
0024 
0025 void TPN::init() {
0026   for (int j = 0; j < nOutVar; j++) {
0027     cuts[0][j] = 0.0;
0028     cuts[1][j] = 10.0e9;
0029     mom[j] = new TMom();
0030   }
0031 }
0032 
0033 void TPN::addEntry(double pn, double pn0, double pn1) {
0034   double val[nOutVar];
0035 
0036   if (_nPN == 0)
0037     val[iPN] = pn0;
0038   else
0039     val[iPN] = pn1;
0040 
0041   if (pn != 0)
0042     val[iPNoPN] = val[iPN] / pn;
0043   else
0044     val[iPNoPN] = 0;
0045 
0046   if (pn0 != 0)
0047     val[iPNoPN0] = val[iPN] / pn0;
0048   else
0049     val[iPNoPN0] = 0;
0050 
0051   if (pn1 != 0)
0052     val[iPNoPN1] = val[iPN] / pn1;
0053   else
0054     val[iPNoPN1] = 0;
0055 
0056   for (int ivar = 0; ivar < nOutVar; ivar++) {
0057     mom[ivar]->addEntry(val[ivar]);
0058   }
0059 }
0060 
0061 void TPN::setCut(int ivar, double mean, double sig) {
0062   cuts[0][ivar] = mean - 2.0 * sig;
0063   cuts[1][ivar] = mean + 2.0 * sig;
0064   if (cuts[0][ivar] < 0)
0065     cuts[0][ivar] = 0.0;
0066 
0067   mom[ivar]->setCut(cuts[0][ivar], cuts[1][ivar]);
0068 }
0069 
0070 void TPN::setPNCut(double mean, double sig) { setCut(TPN::iPN, mean, sig); }
0071 void TPN::setPNoPNCut(double mean, double sig) { setCut(TPN::iPNoPN, mean, sig); }
0072 void TPN::setPNoPN0Cut(double mean, double sig) { setCut(TPN::iPNoPN0, mean, sig); }
0073 void TPN::setPNoPN1Cut(double mean, double sig) { setCut(TPN::iPNoPN1, mean, sig); }
0074 
0075 std::vector<double> TPN::get(int ivar) {
0076   std::vector<double> res;
0077 
0078   if (ivar < nOutVar) {
0079     res.push_back(mom[ivar]->getMean());
0080     res.push_back(mom[ivar]->getRMS());
0081     res.push_back(mom[ivar]->getM3());
0082     res.push_back(mom[ivar]->getNevt());
0083     res.push_back(mom[ivar]->getMin());
0084     res.push_back(mom[ivar]->getMax());
0085   }
0086 
0087   return res;
0088 }
0089 
0090 std::vector<double> TPN::getPN() {
0091   vector<double> x = get(TPN::iPN);
0092   return x;
0093 }
0094 std::vector<double> TPN::getPNoPN() {
0095   vector<double> x = get(TPN::iPNoPN);
0096   return x;
0097 }
0098 std::vector<double> TPN::getPNoPN0() {
0099   vector<double> x = get(TPN::iPNoPN0);
0100   return x;
0101 }
0102 std::vector<double> TPN::getPNoPN1() {
0103   vector<double> x = get(TPN::iPNoPN1);
0104   return x;
0105 }