int main(int argc, char ** argv) { if(argc < 4) { cout << "Usage: " << argv[0] << " fileToSplit.lhe events_per_file tag_for_splitting" << endl ; return -1; } std::ifstream ifs (argv[1]) ; LHEF::Reader reader (ifs) ; int eventsPerFile = atoi (argv[2]) ; LHEF::Writer * writer ; ofstream outputStream ; int ieve = 0 ; int index = 0 ; //PG loop over input events while (reader.readEvent ()) { if (ieve == 0) { stringstream filename ; filename << argv[3] << "_" << index << ".lhe" ; outputStream.open (filename.str ().c_str ()) ; cout << "opening in output : " << filename.str () << endl ; writer = new LHEF::Writer (outputStream) ; writer->headerBlock() << reader.headerBlock ; writer->initComments() << reader.initComments ; writer->heprup = reader.heprup ; writer->init () ; } if ( reader.outsideBlock.length() ) std::cout << reader.outsideBlock; writer->eventComments() << reader.eventComments; writer->hepeup = reader.hepeup; writer->writeEvent(); ieve++ ; if (ieve % eventsPerFile == 0) { ieve = 0 ; index++ ; delete writer ; outputStream.close () ; } } //PG loop over input events if (ieve % eventsPerFile != 0) delete writer ; return 0 ; }
void fillHistos (ifstream & ifs) { LHEF::Reader reader (ifs) ; TH1F h_deta ("h_deta", "h_deta", 100, 0, 10) ; TH1F h_jeta ("h_jeta", "h_jeta", 100, -5, 5) ; TH1F h_j1eta ("h_j1eta", "h_j1eta", 100, -5, 5) ; TH1F h_j2eta ("h_j2eta", "h_j2eta", 100, -5, 5) ; TH1F h_j1pt ("h_j1pt", "h_j1pt", 100, 0, 200) ; TH1F h_j2pt ("h_j2pt", "h_j2pt", 100, 0, 200) ; //PG histograms //method 1 hist // tag Jets TH1F h_vbf_jj_pt ("h_vbf_jj_pt", "h_vbf_jj_pt", 100, 0, 500) ; TH1F h_vbf_jj_eta ("h_vbf_jj_eta", "h_vbf_jj_eta", 100, -5, 5) ; TH1F h_vbf_jj_e ("h_vbf_jj_e", "h_vbf_jj_e", 100, 0, 500) ; TH1F h_vbf_jj_phi ("h_vbf_jj_phi", "h_vbf_jj_phi", 100, -3, 3) ; TH1F h_vbf_jj_m ("h_vbf_jj_m", "h_vbf_jj_m", 100, 0, 2000) ; TH1F h_vbf_aj_pt ("h_vbf_aj_pt", "h_vbf_aj_pt", 100, 0, 500) ; TH1F h_vbf_aj_eta ("h_vbf_aj_eta", "h_vbf_aj_eta", 100, -5, 5) ; TH1F h_vbf_aj_e ("h_vbf_aj_e", "h_vbf_aj_e", 100, 0, 500) ; TH1F h_vbf_aj_phi ("h_vbf_aj_phi", "h_vbf_aj_phi", 100, -3, 3) ; TH1F h_vbf_bj_pt ("h_vbf_bj_pt", "h_vbf_bj_pt", 100, 0, 500) ; TH1F h_vbf_bj_eta ("h_vbf_bj_eta", "h_vbf_bj_eta", 100, -5, 5) ; TH1F h_vbf_bj_e ("h_vbf_bj_e", "h_vbf_bj_e", 100, 0, 500) ; TH1F h_vbf_bj_phi ("h_vbf_bj_phi", "h_vbf_bj_phi", 100, -3, 3) ; TH1F h_vbf_jj_deta ("h_vbf_jj_deta", "h_vbf_jj_deta", 100, -5, 5) ; TH1F h_vbf_jj_dphi ("h_vbf_jj_dphi", "h_vbf_jj_dphi", 100, -3, 3) ; // W JETS TH1F h_vbf_wjj_pt ("h_vbf_wjj_pt", "h_vbf_wjj_pt", 100, 0, 500) ; TH1F h_vbf_wjj_eta ("h_vbf_wjj_eta", "h_vbf_wjj_eta", 100, -5, 5) ; TH1F h_vbf_wjj_e ("h_vbf_wjj_e", "h_vbf_wjj_e", 100, 0, 500) ; TH1F h_vbf_wjj_phi ("h_vbf_wjj_phi", "h_vbf_wjj_phi", 100, -3, 3) ; TH1F h_vbf_wjj_m ("h_vbf_wjj_m", "h_vbf_wjj_m", 100, 0, 500) ; TH1F h_vbf_waj_pt ("h_vbf_waj_pt", "h_vbf_waj_pt", 100, 0, 500) ; TH1F h_vbf_waj_eta ("h_vbf_waj_eta", "h_vbf_waj_eta", 100, -5, 5) ; TH1F h_vbf_waj_e ("h_vbf_waj_e", "h_vbf_waj_e", 100, 0, 500) ; TH1F h_vbf_waj_phi ("h_vbf_waj_phi", "h_vbf_waj_phi", 100, -3, 3) ; TH1F h_vbf_wbj_pt ("h_vbf_wbj_pt", "h_vbf_wbj_pt", 100, 0, 500) ; TH1F h_vbf_wbj_eta ("h_vbf_wbj_eta", "h_vbf_wbj_eta", 100, -5, 5) ; TH1F h_vbf_wbj_e ("h_vbf_wbj_e", "h_vbf_wbj_e", 100, 0, 500) ; TH1F h_vbf_wbj_phi ("h_vbf_wbj_phi", "h_vbf_wbj_phi", 100, -3, 3) ; TH1F h_vbf_lvjj_pt ("h_vbf_lvjj_pt", "h_vbf_lvjj_pt", 100, 0, 500) ; TH1F h_vbf_lvjj_eta ("h_vbf_lvjj_eta", "h_vbf_lvjj_eta", 100, -5, 5) ; TH1F h_vbf_lvjj_e ("h_vbf_lvjj_e", "h_vbf_lvjj_e", 100, 0, 500) ; TH1F h_vbf_lvj_m ("h_vbf_lvj_m", "h_vbf_lvj_m", 100, 0, 500) ; TH1F h_vbf_lvjj_phi ("h_vbf_lvjj_phi", "h_vbf_lvjj_phi", 100, -3, 3) ; TH1F h_vbf_lvjj_m ("h_vbf_lvjj_m", "h_vbf_lvjj_m", 100, 0, 1000) ; TH1F h_vbf_wjj_deta ("h_vbf_wjj_deta", "h_vbf_wjj_deta", 100, -5, 5) ; TH1F h_vbf_wjj_dphi ("h_vbf_wjj_dphi", "h_vbf_wjj_dphi", 100, -3, 3) ; TH1F h_vbf_l_pt ("h_vbf_l_pt", "h_vbf_l_pt", 100, 0, 500) ; TH1F h_vbf_l_eta ("h_vbf_l_eta", "h_vbf_l_eta", 100, -5, 5) ; TH1F h_vbf_l_e ("h_vbf_l_e", "h_vbf_l_e", 100, 0, 500) ; TH1F h_vbf_l_phi ("h_vbf_l_phi", "h_vbf_l_phi", 100, -3, 3) ; TH1F h_vbf_nu_e ("h_vbf_nu_e", "h_vbf_nu_e", 100, 0, 500) ; TH1F h_vbf_l_MET_deltaphi ("h_vbf_l_MET_deltaphi", "h_vbf_l_MET_deltaphi", 100, -3, 3) ; TH1F h_vbf_lW_hW_deltaphi ("h_vbf_lW_hW_deltaphi", "h_vbf_lW_hW_deltaphi", 100, -3, 3) ; TH1F h_vbf_l_tj1_dR ("vbf_l_tj1_dR", "vbf_l_tj1_dR", 100, 0, 6) ; TH1F h_vbf_l_tj2_dR ("vbf_l_tj2_dR", "vbf_l_tj2_dR", 100, 0, 6) ; TH1F h_vbf_l_wj1_dR ("vbf_l_wj1_dR", "vbf_l_wj1_dR", 100, 0, 6) ; TH1F h_vbf_l_wj2_dR ("vbf_l_wj2_dR", "vbf_l_wj2_dR", 100, 0, 6) ; TH1F h_vbf_l_wjj_dR ("vbf_l_wjj_dR", "vbf_l_wjj_dR", 100, 0, 6) ; TH1F h_vbf_l_tjj_dR ("vbf_l_tjj_dR", "vbf_l_tjj_dR", 100, 0, 6) ; /* tmva_t->Branch("vbf_event",&vbf_event, "vbf_event/I"); tmva_t->Branch("vbf_aj_id",&vbf_aj_id, "vbf_aj_id/I"); tmva_t->Branch("vbf_bj_id",&vbf_bj_id, "vbf_bj_id/I"); tmva_t->Branch("vbf_waj_id",&vbf_waj_id, "vbf_waj_id/I"); tmva_t->Branch("vbf_wbj_id",&vbf_wbj_id, "vbf_wbj_id/I"); */ long ieve = 0 ; while ( reader.readEvent() ) { if (ieve % 1000 == 0) std::cout << "event " << ieve << "\n" ; ++ieve; std::vector<int> bosons ; vector<pair<int, TLorentzVector> > fs_particles ; //PG final state particles //PG loop over particles in the event for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size (); ++iPart) { //PG outgoing particle if (reader.hepeup.ISTUP.at (iPart) == 1) { TLorentzVector particle ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E ) ; // fs_particles[reader.hepeup.IDUP.at (iPart)] = particle ; fs_particles.push_back (pair<int, TLorentzVector> (reader.hepeup.IDUP.at (iPart), particle)) ; } //PG outgoing particle } //PG loop over particles in the event TLorentzVector Z_cand ; TLorentzVector H_cand ; vector <TLorentzVector *> Jets ; vector <TLorentzVector *> leptons ; vector <TLorentzVector *> neutrinos ; vector <TLorentzVector *> gluons ; for (int iPart = 0 ; iPart < fs_particles.size () ; ++iPart) { // std::cout<<" Particle Id "<<fs_particles.at (iPart).first<<" Pt "<<(fs_particles.at (iPart).second).Pt()<<std::endl; } for (int iPart = 0 ; iPart < fs_particles.size () ; ++iPart) { if (abs (fs_particles.at (iPart).first) < 11) //PG tag Jets { Jets.push_back (&(fs_particles.at (iPart).second)) ; continue ; } if (abs (fs_particles.at (iPart).first) == 21) //PG gluons { gluons.push_back (&(fs_particles.at (iPart).second)) ; continue ; } if (abs (fs_particles.at (iPart).first) == 12 || abs (fs_particles.at (iPart).first) == 14) { neutrinos.push_back (&(fs_particles.at (iPart).second)) ; } if (abs (fs_particles.at (iPart).first) == 11 || abs (fs_particles.at (iPart).first) == 13) { leptons.push_back (&(fs_particles.at (iPart).second)) ; Z_cand += fs_particles.at (iPart).second ; //PG electron or muon } H_cand += fs_particles.at (iPart).second ; } //PG VBF cuts sort (Jets.begin (), Jets.end (), mySort ()) ; sort (leptons.begin (), leptons.end (), mySort ()) ; sort (neutrinos.begin (), neutrinos.end (), mySort ()) ; TLorentzVector vbf_ajp(0,0,0,0), vbf_bjp(0,0,0,0); TLorentzVector wjj_ajp(0,0,0,0), wjj_bjp(0,0,0,0); TLorentzVector lep(0,0,0,0), nu(0,0,0,0); float best_detatagjj = 0; // float best_mtagjj =0; float best_mjj = 0; // float best_mjj =0; float vbf_jj_e =-999, vbf_jj_pt =-999, vbf_jj_eta=-999, vbf_jj_phi =-999, vbf_jj_m=-999; float vbf_aj_e =-999, vbf_aj_pt =-999, vbf_aj_eta=-999, vbf_aj_phi =-999; float vbf_bj_e =-999, vbf_bj_pt =-999, vbf_bj_eta=-999, vbf_bj_phi =-999; float vbf_jj_deta=-999; Float_t vbf_jj_dphi=-999; int vbf_jj_type=0, vbf_n_excj=0, vbf_n_exfj=0, vbf_n_gdjj=0; float vbf_wjj_e =-999, vbf_wjj_pt =-999, vbf_wjj_eta=-999, vbf_wjj_phi =-999, vbf_wjj_m=-999; float vbf_waj_e =-999, vbf_waj_pt =-999, vbf_waj_eta=-999, vbf_waj_phi =-999; float vbf_wbj_e =-999, vbf_wbj_pt =-999, vbf_wbj_eta=-999, vbf_wbj_phi =-999; float vbf_wjj_deta=-999; Float_t vbf_wjj_dphi=-999; float vbf_lvjj_e =-999, vbf_lvjj_pt =-999, vbf_lvjj_eta=-999, vbf_lvjj_phi =-999, vbf_lvjj_m =-999, vbf_lvj_m=-999; float vbf_l_pt =-999, vbf_l_e =-999, vbf_l_eta=-999, vbf_l_phi =-999, vbf_nu_e =-999; float vbf_l_MET_deltaphi=-999, vbf_lW_hW_deltaphi=-999,vbf_l_tj1_dR=-999,vbf_l_tj2_dR=-999,vbf_l_wj1_dR=-999,vbf_l_wj2_dR=-999,vbf_l_wjj_dR=-999,vbf_l_tjj_dR=-999; // float jess 1.0; int n_excj =0, n_exfj = 0, n_gdjj = 0, jj_type = 0, tag_i_id = -1, tag_j_id = -1, wjj_a_id = -1, wjj_b_id = -1; for ( size_t i=0; i < leptons.size(); ++i) { if ((fabs(leptons.at(i)->Eta()) > 2.5) && (leptons.at(i)->Pt() < 25) ) continue; TLorentzVector l; l.SetPxPyPzE (leptons.at(i)->Px(), leptons.at(i)->Py(), leptons.at(i)->Pz(), leptons.at(i)->E() ); lep=l; } for ( size_t i=0; i < neutrinos.size(); ++i) { if (neutrinos.at(i)->Et() < 25) continue; TLorentzVector n; n.SetPxPyPzE (neutrinos.at(i)->Px(), neutrinos.at(i)->Py(), neutrinos.at(i)->Pz(), neutrinos.at(i)->E() ); nu=n; } //method1a A two tag Jets from complete eta region for ( size_t i=0; i < Jets.size(); ++i) { if ((fabs(Jets.at(i)->Eta()) > 4.7 )&& (Jets.at(i)->Pt()<20)) continue; TLorentzVector i_p; i_p.SetPxPyPzE (Jets.at(i)->Px(), Jets.at(i)->Py(), Jets.at(i)->Pz(), Jets.at(i)->E() ); for (size_t j=i+1; j <Jets.size(); ++j) { if ((fabs(Jets.at(j)->Eta()) > 4.7) && (Jets.at(i)->Pt()<20))continue; TLorentzVector j_p; j_p.SetPxPyPzE (Jets.at(j)->Px(), Jets.at(j)->Py(), Jets.at(j)->Pz(), Jets.at(j)->E() ) ; if ( (Jets.at(i)->Eta()*Jets.at(j)->Eta())>0 ) continue; // 1. have to be one forward, one backward if ( (fabs(Jets.at(i)->Eta()-Jets.at(j)->Eta())<3.5) || (sqrt ((i_p+j_p).M2()) <500)) continue;// 2.Tag pair delta eta>3.5, Mjj>500 //cout<<" "<<sqrt ((i_p+j_p).M2())<<endl; // if find more than one combinations //if ( (fas(i_Eta-j_Eta)>best_detatagjj) ) // 3 Select best combination with maximum deta Eta if ( sqrt((i_p+j_p).M2()) > best_mjj ) { // 3 Select best combination with maximum Mjj because of the bad angular resolution in the HF best_detatagjj = fabs(Jets.at(i)->Eta()-Jets.at(j)->Eta()); n_gdjj++; best_mjj = sqrt ((i_p+j_p).M2()); tag_i_id = i; tag_j_id = j; vbf_ajp = i_p; vbf_bjp = j_p; } //loop to find two tag Jets with highest mjj } // over over loop over Nmax-1 reco Jets inside } //loop over Nmax reco Jets if (tag_i_id !=-1 && tag_j_id != -1) { vbf_jj_e = (vbf_ajp+ vbf_bjp).E(); vbf_jj_pt = (vbf_ajp+ vbf_bjp).Pt(); vbf_jj_eta = (vbf_ajp+ vbf_bjp).Eta(); vbf_jj_phi = (vbf_ajp+ vbf_bjp).Phi(); vbf_jj_m = best_mjj; vbf_aj_e = (vbf_ajp).E(); vbf_aj_pt = (vbf_ajp).Pt(); vbf_aj_eta = (vbf_ajp).Eta(); vbf_aj_phi = (vbf_ajp).Phi(); //vbf_aj_m = (i_p).M(); vbf_bj_e = (vbf_bjp).E(); vbf_bj_pt = (vbf_bjp).Pt(); vbf_bj_eta = (vbf_bjp).Eta(); vbf_bj_phi = (vbf_bjp).Phi(); // vbf_bj_m = (j_p).M(); vbf_jj_deta =vbf_aj_eta-vbf_bj_eta; vbf_jj_dphi = vbf_aj_phi-vbf_bj_phi; //cout<<" "<<vbf_jj_dphi<<endl; } //loop // method1a B if (tag_i_id!=-1&&tag_j_id!=-1) { for ( int k=0; k < (int) Jets.size(); ++k) { if (fabs(Jets.at(k)->Eta()) > 4.7) continue; if ( k!=tag_i_id && k!= tag_j_id && wjj_ajp.Pt()!=0 && wjj_bjp.Pt()==0 ) { int Bj = k; wjj_bjp.SetPxPyPzE (Jets.at(Bj)->Px(), Jets.at(Bj)->Py(), Jets.at(Bj)->Pz(), Jets.at(Bj)->E() ); wjj_b_id=Bj; } if ( k!=tag_i_id&&k!=tag_j_id&&wjj_ajp.Pt()==0 && wjj_bjp.Pt()==0 ) { int Aj = k; wjj_ajp.SetPxPyPzE (Jets.at(Aj)->Px(), Jets.at(Aj)->Py(), Jets.at(Aj)->Pz(), Jets.at(Aj)->E() ); wjj_a_id=Aj; } }// loop over reco Jets upto Nmax } // loop of insuring having allready two tagJets if ( wjj_a_id!=-1 && wjj_b_id!=-1) { // two W Jets vbf_wjj_e = (wjj_ajp+wjj_bjp).E(); vbf_wjj_pt = (wjj_ajp+wjj_bjp).Pt(); vbf_wjj_eta = (wjj_ajp+wjj_bjp).Eta(); vbf_wjj_phi = (wjj_ajp+wjj_bjp).Phi(); vbf_wjj_m = sqrt((wjj_ajp+wjj_bjp).M2()); vbf_waj_e = (wjj_ajp).E(); vbf_waj_pt = (wjj_ajp).Pt(); vbf_waj_eta = (wjj_ajp).Eta(); vbf_waj_phi = (wjj_ajp).Phi(); //vbf_waj_m = (wjj_ajp).M(); vbf_wbj_e = (wjj_bjp).E(); vbf_wbj_pt = (wjj_bjp).Pt(); vbf_wbj_eta = (wjj_bjp).Eta(); vbf_wbj_phi = (wjj_bjp).Phi(); vbf_wjj_deta=vbf_waj_eta-vbf_wbj_eta; vbf_wjj_dphi= vbf_waj_phi-vbf_wbj_phi; } if (tag_i_id!=-1 && tag_j_id!=-1 && wjj_a_id!=-1 && wjj_b_id!=-1 && lep.Pt()>30.) { vbf_lvjj_e = (lep+nu+wjj_ajp+wjj_bjp).E(); vbf_lvjj_pt = (lep+nu+wjj_ajp+wjj_bjp).Pt(); vbf_lvjj_eta = (lep+nu+wjj_ajp+wjj_bjp).Eta(); vbf_lvjj_phi = (lep+nu+wjj_ajp+wjj_bjp).Phi(); vbf_lvjj_m = sqrt((lep+nu+wjj_ajp+wjj_bjp).M2()); vbf_lvj_m = (lep+nu).Mt(); // vbf_lvj_m = sqrt((lep+nu).M2()); vbf_l_pt = lep.Pt(); vbf_l_eta = lep.Eta(); vbf_l_phi = lep.Phi(); vbf_l_e = lep.E(); vbf_nu_e = nu.Et(); vbf_l_MET_deltaphi = getDeltaPhi(vbf_l_phi, nu.Phi()); vbf_lW_hW_deltaphi = getDeltaPhi((lep+nu).Phi(), vbf_wjj_phi); vbf_l_tj1_dR = delta_R(vbf_l_eta,vbf_l_phi,vbf_aj_eta,vbf_aj_phi); vbf_l_tj2_dR = delta_R(vbf_l_eta,vbf_l_phi,vbf_bj_eta,vbf_bj_phi); vbf_l_wj1_dR = delta_R(vbf_l_eta,vbf_l_phi,vbf_waj_eta,vbf_waj_phi); vbf_l_wj2_dR = delta_R(vbf_l_eta,vbf_l_phi,vbf_wbj_eta,vbf_wbj_phi); vbf_l_tjj_dR = delta_R(vbf_aj_eta,vbf_aj_phi, vbf_bj_eta,vbf_bj_phi); vbf_l_wjj_dR = delta_R(vbf_waj_eta,vbf_waj_phi, vbf_wbj_eta,vbf_wbj_phi); } double tj_dEta = fabs (Jets.at (0)->Eta () - Jets.at (1)->Eta ()) ; h_deta.Fill (tj_dEta) ; h_j1eta.Fill (Jets.at (0)->Eta ()) ; h_j2eta.Fill (Jets.at (1)->Eta ()) ; h_j1pt.Fill (Jets.at (0)->Pt ()) ; h_j2pt.Fill (Jets.at (1)->Pt ()) ; if (tag_i_id!=-1 && tag_j_id!=-1 && wjj_a_id!=-1 && wjj_b_id!=-1 && vbf_aj_pt>30. && vbf_bj_pt>30. && vbf_waj_pt>30. && vbf_wbj_pt>30 && vbf_wjj_m>30. && vbf_lvj_m>30. && vbf_l_pt>30. && vbf_nu_e >30); { h_vbf_jj_pt.Fill(vbf_jj_pt); h_vbf_jj_eta.Fill(vbf_jj_eta); h_vbf_jj_phi.Fill(vbf_jj_phi); h_vbf_jj_e.Fill(vbf_jj_e); h_vbf_jj_m.Fill(vbf_jj_m); h_vbf_aj_pt.Fill(vbf_aj_pt); h_vbf_aj_eta.Fill(vbf_aj_eta); h_vbf_aj_phi.Fill(vbf_aj_phi); h_vbf_aj_e.Fill(vbf_aj_e); h_vbf_bj_pt.Fill(vbf_bj_pt); h_vbf_bj_eta.Fill(vbf_bj_eta); h_vbf_bj_phi.Fill(vbf_bj_phi); h_vbf_bj_e.Fill(vbf_bj_e); h_vbf_jj_deta.Fill(vbf_jj_deta); h_vbf_jj_dphi.Fill(vbf_jj_dphi); h_vbf_wjj_pt.Fill(vbf_wjj_pt); h_vbf_wjj_eta.Fill(vbf_wjj_eta); h_vbf_wjj_phi.Fill(vbf_wjj_phi); h_vbf_wjj_e.Fill(vbf_wjj_e); h_vbf_wjj_m.Fill(vbf_wjj_m); h_vbf_waj_pt.Fill(vbf_waj_pt); h_vbf_waj_eta.Fill(vbf_waj_eta); h_vbf_waj_phi.Fill(vbf_waj_phi); h_vbf_waj_e.Fill(vbf_waj_e); h_vbf_wbj_pt.Fill(vbf_wbj_pt); h_vbf_wbj_eta.Fill(vbf_wbj_eta); h_vbf_wbj_phi.Fill(vbf_wbj_phi); h_vbf_wbj_e.Fill(vbf_wbj_e); h_vbf_wjj_deta.Fill(vbf_wjj_deta); h_vbf_wjj_dphi.Fill(vbf_wjj_dphi); h_vbf_lvjj_pt.Fill(vbf_lvjj_pt); h_vbf_lvjj_eta.Fill(vbf_lvjj_eta); h_vbf_lvjj_phi.Fill(vbf_lvjj_phi); h_vbf_lvjj_e.Fill(vbf_lvjj_e); h_vbf_lvjj_m.Fill(vbf_lvjj_m); h_vbf_lvj_m.Fill(vbf_lvj_m); h_vbf_l_pt.Fill(vbf_l_pt); h_vbf_l_eta.Fill(vbf_l_eta); h_vbf_l_phi.Fill(vbf_l_phi); h_vbf_l_e.Fill(vbf_l_e); h_vbf_nu_e.Fill(vbf_nu_e); h_vbf_l_MET_deltaphi.Fill(vbf_l_MET_deltaphi); h_vbf_lW_hW_deltaphi.Fill(vbf_lW_hW_deltaphi); h_vbf_l_tj1_dR.Fill(vbf_l_tj1_dR); h_vbf_l_tj2_dR.Fill(vbf_l_tj2_dR); h_vbf_l_wj1_dR.Fill(vbf_l_wj1_dR); h_vbf_l_wj1_dR.Fill(vbf_l_wj1_dR); h_vbf_l_wjj_dR.Fill(vbf_l_wjj_dR); h_vbf_l_tjj_dR.Fill(vbf_l_tjj_dR); } for (int k = 0 ; k < Jets.size () ; ++k) h_jeta.Fill (Jets.at (k)->Eta ()) ; if (gluons.size () > 0) h_jeta.Fill (gluons.at (0)->Eta ()) ; } // Now loop over all events // TFile histosFile ("cuts_phantom_lheAnalysis_.root","recreate") ; TFile histosFile ("unweighted_500Kevents_VBFcuts.root","recreate") ; // TFile histosFile ("cuts_Madgraph_lheAnalysis_.root","recreate") ; // TFile histosFile ("cuts_vbfnlo_lheAnalysis_.root","recreate") ; histosFile.cd () ; h_deta.Write () ; h_j1eta.Write () ; h_j2eta.Write () ; h_jeta.Write () ; h_j1pt.Write () ; h_j2pt.Write () ; h_vbf_jj_pt.Write (); h_vbf_jj_eta.Write (); h_vbf_jj_phi.Write (); h_vbf_jj_e.Write (); h_vbf_jj_m.Write (); h_vbf_aj_pt.Write (); h_vbf_aj_eta.Write (); h_vbf_aj_phi.Write (); h_vbf_aj_e.Write (); h_vbf_bj_pt.Write (); h_vbf_bj_eta.Write (); h_vbf_bj_phi.Write (); h_vbf_bj_e.Write (); h_vbf_jj_deta.Write (); h_vbf_jj_dphi.Write (); h_vbf_wjj_pt.Write (); h_vbf_wjj_eta.Write (); h_vbf_wjj_phi.Write (); h_vbf_wjj_e.Write (); h_vbf_wjj_m.Write (); h_vbf_waj_pt.Write (); h_vbf_waj_eta.Write (); h_vbf_waj_phi.Write (); h_vbf_waj_e.Write (); h_vbf_wbj_pt.Write (); h_vbf_wbj_eta.Write (); h_vbf_wbj_phi.Write (); h_vbf_wbj_e.Write (); h_vbf_lvjj_pt.Write (); h_vbf_lvjj_eta.Write (); h_vbf_lvjj_phi.Write (); h_vbf_lvjj_e.Write (); h_vbf_lvjj_m.Write (); h_vbf_lvj_m.Write (); h_vbf_l_pt.Write(); h_vbf_l_eta.Write(); h_vbf_l_phi.Write(); h_vbf_l_e.Write(); h_vbf_nu_e.Write(); h_vbf_l_MET_deltaphi.Write(); h_vbf_lW_hW_deltaphi.Write(); h_vbf_l_tj1_dR.Write(); h_vbf_l_tj2_dR.Write(); h_vbf_l_wj1_dR.Write(); h_vbf_l_wj1_dR.Write(); h_vbf_l_wjj_dR.Write(); h_vbf_l_tjj_dR.Write(); h_vbf_wjj_deta.Write (); h_vbf_wjj_dphi.Write (); histosFile.Close () ; return ; }
void fillHistos (std::string fileName, TNtuple & ntuple) { std::ifstream ifs (fileName.c_str ()) ; LHEF::Reader reader (ifs) ; long ieve = 0 ; double jetsNum = 0. ; // loop over events while ( reader.readEvent () ) { ++ieve; if (ieve % 10000 == 0) std::cout << "event " << ieve << "\n" ; std::vector<int> finalJets ; std::vector<int> initialQuarks ; //PG loop over particles in the event //PG and fill the variables of leptons and quarks for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size (); ++iPart) { // std::cout << "\t part type [" << iPart << "] " << reader.hepeup.IDUP.at (iPart) // << "\t status " << reader.hepeup.ISTUP.at (iPart) // << "\n" ; //PG incoming particle if (reader.hepeup.ISTUP.at (iPart) == -1) { initialQuarks.push_back (iPart) ; } //PG incoming particle //PG outgoing particles if (reader.hepeup.ISTUP.at (iPart) == 1) { //PG quarks if (abs (reader.hepeup.IDUP.at (iPart)) < 7 || reader.hepeup.IDUP.at (iPart) == 21) { finalJets.push_back (iPart) ; } } //PG outgoing particles } //PG loop over particles in the event jetsNum += finalJets.size () ; if (finalJets.size () < 2) continue ; //PG build the two quarks TLorentzVector fquark0 ( reader.hepeup.PUP.at (finalJets.at (0)).at (0), //PG px reader.hepeup.PUP.at (finalJets.at (0)).at (1), //PG py reader.hepeup.PUP.at (finalJets.at (0)).at (2), //PG pz reader.hepeup.PUP.at (finalJets.at (0)).at (3) //PG E ) ; TLorentzVector fquark1 ( reader.hepeup.PUP.at (finalJets.at (1)).at (0), //PG px reader.hepeup.PUP.at (finalJets.at (1)).at (1), //PG py reader.hepeup.PUP.at (finalJets.at (1)).at (2), //PG pz reader.hepeup.PUP.at (finalJets.at (1)).at (3) //PG E ) ; //PG the sum pf the two quarks TLorentzVector vCand = fquark0 + fquark1 ; ntuple.Fill ( vCand.M () , fabs (fquark0.Eta () - fquark1.Eta ()) , fquark0.DeltaR (fquark1) , fabs (fquark0.DeltaPhi (fquark1)) ) ; //PG sort the two quarks in pt TLorentzVector fquarkMax, fquarkMin ; if (fquark0.Perp () > fquark1.Perp ()) { fquarkMax = fquark0 ; fquarkMin = fquark1 ; } else { fquarkMax = fquark1 ; fquarkMin = fquark0 ; } } // loop over events std::cout << jetsNum/ieve << " in " << fileName << std::endl ; }
int main(int argc, char *argv[]) { char appName[] = "ExRootLHEFConverter"; if(argc != 4) { cout << " Usage: " << appName << " input_file" << " outOnPeak_file" << " outOffPeak_file" <<endl; cout << " input_file - input file in LHEF format," << endl; cout << " outOnPeak_file - output file with m(H) <140 GeV." << endl; cout << " outOffPeak_file - output file with m(H) >=140 GeV." << endl; return 1; } gROOT->SetBatch(); int appargc = 1; char *appargv[] = {appName}; TApplication app(appName, &appargc, appargv); // Open a stream connected to an event file: ifstream inputFileStream(argv[1]); // Create the Reader object: LHEF::Reader *inputReader = new LHEF::Reader(inputFileStream); ofstream onPeakFile(argv[2]); ofstream offPeakFile(argv[3]); LHEF::Writer *onPeakWriter = new LHEF::Writer(onPeakFile); LHEF::Writer *offPeakWriter = new LHEF::Writer(offPeakFile); onPeakWriter->heprup = inputReader->heprup; offPeakWriter->heprup = inputReader->heprup; onPeakWriter->init(); offPeakWriter->init(); //TFile *outputFile = TFile::Open(argv[2], "RECREATE"); //ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputFile, "LHEF"); // generated event from LHEF //ExRootTreeBranch *branchEvent = treeWriter->NewBranch("Event", TRootLHEFEvent::Class()); // generated partons from LHEF // ExRootTreeBranch *branchParticle = treeWriter->NewBranch("Particle", TRootLHEFParticle::Class()); cout << "** Calculating number of events to process. Please wait..." << endl; Long64_t allEntries = inputReader->getNumberOfEvents(); cout << "** Input file contains " << allEntries << " events" << endl; if(allEntries > 0) { ExRootProgressBar progressBar(allEntries); // Loop over all events Long64_t entry = 0; while(inputReader->readEvent()) { //treeWriter->Clear(); AnalyseEvent(inputReader, entry + 1); //AnalyseEvent(inputReader, branchEvent, entry + 1); if( AnalyseParticles(inputReader ) == 1) { offPeakWriter->hepeup = inputReader->hepeup; offPeakWriter->writeEvent(); }else{ onPeakWriter->hepeup = inputReader->hepeup; onPeakWriter->writeEvent(); } //AnalyseParticles(inputReader, branchParticle); //treeWriter->Fill(); progressBar.Update(entry); ++entry; } progressBar.Finish(); } //treeWriter->Write(); cout << "** Exiting..." << endl; //delete treeWriter; //delete outputFile; delete inputReader; delete onPeakWriter; delete offPeakWriter; onPeakFile.close(); offPeakFile.close(); inputFileStream.close(); }
int main(int argc, char ** argv) { if(argc < 2) { cout << "Usage: " << argv[0] << " input.lhe " << endl ; return -1; } bool REW = false ; if (argc > 2) REW = true ; cout << REW << endl ; const int SUBSET = 0; const string NAME = "cteq6ll"; //"cteq6l1" LHAPDF::initPDFSet(NAME, LHAPDF::LHPDF, SUBSET); const int NUMBER = LHAPDF::numberPDF(); LHAPDF::initPDF (0) ; std::ifstream ifs (argv[1]) ; LHEF::Reader reader (ifs) ; TH1F h_phScale ("h_phScale", "h_phScale", 100, 0, 1000) ; TH1F h_scale ("h_scale", "h_scale", 100, 0, 1000) ; TH1F h_x ("h_x", "h_x", 100, 0, 1) ; TH1F h_weight ("h_weight", "h_weight", 100, 0, 2) ; TH1F h_phaseSp ("h_phaseSp", "h_phaseSp", 1000, 0, 10) ; TH1F h_ptj1 ("h_ptj1", "h_ptj1", 60, 0, 400) ; TH1F h_ptj2 ("h_ptj2", "h_ptj2", 50, 0, 300) ; TH1F h_etaj1 ("h_etaj1", "h_etaj1", 40, 0, 6) ; TH1F h_etaj2 ("h_etaj2", "h_etaj2", 40, 0, 6) ; TH1F h_mjj ("h_mjj", "h_mjj", 50, 0, 3500) ; TH1F h_detajj ("h_detajj", "h_detajj", 100, 30, 10) ; TH1F h_mll ("h_mll", "h_mll", 40, 0, 300) ; h_phScale.Sumw2 () ; h_scale.Sumw2 () ; h_x.Sumw2 () ; h_weight.Sumw2 () ; h_phaseSp.Sumw2 () ; h_ptj1.Sumw2 () ; h_ptj2.Sumw2 () ; h_etaj1.Sumw2 () ; h_etaj2.Sumw2 () ; h_mjj.Sumw2 () ; h_detajj.Sumw2 () ; h_mll.Sumw2 () ; int number_total = 0 ; int number_selec = 0 ; //PG loop over input events while (reader.readEvent ()) { if ( reader.outsideBlock.length() ) std::cout << reader.outsideBlock; ++number_total ; TLorentzVector Higgs; int iPartHiggs; std::vector<int> leptonsFlavour ; std::vector<int> finalJets ; std::vector<int> initialQuarks ; vector<TLorentzVector> v_f_jets ; //PG w/ b's vector<TLorentzVector> v_f_quarks ; //PG w/o b's vector<TLorentzVector> v_f_leptons ; vector<TLorentzVector> v_f_neutrinos ; vector<TLorentzVector> v_f_intermediate ; int nele = 0 ; int nmu = 0 ; int ntau = 0 ; double x[2] = {0., 0.} ; int flavour[2] = {0, 0} ; // loop over particles in the event // and fill the variables of leptons and quarks for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size (); ++iPart) { TLorentzVector dummy = buildP (reader.hepeup, iPart) ; // incoming particle if (reader.hepeup.ISTUP.at (iPart) == -1) { initialQuarks.push_back (iPart) ; x[iPart] = dummy.P () / 4000. ; flavour[iPart] = reader.hepeup.IDUP.at (iPart) ; } // incoming particle if (reader.hepeup.ISTUP.at (iPart) == 2) { if (abs (reader.hepeup.IDUP.at (iPart)) == 6) { v_f_intermediate.push_back (dummy) ; } } // outgoing particles if (reader.hepeup.ISTUP.at (iPart) == 1) { // quarks if (abs (reader.hepeup.IDUP.at (iPart)) < 7) { v_f_jets.push_back (dummy) ; finalJets.push_back (iPart) ; if (abs (reader.hepeup.IDUP.at (iPart)) < 5) { v_f_quarks.push_back (dummy) ; } } // quarks else if (abs (reader.hepeup.IDUP.at (iPart)) == 11 || abs (reader.hepeup.IDUP.at (iPart)) == 13 || abs (reader.hepeup.IDUP.at (iPart)) == 15) { leptonsFlavour.push_back (reader.hepeup.IDUP.at (iPart)) ; v_f_leptons.push_back (dummy) ; nele += (abs (reader.hepeup.IDUP.at (iPart)) == 11) ; nmu += (abs (reader.hepeup.IDUP.at (iPart)) == 13) ; ntau += (abs (reader.hepeup.IDUP.at (iPart)) == 15) ; } else if (abs (reader.hepeup.IDUP.at (iPart)) == 12 || abs (reader.hepeup.IDUP.at (iPart)) == 14 || abs (reader.hepeup.IDUP.at (iPart)) == 16) { v_f_neutrinos.push_back (dummy) ; } } // outgoing particles } // loop over particles in the event //PG selections to equalise the two samples //PG ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- if (ntau > 0) continue ; if (v_f_quarks.size () != finalJets.size ()) continue ; //PG no bs in the final state if (v_f_quarks.size () < 2) continue ; if (v_f_intermediate.size () > 0) continue ; //PG no intermediate tops sort (v_f_quarks.rbegin (), v_f_quarks.rend (), ptsort ()) ; //PG residual differences in the generation thresholds //PG selections like this work only if one expects only 2 quarks in the event //PG otherwise need to reduce the quarks collection first if (v_f_quarks.at (0).Pt () < 20 || v_f_quarks.at (1).Pt () < 20 || v_f_quarks.at (0).E () < 20 || v_f_quarks.at (1).E () < 20 || fabs (v_f_quarks.at (0).Eta ()) > 5 || fabs (v_f_quarks.at (1).Eta ()) > 5 || fabs (v_f_leptons.at (0).Eta ()) > 2.5 || fabs (v_f_leptons.at (1).Eta ()) > 2.5 || v_f_leptons.at (0).Pt () < 6 || v_f_leptons.at (1).Pt () < 6) continue ; // if (v_f_leptons.at (0).DeltaR (v_f_leptons.at (1)) < 0.4) continue ; // if (v_f_quarks.at (0).DeltaR (v_f_quarks.at (1)) < 0.4) continue ; // // int cont = 0 ; // for (int iL = 0 ; iL < 2 ; ++iL) // for (int iJ = 0 ; iJ < 2 ; ++iJ) // if (v_f_quarks.at (iJ).DeltaR (v_f_leptons.at (iL)) < 0.4) cont = 1 ; // if (cont == 1) continue ; TLorentzVector diLepton = v_f_leptons.at (0) + v_f_leptons.at (1) ; if (diLepton.M () < 12) continue ; if (v_f_neutrinos.at (0).Pt () < 6 || v_f_neutrinos.at (1).Pt () < 6) continue ; // TLorentzVector missingEnergy = v_f_neutrinos.at (0) + v_f_neutrinos.at (1) ; // if (missingEnergy.Pt () < 6) continue ; TLorentzVector diJet = v_f_quarks.at (0) + v_f_quarks.at (1) ; if (diJet.M () < 100) continue ; //PG only different flavour if (abs (leptonsFlavour[0]) == abs (leptonsFlavour[1])) continue ; // if (leptonsFlavour[0] == -1 * leptonsFlavour[1] && // diLepton.M () < 97.5 && diLepton.M () > 83.5) continue ; //PG VBF cuts if (diJet.M () < 500 || fabs (v_f_quarks.at (0).Eta () - v_f_quarks.at (1).Eta ()) < 3.5) continue ; //PG opposite charge leptons if (leptonsFlavour.at (0) * leptonsFlavour.at (1) > 0) continue ; sort (v_f_leptons.rbegin (), v_f_leptons.rend (), ptsort ()) ; //PG analysis state cuts if (v_f_quarks.at (0).Pt () < 30 || v_f_quarks.at (1).Pt () < 30 || v_f_leptons.at (0).Pt () < 20 || v_f_leptons.at (1).Pt () < 10) continue ; //PG at this point the two generations should be on the same page //PG ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ++number_selec ; //PG the scale: float scale = reader.hepeup.SCALUP ; //PG determine the scale according to the phantom recipe double phantomScale = 80.385 * 80.385 + (v_f_quarks.at (0).Pt () * v_f_quarks.at (0).Pt () + v_f_quarks.at (1).Pt () * v_f_quarks.at (1).Pt () + v_f_leptons.at (0).Pt () * v_f_leptons.at (0).Pt () + v_f_leptons.at (1).Pt () * v_f_leptons.at (1).Pt () + v_f_neutrinos.at (0).Pt () * v_f_neutrinos.at (0).Pt () + v_f_neutrinos.at (1).Pt () * v_f_neutrinos.at (1).Pt ()) / 6. ; phantomScale = sqrt (phantomScale) ; //PG calculate the weight to be applied to the event double weight = LHAPDF::xfx (x[0], phantomScale, flavour[0]) * LHAPDF::xfx (x[1], phantomScale, flavour[1]) / (LHAPDF::xfx (x[0], scale, flavour[0]) * LHAPDF::xfx (x[1], scale, flavour[1])) ; // cout << weight << endl ; h_weight.Fill (weight) ; h_phaseSp.Fill (LHAPDF::xfx (x[0], scale, flavour[0]) * LHAPDF::xfx (x[1], scale, flavour[1])) ; h_phScale.Fill (phantomScale) ; //PG fill histos if (!REW) weight = 1. ; h_ptj1.Fill (v_f_quarks.at (0).Pt (), weight) ; h_ptj2.Fill (v_f_quarks.at (1).Pt (), weight) ; h_etaj1.Fill (v_f_quarks.at (0).Eta (), weight) ; h_etaj2.Fill (v_f_quarks.at (1).Eta (), weight) ; h_scale.Fill (scale, weight) ; h_x.Fill (x[0], weight) ; h_x.Fill (x[1], weight) ; h_mjj.Fill (diJet.M (), weight) ; h_detajj.Fill (fabs (v_f_quarks.at (0).Eta () - v_f_quarks.at (1).Eta ())) ; h_mll.Fill (diLepton.M (), weight) ; } //PG loop over input events cout << "total " << number_total << endl ; cout << "efficiency " << number_selec * 1. / number_total << endl ; TFile f ("reweight.root", "recreate") ; h_phaseSp.Write () ; h_weight.Write () ; h_phScale.Write () ; h_scale.Write () ; h_x.Write () ; h_mjj.Write () ; h_detajj.Write () ; h_mll.Write () ; h_ptj1.Write () ; h_ptj2.Write () ; h_etaj1.Write () ; h_etaj2.Write () ; f.Close () ; return 0 ; }
map<string, TH1F *> readSample (string sampleName, string radice, LHAPDF::PDF * pdf, float referenceScale = 0., int maxevents = -1) { cout << "reading " << sampleName << endl ; std::ifstream ifs (sampleName.c_str ()) ; LHEF::Reader reader (ifs) ; map<string, TH1F *> histos ; TH1F * h_vbf0_eta = addHistoToMap (histos, string ("vbf0_eta_") + radice, 40, -6, 6) ; TH1F * h_vbf0_pt = addHistoToMap (histos, string ("vbf0_pt_") + radice, 100, 0, 400) ; TH1F * h_vbf0_phi = addHistoToMap (histos, string ("vbf0_phi_") + radice, 30, -3.14, 3.14) ; TH1F * h_vbf1_eta = addHistoToMap (histos, string ("vbf1_eta_") + radice, 40, -6, 6) ; TH1F * h_vbf1_pt = addHistoToMap (histos, string ("vbf1_pt_") + radice, 100, 0, 250) ; TH1F * h_vbf1_phi = addHistoToMap (histos, string ("vbf1_phi_") + radice, 30, -3.14, 3.14) ; TH1F * h_lep0_eta = addHistoToMap (histos, string ("lep0_eta_") + radice, 40, -6, 6) ; TH1F * h_lep0_pt = addHistoToMap (histos, string ("lep0_pt_") + radice, 100, 0, 400) ; TH1F * h_lep0_phi = addHistoToMap (histos, string ("lep0_phi_") + radice, 30, -3.14, 3.14) ; TH1F * h_lep1_eta = addHistoToMap (histos, string ("lep1_eta_") + radice, 40, -6, 6) ; TH1F * h_lep1_pt = addHistoToMap (histos, string ("lep1_pt_") + radice, 100, 0, 250) ; TH1F * h_lep1_phi = addHistoToMap (histos, string ("lep1_phi_") + radice, 30, -3.14, 3.14) ; TH1F * h_lep2_eta = addHistoToMap (histos, string ("lep2_eta_") + radice, 40, -6, 6) ; TH1F * h_lep2_pt = addHistoToMap (histos, string ("lep2_pt_") + radice, 100, 0, 250) ; TH1F * h_lep2_phi = addHistoToMap (histos, string ("lep2_phi_") + radice, 30, -3.14, 3.14) ; TH1F * h_met_eta = addHistoToMap (histos, string ("met_eta_") + radice, 40, -6, 6) ; TH1F * h_met_pt = addHistoToMap (histos, string ("met_pt_") + radice, 100, 0, 250) ; TH1F * h_met_phi = addHistoToMap (histos, string ("met_phi_") + radice, 30, -3.14, 3.14) ; TH1F * h_mjj_vbf = addHistoToMap (histos, string ("mjj_vbf_") + radice, 70, 0, 4000) ; TH1F * h_deta_vbf = addHistoToMap (histos, string ("deta_vbf_") + radice, 70, 0, 10) ; TH1F * h_NJ = addHistoToMap (histos, string ("NJ_") + radice, 5, 0, 5) ; TH1F * h_NG = addHistoToMap (histos, string ("NG_") + radice, 5, 0, 5) ; TH1F * h_scale = addHistoToMap (histos, string ("scale_") + radice, 100, 0., 500.) ; TH1F * h_weight = addHistoToMap (histos, string ("weight_") + radice, 100, 0., 10.) ; int ieve = 0 ; // loop over events while ( reader.readEvent () ) { if (ieve % 10000 == 0) std::cout << "event " << ieve << "\n" ; if (maxevents > 0 && ieve >= maxevents) break ; ++ieve; vector<TLorentzVector> finalJets ; vector<TLorentzVector> initialQuarks ; vector<TLorentzVector> finalQuarks ; vector<TLorentzVector> finalGluons ; vector<TLorentzVector> leptons ; vector<TLorentzVector> neutrinos ; double x[2] = {0., 0.} ; int flavour[2] = {0, 0} ; int iquark = 0 ; //PG loop over particles in the event //PG and fill the variables of leptons and quarks for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size (); ++iPart) { // std::cout << "\t part type [" << iPart << "] " << reader.hepeup.IDUP.at (iPart) // << "\t status " << reader.hepeup.ISTUP.at (iPart) // << "\n" ; TLorentzVector particle ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E ) ; //PG incoming particle if (reader.hepeup.ISTUP.at (iPart) == -1) { x[iquark] = particle.P () / 7000. ; flavour[iquark++] = reader.hepeup.IDUP.at (iPart) ; initialQuarks.push_back (particle) ; } //PG incoming particle //PG outgoing particles if (reader.hepeup.ISTUP.at (iPart) == 1) { // jets if (abs (reader.hepeup.IDUP.at (iPart)) < 7) // quarks { finalJets.push_back (particle) ; finalQuarks.push_back (particle) ; } // quarks else if (abs (reader.hepeup.IDUP.at (iPart)) == 21 ) // gluons { finalJets.push_back (particle) ; finalGluons.push_back (particle) ; } // gluons else if (abs (reader.hepeup.IDUP.at (iPart)) == 11 || abs (reader.hepeup.IDUP.at (iPart)) == 13) // charged leptons (e,u) { leptons.push_back (particle) ; } //PG charged leptons else if (abs (reader.hepeup.IDUP.at (iPart)) == 12 || abs (reader.hepeup.IDUP.at (iPart)) == 14) // neutrinos { neutrinos.push_back (particle) ; } //PG neutrinos else if (abs (reader.hepeup.IDUP.at (iPart)) == 15 || abs (reader.hepeup.IDUP.at (iPart)) == 16) // charged leptons (tau) { cout << "WARNING third family present!" << endl ; } //PG charged leptons else if (abs (reader.hepeup.IDUP.at (iPart)) == 9) // gluon? { cout << "WARNING found gluon with pddgID == 9\n" ; finalJets.push_back (particle) ; } //PG gluon? } //PG outgoing particles } //PG loop over particles in the event // dynamic scale according to phantom recipe if (referenceScale < 0) { referenceScale = leptons.at (0).Pt () * leptons.at (0).Pt () ; referenceScale += leptons.at (1).Pt () * leptons.at (1).Pt () ; referenceScale += leptons.at (2).Pt () * leptons.at (2).Pt () ; referenceScale += neutrinos.at (0).Pt () * neutrinos.at (0).Pt () ; referenceScale += finalJets.at (1).Pt () * finalJets.at (1).Pt () ; referenceScale += finalJets.at (0).Pt () * finalJets.at (0).Pt () ; referenceScale /= 6. ; referenceScale = sqrt (referenceScale) ; referenceScale += 80. ; } double weight = 1. ; float scale = reader.hepeup.SCALUP ; if (referenceScale != 0 ) weight = pdf->xfxQ (flavour[0], x[0], referenceScale) * pdf->xfxQ (flavour[1], x[1], referenceScale) / (pdf->xfxQ (flavour[0], x[0], scale) * pdf->xfxQ (flavour[1], x[1], scale)) ; if (isnan (weight)) { cout << "WARNING weight is not a number, setting to 1." << endl ; weight = 1. ; } if (isinf (weight)) { cout << "WARNING weight is infinite, setting to 1." << endl ; weight = 1. ; } h_weight->Fill (weight) ; h_scale->Fill (scale) ; sort (leptons.rbegin (), leptons.rend (), ptSort ()) ; sort (finalJets.rbegin (), finalJets.rend (), ptSort ()) ; float mjj = (finalJets.at (0) + finalJets.at (1)).M () ; float detajj = fabs (finalJets.at (0).Eta () - finalJets.at (1).Eta ()) ; //CUTS if (leptons.at (0).Pt () < 20) continue ; if (leptons.at (1).Pt () < 20) continue ; if (leptons.at (2).Pt () < 20) continue ; if (finalJets.at (0).Pt () < 20) continue ; if (finalJets.at (1).Pt () < 20) continue ; // if (finalGluons.size () == 1) continue ; if (mjj < 300) continue ; // get the tag jets h_NJ->Fill (finalJets.size (), weight) ; h_NG->Fill (finalGluons.size (), weight) ; h_vbf0_eta->Fill (finalJets.at (0).Eta (), weight) ; h_vbf0_phi->Fill (finalJets.at (0).Phi (), weight) ; h_vbf0_pt-> Fill (finalJets.at (0).Pt (), weight) ; h_vbf1_eta->Fill (finalJets.at (1).Eta (), weight) ; h_vbf1_phi->Fill (finalJets.at (1).Phi (), weight) ; h_vbf1_pt-> Fill (finalJets.at (1).Pt (), weight) ; h_mjj_vbf->Fill (mjj, weight) ; h_deta_vbf->Fill (detajj, weight) ; h_lep0_eta->Fill (leptons.at (0).Eta (), weight) ; h_lep0_phi->Fill (leptons.at (0).Phi (), weight) ; h_lep0_pt-> Fill (leptons.at (0).Pt (), weight) ; h_lep1_eta->Fill (leptons.at (1).Eta (), weight) ; h_lep1_phi->Fill (leptons.at (1).Phi (), weight) ; h_lep1_pt-> Fill (leptons.at (1).Pt (), weight) ; h_lep2_eta->Fill (leptons.at (2).Eta (), weight) ; h_lep2_phi->Fill (leptons.at (2).Phi (), weight) ; h_lep2_pt-> Fill (leptons.at (2).Pt (), weight) ; h_met_eta->Fill (neutrinos.at (0).Eta (), weight) ; h_met_phi->Fill (neutrinos.at (0).Phi (), weight) ; h_met_pt-> Fill (neutrinos.at (0).Pt (), weight) ; } // loop over events return histos ; }
map<string, TH1F *> readSample (string sampleName, string radice, int maxevents = -1) { cout << "reading " << sampleName << endl ; std::ifstream ifs (sampleName.c_str ()) ; LHEF::Reader reader (ifs) ; map<string, TH1F *> histos ; TH1F * h_initPart = addHistoToMap (histos, string ("initPart_") + radice, 25, -22.5, 22.5) ; TH1F * h_vbf0_eta = addHistoToMap (histos, string ("vbf0_eta_") + radice, 20, -6, 6) ; TH1F * h_vbf0_pt = addHistoToMap (histos, string ("vbf0_pt_") + radice, 20, 0, 400) ; TH1F * h_vbf0_phi = addHistoToMap (histos, string ("vbf0_phi_") + radice, 15, -3.14, 3.14) ; TH1F * h_vbf1_eta = addHistoToMap (histos, string ("vbf1_eta_") + radice, 20, -6, 6) ; TH1F * h_vbf1_pt = addHistoToMap (histos, string ("vbf1_pt_") + radice, 12, 0, 250) ; TH1F * h_vbf1_phi = addHistoToMap (histos, string ("vbf1_phi_") + radice, 15, -3.14, 3.14) ; TH1F * h_lep0_eta = addHistoToMap (histos, string ("lep0_eta_") + radice, 20, -6, 6) ; TH1F * h_lep0_pt = addHistoToMap (histos, string ("lep0_pt_") + radice, 10, 0, 400) ; TH1F * h_lep0_phi = addHistoToMap (histos, string ("lep0_phi_") + radice, 15, -3.14, 3.14) ; TH1F * h_lep1_eta = addHistoToMap (histos, string ("lep1_eta_") + radice, 20, -6, 6) ; TH1F * h_lep1_pt = addHistoToMap (histos, string ("lep1_pt_") + radice, 12, 0, 250) ; TH1F * h_lep1_phi = addHistoToMap (histos, string ("lep1_phi_") + radice, 15, -3.14, 3.14) ; TH1F * h_met_eta = addHistoToMap (histos, string ("met_eta_") + radice, 20, -6, 6) ; TH1F * h_met_pt = addHistoToMap (histos, string ("met_pt_") + radice, 12, 0, 250) ; TH1F * h_met_phi = addHistoToMap (histos, string ("met_phi_") + radice, 15, -3.14, 3.14) ; TH1F * h_dphijj_vbf = addHistoToMap (histos, string ("dphijj_vbf_") + radice, 8, 0, 3.14) ; TH1F * h_mjj_vbf = addHistoToMap (histos, string ("mjj_vbf_") + radice, 12, 0, 2500) ; TH1F * h_NJ = addHistoToMap (histos, string ("NJ_") + radice, 5, 0, 5) ; TH1F * h_mll = addHistoToMap (histos, string ("mll_") + radice, 12, 0, 2500) ; TH1F * h_m4l = addHistoToMap (histos, string ("m4l_") + radice, 20, 0, 2275) ; int ieve = 0 ; int btagged = 0 ; int selected = 0 ; // loop over events while ( reader.readEvent () ) { if (ieve % 10000 == 0) std::cout << "event " << ieve << "\n" ; if (maxevents > 0 && ieve >= maxevents) break ; ++ieve; vector<int> initialParticlesPDGId ; vector<TLorentzVector> finalLeptons ; vector<TLorentzVector> finalNeutrinos ; vector<TLorentzVector> initialQuarks ; vector<TLorentzVector> finalJets ; vector<TLorentzVector> finalBs ; int leptonsIDproduct = 1 ; //PG loop over particles in the event //PG and fill the variables of leptons and quarks for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size (); ++iPart) { // std::cout << "\t part type [" << iPart << "] " << reader.hepeup.IDUP.at (iPart) // << "\t status " << reader.hepeup.ISTUP.at (iPart) // << "\n" ; //PG incoming particle if (reader.hepeup.ISTUP.at (iPart) == -1) { initialParticlesPDGId.push_back (reader.hepeup.IDUP.at (iPart)) ; initialQuarks.push_back (TLorentzVector ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E )) ; } //PG incoming particle //PG outgoing particles if (reader.hepeup.ISTUP.at (iPart) == 1) { // jets if (abs (reader.hepeup.IDUP.at (iPart)) < 7 || // quarks abs (reader.hepeup.IDUP.at (iPart)) == 21 ) // gluons { finalJets.push_back (TLorentzVector ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E )) ; if (abs (reader.hepeup.IDUP.at (iPart)) == 5) // b's { finalBs.push_back (TLorentzVector ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E )) ; } // b's } // jets else if (abs (reader.hepeup.IDUP.at (iPart)) == 11 || abs (reader.hepeup.IDUP.at (iPart)) == 13 ) // charged leptons { leptonsIDproduct *= reader.hepeup.IDUP.at (iPart) ; finalLeptons.push_back (TLorentzVector ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E )) ; } //PG charged leptons else if (abs (reader.hepeup.IDUP.at (iPart)) == 12 || abs (reader.hepeup.IDUP.at (iPart)) == 14 ) // neutrinos { finalNeutrinos.push_back (TLorentzVector ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E )) ; } // neutrinos } //PG outgoing particles } //PG loop over particles in the event if (initialParticlesPDGId.size () != 2) exit (1) ; if (finalJets.size () != 2) continue ; if (finalNeutrinos.size () != 2) continue ; if (finalLeptons.size () != 2) continue ; // if (fabs (initialParticlesPDGId.at (0)) > 4) continue ; // if (fabs (initialParticlesPDGId.at (1)) > 4) continue ; // the following remove events with guons as initial particles // if (fabs (initialParticlesPDGId.at (0)) > 6) continue ; // if (fabs (initialParticlesPDGId.at (1)) > 6) continue ; sort (finalJets.rbegin (), finalJets.rend (), ptSort ()) ; if (finalJets.at (0).Pt () < 20) continue ; if (finalJets.at (1).Pt () < 20) continue ; if (finalJets.at (0).E () < 20) continue ; if (finalJets.at (1).E () < 20) continue ; if (fabs (finalJets.at (0).Eta ()) > 6.5) continue ; if (fabs (finalJets.at (1).Eta ()) > 6.5) continue ; sort (finalLeptons.rbegin (), finalLeptons.rend (), ptSort ()) ; if (finalLeptons.at (0).Pt () < 20) continue ; if (finalLeptons.at (1).Pt () < 20) continue ; if (finalLeptons.at (0).E () < 20) continue ; if (finalLeptons.at (1).E () < 20) continue ; if (fabs (finalLeptons.at (0).Eta ()) > 4) continue ; if (fabs (finalLeptons.at (1).Eta ()) > 4) continue ; TLorentzVector tl_diJet = finalJets.at (0) + finalJets.at (1) ; float mjj = tl_diJet.M () ; if (mjj < 300) continue ; if (fabs (finalJets.at (0).Eta () - finalJets.at (1).Eta ()) < 2) continue ; float m4l = (finalNeutrinos.at (0) + finalLeptons.at (0) + finalLeptons.at (1) + finalNeutrinos.at (0)).M () ; if (m4l < 130) continue ; TLorentzVector tl_met = finalNeutrinos.at (0) + finalNeutrinos.at (1) ; h_met_eta->Fill (tl_met.Eta ()) ; h_met_phi->Fill (tl_met.Phi ()) ; h_met_pt-> Fill (tl_met.Pt ()) ; TLorentzVector tl_diLepton = finalLeptons.at (0) + finalLeptons.at (1) ; float mll = tl_diLepton.M () ; // end of pre-selections if (mjj < 625) continue ; if (fabs (finalJets.at (0).Eta () - finalJets.at (1).Eta ()) < 2.5) continue ; if (mll < 40) continue ; if (mll > 81 && mll < 101) continue ; if (tl_met.Pt () < 40) continue ; if (fabs (finalLeptons.at (0).Eta () - finalLeptons.at (1).Eta ()) > 2) continue ; float etamin = min (finalJets.at (0).Eta (), finalJets.at (1).Eta ()) ; float etamax = max (finalJets.at (0).Eta (), finalJets.at (1).Eta ()) ; for (int i = 0 ; i < finalLeptons.size () ; ++i) { if (finalLeptons.at (i).Eta () > etamax) continue ; if (finalLeptons.at (i).Eta () < etamin) continue ; } if (tl_diLepton.DeltaR (tl_diJet) > 6) continue ; // end of analysis-like selection int countBs = 0 ; for (int i = 0 ; i < finalBs.size () ; ++i) if (fabs (finalBs.at (i).Eta ()) < 2.5) ++countBs ; if (countBs > 0) continue ; // end of selections ++selected ; h_NJ->Fill (finalJets.size ()) ; // cout << "Njs = " << finalJets.size () << "\n" ; // cout << "pts: " // << finalJets.at (0).Pt () // << "\t" // << finalJets.at (1).Pt () // << "\n" ; for (int i = 0 ; i < initialParticlesPDGId.size () ; ++i) h_initPart->Fill (initialParticlesPDGId.at (i)) ; h_vbf0_eta->Fill (finalJets.at (0).Eta ()) ; h_vbf0_phi->Fill (finalJets.at (0).Phi ()) ; h_vbf0_pt-> Fill (finalJets.at (0).Pt ()) ; h_vbf1_eta->Fill (finalJets.at (1).Eta ()) ; h_vbf1_phi->Fill (finalJets.at (1).Phi ()) ; h_vbf1_pt-> Fill (finalJets.at (1).Pt ()) ; h_lep0_eta->Fill (finalLeptons.at (0).Eta ()) ; h_lep0_phi->Fill (finalLeptons.at (0).Phi ()) ; h_lep0_pt-> Fill (finalLeptons.at (0).Pt ()) ; h_lep1_eta->Fill (finalLeptons.at (1).Eta ()) ; h_lep1_phi->Fill (finalLeptons.at (1).Phi ()) ; h_lep1_pt-> Fill (finalLeptons.at (1).Pt ()) ; h_mjj_vbf->Fill (mjj) ; h_mll->Fill (mll) ; h_m4l->Fill (m4l) ; h_dphijj_vbf->Fill (deltaPhi (finalJets.at (0).Phi (), finalJets.at (1).Phi ())) ; } // loop over events cout << "total eff : " << selected * 1./ieve << endl ; return histos ; }
double fillHistos (LHEF::Reader & reader, histos & Histos, double XS, double referenceScale = 0, int max = -1) { double totalCount = 0. ; int events = 0 ; //PG loop over input events while (reader.readEvent ()) { // if ( reader.outsideBlock.length() ) std::cout << reader.outsideBlock; if (events % 10000 == 0) cout << "reading " << events << " event" << endl ; vector<lorentzVector> v_f_Ws ; vector<lorentzVector> v_f_quarks ; vector<lorentzVector> v_f_leptons ; vector<lorentzVector> v_f_neutrinos ; double x[2] = {0., 0.} ; int flavour[2] = {0, 0} ; // loop over particles in the event for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size (); ++iPart) { lorentzVector dummy = buildLP (reader.hepeup, iPart) ; // incoming particles if (reader.hepeup.ISTUP.at (iPart) == -1) { x[iPart] = dummy.P () / 4000. ; flavour[iPart] = reader.hepeup.IDUP.at (iPart) ; } // incoming particles // intermediate particles if (reader.hepeup.ISTUP.at (iPart) == 2) { if (abs (reader.hepeup.IDUP.at (iPart)) == 24) { v_f_Ws.push_back (dummy) ; } } // intermediate particles // outgoing particles if (reader.hepeup.ISTUP.at (iPart) == 1) { // quarks if (abs (reader.hepeup.IDUP.at (iPart)) < 7) { v_f_quarks.push_back (dummy) ; } // quarks else if (abs (reader.hepeup.IDUP.at (iPart)) == 11 || abs (reader.hepeup.IDUP.at (iPart)) == 13 || abs (reader.hepeup.IDUP.at (iPart)) == 15) { v_f_leptons.push_back (dummy) ; } else if (abs (reader.hepeup.IDUP.at (iPart)) == 12 || abs (reader.hepeup.IDUP.at (iPart)) == 14 || abs (reader.hepeup.IDUP.at (iPart)) == 16) { v_f_neutrinos.push_back (dummy) ; } } // outgoing particles } // loop over particles in the event // if (totalCount < 10) cout << "PARTICLES " << v_f_leptons.size () << "\t" << v_f_neutrinos.size () << "\t" << v_f_quarks.size () << "\n" ; double weight = 1. ; float scale = reader.hepeup.SCALUP ; if (referenceScale != 0 ) weight = LHAPDF::xfx (x[0], referenceScale, flavour[0]) * LHAPDF::xfx (x[1], referenceScale, flavour[1]) / (LHAPDF::xfx (x[0], scale, flavour[0]) * LHAPDF::xfx (x[1], scale, flavour[1])) ; totalCount += weight ; int warnNum = 0 ; if (v_f_quarks.size () < 4) { cout << "warning, not enough quarks" << endl ; ++warnNum ; } if (v_f_leptons.size () < 1) { cout << "warning, not enough leptons" << endl ; ++warnNum ; } if (v_f_neutrinos.size () < 1) { cout << "warning, not enough neutrinos" << endl ; ++warnNum ; } if (warnNum > 0) continue ; //PG apply all the production cuts from phantom and madgraph to the sample //PG ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- if (v_f_leptons.at (0).Pt () < 20) continue ; if (v_f_leptons.at (0).E () < 20) continue ; if (fabs (v_f_leptons.at (0).Eta ()) > 3) continue ; if (fabs (v_f_neutrinos.at (0).Pt ()) < 20) continue ; int cont = 0 ; for (int i = 0 ; i < 4 ; ++i) if (v_f_quarks.at (i).Pt () > 20 && v_f_quarks.at (i).E () > 20 && fabs (v_f_quarks.at (i).Eta ()) < 6.5) cont += 1 ; if (cont < 4) continue ; pair<int, int> detaIndices = findPairWithLargestDeta (v_f_quarks) ; if (v_f_quarks.at (detaIndices.second).Eta () - v_f_quarks.at (detaIndices.first).Eta () < 2) continue ; lorentzVector largestPair = v_f_quarks.at (detaIndices.second) + v_f_quarks.at (detaIndices.first) ; if (largestPair.M () < 100) continue ; //PG selection applied in phantom cont = 0 ; for (int iJ = 0 ; iJ < 4 ; ++iJ) for (int iJ2 = iJ + 1 ; iJ2 < 4 ; ++iJ2) { // if (v_f_quarks.at (iJ).DeltaR (v_f_quarks.at (iJ2)) < 0.4) // { // cont = 1 ; // break ; // } lorentzVector thisPair = v_f_quarks.at (iJ) + v_f_quarks.at (iJ2) ; if (thisPair.M () < 30) { cont = 1 ; break ; } } if (cont == 1) continue ; cont = 0 ; for (int iJ = 0 ; iJ < 4 ; ++iJ) { if (deltaR2<lorentzVector> (v_f_quarks.at (iJ), v_f_leptons.at (0)) < 0.16) cont = 1 ; } if (cont == 1) continue ; //PG the first two are the VBF jets, the following ones the W jets // sort (v_f_quarks.rbegin (), v_f_quarks.rend (), ptsort ()) ; // pair<int, int> Wpair (2, 3) ; pair<int, int> Wpair = findPairWithWMass (v_f_quarks) ; if (Wpair.first > 3 || Wpair.second > 3) { cout << "warning, wrong quarks in W determination\n" ; } lorentzVector total = (v_f_leptons.at (0) + v_f_neutrinos.at (0)) + (v_f_quarks.at (Wpair.first) + v_f_quarks.at (Wpair.second)) ; //PG the scale: Histos.m_h_scale->Fill (scale) ; Histos.m_h_MWW->Fill (total.M (), weight) ; ++events ; if (max > 0 && max < events) { cout << max << " events reached, exiting" << endl ; break ; } } //PG loop over input events Histos.norm (totalCount) ; return totalCount ; }
int main (int argc, char ** argv) { if(argc < 3) { cout << "Usage: " << argv[0] << " input.lhe output.lhe" << endl ; return -1; } std::ifstream ifs (argv[1]) ; LHEF::Reader reader (ifs) ; ofstream outputStream (argv[2]) ; LHEF::Writer writer (outputStream) ; writer.headerBlock () << reader.headerBlock ; writer.initComments () << reader.initComments ; writer.heprup = reader.heprup ; writer.init () ; //PG mu massless in phantom // float k2 = 0.1056583715 * 0.1056583715 - 1.77682 * 1.77682 ; // GeV -3.14592562093 float k2 = 0. - 1.77682 * 1.77682 ; // GeV -3.14592562093 int count = 0 ; //PG loop over input events while (reader.readEvent ()) { ++count ; if ( reader.outsideBlock.length ()) std::cout << reader.outsideBlock; // loop over particles in the event for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size (); ++iPart) { // outgoing particles if (reader.hepeup.ISTUP.at (iPart) == 1) { if (abs (reader.hepeup.IDUP.at (iPart)) == 13) { TLorentzVector dummy ( reader.hepeup.PUP.at (iPart).at (0), // px reader.hepeup.PUP.at (iPart).at (1), // py reader.hepeup.PUP.at (iPart).at (2), // pz reader.hepeup.PUP.at (iPart).at (3) // E ) ; float p2 = dummy.Vect ().Mag2 () ; float scale = sqrt (1 + k2 / p2) ; if (p2 < (-1 * k2)) { cout << "warning: p2 is smaller than the mass difference " << p2 << endl ; scale = 1 ; } reader.hepeup.PUP.at (iPart).at (0) *= scale ; // px reader.hepeup.PUP.at (iPart).at (1) *= scale ; // px reader.hepeup.PUP.at (iPart).at (2) *= scale ; // px if (reader.hepeup.IDUP.at (iPart) == 13) reader.hepeup.IDUP.at (iPart) = 15 ; if (reader.hepeup.IDUP.at (iPart) == -13) reader.hepeup.IDUP.at (iPart) = -15 ; } if (reader.hepeup.IDUP.at (iPart) == 14) reader.hepeup.IDUP.at (iPart) = 16 ; if (reader.hepeup.IDUP.at (iPart) == -14) reader.hepeup.IDUP.at (iPart) = -16 ; } // outgoing particles } // loop over particles in the event writer.eventComments () << reader.eventComments ; writer.hepeup = reader.hepeup ; bool written = writer.writeEvent () ; if (!written) { cout << "warning: event " << count << " not written" << endl ; } } //PG loop over input events cout << "end loop over " << count << " events" << endl ; return 0 ; }
//////////////////////////////////// // M A I N // /////////////////////////////////// int main(int argc, char **argv) { bool verbose = true; bool higgsDecay = true; // Define tree to fill TFile file(argv[2],"RECREATE"); TTree* tree = new TTree("tree","tree"); float mZ, mH, mVH, mT; //masses float costheta1, costheta2, costhetastar, phi, phi1; //angles float rapidityVH; int isLeptonic; int isUpTypeQuark; int passEta; int isWplus; int decayMode; float b0_e, b0_eta, b0_phi, b0_pt; float b1_e, b1_eta, b1_phi, b1_pt; float f0_e, f0_eta, f0_phi, f0_pt; float f1_e, f1_eta, f1_phi, f1_pt; float V_e, V_eta, V_phi, V_pt; float H_e, H_eta, H_phi, H_pt; //float VH_e, VH_eta, VH_phi, VH_pt; tree->Branch("b0_e", &b0_e, "b0_e/F"); tree->Branch("b0_eta", &b0_eta, "b0_eta/F"); tree->Branch("b0_phi", &b0_phi, "b0_phi/F"); tree->Branch("b0_pt", &b0_pt, "b0_pt/F"); tree->Branch("b1_e", &b1_e, "b1_e/F"); tree->Branch("b1_eta", &b1_eta, "b1_eta/F"); tree->Branch("b1_phi", &b1_phi, "b1_phi/F"); tree->Branch("b1_pt", &b1_pt, "b1_pt/F"); tree->Branch("f0_e", &f0_e, "f0_e/F"); tree->Branch("f0_eta", &f0_eta, "f0_eta/F"); tree->Branch("f0_phi", &f0_phi, "f0_phi/F"); tree->Branch("f0_pt", &f0_pt, "f0_pt/F"); tree->Branch("f1_e", &f1_e, "f1_e/F"); tree->Branch("f1_eta", &f1_eta, "f1_eta/F"); tree->Branch("f1_phi", &f1_phi, "f1_phi/F"); tree->Branch("f1_pt", &f1_pt, "f1_pt/F"); tree->Branch("V_e", &V_e, "V_e/F"); tree->Branch("V_eta", &V_eta, "V_eta/F"); tree->Branch("V_phi", &V_phi, "V_phi/F"); tree->Branch("V_pt", &V_pt, "V_pt/F"); tree->Branch("H_e", &H_e, "H_e/F"); tree->Branch("H_eta", &H_eta, "H_eta/F"); tree->Branch("H_phi", &H_phi, "H_phi/F"); tree->Branch("H_pt", &H_pt, "H_pt/F"); //tree->Branch("VH_e", &VH_e, "VH_e/F"); //tree->Branch("VH_eta", &VH_eta, "VH_eta/F"); //tree->Branch("VH_phi", &VH_phi, "VH_phi/F"); //tree->Branch("VH_pt", &VH_pt, "VH_pt/F"); tree->Branch("mT", &mT, "mT/F"); tree->Branch("mZ", &mZ, "mZ/F"); tree->Branch("mH", &mH, "mH/F"); tree->Branch("mVH", &mVH, "mVH/F"); tree->Branch("costheta1", &costheta1, "costheta1/F"); tree->Branch("costheta2", &costheta2, "costheta2/F"); tree->Branch("costhetastar", &costhetastar, "costhetastar/F"); tree->Branch("phi", &phi, "phi/F"); tree->Branch("phi1", &phi1, "phi1/F"); tree->Branch("rapidityVH", &rapidityVH, "rapidityVH/F"); tree->Branch("isLeptonic", &isLeptonic, "isLeptonic/I"); tree->Branch("isUpTypeQuark",&isUpTypeQuark,"isUpTypeQuark/I"); tree->Branch("passEta", &passEta, "passEta/I"); tree->Branch("isWplus", &isWplus, "isWplus/I"); tree->Branch("decayMode", &decayMode, "decayMode/I"); //Zee=0, Zmm=1, Ztt=2, Zuu=3, Zcc=4, Zdd=5, Zss=6, Zbb=7 //Wen=8, Wmn=9, Wtn=10, Wud=11, Wcs=12 //Znene=13, Znmnm=14, Zntnt=15 // Reader object cout << "Creating reader object for input LHE file " << argv[1] << endl; std::ifstream ifsLHE (argv[1]) ; LHEF::Reader lheReader (ifsLHE) ; // Loop over events int eventCount = 0; int hadronicWCount = 0; int leptonicWCount = 0; int hadronicZCount = 0; int leptonicZCount = 0; int BR_Zee=0, BR_Zmm=0, BR_Ztt=0, BR_Znn=0, BR_Zuu=0, BR_Zcc=0, BR_Zdd=0, BR_Zss=0, BR_Zbb=0; int BR_Wen=0, BR_Wmn=0, BR_Wtn=0, BR_Wud=0, BR_Wcs=0; int BR_Znene=0, BR_Znmnm=0, BR_Zntnt=0; while ( lheReader.readEvent() ) { eventCount++; if (eventCount % 100000 == 0 && verbose) std::cout << "Event " << eventCount << "\n" ; //Sanity check on number of particles if( higgsDecay==1 && lheReader.hepeup.IDUP.size() != 8 ) { cout << "Error! Expected 8 particles in the event but got " << lheReader.hepeup.IDUP.size() << endl; return 0; } else if( higgsDecay==0 && lheReader.hepeup.IDUP.size() != 6 ) { cout << "Error! Expected 6 particles in the event but got " << lheReader.hepeup.IDUP.size() << endl; return 0; } // Indices for particles of interest int i_f0 = -1; //final fermion particle int i_f1 = -1; //final fermion antiparticle int i_b0 = -1; //final b particle int i_b1 = -1; //final b antiparticle int i_H = -1; //intermediate higgs int i_V = -1; //intermediate V bool VisZ = false; bool VisW = false; decayMode = -1; std::vector<int> finalFermions ; // Loop over particles for (int iPart = 0 ; iPart < lheReader.hepeup.IDUP.size (); ++iPart){ if( lheReader.hepeup.ISTUP.at (iPart) == -1 ) // incoming { //cout << "Event " << eventCount << ", incoming: " << lheReader.hepeup.IDUP.at (iPart) << endl; //do nothing } else if( lheReader.hepeup.ISTUP.at (iPart) == 2 ) // intermediate { if( lheReader.hepeup.IDUP.at(iPart) == 25 ) //higgs { i_H = iPart; } if( lheReader.hepeup.IDUP.at(iPart) == 23) //Z { i_V = iPart; VisZ = true; } if( abs(lheReader.hepeup.IDUP.at(iPart)) == 24 ) //W+ or - { i_V = iPart; VisW = true; isWplus=1; if(lheReader.hepeup.IDUP.at(iPart)==-24) isWplus=0; } } else if( lheReader.hepeup.ISTUP.at (iPart) == 1 ) //outgoing { //cout << "Event " << eventCount << ", outgoing: " << lheReader.hepeup.IDUP.at (iPart) << endl; if(higgsDecay==1) { if ( lheReader.hepeup.IDUP.at(iPart) == 5 ) i_b0 = iPart; if ( lheReader.hepeup.IDUP.at(iPart) == -5 ) i_b1 = iPart; if( abs(lheReader.hepeup.IDUP.at(iPart) ) == 5) continue; } finalFermions.push_back (iPart) ; if( isFermion(lheReader.hepeup.IDUP.at(iPart)) ) i_f0 = iPart; if( isAntiFermion(lheReader.hepeup.IDUP.at(iPart)) ) i_f1 = iPart; }//end of outgoing if statement else { assert(0); } //sanity check that all particles are either incoming, intermediate, or outgoing. }// End loop over particles //some sanity checks assert( (VisZ && !VisW) || (VisW && !VisZ) ); assert( finalFermions.size() == 2 ); //if not the case, have to be smarter with assigning i_f0 and i_f1 assert( (i_f0 != -1) && (i_f1 != -1) && (i_H != -1) && (i_V != -1) ); //Add to branching fraction counters and check if leptonic if( VisW && isQuark(lheReader.hepeup.IDUP.at(finalFermions.at(0))) && isQuark(lheReader.hepeup.IDUP.at(finalFermions.at(1))) ) //hadronic W { hadronicWCount++; isLeptonic=0; isUpTypeQuark=0; } else if( VisW && isLepton(lheReader.hepeup.IDUP.at(finalFermions.at(0))) && isLepton(lheReader.hepeup.IDUP.at(finalFermions.at(1))) ) //leptonic W { leptonicWCount++; isLeptonic=1; isUpTypeQuark=0; } else if( VisZ && isQuark(lheReader.hepeup.IDUP.at(finalFermions.at(0))) && isQuark(lheReader.hepeup.IDUP.at(finalFermions.at(1))) ) //hadronic Z { hadronicZCount++; isLeptonic=0; isUpTypeQuark=0; if( isUpType( lheReader.hepeup.IDUP.at(finalFermions.at(0)) ) ) isUpTypeQuark=1; } else if( VisZ && isLepton(lheReader.hepeup.IDUP.at(finalFermions.at(0))) && isLepton(lheReader.hepeup.IDUP.at(finalFermions.at(1))) ) //leptonic Z { leptonicZCount++; isLeptonic=1; isUpTypeQuark=0; } else {assert(0);} //More detailed if(VisZ) { if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==11 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==11 ){ BR_Zee++; decayMode=0; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==13 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==13 ){ BR_Zmm++; decayMode=1; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==15 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==15 ){ BR_Ztt++; decayMode=2; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==12 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==12 ){ BR_Znene++; decayMode=13; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==14 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==14 ){ BR_Znmnm++; decayMode=14; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==16 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==16 ){ BR_Zntnt++; decayMode=15; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==2 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==2 ){ BR_Zuu++; decayMode=3; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==4 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==4 ){ BR_Zcc++; decayMode=4; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==1 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==1 ){ BR_Zdd++; decayMode=5; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==3 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==3 ){ BR_Zss++; decayMode=6; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==5 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==5 ){ BR_Zbb++; decayMode=7; } } else if(VisW) { if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==11 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==12 || abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==12 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==11){ BR_Wen++; decayMode=8; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==13 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==14 || abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==14 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==13){ BR_Wmn++; decayMode=9; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==15 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==16 || abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==16 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==15){ BR_Wtn++; decayMode=10; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==2 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==1 || abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==1 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==2){ BR_Wud++; decayMode=11; } if( abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==4 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==3 || abs(lheReader.hepeup.IDUP.at(finalFermions.at(0)))==3 && abs(lheReader.hepeup.IDUP.at(finalFermions.at(1)))==4){ BR_Wcs++; decayMode=12; } } else {assert(0);} //Create the TLorentzVectors TLorentzVector fs_f0 ( lheReader.hepeup.PUP.at(i_f0).at(0), //PG px lheReader.hepeup.PUP.at(i_f0).at(1), //PG py lheReader.hepeup.PUP.at(i_f0).at(2), //PG pz lheReader.hepeup.PUP.at(i_f0).at(3) //PG E ) ; TLorentzVector fs_f1 ( lheReader.hepeup.PUP.at(i_f1).at(0), //PG px lheReader.hepeup.PUP.at(i_f1).at(1), //PG py lheReader.hepeup.PUP.at(i_f1).at(2), //PG pz lheReader.hepeup.PUP.at(i_f1).at(3) //PG E ) ; TLorentzVector fs_H ( lheReader.hepeup.PUP.at(i_H).at(0), //PG px lheReader.hepeup.PUP.at(i_H).at(1), //PG py lheReader.hepeup.PUP.at(i_H).at(2), //PG pz lheReader.hepeup.PUP.at(i_H).at(3) //PG E ) ; TLorentzVector fs_b0, fs_b1; if(higgsDecay==1) { fs_b0.SetPxPyPzE( lheReader.hepeup.PUP.at(i_b0).at(0), //PG px lheReader.hepeup.PUP.at(i_b0).at(1), //PG py lheReader.hepeup.PUP.at(i_b0).at(2), //PG pz lheReader.hepeup.PUP.at(i_b0).at(3) //PG E ); fs_b1.SetPxPyPzE( lheReader.hepeup.PUP.at(i_b1).at(0), //PG px lheReader.hepeup.PUP.at(i_b1).at(1), //PG py lheReader.hepeup.PUP.at(i_b1).at(2), //PG pz lheReader.hepeup.PUP.at(i_b1).at(3) //PG E ); } else { //fake the H decay -- this creates PROBLEMS for computeAngles. Do i need to boost? fs_b0 = (0.5)*fs_H; fs_b1 = (0.5)*fs_H; //cout << "Total: " << fs_H.E() << " " << fs_H.Px() << " " << fs_H.Py() << " " << fs_H.Pz() << endl; //check that this works //cout << "b0: " << fs_b0.E() << " " << fs_b0.Px() << " " << fs_b0.Py() << " " << fs_b0.Pz() << endl; //cout << "b1: " << fs_b1.E() << " " << fs_b1.Px() << " " << fs_b1.Py() << " " << fs_b1.Pz() << endl; } //acceptance test passEta = 0; if(fabs(fs_f0.PseudoRapidity())<2.4 && fabs(fs_f1.PseudoRapidity())<2.4 && fabs(fs_b0.PseudoRapidity())<2.4 && fabs(fs_b1.PseudoRapidity())<2.4){ passEta = 1; } TLorentzVector p4_Vff = fs_f0 + fs_f1; TLorentzVector p4_Hbb = fs_b0 + fs_b1; TLorentzVector p4_VH = p4_Vff + p4_Hbb; //cuts //if(p4_Vff.Pt()<100 || p4_Hbb.Pt()<100) continue; double a_costheta1, a_costheta2, a_costhetastar, a_Phi, a_Phi1; computeAngles( p4_VH, p4_Vff, fs_f0, fs_f1, p4_Hbb, fs_b0, fs_b1, a_costheta1, a_costheta2, a_Phi, a_costhetastar, a_Phi1); mT = getMT(p4_Vff, p4_Hbb); //remap to convention of arXiv:1309.4819, including fix from Sinan&Alex costheta2 = (float) a_costheta1; costheta1 = (float) a_costhetastar; phi = (float) a_Phi1; costhetastar = (float) a_costheta2; phi1 = (float) a_Phi; mVH = (float) p4_VH.M(); rapidityVH = (float) p4_VH.Rapidity(); mZ = (float) p4_Vff.M(); mH = (float) p4_Hbb.M(); //isLeptonic, isUpTypeQuark, and decayMode already filled b0_e = fs_b0.E(); b0_phi = fs_b0.Phi(); b0_eta = fs_b0.Eta(); b0_pt = fs_b0.Pt(); b1_e = fs_b1.E(); b1_phi = fs_b1.Phi(); b1_eta = fs_b1.Eta(); b1_pt = fs_b1.Pt(); f0_e = fs_f0.E(); f0_phi = fs_f0.Phi(); f0_eta = fs_f0.Eta(); f0_pt = fs_f0.Pt(); f1_e = fs_f1.E(); f1_phi = fs_f1.Phi(); f1_eta = fs_f1.Eta(); f1_pt = fs_f1.Pt(); V_e = p4_Vff.E(); V_phi = p4_Vff.Phi(); V_eta = p4_Vff.Eta(); V_pt = p4_Vff.Pt(); H_e = p4_Hbb.E(); H_phi = p4_Hbb.Phi(); H_eta = p4_Hbb.Eta(); H_pt = p4_Hbb.Pt(); //VH_e = p4_VH.E(); //VH_phi = p4_VH.Phi(); //VH_eta = p4_VH.Eta(); //VH_pt = p4_VH.Pt(); tree->Fill(); }// End loop over events BR_Znn = BR_Znene + BR_Znmnm + BR_Zntnt; if(verbose) { cout << "Total number of events processed: " << eventCount << endl; cout << leptonicWCount << " Leptonic W fraction: " << ((double)leptonicWCount)/((double)eventCount) << endl; cout << hadronicWCount << " Hadronic W fraction: " << ((double)hadronicWCount)/((double)eventCount) << endl; cout << leptonicZCount << " Leptonic Z fraction: " << ((double)leptonicZCount)/((double)eventCount) << endl; cout << hadronicZCount << " Hadronic Z fraction: " << ((double)hadronicZCount)/((double)eventCount) << endl; //detail cout << "BR_Zee " << ((double)BR_Zee)/((double)eventCount) << endl; cout << "BR_Zmm " << ((double)BR_Zmm)/((double)eventCount) << endl; cout << "BR_Ztt " << ((double)BR_Ztt)/((double)eventCount) << endl; cout << "BR_Znene " << ((double)BR_Znene)/((double)eventCount) << endl; cout << "BR_Znmnm " << ((double)BR_Znmnm)/((double)eventCount) << endl; cout << "BR_Zntnt " << ((double)BR_Zntnt)/((double)eventCount) << endl; cout << "BR_Zinv " << ((double)BR_Znn)/((double)eventCount) << endl; cout << "BR_Zuu " << ((double)BR_Zuu)/((double)eventCount) << endl; cout << "BR_Zcc " << ((double)BR_Zcc)/((double)eventCount) << endl; cout << "BR_Zdd " << ((double)BR_Zdd)/((double)eventCount) << endl; cout << "BR_Zss " << ((double)BR_Zss)/((double)eventCount) << endl; cout << "BR_Zbb " << ((double)BR_Zbb)/((double)eventCount) << endl; cout << "BR_Wen " << ((double)BR_Wen)/((double)eventCount) << endl; cout << "BR_Wmn " << ((double)BR_Wmn)/((double)eventCount) << endl; cout << "BR_Wtn " << ((double)BR_Wtn)/((double)eventCount) << endl; cout << "BR_Wud " << ((double)BR_Wud)/((double)eventCount) << endl; cout << "BR_Wcs " << ((double)BR_Wcs)/((double)eventCount) << endl; } // Write to file file.cd(); tree->Write(); file.Close(); return 0; }
map<string, TH1F *> readSample (string sampleName, string radice, int maxevents = -1) { cout << "reading " << sampleName << endl ; std::ifstream ifs (sampleName.c_str ()) ; LHEF::Reader reader (ifs) ; map<string, TH1F *> histos ; TH1F * h_initPart = addHistoToMap (histos, string ("initPart_") + radice, 45, -22.5, 22.5) ; TH1F * h_vbf0_eta = addHistoToMap (histos, string ("vbf0_eta_") + radice, 40, -6, 6) ; TH1F * h_vbf0_pt = addHistoToMap (histos, string ("vbf0_pt_") + radice, 100, 0, 400) ; TH1F * h_vbf0_phi = addHistoToMap (histos, string ("vbf0_phi_") + radice, 30, -3.14, 3.14) ; TH1F * h_vbf1_eta = addHistoToMap (histos, string ("vbf1_eta_") + radice, 40, -6, 6) ; TH1F * h_vbf1_pt = addHistoToMap (histos, string ("vbf1_pt_") + radice, 100, 0, 250) ; TH1F * h_vbf1_phi = addHistoToMap (histos, string ("vbf1_phi_") + radice, 30, -3.14, 3.14) ; TH1F * h_mjj_vbf = addHistoToMap (histos, string ("mjj_vbf_") + radice, 25, 0, 2500) ; TH1F * h_NJ = addHistoToMap (histos, string ("NJ_") + radice, 5, 0, 5) ; TH1F * h_m4l = addHistoToMap (histos, string ("m4l_") + radice, 35, 0, 2275) ; int ieve = 0 ; int btagged = 0 ; int selected = 0 ; // loop over events while ( reader.readEvent () ) { if (ieve % 10000 == 0) std::cout << "event " << ieve << "\n" ; if (maxevents > 0 && ieve >= maxevents) break ; ++ieve; vector<int> initialParticlesPDGId ; vector<TLorentzVector> finalLeptons ; vector<TLorentzVector> finalNeutrinos ; vector<TLorentzVector> initialQuarks ; vector<TLorentzVector> finalJets ; vector<TLorentzVector> finalBs ; int leptonsIDproduct = 1 ; //PG loop over particles in the event //PG and fill the variables of leptons and quarks for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size (); ++iPart) { // std::cout << "\t part type [" << iPart << "] " << reader.hepeup.IDUP.at (iPart) // << "\t status " << reader.hepeup.ISTUP.at (iPart) // << "\n" ; //PG incoming particle if (reader.hepeup.ISTUP.at (iPart) == -1) { initialParticlesPDGId.push_back (reader.hepeup.IDUP.at (iPart)) ; initialQuarks.push_back (TLorentzVector ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E )) ; } //PG incoming particle //PG outgoing particles if (reader.hepeup.ISTUP.at (iPart) == 1) { // jets if (abs (reader.hepeup.IDUP.at (iPart)) < 7 || // quarks abs (reader.hepeup.IDUP.at (iPart)) == 21 ) // gluons { finalJets.push_back (TLorentzVector ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E )) ; if (abs (reader.hepeup.IDUP.at (iPart)) == 5) // b's { finalBs.push_back (TLorentzVector ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E )) ; } // b's } // jets else if (abs (reader.hepeup.IDUP.at (iPart)) == 11 || abs (reader.hepeup.IDUP.at (iPart)) == 13 ) // charged leptons { leptonsIDproduct *= reader.hepeup.IDUP.at (iPart) ; finalLeptons.push_back (TLorentzVector ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E )) ; } //PG charged leptons else if (abs (reader.hepeup.IDUP.at (iPart)) == 12 || abs (reader.hepeup.IDUP.at (iPart)) == 14 ) // neutrinos { finalNeutrinos.push_back (TLorentzVector ( reader.hepeup.PUP.at (iPart).at (0), //PG px reader.hepeup.PUP.at (iPart).at (1), //PG py reader.hepeup.PUP.at (iPart).at (2), //PG pz reader.hepeup.PUP.at (iPart).at (3) //PG E )) ; } // neutrinos } //PG outgoing particles } //PG loop over particles in the event // selections if (finalBs.size () != 2) continue ; ++btagged ; if (initialParticlesPDGId.size () != 2) exit (1) ; // the following remove events with guons as initial particles // if (fabs (initialParticlesPDGId.at (0)) > 6) continue ; // if (fabs (initialParticlesPDGId.at (1)) > 6) continue ; sort (finalJets.rbegin (), finalJets.rend (), ptSort ()) ; if (finalJets.at (0).Pt () < 20) continue ; if (finalJets.at (1).Pt () < 20) continue ; if (finalJets.at (0).E () < 20) continue ; if (finalJets.at (1).E () < 20) continue ; if (fabs (finalJets.at (0).Eta ()) > 6.5) continue ; if (fabs (finalJets.at (1).Eta ()) > 6.5) continue ; sort (finalLeptons.rbegin (), finalLeptons.rend (), ptSort ()) ; if (finalLeptons.at (0).Pt () < 20) continue ; if (finalLeptons.at (1).Pt () < 20) continue ; if (finalLeptons.at (0).E () < 20) continue ; if (finalLeptons.at (1).E () < 20) continue ; if (fabs (finalLeptons.at (0).Eta ()) > 4) continue ; if (fabs (finalLeptons.at (1).Eta ()) > 4) continue ; // this selection has to be performed on Bs to match the two cases of phantom and powheg, // since phantom is not yet matched to a PS // float mjj = (finalJets.at (0) + finalJets.at (1)).M () ; float mjj = (finalBs.at (0) + finalBs.at (1)).M () ; if (mjj < 300) continue ; if (fabs (finalJets.at (0).Eta () - finalJets.at (1).Eta ()) < 2) continue ; float m4l = (finalNeutrinos.at (0) + finalNeutrinos.at (1) + finalLeptons.at (0) + finalLeptons.at (1)).M () ; if (m4l < 130) continue ; ++selected ; h_NJ->Fill (finalJets.size ()) ; // cout << "Njs = " << finalJets.size () << "\n" ; // cout << "pts: " // << finalJets.at (0).Pt () // << "\t" // << finalJets.at (1).Pt () // << "\n" ; for (int i = 0 ; i < initialParticlesPDGId.size () ; ++i) h_initPart->Fill (initialParticlesPDGId.at (i)) ; h_vbf0_eta->Fill (finalJets.at (0).Eta ()) ; h_vbf0_phi->Fill (finalJets.at (0).Phi ()) ; h_vbf0_pt-> Fill (finalJets.at (0).Pt ()) ; h_vbf1_eta->Fill (finalJets.at (1).Eta ()) ; h_vbf1_phi->Fill (finalJets.at (1).Phi ()) ; h_vbf1_pt-> Fill (finalJets.at (1).Pt ()) ; h_mjj_vbf->Fill (mjj) ; h_m4l->Fill (m4l) ; } // loop over events cout << "btagged eff: " << btagged * 1./ieve << endl ; cout << "total eff : " << selected * 1./ieve << endl ; return histos ; }