ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/src/HbbCandidateFinderAlgo.cc
Revision: 1.41
Committed: Fri Jun 15 15:41:39 2012 UTC (12 years, 10 months ago) by arizzi
Content type: text/plain
Branch: MAIN
CVS Tags: EDMV42_Step2_V1, EdmV42, EdmV41alpha1, EdmV40alpha1, EdmV40alpha, EdmV33Jun12v2_consistent, Step2ForV33_v2, Step2ForV33_v1
Changes since 1.40: +10 -1 lines
Log Message:
updates for V33step1 V1step2

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