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