42 produces<std::vector<TtDilepEvtSolution> >();
69 int selMuonp = -1, selMuonm = -1;
70 int selElectronp = -1, selElectronm = -1;
71 int selTaup = -1, selTaum = -1;
72 bool leptonFound =
false;
79 bool leptonFoundEE =
false;
80 bool leptonFoundMM =
false;
81 bool leptonFoundTT =
false;
82 bool leptonFoundEpMm =
false;
83 bool leptonFoundEmMp =
false;
84 bool leptonFoundEpTm =
false;
85 bool leptonFoundEmTp =
false;
86 bool leptonFoundMpTm =
false;
87 bool leptonFoundMmTp =
false;
88 bool jetsFound =
false;
89 bool METFound =
false;
90 std::vector<int> JetVetoByTaus;
93 if(mets->size()>=1) { METFound =
true; }
97 if (muons->size() + electrons->size() >=2) {
99 if (electrons->size() == 0) mumu =
true;
100 else if (muons->size() == 0) ee =
true;
101 else if (electrons->size() == 1) {
102 if (muons->size() == 1) emu =
true;
103 else if (
PTComp(&(*electrons)[0], &(*muons)[1])) emu =
true;
106 else if (electrons->size() > 1) {
107 if (
PTComp(&(*electrons)[1], &(*muons)[0])) ee =
true;
108 else if (muons->size() == 1) emu =
true;
109 else if (
PTComp(&(*electrons)[0], &(*muons)[1])) emu =
true;
115 leptonFoundEE =
true;
129 leptonFoundEpMm =
true;
133 leptonFoundEmMp =
true;
142 leptonFoundMM =
true;
153 if(jets->size()>=2) { jetsFound =
true; }
158 else if(muons->size() + electrons->size()==1 && taus->size()>0) {
160 if(muons->size()==1) {
163 int expectedCharge = - muons->begin()->charge();
165 if (expectedCharge<0) {
168 leptonFoundMpTm =
true;
172 leptonFoundMmTp =
true;
176 std::vector<std::vector<pat::Tau>::const_iterator> subset1;
177 for(std::vector<pat::Tau>::const_iterator
tau = taus->begin();
tau < taus->end(); ++
tau ) {
179 *tauIdx =
tau-taus->begin();
181 subset1.push_back(
tau);
186 for(std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator
tau = subset1.begin();
tau < subset1.end(); ++
tau) {
187 if((*tau)->isCaloTau() && (*tau)->isolationTracksPtSum()<iso) {
188 *tauIdx = *
tau - taus->begin();
189 iso = (*tau)->isolationTracksPtSum();
191 if((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum()<iso) {
192 *tauIdx = *
tau - taus->begin();
193 iso = (*tau)->isolationPFChargedHadrCandsPtSum();
198 if(!leptonFound) { leptonFoundMpTm =
false; leptonFoundMmTp =
false; }
201 for(std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet<jets->end(); ++
jet) {
203 JetVetoByTaus.push_back(
jet-jets->begin());
211 int expectedCharge = - electrons->begin()->charge();
213 if (expectedCharge<0) {
216 leptonFoundEpTm =
true;
220 leptonFoundEmTp =
true;
224 std::vector<std::vector<pat::Tau>::const_iterator> subset1;
225 for(std::vector<pat::Tau>::const_iterator
tau = taus->begin();
tau < taus->end(); ++
tau ) {
227 *tauIdx =
tau-taus->begin();
229 subset1.push_back(
tau);
234 for(std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator
tau = subset1.begin();
tau < subset1.end(); ++
tau) {
235 if((*tau)->isCaloTau() && (*tau)->isolationTracksPtSum()<iso) {
236 *tauIdx = *
tau - taus->begin();
237 iso = (*tau)->isolationTracksPtSum();
239 if((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum()<iso) {
240 *tauIdx = *
tau - taus->begin();
241 iso = (*tau)->isolationPFChargedHadrCandsPtSum();
246 if(!leptonFound) { leptonFoundEpTm =
false; leptonFoundEmTp =
false; }
249 for(std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet<jets->end(); ++
jet) {
251 JetVetoByTaus.push_back(
jet-jets->begin());
257 jetsFound = ((jets->size()-JetVetoByTaus.size())>=2);
258 }
else if(taus->size()>1) {
262 leptonFoundTT =
true;
272 for(std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet<jets->end(); ++
jet) {
274 JetVetoByTaus.push_back(
jet-jets->begin());
278 jetsFound = ((jets->size()-JetVetoByTaus.size())>=2);
282 if(
int(ee)+int(emu)+int(mumu)+int(etau)+int(mutau)+int(tautau)>1)
283 std::cout <<
"[TtDilepEvtSolutionMaker]: "
284 <<
"Lepton selection criteria uncorrectly defined" << std::endl;
286 bool correctLepton = (leptonFoundEE &&
eeChannel_) ||
287 ((leptonFoundEmMp || leptonFoundEpMm) &&
emuChannel_) ||
290 ((leptonFoundEmTp || leptonFoundEpTm) &&
etauChannel_) ||
293 std::vector<TtDilepEvtSolution> * evtsols =
new std::vector<TtDilepEvtSolution>();
294 if(correctLepton && METFound && jetsFound) {
296 unsigned int nrCombJets = 0;
298 for(; nrCombJets<jets->size() && numberOfJets<
nrCombJets_; ++nrCombJets) {
299 if(
find(JetVetoByTaus.begin(),JetVetoByTaus.end(),int(nrCombJets))==JetVetoByTaus.end()) ++numberOfJets;
302 for (
unsigned int ib = 0;
ib < nrCombJets;
ib++) {
304 if(
find(JetVetoByTaus.begin(),JetVetoByTaus.end(),int(
ib))!=JetVetoByTaus.end())
continue;
306 for (
unsigned int ibbar = 0; ibbar < nrCombJets; ibbar++) {
308 if(
ib==ibbar)
continue;
310 if(
find(JetVetoByTaus.begin(),JetVetoByTaus.end(),int(ibbar))!=JetVetoByTaus.end())
continue;
314 double xconstraint = 0, yconstraint = 0;
316 if (leptonFoundEE || leptonFoundEpMm || leptonFoundEpTm) {
318 xconstraint += (*electrons)[selElectronp].px();
319 yconstraint += (*electrons)[selElectronp].py();
322 if (leptonFoundEE || leptonFoundEmMp || leptonFoundEmTp) {
324 xconstraint += (*electrons)[selElectronm].px();
325 yconstraint += (*electrons)[selElectronm].py();
328 if (leptonFoundMM || leptonFoundEmMp || leptonFoundMpTm) {
330 xconstraint += (*muons)[selMuonp].px();
331 yconstraint += (*muons)[selMuonp].py();
334 if (leptonFoundMM || leptonFoundEpMm || leptonFoundMmTp) {
336 xconstraint += (*muons)[selMuonm].px();
337 yconstraint += (*muons)[selMuonm].py();
340 if (leptonFoundEpTm || leptonFoundMpTm || leptonFoundTT) {
342 xconstraint += (*taus)[selTaum].px();
343 yconstraint += (*taus)[selTaum].py();
346 if (leptonFoundEmTp || leptonFoundMmTp || leptonFoundTT) {
348 xconstraint += (*taus)[selTaup].px();
349 yconstraint += (*taus)[selTaup].py();
355 xconstraint += (*jets)[
ib].px() + (*jets)[ibbar].px() + (*mets)[0].px();
356 yconstraint += (*jets)[
ib].py() + (*jets)[ibbar].py() + (*mets)[0].py();
371 (*myLRSignalSelObservables)(asol,
iEvent);
373 evtsols->push_back(asol);
378 double bestSolDR = 9999.;
381 for(
size_t s=0;
s<evtsols->size();
s++) {
382 dR = (*evtsols)[
s].getJetResidual();
383 if(dR<bestSolDR) { bestSolDR =
dR; bestSol =
s; }
385 if(bestSol!=-1) (*evtsols)[bestSol].setBestSol(
true);
388 std::auto_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
393 evtsols->push_back(asol);
394 std::auto_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
edm::EDGetTokenT< std::vector< pat::Jet > > jetSourceToken_
T getParameter(std::string const &) const
void setElectronm(const edm::Handle< std::vector< pat::Electron > > &elec, int i)
~TtDilepEvtSolutionMaker()
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
TtDilepEvtSolution addKinSolInfo(TtDilepEvtSolution *asol)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TtFullLepKinSolver * solver
void setMET(const edm::Handle< std::vector< pat::MET > > &met, int i)
unsigned int numberOfJets(HWW &hww, unsigned int)
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_
bool LepDiffCharge(const reco::Candidate *, const reco::Candidate *) const
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
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)