ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/src/HbbCandidateFinderAlgo.cc
Revision: 1.44.2.4
Committed: Wed Nov 28 02:48:02 2012 UTC (12 years, 5 months ago) by ntran
Content type: text/plain
Branch: hbbsubstructDevPostHCP
CVS Tags: hbbsubstructDev_11, hbbsubstructDev_10, hbbsubstructDev_9, hbbsubstructDev_8, hbbsubstructDev_7
Changes since 1.44.2.3: +2 -2 lines
Log Message:
move substructure tools to a new area

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