CMS 3D CMS Logo

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 "RecoParticleFlow/PFClusterTools/interface/Calibratable.h"
00006 #include "RecoParticleFlow/PFClusterTools/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         /* Returns the calibrated particle energy with the correction
00055          * Note: for, say, ecalOnly particles:
00056          * energy = correction_function([calibrated ecalEnergy + hcalEnergy(v small)])
00057          * ditto hcalOnly
00058          */
00059         double getCalibratedEnergy(const double& ecalE, const double& hcalE,
00060                         const double& eta, const double& phi) const;
00061         
00062         void getCalibratedEnergyEmbedAInHcal(double& ecalE,
00063                         double& hcalE, const double& eta, const double& phi) const;
00064 
00065         /* TESTING purposes only! */
00066         void calibrate(Calibratable& c);
00067 
00068         /* TESTING purposes only! */
00069         void getCalibrationResultWrapper(const Calibratable& c,
00070                         CalibrationResultWrapper& crw);
00071 
00072         /* TESTING purposes only! */
00073         void calibrateTree(TTree* tree);
00074 
00075         /* Sets the 'a' term in the abc calibration and a final linear correction.
00076          * You get these values from the (seperately available) option file. */
00077         void setCorrections(const double& lowEP0, const double& lowEP1,
00078                         const double& globalP0, const double& globalP1);
00079 
00080         /* getCalibratedEnergy() returns max(0, calibrated energy) if this is true. */
00081         void setAllowNegativeEnergy(const bool& allowIt) {
00082                 allowNegativeEnergy_ = allowIt;
00083         }
00084 
00085         /* Whether to apply a final correction function in getCalibratedEnergy()
00086          * Highly recommended ('a' term of abc calibration will be neglected otherwise. */
00087         void setDoCorrection(const int& doCorrection) {
00088                 doCorrection_ = doCorrection;
00089         }
00090         
00091         void setDoEtaCorrection(const int doEtaCorrection) {
00092                 doEtaCorrection_ = doEtaCorrection;
00093         }
00094 
00095         /* Threshold for ecalOnly and hcalOnly evaluation. */
00096         void setEcalHcalEnergyCuts(const double& ecalCut, const double& hcalCut) {
00097                 std::cout << __PRETTY_FUNCTION__ << "WARNING! These will be ignored.\n";
00098                 ecalOnlyDiv_ = ecalCut;
00099                 hcalOnlyDiv_ = hcalCut;
00100         }
00101 
00102         /* Hard cut between barrel and endcap. */
00103         void setBarrelBoundary(const double& eta) {
00104                 barrelEndcapEtaDiv_ = eta;
00105         }
00106         
00107         void setMaxEToCorrect(double maxE) {
00108                 maxEToCorrect_ = maxE;
00109         }
00110 
00111         /* Sets the function parameters - very important! */
00112         void setEvolutionParameters(const std::string& sector,
00113                         std::vector<double> params);
00114         
00115         void setEtaCorrectionParameters(std::vector<double> params);
00116 
00117         /* Elements in this vector refer to the different calibration functions
00118          * available. For each one of these, you should call setEvolutionParameters()
00119          * with the appropriate vector<double> acquired from an options file.
00120          */
00121         std::vector<std::string>* getKnownSectorNames() {
00122                 return &names_;
00123         }
00124 
00125         
00126         /* Dumps the member values to the stream */
00127         friend std::ostream& pftools::operator<<(std::ostream& s, const PFClusterCalibration& cc);
00128 
00129 private:
00130         
00131         void init();
00132 
00133         //where to select either barrel or endcap
00134         double barrelEndcapEtaDiv_;
00135 
00136         //at what energy to split between ecalOnly, hcalOnly, ecalHcal
00137         double ecalOnlyDiv_;
00138         double hcalOnlyDiv_;
00139 
00140         int doCorrection_;
00141         int allowNegativeEnergy_;
00142         int doEtaCorrection_;
00143         double maxEToCorrect_;
00144 
00145         double correctionLowLimit_;
00146         double globalP0_;
00147         double globalP1_;
00148         double lowEP0_;
00149         double lowEP1_;
00150 
00151         //Function used to correct final total energies
00152         TF1* correction_;
00153         //Function to correct eta dependence (post-calibration).
00154         TF1* etaCorrection_;
00155 
00156         std::map<std::string, TF1> namesAndFunctions_;
00157         std::vector<std::string> names_;
00158 
00159 };
00160 }
00161 
00162 #endif /* PFCLUSTERCALIBRATION_H_ */

Generated on Tue Jun 9 17:44:41 2009 for CMSSW by  doxygen 1.5.4