89 dlenMin_(
params.getParameter<double>(
"dlenMin")),
90 dlenSigMin_(
params.getParameter<double>(
"dlenSigMin"))
93 produces<nanoaod::FlatTable>(
"pv");
94 produces<nanoaod::FlatTable>(
"otherPVs");
95 produces<nanoaod::FlatTable>(
"svs");
96 produces<edm::PtrVector<reco::VertexCompositePtrCandidate>>();
113 auto pvTable = std::make_unique<nanoaod::FlatTable>(1,
pvName_,
true);
114 pvTable->addColumnValue<
float>(
"ndof", (*pvsIn)[0].ndof(),
"main primary vertex number of degree of freedom", 8);
115 pvTable->addColumnValue<
float>(
"x", (*pvsIn)[0].position().x(),
"main primary vertex position x coordinate", 10);
116 pvTable->addColumnValue<
float>(
"y", (*pvsIn)[0].position().y(),
"main primary vertex position y coordinate", 10);
117 pvTable->addColumnValue<
float>(
"z", (*pvsIn)[0].position().z(),
"main primary vertex position z coordinate", 16);
118 pvTable->addColumnValue<
float>(
"chi2", (*pvsIn)[0].normalizedChi2(),
"main primary vertex reduced chi2", 8);
120 for (
const auto&
pv : *pvsIn)
123 pvTable->addColumnValue<uint8_t>(
"npvs", pvsIn->size(),
"total number of reconstructed primary vertices");
124 pvTable->addColumnValue<uint8_t>(
126 pvTable->addColumnValue<
float>(
127 "score", pvsScoreProd.get(pvsIn.id(), 0),
"main primary vertex score, i.e. sum pt2 of clustered objects", 8);
129 float pv_sumpt2 = 0.0, pv_sumpx = 0.0, pv_sumpy = 0.0;
130 for (
const auto&
obj : *pfcIn) {
131 if (
obj.charge() == 0) {
134 double dz = fabs(
obj.dz((*pvsIn)[0].position()));
135 bool include_pfc =
false;
138 for (
size_t j = 1;
j < (*pvsIn).size();
j++) {
139 double newdz = fabs(
obj.dz((*pvsIn)[
j].position()));
147 float pfc_pt =
obj.pt();
148 pv_sumpt2 += pfc_pt * pfc_pt;
149 pv_sumpx +=
obj.px();
150 pv_sumpy +=
obj.py();
153 pvTable->addColumnValue<
float>(
154 "sumpt2", pv_sumpt2,
"sum pt2 of pf charged candidates for the main primary vertex", 10);
155 pvTable->addColumnValue<
float>(
"sumpx", pv_sumpx,
"sum px of pf charged candidates for the main primary vertex", 10);
156 pvTable->addColumnValue<
float>(
"sumpy", pv_sumpy,
"sum py of pf charged candidates for the main primary vertex", 10);
159 std::make_unique<nanoaod::FlatTable>((*pvsIn).size() > 4 ? 3 : (*pvsIn).size() - 1,
"Other" +
pvName_,
false);
160 std::vector<float> pvsz;
161 std::vector<float> pvscores;
162 for (
size_t i = 1;
i < (*pvsIn).size() &&
i < 4;
i++) {
164 pvscores.push_back(pvsScoreProd.get(pvsIn.id(),
i));
166 otherPVsTable->addColumn<
float>(
"z", pvsz,
"Z position of other primary vertices, excluding the main PV", 8);
167 otherPVsTable->addColumn<
float>(
"score", pvscores,
"scores of other primary vertices, excluding the main PV", 8);
170 auto selCandSv = std::make_unique<PtrVector<reco::VertexCompositePtrCandidate>>();
171 std::vector<float> dlen, dlenSig, pAngle,
dxy, dxySig;
172 std::vector<int16_t>
charge;
177 const auto& PV0 = pvsIn->front();
178 for (
const auto&
sv : svsProd) {
183 dlen.push_back(dl.
value());
185 selCandSv->push_back(svsProd.ptrAt(
i));
186 double dx = (PV0.x() -
sv.vx()),
dy = (PV0.y() -
sv.vy()),
dz = (PV0.z() -
sv.vz());
188 pAngle.push_back(std::acos(pdotv));
195 for (
unsigned int id = 0;
id <
sv.numberOfDaughters(); ++
id) {
197 sum_charge += daughter->
charge();
199 charge.push_back(sum_charge);
205 auto svsTable = std::make_unique<nanoaod::FlatTable>(selCandSv->size(),
svName_,
false);
208 svsTable->addColumn<
float>(
"dlen", dlen,
"decay length in cm", 10);
209 svsTable->addColumn<
float>(
"dlenSig", dlenSig,
"decay length significance", 10);
210 svsTable->addColumn<
float>(
"dxy",
dxy,
"2D decay length in cm", 10);
211 svsTable->addColumn<
float>(
"dxySig", dxySig,
"2D decay length significance", 10);
212 svsTable->addColumn<
float>(
"pAngle", pAngle,
"pointing angle, i.e. acos(p_SV * (SV - PV)) ", 10);
213 svsTable->addColumn<int16_t>(
"charge",
charge,
"sum of the charge of the SV tracks", 10);
226 "std::vector<reco::Vertex> and ValueMap<float> primary vertex input collections");
227 desc.add<
edm::InputTag>(
"pfcSrc")->setComment(
"packedPFCandidates input collections");
228 desc.add<
std::string>(
"goodPvCut")->setComment(
"selection on the primary vertex");
230 "reco::VertexCompositePtrCandidate compatible secondary vertex input collection");
231 desc.add<
std::string>(
"svCut")->setComment(
"selection on the secondary vertex");
233 desc.add<
double>(
"dlenMin")->setComment(
"minimum value of dl to select secondary vertex");
234 desc.add<
double>(
"dlenSigMin")->setComment(
"minimum value of dl significance to select secondary vertex");
236 desc.add<
std::string>(
"pvName")->setComment(
"name of the flat table ouput");
237 desc.add<
std::string>(
"svName")->setComment(
"name of the flat table ouput");
238 desc.add<
std::string>(
"svDoc")->setComment(
"a few words of documentation");
reco::Vertex::Point convertPos(const GlobalPoint &p)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvs_
const std::string pvName_
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
reco::Vertex::Error convertError(const GlobalError &ge)
std::vector< pat::PackedCandidate > PackedCandidateCollection
const edm::EDGetTokenT< edm::ValueMap< float > > pvsScore_
const std::string goodPvCutString_
goodPVs
Good Primary Vertex Selection.
VertexTableProducer(const edm::ParameterSet &)
const edm::EDGetTokenT< edm::View< reco::VertexCompositePtrCandidate > > svs_
#define DEFINE_FWK_MODULE(type)
virtual int charge() const =0
electric charge
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
void produce(edm::Event &, const edm::EventSetup &) override
double significance() const
const std::string svName_
static int position[264][3]
const StringCutObjectSelector< reco::Vertex > goodPvCut_
const edm::EDGetTokenT< pat::PackedCandidateCollection > pfc_
const StringCutObjectSelector< reco::Candidate > svCut_