40 produces<std::vector<TtDilepEvtSolution> >();
63 int selMuonp = -1, selMuonm = -1;
64 int selElectronp = -1, selElectronm = -1;
65 int selTaup = -1, selTaum = -1;
66 bool leptonFound =
false;
73 bool leptonFoundEE =
false;
74 bool leptonFoundMM =
false;
75 bool leptonFoundTT =
false;
76 bool leptonFoundEpMm =
false;
77 bool leptonFoundEmMp =
false;
78 bool leptonFoundEpTm =
false;
79 bool leptonFoundEmTp =
false;
80 bool leptonFoundMpTm =
false;
81 bool leptonFoundMmTp =
false;
82 bool jetsFound =
false;
83 bool METFound =
false;
84 std::vector<int> JetVetoByTaus;
93 if (muons->size() + electrons->size() >= 2) {
95 if (electrons->empty())
97 else if (muons->empty())
99 else if (electrons->size() == 1) {
100 if (muons->size() == 1)
102 else if (
PTComp(&(*electrons)[0], &(*muons)[1]))
106 }
else if (electrons->size() > 1) {
107 if (
PTComp(&(*electrons)[1], &(*muons)[0]))
109 else if (muons->size() == 1)
111 else if (
PTComp(&(*electrons)[0], &(*muons)[1]))
119 leptonFoundEE =
true;
132 leptonFoundEpMm =
true;
136 leptonFoundEmMp =
true;
144 leptonFoundMM =
true;
155 if (jets->size() >= 2) {
162 else if (muons->size() + electrons->size() == 1 && !taus->empty()) {
164 if (muons->size() == 1) {
167 int expectedCharge = -muons->begin()->charge();
168 int* tauIdx =
nullptr;
169 if (expectedCharge < 0) {
172 leptonFoundMpTm =
true;
176 leptonFoundMmTp =
true;
180 std::vector<std::vector<pat::Tau>::const_iterator> subset1;
181 for (std::vector<pat::Tau>::const_iterator
tau = taus->begin();
tau < taus->end(); ++
tau) {
183 *tauIdx =
tau - taus->begin();
185 subset1.push_back(
tau);
190 for (
std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator
tau = subset1.begin();
193 if ((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum() < iso) {
194 *tauIdx = *
tau - taus->begin();
195 iso = (*tau)->isolationPFChargedHadrCandsPtSum();
201 leptonFoundMpTm =
false;
202 leptonFoundMmTp =
false;
206 for (std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet < jets->end(); ++
jet) {
208 JetVetoByTaus.push_back(
jet - jets->begin());
215 int expectedCharge = -electrons->begin()->charge();
216 int* tauIdx =
nullptr;
217 if (expectedCharge < 0) {
220 leptonFoundEpTm =
true;
224 leptonFoundEmTp =
true;
228 std::vector<std::vector<pat::Tau>::const_iterator> subset1;
229 for (std::vector<pat::Tau>::const_iterator
tau = taus->begin();
tau < taus->end(); ++
tau) {
231 *tauIdx =
tau - taus->begin();
233 subset1.push_back(
tau);
238 for (
std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator
tau = subset1.begin();
241 if ((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum() < iso) {
242 *tauIdx = *
tau - taus->begin();
243 iso = (*tau)->isolationPFChargedHadrCandsPtSum();
249 leptonFoundEpTm =
false;
250 leptonFoundEmTp =
false;
254 for (std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet < jets->end(); ++
jet) {
256 JetVetoByTaus.push_back(
jet - jets->begin());
262 jetsFound = ((jets->size() - JetVetoByTaus.size()) >= 2);
263 }
else if (taus->size() > 1) {
267 leptonFoundTT =
true;
276 for (std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet < jets->end(); ++
jet) {
279 JetVetoByTaus.push_back(
jet - jets->begin());
283 jetsFound = ((jets->size() - JetVetoByTaus.size()) >= 2);
287 if (
int(ee) + int(emu) + int(mumu) + int(etau) + int(mutau) + int(tautau) > 1)
288 std::cout <<
"[TtDilepEvtSolutionMaker]: "
289 <<
"Lepton selection criteria uncorrectly defined" << std::endl;
291 bool correctLepton = (leptonFoundEE &&
eeChannel_) || ((leptonFoundEmMp || leptonFoundEpMm) &&
emuChannel_) ||
295 std::vector<TtDilepEvtSolution>* evtsols =
new std::vector<TtDilepEvtSolution>();
296 if (correctLepton && METFound && jetsFound) {
298 unsigned int nrCombJets = 0;
299 unsigned int numberOfJets = 0;
300 for (; nrCombJets < jets->size() && numberOfJets <
nrCombJets_; ++nrCombJets) {
301 if (
find(JetVetoByTaus.begin(), JetVetoByTaus.end(), int(nrCombJets)) == JetVetoByTaus.end())
305 for (
unsigned int ib = 0;
ib < nrCombJets;
ib++) {
307 if (
find(JetVetoByTaus.begin(), JetVetoByTaus.end(), int(
ib)) != JetVetoByTaus.end())
310 for (
unsigned int ibbar = 0; ibbar < nrCombJets; ibbar++) {
315 if (
find(JetVetoByTaus.begin(), JetVetoByTaus.end(), int(ibbar)) != JetVetoByTaus.end())
320 double xconstraint = 0, yconstraint = 0;
322 if (leptonFoundEE || leptonFoundEpMm || leptonFoundEpTm) {
324 xconstraint += (*electrons)[selElectronp].px();
325 yconstraint += (*electrons)[selElectronp].py();
328 if (leptonFoundEE || leptonFoundEmMp || leptonFoundEmTp) {
330 xconstraint += (*electrons)[selElectronm].px();
331 yconstraint += (*electrons)[selElectronm].py();
334 if (leptonFoundMM || leptonFoundEmMp || leptonFoundMpTm) {
336 xconstraint += (*muons)[selMuonp].px();
337 yconstraint += (*muons)[selMuonp].py();
340 if (leptonFoundMM || leptonFoundEpMm || leptonFoundMmTp) {
342 xconstraint += (*muons)[selMuonm].px();
343 yconstraint += (*muons)[selMuonm].py();
346 if (leptonFoundEpTm || leptonFoundMpTm || leptonFoundTT) {
348 xconstraint += (*taus)[selTaum].px();
349 yconstraint += (*taus)[selTaum].py();
352 if (leptonFoundEmTp || leptonFoundMmTp || leptonFoundTT) {
354 xconstraint += (*taus)[selTaup].px();
355 yconstraint += (*taus)[selTaup].py();
361 xconstraint += (*jets)[
ib].px() + (*jets)[ibbar].px() + (*mets)[0].px();
362 yconstraint += (*jets)[
ib].py() + (*jets)[ibbar].py() + (*mets)[0].py();
377 (*myLRSignalSelObservables)(asol,
iEvent);
379 evtsols->push_back(asol);
384 double bestSolDR = 9999.;
387 for (
size_t s = 0;
s < evtsols->size();
s++) {
389 if (dR < bestSolDR) {
395 (*evtsols)[bestSol].setBestSol(
true);
398 std::unique_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
403 evtsols->push_back(asol);
404 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)
void setB(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
edm::EDGetTokenT< std::vector< pat::Muon > > muonSourceToken_
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)
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)