00001
00002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00003
00004 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00005 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00006 #include "DataFormats/DetId/interface/DetId.h"
00007 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
00008 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
00009 #include "Calibration/Tools/interface/calibXMLwriter.h"
00010 #include "Calibration/Tools/interface/CalibrationCluster.h"
00011 #include "Calibration/Tools/interface/HouseholderDecomposition.h"
00012 #include "Calibration/Tools/interface/MinL3Algorithm.h"
00013 #include "Calibration/EcalCalibAlgos/interface/ZeeKinematicTools.h"
00014 #include "Calibration/Tools/interface/ZIterativeAlgorithmWithFit.h"
00015 #include "DataFormats/EgammaCandidates/interface/Electron.h"
00016 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00017 #include "DataFormats/TrackReco/interface/Track.h"
00018 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00019 #include "DataFormats/TrackReco/interface/TrackExtraFwd.h"
00020 #include "TFile.h"
00021 #include "TH1.h"
00022 #include "TH2.h"
00023 #include "TF1.h"
00024 #include "TRandom.h"
00025
00026
00027 #include <iostream>
00028 #include <string>
00029 #include <stdexcept>
00030 #include <vector>
00031
00032 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00033
00034 ZeeKinematicTools::ZeeKinematicTools(){}
00035
00036 ZeeKinematicTools::~ZeeKinematicTools(){}
00037
00038
00039
00040
00041
00042 float ZeeKinematicTools::cosThetaElectrons_SC( const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate, float ele1EnergyCorrection, float ele2EnergyCorrection ){
00043
00044 float theta1 = 2. * atan( exp(- aZCandidate.first->getRecoElectron()->superCluster()->eta()) );
00045 float phi1 = aZCandidate.first->getRecoElectron()->superCluster()->phi();
00046
00047 float x1 = aZCandidate.first->getRecoElectron()->superCluster()->energy() * sin(theta1) * cos ( phi1 );
00048 float y1 = aZCandidate.first->getRecoElectron()->superCluster()->energy() * sin(theta1) * sin ( phi1 );
00049 float z1 = aZCandidate.first->getRecoElectron()->superCluster()->energy() * cos(theta1);
00050 float mod1 = sqrt( x1*x1 + y1*y1 + z1*z1 );
00051
00052 float theta2 = 2. * atan( exp(- aZCandidate.second->getRecoElectron()->superCluster()->eta()) );
00053 float phi2 = aZCandidate.second->getRecoElectron()->superCluster()->phi();
00054
00055 float x2 = aZCandidate.second->getRecoElectron()->superCluster()->energy() * sin(theta2) * cos ( phi2 );
00056 float y2 = aZCandidate.second->getRecoElectron()->superCluster()->energy() * sin(theta2) * sin ( phi2 );
00057 float z2 = aZCandidate.second->getRecoElectron()->superCluster()->energy() * cos(theta2);
00058 float mod2 = sqrt( x2*x2 + y2*y2 + z2*z2 );
00059
00060 return (x1*x2 + y1*y2 + z1*z2)/( mod1* mod2 );
00061
00062
00063 }
00064
00065
00066
00067 float ZeeKinematicTools::cosThetaElectrons_TK( const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate, float ele1EnergyCorrection, float ele2EnergyCorrection ){
00068
00069 float theta1 = 2. * atan( exp(- aZCandidate.first->getRecoElectron()->eta()) );
00070 float phi1 = aZCandidate.first->getRecoElectron()->phi();
00071
00072 float x1 = aZCandidate.first->getRecoElectron()->superCluster()->energy() * sin(theta1) * cos ( phi1 );
00073 float y1 = aZCandidate.first->getRecoElectron()->superCluster()->energy() * sin(theta1) * sin ( phi1 );
00074 float z1 = aZCandidate.first->getRecoElectron()->superCluster()->energy() * cos(theta1);
00075 float mod1 = sqrt( x1*x1 + y1*y1 + z1*z1 );
00076
00077 float theta2 = 2. * atan( exp(- aZCandidate.second->getRecoElectron()->eta()) );
00078 float phi2 = aZCandidate.second->getRecoElectron()->phi();
00079
00080 float x2 = aZCandidate.second->getRecoElectron()->superCluster()->energy() * sin(theta2) * cos ( phi2 );
00081 float y2 = aZCandidate.second->getRecoElectron()->superCluster()->energy() * sin(theta2) * sin ( phi2 );
00082 float z2 = aZCandidate.second->getRecoElectron()->superCluster()->energy() * cos(theta2);
00083 float mod2 = sqrt( x2*x2 + y2*y2 + z2*z2 );
00084
00085 return (x1*x2 + y1*y2 + z1*z2)/( mod1* mod2 );
00086 }
00087
00088
00089
00090 float ZeeKinematicTools::calculateZMassWithCorrectedElectrons_noTK(const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate, float ele1EnergyCorrection, float ele2EnergyCorrection)
00091 {
00092 return ZIterativeAlgorithmWithFit::invMassCalc(aZCandidate.first->getRecoElectron()->superCluster()->energy() / ele1EnergyCorrection, aZCandidate.first->getRecoElectron()->superCluster()->eta(), aZCandidate.first->getRecoElectron()->superCluster()->phi(), aZCandidate.second->getRecoElectron()->superCluster()->energy() / ele2EnergyCorrection, aZCandidate.second->getRecoElectron()->superCluster()->eta(), aZCandidate.second->getRecoElectron()->superCluster()->phi());
00093
00094 }
00095
00096
00097
00098 float ZeeKinematicTools::calculateZMassWithCorrectedElectrons_withTK(const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate, float ele1EnergyCorrection, float ele2EnergyCorrection)
00099 {
00100 return ZIterativeAlgorithmWithFit::invMassCalc(aZCandidate.first->getRecoElectron()->superCluster()->energy() / ele1EnergyCorrection, aZCandidate.first->getRecoElectron()->eta(), aZCandidate.first->getRecoElectron()->phi(), aZCandidate.second->getRecoElectron()->superCluster()->energy() / ele2EnergyCorrection, aZCandidate.second->getRecoElectron()->eta(), aZCandidate.second->getRecoElectron()->phi());
00101
00102 }
00103
00104
00105
00106 float ZeeKinematicTools::calculateZMass_noTK(const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate)
00107 {
00108
00109 return ZIterativeAlgorithmWithFit::invMassCalc(aZCandidate.first->getRecoElectron()->superCluster()->energy(), aZCandidate.first->getRecoElectron()->superCluster()->eta(), aZCandidate.first->getRecoElectron()->superCluster()->phi(), aZCandidate.second->getRecoElectron()->superCluster()->energy(), aZCandidate.second->getRecoElectron()->superCluster()->eta(), aZCandidate.second->getRecoElectron()->superCluster()->phi());
00110
00111 }
00112
00113
00114
00115 float ZeeKinematicTools::calculateZMass_withTK(const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate)
00116 {
00117
00118 return ZIterativeAlgorithmWithFit::invMassCalc(aZCandidate.first->getRecoElectron()->superCluster()->energy(), aZCandidate.first->getRecoElectron()->eta(), aZCandidate.first->getRecoElectron()->phi(), aZCandidate.second->getRecoElectron()->superCluster()->energy(), aZCandidate.second->getRecoElectron()->eta(), aZCandidate.second->getRecoElectron()->phi());
00119
00120 }
00121
00122
00123
00124 float ZeeKinematicTools::calculateZRapidity(const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate)
00125 {
00126
00127 TLorentzVector ele1LV( aZCandidate.first->getRecoElectron()->px(), aZCandidate.first->getRecoElectron()->py(), aZCandidate.first->getRecoElectron()->pz(), aZCandidate.first->getRecoElectron()->superCluster()->energy());
00128
00129 TLorentzVector ele2LV( aZCandidate.second->getRecoElectron()->px(), aZCandidate.second->getRecoElectron()->py(), aZCandidate.second->getRecoElectron()->pz(), aZCandidate.second->getRecoElectron()->superCluster()->energy());
00130
00131
00132 return (ele1LV + ele2LV).Rapidity();
00133
00134 }
00135
00136
00137
00138 float ZeeKinematicTools::calculateZEta(const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate)
00139 {
00140
00141 TLorentzVector ele1LV( aZCandidate.first->getRecoElectron()->px(), aZCandidate.first->getRecoElectron()->py(), aZCandidate.first->getRecoElectron()->pz(), aZCandidate.first->getRecoElectron()->superCluster()->energy());
00142
00143 TLorentzVector ele2LV( aZCandidate.second->getRecoElectron()->px(), aZCandidate.second->getRecoElectron()->py(), aZCandidate.second->getRecoElectron()->pz(), aZCandidate.second->getRecoElectron()->superCluster()->energy());
00144
00145 return (ele1LV + ele2LV).Eta();
00146
00147 }
00148
00149
00150
00151 float ZeeKinematicTools::calculateZTheta(const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate)
00152 {
00153
00154 TLorentzVector ele1LV( aZCandidate.first->getRecoElectron()->px(), aZCandidate.first->getRecoElectron()->py(), aZCandidate.first->getRecoElectron()->pz(), aZCandidate.first->getRecoElectron()->superCluster()->energy());
00155
00156 TLorentzVector ele2LV( aZCandidate.second->getRecoElectron()->px(), aZCandidate.second->getRecoElectron()->py(), aZCandidate.second->getRecoElectron()->pz(), aZCandidate.second->getRecoElectron()->superCluster()->energy());
00157
00158 return (ele1LV + ele2LV).Theta();
00159
00160 }
00161
00162
00163
00164 float ZeeKinematicTools::calculateZPhi(const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate)
00165 {
00166
00167 TLorentzVector ele1LV( aZCandidate.first->getRecoElectron()->px(), aZCandidate.first->getRecoElectron()->py(), aZCandidate.first->getRecoElectron()->pz(), aZCandidate.first->getRecoElectron()->superCluster()->energy());
00168
00169 TLorentzVector ele2LV( aZCandidate.second->getRecoElectron()->px(), aZCandidate.second->getRecoElectron()->py(), aZCandidate.second->getRecoElectron()->pz(), aZCandidate.second->getRecoElectron()->superCluster()->energy());
00170
00171 return (ele1LV + ele2LV).Phi();
00172
00173 }
00174
00175
00176
00177 float ZeeKinematicTools::calculateZPt(const std::pair<calib::CalibElectron*,calib::CalibElectron*>& aZCandidate)
00178 {
00179
00180 TLorentzVector ele1LV( aZCandidate.first->getRecoElectron()->px(), aZCandidate.first->getRecoElectron()->py(), aZCandidate.first->getRecoElectron()->pz(), aZCandidate.first->getRecoElectron()->superCluster()->energy());
00181
00182 TLorentzVector ele2LV( aZCandidate.second->getRecoElectron()->px(), aZCandidate.second->getRecoElectron()->py(), aZCandidate.second->getRecoElectron()->pz(), aZCandidate.second->getRecoElectron()->superCluster()->energy());
00183
00184 return (ele1LV + ele2LV).Pt();
00185
00186 }
00187
00188
00189