//!PG main function int selector (TChain * tree, histos & plots, int if_signal) { plots.v_hardTAGPt = -99; plots.v_softTAGPt = -99; plots.v_TAGDProdEta = -99; plots.v_TAGDeta = -99; plots.v_TAGMinv = -99; plots.v_LepLep = -99; plots.v_hardLEPPt = -99; plots.v_softLEPPt = -99; plots.v_LEPDPhi = -99; plots.v_LEPDEta = -99; plots.v_LEPDR = -99; plots.v_LEPMinv = -99; plots.v_LEPProdCharge = -99; plots.v_hardLEPCharge = -99; plots.v_softLEPCharge = -99; plots.v_MET = -99; plots.v_ojets = -99 ; plots.v_ojetsCJV = -99 ; plots.v_ojetsRegionalCJV = -99 ; plots.v_ojetsZepp_01 = -99 ; plots.v_ojetsZepp_02 = -99 ; plots.v_ojetsZepp_03 = -99 ; plots.v_ojetsZepp_04 = -99 ; plots.v_ojetsZepp_05 = -99 ; plots.v_ojetsZepp_06 = -99 ; plots.v_ojetsZepp_07 = -99 ; plots.v_ojetsZepp_08 = -99 ; plots.v_ojetsZepp_09 = -99 ; plots.v_ojetsZepp_10 = -99 ; plots.v_ojetsZepp_11 = -99 ; plots.v_ojetsZepp_12 = -99 ; plots.v_ojetsZepp_13 = -99 ; plots.v_ojetsZepp_14 = -99 ; plots.v_decay_Channel_e = -99 ; plots.v_decay_Channel_mu = -99 ; plots.v_decay_Channel_tau = -99 ; TClonesArray * genParticles = new TClonesArray ("TParticle") ; tree->SetBranchAddress ("genParticles", &genParticles) ; // TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; // tree->SetBranchAddress ("tagJets", &tagJets) ; TClonesArray * otherJets_temp = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress (g_KindOfJet.c_str(), &otherJets_temp) ; // tree->SetBranchAddress ("otherJets", &otherJets_temp) ; TClonesArray * electrons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("electrons", &electrons) ; TClonesArray * muons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("muons", &muons) ; TClonesArray * MET = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("MET", &MET) ; TClonesArray * tracks = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("tracks", &tracks) ; TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; TClonesArray * otherJets = new TClonesArray ("TLorentzVector") ; int EleId[100]; float IsolEleSumPt_VBF[100]; int nEle; int EleCharge[30]; tree->SetBranchAddress ("nEle", &nEle) ; tree->SetBranchAddress ("EleId",EleId ) ; tree->SetBranchAddress ("IsolEleSumPt_VBF",IsolEleSumPt_VBF ) ; tree->SetBranchAddress ("EleCharge",EleCharge ) ; float IsolMuTr[100]; int nMu ; int MuCharge[30]; tree->SetBranchAddress ("nMu", &nMu) ; tree->SetBranchAddress ("IsolMuTr",IsolMuTr ) ; tree->SetBranchAddress ("MuCharge", MuCharge) ; int IdEvent; tree->SetBranchAddress ("IdEvent", &IdEvent) ; int nentries = (int) tree->GetEntries () ; plots.passedJetAndLepNumberSelections = 0; plots.analyzed = 0; plots.analyzed_ee = 0; plots.analyzed_mumu = 0; plots.analyzed_tautau = 0; plots.analyzed_emu = 0; plots.analyzed_etau = 0; plots.analyzed_mutau = 0; plots.passedJetAndLepNumberSelections_ee = 0; plots.passedJetAndLepNumberSelections_mumu = 0; plots.passedJetAndLepNumberSelections_tautau = 0; plots.passedJetAndLepNumberSelections_emu = 0; plots.passedJetAndLepNumberSelections_etau = 0; plots.passedJetAndLepNumberSelections_mutau = 0; //PG loop over the events for (int evt = 0 ; evt < nentries ; ++evt) { tree->GetEntry (evt) ; tagJets -> Clear () ; otherJets -> Clear () ; //---- check if signal ---- if (if_signal && (IdEvent!=123 && IdEvent!=124)) continue; plots.analyzed++; //!---- MC ---- if (IdEvent==123 || IdEvent==124) { //---- VBF event ---- plots.v_decay_Channel_e = 0; plots.v_decay_Channel_mu = 0; plots.v_decay_Channel_tau = 0; for (int iGen = 0; iGen < genParticles->GetEntries() ; ++iGen){ TParticle* myparticle = (TParticle*) genParticles->At(iGen); if (abs(myparticle->GetPdgCode()) == 24) { //---- W Int_t mother1 = 0; mother1 = myparticle->GetMother(0); if (mother1 == 25) { //---- mother is higgs ---- for (int iDaughter = 0; iDaughter<2; iDaughter++){ if (abs(myparticle->GetDaughter(iDaughter)) == 11) {//---- W -> e plots.v_decay_Channel_e++; } if (abs(myparticle->GetDaughter(iDaughter)) == 13) {//---- W -> mu plots.v_decay_Channel_mu++; } if (abs(myparticle->GetDaughter(iDaughter)) == 15) {//---- W -> tau plots.v_decay_Channel_tau++; } } } } } } if (plots.v_decay_Channel_e == 2) plots.analyzed_ee++; if (plots.v_decay_Channel_mu == 2) plots.analyzed_mumu++; if (plots.v_decay_Channel_tau == 2) plots.analyzed_tautau++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_mu == 1) plots.analyzed_emu++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_tau == 1) plots.analyzed_etau++; if (plots.v_decay_Channel_mu == 1 && plots.v_decay_Channel_tau == 1) plots.analyzed_mutau++; int cutId = 0 ; plots.increase (cutId++) ; //AM 0 -> total number of events // std::cerr << "--- preambolo leptoni " << std::endl; std::vector<lepton> leptons ; //PG pour electrons into leptons collection //PG --------------------------------------- //PG loop over electrons for (int iele = 0; iele < electrons->GetEntries () ; ++iele) { TLorentzVector * theEle = (TLorentzVector*) (electrons->At (iele)) ; lepton dummy (theEle, 0, iele) ; leptons.push_back (dummy) ; } //PG loop over electrons //PG loop over muons for (int imu = 0 ; imu < nMu ; ++imu) { TLorentzVector * theMu = (TLorentzVector*) (muons->At (imu)) ; lepton dummy (theMu, 1, imu) ; leptons.push_back (dummy) ; } //PG loop over muons //PG this check is not necessary //PG if (leptons.size () < 2) continue ; // std::cerr << "--- inizia leptoni " << std::endl; //PG 2 LEPTONS //PG --------- /* applied after the leptons choice: in this case it is possible to differentiate the selections depending on the position of each lepton in the pt-sorting. the algorithm searches the first two most energetic candidates which satisfy the ID selections required for the first and second lepton respectively. Then check for channel analysis according to "g_LepLep" 0 == ee 1 == mumu 2 == emu 3 == mue pt ordered */ sort (leptons.rbegin (), leptons.rend (), lessThan ()) ; lepton primoLEP ; lepton secondoLEP ; double first_lepton_charge = 0; double second_lepton_charge = 0; int lepton_counter = 0; int electron_counter = 0; int muon_counter = 0; //PG find the first lepton int ilep = 0 ; for ( ; ilep < leptons.size () ; ++ilep) { if (leptons.at (ilep).m_flav == 0) //PG electron { //PG iso check bool eleIso = (IsolEleSumPt_VBF[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoElectron ; // 0.2 per il momento if (g_ISO1[0] == 1 && eleIso != 1) continue; //PG eleID check int eleID = EleId[leptons.at (ilep).m_index] ; if (g_ID1 == 100 && (eleID/100) != 1) continue; else if (g_ID1 == 10 && ((eleID%100)/10) != 1) continue; else if (g_ID1 == 1 && (eleID%10) != 1) continue; first_lepton_charge = EleCharge[leptons.at (ilep).m_index]; } else //PG muon { //PG iso check bool muIso = (IsolMuTr[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoMuon ; if (g_ISO1[1] == 1 && muIso != 1) continue; first_lepton_charge = MuCharge[leptons.at (ilep).m_index]; } primoLEP = leptons[ilep] ; lepton_counter++; if (leptons.at (ilep).m_flav == 0) electron_counter++; else muon_counter++; break ; } //PG find the first lepton //PG find the second lepton bool flag_secondoLEP = false; for (++ilep ; ilep < leptons.size () ; ++ilep) { if (leptons.at (ilep).m_flav == 0) //PG electron { //PG iso check bool eleIso = (IsolEleSumPt_VBF[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoElectron ; // 0.2 per il momento if (g_ISO2[0] == 1 && eleIso != 1) continue; //PG eleID check int eleID = EleId[leptons.at (ilep).m_index] ; if (g_ID2 == 100 && (eleID/100) != 1) continue; else if (g_ID2 == 10 && ((eleID%100)/10) != 1) continue; else if (g_ID2 == 1 && (eleID%10) != 1) continue; second_lepton_charge = EleCharge[leptons.at (ilep).m_index]; } else //PG muon { //PG iso check bool muIso = (IsolMuTr[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoMuon ; if (g_ISO2[1] == 1 && muIso != 1) continue; second_lepton_charge = MuCharge[leptons.at (ilep).m_index]; } if (!flag_secondoLEP) { secondoLEP = leptons[ilep] ; flag_secondoLEP = true; } if (leptons.at (ilep).m_kine->Pt () > 0) { if (leptons.at (ilep).m_flav == 0) electron_counter++; else muon_counter++; lepton_counter++; } } //PG find the second lepton //---- AM 3 --- 2 leptons after Id if (primoLEP.m_flav == -1 || secondoLEP.m_flav == -1) continue ; //---- AM 4 check for the two most transverse-energetic leptons have the right flavours plots.v_numLep = lepton_counter; plots.v_numEle = electron_counter; plots.v_numMu = muon_counter; if (primoLEP.m_flav == 0 && secondoLEP.m_flav == 0) plots.v_LepLep = 0 ; if (primoLEP.m_flav == 1 && secondoLEP.m_flav == 1) plots.v_LepLep = 1 ; if (primoLEP.m_flav == 0 && secondoLEP.m_flav == 1) plots.v_LepLep = 2 ; if (primoLEP.m_flav == 1 && secondoLEP.m_flav == 0) plots.v_LepLep = 3 ; plots.v_hardLEPPt = primoLEP.m_kine->Pt () ; //---- AM 5 pt_min of the most energetic lepton plots.v_softLEPPt = secondoLEP.m_kine->Pt () ; //---- AM 6 pt_min of the least energetic lepton plots.v_LEPDPhi = deltaPhi (primoLEP.m_kine->Phi (), secondoLEP.m_kine->Phi ()) ; //---- AM 7 Delta_phi_min between leptons plots.v_LEPDEta = deltaEta (primoLEP.m_kine->Eta (), secondoLEP.m_kine->Eta ()) ; plots.v_LEPDR = deltaR (primoLEP.m_kine->Phi (),primoLEP.m_kine->Eta (), secondoLEP.m_kine->Phi (), secondoLEP.m_kine->Eta ()) ; TLorentzVector sumLEP = *(primoLEP.m_kine) + *(secondoLEP.m_kine) ; plots.v_LEPMinv = sumLEP.M () ; //---- AM 9 MInv_min of leptons plots.v_LEPProdCharge = first_lepton_charge * second_lepton_charge ; plots.v_hardLEPCharge = first_lepton_charge ; plots.v_softLEPCharge = second_lepton_charge ; //PG MET //PG --- // std::cerr << "--- finito " << std::endl; TLorentzVector* met = ((TLorentzVector*) (MET->At(0))) ; //correct for muons for (int i = 0 ; i < nMu ; i++) { TLorentzVector * mu_v = (TLorentzVector*) (muons->At (i)) ; if (mu_v->Pt () > 3) { met->SetPx (met->Px () - mu_v->Px ()) ; met->SetPy (met->Py () - mu_v->Py ()) ; } } plots.v_MET = met->Pt () ; //---- AM 11 Met_min ----------------> Met correction ? // if (((TLorentzVector*) (MET->At (0)))->Pt () < g_METMin) continue ; plots.increase (cutId++) ; //PG 10 //PG Ztautau vetos //PG ------------- //PG the two electrons should not be opposite to each other // // TVector2 primoLEPT (primoLEP.m_kine->X (), primoLEP.m_kine->Y ()) ; // TVector2 secondoLEPT (secondoLEP.m_kine->X (), secondoLEP.m_kine->Y ()) ; // TVector2 METT (met->X (), met->Y ()) ; // // double Sum = METT * primoLEPT + METT * secondoLEPT / (1 + primoLEPT * secondoLEPT) ; // double Dif = METT * primoLEPT - METT * secondoLEPT / (1 - primoLEPT * secondoLEPT) ; // // TVector2 METT1 = 0.5 * (Sum + Dif) * primoLEPT ; // TVector2 METT2 = 0.5 * (Sum - Dif) * secondoLEPT ; // // double ptNu1 = METT1.Mod () / cos (primoLEP.m_kine->Theta ()) ; // double ptNu2 = METT2.Mod () / cos (secondoLEP.m_kine->Theta ()) ; plots.m_tree_selections->Fill(); plots.passedJetAndLepNumberSelections++; if (plots.v_decay_Channel_e == 2) plots.passedJetAndLepNumberSelections_ee++; if (plots.v_decay_Channel_mu == 2) plots.passedJetAndLepNumberSelections_mumu++; if (plots.v_decay_Channel_tau == 2) plots.passedJetAndLepNumberSelections_tautau++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_mu == 1) plots.passedJetAndLepNumberSelections_emu++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_tau == 1) plots.passedJetAndLepNumberSelections_etau++; if (plots.v_decay_Channel_mu == 1 && plots.v_decay_Channel_tau == 1) plots.passedJetAndLepNumberSelections_mutau++; } //PG loop over the events plots.m_efficiency->Fill(); plots.m_efficiency->Write(); plots.m_tree_selections->Write(); delete otherJets_temp ; delete tagJets ; delete otherJets ; delete electrons ; delete muons ; delete MET ; delete tracks ; return 0; }
TEveTrackList* kine_tracks(Double_t min_pt, Double_t min_p, Bool_t pdg_col, Bool_t recurse, Bool_t use_track_refs) { IlcRunLoader* rl = IlcEveEventManager::AssertRunLoader(); rl->LoadKinematics(); IlcStack* stack = rl->Stack(); if (!stack) { Error("kine_tracks", "can not get kinematics."); return 0; } gEve->DisableRedraw(); TEveTrackList* cont = new TEveTrackList("Kine Tracks"); cont->SetMainColor(3); TEveTrackPropagator* trkProp = cont->GetPropagator(); kine_track_propagator_setup(trkProp); gEve->AddElement(cont); Int_t count = 0; Int_t Np = stack->GetNprimary(); for (Int_t i = 0; i < Np; ++i) { TParticle* p = stack->Particle(i); if (p->GetStatusCode() <= 1) { if (p->Pt() < min_pt && p->P() < min_p) continue; ++count; IlcEveTrack* track = new IlcEveTrack(p, i, trkProp); //PH The line below is replaced waiting for a fix in Root //PH which permits to use variable siza arguments in CINT //PH on some platforms (alphalinuxgcc, solariscc5, etc.) //PH track->SetName(Form("%s [%d]", p->GetName(), i)); char form[1000]; sprintf(form,"%s [%d]", p->GetName(), i); track->SetName(form); track->SetStdTitle(); Int_t ml = p->GetMother(0); if (ml != -1) { track->SetTitle(Form("%s\nMother label=%d\nMother Pdg=%d", track->GetElementTitle(), ml, stack->Particle(ml)->GetPdgCode())); } set_track_color(track, pdg_col); gEve->AddElement(track, cont); if (recurse) kine_daughters(track, stack, min_pt, min_p, pdg_col, recurse); } } // set path marks IlcEveKineTools kt; kt.SetDaughterPathMarks(cont, stack, recurse); if (use_track_refs && rl->LoadTrackRefs() == 0) { kt.SetTrackReferences(cont, rl->TreeTR(), recurse); trkProp->SetEditPathMarks(kTRUE); } kt.SortPathMarks(cont, recurse); //PH const Text_t* tooltip = Form("min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count); char tooltip[1000]; sprintf(tooltip,"min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count); cont->SetTitle(tooltip); // Not broadcasted automatically ... cont->MakeTracks(recurse); gEve->EnableRedraw(); gEve->Redraw3D(); return cont; }