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