CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/HLTriggerOffline/Top/src/TopHLTDQMHelper.cc

Go to the documentation of this file.
00001 #include "HLTriggerOffline/Top/interface/TopHLTDQMHelper.h"
00002 #include <iostream>
00003 /*Originally from DQM/Physics package, written by Roger Wolf and Jeremy Andrea*/
00004 
00005 using namespace std;
00006 
00007 CalculateHLT::CalculateHLT(int maxNJets, double wMass): 
00008   failed_(false), maxNJets_(maxNJets), wMass_(wMass), massWBoson_(-1.), massTopQuark_(-1.),tmassWBoson_(-1),tmassTopQuark_(-1),mlb_(-1)
00009 {
00010 }
00011 
00012 
00013 double
00014 CalculateHLT::massWBoson(const std::vector<reco::Jet>& jets)
00015 {
00016   if(!failed_&& massWBoson_<0) operator()(jets); return massWBoson_;
00017 }
00018 
00019 
00020 double 
00021 CalculateHLT::massTopQuark(const std::vector<reco::Jet>& jets) 
00022 { 
00023   if(!failed_&& massTopQuark_<0) operator()(jets); return massTopQuark_; 
00024 }
00025 
00026 /*
00027 double 
00028 Calculate::tmassWBoson(const T& mu, const reco::MET& met, const reco::Jet& b)
00029 {
00030   if(!failed_&& tmassWBoson_<0) operator()(b,mu,met); return tmassWBoson_;
00031 }
00032 
00033 
00034 double
00035 Calculate::masslb(const T& mu, const reco::MET& met, const reco::Jet& b)
00036 {
00037   if(!failed_&& mlb_<0) operator()(b,mu,met); return mlb_;
00038 }
00039 
00040 
00041 double
00042 Calculate::tmassTopQuark(const T& lepton, const reco::MET& met, const reco::Jet& b)
00043 {
00044   if(!failed_&& tmassTopQuark_<0) operator()(b,lepton,met); return tmassTopQuark_;
00045 }
00046 
00047 
00048 void Calculate::operator()( const reco::Jet& bJet, const T& lepton, const reco::MET& met){
00049   reco::Particle::LorentzVector WT = lepton.p4() + met.p4();
00050   tmassWBoson_ = sqrt((WT.px()*WT.px()) + (WT.py()*WT.py()));   
00051   reco::Particle::LorentzVector topT = WT + bJet.p4();
00052   tmassTopQuark_ = sqrt((topT.px()*topT.px()) + (topT.py()*topT.py()));
00053   reco::Particle::LorentzVector lb = bJet.p4() + lepton.p4();  
00054   mlb_ = lb.mass();
00055 }*/
00056 
00057 
00058 double 
00059 CalculateHLT::tmassWBoson(reco::RecoCandidate* mu, const reco::MET& met, const reco::Jet& b)
00060 {
00061   if(!failed_&& tmassWBoson_<0) operator()(b,mu,met); return tmassWBoson_;
00062 }
00063 
00064 
00065 double
00066 CalculateHLT::masslb(reco::RecoCandidate* mu, const reco::MET& met, const reco::Jet& b)
00067 {
00068   if(!failed_&& mlb_<0) operator()(b,mu,met); return mlb_;
00069 }
00070 
00071 
00072 double
00073 CalculateHLT::tmassTopQuark(reco::RecoCandidate* lepton, const reco::MET& met, const reco::Jet& b)
00074 {
00075   if(!failed_&& tmassTopQuark_<0) operator()(b,lepton,met); return tmassTopQuark_;
00076 }
00077 
00078 
00079 void CalculateHLT::operator()( const reco::Jet& bJet, reco::RecoCandidate* lepton, const reco::MET& met){
00080   double metT = sqrt(pow(met.px(),2) + pow(met.py(),2));
00081   double lepT = sqrt(pow(lepton->px(),2) + pow(lepton->py(),2));
00082   double bT   = sqrt(pow(bJet.px(),2) + pow(bJet.py(),2));
00083   reco::Particle::LorentzVector WT = lepton->p4() + met.p4();
00084   cout<<"in calculate:\n\t"<<bJet.pt()<<"\t"<<lepton->pt()<<"\t"<<met.pt()<<endl;
00085   tmassWBoson_ = sqrt(pow(metT+lepT,2) - (WT.px()*WT.px()) - (WT.py()*WT.py()));        
00086   reco::Particle::LorentzVector topT = WT + bJet.p4();
00087   tmassTopQuark_ = sqrt(pow((metT+lepT+bT),2) - (topT.px()*topT.px()) - (topT.py()*topT.py()));
00088   reco::Particle::LorentzVector lb = bJet.p4() + lepton->p4();  
00089   mlb_ = lb.mass();
00090 }
00091 
00092 
00093 void
00094 CalculateHLT::operator()(const std::vector<reco::Jet>& jets)
00095 {
00096   
00097   if(maxNJets_<0) maxNJets_=jets.size();
00098   failed_= jets.size()<(unsigned int) maxNJets_;
00099   if( failed_){ return; }
00100 
00101   // associate those jets with maximum pt of the vectorial 
00102   // sum to the hadronic decay chain
00103   double maxPt=-1.;
00104   std::vector<int> maxPtIndices;
00105   maxPtIndices.push_back(-1);
00106   maxPtIndices.push_back(-1);
00107   maxPtIndices.push_back(-1);
00108   for(int idx=0; idx<maxNJets_; ++idx){
00109     for(int jdx=0; jdx<maxNJets_; ++jdx){ if(jdx<=idx) continue;
00110       for(int kdx=0; kdx<maxNJets_; ++kdx){ if(kdx==idx || kdx==jdx) continue;
00111         reco::Particle::LorentzVector sum = jets[idx].p4()+jets[jdx].p4()+jets[kdx].p4();
00112         if( maxPt<0. || maxPt<sum.pt() ){
00113           maxPt=sum.pt();
00114           maxPtIndices.clear();
00115           maxPtIndices.push_back(idx);
00116           maxPtIndices.push_back(jdx);
00117           maxPtIndices.push_back(kdx);
00118         }
00119       }
00120     }
00121   }
00122   massTopQuark_= (jets[maxPtIndices[0]].p4()+
00123                   jets[maxPtIndices[1]].p4()+
00124                   jets[maxPtIndices[2]].p4()).mass();
00125 
00126   // associate those jets that get closest to the W mass
00127   // with their invariant mass to the W boson
00128   double wDist =-1.;
00129   std::vector<int> wMassIndices;
00130   wMassIndices.push_back(-1);
00131   wMassIndices.push_back(-1);
00132   for(unsigned idx=0; idx<maxPtIndices.size(); ++idx){  
00133     for(unsigned jdx=0; jdx<maxPtIndices.size(); ++jdx){  
00134       if( jdx==idx || maxPtIndices[idx]>maxPtIndices[jdx] ) continue;
00135         reco::Particle::LorentzVector sum = jets[maxPtIndices[idx]].p4()+jets[maxPtIndices[jdx]].p4();
00136         if( wDist<0. || wDist>fabs(sum.mass()-wMass_) ){
00137           wDist=fabs(sum.mass()-wMass_);
00138           wMassIndices.clear();
00139           wMassIndices.push_back(maxPtIndices[idx]);
00140           wMassIndices.push_back(maxPtIndices[jdx]);
00141         }
00142     }
00143   }
00144   massWBoson_= (jets[wMassIndices[0]].p4()+
00145                 jets[wMassIndices[1]].p4()).mass();
00146 }
00147 
00148 
00149