///////////////// // Markus Klute // // Created: 04/26/2003 // // Purpose: Do Mass Analysis // #include "top_analyze/D0ChunkAnalyze.hpp" using namespace TOPexample; using namespace std; #include "hitfit/Top_Fit.hpp" #include "hitfit/Top_Decaykin.hpp" #include "hitfit/run1_ascii_io.hpp" #include "hitfit/Lepjets_Event.hpp" #include "hitfit/Fit_Results.hpp" #include "hitfit/Fit_Result.hpp" #include "hitfit/Defaults_Text.hpp" #include "hitfit/Lepjets_Event_Jet.hpp" #include "hitfit/Lepjets_Event_Lep.hpp" #include "hitfit/fourvec.hpp" #include "CLHEP/Random/JamesRandom.h" #include #include "kinem_util/AnglesUtil.hpp" #include "top_tree/TheProperty.hpp" #include // ============================================================================= /*****************************************************************************/ void D0ChunkAnalyze::LJets (std::vector& ElectronVector, std::vector& MuonVector, std::vector& JetVector, float metx, float mety, int run, int evt, float pvz, bool svxTag, bool sltTag, bool ipTag, int datatype,bool isMC) { // cout<<"use svx was "<::iterator WMuon; int ntmu=0; for (std::vector::iterator im = MuonVector.begin(); im != MuonVector.end(); im++) { if (im->Isolated()|| datatype == 2 ) { WMuon = im; ntmu++; break; } } int nte=0; std::vector::iterator WElectron; for (std::vector::iterator ie = ElectronVector.begin(); ie != ElectronVector.end(); ie++) { if (ie->isTight() || datatype == 1 ) { WElectron = ie; nte++; break; } } int lflag = 0; if(MuonVector.size()>0 && ElectronVector.size()==0) lflag=3; if(ElectronVector.size()>0 && MuonVector.size() ==0) lflag=2; if( !(ntmu==0 && nte==0) ) { if( ntmu>0 && nte==0 ) lflag=3; if( nte>0 && ntmu==0) lflag=2; if( (ntmu>0 && nte>0)){ lflag=2; if( WMuon -> pT() > WElectron -> pT()) lflag=3; } } else return; // ... if(lflag==3){ hitfit::Fourvec lep_fourvec(WMuon -> GetPx(), WMuon -> GetPy(), WMuon -> GetPz(), WMuon -> E()); ev.add_lep(hitfit::Lepjets_Event_Lep (lep_fourvec,lflag,io_args.muo_res())); } if(lflag==2){ hitfit::Fourvec lep_fourvec(WElectron -> GetPx(), WElectron -> GetPy(), WElectron -> GetPz(), WElectron -> E()); ev.add_lep(hitfit::Lepjets_Event_Lep (lep_fourvec,lflag,io_args.ele_res())); } float missingET = sqrt ( metx * metx + mety * mety); hitfit::Fourvec met(metx, mety,missingET,missingET); ev.met()=met; ev.zvertex() = pvz; std::vector jet_types; bool svx_flag=false; int idxjet = -1; for ( std::vector::iterator ij=JetVector.begin(); ij != JetVector.end() ; ij++) { idxjet++; if(idxjet<4) jet_types.push_back(idxjet+11); else jet_types.push_back(20); hitfit::Fourvec j_fourvec( ij -> GetPx() , ij -> GetPy() , ij -> GetPz() , ij -> E() ); bool has_btag = false; if ( svxTag && ij->GetSvxTags() == 1 ) has_btag = true; if ( sltTag && ij->GetMuoTag() == 1 ) has_btag = true; if ( ipTag && ij->GetIPTag() == 1 ) has_btag = true; ev.add_jet( hitfit::Lepjets_Event_Jet(j_fourvec,jet_types[idxjet],io_args.jet_res(), has_btag,false) ); } jet_types . clear(); ev.kt_res()=io_args.kt_res(); // ... fill event for fitting done ... if (smear) ev.smear (engine, true); ev.sort (); if (print_input_event) std::cout << ev; Int_t npermut = 0; // ... only events wich pass the cuts ... if (ev.cut_leps (leppt_cut, lepeta_cut) < 1 || ev.cut_jets (jetpt_cut, jeteta_cut) < 4 || ev.met().perp() < nupt_cut || ev.nleps() > 1) { std::cout << "failed kin cuts\n"; } else { if (leading_jets > 0) { assert (leading_jets >= 4); ev.trimjets (leading_jets); } hitfit::Fit_Results fitres = fitter.fit (ev); if (fitres[hitfit::all_list].size() > 0) { //std::cout << fitres[hitfit::all_list][0].chisq() // << " " << fitres[hitfit::all_list][0].mt() // << " " << fitres[hitfit::all_list][0].sigmt() // << "\n"; npermut =13; Float_t chisq[13]; // Fit chisq.< 0 means fit didn't converge. Float_t mt[13]; // Top mass from fit. Float_t sigmt[13]; // Top mass uncertainty from fit Float_t umwhad[13]; // Mass of hadronic W in this permutation, before fitting. Float_t utmass[13]; // Mass of hadronic top in this permutation, before fitting. Int_t perm[13]; // Jet types, packed 4 bits per jets. Float_t m_tt[13]; // Invariant mass of ttbar pair. Float_t pt_t[13]; // Top pt, averaged over both. Float_t kt[13]; // Event kT. Float_t eta_t1[13]; // Eta of leptonic top. Float_t eta_t2[13]; // Eta of hadronic top. Float_t phi_t1[13]; // Phi of leptonic top. Float_t phi_t2[13]; // Phi of hadronic top. Float_t pt_t1[13]; // Pt of leptonic top. Float_t pt_t2[13]; // Pt of hadronic top. Float_t t1[13][3]; // eta,phi,pt of leptonic top Float_t t2[13][3]; // eta,phi,pt of hadronic top Float_t w1[13][3]; // eta,phi,pt of leptonic W Float_t w2[13][3]; // eta,phi,pt of hadronic W Float_t jet_lepb[13][4]; //px,py,pz,E of b-jet from leptonic Top after fitting Float_t jet_hadb[13][4]; //px,py,pz,E of b-jet from hadronic Top after fitting Float_t jet_hadw1[13][4]; //px,py,pz,E of first jet from hadronic W after fitting Float_t jet_hadw2[13][4]; //px,py,pz,E of second jet from hadronic W after fitting Float_t lepton[13][4]; //px,py,pz,E of Lepton after fitting Float_t neutrino[13][4]; //px,py,pz,E of Neutrino after fitting //the same but with btagging Float_t bchisq[13]; // Fit chisq.< 0 means fit didn't converge. Float_t bmt[13]; // Top mass from fit. Float_t bsigmt[13]; // Top mass uncertainty from fit Float_t bumwhad[13]; // Mass of hadronic W in this permutation, before fitting. Float_t butmass[13]; // Mass of hadronic top in this permutation, before fitting. Int_t bperm[13]; // Jet types, packed 4 bits per jets. Float_t bm_tt[13]; // Invariant mass of ttbar pair. Float_t bpt_t[13]; // Top pt, averaged over both. Float_t bkt[13]; // Event kT. Float_t beta_t1[13]; // Eta of leptonic top. Float_t beta_t2[13]; // Eta of hadronic top. Float_t bphi_t1[13]; // Phi of leptonic top. Float_t bphi_t2[13]; // Phi of hadronic top. Float_t bpt_t1[13]; // Pt of leptonic top. Float_t bpt_t2[13]; // Pt of hadronic top. Float_t bt1[13][3]; // eta,phi,pt of leptonic top Float_t bt2[13][3]; // eta,phi,pt of hadronic top Float_t bw1[13][3]; // eta,phi,pt of leptonic W Float_t bw2[13][3]; // eta,phi,pt of hadronic W Float_t bjet_lepb[13][4]; //px,py,pz,E of b-jet from leptonic Top after fitting Float_t bjet_hadb[13][4]; //px,py,pz,E of b-jet from hadronic Top after fitting Float_t bjet_hadw1[13][4]; //px,py,pz,E of first jet from hadronic W after fitting Float_t bjet_hadw2[13][4]; //px,py,pz,E of second jet from hadronic W after fitting Float_t blepton[13][4]; //px,py,pz,E of Lepton after fitting Float_t bneutrino[13][4]; //px,py,pz,E of Neutrino after fitting for(int i=0; i 0) { chisq[0] =fitres[hitfit::noperm_list][0].chisq(); mt[0] =fitres[hitfit::noperm_list][0].mt(); sigmt[0] =fitres[hitfit::noperm_list][0].sigmt(); umwhad[0]=fitres[hitfit::noperm_list][0].umwhad(); utmass[0]=fitres[hitfit::noperm_list][0].utmass(); const hitfit::Lepjets_Event& ev_fitted = fitres[hitfit::noperm_list][0].ev(); packed = 0; for (int ii=0; ii < ev.njets(); ii++) packed = ((packed << 4) | (ev_fitted.jet(ii).type() & 0xf)); perm[0]=packed; hitfit::Fourvec hadt = hitfit::Top_Decaykin::hadt(ev_fitted); hitfit::Fourvec lept = hitfit::Top_Decaykin::lept(ev_fitted); hitfit::Fourvec hadw = hitfit::Top_Decaykin::hadw(ev_fitted); hitfit::Fourvec lepw = hitfit::Top_Decaykin::lepw(ev_fitted); m_tt[0] = (hadt + lept).m (); pt_t[0] = (hadt.perp() + lept.perp()) / 2; kt[0] = ev_fitted.kt().perp(); t1[0][0] = lept.pseudoRapidity(); t2[0][0] = hadt.pseudoRapidity(); t1[0][1] = lept.phi(); t2[0][1] = hadt.phi(); t1[0][2] = lept.perp(); t2[0][2] = hadt.perp(); w1[0][0] = lepw.pseudoRapidity(); w2[0][0] = hadw.pseudoRapidity(); w1[0][1] = lepw.phi(); w2[0][1] = hadw.phi(); w1[0][2] = lepw.perp(); w2[0][2] = hadw.perp(); for (int ii=0; ii < ev.njets(); ii++){ hitfit::Fourvec rjet=ev_fitted.jet(ii).p(); switch(ev_fitted.jet(ii).type()){ case hitfit::lepb_label : jet_lepb[0][0]=rjet.px(); jet_lepb[0][1]=rjet.py(); jet_lepb[0][2]=rjet.pz(); jet_lepb[0][3]=rjet.e(); break; case hitfit::hadb_label : jet_hadb[0][0]=rjet.px(); jet_hadb[0][1]=rjet.py(); jet_hadb[0][2]=rjet.pz(); jet_hadb[0][3]=rjet.e(); break; case hitfit::hadw1_label : jet_hadw1[0][0]=rjet.px(); jet_hadw1[0][1]=rjet.py(); jet_hadw1[0][2]=rjet.pz(); jet_hadw1[0][3]=rjet.e(); break; case hitfit::hadw2_label : jet_hadw2[0][0]=rjet.px(); jet_hadw2[0][1]=rjet.py(); jet_hadw2[0][2]=rjet.pz(); jet_hadw2[0][3]=rjet.e(); break; default: // cerr<<"Unknown Jet-Label in HitFit: "< AddTopFit (chisq[i], mt[i], sigmt[i], umwhad[i], utmass[i], m_tt[i], pt_t[i], kt[i], t1[i], t2[i], perm[i], w1[i], w2[i], jet_lepb[i],jet_hadb[i],jet_hadw1[i], jet_hadw2[i], lepton[i], neutrino[i], bchisq[i], bmt[i], bsigmt[i], bumwhad[i], butmass[i], bm_tt[i], bpt_t[i], bkt[i], bt1[i], bt2[i], bperm[i], bw1[i], bw2[i], bjet_lepb[i], bjet_hadb[i], bjet_hadw1[i], bjet_hadw2[i], blepton[i], bneutrino[i] ); } } } } /*****************************************************************************/