CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/Physics/src/TopDQMHelpers.cc

Go to the documentation of this file.
00001 #include "DQM/Physics/interface/TopDQMHelpers.h"
00002 
00003 Calculate::Calculate(int maxNJets, double wMass): 
00004   failed_(false), maxNJets_(maxNJets), wMass_(wMass), massWBoson_(-1.), massTopQuark_(-1.)
00005 {
00006 }
00007 
00008 double
00009 Calculate::massWBoson(const std::vector<reco::Jet>& jets)
00010 {
00011   if(!failed_&& massWBoson_<0) operator()(jets); return massWBoson_;
00012 }
00013 
00014 double 
00015 Calculate::massTopQuark(const std::vector<reco::Jet>& jets) 
00016 { 
00017   if(!failed_&& massTopQuark_<0) operator()(jets); return massTopQuark_; 
00018 }
00019 
00020 void
00021 Calculate::operator()(const std::vector<reco::Jet>& jets)
00022 {
00023   if(maxNJets_<0) maxNJets_=jets.size();
00024   failed_= jets.size()<(unsigned int) maxNJets_;
00025   if( failed_){ return; }
00026 
00027   // associate those jets with maximum pt of the vectorial 
00028   // sum to the hadronic decay chain
00029   double maxPt=-1.;
00030   std::vector<int> maxPtIndices;
00031   maxPtIndices.push_back(-1);
00032   maxPtIndices.push_back(-1);
00033   maxPtIndices.push_back(-1);
00034   for(int idx=0; idx<maxNJets_; ++idx){
00035     for(int jdx=0; jdx<maxNJets_; ++jdx){ if(jdx<=idx) continue;
00036       for(int kdx=0; kdx<maxNJets_; ++kdx){ if(kdx==idx || kdx==jdx) continue;
00037         reco::Particle::LorentzVector sum = jets[idx].p4()+jets[jdx].p4()+jets[kdx].p4();
00038         if( maxPt<0. || maxPt<sum.pt() ){
00039           maxPt=sum.pt();
00040           maxPtIndices.clear();
00041           maxPtIndices.push_back(idx);
00042           maxPtIndices.push_back(jdx);
00043           maxPtIndices.push_back(kdx);
00044         }
00045       }
00046     }
00047   }
00048   massTopQuark_= (jets[maxPtIndices[0]].p4()+
00049                   jets[maxPtIndices[1]].p4()+
00050                   jets[maxPtIndices[2]].p4()).mass();
00051 
00052   // associate those jets that get closest to the W mass
00053   // with their invariant mass to the W boson
00054   double wDist =-1.;
00055   std::vector<int> wMassIndices;
00056   wMassIndices.push_back(-1);
00057   wMassIndices.push_back(-1);
00058   for(unsigned idx=0; idx<maxPtIndices.size(); ++idx){  
00059     for(unsigned jdx=0; jdx<maxPtIndices.size(); ++jdx){  
00060       if( jdx==idx || maxPtIndices[idx]>maxPtIndices[jdx] ) continue;
00061         reco::Particle::LorentzVector sum = jets[maxPtIndices[idx]].p4()+jets[maxPtIndices[jdx]].p4();
00062         if( wDist<0. || wDist>fabs(sum.mass()-wMass_) ){
00063           wDist=fabs(sum.mass()-wMass_);
00064           wMassIndices.clear();
00065           wMassIndices.push_back(maxPtIndices[idx]);
00066           wMassIndices.push_back(maxPtIndices[jdx]);
00067         }
00068     }
00069   }
00070   massWBoson_= (jets[wMassIndices[0]].p4()+
00071                 jets[wMassIndices[1]].p4()).mass();
00072 }