CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/TopQuarkAnalysis/TopEventSelection/src/TtHadLRSignalSelObservables.cc

Go to the documentation of this file.
00001 #include "TopQuarkAnalysis/TopEventSelection/interface/TtHadLRSignalSelObservables.h"
00002 
00003 TtHadLRSignalSelObservables::TtHadLRSignalSelObservables()
00004 {
00005 }
00006 
00007 TtHadLRSignalSelObservables::~TtHadLRSignalSelObservables()
00008 {
00009 }
00010 
00011 void TtHadLRSignalSelObservables::operator() (TtHadEvtSolution &TS)
00012 {
00013   evtselectVarVal.clear();
00014   std::vector<pat::Jet> topJets;
00015   topJets.clear();
00016   topJets.push_back(TS.getHadp());
00017   topJets.push_back(TS.getHadq());
00018   topJets.push_back(TS.getHadj());
00019   topJets.push_back(TS.getHadk());
00020   topJets.push_back(TS.getHadb());
00021   topJets.push_back(TS.getHadbbar());
00022   
00023   //Assume the highest Et jets are the b-jets, the others the jets from the W - but how to work out which two are from which W? FIXME!!! for now don't sort jets in Et before after this...
00024   TLorentzVector *Hadp = new TLorentzVector();  
00025   TLorentzVector *Hadq = new TLorentzVector();
00026   TLorentzVector *Hadj = new TLorentzVector();  
00027   TLorentzVector *Hadk = new TLorentzVector();
00028   TLorentzVector *Hadb = new TLorentzVector();  
00029   TLorentzVector *Hadbbar = new TLorentzVector();
00030   Hadp->SetPxPyPzE(topJets[0].px(),topJets[0].py(),topJets[0].pz(),topJets[3].energy());
00031   Hadq->SetPxPyPzE(topJets[1].px(),topJets[1].py(),topJets[1].pz(),topJets[2].energy());        
00032   Hadj->SetPxPyPzE(topJets[2].px(),topJets[2].py(),topJets[2].pz(),topJets[2].energy());
00033   Hadk->SetPxPyPzE(topJets[3].px(),topJets[3].py(),topJets[3].pz(),topJets[3].energy());
00034   Hadb->SetPxPyPzE(topJets[4].px(),topJets[4].py(),topJets[4].pz(),topJets[1].energy());
00035   Hadbbar->SetPxPyPzE(topJets[4].px(),topJets[4].py(),topJets[4].pz(),topJets[1].energy());
00036   
00037   //sort the topJets in Et
00038   std::sort(topJets.begin(),topJets.end(),EtComparator);
00039   
00040   //Et-Sum of the lightest jets
00041   double EtSum = topJets[5].et()+topJets[5].et();
00042   double Obs1 = (EtSum>0 ? EtSum : -1);
00043   evtselectVarVal.push_back(std::pair<unsigned int,double>(1,Obs1));
00044   
00045   //Log of the difference in Bdisc between the 2nd and the 3rd jets (ordered in Bdisc) - does that still
00046   //make sense for the fully hadronic channel as well?FIXME!!!
00047   
00048   //sort the jets in Bdiscriminant
00049   std::sort(topJets.begin(),topJets.end(),BdiscComparator);
00050   
00051   double BGap = topJets[1].bDiscriminator("trackCountingJetTags") - topJets[2].bDiscriminator("trackCountingJetTags");
00052   double Obs2 = (BGap>0 ? log(BGap) : -1);
00053   evtselectVarVal.push_back(std::pair<unsigned int,double>(2,Obs2));
00054   
00055   //Circularity of the event
00056   double N=0,D=0,C_tmp=0,C=1000;
00057   double nx,ny,nz;
00058   
00059   // C = 2min(E(pt.n)^2/E(pt)^2) = 2*N/D but it is theorically preferable to use C'=PI/2*min(E|pt.n|/E|pt|), sum over all jets+lepton+MET (cf PhysRevD 48 R3953(Nov 1993))
00060   
00061   for(unsigned int i=0;i<6;i++){
00062     D += fabs(topJets[i].pt());
00063   }
00064   
00065   if((D>0)){
00066     // Loop over all the unit vectors in the transverse plane in order to find the miminum : 
00067     for(unsigned int i=0; i<360; i++){
00068       nx = cos((2*PI/360)*i);
00069       ny = sin((2*PI/360)*i);
00070       nz = 0;
00071       N=0;
00072       for(unsigned int i=0;i<4;i++){
00073         N += fabs(topJets[i].px()*nx+topJets[i].py()*ny+topJets[i].pz()*nz);
00074       }
00075       C_tmp = 2*N/D;
00076       if(C_tmp<C) C = C_tmp;
00077     }
00078   }
00079   
00080   double Obs3 = ( C!=1000 ? C : -1);
00081   evtselectVarVal.push_back(std::pair<unsigned int,double>(3,Obs3));
00082   
00083   
00084   //HT variable (Et-sum of the six jets)
00085   double HT=0;
00086   for(unsigned int i=0;i<6;i++){
00087     HT += topJets[i].et();
00088   }
00089   
00090   double Obs4 = ( HT!=0 ? HT : -1);
00091   evtselectVarVal.push_back(std::pair<unsigned int,double>(4,Obs4));
00092   
00093   //Transverse Mass of the system
00094   math::XYZTLorentzVector pjets;
00095   // for the six jets 
00096   for(unsigned int i=0;i<6;i++){
00097     pjets += topJets[i].p4();
00098   }
00099   double MT = sqrt(std::pow(pjets.mass(),2));
00100   double Obs5 = ( MT>0 ? MT : -1);
00101   evtselectVarVal.push_back(std::pair<unsigned int,double>(5,Obs5));
00102   
00103   //CosTheta(Hadp,Hadq) and CosTheta(Hadj,Hadq) 
00104   //sort the lightJets in Et
00105   std::sort(topJets.begin(),topJets.end(),EtComparator);
00106   
00107   double px1 = topJets[2].px();     double px2 = topJets[3].px();
00108   double py1 = topJets[2].py();     double py2 = topJets[3].py();
00109   double pz1 = topJets[2].pz();     double pz2 = topJets[3].pz();
00110   double E1  = topJets[2].energy(); double E2  = topJets[3].energy();
00111   double px3 = topJets[4].px();     double px4 = topJets[5].px();
00112   double py3 = topJets[4].py();     double py4 = topJets[5].py();
00113   double pz3 = topJets[4].pz();     double pz4 = topJets[5].pz();
00114   double E3  = topJets[4].energy(); double E4  = topJets[5].energy();
00115   
00116   TLorentzVector *LightJet1 = new TLorentzVector();
00117   TLorentzVector *LightJet2 = new TLorentzVector();
00118   TLorentzVector *LightJet3 = new TLorentzVector();
00119   TLorentzVector *LightJet4 = new TLorentzVector();
00120   
00121   LightJet1->SetPxPyPzE(px1,py1,pz1,E1);
00122   //LightJet1->Boost(BoostBackToCM);
00123   LightJet2->SetPxPyPzE(px2,py2,pz2,E2);
00124   //LightJet2->Boost(BoostBackToCM);
00125   LightJet3->SetPxPyPzE(px3,py3,pz3,E3);
00126   //LightJet1->Boost(BoostBackToCM);
00127   LightJet4->SetPxPyPzE(px4,py4,pz4,E4);
00128   //LightJet2->Boost(BoostBackToCM);
00129   
00130   double CosTheta1 = cos(LightJet2->Angle(LightJet1->Vect()));
00131   double CosTheta2 = cos(LightJet4->Angle(LightJet3->Vect()));
00132   
00133   double Obs6 = ( -1<CosTheta1 ? CosTheta1 : -2);
00134   evtselectVarVal.push_back(std::pair<unsigned int,double>(6,Obs6));
00135   double Obs7 = ( -1<CosTheta2 ? CosTheta2 : -2);
00136   evtselectVarVal.push_back(std::pair<unsigned int,double>(7,Obs7));
00137   
00138   delete LightJet1;
00139   delete LightJet2;
00140   delete LightJet3;
00141   delete LightJet4;
00142   
00143   // try to find out more powerful observables related to the b-disc
00144   //sort the jets in Bdiscriminant
00145   std::sort(topJets.begin(),topJets.end(),BdiscComparator);
00146   
00147   double BjetsBdiscSum = topJets[0].bDiscriminator("trackCountingJetTags") + topJets[1].bDiscriminator("trackCountingJetTags");
00148   double Ljets1BdiscSum = topJets[2].bDiscriminator("trackCountingJetTags") + topJets[3].bDiscriminator("trackCountingJetTags");
00149   double Ljets2BdiscSum = topJets[4].bDiscriminator("trackCountingJetTags") + topJets[5].bDiscriminator("trackCountingJetTags");
00150   //std::cout<<"BjetsBdiscSum = "<<BjetsBdiscSum<<std::endl;
00151   //std::cout<<"LjetsBdiscSum = "<<LjetsBdiscSum<<std::endl;
00152   
00153   double Obs8 = (Ljets1BdiscSum !=0 ? log(BjetsBdiscSum/Ljets1BdiscSum) : -1);
00154   evtselectVarVal.push_back(std::pair<unsigned int,double>(8,Obs8));    
00155   double Obs9 = (Ljets2BdiscSum !=0 ? log(BjetsBdiscSum/Ljets2BdiscSum) : -1);
00156   evtselectVarVal.push_back(std::pair<unsigned int,double>(9,Obs9));
00157   double Obs10 = (BGap>0 ? log(BjetsBdiscSum*BGap) : -1);
00158   evtselectVarVal.push_back(std::pair<unsigned int,double>(10,Obs10));
00159   
00160   
00161   // Et-Ratio between the two highest in Et jets and four highest jets  
00162   double Obs11 = (HT!=0 ? (HT-EtSum)/HT : -1);
00163   evtselectVarVal.push_back(std::pair<unsigned int,double>(11,Obs11));
00164   
00165   
00166   //Sphericity and Aplanarity without boosting back the system to CM frame
00167   
00168   TMatrixDSym Matrix(3);
00169   double PX2 = std::pow(Hadp->Px(),2)+std::pow(Hadq->Px(),2)+std::pow(Hadb->Px(),2)+
00170     std::pow(Hadj->Px(),2)+std::pow(Hadk->Px(),2)+std::pow(Hadbbar->Px(),2);
00171   double PY2 = std::pow(Hadp->Py(),2)+std::pow(Hadq->Py(),2)+std::pow(Hadb->Py(),2)+
00172     std::pow(Hadj->Py(),2)+std::pow(Hadk->Py(),2)+std::pow(Hadbbar->Py(),2);
00173   double PZ2 = std::pow(Hadp->Pz(),2)+std::pow(Hadq->Pz(),2)+std::pow(Hadb->Pz(),2)+ 
00174     std::pow(Hadj->Pz(),2)+std::pow(Hadk->Pz(),2)+std::pow(Hadbbar->Pz(),2);
00175   double P2  = PX2+PY2+PZ2;
00176   
00177   double PXY = Hadp->Px()*Hadp->Py()+Hadq->Px()*Hadq->Py()+Hadb->Px()*Hadb->Py()+
00178     Hadj->Px()*Hadj->Py()+Hadk->Px()*Hadk->Py()+Hadbbar->Px()*Hadbbar->Py();
00179   double PXZ = Hadp->Px()*Hadp->Pz()+Hadq->Px()*Hadq->Pz()+Hadb->Px()*Hadb->Pz()+
00180     Hadj->Px()*Hadj->Pz()+Hadk->Px()*Hadk->Pz()+Hadbbar->Px()*Hadbbar->Pz();
00181   double PYZ = Hadp->Py()*Hadp->Pz()+Hadq->Py()*Hadq->Pz()+Hadb->Py()*Hadb->Pz()+
00182     Hadj->Py()*Hadj->Pz()+Hadk->Py()*Hadk->Pz()+Hadbbar->Py()*Hadbbar->Pz();
00183   
00184   Matrix(0,0) = PX2/P2; Matrix(0,1) = PXY/P2; Matrix(0,2) = PXZ/P2;
00185   Matrix(1,0) = PXY/P2; Matrix(1,1) = PY2/P2; Matrix(1,2) = PYZ/P2;
00186   Matrix(2,0) = PXZ/P2; Matrix(2,1) = PYZ/P2; Matrix(2,2) = PZ2/P2;
00187   
00188   TMatrixDSymEigen pTensor(Matrix);
00189   
00190   std::vector<double> EigValues;
00191   EigValues.clear();
00192   for(int i=0;i<3;i++){
00193     EigValues.push_back(pTensor.GetEigenValues()[i]);
00194   }
00195   
00196   std::sort(EigValues.begin(),EigValues.end(),dComparator);
00197   
00198   double Sphericity = 1.5*(EigValues[1]+EigValues[2]);
00199   double Aplanarity = 1.5*EigValues[2];
00200   
00201   double Obs12 = (isnan(Sphericity) ? -1 : Sphericity);
00202   evtselectVarVal.push_back(std::pair<unsigned int,double>(12,Obs12));
00203   
00204   double Obs13 = (isnan(Aplanarity) ? -1 : Aplanarity);
00205   evtselectVarVal.push_back(std::pair<unsigned int,double>(13,Obs13));
00206   
00207   
00208   //Sphericity and Aplanarity with boosting back the system to CM frame 
00209   TLorentzVector *TtbarSystem = new TLorentzVector();
00210   TtbarSystem->SetPx(Hadp->Px()+Hadq->Px()+Hadb->Px()+Hadj->Px()+Hadk->Px()+Hadbbar->Px());
00211   TtbarSystem->SetPy(Hadp->Py()+Hadq->Py()+Hadb->Py()+Hadj->Py()+Hadk->Py()+Hadbbar->Py());
00212   TtbarSystem->SetPz(Hadp->Pz()+Hadq->Pz()+Hadb->Pz()+Hadj->Pz()+Hadk->Pz()+Hadbbar->Pz());
00213   TtbarSystem->SetE(Hadp->E()+Hadq->E()+Hadb->E()+Hadj->E()+Hadk->E()+Hadbbar->E());
00214   
00215   TVector3 BoostBackToCM = -(TtbarSystem->BoostVector());
00216   Hadp->Boost(BoostBackToCM);
00217   Hadq->Boost(BoostBackToCM);
00218   Hadb->Boost(BoostBackToCM);
00219   Hadj->Boost(BoostBackToCM);
00220   Hadk->Boost(BoostBackToCM);
00221   Hadbbar->Boost(BoostBackToCM);
00222   
00223   double BOOST_PX2 = std::pow(Hadp->Px(),2)+std::pow(Hadq->Px(),2)+std::pow(Hadb->Px(),2)+
00224     std::pow(Hadj->Px(),2)+std::pow(Hadk->Px(),2)+std::pow(Hadbbar->Px(),2);
00225   double BOOST_PY2 = std::pow(Hadp->Py(),2)+std::pow(Hadq->Py(),2)+std::pow(Hadb->Py(),2)+
00226     std::pow(Hadj->Py(),2)+std::pow(Hadk->Py(),2)+std::pow(Hadbbar->Py(),2);
00227   double BOOST_PZ2 = std::pow(Hadp->Pz(),2)+std::pow(Hadq->Pz(),2)+std::pow(Hadb->Pz(),2)+
00228     std::pow(Hadj->Pz(),2)+std::pow(Hadk->Pz(),2)+std::pow(Hadbbar->Pz(),2);
00229   
00230   double BOOST_P2  = BOOST_PX2+BOOST_PY2+BOOST_PZ2;
00231   
00232   double BOOST_PXY = Hadp->Px()*Hadp->Py()+Hadq->Px()*Hadq->Py()+Hadb->Px()*Hadb->Py()+
00233     Hadj->Px()*Hadj->Py()+Hadk->Px()*Hadk->Py()+Hadbbar->Px()*Hadbbar->Py();
00234   double BOOST_PXZ = Hadp->Px()*Hadp->Pz()+Hadq->Px()*Hadq->Pz()+Hadb->Px()*Hadb->Pz()+
00235     Hadj->Px()*Hadj->Pz()+Hadk->Px()*Hadk->Pz()+Hadbbar->Px()*Hadbbar->Pz();
00236   double BOOST_PYZ = Hadp->Py()*Hadp->Pz()+Hadq->Py()*Hadq->Pz()+Hadb->Py()*Hadb->Pz()+
00237     Hadj->Py()*Hadj->Pz()+Hadk->Py()*Hadk->Pz()+Hadbbar->Py()*Hadbbar->Pz();
00238   
00239   TMatrixDSym BOOST_Matrix(3);
00240   
00241   BOOST_Matrix(0,0) = BOOST_PX2/BOOST_P2; BOOST_Matrix(0,1) = BOOST_PXY/BOOST_P2; BOOST_Matrix(0,2) = BOOST_PXZ/BOOST_P2;
00242   BOOST_Matrix(1,0) = BOOST_PXY/BOOST_P2; BOOST_Matrix(1,1) = BOOST_PY2/BOOST_P2; BOOST_Matrix(1,2) = BOOST_PYZ/BOOST_P2;
00243   BOOST_Matrix(2,0) = BOOST_PXZ/BOOST_P2; BOOST_Matrix(2,1) = BOOST_PYZ/BOOST_P2; BOOST_Matrix(2,2) = BOOST_PZ2/BOOST_P2;
00244   
00245   TMatrixDSymEigen BOOST_pTensor(BOOST_Matrix);
00246   
00247   std::vector<double> BOOST_EigValues;
00248   BOOST_EigValues.clear();
00249   for(int i=0;i<3;i++){
00250     BOOST_EigValues.push_back(BOOST_pTensor.GetEigenValues()[i]);
00251   }
00252   
00253   std::sort(BOOST_EigValues.begin(),BOOST_EigValues.end(),dComparator);
00254   
00255   double BOOST_Sphericity = 1.5*(BOOST_EigValues[1]+BOOST_EigValues[2]);
00256   double BOOST_Aplanarity = 1.5*BOOST_EigValues[2];
00257   
00258   double Obs14 = ( isnan(BOOST_Sphericity) ? -1 : BOOST_Sphericity );
00259   evtselectVarVal.push_back(std::pair<unsigned int,double>(14,Obs14));
00260   
00261   double Obs15 = ( isnan(BOOST_Aplanarity) ? -1 : BOOST_Aplanarity );
00262   evtselectVarVal.push_back(std::pair<unsigned int,double>(15,Obs15));
00263   
00264   
00265   // Centrality of the six jets
00266   double H=0;
00267   for(unsigned int i=0;i<6;i++){
00268     H += topJets[i].energy();
00269   }
00270   double Obs16 = ( H != 0 ? HT/H : -1 );
00271   evtselectVarVal.push_back(std::pair<unsigned int,double>(16,Obs16));
00272   
00273   
00274   // distance from the origin in the (BjetsBdiscSum, Ljets1BdiscSum) and  (BjetsBdiscSum, Ljets2BdiscSum)
00275   double Obs17 = ( BjetsBdiscSum != 0 && Ljets1BdiscSum != 0 ? 0.707*(BjetsBdiscSum-Ljets1BdiscSum) : -1 );
00276   evtselectVarVal.push_back(std::pair<unsigned int,double>(17,Obs17));
00277   double Obs18 = ( BjetsBdiscSum != 0 && Ljets2BdiscSum != 0 ? 0.707*(BjetsBdiscSum-Ljets2BdiscSum) : -1 );
00278   evtselectVarVal.push_back(std::pair<unsigned int,double>(18,Obs18));
00279   
00280   // Ratio of the Et Sum of the two lightest jets over HT=Sum of the Et of the six highest jets in Et
00281   double Obs19 = ( HT != 0 ? EtSum/HT : -1 );
00282   evtselectVarVal.push_back(std::pair<unsigned int,double>(19,Obs19));
00283   
00284   
00285   // Put the vector in the TtHadEvtSolution
00286   TS.setLRSignalEvtObservables(evtselectVarVal);
00287 }