int main(int argc, char** argv) { google::InitGoogleLogging(argv[0]); ceres::Jet<double, 3> jet1(0); ceres::Jet<double, 3> jet2(0); jet2 = sqrt(jet1); std::cout << "jet2.a: " << jet2.a << std::endl; return 0; }
void mjj_match::Loop(int DEBUG) { if (fChain == 0) return; // book histograms TH1D* h_mh_template = new TH1D("h_mh_template","",280,100,1500); h_mh_template->Sumw2(); h_mh_template->SetXTitle("M_{lljj} [GeV/c^{2}]"); h_mh_template->SetYTitle(Form("Candidates per %d GeV/c^{2}", (int)h_mh_template->GetBinWidth(1))); TH1D* h_mll_template = new TH1D("h_mll_template","",35,60,130); h_mll_template->Sumw2(); h_mll_template->SetXTitle("M_{ll} [GeV/c^{2}]"); h_mll_template->SetYTitle(Form("Candidates per %d GeV/c^{2}", (int)h_mll_template->GetBinWidth(1))); TH1D* h_mjj_template = new TH1D("h_mjj_template","",14,60,130); h_mjj_template->Sumw2(); h_mjj_template->SetXTitle("M_{jj} [GeV/c^{2}]"); h_mjj_template->SetYTitle(Form("Candidates per %d GeV/c^{2}", (int)h_mjj_template->GetBinWidth(1))); TH1D* h_jec_template = new TH1D("h_jec_template","",20,0.5,1.5); h_jec_template->Sumw2(); h_jec_template->SetXTitle("p_{T}^{REC}(jet)/p_{T}^{GEN}(jet)"); h_jec_template->SetYTitle(Form("Candidates per %.1f", h_jec_template->GetBinWidth(1))); TH1D* h_dR_template = new TH1D("h_dR_template","",50,0,5.0); h_dR_template->Sumw2(); h_dR_template->SetXTitle("#Delta R"); h_dR_template->SetYTitle(Form("Candidates per %.1f", h_dR_template->GetBinWidth(1))); // status=3 level TH1D* h_mh_parton = (TH1D*)h_mh_template->Clone("h_mh_parton"); h_mh_parton->SetTitle("status=3"); TH1D* h_mll_parton = (TH1D*)h_mll_template->Clone("h_mll_parton"); h_mll_parton->SetTitle("status=3"); TH1D* h_mjj_parton = (TH1D*)h_mjj_template->Clone("h_mjj_parton"); h_mjj_parton->SetTitle("status=3"); // status=1 level TH1D* h_mh_stable = (TH1D*)h_mh_template->Clone("h_mh_stable"); h_mh_stable->SetTitle("status=1"); TH1D* h_mll_stable = (TH1D*)h_mll_template->Clone("h_mll_stable"); h_mll_stable->SetTitle("status=1"); TH1D* h_mjj_stable = (TH1D*)h_mjj_template->Clone("h_mjj_stable"); h_mjj_stable->SetTitle("status=1"); // reconstruction level TH1D* h_mh_rec = (TH1D*)h_mh_template->Clone("h_mh_rec"); h_mh_rec->SetTitle("reconstructed, all"); TH1D* h_mll_rec = (TH1D*)h_mll_template->Clone("h_mll_rec"); h_mll_rec->SetTitle("reconstructed, all"); TH1D* h_mjj_rec = (TH1D*)h_mjj_template->Clone("h_mjj_rec"); h_mjj_rec->SetTitle("reconstructed, all"); TH1D* h_jec[2]; std::string jetName[2]={"leading","subleading"}; for(int i=0; i<2; i++) { h_jec[i] = (TH1D*)h_jec_template->Clone(Form("h_jec_%s",jetName[i].data())); } // separated in dR // const double dRArray[]={0.5,1.0,1.5,2.0,2.5,3.0,3.5}; const double dRArray[]={0.0,1.0,2.0,3.5}; const int NBINS = sizeof(dRArray)/sizeof(dRArray[0])-1; TH1D* h_dR = new TH1D("h_dR","",NBINS,dRArray); TH1D* h_dR_ll = (TH1D*)h_dR_template->Clone("h_dR_ll"); h_dR_ll->SetXTitle("#DeltaR_{ll}"); TH1D* h_dR_jj = (TH1D*)h_dR_template->Clone("h_dR_jj"); h_dR_jj->SetXTitle("#DeltaR_{jj}"); TH1D* h_mll_recdR[NBINS]; TH1D* h_mjj_recdR[NBINS]; TH1D* h_jec_dR[NBINS][2]; for(int i=0; i<NBINS; i++){ h_mll_recdR[i] = (TH1D*)h_mll_template->Clone( Form("h_mll_recdR%d",i)); h_mll_recdR[i]->SetTitle(Form("reconstructed, %.1f < #DeltaR_{ll} < %.1f", dRArray[i],dRArray[i+1])); h_mjj_recdR[i] = (TH1D*)h_mjj_template->Clone( Form("h_mjj_recdR%d",i)); h_mjj_recdR[i]->SetTitle(Form("reconstructed, %.1f < #DeltaR_{jj} < %.1f", dRArray[i],dRArray[i+1])); for(int j=0; j<2; j++){ h_jec_dR[i][j] = (TH1D*)h_jec_template->Clone( Form("h_jec_dR%d_%s", i,jetName[j].data())); h_jec_dR[i][j]->SetTitle(Form("reconstructed, %.1f < #DeltaR_{jj} < %.1f", dRArray[i],dRArray[i+1])); } } Long64_t nentries = fChain->GetEntriesFast(); standalone_LumiReWeighting LumiWeights_central(2012,0); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; double PU_weight = LumiWeights_central.weight(PU_nTrueInt); //================================================================ // STATUS=3 LEVEL //================================================================ TLorentzVector lep1(0,0,0,0); TLorentzVector lep2(0,0,0,0); int lep1Index=-1; int lep2Index=-1; TLorentzVector lep1_post(0,0,0,0); TLorentzVector lep2_post(0,0,0,0); int lep1PostIndex=-1; int lep2PostIndex=-1; TLorentzVector q1(0,0,0,0); TLorentzVector q2(0,0,0,0); int q1Index=-1; int q2Index=-1; const int ZPID=23; int LEPTYPE = -1; for(unsigned int igen=0; igen < genParId_->size(); igen++) { int status = genParSt_->at(igen); int PID = genParId_->at(igen); int momPID = genMomParId_->at(igen); // first status=3 lepton from Z if(status==3 && lep1.E() < 1e-6 && (abs(PID) == 11 || abs(PID) == 13) && momPID == ZPID ) { lep1.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); LEPTYPE = abs(PID); lep1Index = igen; } // second status=3 lepton from Z else if (status==3 && lep2.E() < 1e-6 && (abs(PID) == 11 || abs(PID) == 13) && momPID== ZPID ) { lep2.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); lep2Index = igen; } // first status =1 lepton from Z else if(status==1 && lep1_post.E() < 1e-6 && (abs(PID) == 11 || abs(PID) == 13) && abs(momPID) == LEPTYPE ) { lep1_post.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); lep1PostIndex = igen; } // second status=1 lepton from Z else if (status==1 && lep2_post.E() < 1e-6 && (abs(PID) == 11 || abs(PID) == 13) && abs(momPID) == LEPTYPE ) { lep2_post.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); lep2PostIndex = igen; } // first parton from Z else if(status==3 && q1.E() < 1e-6 && abs(PID) < 6 && momPID == ZPID) { q1.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); q1Index = igen; } // second parton from Z else if(status==3 && q2.E() < 1e-6 && abs(PID) < 6 && momPID == ZPID) { q2.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); q2Index = igen; } } // end of loop over gen particles /* if(DEBUG==1){ cout << "LEPTYPE = " << LEPTYPE << endl; cout << "lep1 = " << lep1Index << "\t lep2 = " << lep2Index << endl; cout << "lep1Post =" << lep1PostIndex << "\t lep2Post = " << lep2PostIndex << endl; cout << "q1 =" << q1Index << "\t q2Index = " << q2Index << endl; // cout << "jet1 = " << jet1Index << "\t jet2Index = " << jet2Index << endl; } */ if(LEPTYPE==-1)continue; if(lep1Index<0 || lep2Index<0)continue; if(lep1PostIndex<0 || lep2PostIndex<0)continue; if(q1Index<0 || q2Index<0)continue; double mH_parton = (lep1+lep2+q1+q2).M(); double mZll_parton = (lep1+lep2).M(); double mZjj_parton = (q1+q2).M(); h_mh_parton->Fill(mH_parton); h_mll_parton->Fill(mZll_parton); h_mjj_parton->Fill(mZjj_parton); // now look for gen jets //================================================================ // STATUS =1 LEVEL //================================================================ TLorentzVector jet1(0,0,0,0); TLorentzVector jet2(0,0,0,0); int jet1Index=-1, jet2Index=-1; for(unsigned int ijet =0; ijet < genJetPt_->size(); ijet++) { if(matchGenToParton(q1Index,ijet) && jet1.E()<1e-6) { jet1.SetPtEtaPhiE( genJetPt_->at(ijet), genJetEta_->at(ijet), genJetPhi_->at(ijet), genJetE_->at(ijet)); jet1Index = ijet; } else if(matchGenToParton(q2Index,ijet) && jet2.E()<1e-6) { jet2.SetPtEtaPhiE( genJetPt_->at(ijet), genJetEta_->at(ijet), genJetPhi_->at(ijet), genJetE_->at(ijet)); jet2Index = ijet; } } if(jet1Index>=0 && jet2Index>=0){ double mH_particle = (jet1+jet2+lep1_post+lep2_post).M(); double mZll_particle = (lep1_post + lep2_post).M(); double mZjj_particle = (jet1+jet2).M(); h_mh_stable->Fill(mH_particle); h_mll_stable->Fill(mZll_particle); h_mjj_stable->Fill(mZjj_particle); } //================================================================ // RECONSTRUCTION LEVEL //================================================================ int nHiggs=0; int best= -1; // check for MC Truth for(int ih=0; ih<higgsM->size(); ih++){ int nMatched=0; for(int ijet=0; ijet<jetPartonPt->size(); ijet++){ if(jetHiggsIndex->at(ijet)!=ih)continue; int jet_index = jetIndex->at(ijet); // if(DEBUG) // cout << "jet index = " << jet_index << endl; if(jet_index<0)continue; if(jet_index>1)continue; if(jetPartonPt->at(ijet)<1e-6)continue; nMatched++; } // end of loop over jets if(nMatched==2){ nHiggs++; best = ih; } } // end of loop over higgs candidate if(DEBUG && nHiggs>1)cout << "nHiggs=" << nHiggs << endl; if(nHiggs!=1)continue; if(best<0)continue; double mh_rec = higgsM->at(best); double mll_rec = zllM->at(best); double mjj_rec = zjjM->at(best); h_mh_rec->Fill(mh_rec, PU_weight); h_mll_rec->Fill(mll_rec, PU_weight); h_mjj_rec->Fill(mjj_rec, PU_weight); double dr_ll = zlldR->at(best); h_dR_ll->Fill(dr_ll, PU_weight); int dRLL_index = h_dR->FindBin(dr_ll)-1; if(dRLL_index>=0 && dRLL_index < NBINS) h_mll_recdR[dRLL_index]->Fill(mll_rec, PU_weight); double dr_jj = zjjdR->at(best); h_dR_jj->Fill(dr_jj, PU_weight); int dRJJ_index = h_dR->FindBin(dr_jj)-1; if(dRJJ_index>=0 && dRJJ_index < NBINS) h_mjj_recdR[dRJJ_index]->Fill(mjj_rec, PU_weight); for(int ijet=0; ijet < jetIndex->size(); ijet++){ int jet_index = jetIndex->at(ijet); if(jet_index < 0 ) continue; if(jet_index > 1 ) continue; if(jetHiggsIndex->at(ijet)!=best)continue; if(jetGenPt->at(ijet)<1e-6) continue; double ratio = jetPt->at(ijet)/jetGenPt->at(ijet); h_jec[jet_index]->Fill(ratio, PU_weight); if(dRJJ_index>=0 && dRJJ_index <NBINS) { h_jec_dR[dRJJ_index][jet_index]->Fill(ratio, PU_weight); } } // end of loop over jets } TFile* outFile = new TFile(Form("partonmatched_mjj_%s",_inputFileName.data()), "recreate"); h_mh_parton->Write(); h_mll_parton->Write(); h_mjj_parton->Write(); h_mh_stable->Write(); h_mll_stable->Write(); h_mjj_stable->Write(); h_mh_rec->Write(); h_mll_rec->Write(); h_mjj_rec->Write(); h_dR_ll->Write(); h_dR_jj->Write(); for(int j=0; j<2; j++) { h_jec[j]->Write(); for(int i=0; i<NBINS; i++){ h_mll_recdR[i]->Write(); h_mjj_recdR[i]->Write(); h_jec_dR[i][j]->Write(); } } outFile->Close(); }
void looper::myLoop(int nsel, int mode, bool silent) { char plotName[300]; sprintf(plotName,"test"); if (nsel == 0) {sprintf(plotName,"tt");} else if (nsel == 1) {sprintf(plotName,"twdr");} else if (nsel == -1) {sprintf(plotName,"twds");} else if (nsel == 2) {sprintf(plotName,"zjets");} else if (nsel == 3) {sprintf(plotName,"di");} else if (nsel == 4) {sprintf(plotName, "st");} else if (nsel == 5) {sprintf(plotName,"wjets");} else if (nsel == 6) {sprintf(plotName,"qcd_mu");} else if (nsel == 7) {sprintf(plotName,"others");} else if (nsel == 555) {sprintf(plotName,"mc");} else if (nsel == 666) {sprintf(plotName,"data");} bool nosf = false; char newRootFile[300]; double lumi = luminosity; if (mode == 0 ) lumi = 11966.617; else if ( mode == 1) lumi = 12067.294; else if ( mode == 2) lumi = 12093.792; sprintf(newRootFile,"results/an_%dpb_%d.root", (int)lumi, mode); TFile f_var(newRootFile, "UPDATE"); if(!silent){ std::cout << "[Info:] results root file " << newRootFile << std::endl; } ////////// char title[300]; sprintf(title,"cuts_%s",plotName); TH1F* histo = new TH1F( title, " ", 10, 0, 10 ); histo->Sumw2(); sprintf(title,"met_high_%s",plotName); TH1F* histo_met_high = new TH1F( title, " ", 100, 0, 200 ); histo_met_high->Sumw2(); sprintf(title,"met_low_%s",plotName); TH1F* histo_met_low = new TH1F( title, " ", 100, 0, 200 ); histo_met_low->Sumw2(); sprintf(title,"promet_%s",plotName); TH1F* histo_promet = new TH1F( title, " ", 100, 0, 200 ); histo_promet->Sumw2(); sprintf(title,"met_cut_%s",plotName); TH1F* histo_met_cut = new TH1F( title, " ", 100, 0, 200 ); histo_met_cut->Sumw2(); sprintf(title,"met_bt_%s",plotName); TH1F* histo_met_bt = new TH1F( title, " ", 100, 0, 200 ); histo_met_bt->Sumw2(); sprintf(title,"mll_after_%s",plotName); TH1F* histo_mll_after = new TH1F( title, " ", 100, 0, 200 ); histo_mll_after->Sumw2(); sprintf(title,"njets_cut_%s",plotName); TH1F* histo_njets_cut = new TH1F( title, " ", 10, -0.5, 9.5 ); histo_njets_cut->Sumw2(); sprintf(title,"njetsbt_cut_%s",plotName); TH1F* histo_njetsbt_cut = new TH1F( title, " ", 10, -0.5, 9.5 ); histo_njetsbt_cut->Sumw2(); sprintf(title,"njetsbt_high_%s",plotName); TH1F* histo_njetsbt_high = new TH1F( title, " ", 10, -0.5, 9.5 ); histo_njetsbt_high->Sumw2(); sprintf(title,"njetsbt_low_%s",plotName); TH1F* histo_njetsbt_low = new TH1F( title, " ", 10, -0.5, 9.5 ); histo_njetsbt_low->Sumw2(); sprintf(title,"njets_high_%s",plotName); TH1F* histo_njets_high = new TH1F( title, " ", 10, -0.5, 9.5 ); histo_njets_high->Sumw2(); sprintf(title,"njets_low_%s",plotName); TH1F* histo_njets_low = new TH1F( title, " ", 10, -0.5, 9.5 ); histo_njets_low->Sumw2(); sprintf(title,"ptsys_high_%s",plotName); TH1F* histo_ptsys_high = new TH1F( title, " ", 100, 0, 200 ); histo_ptsys_high->Sumw2(); sprintf(title,"ptsys_low_%s",plotName); TH1F* histo_ptsys_low = new TH1F( title, " ", 100, 0, 200 ); histo_ptsys_low->Sumw2(); sprintf(title,"ht_high_%s",plotName); TH1F* histo_ht_high = new TH1F( title, " ", 300, 0, 600 ); histo_ht_high->Sumw2(); sprintf(title,"ht_low_%s",plotName); TH1F* histo_ht_low = new TH1F( title, " ", 300, 0, 600 ); histo_ht_low->Sumw2(); sprintf(title,"ht_cut_%s",plotName); TH1F* histo_ht_cut = new TH1F( title, " ", 300, 0, 600 ); histo_ht_cut->Sumw2(); sprintf(title,"pt_max_%s",plotName); TH1F* histo_pt_max = new TH1F( title, " ", 100, 0, 200 ); histo_pt_max->Sumw2(); sprintf(title,"pt_min_%s",plotName); TH1F* histo_pt_min = new TH1F( title, " ", 100, 0, 200 ); histo_pt_min->Sumw2(); sprintf(title,"btagHE_%s",plotName); TH2F* histo_btagHE = new TH2F( title, " ", 300, -200, 100, 100, -2, 7); histo_btagHE->Sumw2(); sprintf(title,"btagHP_%s",plotName); TH2F* histo_btagHP = new TH2F( title, " ", 300, -200, 100, 100, -2, 7); histo_btagHP->Sumw2(); sprintf(title,"etalepton_%s",plotName); TH1F* histo_etalepton = new TH1F( title, " ", 101, -3, 3); histo_etalepton->Sumw2(); sprintf(title,"ht_bf_%s",plotName); TH1F* histo_ht_bf = new TH1F( title, " ", 300, 0, 600 ); histo_ht_bf->Sumw2(); sprintf(title,"ptsys_bf_%s",plotName); TH1F* histo_ptsys_bf = new TH1F( title, " ", 100, 0, 200 ); histo_ptsys_bf->Sumw2(); sprintf(title,"npu_%s",plotName); TH1F* histo_npu = new TH1F( title, " ", 30, -0.5, 29.5 ); histo_npu->Sumw2(); /// Classic plotmaker plots sprintf(title,"met_%s",plotName); TH1F* histo_met = new TH1F( title, " ", 100, 0, 200 ); histo_met->Sumw2(); sprintf(title,"mll_%s",plotName); TH1F* histo_mll = new TH1F( title, " ", 100, 0, 200 ); histo_mll->Sumw2(); sprintf(title,"njets_%s",plotName); TH1F* histo_njets = new TH1F( title, " ", 10, 0, 10 ); histo_njets->Sumw2(); sprintf(title,"njetsbt_%s",plotName); TH1F* histo_njetsbt = new TH1F( title, " ", 10, -0.5, 9.5 ); histo_njetsbt->Sumw2(); sprintf(title,"ptsys_%s",plotName); TH1F* histo_ptsys = new TH1F( title, " ", 200, 0, 200 ); histo_ptsys->Sumw2(); sprintf(title,"ht_%s",plotName); TH1F* histo_ht = new TH1F( title, " ", 300, 0, 600 ); histo_ht->Sumw2(); sprintf(title,"pt_leading_%s",plotName); TH1F* histo_pt_leading = new TH1F( title, " ", 100, 0, 200 ); histo_pt_leading->Sumw2(); sprintf(title,"nvertex_%s",plotName); TH1F* histo_nvertex = new TH1F( title, " ", 70, -0.5, 69.5 ); histo_nvertex->Sumw2(); sprintf(title,"nloosejets_%s",plotName); TH1F* histo_nloosejets = new TH1F( title, " ", 10, -0.5, 9.5 ); histo_nloosejets->Sumw2(); sprintf(title,"nloosejets_bt_%s",plotName); TH1F* histo_nloosejets_bt = new TH1F( title, " ", 10, -0.5, 9.5 ); histo_nloosejets_bt->Sumw2(); // 1 jet level /// Classic plotmaker plots sprintf(title,"met_1j_%s",plotName); TH1F* histo_met_1j = new TH1F( title, " ", 100, 0, 200 ); histo_met_1j->Sumw2(); sprintf(title,"mll_1j_%s",plotName); TH1F* histo_mll_1j = new TH1F( title, " ", 100, 0, 200 ); histo_mll_1j->Sumw2(); sprintf(title,"ptsys_1j_%s",plotName); TH1F* histo_ptsys_1j = new TH1F( title, " ", 100, 0, 200 ); histo_ptsys_1j->Sumw2(); sprintf(title,"ht_1j_%s",plotName); TH1F* histo_ht_1j = new TH1F( title, " ", 300, 0, 600 ); histo_ht_1j->Sumw2(); sprintf(title,"pt_leading_1j_%s",plotName); TH1F* histo_pt_leading_1j = new TH1F( title, " ", 100, 0, 200 ); histo_pt_leading_1j->Sumw2(); sprintf(title,"nvertex_1j_%s",plotName); TH1F* histo_nvertex_1j = new TH1F( title, " ", 30, -0.5, 29.5 ); histo_nvertex_1j->Sumw2(); // 1 jet level /// Classic plotmaker plots sprintf(title,"met_1j1t_%s",plotName); TH1F* histo_met_1j1t = new TH1F( title, " ", 100, 0, 200 ); histo_met_1j1t->Sumw2(); sprintf(title,"mll_1j1t_%s",plotName); TH1F* histo_mll_1j1t = new TH1F( title, " ", 100, 0, 200 ); histo_mll_1j1t->Sumw2(); sprintf(title,"ptsys_1j1t_%s",plotName); TH1F* histo_ptsys_1j1t = new TH1F( title, " ", 100, 0, 200 ); histo_ptsys_1j1t->Sumw2(); sprintf(title,"ht_1j1t_%s",plotName); TH1F* histo_ht_1j1t = new TH1F( title, " ", 200, 0, 200 ); histo_ht_1j1t->Sumw2(); sprintf(title,"pt_leading_1j1t_%s",plotName); TH1F* histo_pt_leading_1j1t = new TH1F( title, " ", 100, 0, 200 ); histo_pt_leading_1j1t->Sumw2(); sprintf(title,"nvertex_1j1t_%s",plotName); TH1F* histo_nvertex_1j1t = new TH1F( title, " ", 30, -0.5, 29.5 ); histo_nvertex_1j1t->Sumw2(); // 2j1t /// Classic plotmaker plots sprintf(title,"met_2j1t_%s",plotName); TH1F* histo_met_2j1t = new TH1F( title, " ", 100, 0, 200 ); histo_met_2j1t->Sumw2(); sprintf(title,"mll_2j1t_%s",plotName); TH1F* histo_mll_2j1t = new TH1F( title, " ", 100, 0, 200 ); histo_mll_2j1t->Sumw2(); sprintf(title,"ptsys_2j1t_%s",plotName); TH1F* histo_ptsys_2j1t = new TH1F( title, " ", 200, 0, 200 ); histo_ptsys_2j1t->Sumw2(); sprintf(title,"ht_2j1t_%s",plotName); TH1F* histo_ht_2j1t = new TH1F( title, " ", 300, 0, 600 ); histo_ht_2j1t->Sumw2(); sprintf(title,"pt_leading_2j1t_%s",plotName); TH1F* histo_pt_leading_2j1t = new TH1F( title, " ", 100, 0, 200 ); histo_pt_leading_2j1t->Sumw2(); sprintf(title,"nvertex_2j1t_%s",plotName); TH1F* histo_nvertex_2j1t = new TH1F( title, " ", 30, -0.5, 29.5 ); histo_nvertex_2j1t->Sumw2(); // 2j2t /// Classic plotmaker plots sprintf(title,"met_2j2t_%s",plotName); TH1F* histo_met_2j2t = new TH1F( title, " ", 100, 0, 200 ); histo_met_2j2t->Sumw2(); sprintf(title,"mll_2j2t_%s",plotName); TH1F* histo_mll_2j2t = new TH1F( title, " ", 100, 0, 200 ); histo_mll_2j2t->Sumw2(); sprintf(title,"ptsys_2j2t_%s",plotName); TH1F* histo_ptsys_2j2t = new TH1F( title, " ", 300, 0, 600 ); histo_ptsys_2j2t->Sumw2(); sprintf(title,"ht_2j2t_%s",plotName); TH1F* histo_ht_2j2t = new TH1F( title, " ", 300, 0, 600 ); histo_ht_2j2t->Sumw2(); sprintf(title,"pt_leading_2j2t_%s",plotName); TH1F* histo_pt_leading_2j2t = new TH1F( title, " ", 100, 0, 200 ); histo_pt_leading_2j2t->Sumw2(); sprintf(title,"nvertex_2j2t_%s",plotName); TH1F* histo_nvertex_2j2t = new TH1F( title, " ", 30, -0.5, 29.5 ); histo_nvertex_2j2t->Sumw2(); // all regions sprintf(title,"R_%s",plotName); TH1F* histo_R = new TH1F( title, " ", 40, 0, 40 ); histo_R->Sumw2(); sprintf(title,"nvertex_2lep_%s",plotName); TH1F* histo_nvertex_2lep = new TH1F( title, " ", 70, -0.5, 69.5 ); histo_nvertex_2lep->Sumw2(); // Test jets sprintf(title,"ht_2j1t_leading_%s",plotName); TH1F* histo_ht_2j1t_leading = new TH1F( title, " ", 300, 0, 600 ); histo_ht_2j1t_leading->Sumw2(); sprintf(title,"ht_2j1t_all_%s",plotName); TH1F* histo_ht_2j1t_all = new TH1F( title, " ", 300, 0, 600 ); histo_ht_2j1t_all->Sumw2(); sprintf(title,"ht_2j2t_leading_%s",plotName); TH1F* histo_ht_2j2t_leading = new TH1F( title, " ", 300, 0, 600 ); histo_ht_2j1t_leading->Sumw2(); sprintf(title,"ht_2j2t_all_%s",plotName); TH1F* histo_ht_2j2t_all = new TH1F( title, " ", 300, 0, 600 ); histo_ht_2j2t_all->Sumw2(); sprintf(title,"ptsys_2j1t_leading_%s",plotName); TH1F* histo_ptsys_2j1t_leading = new TH1F( title, " ", 200, 0, 200 ); histo_ptsys_2j1t_leading->Sumw2(); sprintf(title,"ptsys_2j1t_all_%s",plotName); TH1F* histo_ptsys_2j1t_all = new TH1F( title, " ", 200, 0, 200 ); histo_ptsys_2j1t_all->Sumw2(); sprintf(title,"ptsys_2j2t_leading_%s",plotName); TH1F* histo_ptsys_2j2t_leading = new TH1F( title, " ", 200, 0, 200 ); histo_ptsys_2j1t_leading->Sumw2(); sprintf(title,"ptsys_2j2t_all_%s",plotName); TH1F* histo_ptsys_2j2t_all = new TH1F( title, " ", 200, 0, 200 ); histo_ptsys_2j2t_all->Sumw2(); if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; if (lumi != lum && nsel != 666 && mode !=3){ if (jentry == 0)std::cout << "[Warning:] This tree was made with a different luminosity (" << lum << ") than " << lumi << std::endl; //xlWeight*=(lumi/lum); } if(ptLepton->size() != 2){ std::cout << "[Warning:] Something is wrong, your Tree is not correctly filled" << std::endl; break; } else { histo->Fill(0.,xlWeight); histo_nvertex_2lep->Fill(nvertex,xlWeight); TLorentzVector lepton0(pxLepton->at(0),pyLepton->at(0), pzLepton->at(0), eLepton->at(0)); TLorentzVector lepton1(pxLepton->at(1),pyLepton->at(1), pzLepton->at(1), eLepton->at(1)); TLorentzVector pair = lepton0+lepton1; //if (ptLepton->at(0) < 40 && ptLepton->at(1) < 40) continue; if(ptLepton->at(0) < 30 || ptLepton->at(1) < 30)continue; double phipairmet_t = 0; double pi_m = 3.1416/2; phipairmet_t = pi_m; TVector3 vmet(metPx, metPy, 0); double promet = metPt*sin(phipairmet_t); TVector3 m0(pxLepton->at(0),pyLepton->at(0), pzLepton->at(0)); TVector3 m1(pxLepton->at(1),pyLepton->at(1), pzLepton->at(1)); if (fabs(m0.DeltaPhi(vmet)) < phipairmet_t) phipairmet_t = fabs(m0.DeltaPhi(vmet)); if (fabs(m1.DeltaPhi(vmet)) < phipairmet_t) phipairmet_t = fabs(m1.DeltaPhi(vmet)); if (phipairmet_t == pi_m) promet = metPt; if (pair.M() > 20){ histo->Fill(1, xlWeight); double SFval, SFerror; if ( nsel == 666 || nosf){ SFval = 1; SFerror = 0; } else if (nsel == 0){ SFval = 0.95; SFerror = 0.03; } else { SFval = 0.97; SFerror = 0.03; } int nJetsBT = 0; int nTightJetsBT = 0; int nJets = 0; bool bTagged = false; int iJet = -5; int iSF; double tempSF = SFval; int iLead = -5; int SFvalue = int(tempSF*100); int nloose = 0; int nloosebt = 0; for (unsigned int i =0; i < ptJet->size(); i ++){ TLorentzVector tempJet(pxJet->at(i),pyJet->at(i), pzJet->at(i), eJet->at(i)); if (ptJet->at(i) > 30 && fabs(tempJet.Eta()) < 2.5 && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3) { nJets++; iJet = i; if (iLead == -5) iLead = iJet; if (btCSVBJet->at(i) > 0.679){ iSF = rand() % 100; if (iSF < SFvalue ){ bTagged = true; nJetsBT++; nTightJetsBT++; } } } else if (btCSVBJet->at(i) > 0.679 && fabs(tempJet.Eta()) < 2.5){ iSF = rand() % 100; if (iSF < SFvalue ){ nJetsBT++; nloosebt++;} } if (ptJet->at(i) <= 30 || fabs(tempJet.Eta()) >= 2.5) nloose++; } histo_nloosejets->Fill(nloose, xlWeight); histo_nloosejets_bt->Fill(nloosebt, xlWeight); histo_pt_max->Fill(TMath::Max(lepton0.Pt(), lepton1.Pt()), xlWeight); histo_pt_min->Fill(TMath::Min(lepton0.Pt(), lepton1.Pt()), xlWeight); histo_njets->Fill(nJets, xlWeight); histo_njetsbt->Fill(nJetsBT, xlWeight); histo_mll->Fill(pair.M(), xlWeight); histo_met->Fill(metPt, xlWeight); histo_promet->Fill(promet, xlWeight); if (nvertex > 5){ histo_met_high->Fill(metPt, xlWeight); histo_njets_high->Fill(nJets, xlWeight); histo_njetsbt_high->Fill(nJetsBT, xlWeight); } else { histo_met_low->Fill(metPt, xlWeight); histo_njets_low->Fill(nJets, xlWeight); histo_njetsbt_low->Fill(nJetsBT, xlWeight); } if (nJets) histo_pt_leading->Fill(ptJet->at(0), xlWeight); if (nJets == 1){ histo_etalepton->Fill(lepton0.Eta(), xlWeight); TLorentzVector jet(pxJet->at(iJet),pyJet->at(iJet), pzJet->at(iJet), eJet->at(iJet)); double ptSysPx1 = lepton0.Px() + lepton1.Px() + jet.Px() + metPx; double ptSysPy1 = lepton0.Py() + lepton1.Py() + jet.Py() + metPy; double ptSystem1 = sqrt(ptSysPx1*ptSysPx1 + ptSysPy1*ptSysPy1); double ht1 = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; histo_ptsys_bf->Fill(ptSystem1, xlWeight); histo_ht_bf->Fill(ht1, xlWeight); } bool invMass = false; if (mode == 0) invMass = true; else if (mode == 1 && (pair.M() > invMax || pair.M() < invMin)) invMass = true; else if (mode == 2 && (pair.M() > invMax || pair.M() < invMin)) invMass = true; if (invMass){ histo->Fill(2, xlWeight); histo_mll_after->Fill(pair.M(), xlWeight); histo_met_cut->Fill(metPt, xlWeight); if (metPt >= metCut || mode ==0){ histo->Fill(3, xlWeight); histo_njets_cut->Fill(nJets, xlWeight); if (nJets == 1){ histo->Fill(4, xlWeight); histo_njetsbt_cut->Fill(nJetsBT, xlWeight); TLorentzVector jet(pxJet->at(iJet),pyJet->at(iJet), pzJet->at(iJet), eJet->at(iJet)); double ptSysPx = lepton0.Px() + lepton1.Px() + jet.Px() + metPx; double ptSysPy = lepton0.Py() + lepton1.Py() + jet.Py() + metPy; double ptSystem = sqrt(ptSysPx*ptSysPx + ptSysPy*ptSysPy); double ht = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; histo_mll_1j->Fill(pair.M(), xlWeight); histo_met_1j->Fill(metPt, xlWeight); histo_ptsys_1j->Fill(ptSystem, xlWeight); histo_ht_1j->Fill(ht, xlWeight); histo_pt_leading_1j->Fill(jet.Pt(), xlWeight); if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1){ histo->Fill(5, xlWeight); histo_mll_1j1t->Fill(pair.M(), xlWeight); histo_met_1j1t->Fill(metPt, xlWeight); histo_ptsys_1j1t->Fill(ptSystem, xlWeight); histo_ht_1j1t->Fill(ht, xlWeight); histo_pt_leading_1j1t->Fill(jet.Pt(), xlWeight); histo_ptsys->Fill(ptSystem, xlWeight); histo_ht->Fill(ht, xlWeight); histo_met_bt->Fill(metPt, xlWeight); histo_nvertex->Fill(nvertex, xlWeight); histo_npu->Fill(npu, xlWeight); if (nvertex > 5) { histo_ptsys_high->Fill(ptSystem, xlWeight); histo_ht_high->Fill(ht, xlWeight); } else { histo_ptsys_low->Fill(ptSystem, xlWeight); histo_ht_low->Fill(ht, xlWeight); } if (ht > htMin || mode !=0){ histo->Fill(6, xlWeight); histo_ht_cut->Fill(ht, xlWeight); } } } } //Filling of all region from here if (metPt >= metCut || mode ==0){ if (nJets != 0){ TLorentzVector jet(pxJet->at(iJet),pyJet->at(iJet), pzJet->at(iJet), eJet->at(iJet)); double ptSysPx = lepton0.Px() + lepton1.Px() + jet.Px() + metPx; double ptSysPy = lepton0.Py() + lepton1.Py() + jet.Py() + metPy; double ptSystem = sqrt(ptSysPx*ptSysPx + ptSysPy*ptSysPy); double ht = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; if (nJets == 2 && nTightJetsBT == 1 && nJetsBT == 1) { histo_mll_2j1t->Fill(pair.M(), xlWeight); histo_met_2j1t->Fill(metPt, xlWeight); histo_ptsys_2j1t->Fill(ptSystem, xlWeight); histo_ht_2j1t->Fill(ht, xlWeight); histo_pt_leading_2j1t->Fill(jet.Pt(), xlWeight); TLorentzVector jet2(pxJet->at(iLead),pyJet->at(iLead), pzJet->at(iLead), eJet->at(iLead)); double htled = lepton0.Pt() + lepton1.Pt() + jet2.Pt() + metPt; histo_ht_2j1t_leading->Fill(htled, xlWeight); double htall = lepton0.Pt() + lepton1.Pt() + jet.Pt() + jet2.Pt() + metPt; histo_ht_2j1t_all->Fill(htall, xlWeight); double ptSysPxled = lepton0.Px() + lepton1.Px() + jet2.Px() + metPx; double ptSysPyled = lepton0.Py() + lepton1.Py() + jet2.Py() + metPy; double ptSystemled = sqrt(ptSysPxled*ptSysPxled + ptSysPyled*ptSysPyled); histo_ptsys_2j1t_leading->Fill(ptSystemled, xlWeight); double ptSysPxall = lepton0.Px() + lepton1.Px() + jet.Px() + jet2.Px() + metPx; double ptSysPyall = lepton0.Py() + lepton1.Py() + jet.Py() + jet2.Py() + metPy; double ptSystemall = sqrt(ptSysPxall*ptSysPxall + ptSysPyall*ptSysPyall); histo_ptsys_2j1t_all->Fill(ptSystemall, xlWeight); } else if (nJets == 2 && nTightJetsBT == 2 && nJetsBT == 2) { histo_mll_2j2t->Fill(pair.M(), xlWeight); histo_met_2j2t->Fill(metPt, xlWeight); histo_ptsys_2j2t->Fill(ptSystem, xlWeight); histo_ht_2j2t->Fill(ht, xlWeight); histo_pt_leading_2j2t->Fill(jet.Pt(), xlWeight); TLorentzVector jet2(pxJet->at(iLead),pyJet->at(iLead), pzJet->at(iLead), eJet->at(iLead)); double htled = lepton0.Pt() + lepton1.Pt() + jet2.Pt() + metPt; histo_ht_2j2t_leading->Fill(htled, xlWeight); double htall = lepton0.Pt() + lepton1.Pt() + jet.Pt() + jet2.Pt() + metPt; histo_ht_2j2t_all->Fill(htall, xlWeight); double ptSysPxled = lepton0.Px() + lepton1.Px() + jet2.Px() + metPx; double ptSysPyled = lepton0.Py() + lepton1.Py() + jet2.Py() + metPy; double ptSystemled = sqrt(ptSysPxled*ptSysPxled + ptSysPyled*ptSysPyled); histo_ptsys_2j2t_leading->Fill(ptSystemled, xlWeight); double ptSysPxall = lepton0.Px() + lepton1.Px() + jet.Px() + jet2.Px() + metPx; double ptSysPyall = lepton0.Py() + lepton1.Py() + jet.Py() + jet2.Py() + metPy; double ptSystemall = sqrt(ptSysPxall*ptSysPxall + ptSysPyall*ptSysPyall); histo_ptsys_2j2t_all->Fill(ptSystemall, xlWeight); } //All possible regions if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))histo_R->Fill(1, xlWeight); //signal if (nJets == 1 && nTightJetsBT == 2) histo_R->Fill(2, xlWeight); if (nJets == 1 && nTightJetsBT > 0) histo_R->Fill(3, xlWeight); if (nJets == 1 && nTightJetsBT > 1) histo_R->Fill(4, xlWeight); if (nJets == 2 && nTightJetsBT == 0) histo_R->Fill(5, xlWeight); if (nJets == 2 && nTightJetsBT == 1) histo_R->Fill(6, xlWeight); //CR1 no ht no ptsys if (nJets == 2 && nTightJetsBT == 2) histo_R->Fill(7, xlWeight); //CR2 no ht no ptsys if (nJets == 2 && nTightJetsBT > 0) histo_R->Fill(8, xlWeight); if (nJets == 2 && nTightJetsBT > 1) histo_R->Fill(9, xlWeight); if (nJets > 1 && nTightJetsBT == 0) histo_R->Fill(10, xlWeight); if (nJets > 1 && nTightJetsBT == 1) histo_R->Fill(11, xlWeight); if (nJets > 1 && nTightJetsBT == 2) histo_R->Fill(12, xlWeight); if (nJets > 1 && nTightJetsBT !=0 ) histo_R->Fill(13, xlWeight); if (nJets > 1 && nTightJetsBT > 1 ) histo_R->Fill(14, xlWeight); if (nJets == 3 && nTightJetsBT ==3 ) histo_R->Fill(15, xlWeight); if (nJets == 1 && nTightJetsBT ==1 && bTagged && nJetsBT == 1) histo_R->Fill(16, xlWeight); if (nJets == 2 && nTightJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0)) histo_R->Fill(17, xlWeight); //CR 1 regular if (nJets == 2 && nTightJetsBT == 2 && ptSystem <= ptsysCut && (ht > htMin || mode !=0)) histo_R->Fill(18, xlWeight); //CR 2 regular if (nJets == 2 && nTightJetsBT == 1 && nJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0)) histo_R->Fill(19, xlWeight); if (nJets == 2 && nTightJetsBT == 2 && nJetsBT == 2 && ptSystem <= ptsysCut && (ht > htMin || mode !=0)) histo_R->Fill(20, xlWeight); if (nJets == 2 && nJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0)) histo_R->Fill(21, xlWeight); //CR 1 another way if (nJets == 2 && nJetsBT == 2 && ptSystem <= ptsysCut && (ht > htMin || mode !=0)) histo_R->Fill(22, xlWeight); //CR 2 another way if (nJets == 2 && nTightJetsBT == 1 && nJetsBT == 1) histo_R->Fill(23, xlWeight); //CR1 no ht no ptsys tighter if (nJets == 2 && nTightJetsBT == 2 && nJetsBT == 2) histo_R->Fill(24, xlWeight); //CR2 no ht no ptsys tighter if (nJets == 2 && nJetsBT == 1) histo_R->Fill(25, xlWeight); //CR1 no ht no ptsys another flavor if (nJets == 2 && nJetsBT == 2) histo_R->Fill(26, xlWeight); //CR2 no ht no ptsys another flavor if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1 && (ht > htMin || mode !=0))histo_R->Fill(27, xlWeight); //signal no ptsys if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1 && ptSystem <= ptsysCut)histo_R->Fill(28, xlWeight); //signal no ht if (nJets == 2 && nTightJetsBT == 1 && (ht > htMin || mode !=0)) histo_R->Fill(29, xlWeight); //CR 1 if (nJets == 2 && nTightJetsBT == 2 && (ht > htMin || mode !=0)) histo_R->Fill(30, xlWeight); //CR 2 } //jets in the event } //all CR } // mll } //mll pre } // 2 leptons }// event loop. if (!silent){ cout << "------------------------------------------" << endl; cout << "[Results:] " << plotName << endl; cout << "------------------------------------------" << endl; for (int i = 2; i < 9; i++){ if (i == 2) cout << " leptons: " << histo->GetBinContent(i) << " +/- " << histo->GetBinError(i) << endl; if (i == 3) cout << " inv. mass: " << histo->GetBinContent(i) << " +/- " << histo->GetBinError(i) << endl; if (i == 4) cout << " met: " << histo->GetBinContent(i) << " +/- " << histo->GetBinError(i) << endl; if (i == 5) cout << " jet: " << histo->GetBinContent(i) << " +/- " << histo->GetBinError(i) << endl; if (i == 6) cout << " jet_bt: " << histo->GetBinContent(i) << " +/- " << histo->GetBinError(i) << endl; if (i == 7) cout << " ht: " << histo->GetBinContent(i) << " +/- " << histo->GetBinError(i) << endl; } cout << "------------------------------------------" << endl; } f_var.Write(); f_var.Close(); }
void meoutput(int nsel = 1, int mode = 0, bool silent = false){ // samples used double x_sec = 0.; char plotName[300]; sprintf(plotName,"test"); if (nsel == 0) {sprintf(plotName,"tt");} else if (nsel == 1) {sprintf(plotName,"tw");} if (mode != 0 && mode !=1 && mode !=2) mode = 0; if (!silent){ if (mode == 0) cout << " Electron-Muon Mixed channel " << endl; else if (mode == 1) cout << " Di-Muon channel " << endl; else if (mode == 2) cout << " Di-Electron channel " << endl; } char myRootFile[300]; sprintf(myRootFile,"outputs/out_%d_%s.root", mode, plotName); TFile *input = TFile::Open(myRootFile); char myTexFile[300]; sprintf(myTexFile,"out/%s_%d.lhco", plotName, mode); ofstream salida(myTexFile); // tree variables ///// double xlWeight; double metPt; double metPx; double metPy; std::vector<double> *ptLepton; std::vector<double> *pxLepton; std::vector<double> *pyLepton; std::vector<double> *pzLepton; std::vector<double> *eLepton; std::vector<double> *qLepton; std::vector<double> *ptJet; std::vector<double> *pxJet; std::vector<double> *pyJet; std::vector<double> *pzJet; std::vector<double> *eJet; std::vector<double> *qJet; std::vector<double> *btJet; TTree*Tree = (TTree*) gROOT->FindObject("myTree"); Tree->SetBranchAddress("xlWeight", &xlWeight); Tree->SetBranchAddress("metPt", &metPt); Tree->SetBranchAddress("metPx", &metPx); Tree->SetBranchAddress("metPy", &metPy); Tree->SetBranchAddress("ptLepton",&ptLepton); Tree->SetBranchAddress("pxLepton",&pxLepton); Tree->SetBranchAddress("pyLepton",&pyLepton); Tree->SetBranchAddress("pzLepton",&pzLepton); Tree->SetBranchAddress("eLepton",&eLepton); Tree->SetBranchAddress("qLepton",&qLepton); Tree->SetBranchAddress("ptJet",&ptJet); Tree->SetBranchAddress("pxJet",&pxJet); Tree->SetBranchAddress("pyJet",&pyJet); Tree->SetBranchAddress("pzJet",&pzJet); Tree->SetBranchAddress("eJet",&eJet); Tree->SetBranchAddress("qJet",&qJet); Tree->SetBranchAddress("btJet",&btJet); int nEvents = Tree->GetEntries(); if(!silent){ cout << endl; cout << "------------------------------------------" << endl; cout << "Sample: " << plotName << endl; cout << "------------------------------------------" << endl; cout << "Number of Total events in the tuple: " << nEvents << endl; cout << "------------------------------------------" << endl; } ////////// int n1Jet = 0; int nTotal = 0; int nUsed = 0; for(int event = 0; event<nEvents; event++){ Tree->GetEntry(event); if (luminosity != 1000) xlWeight*=(luminosity/1000); if(ptLepton->size() != 2) cout << "Something is wrong, your Tree is not correctly filled" << endl; else { TLorentzVector lepton0(pxLepton->at(0),pyLepton->at(0), pzLepton->at(0), eLepton->at(0)); TLorentzVector lepton1(pxLepton->at(1),pyLepton->at(1), pzLepton->at(1), eLepton->at(1)); TLorentzVector pair = lepton0+lepton1; bool invMass = false; if (mode == 0) invMass = true; else if (mode == 1 && (pair.M() > invMax || pair.M() < invMin)) invMass = true; else if (mode == 2 && (pair.M() > invMax || pair.M() < invMin)) invMass = true; if (invMass){ if (metPt >= metCut || mode ==0){ int nJets = 0; int nSecondJets = 0; int nJetsBt = 0; bool bTagged = false; int indexJet = -5; for (int i=0; i < ptJet->size(); i++){ TLorentzVector tempJet(pxJet->at(i),pyJet->at(i), pzJet->at(i), eJet->at(i)); if (tempJet.Pt() >= jetCut && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3){ nJets++; indexJet = i; if(btJet->at(i) > 1.74) bTagged = true; } else if (tempJet.Pt() >= secondJetCut && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3) nSecondJets++; if (btJet->at(i) > 1.74) nJetsBt++; } if (nJets == 1){ if (nJetsBt == 1 && bTagged){ // if (bTagged && nSecondJets == 0){ TLorentzVector jet(pxJet->at(indexJet),pyJet->at(indexJet), pzJet->at(indexJet), eJet->at(indexJet)); double ptSysPx = lepton0.Px() + lepton1.Px() + jet.Px() + metPx; double ptSysPy = lepton0.Py() + lepton1.Py() + jet.Py() + metPy; double ptSystem = sqrt(ptSysPx*ptSysPx + ptSysPy*ptSysPy); double ht = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; if (ptSystem <= ptsysCut){ if (ht > htMin || mode !=0){ nTotal++; if (nSecondJets != 0){ nUsed++; int indexSecondJet = -5; for (int i=0; i < ptJet->size(); i++){ TLorentzVector tempJet(pxJet->at(i),pyJet->at(i), pzJet->at(i), eJet->at(i)); if (i != indexJet && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3){ indexSecondJet = i; break; } } TLorentzVector jet2(pxJet->at(indexSecondJet),pyJet->at(indexSecondJet), pzJet->at(indexSecondJet), eJet->at(indexSecondJet)); TVector3 missingEt(metPx, metPy, 0); salida << "0 1 1 " << endl; salida << "1 2 " << lepton0.Eta() << " " << lepton0.Phi() << " " << lepton0.Pt() <<" " << lepton0.M() << " " << qLepton->at(0) << " 0 0 0 0 " << endl; salida << "2 2 " << lepton1.Eta() << " " << lepton1.Phi() << " " << lepton1.Pt() <<" " << lepton1.M() << " " << qLepton->at(1) << " 0 0 0 0 " << endl; salida << "3 4 " << jet.Eta() << " " << jet.Phi() << " " << jet.Pt() <<" " << jet.M() << " " << qJet->at(indexJet) << " 2 0 0 0 " << endl; salida << "4 4 " << jet2.Eta() << " " << jet2.Phi() << " " << jet2.Pt() <<" " << jet2.M() << " " << qJet->at(indexSecondJet) << " 2 0 0 0 " << endl; salida << "5 6 " << missingEt.Eta() << " " << missingEt.Phi() << " " << metPt <<" " << " 0 0 0 0 0 0 " << endl; } else n1Jet++; } } } } } } } // 2 leptons } // events if (!silent){ cout << "Results: " << endl; cout << nTotal << " events passed the selection" << endl; cout << nUsed << " events were used in the lhco file " << endl; cout << n1Jet << " events were not used (only 1 jet exactly) " << endl; cout << "------------------------------------------" << endl; } }