From 6979a663357fee5d6a408512c896f188e784e161 Mon Sep 17 00:00:00 2001 From: matt-komm Date: Fri, 26 Jun 2020 16:29:54 +0100 Subject: [PATCH 01/20] add const values for magic numbers --- DataFormats/interface/DisplacedGenVertex.h | 3 +++ DataFormats/interface/LLPLabel.h | 11 ++++++++--- .../plugins/DisplacedGenVertexProducer.cc | 12 ++++++------ LLPLabelProducer/plugins/LLPGenDecayInfoProducer.cc | 5 +++-- LLPLabelProducer/plugins/LLPLabelProducer.cc | 10 +++++----- NANOProducer/test/produceNANO.py | 7 +++++++ 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/DataFormats/interface/DisplacedGenVertex.h b/DataFormats/interface/DisplacedGenVertex.h index 2e4f319..7f913b9 100644 --- a/DataFormats/interface/DisplacedGenVertex.h +++ b/DataFormats/interface/DisplacedGenVertex.h @@ -17,6 +17,9 @@ namespace llpdnnx struct DisplacedGenVertex { + static constexpr float MIN_DISPLACEMENT = 1e-10; + static constexpr float MIN_LLP_MASS = 1e-8; + bool isHardInteraction; double sharedMassFraction; //fraction of invariant LLP mass carried by its first daughters in vertex reco::Candidate::Point vertex; diff --git a/DataFormats/interface/LLPLabel.h b/DataFormats/interface/LLPLabel.h index d34e63b..07ef0d4 100644 --- a/DataFormats/interface/LLPLabel.h +++ b/DataFormats/interface/LLPLabel.h @@ -2,12 +2,15 @@ #define LLPReco_DataFormats_LLPLabel_h #include "DataFormats/BTauReco/interface/FeaturesTagInfo.h" +#include "LLPReco/DataFormats/interface/DisplacedGenVertex.h" namespace llpdnnx { class LLPLabel { public: + + enum class Type { isPU, isB, @@ -67,9 +70,11 @@ class LLPLabel { partonFlavor(0), hadronFlavor(0), llpId(0), - displacement(-10), //log10(x/1cm) - displacement_xy(-10), //log10(x/1cm) - displacement_z(-10), //log10(x/1cm) + llp_mass(DisplacedGenVertex::MIN_LLP_MASS), + llp_pt(0), + displacement(DisplacedGenVertex::MIN_DISPLACEMENT), //log10(x/1cm) + displacement_xy(DisplacedGenVertex::MIN_DISPLACEMENT), //log10(x/1cm) + displacement_z(DisplacedGenVertex::MIN_DISPLACEMENT), //log10(x/1cm) decay_angle(0), betagamma(0), matchedGenJetDeltaR(-1), diff --git a/LLPLabelProducer/plugins/DisplacedGenVertexProducer.cc b/LLPLabelProducer/plugins/DisplacedGenVertexProducer.cc index ff8659c..e57e409 100644 --- a/LLPLabelProducer/plugins/DisplacedGenVertexProducer.cc +++ b/LLPLabelProducer/plugins/DisplacedGenVertexProducer.cc @@ -52,7 +52,7 @@ class DisplacedGenVertexProducer: static reco::Candidate::Point correctedDisplacement(const reco::Candidate& genParticle) { //return mother vertex if displacement is ignored - if (genParticle.mother() and ignoreDisplacement(*genParticle.mother()) and (distance(genParticle.mother()->vertex(),genParticle.vertex())>1e-10)) + if (genParticle.mother() and ignoreDisplacement(*genParticle.mother()) and (distance(genParticle.mother()->vertex(),genParticle.vertex())>DisplacedGenVertex::MIN_DISPLACEMENT)) { return correctedDisplacement(*genParticle.mother()); //call recursively } @@ -63,7 +63,7 @@ class DisplacedGenVertexProducer: { for (unsigned int idaughter = 0; idaughtervertex(),genParticle.vertex())>1e-10) + if (distance(genParticle.daughter(idaughter)->vertex(),genParticle.vertex())>DisplacedGenVertex::MIN_DISPLACEMENT) { return true; } @@ -133,7 +133,7 @@ DisplacedGenVertexProducer::produce(edm::Event& iEvent, const edm::EventSetup& i { hardInteractionVertex.reset(new reco::Candidate::Point(genParticle.vertex())); } - else if (distance(*hardInteractionVertex,correctedDisplacement(genParticle))>1e-10) + else if (distance(*hardInteractionVertex,correctedDisplacement(genParticle))>DisplacedGenVertex::MIN_DISPLACEMENT) { throw cms::Exception("DisplacedGenVertexProducer: multiple hard interaction vertices found!"); } @@ -144,7 +144,7 @@ DisplacedGenVertexProducer::produce(edm::Event& iEvent, const edm::EventSetup& i for (unsigned int ivertex = 0; ivertexsize(); ++ivertex) { DisplacedGenVertex& displacedGenVertex = displacedGenVertices->at(ivertex); - if (distance(displacedGenVertex.vertex,correctedDisplacement(genParticle))<1e-10) + if (distance(displacedGenVertex.vertex,correctedDisplacement(genParticle))ptrAt(igenParticle)); genParticleToVertexGroupMap[(size_t)&genParticle]=ivertex; @@ -170,7 +170,7 @@ DisplacedGenVertexProducer::produce(edm::Event& iEvent, const edm::EventSetup& i for (unsigned int ivertex = 0; ivertexsize(); ++ivertex) { displacedGenVertices->at(ivertex).hardInteraction = *hardInteractionVertex; - if (hardInteractionVertex and distance(displacedGenVertices->at(ivertex).vertex,*hardInteractionVertex)<1e-10) + if (hardInteractionVertex and distance(displacedGenVertices->at(ivertex).vertex,*hardInteractionVertex)at(ivertex).isHardInteraction=true; } @@ -212,7 +212,7 @@ DisplacedGenVertexProducer::produce(edm::Event& iEvent, const edm::EventSetup& i int decayVertexIndex = -1; for (auto idMomentumPair: momentumDistribution) { - double massRatio = idMomentumPair.second.mass()/genParticle.mass()+1e-8; + double massRatio = idMomentumPair.second.mass()/std::max(genParticle.mass(),DisplacedGenVertex::MIN_LLP_MASS); if (massRatio>maxMassRatio) { maxMassRatio=massRatio; diff --git a/LLPLabelProducer/plugins/LLPGenDecayInfoProducer.cc b/LLPLabelProducer/plugins/LLPGenDecayInfoProducer.cc index 02906b8..e8715a3 100644 --- a/LLPLabelProducer/plugins/LLPGenDecayInfoProducer.cc +++ b/LLPLabelProducer/plugins/LLPGenDecayInfoProducer.cc @@ -17,6 +17,7 @@ #include "DataFormats/HepMCCandidate/interface/GenParticle.h" #include "LLPReco/DataFormats/interface/LLPGenDecayInfo.h" +#include "LLPReco/DataFormats/interface/DisplacedGenVertex.h" #include @@ -121,7 +122,7 @@ LLPGenDecayInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet { hardInteraction.reset(new reco::Candidate::Point(genParticle.vertex())); } - else if (distance(*hardInteraction,genParticle.vertex())>1e-10) + else if (distance(*hardInteraction,genParticle.vertex())>llpdnnx::DisplacedGenVertex::MIN_DISPLACEMENT) { throw cms::Exception("PartonsFromLLPSelector: multiple hard interaction vertices found!"); } @@ -149,7 +150,7 @@ LLPGenDecayInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet //const reco::Candidate* daughter = genParticle.daughter(idaughter); //llp decay products need to be displaced wrt hard interaction - if (distance(*hardInteraction,daughter->vertex())<1e-10) + if (distance(*hardInteraction,daughter->vertex())(matchedVertex->d3d(),1e-10)); - label.displacement_xy = std::log10(std::max(matchedVertex->dxy(),1e-10)); - label.displacement_z = std::log10(std::max(matchedVertex->dz(),1e-10)); + label.displacement = std::log10(std::max(matchedVertex->d3d(),DisplacedGenVertex::MIN_DISPLACEMENT)); + label.displacement_xy = std::log10(std::max(matchedVertex->dxy(),DisplacedGenVertex::MIN_DISPLACEMENT)); + label.displacement_z = std::log10(std::max(matchedVertex->dz(),DisplacedGenVertex::MIN_DISPLACEMENT)); //iteratively check the decay chain to detect e.g. LLP->B->C @@ -304,7 +304,7 @@ LLPLabelProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) const auto &mother = *(llpVertex->motherLongLivedParticle); label.llpId = mother.pdgId(); label.decay_angle = angle(matchedGenJet->p4(),mother.p4()); - label.betagamma = mother.p()/std::max(mother.mass(),1e-10); + label.betagamma = mother.p()/std::max(mother.mass(),DisplacedGenVertex::MIN_LLP_MASS); label.llp_mass = mother.mass(); label.llp_pt = mother.pt(); @@ -320,7 +320,7 @@ LLPLabelProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) //this will associate the decay vertex with a llp decay - if (std::sqrt((ghost->vertex()-llpVertex->vertex).mag2())>1e-10) + if (std::sqrt((ghost->vertex()-llpVertex->vertex).mag2())>DisplacedGenVertex::MIN_DISPLACEMENT) { continue; } diff --git a/NANOProducer/test/produceNANO.py b/NANOProducer/test/produceNANO.py index 176b301..d8365d0 100644 --- a/NANOProducer/test/produceNANO.py +++ b/NANOProducer/test/produceNANO.py @@ -87,8 +87,15 @@ #"mc": "https://github.com/LLPDNNX/test-files/raw/master/miniaod/Moriond17_aug2018_miniAODv3_HNL.root", }, '2016': { +<<<<<<< Updated upstream "mc": "root://gfe02.grid.hep.ph.ic.ac.uk/pnfs/hep.ph.ic.ac.uk/data/cms/store/user/mkomm/HNL/miniaod16v3_200517/HNL_dirac_all_ctau1p0e00_massHNL6p0_Vall6p496e-03/miniaod16v3_200517/200517_004822/0000/HNL2016_140.root", "data": "/store/data/Run2016H/SingleMuon/MINIAOD/17Jul2018-v1/00000/16924A85-4D8C-E811-A51C-A4BF01013F29.root", +======= + "mc": "root://gfe02.grid.hep.ph.ic.ac.uk/pnfs/hep.ph.ic.ac.uk/data/cms/store/user/mkomm/HNL/miniaod16v3_200625/HNL_dirac_all_ctau1p0e-02_massHNL8p0_Vall2p996e-02/miniaod16v3_200625/200625_171726/0000/HNL2016_9.root", + #"mc": "root://gfe02.grid.hep.ph.ic.ac.uk/pnfs/hep.ph.ic.ac.uk/data/cms/store/user/mkomm/HNL/miniaod16v3_200517/HNL_dirac_all_ctau1p0e00_massHNL6p0_Vall6p496e-03/miniaod16v3_200517/200517_004822/0000/HNL2016_140.root", #"root://maite.iihe.ac.be//store/user/tomc/heavyNeutrinoMiniAOD/Moriond17_aug2018_miniAODv3/displaced/HeavyNeutrino_lljj_M-8_V-0.004472135955_tau_Dirac_massiveAndCKM_LO/heavyNeutrino_1.root", + #"mc": "root://maite.iihe.ac.be///store/user/tomc/heavyNeutrinoMiniAOD/Moriond17_aug2018_miniAODv3/displaced/HeavyNeutrino_lljj_M-10_V-0.00112249721603_mu_Dirac_massiveAndCKM_LO/heavyNeutrino_76.root", + "data": "/store/data/Run2016B/SingleMuon/MINIAOD/17Jul2018_ver2-v1/30000/14F647C4-6C92-E811-9571-90E2BACBAD64.root", +>>>>>>> Stashed changes }, '2017': { "mc": "root://maite.iihe.ac.be//store/user/tomc/heavyNeutrinoMiniAOD/Fall17/displaced/HeavyNeutrino_lljj_M-8_V-0.00214242852856_mu_Dirac_massiveAndCKM_LO/heavyNeutrino_10.root", From ab42bcf39b699980decda9bfa00ae45ccc68df25 Mon Sep 17 00:00:00 2001 From: matt-komm Date: Fri, 26 Jun 2020 17:43:08 +0100 Subject: [PATCH 02/20] fix peak in xy --- DataFormats/interface/LLPLabel.h | 6 +++--- LLPLabelProducer/plugins/LLPLabelProducer.cc | 3 ++- NANOProducer/test/produceNANO.py | 7 +------ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/DataFormats/interface/LLPLabel.h b/DataFormats/interface/LLPLabel.h index 07ef0d4..a4dff1e 100644 --- a/DataFormats/interface/LLPLabel.h +++ b/DataFormats/interface/LLPLabel.h @@ -72,9 +72,9 @@ class LLPLabel { llpId(0), llp_mass(DisplacedGenVertex::MIN_LLP_MASS), llp_pt(0), - displacement(DisplacedGenVertex::MIN_DISPLACEMENT), //log10(x/1cm) - displacement_xy(DisplacedGenVertex::MIN_DISPLACEMENT), //log10(x/1cm) - displacement_z(DisplacedGenVertex::MIN_DISPLACEMENT), //log10(x/1cm) + displacement(std::log10(DisplacedGenVertex::MIN_DISPLACEMENT)), //log10(x/1cm) + displacement_xy(std::log10(DisplacedGenVertex::MIN_DISPLACEMENT)), //log10(x/1cm) + displacement_z(std::log10(DisplacedGenVertex::MIN_DISPLACEMENT)), //log10(x/1cm) decay_angle(0), betagamma(0), matchedGenJetDeltaR(-1), diff --git a/LLPLabelProducer/plugins/LLPLabelProducer.cc b/LLPLabelProducer/plugins/LLPLabelProducer.cc index ceff082..dcd5fc3 100644 --- a/LLPLabelProducer/plugins/LLPLabelProducer.cc +++ b/LLPLabelProducer/plugins/LLPLabelProducer.cc @@ -268,7 +268,8 @@ LLPLabelProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) } } - if (matchedVertex and matchedGenJet) + //excludes cases where the displaced vertex is located at 0,0,0 + if (matchedVertex and matchedGenJet and matchedVertex->vertex.mag2()>(DisplacedGenVertex::MIN_DISPLACEMENT*DisplacedGenVertex::MIN_DISPLACEMENT)) { label.matchedGenJetDeltaR = dRmin; label.matchedGenJetPt = matchedGenJet->pt(); diff --git a/NANOProducer/test/produceNANO.py b/NANOProducer/test/produceNANO.py index d8365d0..5c91fba 100644 --- a/NANOProducer/test/produceNANO.py +++ b/NANOProducer/test/produceNANO.py @@ -87,15 +87,10 @@ #"mc": "https://github.com/LLPDNNX/test-files/raw/master/miniaod/Moriond17_aug2018_miniAODv3_HNL.root", }, '2016': { -<<<<<<< Updated upstream - "mc": "root://gfe02.grid.hep.ph.ic.ac.uk/pnfs/hep.ph.ic.ac.uk/data/cms/store/user/mkomm/HNL/miniaod16v3_200517/HNL_dirac_all_ctau1p0e00_massHNL6p0_Vall6p496e-03/miniaod16v3_200517/200517_004822/0000/HNL2016_140.root", - "data": "/store/data/Run2016H/SingleMuon/MINIAOD/17Jul2018-v1/00000/16924A85-4D8C-E811-A51C-A4BF01013F29.root", -======= "mc": "root://gfe02.grid.hep.ph.ic.ac.uk/pnfs/hep.ph.ic.ac.uk/data/cms/store/user/mkomm/HNL/miniaod16v3_200625/HNL_dirac_all_ctau1p0e-02_massHNL8p0_Vall2p996e-02/miniaod16v3_200625/200625_171726/0000/HNL2016_9.root", #"mc": "root://gfe02.grid.hep.ph.ic.ac.uk/pnfs/hep.ph.ic.ac.uk/data/cms/store/user/mkomm/HNL/miniaod16v3_200517/HNL_dirac_all_ctau1p0e00_massHNL6p0_Vall6p496e-03/miniaod16v3_200517/200517_004822/0000/HNL2016_140.root", #"root://maite.iihe.ac.be//store/user/tomc/heavyNeutrinoMiniAOD/Moriond17_aug2018_miniAODv3/displaced/HeavyNeutrino_lljj_M-8_V-0.004472135955_tau_Dirac_massiveAndCKM_LO/heavyNeutrino_1.root", #"mc": "root://maite.iihe.ac.be///store/user/tomc/heavyNeutrinoMiniAOD/Moriond17_aug2018_miniAODv3/displaced/HeavyNeutrino_lljj_M-10_V-0.00112249721603_mu_Dirac_massiveAndCKM_LO/heavyNeutrino_76.root", - "data": "/store/data/Run2016B/SingleMuon/MINIAOD/17Jul2018_ver2-v1/30000/14F647C4-6C92-E811-9571-90E2BACBAD64.root", ->>>>>>> Stashed changes + "data": "/store/data/Run2016H/SingleMuon/MINIAOD/17Jul2018-v1/00000/16924A85-4D8C-E811-A51C-A4BF01013F29.root", }, '2017': { "mc": "root://maite.iihe.ac.be//store/user/tomc/heavyNeutrinoMiniAOD/Fall17/displaced/HeavyNeutrino_lljj_M-8_V-0.00214242852856_mu_Dirac_massiveAndCKM_LO/heavyNeutrino_10.root", From 09af6c3eed9231531658240decf65acc3ea13f25 Mon Sep 17 00:00:00 2001 From: matt-komm Date: Fri, 6 Nov 2020 22:03:25 +0000 Subject: [PATCH 03/20] redo labelling --- .../interface/ChargedCandidateFeatures.h | 5 + .../interface/ElectronCandidateFeatures.h | 9 +- DataFormats/interface/JetFeatures.h | 2 +- DataFormats/interface/LLPLabel.h | 33 +- DataFormats/interface/MuonCandidateFeatures.h | 6 +- .../interface/NeutralCandidateFeatures.h | 5 + DataFormats/interface/XTagFeatures.h | 2 + LLPLabelProducer/plugins/LLPLabelProducer.cc | 525 ++++++++++++------ NANOProducer/plugins/NANOGenProducer.cc | 48 +- NANOProducer/plugins/NANOProducer.cc | 63 ++- NANOProducer/test/produceNANO.py | 7 +- XTagInfoProducer/plugins/XTagInfoProducer.cc | 63 ++- 12 files changed, 558 insertions(+), 210 deletions(-) diff --git a/DataFormats/interface/ChargedCandidateFeatures.h b/DataFormats/interface/ChargedCandidateFeatures.h index e9f5ec7..14fc307 100644 --- a/DataFormats/interface/ChargedCandidateFeatures.h +++ b/DataFormats/interface/ChargedCandidateFeatures.h @@ -10,6 +10,11 @@ struct ChargedCandidateFeatures float cpf_ptrel; float cpf_deta; float cpf_dphi; + float cpf_deltaR; + + float cpf_px; + float cpf_py; + float cpf_pz; float cpf_trackEtaRel; float cpf_trackPtRel; diff --git a/DataFormats/interface/ElectronCandidateFeatures.h b/DataFormats/interface/ElectronCandidateFeatures.h index 76e1d35..e279932 100644 --- a/DataFormats/interface/ElectronCandidateFeatures.h +++ b/DataFormats/interface/ElectronCandidateFeatures.h @@ -8,9 +8,12 @@ class ElectronCandidateFeatures { public: int elec_jetIdx; float elec_ptrel; - float elec_jetDeltaR; + float elec_deltaR; float elec_deta; float elec_dphi; + float elec_px; + float elec_py; + float elec_pz; float elec_charge; float elec_energy; float elec_EtFromCaloEn; @@ -67,7 +70,11 @@ class ElectronCandidateFeatures { // electron gsf variables. float elec_EtaRel; float elec_dxy; + float elec_dxyError; + float elec_dxySig; float elec_dz; + float elec_dzError; + float elec_dzSig; int elec_nbOfMissingHits; float elec_gsfCharge; int elec_ndof; diff --git a/DataFormats/interface/JetFeatures.h b/DataFormats/interface/JetFeatures.h index 2c1262d..3b92287 100644 --- a/DataFormats/interface/JetFeatures.h +++ b/DataFormats/interface/JetFeatures.h @@ -91,7 +91,7 @@ struct JetFeatures circularity(-1), isotropy(-1), eventShapeC(-1), - eventShapeD(-1) + eventShapeD(-1) { } diff --git a/DataFormats/interface/LLPLabel.h b/DataFormats/interface/LLPLabel.h index 6186ee9..c752aef 100644 --- a/DataFormats/interface/LLPLabel.h +++ b/DataFormats/interface/LLPLabel.h @@ -15,17 +15,16 @@ class LLPLabel { isPU, isB, isBB, - isGBB, isLeptonic_B, - isLeptonic_C, isC, isCC, - isGCC, + isLeptonic_C, isS, isUD, isG, isPrompt_MU, isPrompt_E, + isPrompt_PHOTON, isPrompt_TAU, isLLP_RAD, //no flavour match (likely from wide angle radiation) @@ -46,12 +45,28 @@ class LLPLabel { isLLP_TAU, isLLP_QTAU, isLLP_QQTAU, + isLLP_BTAU, + isLLP_BBTAU, isUndefined }; Type type; + enum class TauDecay { + NO_TAU, //no tau decay + INVISIBLE, //tau decay but not reconstructable + E, //to electron + MU, //to muon + H, //1 charged hadron + H_1PI0, //1 charged hadron + pi0(->2gamma) + H_XPI0, //1 charged hadron + 2 or more pi0(->2gamma) + HHH, //3 charged hadrons + HHH_XPI0 //3 charged hadron + 1 or more pi0(->2gamma) + }; + + TauDecay tauDecay; + int jetIdx; int partonFlavor; int hadronFlavor; @@ -70,6 +85,7 @@ class LLPLabel { LLPLabel(): type(Type::isUndefined), + tauDecay(TauDecay::NO_TAU), partonFlavor(0), hadronFlavor(0), llpId(0), @@ -95,8 +111,6 @@ class LLPLabel { return "isB"; case Type::isBB: return "isBB"; - case Type::isGBB: - return "isGBB"; case Type::isLeptonic_B: return "isLeptonic_B"; case Type::isLeptonic_C: @@ -105,8 +119,6 @@ class LLPLabel { return "isC"; case Type::isCC: return "isCC"; - case Type::isGCC: - return "isGCC"; case Type::isS: return "isS"; case Type::isUD: @@ -120,6 +132,8 @@ class LLPLabel { return "isPrompt_E"; case Type::isPrompt_TAU: return "isPrompt_TAU"; + case Type::isPrompt_PHOTON: + return "isPrompt_PHOTON"; case Type::isLLP_RAD: return "isLLP_RAD"; @@ -167,7 +181,10 @@ class LLPLabel { return "isLLP_QTAU"; case Type::isLLP_QQTAU: return "isLLP_QQTAU"; - + case Type::isLLP_BTAU: + return "isLLP_BTAU"; + case Type::isLLP_BBTAU: + return "isLLP_BBTAU"; case Type::isUndefined: return "isUndefined"; } diff --git a/DataFormats/interface/MuonCandidateFeatures.h b/DataFormats/interface/MuonCandidateFeatures.h index 3b3c7f4..a75fdd4 100644 --- a/DataFormats/interface/MuonCandidateFeatures.h +++ b/DataFormats/interface/MuonCandidateFeatures.h @@ -15,10 +15,13 @@ struct MuonCandidateFeatures { float mu_ptrel; float mu_deta; float mu_dphi; + float mu_px; + float mu_py; + float mu_pz; float mu_charge; float mu_energy; float mu_et; - float mu_jetDeltaR; + float mu_deltaR; int mu_numberOfMatchedStations; float mu_2dIP; @@ -32,6 +35,7 @@ struct MuonCandidateFeatures { float mu_dxySig; float mu_dz; float mu_dzError; + float mu_dzSig; int mu_numberOfValidPixelHits; int mu_numberOfpixelLayersWithMeasurement; int mu_numberOfstripLayersWithMeasurement; //that does not help. needs to be discussed. diff --git a/DataFormats/interface/NeutralCandidateFeatures.h b/DataFormats/interface/NeutralCandidateFeatures.h index 6e448e4..e76cb89 100644 --- a/DataFormats/interface/NeutralCandidateFeatures.h +++ b/DataFormats/interface/NeutralCandidateFeatures.h @@ -10,6 +10,11 @@ struct NeutralCandidateFeatures float npf_deta; float npf_dphi; float npf_deltaR; + + float npf_px; + float npf_py; + float npf_pz; + int npf_isGamma; float npf_hcal_fraction; float npf_drminsv; diff --git a/DataFormats/interface/XTagFeatures.h b/DataFormats/interface/XTagFeatures.h index 5379c9b..a421d60 100644 --- a/DataFormats/interface/XTagFeatures.h +++ b/DataFormats/interface/XTagFeatures.h @@ -21,7 +21,9 @@ class XTagFeatures { std::vector cpf_features; std::vector mu_features; std::vector elec_features; + std::size_t npv; + }; } diff --git a/LLPLabelProducer/plugins/LLPLabelProducer.cc b/LLPLabelProducer/plugins/LLPLabelProducer.cc index c4b1d0e..0d55b34 100644 --- a/LLPLabelProducer/plugins/LLPLabelProducer.cc +++ b/LLPLabelProducer/plugins/LLPLabelProducer.cc @@ -26,6 +26,7 @@ #include "DataFormats/Math/interface/angle.h" #include "DataFormats/PatCandidates/interface/Jet.h" +#include "DataFormats/PatCandidates/interface/Tau.h" #include "LLPReco/DataFormats/interface/LLPGhostFlavourInfo.h" @@ -40,6 +41,15 @@ class LLPLabelProducer: { private: + struct CandidateHash + { + long operator() (const reco::CandidatePtr& cand) const + { + return cand.id().id() * 100000 + cand.key(); + } + }; + + struct LLPDecay { const reco::GenParticle* llp; @@ -50,6 +60,72 @@ class LLPLabelProducer: { } }; + + static void gatherVisibleDecayProducts(std::vector& list, const reco::Candidate* genParticle) + { + if (genParticle->numberOfDaughters()==0) + { + int absId = std::abs(genParticle->pdgId()); + if (absId!=12 and absId!=14 and absId!=16 and absId>6 and absId<100000) + { + list.push_back(genParticle); + } + } + else + { + for (size_t d=0; d< genParticle->numberOfDaughters(); ++d) + { + gatherVisibleDecayProducts(list, genParticle->daughter(d)); + } + } + } + + static reco::Candidate::Point getVertex(const reco::Candidate* p) + { + const auto genParticle = dynamic_cast(p); + if (genParticle) return genParticle->vertex(); + const auto packedGenParticle = dynamic_cast(p); + if (packedGenParticle) return packedGenParticle->vertex(); + return reco::Candidate::Point(0,0,0); + } + + static const reco::Candidate* findRecoConstituent(const reco::Candidate* genParticle, const std::vector& constituents) + { + double minDR2 = 1000000; + const reco::Candidate* match = nullptr; + for (const auto& constituent: constituents) + { + double ptRel = std::fabs(constituent->pt()/genParticle->pt()-1.); + if (ptRel>0.5) continue; //prevent random match + double dEta = std::fabs(genParticle->eta()-constituent->eta()); + if (dEta>0.05) continue; + double dPhi = std::fabs(reco::deltaPhi(*genParticle,*constituent)); + if (dPhi>0.1) continue; + double dR2 = dEta*dEta+0.5*dPhi*dPhi; //allow for more spread in phi + if (minDR2>dR2) + { + minDR2 = dR2; + match = constituent; + } + } + return match; + } + + static void classifyTauDecay(const reco::GenParticle* tau, std::vector constituents) + { + + } + + static void printDecayChain(std::vector& finals, const reco::Candidate* p, int indent=1) + { + for (int i=0; i < indent; ++i) std::cout<<" - "; + std::cout<<"id="<<(p->pdgId())<<", pt="<<(p->pt())<numberOfDaughters()==0) finals.push_back(p); + for (size_t d=0; d< p->numberOfDaughters(); ++d) + { + printDecayChain(finals,p->daughter(d), indent+1); + } + } //TH1D *hist; //edm::Service fs; @@ -70,16 +146,25 @@ class LLPLabelProducer: int n = (absPdgId/1000000)%10; return std::max({nq1,nq2,nq3})+n*10000+(n>0 and nL==9)*100; } + double tauPtThreshold_; double quarkPtThreshold_; double bPtThreshold_; double muonPtThreshold_; double electronPtThreshold_; + + int nGenTau_; + int nLabelledTau_; + int nPatTau_; + int nPatNotGen_; + int nLabelledNotPat_; edm::EDGetTokenT> jetToken_; edm::EDGetTokenT> displacedGenVertexToken_; edm::EDGetTokenT> llpFlavourInfoToken_; - + edm::EDGetTokenT> llpGenDecayInfoToken_; + + edm::EDGetTokenT> tauToken_; virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override; @@ -88,6 +173,8 @@ class LLPLabelProducer: ~LLPLabelProducer(); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + }; @@ -99,19 +186,34 @@ LLPLabelProducer::LLPLabelProducer(const edm::ParameterSet& iConfig): electronPtThreshold_(iConfig.getParameter("electronPtThreshold")), jetToken_(consumes>(iConfig.getParameter("srcJets"))), displacedGenVertexToken_(consumes>(iConfig.getParameter("srcVertices"))), - llpFlavourInfoToken_(consumes>(iConfig.getParameter("srcFlavourInfo"))) + llpFlavourInfoToken_(consumes>(iConfig.getParameter("srcFlavourInfo"))), + llpGenDecayInfoToken_(consumes>( iConfig.getParameter("srcDecayInfo") )), + tauToken_(consumes>( iConfig.getParameter("srcTaus") )) { produces(); //hist = fs->make("ptfrac" , "ptfrac" , 100 , 0 , 1. ); + + nGenTau_ = 0; + nLabelledTau_ = 0; + nPatTau_ = 0; + nPatNotGen_ = 0; + nLabelledNotPat_ = 0; } LLPLabelProducer::~LLPLabelProducer() { + std::cout<<"gentau="<> llpGhostFlavourInfoMap; iEvent.getByToken(llpFlavourInfoToken_, llpGhostFlavourInfoMap); + edm::Handle> llpGenDecayInfoCollection; + iEvent.getByToken(llpGenDecayInfoToken_, llpGenDecayInfoCollection); + + edm::Handle> tauCollection; + iEvent.getByToken(tauToken_, tauCollection); + auto outputLLPLabelInfo = std::make_unique(); + for (std::size_t ijet = 0; ijet < jetCollection->size(); ijet++) { const pat::Jet& jet = jetCollection->at(ijet); + if (jet.pt()<15.) continue; + edm::RefToBase jet_ref(jetCollection->refAt(ijet)); llpdnnx::LLPLabel label; @@ -140,174 +251,237 @@ LLPLabelProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) } else { - int partonFlavor = abs(jet.partonFlavour()); - int hadronFlavor = abs(jet.hadronFlavour()); + const auto& genJet = jet.genJet(); - label.partonFlavor = partonFlavor; - label.hadronFlavor = hadronFlavor; + label.partonFlavor = std::abs(jet.partonFlavour()); + label.hadronFlavor = std::abs(jet.hadronFlavour()); label.matchedGenJetDeltaR = reco::deltaR(jet.p4(),jet.genJet()->p4()); label.matchedGenJetPt = jet.genJet()->pt(); + + //std::cout<<"jet "<size())<<", pt="<=1 and nTau==0) //accept any additional number of electrons + else if (label.type==llpdnnx::LLPLabel::Type::isBB or label.type==llpdnnx::LLPLabel::Type::isCC) { - if (nQ==0 and nB==0) label.type = llpdnnx::LLPLabel::Type::isLLP_MU; - - if (nQ==1 and nB==0) label.type = llpdnnx::LLPLabel::Type::isLLP_QMU; - if (nQ==0 and nB==1) label.type = llpdnnx::LLPLabel::Type::isLLP_BMU; - - if (nQ>1 and nB==0) label.type = llpdnnx::LLPLabel::Type::isLLP_QQMU; - if (nB>1 or (nQ==1 and nB==1)) label.type = llpdnnx::LLPLabel::Type::isLLP_BBMU; - } + if (not displacedLepton) + { + label.type=llpdnnx::LLPLabel::Type::isLLP_BB; + } + else + { + if (std::abs(displacedLepton->pdgId())==11) label.type=llpdnnx::LLPLabel::Type::isLLP_BBE; + else if (std::abs(displacedLepton->pdgId())==13) label.type=llpdnnx::LLPLabel::Type::isLLP_BBMU; + else if (std::abs(displacedLepton->pdgId())==15) label.type=llpdnnx::LLPLabel::Type::isLLP_BBTAU; + else throw std::runtime_error("LLPLabel not well defined"); + } + } + else + { + if (not displacedLepton) + { + if (nPartons==0) label.type=llpdnnx::LLPLabel::Type::isLLP_RAD; + else if (nPartons==1) label.type=llpdnnx::LLPLabel::Type::isLLP_Q; + else label.type=llpdnnx::LLPLabel::Type::isLLP_QQ; + } + else + { + if (nPartons==0) + { + if (std::abs(displacedLepton->pdgId())==11) label.type=llpdnnx::LLPLabel::Type::isLLP_E; + else if (std::abs(displacedLepton->pdgId())==13) label.type=llpdnnx::LLPLabel::Type::isLLP_MU; + else if (std::abs(displacedLepton->pdgId())==15) label.type=llpdnnx::LLPLabel::Type::isLLP_TAU; + else throw std::runtime_error("LLPLabel not well defined"); + } + else if (nPartons==1) + { + if (std::abs(displacedLepton->pdgId())==11) label.type=llpdnnx::LLPLabel::Type::isLLP_QE; + else if (std::abs(displacedLepton->pdgId())==13) label.type=llpdnnx::LLPLabel::Type::isLLP_QMU; + else if (std::abs(displacedLepton->pdgId())==15) label.type=llpdnnx::LLPLabel::Type::isLLP_QTAU; + else throw std::runtime_error("LLPLabel not well defined"); + } + else + { + if (std::abs(displacedLepton->pdgId())==11) label.type=llpdnnx::LLPLabel::Type::isLLP_QQE; + else if (std::abs(displacedLepton->pdgId())==13) label.type=llpdnnx::LLPLabel::Type::isLLP_QQMU; + else if (std::abs(displacedLepton->pdgId())==15) label.type=llpdnnx::LLPLabel::Type::isLLP_QQTAU; + else throw std::runtime_error("LLPLabel not well defined"); + } + } + } } } } + if (label.type!=llpdnnx::LLPLabel::Type::isPU) + std::cout<<" jet: "<size())<<", pt="<size())<<", pt="<addColumn("isB", isB, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isBB", isBB, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isGBB", isGBB, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isLeptonic_B", isLeptonic_B, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isLeptonic_C", isLeptonic_C, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isC", isC, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isCC", isCC, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isGCC", isGCC, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isS", isS, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isUD", isUD, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isG", isG, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isPrompt_MU", isPrompt_MU, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isPrompt_E", isPrompt_E, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isPrompt_TAU", isPrompt_TAU, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isPrompt_PHOTON", isPrompt_PHOTON, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isLLP_RAD", isLLP_RAD, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isLLP_MU", isLLP_MU, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isLLP_E", isLLP_E, "doc", nanoaod::FlatTable::IntColumn); @@ -230,7 +252,19 @@ NANOGenProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) jetOriginTable->addColumn("isLLP_TAU", isLLP_TAU, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isLLP_QTAU", isLLP_QTAU, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isLLP_QQTAU", isLLP_QQTAU, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isLLP_BTAU", isLLP_BTAU, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isLLP_BBTAU", isLLP_BBTAU, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isUndefined", isUndefined, "doc", nanoaod::FlatTable::IntColumn); + + jetOriginTable->addColumn("isTauDecay_NO_TAU", isTauDecay_NO_TAU, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isTauDecay_INVISIBLE", isTauDecay_INVISIBLE, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isTauDecay_E", isTauDecay_E, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isTauDecay_MU", isTauDecay_MU, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isTauDecay_H", isTauDecay_H, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isTauDecay_H_1PI0", isTauDecay_H_1PI0, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isTauDecay_H_XPI0", isTauDecay_H_XPI0, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isTauDecay_HHH", isTauDecay_HHH, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isTauDecay_HHH_XPI0", isTauDecay_HHH_XPI0, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("partonFlavor", partonFlavor, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("hadronFlavor", hadronFlavor, "doc", nanoaod::FlatTable::IntColumn); diff --git a/NANOProducer/plugins/NANOProducer.cc b/NANOProducer/plugins/NANOProducer.cc index 7c0dbbd..bbc68d8 100644 --- a/NANOProducer/plugins/NANOProducer.cc +++ b/NANOProducer/plugins/NANOProducer.cc @@ -156,6 +156,9 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector cpf_ptrel; std::vector cpf_deta; std::vector cpf_dphi; + std::vector cpf_px; + std::vector cpf_py; + std::vector cpf_pz; std::vector cpf_drminsv; std::vector cpf_vertex_association; std::vector cpf_fromPV; @@ -176,6 +179,9 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector npf_ptrel; std::vector npf_deta; std::vector npf_dphi; + std::vector npf_px; + std::vector npf_py; + std::vector npf_pz; std::vector npf_deltaR; std::vector npf_isGamma; std::vector npf_hcal_fraction; @@ -210,9 +216,12 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector mu_deta; std::vector mu_dphi; std::vector mu_charge; + std::vector mu_px; + std::vector mu_py; + std::vector mu_pz; std::vector mu_energy; std::vector mu_et; - std::vector mu_jetDeltaR; + std::vector mu_deltaR; std::vector mu_numberOfMatchedStations; std::vector mu_2dIP; @@ -225,6 +234,7 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector mu_dxySig; std::vector mu_dz; std::vector mu_dzError; + std::vector mu_dzSig; std::vector mu_numberOfValidPixelHits; std::vector mu_numberOfpixelLayersWithMeasurement; std::vector mu_numberOfstripLayersWithMeasurement ; @@ -256,9 +266,12 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) // Electron Block std::vector elec_ptrel; - std::vector elec_jetDeltaR; + std::vector elec_deltaR; std::vector elec_deta; std::vector elec_dphi; + std::vector elec_px; + std::vector elec_py; + std::vector elec_pz; std::vector elec_charge; std::vector elec_energy; std::vector elec_EtFromCaloEn ; @@ -304,7 +317,11 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector elec_EtaRel; std::vector elec_dxy; + std::vector elec_dxyError; + std::vector elec_dxySig; std::vector elec_dz; + std::vector elec_dzError; + std::vector elec_dzSig; std::vector elec_nbOfMissingHits; std::vector elec_gsfCharge; std::vector elec_ndof; @@ -472,6 +489,9 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) cpf_ptrel.push_back(cpf_features.cpf_ptrel); cpf_deta.push_back(cpf_features.cpf_deta); cpf_dphi.push_back(cpf_features.cpf_dphi); + cpf_px.push_back(cpf_features.cpf_px); + cpf_py.push_back(cpf_features.cpf_py); + cpf_pz.push_back(cpf_features.cpf_pz); cpf_drminsv.push_back(cpf_features.cpf_drminsv); cpf_vertex_association.push_back(cpf_features.cpf_vertex_association); cpf_fromPV.push_back(cpf_features.cpf_fromPV); @@ -497,6 +517,9 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) npf_ptrel.push_back(npf_features.npf_ptrel); npf_deta.push_back(npf_features.npf_deta); npf_dphi.push_back(npf_features.npf_dphi); + npf_px.push_back(npf_features.npf_px); + npf_py.push_back(npf_features.npf_py); + npf_pz.push_back(npf_features.npf_pz); npf_deltaR.push_back(npf_features.npf_deltaR); npf_isGamma.push_back(npf_features.npf_isGamma); npf_hcal_fraction.push_back(npf_features.npf_hcal_fraction); @@ -542,9 +565,12 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) mu_deta.push_back(mu_features.mu_deta); mu_dphi.push_back(mu_features.mu_dphi); mu_charge.push_back(mu_features.mu_charge); + mu_px.push_back(mu_features.mu_px); + mu_py.push_back(mu_features.mu_py); + mu_pz.push_back(mu_features.mu_pz); mu_energy.push_back(mu_features.mu_energy); mu_et.push_back(mu_features.mu_et); - mu_jetDeltaR.push_back(mu_features.mu_jetDeltaR); + mu_deltaR.push_back(mu_features.mu_deltaR); mu_numberOfMatchedStations.push_back(mu_features.mu_numberOfMatchedStations); mu_2dIP.push_back(mu_features.mu_2dIP); @@ -557,6 +583,7 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) mu_dxySig.push_back(mu_features.mu_dxySig); mu_dz.push_back(mu_features.mu_dz); mu_dzError.push_back(mu_features.mu_dzError); + mu_dzSig.push_back(mu_features.mu_dzSig); mu_numberOfValidPixelHits.push_back(mu_features.mu_numberOfValidPixelHits); mu_numberOfpixelLayersWithMeasurement.push_back(mu_features.mu_numberOfpixelLayersWithMeasurement); mu_numberOfstripLayersWithMeasurement.push_back(mu_features.mu_numberOfstripLayersWithMeasurement); @@ -595,9 +622,12 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) elec_jetIdx.push_back(jetIdx); elec_ptrel.push_back(elec_features.elec_ptrel ); - elec_jetDeltaR.push_back(elec_features.elec_jetDeltaR ); + elec_deltaR.push_back(elec_features.elec_deltaR ); elec_deta.push_back(elec_features.elec_deta ); elec_dphi.push_back(elec_features.elec_dphi ); + elec_px.push_back(elec_features.elec_px ); + elec_py.push_back(elec_features.elec_py ); + elec_pz.push_back(elec_features.elec_pz ); elec_charge.push_back(elec_features.elec_charge ); elec_energy.push_back(elec_features.elec_energy ); @@ -647,7 +677,11 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) elec_EtaRel.push_back(elec_features.elec_EtaRel ); elec_dxy.push_back(elec_features.elec_dxy ); + elec_dxyError.push_back(elec_features.elec_dxyError); + elec_dxySig.push_back(elec_features.elec_dxySig); elec_dz.push_back(elec_features.elec_dz ); + elec_dzError.push_back(elec_features.elec_dzError); + elec_dzSig.push_back(elec_features.elec_dzSig); elec_nbOfMissingHits.push_back(elec_features.elec_nbOfMissingHits ); elec_gsfCharge.push_back(elec_features.elec_gsfCharge ); elec_ndof.push_back(elec_features.elec_ndof ); @@ -760,6 +794,9 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) cpfTable->addColumn("dzMin", cpf_dZmin, "min distance to other PV", nanoaod::FlatTable::FloatColumn); cpfTable->addColumn("deta", cpf_deta, "absolute difference between the charged PF candidate eta and jet eta", nanoaod::FlatTable::FloatColumn); cpfTable->addColumn("dphi", cpf_dphi, "absolute difference between the charged PF candidate phi and jet phi", nanoaod::FlatTable::FloatColumn); + cpfTable->addColumn("px", cpf_px, "px", nanoaod::FlatTable::FloatColumn); + cpfTable->addColumn("py", cpf_py, "py", nanoaod::FlatTable::FloatColumn); + cpfTable->addColumn("pz", cpf_pz, "pz", nanoaod::FlatTable::FloatColumn); npfTable->addColumn("jetIdx", npf_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); npfTable->addColumn("ptrel", npf_ptrel, "neutral PF candidate transverse momentum over jet transverse momentum (uncorrelated)", nanoaod::FlatTable::FloatColumn); @@ -771,6 +808,9 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) npfTable->addColumn("drminsv", npf_drminsv, "pseudoangular distance (Delta R) between neutral PF candidate and closest secondary vertex (SV) within the jet", nanoaod::FlatTable::FloatColumn); npfTable->addColumn("puppi_weight", npf_puppi_weight, "weight assigned by the PUPPI algorithm to neutral PF candidate", nanoaod::FlatTable::FloatColumn); npfTable->addColumn("relmassdrop", npf_relmassdrop, "neutral PF candidate mass drop normalized relative to the jet", nanoaod::FlatTable::FloatColumn); + npfTable->addColumn("px", npf_px, "px", nanoaod::FlatTable::FloatColumn); + npfTable->addColumn("py", npf_py, "py", nanoaod::FlatTable::FloatColumn); + npfTable->addColumn("pz", npf_pz, "pz", nanoaod::FlatTable::FloatColumn); svTable->addColumn("jetIdx", sv_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); svTable->addColumn("ptrel", sv_ptrel, "secondary vertex (SV) transverse momentum relative to the uncorrected jet energy pt", nanoaod::FlatTable::FloatColumn); @@ -806,9 +846,12 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) muonTable->addColumn("EtaRel",mu_EtaRel,"muon candidate pseudorapidity, relative to the jet axis",nanoaod::FlatTable::FloatColumn); muonTable->addColumn("dphi",mu_dphi,"absolute difference between the muon candidate phi and jet phi",nanoaod::FlatTable::FloatColumn); muonTable->addColumn("deta",mu_deta,"absolute difference between the muon candidate eta and jet eta",nanoaod::FlatTable::FloatColumn); + muonTable->addColumn("px", mu_px, "px", nanoaod::FlatTable::FloatColumn); + muonTable->addColumn("py", mu_py, "py", nanoaod::FlatTable::FloatColumn); + muonTable->addColumn("pz", mu_pz, "pz", nanoaod::FlatTable::FloatColumn); muonTable->addColumn("charge",mu_charge,"muon candidate charge (-1 or +1)",nanoaod::FlatTable::FloatColumn); muonTable->addColumn("energy",mu_energy,"muon candidate energy",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("jetDeltaR",mu_jetDeltaR,"pseudoangular distance between jet axis and muon track fourvector",nanoaod::FlatTable::FloatColumn); + muonTable->addColumn("deltaR",mu_deltaR,"pseudoangular distance between jet axis and muon track fourvector",nanoaod::FlatTable::FloatColumn); muonTable->addColumn("numberOfMatchedStations",mu_numberOfMatchedStations,"number of activated muon stations",nanoaod::FlatTable::FloatColumn); muonTable->addColumn("2dIP",mu_2dIP,"muon inner track transverse impact parameter relative to the primary vertex in transverse plane (2D), absolute value",nanoaod::FlatTable::FloatColumn); @@ -822,6 +865,7 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) muonTable->addColumn("dxySig",mu_dxySig,"significance of the transverse impact parameter of the best reconstructed muon track",nanoaod::FlatTable::FloatColumn); muonTable->addColumn("dz",mu_dz,"longitudinal impact parameter of the best reconstructed muon track",nanoaod::FlatTable::FloatColumn); muonTable->addColumn("dzError",mu_dzError,"error on the longitudinal impact parameter of the best reconstructed muon track",nanoaod::FlatTable::FloatColumn); + muonTable->addColumn("dzSig",mu_dzSig,"significance on the longitudinal impact parameter of the best reconstructed muon track",nanoaod::FlatTable::FloatColumn); muonTable->addColumn("numberOfValidPixelHits",mu_numberOfValidPixelHits,"number of pixel hits by the muon track to further suppress muons from decays in flight",nanoaod::FlatTable::IntColumn); muonTable->addColumn("numberOfpixelLayersWithMeasurement",mu_numberOfpixelLayersWithMeasurement,"number of pixel layers with valid hits by the muon track",nanoaod::FlatTable::IntColumn); muonTable->addColumn("numberOfstripLayersWithMeasurement",mu_numberOfstripLayersWithMeasurement,"doc",nanoaod::FlatTable::IntColumn); @@ -849,9 +893,12 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) electronTable->addColumn("jetIdx", elec_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); electronTable->addColumn("ptrel",elec_ptrel,"electron candidate transverse momentum relative to the uncorrected jet energy pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("jetDeltaR",elec_jetDeltaR,"pseudoangular distance between jet axis and electron track fourvector",nanoaod::FlatTable::FloatColumn); + electronTable->addColumn("deltaR",elec_deltaR,"pseudoangular distance between jet axis and electron track fourvector",nanoaod::FlatTable::FloatColumn); electronTable->addColumn("deta",elec_deta,"absolute difference between the electron candidate eta and jet eta",nanoaod::FlatTable::FloatColumn); electronTable->addColumn("dphi",elec_dphi,"absolute difference between the electron candidate phi and jet phi",nanoaod::FlatTable::FloatColumn); + electronTable->addColumn("px", elec_px, "px", nanoaod::FlatTable::FloatColumn); + electronTable->addColumn("py", elec_py, "py", nanoaod::FlatTable::FloatColumn); + electronTable->addColumn("pz", elec_pz, "pz", nanoaod::FlatTable::FloatColumn); electronTable->addColumn("charge",elec_charge,"electron candidate charge (-1 or +1)",nanoaod::FlatTable::FloatColumn); electronTable->addColumn("energy",elec_energy,"electron candidate energy",nanoaod::FlatTable::FloatColumn); electronTable->addColumn("EtFromCaloEn",elec_EtFromCaloEn,"electron transverse energy from calorimeters",nanoaod::FlatTable::FloatColumn); @@ -898,7 +945,11 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) electronTable->addColumn("EtaRel",elec_EtaRel,"electron pseudorapidity, relative to the jet axis",nanoaod::FlatTable::FloatColumn); electronTable->addColumn("dxy",elec_dxy,"transverse impact parameter of the electron",nanoaod::FlatTable::FloatColumn); + electronTable->addColumn("dxyError",elec_dxyError,"error on transverse impact parameter of the electron",nanoaod::FlatTable::FloatColumn); + electronTable->addColumn("dxySig",elec_dxySig,"significance of transverse impact parameter of the electron",nanoaod::FlatTable::FloatColumn); electronTable->addColumn("dz",elec_dz,"longitudinal impact parameter of the best reconstructed electron track",nanoaod::FlatTable::FloatColumn); + electronTable->addColumn("dzError",elec_dzError,"error on longitudinal impact parameter of the best reconstructed electron track",nanoaod::FlatTable::FloatColumn); + electronTable->addColumn("dzSig",elec_dzSig,"significance of longitudinal impact parameter of the best reconstructed electron track",nanoaod::FlatTable::FloatColumn); electronTable->addColumn("nbOfMissingHits",elec_nbOfMissingHits,"number of missing electron hits in its hit pattern",nanoaod::FlatTable::FloatColumn); electronTable->addColumn("gsfCharge",elec_gsfCharge,"gsf electron charge",nanoaod::FlatTable::FloatColumn); electronTable->addColumn("ndof",elec_ndof,"gsf electron number degree of freedom",nanoaod::FlatTable::IntColumn); diff --git a/NANOProducer/test/produceNANO.py b/NANOProducer/test/produceNANO.py index e22d6d5..f5621d2 100644 --- a/NANOProducer/test/produceNANO.py +++ b/NANOProducer/test/produceNANO.py @@ -68,7 +68,7 @@ dataTier = cms.untracked.string('NANOAODSIM') process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) + input = cms.untracked.int32(200) ) process.options = cms.untracked.PSet() @@ -79,6 +79,9 @@ #"mc": "https://github.com/LLPDNNX/test-files/raw/master/miniaod/Moriond17_aug2018_miniAODv3_HNL.root", }, '2016': { + #"mc":"root://xrootd.grid.hep.ph.ic.ac.uk//store/mc/RunIISummer16MiniAODv3/TTJets_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/MINIAODSIM/PUMoriond17_94X_mcRun2_asymptotic_v3-v1/40000/0A4EAAB1-9223-E911-B512-A4BF01283A8B.root", + #"mc":"root://xrootd.grid.hep.ph.ic.ac.uk//store/mc/RunIISummer16MiniAODv3/GluGluToHHTo2B2Tau_node_SM_13TeV-madgraph/MINIAODSIM/PUMoriond17_94X_mcRun2_asymptotic_v3-v2/50000/AEF4E98A-C672-E911-9FD1-AC1F6BAC7D18.root", + #"mc":"root://xrootd.grid.hep.ph.ic.ac.uk//store/mc/RunIISummer16MiniAODv3/DYJetsToLL_M-10to50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/MINIAODSIM/PUMoriond17_94X_mcRun2_asymptotic_v3-v2/00000/025CA8F7-7C08-E911-8165-0242AC1C0501.root", "mc": [ "root://gfe02.grid.hep.ph.ic.ac.uk/pnfs/hep.ph.ic.ac.uk/data/cms/store/user/mkomm/HNL/miniaod16v3_200929/LLPGun/miniaod16v3_200929/201007_212837/0000/GUN2016_%i.root"%(i) for i in range(1,10) ], @@ -287,6 +290,8 @@ srcVertices = cms.InputTag("displacedGenVertices"), srcJets = cms.InputTag("updatedJets"), srcFlavourInfo = cms.InputTag("llpFlavour"), + srcDecayInfo = cms.InputTag("llpGenDecayInfo"), + srcTaus = cms.InputTag("slimmedTaus"), tauPtThreshold = cms.double(1.), quarkPtThreshold = cms.double(1.), bPtThreshold = cms.double(1.), diff --git a/XTagInfoProducer/plugins/XTagInfoProducer.cc b/XTagInfoProducer/plugins/XTagInfoProducer.cc index 2693590..1985f2f 100644 --- a/XTagInfoProducer/plugins/XTagInfoProducer.cc +++ b/XTagInfoProducer/plugins/XTagInfoProducer.cc @@ -349,6 +349,10 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) cpf_features.cpf_ptrel = constituent->pt()/uncorrectedPt; cpf_features.cpf_deta = constituent->eta()-jet.eta(); cpf_features.cpf_dphi = reco::deltaPhi(constituent->phi(),jet.phi()); + + cpf_features.cpf_px = constituent->px(); + cpf_features.cpf_py = constituent->py(); + cpf_features.cpf_pz = constituent->pz(); cpf_features.cpf_drminsv = 0.4; for (const auto& sv: *svs.product()) @@ -437,10 +441,10 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) //find matching muons - llpdnnx::MuonCandidateFeatures mu_features; auto findMuon = muonMap.find(jet.daughterPtr(idaughter)); if (findMuon!=muonMap.end()) { + llpdnnx::MuonCandidateFeatures mu_features; const pat::Muon & muon = *findMuon->second; if (not muon.isGlobalMuon() || reco::deltaR(muon, jet) > 0.4) continue; @@ -453,11 +457,14 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) mu_features.mu_ptrel = muon.pt()/uncorrectedPt; mu_features.mu_deta = muon.eta()-jet.eta(); - mu_features.mu_dphi = reco::deltaPhi(muon.phi(),jet.phi()); + mu_features.mu_dphi = reco::deltaPhi(muon.phi(),jet.phi()); + mu_features.mu_px = muon.px(); + mu_features.mu_py = muon.py(); + mu_features.mu_pz = muon.pz(); mu_features.mu_charge = muon.charge(); mu_features.mu_energy = muon.energy()/muon.pt(); mu_features.mu_et = muon.et(); - mu_features.mu_jetDeltaR = reco::deltaR(muon, jet); + mu_features.mu_deltaR = reco::deltaR(muon, jet); mu_features.mu_numberOfMatchedStations = muon.numberOfMatchedStations(); mu_features.mu_2dIP = muon.dB(); @@ -465,13 +472,6 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) mu_features.mu_3dIP = muon.dB(pat::Muon::PV3D); mu_features.mu_3dIPSig = muon.dB(pat::Muon::PV3D)/muon.edB(pat::Muon::PV3D); - - - cpf_features.cpf_trackSip2dVal=meas_ip2d.value(); - cpf_features.cpf_trackSip2dSig=meas_ip2d.significance(); - cpf_features.cpf_trackSip3dVal=meas_ip3d.value(); - cpf_features.cpf_trackSip3dSig=meas_ip3d.significance(); - if (std::isnan(mu_features.mu_2dIPSig) || std::isnan(mu_features.mu_3dIPSig)) { mu_features.mu_2dIPSig = 0.; @@ -484,9 +484,10 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) mu_features.mu_EtaRel =reco::btau::etaRel(jetDir, muonMom); mu_features.mu_dxy = muon.bestTrack()->dxy(pv.position()); mu_features.mu_dxyError = muon.bestTrack()->dxyError(); - mu_features.mu_dxySig = muon.bestTrack()->dxy(pv.position())/muon.bestTrack()->dxyError(); + mu_features.mu_dxySig = muon.bestTrack()->dxy(pv.position())/(1e-10+std::fabs(muon.bestTrack()->dxyError())); mu_features.mu_dz = muon.bestTrack()->dz(pv.position()); mu_features.mu_dzError = muon.bestTrack()->dzError(); + mu_features.mu_dzSig = muon.bestTrack()->dz(pv.position())/(1e-10+std::fabs(muon.bestTrack()->dzError())); mu_features.mu_numberOfValidPixelHits = muon.bestTrack()->hitPattern().numberOfValidPixelHits(); mu_features.mu_numberOfpixelLayersWithMeasurement = muon.bestTrack()->hitPattern().pixelLayersWithMeasurement(); mu_features.mu_numberOfstripLayersWithMeasurement = muon.bestTrack()->hitPattern().stripLayersWithMeasurement(); @@ -533,10 +534,10 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) //find matching electrons - llpdnnx::ElectronCandidateFeatures elec_features; auto findElectron = electronMap.find(jet.daughterPtr(idaughter)); if(findElectron!=electronMap.end()) { + llpdnnx::ElectronCandidateFeatures elec_features; const pat::Electron & electron = *findElectron->second; cpf_features.cpf_matchedElectron = 1; if (reco::deltaR(electron, jet) > 0.4) continue; @@ -545,8 +546,12 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) elec_features.elec_deta = electron.eta()-jet.eta(); elec_features.elec_dphi = reco::deltaPhi(electron.phi(),jet.phi()); elec_features.elec_charge = electron.charge(); + elec_features.elec_px = electron.px(); + elec_features.elec_py = electron.py(); + elec_features.elec_pz = electron.pz(); + elec_features.elec_energy = electron.energy()/electron.pt(); - elec_features.elec_jetDeltaR = reco::deltaR(electron,jet); + elec_features.elec_deltaR = reco::deltaR(electron,jet); elec_features.elec_EtFromCaloEn = electron.caloEnergy() * sin(electron.p4().theta())/ electron.pt(); elec_features.elec_ecalDrivenSeed = electron.ecalDrivenSeed(); @@ -554,20 +559,22 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) elec_features.elec_isEE = electron.isEE(); elec_features.elec_ecalEnergy = electron.ecalEnergy()/electron.pt(); elec_features.elec_isPassConversionVeto = electron.passConversionVeto(); - if(electron.convDist() >= 0.){ - elec_features.elec_convDist = electron.convDist(); - elec_features.elec_convFlags = electron.convFlags(); - elec_features.elec_convRadius = electron.convRadius(); + if(electron.convDist() >= 0.) + { + elec_features.elec_convDist = electron.convDist(); + elec_features.elec_convFlags = electron.convFlags(); + elec_features.elec_convRadius = electron.convRadius(); } - else{ - elec_features.elec_convDist = -1.; - elec_features.elec_convFlags = -1.; - elec_features.elec_convRadius = -1.; + else + { + elec_features.elec_convDist = -1.; + elec_features.elec_convFlags = -1.; + elec_features.elec_convRadius = -1.; } elec_features.elec_3dIP = electron.dB(pat::Electron::PV3D); - elec_features.elec_3dIPSig = electron.dB(pat::Electron::PV3D); + elec_features.elec_3dIPSig = electron.dB(pat::Electron::PV3D)/electron.edB(pat::Electron::PV3D); elec_features.elec_2dIP = electron.dB(); elec_features.elec_2dIPSig = electron.dB()/electron.edB(); @@ -601,7 +608,12 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) elec_features.elec_EtaRel = reco::btau::etaRel(jetDir, electronMom); elec_features.elec_dxy = electron.gsfTrack()->dxy(pv.position()); + elec_features.elec_dxyError = electron.gsfTrack()->dxyError(); + elec_features.elec_dxySig = electron.gsfTrack()->dxy(pv.position())/(1e-10+std::fabs(electron.gsfTrack()->dxyError())); elec_features.elec_dz = electron.gsfTrack()->dz(pv.position()); + elec_features.elec_dzError = electron.gsfTrack()->dzError(); + elec_features.elec_dzSig = electron.gsfTrack()->dz(pv.position())/(1e-10+std::fabs(electron.gsfTrack()->dzError())); + elec_features.elec_nbOfMissingHits = electron.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS); elec_features.elec_gsfCharge = electron.gsfTrack()->charge(); elec_features.elec_ndof = electron.gsfTrack()->ndof(); @@ -741,6 +753,11 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) npf_features.npf_ptrel = constituent->pt()/uncorrectedPt; npf_features.npf_deta = constituent->eta()-jet.eta(); npf_features.npf_dphi = reco::deltaPhi(constituent->phi(),jet.phi()); + + npf_features.npf_px = constituent->px(); + npf_features.npf_py = constituent->py(); + npf_features.npf_pz = constituent->pz(); + npf_features.npf_puppi_weight = constituent->puppiWeight(); npf_features.npf_deltaR = reco::deltaR(*constituent,jet); npf_features.npf_isGamma = abs(constituent->pdgId())==22; @@ -839,7 +856,7 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) features.jet_features.frac04 = (float)frac04/nCandidates; features.jet_features.dR2Mean = dR2Mean/pt2Sum; } - + output_tag_infos->emplace_back(features, jet_ref); } From edfba0482ba1cb3967e7d5680b03da3fefda88e1 Mon Sep 17 00:00:00 2001 From: matt-komm Date: Sat, 7 Nov 2020 12:28:19 +0000 Subject: [PATCH 04/20] up --- DataFormats/interface/LLPLabel.h | 18 ++ LLPLabelProducer/plugins/LLPLabelProducer.cc | 205 +++++++++---------- 2 files changed, 110 insertions(+), 113 deletions(-) diff --git a/DataFormats/interface/LLPLabel.h b/DataFormats/interface/LLPLabel.h index c752aef..f36c59f 100644 --- a/DataFormats/interface/LLPLabel.h +++ b/DataFormats/interface/LLPLabel.h @@ -47,6 +47,12 @@ class LLPLabel { isLLP_QQTAU, isLLP_BTAU, isLLP_BBTAU, + + isLLP_PHOTON, + isLLP_QPHOTON, + isLLP_QQPHOTON, + isLLP_BPHOTON, + isLLP_BBPHOTON, isUndefined }; @@ -185,6 +191,18 @@ class LLPLabel { return "isLLP_BTAU"; case Type::isLLP_BBTAU: return "isLLP_BBTAU"; + + case Type::isLLP_PHOTON: + return "isLLP_TAU"; + case Type::isLLP_QPHOTON: + return "isLLP_QTAU"; + case Type::isLLP_QQPHOTON: + return "isLLP_QQTAU"; + case Type::isLLP_BPHOTON: + return "isLLP_BTAU"; + case Type::isLLP_BBPHOTON: + return "isLLP_BBTAU"; + case Type::isUndefined: return "isUndefined"; } diff --git a/LLPLabelProducer/plugins/LLPLabelProducer.cc b/LLPLabelProducer/plugins/LLPLabelProducer.cc index 0d55b34..9645192 100644 --- a/LLPLabelProducer/plugins/LLPLabelProducer.cc +++ b/LLPLabelProducer/plugins/LLPLabelProducer.cc @@ -116,6 +116,11 @@ class LLPLabelProducer: } + static double calcFraction(const reco::Candidate::LorentzVector& p, const reco::Candidate::LorentzVector& base) + { + return p.Vect().Dot(base.Vect())/base.Vect().mag2(); + } + static void printDecayChain(std::vector& finals, const reco::Candidate* p, int indent=1) { for (int i=0; i < indent; ++i) std::cout<<" - "; @@ -260,25 +265,20 @@ LLPLabelProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) //std::cout<<"jet "<pdgId())==11) label.type=llpdnnx::LLPLabel::Type::isLLP_BBE; - else if (std::abs(displacedLepton->pdgId())==13) label.type=llpdnnx::LLPLabel::Type::isLLP_BBMU; - else if (std::abs(displacedLepton->pdgId())==15) label.type=llpdnnx::LLPLabel::Type::isLLP_BBTAU; + if (promptRecoMaxId==11) label.type=llpdnnx::LLPLabel::Type::isLLP_BBE; + else if (promptRecoMaxId==13) label.type=llpdnnx::LLPLabel::Type::isLLP_BBMU; + else if (promptRecoMaxId==15) label.type=llpdnnx::LLPLabel::Type::isLLP_BBTAU; + else if (promptRecoMaxId==22) label.type=llpdnnx::LLPLabel::Type::isLLP_BBPHOTON; else throw std::runtime_error("LLPLabel not well defined"); } } else { - if (not displacedLepton) + if (calcFraction(promptRecoMax,jet.p4())<0.1) //arbitrary threshold; reconstructed candidates count! { - if (nPartons==0) label.type=llpdnnx::LLPLabel::Type::isLLP_RAD; - else if (nPartons==1) label.type=llpdnnx::LLPLabel::Type::isLLP_Q; + if (nQuarks==0) label.type=llpdnnx::LLPLabel::Type::isLLP_RAD; + else if (nQuarks==1) label.type=llpdnnx::LLPLabel::Type::isLLP_Q; else label.type=llpdnnx::LLPLabel::Type::isLLP_QQ; } else { - if (nPartons==0) + if (nQuarks==0) { - if (std::abs(displacedLepton->pdgId())==11) label.type=llpdnnx::LLPLabel::Type::isLLP_E; - else if (std::abs(displacedLepton->pdgId())==13) label.type=llpdnnx::LLPLabel::Type::isLLP_MU; - else if (std::abs(displacedLepton->pdgId())==15) label.type=llpdnnx::LLPLabel::Type::isLLP_TAU; + if (promptRecoMaxId==11) label.type=llpdnnx::LLPLabel::Type::isLLP_E; + else if (promptRecoMaxId==13) label.type=llpdnnx::LLPLabel::Type::isLLP_MU; + else if (promptRecoMaxId==15) label.type=llpdnnx::LLPLabel::Type::isLLP_TAU; + else if (promptRecoMaxId==22) label.type=llpdnnx::LLPLabel::Type::isLLP_PHOTON; else throw std::runtime_error("LLPLabel not well defined"); } - else if (nPartons==1) + else if (nQuarks==1) { - if (std::abs(displacedLepton->pdgId())==11) label.type=llpdnnx::LLPLabel::Type::isLLP_QE; - else if (std::abs(displacedLepton->pdgId())==13) label.type=llpdnnx::LLPLabel::Type::isLLP_QMU; - else if (std::abs(displacedLepton->pdgId())==15) label.type=llpdnnx::LLPLabel::Type::isLLP_QTAU; + if (promptRecoMaxId==11) label.type=llpdnnx::LLPLabel::Type::isLLP_QE; + else if (promptRecoMaxId==13) label.type=llpdnnx::LLPLabel::Type::isLLP_QMU; + else if (promptRecoMaxId==15) label.type=llpdnnx::LLPLabel::Type::isLLP_QTAU; + else if (promptRecoMaxId==22) label.type=llpdnnx::LLPLabel::Type::isLLP_QPHOTON; else throw std::runtime_error("LLPLabel not well defined"); } else { - if (std::abs(displacedLepton->pdgId())==11) label.type=llpdnnx::LLPLabel::Type::isLLP_QQE; - else if (std::abs(displacedLepton->pdgId())==13) label.type=llpdnnx::LLPLabel::Type::isLLP_QQMU; - else if (std::abs(displacedLepton->pdgId())==15) label.type=llpdnnx::LLPLabel::Type::isLLP_QQTAU; + if (promptRecoMaxId==11) label.type=llpdnnx::LLPLabel::Type::isLLP_QQE; + else if (promptRecoMaxId==13) label.type=llpdnnx::LLPLabel::Type::isLLP_QQMU; + else if (promptRecoMaxId==15) label.type=llpdnnx::LLPLabel::Type::isLLP_QQTAU; + else if (promptRecoMaxId==22) label.type=llpdnnx::LLPLabel::Type::isLLP_QQPHOTON; else throw std::runtime_error("LLPLabel not well defined"); } } From bad38ff99d0609c8a4b91b6d52c457d7b9c06eee Mon Sep 17 00:00:00 2001 From: matt-komm Date: Sat, 7 Nov 2020 14:54:16 +0000 Subject: [PATCH 05/20] done new labels --- LLPLabelProducer/plugins/BuildFile.xml | 3 + .../plugins/LLPLabelOldProducer.cc | 473 ++++++++++++++++++ LLPLabelProducer/plugins/LLPLabelProducer.cc | 125 ++--- NANOProducer/plugins/NANOGenProducer.cc | 18 +- NANOProducer/test/produceNANO.py | 23 +- 5 files changed, 557 insertions(+), 85 deletions(-) create mode 100644 LLPLabelProducer/plugins/LLPLabelOldProducer.cc diff --git a/LLPLabelProducer/plugins/BuildFile.xml b/LLPLabelProducer/plugins/BuildFile.xml index b655f6f..74d6c0d 100644 --- a/LLPLabelProducer/plugins/BuildFile.xml +++ b/LLPLabelProducer/plugins/BuildFile.xml @@ -21,4 +21,7 @@ + + + diff --git a/LLPLabelProducer/plugins/LLPLabelOldProducer.cc b/LLPLabelProducer/plugins/LLPLabelOldProducer.cc new file mode 100644 index 0000000..e7398e5 --- /dev/null +++ b/LLPLabelProducer/plugins/LLPLabelOldProducer.cc @@ -0,0 +1,473 @@ +// system include files +#include +#include +#include +// user include files + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#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/Framework/interface/ESHandle.h" +#include "FWCore/Utilities/interface/Exception.h" + +#include "LLPReco/DataFormats/interface/DisplacedGenVertex.h" +#include "LLPReco/DataFormats/interface/LLPLabelInfo.h" + +#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" +#include "DataFormats/PatCandidates/interface/PackedGenParticle.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" + +#include "DataFormats/Math/interface/deltaR.h" +#include "DataFormats/Math/interface/angle.h" + +#include "DataFormats/PatCandidates/interface/Jet.h" + +#include "LLPReco/DataFormats/interface/LLPGhostFlavourInfo.h" + +#include "TH1.h" + + +using llpdnnx::DisplacedGenVertex; +using llpdnnx::DisplacedGenVertexCollection; + +class LLPLabelOldProducer: + public edm::stream::EDProducer<> + +{ + private: + struct LLPDecay + { + const reco::GenParticle* llp; + std::vector decayProducts; + + LLPDecay(): + llp(nullptr) + { + } + }; + + //TH1D *hist; + //edm::Service fs; + + + static int getHadronFlavor(const reco::Candidate& genParticle) + { + int absPdgId = std::abs(genParticle.pdgId()); + if (absPdgId<100) + { + if (absPdgId<6) return absPdgId; //parton + return 0; //not a hadron + } + int nq3 = (absPdgId/ 10)%10; //quark content + int nq2 = (absPdgId/ 100)%10; //quark content + int nq1 = (absPdgId/ 1000)%10; //quark content + int nL = (absPdgId/ 10000)%10; + int n = (absPdgId/1000000)%10; + return std::max({nq1,nq2,nq3})+n*10000+(n>0 and nL==9)*100; + } + double tauPtThreshold_; + double quarkPtThreshold_; + double bPtThreshold_; + double muonPtThreshold_; + double electronPtThreshold_; + + std::unordered_map jetsPerLabel_; + + edm::EDGetTokenT> jetToken_; + edm::EDGetTokenT> displacedGenVertexToken_; + edm::EDGetTokenT> llpFlavourInfoToken_; + + + virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override; + + public: + explicit LLPLabelOldProducer(const edm::ParameterSet&); + ~LLPLabelOldProducer(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +}; + +LLPLabelOldProducer::LLPLabelOldProducer(const edm::ParameterSet& iConfig): + tauPtThreshold_(iConfig.getParameter("tauPtThreshold")), + quarkPtThreshold_(iConfig.getParameter("quarkPtThreshold")), + bPtThreshold_(iConfig.getParameter("bPtThreshold")), + muonPtThreshold_(iConfig.getParameter("muonPtThreshold")), + electronPtThreshold_(iConfig.getParameter("electronPtThreshold")), + jetToken_(consumes>(iConfig.getParameter("srcJets"))), + displacedGenVertexToken_(consumes>(iConfig.getParameter("srcVertices"))), + llpFlavourInfoToken_(consumes>(iConfig.getParameter("srcFlavourInfo"))) +{ + produces(); + //hist = fs->make("ptfrac" , "ptfrac" , 100 , 0 , 1. ); +} + + +LLPLabelOldProducer::~LLPLabelOldProducer() +{ + for (const auto& labelCountPair: jetsPerLabel_) + { + std::cout<> jetCollection; + iEvent.getByToken(jetToken_, jetCollection); + + edm::Handle> displacedGenVertexCollection; + iEvent.getByToken(displacedGenVertexToken_, displacedGenVertexCollection); + + edm::Handle> llpGhostFlavourInfoMap; + iEvent.getByToken(llpFlavourInfoToken_, llpGhostFlavourInfoMap); + + auto outputLLPLabelInfo = std::make_unique(); + + for (std::size_t ijet = 0; ijet < jetCollection->size(); ijet++) + { + const pat::Jet& jet = jetCollection->at(ijet); + edm::RefToBase jet_ref(jetCollection->refAt(ijet)); + llpdnnx::LLPLabel label; + + if (not jet.genJet()) + { + label.type = llpdnnx::LLPLabel::Type::isPU; + } + else + { + int partonFlavor = abs(jet.partonFlavour()); + int hadronFlavor = abs(jet.hadronFlavour()); + + label.partonFlavor = partonFlavor; + label.hadronFlavor = hadronFlavor; + label.matchedGenJetDeltaR = reco::deltaR(jet.p4(),jet.genJet()->p4()); + label.matchedGenJetPt = jet.genJet()->pt(); + + unsigned int nbHadrons = jet.jetFlavourInfo().getbHadrons().size(); + unsigned int ncHadrons = jet.jetFlavourInfo().getcHadrons().size(); + + unsigned int nbHadronsToLeptons = 0; + unsigned int ncHadronsToLeptons = 0; + + unsigned int nPromptElectrons = 0; + unsigned int nPromptMuons = 0; + + unsigned int nGluons = 0; + + float tauPtFrac = 0; + + float promptPtThreshold = 0.6; + + if (jet.genParton() and (partonFlavor==5 or partonFlavor==4)) + { + const reco::Candidate* mother = jet.genParton(); + //walk up + while (mother->mother() and mother->mother()->pdgId()==mother->pdgId()) + { + mother = mother->mother(); + } + //find gluon anchestor + if (mother->mother() and mother->mother()->pdgId()==21) + { + nGluons+=1; + } + } + + for (unsigned int iConst = 0; iConst < jet.genJet()->numberOfDaughters(); iConst++) + { + const reco::Candidate* constituent = jet.genJet()->daughter(iConst); + const pat::PackedGenParticle* packedConstituent = dynamic_cast(constituent); + unsigned int absId = std::abs(constituent->pdgId()); + if (not (constituent->mother())) + { + continue; + } + + if (absId == 11 or absId == 13) + { + if (packedConstituent->isPromptFinalState() or packedConstituent->isDirectPromptTauDecayProductFinalState()) + { + int hadFlavor = getHadronFlavor(*constituent->mother()); + if (hadFlavor==5) nbHadronsToLeptons+=1; + if (hadFlavor==4) ncHadronsToLeptons+=1; + + float ptFrac = constituent->pt()/jet.genJet()->pt(); + if (ptFrac > promptPtThreshold) + { + if (absId == 13){ + nPromptMuons += 1; + } + else if (absId == 11){ + nPromptElectrons += 1; + } + } + } + } + + else if (packedConstituent->isDirectPromptTauDecayProductFinalState()) + { + tauPtFrac += constituent->pt()/jet.genJet()->pt(); + } + } + + + if (tauPtFrac > promptPtThreshold) + { + //hist->Fill(tauPtFrac); + label.type = llpdnnx::LLPLabel::Type::isPrompt_TAU; + } + + else if (nPromptMuons > 0) + { + label.type = llpdnnx::LLPLabel::Type::isPrompt_MU; + } + + + else if (nPromptElectrons > 0) + { + label.type = llpdnnx::LLPLabel::Type::isPrompt_E; + } + + else if (hadronFlavor==5) + { + if (nbHadronsToLeptons==0 and ncHadronsToLeptons==0) + { + if (nbHadrons>1) + { + if (nGluons==0) + { + label.type = llpdnnx::LLPLabel::Type::isBB; + } + else + { + label.type = llpdnnx::LLPLabel::Type::isBB; + } + } + else if (nbHadrons==1) + { + label.type = llpdnnx::LLPLabel::Type::isB; + } + } + else + { + if (nbHadronsToLeptons>0) + { + label.type = llpdnnx::LLPLabel::Type::isLeptonic_B; + } + else if (nbHadronsToLeptons==0 and ncHadronsToLeptons>0) + { + label.type = llpdnnx::LLPLabel::Type::isLeptonic_C; + } + } + } + else if (hadronFlavor==4) + { + if (ncHadrons>1) + { + if (nGluons==0) + { + label.type = llpdnnx::LLPLabel::Type::isCC; + } + else + { + label.type = llpdnnx::LLPLabel::Type::isCC; + } + } + else if (ncHadrons==1) + { + label.type = llpdnnx::LLPLabel::Type::isC; + } + } + else if (partonFlavor!=0) + { + if (partonFlavor==5) label.type = llpdnnx::LLPLabel::Type::isB; + if (partonFlavor==4) label.type = llpdnnx::LLPLabel::Type::isC; + if (partonFlavor==3) label.type = llpdnnx::LLPLabel::Type::isS; + if (partonFlavor==2 or partonFlavor==1) label.type = llpdnnx::LLPLabel::Type::isUD; + if (partonFlavor==21) label.type = llpdnnx::LLPLabel::Type::isG; + } + else + { + /* + std::cout<<" jet: "<size())<<", pt="<size())<<", pt="<("quarkPtThreshold")), - bPtThreshold_(iConfig.getParameter("bPtThreshold")), - muonPtThreshold_(iConfig.getParameter("muonPtThreshold")), - electronPtThreshold_(iConfig.getParameter("electronPtThreshold")), jetToken_(consumes>(iConfig.getParameter("srcJets"))), displacedGenVertexToken_(consumes>(iConfig.getParameter("srcVertices"))), - llpFlavourInfoToken_(consumes>(iConfig.getParameter("srcFlavourInfo"))), - llpGenDecayInfoToken_(consumes>( iConfig.getParameter("srcDecayInfo") )), - tauToken_(consumes>( iConfig.getParameter("srcTaus") )) + llpGenDecayInfoToken_(consumes>( iConfig.getParameter("srcDecayInfo") )) { produces(); - //hist = fs->make("ptfrac" , "ptfrac" , 100 , 0 , 1. ); - - nGenTau_ = 0; - nLabelledTau_ = 0; - nPatTau_ = 0; - nPatNotGen_ = 0; - nLabelledNotPat_ = 0; } LLPLabelProducer::~LLPLabelProducer() { - std::cout<<"gentau="<> displacedGenVertexCollection; iEvent.getByToken(displacedGenVertexToken_, displacedGenVertexCollection); - edm::Handle> llpGhostFlavourInfoMap; - iEvent.getByToken(llpFlavourInfoToken_, llpGhostFlavourInfoMap); - edm::Handle> llpGenDecayInfoCollection; iEvent.getByToken(llpGenDecayInfoToken_, llpGenDecayInfoCollection); - edm::Handle> tauCollection; - iEvent.getByToken(tauToken_, tauCollection); - auto outputLLPLabelInfo = std::make_unique(); for (std::size_t ijet = 0; ijet < jetCollection->size(); ijet++) { const pat::Jet& jet = jetCollection->at(ijet); - if (jet.pt()<15.) continue; edm::RefToBase jet_ref(jetCollection->refAt(ijet)); llpdnnx::LLPLabel label; @@ -394,6 +355,41 @@ LLPLabelProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) promptRecoMaxId = 15; promptRecoMax = tauRecoSum; } + + //classify tau decay + int nH = 0; + int nPi0 = 0; + int nE = 0; + int nMu = 0; + for (size_t idaughter = 0; idaughter < tau->numberOfDaughters(); ++idaughter) + { + int daughterAbsId = std::abs( tau->daughter(idaughter)->pdgId()); + if (daughterAbsId==11) nE+=1; + else if (daughterAbsId==13) nMu+=1; + else if (daughterAbsId==111) nPi0+=1; + else if (daughterAbsId>111 and daughterAbsId<500) nH+=1; + } + if (nE>0) label.tauDecay = llpdnnx::LLPLabel::TauDecay::E; + else if (nMu>0) label.tauDecay = llpdnnx::LLPLabel::TauDecay::MU; + else if (nH==1) + { + if (nPi0==0) label.tauDecay = llpdnnx::LLPLabel::TauDecay::H; + else if (nPi0==1) label.tauDecay = llpdnnx::LLPLabel::TauDecay::H_1PI0; + else label.tauDecay = llpdnnx::LLPLabel::TauDecay::H_XPI0; + } + else if (nH>1) + { + if (nPi0==0) label.tauDecay = llpdnnx::LLPLabel::TauDecay::HHH; + else label.tauDecay = llpdnnx::LLPLabel::TauDecay::HHH_XPI0; + } + else + { + std::cout<<"WARNING: Tau decay cannot be characterised"<0) nGenTau_+=1; - - bool matchTau = false; - for (const auto& tau: *tauCollection) - { - if (reco::deltaR(tau,jet)<0.4) - { - matchTau=true; - nPatTau_+=1;//std::cout<<" - "<<"reco tau pt="<size())<<", pt="<addColumn("isLLP_BTAU", isLLP_BTAU, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isLLP_BBTAU", isLLP_BBTAU, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isLLP_PHOTON", isLLP_PHOTON, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isLLP_QPHOTON", isLLP_QPHOTON, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isLLP_QQPHOTON", isLLP_QQPHOTON, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isLLP_BPHOTON", isLLP_BPHOTON, "doc", nanoaod::FlatTable::IntColumn); + jetOriginTable->addColumn("isLLP_BBPHOTON", isLLP_BBPHOTON, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isUndefined", isUndefined, "doc", nanoaod::FlatTable::IntColumn); jetOriginTable->addColumn("isTauDecay_NO_TAU", isTauDecay_NO_TAU, "doc", nanoaod::FlatTable::IntColumn); diff --git a/NANOProducer/test/produceNANO.py b/NANOProducer/test/produceNANO.py index f5621d2..75ebb7e 100644 --- a/NANOProducer/test/produceNANO.py +++ b/NANOProducer/test/produceNANO.py @@ -68,7 +68,7 @@ dataTier = cms.untracked.string('NANOAODSIM') process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(200) + input = cms.untracked.int32(1000) ) process.options = cms.untracked.PSet() @@ -275,30 +275,26 @@ ) ) -process.llpFlavour = cms.EDProducer( - "LLPGhostFlavourProducer", - srcJets = cms.InputTag("updatedJets"), - srcDecayInfo = cms.InputTag("llpGenDecayInfo"), - jetAlgorithm = cms.string("AntiKt"), - rParam = cms.double(0.4), - ghostRescaling = cms.double(1e-18), - relPtTolerance = cms.double(1e-3) -) process.llpLabels = cms.EDProducer( "LLPLabelProducer", srcVertices = cms.InputTag("displacedGenVertices"), srcJets = cms.InputTag("updatedJets"), - srcFlavourInfo = cms.InputTag("llpFlavour"), srcDecayInfo = cms.InputTag("llpGenDecayInfo"), - srcTaus = cms.InputTag("slimmedTaus"), +) +''' +process.llpLabelsOld = cms.EDProducer( + "LLPLabelOldProducer", + srcVertices = cms.InputTag("displacedGenVertices"), + srcJets = cms.InputTag("updatedJets"), + srcFlavourInfo = cms.InputTag("llpFlavour"), tauPtThreshold = cms.double(1.), quarkPtThreshold = cms.double(1.), bPtThreshold = cms.double(1.), muonPtThreshold = cms.double(1.), electronPtThreshold = cms.double(1.), ) - +''' process.lheWeightsTable = cms.EDProducer( @@ -387,7 +383,6 @@ process.pfXTagInfos+ process.displacedGenVertexSequence+ process.llpGenDecayInfo+ - process.llpFlavour+ process.llpLabels+ process.nanoTable+ process.nanoGenTable From 78d472495827d42a11a060a9a5f319b80c1919bc Mon Sep 17 00:00:00 2001 From: matt-komm Date: Fri, 13 Nov 2020 00:17:55 +0000 Subject: [PATCH 06/20] more fixes --- DataFormats/interface/JetFeatures.h | 14 +- DataFormats/interface/LLPLabel.h | 5 +- LLPLabelProducer/plugins/LLPLabelProducer.cc | 2 + NANOProducer/plugins/NANOGenProducer.cc | 3 + NANOProducer/plugins/NANOProducer.cc | 22 +++ NANOProducer/test/crab.py | 136 ++++++++++++++----- NANOProducer/test/getFiles.py | 2 +- XTagInfoProducer/plugins/XTagInfoProducer.cc | 25 ++-- 8 files changed, 161 insertions(+), 48 deletions(-) diff --git a/DataFormats/interface/JetFeatures.h b/DataFormats/interface/JetFeatures.h index 3b92287..473103e 100644 --- a/DataFormats/interface/JetFeatures.h +++ b/DataFormats/interface/JetFeatures.h @@ -49,6 +49,12 @@ struct JetFeatures float eventShapeC; float eventShapeD; + int ncpf; + int nnpf; + int nsv; + int nmuon; + int nelectron; + JetFeatures(): jetIdx(-1), pt(-1), @@ -91,7 +97,13 @@ struct JetFeatures circularity(-1), isotropy(-1), eventShapeC(-1), - eventShapeD(-1) + eventShapeD(-1), + + ncpf(0), + nnpf(0), + nsv(0), + nmuon(0), + nelectron(0) { } diff --git a/DataFormats/interface/LLPLabel.h b/DataFormats/interface/LLPLabel.h index f36c59f..3da4182 100644 --- a/DataFormats/interface/LLPLabel.h +++ b/DataFormats/interface/LLPLabel.h @@ -86,8 +86,10 @@ class LLPLabel { float decay_angle; float betagamma; + float matchedGenJetDeltaR; float matchedGenJetPt; + float sharedVertexFraction; LLPLabel(): type(Type::isUndefined), @@ -103,7 +105,8 @@ class LLPLabel { decay_angle(0), betagamma(0), matchedGenJetDeltaR(-1), - matchedGenJetPt(-1) + matchedGenJetPt(-1), + sharedVertexFraction(0) { } diff --git a/LLPLabelProducer/plugins/LLPLabelProducer.cc b/LLPLabelProducer/plugins/LLPLabelProducer.cc index c66a61c..8c603fd 100644 --- a/LLPLabelProducer/plugins/LLPLabelProducer.cc +++ b/LLPLabelProducer/plugins/LLPLabelProducer.cc @@ -478,6 +478,7 @@ LLPLabelProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) dRmin = dRGenJets; matchedVertex = &vertex; matchedGenJet = &genJet; + label.sharedVertexFraction = vertex.jetFractions[igenJet]; } } } @@ -488,6 +489,7 @@ LLPLabelProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) label.matchedGenJetDeltaR = dRmin; label.matchedGenJetPt = matchedGenJet->pt(); + int maxFlavor = 0; //take displacement from matched vertex, i.e. end of potential decay chain = largest displacement diff --git a/NANOProducer/plugins/NANOGenProducer.cc b/NANOProducer/plugins/NANOGenProducer.cc index 193a1b0..d2ca942 100644 --- a/NANOProducer/plugins/NANOGenProducer.cc +++ b/NANOProducer/plugins/NANOGenProducer.cc @@ -142,6 +142,7 @@ NANOGenProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector matchedGenJetDeltaR; std::vector matchedGenJetPt; + std::vector sharedVertexFraction; for (std::size_t itag = 0; itag < ntruth; itag++) { const auto& labels = label_infos->at(itag).features(); @@ -226,6 +227,7 @@ NANOGenProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) matchedGenJetDeltaR.push_back(labels.matchedGenJetDeltaR); matchedGenJetPt.push_back(labels.matchedGenJetPt); + sharedVertexFraction.push_back(labels.sharedVertexFraction); } @@ -296,6 +298,7 @@ NANOGenProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) jetOriginTable->addColumn("matchedGenJetDeltaR", matchedGenJetDeltaR, "doc", nanoaod::FlatTable::FloatColumn); jetOriginTable->addColumn("matchedGenJetPt", matchedGenJetPt, "doc", nanoaod::FlatTable::FloatColumn); + jetOriginTable->addColumn("sharedVertexFraction", sharedVertexFraction, "doc", nanoaod::FlatTable::FloatColumn); iEvent.put(std::move(jetOriginTable), "jetorigin"); } diff --git a/NANOProducer/plugins/NANOProducer.cc b/NANOProducer/plugins/NANOProducer.cc index bbc68d8..6f567dc 100644 --- a/NANOProducer/plugins/NANOProducer.cc +++ b/NANOProducer/plugins/NANOProducer.cc @@ -140,6 +140,12 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector trackSip3dSigAboveCharm; std::vector jetNSelectedTracks; std::vector jetNTracksEtaRel; + + std::vector ncpf_list; + std::vector nnpf_list; + std::vector nsv_list; + std::vector nmuon_list; + std::vector nelectron_list; std::vector cpf_trackEtaRel; std::vector cpf_trackPtRel; @@ -156,6 +162,7 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector cpf_ptrel; std::vector cpf_deta; std::vector cpf_dphi; + std::vector cpf_deltaR; std::vector cpf_px; std::vector cpf_py; std::vector cpf_pz; @@ -445,6 +452,13 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) jetNSelectedTracks.push_back(tag_info_features.csv_jetNSelectedTracks); jetNTracksEtaRel.push_back(tag_info_features.csv_jetNTracksEtaRel); vertexCategory.push_back(tag_info_features.csv_vertexCategory); + + ncpf_list.push_back(features.jet_features.ncpf); + nnpf_list.push_back(features.jet_features.nnpf); + nsv_list.push_back(features.jet_features.nsv); + nmuon_list.push_back(features.jet_features.nmuon); + nelectron_list.push_back(features.jet_features.nelectron); + } auto muonTable = std::make_unique(nmu_total, "muon", false, false); @@ -489,6 +503,7 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) cpf_ptrel.push_back(cpf_features.cpf_ptrel); cpf_deta.push_back(cpf_features.cpf_deta); cpf_dphi.push_back(cpf_features.cpf_dphi); + cpf_deltaR.push_back(cpf_features.cpf_deltaR); cpf_px.push_back(cpf_features.cpf_px); cpf_py.push_back(cpf_features.cpf_py); cpf_pz.push_back(cpf_features.cpf_pz); @@ -752,6 +767,12 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) globalTable->addColumn("jetR", jetR, "fraction of jet pt carried by lead constituent", nanoaod::FlatTable::FloatColumn); globalTable->addColumn("jetRchg", jetRchg, "fraction of jet pt carried by lead jet constituent", nanoaod::FlatTable::FloatColumn); + globalTable->addColumn("ncpf", ncpf_list, "doc", nanoaod::FlatTable::IntColumn); + globalTable->addColumn("nnpf", nnpf_list, "doc", nanoaod::FlatTable::IntColumn); + globalTable->addColumn("nsv", nsv_list, "doc", nanoaod::FlatTable::IntColumn); + globalTable->addColumn("nmuon", nmuon_list, "doc", nanoaod::FlatTable::IntColumn); + globalTable->addColumn("nelectron", nelectron_list, "doc", nanoaod::FlatTable::IntColumn); + csvTable->addColumn("trackSumJetEtRatio", trackSumJetEtRatio, "ratio of track sum transverse energy over jet energy", nanoaod::FlatTable::FloatColumn); csvTable->addColumn("trackSumJetDeltaR", trackSumJetDeltaR, "pseudoangular distance between jet axis and track fourvector sum", nanoaod::FlatTable::FloatColumn); csvTable->addColumn("vertexCategory", vertexCategory, "category of secondary vertex (Reco, Pseudo, No)", nanoaod::FlatTable::FloatColumn); @@ -794,6 +815,7 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) cpfTable->addColumn("dzMin", cpf_dZmin, "min distance to other PV", nanoaod::FlatTable::FloatColumn); cpfTable->addColumn("deta", cpf_deta, "absolute difference between the charged PF candidate eta and jet eta", nanoaod::FlatTable::FloatColumn); cpfTable->addColumn("dphi", cpf_dphi, "absolute difference between the charged PF candidate phi and jet phi", nanoaod::FlatTable::FloatColumn); + cpfTable->addColumn("deltaR", cpf_deltaR, "R between the charged PF candidate and jet", nanoaod::FlatTable::FloatColumn); cpfTable->addColumn("px", cpf_px, "px", nanoaod::FlatTable::FloatColumn); cpfTable->addColumn("py", cpf_py, "py", nanoaod::FlatTable::FloatColumn); cpfTable->addColumn("pz", cpf_pz, "pz", nanoaod::FlatTable::FloatColumn); diff --git a/NANOProducer/test/crab.py b/NANOProducer/test/crab.py index c91a585..c8c7485 100644 --- a/NANOProducer/test/crab.py +++ b/NANOProducer/test/crab.py @@ -9,45 +9,106 @@ "TTJets_TuneCUETP8M1_13TeV-madgraphMLM-pythia8-2016":{ "inputDataset":"/TTJets_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/RunIISummer16MiniAODv3-PUMoriond17_94X_mcRun2_asymptotic_v3-v1/MINIAODSIM", "year": 2016, + "unitsPerJob": 2, }, "TTJets_TuneCP5_13TeV-madgraphMLM-pythia8-2017":{ "inputDataset":"/TTJets_TuneCP5_13TeV-madgraphMLM-pythia8/RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1/MINIAODSIM", "year": 2017, + "unitsPerJob": 2, }, "TTJets_TuneCP5_13TeV-madgraphMLM-pythia8-2018":{ "inputDataset":"/TTJets_TuneCP5_13TeV-madgraphMLM-pythia8/RunIIAutumn18MiniAOD-102X_upgrade2018_realistic_v15-v1/MINIAODSIM", "year": 2018, + "unitsPerJob": 2, }, - "WJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia-2016":{ - "inputDataset":"/WJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/RunIISummer16MiniAODv3-PUMoriond17_94X_mcRun2_asymptotic_v3-v1/MINIAODSIM", - "year": 2016 + "WJetsToLNu_TuneCUETP8M1_13TeV-madgraphMLM-pythia8-2016":{ + "inputDataset":"/WJetsToLNu_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/RunIISummer16MiniAODv3-PUMoriond17_94X_mcRun2_asymptotic_v3_ext2-v2/MINIAODSIM", + "year": 2016, + "unitsPerJob": 3, }, - "WJetsToLNu_Pt-50To100_TuneCP5_13TeV-amcatnloFXFX-pythia8-2017":{ - "inputDataset":"/WJetsToLNu_Pt-50To100_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1/MINIAODSIM", - "year": 2017 + "WJetsToLNu_TuneCP5_13TeV-madgraphMLM-pythia8-2017":{ + "inputDataset":"/WJetsToLNu_TuneCP5_13TeV-madgraphMLM-pythia8/RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14_ext1-v2/MINIAODSIM", + "year": 2017, + "unitsPerJob": 3, }, - "WJetsToLNu_Pt-50To100_TuneCP5_13TeV-amcatnloFXFX-pythia8-2018":{ - "inputDataset":"/WJetsToLNu_Pt-50To100_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIIAutumn18MiniAOD-102X_upgrade2018_realistic_v15-v1/MINIAODSIM", - "year": 2018 + "WJetsToLNu_TuneCP5_13TeV-madgraphMLM-pythia8-2018":{ + "inputDataset":"/WJetsToLNu_TuneCP5_13TeV-madgraphMLM-pythia8/RunIIAutumn18MiniAOD-102X_upgrade2018_realistic_v15-v2/MINIAODSIM", + "year": 2018, + "unitsPerJob": 3, }, - "QCD_HT200to300_TuneCUETP8M1_13TeV-madgraphMLM-pythia8-2016":{ - "inputDataset":"/QCD_HT200to300_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/RunIISummer16MiniAODv3-PUMoriond17_94X_mcRun2_asymptotic_v3-v2/MINIAODSIM", - "year": 2016 - }, - "QCD_HT200to300_TuneCP5_13TeV-madgraphMLM-pythia8-2017":{ - "inputDataset":"/QCD_HT200to300_TuneCP5_13TeV-madgraph-pythia8/RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1/MINIAODSIM", - "year": 2017 - }, - "QCD_HT200to300_TuneCP5_13TeV-madgraphMLM-pythia8-2018":{ - "inputDataset":"/QCD_HT200to300_TuneCP5_13TeV-madgraphMLM-pythia8/RunIIAutumn18MiniAOD-102X_upgrade2018_realistic_v15-v1/MINIAODSIM", - "year": 2018 + "QCD_Pt_15to30_TuneCUETP8M1_13TeV_pythia8-2016":{ + "inputDataset":"/QCD_Pt_15to30_TuneCUETP8M1_13TeV_pythia8/RunIISummer16MiniAODv3-PUMoriond17_94X_mcRun2_asymptotic_v3-v2/MINIAODSIM", + "year": 2016, + "unitsPerJob": 3, }, - - + "QCD_Pt_30to50_TuneCUETP8M1_13TeV_pythia8-2016":{ + "inputDataset":"/QCD_Pt_30to50_TuneCUETP8M1_13TeV_pythia8/RunIISummer16MiniAODv3-PUMoriond17_94X_mcRun2_asymptotic_v3-v2/MINIAODSIM", + "year": 2016, + "unitsPerJob": 3, + }, + "QCD_Pt_50to80_TuneCUETP8M1_13TeV_pythia8-2016":{ + "inputDataset":"/QCD_Pt_50to80_TuneCUETP8M1_13TeV_pythia8/RunIISummer16MiniAODv3-PUMoriond17_94X_mcRun2_asymptotic_v3-v2/MINIAODSIM", + "year": 2016, + "unitsPerJob": 3, + }, + + + + "QCD_Pt_15to30_TuneCP5_13TeV_pythia8-2017":{ + "inputDataset":"/QCD_Pt_15to30_TuneCP5_13TeV_pythia8/RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14_ext1-v2/MINIAODSIM", + "year": 2017, + "unitsPerJob": 3, + }, + "QCD_Pt_30to50_TuneCP5_13TeV_pythia8-2017":{ + "inputDataset":"/QCD_Pt_30to50_TuneCP5_13TeV_pythia8/RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14_ext1-v2/MINIAODSIM", + "year": 2017, + "unitsPerJob": 3, + }, + "QCD_Pt_50to80_TuneCP5_13TeV_pythia8-2017":{ + "inputDataset":"/QCD_Pt_50to80_TuneCP5_13TeV_pythia8/RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14_ext1-v2/MINIAODSIM", + "year": 2017, + "unitsPerJob": 3, + }, + + + + "QCD_Pt_15to30_TuneCP5_13TeV_pythia8-2018":{ + "inputDataset":"/QCD_Pt_15to30_TuneCP5_13TeV_pythia8/RunIIAutumn18MiniAOD-102X_upgrade2018_realistic_v15_ext1-v2/MINIAODSIM", + "year": 2018, + "unitsPerJob": 3, + }, + "QCD_Pt_30to50_TuneCP5_13TeV_pythia8-2018":{ + "inputDataset":"/QCD_Pt_30to50_TuneCP5_13TeV_pythia8/RunIIAutumn18MiniAOD-102X_upgrade2018_realistic_v15-v1/MINIAODSIM", + "year": 2018, + "unitsPerJob": 3, + }, + "QCD_Pt_50to80_TuneCP5_13TeV_pythia8-2018":{ + "inputDataset":"/QCD_Pt_50to80_TuneCP5_13TeV_pythia8/RunIIAutumn18MiniAOD-102X_upgrade2018_realistic_v15_ext1-v2/MINIAODSIM", + "year": 2018, + "unitsPerJob": 3, + }, + + + "LLPGun-2016":{ + "inputDataset":"/LLPGun/mkomm-miniaod16v3_200929-53f8667ba4b240d5eafd36e71bf34742/USER", + "year": 2016, + "unitsPerJob": 15, + }, + "LLPGun-2017":{ + "inputDataset":"/LLPGun/mkomm-miniaod17v2_200929-442a7f6ea2510b243c486adb7160c528/USER", + "year": 2017, + "unitsPerJob": 15, + }, + "LLPGun-2018":{ + "inputDataset":"/LLPGun/mkomm-miniaod18_200929-c21dec93027231dc6f615dfe5c662834/USER", + "year": 2018, + "unitsPerJob": 15, + }, + } @@ -876,16 +937,21 @@ "year": year, "unitsPerJob": 15, "isData": False, - "addLLPInfo": True, "addSignalLHE": True } -myJobs = myJobsTraining myJobs = myJobsHNL +for k,v in myJobs.items(): + if str(v['year'])!='2016': + del myJobs[k] + -requestName = "NANOX_200720" -userName = "vcepaiti" +#myJobs = myJobsHNL + + +requestName = "NANOX_201107" +userName = "mkomm" configTmpl = Configuration() configTmpl.section_('General') @@ -897,12 +963,16 @@ configTmpl.JobType.pluginName = 'Analysis' configTmpl.JobType.outputFiles = ['nano.root'] configTmpl.JobType.allowUndistributedCMSSW = True -configTmpl.JobType.maxJobRuntimeMin= 8*60 +configTmpl.JobType.maxJobRuntimeMin= 12*60 + + configTmpl.JobType.pyCfgParams = [] configTmpl.JobType.inputFiles = [] configTmpl.JobType.maxMemoryMB = 2500 configTmpl.section_('Data') configTmpl.Data.useParent = False +configTmpl.Data.splitting = 'FileBased' +configTmpl.Data.unitsPerJob = 2 configTmpl.section_('Site') configTmpl.Site.storageSite = 'T2_UK_London_IC' @@ -954,7 +1024,6 @@ def submit(config): isData = myJob.get('isData', False) year = str(myJob.get('year', '0')) - addLLPInfo = str(myJob.get('addLLPInfo', False)) addSignalLHE = str(myJob.get('addSignalLHE', False)) if year not in ['2016','2017','2018','2018D']: @@ -963,7 +1032,6 @@ def submit(config): print "year:", year config.JobType.pyCfgParams.append("year="+str(year)) - config.JobType.pyCfgParams.append("addLLPInfo={}".format(addLLPInfo)) config.JobType.pyCfgParams.append("addSignalLHE={}".format(addSignalLHE)) if isData: @@ -982,12 +1050,9 @@ def submit(config): else: config.JobType.pyCfgParams.append("isData=False") - if myJobs == myJobsHNL: - config.Data.splitting = 'FileBased' - config.Data.unitsPerJob = myJob.get('unitsPerJob', 1) - else: - config.Data.splitting = 'Automatic' - config.Data.unitsPerJob = 8*60 + + config.Data.splitting = 'FileBased' + config.Data.unitsPerJob = myJob.get('unitsPerJob', 2) if "params" in myJob: params = myJob["params"] @@ -1020,3 +1085,4 @@ def submit(config): print print + #break diff --git a/NANOProducer/test/getFiles.py b/NANOProducer/test/getFiles.py index d7c2980..2a80d20 100644 --- a/NANOProducer/test/getFiles.py +++ b/NANOProducer/test/getFiles.py @@ -6,7 +6,7 @@ from fcntl import fcntl, F_GETFL, F_SETFL from os import O_NONBLOCK, read -basepath = "srm://gfe02.grid.hep.ph.ic.ac.uk/pnfs/hep.ph.ic.ac.uk/data/cms/store/user/mkomm/LLP/NANOX_200124" +basepath = "srm://gfe02.grid.hep.ph.ic.ac.uk/pnfs/hep.ph.ic.ac.uk/data/cms/store/user/mkomm/HNL/NANOX_201107" def listdir(path): print "query path ... ",path diff --git a/XTagInfoProducer/plugins/XTagInfoProducer.cc b/XTagInfoProducer/plugins/XTagInfoProducer.cc index 1985f2f..9706acd 100644 --- a/XTagInfoProducer/plugins/XTagInfoProducer.cc +++ b/XTagInfoProducer/plugins/XTagInfoProducer.cc @@ -233,7 +233,7 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) features.jet_features.eventShapeD = eventShapes.D(); } - + // Add CSV variables const edm::View& taginfos = *shallow_tag_infos; edm::Ptr match; @@ -362,14 +362,13 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) } - float dZ0 = std::abs(constituent->dz(pv.position())); - float dZmin = dZ0; + float dZmin = 100; for (size_t i = 0; i < vtxs->size(); i++){ - if (i == 0) continue; auto vtx = vtxs->at(i); if (vtx.isFake() || vtx.ndof() < 4) { continue; } + if ((vtx.position()-pv.position()).mag2()<1e-3) continue; //skip PV dZmin = std::min(dZmin, std::abs(constituent->dz(vtx.position()))); } @@ -847,16 +846,22 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) else if (npf.npf_deltaR < 0.4) frac04 ++; } - float nCandidates = (float)features.cpf_features.size()+(float)features.npf_features.size(); + int nCandidates = features.cpf_features.size()+features.npf_features.size(); - if (nCandidates > 0.){ - features.jet_features.frac01 = (float)frac01/nCandidates; - features.jet_features.frac02 = (float)frac02/nCandidates; - features.jet_features.frac03 = (float)frac03/nCandidates; - features.jet_features.frac04 = (float)frac04/nCandidates; + if (nCandidates > 0) { + features.jet_features.frac01 = 1.*frac01/nCandidates; + features.jet_features.frac02 = 1.*frac02/nCandidates; + features.jet_features.frac03 = 1.*frac03/nCandidates; + features.jet_features.frac04 = 1.*frac04/nCandidates; features.jet_features.dR2Mean = dR2Mean/pt2Sum; } + features.jet_features.ncpf = features.cpf_features.size(); + features.jet_features.nnpf = features.npf_features.size(); + features.jet_features.nsv = features.sv_features.size(); + features.jet_features.nmuon = features.mu_features.size(); + features.jet_features.nelectron = features.elec_features.size(); + output_tag_infos->emplace_back(features, jet_ref); } From f70a981452a92a50802a389d01ac389cbff363ce Mon Sep 17 00:00:00 2001 From: matt-komm Date: Fri, 13 Nov 2020 22:58:13 +0000 Subject: [PATCH 07/20] add helper class to fill tables --- .../interface/ChargedCandidateFeatures.h | 149 +++++-- DataFormats/interface/JetFeatures.h | 21 +- DataFormats/interface/LLPLabel.h | 7 +- .../interface/ShallowTagInfoFeatures.h | 20 +- LLPLabelProducer/plugins/LLPLabelProducer.cc | 4 + NANOProducer/plugins/FlatTableFiller.h | 156 ++++++++ NANOProducer/plugins/NANOGenProducer.cc | 9 + NANOProducer/plugins/NANOProducer.cc | 372 +++++++----------- XTagInfoProducer/plugins/XTagInfoProducer.cc | 153 ++++--- XTagProducer/src/tensor_fillers.cc | 54 +-- 10 files changed, 531 insertions(+), 414 deletions(-) create mode 100644 NANOProducer/plugins/FlatTableFiller.h diff --git a/DataFormats/interface/ChargedCandidateFeatures.h b/DataFormats/interface/ChargedCandidateFeatures.h index 14fc307..47b8da8 100644 --- a/DataFormats/interface/ChargedCandidateFeatures.h +++ b/DataFormats/interface/ChargedCandidateFeatures.h @@ -1,51 +1,122 @@ #ifndef LLPReco_DataFormats_ChargedCandidateFeatures_h #define LLPReco_DataFormats_ChargedCandidateFeatures_h +#include + namespace llpdnnx { struct ChargedCandidateFeatures { - int cpf_jetIdx; - float cpf_ptrel; - float cpf_deta; - float cpf_dphi; - float cpf_deltaR; + int jetIdx; + float ptrel; + float deta; + float dphi; + float deltaR; + + float px; + float py; + float pz; + + float trackEtaRel; + float trackPtRel; + float trackPPar; + float trackDeltaR; + float trackPParRatio; + float trackPtRatio; + float trackSip2dVal; + float trackSip2dSig; + float trackSip3dVal; + float trackSip3dSig; + float trackJetDistVal; + float trackJetDistSig; + float drminsv; + int vertex_association; + float fromPV; + float puppi_weight; + float track_chi2; + float track_quality; + int track_numberOfValidPixelHits; + int track_pixelLayersWithMeasurement; + int track_numberOfValidStripHits; + int track_stripLayersWithMeasurement; + float relmassdrop; + + int matchedMuon; + int matchedElectron; + int matchedSV; + int track_ndof; + + float dZmin; + + ChargedCandidateFeatures(): + jetIdx(-1), + ptrel(-1), + deta(1), + dphi(1), + deltaR(1), + + px(0), + py(0), + pz(0), + + trackEtaRel(0), + trackPtRel(0), + trackPPar(0), + trackDeltaR(0), + trackPParRatio(0), + trackPtRatio(0), + trackSip2dVal(0), + trackSip2dSig(0), + trackSip3dVal(0), + trackSip3dSig(0), + trackJetDistVal(0), + trackJetDistSig(0), + drminsv(0), + vertex_association(0), + fromPV(0), + puppi_weight(0), + track_chi2(0), + track_quality(0), + track_numberOfValidPixelHits(0), + track_pixelLayersWithMeasurement(0), + track_numberOfValidStripHits(0), + track_stripLayersWithMeasurement(0), + relmassdrop(0), + + matchedMuon(0), + matchedElectron(0), + matchedSV(0), + track_ndof(0), + + dZmin(100) + {} - float cpf_px; - float cpf_py; - float cpf_pz; - - float cpf_trackEtaRel; - float cpf_trackPtRel; - float cpf_trackPPar; - float cpf_trackDeltaR; - float cpf_trackPParRatio; - float cpf_trackPtRatio; - float cpf_trackSip2dVal; - float cpf_trackSip2dSig; - float cpf_trackSip3dVal; - float cpf_trackSip3dSig; - float cpf_trackJetDistVal; - float cpf_trackJetDistSig; - float cpf_drminsv; - int cpf_vertex_association; - float cpf_fromPV; - float cpf_puppi_weight; - float cpf_track_chi2; - float cpf_track_quality; - int cpf_track_numberOfValidPixelHits; - int cpf_track_pixelLayersWithMeasurement; - int cpf_track_numberOfValidStripHits; - int cpf_track_stripLayersWithMeasurement; - float cpf_relmassdrop; - - int cpf_matchedMuon; - int cpf_matchedElectron; - int cpf_matchedSV; - int cpf_track_ndof; - - float cpf_dZmin; + bool operator<(const ChargedCandidateFeatures& other) const + { + if (trackSip2dSig>0 and other.trackSip2dSig>0) + { + return std::fabs(trackSip2dSig)>std::fabs(other.trackSip2dSig); //sort decreasing + } + else if (trackSip2dSig<0 and other.trackSip2dSig>0) + { + return false; + } + else if (trackSip2dSig>0 and other.trackSip2dSig<0) + { + return true; + } + else if (std::fabs(drminsv-other.drminsv)>std::numeric_limits::epsilon()) + { + return drminsvother.ptrel; //sort decreasing + } + + return false; + } }; } diff --git a/DataFormats/interface/JetFeatures.h b/DataFormats/interface/JetFeatures.h index 473103e..4e5eb0e 100644 --- a/DataFormats/interface/JetFeatures.h +++ b/DataFormats/interface/JetFeatures.h @@ -5,7 +5,6 @@ namespace llpdnnx { struct JetFeatures { - int jetIdx; float pt; float eta; @@ -49,11 +48,11 @@ struct JetFeatures float eventShapeC; float eventShapeD; - int ncpf; - int nnpf; - int nsv; - int nmuon; - int nelectron; + int numberCpf; + int numberNpf; + int numberSv; + int numberMuon; + int numberElectron; JetFeatures(): jetIdx(-1), @@ -99,11 +98,11 @@ struct JetFeatures eventShapeC(-1), eventShapeD(-1), - ncpf(0), - nnpf(0), - nsv(0), - nmuon(0), - nelectron(0) + numberCpf(0), + numberNpf(0), + numberSv(0), + numberMuon(0), + numberElectron(0) { } diff --git a/DataFormats/interface/LLPLabel.h b/DataFormats/interface/LLPLabel.h index 3da4182..a394303 100644 --- a/DataFormats/interface/LLPLabel.h +++ b/DataFormats/interface/LLPLabel.h @@ -91,6 +91,9 @@ class LLPLabel { float matchedGenJetPt; float sharedVertexFraction; + float genTauMass; + float recoTauMass; + LLPLabel(): type(Type::isUndefined), tauDecay(TauDecay::NO_TAU), @@ -106,7 +109,9 @@ class LLPLabel { betagamma(0), matchedGenJetDeltaR(-1), matchedGenJetPt(-1), - sharedVertexFraction(0) + sharedVertexFraction(0), + genTauMass(-1), + recoTauMass(-1) { } diff --git a/DataFormats/interface/ShallowTagInfoFeatures.h b/DataFormats/interface/ShallowTagInfoFeatures.h index f52176f..e37813b 100644 --- a/DataFormats/interface/ShallowTagInfoFeatures.h +++ b/DataFormats/interface/ShallowTagInfoFeatures.h @@ -6,17 +6,17 @@ namespace llpdnnx { struct ShallowTagInfoFeatures { // jet general - int csv_jetIdx; - float csv_trackSumJetEtRatio; // ratio of track sum transverse energy over jet energy - float csv_trackSumJetDeltaR; // pseudoangular distance between jet axis and track fourvector sum - int csv_vertexCategory; // category of secondary vertex (Reco, Pseudo, No) - float csv_trackSip2dValAboveCharm; // track 2D signed impact parameter of first track lifting mass above charm - float csv_trackSip2dSigAboveCharm; // track 2D signed impact parameter significance of first track lifting mass above charm - float csv_trackSip3dValAboveCharm; // track 3D signed impact parameter of first track lifting mass above charm - float csv_trackSip3dSigAboveCharm; // track 3D signed impact parameter significance of first track lifting mass above charm + int jetIdx; + float trackSumJetEtRatio; // ratio of track sum transverse energy over jet energy + float trackSumJetDeltaR; // pseudoangular distance between jet axis and track fourvector sum + int vertexCategory; // category of secondary vertex (Reco, Pseudo, No) + float trackSip2dValAboveCharm; // track 2D signed impact parameter of first track lifting mass above charm + float trackSip2dSigAboveCharm; // track 2D signed impact parameter significance of first track lifting mass above charm + float trackSip3dValAboveCharm; // track 3D signed impact parameter of first track lifting mass above charm + float trackSip3dSigAboveCharm; // track 3D signed impact parameter significance of first track lifting mass above charm // track info - int csv_jetNTracksEtaRel; // tracks associated to jet for which trackEtaRel is calculated - int csv_jetNSelectedTracks; + int jetNTracksEtaRel; // tracks associated to jet for which trackEtaRel is calculated + int jetNSelectedTracks; }; diff --git a/LLPLabelProducer/plugins/LLPLabelProducer.cc b/LLPLabelProducer/plugins/LLPLabelProducer.cc index 8c603fd..39a1228 100644 --- a/LLPLabelProducer/plugins/LLPLabelProducer.cc +++ b/LLPLabelProducer/plugins/LLPLabelProducer.cc @@ -340,20 +340,24 @@ LLPLabelProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for (const auto tau: taus) { + reco::Candidate::LorentzVector tauGenSum(0,0,0,0); reco::Candidate::LorentzVector tauRecoSum(0,0,0,0); std::vector decayProducts; gatherVisibleDecayProducts(decayProducts, tau.get()); for (const auto decayProduct: decayProducts) { + tauGenSum += decayProduct->p4(); auto match = findRecoConstituent(decayProduct,jetConstituents); if (match) tauRecoSum+=match->p4(); } if (calcFraction(tauRecoSum,tau->p4())>0.5) //at least 50% of momentum reconstructed { + label.genTauMass = tauGenSum.mass(); if (calcFraction(promptRecoMax,jet.p4()) +class FlatTableFiller +{ + public: + virtual void push_back(const CLASS& obj) = 0; + virtual void fill(std::unique_ptr& flatTable) const = 0; + + virtual ~FlatTableFiller() + { + } +}; + +template +class Property +{ + public: + virtual const std::string& name() const = 0; + virtual const std::string& doc() const = 0; + virtual std::shared_ptr> createFiller() const = 0; + + virtual ~Property() + { + } +}; + + + +template +class PropertyTmpl: + public Property +{ + private: + TYPE CLASS::*memberPtr_; + std::string name_; + std::string doc_; + public: + PropertyTmpl(TYPE CLASS::*memberPtr, const std::string& name, const std::string& doc="doc"): + memberPtr_(memberPtr), + name_(name), + doc_(doc) + { + } + + virtual ~PropertyTmpl() + { + } + + TYPE get(const CLASS& obj) const + { + return obj.*memberPtr_; + } + + virtual const std::string& name() const + { + return name_; + } + + virtual const std::string& doc() const + { + return doc_; + } + + virtual std::shared_ptr> createFiller() const; +}; + + +template +void fillTable(const std::vector& data, std::unique_ptr& flatTable, const std::string& name, const std::string& doc) +{ + throw std::runtime_error(std::string("Filler not implemented for type '")+(typeid(TYPE)).name()+"'"); +} + +template<> +void fillTable(const std::vector& data, std::unique_ptr& flatTable, const std::string& name, const std::string& doc) +{ + flatTable->addColumn(name, data, doc, nanoaod::FlatTable::IntColumn); +} + +template<> +void fillTable(const std::vector& data, std::unique_ptr& flatTable, const std::string& name, const std::string& doc) +{ + flatTable->addColumn(name, data, doc, nanoaod::FlatTable::FloatColumn); +} + +template +class FlatTableFillerTmpl: + public FlatTableFiller +{ + private: + PropertyTmpl property_; + std::vector data_; + public: + FlatTableFillerTmpl(const PropertyTmpl& property): + property_(property) + { + } + + virtual void push_back(const CLASS& obj) + { + data_.push_back(property_.get(obj)); + } + + virtual void fill(std::unique_ptr& flatTable) const + { + fillTable(data_,flatTable,property_.name(),property_.doc()); + } + + virtual ~FlatTableFillerTmpl() + { + } +}; + + + +template std::shared_ptr> PropertyTmpl::createFiller() const +{ + return std::shared_ptr>(new FlatTableFillerTmpl(*this)); +} + + +template using PropertyList = std::vector>>; + +template +class FlatTableFillerList +{ + protected: + std::vector>> fillers_; + + public: + FlatTableFillerList(const PropertyList& propertyList) + { + for (const auto& property: propertyList) fillers_.push_back(property->createFiller()); + } + + void push_back(const CLASS& obj) + { + for (const auto& filler: fillers_) filler->push_back(obj); + } + + void fill(std::unique_ptr& flatTable) const + { + for (const auto& filler: fillers_) filler->fill(flatTable); + } +}; + +#define PROPERTY(class, name, doc) \ + std::shared_ptr>(new PropertyTmpl< class , decltype( class :: name )>(& class :: name , #name , doc)) + + + +#endif diff --git a/NANOProducer/plugins/NANOGenProducer.cc b/NANOProducer/plugins/NANOGenProducer.cc index d2ca942..c3a9604 100644 --- a/NANOProducer/plugins/NANOGenProducer.cc +++ b/NANOProducer/plugins/NANOGenProducer.cc @@ -143,6 +143,9 @@ NANOGenProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector matchedGenJetDeltaR; std::vector matchedGenJetPt; std::vector sharedVertexFraction; + + std::vector genTauMass; + std::vector recoTauMass; for (std::size_t itag = 0; itag < ntruth; itag++) { const auto& labels = label_infos->at(itag).features(); @@ -228,6 +231,9 @@ NANOGenProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) matchedGenJetDeltaR.push_back(labels.matchedGenJetDeltaR); matchedGenJetPt.push_back(labels.matchedGenJetPt); sharedVertexFraction.push_back(labels.sharedVertexFraction); + + genTauMass.push_back(labels.genTauMass); + recoTauMass.push_back(labels.recoTauMass); } @@ -299,6 +305,9 @@ NANOGenProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) jetOriginTable->addColumn("matchedGenJetDeltaR", matchedGenJetDeltaR, "doc", nanoaod::FlatTable::FloatColumn); jetOriginTable->addColumn("matchedGenJetPt", matchedGenJetPt, "doc", nanoaod::FlatTable::FloatColumn); jetOriginTable->addColumn("sharedVertexFraction", sharedVertexFraction, "doc", nanoaod::FlatTable::FloatColumn); + + jetOriginTable->addColumn("genTauMass", genTauMass, "doc", nanoaod::FlatTable::FloatColumn); + jetOriginTable->addColumn("recoTauMass", recoTauMass, "doc", nanoaod::FlatTable::FloatColumn); iEvent.put(std::move(jetOriginTable), "jetorigin"); } diff --git a/NANOProducer/plugins/NANOProducer.cc b/NANOProducer/plugins/NANOProducer.cc index 6f567dc..6fbfaee 100644 --- a/NANOProducer/plugins/NANOProducer.cc +++ b/NANOProducer/plugins/NANOProducer.cc @@ -18,18 +18,22 @@ #include "DataFormats/NanoAOD/interface/FlatTable.h" #include - +#include "FlatTableFiller.h" // // class declaration // class NANOProducer : public edm::stream::EDProducer<> { - public: - explicit NANOProducer(const edm::ParameterSet&); - ~NANOProducer(); + public: + explicit NANOProducer(const edm::ParameterSet&); + ~NANOProducer(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + PropertyList globalProperties; + PropertyList csvProperties; + PropertyList cpfProperties; private: const edm::EDGetTokenT> _jet_src; @@ -43,6 +47,112 @@ NANOProducer::NANOProducer(const edm::ParameterSet& iConfig) : _jet_src(consumes>(iConfig.getParameter("srcJets"))), _tag_src(consumes>(iConfig.getParameter("srcTags"))) { + globalProperties = { + PROPERTY(llpdnnx::JetFeatures, pt, "doc"), + PROPERTY(llpdnnx::JetFeatures, eta, "doc"), + PROPERTY(llpdnnx::JetFeatures, phi, "doc"), + PROPERTY(llpdnnx::JetFeatures, mass, "doc"), + PROPERTY(llpdnnx::JetFeatures, energy, "doc"), + + PROPERTY(llpdnnx::JetFeatures, area, "doc"), + + PROPERTY(llpdnnx::JetFeatures, beta, "doc"), + PROPERTY(llpdnnx::JetFeatures, dR2Mean, "doc"), + PROPERTY(llpdnnx::JetFeatures, frac01, "doc"), + PROPERTY(llpdnnx::JetFeatures, frac02, "doc"), + PROPERTY(llpdnnx::JetFeatures, frac03, "doc"), + PROPERTY(llpdnnx::JetFeatures, frac04, "doc"), + + PROPERTY(llpdnnx::JetFeatures, jetR, "doc"), + PROPERTY(llpdnnx::JetFeatures, jetRchg, "doc"), + + PROPERTY(llpdnnx::JetFeatures, n60, "doc"), + PROPERTY(llpdnnx::JetFeatures, n90, "doc"), + + PROPERTY(llpdnnx::JetFeatures, chargedEmEnergyFraction, "doc"), + PROPERTY(llpdnnx::JetFeatures, chargedHadronEnergyFraction, "doc"), + PROPERTY(llpdnnx::JetFeatures, chargedMuEnergyFraction, "doc"), + PROPERTY(llpdnnx::JetFeatures, electronEnergyFraction, "doc"), + + PROPERTY(llpdnnx::JetFeatures, tau1, "doc"), + PROPERTY(llpdnnx::JetFeatures, tau2, "doc"), + PROPERTY(llpdnnx::JetFeatures, tau3, "doc"), + + PROPERTY(llpdnnx::JetFeatures, relMassDropMassAK, "doc"), + PROPERTY(llpdnnx::JetFeatures, relMassDropMassCA, "doc"), + PROPERTY(llpdnnx::JetFeatures, relSoftDropMassAK, "doc"), + PROPERTY(llpdnnx::JetFeatures, relSoftDropMassCA, "doc"), + + PROPERTY(llpdnnx::JetFeatures, thrust, "doc"), + PROPERTY(llpdnnx::JetFeatures, sphericity, "doc"), + PROPERTY(llpdnnx::JetFeatures, circularity, "doc"), + PROPERTY(llpdnnx::JetFeatures, isotropy, "doc"), + PROPERTY(llpdnnx::JetFeatures, eventShapeC, "doc"), + PROPERTY(llpdnnx::JetFeatures, eventShapeD, "doc"), + + PROPERTY(llpdnnx::JetFeatures, numberCpf, "doc"), + PROPERTY(llpdnnx::JetFeatures, numberNpf, "doc"), + PROPERTY(llpdnnx::JetFeatures, numberSv, "doc"), + PROPERTY(llpdnnx::JetFeatures, numberMuon, "doc"), + PROPERTY(llpdnnx::JetFeatures, numberElectron, "doc") + + }; + + csvProperties = { + PROPERTY(llpdnnx::ShallowTagInfoFeatures, trackSumJetEtRatio, "ratio of track sum transverse energy over jet energy"), + PROPERTY(llpdnnx::ShallowTagInfoFeatures, trackSumJetDeltaR, "pseudoangular distance between jet axis and track fourvector sum"), + PROPERTY(llpdnnx::ShallowTagInfoFeatures, vertexCategory, "category of secondary vertex (Reco, Pseudo, No)"), + PROPERTY(llpdnnx::ShallowTagInfoFeatures, trackSip2dValAboveCharm, "track 2D signed impact parameter of first track lifting mass above charm"), + PROPERTY(llpdnnx::ShallowTagInfoFeatures, trackSip2dSigAboveCharm, "track 2D signed impact parameter significance of first track lifting mass above charm"), + PROPERTY(llpdnnx::ShallowTagInfoFeatures, trackSip3dValAboveCharm, "track 3D signed impact parameter of first track lifting mass above charm"), + PROPERTY(llpdnnx::ShallowTagInfoFeatures, trackSip3dSigAboveCharm, "track 3D signed impact parameter significance of first track lifting mass above charm"), + PROPERTY(llpdnnx::ShallowTagInfoFeatures, jetNTracksEtaRel, "tracks associated to jet for which trackEtaRel is calculated"), + PROPERTY(llpdnnx::ShallowTagInfoFeatures, jetNSelectedTracks, "doc") + }; + + cpfProperties = { + PROPERTY(llpdnnx::ChargedCandidateFeatures, ptrel, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, deta, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, dphi, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, deltaR, "doc"), + + PROPERTY(llpdnnx::ChargedCandidateFeatures, px, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, py, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, pz, "doc"), + + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackEtaRel, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackPtRel, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackPPar, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackDeltaR, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackPParRatio, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackPtRatio, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip2dVal, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip2dSig, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip3dVal, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip3dSig, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackJetDistVal, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackJetDistSig, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, drminsv, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, vertex_association, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, fromPV, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, puppi_weight, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, track_chi2, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, track_quality, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, track_numberOfValidPixelHits, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, track_pixelLayersWithMeasurement, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, track_numberOfValidStripHits, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, track_stripLayersWithMeasurement, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, relmassdrop, "doc"), + + PROPERTY(llpdnnx::ChargedCandidateFeatures, matchedMuon, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, matchedElectron, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, matchedSV, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, track_ndof, "doc"), + + PROPERTY(llpdnnx::ChargedCandidateFeatures, dZmin, "doc") + }; + + produces("global"); produces("csv"); produces("cpf"); @@ -73,6 +183,7 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) unsigned int ntags = tag_infos->size(); std::vector global_jetIdx; + std::vector csv_jetIdx; std::vector cpf_jetIdx; std::vector npf_jetIdx; std::vector sv_jetIdx; @@ -88,64 +199,8 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector mu_length; auto globalTable = std::make_unique(ntags, "global", false, false); - std::vector pt; - std::vector eta; - std::vector phi; - std::vector mass; - - std::vector area; - - std::vector n60; - std::vector n90; - - std::vector beta; - std::vector dR2Mean; - std::vector frac01; - std::vector frac02; - std::vector frac03; - std::vector frac04; - - std::vector jetR; - std::vector jetRchg; - - std::vector chargedEmEnergyFraction; - std::vector chargedHadronEnergyFraction; - std::vector chargedMuEnergyFraction; - std::vector electronEnergyFraction; - - std::vector tau1; - std::vector tau2; - std::vector tau3; - - std::vector relMassDropMassAK; - std::vector relMassDropMassCA; - std::vector relSoftDropMassAK; - std::vector relSoftDropMassCA; - - std::vector thrust; - std::vector sphericity; - std::vector circularity; - std::vector isotropy; - std::vector eventShapeC; - std::vector eventShapeD; - - auto csvTable = std::make_unique(ntags, "csv", false, false); - std::vector trackSumJetEtRatio; - std::vector trackSumJetDeltaR; - std::vector vertexCategory; - std::vector trackSip2dValAboveCharm; - std::vector trackSip2dSigAboveCharm; - std::vector trackSip3dValAboveCharm; - std::vector trackSip3dSigAboveCharm; - std::vector jetNSelectedTracks; - std::vector jetNTracksEtaRel; - std::vector ncpf_list; - std::vector nnpf_list; - std::vector nsv_list; - std::vector nmuon_list; - std::vector nelectron_list; std::vector cpf_trackEtaRel; std::vector cpf_trackPtRel; @@ -361,6 +416,11 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector elec_dr04HcalDepth2TowerSumEtBc; std::vector elec_dr04HcalTowerSumEt; std::vector elec_dr04HcalTowerSumEtBc; + + FlatTableFillerList globalFillerList(globalProperties); + FlatTableFillerList csvFillerList(csvProperties); + + FlatTableFillerList cpfFillerList(cpfProperties); unsigned int nmu_total = 0; unsigned int nelec_total = 0; @@ -370,7 +430,6 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for (unsigned int itag= 0; itag < ntags; itag++){ const auto& features = tag_infos->at(itag).features(); - const auto& tag_info_features = features.tag_info_features; unsigned int nmu = features.mu_features.size(); unsigned int nelec = features.elec_features.size(); @@ -400,65 +459,13 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) } } } - + global_jetIdx.push_back(jetIdx); - pt.push_back(features.jet_features.pt); - eta.push_back(features.jet_features.eta); - phi.push_back(features.jet_features.phi); - mass.push_back(features.jet_features.mass); - - area.push_back(features.jet_features.area); - - n60.push_back(features.jet_features.n60); - n90.push_back(features.jet_features.n90); - - beta.push_back(features.jet_features.beta); - dR2Mean.push_back(features.jet_features.dR2Mean); - frac01.push_back(features.jet_features.frac01); - frac02.push_back(features.jet_features.frac02); - frac03.push_back(features.jet_features.frac03); - frac04.push_back(features.jet_features.frac04); - - jetR.push_back(features.jet_features.jetR); - jetRchg.push_back(features.jet_features.jetRchg); - - chargedEmEnergyFraction.push_back(features.jet_features.chargedEmEnergyFraction); - chargedHadronEnergyFraction.push_back(features.jet_features.chargedHadronEnergyFraction); - chargedMuEnergyFraction.push_back(features.jet_features.chargedMuEnergyFraction); - electronEnergyFraction.push_back(features.jet_features.electronEnergyFraction); - - tau1.push_back(features.jet_features.tau1); - tau2.push_back(features.jet_features.tau2); - tau3.push_back(features.jet_features.tau3); - - relMassDropMassAK.push_back(features.jet_features.relMassDropMassAK); - relMassDropMassCA.push_back(features.jet_features.relMassDropMassCA); - relSoftDropMassAK.push_back(features.jet_features.relSoftDropMassAK); - relSoftDropMassCA.push_back(features.jet_features.relSoftDropMassCA); - - thrust.push_back(features.jet_features.thrust); - sphericity.push_back(features.jet_features.sphericity); - circularity.push_back(features.jet_features.circularity); - isotropy.push_back(features.jet_features.isotropy); - eventShapeC.push_back(features.jet_features.eventShapeC); - eventShapeD.push_back(features.jet_features.eventShapeD); - - trackSumJetEtRatio.push_back(tag_info_features.csv_trackSumJetEtRatio); - trackSumJetDeltaR.push_back(tag_info_features.csv_trackSumJetDeltaR); - trackSip2dValAboveCharm.push_back(tag_info_features.csv_trackSip2dValAboveCharm); - trackSip2dSigAboveCharm.push_back(tag_info_features.csv_trackSip2dSigAboveCharm); - trackSip3dValAboveCharm.push_back(tag_info_features.csv_trackSip3dValAboveCharm); - trackSip3dSigAboveCharm.push_back(tag_info_features.csv_trackSip3dSigAboveCharm); - jetNSelectedTracks.push_back(tag_info_features.csv_jetNSelectedTracks); - jetNTracksEtaRel.push_back(tag_info_features.csv_jetNTracksEtaRel); - vertexCategory.push_back(tag_info_features.csv_vertexCategory); + csv_jetIdx.push_back(jetIdx); - ncpf_list.push_back(features.jet_features.ncpf); - nnpf_list.push_back(features.jet_features.nnpf); - nsv_list.push_back(features.jet_features.nsv); - nmuon_list.push_back(features.jet_features.nmuon); - nelectron_list.push_back(features.jet_features.nelectron); - + globalFillerList.push_back(features.jet_features); + csvFillerList.push_back(features.tag_info_features); + } auto muonTable = std::make_unique(nmu_total, "muon", false, false); @@ -486,43 +493,8 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for (unsigned int i = 0; i < ncpf; i++) { - const auto& cpf_features = cpf.at(i); cpf_jetIdx.push_back(jetIdx); - cpf_trackEtaRel.push_back(cpf_features.cpf_trackEtaRel); - cpf_trackPtRel.push_back(cpf_features.cpf_trackPtRel); - cpf_trackPPar.push_back(cpf_features.cpf_trackPPar); - cpf_trackDeltaR.push_back(cpf_features.cpf_trackDeltaR); - cpf_trackPParRatio.push_back(cpf_features.cpf_trackPParRatio); - cpf_trackPtRatio.push_back(cpf_features.cpf_trackPtRatio); - cpf_trackSip2dVal.push_back(cpf_features.cpf_trackSip2dVal); - cpf_trackSip2dSig.push_back(cpf_features.cpf_trackSip2dSig); - cpf_trackSip3dVal.push_back(cpf_features.cpf_trackSip3dVal); - cpf_trackSip3dSig.push_back(cpf_features.cpf_trackSip3dSig); - cpf_trackJetDistVal.push_back(cpf_features.cpf_trackJetDistVal); - cpf_trackJetDistSig.push_back(cpf_features.cpf_trackJetDistSig); - cpf_ptrel.push_back(cpf_features.cpf_ptrel); - cpf_deta.push_back(cpf_features.cpf_deta); - cpf_dphi.push_back(cpf_features.cpf_dphi); - cpf_deltaR.push_back(cpf_features.cpf_deltaR); - cpf_px.push_back(cpf_features.cpf_px); - cpf_py.push_back(cpf_features.cpf_py); - cpf_pz.push_back(cpf_features.cpf_pz); - cpf_drminsv.push_back(cpf_features.cpf_drminsv); - cpf_vertex_association.push_back(cpf_features.cpf_vertex_association); - cpf_fromPV.push_back(cpf_features.cpf_fromPV); - cpf_puppi_weight.push_back(cpf_features.cpf_puppi_weight); - cpf_track_chi2.push_back(cpf_features.cpf_track_chi2); - cpf_track_quality.push_back(cpf_features.cpf_track_quality); - cpf_relmassdrop.push_back(cpf_features.cpf_relmassdrop); - cpf_track_ndof.push_back(cpf_features.cpf_track_ndof); - cpf_matchedMuon.push_back(cpf_features.cpf_matchedMuon); - cpf_matchedElectron.push_back(cpf_features.cpf_matchedElectron); - cpf_matchedSV.push_back(cpf_features.cpf_matchedSV); - cpf_track_numberOfValidPixelHits.push_back(cpf_features.cpf_track_numberOfValidPixelHits); - cpf_track_pixelLayersWithMeasurement.push_back(cpf_features.cpf_track_pixelLayersWithMeasurement); - cpf_track_numberOfValidStripHits.push_back(cpf_features.cpf_track_numberOfValidStripHits); - cpf_track_stripLayersWithMeasurement.push_back(cpf_features.cpf_track_stripLayersWithMeasurement); - cpf_dZmin.push_back(cpf_features.cpf_dZmin); + cpfFillerList.push_back(cpf.at(i)); } for (unsigned int i = 0; i < nnpf; i++) @@ -734,91 +706,13 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) } globalTable->addColumn("jetIdx", global_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); - globalTable->addColumn("pt", pt, "global jet pt (uncorrected)", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("eta", eta, "global jet eta", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("phi", phi, "global jet phi", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("mass", mass, "global jet mass", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("area", area, "global jet area", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("n60", n60, "n60", nanoaod::FlatTable::IntColumn); - globalTable->addColumn("n90", n90, "n90", nanoaod::FlatTable::IntColumn); - globalTable->addColumn("chargedEmEnergyFraction", chargedEmEnergyFraction, "chargedEmEnergyFraction", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("chargedHadronEnergyFraction", chargedHadronEnergyFraction, "chargedHadronEnergyFraction", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("chargedMuEnergyFraction", chargedMuEnergyFraction, "chargedMuEnergyFraction", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("electronEnergyFraction", electronEnergyFraction, "electronEnergyFraction", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("tau1", tau1, "nsubjettiness 1", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("tau2", tau2, "nsubjettiness 2", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("tau3", tau3, "nsubjettiness 3", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("relMassDropMassAK", relMassDropMassAK, "mass drop mass with anti-kT", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("relMassDropMassCA", relMassDropMassCA, "mass drop mass with Cambridge/Aachen", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("relSoftDropMassAK", relSoftDropMassAK, "soft drop mass with anti-kT", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("relSoftDropMassCA", relSoftDropMassCA, "soft drop mass with Cambridge/Aachen", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("thrust", thrust, "thrust", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("sphericity", sphericity, "sphericity", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("circularity", circularity, "circularity", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("isotropy", isotropy, "isotropy", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("eventShapeC", eventShapeC, "eventShapeC", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("eventShapeD", eventShapeD, "eventShapeD", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("beta", beta, "fraction of tracks associated to the PV", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("dR2Mean", dR2Mean, "pt2 weighted average square distance of jet constituents from the jet axis", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("frac01", frac01, "fraction of constituents in the region dR < 0.1 around the jet axis", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("frac02", frac02, "fraction of constituents in the region 0.1 < dR < 0.2 around the jet axis", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("frac03", frac03, "fraction of constituents in the region 0.2 < dR < 0.3 around the jet axis", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("frac04", frac04, "fraction of constituents in the region 0.3 < dR < 0.4 around the jet axis", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("jetR", jetR, "fraction of jet pt carried by lead constituent", nanoaod::FlatTable::FloatColumn); - globalTable->addColumn("jetRchg", jetRchg, "fraction of jet pt carried by lead jet constituent", nanoaod::FlatTable::FloatColumn); - - globalTable->addColumn("ncpf", ncpf_list, "doc", nanoaod::FlatTable::IntColumn); - globalTable->addColumn("nnpf", nnpf_list, "doc", nanoaod::FlatTable::IntColumn); - globalTable->addColumn("nsv", nsv_list, "doc", nanoaod::FlatTable::IntColumn); - globalTable->addColumn("nmuon", nmuon_list, "doc", nanoaod::FlatTable::IntColumn); - globalTable->addColumn("nelectron", nelectron_list, "doc", nanoaod::FlatTable::IntColumn); - - csvTable->addColumn("trackSumJetEtRatio", trackSumJetEtRatio, "ratio of track sum transverse energy over jet energy", nanoaod::FlatTable::FloatColumn); - csvTable->addColumn("trackSumJetDeltaR", trackSumJetDeltaR, "pseudoangular distance between jet axis and track fourvector sum", nanoaod::FlatTable::FloatColumn); - csvTable->addColumn("vertexCategory", vertexCategory, "category of secondary vertex (Reco, Pseudo, No)", nanoaod::FlatTable::FloatColumn); - csvTable->addColumn("trackSip2dValAboveCharm", trackSip2dValAboveCharm, "track 2D signed impact parameter of first track lifting mass above charm", nanoaod::FlatTable::FloatColumn); - csvTable->addColumn("trackSip2dSigAboveCharm", trackSip2dSigAboveCharm, "track 2D signed impact parameter significance of first track lifting mass above charm", nanoaod::FlatTable::FloatColumn); - csvTable->addColumn("trackSip3dValAboveCharm", trackSip3dValAboveCharm, "track 3D signed impact parameter of first track lifting mass above charm", nanoaod::FlatTable::FloatColumn); - csvTable->addColumn("trackSip3dSigAboveCharm", trackSip3dSigAboveCharm, "track 3D signed impact parameter significance of first track lifting mass above charm", nanoaod::FlatTable::FloatColumn); - csvTable->addColumn("jetNSelectedTracks", jetNSelectedTracks, "tracks associated to jet", nanoaod::FlatTable::IntColumn); - csvTable->addColumn("jetNTracksEtaRel", jetNTracksEtaRel, "number of tracks for which etaRel is computed", nanoaod::FlatTable::IntColumn); - + globalFillerList.fill(globalTable); + + csvTable->addColumn("jetIdx", csv_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); + csvFillerList.fill(csvTable); + cpfTable->addColumn("jetIdx", cpf_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); - cpfTable->addColumn("trackEtaRel", cpf_trackEtaRel, "track pseudorapidity, relative to the jet axis", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackPtRel", cpf_trackPtRel, "track transverse momentum, relative to the jet axis", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackPPar", cpf_trackPPar, "track parallel momentum, along the jet axis", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackDeltaR", cpf_trackDeltaR, "charged PF candidate track pseudoangular distance (Delta R) from the jet axis", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackPParRatio", cpf_trackPParRatio, "track parallel momentum, along the jet axis, normalized to its energy", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackPtRatio", cpf_trackPtRatio, "track transverse momentum, relative to the jet axis, normalized to its energy", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackSip2dVal", cpf_trackSip2dVal, "track 2D signed impact parameter", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackSip2dSig", cpf_trackSip2dSig, "track 2D signed impact parameter significance", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackSip3dVal", cpf_trackSip3dVal, "track 3D signed impact parameter", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackSip3dSig", cpf_trackSip3dSig, "track 3D signed impact parameter significance", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackJetDistVal", cpf_trackJetDistVal, "minimum track approach distance to jet axis", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("trackJetDistSig", cpf_trackJetDistSig, "minimum track approach distance to jet axis significance", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("ptrel", cpf_ptrel, "Charged PF candidate track transverse momentum over jet transverse momentum (uncorrelated)", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("drminsv", cpf_drminsv, "pseudoangular distance (Delta R) between the charged PF candidate track and closest secondary vertex (SV) within the jet", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("vertex_association", cpf_vertex_association, "Indicates whether the charged PF candidate track is used in the primary vertex fit", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("fromPV", cpf_fromPV, "Indicates whether the charged PF candidate track is associated to the primary vertex (PV)", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("puppi_weight", cpf_puppi_weight, "weight assigned by the PUPPI algorithm to neutral PF candidate track", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("track_chi2", cpf_track_chi2, "chi^2 of a charged PF candidate track", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("track_quality", cpf_track_quality, "Indicates charged particle track reconstruction quality", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("track_ndof", cpf_track_ndof, "Track fit number of degrees of freedom of charged PF candidate track", nanoaod::FlatTable::IntColumn); - cpfTable->addColumn("matchedMuon", cpf_matchedMuon, "flag to specify whether the track is matched to a PF muon", nanoaod::FlatTable::IntColumn); - cpfTable->addColumn("matchedElectron", cpf_matchedElectron, "flag to specify whether the track is matched to a PF electron", nanoaod::FlatTable::IntColumn); - cpfTable->addColumn("matchedSV", cpf_matchedSV, "flag to specify whether the track is matched to a PF secondary vertex", nanoaod::FlatTable::IntColumn); - cpfTable->addColumn("numberOfValidPixelHits", cpf_track_numberOfValidPixelHits , "number of valid pixel hits " , nanoaod::FlatTable::IntColumn); - cpfTable->addColumn("pixelLayersWithMeasurement", cpf_track_pixelLayersWithMeasurement , "pixel layers with measurment ", nanoaod::FlatTable::IntColumn); - cpfTable->addColumn("numberOfValidStripHits" , cpf_track_numberOfValidStripHits , "nb of valid strip hits " , nanoaod::FlatTable::IntColumn); - cpfTable->addColumn("stripLayersWithMeasurement" , cpf_track_stripLayersWithMeasurement , "nb of strip layers with measurement ", nanoaod::FlatTable::IntColumn); - cpfTable->addColumn("relmassdrop", cpf_relmassdrop, "doc", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("dzMin", cpf_dZmin, "min distance to other PV", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("deta", cpf_deta, "absolute difference between the charged PF candidate eta and jet eta", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("dphi", cpf_dphi, "absolute difference between the charged PF candidate phi and jet phi", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("deltaR", cpf_deltaR, "R between the charged PF candidate and jet", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("px", cpf_px, "px", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("py", cpf_py, "py", nanoaod::FlatTable::FloatColumn); - cpfTable->addColumn("pz", cpf_pz, "pz", nanoaod::FlatTable::FloatColumn); + cpfFillerList.fill(cpfTable); npfTable->addColumn("jetIdx", npf_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); npfTable->addColumn("ptrel", npf_ptrel, "neutral PF candidate transverse momentum over jet transverse momentum (uncorrelated)", nanoaod::FlatTable::FloatColumn); diff --git a/XTagInfoProducer/plugins/XTagInfoProducer.cc b/XTagInfoProducer/plugins/XTagInfoProducer.cc index 9706acd..11f2fb4 100644 --- a/XTagInfoProducer/plugins/XTagInfoProducer.cc +++ b/XTagInfoProducer/plugins/XTagInfoProducer.cc @@ -252,15 +252,15 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) } // will be default values otherwise reco::TaggingVariableList vars = tag_info.taggingVariables(); - features.tag_info_features.csv_trackSumJetEtRatio = vars.get(reco::btau::trackSumJetEtRatio, -1); - features.tag_info_features.csv_trackSumJetDeltaR = vars.get(reco::btau::trackSumJetDeltaR, -1); - features.tag_info_features.csv_vertexCategory = vars.get(reco::btau::vertexCategory, -1); - features.tag_info_features.csv_trackSip2dValAboveCharm = vars.get(reco::btau::trackSip2dValAboveCharm, -1); - features.tag_info_features.csv_trackSip2dSigAboveCharm = vars.get(reco::btau::trackSip2dSigAboveCharm, -1); - features.tag_info_features.csv_trackSip3dValAboveCharm = vars.get(reco::btau::trackSip3dValAboveCharm, -1); - features.tag_info_features.csv_trackSip3dSigAboveCharm = vars.get(reco::btau::trackSip3dSigAboveCharm, -1); - features.tag_info_features.csv_jetNTracksEtaRel = vars.get(reco::btau::jetNTracksEtaRel, -1); - features.tag_info_features.csv_jetNSelectedTracks = vars.get(reco::btau::jetNSelectedTracks, -1); + features.tag_info_features.trackSumJetEtRatio = vars.get(reco::btau::trackSumJetEtRatio, -1); + features.tag_info_features.trackSumJetDeltaR = vars.get(reco::btau::trackSumJetDeltaR, -1); + features.tag_info_features.vertexCategory = vars.get(reco::btau::vertexCategory, -1); + features.tag_info_features.trackSip2dValAboveCharm = vars.get(reco::btau::trackSip2dValAboveCharm, -1); + features.tag_info_features.trackSip2dSigAboveCharm = vars.get(reco::btau::trackSip2dSigAboveCharm, -1); + features.tag_info_features.trackSip3dValAboveCharm = vars.get(reco::btau::trackSip3dValAboveCharm, -1); + features.tag_info_features.trackSip3dSigAboveCharm = vars.get(reco::btau::trackSip3dSigAboveCharm, -1); + features.tag_info_features.jetNTracksEtaRel = vars.get(reco::btau::jetNTracksEtaRel, -1); + features.tag_info_features.jetNSelectedTracks = vars.get(reco::btau::jetNSelectedTracks, -1); std::unordered_set candidatesMatchedToSV; @@ -346,19 +346,19 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) llpdnnx::ChargedCandidateFeatures cpf_features; - cpf_features.cpf_ptrel = constituent->pt()/uncorrectedPt; - cpf_features.cpf_deta = constituent->eta()-jet.eta(); - cpf_features.cpf_dphi = reco::deltaPhi(constituent->phi(),jet.phi()); + cpf_features.ptrel = constituent->pt()/uncorrectedPt; + cpf_features.deta = constituent->eta()-jet.eta(); + cpf_features.dphi = reco::deltaPhi(constituent->phi(),jet.phi()); - cpf_features.cpf_px = constituent->px(); - cpf_features.cpf_py = constituent->py(); - cpf_features.cpf_pz = constituent->pz(); + cpf_features.px = constituent->px(); + cpf_features.py = constituent->py(); + cpf_features.pz = constituent->pz(); - cpf_features.cpf_drminsv = 0.4; + cpf_features.drminsv = 0.4; for (const auto& sv: *svs.product()) { float dR = reco::deltaR(sv,*constituent); - cpf_features.cpf_drminsv = std::min(cpf_features.cpf_drminsv,dR); + cpf_features.drminsv = std::min(cpf_features.drminsv,dR); } @@ -372,26 +372,26 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) dZmin = std::min(dZmin, std::abs(constituent->dz(vtx.position()))); } - cpf_features.cpf_dZmin = dZmin; - cpf_features.cpf_vertex_association = constituent->pvAssociationQuality(); - cpf_features.cpf_fromPV = constituent->fromPV(); - cpf_features.cpf_puppi_weight = constituent->puppiWeight(); - cpf_features.cpf_track_chi2 = constituent->pseudoTrack().chi2(); - cpf_features.cpf_track_ndof = constituent->pseudoTrack().ndof(); - cpf_features.cpf_track_quality = constituent->pseudoTrack().qualityMask(); - cpf_features.cpf_track_numberOfValidPixelHits = constituent->pseudoTrack().hitPattern().numberOfValidPixelHits(); - cpf_features.cpf_track_pixelLayersWithMeasurement = constituent->pseudoTrack().hitPattern().pixelLayersWithMeasurement(); - cpf_features.cpf_track_numberOfValidStripHits = constituent->pseudoTrack().hitPattern().numberOfValidStripHits(); - cpf_features.cpf_track_stripLayersWithMeasurement = constituent->pseudoTrack().hitPattern().stripLayersWithMeasurement(); + cpf_features.dZmin = dZmin; + cpf_features.vertex_association = constituent->pvAssociationQuality(); + cpf_features.fromPV = constituent->fromPV(); + cpf_features.puppi_weight = constituent->puppiWeight(); + cpf_features.track_chi2 = constituent->pseudoTrack().chi2(); + cpf_features.track_ndof = constituent->pseudoTrack().ndof(); + cpf_features.track_quality = constituent->pseudoTrack().qualityMask(); + cpf_features.track_numberOfValidPixelHits = constituent->pseudoTrack().hitPattern().numberOfValidPixelHits(); + cpf_features.track_pixelLayersWithMeasurement = constituent->pseudoTrack().hitPattern().pixelLayersWithMeasurement(); + cpf_features.track_numberOfValidStripHits = constituent->pseudoTrack().hitPattern().numberOfValidStripHits(); + cpf_features.track_stripLayersWithMeasurement = constituent->pseudoTrack().hitPattern().stripLayersWithMeasurement(); if (jet.mass()<1e-10) { - cpf_features.cpf_relmassdrop = -1; + cpf_features.relmassdrop = -1; } else { - cpf_features.cpf_relmassdrop = (jet.p4()-constituent->p4()).mass()/jet.mass(); + cpf_features.relmassdrop = (jet.p4()-constituent->p4()).mass()/jet.mass(); } reco::TransientTrack transientTrack = builder->build(constituent->pseudoTrack()); @@ -406,36 +406,36 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) TVector3 trackMom3(trackMom.x(),trackMom.y(),trackMom.z()); TVector3 jetDir3(jetDir.x(),jetDir.y(),jetDir.z()); - cpf_features.cpf_trackEtaRel=reco::btau::etaRel(jetDir, trackMom); - cpf_features.cpf_trackPtRel=trackMom3.Perp(jetDir3); - cpf_features.cpf_trackPPar=jetDir.Dot(trackMom); - cpf_features.cpf_trackDeltaR=reco::deltaR(trackMom, jetDir); - cpf_features.cpf_trackPtRatio=cpf_features.cpf_trackPtRel / trackMag; - cpf_features.cpf_trackPParRatio=cpf_features.cpf_trackPPar / trackMag; - - cpf_features.cpf_trackSip2dVal=meas_ip2d.value(); - cpf_features.cpf_trackSip2dSig=meas_ip2d.significance(); - cpf_features.cpf_trackSip3dVal=meas_ip3d.value(); - cpf_features.cpf_trackSip3dSig=meas_ip3d.significance(); - if (std::isnan(cpf_features.cpf_trackSip2dSig) || std::isnan(cpf_features.cpf_trackSip3dSig)) + cpf_features.trackEtaRel=reco::btau::etaRel(jetDir, trackMom); + cpf_features.trackPtRel=trackMom3.Perp(jetDir3); + cpf_features.trackPPar=jetDir.Dot(trackMom); + cpf_features.trackDeltaR=reco::deltaR(trackMom, jetDir); + cpf_features.trackPtRatio=cpf_features.trackPtRel / trackMag; + cpf_features.trackPParRatio=cpf_features.trackPPar / trackMag; + + cpf_features.trackSip2dVal=meas_ip2d.value(); + cpf_features.trackSip2dSig=meas_ip2d.significance(); + cpf_features.trackSip3dVal=meas_ip3d.value(); + cpf_features.trackSip3dSig=meas_ip3d.significance(); + if (std::isnan(cpf_features.trackSip2dSig) || std::isnan(cpf_features.trackSip3dSig)) { - cpf_features.cpf_trackSip2dSig=0.; - cpf_features.cpf_trackSip3dSig=0.; + cpf_features.trackSip2dSig=0.; + cpf_features.trackSip3dSig=0.; } - cpf_features.cpf_trackJetDistVal = jetdist.value(); - cpf_features.cpf_trackJetDistSig = jetdist.significance(); + cpf_features.trackJetDistVal = jetdist.value(); + cpf_features.trackJetDistSig = jetdist.significance(); - cpf_features.cpf_matchedMuon = 0; - cpf_features.cpf_matchedElectron = 0; + cpf_features.matchedMuon = 0; + cpf_features.matchedElectron = 0; if (candidatesMatchedToSV.find(jet.daughterPtr(idaughter))!=candidatesMatchedToSV.end()) { - cpf_features.cpf_matchedSV = 1; + cpf_features.matchedSV = 1; } else { - cpf_features.cpf_matchedSV = 0; + cpf_features.matchedSV = 0; } @@ -447,7 +447,7 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) const pat::Muon & muon = *findMuon->second; if (not muon.isGlobalMuon() || reco::deltaR(muon, jet) > 0.4) continue; - cpf_features.cpf_matchedMuon = 1; + cpf_features.matchedMuon = 1; mu_features.mu_isGlobal = muon.isGlobalMuon(); mu_features.mu_isTight = muon.isTightMuon(pv); mu_features.mu_isMedium = muon.isMediumMuon(); @@ -538,7 +538,7 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { llpdnnx::ElectronCandidateFeatures elec_features; const pat::Electron & electron = *findElectron->second; - cpf_features.cpf_matchedElectron = 1; + cpf_features.matchedElectron = 1; if (reco::deltaR(electron, jet) > 0.4) continue; elec_features.elec_ptrel = electron.pt()/uncorrectedPt; @@ -714,28 +714,7 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::stable_sort(features.cpf_features.begin(),features.cpf_features.end(),[](const auto& d1, const auto& d2) { - if (d1.cpf_trackSip2dSig>0 and d2.cpf_trackSip2dSig>0) - { - return std::fabs(d1.cpf_trackSip2dSig)>std::fabs(d2.cpf_trackSip2dSig); //sort decreasing - } - else if (d1.cpf_trackSip2dSig<0 and d2.cpf_trackSip2dSig>0) - { - return false; - } - else if (d1.cpf_trackSip2dSig>0 and d2.cpf_trackSip2dSig<0) - { - return true; - } - else if (std::fabs(d1.cpf_drminsv-d2.cpf_drminsv)>std::numeric_limits::epsilon()) - { - return d1.cpf_drminsvd2.cpf_ptrel; //sort decreasing - } - - return false; + return d1 0){ - jetRchg = features.cpf_features.at(0).cpf_ptrel; + jetRchg = features.cpf_features.at(0).ptrel; } if (features.npf_features.size() > 0){ @@ -819,13 +798,13 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for (size_t i = 0; i < features.cpf_features.size(); i++){ llpdnnx::ChargedCandidateFeatures cpf = features.cpf_features.at(i); - beta += cpf.cpf_fromPV; - dR2Mean += (cpf.cpf_ptrel*cpf.cpf_trackDeltaR) * (cpf.cpf_ptrel*cpf.cpf_trackDeltaR); - pt2Sum += (cpf.cpf_ptrel) * (cpf.cpf_ptrel); - if (cpf.cpf_trackDeltaR < 0.1) frac01 ++; - else if (cpf.cpf_trackDeltaR < 0.2) frac02 ++; - else if (cpf.cpf_trackDeltaR < 0.3) frac03 ++; - else if (cpf.cpf_trackDeltaR < 0.4) frac04 ++; + beta += cpf.fromPV; + dR2Mean += (cpf.ptrel*cpf.trackDeltaR) * (cpf.ptrel*cpf.trackDeltaR); + pt2Sum += (cpf.ptrel) * (cpf.ptrel); + if (cpf.trackDeltaR < 0.1) frac01 ++; + else if (cpf.trackDeltaR < 0.2) frac02 ++; + else if (cpf.trackDeltaR < 0.3) frac03 ++; + else if (cpf.trackDeltaR < 0.4) frac04 ++; } if (features.cpf_features.size() > 0) @@ -856,11 +835,11 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) features.jet_features.dR2Mean = dR2Mean/pt2Sum; } - features.jet_features.ncpf = features.cpf_features.size(); - features.jet_features.nnpf = features.npf_features.size(); - features.jet_features.nsv = features.sv_features.size(); - features.jet_features.nmuon = features.mu_features.size(); - features.jet_features.nelectron = features.elec_features.size(); + features.jet_features.numberCpf = features.cpf_features.size(); + features.jet_features.numberNpf = features.npf_features.size(); + features.jet_features.numberSv = features.sv_features.size(); + features.jet_features.numberMuon = features.mu_features.size(); + features.jet_features.numberElectron = features.elec_features.size(); output_tag_infos->emplace_back(features, jet_ref); } diff --git a/XTagProducer/src/tensor_fillers.cc b/XTagProducer/src/tensor_fillers.cc index 31636ac..fb7e38c 100644 --- a/XTagProducer/src/tensor_fillers.cc +++ b/XTagProducer/src/tensor_fillers.cc @@ -26,15 +26,15 @@ namespace llpdnnx { *(++ptr) = features.sv_features.size(); // variables from ShallowTagInfo const auto& tag_info_features = features.tag_info_features; - *(++ptr) = tag_info_features.csv_trackSumJetEtRatio; - *(++ptr) = tag_info_features.csv_trackSumJetDeltaR; - *(++ptr) = tag_info_features.csv_vertexCategory; - *(++ptr) = tag_info_features.csv_trackSip2dValAboveCharm; - *(++ptr) = tag_info_features.csv_trackSip2dSigAboveCharm; - *(++ptr) = tag_info_features.csv_trackSip3dValAboveCharm; - *(++ptr) = tag_info_features.csv_trackSip3dSigAboveCharm; - *(++ptr) = tag_info_features.csv_jetNSelectedTracks; - *(++ptr) = tag_info_features.csv_jetNTracksEtaRel; + *(++ptr) = tag_info_features.trackSumJetEtRatio; + *(++ptr) = tag_info_features.trackSumJetDeltaR; + *(++ptr) = tag_info_features.vertexCategory; + *(++ptr) = tag_info_features.trackSip2dValAboveCharm; + *(++ptr) = tag_info_features.trackSip2dSigAboveCharm; + *(++ptr) = tag_info_features.trackSip3dValAboveCharm; + *(++ptr) = tag_info_features.trackSip3dSigAboveCharm; + *(++ptr) = tag_info_features.jetNSelectedTracks; + *(++ptr) = tag_info_features.jetNTracksEtaRel; } void cpf_tensor_filler(tensorflow::Tensor& tensor, @@ -43,24 +43,24 @@ namespace llpdnnx { const llpdnnx::ChargedCandidateFeatures& cpf_features) { float* ptr = &tensor.tensor()(jet_n, cpf_n, 0); - *ptr = cpf_features.cpf_trackEtaRel; - *(++ptr) = cpf_features.cpf_trackPtRel; - *(++ptr) = cpf_features.cpf_trackPPar; - *(++ptr) = cpf_features.cpf_trackDeltaR; - *(++ptr) = cpf_features.cpf_trackPParRatio; - *(++ptr) = cpf_features.cpf_trackSip2dVal; - *(++ptr) = cpf_features.cpf_trackSip2dSig; - *(++ptr) = cpf_features.cpf_trackSip3dVal; - *(++ptr) = cpf_features.cpf_trackSip3dSig; - *(++ptr) = cpf_features.cpf_trackJetDistVal; - *(++ptr) = cpf_features.cpf_ptrel; - *(++ptr) = cpf_features.cpf_drminsv; - *(++ptr) = cpf_features.cpf_vertex_association; - *(++ptr) = cpf_features.cpf_fromPV; - *(++ptr) = cpf_features.cpf_puppi_weight; - *(++ptr) = cpf_features.cpf_track_chi2; - *(++ptr) = cpf_features.cpf_track_ndof; - *(++ptr) = cpf_features.cpf_track_quality; + *ptr = cpf_features.trackEtaRel; + *(++ptr) = cpf_features.trackPtRel; + *(++ptr) = cpf_features.trackPPar; + *(++ptr) = cpf_features.trackDeltaR; + *(++ptr) = cpf_features.trackPParRatio; + *(++ptr) = cpf_features.trackSip2dVal; + *(++ptr) = cpf_features.trackSip2dSig; + *(++ptr) = cpf_features.trackSip3dVal; + *(++ptr) = cpf_features.trackSip3dSig; + *(++ptr) = cpf_features.trackJetDistVal; + *(++ptr) = cpf_features.ptrel; + *(++ptr) = cpf_features.drminsv; + *(++ptr) = cpf_features.vertex_association; + *(++ptr) = cpf_features.fromPV; + *(++ptr) = cpf_features.puppi_weight; + *(++ptr) = cpf_features.track_chi2; + *(++ptr) = cpf_features.track_ndof; + *(++ptr) = cpf_features.track_quality; } void npf_tensor_filler(tensorflow::Tensor& tensor, From 91c81b225852a097e099622d305f4c37e99af5bd Mon Sep 17 00:00:00 2001 From: matt-komm Date: Sat, 14 Nov 2020 13:16:36 +0000 Subject: [PATCH 08/20] refactored flat table production --- .../interface/ElectronCandidateFeatures.h | 283 ++++-- DataFormats/interface/MuonCandidateFeatures.h | 185 ++-- .../interface/NeutralCandidateFeatures.h | 41 +- .../interface/SecondaryVertexFeatures.h | 44 +- NANOProducer/plugins/NANOGenProducer.cc | 317 +++---- NANOProducer/plugins/NANOProducer.cc | 818 +++++------------- XTagInfoProducer/plugins/XTagInfoProducer.cc | 418 ++++----- XTagProducer/src/tensor_fillers.cc | 36 +- 8 files changed, 925 insertions(+), 1217 deletions(-) diff --git a/DataFormats/interface/ElectronCandidateFeatures.h b/DataFormats/interface/ElectronCandidateFeatures.h index e279932..3c7745e 100644 --- a/DataFormats/interface/ElectronCandidateFeatures.h +++ b/DataFormats/interface/ElectronCandidateFeatures.h @@ -3,108 +3,221 @@ namespace llpdnnx { -class ElectronCandidateFeatures { - - public: - int elec_jetIdx; - float elec_ptrel; - float elec_deltaR; - float elec_deta; - float elec_dphi; - float elec_px; - float elec_py; - float elec_pz; - float elec_charge; - float elec_energy; - float elec_EtFromCaloEn; - int elec_isEB; - int elec_isEE; - float elec_ecalEnergy; - int elec_isPassConversionVeto; - float elec_convDist; - int elec_convFlags; - float elec_convRadius; - float elec_hadronicOverEm; - float elec_ecalDrivenSeed; - float elec_2dIP; - float elec_2dIPSig; - float elec_3dIP; - float elec_3dIPSig; +struct ElectronCandidateFeatures { + int jetIdx; + float ptrel; + float deltaR; + float deta; + float dphi; + float px; + float py; + float pz; + float charge; + float energy; + float EtFromCaloEn; + int isEB; + int isEE; + float ecalEnergy; + int isPassConversionVeto; + float convDist; + int convFlags; + float convRadius; + float hadronicOverEm; + float ecalDrivenSeed; + float IP2d; + float IP2dSig; + float IP3d; + float IP3dSig; float elecSC_energy; float elecSC_deta; float elecSC_dphi; float elecSC_et; float elecSC_eSuperClusterOverP; - float elec_scPixCharge; - float elec_superClusterFbrem; + float scPixCharge; + float superClusterFbrem; - float elec_eSeedClusterOverP; - float elec_eSeedClusterOverPout; - float elec_eSuperClusterOverP; + float eSeedClusterOverP; + float eSeedClusterOverPout; + float eSuperClusterOverP; // shower shape - float elec_sigmaEtaEta; - float elec_sigmaIetaIeta; - float elec_sigmaIphiIphi; - float elec_e5x5; - float elec_e5x5Rel; - float elec_e1x5Overe5x5; - float elec_e2x5MaxOvere5x5; - float elec_r9; - float elec_hcalOverEcal; - float elec_hcalDepth1OverEcal; - float elec_hcalDepth2OverEcal; + float sigmaEtaEta; + float sigmaIetaIeta; + float sigmaIphiIphi; + float e5x5; + float e5x5Rel; + float e1x5Overe5x5; + float e2x5MaxOvere5x5; + float r9; + float hcalOverEcal; + float hcalDepth1OverEcal; + float hcalDepth2OverEcal; // Track-Cluster Matching Attributes - float elec_deltaEtaEleClusterTrackAtCalo; - float elec_deltaEtaSeedClusterTrackAtCalo; - float elec_deltaPhiSeedClusterTrackAtCalo; - float elec_deltaEtaSeedClusterTrackAtVtx; - float elec_deltaEtaSuperClusterTrackAtVtx; - float elec_deltaPhiEleClusterTrackAtCalo; - float elec_deltaPhiSuperClusterTrackAtVtx; + float deltaEtaEleClusterTrackAtCalo; + float deltaEtaSeedClusterTrackAtCalo; + float deltaPhiSeedClusterTrackAtCalo; + float deltaEtaSeedClusterTrackAtVtx; + float deltaEtaSuperClusterTrackAtVtx; + float deltaPhiEleClusterTrackAtCalo; + float deltaPhiSuperClusterTrackAtVtx; - float elec_sCseedEta; + float sCseedEta; // electron gsf variables. - float elec_EtaRel; - float elec_dxy; - float elec_dxyError; - float elec_dxySig; - float elec_dz; - float elec_dzError; - float elec_dzSig; - int elec_nbOfMissingHits; - float elec_gsfCharge; - int elec_ndof; - float elec_chi2; - int elec_numberOfBrems; - float elec_trackFbrem; - float elec_fbrem; + float EtaRel; + float dxy; + float dxyError; + float dxySig; + float dz; + float dzError; + float dzSig; + int nbOfMissingHits; + float gsfCharge; + int ndof; + float chi2; + int numberOfBrems; + float trackFbrem; + float fbrem; // Isolation block - float elec_neutralHadronIso; - float elec_particleIso; - float elec_photonIso; - float elec_puChargedHadronIso; - float elec_trackIso; - float elec_ecalPFClusterIso; - float elec_hcalPFClusterIso; + float neutralHadronIso; + float particleIso; + float photonIso; + float puChargedHadronIso; + float trackIso; + float ecalPFClusterIso; + float hcalPFClusterIso; - float elec_pfSumPhotonEt; - float elec_pfSumChargedHadronPt; - float elec_pfSumNeutralHadronEt; - float elec_pfSumPUPt; - - float elec_dr04TkSumPt; - float elec_dr04EcalRecHitSumEt; - float elec_dr04HcalDepth1TowerSumEt; - float elec_dr04HcalDepth1TowerSumEtBc; - float elec_dr04HcalDepth2TowerSumEt; - float elec_dr04HcalDepth2TowerSumEtBc; - float elec_dr04HcalTowerSumEt; - float elec_dr04HcalTowerSumEtBc; + float pfSumPhotonEt; + float pfSumChargedHadronPt; + float pfSumNeutralHadronEt; + float pfSumPUPt; + + float dr04TkSumPt; + float dr04EcalRecHitSumEt; + float dr04HcalDepth1TowerSumEt; + float dr04HcalDepth1TowerSumEtBc; + float dr04HcalDepth2TowerSumEt; + float dr04HcalDepth2TowerSumEtBc; + float dr04HcalTowerSumEt; + float dr04HcalTowerSumEtBc; + + + ElectronCandidateFeatures(): + jetIdx(-1), + ptrel(0), + deltaR(0), + deta(0), + dphi(0), + px(0), + py(0), + pz(0), + charge(0), + energy(0), + EtFromCaloEn(0), + isEB(0), + isEE(0), + ecalEnergy(0), + isPassConversionVeto(0), + convDist(0), + convFlags(0), + convRadius(0), + hadronicOverEm(0), + ecalDrivenSeed(0), + IP2d(0), + IP2dSig(0), + IP3d(0), + IP3dSig(0), + + elecSC_energy(0), + elecSC_deta(0), + elecSC_dphi(0), + elecSC_et(0), + elecSC_eSuperClusterOverP(0), + scPixCharge(0), + superClusterFbrem(0), + + eSeedClusterOverP(0), + eSeedClusterOverPout(0), + eSuperClusterOverP(0), + + // shower shape + sigmaEtaEta(0), + sigmaIetaIeta(0), + sigmaIphiIphi(0), + e5x5(0), + e5x5Rel(0), + e1x5Overe5x5(0), + e2x5MaxOvere5x5(0), + r9(0), + hcalOverEcal(0), + hcalDepth1OverEcal(0), + hcalDepth2OverEcal(0), + + // Track-Cluster Matching Attributes + deltaEtaEleClusterTrackAtCalo(0), + deltaEtaSeedClusterTrackAtCalo(0), + deltaPhiSeedClusterTrackAtCalo(0), + deltaEtaSeedClusterTrackAtVtx(0), + deltaEtaSuperClusterTrackAtVtx(0), + deltaPhiEleClusterTrackAtCalo(0), + deltaPhiSuperClusterTrackAtVtx(0), + + sCseedEta(0), + + // electron gsf variables. + EtaRel(0), + dxy(0), + dxyError(0), + dxySig(0), + dz(0), + dzError(0), + dzSig(0), + nbOfMissingHits(0), + gsfCharge(0), + ndof(0), + chi2(0), + numberOfBrems(0), + trackFbrem(0), + fbrem(0), + + // Isolation block + neutralHadronIso(0), + particleIso(0), + photonIso(0), + puChargedHadronIso(0), + trackIso(0), + ecalPFClusterIso(0), + hcalPFClusterIso(0), + + pfSumPhotonEt(0), + pfSumChargedHadronPt(0), + pfSumNeutralHadronEt(0), + pfSumPUPt(0), + + dr04TkSumPt(0), + dr04EcalRecHitSumEt(0), + dr04HcalDepth1TowerSumEt(0), + dr04HcalDepth1TowerSumEtBc(0), + dr04HcalDepth2TowerSumEt(0), + dr04HcalDepth2TowerSumEtBc(0), + dr04HcalTowerSumEt(0), + dr04HcalTowerSumEtBc(0) + {} + + bool operator<(const ElectronCandidateFeatures& other) const + { + if (IP2dSig>0 and other.IP2dSig>0) + { + if (std::fabs(IP2dSig-other.IP2dSig)>std::numeric_limits::epsilon()) + { + return std::fabs(IP2dSig)>std::fabs(other.IP2dSig); //sort decreasing + } + } + return ptrel>other.ptrel; //sort decreasing + } }; } diff --git a/DataFormats/interface/MuonCandidateFeatures.h b/DataFormats/interface/MuonCandidateFeatures.h index a75fdd4..b86f41e 100644 --- a/DataFormats/interface/MuonCandidateFeatures.h +++ b/DataFormats/interface/MuonCandidateFeatures.h @@ -5,63 +5,134 @@ namespace llpdnnx { struct MuonCandidateFeatures { - int mu_jetIdx; - int mu_isGlobal; - int mu_isTight; - int mu_isMedium; - int mu_isLoose; - int mu_isStandAlone; - - float mu_ptrel; - float mu_deta; - float mu_dphi; - float mu_px; - float mu_py; - float mu_pz; - float mu_charge; - float mu_energy; - float mu_et; - float mu_deltaR; - int mu_numberOfMatchedStations; - - float mu_2dIP; - float mu_2dIPSig; - float mu_3dIP; - float mu_3dIPSig; - - float mu_EtaRel; - float mu_dxy; - float mu_dxyError; - float mu_dxySig; - float mu_dz; - float mu_dzError; - float mu_dzSig; - int mu_numberOfValidPixelHits; - int mu_numberOfpixelLayersWithMeasurement; - int mu_numberOfstripLayersWithMeasurement; //that does not help. needs to be discussed. - - float mu_chi2; - int mu_ndof; - - float mu_caloIso; - float mu_ecalIso; - float mu_hcalIso; - - float mu_sumPfChHadronPt; - float mu_sumPfNeuHadronEt; - float mu_Pfpileup; - float mu_sumPfPhotonEt; - - float mu_sumPfChHadronPt03; - float mu_sumPfNeuHadronEt03; - float mu_Pfpileup03; - float mu_sumPfPhotonEt03; - - - float mu_timeAtIpInOut; - float mu_timeAtIpInOutErr; - float mu_timeAtIpOutIn; - + int jetIdx; + int isGlobal; + int isTight; + int isMedium; + int isLoose; + int isStandAlone; + + float ptrel; + float deta; + float dphi; + float px; + float py; + float pz; + float charge; + float energy; + float et; + float deltaR; + int numberOfMatchedStations; + + float IP2d; + float IP2dSig; + float IP3d; + float IP3dSig; + + float EtaRel; + float dxy; + float dxyError; + float dxySig; + float dz; + float dzError; + float dzSig; + int numberOfValidPixelHits; + int numberOfpixelLayersWithMeasurement; + int numberOfstripLayersWithMeasurement; //that does not help. needs to be discussed. + + float chi2; + int ndof; + + float caloIso; + float ecalIso; + float hcalIso; + + float sumPfChHadronPt; + float sumPfNeuHadronEt; + float Pfpileup; + float sumPfPhotonEt; + + float sumPfChHadronPt03; + float sumPfNeuHadronEt03; + float Pfpileup03; + float sumPfPhotonEt03; + + + float timeAtIpInOut; + float timeAtIpInOutErr; + float timeAtIpOutIn; + + + MuonCandidateFeatures(): + jetIdx(-1), + isGlobal(-1), + isTight(-1), + isMedium(-1), + isLoose(-1), + isStandAlone(-1), + + ptrel(0), + deta(0), + dphi(0), + px(0), + py(0), + pz(0), + charge(0), + energy(0), + et(0), + deltaR(0), + numberOfMatchedStations(0), + + IP2d(0), + IP2dSig(0), + IP3d(0), + IP3dSig(0), + + EtaRel(0), + dxy(0), + dxyError(0), + dxySig(0), + dz(0), + dzError(0), + dzSig(0), + numberOfValidPixelHits(0), + numberOfpixelLayersWithMeasurement(0), + numberOfstripLayersWithMeasurement(0), //that does not help. needs to be discussed. + + chi2(0), + ndof(0), + + caloIso(0), + ecalIso(0), + hcalIso(0), + + sumPfChHadronPt(0), + sumPfNeuHadronEt(0), + Pfpileup(0), + sumPfPhotonEt(0), + + sumPfChHadronPt03(0), + sumPfNeuHadronEt03(0), + Pfpileup03(0), + sumPfPhotonEt03(0), + + + timeAtIpInOut(0), + timeAtIpInOutErr(0), + timeAtIpOutIn(0) + {} + + bool operator<(const MuonCandidateFeatures& other) const + { + if (IP2dSig>0 and other.IP2dSig>0) + { + if (std::fabs(IP2dSig-other.IP2dSig)>std::numeric_limits::epsilon()) + { + return std::fabs(IP2dSig)>std::fabs(other.IP2dSig); //sort decreasing + } + } + return ptrel>other.ptrel; //sort decreasing + } }; diff --git a/DataFormats/interface/NeutralCandidateFeatures.h b/DataFormats/interface/NeutralCandidateFeatures.h index e76cb89..f63f228 100644 --- a/DataFormats/interface/NeutralCandidateFeatures.h +++ b/DataFormats/interface/NeutralCandidateFeatures.h @@ -1,25 +1,40 @@ #ifndef LLPReco_DataFormats_NeutralCandidateFeatures_h #define LLPReco_DataFormats_NeutralCandidateFeatures_h +#include + namespace llpdnnx { struct NeutralCandidateFeatures { - int npf_jetIdx; - float npf_ptrel; - float npf_deta; - float npf_dphi; - float npf_deltaR; + int jetIdx; + float ptrel; + float deta; + float dphi; + float deltaR; + + float px; + float py; + float pz; - float npf_px; - float npf_py; - float npf_pz; + int isGamma; + float hcal_fraction; + float drminsv; + float puppi_weight; + float relmassdrop; - int npf_isGamma; - float npf_hcal_fraction; - float npf_drminsv; - float npf_puppi_weight; - float npf_relmassdrop; + bool operator<(const NeutralCandidateFeatures& other) const + { + if (std::fabs(drminsv-other.drminsv)>std::numeric_limits::epsilon()) + { + return drminsvother.ptrel; //sort decreasing + } + return false; + } }; } diff --git a/DataFormats/interface/SecondaryVertexFeatures.h b/DataFormats/interface/SecondaryVertexFeatures.h index aff8b28..25abd92 100644 --- a/DataFormats/interface/SecondaryVertexFeatures.h +++ b/DataFormats/interface/SecondaryVertexFeatures.h @@ -1,26 +1,40 @@ #ifndef LLPReco_DataFormats_SecondaryVertexFeatures_h #define LLPReco_DataFormats_SecondaryVertexFeatures_h +#include + namespace llpdnnx { struct SecondaryVertexFeatures { - int sv_jetIdx; - float sv_ptrel; - float sv_deta; - float sv_dphi; - float sv_deltaR; - float sv_mass; - int sv_ntracks; - float sv_chi2; - int sv_ndof; - float sv_dxy; - float sv_dxysig; - float sv_d3d; - float sv_d3dsig; - float sv_costhetasvpv; - float sv_enratio; + int jetIdx; + float ptrel; + float deta; + float dphi; + float deltaR; + float mass; + int ntracks; + float chi2; + int ndof; + float dxy; + float dxysig; + float d3d; + float d3dsig; + float costhetasvpv; + float enratio; + + bool operator<(const SecondaryVertexFeatures& other) const + { + if (dxysig>0 and other.dxysig>0) + { + if (std::fabs(dxysig-other.dxysig)>std::numeric_limits::epsilon()) + { + return dxysig>other.dxysig; + } + } + return ptrel>other.ptrel; //sort decreasing + } }; diff --git a/NANOProducer/plugins/NANOGenProducer.cc b/NANOProducer/plugins/NANOGenProducer.cc index c3a9604..0e0ec02 100644 --- a/NANOProducer/plugins/NANOGenProducer.cc +++ b/NANOProducer/plugins/NANOGenProducer.cc @@ -18,19 +18,29 @@ #include "DataFormats/NanoAOD/interface/FlatTable.h" #include - - +#include "FlatTableFiller.h" // // class declaration // +#define LABEL(name) \ + std::pair( #name , llpdnnx::LLPLabel::Type:: name ) + +#define TAUDECAY(name) \ + std::pair( #name , llpdnnx::LLPLabel::TauDecay:: name ) + class NANOGenProducer : public edm::stream::EDProducer<> { public: explicit NANOGenProducer(const edm::ParameterSet&); ~NANOGenProducer(); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + std::vector> labelTypes; + std::vector> tauDecayTypes; + + PropertyList labelProperties; private: const edm::EDGetTokenT> _jet_src; @@ -45,6 +55,86 @@ NANOGenProducer::NANOGenProducer(const edm::ParameterSet& iConfig) : _label_src(consumes>(iConfig.getParameter("srcLabels"))) { + + labelTypes = { + LABEL(isPU), + LABEL(isB), + LABEL(isBB), + LABEL(isLeptonic_B), + LABEL(isC), + LABEL(isCC), + LABEL(isLeptonic_C), + LABEL(isS), + LABEL(isUD), + LABEL(isG), + LABEL(isPrompt_MU), + LABEL(isPrompt_E), + LABEL(isPrompt_PHOTON), + LABEL(isPrompt_TAU), + + LABEL(isLLP_RAD), //no flavour match (likely from wide angle radiation) + LABEL(isLLP_MU), //prompt lepton + LABEL(isLLP_E), //prompt lepton + LABEL(isLLP_Q), //single light quark + LABEL(isLLP_QMU), //single light quark + prompt lepton + LABEL(isLLP_QE), //single light quark + prompt lepton + LABEL(isLLP_QQ), //double light quark + LABEL(isLLP_QQMU), //double light quark + prompt lepton + LABEL(isLLP_QQE), //double light quark + prompt lepton + LABEL(isLLP_B), //single b/c quark + LABEL(isLLP_BMU), //single b/c quark + prompt lepton + LABEL(isLLP_BE), //single b/c quark + prompt lepton + LABEL(isLLP_BB), //double b/c quark + LABEL(isLLP_BBMU), //double b/c quark + prompt lepton + LABEL(isLLP_BBE), //double b/c quark + prompt lepton + LABEL(isLLP_TAU), + LABEL(isLLP_QTAU), + LABEL(isLLP_QQTAU), + LABEL(isLLP_BTAU), + LABEL(isLLP_BBTAU), + + LABEL(isLLP_PHOTON), + LABEL(isLLP_QPHOTON), + LABEL(isLLP_QQPHOTON), + LABEL(isLLP_BPHOTON), + LABEL(isLLP_BBPHOTON), + LABEL(isUndefined) + }; + + tauDecayTypes = { + TAUDECAY(NO_TAU), //no tau decay + TAUDECAY(INVISIBLE), //tau decay but not reconstructable + TAUDECAY(E), //to electron + TAUDECAY(MU), //to muon + TAUDECAY(H), //1 charged hadron + TAUDECAY(H_1PI0), //1 charged hadron + pi0(->2gamma) + TAUDECAY(H_XPI0), //1 charged hadron + 2 or more pi0(->2gamma) + TAUDECAY(HHH), //3 charged hadrons + TAUDECAY(HHH_XPI0) //3 charged hadron + 1 or more pi0(->2gamma) + }; + + labelProperties = { + PROPERTY(llpdnnx::LLPLabel, partonFlavor, "doc"), + PROPERTY(llpdnnx::LLPLabel, hadronFlavor, "doc"), + PROPERTY(llpdnnx::LLPLabel, llpId, "doc"), + PROPERTY(llpdnnx::LLPLabel, llp_mass, "doc"), + PROPERTY(llpdnnx::LLPLabel, llp_pt, "doc"), + + PROPERTY(llpdnnx::LLPLabel, displacement, "doc"), + PROPERTY(llpdnnx::LLPLabel, displacement_xy, "doc"), + PROPERTY(llpdnnx::LLPLabel, displacement_z, "doc"), + PROPERTY(llpdnnx::LLPLabel, decay_angle, "doc"), + PROPERTY(llpdnnx::LLPLabel, betagamma, "doc"), + + + PROPERTY(llpdnnx::LLPLabel, matchedGenJetDeltaR, "doc"), + PROPERTY(llpdnnx::LLPLabel, matchedGenJetPt, "doc"), + PROPERTY(llpdnnx::LLPLabel, sharedVertexFraction, "doc"), + + PROPERTY(llpdnnx::LLPLabel, genTauMass, "doc"), + PROPERTY(llpdnnx::LLPLabel, recoTauMass, "doc") + }; + produces("jetorigin"); } @@ -74,81 +164,16 @@ NANOGenProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector truth_jetIdx; - std::vector isPU; - std::vector isB; - std::vector isBB; - std::vector isLeptonic_B; - std::vector isLeptonic_C; - std::vector isC; - std::vector isCC; - std::vector isS; - std::vector isUD; - std::vector isG; - std::vector isPrompt_MU; - std::vector isPrompt_E; - std::vector isPrompt_TAU; - std::vector isPrompt_PHOTON; - - std::vector isLLP_RAD; //no flavour match (likely from wide angle radiation) - std::vector isLLP_MU; //prompt lepton - std::vector isLLP_E; //prompt lepton - std::vector isLLP_Q; //single light quark - std::vector isLLP_QMU; //single light quark + prompt lepton - std::vector isLLP_QE; //single light quark + prompt lepton - std::vector isLLP_QQ; //double light quark - std::vector isLLP_QQMU; //double light quark + prompt lepton - std::vector isLLP_QQE; //double light quark + prompt lepton - std::vector isLLP_B; //single b/c quark - std::vector isLLP_BMU; //single b/c quark + prompt lepton - std::vector isLLP_BE; //single b/c quark + prompt lepton - std::vector isLLP_BB; //double b/c quark - std::vector isLLP_BBMU; //double b/c quark + prompt lepton - std::vector isLLP_BBE; //double b/c quark + prompt lepton - std::vector isLLP_TAU; - std::vector isLLP_QTAU; - std::vector isLLP_QQTAU; - std::vector isLLP_BTAU; - std::vector isLLP_BBTAU; - - std::vector isLLP_PHOTON; - std::vector isLLP_QPHOTON; - std::vector isLLP_QQPHOTON; - std::vector isLLP_BPHOTON; - std::vector isLLP_BBPHOTON; + + std::unordered_map> labelList; + std::unordered_map> tauDecayList; - std::vector isTauDecay_NO_TAU; //no tau decay - std::vector isTauDecay_INVISIBLE; //tau decay but not reconstructable - std::vector isTauDecay_E; //to electron - std::vector isTauDecay_MU; //to muon - std::vector isTauDecay_H; //1 charged hadron - std::vector isTauDecay_H_1PI0; //1 charged hadron + pi0(->2gamma) - std::vector isTauDecay_H_XPI0; //1 charged hadron + 2 or more pi0(->2gamma) - std::vector isTauDecay_HHH; //3 charged hadrons - std::vector isTauDecay_HHH_XPI0; //3 charged hadron + 1 or more pi0(->2gamma) - - std::vector isUndefined; + - std::vector partonFlavor; - std::vector hadronFlavor; - std::vector llpId; - std::vector llp_pt; - std::vector llp_mass; - - std::vector displacement; - std::vector displacement_xy; - std::vector displacement_z; - std::vector decay_angle; - std::vector betagamma; - - std::vector matchedGenJetDeltaR; - std::vector matchedGenJetPt; - std::vector sharedVertexFraction; - - std::vector genTauMass; - std::vector recoTauMass; + FlatTableFillerList labelPropertyFillerList(labelProperties); for (std::size_t itag = 0; itag < ntruth; itag++) { - const auto& labels = label_infos->at(itag).features(); + const auto& label = label_infos->at(itag).features(); int jetIdx = -1; auto base_jet_ref = label_infos->at(itag).jet(); if (base_jet_ref.isAvailable() and base_jet_ref.isNonnull()){ @@ -164,150 +189,22 @@ NANOGenProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) truth_jetIdx.push_back(jetIdx); - isPU.push_back(labels.type == llpdnnx::LLPLabel::Type::isPU ? 1 : 0); - isB.push_back(labels.type == llpdnnx::LLPLabel::Type::isB ? 1 : 0); - isBB.push_back(labels.type == llpdnnx::LLPLabel::Type::isBB ? 1 : 0); - isLeptonic_B.push_back(labels.type == llpdnnx::LLPLabel::Type::isLeptonic_B ? 1 : 0); - isLeptonic_C.push_back(labels.type == llpdnnx::LLPLabel::Type::isLeptonic_C ? 1 : 0); - isC.push_back(labels.type == llpdnnx::LLPLabel::Type::isC ? 1 : 0); - isCC.push_back(labels.type == llpdnnx::LLPLabel::Type::isCC ? 1 : 0); - isS.push_back(labels.type == llpdnnx::LLPLabel::Type::isS ? 1 : 0); - isUD.push_back(labels.type == llpdnnx::LLPLabel::Type::isUD ? 1 : 0); - isG.push_back(labels.type == llpdnnx::LLPLabel::Type::isG ? 1 : 0); - isPrompt_MU.push_back(labels.type == llpdnnx::LLPLabel::Type::isPrompt_MU ? 1 : 0); - isPrompt_E.push_back(labels.type == llpdnnx::LLPLabel::Type::isPrompt_E ? 1 : 0); - isPrompt_TAU.push_back(labels.type == llpdnnx::LLPLabel::Type::isPrompt_TAU ? 1 : 0); - isPrompt_PHOTON.push_back(labels.type == llpdnnx::LLPLabel::Type::isPrompt_PHOTON ? 1 : 0); - isLLP_RAD.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_RAD ? 1 : 0); - isLLP_MU.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_MU ? 1 : 0); - isLLP_E.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_E ? 1 : 0); - isLLP_Q.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_Q ? 1 : 0); - isLLP_QMU.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_QMU ? 1 : 0); - isLLP_QE.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_QE ? 1 : 0); - isLLP_QQ.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_QQ ? 1 : 0); - isLLP_QQMU.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_QQMU ? 1 : 0); - isLLP_QQE.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_QQE ? 1 : 0); - isLLP_B.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_B ? 1 : 0); - isLLP_BMU.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_BMU ? 1 : 0); - isLLP_BE.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_BE ? 1 : 0); - isLLP_BB.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_BB ? 1 : 0); - isLLP_BBMU.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_BBMU ? 1 : 0); - isLLP_BBE.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_BBE ? 1 : 0); - isLLP_TAU.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_TAU ? 1 : 0); - isLLP_QTAU.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_QTAU ? 1 : 0); - isLLP_QQTAU.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_QQTAU ? 1 : 0); - isLLP_BTAU.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_BTAU ? 1 : 0); - isLLP_BBTAU.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_BBTAU ? 1 : 0); - isLLP_PHOTON.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_PHOTON ? 1 : 0); - isLLP_QPHOTON.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_QPHOTON ? 1 : 0); - isLLP_QQPHOTON.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_QQPHOTON ? 1 : 0); - isLLP_BPHOTON.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_BPHOTON ? 1 : 0); - isLLP_BBPHOTON.push_back(labels.type == llpdnnx::LLPLabel::Type::isLLP_BBPHOTON ? 1 : 0); - isUndefined.push_back(labels.type == llpdnnx::LLPLabel::Type::isUndefined ? 1 : 0); - - - isTauDecay_NO_TAU.push_back(labels.tauDecay == llpdnnx::LLPLabel::TauDecay::NO_TAU ? 1 : 0); - isTauDecay_INVISIBLE.push_back(labels.tauDecay == llpdnnx::LLPLabel::TauDecay::INVISIBLE ? 1 : 0); - isTauDecay_E.push_back(labels.tauDecay == llpdnnx::LLPLabel::TauDecay::E ? 1 : 0); - isTauDecay_MU.push_back(labels.tauDecay == llpdnnx::LLPLabel::TauDecay::MU ? 1 : 0); - isTauDecay_H.push_back(labels.tauDecay == llpdnnx::LLPLabel::TauDecay::H ? 1 : 0); - isTauDecay_H_1PI0.push_back(labels.tauDecay == llpdnnx::LLPLabel::TauDecay::H_1PI0 ? 1 : 0); - isTauDecay_H_XPI0.push_back(labels.tauDecay == llpdnnx::LLPLabel::TauDecay::H_XPI0 ? 1 : 0); - isTauDecay_HHH.push_back(labels.tauDecay == llpdnnx::LLPLabel::TauDecay::HHH ? 1 : 0); - isTauDecay_HHH_XPI0.push_back(labels.tauDecay == llpdnnx::LLPLabel::TauDecay::HHH_XPI0 ? 1 : 0); - - - partonFlavor.push_back(labels.partonFlavor); - hadronFlavor.push_back(labels.hadronFlavor); - llpId.push_back(labels.llpId); - llp_pt.push_back(labels.llp_pt); - llp_mass.push_back(labels.llp_mass); - displacement.push_back(labels.displacement); - displacement_xy.push_back(labels.displacement_xy); - displacement_z.push_back(labels.displacement_z); - decay_angle.push_back(labels.decay_angle); - betagamma.push_back(labels.betagamma); - - matchedGenJetDeltaR.push_back(labels.matchedGenJetDeltaR); - matchedGenJetPt.push_back(labels.matchedGenJetPt); - sharedVertexFraction.push_back(labels.sharedVertexFraction); - genTauMass.push_back(labels.genTauMass); - recoTauMass.push_back(labels.recoTauMass); + for (const auto& labelType: labelTypes) labelList[labelType.first].push_back(label.type == labelType.second ? 1 : 0); + for (const auto& tauDecayType: tauDecayTypes) tauDecayList[tauDecayType.first].push_back(label.tauDecay == tauDecayType.second ? 1 : 0); + + + labelPropertyFillerList.push_back(label); } jetOriginTable->addColumn("jetIdx", truth_jetIdx, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isPU", isPU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isB", isB, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isBB", isBB, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLeptonic_B", isLeptonic_B, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLeptonic_C", isLeptonic_C, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isC", isC, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isCC", isCC, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isS", isS, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isUD", isUD, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isG", isG, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isPrompt_MU", isPrompt_MU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isPrompt_E", isPrompt_E, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isPrompt_TAU", isPrompt_TAU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isPrompt_PHOTON", isPrompt_PHOTON, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_RAD", isLLP_RAD, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_MU", isLLP_MU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_E", isLLP_E, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_Q", isLLP_Q, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_QMU", isLLP_QMU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_QE", isLLP_QE, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_QQ", isLLP_QQ, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_QQMU", isLLP_QQMU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_QQE", isLLP_QQE, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_B", isLLP_B, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_BMU", isLLP_BMU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_BE", isLLP_BE, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_BB", isLLP_BB, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_BBMU", isLLP_BBMU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_BBE", isLLP_BBE, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_TAU", isLLP_TAU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_QTAU", isLLP_QTAU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_QQTAU", isLLP_QQTAU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_BTAU", isLLP_BTAU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_BBTAU", isLLP_BBTAU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_PHOTON", isLLP_PHOTON, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_QPHOTON", isLLP_QPHOTON, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_QQPHOTON", isLLP_QQPHOTON, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_BPHOTON", isLLP_BPHOTON, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isLLP_BBPHOTON", isLLP_BBPHOTON, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isUndefined", isUndefined, "doc", nanoaod::FlatTable::IntColumn); - - jetOriginTable->addColumn("isTauDecay_NO_TAU", isTauDecay_NO_TAU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isTauDecay_INVISIBLE", isTauDecay_INVISIBLE, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isTauDecay_E", isTauDecay_E, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isTauDecay_MU", isTauDecay_MU, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isTauDecay_H", isTauDecay_H, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isTauDecay_H_1PI0", isTauDecay_H_1PI0, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isTauDecay_H_XPI0", isTauDecay_H_XPI0, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isTauDecay_HHH", isTauDecay_HHH, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("isTauDecay_HHH_XPI0", isTauDecay_HHH_XPI0, "doc", nanoaod::FlatTable::IntColumn); - - jetOriginTable->addColumn("partonFlavor", partonFlavor, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("hadronFlavor", hadronFlavor, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("llpId", llpId, "doc", nanoaod::FlatTable::IntColumn); - jetOriginTable->addColumn("llp_pt", llp_pt, "doc", nanoaod::FlatTable::FloatColumn); - jetOriginTable->addColumn("llp_mass", llp_mass, "doc", nanoaod::FlatTable::FloatColumn); - - jetOriginTable->addColumn("displacement", displacement, "doc", nanoaod::FlatTable::FloatColumn); - jetOriginTable->addColumn("displacement_xy", displacement_xy, "doc", nanoaod::FlatTable::FloatColumn); - jetOriginTable->addColumn("displacement_z", displacement_z, "doc", nanoaod::FlatTable::FloatColumn); - jetOriginTable->addColumn("decay_angle", decay_angle, "doc", nanoaod::FlatTable::FloatColumn); - jetOriginTable->addColumn("betagamma", betagamma, "doc", nanoaod::FlatTable::FloatColumn); - jetOriginTable->addColumn("matchedGenJetDeltaR", matchedGenJetDeltaR, "doc", nanoaod::FlatTable::FloatColumn); - jetOriginTable->addColumn("matchedGenJetPt", matchedGenJetPt, "doc", nanoaod::FlatTable::FloatColumn); - jetOriginTable->addColumn("sharedVertexFraction", sharedVertexFraction, "doc", nanoaod::FlatTable::FloatColumn); - - jetOriginTable->addColumn("genTauMass", genTauMass, "doc", nanoaod::FlatTable::FloatColumn); - jetOriginTable->addColumn("recoTauMass", recoTauMass, "doc", nanoaod::FlatTable::FloatColumn); + for (const auto& labelType: labelTypes) jetOriginTable->addColumn(labelType.first, labelList[labelType.first], "doc", nanoaod::FlatTable::IntColumn); + for (const auto& tauDecayType: tauDecayTypes) jetOriginTable->addColumn(tauDecayType.first, tauDecayList[tauDecayType.first], "doc", nanoaod::FlatTable::IntColumn); + + labelPropertyFillerList.fill(jetOriginTable); iEvent.put(std::move(jetOriginTable), "jetorigin"); } diff --git a/NANOProducer/plugins/NANOProducer.cc b/NANOProducer/plugins/NANOProducer.cc index 6fbfaee..5ccf319 100644 --- a/NANOProducer/plugins/NANOProducer.cc +++ b/NANOProducer/plugins/NANOProducer.cc @@ -34,7 +34,11 @@ class NANOProducer : public edm::stream::EDProducer<> { PropertyList globalProperties; PropertyList csvProperties; PropertyList cpfProperties; - + PropertyList npfProperties; + PropertyList svProperties; + PropertyList muonProperties; + PropertyList electronProperties; + private: const edm::EDGetTokenT> _jet_src; const edm::EDGetTokenT> _tag_src; @@ -151,6 +155,198 @@ NANOProducer::NANOProducer(const edm::ParameterSet& iConfig) : PROPERTY(llpdnnx::ChargedCandidateFeatures, dZmin, "doc") }; + + + npfProperties = { + PROPERTY(llpdnnx::NeutralCandidateFeatures, ptrel, "doc"), + PROPERTY(llpdnnx::NeutralCandidateFeatures, deta, "doc"), + PROPERTY(llpdnnx::NeutralCandidateFeatures, dphi, "doc"), + PROPERTY(llpdnnx::NeutralCandidateFeatures, deltaR, "doc"), + + PROPERTY(llpdnnx::NeutralCandidateFeatures, px, "doc"), + PROPERTY(llpdnnx::NeutralCandidateFeatures, py, "doc"), + PROPERTY(llpdnnx::NeutralCandidateFeatures, pz, "doc"), + + PROPERTY(llpdnnx::NeutralCandidateFeatures, isGamma, "doc"), + PROPERTY(llpdnnx::NeutralCandidateFeatures, hcal_fraction, "doc"), + PROPERTY(llpdnnx::NeutralCandidateFeatures, drminsv, "doc"), + PROPERTY(llpdnnx::NeutralCandidateFeatures, puppi_weight, "doc"), + PROPERTY(llpdnnx::NeutralCandidateFeatures, relmassdrop, "doc") + }; + + svProperties = { + PROPERTY(llpdnnx::SecondaryVertexFeatures, ptrel, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, deta, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, dphi, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, deltaR, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, mass, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, ntracks, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, chi2, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, ndof, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, dxy, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, dxysig, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, d3d, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, d3dsig, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, costhetasvpv, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, enratio, "doc") + }; + + muonProperties = { + PROPERTY(llpdnnx::MuonCandidateFeatures, isGlobal, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, isTight, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, isMedium, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, isLoose, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, isStandAlone, "doc"), + + PROPERTY(llpdnnx::MuonCandidateFeatures, ptrel, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, deta, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, dphi, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, px, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, py, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, pz, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, charge, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, energy, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, et, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, deltaR, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, numberOfMatchedStations, "doc"), + + PROPERTY(llpdnnx::MuonCandidateFeatures, IP2d, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, IP2dSig, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, IP3d, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, IP3dSig, "doc"), + + PROPERTY(llpdnnx::MuonCandidateFeatures, EtaRel, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, dxy, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, dxyError, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, dxySig, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, dz, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, dzError, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, dzSig, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, numberOfValidPixelHits, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, numberOfpixelLayersWithMeasurement, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, numberOfstripLayersWithMeasurement, "doc"), //that does not help. needs to be discussed. + + PROPERTY(llpdnnx::MuonCandidateFeatures, chi2, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, ndof, "doc"), + + PROPERTY(llpdnnx::MuonCandidateFeatures, caloIso, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, ecalIso, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, hcalIso, "doc"), + + PROPERTY(llpdnnx::MuonCandidateFeatures, sumPfChHadronPt, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, sumPfNeuHadronEt, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, Pfpileup, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, sumPfPhotonEt, "doc"), + + PROPERTY(llpdnnx::MuonCandidateFeatures, sumPfChHadronPt03, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, sumPfNeuHadronEt03, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, Pfpileup03, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, sumPfPhotonEt03, "doc") + + }; + + + electronProperties = { + PROPERTY(llpdnnx::ElectronCandidateFeatures, ptrel, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures, deltaR, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,deta, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dphi, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,px, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,py, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,pz, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,charge, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,energy, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,EtFromCaloEn, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures, isEB, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures, isEE, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,ecalEnergy, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures, isPassConversionVeto, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,convDist, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures, convFlags, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,convRadius, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,hadronicOverEm, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,ecalDrivenSeed, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,IP2d, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,IP2dSig, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,IP3d, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,IP3dSig, "doc"), + + PROPERTY(llpdnnx::ElectronCandidateFeatures,elecSC_energy, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,elecSC_deta, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,elecSC_dphi, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,elecSC_et, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,elecSC_eSuperClusterOverP, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,scPixCharge, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,superClusterFbrem, "doc"), + + PROPERTY(llpdnnx::ElectronCandidateFeatures,eSeedClusterOverP, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,eSeedClusterOverPout, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,eSuperClusterOverP, "doc"), + + // shower shape + PROPERTY(llpdnnx::ElectronCandidateFeatures,sigmaEtaEta, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,sigmaIetaIeta, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,sigmaIphiIphi, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,e5x5, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,e5x5Rel, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,e1x5Overe5x5, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,e2x5MaxOvere5x5, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,r9, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,hcalOverEcal, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,hcalDepth1OverEcal, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,hcalDepth2OverEcal, "doc"), + + // Track-Cluster Matching Attributes + PROPERTY(llpdnnx::ElectronCandidateFeatures,deltaEtaEleClusterTrackAtCalo, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,deltaEtaSeedClusterTrackAtCalo, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,deltaPhiSeedClusterTrackAtCalo, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,deltaEtaSeedClusterTrackAtVtx, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,deltaEtaSuperClusterTrackAtVtx, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,deltaPhiEleClusterTrackAtCalo, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,deltaPhiSuperClusterTrackAtVtx, "doc"), + + PROPERTY(llpdnnx::ElectronCandidateFeatures,sCseedEta, "doc"), + + // electron gsf variables. + PROPERTY(llpdnnx::ElectronCandidateFeatures,EtaRel, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dxy, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dxyError, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dxySig, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dz, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dzError, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dzSig, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures, nbOfMissingHits, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,gsfCharge, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures, ndof, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,chi2, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures, numberOfBrems, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,trackFbrem, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,fbrem, "doc"), + + // Isolation block + PROPERTY(llpdnnx::ElectronCandidateFeatures,neutralHadronIso, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,particleIso, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,photonIso, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,puChargedHadronIso, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,trackIso, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,ecalPFClusterIso, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,hcalPFClusterIso, "doc"), + + PROPERTY(llpdnnx::ElectronCandidateFeatures,pfSumPhotonEt, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,pfSumChargedHadronPt, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,pfSumNeutralHadronEt, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,pfSumPUPt, "doc"), + + PROPERTY(llpdnnx::ElectronCandidateFeatures,dr04TkSumPt, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dr04EcalRecHitSumEt, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dr04HcalDepth1TowerSumEt, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dr04HcalDepth1TowerSumEtBc, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dr04HcalDepth2TowerSumEt, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dr04HcalDepth2TowerSumEtBc, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dr04HcalTowerSumEt, "doc"), + PROPERTY(llpdnnx::ElectronCandidateFeatures,dr04HcalTowerSumEtBc, "doc") + + }; produces("global"); @@ -161,6 +357,7 @@ NANOProducer::NANOProducer(const edm::ParameterSet& iConfig) : produces("length"); produces("muon") ; produces("electron") ; + } @@ -202,225 +399,15 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) auto csvTable = std::make_unique(ntags, "csv", false, false); - std::vector cpf_trackEtaRel; - std::vector cpf_trackPtRel; - std::vector cpf_trackPPar; - std::vector cpf_trackDeltaR; - std::vector cpf_trackPParRatio; - std::vector cpf_trackPtRatio; - std::vector cpf_trackSip2dVal; - std::vector cpf_trackSip2dSig; - std::vector cpf_trackSip3dVal; - std::vector cpf_trackSip3dSig; - std::vector cpf_trackJetDistVal; - std::vector cpf_trackJetDistSig; - std::vector cpf_ptrel; - std::vector cpf_deta; - std::vector cpf_dphi; - std::vector cpf_deltaR; - std::vector cpf_px; - std::vector cpf_py; - std::vector cpf_pz; - std::vector cpf_drminsv; - std::vector cpf_vertex_association; - std::vector cpf_fromPV; - std::vector cpf_puppi_weight; - std::vector cpf_track_chi2; - std::vector cpf_track_quality; - std::vector cpf_relmassdrop; - std::vector cpf_track_ndof; - std::vector cpf_matchedMuon; - std::vector cpf_matchedElectron; - std::vector cpf_matchedSV; - std::vector cpf_track_numberOfValidPixelHits; - std::vector cpf_track_pixelLayersWithMeasurement; - std::vector cpf_track_numberOfValidStripHits; - std::vector cpf_track_stripLayersWithMeasurement; - std::vector cpf_dZmin; - - std::vector npf_ptrel; - std::vector npf_deta; - std::vector npf_dphi; - std::vector npf_px; - std::vector npf_py; - std::vector npf_pz; - std::vector npf_deltaR; - std::vector npf_isGamma; - std::vector npf_hcal_fraction; - std::vector npf_drminsv; - std::vector npf_puppi_weight; - std::vector npf_relmassdrop; - - std::vector sv_ptrel; - std::vector sv_deta; - std::vector sv_dphi; - std::vector sv_deltaR; - std::vector sv_mass; - std::vector sv_ntracks; - std::vector sv_chi2; - std::vector sv_ndof; - std::vector sv_dxy; - std::vector sv_dxysig; - std::vector sv_d3d; - std::vector sv_d3dsig; - std::vector sv_costhetasvpv; - std::vector sv_enratio; - - std::vector mu_isGlobal ; - std::vector mu_isTight ; - std::vector mu_isMedium ; - std::vector mu_isLoose ; - std::vector mu_isStandAlone ; - - - std::vector mu_ptrel; - std::vector mu_EtaRel; - std::vector mu_deta; - std::vector mu_dphi; - std::vector mu_charge; - std::vector mu_px; - std::vector mu_py; - std::vector mu_pz; - std::vector mu_energy; - std::vector mu_et; - std::vector mu_deltaR; - std::vector mu_numberOfMatchedStations; - - std::vector mu_2dIP; - std::vector mu_2dIPSig; - std::vector mu_3dIP; - std::vector mu_3dIPSig; - - std::vector mu_dxy; - std::vector mu_dxyError; - std::vector mu_dxySig; - std::vector mu_dz; - std::vector mu_dzError; - std::vector mu_dzSig; - std::vector mu_numberOfValidPixelHits; - std::vector mu_numberOfpixelLayersWithMeasurement; - std::vector mu_numberOfstripLayersWithMeasurement ; - - std::vector mu_chi2; - std::vector mu_ndof; - - std::vector mu_caloIso; - std::vector mu_ecalIso; - std::vector mu_hcalIso; - - std::vector mu_sumPfChHadronPt; - std::vector mu_sumPfNeuHadronEt; - std::vector mu_Pfpileup; - std::vector mu_sumPfPhotonEt; - - std::vector mu_sumPfChHadronPt03; - std::vector mu_sumPfNeuHadronEt03; - std::vector mu_Pfpileup03; - std::vector mu_sumPfPhotonEt03; - - - - std::vector mu_timeAtIpInOut; - std::vector mu_timeAtIpInOutErr; - std::vector mu_timeAtIpOutIn; - - - // Electron Block - - std::vector elec_ptrel; - std::vector elec_deltaR; - std::vector elec_deta; - std::vector elec_dphi; - std::vector elec_px; - std::vector elec_py; - std::vector elec_pz; - std::vector elec_charge; - std::vector elec_energy; - std::vector elec_EtFromCaloEn ; - std::vector elec_isEB; - std::vector elec_isEE; - std::vector elec_ecalEnergy; - std::vector elec_isPassConversionVeto; - std::vector elec_convDist; - std::vector elec_convFlags; - - std::vector elec_convRadius; - std::vector elec_hadronicOverEm; - std::vector elec_ecalDrivenSeed; - - std::vector elecSC_energy; - std::vector elecSC_deta; - std::vector elecSC_dphi; - std::vector elecSC_et; - std::vector elecSC_eSuperClusterOverP; - std::vector elec_scPixCharge; - std::vector elec_sigmaEtaEta; - std::vector elec_sigmaIetaIeta; - std::vector elec_sigmaIphiIphi; - std::vector elec_r9; - std::vector elec_superClusterFbrem; - - std::vector elec_2dIP; - std::vector elec_2dIPSig; - std::vector elec_3dIP; - std::vector elec_3dIPSig; - std::vector elec_eSeedClusterOverP; - std::vector elec_eSeedClusterOverPout; - std::vector elec_eSuperClusterOverP; - - std::vector elec_deltaEtaEleClusterTrackAtCalo; - std::vector elec_deltaEtaSeedClusterTrackAtCalo; - std::vector elec_deltaPhiSeedClusterTrackAtCalo; - std::vector elec_deltaEtaSeedClusterTrackAtVtx; - std::vector elec_deltaEtaSuperClusterTrackAtVtx; - std::vector elec_deltaPhiEleClusterTrackAtCalo; - std::vector elec_deltaPhiSuperClusterTrackAtVtx; - std::vector elec_sCseedEta; - - std::vector elec_EtaRel; - std::vector elec_dxy; - std::vector elec_dxyError; - std::vector elec_dxySig; - std::vector elec_dz; - std::vector elec_dzError; - std::vector elec_dzSig; - std::vector elec_nbOfMissingHits; - std::vector elec_gsfCharge; - std::vector elec_ndof; - std::vector elec_chi2; - - std::vector elec_e2x5MaxOvere5x5; - std::vector elec_e1x5Overe5x5; - std::vector elec_e5x5; - std::vector elec_e5x5Rel; - std::vector elec_numberOfBrems; - std::vector elec_fbrem; - std::vector elec_neutralHadronIso; - std::vector elec_particleIso; - std::vector elec_photonIso; - std::vector elec_puChargedHadronIso; - std::vector elec_trackIso; - std::vector elec_hcalDepth1OverEcal; - std::vector elec_hcalDepth2OverEcal; - std::vector elec_ecalPFClusterIso; - std::vector elec_hcalPFClusterIso; - std::vector elec_pfSumPhotonEt; - std::vector elec_pfSumChargedHadronPt; - std::vector elec_pfSumNeutralHadronEt; - std::vector elec_pfSumPUPt; - std::vector elec_dr04TkSumPt; - std::vector elec_dr04EcalRecHitSumEt; - std::vector elec_dr04HcalDepth1TowerSumEt; - std::vector elec_dr04HcalDepth1TowerSumEtBc; - std::vector elec_dr04HcalDepth2TowerSumEt; - std::vector elec_dr04HcalDepth2TowerSumEtBc; - std::vector elec_dr04HcalTowerSumEt; - std::vector elec_dr04HcalTowerSumEtBc; - FlatTableFillerList globalFillerList(globalProperties); FlatTableFillerList csvFillerList(csvProperties); FlatTableFillerList cpfFillerList(cpfProperties); + FlatTableFillerList npfFillerList(npfProperties); + FlatTableFillerList svFillerList(svProperties); + FlatTableFillerList muonFillerList(muonProperties); + FlatTableFillerList electronFillerList(electronProperties); + unsigned int nmu_total = 0; unsigned int nelec_total = 0; @@ -499,408 +486,59 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for (unsigned int i = 0; i < nnpf; i++) { - const auto& npf_features = npf.at(i); - npf_jetIdx.push_back(jetIdx); - npf_ptrel.push_back(npf_features.npf_ptrel); - npf_deta.push_back(npf_features.npf_deta); - npf_dphi.push_back(npf_features.npf_dphi); - npf_px.push_back(npf_features.npf_px); - npf_py.push_back(npf_features.npf_py); - npf_pz.push_back(npf_features.npf_pz); - npf_deltaR.push_back(npf_features.npf_deltaR); - npf_isGamma.push_back(npf_features.npf_isGamma); - npf_hcal_fraction.push_back(npf_features.npf_hcal_fraction); - npf_drminsv.push_back(npf_features.npf_drminsv); - npf_puppi_weight.push_back(npf_features.npf_puppi_weight); - npf_relmassdrop.push_back(npf_features.npf_relmassdrop); + npf_jetIdx.push_back(jetIdx); + npfFillerList.push_back(npf.at(i)); } for (unsigned int i = 0; i < nsv; i++) { - const auto& sv_features = sv.at(i); sv_jetIdx.push_back(jetIdx); - sv_ptrel.push_back(sv_features.sv_ptrel); - sv_deta.push_back(sv_features.sv_deta); - sv_dphi.push_back(sv_features.sv_dphi); - sv_deltaR.push_back(sv_features.sv_deltaR); - sv_mass.push_back(sv_features.sv_mass); - sv_ntracks.push_back(sv_features.sv_ntracks); - sv_chi2.push_back(sv_features.sv_chi2); - sv_ndof.push_back(sv_features.sv_ndof); - sv_dxy.push_back(sv_features.sv_dxy); - sv_dxysig.push_back(sv_features.sv_dxysig); - sv_d3d.push_back(sv_features.sv_d3d); - sv_d3dsig.push_back(sv_features.sv_d3dsig); - sv_costhetasvpv.push_back(sv_features.sv_costhetasvpv); - sv_enratio.push_back(sv_features.sv_enratio); + svFillerList.push_back(sv.at(i)); } for(unsigned int i = 0; i < nmu; i++) { - const auto& mu_features = mu.at(i); mu_jetIdx.push_back(jetIdx); - mu_isGlobal.push_back(mu_features.mu_isGlobal) ; - mu_isTight.push_back(mu_features.mu_isTight) ; - mu_isMedium.push_back(mu_features.mu_isMedium) ; - mu_isLoose.push_back(mu_features.mu_isLoose) ; - mu_isStandAlone.push_back(mu_features.mu_isStandAlone) ; - - - mu_ptrel.push_back(mu_features.mu_ptrel); - mu_EtaRel.push_back(mu_features.mu_EtaRel); - mu_deta.push_back(mu_features.mu_deta); - mu_dphi.push_back(mu_features.mu_dphi); - mu_charge.push_back(mu_features.mu_charge); - mu_px.push_back(mu_features.mu_px); - mu_py.push_back(mu_features.mu_py); - mu_pz.push_back(mu_features.mu_pz); - mu_energy.push_back(mu_features.mu_energy); - mu_et.push_back(mu_features.mu_et); - mu_deltaR.push_back(mu_features.mu_deltaR); - mu_numberOfMatchedStations.push_back(mu_features.mu_numberOfMatchedStations); - - mu_2dIP.push_back(mu_features.mu_2dIP); - mu_2dIPSig.push_back(mu_features.mu_2dIPSig); - mu_3dIP.push_back(mu_features.mu_3dIP); - mu_3dIPSig.push_back(mu_features.mu_3dIPSig); - - mu_dxy.push_back(mu_features.mu_dxy); - mu_dxyError.push_back(mu_features.mu_dxyError); - mu_dxySig.push_back(mu_features.mu_dxySig); - mu_dz.push_back(mu_features.mu_dz); - mu_dzError.push_back(mu_features.mu_dzError); - mu_dzSig.push_back(mu_features.mu_dzSig); - mu_numberOfValidPixelHits.push_back(mu_features.mu_numberOfValidPixelHits); - mu_numberOfpixelLayersWithMeasurement.push_back(mu_features.mu_numberOfpixelLayersWithMeasurement); - mu_numberOfstripLayersWithMeasurement.push_back(mu_features.mu_numberOfstripLayersWithMeasurement); - - - mu_chi2.push_back(mu_features.mu_chi2); - mu_ndof.push_back(mu_features.mu_ndof); - - mu_caloIso.push_back(mu_features.mu_caloIso); - mu_ecalIso.push_back(mu_features.mu_ecalIso); - mu_hcalIso.push_back(mu_features.mu_hcalIso); - - mu_sumPfChHadronPt.push_back(mu_features.mu_sumPfChHadronPt); - mu_sumPfNeuHadronEt.push_back(mu_features.mu_sumPfNeuHadronEt); - mu_Pfpileup.push_back(mu_features.mu_Pfpileup); - mu_sumPfPhotonEt.push_back(mu_features.mu_sumPfPhotonEt); - - mu_sumPfChHadronPt03.push_back(mu_features.mu_sumPfChHadronPt03); - mu_sumPfNeuHadronEt03.push_back(mu_features.mu_sumPfNeuHadronEt03); - mu_Pfpileup03.push_back(mu_features.mu_Pfpileup03); - mu_sumPfPhotonEt03.push_back(mu_features.mu_sumPfPhotonEt03); - - - mu_timeAtIpInOut.push_back(mu_features.mu_timeAtIpInOut) ; - mu_timeAtIpInOutErr.push_back(mu_features.mu_timeAtIpInOutErr) ; - mu_timeAtIpOutIn.push_back(mu_features.mu_timeAtIpOutIn) ; - - + muonFillerList.push_back(mu.at(i)); } for(unsigned int i = 0; i < nelec ; i++) { - - const auto& elec_features = elec.at(i); - elec_jetIdx.push_back(jetIdx); - - elec_ptrel.push_back(elec_features.elec_ptrel ); - elec_deltaR.push_back(elec_features.elec_deltaR ); - elec_deta.push_back(elec_features.elec_deta ); - elec_dphi.push_back(elec_features.elec_dphi ); - elec_px.push_back(elec_features.elec_px ); - elec_py.push_back(elec_features.elec_py ); - elec_pz.push_back(elec_features.elec_pz ); - elec_charge.push_back(elec_features.elec_charge ); - - elec_energy.push_back(elec_features.elec_energy ); - elec_EtFromCaloEn.push_back(elec_features.elec_EtFromCaloEn ); - elec_isEB.push_back(elec_features.elec_isEB ); - elec_isEE.push_back(elec_features.elec_isEE ); - elec_ecalEnergy.push_back(elec_features.elec_ecalEnergy ); - elec_isPassConversionVeto.push_back(elec_features.elec_isPassConversionVeto ); - elec_convDist.push_back(elec_features.elec_convDist ); - elec_convFlags.push_back(elec_features.elec_convFlags ); - - elec_convRadius.push_back(elec_features.elec_convRadius ); - elec_hadronicOverEm.push_back(elec_features.elec_hadronicOverEm ); - elec_ecalDrivenSeed.push_back(elec_features.elec_ecalDrivenSeed ); - - - elecSC_energy.push_back(elec_features.elecSC_energy ); - elecSC_deta.push_back(elec_features.elecSC_deta ); - elecSC_dphi.push_back(elec_features.elecSC_dphi ); - elecSC_et.push_back(elec_features.elecSC_et ); - elecSC_eSuperClusterOverP.push_back(elec_features.elecSC_eSuperClusterOverP ); - - elec_scPixCharge.push_back(elec_features.elec_scPixCharge ); - elec_sigmaEtaEta.push_back(elec_features.elec_sigmaEtaEta ); - elec_sigmaIetaIeta.push_back(elec_features.elec_sigmaIetaIeta ); - elec_sigmaIphiIphi.push_back(elec_features.elec_sigmaIphiIphi ); - elec_r9.push_back(elec_features.elec_r9 ); - elec_superClusterFbrem.push_back(elec_features.elec_superClusterFbrem ); - - elec_2dIP.push_back(elec_features.elec_2dIP ); - elec_2dIPSig.push_back(elec_features.elec_2dIPSig ); - elec_3dIP.push_back(elec_features.elec_3dIP ); - elec_3dIPSig.push_back(elec_features.elec_3dIPSig ); - elec_eSeedClusterOverP.push_back(elec_features.elec_eSeedClusterOverP ); - elec_eSeedClusterOverPout.push_back(elec_features.elec_eSeedClusterOverPout ); - elec_eSuperClusterOverP.push_back(elec_features.elec_eSuperClusterOverP ); - - elec_deltaEtaEleClusterTrackAtCalo.push_back(elec_features.elec_deltaEtaEleClusterTrackAtCalo ); - elec_deltaEtaSeedClusterTrackAtCalo.push_back(elec_features.elec_deltaEtaSeedClusterTrackAtCalo ); - elec_deltaPhiSeedClusterTrackAtCalo.push_back(elec_features.elec_deltaPhiSeedClusterTrackAtCalo ); - elec_deltaEtaSeedClusterTrackAtVtx.push_back(elec_features.elec_deltaEtaSeedClusterTrackAtVtx ); - elec_deltaEtaSuperClusterTrackAtVtx.push_back(elec_features.elec_deltaEtaSuperClusterTrackAtVtx ); - elec_deltaPhiEleClusterTrackAtCalo.push_back(elec_features.elec_deltaPhiEleClusterTrackAtCalo ); - elec_deltaPhiSuperClusterTrackAtVtx.push_back(elec_features.elec_deltaPhiSuperClusterTrackAtVtx ); - elec_sCseedEta.push_back(elec_features.elec_sCseedEta ); - - - elec_EtaRel.push_back(elec_features.elec_EtaRel ); - elec_dxy.push_back(elec_features.elec_dxy ); - elec_dxyError.push_back(elec_features.elec_dxyError); - elec_dxySig.push_back(elec_features.elec_dxySig); - elec_dz.push_back(elec_features.elec_dz ); - elec_dzError.push_back(elec_features.elec_dzError); - elec_dzSig.push_back(elec_features.elec_dzSig); - elec_nbOfMissingHits.push_back(elec_features.elec_nbOfMissingHits ); - elec_gsfCharge.push_back(elec_features.elec_gsfCharge ); - elec_ndof.push_back(elec_features.elec_ndof ); - elec_chi2.push_back(elec_features.elec_chi2 ); - elec_numberOfBrems.push_back(elec_features.elec_numberOfBrems ); - elec_fbrem.push_back(elec_features.elec_fbrem ); - elec_e2x5MaxOvere5x5.push_back(elec_features.elec_e2x5MaxOvere5x5 ); - elec_e1x5Overe5x5.push_back(elec_features.elec_e1x5Overe5x5 ); - elec_e5x5.push_back(elec_features.elec_e5x5 ); - elec_e5x5Rel.push_back(elec_features.elec_e5x5Rel ); - elec_neutralHadronIso.push_back(elec_features.elec_neutralHadronIso ); - elec_particleIso .push_back(elec_features.elec_particleIso ); - elec_photonIso.push_back(elec_features.elec_photonIso ); - elec_puChargedHadronIso.push_back(elec_features.elec_puChargedHadronIso ); - elec_trackIso.push_back(elec_features.elec_trackIso ); - elec_hcalDepth1OverEcal.push_back(elec_features.elec_hcalDepth1OverEcal ); - elec_hcalDepth2OverEcal.push_back(elec_features.elec_hcalDepth2OverEcal ); - elec_ecalPFClusterIso.push_back(elec_features.elec_ecalPFClusterIso ); - elec_hcalPFClusterIso.push_back(elec_features.elec_hcalPFClusterIso ); - elec_pfSumPhotonEt.push_back(elec_features.elec_pfSumPhotonEt ); - elec_pfSumChargedHadronPt.push_back(elec_features.elec_pfSumChargedHadronPt ); - elec_pfSumNeutralHadronEt.push_back(elec_features.elec_pfSumNeutralHadronEt ); - elec_pfSumPUPt.push_back(elec_features.elec_pfSumPUPt ); - elec_dr04TkSumPt.push_back(elec_features.elec_dr04TkSumPt ); - elec_dr04EcalRecHitSumEt.push_back(elec_features.elec_dr04EcalRecHitSumEt ); - elec_dr04HcalDepth1TowerSumEt.push_back(elec_features.elec_dr04HcalDepth1TowerSumEt ); - elec_dr04HcalDepth1TowerSumEtBc.push_back(elec_features.elec_dr04HcalDepth1TowerSumEtBc ); - elec_dr04HcalDepth2TowerSumEt.push_back(elec_features.elec_dr04HcalDepth2TowerSumEt ); - elec_dr04HcalDepth2TowerSumEtBc.push_back(elec_features.elec_dr04HcalDepth2TowerSumEtBc ); - elec_dr04HcalTowerSumEt.push_back(elec_features.elec_dr04HcalTowerSumEt ); - elec_dr04HcalTowerSumEtBc.push_back(elec_features.elec_dr04HcalTowerSumEtBc ); - - + electronFillerList.push_back(elec.at(i)); } } - globalTable->addColumn("jetIdx", global_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); + + lengthTable->addColumn("cpf", cpf_length, "charged PF candidate track offset", nanoaod::FlatTable::IntColumn); + lengthTable->addColumn("npf", npf_length, "neutral PF candidate offset", nanoaod::FlatTable::IntColumn); + lengthTable->addColumn("sv", sv_length, "secondary vertex (SV) offset", nanoaod::FlatTable::IntColumn); + lengthTable->addColumn("mu", mu_length, "muon offset", nanoaod::FlatTable::IntColumn); + lengthTable->addColumn("ele", elec_length, "electron offset", nanoaod::FlatTable::IntColumn); + + + globalTable->addColumn("jetIdx", global_jetIdx, "linked jet Idx", nanoaod::FlatTable::IntColumn); globalFillerList.fill(globalTable); - csvTable->addColumn("jetIdx", csv_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); + csvTable->addColumn("jetIdx", csv_jetIdx, "linked jet Idx", nanoaod::FlatTable::IntColumn); csvFillerList.fill(csvTable); - cpfTable->addColumn("jetIdx", cpf_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); + cpfTable->addColumn("jetIdx", cpf_jetIdx, "linked jet Idx", nanoaod::FlatTable::IntColumn); cpfFillerList.fill(cpfTable); - npfTable->addColumn("jetIdx", npf_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); - npfTable->addColumn("ptrel", npf_ptrel, "neutral PF candidate transverse momentum over jet transverse momentum (uncorrelated)", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("deta", npf_deta, "absolute difference between the neutral PF candidate eta and jet eta", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("dphi", npf_dphi, "absolute difference between the neutral PF candidate phi and jet phi", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("deltaR", npf_deltaR, "neutral PF candidate pseudoangular distance (Delta R) from the jet axis", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("isGamma", npf_isGamma, "flag for passing loose photon identification requirements", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("hcal_fraction", npf_hcal_fraction, "fraction of energy deposited in the hadronic calorimeter", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("drminsv", npf_drminsv, "pseudoangular distance (Delta R) between neutral PF candidate and closest secondary vertex (SV) within the jet", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("puppi_weight", npf_puppi_weight, "weight assigned by the PUPPI algorithm to neutral PF candidate", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("relmassdrop", npf_relmassdrop, "neutral PF candidate mass drop normalized relative to the jet", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("px", npf_px, "px", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("py", npf_py, "py", nanoaod::FlatTable::FloatColumn); - npfTable->addColumn("pz", npf_pz, "pz", nanoaod::FlatTable::FloatColumn); - - svTable->addColumn("jetIdx", sv_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); - svTable->addColumn("ptrel", sv_ptrel, "secondary vertex (SV) transverse momentum relative to the uncorrected jet energy pt", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("deta", sv_deta, "absolute difference between the secondary vertex (SV) eta and jet eta", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("dphi", sv_dphi, "absolute difference between the secondary vertex (SV) phi and jet phi", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("deltaR", sv_deltaR, "pseudoangular distance (Delta R) between jet axis and SV flight direction", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("mass", sv_mass, "invariant mass of reconstructed secondary vertex (SV)", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("ntracks", sv_ntracks, "number of tracks associated to the secondary vertex (SV)", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("chi2", sv_chi2, "chi^2 of secondary vertex (SV)", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("ndof", sv_ndof, "number of degrees of freedom of secondary vertex (SV) fit", nanoaod::FlatTable::IntColumn); - svTable->addColumn("dxy", sv_dxy, "transverse impact parameter of the secondary vertex (SV)", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("dxysig", sv_dxysig, "transverse impact parameter significance of the secondary vertex (SV)", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("d3d", sv_d3d, "3D impact parameter of secondary vertex (SV)", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("d3dsig", sv_d3dsig, "3D impact parameter significance of secondary vertex (SV)", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("costhetasvpv", sv_costhetasvpv, "cos(theta) of the secondary vertex (SV) with respect to the primary vertex (PV)", nanoaod::FlatTable::FloatColumn); - svTable->addColumn("enratio", sv_enratio, "ratio of secondary vertex (SV) energy with respect to the jet", nanoaod::FlatTable::FloatColumn); + npfTable->addColumn("jetIdx", npf_jetIdx, "linked jet Idx", nanoaod::FlatTable::IntColumn); + npfFillerList.fill(npfTable); - lengthTable->addColumn("cpf", cpf_length, "charged PF candidate track offset", nanoaod::FlatTable::IntColumn); - lengthTable->addColumn("npf", npf_length, "neutral PF candidate offset", nanoaod::FlatTable::IntColumn); - lengthTable->addColumn("sv", sv_length, "secondary vertex (SV) offset", nanoaod::FlatTable::IntColumn); - lengthTable->addColumn("mu", mu_length, "muon offset", nanoaod::FlatTable::IntColumn); - lengthTable->addColumn("ele", elec_length, "electron offset", nanoaod::FlatTable::IntColumn); + svTable->addColumn("jetIdx", sv_jetIdx, "linked jet Idx", nanoaod::FlatTable::IntColumn); + svFillerList.fill(svTable); - muonTable->addColumn("jetIdx", mu_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); - - muonTable->addColumn("isGlobal",mu_isGlobal,"muon fitted from the tracker and muon stations",nanoaod::FlatTable::IntColumn); - muonTable->addColumn("isTight",mu_isTight,"global muon with additional muon-quality requirements.Tight Muon ID selects a subset of the Particle-Flow muons",nanoaod::FlatTable::IntColumn); - muonTable->addColumn("isMedium",mu_isMedium,"loose muon (i.e. PF muon that is either a global or an arbitrated tracker muon) with additional track-quality and muon-quality requirements.",nanoaod::FlatTable::IntColumn); - muonTable->addColumn("isLoose",mu_isLoose,"particle identified as a muon by the Particle-Flow event reconstruction, and that is also reconstructed either as a global-muon or as an arbitrated tracker-muon.",nanoaod::FlatTable::IntColumn); - muonTable->addColumn("isStandAlone",mu_isStandAlone,"particle identified as a muon by the Particle-Flow event reconstruction reconstructed only in the muon chambers", nanoaod::FlatTable::IntColumn); - - muonTable->addColumn("ptrel",mu_ptrel,"muon candidate transverse momentum relative to the uncorrected jet energy pt",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("EtaRel",mu_EtaRel,"muon candidate pseudorapidity, relative to the jet axis",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("dphi",mu_dphi,"absolute difference between the muon candidate phi and jet phi",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("deta",mu_deta,"absolute difference between the muon candidate eta and jet eta",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("px", mu_px, "px", nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("py", mu_py, "py", nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("pz", mu_pz, "pz", nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("charge",mu_charge,"muon candidate charge (-1 or +1)",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("energy",mu_energy,"muon candidate energy",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("deltaR",mu_deltaR,"pseudoangular distance between jet axis and muon track fourvector",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("numberOfMatchedStations",mu_numberOfMatchedStations,"number of activated muon stations",nanoaod::FlatTable::FloatColumn); - - muonTable->addColumn("2dIP",mu_2dIP,"muon inner track transverse impact parameter relative to the primary vertex in transverse plane (2D), absolute value",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("2dIPSig",mu_2dIPSig,"muon inner track transverse impact parameter relative to the primary vertex relative to its uncertainty in transverse plane (2D)",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("3dIP",mu_3dIP,"muon inner track transverse impact parameter relative to the primary vertex in 3D",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("3dIPSig",mu_3dIPSig,"muon inner track transverse impact parameter relative to the primary vertex relative to its uncertainty in 3D",nanoaod::FlatTable::FloatColumn); - -// Adding new documentation - muonTable->addColumn("dxy",mu_dxy,"transverse impact parameter of the best reconstructed muon track",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("dxyError",mu_dxyError,"error on transverse impact parameter of the best reconstructed muon track",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("dxySig",mu_dxySig,"significance of the transverse impact parameter of the best reconstructed muon track",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("dz",mu_dz,"longitudinal impact parameter of the best reconstructed muon track",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("dzError",mu_dzError,"error on the longitudinal impact parameter of the best reconstructed muon track",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("dzSig",mu_dzSig,"significance on the longitudinal impact parameter of the best reconstructed muon track",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("numberOfValidPixelHits",mu_numberOfValidPixelHits,"number of pixel hits by the muon track to further suppress muons from decays in flight",nanoaod::FlatTable::IntColumn); - muonTable->addColumn("numberOfpixelLayersWithMeasurement",mu_numberOfpixelLayersWithMeasurement,"number of pixel layers with valid hits by the muon track",nanoaod::FlatTable::IntColumn); - muonTable->addColumn("numberOfstripLayersWithMeasurement",mu_numberOfstripLayersWithMeasurement,"doc",nanoaod::FlatTable::IntColumn); - - muonTable->addColumn("chi2",mu_chi2,"chi^2 of muon track",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("ndof",mu_ndof,"number of degrees of freedom of muon track fit",nanoaod::FlatTable::IntColumn); - - muonTable->addColumn("caloIso",mu_caloIso,"returns the fraction of the summed transverse energy of the muon track recHits in the ECAL & HCAL in a cone of deltaR<0.3 normalized against its transverse momentum",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("ecalIso",mu_ecalIso,"returns the fraction of the transverse energy of the muon track recHits in the ECAL normalized against its transverse momentum",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("hcalIso",mu_hcalIso,"returns the fraction of the transverse energy of the muon track recHits in the HCAL normalized against its transverse momentum",nanoaod::FlatTable::FloatColumn); - - muonTable->addColumn("sumPfChHadronPt",mu_sumPfChHadronPt,"summed pt of charged hadron normalized against the muon's pt (PF based isolation of cone of 0.4 - Suggested)",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("sumPfNeuHadronEt",mu_sumPfNeuHadronEt,"summed pt of neutral hadron normalized against the muon's pt (PF based isolation of cone of 0.4 - Suggested)",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("Pfpileup",mu_Pfpileup,"summed pt of charged particles not from PV (for PU corrections) normalized against the muon's pt (PF based isolation of cone of 0.4 - Suggested)",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("sumPfPhotonEt",mu_sumPfPhotonEt,"summed pt of PF photons normalized against the muon's pt (PF based isolation of cone of 0.4 - Suggested)",nanoaod::FlatTable::FloatColumn); - - muonTable->addColumn("sumPfChHadronPt03",mu_sumPfChHadronPt03,"summed pt of charged hadron normalized against the muon's pt (PF based isolation of cone of 0.3)",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("sumPfNeuHadronEt03",mu_sumPfNeuHadronEt03,"summed pt of neutral hadron normalized against the muon's pt (PF based isolation of cone of 0.3)",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("Pfpileup03",mu_Pfpileup03,"summed pt of charged particles not from PV (for PU corrections) normalized against the muon's pt (PF based isolation of cone of 0.3)",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("sumPfPhotonEt03",mu_sumPfPhotonEt03,"summed pt of PF photons normalized against the muon's pt (PF based isolation of cone of 0.3)",nanoaod::FlatTable::FloatColumn); - - muonTable->addColumn("timeAtIpInOut",mu_timeAtIpInOut,"the time at the interaction point for muons moving inside-out",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("timeAtIpInOutErr",mu_timeAtIpInOutErr,"error on the time at the interaction point for muons moving inside-out",nanoaod::FlatTable::FloatColumn); - muonTable->addColumn("timeAtIpOutIn",mu_timeAtIpOutIn,"The time at the interaction point for muons moving outside-in",nanoaod::FlatTable::FloatColumn); - - electronTable->addColumn("jetIdx", elec_jetIdx, "linked jet Id", nanoaod::FlatTable::IntColumn); - electronTable->addColumn("ptrel",elec_ptrel,"electron candidate transverse momentum relative to the uncorrected jet energy pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("deltaR",elec_deltaR,"pseudoangular distance between jet axis and electron track fourvector",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("deta",elec_deta,"absolute difference between the electron candidate eta and jet eta",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dphi",elec_dphi,"absolute difference between the electron candidate phi and jet phi",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("px", elec_px, "px", nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("py", elec_py, "py", nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("pz", elec_pz, "pz", nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("charge",elec_charge,"electron candidate charge (-1 or +1)",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("energy",elec_energy,"electron candidate energy",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("EtFromCaloEn",elec_EtFromCaloEn,"electron transverse energy from calorimeters",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("isEB",elec_isEB,"electron energy deposited in the ECAL barrel",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("isEE",elec_isEE,"electron energy deposited in the ECAL endcap",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("ecalEnergy",elec_ecalEnergy,"electron energy deposited in the ECAL normalized against the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("isPassConversionVeto",elec_isPassConversionVeto,"vertex fit combined with missing number of hits method",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("convDist",elec_convDist,"minimum distance between conversion tracks",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("convFlags",elec_convFlags,"flag for electron coming from photon conversion",nanoaod::FlatTable::IntColumn); - - electronTable->addColumn("convRadius",elec_convRadius,"electron conversion radius",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("hadronicOverEm",elec_hadronicOverEm,"sum of hcal over ecal seed cluster energy using 1st and 2nd hcal depth (using hcal towers within a cone)",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("ecalDrivenSeed",elec_ecalDrivenSeed,"ECAL driven seed",nanoaod::FlatTable::FloatColumn); - - - electronTable->addColumn("SC_energy",elecSC_energy,"electron supercluster energy normalized against the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("SC_deta",elecSC_deta,"absolute difference between the electron supercluster eta and gsfTrack electron eta",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("SC_dphi",elecSC_dphi,"absolute difference between the electron supercluster phi and gsfTrack electron phi",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("SC_et",elecSC_et,"electron supercluster transverse energy normalized against the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("SC_eSuperClusterOverP",elecSC_eSuperClusterOverP,"the electron supercluster energy / track momentum at the PCA to the beam spot",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("scPixCharge",elec_scPixCharge,"electron supercluster pixel charge",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("sigmaEtaEta",elec_sigmaEtaEta,"electron supercluster Sigma Eta Eta variable (quite unintuitive)",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("sigmaIetaIeta",elec_sigmaIetaIeta,"electron supercluster Sigma iEta iEta variable (improved variable against Sigma Eta Eta to resolv issues in cracks)",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("sigmaIphiIphi",elec_sigmaIphiIphi,"electron supercluster Sigma iphi iphi variable",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("r9",elec_r9,"electron supercluster r9 variable",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("superClusterFbrem",elec_superClusterFbrem,"the brem fraction from supercluster: (supercluster energy - electron cluster energy) / supercluster energy",nanoaod::FlatTable::FloatColumn); - - electronTable->addColumn("2dIP",elec_2dIP,"electron inner track transverse impact parameter relative to the primary vertex in transverse plane (2D), absolute value",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("2dIPSig",elec_2dIPSig,"electron inner track transverse impact parameter relative to the primary vertex relative to its uncertainty in transverse plane (2D)",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("3dIP",elec_3dIP,"electron inner track transverse impact parameter relative to the primary vertex in 3D",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("3dIPSig",elec_3dIPSig,"electron inner track transverse impact parameter relative to the primary vertex relative to its uncertainty in 3D",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("eSeedClusterOverP",elec_eSeedClusterOverP,"the seed cluster energy / track momentum at the PCA to the beam spot",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("eSeedClusterOverPout",elec_eSeedClusterOverPout,"the seed cluster energy / track momentum at calo extrapolated from the outermost track state",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("eSuperClusterOverP",elec_eSuperClusterOverP,"the supercluster energy / track momentum at the PCA to the beam spot",nanoaod::FlatTable::FloatColumn); - - electronTable->addColumn("deltaEtaEleClusterTrackAtCalo",elec_deltaEtaEleClusterTrackAtCalo,"doc",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("deltaEtaSeedClusterTrackAtCalo",elec_deltaEtaSeedClusterTrackAtCalo,"doc",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("deltaPhiSeedClusterTrackAtCalo",elec_deltaPhiSeedClusterTrackAtCalo,"doc",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("deltaEtaSeedClusterTrackAtVtx",elec_deltaEtaSeedClusterTrackAtVtx,"doc",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("deltaEtaSuperClusterTrackAtVtx",elec_deltaEtaSuperClusterTrackAtVtx,"doc",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("deltaPhiEleClusterTrackAtCalo",elec_deltaPhiEleClusterTrackAtCalo,"doc",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("deltaPhiSuperClusterTrackAtVtx",elec_deltaPhiSuperClusterTrackAtVtx,"doc",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("sCseedEta",elec_sCseedEta,"doc",nanoaod::FlatTable::FloatColumn); - - electronTable->addColumn("EtaRel",elec_EtaRel,"electron pseudorapidity, relative to the jet axis",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dxy",elec_dxy,"transverse impact parameter of the electron",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dxyError",elec_dxyError,"error on transverse impact parameter of the electron",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dxySig",elec_dxySig,"significance of transverse impact parameter of the electron",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dz",elec_dz,"longitudinal impact parameter of the best reconstructed electron track",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dzError",elec_dzError,"error on longitudinal impact parameter of the best reconstructed electron track",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dzSig",elec_dzSig,"significance of longitudinal impact parameter of the best reconstructed electron track",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("nbOfMissingHits",elec_nbOfMissingHits,"number of missing electron hits in its hit pattern",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("gsfCharge",elec_gsfCharge,"gsf electron charge",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("ndof",elec_ndof,"gsf electron number degree of freedom",nanoaod::FlatTable::IntColumn); - electronTable->addColumn("chi2",elec_chi2,"chi2 of the fit ",nanoaod::FlatTable::FloatColumn); - - electronTable->addColumn("numberOfBrems",elec_numberOfBrems,"number of Bremsstrahlung electrons in a shower",nanoaod::FlatTable::IntColumn); - electronTable->addColumn("fbrem",elec_fbrem,"doc",nanoaod::FlatTable::FloatColumn); - - electronTable->addColumn("e5x5",elec_e5x5,"electron energy in 5x5 ECAL block on seed",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("e5x5Rel",elec_e5x5Rel,"electron energy in 5x5 ECAL block on seed relative to the jet pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("e2x5MaxOvere5x5",elec_e2x5MaxOvere5x5,"electron energy ratio of highest energy 2x5 ECAL block containing seed over total energy in 5x5 block on seed",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("e1x5Overe5x5",elec_e1x5Overe5x5,"electron energy ratio of highest energy 1x5 ECAL block containing seed over total energy in 5x5 block on seed",nanoaod::FlatTable::FloatColumn); - - electronTable->addColumn("neutralHadronIso",elec_neutralHadronIso,"returns the isolation calculated with only the neutral hadron PFCandidates relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("particleIso",elec_particleIso,"returns the isolation calculated with all the PFCandidates relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("photonIso",elec_photonIso,"returns the isolation calculated with only the gamma PFCandidates relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("puChargedHadronIso",elec_puChargedHadronIso,"returns the isolation calculated with only the pile-up charged hadron PFCandidates relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("trackIso",elec_trackIso,"returns the tracker isolation variable that was stored in this object when produced, or -1.0 if there is none, relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("hcalDepth1OverEcal",elec_hcalDepth1OverEcal,"HCAL over ECAL seed cluster energy using 1st HCAL depth (using HCAL towers within a cone)",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("hcalDepth2OverEcal",elec_hcalDepth2OverEcal,"HCAL over ECAL seed cluster energy using 2nd HCAL depth (using HCAL towers within a cone)",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("ecalPFClusterIso",elec_ecalPFClusterIso,"sum pt of isolated ECAL clusters, vetoing clusters part of electron",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("hcalPFClusterIso",elec_hcalPFClusterIso,"sum pt of isolated HCAL clusters, vetoing clusters part of electron",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("pfSumPhotonEt",elec_pfSumPhotonEt,"sum pt of PF photons // old float photonIso, relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("pfSumChargedHadronPt",elec_pfSumChargedHadronPt,"sum pt of charged hadron // old float chargedHadronIso, relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("pfSumNeutralHadronEt",elec_pfSumNeutralHadronEt,"sum transverse energy of neutral hadron // old float neutralHadronIso, relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("pfSumPUPt",elec_pfSumPUPt,"sum pt of charged particles not from PV (for PU corrections) ",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dr04TkSumPt",elec_dr04TkSumPt,"track iso deposit with electron footprint removed relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dr04EcalRecHitSumEt",elec_dr04EcalRecHitSumEt,"ECAL iso deposit with electron footprint removed relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dr04HcalDepth1TowerSumEt",elec_dr04HcalDepth1TowerSumEt,"HCAL depth 1 iso deposit with electron footprint removed relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dr04HcalDepth1TowerSumEtBc",elec_dr04HcalDepth1TowerSumEtBc,"HCAL depth 1 iso deposit without towers behind cluster relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dr04HcalDepth2TowerSumEt",elec_dr04HcalDepth2TowerSumEt,"HCAL depth 2 iso deposit with towers behind cluster relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dr04HcalDepth2TowerSumEtBc",elec_dr04HcalDepth2TowerSumEtBc,"HCAL depth 2 iso deposit without towers behind cluster relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dr04HcalTowerSumEt",elec_dr04HcalTowerSumEt,"HCAL depth 1+2 iso deposit with towers behind cluster relative to the electron pt",nanoaod::FlatTable::FloatColumn); - electronTable->addColumn("dr04HcalTowerSumEtBc",elec_dr04HcalTowerSumEtBc,"HCAL depth 1+2 iso deposit without towers behind cluster relative to the electron pt",nanoaod::FlatTable::FloatColumn); + muonTable->addColumn("jetIdx", mu_jetIdx, "linked jet Idx", nanoaod::FlatTable::IntColumn); + muonFillerList.fill(muonTable); + electronTable->addColumn("jetIdx", elec_jetIdx, "linked jet Idx", nanoaod::FlatTable::IntColumn); + electronFillerList.fill(electronTable); + iEvent.put(std::move(globalTable), "global"); iEvent.put(std::move(csvTable), "csv"); iEvent.put(std::move(cpfTable), "cpf"); diff --git a/XTagInfoProducer/plugins/XTagInfoProducer.cc b/XTagInfoProducer/plugins/XTagInfoProducer.cc index 11f2fb4..1c23e21 100644 --- a/XTagInfoProducer/plugins/XTagInfoProducer.cc +++ b/XTagInfoProducer/plugins/XTagInfoProducer.cc @@ -286,14 +286,14 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) llpdnnx::SecondaryVertexFeatures sv_features; - sv_features.sv_ptrel = sv.pt()/uncorrectedPt; - sv_features.sv_deta = sv.eta()-jet.eta(); - sv_features.sv_dphi = reco::deltaPhi(sv.phi(),jet.phi()); - sv_features.sv_deltaR = reco::deltaR(sv,jet); - sv_features.sv_mass = sv.mass(); - sv_features.sv_ntracks = sv.numberOfDaughters(); - sv_features.sv_chi2 = sv.vertexChi2(); - sv_features.sv_ndof = sv.vertexNdof(); + sv_features.ptrel = sv.pt()/uncorrectedPt; + sv_features.deta = sv.eta()-jet.eta(); + sv_features.dphi = reco::deltaPhi(sv.phi(),jet.phi()); + sv_features.deltaR = reco::deltaR(sv,jet); + sv_features.mass = sv.mass(); + sv_features.ntracks = sv.numberOfDaughters(); + sv_features.chi2 = sv.vertexChi2(); + sv_features.ndof = sv.vertexNdof(); reco::Vertex::CovarianceMatrix covsv; @@ -302,32 +302,29 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) VertexDistanceXY distXY; Measurement1D distanceXY = distXY.distance(svtx, pv); - sv_features.sv_dxy = distanceXY.value(); - sv_features.sv_dxysig = distanceXY.value()/distanceXY.error(); + sv_features.dxy = distanceXY.value(); + sv_features.dxysig = distanceXY.value()/distanceXY.error(); VertexDistance3D dist3D; Measurement1D distance3D = dist3D.distance(svtx, pv); - sv_features.sv_d3d = distance3D.value(); - sv_features.sv_d3dsig = distance3D.value()/distance3D.error(); + sv_features.d3d = distance3D.value(); + sv_features.d3dsig = distance3D.value()/distance3D.error(); - if (std::isnan(sv_features.sv_dxysig) || std::isnan(sv_features.sv_d3dsig)) + if (std::isnan(sv_features.dxysig) || std::isnan(sv_features.d3dsig)) { - sv_features.sv_dxysig = 0.; - sv_features.sv_d3dsig = 0.; + sv_features.dxysig = 0.; + sv_features.d3dsig = 0.; } reco::Candidate::Vector distance(sv.vx() - pv.x(), sv.vy() - pv.y(), sv.vz() - pv.z()); - sv_features.sv_costhetasvpv = sv.momentum().Unit().Dot(distance.Unit()); - sv_features.sv_enratio = sv.energy()/jet.pt(); + sv_features.costhetasvpv = sv.momentum().Unit().Dot(distance.Unit()); + sv_features.enratio = sv.energy()/jet.pt(); features.sv_features.emplace_back(sv_features); } - std::stable_sort(features.sv_features.begin(),features.sv_features.end(),[](const auto& d1, const auto& d2) - { - return d1.sv_dxysig>d2.sv_dxysig; //sort decreasing - }); + std::stable_sort(features.sv_features.begin(),features.sv_features.end()); // Fill cpf info @@ -448,88 +445,78 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) if (not muon.isGlobalMuon() || reco::deltaR(muon, jet) > 0.4) continue; cpf_features.matchedMuon = 1; - mu_features.mu_isGlobal = muon.isGlobalMuon(); - mu_features.mu_isTight = muon.isTightMuon(pv); - mu_features.mu_isMedium = muon.isMediumMuon(); - mu_features.mu_isLoose = muon.isLooseMuon(); - mu_features.mu_isStandAlone = muon.isStandAloneMuon(); - - mu_features.mu_ptrel = muon.pt()/uncorrectedPt; - mu_features.mu_deta = muon.eta()-jet.eta(); - mu_features.mu_dphi = reco::deltaPhi(muon.phi(),jet.phi()); - mu_features.mu_px = muon.px(); - mu_features.mu_py = muon.py(); - mu_features.mu_pz = muon.pz(); - mu_features.mu_charge = muon.charge(); - mu_features.mu_energy = muon.energy()/muon.pt(); - mu_features.mu_et = muon.et(); - mu_features.mu_deltaR = reco::deltaR(muon, jet); - mu_features.mu_numberOfMatchedStations = muon.numberOfMatchedStations(); - - mu_features.mu_2dIP = muon.dB(); - mu_features.mu_2dIPSig = muon.dB()/muon.edB(); - mu_features.mu_3dIP = muon.dB(pat::Muon::PV3D); - mu_features.mu_3dIPSig = muon.dB(pat::Muon::PV3D)/muon.edB(pat::Muon::PV3D); - - if (std::isnan(mu_features.mu_2dIPSig) || std::isnan(mu_features.mu_3dIPSig)) + mu_features.isGlobal = muon.isGlobalMuon(); + mu_features.isTight = muon.isTightMuon(pv); + mu_features.isMedium = muon.isMediumMuon(); + mu_features.isLoose = muon.isLooseMuon(); + mu_features.isStandAlone = muon.isStandAloneMuon(); + + mu_features.ptrel = muon.pt()/uncorrectedPt; + mu_features.deta = muon.eta()-jet.eta(); + mu_features.dphi = reco::deltaPhi(muon.phi(),jet.phi()); + mu_features.px = muon.px(); + mu_features.py = muon.py(); + mu_features.pz = muon.pz(); + mu_features.charge = muon.charge(); + mu_features.energy = muon.energy()/muon.pt(); + mu_features.et = muon.et(); + mu_features.deltaR = reco::deltaR(muon, jet); + mu_features.numberOfMatchedStations = muon.numberOfMatchedStations(); + + mu_features.IP2d = muon.dB(); + mu_features.IP2dSig = muon.dB()/muon.edB(); + mu_features.IP3d = muon.dB(pat::Muon::PV3D); + mu_features.IP3dSig = muon.dB(pat::Muon::PV3D)/muon.edB(pat::Muon::PV3D); + + if (std::isnan(mu_features.IP2dSig) || std::isnan(mu_features.IP3dSig)) { - mu_features.mu_2dIPSig = 0.; - mu_features.mu_3dIPSig = 0.; + mu_features.IP2dSig = 0.; + mu_features.IP3dSig = 0.; } reco::Candidate::Vector muonMom = muon.bestTrack()->momentum(); - mu_features.mu_EtaRel =reco::btau::etaRel(jetDir, muonMom); - mu_features.mu_dxy = muon.bestTrack()->dxy(pv.position()); - mu_features.mu_dxyError = muon.bestTrack()->dxyError(); - mu_features.mu_dxySig = muon.bestTrack()->dxy(pv.position())/(1e-10+std::fabs(muon.bestTrack()->dxyError())); - mu_features.mu_dz = muon.bestTrack()->dz(pv.position()); - mu_features.mu_dzError = muon.bestTrack()->dzError(); - mu_features.mu_dzSig = muon.bestTrack()->dz(pv.position())/(1e-10+std::fabs(muon.bestTrack()->dzError())); - mu_features.mu_numberOfValidPixelHits = muon.bestTrack()->hitPattern().numberOfValidPixelHits(); - mu_features.mu_numberOfpixelLayersWithMeasurement = muon.bestTrack()->hitPattern().pixelLayersWithMeasurement(); - mu_features.mu_numberOfstripLayersWithMeasurement = muon.bestTrack()->hitPattern().stripLayersWithMeasurement(); + mu_features.EtaRel =reco::btau::etaRel(jetDir, muonMom); + mu_features.dxy = muon.bestTrack()->dxy(pv.position()); + mu_features.dxyError = muon.bestTrack()->dxyError(); + mu_features.dxySig = muon.bestTrack()->dxy(pv.position())/(1e-10+std::fabs(muon.bestTrack()->dxyError())); + mu_features.dz = muon.bestTrack()->dz(pv.position()); + mu_features.dzError = muon.bestTrack()->dzError(); + mu_features.dzSig = muon.bestTrack()->dz(pv.position())/(1e-10+std::fabs(muon.bestTrack()->dzError())); + mu_features.numberOfValidPixelHits = muon.bestTrack()->hitPattern().numberOfValidPixelHits(); + mu_features.numberOfpixelLayersWithMeasurement = muon.bestTrack()->hitPattern().pixelLayersWithMeasurement(); + mu_features.numberOfstripLayersWithMeasurement = muon.bestTrack()->hitPattern().stripLayersWithMeasurement(); - mu_features.mu_chi2 = muon.bestTrack()->chi2(); - mu_features.mu_ndof = muon.bestTrack()->ndof(); + mu_features.chi2 = muon.bestTrack()->chi2(); + mu_features.ndof = muon.bestTrack()->ndof(); - mu_features.mu_caloIso = muon.caloIso()/muon.pt(); - mu_features.mu_ecalIso = muon.ecalIso()/muon.pt(); - mu_features.mu_hcalIso = muon.hcalIso()/muon.pt(); + mu_features.caloIso = muon.caloIso()/muon.pt(); + mu_features.ecalIso = muon.ecalIso()/muon.pt(); + mu_features.hcalIso = muon.hcalIso()/muon.pt(); - mu_features.mu_sumPfChHadronPt = muon.pfIsolationR04().sumChargedHadronPt/muon.pt(); - mu_features.mu_sumPfNeuHadronEt = muon.pfIsolationR04().sumNeutralHadronEt/muon.pt(); - mu_features.mu_Pfpileup = muon.pfIsolationR04().sumPUPt/muon.pt(); - mu_features.mu_sumPfPhotonEt = muon.pfIsolationR04().sumPhotonEt/muon.pt(); + mu_features.sumPfChHadronPt = muon.pfIsolationR04().sumChargedHadronPt/muon.pt(); + mu_features.sumPfNeuHadronEt = muon.pfIsolationR04().sumNeutralHadronEt/muon.pt(); + mu_features.Pfpileup = muon.pfIsolationR04().sumPUPt/muon.pt(); + mu_features.sumPfPhotonEt = muon.pfIsolationR04().sumPhotonEt/muon.pt(); - mu_features.mu_sumPfChHadronPt03 = muon.pfIsolationR03().sumChargedHadronPt/muon.pt(); - mu_features.mu_sumPfNeuHadronEt03 = muon.pfIsolationR03().sumNeutralHadronEt/muon.pt(); - mu_features.mu_Pfpileup03 = muon.pfIsolationR03().sumPUPt/muon.pt(); - mu_features.mu_sumPfPhotonEt03 = muon.pfIsolationR03().sumPhotonEt/muon.pt(); + mu_features.sumPfChHadronPt03 = muon.pfIsolationR03().sumChargedHadronPt/muon.pt(); + mu_features.sumPfNeuHadronEt03 = muon.pfIsolationR03().sumNeutralHadronEt/muon.pt(); + mu_features.Pfpileup03 = muon.pfIsolationR03().sumPUPt/muon.pt(); + mu_features.sumPfPhotonEt03 = muon.pfIsolationR03().sumPhotonEt/muon.pt(); - mu_features.mu_timeAtIpInOut = muon.time().timeAtIpInOut; - mu_features.mu_timeAtIpInOutErr = muon.time().timeAtIpInOutErr; - mu_features.mu_timeAtIpOutIn = muon.time().timeAtIpOutIn; + mu_features.timeAtIpInOut = muon.time().timeAtIpInOut; + mu_features.timeAtIpInOutErr = muon.time().timeAtIpInOutErr; + mu_features.timeAtIpOutIn = muon.time().timeAtIpOutIn; features.mu_features.emplace_back(mu_features); } - std::stable_sort(features.mu_features.begin(),features.mu_features.end(),[](const auto& d1, const auto& d2) - { - if (d1.mu_2dIPSig>0 and d2.mu_2dIPSig>0) - { - if (std::fabs(d1.mu_2dIPSig-d2.mu_2dIPSig)>std::numeric_limits::epsilon()) - { - return std::fabs(d1.mu_2dIPSig)>std::fabs(d2.mu_2dIPSig); //sort decreasing - } - } - return d1.mu_ptrel>d2.mu_ptrel; //sort decreasing - }); + std::stable_sort(features.mu_features.begin(),features.mu_features.end()); //find matching electrons @@ -541,181 +528,166 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) cpf_features.matchedElectron = 1; if (reco::deltaR(electron, jet) > 0.4) continue; - elec_features.elec_ptrel = electron.pt()/uncorrectedPt; - elec_features.elec_deta = electron.eta()-jet.eta(); - elec_features.elec_dphi = reco::deltaPhi(electron.phi(),jet.phi()); - elec_features.elec_charge = electron.charge(); - elec_features.elec_px = electron.px(); - elec_features.elec_py = electron.py(); - elec_features.elec_pz = electron.pz(); + elec_features.ptrel = electron.pt()/uncorrectedPt; + elec_features.deta = electron.eta()-jet.eta(); + elec_features.dphi = reco::deltaPhi(electron.phi(),jet.phi()); + elec_features.charge = electron.charge(); + elec_features.px = electron.px(); + elec_features.py = electron.py(); + elec_features.pz = electron.pz(); - elec_features.elec_energy = electron.energy()/electron.pt(); - elec_features.elec_deltaR = reco::deltaR(electron,jet); - elec_features.elec_EtFromCaloEn = electron.caloEnergy() * sin(electron.p4().theta())/ electron.pt(); - elec_features.elec_ecalDrivenSeed = electron.ecalDrivenSeed(); - - elec_features.elec_isEB = electron.isEB(); - elec_features.elec_isEE = electron.isEE(); - elec_features.elec_ecalEnergy = electron.ecalEnergy()/electron.pt(); - elec_features.elec_isPassConversionVeto = electron.passConversionVeto(); + elec_features.energy = electron.energy()/electron.pt(); + elec_features.deltaR = reco::deltaR(electron,jet); + elec_features.EtFromCaloEn = electron.caloEnergy() * sin(electron.p4().theta())/ electron.pt(); + elec_features.ecalDrivenSeed = electron.ecalDrivenSeed(); + + elec_features.isEB = electron.isEB(); + elec_features.isEE = electron.isEE(); + elec_features.ecalEnergy = electron.ecalEnergy()/electron.pt(); + elec_features.isPassConversionVeto = electron.passConversionVeto(); if(electron.convDist() >= 0.) { - elec_features.elec_convDist = electron.convDist(); - elec_features.elec_convFlags = electron.convFlags(); - elec_features.elec_convRadius = electron.convRadius(); + elec_features.convDist = electron.convDist(); + elec_features.convFlags = electron.convFlags(); + elec_features.convRadius = electron.convRadius(); } else { - elec_features.elec_convDist = -1.; - elec_features.elec_convFlags = -1.; - elec_features.elec_convRadius = -1.; + elec_features.convDist = -1.; + elec_features.convFlags = -1.; + elec_features.convRadius = -1.; } - elec_features.elec_3dIP = electron.dB(pat::Electron::PV3D); - elec_features.elec_3dIPSig = electron.dB(pat::Electron::PV3D)/electron.edB(pat::Electron::PV3D); - elec_features.elec_2dIP = electron.dB(); - elec_features.elec_2dIPSig = electron.dB()/electron.edB(); + elec_features.IP3d = electron.dB(pat::Electron::PV3D); + elec_features.IP3dSig = electron.dB(pat::Electron::PV3D)/electron.edB(pat::Electron::PV3D); + elec_features.IP2d = electron.dB(); + elec_features.IP2dSig = electron.dB()/electron.edB(); - if (std::isnan(elec_features.elec_2dIPSig) || std::isnan(elec_features.elec_3dIPSig)) + if (std::isnan(elec_features.IP2dSig) || std::isnan(elec_features.IP3dSig)) { - elec_features.elec_2dIPSig = 0.; - elec_features.elec_3dIPSig = 0.; + elec_features.IP2dSig = 0.; + elec_features.IP3dSig = 0.; } - elec_features.elec_sCseedEta = electron.superCluster()->seed()->eta(); + elec_features.sCseedEta = electron.superCluster()->seed()->eta(); - elec_features.elec_eSeedClusterOverP = electron.eSeedClusterOverP(); - elec_features.elec_eSeedClusterOverPout = electron.eSeedClusterOverPout(); - elec_features.elec_eSuperClusterOverP = electron.eSuperClusterOverP(); - elec_features.elec_hadronicOverEm = electron.hadronicOverEm(); + elec_features.eSeedClusterOverP = electron.eSeedClusterOverP(); + elec_features.eSeedClusterOverPout = electron.eSeedClusterOverPout(); + elec_features.eSuperClusterOverP = electron.eSuperClusterOverP(); + elec_features.hadronicOverEm = electron.hadronicOverEm(); - elec_features.elec_deltaEtaEleClusterTrackAtCalo = electron.deltaEtaEleClusterTrackAtCalo(); - elec_features.elec_deltaPhiEleClusterTrackAtCalo = electron.deltaPhiEleClusterTrackAtCalo(); + elec_features.deltaEtaEleClusterTrackAtCalo = electron.deltaEtaEleClusterTrackAtCalo(); + elec_features.deltaPhiEleClusterTrackAtCalo = electron.deltaPhiEleClusterTrackAtCalo(); - elec_features.elec_deltaEtaSeedClusterTrackAtCalo = electron.deltaEtaSeedClusterTrackAtCalo(); - elec_features.elec_deltaPhiSeedClusterTrackAtCalo = electron.deltaPhiSeedClusterTrackAtCalo(); + elec_features.deltaEtaSeedClusterTrackAtCalo = electron.deltaEtaSeedClusterTrackAtCalo(); + elec_features.deltaPhiSeedClusterTrackAtCalo = electron.deltaPhiSeedClusterTrackAtCalo(); - elec_features.elec_deltaEtaSeedClusterTrackAtVtx = electron.deltaEtaSeedClusterTrackAtVtx(); - elec_features.elec_deltaEtaSuperClusterTrackAtVtx = electron.deltaEtaSuperClusterTrackAtVtx(); - elec_features.elec_deltaPhiSuperClusterTrackAtVtx = electron.deltaPhiSuperClusterTrackAtVtx(); + elec_features.deltaEtaSeedClusterTrackAtVtx = electron.deltaEtaSeedClusterTrackAtVtx(); + elec_features.deltaEtaSuperClusterTrackAtVtx = electron.deltaEtaSuperClusterTrackAtVtx(); + elec_features.deltaPhiSuperClusterTrackAtVtx = electron.deltaPhiSuperClusterTrackAtVtx(); reco::Candidate::Vector electronMom = electron.gsfTrack()->momentum(); - elec_features.elec_EtaRel = reco::btau::etaRel(jetDir, electronMom); - elec_features.elec_dxy = electron.gsfTrack()->dxy(pv.position()); - elec_features.elec_dxyError = electron.gsfTrack()->dxyError(); - elec_features.elec_dxySig = electron.gsfTrack()->dxy(pv.position())/(1e-10+std::fabs(electron.gsfTrack()->dxyError())); - elec_features.elec_dz = electron.gsfTrack()->dz(pv.position()); - elec_features.elec_dzError = electron.gsfTrack()->dzError(); - elec_features.elec_dzSig = electron.gsfTrack()->dz(pv.position())/(1e-10+std::fabs(electron.gsfTrack()->dzError())); + elec_features.EtaRel = reco::btau::etaRel(jetDir, electronMom); + elec_features.dxy = electron.gsfTrack()->dxy(pv.position()); + elec_features.dxyError = electron.gsfTrack()->dxyError(); + elec_features.dxySig = electron.gsfTrack()->dxy(pv.position())/(1e-10+std::fabs(electron.gsfTrack()->dxyError())); + elec_features.dz = electron.gsfTrack()->dz(pv.position()); + elec_features.dzError = electron.gsfTrack()->dzError(); + elec_features.dzSig = electron.gsfTrack()->dz(pv.position())/(1e-10+std::fabs(electron.gsfTrack()->dzError())); - elec_features.elec_nbOfMissingHits = electron.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS); - elec_features.elec_gsfCharge = electron.gsfTrack()->charge(); - elec_features.elec_ndof = electron.gsfTrack()->ndof(); - elec_features.elec_chi2 = electron.gsfTrack()->chi2(); + elec_features.nbOfMissingHits = electron.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS); + elec_features.gsfCharge = electron.gsfTrack()->charge(); + elec_features.ndof = electron.gsfTrack()->ndof(); + elec_features.chi2 = electron.gsfTrack()->chi2(); elec_features.elecSC_energy = electron.superCluster()->energy()/electron.pt(); elec_features.elecSC_deta = electron.superCluster()->eta()-electron.gsfTrack()->eta(); elec_features.elecSC_dphi = reco::deltaPhi(electron.superCluster()->phi(),electron.gsfTrack()->phi()); elec_features.elecSC_et = electron.superCluster()->energy() * sin(electron.p4().theta())/electron.pt(); - elec_features.elec_scPixCharge = electron.scPixCharge(); + elec_features.scPixCharge = electron.scPixCharge(); - elec_features.elec_numberOfBrems = electron.numberOfBrems(); + elec_features.numberOfBrems = electron.numberOfBrems(); if(electron.pt() >= 5.){ - elec_features.elec_fbrem = electron.fbrem(); - elec_features.elec_sigmaEtaEta = electron.sigmaEtaEta(); - elec_features.elec_sigmaIetaIeta = electron.sigmaIetaIeta(); - elec_features.elec_sigmaIphiIphi = electron.sigmaIphiIphi(); - elec_features.elec_r9 = electron.r9(); - elec_features.elec_superClusterFbrem = electron.superClusterFbrem(); + elec_features.fbrem = electron.fbrem(); + elec_features.sigmaEtaEta = electron.sigmaEtaEta(); + elec_features.sigmaIetaIeta = electron.sigmaIetaIeta(); + elec_features.sigmaIphiIphi = electron.sigmaIphiIphi(); + elec_features.r9 = electron.r9(); + elec_features.superClusterFbrem = electron.superClusterFbrem(); } else { - elec_features.elec_fbrem = -1.; - elec_features.elec_sigmaEtaEta = -1.; - elec_features.elec_sigmaIetaIeta = -1.; - elec_features.elec_sigmaIphiIphi = -1; - elec_features.elec_superClusterFbrem = -1.; + elec_features.fbrem = -1.; + elec_features.sigmaEtaEta = -1.; + elec_features.sigmaIetaIeta = -1.; + elec_features.sigmaIphiIphi = -1; + elec_features.superClusterFbrem = -1.; } - elec_features.elec_e5x5 = electron.e5x5(); + elec_features.e5x5 = electron.e5x5(); - elec_features.elec_e5x5Rel = electron.e5x5()/jet.pt(); - elec_features.elec_e1x5Overe5x5 = electron.e1x5()/electron.e5x5(); - elec_features.elec_e2x5MaxOvere5x5 = electron.e2x5Max()/electron.e5x5(); + elec_features.e5x5Rel = electron.e5x5()/jet.pt(); + elec_features.e1x5Overe5x5 = electron.e1x5()/electron.e5x5(); + elec_features.e2x5MaxOvere5x5 = electron.e2x5Max()/electron.e5x5(); if (electron.e5x5() == 0){ - elec_features.elec_e1x5Overe5x5 = -1.; - elec_features.elec_e2x5MaxOvere5x5 = -1.; + elec_features.e1x5Overe5x5 = -1.; + elec_features.e2x5MaxOvere5x5 = -1.; } - elec_features.elec_hcalOverEcal = electron.hcalOverEcal(); - elec_features.elec_hcalDepth1OverEcal = electron.hcalDepth1OverEcal(); - elec_features.elec_hcalDepth2OverEcal = electron.hcalDepth2OverEcal(); + elec_features.hcalOverEcal = electron.hcalOverEcal(); + elec_features.hcalDepth1OverEcal = electron.hcalDepth1OverEcal(); + elec_features.hcalDepth2OverEcal = electron.hcalDepth2OverEcal(); elec_features.elecSC_eSuperClusterOverP = electron.eSuperClusterOverP(); - elec_features.elec_neutralHadronIso = electron.neutralHadronIso()/electron.pt(); - elec_features.elec_photonIso = electron.photonIso()/electron.pt(); - elec_features.elec_puChargedHadronIso = electron.puChargedHadronIso()/electron.pt(); + elec_features.neutralHadronIso = electron.neutralHadronIso()/electron.pt(); + elec_features.photonIso = electron.photonIso()/electron.pt(); + elec_features.puChargedHadronIso = electron.puChargedHadronIso()/electron.pt(); - elec_features.elec_trackIso = electron.trackIso()/electron.pt(); - elec_features.elec_hcalDepth1OverEcal = electron.hcalDepth1OverEcal(); - elec_features.elec_hcalDepth2OverEcal = electron.hcalDepth2OverEcal(); - elec_features.elec_ecalPFClusterIso = electron.ecalPFClusterIso()/electron.pt(); - elec_features.elec_hcalPFClusterIso = electron.hcalPFClusterIso()/electron.pt(); + elec_features.trackIso = electron.trackIso()/electron.pt(); + elec_features.hcalDepth1OverEcal = electron.hcalDepth1OverEcal(); + elec_features.hcalDepth2OverEcal = electron.hcalDepth2OverEcal(); + elec_features.ecalPFClusterIso = electron.ecalPFClusterIso()/electron.pt(); + elec_features.hcalPFClusterIso = electron.hcalPFClusterIso()/electron.pt(); - elec_features.elec_pfSumPhotonEt = electron.pfIsolationVariables().sumPhotonEt/electron.pt(); - elec_features.elec_pfSumChargedHadronPt = electron.pfIsolationVariables().sumChargedHadronPt/electron.pt(); - elec_features.elec_pfSumNeutralHadronEt = electron.pfIsolationVariables().sumNeutralHadronEt/electron.pt(); - elec_features.elec_pfSumPUPt = electron.pfIsolationVariables().sumPUPt/electron.pt(); + elec_features.pfSumPhotonEt = electron.pfIsolationVariables().sumPhotonEt/electron.pt(); + elec_features.pfSumChargedHadronPt = electron.pfIsolationVariables().sumChargedHadronPt/electron.pt(); + elec_features.pfSumNeutralHadronEt = electron.pfIsolationVariables().sumNeutralHadronEt/electron.pt(); + elec_features.pfSumPUPt = electron.pfIsolationVariables().sumPUPt/electron.pt(); // isolation - elec_features.elec_dr04TkSumPt = electron.dr04TkSumPt()/electron.pt(); - elec_features.elec_dr04EcalRecHitSumEt = electron.dr04EcalRecHitSumEt()/electron.pt(); - elec_features.elec_dr04HcalDepth1TowerSumEt = electron.dr04HcalDepth1TowerSumEt()/electron.pt(); - elec_features.elec_dr04HcalDepth1TowerSumEtBc = electron.dr04HcalDepth1TowerSumEtBc()/electron.pt(); - elec_features.elec_dr04HcalDepth2TowerSumEt = electron.dr04HcalDepth2TowerSumEt()/electron.pt(); - elec_features.elec_dr04HcalDepth2TowerSumEtBc = electron.dr04HcalDepth2TowerSumEtBc()/electron.pt(); + elec_features.dr04TkSumPt = electron.dr04TkSumPt()/electron.pt(); + elec_features.dr04EcalRecHitSumEt = electron.dr04EcalRecHitSumEt()/electron.pt(); + elec_features.dr04HcalDepth1TowerSumEt = electron.dr04HcalDepth1TowerSumEt()/electron.pt(); + elec_features.dr04HcalDepth1TowerSumEtBc = electron.dr04HcalDepth1TowerSumEtBc()/electron.pt(); + elec_features.dr04HcalDepth2TowerSumEt = electron.dr04HcalDepth2TowerSumEt()/electron.pt(); + elec_features.dr04HcalDepth2TowerSumEtBc = electron.dr04HcalDepth2TowerSumEtBc()/electron.pt(); - elec_features.elec_dr04HcalTowerSumEt = electron.dr04HcalTowerSumEt()/electron.pt(); - elec_features.elec_dr04HcalTowerSumEtBc = electron.dr04HcalTowerSumEtBc()/electron.pt(); + elec_features.dr04HcalTowerSumEt = electron.dr04HcalTowerSumEt()/electron.pt(); + elec_features.dr04HcalTowerSumEtBc = electron.dr04HcalTowerSumEtBc()/electron.pt(); features.elec_features.emplace_back(elec_features); } - std::stable_sort(features.elec_features.begin(),features.elec_features.end(),[](const auto& d1, const auto& d2) + std::stable_sort(features.elec_features.begin(),features.elec_features.end()); - { - if (d1.elec_2dIPSig>0 and d2.elec_2dIPSig>0) - { - if (std::fabs(d1.elec_2dIPSig-d2.elec_2dIPSig)>std::numeric_limits::epsilon()) - { - return std::fabs(d1.elec_2dIPSig)>std::fabs(d2.elec_2dIPSig); //sort decreasing - } - } - return d1.elec_ptrel>d2.elec_ptrel; //sort decreasing - }); - - features.cpf_features.emplace_back(cpf_features); } //end loop over charged consistuents - std::stable_sort(features.cpf_features.begin(),features.cpf_features.end(),[](const auto& d1, const auto& d2) - { - return d1pt()/uncorrectedPt; - npf_features.npf_deta = constituent->eta()-jet.eta(); - npf_features.npf_dphi = reco::deltaPhi(constituent->phi(),jet.phi()); + npf_features.ptrel = constituent->pt()/uncorrectedPt; + npf_features.deta = constituent->eta()-jet.eta(); + npf_features.dphi = reco::deltaPhi(constituent->phi(),jet.phi()); - npf_features.npf_px = constituent->px(); - npf_features.npf_py = constituent->py(); - npf_features.npf_pz = constituent->pz(); + npf_features.px = constituent->px(); + npf_features.py = constituent->py(); + npf_features.pz = constituent->pz(); - npf_features.npf_puppi_weight = constituent->puppiWeight(); - npf_features.npf_deltaR = reco::deltaR(*constituent,jet); - npf_features.npf_isGamma = abs(constituent->pdgId())==22; - npf_features.npf_hcal_fraction = constituent->hcalFraction(); + npf_features.puppi_weight = constituent->puppiWeight(); + npf_features.deltaR = reco::deltaR(*constituent,jet); + npf_features.isGamma = abs(constituent->pdgId())==22; + npf_features.hcal_fraction = constituent->hcalFraction(); - npf_features.npf_drminsv = 0.4; + npf_features.drminsv = 0.4; for (const auto& sv: *svs.product()) { float dR = reco::deltaR(sv,*constituent); - npf_features.npf_drminsv = std::min(npf_features.npf_drminsv,dR); + npf_features.drminsv = std::min(npf_features.drminsv,dR); } if (jet.mass()<1e-10) { - npf_features.npf_relmassdrop = -1; + npf_features.relmassdrop = -1; } else { - npf_features.npf_relmassdrop = (jet.p4()- constituent->p4()).mass()/jet.mass(); + npf_features.relmassdrop = (jet.p4()- constituent->p4()).mass()/jet.mass(); } features.npf_features.emplace_back(npf_features); } - std::stable_sort(features.npf_features.begin(),features.npf_features.end(),[](const auto& d1, const auto& d2) - { - - if (std::fabs(d1.npf_drminsv-d2.npf_drminsv)>std::numeric_limits::epsilon()) - { - return d1.npf_drminsvd2.npf_ptrel; //sort decreasing - } - return false; - }); + std::stable_sort(features.npf_features.begin(),features.npf_features.end()); float jetRchg(-1), jetRntr(-1); if (features.cpf_features.size() > 0){ @@ -779,7 +739,7 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) } if (features.npf_features.size() > 0){ - jetRntr = features.npf_features.at(0).npf_ptrel; + jetRntr = features.npf_features.at(0).ptrel; } float jetR = std::max(jetRchg, jetRntr); @@ -817,12 +777,12 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for (size_t i = 0; i < features.npf_features.size(); i++){ llpdnnx::NeutralCandidateFeatures npf = features.npf_features.at(i); - dR2Mean += (npf.npf_ptrel*npf.npf_deltaR) * (npf.npf_ptrel*npf.npf_deltaR); - pt2Sum += (npf.npf_ptrel) * (npf.npf_ptrel); - if (npf.npf_deltaR < 0.1) frac01 ++; - else if (npf.npf_deltaR < 0.2) frac02 ++; - else if (npf.npf_deltaR < 0.3) frac03 ++; - else if (npf.npf_deltaR < 0.4) frac04 ++; + dR2Mean += (npf.ptrel*npf.deltaR) * (npf.ptrel*npf.deltaR); + pt2Sum += (npf.ptrel) * (npf.ptrel); + if (npf.deltaR < 0.1) frac01 ++; + else if (npf.deltaR < 0.2) frac02 ++; + else if (npf.deltaR < 0.3) frac03 ++; + else if (npf.deltaR < 0.4) frac04 ++; } int nCandidates = features.cpf_features.size()+features.npf_features.size(); diff --git a/XTagProducer/src/tensor_fillers.cc b/XTagProducer/src/tensor_fillers.cc index fb7e38c..165a36c 100644 --- a/XTagProducer/src/tensor_fillers.cc +++ b/XTagProducer/src/tensor_fillers.cc @@ -69,12 +69,12 @@ namespace llpdnnx { const llpdnnx::NeutralCandidateFeatures& npf_features) { float* ptr = &tensor.tensor()(jet_n, npf_n, 0); - *ptr = npf_features.npf_ptrel; - *(++ptr) = npf_features.npf_deltaR; - *(++ptr) = npf_features.npf_isGamma; - *(++ptr) = npf_features.npf_hcal_fraction; - *(++ptr) = npf_features.npf_drminsv; - *(++ptr) = npf_features.npf_puppi_weight; + *ptr = npf_features.ptrel; + *(++ptr) = npf_features.deltaR; + *(++ptr) = npf_features.isGamma; + *(++ptr) = npf_features.hcal_fraction; + *(++ptr) = npf_features.drminsv; + *(++ptr) = npf_features.puppi_weight; } void sv_tensor_filler(tensorflow::Tensor& tensor, @@ -83,17 +83,17 @@ namespace llpdnnx { const llpdnnx::SecondaryVertexFeatures& sv_features) { float* ptr = &tensor.tensor()(jet_n, sv_n, 0); - *ptr = sv_features.sv_ptrel; - *(++ptr) = sv_features.sv_deltaR; - *(++ptr) = sv_features.sv_mass; - *(++ptr) = sv_features.sv_ntracks; - *(++ptr) = sv_features.sv_chi2; - *(++ptr) = sv_features.sv_ndof; - *(++ptr) = sv_features.sv_dxy; - *(++ptr) = sv_features.sv_dxysig; - *(++ptr) = sv_features.sv_d3d; - *(++ptr) = sv_features.sv_d3dsig; - *(++ptr) = sv_features.sv_costhetasvpv; - *(++ptr) = sv_features.sv_enratio; + *ptr = sv_features.ptrel; + *(++ptr) = sv_features.deltaR; + *(++ptr) = sv_features.mass; + *(++ptr) = sv_features.ntracks; + *(++ptr) = sv_features.chi2; + *(++ptr) = sv_features.ndof; + *(++ptr) = sv_features.dxy; + *(++ptr) = sv_features.dxysig; + *(++ptr) = sv_features.d3d; + *(++ptr) = sv_features.d3dsig; + *(++ptr) = sv_features.costhetasvpv; + *(++ptr) = sv_features.enratio; } } From 1727117d068219126db3de4cefc28ff7b34125ad Mon Sep 17 00:00:00 2001 From: matt-komm Date: Sat, 14 Nov 2020 13:55:31 +0000 Subject: [PATCH 09/20] missing commit --- .../interface/ChargedCandidateFeatures.h | 41 +------------------ DataFormats/interface/JetFeatures.h | 2 + 2 files changed, 4 insertions(+), 39 deletions(-) diff --git a/DataFormats/interface/ChargedCandidateFeatures.h b/DataFormats/interface/ChargedCandidateFeatures.h index e239356..0f9f199 100644 --- a/DataFormats/interface/ChargedCandidateFeatures.h +++ b/DataFormats/interface/ChargedCandidateFeatures.h @@ -7,8 +7,6 @@ namespace llpdnnx { struct ChargedCandidateFeatures { - -<<<<<<< HEAD int jetIdx; float ptrel; float deta; @@ -46,6 +44,7 @@ struct ChargedCandidateFeatures int matchedMuon; int matchedElectron; int matchedSV; + int matchedSV_adapted; int track_ndof; float dZmin; @@ -88,6 +87,7 @@ struct ChargedCandidateFeatures matchedMuon(0), matchedElectron(0), matchedSV(0), + matchedSV_adapted(0), track_ndof(0), dZmin(100) @@ -118,44 +118,7 @@ struct ChargedCandidateFeatures return false; } -======= - int cpf_jetIdx; - float cpf_ptrel; - float cpf_deta; - float cpf_dphi; - - float cpf_trackEtaRel; - float cpf_trackPtRel; - float cpf_trackPPar; - float cpf_trackDeltaR; - float cpf_trackPParRatio; - float cpf_trackPtRatio; - float cpf_trackSip2dVal; - float cpf_trackSip2dSig; - float cpf_trackSip3dVal; - float cpf_trackSip3dSig; - float cpf_trackJetDistVal; - float cpf_trackJetDistSig; - float cpf_drminsv; - int cpf_vertex_association; - float cpf_fromPV; - float cpf_puppi_weight; - float cpf_track_chi2; - float cpf_track_quality; - int cpf_track_numberOfValidPixelHits; - int cpf_track_pixelLayersWithMeasurement; - int cpf_track_numberOfValidStripHits; - int cpf_track_stripLayersWithMeasurement; - float cpf_relmassdrop; - - int cpf_matchedMuon; - int cpf_matchedElectron; - int cpf_matchedSV; - int cpf_matchedSV_adapted; - int cpf_track_ndof; - float cpf_dZmin; ->>>>>>> 67aeda89218e90ffff71ab173bbac198bb4638cb }; } diff --git a/DataFormats/interface/JetFeatures.h b/DataFormats/interface/JetFeatures.h index 4e5eb0e..1897049 100644 --- a/DataFormats/interface/JetFeatures.h +++ b/DataFormats/interface/JetFeatures.h @@ -51,6 +51,7 @@ struct JetFeatures int numberCpf; int numberNpf; int numberSv; + int numberSvAdapted; int numberMuon; int numberElectron; @@ -101,6 +102,7 @@ struct JetFeatures numberCpf(0), numberNpf(0), numberSv(0), + numberSvAdapted(0), numberMuon(0), numberElectron(0) { From 1176c5eea54eb9b454babb0ffe8c9ab3a72d961f Mon Sep 17 00:00:00 2001 From: matt-komm Date: Sat, 14 Nov 2020 17:10:03 +0000 Subject: [PATCH 10/20] fix fractions --- XTagInfoProducer/plugins/XTagInfoProducer.cc | 28 ++++++-------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/XTagInfoProducer/plugins/XTagInfoProducer.cc b/XTagInfoProducer/plugins/XTagInfoProducer.cc index 41d70b2..cf8286f 100644 --- a/XTagInfoProducer/plugins/XTagInfoProducer.cc +++ b/XTagInfoProducer/plugins/XTagInfoProducer.cc @@ -815,39 +815,27 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) beta += cpf.fromPV; dR2Mean += (cpf.ptrel*cpf.trackDeltaR) * (cpf.ptrel*cpf.trackDeltaR); pt2Sum += (cpf.ptrel) * (cpf.ptrel); - if (cpf.trackDeltaR < 0.1) frac01 ++; - else if (cpf.trackDeltaR < 0.2) frac02 ++; - else if (cpf.trackDeltaR < 0.3) frac03 ++; - else if (cpf.trackDeltaR < 0.4) frac04 ++; + if (cpf.trackDeltaR < 0.1) frac01+=cpf.ptrel; + else if (cpf.trackDeltaR < 0.2) frac02+=cpf.ptrel; + else if (cpf.trackDeltaR < 0.3) frac03+=cpf.ptrel; + else if (cpf.trackDeltaR < 0.4) frac04+=cpf.ptrel; } if (features.cpf_features.size() > 0) { features.jet_features.beta = (float)beta/(float)features.cpf_features.size(); - } - - for (size_t i = 0; i < features.npf_features.size(); i++){ llpdnnx::NeutralCandidateFeatures npf = features.npf_features.at(i); dR2Mean += (npf.ptrel*npf.deltaR) * (npf.ptrel*npf.deltaR); pt2Sum += (npf.ptrel) * (npf.ptrel); - if (npf.deltaR < 0.1) frac01 ++; - else if (npf.deltaR < 0.2) frac02 ++; - else if (npf.deltaR < 0.3) frac03 ++; - else if (npf.deltaR < 0.4) frac04 ++; + if (npf.deltaR < 0.1) frac01+=npf.ptrel; + else if (npf.deltaR < 0.2) frac02+=npf.ptrel; + else if (npf.deltaR < 0.3) frac03+=npf.ptrel; + else if (npf.deltaR < 0.4) frac04+=npf.ptrel; } - int nCandidates = features.cpf_features.size()+features.npf_features.size(); - - if (nCandidates > 0) { - features.jet_features.frac01 = 1.*frac01/nCandidates; - features.jet_features.frac02 = 1.*frac02/nCandidates; - features.jet_features.frac03 = 1.*frac03/nCandidates; - features.jet_features.frac04 = 1.*frac04/nCandidates; - features.jet_features.dR2Mean = dR2Mean/pt2Sum; - } features.jet_features.numberCpf = features.cpf_features.size(); features.jet_features.numberNpf = features.npf_features.size(); From 95432ee583cbaae368e96f1144cfeb3f218dfb8e Mon Sep 17 00:00:00 2001 From: matt-komm Date: Mon, 16 Nov 2020 11:29:32 +0000 Subject: [PATCH 11/20] add vtx --- NANOProducer/test/produceNANO.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NANOProducer/test/produceNANO.py b/NANOProducer/test/produceNANO.py index 2090c3d..be8c644 100644 --- a/NANOProducer/test/produceNANO.py +++ b/NANOProducer/test/produceNANO.py @@ -454,6 +454,10 @@ #process.finalPhotons.cut = cms.string("pt > 5") #process.finalPhotons.src = cms.InputTag("slimmedPhotons") +process.genParticleTable.variables.vertex_x = Var("vertex().x()", float, doc="vertex x position") +process.genParticleTable.variables.vertex_y = Var("vertex().y()", float, doc="vertex y position") +process.genParticleTable.variables.vertex_z = Var("vertex().z()", float, doc="vertex z position") + ''' process.MINIAODoutput = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string('output.root'), From 1b7e45108d534b9954bf5e9d0914665ba09d5360 Mon Sep 17 00:00:00 2001 From: matt-komm Date: Mon, 16 Nov 2020 13:34:34 +0000 Subject: [PATCH 12/20] add sv position --- .../interface/SecondaryVertexFeatures.h | 24 +++++++++++++++++++ NANOProducer/plugins/NANOProducer.cc | 5 +++- XTagInfoProducer/plugins/XTagInfoProducer.cc | 4 ++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/DataFormats/interface/SecondaryVertexFeatures.h b/DataFormats/interface/SecondaryVertexFeatures.h index 25abd92..96cfb0c 100644 --- a/DataFormats/interface/SecondaryVertexFeatures.h +++ b/DataFormats/interface/SecondaryVertexFeatures.h @@ -23,6 +23,30 @@ struct SecondaryVertexFeatures float d3dsig; float costhetasvpv; float enratio; + float vx; //vertex position if we want to make NI map + float vy; + float vz; + + SecondaryVertexFeatures(): + jetIdx(-1), + ptrel(0), + deta(0), + dphi(0), + deltaR(0), + mass(0), + ntracks(0), + chi2(0), + ndof(0), + dxy(0), + dxysig(0), + d3d(0), + d3dsig(0), + costhetasvpv(0), + enratio(0), + vx(0), + vy(0), + vz(0) + {} bool operator<(const SecondaryVertexFeatures& other) const { diff --git a/NANOProducer/plugins/NANOProducer.cc b/NANOProducer/plugins/NANOProducer.cc index e159583..6030e33 100644 --- a/NANOProducer/plugins/NANOProducer.cc +++ b/NANOProducer/plugins/NANOProducer.cc @@ -191,7 +191,10 @@ NANOProducer::NANOProducer(const edm::ParameterSet& iConfig) : PROPERTY(llpdnnx::SecondaryVertexFeatures, d3d, "doc"), PROPERTY(llpdnnx::SecondaryVertexFeatures, d3dsig, "doc"), PROPERTY(llpdnnx::SecondaryVertexFeatures, costhetasvpv, "doc"), - PROPERTY(llpdnnx::SecondaryVertexFeatures, enratio, "doc") + PROPERTY(llpdnnx::SecondaryVertexFeatures, enratio, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, vx, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, vy, "doc"), + PROPERTY(llpdnnx::SecondaryVertexFeatures, vz, "doc") }; muonProperties = { diff --git a/XTagInfoProducer/plugins/XTagInfoProducer.cc b/XTagInfoProducer/plugins/XTagInfoProducer.cc index cf8286f..a44f1d6 100644 --- a/XTagInfoProducer/plugins/XTagInfoProducer.cc +++ b/XTagInfoProducer/plugins/XTagInfoProducer.cc @@ -88,6 +88,10 @@ llpdnnx::SecondaryVertexFeatures fillSVFeatures(const reco::VertexCompositePtrCa sv_features.costhetasvpv = sv.momentum().Unit().Dot(distance.Unit()); sv_features.enratio = sv.energy()/jet.pt(); + sv_features.vx = sv.vertex().x(); + sv_features.vy = sv.vertex().y(); + sv_features.vz = sv.vertex().z(); + return sv_features; } From f21be74089d05aece4a605a712b2967a0621d1c5 Mon Sep 17 00:00:00 2001 From: matt-komm Date: Mon, 16 Nov 2020 14:20:56 +0000 Subject: [PATCH 13/20] add tau decay prefix --- NANOProducer/plugins/NANOGenProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NANOProducer/plugins/NANOGenProducer.cc b/NANOProducer/plugins/NANOGenProducer.cc index 0e0ec02..4bbf92c 100644 --- a/NANOProducer/plugins/NANOGenProducer.cc +++ b/NANOProducer/plugins/NANOGenProducer.cc @@ -202,7 +202,7 @@ NANOGenProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) jetOriginTable->addColumn("jetIdx", truth_jetIdx, "doc", nanoaod::FlatTable::IntColumn); for (const auto& labelType: labelTypes) jetOriginTable->addColumn(labelType.first, labelList[labelType.first], "doc", nanoaod::FlatTable::IntColumn); - for (const auto& tauDecayType: tauDecayTypes) jetOriginTable->addColumn(tauDecayType.first, tauDecayList[tauDecayType.first], "doc", nanoaod::FlatTable::IntColumn); + for (const auto& tauDecayType: tauDecayTypes) jetOriginTable->addColumn("tauDecay_"+tauDecayType.first, tauDecayList[tauDecayType.first], "doc", nanoaod::FlatTable::IntColumn); labelPropertyFillerList.fill(jetOriginTable); From 103239e80278ca0bf3ea68dc834f58ea1d4bc792 Mon Sep 17 00:00:00 2001 From: matt-komm Date: Mon, 16 Nov 2020 17:12:22 +0000 Subject: [PATCH 14/20] add 2d/3d to SVs --- .../interface/ChargedCandidateFeatures.h | 22 ++++++++- NANOProducer/plugins/NANOProducer.cc | 11 ++++- XTagInfoProducer/plugins/XTagInfoProducer.cc | 45 ++++++++++++++----- 3 files changed, 65 insertions(+), 13 deletions(-) diff --git a/DataFormats/interface/ChargedCandidateFeatures.h b/DataFormats/interface/ChargedCandidateFeatures.h index 0f9f199..5fa2824 100644 --- a/DataFormats/interface/ChargedCandidateFeatures.h +++ b/DataFormats/interface/ChargedCandidateFeatures.h @@ -40,6 +40,16 @@ struct ChargedCandidateFeatures int track_numberOfValidStripHits; int track_stripLayersWithMeasurement; float relmassdrop; + + float trackSip2dValSV; + float trackSip2dSigSV; + float trackSip3dValSV; + float trackSip3dSigSV; + + float trackSip2dValSV_adapted; + float trackSip2dSigSV_adapted; + float trackSip3dValSV_adapted; + float trackSip3dSigSV_adapted; int matchedMuon; int matchedElectron; @@ -83,13 +93,23 @@ struct ChargedCandidateFeatures track_numberOfValidStripHits(0), track_stripLayersWithMeasurement(0), relmassdrop(0), + + trackSip2dValSV(1), + trackSip2dSigSV(0), + trackSip3dValSV(1), + trackSip3dSigSV(0), + + trackSip2dValSV_adapted(1), + trackSip2dSigSV_adapted(0), + trackSip3dValSV_adapted(1), + trackSip3dSigSV_adapted(0), matchedMuon(0), matchedElectron(0), matchedSV(0), matchedSV_adapted(0), + track_ndof(0), - dZmin(100) {} diff --git a/NANOProducer/plugins/NANOProducer.cc b/NANOProducer/plugins/NANOProducer.cc index 6030e33..31d06ce 100644 --- a/NANOProducer/plugins/NANOProducer.cc +++ b/NANOProducer/plugins/NANOProducer.cc @@ -148,6 +148,16 @@ NANOProducer::NANOProducer(const edm::ParameterSet& iConfig) : PROPERTY(llpdnnx::ChargedCandidateFeatures, track_numberOfValidStripHits, "doc"), PROPERTY(llpdnnx::ChargedCandidateFeatures, track_stripLayersWithMeasurement, "doc"), PROPERTY(llpdnnx::ChargedCandidateFeatures, relmassdrop, "doc"), + + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip2dValSV, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip2dSigSV, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip3dValSV, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip3dSigSV, "doc"), + + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip2dValSV_adapted, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip2dSigSV_adapted, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip3dValSV_adapted, "doc"), + PROPERTY(llpdnnx::ChargedCandidateFeatures, trackSip3dSigSV_adapted, "doc"), PROPERTY(llpdnnx::ChargedCandidateFeatures, matchedMuon, "doc"), PROPERTY(llpdnnx::ChargedCandidateFeatures, matchedElectron, "doc"), @@ -155,7 +165,6 @@ NANOProducer::NANOProducer(const edm::ParameterSet& iConfig) : PROPERTY(llpdnnx::ChargedCandidateFeatures, matchedSV_adapted, "doc"), PROPERTY(llpdnnx::ChargedCandidateFeatures, track_ndof, "doc"), - PROPERTY(llpdnnx::ChargedCandidateFeatures, dZmin, "doc") }; diff --git a/XTagInfoProducer/plugins/XTagInfoProducer.cc b/XTagInfoProducer/plugins/XTagInfoProducer.cc index a44f1d6..b059a8c 100644 --- a/XTagInfoProducer/plugins/XTagInfoProducer.cc +++ b/XTagInfoProducer/plugins/XTagInfoProducer.cc @@ -315,8 +315,8 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) features.tag_info_features.jetNSelectedTracks = vars.get(reco::btau::jetNSelectedTracks, -1); - std::unordered_set candidatesMatchedToSV; - std::unordered_set candidatesMatchedToSVAdapted; + std::unordered_map, CandidateHash> candidatesMatchedToSV; + std::unordered_map, CandidateHash> candidatesMatchedToSVAdapted; // fill features from secondary vertices @@ -333,7 +333,7 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { if (jetConstituentSet.find(candidateFromVertex)!=jetConstituentSet.end()) { - candidatesMatchedToSV.insert(candidateFromVertex); + candidatesMatchedToSV[candidateFromVertex].push_back(&sv); matchingTrack = true; } } @@ -363,7 +363,7 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { if (jetConstituentSet.find(candidateFromVertex)!=jetConstituentSet.end()) { - candidatesMatchedToSVAdapted.insert(candidateFromVertex); + candidatesMatchedToSVAdapted[candidateFromVertex].push_back(&sv_adapted); matchingTrack = true; } } @@ -460,14 +460,9 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) cpf_features.trackPParRatio=cpf_features.trackPPar / trackMag; cpf_features.trackSip2dVal=meas_ip2d.value(); - cpf_features.trackSip2dSig=meas_ip2d.significance(); + cpf_features.trackSip2dSig=std::isnan(meas_ip2d.significance()) ? 0 : meas_ip2d.significance(); cpf_features.trackSip3dVal=meas_ip3d.value(); - cpf_features.trackSip3dSig=meas_ip3d.significance(); - if (std::isnan(cpf_features.trackSip2dSig) || std::isnan(cpf_features.trackSip3dSig)) - { - cpf_features.trackSip2dSig=0.; - cpf_features.trackSip3dSig=0.; - } + cpf_features.trackSip3dSig=std::isnan(meas_ip3d.significance()) ? 0 : meas_ip3d.significance(); cpf_features.trackJetDistVal = jetdist.value(); cpf_features.trackJetDistSig = jetdist.significance(); @@ -478,6 +473,20 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) if (candidatesMatchedToSV.find(jet.daughterPtr(idaughter))!=candidatesMatchedToSV.end()) { cpf_features.matchedSV = 1; + for (const auto& vertexCompositePtrCandidate: candidatesMatchedToSV[jet.daughterPtr(idaughter)]) + { + reco::Vertex svVertex(vertexCompositePtrCandidate->position(), vertexCompositePtrCandidate->error4D(),vertexCompositePtrCandidate->t()); + Measurement1D meas_sv_ip2d=IPTools::signedTransverseImpactParameter(transientTrack, jetRefTrackDir, svVertex).second; + Measurement1D meas_sv_ip3d=IPTools::signedImpactParameter3D(transientTrack, jetRefTrackDir, svVertex).second; + + if (std::fabs(meas_sv_ip3d.value())position(), vertexCompositePtrCandidate->error4D(),vertexCompositePtrCandidate->t()); + Measurement1D meas_sv_ip2d=IPTools::signedTransverseImpactParameter(transientTrack, jetRefTrackDir, svVertex).second; + Measurement1D meas_sv_ip3d=IPTools::signedImpactParameter3D(transientTrack, jetRefTrackDir, svVertex).second; + + if (std::fabs(meas_sv_ip3d.value()) Date: Mon, 16 Nov 2020 17:34:53 +0000 Subject: [PATCH 15/20] fix test --- NANOProducer/test/produceNANO.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/NANOProducer/test/produceNANO.py b/NANOProducer/test/produceNANO.py index be8c644..62387e3 100644 --- a/NANOProducer/test/produceNANO.py +++ b/NANOProducer/test/produceNANO.py @@ -31,6 +31,15 @@ VarParsing.varType.string, "add year file" ) + +options.register( + 'test', + False, + VarParsing.multiplicity.singleton, + VarParsing.varType.bool, + "running test" +) + options.parseArguments() if options.year == '2016': @@ -104,10 +113,14 @@ } } -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring(files[options.year]['data'] if options.isData else files[options.year]['mc']) - -) +if len(options.inputFiles)>0: + process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring(options.inputFiles) + ) +else: + process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring(files[options.year]['data'] if options.isData else files[options.year]['mc']) + ) # Production Info process.configurationMetadata = cms.untracked.PSet( annotation = cms.untracked.string('test102X nevts:10000'), From c6fc6f5d37652c10802ec8f374776b0d2557df53 Mon Sep 17 00:00:00 2001 From: matt-komm Date: Mon, 16 Nov 2020 21:26:30 +0000 Subject: [PATCH 16/20] init npf --- .../interface/NeutralCandidateFeatures.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/DataFormats/interface/NeutralCandidateFeatures.h b/DataFormats/interface/NeutralCandidateFeatures.h index f63f228..54e3a86 100644 --- a/DataFormats/interface/NeutralCandidateFeatures.h +++ b/DataFormats/interface/NeutralCandidateFeatures.h @@ -23,6 +23,24 @@ struct NeutralCandidateFeatures float puppi_weight; float relmassdrop; + NeutralCandidateFeatures(): + jetIdx(-1), + ptrel(0), + deta(0), + dphi(0), + deltaR(0), + + px(0), + py(0), + pz(0), + + isGamma(0), + hcal_fraction(0), + drminsv(0), + puppi_weight(0), + relmassdrop(0) + {} + bool operator<(const NeutralCandidateFeatures& other) const { if (std::fabs(drminsv-other.drminsv)>std::numeric_limits::epsilon()) From 1c1462efd1aa1a3fa594f51433aa5e1e8e66cdbb Mon Sep 17 00:00:00 2001 From: matt-komm Date: Mon, 16 Nov 2020 22:01:59 +0000 Subject: [PATCH 17/20] add missing muon feat --- DataFormats/interface/MuonCandidateFeatures.h | 2 -- NANOProducer/plugins/NANOProducer.cc | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DataFormats/interface/MuonCandidateFeatures.h b/DataFormats/interface/MuonCandidateFeatures.h index b86f41e..8b1d333 100644 --- a/DataFormats/interface/MuonCandidateFeatures.h +++ b/DataFormats/interface/MuonCandidateFeatures.h @@ -57,7 +57,6 @@ struct MuonCandidateFeatures { float Pfpileup03; float sumPfPhotonEt03; - float timeAtIpInOut; float timeAtIpInOutErr; float timeAtIpOutIn; @@ -116,7 +115,6 @@ struct MuonCandidateFeatures { Pfpileup03(0), sumPfPhotonEt03(0), - timeAtIpInOut(0), timeAtIpInOutErr(0), timeAtIpOutIn(0) diff --git a/NANOProducer/plugins/NANOProducer.cc b/NANOProducer/plugins/NANOProducer.cc index 31d06ce..39529b0 100644 --- a/NANOProducer/plugins/NANOProducer.cc +++ b/NANOProducer/plugins/NANOProducer.cc @@ -256,8 +256,11 @@ NANOProducer::NANOProducer(const edm::ParameterSet& iConfig) : PROPERTY(llpdnnx::MuonCandidateFeatures, sumPfChHadronPt03, "doc"), PROPERTY(llpdnnx::MuonCandidateFeatures, sumPfNeuHadronEt03, "doc"), PROPERTY(llpdnnx::MuonCandidateFeatures, Pfpileup03, "doc"), - PROPERTY(llpdnnx::MuonCandidateFeatures, sumPfPhotonEt03, "doc") + PROPERTY(llpdnnx::MuonCandidateFeatures, sumPfPhotonEt03, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, timeAtIpInOut, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, timeAtIpInOutErr, "doc"), + PROPERTY(llpdnnx::MuonCandidateFeatures, timeAtIpOutIn, "doc") }; From 8b455ef76da22e340887db2fd70995bc1386cd4e Mon Sep 17 00:00:00 2001 From: matt-komm Date: Mon, 16 Nov 2020 22:12:22 +0000 Subject: [PATCH 18/20] init jetIdx --- DataFormats/interface/LLPLabel.h | 1 + NANOProducer/plugins/NANOProducer.cc | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/DataFormats/interface/LLPLabel.h b/DataFormats/interface/LLPLabel.h index a394303..f84947e 100644 --- a/DataFormats/interface/LLPLabel.h +++ b/DataFormats/interface/LLPLabel.h @@ -97,6 +97,7 @@ class LLPLabel { LLPLabel(): type(Type::isUndefined), tauDecay(TauDecay::NO_TAU), + jetIdx(-1), partonFlavor(0), hadronFlavor(0), llpId(0), diff --git a/NANOProducer/plugins/NANOProducer.cc b/NANOProducer/plugins/NANOProducer.cc index 39529b0..473ce5e 100644 --- a/NANOProducer/plugins/NANOProducer.cc +++ b/NANOProducer/plugins/NANOProducer.cc @@ -480,7 +480,6 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) globalFillerList.push_back(features.jet_features); csvFillerList.push_back(features.tag_info_features); - } auto muonTable = std::make_unique(nmu_total, "muon", false, false); @@ -512,7 +511,6 @@ NANOProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for (unsigned int i = 0; i < ncpf; i++) { cpf_jetIdx.push_back(jetIdx); - cpfFillerList.push_back(cpf.at(i)); } From 17186f55be5ae66cdcff48a00162cd088b00ca70 Mon Sep 17 00:00:00 2001 From: matt-komm Date: Mon, 16 Nov 2020 22:50:58 +0000 Subject: [PATCH 19/20] rm jetIdx/ fixed frac01..04 --- .../interface/ChargedCandidateFeatures.h | 2 -- .../interface/ElectronCandidateFeatures.h | 2 -- DataFormats/interface/JetFeatures.h | 2 -- DataFormats/interface/LLPLabel.h | 2 -- DataFormats/interface/MuonCandidateFeatures.h | 2 -- .../interface/NeutralCandidateFeatures.h | 2 -- .../interface/SecondaryVertexFeatures.h | 3 -- .../interface/ShallowTagInfoFeatures.h | 14 ++++++++- XTagInfoProducer/plugins/XTagInfoProducer.cc | 29 ++++++++++--------- 9 files changed, 28 insertions(+), 30 deletions(-) diff --git a/DataFormats/interface/ChargedCandidateFeatures.h b/DataFormats/interface/ChargedCandidateFeatures.h index 5fa2824..85add3c 100644 --- a/DataFormats/interface/ChargedCandidateFeatures.h +++ b/DataFormats/interface/ChargedCandidateFeatures.h @@ -7,7 +7,6 @@ namespace llpdnnx { struct ChargedCandidateFeatures { - int jetIdx; float ptrel; float deta; float dphi; @@ -60,7 +59,6 @@ struct ChargedCandidateFeatures float dZmin; ChargedCandidateFeatures(): - jetIdx(-1), ptrel(-1), deta(1), dphi(1), diff --git a/DataFormats/interface/ElectronCandidateFeatures.h b/DataFormats/interface/ElectronCandidateFeatures.h index 3c7745e..471c067 100644 --- a/DataFormats/interface/ElectronCandidateFeatures.h +++ b/DataFormats/interface/ElectronCandidateFeatures.h @@ -4,7 +4,6 @@ namespace llpdnnx { struct ElectronCandidateFeatures { - int jetIdx; float ptrel; float deltaR; float deta; @@ -106,7 +105,6 @@ struct ElectronCandidateFeatures { ElectronCandidateFeatures(): - jetIdx(-1), ptrel(0), deltaR(0), deta(0), diff --git a/DataFormats/interface/JetFeatures.h b/DataFormats/interface/JetFeatures.h index 1897049..dbefbdf 100644 --- a/DataFormats/interface/JetFeatures.h +++ b/DataFormats/interface/JetFeatures.h @@ -5,7 +5,6 @@ namespace llpdnnx { struct JetFeatures { - int jetIdx; float pt; float eta; float phi; @@ -56,7 +55,6 @@ struct JetFeatures int numberElectron; JetFeatures(): - jetIdx(-1), pt(-1), eta(0), phi(0), diff --git a/DataFormats/interface/LLPLabel.h b/DataFormats/interface/LLPLabel.h index f84947e..8596b26 100644 --- a/DataFormats/interface/LLPLabel.h +++ b/DataFormats/interface/LLPLabel.h @@ -73,7 +73,6 @@ class LLPLabel { TauDecay tauDecay; - int jetIdx; int partonFlavor; int hadronFlavor; int llpId; @@ -97,7 +96,6 @@ class LLPLabel { LLPLabel(): type(Type::isUndefined), tauDecay(TauDecay::NO_TAU), - jetIdx(-1), partonFlavor(0), hadronFlavor(0), llpId(0), diff --git a/DataFormats/interface/MuonCandidateFeatures.h b/DataFormats/interface/MuonCandidateFeatures.h index 8b1d333..55e38fc 100644 --- a/DataFormats/interface/MuonCandidateFeatures.h +++ b/DataFormats/interface/MuonCandidateFeatures.h @@ -5,7 +5,6 @@ namespace llpdnnx { struct MuonCandidateFeatures { - int jetIdx; int isGlobal; int isTight; int isMedium; @@ -63,7 +62,6 @@ struct MuonCandidateFeatures { MuonCandidateFeatures(): - jetIdx(-1), isGlobal(-1), isTight(-1), isMedium(-1), diff --git a/DataFormats/interface/NeutralCandidateFeatures.h b/DataFormats/interface/NeutralCandidateFeatures.h index 54e3a86..c3648eb 100644 --- a/DataFormats/interface/NeutralCandidateFeatures.h +++ b/DataFormats/interface/NeutralCandidateFeatures.h @@ -7,7 +7,6 @@ namespace llpdnnx { struct NeutralCandidateFeatures { - int jetIdx; float ptrel; float deta; float dphi; @@ -24,7 +23,6 @@ struct NeutralCandidateFeatures float relmassdrop; NeutralCandidateFeatures(): - jetIdx(-1), ptrel(0), deta(0), dphi(0), diff --git a/DataFormats/interface/SecondaryVertexFeatures.h b/DataFormats/interface/SecondaryVertexFeatures.h index 96cfb0c..f416072 100644 --- a/DataFormats/interface/SecondaryVertexFeatures.h +++ b/DataFormats/interface/SecondaryVertexFeatures.h @@ -7,8 +7,6 @@ namespace llpdnnx { struct SecondaryVertexFeatures { - - int jetIdx; float ptrel; float deta; float dphi; @@ -28,7 +26,6 @@ struct SecondaryVertexFeatures float vz; SecondaryVertexFeatures(): - jetIdx(-1), ptrel(0), deta(0), dphi(0), diff --git a/DataFormats/interface/ShallowTagInfoFeatures.h b/DataFormats/interface/ShallowTagInfoFeatures.h index e37813b..3df3fb4 100644 --- a/DataFormats/interface/ShallowTagInfoFeatures.h +++ b/DataFormats/interface/ShallowTagInfoFeatures.h @@ -6,7 +6,6 @@ namespace llpdnnx { struct ShallowTagInfoFeatures { // jet general - int jetIdx; float trackSumJetEtRatio; // ratio of track sum transverse energy over jet energy float trackSumJetDeltaR; // pseudoangular distance between jet axis and track fourvector sum int vertexCategory; // category of secondary vertex (Reco, Pseudo, No) @@ -17,6 +16,19 @@ struct ShallowTagInfoFeatures // track info int jetNTracksEtaRel; // tracks associated to jet for which trackEtaRel is calculated int jetNSelectedTracks; + + ShallowTagInfoFeatures(): + trackSumJetEtRatio(0), // ratio of track sum transverse energy over jet energy + trackSumJetDeltaR(0), // pseudoangular distance between jet axis and track fourvector sum + vertexCategory(0), // category of secondary vertex (Reco, Pseudo, No) + trackSip2dValAboveCharm(0), // track 2D signed impact parameter of first track lifting mass above charm + trackSip2dSigAboveCharm(0), // track 2D signed impact parameter significance of first track lifting mass above charm + trackSip3dValAboveCharm(0), // track 3D signed impact parameter of first track lifting mass above charm + trackSip3dSigAboveCharm(0), // track 3D signed impact parameter significance of first track lifting mass above charm + // track info + jetNTracksEtaRel(0), // tracks associated to jet for which trackEtaRel is calculated + jetNSelectedTracks(0) + {} }; diff --git a/XTagInfoProducer/plugins/XTagInfoProducer.cc b/XTagInfoProducer/plugins/XTagInfoProducer.cc index b059a8c..364cf57 100644 --- a/XTagInfoProducer/plugins/XTagInfoProducer.cc +++ b/XTagInfoProducer/plugins/XTagInfoProducer.cc @@ -828,11 +828,11 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) features.jet_features.jetRchg = jetRchg; features.jet_features.jetR = jetR; - int beta = 0; - int frac01 = 0; - int frac02 = 0; - int frac03 = 0; - int frac04 = 0; + float beta = 0; + features.jet_features.frac01 = 0; + features.jet_features.frac02 = 0; + features.jet_features.frac03 = 0; + features.jet_features.frac04 = 0; float dR2Mean = 0; float pt2Sum = 0; @@ -842,27 +842,28 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) beta += cpf.fromPV; dR2Mean += (cpf.ptrel*cpf.trackDeltaR) * (cpf.ptrel*cpf.trackDeltaR); pt2Sum += (cpf.ptrel) * (cpf.ptrel); - if (cpf.trackDeltaR < 0.1) frac01+=cpf.ptrel; - else if (cpf.trackDeltaR < 0.2) frac02+=cpf.ptrel; - else if (cpf.trackDeltaR < 0.3) frac03+=cpf.ptrel; - else if (cpf.trackDeltaR < 0.4) frac04+=cpf.ptrel; + if (cpf.trackDeltaR < 0.1) features.jet_features.frac01+=cpf.ptrel; + else if (cpf.trackDeltaR < 0.2) features.jet_features.frac02+=cpf.ptrel; + else if (cpf.trackDeltaR < 0.3) features.jet_features.frac03+=cpf.ptrel; + else if (cpf.trackDeltaR < 0.4) features.jet_features.frac04+=cpf.ptrel; } if (features.cpf_features.size() > 0) { - features.jet_features.beta = (float)beta/(float)features.cpf_features.size(); + features.jet_features.beta = 1.*beta/features.cpf_features.size(); } for (size_t i = 0; i < features.npf_features.size(); i++){ llpdnnx::NeutralCandidateFeatures npf = features.npf_features.at(i); dR2Mean += (npf.ptrel*npf.deltaR) * (npf.ptrel*npf.deltaR); pt2Sum += (npf.ptrel) * (npf.ptrel); - if (npf.deltaR < 0.1) frac01+=npf.ptrel; - else if (npf.deltaR < 0.2) frac02+=npf.ptrel; - else if (npf.deltaR < 0.3) frac03+=npf.ptrel; - else if (npf.deltaR < 0.4) frac04+=npf.ptrel; + if (npf.deltaR < 0.1) features.jet_features.frac01+=npf.ptrel; + else if (npf.deltaR < 0.2) features.jet_features.frac02+=npf.ptrel; + else if (npf.deltaR < 0.3) features.jet_features.frac03+=npf.ptrel; + else if (npf.deltaR < 0.4) features.jet_features.frac04+=npf.ptrel; } + features.jet_features.dR2Mean = dR2Mean/pt2Sum; features.jet_features.numberCpf = features.cpf_features.size(); features.jet_features.numberNpf = features.npf_features.size(); From 739f5bb42e65b581f447af22f0e57ff0c3a69734 Mon Sep 17 00:00:00 2001 From: matt-komm Date: Tue, 17 Nov 2020 11:05:29 +0000 Subject: [PATCH 20/20] fix substructure --- DataFormats/interface/ElectronCandidateFeatures.h | 2 -- NANOProducer/plugins/NANOProducer.cc | 1 - XTagInfoProducer/interface/JetSubstructure.h | 2 +- XTagInfoProducer/plugins/XTagInfoProducer.cc | 2 ++ XTagInfoProducer/src/JetSubstructure.cc | 11 ++++++----- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/DataFormats/interface/ElectronCandidateFeatures.h b/DataFormats/interface/ElectronCandidateFeatures.h index 471c067..3289e66 100644 --- a/DataFormats/interface/ElectronCandidateFeatures.h +++ b/DataFormats/interface/ElectronCandidateFeatures.h @@ -77,7 +77,6 @@ struct ElectronCandidateFeatures { int ndof; float chi2; int numberOfBrems; - float trackFbrem; float fbrem; // Isolation block @@ -178,7 +177,6 @@ struct ElectronCandidateFeatures { ndof(0), chi2(0), numberOfBrems(0), - trackFbrem(0), fbrem(0), // Isolation block diff --git a/NANOProducer/plugins/NANOProducer.cc b/NANOProducer/plugins/NANOProducer.cc index 473ce5e..1876a50 100644 --- a/NANOProducer/plugins/NANOProducer.cc +++ b/NANOProducer/plugins/NANOProducer.cc @@ -338,7 +338,6 @@ NANOProducer::NANOProducer(const edm::ParameterSet& iConfig) : PROPERTY(llpdnnx::ElectronCandidateFeatures, ndof, "doc"), PROPERTY(llpdnnx::ElectronCandidateFeatures,chi2, "doc"), PROPERTY(llpdnnx::ElectronCandidateFeatures, numberOfBrems, "doc"), - PROPERTY(llpdnnx::ElectronCandidateFeatures,trackFbrem, "doc"), PROPERTY(llpdnnx::ElectronCandidateFeatures,fbrem, "doc"), // Isolation block diff --git a/XTagInfoProducer/interface/JetSubstructure.h b/XTagInfoProducer/interface/JetSubstructure.h index ec7b757..d9845f2 100644 --- a/XTagInfoProducer/interface/JetSubstructure.h +++ b/XTagInfoProducer/interface/JetSubstructure.h @@ -56,7 +56,7 @@ class JetSubstructure //default values from https://cmssdt.cern.ch/lxr/source/RecoJets/JetProducers/python/nJettinessAdder_cfi.py except R=0.8 -> 0.4 double nSubjettiness( - int n, + size_t n, const fastjet::contrib::AxesDefinition& axisDef = fastjet::contrib::OnePass_KT_Axes(), const fastjet::contrib::MeasureDefinition& measureDef = fastjet::contrib::NormalizedMeasure(1.0, 0.4) ) const; diff --git a/XTagInfoProducer/plugins/XTagInfoProducer.cc b/XTagInfoProducer/plugins/XTagInfoProducer.cc index 364cf57..d0d07b5 100644 --- a/XTagInfoProducer/plugins/XTagInfoProducer.cc +++ b/XTagInfoProducer/plugins/XTagInfoProducer.cc @@ -395,6 +395,7 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) cpf_features.ptrel = constituent->pt()/uncorrectedPt; cpf_features.deta = constituent->eta()-jet.eta(); cpf_features.dphi = reco::deltaPhi(constituent->phi(),jet.phi()); + cpf_features.deltaR = reco::deltaR(*constituent,jet); cpf_features.px = constituent->px(); cpf_features.py = constituent->py(); @@ -729,6 +730,7 @@ XTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) elec_features.elecSC_eSuperClusterOverP = electron.eSuperClusterOverP(); elec_features.neutralHadronIso = electron.neutralHadronIso()/electron.pt(); + elec_features.particleIso = electron.particleIso()/electron.pt(); elec_features.photonIso = electron.photonIso()/electron.pt(); elec_features.puChargedHadronIso = electron.puChargedHadronIso()/electron.pt(); diff --git a/XTagInfoProducer/src/JetSubstructure.cc b/XTagInfoProducer/src/JetSubstructure.cc index 82bec6e..5865734 100644 --- a/XTagInfoProducer/src/JetSubstructure.cc +++ b/XTagInfoProducer/src/JetSubstructure.cc @@ -10,7 +10,7 @@ JetSubstructure::JetSubstructure(const reco::Jet& jet) for(unsigned int iconstituent = 0; iconstituent < jet.numberOfDaughters(); ++iconstituent) { const reco::Candidate* constituent = jet.daughter(iconstituent); - if((constituent->energy() < 1e-10) or (constituent->mass()<1e-10)) + if((constituent->energy() < 1e-10) or (constituent->energy() > 1e5) or (constituent->mass()<0) or std::fabs(constituent->eta())>1e3) { continue; } @@ -30,7 +30,7 @@ JetSubstructure::JetSubstructure(const fastjet::PseudoJet& jet) TLorentzVector jetVectorFromConsituents(0,0,0,0); for(auto const& constituent: jet.constituents()) { - if((constituent.e()<1e-10) or (constituent.m()<1e-10)) + if((constituent.e()<1e-10) or (constituent.e() > 1e5) or (constituent.m()<0) or std::fabs(constituent.eta())>1e3) { continue; } @@ -119,11 +119,12 @@ std::vector JetSubstructure::reclusterExclusive( } double JetSubstructure::nSubjettiness( - int n, + size_t n, const fastjet::contrib::AxesDefinition& axisDef, const fastjet::contrib::MeasureDefinition& measureDef ) const { + if (consituents_.size()<(n+1)) return 0; fastjet::contrib::Njettiness njettiness(axisDef,measureDef); return njettiness.getTau(n, consituents_); } @@ -217,7 +218,7 @@ double JetSubstructure::thrust(bool boostToCM) const double JetSubstructure::relMassDropMass(ClusterType type, double r, double muCut, double yCut) const { if (massFromConstituents_<1e-10) return 0; - if (consituents_.size()<2) return 0; + if (consituents_.size()<3) return 0; fastjet::ClusterSequence clusterSequence(consituents_, makeJetDefinition(type,r)); std::vector reclusteredJets = fastjet::sorted_by_pt( @@ -237,7 +238,7 @@ double JetSubstructure::relMassDropMass(ClusterType type, double r, double muCut double JetSubstructure::relSoftDropMass(ClusterType type, double r, double zCut, double beta) const { if (massFromConstituents_<1e-10) return 0; - if (consituents_.size()<2) return 0; + if (consituents_.size()<3) return 0; fastjet::ClusterSequence clusterSequence(consituents_, makeJetDefinition(type,r)); std::vector reclusteredJets = fastjet::sorted_by_pt(