105 int selMuonp = -1, selMuonm = -1;
106 int selElectronp = -1, selElectronm = -1;
107 int selTaup = -1, selTaum = -1;
108 bool leptonFound =
false;
115 bool leptonFoundEE =
false;
116 bool leptonFoundMM =
false;
117 bool leptonFoundTT =
false;
118 bool leptonFoundEpMm =
false;
119 bool leptonFoundEmMp =
false;
120 bool leptonFoundEpTm =
false;
121 bool leptonFoundEmTp =
false;
122 bool leptonFoundMpTm =
false;
123 bool leptonFoundMmTp =
false;
124 bool jetsFound =
false;
125 bool METFound =
false;
126 std::vector<int> JetVetoByTaus;
129 if (!
mets->empty()) {
139 else if (
muons->empty())
142 if (
muons->size() == 1)
151 else if (
muons->size() == 1)
161 leptonFoundEE =
true;
174 leptonFoundEpMm =
true;
178 leptonFoundEmMp =
true;
186 leptonFoundMM =
true;
197 if (
jets->size() >= 2) {
206 if (
muons->size() == 1) {
209 int expectedCharge = -
muons->begin()->charge();
210 int* tauIdx =
nullptr;
211 if (expectedCharge < 0) {
214 leptonFoundMpTm =
true;
218 leptonFoundMmTp =
true;
222 std::vector<std::vector<pat::Tau>::const_iterator> subset1;
223 for (std::vector<pat::Tau>::const_iterator
tau =
taus->begin();
tau <
taus->end(); ++
tau) {
227 subset1.push_back(
tau);
232 for (
std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator
tau = subset1.begin();
235 if ((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum() < iso) {
236 *tauIdx = *
tau -
taus->begin();
237 iso = (*tau)->isolationPFChargedHadrCandsPtSum();
243 leptonFoundMpTm =
false;
244 leptonFoundMmTp =
false;
248 for (std::vector<pat::Jet>::const_iterator
jet =
jets->begin();
jet <
jets->end(); ++
jet) {
250 JetVetoByTaus.push_back(
jet -
jets->begin());
257 int expectedCharge = -
electrons->begin()->charge();
258 int* tauIdx =
nullptr;
259 if (expectedCharge < 0) {
262 leptonFoundEpTm =
true;
266 leptonFoundEmTp =
true;
270 std::vector<std::vector<pat::Tau>::const_iterator> subset1;
271 for (std::vector<pat::Tau>::const_iterator
tau =
taus->begin();
tau <
taus->end(); ++
tau) {
275 subset1.push_back(
tau);
280 for (
std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator
tau = subset1.begin();
283 if ((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum() < iso) {
284 *tauIdx = *
tau -
taus->begin();
285 iso = (*tau)->isolationPFChargedHadrCandsPtSum();
291 leptonFoundEpTm =
false;
292 leptonFoundEmTp =
false;
296 for (std::vector<pat::Jet>::const_iterator
jet =
jets->begin();
jet <
jets->end(); ++
jet) {
298 JetVetoByTaus.push_back(
jet -
jets->begin());
304 jetsFound = ((
jets->size() - JetVetoByTaus.size()) >= 2);
305 }
else if (
taus->size() > 1) {
309 leptonFoundTT =
true;
318 for (std::vector<pat::Jet>::const_iterator
jet =
jets->begin();
jet <
jets->end(); ++
jet) {
321 JetVetoByTaus.push_back(
jet -
jets->begin());
325 jetsFound = ((
jets->size() - JetVetoByTaus.size()) >= 2);
329 if (
int(ee) +
int(emu) +
int(mumu) +
int(etau) +
int(mutau) +
int(tautau) > 1)
330 std::cout <<
"[TtDilepEvtSolutionMaker]: " 331 <<
"Lepton selection criteria uncorrectly defined" << std::endl;
333 bool correctLepton = (leptonFoundEE &&
eeChannel_) || ((leptonFoundEmMp || leptonFoundEpMm) &&
emuChannel_) ||
337 std::vector<TtDilepEvtSolution>* evtsols =
new std::vector<TtDilepEvtSolution>();
338 if (correctLepton && METFound && jetsFound) {
341 unsigned int numberOfJets = 0;
343 if (
find(JetVetoByTaus.begin(), JetVetoByTaus.end(),
int(
nrCombJets)) == JetVetoByTaus.end())
349 if (
find(JetVetoByTaus.begin(), JetVetoByTaus.end(),
int(
ib)) != JetVetoByTaus.end())
352 for (
unsigned int ibbar = 0; ibbar <
nrCombJets; ibbar++) {
357 if (
find(JetVetoByTaus.begin(), JetVetoByTaus.end(),
int(ibbar)) != JetVetoByTaus.end())
362 double xconstraint = 0, yconstraint = 0;
364 if (leptonFoundEE || leptonFoundEpMm || leptonFoundEpTm) {
366 xconstraint += (*electrons)[selElectronp].px();
367 yconstraint += (*electrons)[selElectronp].py();
370 if (leptonFoundEE || leptonFoundEmMp || leptonFoundEmTp) {
372 xconstraint += (*electrons)[selElectronm].px();
373 yconstraint += (*electrons)[selElectronm].py();
376 if (leptonFoundMM || leptonFoundEmMp || leptonFoundMpTm) {
378 xconstraint += (*muons)[selMuonp].px();
379 yconstraint += (*muons)[selMuonp].py();
382 if (leptonFoundMM || leptonFoundEpMm || leptonFoundMmTp) {
384 xconstraint += (*muons)[selMuonm].px();
385 yconstraint += (*muons)[selMuonm].py();
388 if (leptonFoundEpTm || leptonFoundMpTm || leptonFoundTT) {
390 xconstraint += (*taus)[selTaum].px();
391 yconstraint += (*taus)[selTaum].py();
394 if (leptonFoundEmTp || leptonFoundMmTp || leptonFoundTT) {
396 xconstraint += (*taus)[selTaup].px();
397 yconstraint += (*taus)[selTaup].py();
403 xconstraint += (*jets)[
ib].px() + (*jets)[ibbar].px() + (*mets)[0].px();
404 yconstraint += (*jets)[
ib].py() + (*jets)[ibbar].py() + (*mets)[0].py();
419 (*myLRSignalSelObservables)(asol,
iEvent);
421 evtsols->push_back(asol);
426 double bestSolDR = 9999.;
429 for (
size_t s = 0;
s < evtsols->size();
s++) {
430 dR = (*evtsols)[
s].getJetResidual();
431 if (
dR < bestSolDR) {
437 (*evtsols)[bestSol].setBestSol(
true);
440 std::unique_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
445 evtsols->push_back(asol);
446 std::unique_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
edm::EDGetTokenT< std::vector< pat::Jet > > jetSourceToken_
bool HasPositiveCharge(const reco::Candidate *) const
void setElectronm(const edm::Handle< std::vector< pat::Electron > > &elec, int i)
void setElectronp(const edm::Handle< std::vector< pat::Electron > > &elec, int i)
void setB(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
edm::EDGetTokenT< std::vector< pat::Muon > > muonSourceToken_
void SetConstraints(const double xx=0, const double yy=0)
bool LepDiffCharge(const reco::Candidate *, const reco::Candidate *) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
edm::EDGetTokenT< std::vector< pat::Tau > > tauSourceToken_
edm::EDGetTokenT< std::vector< pat::MET > > metSourceToken_
void setMuonm(const edm::Handle< std::vector< pat::Muon > > &muon, int i)
edm::EDGetTokenT< std::vector< pat::Electron > > electronSourceToken_
TtDilepEvtSolution addKinSolInfo(TtDilepEvtSolution *asol)
TtFullLepKinSolver * solver
void setMET(const edm::Handle< std::vector< pat::MET > > &met, int i)
void useWeightFromMC(bool useMC)
void setTaup(const edm::Handle< std::vector< pat::Tau > > &tau, int i)
void setJetCorrectionScheme(int jetCorrScheme)
edm::EDGetTokenT< TtGenEvent > evtSourceToken_
void setGenEvt(const edm::Handle< TtGenEvent > &)
void setMuonp(const edm::Handle< std::vector< pat::Muon > > &muon, int i)
bool PTComp(const reco::Candidate *, const reco::Candidate *) const
void setTaum(const edm::Handle< std::vector< pat::Tau > > &tau, int i)
void setBbar(const edm::Handle< std::vector< pat::Jet > > &jet, int i)