CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DataFormats/ParticleFlowReco/interface/Calibratable.h

Go to the documentation of this file.
00001 #ifndef CALIBRATABLE_H_
00002 #define CALIBRATABLE_H_
00003 
00004 //#include <boost/shared_ptr.hpp>
00005 
00006 #include <vector>
00007 #include <iostream>
00008 
00009 #include "DataFormats/ParticleFlowReco/interface/CalibrationResultWrapper.h"
00010 #include "DataFormats/ParticleFlowReco/interface/CalibrationProvenance.h"
00011 #include "DataFormats/Math/interface/LorentzVector.h"
00012 #include "DataFormats/ParticleFlowReco/interface/CaloWindow.h"
00013 #include "DataFormats/ParticleFlowReco/interface/CaloEllipse.h"
00014 
00015 namespace pftools {
00016 
00024 class CalibratableElement {
00025 public:
00026         CalibratableElement() {
00027                 reset();
00028         }
00029 
00030         CalibratableElement(double energy, double eta, double phi, int layer,
00031                         double extent = 0.0, double time = 0.0) :
00032                 energy_(energy), eta_(eta), phi_(phi), time_(time), layer_(layer), extent_(extent) {
00033         }
00034 
00035         double energy_, eta_, phi_, time_;
00036         int layer_;
00037 
00038         //RMS of deltaR of hits in the cluster to its centre
00039         double extent_;
00040 
00041         void reset() {
00042                 energy_ = 0.0;
00043                 eta_ = 0.0;
00044                 phi_ = 0.0;
00045                 layer_ = 0;
00046                 extent_ = 0.0;
00047                 time_ = 0.0;
00048         }
00049         bool operator<(const CalibratableElement& em) const {
00050                 if (em.energy_ < energy_)
00051                         return true;
00052                 return false;
00053         }
00054 
00055 
00056 };
00057 
00066 class CandidateWrapper {
00067 public:
00068         CandidateWrapper() {
00069                 reset();
00070         }
00071 
00072         CandidateWrapper(double energy, double eta, double phi, double energyEcal,
00073                         double energyHcal, int type) :
00074                 energy_(energy), eta_(eta), phi_(phi), energyEcal_(energyEcal),
00075                                 energyHcal_(energyHcal), type_(type) {
00076                 calowindow_ecal_.reset();
00077                 calowindow_hcal_.reset();
00078                 caloellipse_ecal_.reset();
00079                 caloellipse_hcal_.reset();
00080 
00081         }
00082 
00083         double energy_, eta_, phi_, energyEcal_, energyHcal_;
00084         int cluster_numEcal_, cluster_numHcal_;
00085         int type_;
00086 
00087         CaloWindow calowindow_ecal_;
00088         CaloWindow calowindow_hcal_;
00089 
00090         CaloEllipse caloellipse_ecal_;
00091         CaloEllipse caloellipse_hcal_;
00092 
00093         void reset() {
00094                 energy_ = 0;
00095                 eta_ = 0;
00096                 phi_ = 0;
00097                 energyEcal_ = 0;
00098                 energyHcal_ = 0;
00099                 cluster_numEcal_ = 0;
00100                 cluster_numHcal_ = 0;
00101                 type_ = -1;
00102                 calowindow_ecal_.reset();
00103                 calowindow_hcal_.reset();
00104                 caloellipse_ecal_.reset();
00105                 caloellipse_hcal_.reset();
00106         }
00107 
00108         void recompute() {
00109                 caloellipse_ecal_.makeCaches();
00110                 caloellipse_hcal_.makeCaches();
00111         }
00112 };
00122 class Calibratable {
00123 public:
00124 
00125         Calibratable() {
00126                 reset();
00127         }
00128 
00129         virtual ~Calibratable() {
00130         }
00131 
00135         virtual void reset();
00136 
00145         //truth first
00146         double sim_energyEvent_, sim_eta_, sim_phi_;
00147         double sim_energyEcal_, sim_energyHcal_;
00148         double sim_etaEcal_, sim_etaHcal_, sim_phiEcal_, sim_phiHcal_;
00149         int sim_numEvent_;
00150         //set to true if this event is not real data
00151         bool sim_isMC_;
00152         //test beam specific
00153         bool tb_isTB_;
00154         //where was the TB table?
00155         double tb_eta_, tb_phi_;
00156         //TB run number and PDG particle type
00157         int tb_run_, tb_pdg_;
00158         //Veto counter values
00159         double tb_tof_, tb_ck3_, tb_ck2_;
00160         //Erm, bit complicated this one...
00161         char tb_vetosPassed_;
00162 
00163         //DYNAMIC: Computed from tb_ecal_ and tb_hcal_
00164         double tb_energyEvent_, tb_energyEcal_, tb_energyHcal_;
00165         std::vector<CalibratableElement> tb_ecal_, tb_hcal_;
00166         int tb_numEcal_, tb_numHcal_; //DYNAMIC
00167 
00168         CalibratableElement tb_meanEcal_, tb_meanHcal_; //DYNAMIC
00169 
00170         //leading track
00171         double recotrk_numHits_, recotrk_quality_, recotrk_charge_;
00172         double recotrk_etaEcal_, recotrk_phiEcal_;
00173         //delta phi between sim particle and leading track
00174         double recotrk_deltaRWithSim_;
00175         math::XYZTLorentzVector recotrk_momentum_;
00176 
00177         //CaloWindow class (new for 3_1_X)
00178         CaloWindow calowindow_ecal_;
00179         CaloWindow calowindow_hcal_;
00180 
00181         //pf clusters
00182         //DYNAMIC: Computed from cluster_ecal_ and cluster_hcal_
00183         double cluster_energyEvent_, cluster_energyEcal_, cluster_energyHcal_; //DYNAMIC
00184         std::vector<CalibratableElement> cluster_ecal_, cluster_hcal_;
00185         int cluster_numEcal_, cluster_numHcal_; //DYNAMIC
00186         CalibratableElement cluster_meanEcal_, cluster_meanHcal_; //DYNAMIC
00187 
00188         //pf rechits
00189         //DYNAMIC: Computed from rechits_ecal_ and rechits_hcal_
00190         double rechits_energyEvent_, rechits_energyEcal_, rechits_energyHcal_;
00191         std::vector<CalibratableElement> rechits_ecal_, rechits_hcal_;
00192         int rechits_numEcal_, rechits_numHcal_; //DYNAMIC
00193         CalibratableElement rechits_meanEcal_, rechits_meanHcal_; //DYNAMIC
00194 
00195         //pf candidates
00196         std::vector<CandidateWrapper> cands_;
00197         CandidateWrapper cands_mean_; //DYNAMIC
00198         int cands_num_; //DYNAMIC
00199 
00200         //DYNAMIC: Computed from cands_
00201         double cand_energyEvent_, cand_energyEcal_, cand_energyHcal_, cand_eta_,
00202                         cand_phi_;
00203         double cand_energyNeutralEM_, cand_energyNeutralHad_; //DYNAMIC
00204         int cand_type_; //DYNAMIC
00205 
00206         std::vector<CalibrationResultWrapper> calibrations_;
00207 
00208         //Recomputes cluster and rechit averages using the vectors of DepositDiets
00209         //Users should call this before filling the tree.
00210         virtual void recompute();
00211 
00217         virtual CalibratableElement computeMean(const std::vector<
00218                         CalibratableElement>& diets);
00219 
00225         virtual CandidateWrapper computeMean(
00226                         const std::vector<CandidateWrapper>& wrappers);
00227 
00234         virtual void fillCaloWindow(const std::vector<CalibratableElement>& source,
00235                         CaloWindow& destination) const;
00236 
00237 };
00238 
00239 //typedef boost::shared_ptr<Calibratable> CalibratablePtr;
00240 
00241 std::ostream& operator<<(std::ostream& s, const Calibratable& calib_);
00242 std::ostream& operator<<(std::ostream& s, const CalibratableElement& ce_);
00243 
00244 }
00245 #endif /*CALIBRATABLE_H_*/
00246