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());
56 return (
l->charge() > 0);
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()) {
144 else if (
muons->empty())
147 if (
muons->size() == 1)
156 else if (
muons->size() == 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;
246 TLorentzVector LV_bbar = TLorentzVector((*
jets)[ibbar].correctedJet(
jetCorrLevel_,
"bottom").
px(),
251 double xconstraint = 0, yconstraint = 0;
254 idcs.push_back(selElectron1);
259 xconstraint += (*electrons)[selElectron1].px();
260 yconstraint += (*electrons)[selElectron1].py();
262 idcs.push_back(selElectron2);
267 xconstraint += (*electrons)[selElectron2].px();
268 yconstraint += (*electrons)[selElectron2].py();
275 if (!isWrongCharge) {
277 idcs.push_back(selElectron1);
282 xconstraint += (*electrons)[selElectron1].px();
283 yconstraint += (*electrons)[selElectron1].py();
288 idcs.push_back(selMuon1);
289 LV_l2.SetXYZT((*
muons)[selMuon1].
px(),
291 (*
muons)[selMuon1].pz(),
293 xconstraint += (*muons)[selMuon1].px();
294 yconstraint += (*muons)[selMuon1].py();
298 idcs.push_back(selMuon1);
299 LV_l1.SetXYZT((*
muons)[selMuon1].
px(),
301 (*
muons)[selMuon1].pz(),
303 xconstraint += (*muons)[selMuon1].px();
304 yconstraint += (*muons)[selMuon1].py();
306 idcs.push_back(selElectron1);
311 xconstraint += (*electrons)[selElectron1].px();
312 yconstraint += (*electrons)[selElectron1].py();
318 idcs.push_back(selElectron1);
323 xconstraint += (*electrons)[selElectron1].px();
324 yconstraint += (*electrons)[selElectron1].py();
328 idcs.push_back(selMuon1);
329 LV_l2.SetXYZT((*
muons)[selMuon1].
px(),
331 (*
muons)[selMuon1].pz(),
333 xconstraint += (*muons)[selMuon1].px();
334 yconstraint += (*muons)[selMuon1].py();
340 idcs.push_back(selElectron1);
345 xconstraint += (*electrons)[selElectron1].px();
346 yconstraint += (*electrons)[selElectron1].py();
350 idcs.push_back(selMuon1);
351 LV_l1.SetXYZT((*
muons)[selMuon1].
px(),
353 (*
muons)[selMuon1].pz(),
355 xconstraint += (*muons)[selMuon1].px();
356 yconstraint += (*muons)[selMuon1].py();
365 idcs.push_back(selMuon1);
368 xconstraint += (*muons)[selMuon1].px();
369 yconstraint += (*muons)[selMuon1].py();
371 idcs.push_back(selMuon2);
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) {
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_
T getParameter(std::string const &) 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_)
virtual double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
~TtFullLepKinSolutionProducer() override
std::vector< double > nupars_
void SetConstraints(const double xx=0, const double yy=0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
U second(std::pair< T, U > const &p)
void produce(edm::Event &evt, const edm::EventSetup &iSetup) override
reco::LeafCandidate neutrino
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_
bool PTComp(const reco::Candidate *, const reco::Candidate *) const
Log< level::Warning, false > LogWarning
reco::LeafCandidate neutrinoBar
TtFullLepKinSolver * solver