CMS 3D CMS Logo

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