CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFClusterCalibration.h
Go to the documentation of this file.
1 #ifndef PFCLUSTERCALIBRATION_H_
2 #define PFCLUSTERCALIBRATION_H_
3 
7 //#include "RecoParticleFlow/PFClusterTools/interface/IO.h"
8 
9 #include <vector>
10 #include <string>
11 #include <map>
12 #include <ostream>
13 
14 class TF1;
15 class TTree;
16 
17 namespace pftools {
18 
19 /*
20  * \class PFClusterCalibration
21  * \brief Calibrated calorimeter cluster energy for hadronic PFCandidates.
22  * \author Jamie Ballin, Imperial College London
23  * \date September 2008
24  *
25  * The ECAL and HCAL have been calibrated to 50 GeV electrons. Therefore, a calibration is required
26  * to evaluate the correct hadronic response. This class will calibrate clusters belonging to a PFCandidate.
27  * (Users should access these clusters from the blocks in the PFCandidate).
28  *
29  * A linear calibration is evaluated, for barrel and endcap (call setBarrelBoundary(double eta)
30  * to set this limit).
31  *
32  * Sensible default values are set for all members, but in order to get usable results, you must supply the
33  * latest function parameters and corrections (seperately available) - see setCorrections()
34  * and setEvolutionParameters() documentation below.
35  */
37 public:
38 
39  /* Constructor with sensible defaults */
41 
42  //PFClusterCalibration(IO* io);
43 
44  virtual ~PFClusterCalibration();
45 
46  /* Returns the calibrated ecalEnergy */
47  double getCalibratedEcalEnergy(const double& ecalE, const double& hcalE,
48  const double& eta, const double& phi) const;
49 
50  /* Returns the calibrated hcalEnergy */
51  double getCalibratedHcalEnergy(const double& ecalE, const double& hcalE,
52  const double& eta, const double& phi) const;
53 
54  /* DEPRECATED METHOD - do not use.
55  *
56  * Returns the calibrated particle energy with the correction
57  * Note: for, say, ecalOnly particles:
58  * energy = correction_function([calibrated ecalEnergy + hcalEnergy(v small)])
59  * ditto hcalOnly
60  */
61  double getCalibratedEnergy(const double& ecalE, const double& hcalE,
62  const double& eta, const double& phi) const;
63 
64  void getCalibratedEnergyEmbedAInHcal(double& ecalE,
65  double& hcalE, const double& eta, const double& phi) const;
66 
67  /* TESTING purposes only! */
68  void calibrate(Calibratable& c);
69 
70  /* TESTING purposes only! */
73 
74  /* TESTING purposes only! */
75  void calibrateTree(TTree* tree);
76 
77  /* Sets the 'a' term in the abc calibration and a final linear correction.
78  * You get these values from the (seperately available) option file. */
79  void setCorrections(const double& lowEP0, const double& lowEP1,
80  const double& globalP0, const double& globalP1);
81 
82  /* getCalibratedEnergy() returns max(0, calibrated energy) if this is true. */
83  void setAllowNegativeEnergy(const bool& allowIt) {
84  allowNegativeEnergy_ = allowIt;
85  }
86 
87  /* Whether to apply a final correction function in getCalibratedEnergy()
88  * Highly recommended ('a' term of abc calibration will be neglected otherwise. */
89  void setDoCorrection(const int& doCorrection) {
90  doCorrection_ = doCorrection;
91  }
92 
93  void setDoEtaCorrection(const int doEtaCorrection) {
94  doEtaCorrection_ = doEtaCorrection;
95  }
96 
97  /* Threshold for ecalOnly and hcalOnly evaluation. */
98  void setEcalHcalEnergyCuts(const double& ecalCut, const double& hcalCut) {
99  //std::cout << __PRETTY_FUNCTION__ << "WARNING! These will be ignored.\n";
100  ecalOnlyDiv_ = ecalCut;
101  hcalOnlyDiv_ = hcalCut;
102  }
103 
104  /* Hard cut between barrel and endcap. */
105  void setBarrelBoundary(const double& eta) {
107  }
108 
109  void setMaxEToCorrect(double maxE) {
110  maxEToCorrect_ = maxE;
111  }
112 
113  /* Sets the function parameters - very important! */
114  void setEvolutionParameters(const std::string& sector,
115  std::vector<double> params);
116 
117  void setEtaCorrectionParameters(std::vector<double> params);
118 
119  /* Elements in this vector refer to the different calibration functions
120  * available. For each one of these, you should call setEvolutionParameters()
121  * with the appropriate vector<double> acquired from an options file.
122  */
123  std::vector<std::string>* getKnownSectorNames() {
124  return &names_;
125  }
126 
127 
128  /* Dumps the member values to the stream */
129  friend std::ostream& pftools::operator<<(std::ostream& s, const PFClusterCalibration& cc);
130 
131 private:
132 
133  void init();
134 
135  //where to select either barrel or endcap
137 
138  //at what energy to split between ecalOnly, hcalOnly, ecalHcal
139  double ecalOnlyDiv_;
140  double hcalOnlyDiv_;
141 
146 
148  double globalP0_;
149  double globalP1_;
150  double lowEP0_;
151  double lowEP1_;
152 
153  //Function used to correct final total energies
155  //Function to correct eta dependence (post-calibration).
157 
158  std::map<std::string, TF1> namesAndFunctions_;
159  std::vector<std::string> names_;
160 
161 };
162 }
163 
164 #endif /* PFCLUSTERCALIBRATION_H_ */
void setEvolutionParameters(const std::string &sector, std::vector< double > params)
std::vector< std::string > names_
std::vector< std::string > * getKnownSectorNames()
Wraps essential single particle calibration data ready for export to a Root file. ...
Definition: Calibratable.h:122
std::map< std::string, TF1 > namesAndFunctions_
void setBarrelBoundary(const double &eta)
void getCalibrationResultWrapper(const Calibratable &c, CalibrationResultWrapper &crw)
double getCalibratedEnergy(const double &ecalE, const double &hcalE, const double &eta, const double &phi) const
T eta() const
void getCalibratedEnergyEmbedAInHcal(double &ecalE, double &hcalE, const double &eta, const double &phi) const
void setEcalHcalEnergyCuts(const double &ecalCut, const double &hcalCut)
double getCalibratedHcalEnergy(const double &ecalE, const double &hcalE, const double &eta, const double &phi) const
double getCalibratedEcalEnergy(const double &ecalE, const double &hcalE, const double &eta, const double &phi) const
A small class designed to hold the result of a calibration of a SingleParticleWrapper.
void setDoCorrection(const int &doCorrection)
void setCorrections(const double &lowEP0, const double &lowEP1, const double &globalP0, const double &globalP1)
void setAllowNegativeEnergy(const bool &allowIt)
void setEtaCorrectionParameters(std::vector< double > params)
std::ostream & operator<<(std::ostream &s, const Calibratable &calib_)
Definition: Calibratable.cc:6
void setDoEtaCorrection(const int doEtaCorrection)
Definition: DDAxes.h:10