ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/src/HbbCandidateFinderAlgo.cc
Revision: 1.44.2.2
Committed: Mon Nov 19 20:53:45 2012 UTC (12 years, 5 months ago) by ntran
Content type: text/plain
Branch: hbbsubstructDevPostHCP
CVS Tags: hbbsubstructDev_4, hbbsubstructDev_3, hbbsubstructDev_2, hbbsubstructDev_1
Changes since 1.44.2.1: +1 -1 lines
Log Message:
update with all the new jet collections

File Contents

# User Rev Content
1 tboccali 1.1 #include "VHbbAnalysis/VHbbDataFormats/interface/HbbCandidateFinderAlgo.h"
2     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbCandidateTools.h"
3 arizzi 1.24 #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEventAuxInfo.h"
4    
5 ntran 1.44.2.1 #include "VHbbAnalysis/VHbbDataFormats/interface/JetSubstructureTools.h"
6    
7 dlopes 1.19 #include "DataFormats/Math/interface/deltaR.h"
8 tboccali 1.10 #include <algorithm>
9 tboccali 1.1
10     #include <iostream>
11     #include<cstdlib>
12    
13     struct CompareJetPt {
14 ntran 1.44.2.1 bool operator()( const VHbbEvent::SimpleJet& j1, const VHbbEvent::SimpleJet& j2 ) const {
15     return j1.p4.Pt() > j2.p4.Pt();
16     }
17 tboccali 1.1 };
18    
19     struct CompareBTag {
20 ntran 1.44.2.1 bool operator()(const VHbbEvent::SimpleJet& j1, const VHbbEvent::SimpleJet& j2 ) const {
21     return j1.csv > j2.csv;
22     }
23 tboccali 1.1 };
24    
25 arizzi 1.5 VHbbCandidate HbbCandidateFinderAlgo::changeHiggs(bool useHighestPtHiggs , const VHbbCandidate & old)
26     {
27 ntran 1.44.2.1 VHbbCandidateTools selector(verbose_);
28    
29     VHbbCandidate temp(old);
30     VHbbEvent::SimpleJet j1,j2;
31     std::vector<VHbbEvent::SimpleJet> addJets;
32     std::vector<VHbbEvent::SimpleJet> jets;
33    
34     for(size_t i=0; i < old.H.jets.size();i++) jets.push_back(old.H.jets[i]);
35     for(size_t i=0; i < old.additionalJets.size();i++) jets.push_back(old.additionalJets[i]);
36    
37     bool foundJets;
38    
39     if (useHighestPtHiggs == false){
40     foundJets = findDiJets(jets,j1,j2,addJets) ;
41     }else{
42     foundJets= findDiJetsHighestPt(jets,j1,j2,addJets) ;
43     }
44    
45     temp.H.jets.clear();
46     temp.H.jets.push_back(j1);
47     temp.H.jets.push_back(j2);
48     temp.H.p4 = (j1).p4+(j2).p4;
49     TVector3 higgsBoost;
50     higgsBoost = (temp.H.p4).BoostVector();
51     temp.H.helicities.clear();
52     temp.H.helicities.push_back(selector.getHelicity(j1,higgsBoost));
53     temp.H.helicities.push_back(selector.getHelicity(j2,higgsBoost));
54     temp.H.deltaTheta = selector.getDeltaTheta(j1,j2);
55     temp.additionalJets = addJets;
56     return temp;
57    
58 arizzi 1.5 }
59 tboccali 1.1
60    
61    
62 arizzi 1.24 void HbbCandidateFinderAlgo::run (const VHbbEvent* event, std::vector<VHbbCandidate> & candidates,const VHbbEventAuxInfo & aux){
63 ntran 1.44.2.1 //
64     // search for leptons
65     //
66     std::vector<VHbbEvent::MuonInfo> mu;
67     std::vector<VHbbEvent::ElectronInfo> ele;
68     // std::vector<VHbbEvent::MuonInfo> mu;
69     std::vector<unsigned int> muPos;
70     findMuons(event->muInfo,mu, muPos,aux);
71     // std::vector<VHbbEvent::ElectronInfo> ele;
72     std::vector<unsigned int> elePos;
73     findElectrons(event->eleInfo,ele, elePos,aux);
74    
75     std::vector<VHbbEvent::TauInfo> tau;
76     std::vector<unsigned int> tauPos;
77     findTaus(event->tauInfo,tau, tauPos);
78    
79     //FIXME: cleaning here
80    
81     //
82     // first find the jets
83     //
84    
85     VHbbCandidateTools selector(verbose_);
86     std::vector<VHbbEvent::SimpleJet> noOverlap;
87     for(size_t j=0; j< event->simpleJets2.size(); j++)
88     {
89     float overlap=false;
90     for(size_t i=0; i< mu.size(); i++) {
91     if(deltaR(mu[i].p4.Eta(),mu[i].p4.Phi(),event->simpleJets2[j].p4.Eta(),event->simpleJets2[j].p4.Phi()) < 0.5) overlap=true;
92     }
93     for(size_t i=0; i< ele.size(); i++) {
94     if(deltaR(ele[i].p4.Eta(),ele[i].p4.Phi(),event->simpleJets2[j].p4.Eta(),event->simpleJets2[j].p4.Phi()) < 0.5) overlap=true;
95     }
96    
97     if(!overlap) noOverlap.push_back(event->simpleJets2[j]);
98     else
99     {
100     // std::cout << "jet removed in cleaning" << std::endl;
101     }
102     }
103    
104    
105     VHbbEvent::SimpleJet j1,j2;
106     std::vector<VHbbEvent::SimpleJet> addJets;
107     bool foundJets;
108     if (useHighestPtHiggs_ == false){
109     foundJets = findDiJets(noOverlap,j1,j2,addJets) ;
110     }else{
111     foundJets= findDiJetsHighestPt(noOverlap,j1,j2,addJets) ;
112     }
113    
114     if (verbose_){
115     std::cout <<" Found Dijets: "<<foundJets<< " Additional: "<<addJets.size()<< std::endl;
116     }
117    
118     // if (foundJets == false) return;
119    
120    
121     bool foundHardJets;
122     VHbbEvent::HardJet fatj1;
123     std::vector<VHbbEvent::SimpleJet> subJetsout;
124     std::vector<VHbbEvent::SimpleJet> addJetsFat;
125     // foundHardJets= findFatJet(event->hardJets,event->subJets,event->filterJets,fatj1,subJetsout, event->simpleJets2, addJetsFat, mu, ele) ;
126     foundHardJets= findFatJet(event->hardJets,event->subJets,event->filterJets,fatj1,subJetsout, event->simpleJets2, addJetsFat, event->muInfo, event->eleInfo) ;
127    
128     if (foundJets == false && foundHardJets == false) return;
129    
130     std::vector<VHbbEvent::METInfo> met;
131    
132     // findMET(event->pfmet, met);
133     findMET(event->pfmetType1corr, met);
134    
135     if (verbose_){
136     std::cout <<" Electrons: "<< ele.size()<<std::endl;
137     std::cout <<" Muons : "<< mu.size()<<std::endl;
138     std::cout <<" Taus : "<< tau.size()<<std::endl;
139     std::cout <<" MET : "<< met.size()<<std::endl;
140     }
141     if (ele.size()<1 && mu.size() < 1 && met.size()<1 && tau.size()<1) return;
142     //
143     // fill!
144     //
145     VHbbCandidate temp;
146     temp.H.HiggsFlag = foundJets;
147     if(foundJets){
148     temp.H.jets.push_back(j1);
149     temp.H.jets.push_back(j2);
150     temp.H.p4 = (j1).p4+(j2).p4;
151     TVector3 higgsBoost;
152     higgsBoost = (temp.H.p4).BoostVector();
153     temp.H.helicities.push_back(selector.getHelicity(j1,higgsBoost));
154     temp.H.helicities.push_back(selector.getHelicity(j2,higgsBoost));
155     temp.H.deltaTheta = selector.getDeltaTheta(j1,j2);
156     }
157    
158     temp.FatH.FatHiggsFlag= foundHardJets;
159     if(foundHardJets){
160     temp.FatH.p4 = fatj1.p4;
161     temp.FatH.subjetsSize=subJetsout.size();
162     if(subJetsout.size()==2) {temp.FatH.jets.push_back(subJetsout[0]);temp.FatH.jets.push_back(subJetsout[1]);}
163     if(subJetsout.size()==3) {temp.FatH.jets.push_back(subJetsout[0]);
164     temp.FatH.jets.push_back(subJetsout[1]);temp.FatH.jets.push_back(subJetsout[2]);}
165     }
166    
167    
168     // ***********************************
169     // added by Nhan
170     std::cout << "My Fat H!!!! -------" << std::endl;
171     bool foundRawJets = false;
172 ntran 1.44.2.2 std::vector< VHbbEvent::RawJet > rjets = event->CA12wConstits;
173 ntran 1.44.2.1 // for (unsigned int kk = 0; kk < rjets.size(); kk++){
174     //
175     // std::cout << "rjet #" << kk << ": " << rjets[kk].p4.Pt() << std::endl;
176     //
177     // }
178     if (rjets.size() > 0){
179     JetSubstructureTools tmpJet( rjets[0].constituents_px, rjets[0].constituents_py, rjets[0].constituents_pz, rjets[0].constituents_e, rjets[0].constituents_pdgId ) ;
180    
181     temp.RawFatH.p4 = rjets[0].p4;
182     temp.RawFatH.RawFatHiggsFlag = true;
183     temp.RawFatH.prunedJetMass = tmpJet.prunedJetMass_;
184     temp.RawFatH.trimmedJetMass = tmpJet.trimmedJetMass_;
185     temp.RawFatH.filteredJetMass = tmpJet.filteredJetMass_;
186     temp.RawFatH.ungroomedJetMass = tmpJet.ungroomedJetMass_;
187     // std::cout << "jet pT: " << rjets[0].p4.Pt() << std::endl;
188     temp.RawFatH.pT_pr = rjets[0].p4.Pt();
189     temp.RawFatH.eta_pr = rjets[0].p4.Eta();
190     temp.RawFatH.px_pr = rjets[0].p4.Px();
191     temp.RawFatH.py_pr = rjets[0].p4.Py();
192     temp.RawFatH.pz_pr = rjets[0].p4.Pz();
193     temp.RawFatH.e_pr = rjets[0].p4.E();
194    
195     temp.RawFatH.tau1 = tmpJet.tau1_;
196     temp.RawFatH.tau2 = tmpJet.tau2_;
197     temp.RawFatH.tau3 = tmpJet.tau3_;
198     temp.RawFatH.tau4 = tmpJet.tau4_;
199    
200     // std::cout << "tmpJet.tau1 = " << tmpJet.tau1_ << std::endl;
201     // std::cout << "tmpJet.tau2 = " << tmpJet.tau2_ << std::endl;
202    
203     temp.RawFatH.sj1_px_pr = tmpJet.prunedSubJet1_.px();
204     temp.RawFatH.sj1_py_pr = tmpJet.prunedSubJet1_.py();
205     temp.RawFatH.sj1_pz_pr = tmpJet.prunedSubJet1_.pz();
206     temp.RawFatH.sj1_e_pr = tmpJet.prunedSubJet1_.e();
207     temp.RawFatH.sj2_px_pr = tmpJet.prunedSubJet2_.px();
208     temp.RawFatH.sj2_py_pr = tmpJet.prunedSubJet2_.py();
209     temp.RawFatH.sj2_pz_pr = tmpJet.prunedSubJet2_.pz();
210     temp.RawFatH.sj2_e_pr = tmpJet.prunedSubJet2_.e();
211    
212     }
213    
214     // ***********************************
215    
216    
217     std::vector<VHbbEvent::TauInfo> tauNoCandidateJetOverlap;
218     std::vector<unsigned int> tauPosNoCandidateJetOverlap;
219     removeTauOverlapWithJets(tau,temp.H.jets,tauNoCandidateJetOverlap,tauPos,tauPosNoCandidateJetOverlap);
220    
221     temp.additionalJets = addJets;
222     temp.additionalJetsFat = addJetsFat;
223     temp.V.mets = met;
224     temp.V.muons = mu;
225     temp.V.electrons = ele;
226     temp.V.taus = tauNoCandidateJetOverlap;
227    
228     //
229     // now see which kind of andidate this can be
230     //
231    
232     VHbbCandidate result;
233     bool ok = false;
234     //
235     // first: hZmumu
236     //
237    
238     if (verbose_){
239     std::cout <<" START SELECTION "<<std::endl;
240     }
241     //
242     //
243     // change must allow a candidate to be both Zee and Zmumu
244    
245     // Zmumu
246     result = selector.getHZmumuCandidate(temp,ok,muPos);
247     if ( ok == true ){
248     result.setCandidateType(VHbbCandidate::Zmumu);
249     candidates.push_back(result);
250     }
251     // HZee
252     result = selector. getHZeeCandidate(temp,ok,elePos);
253     if ( ok == true ){
254     result.setCandidateType(VHbbCandidate::Zee);
255     candidates.push_back(result);
256     }
257     //HWmunu
258     result = selector. getHWmunCandidate(temp,ok,muPos);
259     if ( ok == true ){
260     result.setCandidateType(VHbbCandidate::Wmun);
261     candidates.push_back(result);
262     }
263     // HWenu
264     result = selector. getHWenCandidate(temp,ok,elePos);
265     if ( ok == true ){
266     result.setCandidateType(VHbbCandidate::Wen);
267     candidates.push_back(result);
268     }
269    
270     // New tau categorizations currently commented out
271     /*
272     result = selector.getHWtaunCandidate(temp,ok,tauPosNoCandidateJetOverlap);
273     if ( ok == true ){
274 malbouis 1.34 if (verbose_) std::cout << "We have a taun candidate" << std::endl;
275     result.setCandidateType(VHbbCandidate::Wtaun);
276     candidates.push_back(result);
277 ntran 1.44.2.1 }
278     result = selector.getHZtaumuCandidate(temp,ok,muPos,tauPosNoCandidateJetOverlap);
279     if ( ok == true ){
280 malbouis 1.34 if (verbose_) std::cout << "We have a HZtaumu candidate" << std::endl;
281     result.setCandidateType(VHbbCandidate::Ztaumu);
282     candidates.push_back(result);
283 ntran 1.44.2.1 }
284     */
285    
286     if (candidates.size()!=0 ) return;
287    
288     // HZnn - look at it only if nothing found up to now
289     result = selector. getHZnnCandidate(temp,ok);
290     if ( ok == true ){
291     result.setCandidateType(VHbbCandidate::Znn);
292     candidates.push_back(result);
293     }
294     return;
295 tboccali 1.1 }
296    
297     void HbbCandidateFinderAlgo::findMET(const VHbbEvent::METInfo & met, std::vector<VHbbEvent::METInfo>& out){
298 ntran 1.44.2.1 //
299    
300     // just preselection: met significance > 2
301     // removed on request by A. Rizzi - no filter at all
302     // if (met.metSig >2 ) out.push_back(met);
303     out.push_back(met);
304 tboccali 1.1 if (verbose_){
305 ntran 1.44.2.1 std::cout <<" CandidateFinder: Input MET = "<<met.metSig<<" Output MET = "<<out.size()<<std::endl;
306 tboccali 1.1 }
307    
308     }
309 arizzi 1.14 bool HbbCandidateFinderAlgo::jetID(const VHbbEvent::SimpleJet & j)
310     {
311     if(j.neutralHadronEFraction > 0.99) return false;
312     if(j.neutralEmEFraction > 0.99) return false;
313 arizzi 1.21 if(fabs(j.p4.Eta())<2.4 && j.chargedEmEFraction > 0.99) return false;
314     if(fabs(j.p4.Eta())<2.4 && j.chargedHadronEFraction == 0) return false;
315     if(fabs(j.p4.Eta())<2.4 && j.ntracks == 0) return false;
316 arizzi 1.14 if(j.nConstituents <= 1) return false;
317 ntran 1.44.2.1 return true;
318 arizzi 1.14 }
319 tboccali 1.1
320    
321 tboccali 1.10 bool HbbCandidateFinderAlgo::findDiJets (const std::vector<VHbbEvent::SimpleJet>& jetsin, VHbbEvent::SimpleJet& j1, VHbbEvent::SimpleJet& j2,std::vector<VHbbEvent::SimpleJet>& addJets){
322 ntran 1.44.2.1
323    
324    
325     if (verbose_){
326     std::cout <<" CandidateFinder: Input Jets = "<<jetsin.size()<<std::endl;
327     }
328    
329    
330     CompareBTag bTagComparator;
331     CompareJetPt ptComparator;
332     float etaThr = 2.5;
333    
334    
335     if (jetsin.size()<2) return false;
336    
337     std::vector<VHbbEvent::SimpleJet> jets = jetsin;
338    
339     std::sort(jets.begin(), jets.end(), bTagComparator);
340    
341     //
342     // now I need at least 2 with pt > threshold
343     //
344     unsigned int index1=999999, index2=999999;
345     for (unsigned int i =0; i< jets.size(); ++i){
346     if (jets[i].p4.Pt()> jetPtThreshold && fabs(jets[i].p4.Eta()) < etaThr /*&& jetID(jets[i])*/){
347     if (index1 == 999999) {
348     index1=i;
349     }else if (index2 == 999999){
350     index2=i;
351     break;
352     }
353     }
354     }
355     if (index1==999999 || index2== 999999) return false;
356    
357     if (jets[index1].p4.Pt()<(jets[index2].p4.Pt())){
358     std::swap (index1,index2);
359     }
360     j1 = jets[index1];
361     j2 = jets[index2];
362    
363     //
364     // additional jets
365     //
366     if (jets.size()>2){
367     for (unsigned int i=0 ; i< jets.size(); ++i){
368     if (i != index1 && i != index2 )
369     addJets.push_back(jets[i]);
370     }
371     }
372    
373     if (verbose_){
374     std::cout <<" CandidateFinder: Output Jets = "<<2<<" Additional = "<<addJets.size()<<std::endl;
375     }
376    
377    
378     std::sort(addJets.begin(), addJets.end(), ptComparator);
379     return true;
380    
381    
382    
383    
384    
385 tboccali 1.1 }
386    
387 tboccali 1.2
388 tboccali 1.10 bool HbbCandidateFinderAlgo::findDiJetsHighestPt (const std::vector<VHbbEvent::SimpleJet>& jetsin, VHbbEvent::SimpleJet& j1, VHbbEvent::SimpleJet& j2,std::vector<VHbbEvent::SimpleJet>& addJets){
389 ntran 1.44.2.1
390    
391     if (verbose_){
392     std::cout <<" CandidateFinder: Input Jets = "<<jetsin.size()<<std::endl;
393     }
394     if (jetsin.size()<2) return false;
395    
396     float etaThr = 2.5;
397     std::vector<VHbbEvent::SimpleJet> jets = jetsin;
398     //loop over the dijets and save the one with highest Pt
399    
400     CompareJetPt ptComparator;
401     std::sort(jets.begin(), jets.end(), ptComparator);
402     //
403     // so if i<j, pt(i)>pt(j)
404     //
405    
406     float highestPt = -1000;
407     unsigned int highesti=999999,highestj=999999;
408     for (unsigned int i =0; i< jets.size()-1; ++i){
409     for (unsigned int j =i+1; j< jets.size(); ++j){
410     float pt = (jets[i].p4+jets[j].p4).Pt();
411     if (pt>highestPt && jets[j].p4.Pt()> jetPtThreshold && jets[i].p4.Pt()> jetPtThreshold && fabs(jets[i].p4.Eta()) < etaThr && fabs(jets[j].p4.Eta()) < etaThr && jetID(jets[i]) && jetID(jets[j]) ){
412     highestPt = pt;
413     highesti=i;
414     highestj=j;
415     }
416     }
417     }
418    
419     if (highesti == 999999 || highestj == 999999) return false;
420     j1 = jets[highesti];
421     j2 = jets[highestj];
422    
423     for (unsigned int i=0; i<jets.size(); ++i){
424     if (i!= highesti && i!= highestj)
425     addJets.push_back(jets[i]);
426     }
427    
428     if (verbose_){
429     std::cout <<" CandidateFinder: Output Jets = "<<2<<" Additional = "<<addJets.size()<<std::endl;
430     }
431     std::sort(addJets.begin(), addJets.end(), ptComparator);
432     return true;
433 tboccali 1.2 }
434    
435    
436 arizzi 1.21 bool HbbCandidateFinderAlgo::findFatJet (const std::vector<VHbbEvent::HardJet>& jetsin, const std::vector<VHbbEvent::SimpleJet>& subjetsin, const std::vector<VHbbEvent::SimpleJet>& filterjetsin, VHbbEvent::HardJet& fatj1,std::vector<VHbbEvent::SimpleJet>& subJetsout, const std::vector<VHbbEvent::SimpleJet>& ak5jetsin, std::vector<VHbbEvent::SimpleJet>& addJetsFat, const std::vector<VHbbEvent::MuonInfo>& muons, const std::vector<VHbbEvent::ElectronInfo>& electrons){
437 ntran 1.44.2.1
438     if (verbose_){
439     std::cout <<" CandidateFinder: Input Jets = "<<jetsin.size()<<std::endl;
440     }
441     if (jetsin.size()<1) return false;
442    
443     float etaThr = 2.5;
444     std::vector<VHbbEvent::HardJet> hardjets = jetsin;
445     std::vector<VHbbEvent::SimpleJet> subjets = subjetsin;
446     std::vector<VHbbEvent::SimpleJet> filterjets = filterjetsin;
447    
448     fatj1=hardjets[0]; // to avoid warning if subjet below fail selection
449    
450    
451     /* TMatrixD *pointerEta = new TMatrixD(90,80);
452     TMatrixD* pointerPhi = new TMatrixD(90,80);
453     for (unsigned int i =0; i< hardjets.size(); i++){
454     for (unsigned int j=0; j< i.constituents; j++){
455     TMatrixDRow(*pointerEta,i)(j)=i.etaSub[j];
456     TMatrixDRow(*pointerPhi,i)(j)=i.phiSub[j];
457 dlopes 1.19 }
458 ntran 1.44.2.1 }
459     */
460    
461     // debug
462     /* std::cout << "hardjet size: " << hardjets.size() << "\n";
463     std::cout << "subjet size: " << subjets.size() << "\n";
464     std::cout << "filterjet size: " << filterjets.size() << "\n";
465     for(unsigned int kk=0;kk<subjets.size();kk++){
466     std::cout << "subjet pt: " << subjets[kk].p4.Pt() << " eta,phi " <<
467     subjets[kk].p4.Eta() << " , " << subjets[kk].p4.Phi() << "\n";
468     }
469     for(unsigned int kk=0;kk<filterjets.size();kk++){
470     std::cout << "filterjet pt: " << filterjets[kk].p4.Pt() << " eta,phi " <<
471     filterjets[kk].p4.Eta() << " , " << filterjets[kk].p4.Phi() << "\n";
472     }*/
473     // debug
474    
475     double minBtag1=-9999.;
476     for (unsigned int i =0; i< hardjets.size(); i++){
477     int subJetIn[300];
478     for(int k=0;k<300;k++)subJetIn[k]=-99;
479     int subJetIn1st[2];
480     for(int k=0;k<2;k++)subJetIn1st[k]=-99;
481     // TMatrixDRow* roweta=new TMatrixDRow(*pointerEta,i);
482     // TMatrixDRow* rowphi=new TMatrixDRow(*pointerPhi,i);
483    
484    
485     // debug
486     // std::cout << "HardJet pt: " << hardjets[i].p4.Pt() << " # daughters " <<
487     // hardjets[i].constituents << "\n";
488     // debug
489    
490     if(hardjets[i].constituents<4) continue;
491    
492     // first get ja and jb from first decomposition
493     int In1st=0;
494     for(int j=0;j<2;j++){
495     // debug
496     // std::cout << "hardJet constituent pt: " << hardjets[i].subFourMomentum[j].Pt() << " eta,phi " <<
497     // hardjets[i].subFourMomentum[j].Eta() << " , " << hardjets[i].subFourMomentum[j].Phi() << "\n";
498     // debug
499     for(unsigned int kk=0;kk<subjets.size();kk++){
500     // if(subjets.eta[kk]==roweta->GetPtr()[j] && subjets.phi[kk]==rowphi->GetPtr()[j])
501     // subJetIn1st[In1st]=kk;}
502     // if(subjets[kk].p4.Eta()==hardjets[i].etaSub[j] && subjets[kk].p4.Phi()==hardjets[i].phiSub[j])
503     // subJetIn1st[In1st]=kk;}
504     // if(subjets[kk].p4.Eta()==hardjets[i].subFourMomentum[j].Eta() && subjets[kk].p4.Phi()==hardjets[i].subFourMomentum[j].Phi())
505     // subJetIn1st[In1st]=kk;}
506     double deltaR_1=deltaR(subjets[kk].p4.Eta(),subjets[kk].p4.Phi(),hardjets[i].subFourMomentum[j].Eta(),hardjets[i].subFourMomentum[j].Phi()); if(deltaR_1<0.01) subJetIn1st[In1st]=kk;}
507     In1st++;
508     }
509    
510     // then get all subjets from decomposition with
511     for(int j=2;j<hardjets[i].constituents;j++){
512     // debug
513     // std::cout << "hardJet constituent pt: " << hardjets[i].subFourMomentum[j].Pt() << " eta,phi " <<
514     // hardjets[i].subFourMomentum[j].Eta() << " , " << hardjets[i].subFourMomentum[j].Phi() << "\n";
515     // debug
516     // cout << "n: " << i << "," << j << " hardjetsub eta: " << roweta->GetPtr()[j] << " phi: " <<
517     // rowphi->GetPtr()[j] << "\n";
518     for(unsigned int kk=0;kk<filterjets.size();kk++){
519     // if(subjets.eta[kk]==roweta->GetPtr()[j] && subjets.phi[kk]==rowphi->GetPtr()[j])
520     // subJetIn[j]=kk;}
521     // if(subjets[kk].p4.Eta()==hardjets[i].etaSub[j] && subjets[kk].p4.Phi()==hardjets[i].phiSub[j])
522     // subJetIn[j]=kk;}
523     // if(subjets[kk].p4.Eta()==hardjets[i].subFourMomentum[j].Eta() && subjets[kk].p4.Phi()==hardjets[i].subFourMomentum[j].Phi()) subJetIn[j]=kk;
524     double deltaR_1=deltaR(filterjets[kk].p4.Eta(),filterjets[kk].p4.Phi(),hardjets[i].subFourMomentum[j].Eta(),hardjets[i].subFourMomentum[j].Phi()); if(deltaR_1<0.01) subJetIn[j-2]=kk;}
525     }
526    
527    
528     //debug
529     // std::cout << "index in subjetTag: " << subJetIn1st[0] << "," << subJetIn1st[1] << "\n";
530     // std::cout << "index in subfilterTag: " << subJetIn[0] << "," << subJetIn[1] << "," << subJetIn[2] << "\n";
531     // debug
532    
533     if(subJetIn1st[0]==-99 || subJetIn1st[1]==-99) continue;
534     if(subJetIn[0]==-99 || subJetIn[1]==-99) continue;
535    
536     int nBtag=0;
537     for(int j=0;j<2;j++){
538     if(subjets[subJetIn1st[j]].csv>0.) nBtag++;}
539    
540     int nPt=0;
541     for(int j=0;j<2;j++){
542     //// if(subjets[subJetIn1st[j]].p4.Pt()>30. && fabs(subjets[subJetIn1st[j]].p4.Eta())<etaThr && jetID(subjets[subJetIn1st[j]])) nPt++;}
543     if(filterjets[subJetIn[j]].p4.Pt()>20. && fabs(filterjets[subJetIn[j]].p4.Eta())<etaThr && jetID(filterjets[subJetIn[j]])) nPt++;}
544    
545     // if(nBtag<2 || nPt<2) continue;
546     if(nPt<2) continue;
547    
548     ///// lepton overlap
549     int muOverlap=0;
550     for (unsigned int it = 0; it < muons.size(); ++it){
551     if (
552     muons[it]. globChi2<10 &&
553     muons[it].nPixelHits>= 1 &&
554     muons[it].globNHits != 0 &&
555     muons[it].nHits > 10 &&
556     //tracker
557     (muons[it].cat & 0x1) &&
558     //global
559     (muons[it].cat & 0x2) &&
560     muons[it].nMatches >=2 &&
561     muons[it].ipDb<.2 &&
562     (muons[it].pfChaIso+muons[it].pfPhoIso+muons[it].pfNeuIso)/muons[it].p4.Pt()<.15 &&
563     fabs(muons[it].p4.Eta())<2.4 &&
564     muons[it].p4.Pt()>20 ) {
565     for(int j=0;j<2;j++){
566     if(deltaR(muons[it].p4.Eta(),muons[it].p4.Phi(),filterjets[subJetIn[j]].p4.Eta(),filterjets[subJetIn[j]].p4.Phi())<0.3) muOverlap++;}
567     }
568     }
569    
570     int elecOverlap=0;
571     for (unsigned int it = 0; it< electrons.size(); ++it){
572     if (
573     // fake
574     (fabs(electrons[it].id95 - 7)) < 0.1 &&
575     fabs(electrons[it].p4.Eta()) < 2.5 &&
576     //Remove this workaround as now we have the proper flags
577     // !( fabs(electrons[it].p4.Eta()) < 1.57 && fabs(electrons[it].p4.Eta()) > 1.44) &&
578     electrons[it].p4.Pt()>15 // I use the minimum ok for both Z and W
579     && (electrons[it].pfChaIso+electrons[it].pfPhoIso+electrons[it].pfNeuIso)/electrons[it].p4.Pt()<.15
580     ){
581     for(int j=0;j<2;j++){
582     if(deltaR(electrons[it].p4.Eta(),electrons[it].p4.Phi(),filterjets[subJetIn[j]].p4.Eta(),filterjets[subJetIn[j]].p4.Phi())<0.3) elecOverlap++;}
583     }
584     }
585    
586    
587     if(muOverlap>0) continue;
588     if(elecOverlap>0) continue;
589    
590     // if(subjets[subJetIn1st[0]].csv+subjets[subJetIn1st[1]].csv>minBtag1){
591     // minBtag1=subjets[subJetIn1st[0]].csv+subjets[subJetIn1st[1]].csv;
592     if((subjets[subJetIn1st[0]].p4+subjets[subJetIn1st[1]].p4).Pt()>minBtag1){
593     minBtag1=(subjets[subJetIn1st[0]].p4+subjets[subJetIn1st[1]].p4).Pt();
594     /* double filtpt=0;
595     if(subJetIn[0]!=-99 && subJetIn[1]!=-99) filtpt=(filterjets[subJetIn[0]].p4+filterjets[subJetIn[1]].p4).Pt();
596     if(subJetIn[0]!=-99 && subJetIn[1]!=-99 && subJetIn[2]!=-99) filtpt=(filterjets[subJetIn[0]].p4+filterjets[subJetIn[1]].p4+filterjets[subJetIn[2]].p4).Pt();
597     if(filtpt>minBtag1){
598     minBtag1=filtpt;
599     */
600     // if(hardjets[i].p4.Pt()>minBtag1){
601     // minBtag1=hardjets[i].p4.Pt();
602     fatj1=hardjets[i];
603     subJetsout.clear();
604     if(subJetIn[0]!=-99) subJetsout.push_back(filterjets[subJetIn[0]]);
605     if(subJetIn[1]!=-99) subJetsout.push_back(filterjets[subJetIn[1]]);
606     if(subJetIn[2]!=-99) subJetsout.push_back(filterjets[subJetIn[2]]);
607     }
608    
609     } // loop hard jet
610    
611    
612     //
613     // additional jets
614     //
615     std::vector<VHbbEvent::SimpleJet> ak5jets = ak5jetsin;
616    
617     addJetsFat.clear();
618     for (unsigned int i=0 ; i< ak5jets.size(); ++i){
619     int overlap=0;
620     for (unsigned int j=0 ; j< subJetsout.size(); ++j){
621     if(subJetsout[j].p4.Pt() <20.) continue;
622     if (deltaR(ak5jets[i].p4.Eta(),ak5jets[i].p4.Phi(),subJetsout[j].p4.Eta(),subJetsout[j].p4.Phi())<0.3) overlap++;
623     }
624     if(overlap==0) addJetsFat.push_back(ak5jets[i]);
625     }
626    
627    
628    
629     return true;
630 dlopes 1.19 }
631    
632 malbouis 1.34 void HbbCandidateFinderAlgo::removeTauOverlapWithJets(const std::vector<VHbbEvent::TauInfo>& taus, const std::vector<VHbbEvent::SimpleJet>& jets, std::vector<VHbbEvent::TauInfo>& out, const std::vector<unsigned int>& oldPositions,std::vector<unsigned int>& positions) {
633 ntran 1.44.2.1 for (unsigned int it = 0; it < taus.size(); ++it){
634     bool overlap = false;
635     for (unsigned int jit = 0 ; jit < jets.size() ; ++jit) {
636     if (taus[it].p4.DeltaR(jets[jit].p4) < 0.2) {
637     overlap = true;
638     if (verbose_) {
639     std::cout << "Found overlap of tau (pt,eta,phi)=(" << taus[it].p4.Pt() <<","<< taus[it].p4.Eta() <<","<< taus[it].p4.Phi() << ")"
640     << "with candidate jet (pt,eta,phi)=(" << jets[jit].p4.Pt() <<","<< jets[jit].p4.Eta() <<","<< jets[jit].p4.Phi() << ")"
641     << std::endl;
642     }
643     }
644     }
645     if (!overlap) {
646     if (verbose_) {
647     std::cout << "No overlap with tau (pt,eta,phi)=(" << taus[it].p4.Pt() <<","<< taus[it].p4.Eta() <<","<< taus[it].p4.Phi() << "); keeping it " << std::endl;
648     }
649     out.push_back(taus[it]);
650     positions.push_back(oldPositions[it]);
651     }
652 malbouis 1.34 }
653     }
654 ntran 1.44.2.1
655 malbouis 1.34 void HbbCandidateFinderAlgo::findTaus(const std::vector<VHbbEvent::TauInfo>& taus, std::vector<VHbbEvent::TauInfo>& out, std::vector<unsigned int>& positions){
656 ntran 1.44.2.1 if (verbose_) std::cout << "[SCZ] Tau size=" << taus.size() << std::endl;
657     for (unsigned int it = 0; it < taus.size(); ++it){
658     /*
659     myPatTau.tauID("decayModeFinding"); // cuts on tau invariant mass, etc
660     myPatTau.tauID("byLooseCombinedIsolationDeltaBetaCorr") // isolated
661     taus, corrected for PU use DB technique
662     myPatTau.tauID("againstMuonTight"); // remove muons faking hadronic taus
663     myPatTau.tauID("againstElectronLoose/againstElectronMedium/againstElectronMVA");
664     // remove electrons faking hadronic taus, choose based on your fake - e background.
665     */
666    
667     if (verbose_) {
668     std::cout << "(pt,decayModeFinding,byLooseCombinedIsolationDeltaBetaCorr,againstMuonTight,againstElectronLoose,againstElectronMedium,againstElectronMVA)=("
669     << taus[it].p4.Pt() << ","
670     << (taus[it].decayModeFinding>0.5) << ","
671     << (taus[it].byLooseCombinedIsolationDeltaBetaCorr>0.5) << ","
672     << (taus[it].againstMuonTight>0.5) << ","
673     << (taus[it].againstElectronLoose>0.5) <<","
674     << (taus[it].againstElectronMedium>0.5) <<","
675     << (taus[it].againstElectronMVA>0.5) << ")" << std::endl;
676     }
677    
678     if (taus[it].decayModeFinding>0.5&&taus[it].byLooseCombinedIsolationDeltaBetaCorr>0.5&&taus[it].againstMuonTight>0.5&&taus[it].againstElectronLoose>0.5&&taus[it].p4.Pt()>20.) {
679     out.push_back(taus[it]);
680     positions.push_back(it);
681     }
682     }
683     if (verbose_){
684     std::cout <<" CandidateFinder: Input Taus = "<<taus.size()<<" Output Taus = "<<out.size()<<std::endl;
685     }
686 malbouis 1.34 }
687    
688 tboccali 1.2
689 arizzi 1.24 void HbbCandidateFinderAlgo::findMuons(const std::vector<VHbbEvent::MuonInfo>& muons, std::vector<VHbbEvent::MuonInfo>& out, std::vector<unsigned int>& positions,const VHbbEventAuxInfo & aux){
690 ntran 1.44.2.1 /* Use:
691     For both W -> mu nu and Z -> mu mu, we adopt the standard VBTF muon selection described in VbtfWmunuBaselineSelection. The explicit cuts are reproduced here:
692    
693     We use RECO (pf?) Muons that are both Global and Tracker
694     chi2/ndof < 10 for the global muon fit
695     The track associated to the muon must have
696     >= 1 pixel hits
697     >= 10 pixel + strip hits
698     >= 1 valid hit in the muon chambers
699     >= 2 muon stations
700     |dxy| < 0.2
701     |eta| < 2.4
702     PF Relative combined isolation (R) is required to be < 0.15
703     R = [pfChaIso + pfNeuIso + pfPhoIso] / pT(mu) computed in a cone of radius 0.3 in eta-phi
704     pT(mu) > 20 GeV
705     */
706     // for (std::vector<VHbbEvent::MuonInfo>::const_iterator it = muons.begin(); it!= muons.end(); ++it){
707    
708     /* New iso:
709    
710     Alternatively, for analysis using rho correction, Effective Areas are also provided using following prescription:
711     Correction to be done as PFIsoCorr = PF(PFNoPU) – Max ((PF(Nh+Ph) - ρ’EACombined),0.0)) where ρ’=max(ρ,0.0) and with a 0.5 GeV threshold on neutrals
712     Rho is neutral rho, defined in full tracker acceptance, with a 0.5 GeV threshold on neutrals. This can be taken, starting from 50X, from the event directly (double_kt6PFJetsCentralNeutral_rho_RECO.obj) For its exact definition see [2].
713     Values of Effective Areas EACombined are provided in this link, page 9 (see PF Combined Column, DeltaR >0/4 )
714     [2] kt6PFJetsCentralNeutral = kt6PFJets.clone( src = cms.InputTag("pfAllNeutralHadronsAndPhotons"), Ghost_EtaMax = cms.double(3.1), Rho_EtaMax = cms.double(2.5), inputEtMin = cms.double(0.5) )
715    
716     Effective area, last column matters for us:
717     | PF Neutral | PF Photons | PF Combined |
718 arizzi 1.22 Muon Eta | DR < 0.30 | DR < 0.40 | DR < 0.30 | DR < 0.40 | DR < 0.30 | DR < 0.40 |
719 ntran 1.44.2.1 0.0 < |eta| < 1.0 | 0.107 +/- 0.010 | 0.166 +/- 0.013 | 0.274 +/- 0.017 | 0.504 +/- 0.020 | 0.382 +/- 0.034 | 0.674 +/- 0.020 |
720     1.0 < |eta| < 1.5 | 0.141 +/- 0.016 | 0.259 +/- 0.023 | 0.161 +/- 0.019 | 0.306 +/- 0.027 | 0.317 +/- 0.045 | 0.565 +/- 0.027 |
721     1.5 < |eta| < 2.0 | 0.159 +/- 0.017 | 0.247 +/- 0.025 | 0.079 +/- 0.015 | 0.198 +/- 0.026 | 0.242 +/- 0.040 | 0.442 +/- 0.026 |
722     2.0 < |eta| < 2.2 | 0.102 +/- 0.022 | 0.220 +/- 0.036 | 0.168 +/- 0.035 | 0.287 +/- 0.048 | 0.326 +/- 0.076 | 0.515 +/- 0.048 |
723     2.2 < |eta| < 2.3 | 0.096 +/- 0.030 | 0.340 +/- 0.072 | 0.359 +/- 0.072 | 0.525 +/- 0.074 | 0.462 +/- 0.159 | 0.821 +/- 0.074 |
724     2.3 < |eta| < 2.4 | 0.104 +/- 0.036 | 0.216 +/- 0.056 | 0.294 +/- 0.064 | 0.488 +/- 0.083 | 0.372 +/- 0.141 | 0.660 +/- 0.083 |
725    
726     */
727    
728     for (unsigned int it = 0; it < muons.size(); ++it){
729     float mincor=0.0;
730     float minrho=0.0;
731     float rhoN = std::max(aux.puInfo.rhoNeutral,minrho);
732     float eta=muons[it].p4.Eta();
733     float area=0.5;
734     if(fabs(eta)>0.0 && fabs(eta) <= 1.0) {area=0.674;}
735     if(fabs(eta)>1.0 && fabs(eta) <= 1.5) {area=0.565;}
736     if(fabs(eta)>1.5 && fabs(eta) <= 2.0) {area=0.442;}
737     if(fabs(eta)>2.0 && fabs(eta) <= 2.2) {area=0.515;}
738     if(fabs(eta)>2.2 && fabs(eta) <= 2.3) {area=0.821;}
739     if(fabs(eta)>2.3 && fabs(eta) <= 2.4) {area=0.660;}
740     float pfCorrIso = (muons[it].pfChaIso+ std::max(muons[it].pfPhoIso+muons[it].pfNeuIso-rhoN*area,mincor))/muons[it].p4.Pt();
741     if (
742     muons[it].isPF &&
743     muons[it]. globChi2<10 &&
744     muons[it].nPixelHits>= 1 &&
745     muons[it].globNHits != 0 &&
746     muons[it].nValidLayers > 5 &&
747     // muons[it].nHits > 10 &&
748     //tracker
749     // (muons[it].cat & 0x2) &&
750     //global
751     (muons[it].cat & 0x1) &&
752     muons[it].nMatches >=2 &&
753     muons[it].ipDb<.2 &&
754     muons[it].zPVPt<0.5 &&
755     // (muons[it].hIso+muons[it].eIso+muons[it].tIso)/muons[it].p4.Pt()<.15 &&
756     pfCorrIso < 0.12 &&
757     fabs(muons[it].p4.Eta())<2.4 &&
758     muons[it].p4.Pt()>20 ) {
759     out.push_back(muons[it]);
760     positions.push_back(it);
761     }
762     }
763 tboccali 1.1 if (verbose_){
764 ntran 1.44.2.1 std::cout <<" CandidateFinder: Input Muons = "<<muons.size()<<" Output Muons = "<<out.size()<<std::endl;
765 tboccali 1.1 }
766 ntran 1.44.2.1
767    
768 tboccali 1.1 }
769    
770    
771 arizzi 1.24 void HbbCandidateFinderAlgo::findElectrons(const std::vector<VHbbEvent::ElectronInfo>& electrons, std::vector<VHbbEvent::ElectronInfo>& out, std::vector<unsigned int>& positions,const VHbbEventAuxInfo & aux){
772 ntran 1.44.2.1 /*
773     We adopt the standard cut-based selection from VBTF described in detail here.
774    
775     Z -> ee
776     gsf (pf?) electrons
777     VBTF WP95
778     |eta|<2.5, excluding the gap 1.44 < |eta| < 1.57
779     pT(e) > 20
780    
781     W -> e nu
782     gsf (pf?) electrons
783     VBTF WP80
784     |eta|<2.5, excluding the gap 1.44 < |eta| < 1.57
785     pT(e) > 30
786     */
787     // for (std::vector<VHbbEvent::ElectronInfo>::const_iterator it = electrons.begin(); it!= electrons.end(); ++it){
788     /*
789     isocorr = chargediso + max(PFIso(&gamma;) - rho * Aeff(&gamma), 0.) + max(PFIso(NH) - rho * Aeff(NH), 0.)
790     0<abs(eta)<1.0 Aeff(NH) = 0.024 +/- 0.001 Aeff(γ) = 0.081 +/- 0.001 Aeff(γ+NH) = 0.10 +/- 0.002
791     1.0<abs(eta)<1.479 Aeff(NH) = 0.037 +/- 0.001 Aeff(γ) = 0.084 +/- 0.003 Aeff(γ+NH) = 0.12 +/- 0.003
792     1.479<abs(eta)<2.0 Aeff(NH) = 0.037 +/- 0.001 Aeff(γ) = 0.048 +/- 0.001 Aeff(γ+NH) = 0.085 +/- 0.002
793     2.0<abs(eta)<2.2 Aeff(NH) = 0.023 +/- 0.001 Aeff(γ) = 0.089 +/- 0.002 Aeff(γ+NH) = 0.11 +/- 0.003
794     2.2<abs(eta)<2.3 Aeff(NH) = 0.023 +/- 0.002 Aeff(γ) = 0.092 +/- 0.004 Aeff(γ+NH) = 0.12 +/- 0.004
795     2.3<abs(eta)<2.4 Aeff(NH) = 0.021 +/- 0.002 Aeff(γ) = 0.097 +/- 0.004 Aeff(γ+NH) = 0.12 +/- 0.005
796     2.4< abs(eta)<123213 Aeff(NH) = 0.021 +/- 0.003 Aeff(γ) = 0.11 +/- 0.004 Aeff(γ+NH) = 0.13 +/- 0.006
797    
798     */
799     for (unsigned int it = 0; it< electrons.size(); ++it){
800     float mincor=0.0;
801     float minrho=0.0;
802     float rho = std::max(aux.puInfo.rho25Iso,minrho);
803     float eta=electrons[it].p4.Eta();
804     float areagamma=0.5;
805     float areaNH=0.5;
806     float areaComb=0.5;
807    
808     if(fabs(eta) <= 1.0 ) {areagamma=0.14; areaNH=0.044; areaComb=0.18;}
809     if(fabs(eta) > 1.0 && fabs(eta) <= 1.479 ) {areagamma=0.13; areaNH=0.065; areaComb=0.20;}
810     if(fabs(eta) > 1.479 && fabs(eta) <= 2.0 ) {areagamma=0.079; areaNH=0.068; areaComb=0.15;}
811     if(fabs(eta) > 2.0 && fabs(eta) <= 2.2 ) {areagamma=0.13; areaNH=0.057; areaComb=0.19;}
812     if(fabs(eta) > 2.2 && fabs(eta) <= 2.3 ) {areagamma=0.15; areaNH=0.058; areaComb=0.21;}
813     if(fabs(eta) > 2.3 && fabs(eta) <= 2.4 ) {areagamma=0.16; areaNH=0.061; areaComb=0.22;}
814     if(fabs(eta) > 2.4 ) {areagamma=0.18; areaNH=0.11; areaComb=0.29;}
815     /*
816     if(fabs(eta) <= 1.0 ) {areagamma=0.081; areaNH=0.024; areaComb=0.10;}
817     if(fabs(eta) > 1.0 && fabs(eta) <= 1.479 ) {areagamma=0.084; areaNH=0.037; areaComb=0.12;}
818     if(fabs(eta) > 1.479 && fabs(eta) <= 2.0 ) {areagamma=0.048; areaNH=0.037; areaComb=0.085;}
819     if(fabs(eta) > 2.0 && fabs(eta) <= 2.2 ) {areagamma=0.089; areaNH=0.023; areaComb=0.11;}
820     if(fabs(eta) > 2.2 && fabs(eta) <= 2.3 ) {areagamma=0.092; areaNH=0.023; areaComb=0.12;}
821     if(fabs(eta) > 2.3 && fabs(eta) <= 2.4 ) {areagamma=0.097; areaNH=0.021; areaComb=0.12;}
822     if(fabs(eta) > 2.4 ) {areagamma=0.11; areaNH=0.021; areaComb=0.13;}
823     */
824    
825     //Correct electron photon double count
826     float pho=electrons[it].pfPhoIso;
827     if(electrons[it].innerHits>0)
828     {
829     pho-=electrons[it].pfPhoIsoDoubleCounted;
830     }
831    
832     float pfCorrIso = (electrons[it].pfChaIso+ std::max(pho-rho*areagamma,mincor )+std::max(electrons[it].pfNeuIso-rho*areaNH,mincor))/electrons[it].p4.Pt();
833     float iso=pfCorrIso;
834     float id=electrons[it].mvaOutTrig;
835     bool wp70=((fabs(eta) < 0.8 && id>0.977 && iso < 0.093) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.956 && iso < 0.095) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.966 && iso < 0.171));
836     bool wp80=((fabs(eta) < 0.8 && id>0.913 && iso < 0.105) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.964 && iso < 0.178) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.899 && iso < 0.150));
837     bool wp85=((fabs(eta) < 0.8 && id>0.929 && iso < 0.135) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.931 && iso < 0.159) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.805 && iso < 0.155));
838     bool wp90=((fabs(eta) < 0.8 && id>0.877 && iso < 0.177) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.794 && iso < 0.180) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.846 && iso < 0.244));
839     bool wp95=((fabs(eta) < 0.8 && id>0.858 && iso < 0.253) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.425 && iso < 0.225) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.759 && iso < 0.308));
840     bool wpHWW=((fabs(eta) < 0.8 && id>0.94 && iso < 0.15) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.85 && iso < 0.15) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.92 && iso < 0.15));
841    
842    
843     if (
844    
845     // fake
846     /* "(isEE || isEB) && !isEBEEGap &&"
847     " (chargedHadronIso + neutralHadronIso + photonIso)/pt <0.10 &&"
848     "dB < 0.02 && " #dB is computed wrt PV but is transverse only, no info about dZ(vertex)
849     "( "
850     "(isEE && ("
851     "abs(deltaEtaSuperClusterTrackAtVtx) < 0.005 && abs(deltaPhiSuperClusterTrackAtVtx) < 0.02 && sigmaIetaIeta < 0.03 && hadronicOverEm < 0.10 && abs(1./ecalEnergy*(1.-eSuperClusterOverP)) < 0.05 "
852     ")) || "
853     "(isEB && ( "
854     "abs(deltaEtaSuperClusterTrackAtVtx) < 0.004 && abs(deltaPhiSuperClusterTrackAtVtx) < 0.03 && sigmaIetaIeta < 0.01 && hadronicOverEm < 0.12 && abs(1./ecalEnergy*(1.-eSuperClusterOverP)) < 0.05"
855     "))"
856     #or use mvaNonTrigV0 and mvaTrigV0
857     ")" */
858     // (fabs(electrons[it].id95 - 7)) < 0.1 &&
859     wp95 &&
860     (
861     (electrons[it].isEE &&
862     //fabs(electrons[it].Deta) < 0.009 &&
863     //fabs(electrons[it].Dphi) < 0.1 &&
864     electrons[it].sihih < 0.03 &&
865     electrons[it].HoE < 0.10 &&
866     electrons[it].innerHits == 0 &&
867     (electrons[it].tIso/electrons[it].p4.Pt()) < 0.2 &&
868     (electrons[it].eIso/electrons[it].p4.Pt()) < 0.2 &&
869     (electrons[it].hIso/electrons[it].p4.Pt()) < 0.2)
870     ||
871     (electrons[it].isEB &&
872     //fabs(electrons[it].Deta) < 0.007 &&
873     //fabs(electrons[it].Dphi) < 0.015 &&
874     electrons[it].sihih < 0.01 &&
875     electrons[it].HoE < 0.12 &&
876     electrons[it].innerHits == 0 &&
877     (electrons[it].tIso/electrons[it].p4.Pt()) < 0.2 &&
878     (electrons[it].eIso/electrons[it].p4.Pt()) < 0.2 &&
879     (electrons[it].hIso/electrons[it].p4.Pt()) < 0.2)
880     ) &&
881     //2012 cut based ELE ID
882     /* fabs(electrons[it].dxy) < 0.02 &&
883     fabs(electrons[it].dz) < 0.1 &&
884     ((electrons[it].isEE &&
885     fabs(electrons[it].Deta) < 0.005 &&
886     fabs(electrons[it].Dphi) < 0.02 &&
887     electrons[it].sihih < 0.03 &&
888     electrons[it].HoE < 0.10 &&
889     fabs(electrons[it].fMVAVar_IoEmIoP) < 0.05
890     ) ||
891     (electrons[it].isEB &&
892     fabs(electrons[it].Deta) < 0.004 &&
893     fabs(electrons[it].Dphi) < 0.03 &&
894     electrons[it].sihih < 0.01 &&
895     electrons[it].HoE < 0.12 &&
896     fabs(electrons[it].fMVAVar_IoEmIoP) < 0.05
897     )
898     ) &&
899     pfCorrIso < 0.1 &&
900     fabs(electrons[it].p4.Eta()) < 2.5 &&
901     */
902     //Remove this workaround as now we have the proper flags
903     // !( fabs(electrons[it].p4.Eta()) < 1.57 && fabs(electrons[it].p4.Eta()) > 1.44) &&
904     electrons[it].p4.Pt()>20 // I use the minimum ok for both Z and W
905     ){
906     /* std::cout << "dxy .dz .isEE .Deta .Dphi .sihih .HoE .fMVAVar_IoEmIoP .isEB " <<std::endl;
907     std::cout << fabs(electrons[it].dxy) << " " << fabs(electrons[it].dz) << " " << electrons[it].isEE << " " <<
908     fabs(electrons[it].Deta)
909     << " " << fabs(electrons[it].Dphi)
910     << " " <<electrons[it].sihih
911     << " " <<electrons[it].HoE
912     << " " <<fabs(electrons[it].fMVAVar_IoEmIoP)
913     << " " <<electrons[it].isEB << std::endl;
914     */
915    
916     out.push_back(electrons[it]);
917     positions.push_back(it);
918     }
919     }
920 tboccali 1.1 if (verbose_){
921 ntran 1.44.2.1 std::cout <<" CandidateFinder: Input Electrons = "<<electrons.size()<<" Output Electrons = "<<out.size()<<std::endl;
922 tboccali 1.1 }
923 ntran 1.44.2.1
924    
925 tboccali 1.1 }
926