Go to the documentation of this file.00001 #include "DataFormats/Math/interface/LorentzVector.h"
00002 #include "RecoMET/METAlgorithms/interface/GenSpecificAlgo.h"
00003 #include "DataFormats/Candidate/interface/Candidate.h"
00004 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00005 #include "DataFormats/METReco/interface/CommonMETData.h"
00006 #include "TMath.h"
00007 using namespace reco;
00008 using namespace std;
00009
00010
00011
00012
00013
00014
00015
00016
00017 reco::GenMET GenSpecificAlgo::addInfo(edm::Handle<edm::View<Candidate> > particles, CommonMETData *met, double globalThreshold, bool onlyFiducial, bool usePt)
00018 {
00019
00020 double sum_et = 0.0;
00021 double sum_ex = 0.0;
00022 double sum_ey = 0.0;
00023 double sum_ez = 0.0;
00024
00025
00026 SpecificGenMETData specific = SpecificGenMETData();
00027
00028
00029 specific.NeutralEMEtFraction = 0.0;
00030 specific.NeutralHadEtFraction = 0.0;
00031 specific.ChargedEMEtFraction = 0.0;
00032 specific.ChargedHadEtFraction = 0.0;
00033 specific.MuonEtFraction = 0.0;
00034 specific.InvisibleEtFraction = 0.0;
00035
00036
00037 double Et_unclassified = 0.;
00038
00039 for( edm::View<reco::Candidate>::const_iterator iParticle = (particles.product())->begin() ; iParticle != (particles.product())->end() ; iParticle++ )
00040 {
00041
00042
00043
00044 if(!onlyFiducial || (onlyFiducial && TMath::Abs(iParticle->eta()) < 5.0))
00045 {
00046 if(!usePt)
00047 {
00048 if( iParticle->et() > globalThreshold )
00049 {
00050 double phi = iParticle->phi();
00051 double theta = iParticle->theta();
00052 double e = iParticle->energy();
00053 double et = e*sin(theta);
00054 sum_ez += e*cos(theta);
00055 sum_et += et;
00056 sum_ex += et*cos(phi);
00057 sum_ey += et*sin(phi);
00058 }
00059 }
00060
00061 if(usePt)
00062 {
00063 if( iParticle->pt() > globalThreshold )
00064 {
00065 double phi = iParticle->phi();
00066 double et = iParticle->pt();
00067 sum_ez += iParticle->pz();
00068 sum_et += et;
00069 sum_ex += et*cos(phi);
00070 sum_ey += et*sin(phi);
00071 }
00072 }
00073 }
00074
00075
00076
00077 int pdgId = TMath::Abs( iParticle->pdgId() ) ;
00078
00079 switch (pdgId) {
00080
00081 case 22 :
00082 if(usePt){
00083 specific.NeutralEMEtFraction += iParticle->pt();
00084 }else{
00085 specific.NeutralEMEtFraction += iParticle->et();
00086 }
00087 break;
00088 case 11 :
00089 if(usePt){
00090 specific.ChargedEMEtFraction += iParticle->pt();
00091 }else{
00092 specific.ChargedEMEtFraction += iParticle->et();
00093 }
00094 break;
00095 case 130 :
00096 case 310 :
00097 case 3122:
00098 case 2112:
00099 case 3222:
00100 if(usePt){
00101 specific.NeutralHadEtFraction += iParticle->pt();
00102 }else{
00103 specific.NeutralHadEtFraction += iParticle->et();
00104 }
00105 break;
00106 case 211 :
00107 case 321 :
00108 case 2212:
00109 case 3312:
00110 case 3112:
00111 case 3322:
00112 case 3334:
00113 if(usePt){
00114 specific.ChargedHadEtFraction += iParticle->pt();
00115 }else{
00116 specific.ChargedHadEtFraction += iParticle->et();
00117 }
00118 break;
00119 case 13 :
00120 if(usePt){
00121 specific.MuonEtFraction += iParticle->pt();
00122 }else{
00123 specific.MuonEtFraction += iParticle->et();
00124 }
00125 break;
00126 case 12 :
00127 case 14 :
00128 case 16 :
00129 case 1000022 :
00130 case 1000012 :
00131 case 1000014 :
00132 case 1000016 :
00133 case 2000012 :
00134 case 2000014 :
00135 case 2000016 :
00136 case 39 :
00137 case 1000039 :
00138 case 5100039 :
00139 case 4000012 :
00140 case 4000014 :
00141 case 4000016 :
00142 case 9900012 :
00143 case 9900014 :
00144 case 9900016 :
00145 if(usePt){
00146 specific.InvisibleEtFraction += iParticle->pt();
00147 }else {
00148 specific.InvisibleEtFraction += iParticle->et();
00149 }
00150 break;
00151 default :
00152 if(usePt){
00153 Et_unclassified += iParticle->pt();
00154 }else{
00155 Et_unclassified += iParticle->et();
00156 }
00157
00158
00159
00160 }
00161 }
00162
00163 met->mex = -sum_ex;
00164 met->mey = -sum_ey;
00165 met->mez = -sum_ez;
00166 met->met = sqrt( sum_ex*sum_ex + sum_ey*sum_ey );
00167
00168 met->sumet = sum_et;
00169 met->phi = atan2( -sum_ey, -sum_ex );
00170
00171 double Et_Total = specific.NeutralEMEtFraction + specific.NeutralHadEtFraction + specific.ChargedEMEtFraction +
00172 specific.ChargedHadEtFraction + specific.MuonEtFraction + specific.InvisibleEtFraction + Et_unclassified;
00173
00174
00175 if( Et_Total )
00176 {
00177 specific.NeutralEMEtFraction /= Et_Total;
00178 specific.NeutralHadEtFraction /= Et_Total;
00179 specific.ChargedEMEtFraction /= Et_Total;
00180 specific.ChargedHadEtFraction /= Et_Total;
00181 specific.MuonEtFraction /= Et_Total;
00182 specific.InvisibleEtFraction /= Et_Total;
00183 }
00184
00185
00186
00187 const LorentzVector p4( met->mex, met->mey, met->mez, met->met );
00188 const Point vtx( 0.0, 0.0, 0.0 );
00189
00190
00191 GenMET specificmet( specific, met->sumet, p4, vtx );
00192 return specificmet;
00193 }
00194