diff --git a/.gitignore b/.gitignore index e1e141aaee1..14d53093f0c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ __init__.py #*# *.hdf */#*.*# -production/mc/crab* \ No newline at end of file +BParkingNano/production/crab/BParkingNANO* +NanoAOD/ diff --git a/BParkingNano/plugins/BToKLLBuilder.cc b/BParkingNano/plugins/BToKLLBuilder.cc index bb261abdf36..8677cfc379c 100644 --- a/BParkingNano/plugins/BToKLLBuilder.cc +++ b/BParkingNano/plugins/BToKLLBuilder.cc @@ -121,6 +121,7 @@ void BToKLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup cons //for isolation edm::Handle iso_tracks; evt.getByToken(isotracksToken_, iso_tracks); + edm::Handle iso_lostTracks; evt.getByToken(isolostTracksToken_, iso_lostTracks); unsigned int nTracks = iso_tracks->size(); diff --git a/BParkingNano/plugins/BToKstarLLBuilder.cc b/BParkingNano/plugins/BToKstarLLBuilder.cc index 4b7fa654b43..190210844b1 100644 --- a/BParkingNano/plugins/BToKstarLLBuilder.cc +++ b/BParkingNano/plugins/BToKstarLLBuilder.cc @@ -1,5 +1,4 @@ ////////////////////// Code to produce K*LL candidates ///////////////////////// - #include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -8,6 +7,10 @@ #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/BeamSpot/interface/BeamSpot.h" #include "TrackingTools/TransientTrack/interface/TransientTrack.h" +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include #include @@ -16,16 +19,13 @@ #include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" #include "DataFormats/PatCandidates/interface/CompositeCandidate.h" -#include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/Math/interface/deltaR.h" #include "CommonTools/Statistics/interface/ChiSquaredProbability.h" #include "helper.h" #include #include #include "KinVtxFitter.h" - - - +#include class BToKstarLLBuilder : public edm::global::EDProducer<> { @@ -34,18 +34,28 @@ class BToKstarLLBuilder : public edm::global::EDProducer<> { typedef std::vector TransientTrackCollection; explicit BToKstarLLBuilder(const edm::ParameterSet &cfg): + bFieldToken_(esConsumes()), // selections pre_vtx_selection_{cfg.getParameter("preVtxSelection")}, post_vtx_selection_{cfg.getParameter("postVtxSelection")}, + filter_by_selection_{cfg.getParameter("filterBySelection")}, //inputs dileptons_{consumes( cfg.getParameter("dileptons") )}, + dileptons_kinVtxs_{consumes >( cfg.getParameter("dileptonKinVtxs") )}, kstars_{consumes( cfg.getParameter("kstars") )}, leptons_ttracks_{consumes( cfg.getParameter("leptonTransientTracks") )}, kstars_ttracks_{consumes( cfg.getParameter("kstarsTransientTracks") )}, + tracks_ttracks_(consumes(cfg.getParameter("tracksTransientTracks"))), + tracks_(consumes(cfg.getParameter("tracks_kpi"))), isotracksToken_{consumes(cfg.getParameter("tracks"))}, isolostTracksToken_{consumes(cfg.getParameter("lostTracks"))}, isotrk_selection_{cfg.getParameter("isoTracksSelection")}, - beamspot_{consumes( cfg.getParameter("beamSpot") )} + isotrk_dca_selection_{cfg.getParameter("isoTracksDCASelection")}, + isotrkDCACut_(cfg.getParameter("isotrkDCACut")), + isotrkDCATightCut_(cfg.getParameter("isotrkDCATightCut")), + drIso_cleaning_(cfg.getParameter("drIso_cleaning")), + beamspot_{consumes( cfg.getParameter("beamSpot") )}, + vertex_src_{consumes( cfg.getParameter("offlinePrimaryVertexSrc") )} { //output produces(); @@ -58,43 +68,74 @@ class BToKstarLLBuilder : public edm::global::EDProducer<> { static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) {} private: + const edm::ESGetToken bFieldToken_; // selections const StringCutObjectSelector pre_vtx_selection_; // cut on the di-lepton before the SV fit const StringCutObjectSelector post_vtx_selection_; // cut on the di-lepton after the SV fit + const bool filter_by_selection_; const edm::EDGetTokenT dileptons_; + const edm::EDGetTokenT > dileptons_kinVtxs_; const edm::EDGetTokenT kstars_; const edm::EDGetTokenT leptons_ttracks_; const edm::EDGetTokenT kstars_ttracks_; + const edm::EDGetTokenT tracks_ttracks_; + const edm::EDGetTokenT tracks_; + const edm::EDGetTokenT isotracksToken_; const edm::EDGetTokenT isolostTracksToken_; const StringCutObjectSelector isotrk_selection_; + const StringCutObjectSelector isotrk_dca_selection_; + const double isotrkDCACut_; + const double isotrkDCATightCut_; + const double drIso_cleaning_; + const edm::EDGetTokenT beamspot_; + const edm::EDGetTokenT vertex_src_; }; -void BToKstarLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup const &) const { +void BToKstarLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup const &iSetup) const { //input edm::Handle dileptons; evt.getByToken(dileptons_, dileptons); + + edm::Handle > dileptons_kinVtxs; + evt.getByToken(dileptons_kinVtxs_, dileptons_kinVtxs); + edm::Handle leptons_ttracks; evt.getByToken(leptons_ttracks_, leptons_ttracks); edm::Handle kstars; evt.getByToken(kstars_, kstars); + edm::Handle kstars_ttracks; - evt.getByToken(kstars_ttracks_, kstars_ttracks); + evt.getByToken(kstars_ttracks_, kstars_ttracks); + + edm::Handle tracks; + evt.getByToken(tracks_, tracks); + + edm::Handle tracks_ttracks; + evt.getByToken(tracks_ttracks_, tracks_ttracks); edm::Handle beamspot; evt.getByToken(beamspot_, beamspot); + + edm::Handle pvtxs; + evt.getByToken(vertex_src_, pvtxs); + + const auto& bField = iSetup.getData(bFieldToken_); + AnalyticalImpactPointExtrapolator extrapolator(&bField); //for isolation edm::Handle iso_tracks; evt.getByToken(isotracksToken_, iso_tracks); + edm::Handle iso_lostTracks; evt.getByToken(isolostTracksToken_, iso_lostTracks); + unsigned int nTracks = iso_tracks->size(); unsigned int totalTracks = nTracks + iso_lostTracks->size(); @@ -213,6 +254,12 @@ void BToKstarLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup auto lxy = l_xy(fitter, *beamspot); cand.addUserFloat("l_xy", lxy.value()); cand.addUserFloat("l_xy_unc", lxy.error()); + cand.addUserFloat("vtx_x", cand.vx()); + cand.addUserFloat("vtx_y", cand.vy()); + cand.addUserFloat("vtx_z", cand.vz()); + cand.addUserFloat("vtx_ex", sqrt(fitter.fitted_vtx_uncertainty().cxx())); + cand.addUserFloat("vtx_ey", sqrt(fitter.fitted_vtx_uncertainty().cyy())); + cand.addUserFloat("vtx_ez", sqrt(fitter.fitted_vtx_uncertainty().czz())); // second mass hypothesis auto trk1p4 = fitter.daughter_p4(0); @@ -220,20 +267,42 @@ void BToKstarLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup trk1p4.SetM(PI_MASS); trk2p4.SetM(K_MASS); cand.addUserFloat("barMasskstar_fullfit",(trk1p4+trk2p4).M()); - cand.addUserFloat("fitted_barMass",(trk1p4+trk2p4+fitter.daughter_p4(2) + fitter.daughter_p4(3)).M()); + cand.addUserFloat("fitted_barMass",(trk1p4+trk2p4+fitter.daughter_p4(2) + fitter.daughter_p4(3)).M()); + + // track 3D impact parameter from dilepton SV + TrajectoryStateOnSurface tsos_trk1 = extrapolator.extrapolate(tracks_ttracks->at(trk1_idx).impactPointState(), dileptons_kinVtxs->at(ll_idx).fitted_vtx()); + std::pair cur2DIP_trk1 = signedTransverseImpactParameter(tsos_trk1, dileptons_kinVtxs->at(ll_idx).fitted_refvtx(), *beamspot); + std::pair cur3DIP_trk1 = signedImpactParameter3D(tsos_trk1, dileptons_kinVtxs->at(ll_idx).fitted_refvtx(), *beamspot, (*pvtxs)[0].position().z()); + + cand.addUserFloat("trk1_svip2d" , cur2DIP_trk1.second.value()); + cand.addUserFloat("trk1_svip2d_err" , cur2DIP_trk1.second.error()); + cand.addUserFloat("trk1_svip3d" , cur3DIP_trk1.second.value()); + cand.addUserFloat("trk1_svip3d_err" , cur3DIP_trk1.second.error()); + + // track 3D impact parameter from dilepton SV + TrajectoryStateOnSurface tsos_trk2 = extrapolator.extrapolate(tracks_ttracks->at(trk2_idx).impactPointState(), dileptons_kinVtxs->at(ll_idx).fitted_vtx()); + std::pair cur2DIP_trk2 = signedTransverseImpactParameter(tsos_trk2, dileptons_kinVtxs->at(ll_idx).fitted_refvtx(), *beamspot); + std::pair cur3DIP_trk2 = signedImpactParameter3D(tsos_trk2, dileptons_kinVtxs->at(ll_idx).fitted_refvtx(), *beamspot, (*pvtxs)[0].position().z()); + + cand.addUserFloat("trk2_svip2d" , cur2DIP_trk2.second.value()); + cand.addUserFloat("trk2_svip2d_err" , cur2DIP_trk2.second.error()); + cand.addUserFloat("trk2_svip3d" , cur3DIP_trk2.second.value()); + cand.addUserFloat("trk2_svip3d_err" , cur3DIP_trk2.second.error()); // post fit selection - if( !post_vtx_selection_(cand) ) continue; + bool post_vtx_sel = post_vtx_selection_(cand); + cand.addUserInt("post_vtx_sel",post_vtx_sel); + if( filter_by_selection_ && !post_vtx_sel ) continue; //compute isolation float l1_iso03 = 0; float l1_iso04 = 0; float l2_iso03 = 0; float l2_iso04 = 0; - float tk1_iso03 = 0; - float tk1_iso04 = 0; - float tk2_iso03 = 0; - float tk2_iso04 = 0; + float trk1_iso03 = 0; + float trk1_iso04 = 0; + float trk2_iso03 = 0; + float trk2_iso04 = 0; float b_iso03 = 0; float b_iso04 = 0; @@ -252,8 +321,8 @@ void BToKstarLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup // add to final particle iso if dR < cone float dr_to_l1 = deltaR(cand.userFloat("fitted_l1_eta"), cand.userFloat("fitted_l1_phi"), trk.eta(), trk.phi()); float dr_to_l2 = deltaR(cand.userFloat("fitted_l2_eta"), cand.userFloat("fitted_l2_phi"), trk.eta(), trk.phi()); - float dr_to_tk1 = deltaR(cand.userFloat("fitted_trk1_eta"),cand.userFloat("fitted_trk1_phi"),trk.eta(), trk.phi()); - float dr_to_tk2 = deltaR(cand.userFloat("fitted_trk2_eta"),cand.userFloat("fitted_trk2_phi"),trk.eta(), trk.phi()); + float dr_to_trk1 = deltaR(cand.userFloat("fitted_trk1_eta"),cand.userFloat("fitted_trk1_phi"),trk.eta(), trk.phi()); + float dr_to_trk2 = deltaR(cand.userFloat("fitted_trk2_eta"),cand.userFloat("fitted_trk2_phi"),trk.eta(), trk.phi()); float dr_to_b = deltaR(cand.userFloat("fitted_eta"), cand.userFloat("fitted_phi"), trk.eta(), trk.phi()); if (dr_to_l1 < 0.4){ @@ -264,29 +333,211 @@ void BToKstarLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup l2_iso04 += trk.pt(); if (dr_to_l2 < 0.3) l2_iso03 += trk.pt(); } - if (dr_to_tk1 < 0.4){ - tk1_iso04 += trk.pt(); - if (dr_to_tk1 < 0.3) tk1_iso03 += trk.pt(); + if (dr_to_trk1 < 0.4){ + trk1_iso04 += trk.pt(); + if (dr_to_trk1 < 0.3) trk1_iso03 += trk.pt(); } - if (dr_to_tk2 < 0.4){ - tk2_iso04 += trk.pt(); - if (dr_to_tk2 < 0.3) tk2_iso03 += trk.pt(); + if (dr_to_trk2 < 0.4){ + trk2_iso04 += trk.pt(); + if (dr_to_trk2 < 0.3) trk2_iso03 += trk.pt(); } if (dr_to_b < 0.4){ b_iso04 += trk.pt(); if (dr_to_b < 0.3) b_iso03 += trk.pt(); } } - cand.addUserFloat("l1_iso03" , l1_iso03); - cand.addUserFloat("l1_iso04" , l1_iso04); - cand.addUserFloat("l2_iso03" , l2_iso03); - cand.addUserFloat("l2_iso04" , l2_iso04); - cand.addUserFloat("tk1_iso03", tk1_iso03); - cand.addUserFloat("tk1_iso04", tk1_iso04); - cand.addUserFloat("tk2_iso03", tk2_iso03); - cand.addUserFloat("tk2_iso04", tk2_iso04); - cand.addUserFloat("b_iso03" , b_iso03 ); - cand.addUserFloat("b_iso04" , b_iso04 ); + + + //compute isolation from surrounding tracks only + float l1_iso03_dca = 0; + float l1_iso04_dca = 0; + float l2_iso03_dca = 0; + float l2_iso04_dca = 0; + float trk1_iso03_dca = 0; + float trk2_iso03_dca = 0; + float trk1_iso04_dca = 0; + float trk2_iso04_dca = 0; + float b_iso03_dca = 0; + float b_iso04_dca = 0; + int l1_n_isotrk = 0; + int l2_n_isotrk = 0; + int trk1_n_isotrk = 0; + int trk2_n_isotrk = 0; + int b_n_isotrk = 0; + int l1_n_isotrk_dca = 0; + int l2_n_isotrk_dca = 0; + int trk1_n_isotrk_dca = 0; + int trk2_n_isotrk_dca = 0; + int b_n_isotrk_dca = 0; + + float l1_iso03_dca_tight = 0; + float l1_iso04_dca_tight = 0; + float l2_iso03_dca_tight = 0; + float l2_iso04_dca_tight = 0; + float trk1_iso03_dca_tight = 0; + float trk1_iso04_dca_tight = 0; + float trk2_iso03_dca_tight = 0; + float trk2_iso04_dca_tight = 0; + float b_iso03_dca_tight = 0; + float b_iso04_dca_tight = 0; + int l1_n_isotrk_dca_tight = 0; + int l2_n_isotrk_dca_tight = 0; + int trk1_n_isotrk_dca_tight = 0; + int trk2_n_isotrk_dca_tight = 0; + int b_n_isotrk_dca_tight = 0; + + for(size_t trk_idx = 0; trk_idx < tracks->size(); ++trk_idx) { + // corss clean kaon + if (int(trk_idx) == trk1_idx || int(trk_idx) == trk2_idx) continue; + edm::Ptr trk_ptr(tracks, trk_idx); + if( !isotrk_dca_selection_(*trk_ptr) ) continue; + // cross clean PF (electron and muon) + unsigned int iTrk = trk_ptr->userInt("keyPacked"); + if (track_to_lepton_match(l1_ptr, iso_tracks.id().id(), iTrk) || + track_to_lepton_match(l2_ptr, iso_tracks.id().id(), iTrk) ) { + continue; + } + // cross clean leptons + // hard to trace the source particles of low-pT electron in B builder + // use simple dR cut instead + float dr_to_l1_prefit = deltaR(l1_ptr->eta(), l1_ptr->phi(), trk_ptr->eta(), trk_ptr->phi()); + float dr_to_l2_prefit = deltaR(l2_ptr->eta(), l2_ptr->phi(), trk_ptr->eta(), trk_ptr->phi()); + if ((dr_to_l1_prefit < drIso_cleaning_) || (dr_to_l2_prefit < drIso_cleaning_)) continue; + + TrajectoryStateOnSurface tsos_iso = extrapolator.extrapolate(tracks_ttracks->at(trk_idx).impactPointState(), fitter.fitted_vtx()); + std::pair cur3DIP_iso = absoluteImpactParameter3D(tsos_iso, fitter.fitted_refvtx()); + float svip_iso = cur3DIP_iso.second.value(); + if (cur3DIP_iso.first && svip_iso < isotrkDCACut_) { + // add to final particle iso if dR < cone + float dr_to_l1 = deltaR(cand.userFloat("fitted_l1_eta"), cand.userFloat("fitted_l1_phi"), trk_ptr->eta(), trk_ptr->phi()); + float dr_to_l2 = deltaR(cand.userFloat("fitted_l2_eta"), cand.userFloat("fitted_l2_phi"), trk_ptr->eta(), trk_ptr->phi()); + float dr_to_trk1 = deltaR(cand.userFloat("fitted_trk1_eta") , cand.userFloat("fitted_trk1_phi") , trk_ptr->eta(), trk_ptr->phi()); + float dr_to_trk2 = deltaR(cand.userFloat("fitted_trk2_eta") , cand.userFloat("fitted_trk2_phi") , trk_ptr->eta(), trk_ptr->phi()); + float dr_to_b = deltaR(cand.userFloat("fitted_eta") , cand.userFloat("fitted_phi") , trk_ptr->eta(), trk_ptr->phi()); + + if (dr_to_l1 < 0.4){ + l1_iso04_dca += trk_ptr->pt(); + l1_n_isotrk_dca++; + if (svip_iso < isotrkDCATightCut_) { + l1_iso04_dca_tight += trk_ptr->pt(); + l1_n_isotrk_dca_tight++; + } + if (dr_to_l1 < 0.3) { + l1_iso03_dca += trk_ptr->pt(); + if (svip_iso < isotrkDCATightCut_) { + l1_iso03_dca_tight += trk_ptr->pt(); + } + } + } + if (dr_to_l2 < 0.4){ + l2_iso04_dca += trk_ptr->pt(); + l2_n_isotrk_dca++; + if (svip_iso < isotrkDCATightCut_) { + l2_iso04_dca_tight += trk_ptr->pt(); + l2_n_isotrk_dca_tight++; + } + if (dr_to_l2 < 0.3) { + l2_iso03_dca += trk_ptr->pt(); + if (svip_iso < isotrkDCATightCut_) { + l2_iso03_dca_tight += trk_ptr->pt(); + } + } + } + if (dr_to_trk1 < 0.4){ + trk1_iso04_dca += trk_ptr->pt(); + trk1_n_isotrk_dca++; + if (svip_iso < isotrkDCATightCut_) { + trk1_iso04_dca_tight += trk_ptr->pt(); + trk1_n_isotrk_dca_tight++; + } + if (dr_to_trk1 < 0.3) { + trk1_iso03_dca += trk_ptr->pt(); + if (svip_iso < isotrkDCATightCut_) { + trk1_iso03_dca_tight += trk_ptr->pt(); + } + } + } + if (dr_to_trk2 < 0.4){ + trk2_iso04_dca += trk_ptr->pt(); + trk2_n_isotrk_dca++; + if (svip_iso < isotrkDCATightCut_) { + trk2_iso04_dca_tight += trk_ptr->pt(); + trk2_n_isotrk_dca_tight++; + } + if (dr_to_trk2 < 0.3) { + trk2_iso03_dca += trk_ptr->pt(); + if (svip_iso < isotrkDCATightCut_) { + trk2_iso03_dca_tight += trk_ptr->pt(); + } + } + } + if (dr_to_b < 0.4){ + b_iso04_dca += trk_ptr->pt(); + b_n_isotrk_dca++; + if (svip_iso < isotrkDCATightCut_) { + b_iso04_dca_tight += trk_ptr->pt(); + b_n_isotrk_dca_tight++; + } + if (dr_to_b < 0.3) { + b_iso03_dca += trk_ptr->pt(); + if (svip_iso < isotrkDCATightCut_) { + b_iso03_dca_tight += trk_ptr->pt(); + } + } + } + } + } + + + cand.addUserFloat("l1_iso03", l1_iso03); + cand.addUserFloat("l1_iso04", l1_iso04); + cand.addUserFloat("l2_iso03", l2_iso03); + cand.addUserFloat("l2_iso04", l2_iso04); + cand.addUserFloat("trk1_iso03" , trk1_iso03 ); + cand.addUserFloat("trk1_iso04" , trk1_iso04 ); + cand.addUserFloat("trk2_iso03" , trk2_iso03 ); + cand.addUserFloat("trk2_iso04" , trk2_iso04 ); + cand.addUserFloat("b_iso03" , b_iso03 ); + cand.addUserFloat("b_iso04" , b_iso04 ); + cand.addUserInt("l1_n_isotrk" , l1_n_isotrk); + cand.addUserInt("l2_n_isotrk" , l2_n_isotrk); + cand.addUserInt("trk1_n_isotrk" , trk1_n_isotrk); + cand.addUserInt("trk2_n_isotrk" , trk2_n_isotrk); + cand.addUserInt("b_n_isotrk" , b_n_isotrk); + + cand.addUserFloat("l1_iso03_dca", l1_iso03_dca); + cand.addUserFloat("l1_iso04_dca", l1_iso04_dca); + cand.addUserFloat("l2_iso03_dca", l2_iso03_dca); + cand.addUserFloat("l2_iso04_dca", l2_iso04_dca); + cand.addUserFloat("trk1_iso03_dca" , trk1_iso03_dca ); + cand.addUserFloat("trk1_iso04_dca" , trk1_iso04_dca ); + cand.addUserFloat("trk2_iso03_dca" , trk2_iso03_dca ); + cand.addUserFloat("trk2_iso04_dca" , trk2_iso04_dca ); + cand.addUserFloat("b_iso03_dca" , b_iso03_dca ); + cand.addUserFloat("b_iso04_dca" , b_iso04_dca ); + cand.addUserInt("l1_n_isotrk_dca" , l1_n_isotrk_dca); + cand.addUserInt("l2_n_isotrk_dca" , l2_n_isotrk_dca); + cand.addUserInt("trk1_n_isotrk_dca" , trk1_n_isotrk_dca); + cand.addUserInt("trk2_n_isotrk_dca" , trk2_n_isotrk_dca); + cand.addUserInt("b_n_isotrk_dca" , b_n_isotrk_dca); + + cand.addUserFloat("l1_iso03_dca_tight", l1_iso03_dca_tight); + cand.addUserFloat("l1_iso04_dca_tight", l1_iso04_dca_tight); + cand.addUserFloat("l2_iso03_dca_tight", l2_iso03_dca_tight); + cand.addUserFloat("l2_iso04_dca_tight", l2_iso04_dca_tight); + cand.addUserFloat("trk1_iso03_dca_tight" , trk1_iso03_dca_tight ); + cand.addUserFloat("trk1_iso04_dca_tight" , trk1_iso04_dca_tight ); + cand.addUserFloat("trk2_iso03_dca_tight" , trk2_iso03_dca_tight ); + cand.addUserFloat("trk2_iso04_dca_tight" , trk2_iso04_dca_tight ); + cand.addUserFloat("b_iso03_dca_tight" , b_iso03_dca_tight ); + cand.addUserFloat("b_iso04_dca_tight" , b_iso04_dca_tight ); + cand.addUserInt("l1_n_isotrk_dca_tight" , l1_n_isotrk_dca_tight); + cand.addUserInt("l2_n_isotrk_dca_tight" , l2_n_isotrk_dca_tight); + cand.addUserInt("trk1_n_isotrk_dca_tight" , trk1_n_isotrk_dca_tight); + cand.addUserInt("trk2_n_isotrk_dca_tight" , trk2_n_isotrk_dca_tight); + cand.addUserInt("b_n_isotrk_dca_tight" , b_n_isotrk_dca_tight); + + ret_val->push_back(cand); diff --git a/BParkingNano/plugins/ElectronMerger.cc b/BParkingNano/plugins/ElectronMerger.cc index 689c538bc01..058e599d69a 100644 --- a/BParkingNano/plugins/ElectronMerger.cc +++ b/BParkingNano/plugins/ElectronMerger.cc @@ -334,7 +334,11 @@ void ElectronMerger::produce(edm::StreamID, edm::Event &evt, edm::EventSetup con ele.addUserFloat("LPEleMvaID_2020Sept15RawValue", mva_id); // was called "mvaId" ele.addUserFloat("PFEleMvaID_RetrainedRawValue", 20.); // was called "pfmvaId" // Run-2 PF ele ID - ele.addUserFloat("PFEleMvaID_Fall17NoIsoV2RawValue", 20.); // Run 2 ID + ele.addUserFloat("PFEleMvaID_Fall17NoIsoV2RawValue", 20.0); + ele.addUserInt("PFEleMvaID_Fall17NoIsoV1wpLoose", 0); //@@ to be deprecated + ele.addUserInt("PFEleMvaID_Fall17NoIsoV2wpLoose", 0); + ele.addUserInt("PFEleMvaID_Fall17NoIsoV2wp90", 0); + ele.addUserInt("PFEleMvaID_Fall17NoIsoV2wp80", 0); // Run-3 PF ele ID //ele.addUserFloat("PFEleMvaID_Winter22NoIsoV1RawValue", 20.); // Run 3 ID ele.addUserFloat("chargeMode", ele.gsfTrack()->chargeMode()); @@ -401,4 +405,4 @@ void ElectronMerger::produce(edm::StreamID, edm::Event &evt, edm::EventSetup con } #include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(ElectronMerger); +DEFINE_FWK_MODULE(ElectronMerger); \ No newline at end of file diff --git a/BParkingNano/plugins/TrackMerger.cc b/BParkingNano/plugins/TrackMerger.cc index 6452c6977af..462de4d9cde 100644 --- a/BParkingNano/plugins/TrackMerger.cc +++ b/BParkingNano/plugins/TrackMerger.cc @@ -144,10 +144,10 @@ void TrackMerger::produce(edm::StreamID, edm::Event &evt, edm::EventSetup const // for loop is better to be range based - especially for large ensembles for( unsigned int iTrk=0; iTrk trkEtaCut_) continue; diff --git a/BParkingNano/production/condor/BuToKJPsi_1712764458/BuToKJPsi.jdl b/BParkingNano/production/condor/BuToKJPsi_1712764458/BuToKJPsi.jdl new file mode 100644 index 00000000000..8324a190fda --- /dev/null +++ b/BParkingNano/production/condor/BuToKJPsi_1712764458/BuToKJPsi.jdl @@ -0,0 +1,12 @@ +universe = vanilla +Executable = cmsRun.sh +Should_Transfer_Files = YES +WhenToTransferOutput = ON_EXIT +Transfer_Input_Files = cmsRun.sh, run_nano_cfg.py, filelist_BuToKJPsi.tgz +Output = /afs/cern.ch/work/x/xuyan/RKProj/BParkingNanoOfficial/CMSSW_13_1_0/src/PhysicsTools/BParkingNano/production/condor/BuToKJPsi_1712764458/out/$(ProcId).out +Error = /afs/cern.ch/work/x/xuyan/RKProj/BParkingNanoOfficial/CMSSW_13_1_0/src/PhysicsTools/BParkingNano/production/condor/BuToKJPsi_1712764458/err/$(ProcId).err +Log = /afs/cern.ch/work/x/xuyan/RKProj/BParkingNanoOfficial/CMSSW_13_1_0/src/PhysicsTools/BParkingNano/production/condor/BuToKJPsi_1712764458/log/$(ProcId).log +Arguments = /eos/home-x/xuyan/RKProj/RKAnalyzer/KStarllStudy/Data/BuToKJPsi_1712764458/ BuToKJPsi CMSSW_13_1_0 $(ProcId) run_nano_cfg.py filelist_tmp_$(ProcId).list /afs/cern.ch/user/x/xuyan/private/x509up/x509up_u93529 True +MY.WantOS = "el7" ++JobFlavour = "tomorrow" +Queue 11 diff --git a/BParkingNano/production/condor/cmsRun.sh b/BParkingNano/production/condor/cmsRun.sh new file mode 100644 index 00000000000..ed73bdca878 --- /dev/null +++ b/BParkingNano/production/condor/cmsRun.sh @@ -0,0 +1,32 @@ +#!/bin/bash +echo "Starting job on " `date` #Date/time of start of job +echo "Running on: `uname -a`" #Condor job is running on this node +echo "System software: `cat /etc/redhat-release`" #Operating System on that node +source /cvmfs/cms.cern.ch/cmsset_default.sh ## if a bash script, use .sh instead of .csh +export X509_USER_PROXY=${7} +voms-proxy-info -all +voms-proxy-info -all -file ${7} +### for case 1. EOS have the following line, otherwise remove this line in case 2. +#Arguments 1)eosDir 2)jobName 3)rel 4)iJob 5)jobCfg 6)inputFile 7)fileName + +# You need to move transfered files to the working area +cp ${1}${2}.tgz . +tar -xf ${2}.tgz +rm ${2}.tgz +mv ${5} ${3}/src/PhysicsTools/BParkingNano +mv filelist_${2}.tgz ${3}/src/PhysicsTools/BParkingNano + +# export $SCRAM_ARCH=slc7_amd64_gcc700 +cd ${3}/src/ +scramv1 b ProjectRename -j 8 +eval `scramv1 runtime -sh` # cmsenv is an alias not on the workers +cd PhysicsTools/BParkingNano +tar -xf filelist_${2}.tgz +ls ./ +touch log.txt +cmsRun ${5} inputFiles_load=${6} isMC=${8} 2>&1 | tee log.txt +cp log.txt ${1}/log_${4}.txt +cp BParkingNANO_Run3_*.root ${1}/myNano_${4}.root +rm BParkingNANO_Run3_*.root +cd ${_CONDOR_SCRATCH_DIR} +rm -rf ${3} \ No newline at end of file diff --git a/BParkingNano/production/condor/condor_sub.py b/BParkingNano/production/condor/condor_sub.py new file mode 100644 index 00000000000..1cc58773fb2 --- /dev/null +++ b/BParkingNano/production/condor/condor_sub.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python +import os, re, sys, commands, math, time, calendar + +print '\nSTART\n' +ts = calendar.timegm(time.gmtime()) + +# joblist = ["BuToKEE","BdToK0starEE_postEE","BdToK0starEE_postEE_ext1","BdToK0starEE_preEE","BdToK0starEE_preEE_ext1"] +joblist = ["BuToKJPsi"] + +jobdic = {"BuToKJPsi":"BuToKJPsi_JPsiToEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen.list", + # "DataF":"ParkingDoubleElectronLowMass0_Run2022F.list", + # "BuToKEE":"BuToKEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen.list", + # "BdToK0starEE_postEE":"BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen_postEE.list", + # "BdToK0starEE_postEE_ext1":"BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen_postEE_ext1.list", + # "BdToK0starEE_preEE":"BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen_preEE.list", + # "BdToK0starEE_preEE_ext1":"BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen_preEE_ext1.list", +} + +for jobName in joblist: + print(jobName, jobdic[jobName]) + jobCfg = "run_nano_cfg.py" + jobScript = "cmsRun.sh" + rel = "CMSSW_13_1_0" + eosDir = "/eos/home-x/xuyan/RKProj/RKAnalyzer/KStarllStudy/Data/" + jobName + "_" + str(ts) + "/" + isMC = "True" + if "Data" in jobName: + isMC = "False" + print("Running on MC: ",isMC) + + rootDir = os.environ["CMSSW_BASE"] + "/src/PhysicsTools/BParkingNano/production/condor/" + jobDir = rootDir + jobName + "_" + str(ts) + "/" + files_batch = 10 + + fileList = rootDir + jobdic[jobName] + + ret = os.system("rm filelist_tmp_*.list") + ret = os.system("cp ../../test/" + jobCfg + " ./") + ret = os.system("mkdir -p " + jobDir) + ret = os.system("mkdir -p " + eosDir) + ret = os.system("mkdir -p " + jobDir + "out/") + ret = os.system("mkdir -p " + jobDir + "err/") + ret = os.system("mkdir -p " + jobDir + "log/") + ret = os.chdir(os.environ["CMSSW_BASE"]+"/../") + print('Tarballing ' + rel + "/ into " + jobName + ".tgz...") + ret = os.system("tar --exclude='*.root' --exclude='ignore' --exclude='.git' " + "-zcf " + jobName + ".tgz " + rel) + print 'Done!' + ret = os.system("mv " + jobName + ".tgz " + eosDir) + ret = os.chdir(rootDir) + ret = os.system("cp /tmp/x509up_u93529 /afs/cern.ch/user/x/xuyan/private/x509up/x509up_u93529") + proxy_path = "/afs/cern.ch/user/x/xuyan/private/x509up/x509up_u93529" + + file1 = open(fileList, 'r') + file_content = file1.readlines() + chunks = len(file_content) / files_batch + 1 + + ret = os.system("rm filelist_tmp_*.list") + for ichunk in range(chunks): + filelist_name = "filelist_tmp_%i.list" %(ichunk) + filelist_tmp = open(filelist_name, 'w') + for file in file_content[ichunk*files_batch:(ichunk+1)*files_batch]: + filelist_tmp.write(file) + filelist_tmp.close() + ret = os.system("tar -cvf filelist_" + jobName + ".tgz filelist_tmp_*") + + with open(jobDir + jobName + '.jdl', 'w') as jdl: + jdl.write("universe = vanilla\n") + jdl.write("Executable = " + jobScript + "\n") + jdl.write("Should_Transfer_Files = YES\n") + jdl.write("WhenToTransferOutput = ON_EXIT\n") + jdl.write("Transfer_Input_Files = " + jobScript + ", " + jobCfg + ", filelist_" + jobName + ".tgz" + "\n") + jdl.write("Output = " + jobDir + "out/$(ProcId).out\n") + jdl.write("Error = " + jobDir + "err/$(ProcId).err\n") + jdl.write("Log = " + jobDir + "log/$(ProcId).log\n") + jdl.write("Arguments = " + eosDir + " " + jobName + " " + rel + " $(ProcId) " + jobCfg + " filelist_tmp_$(ProcId).list " + proxy_path + " " + isMC +"\n") + jdl.write("MY.WantOS = \"el7\"\n") + jdl.write("+JobFlavour = " + "\"tomorrow\"" + "\n") + # jdl.write("+MaxRuntime = 28800\n") + # jdl.write("on_exit_remove = (ExitBySignal == False) && (ExitCode == 0)\n") + # jdl.write("max_retries = 3\n") + # jdl.write("requirements = Machine =!= LastRemoteHost\n") + jdl.write("Queue " + str(chunks) + "\n") + + os.system("condor_submit " + jobDir + jobName + ".jdl") + print str(chunks) + " jobs submitted." + os.system("condor_q") \ No newline at end of file diff --git a/BParkingNano/production/condor/filelist_BuToKJPsi.tgz b/BParkingNano/production/condor/filelist_BuToKJPsi.tgz new file mode 100644 index 00000000000..576583fed01 Binary files /dev/null and b/BParkingNano/production/condor/filelist_BuToKJPsi.tgz differ diff --git a/BParkingNano/production/condor/filelist_DataF.tgz b/BParkingNano/production/condor/filelist_DataF.tgz new file mode 100644 index 00000000000..010fb7ab305 Binary files /dev/null and b/BParkingNano/production/condor/filelist_DataF.tgz differ diff --git a/BParkingNano/production/condor/run_nano_cfg.py b/BParkingNano/production/condor/run_nano_cfg.py new file mode 100644 index 00000000000..3fa34e015d3 --- /dev/null +++ b/BParkingNano/production/condor/run_nano_cfg.py @@ -0,0 +1,251 @@ +from FWCore.ParameterSet.VarParsing import VarParsing +import FWCore.ParameterSet.Config as cms + +options = VarParsing('python') + +options.register('isMC', True, + VarParsing.multiplicity.singleton, + VarParsing.varType.bool, + "Run this on real data" +) +options.register('globalTag', 'NOTSET', + VarParsing.multiplicity.singleton, + VarParsing.varType.string, + "Set global tag" +) +options.register('wantSummary', True, + VarParsing.multiplicity.singleton, + VarParsing.varType.bool, + "Run this on real data" +) +options.register('wantFullRECO', False, + VarParsing.multiplicity.singleton, + VarParsing.varType.bool, + "Run this on real data" +) +options.register('reportEvery', 10000, + VarParsing.multiplicity.singleton, + VarParsing.varType.int, + "report every N events" +) +options.register('skip', 0, + VarParsing.multiplicity.singleton, + VarParsing.varType.int, + "skip first N events" +) +options.register('lhcRun', 3, + VarParsing.multiplicity.singleton, + VarParsing.varType.int, + "LHC Run 2 or 3 (default)" +) + +options.setDefault('maxEvents', -1) +options.setDefault('tag', '124X') +options.parseArguments() +print(options) + +globaltag = None +if options.lhcRun == 3: globaltag = '124X_mcRun3_2022_realistic_v11' if options.isMC else '124X_dataRun3_Prompt_v4' +elif options.lhcRun == 2: globaltag = '102X_upgrade2018_realistic_v15' if options.isMC else '102X_dataRun2_v11' +if options._beenSet['globalTag']: globaltag = options.globalTag + +ext1 = {2:'Run2', 3:'Run3'} +ext2 = {False:'data', True:'mc'} +outputFileNANO = cms.untracked.string('_'.join(['BParkingNANO', + ext1[options.lhcRun], + ext2[options.isMC], + options.tag])+'.root') +outputFileFEVT = cms.untracked.string('_'.join(['BParkingFullEvt', + ext1[options.lhcRun], + ext2[options.isMC], + options.tag])+'.root') +if not options.inputFiles: + if options.lhcRun == 2: + options.inputFiles = [ + 'file:///eos/cms/store/cmst3/group/bpark/BToKmumu_1000Events_MINIAOD.root' + ] if options.isMC else [ + 'root://cms-xrd-global.cern.ch//store/data/Run2018B/ParkingBPH4/MINIAOD/05May2019-v2/230000/6B5A24B1-0E6E-504B-8331-BD899EB60110.root' + ] + elif options.lhcRun == 3: + options.inputFiles = [ + 'file:/eos/home-x/xuyan/RKProj/RKAnalyzer/KStarllStudy/BToKEE_signal.root', + ] if options.isMC else [ + 'file:/eos/home-x/xuyan/RKProj/RKAnalyzer/KStarllStudy/BToKEE_signal.root' + ] +annotation = '%s nevts:%d' % (outputFileNANO, options.maxEvents) + +# Process +from Configuration.StandardSequences.Eras import eras +from PhysicsTools.BParkingNano.modifiers_cff import * +process = None +if options.lhcRun == 3: process = cms.Process('BParkNANO',eras.Run3,BToKEE_DiEle) +elif options.lhcRun == 2: process = cms.Process('BParkNANO',eras.Run2_2018) + +# import of standard configurations +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load("Configuration.StandardSequences.MagneticField_cff") +process.load('PhysicsTools.BParkingNano.nanoBPark_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.MessageLogger.cerr.FwkReport.reportEvery = options.reportEvery +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(options.maxEvents) +) + +# Input source +process.source = cms.Source( + "PoolSource", + fileNames = cms.untracked.vstring(options.inputFiles), + secondaryFileNames = cms.untracked.vstring(), + skipEvents=cms.untracked.uint32(options.skip), +) + +process.options = cms.untracked.PSet( + wantSummary = cms.untracked.bool(options.wantSummary), +) + +process.nanoMetadata.strings.tag = annotation +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string(annotation), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-RECO'), + filterName = cms.untracked.string('') + ), + fileName = outputFileFEVT, + outputCommands = (cms.untracked.vstring('keep *', + 'drop *_*_SelectedTransient*_*', + )), + splitLevel = cms.untracked.int32(0) +) + +process.NANOAODoutput = cms.OutputModule("NanoAODOutputModule", + compressionAlgorithm = cms.untracked.string('LZMA'), + compressionLevel = cms.untracked.int32(9), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('NANOAOD'), + filterName = cms.untracked.string('') + ), + fileName = outputFileNANO, + outputCommands = cms.untracked.vstring( + 'drop *', + "keep nanoaodFlatTable_*Table_*_*", # event data + "keep nanoaodUniqueString_nanoMetadata_*_*", # basic metadata + ) + +) + + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, globaltag, '') + +from PhysicsTools.BParkingNano.nanoBPark_cff import * +if options.lhcRun == 2: + process = nanoAOD_customizeMuonTriggerBPark(process) + process = nanoAOD_customizeElectronFilteredBPark(process) + process = nanoAOD_customizeTrackFilteredBPark(process) + process = nanoAOD_customizeBToKLL(process) + process = nanoAOD_customizeBToKstarEE(process) + process = nanoAOD_customizeBToKstarMuMu(process) +elif options.lhcRun == 3: + from PhysicsTools.BParkingNano.electronsTrigger_cff import * + process = nanoAOD_customizeDiEle(process) + process = nanoAOD_customizeElectronFilteredBPark(process) + process = nanoAOD_customizeTriggerBitsBPark(process) + process = nanoAOD_customizeTrackFilteredBPark(process) + process = nanoAOD_customizeBToKLL(process) + process = nanoAOD_customizeBToKstarEE(process) + +# Path and EndPath definitions +if options.lhcRun == 2: + process.nanoAOD_KMuMu_step = cms.Path(process.nanoSequence + process.nanoTracksSequence + process.nanoBKMuMuSequence + CountBToKmumu ) + process.nanoAOD_Kee_step = cms.Path(process.nanoSequence + process.nanoTracksSequence + process.nanoBKeeSequence + CountBToKee ) + process.nanoAOD_KstarMuMu_step = cms.Path(process.nanoSequence + process.nanoTracksSequence + process.KstarToKPiSequence + process.nanoBKstarMuMuSequence + CountBToKstarMuMu ) + process.nanoAOD_KstarEE_step = cms.Path(process.nanoSequence + process.nanoTracksSequence + process.KstarToKPiSequence + process.nanoBKstarEESequence + CountBToKstarEE ) +elif options.lhcRun == 3: + process.nanoAOD_DiEle_step = cms.Path(process.nanoSequence + +process.nanoDiEleSequence + +process.nanoTracksSequence + +process.nanoBKeeSequence + +CountBToKee + +process.nanoBKstarEESequence + +CountBToKstarEE) + +# customisation of the process. +if options.isMC: + from PhysicsTools.BParkingNano.nanoBPark_cff import nanoAOD_customizeMC + nanoAOD_customizeMC(process) + +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) +process.NANOAODoutput_step = cms.EndPath(process.NANOAODoutput) + +# Schedule definition +if options.lhcRun == 3: + + process.schedule = cms.Schedule(process.nanoAOD_DiEle_step, + process.endjob_step, + process.NANOAODoutput_step) + if options.wantFullRECO: + process.schedule = cms.Schedule(process.nanoAOD_DiEle_step, + process.endjob_step, + process.FEVTDEBUGHLToutput_step, + process.NANOAODoutput_step) + from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask + associatePatAlgosToolsTask(process) + process.NANOAODoutput.SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('nanoAOD_DiEle_step') + ) + +elif options.lhcRun == 2: + + process.schedule = cms.Schedule( + process.nanoAOD_KMuMu_step, + process.nanoAOD_Kee_step, + #process.nanoAOD_KstarMuMu_step, + #process.nanoAOD_KstarEE_step, + process.endjob_step, + process.NANOAODoutput_step + ) + if options.wantFullRECO: + process.schedule = cms.Schedule( + process.nanoAOD_KMuMu_step, + process.nanoAOD_Kee_step, + #process.nanoAOD_KstarMuMu_step, + #process.nanoAOD_KstarEE_step, + process.endjob_step, + process.FEVTDEBUGHLToutput_step, + process.NANOAODoutput_step + ) + from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask + associatePatAlgosToolsTask(process) + process.NANOAODoutput.SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring( + 'nanoAOD_KMuMu_step', + 'nanoAOD_Kee_step', + #'nanoAOD_KstarMuMu_step', + #'nanoAOD_KstarEE_step', + ) + ) + +### from https://hypernews.cern.ch/HyperNews/CMS/get/physics-validation/3287/1/1/1/1/1.html +process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False))) +process.NANOAODoutput.fakeNameForCrab=cms.untracked.bool(True) + +process.load("TrackingTools/TransientTrack/TransientTrackBuilder_cfi") +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) diff --git a/BParkingNano/production/condor/xuyan.cc b/BParkingNano/production/condor/xuyan.cc new file mode 100644 index 00000000000..fa70d344049 Binary files /dev/null and b/BParkingNano/production/condor/xuyan.cc differ diff --git a/BParkingNano/production/crab/resubmit_on_crab.py b/BParkingNano/production/crab/resubmit_on_crab.py new file mode 100644 index 00000000000..670fb7af3ab --- /dev/null +++ b/BParkingNano/production/crab/resubmit_on_crab.py @@ -0,0 +1,5 @@ +import os + +for job in os.listdir("/afs/cern.ch/work/x/xuyan/RKProj/BParkingNanoOfficial/CMSSW_13_1_0/src/PhysicsTools/BParkingNano/production/crab/BParkingNANO_2024May02"): + print(job) + os.system(f"crab resubmit BParkingNANO_2024May02/{job}") diff --git a/BParkingNano/production/crab/run.sh b/BParkingNano/production/crab/run.sh new file mode 100755 index 00000000000..a069e2d349d --- /dev/null +++ b/BParkingNano/production/crab/run.sh @@ -0,0 +1,36 @@ +# Uncommented as required ... +# python3 submit_on_crab.py --filter=Run2022C_part* #Noah +# python3 submit_on_crab.py --filter=Run2022Dv1_part* #Noah +# python3 submit_on_crab.py --filter=Run2022Dv2_part* #Noah +# python3 submit_on_crab.py --filter=Run2022E_part* #Sebastian +# python3 submit_on_crab.py --filter=Run2022F_part* #Sebastian +# python3 submit_on_crab.py --filter=Run2022G_part* #Sebastian + +# python3 submit_on_crab.py --filter=BuToKee_v1_preEE # Jay +# python3 submit_on_crab.py --filter=BuToKee_v1_postEE # Jay +# python3 submit_on_crab.py --filter=BuToKJpsi_Toee_v1_preEE # Jay +# python3 submit_on_crab.py --filter=BuToKJpsi_Toee_v1_postEE # Jay +# python3 submit_on_crab.py --filter=BuToKPsi2S_Toee_v1_preEE # Jay +# python3 submit_on_crab.py --filter=BuToKPsi2S_Toee_v1_postEE # Jay + +# python3 submit_on_crab.py --filter=BdToK0starEE_v1_preEE # George +# python3 submit_on_crab.py --filter=BdToK0starEE_v1_postEE # George +# python3 submit_on_crab.py --filter=BdToK0starJpsi_Toee_v1_preEE # George +# python3 submit_on_crab.py --filter=BdToK0starJpsi_Toee_v1_postEE # George +# python3 submit_on_crab.py --filter=BdToK0starPsi2S_Toee_v1_preEE # George +# python3 submit_on_crab.py --filter=BdToK0starPsi2S_Toee_v1_postEE # George + +# python3 submit_on_crab.py --filter=BuToKstarEE_v1_preEE # Claudio +# python3 submit_on_crab.py --filter=BuToKstarEE_v1_postEE # Claudio +# python3 submit_on_crab.py --filter=BuToKstarJpsi_Toee_v1_preEE # Claudio +# python3 submit_on_crab.py --filter=BuToKstarJpsi_Toee_v1_postEE # Claudio +# python3 submit_on_crab.py --filter=BuToKstarPsi2S_Toee_v1_preEE # Claudio +# python3 submit_on_crab.py --filter=BuToKstarPsi2S_Toee_v1_postEE # Claudio + +# python3 submit_on_crab.py --filter=BdToK0starEE_MiniAODv4_preEE #Sebastian +# python3 submit_on_crab.py --filter=BdToK0starEE_MiniAODv4_postEE #Sebastian +# python3 submit_on_crab.py --filter=BdToK0starEE_MiniAODv4_ext1_preEE #Sebastian +# python3 submit_on_crab.py --filter=BdToK0starEE_MiniAODv4_ext1_postEE #Sebastian + +python3 submit_on_crab.py --filter=BuToKee_2023 #Sebastian + diff --git a/BParkingNano/production/samples.yml b/BParkingNano/production/crab/samples.yml similarity index 100% rename from BParkingNano/production/samples.yml rename to BParkingNano/production/crab/samples.yml diff --git a/BParkingNano/production/crab/samples_Run3.yml b/BParkingNano/production/crab/samples_Run3.yml new file mode 100644 index 00000000000..9ca75aac951 --- /dev/null +++ b/BParkingNano/production/crab/samples_Run3.yml @@ -0,0 +1,196 @@ +common: + data: + splitting: 20 + globaltag: 124X_dataRun3_Prompt_v4 + lumimask: https://cms-service-dqmdc.web.cern.ch/CAF/certification/Collisions22/Cert_Collisions2022_355100_362760_Golden.json + mc: + splitting: 1 + globaltag: 124X_mcRun3_2022_realistic_v11 +samples: + Run2022C_part%d: + dataset: /ParkingDoubleElectronLowMass%d/Run2022C-PromptReco-v1/MINIAOD + isMC: False + parts: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + Run2022Dv1_part%d: + dataset: /ParkingDoubleElectronLowMass%d/Run2022D-PromptReco-v1/MINIAOD + isMC: False + parts: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + Run2022Dv2_part%d: + dataset: /ParkingDoubleElectronLowMass%d/Run2022D-PromptReco-v2/MINIAOD + isMC: False + parts: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + Run2022E_part%d: + dataset: /ParkingDoubleElectronLowMass%d/Run2022E-PromptReco-v1/MINIAOD + isMC: False + parts: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + Run2022F_part%d: + dataset: /ParkingDoubleElectronLowMass%d/Run2022F-PromptReco-v1/MINIAOD + isMC: False + parts: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + Run2022G_part%d: + dataset: /ParkingDoubleElectronLowMass%d/Run2022G-PromptReco-v1/MINIAOD + isMC: False + parts: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + BuToKee_PU0: + dataset: /BuTOKEE20220826bettersplitting/jodedra-SUMMER22_MINIAOD-d5db235e2a58bcae594a314d29cbde75/USER + isMC: True + dbs: phys03 + BuToKJpsi_Toee_PU0: + dataset: /BuTOjpsiKEE20220831fiftyMbettersplitting/jodedra-SUMMER22_MINIAOD-d5db235e2a58bcae594a314d29cbde75/USER + isMC: True + dbs: phys03 + BuToKPsi2S_Toee_PU0: + dataset: /BuTOpsi2sKEE20220831fiftyMbettersplitting/jodedra-SUMMER22_MINIAOD-d5db235e2a58bcae594a314d29cbde75/USER + isMC: True + dbs: phys03 + BuToKee: + dataset: /BuTOKEE20221103FIFTYM/jodedra-SUMMER22_MINIAOD-8da3c779fd247f42d8411cf96207b146/USER + isMC: True + dbs: phys03 + BuToKJpsi_Toee: + dataset: /BuTOjpsiKEE20221103FIFTYM/jodedra-SUMMER22_MINIAOD-8da3c779fd247f42d8411cf96207b146/USER + isMC: True + dbs: phys03 + BuToKPsi2S_Toee: + dataset: /BuTOpsi2sKEE20221103FIFTYM/jodedra-SUMMER22_MINIAOD-8da3c779fd247f42d8411cf96207b146/USER + isMC: True + dbs: phys03 + + BuToKee_v1_preEE: + dataset: /BuToKEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv3-124X_mcRun3_2022_realistic_v12-v2/MINIAODSIM + isMC: True + dbs: global + BuToKee_v1_postEE: + dataset: /BuToKEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv3-124X_mcRun3_2022_realistic_postEE_v1-v2/MINIAODSIM + isMC: True + dbs: global + BuToKee_2023: + dataset: /BuToKEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer23MiniAODv4-130X_mcRun3_2023_realistic_v14-v3/MINIAODSIM + isMC: True + dbs: global + + BuToKJpsi_Toee_v1_preEE: + dataset: /BuToKJPsi_JPsiToEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv3-124X_mcRun3_2022_realistic_v12-v2/MINIAODSIM + isMC: True + dbs: global + BuToKJpsi_Toee_v1_postEE: + dataset: /BuToKJPsi_JPsiToEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv3-124X_mcRun3_2022_realistic_postEE_v1-v2/MINIAODSIM + isMC: True + dbs: global + + BuToKPsi2S_Toee_v1_preEE: + dataset: /BuToKPsi2s_Psi2sToEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv3-124X_mcRun3_2022_realistic_v12-v2/MINIAODSIM + isMC: True + dbs: global + BuToKPsi2S_Toee_v1_postEE: + dataset: /BuToKPsi2s_Psi2sToEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv3-124X_mcRun3_2022_realistic_postEE_v1-v2/MINIAODSIM + isMC: True + dbs: global + + BdToK0starEE_v1_preEE: + dataset: /BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv3-124X_mcRun3_2022_realistic_v12-v2/MINIAODSIM + isMC: True + dbs: global + BdToK0starEE_v1_postEE: + dataset: /BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv3-124X_mcRun3_2022_realistic_postEE_v1-v2/MINIAODSIM + isMC: True + dbs: global + + BdToK0starEE_MiniAODv4_preEE: + dataset: /BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv4-130X_mcRun3_2022_realistic_v5-v2/MINIAODSIM + isMC: True + dbs: global + BdToK0starEE_MiniAODv4_postEE: + dataset: /BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv4-130X_mcRun3_2022_realistic_postEE_v6-v2/MINIAODSIM + isMC: True + dbs: global + + BdToK0starEE_MiniAODv4_ext1_preEE: + dataset: /BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv4-130X_mcRun3_2022_realistic_v5_ext1-v2/MINIAODSIM + isMC: True + dbs: global + BdToK0starEE_MiniAODv4_ext1_postEE: + dataset: /BdToK0starEE_K0starToKPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv4-130X_mcRun3_2022_realistic_postEE_v6_ext1-v2/MINIAODSIM + isMC: True + dbs: global + + BdToK0starJpsi_Toee_v1_preEE: + dataset: /BdToK0starJPsi_K0starToKPi_JPsiToEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv3-124X_mcRun3_2022_realistic_v12-v2/MINIAODSIM + isMC: True + dbs: global + BdToK0starJpsi_Toee_v1_postEE: + dataset: /BdToK0starJPsi_K0starToKPi_JPsiToEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv3-124X_mcRun3_2022_realistic_postEE_v1-v2/MINIAODSIM + isMC: True + dbs: global + + BdToK0starPsi2S_Toee_v1_preEE: + dataset: /BdToK0starPsi2s_K0starToKPi_Psi2sToEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv3-124X_mcRun3_2022_realistic_v12-v2/MINIAODSIM + isMC: True + dbs: global + BdToK0starPsi2S_Toee_v1_postEE: + dataset: /BdToK0starPsi2s_K0starToKPi_Psi2sToEE_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv3-124X_mcRun3_2022_realistic_postEE_v1-v2/MINIAODSIM + isMC: True + dbs: global + + BuToKstarEE_v1_preEE: + dataset: /BuToKstarEE_KstarToK0Pi_K0ToPiPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv3-124X_mcRun3_2022_realistic_v12-v2/MINIAODSIM + isMC: True + dbs: global + BuToKstarEE_v1_postEE: + dataset: /BuToKstarEE_KstarToK0Pi_K0ToPiPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv3-124X_mcRun3_2022_realistic_postEE_v1-v2/MINIAODSIM + isMC: True + dbs: global + + BuToKstarJpsi_Toee_v1_preEE: + dataset: /BuToKstarJPsi_KstarToK0Pi_JPsiToEE_K0ToPiPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv3-124X_mcRun3_2022_realistic_v12-v2/MINIAODSIM + isMC: True + dbs: global + BuToKstarJpsi_Toee_v1_postEE: + dataset: /BuToKstarJPsi_KstarToK0Pi_JPsiToEE_K0ToPiPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv3-124X_mcRun3_2022_realistic_postEE_v1-v2/MINIAODSIM + isMC: True + dbs: global + + BuToKstarPsi2S_Toee_v1_preEE: + dataset: /BuToKstarPsi2s_KstarToK0Pi_Psi2sToEE_K0ToPiPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22MiniAODv3-124X_mcRun3_2022_realistic_v12-v2/MINIAODSIM + isMC: True + dbs: global + BuToKstarPsi2S_Toee_v1_postEE: + dataset: /BuToKstarPsi2s_KstarToK0Pi_Psi2sToEE_K0ToPiPi_SoftQCD_TuneCP5_13p6TeV_pythia8-evtgen/Run3Summer22EEMiniAODv3-124X_mcRun3_2022_realistic_postEE_v1-v2/MINIAODSIM + isMC: True + dbs: global diff --git a/BParkingNano/production/samples_Run3.yml b/BParkingNano/production/crab/samples_Run3_resub.yml similarity index 100% rename from BParkingNano/production/samples_Run3.yml rename to BParkingNano/production/crab/samples_Run3_resub.yml diff --git a/BParkingNano/production/submit_on_crab.py b/BParkingNano/production/crab/submit_on_crab.py similarity index 96% rename from BParkingNano/production/submit_on_crab.py rename to BParkingNano/production/crab/submit_on_crab.py index a9738a5866f..b01b967da8e 100644 --- a/BParkingNano/production/submit_on_crab.py +++ b/BParkingNano/production/crab/submit_on_crab.py @@ -1,4 +1,4 @@ -from CRABClient.UserUtilities import config, ClientException, getUsernameFromCRIC +from CRABClient.UserUtilities import config, ClientException import yaml import datetime from fnmatch import fnmatch @@ -19,7 +19,7 @@ config.section_('JobType') config.JobType.pluginName = 'Analysis' -config.JobType.psetName = '../test/run_nano_cfg.py' +config.JobType.psetName = '../../test/run_nano_cfg.py' config.JobType.maxJobRuntimeMin = 3000 config.JobType.allowUndistributedCMSSW = True diff --git a/BParkingNano/production/run.sh b/BParkingNano/production/run.sh deleted file mode 100644 index 8a8c0349de7..00000000000 --- a/BParkingNano/production/run.sh +++ /dev/null @@ -1,30 +0,0 @@ -# Uncommented as required ... -#python3 submit_on_crab.py --filter=Run2022C_part* #Noah -#python3 submit_on_crab.py --filter=Run2022Dv1_part* #Noah -#python3 submit_on_crab.py --filter=Run2022Dv2_part* #Noah - -#python3 submit_on_crab.py --filter=Run2022E_part* #Sebastian -#python3 submit_on_crab.py --filter=Run2022F_part* #Sebastian -#python3 submit_on_crab.py --filter=Run2022G_part* #Sebastian - -#python3 submit_on_crab.py --filter=BuToKee_v1_preEE # Jay -#python3 submit_on_crab.py --filter=BuToKee_v1_postEE # Jay -#python3 submit_on_crab.py --filter=BuToKJpsi_Toee_v1_preEE # Jay -#python3 submit_on_crab.py --filter=BuToKJpsi_Toee_v1_postEE # Jay -#python3 submit_on_crab.py --filter=BuToKPsi2S_Toee_v1_preEE # Jay -#python3 submit_on_crab.py --filter=BuToKPsi2S_Toee_v1_postEE # Jay - -#python3 submit_on_crab.py --filter=BdToK0starEE_v1_preEE # George -#python3 submit_on_crab.py --filter=BdToK0starEE_v1_postEE # George -#python3 submit_on_crab.py --filter=BdToK0starJpsi_Toee_v1_preEE # George -#python3 submit_on_crab.py --filter=BdToK0starJpsi_Toee_v1_postEE # George -#python3 submit_on_crab.py --filter=BdToK0starPsi2S_Toee_v1_preEE # George -#python3 submit_on_crab.py --filter=BdToK0starPsi2S_Toee_v1_postEE # George - -#python3 submit_on_crab.py --filter=BuToKstarEE_v1_preEE # Claudio -#python3 submit_on_crab.py --filter=BuToKstarEE_v1_postEE # Claudio -#python3 submit_on_crab.py --filter=BuToKstarJpsi_Toee_v1_preEE # Claudio -#python3 submit_on_crab.py --filter=BuToKstarJpsi_Toee_v1_postEE # Claudio -#python3 submit_on_crab.py --filter=BuToKstarPsi2S_Toee_v1_preEE # Claudio -#python3 submit_on_crab.py --filter=BuToKstarPsi2S_Toee_v1_postEE # Claudio - diff --git a/BParkingNano/python/BToKLL_cff.py b/BParkingNano/python/BToKLL_cff.py index 7af8917690e..d33c1693068 100644 --- a/BParkingNano/python/BToKLL_cff.py +++ b/BParkingNano/python/BToKLL_cff.py @@ -103,7 +103,7 @@ pre_vtx_sel = Var("userInt('pre_vtx_sel')", bool, doc="Satisfies pre-vertexing selections?"), post_vtx_sel = Var("userInt('post_vtx_sel')", bool, doc="Satisfies post-vertexing selections?"), # fit and vtx info - #chi2 = ufloat('sv_chi2'), + chi2 = ufloat('sv_chi2'), svprob = ufloat('sv_prob'), l_xy = ufloat('l_xy'), l_xy_unc = ufloat('l_xy_unc'), @@ -115,6 +115,7 @@ vtx_ez = ufloat('vtx_ez'), # Mll mll_raw = Var('userCand("dilepton").mass()', float), + mll_charge = Var('userCand("dilepton").charge()', float), mll_llfit = Var('userCand("dilepton").userFloat("fitted_mass")', float), # this might not work mllErr_llfit = Var('userCand("dilepton").userFloat("fitted_massErr")', float), # this might not work mll_fullfit = ufloat('fitted_mll'), @@ -193,7 +194,7 @@ CountBToKee = cms.EDFilter("PATCandViewCountFilter", minNumber = cms.uint32(1), - maxNumber = cms.uint32(999999), + maxNumber = cms.uint32(99999999), src = cms.InputTag("BToKee") ) CountBToKmumu = CountBToKee.clone( diff --git a/BParkingNano/python/BToKstarLL_cff.py b/BParkingNano/python/BToKstarLL_cff.py index ccb32a67880..22d5f43523b 100644 --- a/BParkingNano/python/BToKstarLL_cff.py +++ b/BParkingNano/python/BToKstarLL_cff.py @@ -1,84 +1,90 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.BParkingNano.common_cff import * - -########## inputs preparation ################ electronPairsForKstarEE = cms.EDProducer( 'DiElectronBuilder', src = cms.InputTag('electronsForAnalysis', 'SelectedElectrons'), transientTracksSrc = cms.InputTag('electronsForAnalysis', 'SelectedTransientElectrons'), - lep1Selection = cms.string('pt > 1.5 && userFloat("unBiased") >= 3'), + lep1Selection = cms.string('pt > 1.3'), lep2Selection = cms.string(''), + filterBySelection = cms.bool(True), preVtxSelection = cms.string( 'abs(userCand("l1").vz - userCand("l2").vz) <= 1. && mass() < 5 ' - '&& mass() > 0 && charge() == 0 && userFloat("lep_deltaR") > 0.03' + '&& mass() > 0 && charge() == 0 && userFloat("lep_deltaR") > 0.03 && userInt("nlowpt") < 2' + ), postVtxSelection = cms.string('userFloat("sv_chi2") < 998 && userFloat("sv_prob") > 1.e-5'), ) -muonPairsForKstarMuMu = cms.EDProducer( - 'DiMuonBuilder', - src = cms.InputTag('muonTrgSelector', 'SelectedMuons'), - transientTracksSrc = cms.InputTag('muonTrgSelector', 'SelectedTransientMuons'), - lep1Selection = cms.string('pt > 1.5'), - lep2Selection = cms.string(''), - preVtxSelection = cms.string('abs(userCand("l1").vz - userCand("l2").vz) <= 1. && mass() < 5 ' - '&& mass() > 0 && charge() == 0 && userFloat("lep_deltaR") > 0.03'), - postVtxSelection = electronPairsForKstarEE.postVtxSelection, -) - KstarToKPi = cms.EDProducer( 'KstarBuilder', pfcands= cms.InputTag('tracksBPark', 'SelectedTracks'), transientTracks= cms.InputTag('tracksBPark', 'SelectedTransientTracks'), - trk1Selection = cms.string('pt > 1.5 && abs(eta)<2.4'), #need optimization - trk2Selection = cms.string('pt > 1.0 && abs(eta)<2.4'), #need optimization - preVtxSelection = cms.string('abs(userCand("trk1").vz - userCand("trk2").vz)<1.0' - ' && pt()>2.0 && ( (mass() < 1.042 && mass() > 0.742)' - ' || (userFloat("barMass") < 1.042 && userFloat("barMass") > 0.742) ) ' + trk1Selection = cms.string('pt > 0.5 && abs(eta) < 2.5'), #need optimization + trk2Selection = cms.string('pt > 0.5 && abs(eta) < 2.5'), #need optimization + preVtxSelection = cms.string('abs(userCand("trk1").vz - userCand("trk2").vz) < 1.0' + ' && pt() > 2.0 && ( (mass() < 1.2 && mass() > 0.6)' + ' || (userFloat("barMass") < 1.2 && userFloat("barMass") > 0.6) ) ' ), postVtxSelection = cms.string('userFloat("sv_prob") > 1.e-5' - ' && ( (userFloat("fitted_mass")<1.042 && userFloat("fitted_mass")>0.742)' - ' || (userFloat("fitted_barMass")<1.042 && userFloat("fitted_barMass")>0.742) )' -) + ' && ( (userFloat("fitted_mass") < 1.042 && userFloat("fitted_mass") > 0.742)' + ' || (userFloat("fitted_barMass") < 1.042 && userFloat("fitted_barMass") > 0.742) )' + ) ) - - -########################### B-> K* ll ########################## -BToKstarMuMu = cms.EDProducer( +BToKstarEE = cms.EDProducer( 'BToKstarLLBuilder', - dileptons = cms.InputTag('muonPairsForKstarMuMu', 'SelectedDiLeptons'), - leptonTransientTracks = muonPairsForKstarMuMu.transientTracksSrc, + dileptons = cms.InputTag('electronPairsForKstarEE', 'SelectedDiLeptons'), + dileptonKinVtxs = cms.InputTag('electronPairsForKee', 'SelectedDiLeptonKinVtxs'), + leptonTransientTracks = electronPairsForKstarEE.transientTracksSrc, + beamSpot = cms.InputTag("offlineBeamSpot"), + offlinePrimaryVertexSrc = cms.InputTag('offlineSlimmedPrimaryVertices'), kstars = cms.InputTag('KstarToKPi'), kstarsTransientTracks = cms.InputTag('tracksBPark', 'SelectedTransientTracks'), + tracksTransientTracks = cms.InputTag('tracksBPark', 'SelectedTransientTracks'), + tracks_kpi = cms.InputTag('tracksBPark', 'SelectedTracks'), tracks = cms.InputTag("packedPFCandidates"), lostTracks = cms.InputTag("lostTracks"), - isoTracksSelection = cms.string('pt > 0.7 && abs(eta)<2.5'), - - beamSpot = cms.InputTag("offlineBeamSpot"), + isoTracksSelection = cms.string('pt > 0.5 && abs(eta)<2.5'), + isoTracksDCASelection = cms.string('pt > 0.5 && abs(eta)<2.5'), + isotrkDCACut = cms.double(1.0), + isotrkDCATightCut = cms.double(0.1), + drIso_cleaning = cms.double(0.03), + filterBySelection = cms.bool(True), preVtxSelection = cms.string( - 'pt > 3. && userFloat("min_dr") > 0.03' - '&& ( (mass < 7. && mass > 4.) ' - '|| (userFloat("barMass")<7. && userFloat("barMass")>4.) )' + 'pt > 1.75 && userFloat("min_dr") > 0.03' + '&& ( (mass < 8. && mass > 3.) ' + '|| (userFloat("barMass") < 8. && userFloat("barMass") > 3.) )' ), postVtxSelection = cms.string( - 'userFloat("sv_prob") > 0.001 ' - '&& userFloat("fitted_cos_theta_2D") >= 0' - '&& ( (userFloat("fitted_mass") > 4.5 && userFloat("fitted_mass") < 6.)' - '|| (userFloat("fitted_barMass") > 4.5 && userFloat("fitted_barMass") < 6.) )' + 'userFloat("sv_prob") > 1.e-5 ' + # '&& userFloat("fitted_cos_theta_2D") >= 0' + '&& ( (userFloat("fitted_mass") > 3.5 && userFloat("fitted_mass") < 7.)' + '|| (userFloat("fitted_barMass") > 3.5 && userFloat("fitted_barMass") < 7.) )' ) ) -BToKstarEE = cms.EDProducer( +muonPairsForKstarMuMu = cms.EDProducer( + 'DiMuonBuilder', + src = cms.InputTag('muonTrgSelector', 'SelectedMuons'), + transientTracksSrc = cms.InputTag('muonTrgSelector', 'SelectedTransientMuons'), + lep1Selection = cms.string('pt > 1.5'), + lep2Selection = cms.string(''), + preVtxSelection = cms.string('abs(userCand("l1").vz - userCand("l2").vz) <= 1. && mass() < 5 ' + '&& mass() > 0 && charge() == 0 && userFloat("lep_deltaR") > 0.03'), + postVtxSelection = electronPairsForKstarEE.postVtxSelection, +) + + +BToKstarMuMu = cms.EDProducer( 'BToKstarLLBuilder', - dileptons = cms.InputTag('electronPairsForKstarEE', 'SelectedDiLeptons'), - leptonTransientTracks = electronPairsForKstarEE.transientTracksSrc, + dileptons = cms.InputTag('muonPairsForKstarMuMu', 'SelectedDiLeptons'), + leptonTransientTracks = muonPairsForKstarMuMu.transientTracksSrc, kstars = cms.InputTag('KstarToKPi'), kstarsTransientTracks = cms.InputTag('tracksBPark', 'SelectedTransientTracks'), tracks = cms.InputTag("packedPFCandidates"), lostTracks = cms.InputTag("lostTracks"), - isoTracksSelection = BToKstarMuMu.isoTracksSelection, + isoTracksSelection = cms.string('pt > 0.7 && abs(eta)<2.5'), beamSpot = cms.InputTag("offlineBeamSpot"), preVtxSelection = cms.string( @@ -144,8 +150,15 @@ svprob = ufloat('sv_prob'), l_xy = ufloat('l_xy'), l_xy_unc = ufloat('l_xy_unc'), + vtx_x = ufloat('vtx_x'), + vtx_y = ufloat('vtx_y'), + vtx_z = ufloat('vtx_z'), + vtx_ex = ufloat('vtx_ex'), ## only saving diagonal elements of the cov matrix + vtx_ey = ufloat('vtx_ey'), + vtx_ez = ufloat('vtx_ez'), # Mll mll_raw = Var('userCand("dilepton").mass()', float), + mll_charge = Var('userCand("dilepton").charge()', float), mll_llfit = Var('userCand("dilepton").userFloat("fitted_mass")', float), mll_fullfit = ufloat('fitted_mll'), # kstar fitted in b0 vertex @@ -179,21 +192,64 @@ fit_trk1_pt = ufloat('fitted_trk1_pt'), fit_trk1_eta = ufloat('fitted_trk1_eta'), fit_trk1_phi = ufloat('fitted_trk1_phi'), + trk1_svip2d = ufloat('trk1_svip2d'), + trk1_svip2d_err = ufloat('trk1_svip2d_err'), + trk1_svip3d = ufloat('trk1_svip3d'), + trk1_svip3d_err = ufloat('trk1_svip3d_err'), #trk2 fit_trk2_pt = ufloat('fitted_trk2_pt'), fit_trk2_eta = ufloat('fitted_trk2_eta'), - fit_trk2_phi = ufloat('fitted_trk2_phi'), + fit_trk2_phi = ufloat('fitted_trk2_phi'), + trk2_svip2d = ufloat('trk2_svip2d'), + trk2_svip2d_err = ufloat('trk2_svip2d_err'), + trk2_svip3d = ufloat('trk2_svip3d'), + trk2_svip3d_err = ufloat('trk2_svip3d_err'), # isolation l1_iso03 = ufloat('l1_iso03'), l1_iso04 = ufloat('l1_iso04'), l2_iso03 = ufloat('l2_iso03'), l2_iso04 = ufloat('l2_iso04'), - tk1_iso03 = ufloat('tk1_iso03'), - tk1_iso04 = ufloat('tk1_iso04'), - tk2_iso03 = ufloat('tk2_iso03'), - tk2_iso04 = ufloat('tk2_iso04'), + trk1_iso03 = ufloat('trk1_iso03'), + trk1_iso04 = ufloat('trk1_iso04'), + trk2_iso03 = ufloat('trk2_iso03'), + trk2_iso04 = ufloat('trk2_iso04'), b_iso03 = ufloat('b_iso03'), b_iso04 = ufloat('b_iso04'), + l1_n_isotrk = uint('l1_n_isotrk'), + l2_n_isotrk = uint('l2_n_isotrk'), + trk1_n_isotrk = uint('trk1_n_isotrk'), + trk2_n_isotrk = uint('trk2_n_isotrk'), + b_n_isotrk = uint('b_n_isotrk'), + l1_iso03_dca = ufloat('l1_iso03_dca'), + l1_iso04_dca = ufloat('l1_iso04_dca'), + l2_iso03_dca = ufloat('l2_iso03_dca'), + l2_iso04_dca = ufloat('l2_iso04_dca'), + trk1_iso03_dca = ufloat('trk1_iso03_dca'), + trk1_iso04_dca = ufloat('trk1_iso04_dca'), + trk2_iso03_dca = ufloat('trk2_iso03_dca'), + trk2_iso04_dca = ufloat('trk2_iso04_dca'), + b_iso03_dca = ufloat('b_iso03_dca'), + b_iso04_dca = ufloat('b_iso04_dca'), + l1_n_isotrk_dca = uint('l1_n_isotrk_dca'), + l2_n_isotrk_dca = uint('l2_n_isotrk_dca'), + trk1_n_isotrk_dca = uint('trk1_n_isotrk_dca'), + trk2_n_isotrk_dca = uint('trk2_n_isotrk_dca'), + b_n_isotrk_dca = uint('b_n_isotrk_dca'), + l1_iso03_dca_tight = ufloat('l1_iso03_dca_tight'), + l1_iso04_dca_tight = ufloat('l1_iso04_dca_tight'), + l2_iso03_dca_tight = ufloat('l2_iso03_dca_tight'), + l2_iso04_dca_tight = ufloat('l2_iso04_dca_tight'), + trk1_iso03_dca_tight = ufloat('trk1_iso03_dca_tight'), + trk1_iso04_dca_tight = ufloat('trk1_iso04_dca_tight'), + trk2_iso03_dca_tight = ufloat('trk2_iso03_dca_tight'), + trk2_iso04_dca_tight = ufloat('trk2_iso04_dca_tight'), + b_iso03_dca_tight = ufloat('b_iso03_dca_tight'), + b_iso04_dca_tight = ufloat('b_iso04_dca_tight'), + l1_n_isotrk_dca_tight = uint('l1_n_isotrk_dca_tight'), + l2_n_isotrk_dca_tight = uint('l2_n_isotrk_dca_tight'), + trk1_n_isotrk_dca_tight = uint('trk1_n_isotrk_dca_tight'), + trk2_n_isotrk_dca_tight = uint('trk2_n_isotrk_dca_tight'), + b_n_isotrk_dca_tight = uint('b_n_isotrk_dca_tight'), ) ) @@ -204,12 +260,12 @@ ) CountBToKstarEE = cms.EDFilter("PATCandViewCountFilter", - minNumber = cms.uint32(1), - maxNumber = cms.uint32(999999), + minNumber = cms.uint32(0), + maxNumber = cms.uint32(99999999), src = cms.InputTag("BToKstarEE") ) CountBToKstarMuMu = CountBToKstarEE.clone( - minNumber = cms.uint32(1), + minNumber = cms.uint32(0), src = cms.InputTag("BToKstarMuMu") ) @@ -236,3 +292,22 @@ BToKstarLLTables = cms.Sequence( BToKstarEETable + BToKstarMuMuTable ) +########### +# Modifiers +########### + +from PhysicsTools.BParkingNano.modifiers_cff import * + +BToKstarEE_OpenConfig.toModify(electronPairsForKstarEE, + lep1Selection='pt > 0.5', + lep2Selection='', + filterBySelection=False) +BToKstarEE_OpenConfig.toModify(BToKstarEE, + kaonSelection='', + isoTracksSelection='pt > 0.5 && abs(eta)<2.5', + isoTracksDCASelection='pt > 0.5 && abs(eta)<2.5', + isotrkDCACut=0., + isotrkDCATightCut=0., + drIso_cleaning=0., + filterBySelection=False) +# BToKstarEE_OpenConfig.toModify(CountBToKstarEE,minNumber=0) \ No newline at end of file diff --git a/BParkingNano/python/modifiers_cff.py b/BParkingNano/python/modifiers_cff.py index e39bfe7dc83..1a8cdc84738 100644 --- a/BParkingNano/python/modifiers_cff.py +++ b/BParkingNano/python/modifiers_cff.py @@ -1,6 +1,9 @@ import FWCore.ParameterSet.Config as cms BToKMuMu_OpenConfig = cms.Modifier() +BToKMuMu_DiMuon = cms.Modifier() BToKEE_OpenConfig = cms.Modifier() BToKEE_DiEle = cms.Modifier() -BToKMuMu_DiMuon = cms.Modifier() +BToKstarEE_OpenConfig = cms.Modifier() +BToKstarEE_DiEle = cms.Modifier() + diff --git a/BParkingNano/python/nanoBPark_cff.py b/BParkingNano/python/nanoBPark_cff.py index 13c5d12678d..b4dd0c3f8d6 100644 --- a/BParkingNano/python/nanoBPark_cff.py +++ b/BParkingNano/python/nanoBPark_cff.py @@ -70,11 +70,11 @@ def nanoAOD_customizeBToKstarLL(process): return process def nanoAOD_customizeBToKstarEE(process): - process.nanoBKstarEESequence = cms.Sequence( process.nanoBKstarEESequence + BToKstarEESequence + BToKstarEETable + KstarToKPiTable ) + process.nanoBKstarEESequence = cms.Sequence( process.nanoBKstarEESequence + KstarToKPiSequence + BToKstarEESequence + BToKstarEETable + KstarToKPiTable ) return process def nanoAOD_customizeBToKstarMuMu(process): - process.nanoBKstarMuMuSequence = cms.Sequence( BToKstarMuMuSequence + BToKstarMuMuTable + KstarToKPiTable ) + process.nanoBKstarMuMuSequence = cms.Sequence( KstarToKPiSequence + BToKstarMuMuSequence + BToKstarMuMuTable + KstarToKPiTable ) return process from FWCore.ParameterSet.MassReplace import massSearchReplaceAnyInputTag diff --git a/BParkingNano/test/run_nano_cfg.py b/BParkingNano/test/run_nano_cfg.py index 1452cc283ba..024d4f7fb3e 100644 --- a/BParkingNano/test/run_nano_cfg.py +++ b/BParkingNano/test/run_nano_cfg.py @@ -23,7 +23,7 @@ VarParsing.varType.bool, "Run this on real data" ) -options.register('reportEvery', 10, +options.register('reportEvery', 10000, VarParsing.multiplicity.singleton, VarParsing.varType.int, "report every N events" @@ -39,7 +39,7 @@ "LHC Run 2 or 3 (default)" ) -options.setDefault('maxEvents', 1000) +options.setDefault('maxEvents', -1) options.setDefault('tag', '124X') options.parseArguments() print(options) @@ -68,9 +68,11 @@ ] elif options.lhcRun == 3: options.inputFiles = [ - 'root://cms-xrd-global.cern.ch//store/user/jodedra/BuTOjpsiKEE20221103FIFTYMminiaod/BuTOjpsiKEE20221103FIFTYM/SUMMER22_MINIAOD/221106_001759/0000/step1_inMINIAODSIM_1.root', + '/store/data/Run2022F/ParkingDoubleElectronLowMass0/MINIAOD/PromptReco-v1/000/360/390/00000/8d5c45b2-a30f-454e-ba91-aa69de96ec56.root', + '/store/data/Run2022F/ParkingDoubleElectronLowMass0/MINIAOD/PromptReco-v1/000/360/391/00000/ee216f8f-5131-42de-9ffd-1d706b811f05.root', ] if options.isMC else [ - 'root://cms-xrd-global.cern.ch//store/data/Run2022C/ParkingDoubleElectronLowMass0/MINIAOD/PromptReco-v1/000/356/170/00000/45c0f2ed-eb5b-4292-abc8-3117424d9432.root' + '/store/data/Run2022F/ParkingDoubleElectronLowMass0/MINIAOD/PromptReco-v1/000/360/390/00000/8d5c45b2-a30f-454e-ba91-aa69de96ec56.root', + '/store/data/Run2022F/ParkingDoubleElectronLowMass0/MINIAOD/PromptReco-v1/000/360/391/00000/ee216f8f-5131-42de-9ffd-1d706b811f05.root', ] annotation = '%s nevts:%d' % (outputFileNANO, options.maxEvents) @@ -168,6 +170,7 @@ process = nanoAOD_customizeTriggerBitsBPark(process) process = nanoAOD_customizeTrackFilteredBPark(process) process = nanoAOD_customizeBToKLL(process) + process = nanoAOD_customizeBToKstarEE(process) # Path and EndPath definitions if options.lhcRun == 2: @@ -180,7 +183,9 @@ +process.nanoDiEleSequence +process.nanoTracksSequence +process.nanoBKeeSequence - +CountBToKee) + +CountBToKee + +process.nanoBKstarEESequence + +CountBToKstarEE) # customisation of the process. if options.isMC: