4 #include "TLorentzVector.h" 28 bool operator()(std::pair<double, int>
a, std::pair<double, int>
b) {
return a.first >
b.first; }
42 std::unique_ptr<TtFullLepKinSolver>
solver;
46 return (l1->
pt() > l2->
pt());
54 return (
l->charge() > 0);
76 produces<std::vector<std::vector<int> > >();
77 produces<std::vector<reco::LeafCandidate> >(
"fullLepNeutrinos");
78 produces<std::vector<reco::LeafCandidate> >(
"fullLepNeutrinoBars");
79 produces<std::vector<double> >(
"solWeight");
80 produces<bool>(
"isWrongCharge");
87 std::vector<std::vector<int> > idcsV;
88 std::vector<reco::LeafCandidate> nusV;
89 std::vector<reco::LeafCandidate> nuBarsV;
90 std::vector<std::pair<double, int> > weightsV;
93 std::unique_ptr<std::vector<std::vector<int> > > pIdcs(
new std::vector<std::vector<int> >);
94 std::unique_ptr<std::vector<reco::LeafCandidate> > pNus(
new std::vector<reco::LeafCandidate>);
95 std::unique_ptr<std::vector<reco::LeafCandidate> > pNuBars(
new std::vector<reco::LeafCandidate>);
96 std::unique_ptr<std::vector<double> > pWeight(
new std::vector<double>);
97 std::unique_ptr<bool> pWrongCharge(
new bool);
104 int selMuon1 = -1, selMuon2 = -1;
105 int selElectron1 = -1, selElectron2 = -1;
109 bool isWrongCharge =
false;
110 bool jetsFound =
false;
111 bool METFound =
false;
112 bool electronsFound =
false;
113 bool electronMuonFound =
false;
114 bool muonsFound =
false;
117 if (
jets->size() >= 2) {
122 if (!
mets->empty()) {
132 else if (
muons->empty())
135 if (
muons->size() == 1)
144 else if (
muons->size() == 1)
160 electronsFound =
true;
162 isWrongCharge =
true;
168 electronMuonFound =
true;
170 isWrongCharge =
true;
183 isWrongCharge =
true;
188 *pWrongCharge = isWrongCharge;
191 if (
int(ee) +
int(emu) +
int(mumu) > 1) {
192 edm::LogWarning(
"TtFullLepKinSolutionProducer") <<
"Lepton selection criteria uncorrectly defined";
196 bool correctLeptons =
203 if (correctLeptons && METFound && jetsFound) {
208 if (
jets->size() <
static_cast<unsigned int>(stop) || stop < 0)
215 for (
int ib = 0;
ib < stop;
ib++) {
217 for (
int ibbar = 0; ibbar < stop; ibbar++) {
222 std::vector<int> idcs;
226 idcs.push_back(ibbar);
228 TLorentzVector LV_l1;
229 TLorentzVector LV_l2;
234 TLorentzVector LV_bbar = TLorentzVector((*
jets)[ibbar].correctedJet(
jetCorrLevel_,
"bottom").
px(),
239 double xconstraint = 0, yconstraint = 0;
242 idcs.push_back(selElectron1);
247 xconstraint += (*electrons)[selElectron1].px();
248 yconstraint += (*electrons)[selElectron1].py();
250 idcs.push_back(selElectron2);
255 xconstraint += (*electrons)[selElectron2].px();
256 yconstraint += (*electrons)[selElectron2].py();
263 if (!isWrongCharge) {
265 idcs.push_back(selElectron1);
270 xconstraint += (*electrons)[selElectron1].px();
271 yconstraint += (*electrons)[selElectron1].py();
276 idcs.push_back(selMuon1);
277 LV_l2.SetXYZT((*
muons)[selMuon1].
px(),
279 (*
muons)[selMuon1].pz(),
281 xconstraint += (*muons)[selMuon1].px();
282 yconstraint += (*muons)[selMuon1].py();
286 idcs.push_back(selMuon1);
287 LV_l1.SetXYZT((*
muons)[selMuon1].
px(),
289 (*
muons)[selMuon1].pz(),
291 xconstraint += (*muons)[selMuon1].px();
292 yconstraint += (*muons)[selMuon1].py();
294 idcs.push_back(selElectron1);
299 xconstraint += (*electrons)[selElectron1].px();
300 yconstraint += (*electrons)[selElectron1].py();
306 idcs.push_back(selElectron1);
311 xconstraint += (*electrons)[selElectron1].px();
312 yconstraint += (*electrons)[selElectron1].py();
316 idcs.push_back(selMuon1);
317 LV_l2.SetXYZT((*
muons)[selMuon1].
px(),
319 (*
muons)[selMuon1].pz(),
321 xconstraint += (*muons)[selMuon1].px();
322 yconstraint += (*muons)[selMuon1].py();
328 idcs.push_back(selElectron1);
333 xconstraint += (*electrons)[selElectron1].px();
334 yconstraint += (*electrons)[selElectron1].py();
338 idcs.push_back(selMuon1);
339 LV_l1.SetXYZT((*
muons)[selMuon1].
px(),
341 (*
muons)[selMuon1].pz(),
343 xconstraint += (*muons)[selMuon1].px();
344 yconstraint += (*muons)[selMuon1].py();
353 idcs.push_back(selMuon1);
356 xconstraint += (*muons)[selMuon1].px();
357 yconstraint += (*muons)[selMuon1].py();
359 idcs.push_back(selMuon2);
362 xconstraint += (*muons)[selMuon2].px();
363 yconstraint += (*muons)[selMuon2].py();
366 xconstraint += (*jets)[
ib].px() + (*jets)[ibbar].px() + (*mets)[0].px();
367 yconstraint += (*jets)[
ib].py() + (*jets)[ibbar].py() + (*mets)[0].py();
370 solver->SetConstraints(xconstraint, yconstraint);
376 idcsV.push_back(idcs);
383 weightsV.push_back(std::make_pair(nuSol.
weight, nSol));
391 if (weightsV.empty()) {
393 std::vector<int> idcs;
395 for (
int i = 0;
i < 6; ++
i)
398 idcsV.push_back(idcs);
399 weightsV.push_back(std::make_pair(-1, 0));
403 nuBarsV.push_back(nuBar);
407 int weightL = weightsV.
size();
408 int nuL = nusV.size();
409 int nuBarL = nuBarsV.size();
410 int idxL = idcsV.size();
412 if (weightL != nuL || weightL != nuBarL || weightL != idxL) {
414 <<
"Output vectors are of different length:" 415 <<
"\n weight: " << weightL <<
"\n nu: " << nuL <<
"\n nubar: " << nuBarL <<
"\n idcs: " << idxL;
419 if (weightsV.size() > 1) {
428 for (
int i = 0;
i < stop; ++
i) {
429 pWeight->push_back(weightsV[
i].
first);
430 pNus->push_back(nusV[weightsV[
i].
second]);
431 pNuBars->push_back(nuBarsV[weightsV[
i].
second]);
432 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_
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::unique_ptr< TtFullLepKinSolver > solver
virtual double pt() const =0
transverse momentum
std::vector< double > nupars_
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
~TtFullLepKinSolutionProducer() override=default
U second(std::pair< T, U > const &p)
void produce(edm::Event &evt, const edm::EventSetup &iSetup) override
reco::LeafCandidate neutrino
#define DEFINE_FWK_MODULE(type)
bool LepDiffCharge(const reco::Candidate *, const reco::Candidate *) const
virtual int charge() const =0
electric charge
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
bool HasPositiveCharge(const reco::Candidate *) const
std::string jetCorrLevel_
TtFullLepKinSolutionProducer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< std::vector< pat::Electron > > electronsToken_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
bool PTComp(const reco::Candidate *, const reco::Candidate *) const
Log< level::Warning, false > LogWarning
reco::LeafCandidate neutrinoBar