CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoMET/METAlgorithms/src/GenSpecificAlgo.cc

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 // This algorithm adds calorimeter specific global event information to 
00012 // the MET object which may be useful/needed for MET Data Quality Monitoring
00013 // and MET cleaning.  This list is not exhaustive and additional 
00014 // information will be added in the future. 
00015 //-------------------------------------
00016 //reco::GenMET GenSpecificAlgo::addInfo(const CandidateCollection *particles, CommonMETData met)
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   // Instantiate the container to hold the calorimeter specific information
00026   SpecificGenMETData specific = SpecificGenMETData();
00027 
00028   // Initialise the container 
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   // tally Et contribution from undecayed genparticles that don't fall into the following classifications (for normalization purposes)
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       //  if "onlyFiducial" is true take only particles within fudical volume AND use pT instead of et if "usePt" is true
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(); // change et-->pt
00067                   sum_ez += iParticle->pz(); // change ez-->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 : // photon
00082             if(usePt){
00083               specific.NeutralEMEtFraction += iParticle->pt();
00084             }else{
00085               specific.NeutralEMEtFraction += iParticle->et();
00086             }
00087             break;
00088           case 11 : // e
00089             if(usePt){
00090             specific.ChargedEMEtFraction += iParticle->pt();
00091             }else{
00092             specific.ChargedEMEtFraction += iParticle->et();
00093             }
00094             break;
00095           case 130 : // K_long
00096           case 310 : // K_short
00097           case 3122: // Lambda
00098           case 2112: // n
00099           case 3222: // Neutral Cascade
00100             if(usePt){
00101               specific.NeutralHadEtFraction += iParticle->pt();
00102             }else{
00103               specific.NeutralHadEtFraction += iParticle->et();
00104             }
00105             break;
00106           case 211 : // pi
00107           case 321 : // K+/K-
00108           case 2212: // p
00109           case 3312: // Cascade -
00110           case 3112: // Sigma -
00111           case 3322: // Sigma + 
00112           case 3334: // Omega - 
00113             if(usePt){
00114               specific.ChargedHadEtFraction += iParticle->pt();
00115             }else{
00116               specific.ChargedHadEtFraction += iParticle->et();
00117             }
00118             break;
00119           case 13 : //muon
00120             if(usePt){
00121               specific.MuonEtFraction += iParticle->pt();
00122             }else{
00123               specific.MuonEtFraction += iParticle->et();
00124             }
00125             break;
00126           case 12 : // e_nu
00127           case 14 : // mu_nu
00128           case 16 : // tau_nu
00129           case 1000022 : // Neutral ~Chi_0 
00130           case 1000012 :  // LH ~e_nu  
00131           case 1000014 :  // LH ~mu_nu
00132           case 1000016 :  // LH ~tau_nu
00133           case 2000012 :  // RH ~e_nu  
00134           case 2000014 :  // RH ~mu_nu
00135           case 2000016 :  // RH ~tau_nu
00136           case 39 :       //  G
00137           case 1000039 :  // ~G
00138           case 5100039 :  // KK G
00139           case 4000012 :  // excited e_nu
00140           case 4000014 :  // excited mu_nu 
00141           case 4000016 :  // excited tau_nu 
00142           case 9900012 :  // Maj e_nu
00143           case 9900014 :  // Maj mu_nu 
00144           case 9900016 :  // Maj tau_nu 
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             //  cout << "PdgId : "<< iParticle->pdgId() << "    " << iParticle->status() << "  does not fall into a category " << endl;
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   // cout << "MET = " << met->met << endl;
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   //Normalize
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   // Instantiate containers for the MET candidate and initialise them with
00186   // the MET information in "met" (of type CommonMETData)
00187   const LorentzVector p4( met->mex, met->mey, met->mez, met->met );
00188   const Point vtx( 0.0, 0.0, 0.0 );
00189   // Create and return an object of type GenMET, which is a MET object with 
00190   // the extra calorimeter specfic information added
00191   GenMET specificmet( specific, met->sumet, p4, vtx );
00192   return specificmet;
00193 }
00194 //-------------------------------------------------------------------------