51 return (l1->
pt() > l2->
pt());
85 produces<std::vector<TtDilepEvtSolution> >();
108 int selMuonp = -1, selMuonm = -1;
109 int selElectronp = -1, selElectronm = -1;
110 int selTaup = -1, selTaum = -1;
111 bool leptonFound =
false;
118 bool leptonFoundEE =
false;
119 bool leptonFoundMM =
false;
120 bool leptonFoundTT =
false;
121 bool leptonFoundEpMm =
false;
122 bool leptonFoundEmMp =
false;
123 bool leptonFoundEpTm =
false;
124 bool leptonFoundEmTp =
false;
125 bool leptonFoundMpTm =
false;
126 bool leptonFoundMmTp =
false;
127 bool jetsFound =
false;
128 bool METFound =
false;
129 std::vector<int> JetVetoByTaus;
132 if (!mets->empty()) {
138 if (muons->size() + electrons->size() >= 2) {
140 if (electrons->empty())
142 else if (muons->empty())
144 else if (electrons->size() == 1) {
145 if (muons->size() == 1)
147 else if (
PTComp(&(*electrons)[0], &(*muons)[1]))
151 }
else if (electrons->size() > 1) {
152 if (
PTComp(&(*electrons)[1], &(*muons)[0]))
154 else if (muons->size() == 1)
156 else if (
PTComp(&(*electrons)[0], &(*muons)[1]))
164 leptonFoundEE =
true;
177 leptonFoundEpMm =
true;
181 leptonFoundEmMp =
true;
189 leptonFoundMM =
true;
200 if (jets->size() >= 2) {
207 else if (muons->size() + electrons->size() == 1 && !taus->empty()) {
209 if (muons->size() == 1) {
212 int expectedCharge = -muons->begin()->charge();
213 int* tauIdx =
nullptr;
214 if (expectedCharge < 0) {
217 leptonFoundMpTm =
true;
221 leptonFoundMmTp =
true;
225 std::vector<std::vector<pat::Tau>::const_iterator> subset1;
226 for (std::vector<pat::Tau>::const_iterator
tau = taus->begin();
tau < taus->end(); ++
tau) {
228 *tauIdx =
tau - taus->begin();
230 subset1.push_back(
tau);
235 for (
std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator
tau = subset1.begin();
238 if ((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum() < iso) {
239 *tauIdx = *
tau - taus->begin();
240 iso = (*tau)->isolationPFChargedHadrCandsPtSum();
246 leptonFoundMpTm =
false;
247 leptonFoundMmTp =
false;
251 for (std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet < jets->end(); ++
jet) {
253 JetVetoByTaus.push_back(
jet - jets->begin());
260 int expectedCharge = -electrons->begin()->charge();
261 int* tauIdx =
nullptr;
262 if (expectedCharge < 0) {
265 leptonFoundEpTm =
true;
269 leptonFoundEmTp =
true;
273 std::vector<std::vector<pat::Tau>::const_iterator> subset1;
274 for (std::vector<pat::Tau>::const_iterator
tau = taus->begin();
tau < taus->end(); ++
tau) {
276 *tauIdx =
tau - taus->begin();
278 subset1.push_back(
tau);
283 for (
std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator
tau = subset1.begin();
286 if ((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum() < iso) {
287 *tauIdx = *
tau - taus->begin();
288 iso = (*tau)->isolationPFChargedHadrCandsPtSum();
294 leptonFoundEpTm =
false;
295 leptonFoundEmTp =
false;
299 for (std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet < jets->end(); ++
jet) {
301 JetVetoByTaus.push_back(
jet - jets->begin());
307 jetsFound = ((jets->size() - JetVetoByTaus.size()) >= 2);
308 }
else if (taus->size() > 1) {
312 leptonFoundTT =
true;
321 for (std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet < jets->end(); ++
jet) {
324 JetVetoByTaus.push_back(
jet - jets->begin());
328 jetsFound = ((jets->size() - JetVetoByTaus.size()) >= 2);
332 if (
int(ee) + int(emu) + int(mumu) + int(etau) + int(mutau) + int(tautau) > 1)
333 std::cout <<
"[TtDilepEvtSolutionMaker]: "
334 <<
"Lepton selection criteria uncorrectly defined" << std::endl;
336 bool correctLepton = (leptonFoundEE &&
eeChannel_) || ((leptonFoundEmMp || leptonFoundEpMm) &&
emuChannel_) ||
340 std::vector<TtDilepEvtSolution>* evtsols =
new std::vector<TtDilepEvtSolution>();
341 if (correctLepton && METFound && jetsFound) {
343 unsigned int nrCombJets = 0;
344 unsigned int numberOfJets = 0;
345 for (; nrCombJets < jets->size() && numberOfJets <
nrCombJets_; ++nrCombJets) {
346 if (
find(JetVetoByTaus.begin(), JetVetoByTaus.end(), int(nrCombJets)) == JetVetoByTaus.end())
350 for (
unsigned int ib = 0;
ib < nrCombJets;
ib++) {
352 if (
find(JetVetoByTaus.begin(), JetVetoByTaus.end(), int(
ib)) != JetVetoByTaus.end())
355 for (
unsigned int ibbar = 0; ibbar < nrCombJets; ibbar++) {
360 if (
find(JetVetoByTaus.begin(), JetVetoByTaus.end(), int(ibbar)) != JetVetoByTaus.end())
365 double xconstraint = 0, yconstraint = 0;
367 if (leptonFoundEE || leptonFoundEpMm || leptonFoundEpTm) {
369 xconstraint += (*electrons)[selElectronp].px();
370 yconstraint += (*electrons)[selElectronp].py();
373 if (leptonFoundEE || leptonFoundEmMp || leptonFoundEmTp) {
375 xconstraint += (*electrons)[selElectronm].px();
376 yconstraint += (*electrons)[selElectronm].py();
379 if (leptonFoundMM || leptonFoundEmMp || leptonFoundMpTm) {
381 xconstraint += (*muons)[selMuonp].px();
382 yconstraint += (*muons)[selMuonp].py();
385 if (leptonFoundMM || leptonFoundEpMm || leptonFoundMmTp) {
387 xconstraint += (*muons)[selMuonm].px();
388 yconstraint += (*muons)[selMuonm].py();
391 if (leptonFoundEpTm || leptonFoundMpTm || leptonFoundTT) {
393 xconstraint += (*taus)[selTaum].px();
394 yconstraint += (*taus)[selTaum].py();
397 if (leptonFoundEmTp || leptonFoundMmTp || leptonFoundTT) {
399 xconstraint += (*taus)[selTaup].px();
400 yconstraint += (*taus)[selTaup].py();
406 xconstraint += (*jets)[
ib].px() + (*jets)[ibbar].px() + (*mets)[0].px();
407 yconstraint += (*jets)[
ib].py() + (*jets)[ibbar].py() + (*mets)[0].py();
422 (*myLRSignalSelObservables)(asol,
iEvent);
424 evtsols->push_back(asol);
429 double bestSolDR = 9999.;
432 for (
size_t s = 0;
s < evtsols->size();
s++) {
434 if (dR < bestSolDR) {
440 (*evtsols)[bestSol].setBestSol(
true);
443 std::unique_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
448 evtsols->push_back(asol);
449 std::unique_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
edm::EDGetTokenT< std::vector< pat::Jet > > jetSourceToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void setElectronm(const edm::Handle< std::vector< pat::Electron > > &elec, int i)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setElectronp(const edm::Handle< std::vector< pat::Electron > > &elec, int i)
virtual double pt() const =0
transverse momentum
void setB(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
edm::EDGetTokenT< std::vector< pat::Muon > > muonSourceToken_
#define DEFINE_FWK_MODULE(type)
bool HasPositiveCharge(const reco::Candidate *) const
void SetConstraints(const double xx=0, const double yy=0)
TtDilepEvtSolutionMaker(const edm::ParameterSet &iConfig)
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_
bool PTComp(const reco::Candidate *, const reco::Candidate *) const
TtDilepEvtSolution addKinSolInfo(TtDilepEvtSolution *asol)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
TtFullLepKinSolver * solver
void setMET(const edm::Handle< std::vector< pat::MET > > &met, int i)
virtual int charge() const =0
electric charge
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)
std::vector< double > nupars_
T getParameter(std::string const &) const
bool LepDiffCharge(const reco::Candidate *, const reco::Candidate *) const
double getJetResidual() const
~TtDilepEvtSolutionMaker() override
void setTaum(const edm::Handle< std::vector< pat::Tau > > &tau, int i)
TtDilepLRSignalSelObservables * myLRSignalSelObservables
void setBbar(const edm::Handle< std::vector< pat::Jet > > &jet, int i)