CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/RecoParticleFlow/PFClusterTools/interface/PFClusterCalibration.h

Go to the documentation of this file.
00001 #ifndef PFCLUSTERCALIBRATION_H_
00002 #define PFCLUSTERCALIBRATION_H_
00003 
00004 #include "RecoParticleFlow/PFClusterTools/interface/DetectorElementType.h"
00005 #include "DataFormats/ParticleFlowReco/interface/Calibratable.h"
00006 #include "DataFormats/ParticleFlowReco/interface/CalibrationResultWrapper.h"
00007 //#include "RecoParticleFlow/PFClusterTools/interface/IO.h"
00008 
00009 #include <vector>
00010 #include <string>
00011 #include <map>
00012 #include <ostream>
00013 
00014 class TF1;
00015 class TTree;
00016 
00017 namespace pftools {
00018 
00019 /*
00020  * \class PFClusterCalibration
00021  * \brief Calibrated calorimeter cluster energy for hadronic PFCandidates.
00022  * \author Jamie Ballin, Imperial College London
00023  * \date September 2008
00024  * 
00025  * The ECAL and HCAL have been calibrated to 50 GeV electrons. Therefore, a calibration is required 
00026  * to evaluate the correct hadronic response. This class will calibrate clusters belonging to a PFCandidate.
00027  * (Users should access these clusters from the blocks in the PFCandidate).
00028  * 
00029  * A linear calibration is evaluated, for barrel and endcap (call setBarrelBoundary(double eta)
00030  * to set this limit).
00031  * 
00032  * Sensible default values are set for all members, but in order to get usable results, you must supply the
00033  * latest function parameters and corrections (seperately available) - see setCorrections() 
00034  * and setEvolutionParameters() documentation below.
00035  */
00036 class PFClusterCalibration {
00037 public:
00038         
00039         /* Constructor with sensible defaults */
00040         PFClusterCalibration();
00041         
00042         //PFClusterCalibration(IO* io);
00043 
00044         virtual ~PFClusterCalibration();
00045 
00046         /* Returns the calibrated ecalEnergy */
00047         double getCalibratedEcalEnergy(const double& ecalE, const double& hcalE,
00048                         const double& eta, const double& phi) const;
00049         
00050         /* Returns the calibrated hcalEnergy */
00051         double getCalibratedHcalEnergy(const double& ecalE, const double& hcalE,
00052                         const double& eta, const double& phi) const;
00053 
00054         /* DEPRECATED METHOD - do not use.
00055          * 
00056          * Returns the calibrated particle energy with the correction
00057          * Note: for, say, ecalOnly particles:
00058          * energy = correction_function([calibrated ecalEnergy + hcalEnergy(v small)])
00059          * ditto hcalOnly
00060          */
00061         double getCalibratedEnergy(const double& ecalE, const double& hcalE,
00062                         const double& eta, const double& phi) const;
00063         
00064         void getCalibratedEnergyEmbedAInHcal(double& ecalE,
00065                         double& hcalE, const double& eta, const double& phi) const;
00066 
00067         /* TESTING purposes only! */
00068         void calibrate(Calibratable& c);
00069 
00070         /* TESTING purposes only! */
00071         void getCalibrationResultWrapper(const Calibratable& c,
00072                         CalibrationResultWrapper& crw);
00073 
00074         /* TESTING purposes only! */
00075         void calibrateTree(TTree* tree);
00076 
00077         /* Sets the 'a' term in the abc calibration and a final linear correction.
00078          * You get these values from the (seperately available) option file. */
00079         void setCorrections(const double& lowEP0, const double& lowEP1,
00080                         const double& globalP0, const double& globalP1);
00081 
00082         /* getCalibratedEnergy() returns max(0, calibrated energy) if this is true. */
00083         void setAllowNegativeEnergy(const bool& allowIt) {
00084                 allowNegativeEnergy_ = allowIt;
00085         }
00086 
00087         /* Whether to apply a final correction function in getCalibratedEnergy()
00088          * Highly recommended ('a' term of abc calibration will be neglected otherwise. */
00089         void setDoCorrection(const int& doCorrection) {
00090                 doCorrection_ = doCorrection;
00091         }
00092         
00093         void setDoEtaCorrection(const int doEtaCorrection) {
00094                 doEtaCorrection_ = doEtaCorrection;
00095         }
00096 
00097         /* Threshold for ecalOnly and hcalOnly evaluation. */
00098         void setEcalHcalEnergyCuts(const double& ecalCut, const double& hcalCut) {
00099                 //std::cout << __PRETTY_FUNCTION__ << "WARNING! These will be ignored.\n";
00100                 ecalOnlyDiv_ = ecalCut;
00101                 hcalOnlyDiv_ = hcalCut;
00102         }
00103 
00104         /* Hard cut between barrel and endcap. */
00105         void setBarrelBoundary(const double& eta) {
00106                 barrelEndcapEtaDiv_ = eta;
00107         }
00108         
00109         void setMaxEToCorrect(double maxE) {
00110                 maxEToCorrect_ = maxE;
00111         }
00112 
00113         /* Sets the function parameters - very important! */
00114         void setEvolutionParameters(const std::string& sector,
00115                         std::vector<double> params);
00116         
00117         void setEtaCorrectionParameters(std::vector<double> params);
00118 
00119         /* Elements in this vector refer to the different calibration functions
00120          * available. For each one of these, you should call setEvolutionParameters()
00121          * with the appropriate vector<double> acquired from an options file.
00122          */
00123         std::vector<std::string>* getKnownSectorNames() {
00124                 return &names_;
00125         }
00126 
00127         
00128         /* Dumps the member values to the stream */
00129         friend std::ostream& pftools::operator<<(std::ostream& s, const PFClusterCalibration& cc);
00130 
00131 private:
00132         
00133         void init();
00134 
00135         //where to select either barrel or endcap
00136         double barrelEndcapEtaDiv_;
00137 
00138         //at what energy to split between ecalOnly, hcalOnly, ecalHcal
00139         double ecalOnlyDiv_;
00140         double hcalOnlyDiv_;
00141 
00142         int doCorrection_;
00143         int allowNegativeEnergy_;
00144         int doEtaCorrection_;
00145         double maxEToCorrect_;
00146 
00147         double correctionLowLimit_;
00148         double globalP0_;
00149         double globalP1_;
00150         double lowEP0_;
00151         double lowEP1_;
00152 
00153         //Function used to correct final total energies
00154         TF1* correction_;
00155         //Function to correct eta dependence (post-calibration).
00156         TF1* etaCorrection_;
00157 
00158         std::map<std::string, TF1> namesAndFunctions_;
00159         std::vector<std::string> names_;
00160 
00161 };
00162 }
00163 
00164 #endif /* PFCLUSTERCALIBRATION_H_ */