Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:22

0001 //
0002 //
0003 
0004 #include "TopQuarkAnalysis/TopJetCombination/interface/TtSemiSimpleBestJetComb.h"
0005 
0006 TtSemiSimpleBestJetComb::TtSemiSimpleBestJetComb() {}
0007 
0008 TtSemiSimpleBestJetComb::~TtSemiSimpleBestJetComb() {}
0009 
0010 int TtSemiSimpleBestJetComb::operator()(std::vector<TtSemiEvtSolution>& sols) {
0011   // search the highest probChi^2 value in the among the different jet combination solutions
0012   double maxProbChi2 = 0;
0013   for (unsigned int s = 0; s < sols.size(); s++)
0014     maxProbChi2 = std::max(maxProbChi2, sols[s].getProbChi2());
0015 
0016   //search indices of original solutions with highest probChi2 value
0017   std::vector<unsigned int> indices;
0018   indices.clear();
0019   for (unsigned int s = 0; s < sols.size(); s++) {
0020     if (fabs(sols[s].getProbChi2() - maxProbChi2) < 0.0001)
0021       indices.push_back(s);
0022   }
0023 
0024   int bestSol = -999;
0025   if (maxProbChi2 > 0.) {
0026     if (indices.size() == 1)
0027       bestSol = indices[0];
0028     if (indices.size() == 2) {
0029       //typically only light jets constraints applied, so still b-jet ambiguity to resolve
0030       // -> look at DPhi(Whadr,bhadr) and choose smallest value
0031       double DPhi_Wb0 = fabs(sols[indices[0]].getFitHadW().phi() - sols[indices[0]].getFitHadb().phi());
0032       double DPhi_Wb1 = fabs(sols[indices[1]].getFitHadW().phi() - sols[indices[1]].getFitHadb().phi());
0033       if (DPhi_Wb0 > 3.1415)
0034         DPhi_Wb0 = 2. * 3.1415 - DPhi_Wb0;
0035       if (DPhi_Wb1 > 3.1415)
0036         DPhi_Wb1 = 2. * 3.1415 - DPhi_Wb1;
0037       if (DPhi_Wb0 < DPhi_Wb1) {
0038         bestSol = indices[0];
0039       } else {
0040         bestSol = indices[1];
0041       }
0042     }
0043   }
0044   return bestSol;
0045 }