Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:27

0001 #include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibrationHF.h"
0002 #include <TMath.h>
0003 #include <cmath>
0004 #include <vector>
0005 #include <TF1.h>
0006 
0007 using namespace std;
0008 using namespace edm;
0009 
0010 PFEnergyCalibrationHF::PFEnergyCalibrationHF() {
0011   calibHF_use_ = false;
0012   calibHF_eta_step_.push_back(0.00);
0013   calibHF_eta_step_.push_back(2.90);
0014   calibHF_eta_step_.push_back(3.00);
0015   calibHF_eta_step_.push_back(3.20);
0016   calibHF_eta_step_.push_back(4.20);
0017   calibHF_eta_step_.push_back(4.40);
0018   calibHF_eta_step_.push_back(4.60);
0019   calibHF_eta_step_.push_back(4.80);
0020   calibHF_eta_step_.push_back(5.20);
0021   calibHF_eta_step_.push_back(5.40);
0022   for (unsigned int i = 0; i < calibHF_eta_step_.size(); ++i) {
0023     calibHF_a_EMonly_.push_back(1.00);
0024     calibHF_b_HADonly_.push_back(1.00);
0025     calibHF_a_EMHAD_.push_back(1.00);
0026     calibHF_b_EMHAD_.push_back(1.00);
0027   }
0028 }
0029 
0030 PFEnergyCalibrationHF::PFEnergyCalibrationHF(bool calibHF_use,
0031                                              const std::vector<double>& calibHF_eta_step,
0032                                              const std::vector<double>& calibHF_a_EMonly,
0033                                              const std::vector<double>& calibHF_b_HADonly,
0034                                              const std::vector<double>& calibHF_a_EMHAD,
0035                                              const std::vector<double>& calibHF_b_EMHAD) {
0036   calibHF_use_ = calibHF_use;
0037   calibHF_eta_step_ = calibHF_eta_step;
0038   calibHF_a_EMonly_ = calibHF_a_EMonly;
0039   calibHF_b_HADonly_ = calibHF_b_HADonly;
0040   calibHF_a_EMHAD_ = calibHF_a_EMHAD;
0041   calibHF_b_EMHAD_ = calibHF_b_EMHAD;
0042 }
0043 
0044 PFEnergyCalibrationHF::~PFEnergyCalibrationHF() {
0045   //--- nothing to be done yet
0046 }
0047 
0048 double PFEnergyCalibrationHF::energyEm(double uncalibratedEnergyECAL, double eta, double phi) {
0049   double calibrated = 0.0;
0050   //find eta bin.  default : 0.00;2.90;3.00;3.20;4.20;4.40;4.60;4.80;5.20;5.40;
0051   int ietabin = 0;
0052   for (unsigned int i = 0; i < calibHF_eta_step_.size(); ++i) {
0053     if ((fabs(eta)) >= calibHF_eta_step_[i]) {
0054       ietabin = i;
0055     }
0056   }
0057   calibrated = uncalibratedEnergyECAL * calibHF_a_EMonly_[ietabin];
0058   return calibrated;
0059 
0060   // return calibrated;
0061 }
0062 
0063 double PFEnergyCalibrationHF::energyHad(double uncalibratedEnergyHCAL, double eta, double phi) {
0064   double calibrated = 0.0;
0065   //find eta bin.  default : 0.00;2.90;3.00;3.20;4.20;4.40;4.60;4.80;5.20;5.40;
0066   int ietabin = 0;
0067   for (unsigned int i = 0; i < calibHF_eta_step_.size(); ++i) {
0068     if ((fabs(eta)) >= calibHF_eta_step_[i]) {
0069       ietabin = i;
0070     }
0071   }
0072   calibrated = uncalibratedEnergyHCAL * calibHF_b_HADonly_[ietabin];
0073   return calibrated;
0074 }
0075 
0076 double PFEnergyCalibrationHF::energyEmHad(double uncalibratedEnergyECAL,
0077                                           double uncalibratedEnergyHCAL,
0078                                           double eta,
0079                                           double phi) {
0080   double calibrated = 0.0;
0081   //find eta bin.  default : 0.00;2.90;3.00;3.20;4.20;4.40;4.60;4.80;5.20;5.40+;
0082   int ietabin = 0;
0083   for (unsigned int i = 0; i < calibHF_eta_step_.size(); ++i) {
0084     if ((fabs(eta)) >= calibHF_eta_step_[i]) {
0085       ietabin = i;
0086     }
0087   }
0088   calibrated = uncalibratedEnergyECAL * calibHF_a_EMHAD_[ietabin] + uncalibratedEnergyHCAL * calibHF_b_EMHAD_[ietabin];
0089   return calibrated;
0090 }
0091 
0092 std::ostream& operator<<(std::ostream& out, const PFEnergyCalibrationHF& calib) {
0093   if (!out)
0094     return out;
0095   out << "PFEnergyCalibrationHF -- " << endl;
0096   int ii = 0;
0097   for (std::vector<double>::const_iterator iteta = (calib.getcalibHF_eta_step()).begin();
0098        iteta != (calib.getcalibHF_eta_step()).end();
0099        ++iteta) {
0100     //double currenteta = *iteta;
0101     out << " i " << ii << ",";
0102     out << "use " << calib.getcalibHF_use() << ",";
0103     out << "currenteta " << calib.getcalibHF_eta_step()[ii] << ",";
0104     out << "calibHF_a_EMonly_ " << calib.getcalibHF_a_EMonly()[ii] << ",";
0105     out << "calibHF_b_HADonly_ " << calib.getcalibHF_b_HADonly()[ii] << ",";
0106     out << "calibHF_a_EMHAD_ " << calib.getcalibHF_a_EMHAD()[ii] << ",";
0107     out << "calibHF_b_EMHAD_ " << calib.getcalibHF_b_EMHAD()[ii] << ",";
0108     out << endl;
0109     ii++;
0110   }
0111 
0112   return out;
0113 }