diff --git a/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc b/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc index 415e0846d93d6..ca776d47ae56c 100644 --- a/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc @@ -143,6 +143,7 @@ void VertexTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe iEvent.getByToken(svs_, svsIn); auto selCandSv = std::make_unique>(); std::vector dlen, dlenSig, pAngle, dxy, dxySig; + std::vector charge; VertexDistance3D vdist; VertexDistanceXY vdistXY; @@ -164,6 +165,13 @@ void VertexTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe PV0, VertexState(RecoVertex::convertPos(sv.position()), RecoVertex::convertError(sv.error()))); dxy.push_back(d2d.value()); dxySig.push_back(d2d.significance()); + + int sum_charge = 0; + for (unsigned int id = 0; id < sv.numberOfDaughters(); ++id) { + const reco::Candidate* daughter = sv.daughter(id); + sum_charge += daughter->charge(); + } + charge.push_back(sum_charge); } } i++; @@ -176,6 +184,7 @@ void VertexTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe svsTable->addColumn("dxy", dxy, "2D decay length in cm", 10); svsTable->addColumn("dxySig", dxySig, "2D decay length significance", 10); svsTable->addColumn("pAngle", pAngle, "pointing angle, i.e. acos(p_SV * (SV - PV)) ", 10); + svsTable->addColumn("charge", charge, "sum of the charge of the SV tracks", 10); iEvent.put(std::move(pvTable), "pv"); iEvent.put(std::move(otherPVsTable), "otherPVs"); diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 7ef08b85c3bc7..89a90eb9e6c47 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -669,6 +669,7 @@ Plot1D('y', 'y', 20, -0.5, 0.5, 'secondary vertex Y position, in cm'), Plot1D('z', 'z', 20, -10, 10, 'secondary vertex Z position, in cm'), Plot1D('ntracks', 'ntracks', 11, -0.5, 10.5, 'number of tracks'), + Plot1D('charge', 'charge', 11 , -0.5, 10.5, 'sum of the charge of the SV tracks'), ) ), SoftActivityJet = cms.PSet(