4 #include "TLorentzVector.h"
30 bool operator()(std::pair<double, int>
a, std::pair<double, int>
b) {
return a.first > b.first; }
48 return (l1->
pt() > l2->
pt());
78 produces<std::vector<std::vector<int> > >();
79 produces<std::vector<reco::LeafCandidate> >(
"fullLepNeutrinos");
80 produces<std::vector<reco::LeafCandidate> >(
"fullLepNeutrinoBars");
81 produces<std::vector<double> >(
"solWeight");
82 produces<bool>(
"isWrongCharge");
95 std::vector<std::vector<int> > idcsV;
96 std::vector<reco::LeafCandidate> nusV;
97 std::vector<reco::LeafCandidate> nuBarsV;
98 std::vector<std::pair<double, int> > weightsV;
101 std::unique_ptr<std::vector<std::vector<int> > > pIdcs(
new std::vector<std::vector<int> >);
102 std::unique_ptr<std::vector<reco::LeafCandidate> > pNus(
new std::vector<reco::LeafCandidate>);
103 std::unique_ptr<std::vector<reco::LeafCandidate> > pNuBars(
new std::vector<reco::LeafCandidate>);
104 std::unique_ptr<std::vector<double> > pWeight(
new std::vector<double>);
105 std::unique_ptr<bool> pWrongCharge(
new bool);
116 int selMuon1 = -1, selMuon2 = -1;
117 int selElectron1 = -1, selElectron2 = -1;
121 bool isWrongCharge =
false;
122 bool jetsFound =
false;
123 bool METFound =
false;
124 bool electronsFound =
false;
125 bool electronMuonFound =
false;
126 bool muonsFound =
false;
129 if (jets->size() >= 2) {
134 if (!mets->empty()) {
140 if (muons->size() + electrons->size() >= 2) {
142 if (electrons->empty())
144 else if (muons->empty())
146 else if (electrons->size() == 1) {
147 if (muons->size() == 1)
149 else if (
PTComp(&(*electrons)[0], &(*muons)[1]))
153 }
else if (electrons->size() > 1) {
154 if (
PTComp(&(*electrons)[1], &(*muons)[0]))
156 else if (muons->size() == 1)
158 else if (
PTComp(&(*electrons)[0], &(*muons)[1]))
172 electronsFound =
true;
174 isWrongCharge =
true;
180 electronMuonFound =
true;
182 isWrongCharge =
true;
195 isWrongCharge =
true;
200 *pWrongCharge = isWrongCharge;
203 if (
int(ee) + int(emu) + int(mumu) > 1) {
204 edm::LogWarning(
"TtFullLepKinSolutionProducer") <<
"Lepton selection criteria uncorrectly defined";
208 bool correctLeptons =
215 if (correctLeptons && METFound && jetsFound) {
220 if (jets->size() <
static_cast<unsigned int>(stop) || stop < 0)
227 for (
int ib = 0;
ib < stop;
ib++) {
229 for (
int ibbar = 0; ibbar < stop; ibbar++) {
234 std::vector<int> idcs;
238 idcs.push_back(ibbar);
240 TLorentzVector LV_l1;
241 TLorentzVector LV_l2;
242 TLorentzVector LV_b = TLorentzVector((*jets)[
ib].correctedJet(
jetCorrLevel_,
"bottom").px(),
246 TLorentzVector LV_bbar = TLorentzVector((*jets)[ibbar].correctedJet(
jetCorrLevel_,
"bottom").px(),
251 double xconstraint = 0, yconstraint = 0;
254 idcs.push_back(selElectron1);
255 LV_l1.SetXYZT((*electrons)[selElectron1].px(),
256 (*electrons)[selElectron1].py(),
257 (*electrons)[selElectron1].pz(),
258 (*electrons)[selElectron1].
energy());
259 xconstraint += (*electrons)[selElectron1].px();
260 yconstraint += (*electrons)[selElectron1].py();
262 idcs.push_back(selElectron2);
263 LV_l2.SetXYZT((*electrons)[selElectron2].px(),
264 (*electrons)[selElectron2].py(),
265 (*electrons)[selElectron2].pz(),
266 (*electrons)[selElectron2].
energy());
267 xconstraint += (*electrons)[selElectron2].px();
268 yconstraint += (*electrons)[selElectron2].py();
275 if (!isWrongCharge) {
277 idcs.push_back(selElectron1);
278 LV_l1.SetXYZT((*electrons)[selElectron1].px(),
279 (*electrons)[selElectron1].py(),
280 (*electrons)[selElectron1].pz(),
281 (*electrons)[selElectron1].
energy());
282 xconstraint += (*electrons)[selElectron1].px();
283 yconstraint += (*electrons)[selElectron1].py();
288 idcs.push_back(selMuon1);
289 LV_l2.SetXYZT((*muons)[selMuon1].px(),
290 (*muons)[selMuon1].py(),
291 (*muons)[selMuon1].pz(),
292 (*muons)[selMuon1].
energy());
293 xconstraint += (*muons)[selMuon1].px();
294 yconstraint += (*muons)[selMuon1].py();
298 idcs.push_back(selMuon1);
299 LV_l1.SetXYZT((*muons)[selMuon1].px(),
300 (*muons)[selMuon1].py(),
301 (*muons)[selMuon1].pz(),
302 (*muons)[selMuon1].
energy());
303 xconstraint += (*muons)[selMuon1].px();
304 yconstraint += (*muons)[selMuon1].py();
306 idcs.push_back(selElectron1);
307 LV_l2.SetXYZT((*electrons)[selElectron1].px(),
308 (*electrons)[selElectron1].py(),
309 (*electrons)[selElectron1].pz(),
310 (*electrons)[selElectron1].
energy());
311 xconstraint += (*electrons)[selElectron1].px();
312 yconstraint += (*electrons)[selElectron1].py();
318 idcs.push_back(selElectron1);
319 LV_l1.SetXYZT((*electrons)[selElectron1].px(),
320 (*electrons)[selElectron1].py(),
321 (*electrons)[selElectron1].pz(),
322 (*electrons)[selElectron1].
energy());
323 xconstraint += (*electrons)[selElectron1].px();
324 yconstraint += (*electrons)[selElectron1].py();
328 idcs.push_back(selMuon1);
329 LV_l2.SetXYZT((*muons)[selMuon1].px(),
330 (*muons)[selMuon1].py(),
331 (*muons)[selMuon1].pz(),
332 (*muons)[selMuon1].
energy());
333 xconstraint += (*muons)[selMuon1].px();
334 yconstraint += (*muons)[selMuon1].py();
340 idcs.push_back(selElectron1);
341 LV_l2.SetXYZT((*electrons)[selElectron1].px(),
342 (*electrons)[selElectron1].py(),
343 (*electrons)[selElectron1].pz(),
344 (*electrons)[selElectron1].
energy());
345 xconstraint += (*electrons)[selElectron1].px();
346 yconstraint += (*electrons)[selElectron1].py();
350 idcs.push_back(selMuon1);
351 LV_l1.SetXYZT((*muons)[selMuon1].px(),
352 (*muons)[selMuon1].py(),
353 (*muons)[selMuon1].pz(),
354 (*muons)[selMuon1].
energy());
355 xconstraint += (*muons)[selMuon1].px();
356 yconstraint += (*muons)[selMuon1].py();
365 idcs.push_back(selMuon1);
367 (*muons)[selMuon1].px(), (*muons)[selMuon1].py(), (*muons)[selMuon1].pz(), (*muons)[selMuon1].
energy());
368 xconstraint += (*muons)[selMuon1].px();
369 yconstraint += (*muons)[selMuon1].py();
371 idcs.push_back(selMuon2);
373 (*muons)[selMuon2].px(), (*muons)[selMuon2].py(), (*muons)[selMuon2].pz(), (*muons)[selMuon2].
energy());
374 xconstraint += (*muons)[selMuon2].px();
375 yconstraint += (*muons)[selMuon2].py();
378 xconstraint += (*jets)[
ib].px() + (*jets)[ibbar].px() + (*mets)[0].px();
379 yconstraint += (*jets)[
ib].py() + (*jets)[ibbar].py() + (*mets)[0].py();
388 idcsV.push_back(idcs);
395 weightsV.push_back(std::make_pair(nuSol.
weight, nSol));
403 if (weightsV.empty()) {
405 std::vector<int> idcs;
407 for (
int i = 0;
i < 6; ++
i)
410 idcsV.push_back(idcs);
411 weightsV.push_back(std::make_pair(-1, 0));
415 nuBarsV.push_back(nuBar);
419 int weightL = weightsV.
size();
420 int nuL = nusV.size();
421 int nuBarL = nuBarsV.size();
422 int idxL = idcsV.size();
424 if (weightL != nuL || weightL != nuBarL || weightL != idxL) {
426 <<
"Output vectors are of different length:"
427 <<
"\n weight: " << weightL <<
"\n nu: " << nuL <<
"\n nubar: " << nuBarL <<
"\n idcs: " << idxL;
431 if (weightsV.size() > 1) {
432 sort(weightsV.begin(), weightsV.end(),
Compare());
440 for (
int i = 0;
i < stop; ++
i) {
441 pWeight->push_back(weightsV[
i].
first);
442 pNus->push_back(nusV[weightsV[
i].
second]);
443 pNuBars->push_back(nuBarsV[weightsV[
i].second]);
444 pIdcs->push_back(idcsV[weightsV[
i].second]);
bool operator()(std::pair< double, int > a, std::pair< double, int > b)
edm::EDGetTokenT< std::vector< pat::Muon > > muonsToken_
bool LepDiffCharge(const reco::Candidate *, const reco::Candidate *) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
NeutrinoSolution getNuSolution(const TLorentzVector &LV_l, const TLorentzVector &LV_l_, const TLorentzVector &LV_b, const TLorentzVector &LV_b_)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
bool HasPositiveCharge(const reco::Candidate *) const
~TtFullLepKinSolutionProducer() override
std::vector< double > nupars_
void SetConstraints(const double xx=0, const double yy=0)
U second(std::pair< T, U > const &p)
void produce(edm::Event &evt, const edm::EventSetup &iSetup) override
bool PTComp(const reco::Candidate *, const reco::Candidate *) const
reco::LeafCandidate neutrino
virtual int charge() const =0
electric charge
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
std::string jetCorrLevel_
T getParameter(std::string const &) const
TtFullLepKinSolutionProducer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< std::vector< pat::Electron > > electronsToken_
Log< level::Warning, false > LogWarning
reco::LeafCandidate neutrinoBar
TtFullLepKinSolver * solver