From 092120a2c6b807d0fa4b964debd7f6a33a4dbb08 Mon Sep 17 00:00:00 2001 From: Annika Stein Date: Mon, 12 Dec 2022 22:06:58 +0100 Subject: [PATCH 1/4] feat: ParT features with new producer --- plugins/ParTTableProducer.cc | 1220 ++++++++++++++++++++++++++++++++++ python/addBTV.py | 7 +- python/pfnano_cff.py | 66 +- test/card_mc_ULv2.yml | 10 +- 4 files changed, 1279 insertions(+), 24 deletions(-) create mode 100644 plugins/ParTTableProducer.cc diff --git a/plugins/ParTTableProducer.cc b/plugins/ParTTableProducer.cc new file mode 100644 index 0000000..78d206b --- /dev/null +++ b/plugins/ParTTableProducer.cc @@ -0,0 +1,1220 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" + +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "TLorentzVector.h" +#include "DataFormats/Math/interface/deltaR.h" +#include "RecoVertex/VertexTools/interface/VertexDistance3D.h" +#include "RecoVertex/VertexTools/interface/VertexDistanceXY.h" +#include "RecoVertex/VertexPrimitives/interface/ConvertToFromReco.h" +#include "RecoVertex/VertexPrimitives/interface/VertexState.h" + +#include "DataFormats/PatCandidates/interface/Jet.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" + +#include "DataFormats/Candidate/interface/CandidateFwd.h" + +#include "RecoBTag/FeatureTools/interface/TrackInfoBuilder.h" +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/IPTools/interface/IPTools.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" +#include "TrackingTools/GeomPropagators/interface/AnalyticalTrajectoryExtrapolatorToLine.h" +#include "TrackingTools/GeomPropagators/interface/AnalyticalImpactPointExtrapolator.h" + +#include "DataFormats/BTauReco/interface/TrackIPTagInfo.h" +#include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h" +#include "RecoBTag/FeatureTools/interface/deep_helpers.h" +#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h" + +#include "RecoBTag/FeatureTools/interface/sorting_modules.h" + + + +//#include "../interface/ntuple_pfCands.h" +//#include "../interface/sorting_modules.h" + + +#include "TVector3.h" + +#include "DataFormats/GeometrySurface/interface/Line.h" +#include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h" + +//using namespace btagbtvdeep; +using btagbtvdeep::SortingClass; +using btagbtvdeep::mindrsvpfcand; +using btagbtvdeep::invertSortingVector; + +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "DataFormats/NanoAOD/interface/FlatTable.h" +#include + +// add tag info and a way to go back to the jet reference +#include "FWCore/Framework/interface/makeRefToBaseProdFrom.h" +#include "DataFormats/BTauReco/interface/JetTag.h" +#include "DataFormats/BTauReco/interface/DeepFlavourTagInfo.h" + +//#include "DataFormats/HepMCCandidate/interface/GenParticle.h" + +//#include "../interface/helpers.h" + +class TrackInfoBuilder{ +public: + TrackInfoBuilder(edm::ESHandle & build): + builder(build), + trackMomentum_(0), + trackEta_(0), + trackEtaRel_(0), + trackPtRel_(0), + trackPPar_(0), + trackDeltaR_(0), + trackPtRatio_(0), + trackPParRatio_(0), + trackSip2dVal_(0), + trackSip2dSig_(0), + trackSip3dVal_(0), + trackSip3dSig_(0), + + trackJetDistVal_(0), + trackJetDistSig_(0), + //trackMinDistSV_(0), + //trackMinDistXSV_(0), + //trackMinDistYSV_(0), + //trackMinDistZSV_(0) + ttrack_(0) + +{ + + +} + + void buildTrackInfo(const pat::PackedCandidate* PackedCandidate_ ,const math::XYZVector& jetDir, GlobalVector refjetdirection, const reco::Vertex & pv){ + TVector3 jetDir3(jetDir.x(),jetDir.y(),jetDir.z()); + if(!PackedCandidate_->hasTrackDetails()) { + TVector3 trackMom3( + PackedCandidate_->momentum().x(), + PackedCandidate_->momentum().y(), + PackedCandidate_->momentum().z() + ); + trackMomentum_=PackedCandidate_->p(); + trackEta_= PackedCandidate_->eta(); + trackEtaRel_=reco::btau::etaRel(jetDir, PackedCandidate_->momentum()); + trackPtRel_=trackMom3.Perp(jetDir3); + trackPPar_=jetDir.Dot(PackedCandidate_->momentum()); + trackDeltaR_=reco::deltaR(PackedCandidate_->momentum(), jetDir); + trackPtRatio_=trackMom3.Perp(jetDir3) / PackedCandidate_->p(); + trackPParRatio_=jetDir.Dot(PackedCandidate_->momentum()) / PackedCandidate_->p(); + trackSip2dVal_=0.; + trackSip2dSig_=0.; + trackSip3dVal_=0.; + trackSip3dSig_=0.; + trackJetDistVal_=0.; + trackJetDistSig_=0.; + //ttrack_ = 0; + //trackMinDistSV_=0.; + //trackMinDistXSV_=0.; + //trackMinDistYSV_=0.; + //trackMinDistZSV_=0.; + return; + } + + const reco::Track & PseudoTrack = PackedCandidate_->pseudoTrack(); + + reco::TransientTrack transientTrack; + //reco::TransientTrack* transientTrack2; + transientTrack=builder->build(PseudoTrack); + Measurement1D meas_ip2d=IPTools::signedTransverseImpactParameter(transientTrack, refjetdirection, pv).second; + Measurement1D meas_ip3d=IPTools::signedImpactParameter3D(transientTrack, refjetdirection, pv).second; + Measurement1D jetdist=IPTools::jetTrackDistance(transientTrack, refjetdirection, pv).second; + math::XYZVector trackMom = PseudoTrack.momentum(); + double trackMag = std::sqrt(trackMom.Mag2()); + TVector3 trackMom3(trackMom.x(),trackMom.y(),trackMom.z()); + //float mindistsv = mindistsvpfcand(transientTrack); + //GlobalPoint mindistgpsv = mingpsvpfcand(transientTrack); + + + trackMomentum_=std::sqrt(trackMom.Mag2()); + trackEta_= trackMom.Eta(); + trackEtaRel_=reco::btau::etaRel(jetDir, trackMom); + trackPtRel_=trackMom3.Perp(jetDir3); + trackPPar_=jetDir.Dot(trackMom); + trackDeltaR_=reco::deltaR(trackMom, jetDir); + trackPtRatio_=trackMom3.Perp(jetDir3) / trackMag; + trackPParRatio_=jetDir.Dot(trackMom) / trackMag; + trackSip2dVal_=(meas_ip2d.value()); + + trackSip2dSig_=(meas_ip2d.significance()); + trackSip3dVal_=(meas_ip3d.value()); + + + trackSip3dSig_= meas_ip3d.significance(); + trackJetDistVal_= jetdist.value(); + trackJetDistSig_= jetdist.significance(); + + //trackMinDistSV_= mindistsv; + //trackMinDistXSV_= mindistgpsv.x(); + //trackMinDistYSV_= mindistgpsv.y(); + //trackMinDistZSV_= mindistgpsv.z(); + ttrack_ = transientTrack; + + + } + + const float& getTrackDeltaR() const {return trackDeltaR_;} + const float& getTrackEta() const {return trackEta_;} + const float& getTrackEtaRel() const {return trackEtaRel_;} + const float& getTrackJetDistSig() const {return trackJetDistSig_;} + const float& getTrackJetDistVal() const {return trackJetDistVal_;} + const float& getTrackMomentum() const {return trackMomentum_;} + const float& getTrackPPar() const {return trackPPar_;} + const float& getTrackPParRatio() const {return trackPParRatio_;} + const float& getTrackPtRatio() const {return trackPtRatio_;} + const float& getTrackPtRel() const {return trackPtRel_;} + const float& getTrackSip2dSig() const {return trackSip2dSig_;} + const float& getTrackSip2dVal() const {return trackSip2dVal_;} + const float& getTrackSip3dSig() const {return trackSip3dSig_;} + const float& getTrackSip3dVal() const {return trackSip3dVal_;} + + const reco::TransientTrack getTTrack() const {return ttrack_;} + + //const float& getrackMinDistSV() const {return trackMinDistSV_;} + //const float& getTrackMinDistXSV() const {return trackMinDistXSV_;} + //const float& getTrackMinDistYSV() const {return trackMinDistYSV_;} + //const float& getTrackMinDistZSV() const {return trackMinDistZSV_;} + +private: + + edm::ESHandle& builder; + + float trackMomentum_; + float trackEta_; + float trackEtaRel_; + float trackPtRel_; + float trackPPar_; + float trackDeltaR_; + float trackPtRatio_; + float trackPParRatio_; + float trackSip2dVal_; + float trackSip2dSig_; + float trackSip3dVal_; + float trackSip3dSig_; + + float trackJetDistVal_; + float trackJetDistSig_; + reco::TransientTrack ttrack_; + //float trackMinDistSV_; + //float trackMinDistXSV_; + //float trackMinDistYSV_; + //float trackMinDistZSV_; + +}; + + +template +class ParTTableProducer : public edm::stream::EDProducer<> { +public: + explicit ParTTableProducer(const edm::ParameterSet &); + ~ParTTableProducer() override; + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + static float mindistsvpfcand(const reco::TransientTrack track, const reco::VertexCompositePtrCandidateCollection svs_unsorted); + + /* + int jet_flavour(const pat::Jet& jet, + const std::vector& gToBB, + const std::vector& gToCC, + const std::vector& neutrinosLepB, + const std::vector& neutrinosLepB_C, + const std::vector& alltaus, + bool usePhysForLightAndUndefined) { + + int hflav = abs(jet.hadronFlavour()); + int pflav = abs(jet.partonFlavour()); + int physflav = 0; + if ( !( jet.genJet() ) ){ + if (pflav == 0) return 999; + else return 1000; + } + if(jet.genParton()) physflav=abs(jet.genParton()->pdgId()); + std::size_t nbs = jet.jetFlavourInfo().getbHadrons().size(); + std::size_t ncs = jet.jetFlavourInfo().getcHadrons().size(); + + unsigned int nbFromGSP(0); + for (reco::GenParticle p : gToBB) { + double dr(reco::deltaR(jet, p)); + if (dr < jetR_) ++nbFromGSP; + } + + unsigned int ncFromGSP(0); + for (reco::GenParticle p : gToCC) { + double dr(reco::deltaR(jet, p)); + if (dr < jetR_) ++ncFromGSP; + } + + //std::cout << " jet pt = " << jet.pt() << " hfl = " << hflav << " pfl = " << pflav << " genpart = " << physflav + // << " nbFromGSP = " << nbFromGSP << " ncFromGSP = " << ncFromGSP + // << " nBhadrons " << nbs << " nCHadrons " << ncs << std::endl; + if(hflav == 5) { //B jet + if(nbs > 1) { + if (nbFromGSP > 0) return 511; + else return 510; + } + else if(nbs == 1) { + for (std::vector::const_iterator it = neutrinosLepB.begin(); it != neutrinosLepB.end(); ++it){ + if(reco::deltaR(it->eta(),it->phi(),jet.eta(),jet.phi()) < 0.4) { + return 520; + } + } + for (std::vector::const_iterator it = neutrinosLepB_C.begin(); it != neutrinosLepB_C.end(); ++it){ + if(reco::deltaR(it->eta(),it->phi(),jet.eta(),jet.phi()) < 0.4) { + return 521; + } + } + return 500; + } + else { + if(usePhysForLightAndUndefined){ + if(physflav == 21) return 0; + else if(physflav == 3) return 2; + else if(physflav == 2 || physflav ==1) return 1; + else return 1000; + } + else return 1000; + } + } + else if(hflav == 4) { //C jet + if (ncs > 1) { + if (ncFromGSP > 0) return 411; + else return 410; + } + else return 400; + } + else { //not a heavy jet + if(alltaus.size()>0){ //check for tau in a simplistic way + bool ishadrtaucontained=true; + for(const auto& p:alltaus){ + size_t ndau=p.numberOfDaughters(); + for(size_t i=0;ipdgId()); + if(daupid == 13 || daupid == 11){ + ishadrtaucontained=false; + break; + } + if(daupid != 12 && daupid!=14 && daupid!=16 && + reco::deltaR(*dau,jet) > jetR_){ + ishadrtaucontained=false; + break; + } + } + } + if(ishadrtaucontained) return 600; + } + if(std::abs(pflav) == 4 || std::abs(pflav) == 5 || nbs || ncs) { + if(usePhysForLightAndUndefined){ + if(physflav == 21) return 0; + else if(physflav == 3) return 2; + else if(physflav == 2 || physflav ==1) return 1; + else return 1000; + } + else return 1000; + } + else if(usePhysForLightAndUndefined){ + if(physflav == 21) return 0; + else if(physflav == 3) return 2; + else if(physflav == 2 || physflav ==1) return 1; + else return 1000; + } + else { + if(pflav == 21) return 0; + else if(pflav == 3) return 2; + else if(pflav == 2 || pflav ==1) return 1; + else return 1000; + } + } + + }*/ + + +private: + void produce(edm::Event &, const edm::EventSetup &) override; + + typedef reco::VertexCollection VertexCollection; + typedef reco::VertexCompositePtrCandidateCollection SVCollection; + + + + const std::string nameParT_; + const std::string idx_nameParT_; + //const std::string storeAK4Truth_; + + + //const edm::EDGetTokenT genParticlesToken_; + + //const bool readBtag_; + //const double jet_radius_; + //const bool add_DeepJet_noclip_; + + edm::EDGetTokenT> jet_token_; + edm::EDGetTokenT vtx_token_; + edm::EDGetTokenT cand_token_; + edm::EDGetTokenT sv_token_; + + edm::Handle vtxs_; + edm::Handle cands_; + edm::Handle svs_; + edm::ESHandle track_builder_; + + const reco::Vertex *pv_ = nullptr; + + const float min_candidate_pt_ = 0.95; + + //typedef std::vector TagInfoCollection; + //const edm::EDGetTokenT tag_info_src_; + + + constexpr static unsigned n_cpf_ = 25; + constexpr static unsigned n_npf_ = 25; + constexpr static unsigned n_sv_ = 5; + + constexpr static double jetR_ = 0.4; + + //constexpr static bool usePhysForLightAndUndefined = false; + + +}; + +// +// constructors and destructor +// +template< typename T> +ParTTableProducer::ParTTableProducer(const edm::ParameterSet &iConfig) + : nameParT_(iConfig.getParameter("nameParT")), + idx_nameParT_(iConfig.getParameter("idx_nameParT")), + //readBtag_(iConfig.getParameter("readBtag")), + //jet_radius_(iConfig.getParameter("jet_radius")), + //add_DeepJet_noclip_(iConfig.getParameter("add_DeepJet_noclip")), + jet_token_(consumes>(iConfig.getParameter("jets"))), + vtx_token_(consumes(iConfig.getParameter("vertices"))), + cand_token_(consumes(iConfig.getParameter("candidates"))), + sv_token_(consumes(iConfig.getParameter("secondary_vertices"))){ + + //storeAK4Truth_(iConfig.getParameter("storeAK4Truth")), + //genParticlesToken_(consumes(iConfig.getParameter("genparticles"))), + //jet_token_(consumes>(iConfig.getParameter("jets"))), + //tag_info_src_(consumes(iConfig.getParameter("tagInfo_src"))){ + produces(nameParT_); +} + +template< typename T> +ParTTableProducer::~ParTTableProducer() {} + +template< typename T> +void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { + // elements in all these collections must have the same order! + + // only necessary to explicitly check correct matching of jets + std::vector jetIdx_dj; + + //edm::Handle genParticlesHandle; + //iEvent.getByToken(genParticlesToken_, genParticlesHandle); + + auto jets = iEvent.getHandle(jet_token_); + iEvent.getByToken(vtx_token_, vtxs_); + iEvent.getByToken(cand_token_, cands_); + iEvent.getByToken(sv_token_, svs_); + + iSetup.get().get("TransientTrackBuilder", track_builder_); + + //edm::Handle tag_infos; + //iEvent.getByToken(tag_info_src_, tag_infos); + + + //std::vector neutrinosLepB; + //std::vector neutrinosLepB_C; + + //std::vector gToBB; + //std::vector gToCC; + //std::vector alltaus; + + + unsigned nJets = jets->size(); + + //std::vector jet_N_CPFCands(nJets); + //std::vector jet_N_NPFCands(nJets); + //std::vector jet_N_PVs(nJets); + //std::vector jet_N_SVs(nJets); + + + //std::vector jet_FlavSplit(nJets); + + // should default to 0 if less than nCpf cpf with information + //std::vector> Cpfcan_BtagPf_trackEtaRel_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_BtagPf_trackPtRel_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_BtagPf_trackPPar_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_BtagPf_trackDeltaR_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_BtagPf_trackPParRatio_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_BtagPf_trackSip2dVal_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_BtagPf_trackSip2dSig_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_BtagPf_trackSip3dVal_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_BtagPf_trackSip3dSig_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_BtagPf_trackJetDistVal_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_ptrel_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_drminsv_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_VTX_ass_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_puppiw_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_chi2_nCpf(n_cpf_, std::vector(nJets)); + //std::vector> Cpfcan_quality_nCpf(n_cpf_, std::vector(nJets)); + + // new variables for ParT + std::vector> Cpfcan_distminsv_nCpf(n_cpf_, std::vector(nJets)); + // 4 vectors + std::vector> Cpfcan_pt_nCpf(n_cpf_, std::vector(nJets)); + std::vector> Cpfcan_eta_nCpf(n_cpf_, std::vector(nJets)); + std::vector> Cpfcan_phi_nCpf(n_cpf_, std::vector(nJets)); + std::vector> Cpfcan_e_nCpf(n_cpf_, std::vector(nJets)); + + + // should default to 0 if less than nNpf npf with information + //std::vector> Npfcan_ptrel_nNpf(n_npf_, std::vector(nJets)); + //std::vector> Npfcan_deltaR_nNpf(n_npf_, std::vector(nJets)); + //std::vector> Npfcan_isGamma_nNpf(n_npf_, std::vector(nJets)); + //std::vector> Npfcan_HadFrac_nNpf(n_npf_, std::vector(nJets)); + //std::vector> Npfcan_drminsv_nNpf(n_npf_, std::vector(nJets)); + //std::vector> Npfcan_puppiw_nNpf(n_npf_, std::vector(nJets)); + + // new variables for ParT + std::vector> Npfcan_etarel_nNpf(n_npf_, std::vector(nJets)); + std::vector> Npfcan_phirel_nNpf(n_npf_, std::vector(nJets)); + // 4 vectors + std::vector> Npfcan_pt_nNpf(n_npf_, std::vector(nJets)); + std::vector> Npfcan_eta_nNpf(n_npf_, std::vector(nJets)); + std::vector> Npfcan_phi_nNpf(n_npf_, std::vector(nJets)); + std::vector> Npfcan_e_nNpf(n_npf_, std::vector(nJets)); + + + + // should default to 0 if less than nSv SVs with information + //std::vector> sv_mass_nSV(n_sv_, std::vector(nJets)); + //std::vector> sv_pt_nSV(n_sv_, std::vector(nJets)); + //std::vector> sv_ntracks_nSV(n_sv_, std::vector(nJets)); + //std::vector> sv_chi2_nSV(n_sv_, std::vector(nJets)); + //std::vector> sv_normchi2_nSV(n_sv_, std::vector(nJets)); + //std::vector> sv_dxy_nSV(n_sv_, std::vector(nJets)); + //std::vector> sv_dxysig_nSV(n_sv_, std::vector(nJets)); + //std::vector> sv_d3d_nSV(n_sv_, std::vector(nJets)); + //std::vector> sv_d3dsig_nSV(n_sv_, std::vector(nJets)); + //std::vector> sv_costhetasvpv_nSV(n_sv_, std::vector(nJets)); + + // new variables for ParT + std::vector> sv_etarel_nSV(n_sv_, std::vector(nJets)); + std::vector> sv_phirel_nSV(n_sv_, std::vector(nJets)); + // 4 vectors (pt was already included in DeepJet) + std::vector> sv_eta_nSV(n_sv_, std::vector(nJets)); + std::vector> sv_phi_nSV(n_sv_, std::vector(nJets)); + std::vector> sv_e_nSV(n_sv_, std::vector(nJets)); + + //std::vector> sv_deltaR_nSV(n_sv_, std::vector(nJets)); + //std::vector> sv_enratio_nSV(n_sv_, std::vector(nJets)); + + + + // old variables, but use a fifth SV as well for ParT + std::vector sv_mass_4(nJets); + std::vector sv_pt_4(nJets); + std::vector sv_ntracks_4(nJets); + std::vector sv_chi2_4(nJets); + std::vector sv_normchi2_4(nJets); + std::vector sv_dxy_4(nJets); + std::vector sv_dxysig_4(nJets); + std::vector sv_d3d_4(nJets); + std::vector sv_d3dsig_4(nJets); + std::vector sv_costhetasvpv_4(nJets); + std::vector sv_deltaR_4(nJets); + std::vector sv_enratio_4(nJets); + + /* + if (storeAK4Truth_ == "yes") { + + neutrinosLepB.clear(); + neutrinosLepB_C.clear(); + gToBB.clear(); + gToCC.clear(); + alltaus.clear(); + + for (const reco::Candidate &genC : *genParticlesHandle) { + const reco::GenParticle &gen = static_cast< const reco::GenParticle &>(genC); + if(abs(gen.pdgId())==12||abs(gen.pdgId())==14||abs(gen.pdgId())==16) { + const reco::GenParticle* mother = static_cast< const reco::GenParticle*> (gen.mother()); + if(mother!=NULL) { + if((abs(mother->pdgId())>500&&abs(mother->pdgId())<600)||(abs(mother->pdgId())>5000&&abs(mother->pdgId())<6000)) { + neutrinosLepB.emplace_back(gen); + } + if((abs(mother->pdgId())>400&&abs(mother->pdgId())<500)||(abs(mother->pdgId())>4000&&abs(mother->pdgId())<5000)) { + neutrinosLepB_C.emplace_back(gen); + } + } + else { + std::cout << "No mother" << std::endl; + } + } + + int id(std::abs(gen.pdgId())); + int status(gen.status()); + + if (id == 21 && status >= 21 && status <= 59) { //// Pythia8 hard scatter, ISR, or FSR + if ( gen.numberOfDaughters() == 2 ) { + const reco::Candidate* d0 = gen.daughter(0); + const reco::Candidate* d1 = gen.daughter(1); + if ( std::abs(d0->pdgId()) == 5 && std::abs(d1->pdgId()) == 5 + && d0->pdgId()*d1->pdgId() < 0 && reco::deltaR(*d0, *d1) < jetR_) gToBB.push_back(gen) ; + if ( std::abs(d0->pdgId()) == 4 && std::abs(d1->pdgId()) == 4 + && d0->pdgId()*d1->pdgId() < 0 && reco::deltaR(*d0, *d1) < jetR_) gToCC.push_back(gen) ; + } + } + + if(id == 15 && false){ + alltaus.push_back(gen); + } + + } + + } + */ + + + //std::cout << "Start jet loop." << std::endl; + + for (unsigned i_jet = 0; i_jet < jets->size(); ++i_jet) { + const auto &jet = jets->at(i_jet); + + const float jet_uncorr_pt=jet.correctedJet("Uncorrected").pt(); + const float jet_uncorr_e=jet.correctedJet("Uncorrected").energy(); + + math::XYZVector jet_dir = jet.momentum().Unit(); + GlobalVector jet_ref_track_dir(jet.px(), jet.py(), jet.pz()); + VertexDistance3D vdist; + + pv_ = &vtxs_->at(0); + + ////////////////////// + // Secondary Vertices + std::vector jetSVs; + std::vector allSVs; + + + //std::vector> sv_mass_0to3(4, std::vector(jets->size())); + jetIdx_dj.push_back(i_jet); + + //jet_N_SVs[i_jet] = 0; + for (const auto &sv : *svs_) { + // Factor in cuts in NanoAOD for indexing + Measurement1D dl= vdist.distance(vtxs_->front(), VertexState(RecoVertex::convertPos(sv.position()),RecoVertex::convertError(sv.error()))); + if(dl.significance() > 3){ + allSVs.push_back(&sv); + } + if (reco::deltaR2(sv, jet) < jetR_ * jetR_) { + jetSVs.push_back(&sv); + //jet_N_SVs[i_jet]++; + } + } + + + // sort by dxy significance + std::sort(jetSVs.begin(), + jetSVs.end(), + [&](const reco::VertexCompositePtrCandidate *sva, const reco::VertexCompositePtrCandidate *svb) { + return btagbtvdeep::sv_vertex_comparator(*sva, *svb, *pv_); + }); + + // counter to get flat info per jet for SVs + unsigned i_sv_in_jet = 0; + // I'd like to try something like this: https://stackoverflow.com/questions/50870374/better-way-to-map-string-fields-to-variables + // have a map from key to variables inside the SV loop such that I do not need to write every single constituent (more relevant for PFcands later) + + for (const auto &sv : jetSVs) { +/* + // auto svPtrs = svs_->ptrs(); + auto svInNewList = std::find(allSVs.begin(), allSVs.end(), sv ); + if (svInNewList == allSVs.end()) { + // continue; + svIdx.push_back(-1); + } else{ + svIdx.push_back(svInNewList - allSVs.begin()); + } + outSVs->push_back(sv); + jetIdx_sv.push_back(i_jet); +*/ + //if (readBtag_ && !vtxs_->empty()) { + if (!vtxs_->empty()) { + + if (i_sv_in_jet < 4) { + /* + // this is all already included via DeepJet + sv_mass_0to3[i_sv_in_jet][i_jet] = sv->mass(); + sv_pt_0to3[i_sv_in_jet][i_jet] = sv->pt(); + sv_ntracks_0to3[i_sv_in_jet][i_jet] = sv->numberOfDaughters(); + sv_chi2_0to3[i_sv_in_jet][i_jet] = sv->vertexChi2(); + sv_normchi2_0to3[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(sv->vertexChi2() / sv->vertexNdof(), 1000, -1000, 1000); + const auto& dxy_meas = btagbtvdeep::vertexDxy(*sv, *pv_); + sv_dxy_0to3[i_sv_in_jet][i_jet] = dxy_meas.value(); + sv_dxysig_0to3[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(dxy_meas.value() / dxy_meas.error(), 0, -1, 800); + const auto& d3d_meas = btagbtvdeep::vertexD3d(*sv, *pv_); + sv_d3d_0to3[i_sv_in_jet][i_jet] = d3d_meas.value(); + sv_d3dsig_0to3[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(d3d_meas.value() / d3d_meas.error(), 0, -1, 800); + sv_costhetasvpv_0to3[i_sv_in_jet][i_jet] = btagbtvdeep::vertexDdotP(*sv, *pv_); + // Jet related + sv_ptrel_0to3[i_sv_in_jet][i_jet] = sv->pt() / jet.pt(); + sv_phirel_0to3[i_sv_in_jet][i_jet] = reco::deltaPhi(*sv, jet); + sv_deltaR_0to3[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaR(*sv, jet_dir)) - 0.5, 0, -2, 0); + sv_enratio_0to3[i_sv_in_jet][i_jet] = sv->energy() / jet.energy(); + */ + /* + // no clip + if (add_DeepJet_noclip_) { + sv_normchi2_0to3_noclip[i_sv_in_jet][i_jet] = sv->vertexChi2() / sv->vertexNdof(); + sv_dxysig_0to3_noclip[i_sv_in_jet][i_jet] = dxy_meas.value() / dxy_meas.error(); + sv_d3dsig_0to3_noclip[i_sv_in_jet][i_jet] = d3d_meas.value() / d3d_meas.error(); + sv_deltaR_0to3_noclip[i_sv_in_jet][i_jet] = std::fabs(reco::deltaR(*sv, jet_dir)); + } + */ + + // this is new for ParT: + sv_etarel_nSV[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(sv->eta()-jet.eta())-0.5,0,-2,0); + sv_phirel_nSV[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaPhi(sv->phi(),jet.phi()))-0.5,0,-2,0); + + sv_eta_nSV[i_sv_in_jet][i_jet] = sv->eta(); + sv_phi_nSV[i_sv_in_jet][i_jet] = sv->phi(); + sv_e_nSV[i_sv_in_jet][i_jet] = sv->energy(); + + } else { + if (i_sv_in_jet == 4) { // the fifth SV, new for ParT, not yet for DeepJet + /* + 'sv_pt','sv_deltaR', + 'sv_mass', + 'sv_etarel', + 'sv_phirel', + 'sv_ntracks', + 'sv_chi2', + 'sv_normchi2', + 'sv_dxy', + 'sv_dxysig', + 'sv_d3d', + 'sv_d3dsig', + 'sv_costhetasvpv', + 'sv_enratio', + */ + sv_pt_4[i_jet] = sv->pt(); + sv_deltaR_4[i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaR(*sv, jet)) - 0.5, 0, -2, 0); + sv_mass_4[i_jet] = sv->mass(); + sv_ntracks_4[i_jet] = sv->numberOfDaughters(); + sv_chi2_4[i_jet] = sv->vertexChi2(); + sv_normchi2_4[i_jet] = btagbtvdeep::catch_infs_and_bound(sv_chi2_4[i_jet] / sv->vertexNdof(), 1000, -1000, 1000); + const auto& dxy_meas = btagbtvdeep::vertexDxy(*sv, *pv_); + sv_dxy_4[i_jet] = dxy_meas.value(); + sv_dxysig_4[i_jet] = btagbtvdeep::catch_infs_and_bound(sv_dxy_4[i_jet] / dxy_meas.error(), 0, -1, 800); + const auto& d3d_meas = btagbtvdeep::vertexD3d(*sv, *pv_); + sv_d3d_4[i_jet] = d3d_meas.value(); + sv_d3dsig_4[i_jet] = btagbtvdeep::catch_infs_and_bound(sv_d3d_4[i_jet] / d3d_meas.error(), 0, -1, 800); + sv_costhetasvpv_4[i_jet] = btagbtvdeep::vertexDdotP(*sv, *pv_); + // Jet related + //sv_ptrel_4[i_jet] = sv->pt() / jet.pt(); + sv_enratio_4[i_jet] = sv->energy() / jet_uncorr_e; + + + // also the fifth SV needs new features: + sv_etarel_nSV[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(sv->eta()-jet.eta())-0.5,0,-2,0); + sv_phirel_nSV[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaPhi(sv->phi(),jet.phi()))-0.5,0,-2,0); + + sv_eta_nSV[i_sv_in_jet][i_jet] = sv->eta(); + sv_phi_nSV[i_sv_in_jet][i_jet] = sv->phi(); + sv_e_nSV[i_sv_in_jet][i_jet] = sv->energy(); + } else { // more than 5 SV irrelevant for this tagger + continue; + } + } + + } + i_sv_in_jet++; + } + + //std::cout << "Successfully filled SV info, start sorting PF cands now." << std::endl; + // PF Cands + std::vector const & daughters = jet.daughterPtrVector(); + + const auto& svs_unsorted = *svs_; + + std::vector> c_sorted, n_sorted; + + // first time looping over all pf candidates + // to fill sorted indices and get a connection back to the old indices + + //jet_N_CPFCands[i_jet] = 0; + //jet_N_NPFCands[i_jet] = 0; + + for (unsigned int i = 0; i < jet.numberOfDaughters(); i++) { + auto cand = jet.daughter(i); + //if ( cand.isNull() ) continue; + //auto const *packedCand = dynamic_cast (cand.get()); + //if ( packedCand == nullptr ) continue; + if (cand) { + // candidates under 950MeV (configurable) are not considered + // might change if we use also white-listing + if (cand->pt() < min_candidate_pt_) continue; + + if (cand->charge() != 0) { + //auto& trackinfo = trackinfos.emplace(i, track_builder).first->second; + //trackinfo.buildTrackInfo(cand, jet_dir, jet_ref_track_dir, *pv_); // *pv_ is an alternative to vtxs_->at(0) + btagbtvdeep::TrackInfoBuilder trkinfo(track_builder_); + // similar to https://github.com/cms-sw/cmssw/blob/master/RecoBTag/FeatureTools/interface/ChargedCandidateConverter.h + trkinfo.buildTrackInfo(cand, jet_dir, jet_ref_track_dir, *pv_); + c_sorted.emplace_back( + i, trkinfo.getTrackSip2dSig(), -btagbtvdeep::mindrsvpfcand(svs_unsorted, cand), cand->pt() / jet_uncorr_pt); + //jet_N_CPFCands[i_jet]++; + } else { + n_sorted.emplace_back(i, -1, -btagbtvdeep::mindrsvpfcand(svs_unsorted, cand), cand->pt() / jet_uncorr_pt); + //jet_N_NPFCands[i_jet]++; + } + } + } + + // sort collections (open the black-box if you please) + std::sort(c_sorted.begin(), c_sorted.end(), btagbtvdeep::SortingClass::compareByABCInv); + std::sort(n_sorted.begin(), n_sorted.end(), btagbtvdeep::SortingClass::compareByABCInv); + + std::vector c_sortedindices, n_sortedindices; + + // this puts 0 everywhere and the right position in ind + c_sortedindices = btagbtvdeep::invertSortingVector(c_sorted); + n_sortedindices = btagbtvdeep::invertSortingVector(n_sorted); + +/* + if (readBtag_ && !vtxs_->empty()) { + for (unsigned int i = 0; i < jet.numberOfDaughters(); i++) { + // get pointer and check that is correct + auto cand = dynamic_cast(jet.daughter(i)); + if (!cand) + continue; + // candidates under 950MeV are not considered + // might change if we use also white-listing + if (cand->pt() < 0.95) + continue; + + auto packed_cand = dynamic_cast(cand); + + + float drminpfcandsv = btagbtvdeep::mindrsvpfcand(svs_unsorted, cand); + + if (cand->charge() != 0) { + // is charged candidate + auto entry = c_sortedindices.at(i); + std::cout << "Current candidate is " << i << " and entry = c_sortedindices.at(i) = " << entry << std::endl; + // need only the first 25 cpfs for DeepJet + if (entry > 24) { + continue; + } +*/ + // get cached track info + //auto& trackinfo = trackinfos.at(i); +/* + if (flip_ && (trackinfo.getTrackSip3dSig() > negative_cut)) { + continue; + } +*/ +/* + // get_ref to vector element + auto& c_pf_features = features.c_pf_features.at(entry); +*/ +/* + std::cout << "Prior to filling with entries for this candidate:" << std::endl; + std::cout << "Size of Cpfcan_puppiw_0to24 is " << Cpfcan_puppiw_0to24.size() << std::endl; + std::cout << "Size of the first column of Cpfcan_puppiw_0to24 is " << Cpfcan_puppiw_0to24[0].size() << std::endl; + // fill feature structure + if (packed_cand) { + Cpfcan_puppiw_0to24[entry][i_jet] = packed_cand->puppiWeight(); + + std::cout << "After filling with entries for this candidate:" << std::endl; + std::cout << "Size of Cpfcan_puppiw_0to24 is " << Cpfcan_puppiw_0to24.size() << std::endl; + std::cout << "Size of the first column of Cpfcan_puppiw_0to24 is " << Cpfcan_puppiw_0to24[0].size() << std::endl; +*/ +/* + btagbtvdeep::packedCandidateToFeatures( + packed_cand, jet, trackinfo, drminpfcandsv, static_cast(jet_radius_), c_pf_features, flip_); +*/ +/* + } else { + // is neutral candidate + auto entry = n_sortedindices.at(i); + // need only the first 25 npfs for DeepJet + if (entry > 24) { + continue; + } + + } + } + } +*/ + //std::cout << "Start looping over PF cands to fill info." << std::endl; + + int i_pf_in_jet = 0; + for (const auto &cand : daughters) { + + auto candPtrs = cands_->ptrs(); + auto candInNewList = std::find( candPtrs.begin(), candPtrs.end(), cand ); + if ( candInNewList == candPtrs.end() ) { + //std::cout << "Cannot find candidate : " << cand.id() << ", " << cand.key() << ", pt = " << cand->pt() << std::endl; + continue; + } +/* + outCands->push_back(cand); + jetIdx_pf.push_back(i_jet); + pfcandIdx.push_back(candInNewList - candPtrs.begin()); + //cand_pt.push_back(cand->pt()); +*/ + if (!vtxs_->empty()) { + if ( cand.isNull() ) continue; + auto const *packedCand = dynamic_cast (cand.get()); + if ( packedCand == nullptr ) continue; + if (packedCand->pt() < min_candidate_pt_) continue; + //float drminpfcandsv = btagbtvdeep::mindrsvpfcand(svs_unsorted, &(*cand)); + if ( packedCand->charge() != 0 ) { + + // is charged candidate + auto entry_sorted = c_sortedindices.at(i_pf_in_jet); + //std::cout << "Current candidate is " << i_pf_in_jet << " and entry_sorted = c_sortedindices.at(i_pf_in_jet) = " << entry_sorted << std::endl; + // need only the first 25 cpfs for ParT + if (entry_sorted >= n_cpf_) { + continue; + } + + //Cpfcan_puppiw_0to24[entry_sorted][i_jet] = packedCand->puppiWeight(); + //Cpfcan_VTX_ass_0to24[entry_sorted][i_jet] = packedCand->pvAssociationQuality(); + //Cpfcan_drminsv_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(drminpfcandsv, 0, -1. * jet_radius_, 0, -1. * jet_radius_); + //Cpfcan_ptrel_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(packedCand->pt() / jet.pt(), 0, -1, 0, -1); + + + + + + Cpfcan_pt_nCpf[entry_sorted][i_jet] = cand->pt(); + Cpfcan_eta_nCpf[entry_sorted][i_jet] = cand->eta(); + Cpfcan_phi_nCpf[entry_sorted][i_jet] = cand->phi(); + Cpfcan_e_nCpf[entry_sorted][i_jet] = cand->energy(); + + + if ( packedCand && packedCand->hasTrackDetails()){ + //const auto& pseudo_track = packedCand->pseudoTrack(); + //Cpfcan_chi2_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(pseudo_track.normalizedChi2(), 300, -1, 300); + + // this returns the quality enum not a mask. + //Cpfcan_quality_0to24[entry_sorted][i_jet] = pseudo_track.qualityMask(); + + + //btagbtvdeep::TrackInfoBuilder trkinfo(track_builder_); + TrackInfoBuilder trkinfo(track_builder_); + // similar to https://github.com/cms-sw/cmssw/blob/master/RecoBTag/FeatureTools/interface/ChargedCandidateConverter.h + trkinfo.buildTrackInfo(&(*packedCand), jet_dir, jet_ref_track_dir, *pv_); + + + // with clip + //Cpfcan_BtagPf_trackEtaRel_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackEtaRel(), 0, -5, 15); + //Cpfcan_BtagPf_trackPtRel_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackPtRel(), 0, -1, 4); + //Cpfcan_BtagPf_trackPPar_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackPPar(), 0, -1e5, 1e5); + //Cpfcan_BtagPf_trackDeltaR_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackDeltaR(), 0, -5, 5); + //Cpfcan_BtagPf_trackPParRatio_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackPParRatio(), 0, -10, 100); + //Cpfcan_BtagPf_trackSip2dVal_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackSip2dVal(), 0, -1, 70); + //Cpfcan_BtagPf_trackSip2dSig_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackSip2dSig(), 0, -1, 4e4); + //Cpfcan_BtagPf_trackSip3dVal_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackSip3dVal(), 0, -1, 1e5); + //Cpfcan_BtagPf_trackSip3dSig_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackSip3dSig(), 0, -1, 4e4); + //Cpfcan_BtagPf_trackJetDistVal_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackJetDistVal(), 0, -20, 1); + + + + //c_pf_features.btagPf_trackPtRatio = btagbtvdeep::catch_infs_and_bound(track_info.getTrackPtRatio(), 0, -1, 10); + + //Cpfcan_ptrel.push_back(btagbtvdeep::catch_infs_and_bound(cand->pt() / jet.pt(), 0, -1, 0, -1)); + //Cpfcan_drminsv.push_back(btagbtvdeep::catch_infs_and_bound(mindrsvpfcand(svs_unsorted, &(*cand), 0.4), 0, -1. * jet_radius_, 0, -1. * jet_radius_)); + + + // already done trackinfo.buildTrackInfo(PackedCandidate_,jetDir,jetRefTrackDir,pv); + const reco::TransientTrack ttrack = trkinfo.getTTrack(); + float mindistsv = mindistsvpfcand(ttrack, svs_unsorted); + //GlobalPoint mindistgpsv = mingpsvpfcand(ttrack); + //GlobalPoint gppv = gppvpfcand(ttrack, jetRefTrackDir, pv); + + Cpfcan_distminsv_nCpf[entry_sorted][i_jet] = mindistsv; + + + } else { + continue; + // nothing else new to fill for ParT which does not have track details for cpfs + /* + // default negative chi2 and loose track if notTrackDetails + Cpfcan_chi2_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(-1, 300, -1, 300); + Cpfcan_quality_0to24[entry_sorted][i_jet] = (1 << reco::TrackBase::loose); + */ + + + + + // vector defaults to 0 anyway + //Cpfcan_BtagPf_trackEtaRel.push_back(0); + //Cpfcan_BtagPf_trackPtRel.push_back(0); + //Cpfcan_BtagPf_trackPPar.push_back(0); + //Cpfcan_BtagPf_trackDeltaR.push_back(0); + //Cpfcan_BtagPf_trackPParRatio.push_back(0); + //Cpfcan_BtagPf_trackSip2dVal.push_back(0); + //Cpfcan_BtagPf_trackSip2dSig.push_back(0); + //Cpfcan_BtagPf_trackSip3dVal.push_back(0); + //Cpfcan_BtagPf_trackSip3dSig.push_back(0); + //Cpfcan_BtagPf_trackJetDistVal.push_back(0); + //Cpfcan_ptrel.push_back(0); + //Cpfcan_drminsv.push_back(0); + + } + } else { + + + // is neutral candidate + auto entry_sorted = n_sortedindices.at(i_pf_in_jet); + //std::cout << "Current candidate is " << i_pf_in_jet << " and entry_sorted = c_sortedindices.at(i_pf_in_jet) = " << entry_sorted << std::endl; + // need only the first 25 npfs for ParT + if (entry_sorted >= n_npf_) { + continue; + } + /* + Npfcan_puppiw_0to24[entry_sorted][i_jet] = packedCand->puppiWeight(); + Npfcan_HadFrac_0to24[entry_sorted][i_jet] = packedCand->hcalFraction(); + if (std::abs(packedCand->pdgId()) == 22) + Npfcan_isGamma_0to24[entry_sorted][i_jet] = 1; + // catch + Npfcan_deltaR_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(reco::deltaR(*packedCand, jet), 0, -0.6, 0, -0.6); + Npfcan_drminsv_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(drminpfcandsv, 0, -1. * jet_radius_, 0, -1. * jet_radius_); + Npfcan_ptrel_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(packedCand->pt() / jet.pt(), 0, -1, 0, -1); + */ + Npfcan_etarel_nNpf[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(cand->eta()-jet.eta()), 0, -2, 0, -0.5); + Npfcan_phirel_nNpf[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaPhi(cand->phi(),jet.phi())), 0, -2, 0, -0.5); + Npfcan_pt_nNpf[entry_sorted][i_jet] = cand->pt(); + Npfcan_eta_nNpf[entry_sorted][i_jet] = cand->eta(); + Npfcan_phi_nNpf[entry_sorted][i_jet] = cand->phi(); + Npfcan_e_nNpf[entry_sorted][i_jet] = cand->energy(); + + } + } + i_pf_in_jet++; + } // end jet loop + } + + + // ParTInputs table + auto partTable = std::make_unique(nJets, nameParT_, false, true); + //partTable->addColumn("ParT_jetIdx", jetIdx_dj, "Index of the parent jet", nanoaod::FlatTable::IntColumn); + + + // ============================================================== Cpfs =================================================================== + for (unsigned int p = 0; p < n_cpf_; p++) { + auto s = std::to_string(p); + partTable->addColumn("ParT_Cpfcan_pt_" + s, + Cpfcan_pt_nCpf[p], + "transverse momentum of the " + s + ". cpf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Cpfcan_eta_" + s, + Cpfcan_eta_nCpf[p], + "pseudorapidity of the " + s + ". cpf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Cpfcan_phi_" + s, + Cpfcan_phi_nCpf[p], + "phi of the " + s + ". cpf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Cpfcan_e_" + s, + Cpfcan_e_nCpf[p], + "energy of the " + s + ". cpf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Cpfcan_distminsv_" + s, + Cpfcan_distminsv_nCpf[p], + "track 3D cartesian distance (signed) from the closest secondary vertex of the " + s + ". cpf", + nanoaod::FlatTable::FloatColumn, 10); + } + + // ============================================================== Npfs =================================================================== + for (unsigned int p = 0; p < n_npf_; p++) { + auto s = std::to_string(p); + partTable->addColumn("ParT_Npfcan_etarel_" + s, + Npfcan_etarel_nNpf[p], + "pseudorapidity relative to the jet for the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Npfcan_phirel_" + s, + Npfcan_phirel_nNpf[p], + "phi relative to the jet for the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Npfcan_pt_" + s, + Npfcan_pt_nNpf[p], + "transverse momentum of the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Npfcan_eta_" + s, + Npfcan_eta_nNpf[p], + "pseudorapidity of the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Npfcan_phi_" + s, + Npfcan_phi_nNpf[p], + "phi of the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Npfcan_e_" + s, + Npfcan_e_nNpf[p], + "energy of the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + } + + // ============================================================== SVs =================================================================== + for (unsigned int p = 0; p < n_sv_; p++) { + auto s = std::to_string(p); + // new for ParT + partTable->addColumn("ParT_sv_etarel_" + s, + sv_etarel_nSV[p], + "pseudorapidity relative to parent jet for the " + s + ". SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_phirel_" + s, + sv_phirel_nSV[p], + "DeltaPhi(sv, jet) for the " + s + ". SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_eta_" + s, + sv_eta_nSV[p], + "pseudorapidity of the " + s + ". SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_phi_" + s, + sv_phi_nSV[p], + "phi of the " + s + ". SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_e_" + s, + sv_e_nSV[p], + "energy of the " + s + ". SV", + nanoaod::FlatTable::FloatColumn, 10); + } + + + partTable->addColumn("ParT_sv_mass_4", + sv_mass_4, + "SV mass of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_pt_4", + sv_pt_4, + "SV pt of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_ntracks_4", + sv_ntracks_4, + "Number of tracks asociated to the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_chi2_4", + sv_chi2_4, + "chi2 of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_normchi2_4", + sv_normchi2_4, + "chi2/dof of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_dxy_4", + sv_dxy_4, + "2D impact parameter (flight distance) value of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_dxysig_4", + sv_dxysig_4, + "2D impact parameter (flight distance) significance of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_d3d_4", + sv_d3d_4, + "3D impact parameter (flight distance) value of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_d3dsig_4", + sv_d3dsig_4, + "3D impact parameter (flight distance) significance of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_costhetasvpv_4", + sv_costhetasvpv_4, + "cosine of the angle between the 4. SV flight direction and the direction of the 4. SV momentum", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_deltaR_4", + sv_deltaR_4, + "pseudoangular distance between jet axis and the 4. SV direction", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_enratio_4", + sv_enratio_4, + "ratio of the 4. SV energy ratio to the jet energy", + nanoaod::FlatTable::FloatColumn, 10); + + iEvent.put(std::move(partTable), nameParT_); + +} + +// below OK +template< typename T> +void ParTTableProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { + edm::ParameterSetDescription desc; + desc.add("nameParT", "Jet"); + desc.add("idx_nameParT", "djIdx"); + //desc.add("jet_radius", true); + //desc.add("storeAK4Truth","no"); + //desc.add("genparticles", edm::InputTag("prunedGenParticles")); + desc.add("jets", edm::InputTag("slimmedJets")); + //desc.add("tagInfo_src", edm::InputTag("pfDeepFlavourTagInfosWithDeepInfo")); + desc.add("vertices", edm::InputTag("offlineSlimmedPrimaryVertices")); + desc.add("candidates", edm::InputTag("packedPFCandidates")); + desc.add("secondary_vertices", edm::InputTag("slimmedSecondaryVertices")); + descriptions.addWithDefaultLabel(desc); +} + + +template< typename T> +float ParTTableProducer::mindistsvpfcand(const reco::TransientTrack track, const reco::VertexCompositePtrCandidateCollection svs_unsorted) { + + float mindist_ = 999.999; + float out_dist = 0.0; + for (unsigned int i=0; i result(true, dist.distance(VertexState(vertexPosition, vertexPositionErr), VertexState(refPoint, refPointErr))); + if (!result.first) {continue;} + + GlobalPoint impactPoint = tsos.globalPosition(); + GlobalVector IPVec(impactPoint.x() - vertex.x(), impactPoint.y() - vertex.y(), impactPoint.z() - vertex.z()); + double prod = IPVec.dot(direction); + double sign = (prod >= 0) ? 1. : -1.; + + if(result.second.value() < mindist_){ + out_dist = sign * result.second.value(); + mindist_ = result.second.value(); + } + } + return out_dist; +} + +typedef ParTTableProducer PatJetParTTableProducer; +//typedef ParTTableProducer GenJetParTTableProducer; + +DEFINE_FWK_MODULE(PatJetParTTableProducer); +//DEFINE_FWK_MODULE(GenJetParTTableProducer); diff --git a/python/addBTV.py b/python/addBTV.py index 914c0b9..47b8e36 100644 --- a/python/addBTV.py +++ b/python/addBTV.py @@ -330,7 +330,10 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D jets = cms.InputTag("finalJets"), storeAK4Truth = cms.string(storeAK4Truth) ) - + if ('ParT' in keepInputs): + process.customAK4ConstituentsForParTTable = cms.EDProducer("PatJetParTTableProducer", + jets = cms.InputTag("finalJets") + ) # AK8 process.customFatJetExtTable = cms.EDProducer( @@ -394,6 +397,8 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D process.customizeJetTask.add(process.customJetExtTable) if ('DeepJet' in keepInputs): process.customizeJetTask.add(process.customAK4ConstituentsForDeepJetTable) + if ('ParT' in keepInputs): + process.customizeJetTask.add(process.customAK4ConstituentsForParTTable) if addAK8: process.customizeJetTask.add(process.customFatJetExtTable) diff --git a/python/pfnano_cff.py b/python/pfnano_cff.py index d3a223f..f690abf 100644 --- a/python/pfnano_cff.py +++ b/python/pfnano_cff.py @@ -3,58 +3,76 @@ from PhysicsTools.PFNano.addBTV import add_BTV from PhysicsTools.NanoAOD.common_cff import Var -# keepInputs can take DeepCSV, DeepJet and DDX (any combination, or use empty placeholder list if no inputs are required) +# keepInputs can take DeepCSV, DeepJet, DDX and ParT (any combination, or use empty placeholder list if no inputs are required) def PFnano_customizeMC(process): addPFCands(process, True) add_BTV(process, True, keepInputs=['DeepCSV','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_add_DeepJet(process): addPFCands(process, True) add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_add_DeepJet_and_Truth(process): addPFCands(process, True) add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX'], storeAK4Truth="yes") - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + return process + +def PFnano_customizeMC_add_DeepJet_ParT_and_Truth(process): + addPFCands(process, True) + add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX','ParT'], storeAK4Truth="yes") + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_allPF(process): addPFCands(process, True, True) add_BTV(process, True, keepInputs=['DeepCSV','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_allPF_add_DeepJet(process): addPFCands(process, True, True) add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + return process + +def PFnano_customizeMC_allPF_add_DeepJet_and_Truth(process): + addPFCands(process, True, True) + add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX'], storeAK4Truth="yes") + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + return process + +def PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth(process): + addPFCands(process, True, True) + add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX','ParT'], storeAK4Truth="yes") + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_AK4JetsOnly(process): addPFCands(process, True, False, True) add_BTV(process, True, True, keepInputs=['DeepCSV']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_AK4JetsOnly_add_DeepJet(process): addPFCands(process, True, False, True) add_BTV(process, True, True, keepInputs=['DeepCSV','DeepJet']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_AK8JetsOnly(process): addPFCands(process, True, False, False, True) add_BTV(process, True, False, True, keepInputs=['DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_noInputs(process): add_BTV(process, True, keepInputs=[]) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process @@ -62,46 +80,58 @@ def PFnano_customizeMC_noInputs(process): def PFnano_customizeData(process): addPFCands(process, False) add_BTV(process, False, keepInputs=['DeepCSV','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_add_DeepJet(process): addPFCands(process, False) add_BTV(process, False, keepInputs=['DeepCSV','DeepJet','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + return process + +def PFnano_customizeData_add_DeepJet_ParT(process): + addPFCands(process, False) + add_BTV(process, False, keepInputs=['DeepCSV','DeepJet','DDX','ParT']) + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_allPF(process): addPFCands(process, False, True) add_BTV(process, False, keepInputs=['DeepCSV','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_allPF_add_DeepJet(process): addPFCands(process, False, True) add_BTV(process, False, keepInputs=['DeepCSV','DeepJet','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + return process + +def PFnano_customizeData_allPF_add_DeepJet_ParT(process): + addPFCands(process, False, True) + add_BTV(process, False, keepInputs=['DeepCSV','DeepJet','DDX','ParT']) + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_AK4JetsOnly(process): addPFCands(process, False, False, True) add_BTV(process, False, True, keepInputs=['DeepCSV']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_AK4JetsOnly_add_DeepJet(process): addPFCands(process, False, False, True) add_BTV(process, False, True, keepInputs=['DeepCSV','DeepJet']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_AK8JetsOnly(process): addPFCands(process, False, False, False, True) add_BTV(process, False, False, True, keepInputs=['DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_noInputs(process): add_BTV(process, False, keepInputs=[]) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process diff --git a/test/card_mc_ULv2.yml b/test/card_mc_ULv2.yml index 61c0bb6..1ccd707 100644 --- a/test/card_mc_ULv2.yml +++ b/test/card_mc_ULv2.yml @@ -3,20 +3,20 @@ campaign: crab_template: template_crab.py # User specific - workArea: mc_ULv2_yml + workArea: DYJetsToLL_ULv2_yml storageSite: T2_DE_RWTH outLFNDirBase: /store/user/anstein/PFNano voGroup: dcms # Campaign specific - tag_extension: PFtestNano # Will get appended after the current tag + tag_extension: PFNanoFromMiniV2 # Will get appended after the current tag tag_mod: # Will modify name in-place for MC eg. "PFNanoAODv1" will replace MiniAODv2 -> PFNanoAODv1 - publication: True - config: nano_mc_2017_ULv2_NANO.py + publication: False + config: nano_mc_2017_ULv2_allPF_NANO.py # Specify if running on data # data: True data: False lumiMask: # json file # datasets will take either a list of DAS names or a text file containing them - datasets: /TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM + datasets: /DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM \ No newline at end of file From 77abeffae6638af2806976d37ba4100d7b0223bf Mon Sep 17 00:00:00 2001 From: Annika Stein Date: Wed, 14 Dec 2022 23:23:07 +0100 Subject: [PATCH 2/4] feat: tested ParT configs --- README.md | 64 ++++++++---- test/card_data_ULv2_with_ParT.yml | 22 +++++ test/card_mc_ULv2_with_ParT.yml | 22 +++++ test/datasets/ULv2/data2017.txt | 11 +++ test/datasets/ULv2/mc2017.txt | 0 test/nano_data_2017_ULv2_allPF_ParT_NANO.py | 101 +++++++++++++++++++ test/nano_mc_2017_ULv2_allPF_ParT_NANO.py | 102 ++++++++++++++++++++ 7 files changed, 302 insertions(+), 20 deletions(-) create mode 100644 test/card_data_ULv2_with_ParT.yml create mode 100644 test/card_mc_ULv2_with_ParT.yml create mode 100644 test/datasets/ULv2/data2017.txt create mode 100644 test/datasets/ULv2/mc2017.txt create mode 100644 test/nano_data_2017_ULv2_allPF_ParT_NANO.py create mode 100644 test/nano_mc_2017_ULv2_allPF_ParT_NANO.py diff --git a/README.md b/README.md index d996e18..a479fb0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is a [NanoAOD](https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookNanoAOD) framework for advanced developments of jet algorithms. -The repository consists of multiple branches which are each dedicated to specific releases of [CMSSW](https://github.com/cms-sw/cmssw). If you came here to run over Run3 samples, please checkout the most up-to-date 12_4_8 branch (e.g. from the dropdown menu above). The master branch you are viewing right now is optimized to run over Run2 samples, using the 106X release cycle. +The repository consists of multiple branches which are each dedicated to specific releases of [CMSSW](https://github.com/cms-sw/cmssw). If you came here to run over Run3 samples, please checkout the most up-to-date 12_4_8 branch (e.g. from the dropdown menu above). The branch you are viewing right now is optimized to run over Run2 UL samples, using the 106X release cycle. The current full content of this development branch can be seen [here](https://annika-stein.web.cern.ch/PFNano/AddDeepJetTagInfo_desc.html) and the size [here](https://annika-stein.web.cern.ch/PFNano/AddDeepJetTagInfo_size.html). @@ -13,32 +13,52 @@ This format can be used with [fastjet](http://fastjet.fr) directly. **THIS IS A DEVELOPMENT BRANCH** -For **UL** 2016, 2017 and 2018 data and MC **NanoAODv8** according to the [XPOG](https://gitlab.cern.ch/cms-nanoAOD/nanoaod-doc/-/wikis/Releases/NanoAODv8) and [PPD](https://twiki.cern.ch/twiki/bin/view/CMS/PdmVRun2LegacyAnalysisSummaryTable) recommendations: +For **UL** 2016, 2017 and 2018 data and MC **NanoAODv8/v9** according to the [XPOG](https://gitlab.cern.ch/cms-nanoAOD/nanoaod-doc/-/wikis/home) and [PPD](https://twiki.cern.ch/twiki/bin/view/CMS/PdmVRun2LegacyAnalysisSummaryTable) recommendations: +### Prerequisites +If not already done in your `.bashrc` or similar: ``` -cmsrel CMSSW_10_6_20 # in principle not a constraint -cd CMSSW_10_6_20/src +source /cvmfs/grid.desy.de/etc/profile.d/grid-ui-env.sh or /cvmfs/grid.cern.ch/centos7-umd4-ui-4_200423/etc/profile.d/setup-c7-ui-example.sh +source /cvmfs/cms.cern.ch/common/crab-setup.sh prod +source /cvmfs/cms.cern.ch/cmsset_default.sh +``` +### Setup PFNano +``` +cmsrel CMSSW_10_6_30 +cd CMSSW_10_6_30/src cmsenv -git cms-rebase-topic andrzejnovak:614nosort -git clone https://github.com/cms-jet/PFNano.git PhysicsTools/PFNano +git clone https://github.com/AnnikaStein/PFNano.git PhysicsTools/PFNano #change once it's officially included: git clone https://github.com/cms-jet/PFNano.git PhysicsTools/PFNano +cd PhysicsTools/PFNano +git fetch +git switch ParT_106X +cd ../.. scram b -j 10 cd PhysicsTools/PFNano/test +voms-proxy-init --voms cms:/cms/dcms --valid 192:00 # cms:/cms/dcms if you have a German grid certificate, prio to run at German sites; use cms only otherwise ``` Note: When running over a new dataset you should check with [the nanoAOD workbook twiki](https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookNanoAOD#Running_on_various_datasets_from) to see if the era modifiers in the CRAB configuration files are correct. The jet correction versions are taken from the global tag. ## Local Usage: -There are python config files ready to run in `PhysicsTools/PFNano/test/` for the UL campaign of nanoAODv8, named `nano106Xv8_on_mini106X_201*_data_NANO.py`. Notice that the current version can create different types of files depending on the PF candidates content. +There are python config files ready to run in `PhysicsTools/PFNano/test/` for the UL campaign of nanoAODv8(v9), named `nano106Xv8_on_mini106X_201*_data_NANO.py` (`nano_data_2017_ULv2_allPF_ParT_NANO.py`, similar for MC). Notice that the current version can create different types of files depending on the PF candidates content. Run a configuration via `cmsRun nano_data_2017_ULv2_allPF_ParT_NANO.py` to test on one file locally. If that works, configure your crab submission (more below). + +### Different use cases: -New since Pull Request [#39](https://github.com/cms-jet/PFNano/pull/39): Examples to include or exclude the input features for the DeepJet tagger are given in `nano106Xv8_on_mini106X_2017_mc_NANO.py`. Now the list of options that are currently implemented inside `pfnano_cff.py` (e.g. for MC) looks like that: +New since December 2022: Particle Transformer inputs. Particle Transformer variables can be added by specifying one of the suiting customizations `*add_DeepJet_ParT*`. + +Now the list of options that are currently implemented inside `pfnano_cff.py` (e.g. for MC) looks like that: ``` process = PFnano_customizeMC(process) #process = PFnano_customizeMC_add_DeepJet(process) ##### DeepJet inputs are added to the Jet collection -#process = PFnano_customizeMC_allPF(process) ##### PFcands will content ALL the PF Cands -#process = PFnano_customizeMC_allPF_add_DeepJet(process) ##### PFcands will content ALL the PF Cands; + DeepJet inputs for Jets -#process = PFnano_customizeMC_AK4JetsOnly(process) ##### PFcands will content only the AK4 jets PF cands -#process = PFnano_customizeMC_AK4JetsOnly_add_DeepJet(process) ##### PFcands will content only the AK4 jets PF cands; + DeepJet inputs for Jets -#process = PFnano_customizeMC_AK8JetsOnly(process) ##### PFcands will content only the AK8 jets PF cands +#process = PFnano_customizeMC_add_DeepJet_and_Truth(process) ##### DeepJet inputs as well as a truth branch with fine-grained labels +#process = PFnano_customizeMC_add_DeepJet_ParT_and_Truth(process) ##### DeepJet & ParT inputs as well as a truth branch with fine-grained labels +#process = PFnano_customizeMC_allPF(process) ##### PFcands will contain ALL the PF Cands +#process = PFnano_customizeMC_allPF_add_DeepJet(process) ##### PFcands will contain ALL the PF Cands; + DeepJet inputs for Jets +#process = PFnano_customizeMC_allPF_add_DeepJet_and_Truth(process) ##### PFcands will contain ALL the PF Cands; + DeepJet inputs + truth labels for Jets +#process = PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth(process) ##### PFcands will contain ALL the PF Cands; + DeepJet & ParT inputs + truth labels for Jets +#process = PFnano_customizeMC_AK4JetsOnly(process) ##### PFcands will contain only the AK4 jets PF cands +#process = PFnano_customizeMC_AK4JetsOnly_add_DeepJet(process) ##### PFcands will contain only the AK4 jets PF cands; + DeepJet inputs for Jets +#process = PFnano_customizeMC_AK8JetsOnly(process) ##### PFcands will contain only the AK8 jets PF cands #process = PFnano_customizeMC_noInputs(process) ##### No PFcands but all the other content is available. ``` In general, whenever `_add_DeepJet` is specified (does not apply to `AK8JetsOnly` and `noInputs`), the DeepJet inputs are added to the Jet collection. For all other cases that involve adding tagger inputs, only DeepCSV and / or DDX are taken into account as default (= the old behaviour when `keepInputs=True`). Internally, this is handled by selecting a list of taggers, namely choosing from `DeepCSV`, `DeepJet`, and `DDX` (or an empty list for the `noInputs`-case, formerly done by setting `keepInputs=False`, now set `keepInputs=[]`). This refers to a change of the logic inside `pfnano_cff.py` and `addBTV.py`. If one wants to use this new flexibility, one can also define new customization functions with other combinations of taggers. Currently, there are all configurations to reproduce the ones that were available previously, and all configuations that extend the old ones by adding DeepJet inputs. DeepJet outputs, on top of the discriminators already present in NanoAOD, are added in any case where AK4Jets are added, i.e. there is no need to require the full set of inputs to get the individual output nodes / probabilities. The updated description using `PFnano_customizeMC_add_DeepJet` can be viewed [here](https://annika-stein.web.cern.ch/PFNano/AddDeepJetTagInfo_desc.html) and the size [here](https://annika-stein.web.cern.ch/PFNano/AddDeepJetTagInfo_size.html). @@ -47,10 +67,12 @@ The latest addition before moving to the Run3 recipe was the inclusion of a fine ### How to create python files using cmsDriver +(You can skip this step, if the existing configurations are sufficient for your use case.) + All python config files were produced with `cmsDriver.py`. Two imporant parameters that one needs to verify in the central nanoAOD documentation are `--conditions` and `--era`. -- `--era` options from [WorkBookNanoAOD](https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookNanoAOD) or [XPOG](https://gitlab.cern.ch/cms-nanoAOD/nanoaod-doc/-/wikis/Releases/NanoAODv8) +- `--era` options from [WorkBookNanoAOD](https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookNanoAOD) or [XPOG](https://gitlab.cern.ch/cms-nanoAOD/nanoaod-doc/-/wikis/home) - `--conditions` can be found here [PdMV](https://twiki.cern.ch/twiki/bin/view/CMS/PdmV) Pre UL `cmsRun` python config files are generated by running `make_configs_preUL.sh` @@ -79,14 +101,14 @@ submission yaml card `card_example.yml` are provided. python crabby.py -c card.yml --make --submit ``` - `--make` and `--submit` calls are independent, allowing manual inspection of submit configs -- Add `--test` to disable publication on otherwise publishable config and produce a single file per dataset +- Add `--test True` to disable publication on otherwise publishable config and produce a single file per dataset
If experiencing problems with crab submission using the above instructions, e.g. on NAF-DESY ``` - source /cvmfs/grid.cern.ch/centos7-umd4-ui-4_200423/etc/profile.d/setup-c7-ui-example.sh + source /cvmfs/grid.desy.de/etc/profile.d/grid-ui-env.sh or /cvmfs/grid.cern.ch/centos7-umd4-ui-4_200423/etc/profile.d/setup-c7-ui-example.sh source /cvmfs/cms.cern.ch/common/crab-setup.sh prod source /cvmfs/cms.cern.ch/cmsset_default.sh < navigate to CMSSW_X_Y_Z/src > @@ -101,11 +123,13 @@ submission yaml card `card_example.yml` are provided.
Useful commands to get paths to individual processed files + This is to get a list of files stored at the respective site. ``` xrdfs [insert redirector to site] ls /store/path/to/your/crab/output/serialnumber > filelist.txt - ( if there is more than one serial number (more than 1k files processed) repeat command but append to textfile using >> instead of > ) - ( clean textfile for log entries ) - ( then append the redirector (needs modification by you for specific site) using this helper ) + # (example for T2_DE_RWTH: redirector would be grid-cms-xrootd.physik.rwth-aachen.de) + # ( if there is more than one serial number (more than 1k files processed) repeat command but append to textfile using >> instead of > ) + # ( clean textfile for log entries ) + # ( then append the redirector (needs modification by you for specific site) using this helper: ) python dataset_paths.py name_of_txt_file T2_DE_RWTH ``` @@ -144,9 +168,9 @@ When processing data, a lumi mask should be applied. The so called golden JSON s * Golden JSON, UL ``` +# 2ß16: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions16/13TeV/Legacy_2016/Cert_271036-284044_13TeV_Legacy2016_Collisions16_JSON.txt # 2017: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions17/13TeV/Legacy_2017/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt # 2018: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions18/13TeV/Legacy_2018/Cert_314472-325175_13TeV_Legacy2018_Collisions18_JSON.txt -# ``` * Golden JSON, pre-UL diff --git a/test/card_data_ULv2_with_ParT.yml b/test/card_data_ULv2_with_ParT.yml new file mode 100644 index 0000000..73d625d --- /dev/null +++ b/test/card_data_ULv2_with_ParT.yml @@ -0,0 +1,22 @@ +campaign: + name: 'test' # irrelevant + crab_template: template_crab.py + + # User specific + workArea: DataDoubleMuon17B_ULv2_with_ParT_yml + storageSite: T2_DE_RWTH + outLFNDirBase: /store/user/anstein/PFNano + voGroup: dcms + + # Campaign specific + tag_extension: PFNanoFromMiniV2WithParT # Will get appended after the current tag + tag_mod: # Will modify name in-place for MC eg. "PFNanoAODv1" will replace MiniAODv2 -> PFNanoAODv1 + publication: True + config: nano_data_2017_ULv2_allPF_ParT_NANO.py + # Specify if running on data + data: True + # data: False + lumiMask: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions17/13TeV/Legacy_2017/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt + # datasets will take either a list of DAS names or a text file containing them + datasets: /DoubleMuon/Run2017B-UL2017_MiniAODv2-v1/MINIAOD + \ No newline at end of file diff --git a/test/card_mc_ULv2_with_ParT.yml b/test/card_mc_ULv2_with_ParT.yml new file mode 100644 index 0000000..4c4a261 --- /dev/null +++ b/test/card_mc_ULv2_with_ParT.yml @@ -0,0 +1,22 @@ +campaign: + name: 'test' # irrelevant + crab_template: template_crab.py + + # User specific + workArea: MC_ULv2_with_ParT_yml + storageSite: T2_DE_RWTH + outLFNDirBase: /store/user/anstein/PFNano + voGroup: dcms + + # Campaign specific + tag_extension: PFNanoFromMiniV2WithParT # Will get appended after the current tag + tag_mod: # Will modify name in-place for MC eg. "PFNanoAODv1" will replace MiniAODv2 -> PFNanoAODv1 + publication: True + config: nano_mc_2017_ULv2_allPF_ParT_NANO.py + # Specify if running on data + # data: True + data: False + lumiMask: # json file + # datasets will take either a list of DAS names or a text file containing them + datasets: /DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM + \ No newline at end of file diff --git a/test/datasets/ULv2/data2017.txt b/test/datasets/ULv2/data2017.txt new file mode 100644 index 0000000..692f4a3 --- /dev/null +++ b/test/datasets/ULv2/data2017.txt @@ -0,0 +1,11 @@ +/DoubleMuon/Run2017B-UL2017_MiniAODv2-v1/MINIAOD +/DoubleMuon/Run2017C-UL2017_MiniAODv2-v1/MINIAOD +/DoubleMuon/Run2017D-UL2017_MiniAODv2-v1/MINIAOD +/DoubleMuon/Run2017E-UL2017_MiniAODv2-v1/MINIAOD +/DoubleMuon/Run2017F-UL2017_MiniAODv2-v1/MINIAOD + +/SingleMuon/Run2017B-UL2017_MiniAODv2-v1/MINIAOD +/SingleMuon/Run2017C-UL2017_MiniAODv2-v1/MINIAOD +/SingleMuon/Run2017D-UL2017_MiniAODv2-v1/MINIAOD +/SingleMuon/Run2017E-UL2017_MiniAODv2-v1/MINIAOD +/SingleMuon/Run2017F-UL2017_MiniAODv2-v1/MINIAOD \ No newline at end of file diff --git a/test/datasets/ULv2/mc2017.txt b/test/datasets/ULv2/mc2017.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/nano_data_2017_ULv2_allPF_ParT_NANO.py b/test/nano_data_2017_ULv2_allPF_ParT_NANO.py new file mode 100644 index 0000000..5cf3840 --- /dev/null +++ b/test/nano_data_2017_ULv2_allPF_ParT_NANO.py @@ -0,0 +1,101 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: nano_data_2017_ULv2_allPF_ParT --data --eventcontent NANOAOD --datatier NANOAOD --step NANO --conditions 106X_dataRun2_v37 --era Run2_2017,run2_nanoAOD_106Xv2 --customise_commands=process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)));process.MessageLogger.cerr.FwkReport.reportEvery=100;process.NANOAODoutput.fakeNameForCrab=cms.untracked.bool(True) --nThreads 4 -n -1 --filein /store/data/Run2017B/SingleMuon/MINIAOD/UL2017_MiniAODv2-v1/260000/9032A966-8ED0-B645-97B6-A8EBC1D8D3B9.root --customise PhysicsTools/PFNano/pfnano_cff.PFnano_customizeData_allPF_add_DeepJet_ParT --no_exec +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run2_2017_cff import Run2_2017 +from Configuration.Eras.Modifier_run2_nanoAOD_106Xv2_cff import run2_nanoAOD_106Xv2 + +process = cms.Process('NANO',Run2_2017,run2_nanoAOD_106Xv2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('PhysicsTools.NanoAOD.nano_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('/store/data/Run2017B/SingleMuon/MINIAOD/UL2017_MiniAODv2-v1/260000/9032A966-8ED0-B645-97B6-A8EBC1D8D3B9.root'), + secondaryFileNames = cms.untracked.vstring() +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('nano_data_2017_ULv2_allPF_ParT nevts:-1'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +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 = cms.untracked.string('nano_data_2017_ULv2_allPF_ParT_NANO.root'), + outputCommands = process.NANOAODEventContent.outputCommands +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '106X_dataRun2_v37', '') + +# Path and EndPath definitions +process.nanoAOD_step = cms.Path(process.nanoSequence) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.NANOAODoutput_step = cms.EndPath(process.NANOAODoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.nanoAOD_step,process.endjob_step,process.NANOAODoutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads=cms.untracked.uint32(4) +process.options.numberOfStreams=cms.untracked.uint32(0) +process.options.numberOfConcurrentLuminosityBlocks=cms.untracked.uint32(1) + +# customisation of the process. + +# Automatic addition of the customisation function from PhysicsTools.NanoAOD.nano_cff +from PhysicsTools.NanoAOD.nano_cff import nanoAOD_customizeData + +#call to customisation function nanoAOD_customizeData imported from PhysicsTools.NanoAOD.nano_cff +process = nanoAOD_customizeData(process) + +# Automatic addition of the customisation function from PhysicsTools.PFNano.pfnano_cff +from PhysicsTools.PFNano.pfnano_cff import PFnano_customizeData_allPF_add_DeepJet_ParT + +#call to customisation function PFnano_customizeData_allPF_add_DeepJet_ParT imported from PhysicsTools.PFNano.pfnano_cff +process = PFnano_customizeData_allPF_add_DeepJet_ParT(process) + +# End of customisation functions + +# Customisation from command line + +process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)));process.MessageLogger.cerr.FwkReport.reportEvery=100;process.NANOAODoutput.fakeNameForCrab=cms.untracked.bool(True) +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/test/nano_mc_2017_ULv2_allPF_ParT_NANO.py b/test/nano_mc_2017_ULv2_allPF_ParT_NANO.py new file mode 100644 index 0000000..304c4d3 --- /dev/null +++ b/test/nano_mc_2017_ULv2_allPF_ParT_NANO.py @@ -0,0 +1,102 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: nano_mc_2017_ULv2_allPF_ParT --mc --eventcontent NANOAODSIM --datatier NANOAODSIM --step NANO --conditions 106X_mc2017_realistic_v9 --era Run2_2017,run2_nanoAOD_106Xv2 --customise_commands=process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)));process.MessageLogger.cerr.FwkReport.reportEvery=100;process.NANOAODSIMoutput.fakeNameForCrab=cms.untracked.bool(True) --nThreads 4 -n -1 --filein root://cmsdcadisk.fnal.gov:1094/dcache/uscmsdisk/store/mc/RunIISummer20UL17MiniAODv2/DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/MINIAODSIM/106X_mc2017_realistic_v9-v2/100000/05044CB0-D61E-BC4D-95B5-EBE372E35C6F.root --customise PhysicsTools/PFNano/pfnano_cff.PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth --no_exec +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run2_2017_cff import Run2_2017 +from Configuration.Eras.Modifier_run2_nanoAOD_106Xv2_cff import run2_nanoAOD_106Xv2 + +process = cms.Process('NANO',Run2_2017,run2_nanoAOD_106Xv2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('PhysicsTools.NanoAOD.nano_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('root://cmsdcadisk.fnal.gov:1094/dcache/uscmsdisk/store/mc/RunIISummer20UL17MiniAODv2/DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/MINIAODSIM/106X_mc2017_realistic_v9-v2/100000/05044CB0-D61E-BC4D-95B5-EBE372E35C6F.root'), + secondaryFileNames = cms.untracked.vstring() +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('nano_mc_2017_ULv2_allPF_ParT nevts:-1'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.NANOAODSIMoutput = cms.OutputModule("NanoAODOutputModule", + compressionAlgorithm = cms.untracked.string('LZMA'), + compressionLevel = cms.untracked.int32(9), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('NANOAODSIM'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('nano_mc_2017_ULv2_allPF_ParT_NANO.root'), + outputCommands = process.NANOAODSIMEventContent.outputCommands +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '106X_mc2017_realistic_v9', '') + +# Path and EndPath definitions +process.nanoAOD_step = cms.Path(process.nanoSequenceMC) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.NANOAODSIMoutput_step = cms.EndPath(process.NANOAODSIMoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.nanoAOD_step,process.endjob_step,process.NANOAODSIMoutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads=cms.untracked.uint32(4) +process.options.numberOfStreams=cms.untracked.uint32(0) +process.options.numberOfConcurrentLuminosityBlocks=cms.untracked.uint32(1) + +# customisation of the process. + +# Automatic addition of the customisation function from PhysicsTools.NanoAOD.nano_cff +from PhysicsTools.NanoAOD.nano_cff import nanoAOD_customizeMC + +#call to customisation function nanoAOD_customizeMC imported from PhysicsTools.NanoAOD.nano_cff +process = nanoAOD_customizeMC(process) + +# Automatic addition of the customisation function from PhysicsTools.PFNano.pfnano_cff +from PhysicsTools.PFNano.pfnano_cff import PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth + +#call to customisation function PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth imported from PhysicsTools.PFNano.pfnano_cff +process = PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth(process) + +# End of customisation functions + +# Customisation from command line + +process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)));process.MessageLogger.cerr.FwkReport.reportEvery=100;process.NANOAODSIMoutput.fakeNameForCrab=cms.untracked.bool(True) +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion From 4ce6b1c7bc02b165faed3076d16bd48655a63481 Mon Sep 17 00:00:00 2001 From: Annika Stein Date: Thu, 15 Dec 2022 01:30:36 +0100 Subject: [PATCH 3/4] feat: more samples --- test/datasets/ULv2/data2017.txt | 4 +++- test/datasets/ULv2/mc2017.txt | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/test/datasets/ULv2/data2017.txt b/test/datasets/ULv2/data2017.txt index 692f4a3..a6733d5 100644 --- a/test/datasets/ULv2/data2017.txt +++ b/test/datasets/ULv2/data2017.txt @@ -1,3 +1,5 @@ +# https://cmsweb.cern.ch/das/request?view=list&limit=50&instance=prod/global&input=dataset=/*/*UL*MiniAODv2*/MINIAOD + /DoubleMuon/Run2017B-UL2017_MiniAODv2-v1/MINIAOD /DoubleMuon/Run2017C-UL2017_MiniAODv2-v1/MINIAOD /DoubleMuon/Run2017D-UL2017_MiniAODv2-v1/MINIAOD @@ -8,4 +10,4 @@ /SingleMuon/Run2017C-UL2017_MiniAODv2-v1/MINIAOD /SingleMuon/Run2017D-UL2017_MiniAODv2-v1/MINIAOD /SingleMuon/Run2017E-UL2017_MiniAODv2-v1/MINIAOD -/SingleMuon/Run2017F-UL2017_MiniAODv2-v1/MINIAOD \ No newline at end of file +/SingleMuon/Run2017F-UL2017_MiniAODv2-v1/MINIAOD diff --git a/test/datasets/ULv2/mc2017.txt b/test/datasets/ULv2/mc2017.txt index e69de29..1b4485b 100644 --- a/test/datasets/ULv2/mc2017.txt +++ b/test/datasets/ULv2/mc2017.txt @@ -0,0 +1,20 @@ +# https://cmsweb.cern.ch/das/request?view=list&limit=50&instance=prod%2Fglobal&input=dataset%3D%2F*%2FRunIISummer20UL17*MiniAOD*v2-106X*%2FMINIAODSIM + +# V + jets (inclusive only) +/DYJetsToLL_M-50_TuneCP5_13TeV-madgraphMLM-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM +/WJetsToLNu_TuneCP5_13TeV-madgraphMLM-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM + +# TTbar & single top +/TTTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/TTToHadronic_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM +/ST_s-channel_4f_leptonDecays_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/ST_t-channel_antitop_4f_InclusiveDecays_TuneCP5_13TeV-powheg-madspin-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/ST_t-channel_top_4f_InclusiveDecays_TuneCP5_13TeV-powheg-madspin-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/ST_tW_antitop_5f_inclusiveDecays_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM +/ST_tW_top_5f_inclusiveDecays_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM + +# Diboson +/WW_TuneCP5_13TeV-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/WZ_TuneCP5_13TeV-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/ZZ_TuneCP5_13TeV-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM From 228e453a4f7417760a2dd10f727d149dc133425c Mon Sep 17 00:00:00 2001 From: Annika Stein Date: Thu, 29 Dec 2022 00:23:31 +0100 Subject: [PATCH 4/4] fix: btagDeepC in all jet collections (ULv2), chore ParTTable --- plugins/ParTTableProducer.cc | 514 +----------------- python/addBTV.py | 44 +- test/card_data_ULv2_with_ParT.yml | 4 +- .../card_data_ULv2_with_ParT_for_resubmit.yml | 23 + test/card_mc_ULv2_with_ParT.yml | 4 +- test/dataset_paths.py | 2 +- test/datasets/ULv2/data2017.txt | 2 +- 7 files changed, 64 insertions(+), 529 deletions(-) create mode 100644 test/card_data_ULv2_with_ParT_for_resubmit.yml diff --git a/plugins/ParTTableProducer.cc b/plugins/ParTTableProducer.cc index 78d206b..8516c2b 100644 --- a/plugins/ParTTableProducer.cc +++ b/plugins/ParTTableProducer.cc @@ -39,17 +39,11 @@ #include "RecoBTag/FeatureTools/interface/sorting_modules.h" - -//#include "../interface/ntuple_pfCands.h" -//#include "../interface/sorting_modules.h" - - #include "TVector3.h" #include "DataFormats/GeometrySurface/interface/Line.h" #include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h" -//using namespace btagbtvdeep; using btagbtvdeep::SortingClass; using btagbtvdeep::mindrsvpfcand; using btagbtvdeep::invertSortingVector; @@ -63,9 +57,6 @@ using btagbtvdeep::invertSortingVector; #include "DataFormats/BTauReco/interface/JetTag.h" #include "DataFormats/BTauReco/interface/DeepFlavourTagInfo.h" -//#include "DataFormats/HepMCCandidate/interface/GenParticle.h" - -//#include "../interface/helpers.h" class TrackInfoBuilder{ public: @@ -227,122 +218,6 @@ class ParTTableProducer : public edm::stream::EDProducer<> { static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); static float mindistsvpfcand(const reco::TransientTrack track, const reco::VertexCompositePtrCandidateCollection svs_unsorted); - - /* - int jet_flavour(const pat::Jet& jet, - const std::vector& gToBB, - const std::vector& gToCC, - const std::vector& neutrinosLepB, - const std::vector& neutrinosLepB_C, - const std::vector& alltaus, - bool usePhysForLightAndUndefined) { - - int hflav = abs(jet.hadronFlavour()); - int pflav = abs(jet.partonFlavour()); - int physflav = 0; - if ( !( jet.genJet() ) ){ - if (pflav == 0) return 999; - else return 1000; - } - if(jet.genParton()) physflav=abs(jet.genParton()->pdgId()); - std::size_t nbs = jet.jetFlavourInfo().getbHadrons().size(); - std::size_t ncs = jet.jetFlavourInfo().getcHadrons().size(); - - unsigned int nbFromGSP(0); - for (reco::GenParticle p : gToBB) { - double dr(reco::deltaR(jet, p)); - if (dr < jetR_) ++nbFromGSP; - } - - unsigned int ncFromGSP(0); - for (reco::GenParticle p : gToCC) { - double dr(reco::deltaR(jet, p)); - if (dr < jetR_) ++ncFromGSP; - } - - //std::cout << " jet pt = " << jet.pt() << " hfl = " << hflav << " pfl = " << pflav << " genpart = " << physflav - // << " nbFromGSP = " << nbFromGSP << " ncFromGSP = " << ncFromGSP - // << " nBhadrons " << nbs << " nCHadrons " << ncs << std::endl; - if(hflav == 5) { //B jet - if(nbs > 1) { - if (nbFromGSP > 0) return 511; - else return 510; - } - else if(nbs == 1) { - for (std::vector::const_iterator it = neutrinosLepB.begin(); it != neutrinosLepB.end(); ++it){ - if(reco::deltaR(it->eta(),it->phi(),jet.eta(),jet.phi()) < 0.4) { - return 520; - } - } - for (std::vector::const_iterator it = neutrinosLepB_C.begin(); it != neutrinosLepB_C.end(); ++it){ - if(reco::deltaR(it->eta(),it->phi(),jet.eta(),jet.phi()) < 0.4) { - return 521; - } - } - return 500; - } - else { - if(usePhysForLightAndUndefined){ - if(physflav == 21) return 0; - else if(physflav == 3) return 2; - else if(physflav == 2 || physflav ==1) return 1; - else return 1000; - } - else return 1000; - } - } - else if(hflav == 4) { //C jet - if (ncs > 1) { - if (ncFromGSP > 0) return 411; - else return 410; - } - else return 400; - } - else { //not a heavy jet - if(alltaus.size()>0){ //check for tau in a simplistic way - bool ishadrtaucontained=true; - for(const auto& p:alltaus){ - size_t ndau=p.numberOfDaughters(); - for(size_t i=0;ipdgId()); - if(daupid == 13 || daupid == 11){ - ishadrtaucontained=false; - break; - } - if(daupid != 12 && daupid!=14 && daupid!=16 && - reco::deltaR(*dau,jet) > jetR_){ - ishadrtaucontained=false; - break; - } - } - } - if(ishadrtaucontained) return 600; - } - if(std::abs(pflav) == 4 || std::abs(pflav) == 5 || nbs || ncs) { - if(usePhysForLightAndUndefined){ - if(physflav == 21) return 0; - else if(physflav == 3) return 2; - else if(physflav == 2 || physflav ==1) return 1; - else return 1000; - } - else return 1000; - } - else if(usePhysForLightAndUndefined){ - if(physflav == 21) return 0; - else if(physflav == 3) return 2; - else if(physflav == 2 || physflav ==1) return 1; - else return 1000; - } - else { - if(pflav == 21) return 0; - else if(pflav == 3) return 2; - else if(pflav == 2 || pflav ==1) return 1; - else return 1000; - } - } - - }*/ private: @@ -355,14 +230,6 @@ class ParTTableProducer : public edm::stream::EDProducer<> { const std::string nameParT_; const std::string idx_nameParT_; - //const std::string storeAK4Truth_; - - - //const edm::EDGetTokenT genParticlesToken_; - - //const bool readBtag_; - //const double jet_radius_; - //const bool add_DeepJet_noclip_; edm::EDGetTokenT> jet_token_; edm::EDGetTokenT vtx_token_; @@ -378,9 +245,6 @@ class ParTTableProducer : public edm::stream::EDProducer<> { const float min_candidate_pt_ = 0.95; - //typedef std::vector TagInfoCollection; - //const edm::EDGetTokenT tag_info_src_; - constexpr static unsigned n_cpf_ = 25; constexpr static unsigned n_npf_ = 25; @@ -388,8 +252,6 @@ class ParTTableProducer : public edm::stream::EDProducer<> { constexpr static double jetR_ = 0.4; - //constexpr static bool usePhysForLightAndUndefined = false; - }; @@ -400,18 +262,10 @@ template< typename T> ParTTableProducer::ParTTableProducer(const edm::ParameterSet &iConfig) : nameParT_(iConfig.getParameter("nameParT")), idx_nameParT_(iConfig.getParameter("idx_nameParT")), - //readBtag_(iConfig.getParameter("readBtag")), - //jet_radius_(iConfig.getParameter("jet_radius")), - //add_DeepJet_noclip_(iConfig.getParameter("add_DeepJet_noclip")), jet_token_(consumes>(iConfig.getParameter("jets"))), vtx_token_(consumes(iConfig.getParameter("vertices"))), cand_token_(consumes(iConfig.getParameter("candidates"))), sv_token_(consumes(iConfig.getParameter("secondary_vertices"))){ - - //storeAK4Truth_(iConfig.getParameter("storeAK4Truth")), - //genParticlesToken_(consumes(iConfig.getParameter("genparticles"))), - //jet_token_(consumes>(iConfig.getParameter("jets"))), - //tag_info_src_(consumes(iConfig.getParameter("tagInfo_src"))){ produces(nameParT_); } @@ -425,57 +279,18 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS // only necessary to explicitly check correct matching of jets std::vector jetIdx_dj; - //edm::Handle genParticlesHandle; - //iEvent.getByToken(genParticlesToken_, genParticlesHandle); - auto jets = iEvent.getHandle(jet_token_); iEvent.getByToken(vtx_token_, vtxs_); iEvent.getByToken(cand_token_, cands_); iEvent.getByToken(sv_token_, svs_); iSetup.get().get("TransientTrackBuilder", track_builder_); - - //edm::Handle tag_infos; - //iEvent.getByToken(tag_info_src_, tag_infos); - - - //std::vector neutrinosLepB; - //std::vector neutrinosLepB_C; - - //std::vector gToBB; - //std::vector gToCC; - //std::vector alltaus; unsigned nJets = jets->size(); - //std::vector jet_N_CPFCands(nJets); - //std::vector jet_N_NPFCands(nJets); - //std::vector jet_N_PVs(nJets); - //std::vector jet_N_SVs(nJets); - - - //std::vector jet_FlavSplit(nJets); - - // should default to 0 if less than nCpf cpf with information - //std::vector> Cpfcan_BtagPf_trackEtaRel_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_BtagPf_trackPtRel_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_BtagPf_trackPPar_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_BtagPf_trackDeltaR_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_BtagPf_trackPParRatio_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_BtagPf_trackSip2dVal_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_BtagPf_trackSip2dSig_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_BtagPf_trackSip3dVal_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_BtagPf_trackSip3dSig_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_BtagPf_trackJetDistVal_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_ptrel_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_drminsv_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_VTX_ass_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_puppiw_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_chi2_nCpf(n_cpf_, std::vector(nJets)); - //std::vector> Cpfcan_quality_nCpf(n_cpf_, std::vector(nJets)); - // new variables for ParT + std::vector> Cpfcan_distminsv_nCpf(n_cpf_, std::vector(nJets)); // 4 vectors std::vector> Cpfcan_pt_nCpf(n_cpf_, std::vector(nJets)); @@ -483,16 +298,7 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS std::vector> Cpfcan_phi_nCpf(n_cpf_, std::vector(nJets)); std::vector> Cpfcan_e_nCpf(n_cpf_, std::vector(nJets)); - - // should default to 0 if less than nNpf npf with information - //std::vector> Npfcan_ptrel_nNpf(n_npf_, std::vector(nJets)); - //std::vector> Npfcan_deltaR_nNpf(n_npf_, std::vector(nJets)); - //std::vector> Npfcan_isGamma_nNpf(n_npf_, std::vector(nJets)); - //std::vector> Npfcan_HadFrac_nNpf(n_npf_, std::vector(nJets)); - //std::vector> Npfcan_drminsv_nNpf(n_npf_, std::vector(nJets)); - //std::vector> Npfcan_puppiw_nNpf(n_npf_, std::vector(nJets)); - - // new variables for ParT + std::vector> Npfcan_etarel_nNpf(n_npf_, std::vector(nJets)); std::vector> Npfcan_phirel_nNpf(n_npf_, std::vector(nJets)); // 4 vectors @@ -500,32 +306,14 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS std::vector> Npfcan_eta_nNpf(n_npf_, std::vector(nJets)); std::vector> Npfcan_phi_nNpf(n_npf_, std::vector(nJets)); std::vector> Npfcan_e_nNpf(n_npf_, std::vector(nJets)); + - - - // should default to 0 if less than nSv SVs with information - //std::vector> sv_mass_nSV(n_sv_, std::vector(nJets)); - //std::vector> sv_pt_nSV(n_sv_, std::vector(nJets)); - //std::vector> sv_ntracks_nSV(n_sv_, std::vector(nJets)); - //std::vector> sv_chi2_nSV(n_sv_, std::vector(nJets)); - //std::vector> sv_normchi2_nSV(n_sv_, std::vector(nJets)); - //std::vector> sv_dxy_nSV(n_sv_, std::vector(nJets)); - //std::vector> sv_dxysig_nSV(n_sv_, std::vector(nJets)); - //std::vector> sv_d3d_nSV(n_sv_, std::vector(nJets)); - //std::vector> sv_d3dsig_nSV(n_sv_, std::vector(nJets)); - //std::vector> sv_costhetasvpv_nSV(n_sv_, std::vector(nJets)); - - // new variables for ParT std::vector> sv_etarel_nSV(n_sv_, std::vector(nJets)); std::vector> sv_phirel_nSV(n_sv_, std::vector(nJets)); // 4 vectors (pt was already included in DeepJet) std::vector> sv_eta_nSV(n_sv_, std::vector(nJets)); std::vector> sv_phi_nSV(n_sv_, std::vector(nJets)); std::vector> sv_e_nSV(n_sv_, std::vector(nJets)); - - //std::vector> sv_deltaR_nSV(n_sv_, std::vector(nJets)); - //std::vector> sv_enratio_nSV(n_sv_, std::vector(nJets)); - // old variables, but use a fifth SV as well for ParT @@ -542,57 +330,6 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS std::vector sv_deltaR_4(nJets); std::vector sv_enratio_4(nJets); - /* - if (storeAK4Truth_ == "yes") { - - neutrinosLepB.clear(); - neutrinosLepB_C.clear(); - gToBB.clear(); - gToCC.clear(); - alltaus.clear(); - - for (const reco::Candidate &genC : *genParticlesHandle) { - const reco::GenParticle &gen = static_cast< const reco::GenParticle &>(genC); - if(abs(gen.pdgId())==12||abs(gen.pdgId())==14||abs(gen.pdgId())==16) { - const reco::GenParticle* mother = static_cast< const reco::GenParticle*> (gen.mother()); - if(mother!=NULL) { - if((abs(mother->pdgId())>500&&abs(mother->pdgId())<600)||(abs(mother->pdgId())>5000&&abs(mother->pdgId())<6000)) { - neutrinosLepB.emplace_back(gen); - } - if((abs(mother->pdgId())>400&&abs(mother->pdgId())<500)||(abs(mother->pdgId())>4000&&abs(mother->pdgId())<5000)) { - neutrinosLepB_C.emplace_back(gen); - } - } - else { - std::cout << "No mother" << std::endl; - } - } - - int id(std::abs(gen.pdgId())); - int status(gen.status()); - - if (id == 21 && status >= 21 && status <= 59) { //// Pythia8 hard scatter, ISR, or FSR - if ( gen.numberOfDaughters() == 2 ) { - const reco::Candidate* d0 = gen.daughter(0); - const reco::Candidate* d1 = gen.daughter(1); - if ( std::abs(d0->pdgId()) == 5 && std::abs(d1->pdgId()) == 5 - && d0->pdgId()*d1->pdgId() < 0 && reco::deltaR(*d0, *d1) < jetR_) gToBB.push_back(gen) ; - if ( std::abs(d0->pdgId()) == 4 && std::abs(d1->pdgId()) == 4 - && d0->pdgId()*d1->pdgId() < 0 && reco::deltaR(*d0, *d1) < jetR_) gToCC.push_back(gen) ; - } - } - - if(id == 15 && false){ - alltaus.push_back(gen); - } - - } - - } - */ - - - //std::cout << "Start jet loop." << std::endl; for (unsigned i_jet = 0; i_jet < jets->size(); ++i_jet) { const auto &jet = jets->at(i_jet); @@ -612,10 +349,8 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS std::vector allSVs; - //std::vector> sv_mass_0to3(4, std::vector(jets->size())); jetIdx_dj.push_back(i_jet); - //jet_N_SVs[i_jet] = 0; for (const auto &sv : *svs_) { // Factor in cuts in NanoAOD for indexing Measurement1D dl= vdist.distance(vtxs_->front(), VertexState(RecoVertex::convertPos(sv.position()),RecoVertex::convertError(sv.error()))); @@ -624,7 +359,6 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS } if (reco::deltaR2(sv, jet) < jetR_ * jetR_) { jetSVs.push_back(&sv); - //jet_N_SVs[i_jet]++; } } @@ -637,56 +371,13 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS }); // counter to get flat info per jet for SVs - unsigned i_sv_in_jet = 0; - // I'd like to try something like this: https://stackoverflow.com/questions/50870374/better-way-to-map-string-fields-to-variables - // have a map from key to variables inside the SV loop such that I do not need to write every single constituent (more relevant for PFcands later) + unsigned i_sv_in_jet = 0; for (const auto &sv : jetSVs) { -/* - // auto svPtrs = svs_->ptrs(); - auto svInNewList = std::find(allSVs.begin(), allSVs.end(), sv ); - if (svInNewList == allSVs.end()) { - // continue; - svIdx.push_back(-1); - } else{ - svIdx.push_back(svInNewList - allSVs.begin()); - } - outSVs->push_back(sv); - jetIdx_sv.push_back(i_jet); -*/ //if (readBtag_ && !vtxs_->empty()) { if (!vtxs_->empty()) { - if (i_sv_in_jet < 4) { - /* - // this is all already included via DeepJet - sv_mass_0to3[i_sv_in_jet][i_jet] = sv->mass(); - sv_pt_0to3[i_sv_in_jet][i_jet] = sv->pt(); - sv_ntracks_0to3[i_sv_in_jet][i_jet] = sv->numberOfDaughters(); - sv_chi2_0to3[i_sv_in_jet][i_jet] = sv->vertexChi2(); - sv_normchi2_0to3[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(sv->vertexChi2() / sv->vertexNdof(), 1000, -1000, 1000); - const auto& dxy_meas = btagbtvdeep::vertexDxy(*sv, *pv_); - sv_dxy_0to3[i_sv_in_jet][i_jet] = dxy_meas.value(); - sv_dxysig_0to3[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(dxy_meas.value() / dxy_meas.error(), 0, -1, 800); - const auto& d3d_meas = btagbtvdeep::vertexD3d(*sv, *pv_); - sv_d3d_0to3[i_sv_in_jet][i_jet] = d3d_meas.value(); - sv_d3dsig_0to3[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(d3d_meas.value() / d3d_meas.error(), 0, -1, 800); - sv_costhetasvpv_0to3[i_sv_in_jet][i_jet] = btagbtvdeep::vertexDdotP(*sv, *pv_); - // Jet related - sv_ptrel_0to3[i_sv_in_jet][i_jet] = sv->pt() / jet.pt(); - sv_phirel_0to3[i_sv_in_jet][i_jet] = reco::deltaPhi(*sv, jet); - sv_deltaR_0to3[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaR(*sv, jet_dir)) - 0.5, 0, -2, 0); - sv_enratio_0to3[i_sv_in_jet][i_jet] = sv->energy() / jet.energy(); - */ - /* - // no clip - if (add_DeepJet_noclip_) { - sv_normchi2_0to3_noclip[i_sv_in_jet][i_jet] = sv->vertexChi2() / sv->vertexNdof(); - sv_dxysig_0to3_noclip[i_sv_in_jet][i_jet] = dxy_meas.value() / dxy_meas.error(); - sv_d3dsig_0to3_noclip[i_sv_in_jet][i_jet] = d3d_meas.value() / d3d_meas.error(); - sv_deltaR_0to3_noclip[i_sv_in_jet][i_jet] = std::fabs(reco::deltaR(*sv, jet_dir)); - } - */ + if (i_sv_in_jet < 4) { // this is new for ParT: sv_etarel_nSV[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(sv->eta()-jet.eta())-0.5,0,-2,0); @@ -698,21 +389,6 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS } else { if (i_sv_in_jet == 4) { // the fifth SV, new for ParT, not yet for DeepJet - /* - 'sv_pt','sv_deltaR', - 'sv_mass', - 'sv_etarel', - 'sv_phirel', - 'sv_ntracks', - 'sv_chi2', - 'sv_normchi2', - 'sv_dxy', - 'sv_dxysig', - 'sv_d3d', - 'sv_d3dsig', - 'sv_costhetasvpv', - 'sv_enratio', - */ sv_pt_4[i_jet] = sv->pt(); sv_deltaR_4[i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaR(*sv, jet)) - 0.5, 0, -2, 0); sv_mass_4[i_jet] = sv->mass(); @@ -726,8 +402,6 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS sv_d3d_4[i_jet] = d3d_meas.value(); sv_d3dsig_4[i_jet] = btagbtvdeep::catch_infs_and_bound(sv_d3d_4[i_jet] / d3d_meas.error(), 0, -1, 800); sv_costhetasvpv_4[i_jet] = btagbtvdeep::vertexDdotP(*sv, *pv_); - // Jet related - //sv_ptrel_4[i_jet] = sv->pt() / jet.pt(); sv_enratio_4[i_jet] = sv->energy() / jet_uncorr_e; @@ -745,9 +419,8 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS } i_sv_in_jet++; - } + } // end sv loop - //std::cout << "Successfully filled SV info, start sorting PF cands now." << std::endl; // PF Cands std::vector const & daughters = jet.daughterPtrVector(); @@ -757,32 +430,21 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS // first time looping over all pf candidates // to fill sorted indices and get a connection back to the old indices - - //jet_N_CPFCands[i_jet] = 0; - //jet_N_NPFCands[i_jet] = 0; - for (unsigned int i = 0; i < jet.numberOfDaughters(); i++) { auto cand = jet.daughter(i); - //if ( cand.isNull() ) continue; - //auto const *packedCand = dynamic_cast (cand.get()); - //if ( packedCand == nullptr ) continue; if (cand) { // candidates under 950MeV (configurable) are not considered // might change if we use also white-listing if (cand->pt() < min_candidate_pt_) continue; if (cand->charge() != 0) { - //auto& trackinfo = trackinfos.emplace(i, track_builder).first->second; - //trackinfo.buildTrackInfo(cand, jet_dir, jet_ref_track_dir, *pv_); // *pv_ is an alternative to vtxs_->at(0) btagbtvdeep::TrackInfoBuilder trkinfo(track_builder_); // similar to https://github.com/cms-sw/cmssw/blob/master/RecoBTag/FeatureTools/interface/ChargedCandidateConverter.h trkinfo.buildTrackInfo(cand, jet_dir, jet_ref_track_dir, *pv_); c_sorted.emplace_back( i, trkinfo.getTrackSip2dSig(), -btagbtvdeep::mindrsvpfcand(svs_unsorted, cand), cand->pt() / jet_uncorr_pt); - //jet_N_CPFCands[i_jet]++; } else { n_sorted.emplace_back(i, -1, -btagbtvdeep::mindrsvpfcand(svs_unsorted, cand), cand->pt() / jet_uncorr_pt); - //jet_N_NPFCands[i_jet]++; } } } @@ -797,113 +459,30 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS c_sortedindices = btagbtvdeep::invertSortingVector(c_sorted); n_sortedindices = btagbtvdeep::invertSortingVector(n_sorted); -/* - if (readBtag_ && !vtxs_->empty()) { - for (unsigned int i = 0; i < jet.numberOfDaughters(); i++) { - // get pointer and check that is correct - auto cand = dynamic_cast(jet.daughter(i)); - if (!cand) - continue; - // candidates under 950MeV are not considered - // might change if we use also white-listing - if (cand->pt() < 0.95) - continue; - - auto packed_cand = dynamic_cast(cand); - - - float drminpfcandsv = btagbtvdeep::mindrsvpfcand(svs_unsorted, cand); - if (cand->charge() != 0) { - // is charged candidate - auto entry = c_sortedindices.at(i); - std::cout << "Current candidate is " << i << " and entry = c_sortedindices.at(i) = " << entry << std::endl; - // need only the first 25 cpfs for DeepJet - if (entry > 24) { - continue; - } -*/ - // get cached track info - //auto& trackinfo = trackinfos.at(i); -/* - if (flip_ && (trackinfo.getTrackSip3dSig() > negative_cut)) { - continue; - } -*/ -/* - // get_ref to vector element - auto& c_pf_features = features.c_pf_features.at(entry); -*/ -/* - std::cout << "Prior to filling with entries for this candidate:" << std::endl; - std::cout << "Size of Cpfcan_puppiw_0to24 is " << Cpfcan_puppiw_0to24.size() << std::endl; - std::cout << "Size of the first column of Cpfcan_puppiw_0to24 is " << Cpfcan_puppiw_0to24[0].size() << std::endl; - // fill feature structure - if (packed_cand) { - Cpfcan_puppiw_0to24[entry][i_jet] = packed_cand->puppiWeight(); - - std::cout << "After filling with entries for this candidate:" << std::endl; - std::cout << "Size of Cpfcan_puppiw_0to24 is " << Cpfcan_puppiw_0to24.size() << std::endl; - std::cout << "Size of the first column of Cpfcan_puppiw_0to24 is " << Cpfcan_puppiw_0to24[0].size() << std::endl; -*/ -/* - btagbtvdeep::packedCandidateToFeatures( - packed_cand, jet, trackinfo, drminpfcandsv, static_cast(jet_radius_), c_pf_features, flip_); -*/ -/* - } else { - // is neutral candidate - auto entry = n_sortedindices.at(i); - // need only the first 25 npfs for DeepJet - if (entry > 24) { - continue; - } - - } - } - } -*/ - //std::cout << "Start looping over PF cands to fill info." << std::endl; - int i_pf_in_jet = 0; for (const auto &cand : daughters) { auto candPtrs = cands_->ptrs(); auto candInNewList = std::find( candPtrs.begin(), candPtrs.end(), cand ); if ( candInNewList == candPtrs.end() ) { - //std::cout << "Cannot find candidate : " << cand.id() << ", " << cand.key() << ", pt = " << cand->pt() << std::endl; continue; } -/* - outCands->push_back(cand); - jetIdx_pf.push_back(i_jet); - pfcandIdx.push_back(candInNewList - candPtrs.begin()); - //cand_pt.push_back(cand->pt()); -*/ + if (!vtxs_->empty()) { if ( cand.isNull() ) continue; auto const *packedCand = dynamic_cast (cand.get()); if ( packedCand == nullptr ) continue; if (packedCand->pt() < min_candidate_pt_) continue; - //float drminpfcandsv = btagbtvdeep::mindrsvpfcand(svs_unsorted, &(*cand)); + if ( packedCand->charge() != 0 ) { // is charged candidate auto entry_sorted = c_sortedindices.at(i_pf_in_jet); - //std::cout << "Current candidate is " << i_pf_in_jet << " and entry_sorted = c_sortedindices.at(i_pf_in_jet) = " << entry_sorted << std::endl; // need only the first 25 cpfs for ParT if (entry_sorted >= n_cpf_) { continue; } - - //Cpfcan_puppiw_0to24[entry_sorted][i_jet] = packedCand->puppiWeight(); - //Cpfcan_VTX_ass_0to24[entry_sorted][i_jet] = packedCand->pvAssociationQuality(); - //Cpfcan_drminsv_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(drminpfcandsv, 0, -1. * jet_radius_, 0, -1. * jet_radius_); - //Cpfcan_ptrel_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(packedCand->pt() / jet.pt(), 0, -1, 0, -1); - - - - Cpfcan_pt_nCpf[entry_sorted][i_jet] = cand->pt(); Cpfcan_eta_nCpf[entry_sorted][i_jet] = cand->eta(); @@ -912,95 +491,29 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS if ( packedCand && packedCand->hasTrackDetails()){ - //const auto& pseudo_track = packedCand->pseudoTrack(); - //Cpfcan_chi2_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(pseudo_track.normalizedChi2(), 300, -1, 300); - - // this returns the quality enum not a mask. - //Cpfcan_quality_0to24[entry_sorted][i_jet] = pseudo_track.qualityMask(); - - //btagbtvdeep::TrackInfoBuilder trkinfo(track_builder_); TrackInfoBuilder trkinfo(track_builder_); // similar to https://github.com/cms-sw/cmssw/blob/master/RecoBTag/FeatureTools/interface/ChargedCandidateConverter.h trkinfo.buildTrackInfo(&(*packedCand), jet_dir, jet_ref_track_dir, *pv_); - - // with clip - //Cpfcan_BtagPf_trackEtaRel_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackEtaRel(), 0, -5, 15); - //Cpfcan_BtagPf_trackPtRel_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackPtRel(), 0, -1, 4); - //Cpfcan_BtagPf_trackPPar_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackPPar(), 0, -1e5, 1e5); - //Cpfcan_BtagPf_trackDeltaR_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackDeltaR(), 0, -5, 5); - //Cpfcan_BtagPf_trackPParRatio_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackPParRatio(), 0, -10, 100); - //Cpfcan_BtagPf_trackSip2dVal_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackSip2dVal(), 0, -1, 70); - //Cpfcan_BtagPf_trackSip2dSig_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackSip2dSig(), 0, -1, 4e4); - //Cpfcan_BtagPf_trackSip3dVal_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackSip3dVal(), 0, -1, 1e5); - //Cpfcan_BtagPf_trackSip3dSig_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackSip3dSig(), 0, -1, 4e4); - //Cpfcan_BtagPf_trackJetDistVal_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(trkinfo.getTrackJetDistVal(), 0, -20, 1); - - - - //c_pf_features.btagPf_trackPtRatio = btagbtvdeep::catch_infs_and_bound(track_info.getTrackPtRatio(), 0, -1, 10); - - //Cpfcan_ptrel.push_back(btagbtvdeep::catch_infs_and_bound(cand->pt() / jet.pt(), 0, -1, 0, -1)); - //Cpfcan_drminsv.push_back(btagbtvdeep::catch_infs_and_bound(mindrsvpfcand(svs_unsorted, &(*cand), 0.4), 0, -1. * jet_radius_, 0, -1. * jet_radius_)); - - - // already done trackinfo.buildTrackInfo(PackedCandidate_,jetDir,jetRefTrackDir,pv); const reco::TransientTrack ttrack = trkinfo.getTTrack(); float mindistsv = mindistsvpfcand(ttrack, svs_unsorted); - //GlobalPoint mindistgpsv = mingpsvpfcand(ttrack); - //GlobalPoint gppv = gppvpfcand(ttrack, jetRefTrackDir, pv); Cpfcan_distminsv_nCpf[entry_sorted][i_jet] = mindistsv; } else { - continue; + continue; // nothing else new to fill for ParT which does not have track details for cpfs - /* - // default negative chi2 and loose track if notTrackDetails - Cpfcan_chi2_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(-1, 300, -1, 300); - Cpfcan_quality_0to24[entry_sorted][i_jet] = (1 << reco::TrackBase::loose); - */ - - - - - // vector defaults to 0 anyway - //Cpfcan_BtagPf_trackEtaRel.push_back(0); - //Cpfcan_BtagPf_trackPtRel.push_back(0); - //Cpfcan_BtagPf_trackPPar.push_back(0); - //Cpfcan_BtagPf_trackDeltaR.push_back(0); - //Cpfcan_BtagPf_trackPParRatio.push_back(0); - //Cpfcan_BtagPf_trackSip2dVal.push_back(0); - //Cpfcan_BtagPf_trackSip2dSig.push_back(0); - //Cpfcan_BtagPf_trackSip3dVal.push_back(0); - //Cpfcan_BtagPf_trackSip3dSig.push_back(0); - //Cpfcan_BtagPf_trackJetDistVal.push_back(0); - //Cpfcan_ptrel.push_back(0); - //Cpfcan_drminsv.push_back(0); - } } else { - // is neutral candidate auto entry_sorted = n_sortedindices.at(i_pf_in_jet); - //std::cout << "Current candidate is " << i_pf_in_jet << " and entry_sorted = c_sortedindices.at(i_pf_in_jet) = " << entry_sorted << std::endl; // need only the first 25 npfs for ParT if (entry_sorted >= n_npf_) { continue; } - /* - Npfcan_puppiw_0to24[entry_sorted][i_jet] = packedCand->puppiWeight(); - Npfcan_HadFrac_0to24[entry_sorted][i_jet] = packedCand->hcalFraction(); - if (std::abs(packedCand->pdgId()) == 22) - Npfcan_isGamma_0to24[entry_sorted][i_jet] = 1; - // catch - Npfcan_deltaR_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(reco::deltaR(*packedCand, jet), 0, -0.6, 0, -0.6); - Npfcan_drminsv_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(drminpfcandsv, 0, -1. * jet_radius_, 0, -1. * jet_radius_); - Npfcan_ptrel_0to24[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(packedCand->pt() / jet.pt(), 0, -1, 0, -1); - */ Npfcan_etarel_nNpf[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(cand->eta()-jet.eta()), 0, -2, 0, -0.5); Npfcan_phirel_nNpf[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaPhi(cand->phi(),jet.phi())), 0, -2, 0, -0.5); Npfcan_pt_nNpf[entry_sorted][i_jet] = cand->pt(); @@ -1011,13 +524,12 @@ void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iS } } i_pf_in_jet++; - } // end jet loop - } + } // end constituents loop + } // end jet loop // ParTInputs table auto partTable = std::make_unique(nJets, nameParT_, false, true); - //partTable->addColumn("ParT_jetIdx", jetIdx_dj, "Index of the parent jet", nanoaod::FlatTable::IntColumn); // ============================================================== Cpfs =================================================================== @@ -1160,11 +672,7 @@ void ParTTableProducer::fillDescriptions(edm::ConfigurationDescriptions &desc edm::ParameterSetDescription desc; desc.add("nameParT", "Jet"); desc.add("idx_nameParT", "djIdx"); - //desc.add("jet_radius", true); - //desc.add("storeAK4Truth","no"); - //desc.add("genparticles", edm::InputTag("prunedGenParticles")); desc.add("jets", edm::InputTag("slimmedJets")); - //desc.add("tagInfo_src", edm::InputTag("pfDeepFlavourTagInfosWithDeepInfo")); desc.add("vertices", edm::InputTag("offlineSlimmedPrimaryVertices")); desc.add("candidates", edm::InputTag("packedPFCandidates")); desc.add("secondary_vertices", edm::InputTag("slimmedSecondaryVertices")); diff --git a/python/addBTV.py b/python/addBTV.py index 47b8e36..9244c12 100644 --- a/python/addBTV.py +++ b/python/addBTV.py @@ -243,10 +243,10 @@ def get_DeepJet_outputs(): float, doc="DeepJet lepb tag probability", precision=10), - #btagDeepFlavC=Var("bDiscriminator('pfDeepFlavourJetTags:probc')", - # float, - # doc="DeepJet c tag probability", - # precision=10), # until 106X already included in nano + btagDeepFlavC=Var("bDiscriminator('pfDeepFlavourJetTags:probc')", + float, + doc="DeepJet c tag probability", + precision=10), # until 106X already included in nano btagDeepFlavUDS=Var("bDiscriminator('pfDeepFlavourJetTags:probuds')", float, doc="DeepJet uds tag probability", @@ -280,19 +280,19 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D precision=10), btagDeepB_b=Var("bDiscriminator('pfDeepCSVJetTags:probb')", float, - doc="DeepCSV b tag discriminator", + doc="DeepCSV Prob(b)", precision=10), btagDeepB_bb=Var("bDiscriminator('pfDeepCSVJetTags:probbb')", float, - doc="DeepCSV bb tag discriminator", + doc="DeepCSV Prob(bb)", precision=10), - #btagDeepC=Var("bDiscriminator('pfDeepCSVJetTags:probc')", - # float, - # doc="DeepCSV c btag discriminator", - # precision=10), # only necessary after 106X + btagDeepC=Var("bDiscriminator('pfDeepCSVJetTags:probc')", + float, + doc="DeepCSV Prob(c)", + precision=10), # only necessary after 106X btagDeepL=Var("bDiscriminator('pfDeepCSVJetTags:probudsg')", float, - doc="DeepCSV light btag discriminator", + doc="DeepCSV Prob(udsg)", precision=10), ) @@ -320,7 +320,11 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D CommonVars, HadronCountingVars if runOnMC else cms.PSet(), # hadrons from Generator only relevant for MC get_DeepCSV_vars() if ('DeepCSV' in keepInputs) else cms.PSet(), - get_DeepJet_outputs() # outputs are added in any case, inputs only if requested + get_DeepJet_outputs(), # outputs are added in any case, inputs only if requested + #btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')", + # float, + # doc="DeepCSV Prob(c)", + # precision=10), )) if ('DeepJet' in keepInputs): @@ -353,10 +357,10 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D # btagDDCvBV2 = Var("bDiscriminator('pfMassIndependentDeepDoubleCvBV2JetTags:probHcc')",float,doc="DeepDoubleX V2 discriminator for H(Z)->cc vs H(Z)->bb",precision=10), #), # only necessary before 10_6_19 get_DDX_vars() if ('DDX' in keepInputs) else cms.PSet(), - btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')", - float, - doc="DeepCSV charm btag discriminator", - precision=10), + #btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')", + # float, + # doc="DeepCSV Prob(c)", + # precision=10), )) # Subjets @@ -371,10 +375,10 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D variables=cms.PSet( CommonVars, #HadronCountingVars if runOnMC else cms.PSet(), # only necessary before 106x - btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')", - float, - doc="DeepCSV charm btag discriminator", - precision=10), + #btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')", + # float, + # doc="DeepCSV Prob(c)", + # precision=10), )) diff --git a/test/card_data_ULv2_with_ParT.yml b/test/card_data_ULv2_with_ParT.yml index 73d625d..2d89fbb 100644 --- a/test/card_data_ULv2_with_ParT.yml +++ b/test/card_data_ULv2_with_ParT.yml @@ -3,7 +3,7 @@ campaign: crab_template: template_crab.py # User specific - workArea: DataDoubleMuon17B_ULv2_with_ParT_yml + workArea: DataSingleMuon17C_ULv2v1_with_ParT_yml storageSite: T2_DE_RWTH outLFNDirBase: /store/user/anstein/PFNano voGroup: dcms @@ -18,5 +18,5 @@ campaign: # data: False lumiMask: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions17/13TeV/Legacy_2017/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt # datasets will take either a list of DAS names or a text file containing them - datasets: /DoubleMuon/Run2017B-UL2017_MiniAODv2-v1/MINIAOD + datasets: /SingleMuon/Run2017C-UL2017_MiniAODv2-v1/MINIAOD \ No newline at end of file diff --git a/test/card_data_ULv2_with_ParT_for_resubmit.yml b/test/card_data_ULv2_with_ParT_for_resubmit.yml new file mode 100644 index 0000000..9d3be67 --- /dev/null +++ b/test/card_data_ULv2_with_ParT_for_resubmit.yml @@ -0,0 +1,23 @@ +campaign: + name: 'test' # irrelevant + crab_template: template_crab.py + + # User specific + workArea: DataDoubleMuon17F_recov_ULv2_with_ParT_yml + storageSite: T2_DE_RWTH + outLFNDirBase: /store/user/anstein/PFNano + voGroup: dcms + + # Campaign specific + tag_extension: PFNanoFromMiniV2WithParT # Will get appended after the current tag + tag_mod: # Will modify name in-place for MC eg. "PFNanoAODv1" will replace MiniAODv2 -> PFNanoAODv1 + publication: True + config: nano_data_2017_ULv2_allPF_ParT_NANO.py + # Specify if running on data + data: True + # data: False + # lumiMask: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions17/13TeV/Legacy_2017/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt + lumiMask: /afs/desy.de/user/a/anstein/private/pfnano_dev/CMSSW_10_6_30/src/PhysicsTools/PFNano/test/DataDoubleMuon17F_ULv2_with_ParT_yml/crab_DoubleMuon_Run2017F-UL2017_MiniAODv2-v1_MINIAOD/results/notFinishedLumis.json + # datasets will take either a list of DAS names or a text file containing them + datasets: /DoubleMuon/Run2017F-UL2017_MiniAODv2-v1/MINIAOD + \ No newline at end of file diff --git a/test/card_mc_ULv2_with_ParT.yml b/test/card_mc_ULv2_with_ParT.yml index 4c4a261..be9f54d 100644 --- a/test/card_mc_ULv2_with_ParT.yml +++ b/test/card_mc_ULv2_with_ParT.yml @@ -3,7 +3,7 @@ campaign: crab_template: template_crab.py # User specific - workArea: MC_ULv2_with_ParT_yml + workArea: Test2_MC_DYJetsToLL_M-50_ULv2_with_ParT_yml storageSite: T2_DE_RWTH outLFNDirBase: /store/user/anstein/PFNano voGroup: dcms @@ -18,5 +18,5 @@ campaign: data: False lumiMask: # json file # datasets will take either a list of DAS names or a text file containing them - datasets: /DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM + datasets: /DYJetsToLL_M-50_TuneCP5_13TeV-madgraphMLM-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM \ No newline at end of file diff --git a/test/dataset_paths.py b/test/dataset_paths.py index bdca125..4dcd842 100644 --- a/test/dataset_paths.py +++ b/test/dataset_paths.py @@ -8,7 +8,7 @@ } txt_name = "doublemuon2017" -site = "T2_DE_RWTW" +site = 'T2_DE_RWTH' if len(sys.argv) > 1: txt_name = sys.argv[1] diff --git a/test/datasets/ULv2/data2017.txt b/test/datasets/ULv2/data2017.txt index a6733d5..b7dc15c 100644 --- a/test/datasets/ULv2/data2017.txt +++ b/test/datasets/ULv2/data2017.txt @@ -3,7 +3,7 @@ /DoubleMuon/Run2017B-UL2017_MiniAODv2-v1/MINIAOD /DoubleMuon/Run2017C-UL2017_MiniAODv2-v1/MINIAOD /DoubleMuon/Run2017D-UL2017_MiniAODv2-v1/MINIAOD -/DoubleMuon/Run2017E-UL2017_MiniAODv2-v1/MINIAOD +/DoubleMuon/Run2017E-UL2017_MiniAODv2-v2/MINIAOD /DoubleMuon/Run2017F-UL2017_MiniAODv2-v1/MINIAOD /SingleMuon/Run2017B-UL2017_MiniAODv2-v1/MINIAOD