47 maxDR_(iConfig.getParameter<double>(
"maxDR")) {
48 produces<edm::ValueMap<float>>(
"chargedFromPV0EnergyFraction");
49 produces<edm::ValueMap<float>>(
"chargedFromPV1EnergyFraction");
50 produces<edm::ValueMap<float>>(
"chargedFromPV2EnergyFraction");
51 produces<edm::ValueMap<float>>(
"chargedFromPV3EnergyFraction");
61 const std::vector<float> &
values,
78 unsigned int nJet =
srcJet->size();
82 std::vector<double> jet2pue(nJet, 0);
88 int bestjet = -1, jetidx = 0;
99 jet2pue[bestjet] +=
cand.energy();
102 std::vector<float> chargedFromPV0EnergyFraction(nJet, -1);
103 std::vector<float> chargedFromPV1EnergyFraction(nJet, -1);
104 std::vector<float> chargedFromPV2EnergyFraction(nJet, -1);
105 std::vector<float> chargedFromPV3EnergyFraction(nJet, -1);
107 for (
unsigned int ij = 0; ij < nJet; ++ij) {
108 auto vals = calculateCHSEnergies(
srcJet->ptrAt(ij), jet2pue[ij]);
109 chargedFromPV0EnergyFraction[ij] = std::get<0>(vals);
110 chargedFromPV1EnergyFraction[ij] = std::get<1>(vals);
111 chargedFromPV2EnergyFraction[ij] = std::get<2>(vals);
112 chargedFromPV3EnergyFraction[ij] = std::get<3>(vals);
115 fillValueMaps(
"chargedFromPV0EnergyFraction", chargedFromPV0EnergyFraction,
srcJet,
iEvent);
116 fillValueMaps(
"chargedFromPV1EnergyFraction", chargedFromPV1EnergyFraction,
srcJet,
iEvent);
117 fillValueMaps(
"chargedFromPV2EnergyFraction", chargedFromPV2EnergyFraction,
srcJet,
iEvent);
118 fillValueMaps(
"chargedFromPV3EnergyFraction", chargedFromPV3EnergyFraction,
srcJet,
iEvent);
121 template <
typename T>
123 const std::vector<float> &
values,
133 template <
typename T>
135 double chefrompv0)
const {
137 double chefrompv1 = 0.0;
138 double chefrompv2 = 0.0;
139 double chefrompv3 = 0.0;
144 auto *dtr = dynamic_cast<const pat::PackedCandidate *>(ijet->
daughter(pidx));
145 if (dtr->charge() == 0)
147 if (dtr->fromPV() == 1)
148 chefrompv1 += dtr->energy();
149 else if (dtr->fromPV() == 2)
150 chefrompv2 += dtr->energy();
151 else if (dtr->fromPV() == 3)
152 chefrompv3 += dtr->energy();
157 double chffpv0 = chefrompv0 / rawP4.energy();
158 double chffpv1 = chefrompv1 / rawP4.energy();
159 double chffpv2 = chefrompv2 / rawP4.energy();
160 double chffpv3 = chefrompv3 / rawP4.energy();
162 return std::tuple<float, float, float, float>(chffpv0, chffpv1, chffpv2, chffpv3);
165 template <
typename T>
170 desc.add<
double>(
"maxDR")->setComment(
"Maximum DR to consider for jet-->pf cand association");