43 produces<std::vector<TtDilepEvtSolution> >();
46 myLRSignalSelObservables->jetSource(jetSource_);
71 int selMuonp = -1, selMuonm = -1;
72 int selElectronp = -1, selElectronm = -1;
73 int selTaup = -1, selTaum = -1;
74 bool leptonFound =
false;
81 bool leptonFoundEE =
false;
82 bool leptonFoundMM =
false;
83 bool leptonFoundTT =
false;
84 bool leptonFoundEpMm =
false;
85 bool leptonFoundEmMp =
false;
86 bool leptonFoundEpTm =
false;
87 bool leptonFoundEmTp =
false;
88 bool leptonFoundMpTm =
false;
89 bool leptonFoundMmTp =
false;
90 bool jetsFound =
false;
91 bool METFound =
false;
92 std::vector<int> JetVetoByTaus;
95 if(mets->size()>=1) { METFound =
true; }
99 if (muons->size() + electrons->size() >=2) {
101 if (electrons->size() == 0) mumu =
true;
102 else if (muons->size() == 0) ee =
true;
103 else if (electrons->size() == 1) {
104 if (muons->size() == 1) emu =
true;
105 else if (
PTComp(&(*electrons)[0], &(*muons)[1])) emu =
true;
108 else if (electrons->size() > 1) {
109 if (
PTComp(&(*electrons)[1], &(*muons)[0])) ee =
true;
110 else if (muons->size() == 1) emu =
true;
111 else if (
PTComp(&(*electrons)[0], &(*muons)[1])) emu =
true;
117 leptonFoundEE =
true;
131 leptonFoundEpMm =
true;
135 leptonFoundEmMp =
true;
144 leptonFoundMM =
true;
155 if(jets->size()>=2) { jetsFound =
true; }
160 else if(muons->size() + electrons->size()==1 && taus->size()>0) {
162 if(muons->size()==1) {
165 int expectedCharge = - muons->begin()->charge();
167 if (expectedCharge<0) {
170 leptonFoundMpTm =
true;
174 leptonFoundMmTp =
true;
178 std::vector<std::vector<pat::Tau>::const_iterator> subset1;
179 for(std::vector<pat::Tau>::const_iterator
tau = taus->begin();
tau < taus->end(); ++
tau ) {
181 *tauIdx =
tau-taus->begin();
183 subset1.push_back(
tau);
188 for(std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator
tau = subset1.begin();
tau < subset1.end(); ++
tau) {
189 if((*tau)->isCaloTau() && (*tau)->isolationTracksPtSum()<iso) {
190 *tauIdx = *
tau - taus->begin();
191 iso = (*tau)->isolationTracksPtSum();
193 if((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum()<iso) {
194 *tauIdx = *
tau - taus->begin();
195 iso = (*tau)->isolationPFChargedHadrCandsPtSum();
200 if(!leptonFound) { leptonFoundMpTm =
false; leptonFoundMmTp =
false; }
203 for(std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet<jets->end(); ++
jet) {
205 JetVetoByTaus.push_back(
jet-jets->begin());
213 int expectedCharge = - electrons->begin()->charge();
215 if (expectedCharge<0) {
218 leptonFoundEpTm =
true;
222 leptonFoundEmTp =
true;
226 std::vector<std::vector<pat::Tau>::const_iterator> subset1;
227 for(std::vector<pat::Tau>::const_iterator
tau = taus->begin();
tau < taus->end(); ++
tau ) {
229 *tauIdx =
tau-taus->begin();
231 subset1.push_back(
tau);
236 for(std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator
tau = subset1.begin();
tau < subset1.end(); ++
tau) {
237 if((*tau)->isCaloTau() && (*tau)->isolationTracksPtSum()<iso) {
238 *tauIdx = *
tau - taus->begin();
239 iso = (*tau)->isolationTracksPtSum();
241 if((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum()<iso) {
242 *tauIdx = *
tau - taus->begin();
243 iso = (*tau)->isolationPFChargedHadrCandsPtSum();
248 if(!leptonFound) { leptonFoundEpTm =
false; leptonFoundEmTp =
false; }
251 for(std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet<jets->end(); ++
jet) {
253 JetVetoByTaus.push_back(
jet-jets->begin());
259 jetsFound = ((jets->size()-JetVetoByTaus.size())>=2);
260 }
else if(taus->size()>1) {
264 leptonFoundTT =
true;
274 for(std::vector<pat::Jet>::const_iterator
jet = jets->begin();
jet<jets->end(); ++
jet) {
276 JetVetoByTaus.push_back(
jet-jets->begin());
280 jetsFound = ((jets->size()-JetVetoByTaus.size())>=2);
284 if(
int(ee)+int(emu)+int(mumu)+int(etau)+int(mutau)+int(tautau)>1)
285 std::cout <<
"[TtDilepEvtSolutionMaker]: "
286 <<
"Lepton selection criteria uncorrectly defined" << std::endl;
288 bool correctLepton = (leptonFoundEE &&
eeChannel_) ||
289 ((leptonFoundEmMp || leptonFoundEpMm) &&
emuChannel_) ||
292 ((leptonFoundEmTp || leptonFoundEpTm) &&
etauChannel_) ||
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()) ++numberOfJets;
304 for (
unsigned int ib = 0;
ib < nrCombJets;
ib++) {
306 if(
find(JetVetoByTaus.begin(),JetVetoByTaus.end(),int(
ib))!=JetVetoByTaus.end())
continue;
308 for (
unsigned int ibbar = 0; ibbar < nrCombJets; ibbar++) {
310 if(
ib==ibbar)
continue;
312 if(
find(JetVetoByTaus.begin(),JetVetoByTaus.end(),int(ibbar))!=JetVetoByTaus.end())
continue;
316 double xconstraint = 0, yconstraint = 0;
318 if (leptonFoundEE || leptonFoundEpMm || leptonFoundEpTm) {
320 xconstraint += (*electrons)[selElectronp].px();
321 yconstraint += (*electrons)[selElectronp].py();
324 if (leptonFoundEE || leptonFoundEmMp || leptonFoundEmTp) {
326 xconstraint += (*electrons)[selElectronm].px();
327 yconstraint += (*electrons)[selElectronm].py();
330 if (leptonFoundMM || leptonFoundEmMp || leptonFoundMpTm) {
332 xconstraint += (*muons)[selMuonp].px();
333 yconstraint += (*muons)[selMuonp].py();
336 if (leptonFoundMM || leptonFoundEpMm || leptonFoundMmTp) {
338 xconstraint += (*muons)[selMuonm].px();
339 yconstraint += (*muons)[selMuonm].py();
342 if (leptonFoundEpTm || leptonFoundMpTm || leptonFoundTT) {
344 xconstraint += (*taus)[selTaum].px();
345 yconstraint += (*taus)[selTaum].py();
348 if (leptonFoundEmTp || leptonFoundMmTp || leptonFoundTT) {
350 xconstraint += (*taus)[selTaup].px();
351 yconstraint += (*taus)[selTaup].py();
357 xconstraint += (*jets)[
ib].px() + (*jets)[ibbar].px() + (*mets)[0].px();
358 yconstraint += (*jets)[
ib].py() + (*jets)[ibbar].py() + (*mets)[0].py();
373 (*myLRSignalSelObservables)(asol,
iEvent);
375 evtsols->push_back(asol);
380 double bestSolDR = 9999.;
383 for(
size_t s=0;
s<evtsols->size();
s++) {
384 dR = (*evtsols)[
s].getJetResidual();
385 if(dR<bestSolDR) { bestSolDR =
dR; bestSol =
s; }
387 if(bestSol!=-1) (*evtsols)[bestSol].setBestSol(
true);
390 std::auto_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
395 evtsols->push_back(asol);
396 std::auto_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
T getParameter(std::string const &) const
edm::InputTag muonSource_
void setElectronm(const edm::Handle< std::vector< pat::Electron > > &elec, int i)
~TtDilepEvtSolutionMaker()
void setElectronp(const edm::Handle< std::vector< pat::Electron > > &elec, int i)
void setB(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
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)
void setMuonm(const edm::Handle< std::vector< pat::Muon > > &muon, int i)
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)
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)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void setJetCorrectionScheme(int jetCorrScheme)
edm::InputTag electronSource_
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)