ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/NonMCBackground/src/SelectionEMU.cc
(Generate patch)

Comparing UserCode/MitHzz4l/NonMCBackground/src/SelectionEMU.cc (file contents):
Revision 1.2 by khahn, Tue Feb 14 21:29:18 2012 UTC vs.
Revision 1.8 by dkralph, Thu Jun 21 21:25:38 2012 UTC

# Line 1 | Line 1
1 + //***************************************************************************************************
2 + //
3 + // selection sync'ed with https://twiki.cern.ch/twiki/bin/viewauth/CMS/HiggsZZ4l2012SummerSync
4 + //
5 + //***************************************************************************************************
6 +
7 + // system headers
8 + #include <map>
9 + #include <utility>
10 +
11 + // mit headers
12 + #include "Vertex.h"
13 +
14 + // 4L stuff
15   #include "SelectionStatus.h"
16   #include "EventData.h"
17   #include "SimpleLepton.h"
18   #include "EfficiencyWeightsInterface.h"
19 <
20 < #include "HZZBDTElectronSelection.h"
19 > #include "ElectronSelection.h"
20 > #include "MuonSelection.h"
21   #include "IsolationSelection.h"
8 #include "PassHLT.h"
22   #include "SelectionEMU.h"
23 <
24 < #include "ExternData.h"
23 > #include "ReferenceSelection.h"
24 > #include "Selection.h"
25 > #include "CommonDefs.h"
26   #include "SelectionDefs.h"
27 + #include "FSR.h"
28 + #include "SelectionFuncs.h"
29  
30  
31 + extern vector<SimpleLepton> failingLeptons;
32 + extern vector<SimpleLepton> passingLeptons;
33  
34 < // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
35 < // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
36 < EventData apply_EMU_selection(ControlFlags &ctrl,           // input control
37 <                              mithep::TEventInfo *info,     // input event info
38 <                              TClonesArray *electronArr,    // input electrons
39 <                              SelectionStatus (*ElectronPreSelector)( ControlFlags &, const mithep::TElectron*),
40 <                              SelectionStatus (*ElectronIDSelector)( ControlFlags &, const mithep::TElectron*),
41 <                              SelectionStatus (*ElectronIsoSelector)( ControlFlags &, const mithep::TElectron*),
42 <                              TClonesArray *muonArr,         // input muons
43 <                              SelectionStatus (*MuonPreSelector)( ControlFlags &, const mithep::TMuon*),
44 <                              SelectionStatus (*MuonIDSelector)( ControlFlags &, const mithep::TMuon*),
45 <                              SelectionStatus (*MuonIsoSelector)( ControlFlags &, const mithep::TMuon*) )
46 < // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
47 < // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34 > //--------------------------------------------------------------------------------------------------
35 > EventData apply_HZZ4L_EMU_selection(ControlFlags &ctrl,           // input control
36 >                                        const mithep::EventHeader *info,     // input event info
37 >                                        const mithep::Array<mithep::Vertex>       * vtxArr ,
38 >                                        const mithep::Array<mithep::PFCandidate>  *pfCandidates,
39 >                                        const mithep::Array<mithep::PileupEnergyDensity>  *puEnergyDensity,
40 >                                        const mithep::Array<mithep::Electron> *electronArr,    // input electrons
41 >                                        SelectionStatus (*ElectronPreSelector)( ControlFlags &,
42 >                                                                                const mithep::Electron*,
43 >                                                                                const mithep::Vertex *),
44 >                                        SelectionStatus (*ElectronIDSelector)( ControlFlags &,
45 >                                                                               const mithep::Electron*,
46 >                                                                               const mithep::Vertex *),
47 >                                        SelectionStatus (*ElectronIsoSelector)( ControlFlags &,
48 >                                                                                const mithep::Electron*,
49 >                                                                                const mithep::Vertex *,
50 >                                                                                const mithep::Array<mithep::PFCandidate> *,
51 >                                                                                const mithep::Array<mithep::PileupEnergyDensity> *,
52 >                                                                                mithep::ElectronTools::EElectronEffectiveAreaTarget,
53 >                                                                                vector<const mithep::PFCandidate*>),
54 >                                        const mithep::Array<mithep::Muon> *muonArr,    // input muons
55 >                                        SelectionStatus (*MuonPreSelector)( ControlFlags &,
56 >                                                                            const mithep::Muon*,
57 >                                                                            const mithep::Vertex *,
58 >                                                                            const mithep::Array<mithep::PFCandidate> *),
59 >                                        SelectionStatus (*MuonIDSelector)( ControlFlags &,
60 >                                                                           const mithep::Muon*,
61 >                                                                           // const mithep::Vertex &),
62 >                                                                           const mithep::Vertex *,
63 >                                                                           const mithep::Array<mithep::PFCandidate> *),
64 >                                        SelectionStatus (*MuonIsoSelector)( ControlFlags &,
65 >                                                                            const mithep::Muon*,
66 >                                                                            const mithep::Vertex *,
67 >                                                                            const mithep::Array<mithep::PFCandidate> *,
68 >                                                                            const mithep::Array<mithep::PileupEnergyDensity> *,
69 >                                                                            mithep::MuonTools::EMuonEffectiveAreaTarget,
70 >                                                                            vector<const mithep::PFCandidate*>)
71 >                                        )
72 > //--------------------------------------------------------------------------------------------------
73   {      
74  
75    EventData ret;
76    unsigned evtfail = 0x0;
77    TRandom3 r;
35  
36  if( ctrl.debug ) {
37    cout << "Run: " << info->runNum
38         << "\tEvt: " << info->evtNum
39         << "\tLumi: " << info->lumiSec
40         << endl;
41  }
78  
79 <  if( !ctrl.mc ) {
80 <    // not accounting for overlap atm
45 <    RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec);      
46 <    if( !(rlrm.HasRunLumi(rl)) )  {
47 <      if( ctrl.debug ) cout << "\tfails JSON" << endl;
48 <      ret.status.setStatus(0);
49 <      return ret;
50 <    }
51 <  }
52 <  
53 <  
54 <  //********************************************************
55 <  // Trigger
56 <  //********************************************************
57 < //   if( !ctrl.mc ) {
58 < //     if( !(passHLTSingleMuon(info->triggerBits) )  ) {
59 < //       if( ctrl.debug ) cout << "\tfails trigger" << endl;
60 < //       evtfail |= (1<<EVTFAIL_TRIGGER);
61 < //       ret.status.setStatus(0);
62 < //       return ret;
63 < //     }        
64 < //   }
65 <  if( ctrl.debug ) {
66 <    cout << "presel nlep: " << muonArr->GetEntries() + electronArr->GetEntries()
67 <         << "\tnmuon: "    << muonArr->GetEntries()
68 <         << "\tnelectron: " << electronArr->GetEntries()
69 <         << endl;
70 <  }
79 >  failingLeptons.clear();
80 >  passingLeptons.clear();
81  
82 <  //********************************************************
83 <  // Lepton Selection
84 <  //********************************************************
85 <  vector<SimpleLepton> lepvec;
86 <  if( muonArr->GetEntries() != 1 && electronArr->GetEntries() != 1 ) {
87 <    ret.status.setStatus(0);
82 >  mithep::MuonTools::EMuonEffectiveAreaTarget eraMu;
83 >  mithep::ElectronTools::EElectronEffectiveAreaTarget eraEle;
84 >  getEATargets(ctrl,eraMu,eraEle);
85 >
86 >  const mithep::Vertex * vtx;
87 >  bool goodVertex = setPV( ctrl, vtxArr, vtx );
88 >  if(goodVertex) {
89 >    ret.status.selectionBits.flip(PASS_SKIM2);
90 >  } else {
91 >    if(ctrl.debug) cout << "found bad vertex" << endl;
92 >    ret.status.setStatus(SelectionStatus::FAIL);
93      return ret;
94    }
95  
96 <  //    
96 >  //***********************************************************
97 >  // Lepton Selection
98 >  //***********************************************************
99 >  vector<SimpleLepton> lepvec;
100 >  vector<const mithep::PFCandidate*> photonsToVeto;
101 >
102 >
103    if( ctrl.debug ) cout << "\tnMuons: " << muonArr->GetEntries() << endl;
104    //----------------------------------------------------
105 <  for(Int_t i=0; i<muonArr->GetEntries(); i++)
105 >  for(int i=0; i<muonArr->GetEntries(); i++)
106      {
107 <      const mithep::TMuon *mu = (mithep::TMuon*)((*muonArr)[i]);      
107 >      const mithep::Muon *mu = (mithep::Muon*)((*muonArr)[i]);      
108        
109 +
110 +      SelectionStatus denomSel;
111 +      denomSel |= muonDenominatorSelection(ctrl,mu,vtx,pfCandidates);
112 +      if( !(denomSel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
113 +
114        SelectionStatus musel;
115 <      if(ctrl.debug) cout << "musel.status  before anything: " << musel.getStatus() << endl;
116 <      musel |= (*MuonPreSelector)(ctrl,mu);
117 <      if(ctrl.debug) cout << "musel.status  after presel: " << musel.getStatus() << endl;
118 <      musel |= (*MuonIDSelector)(ctrl,mu);
119 <      if(ctrl.debug) cout << "musel.status  after ID: " << musel.getStatus() << endl;
120 <      musel |= (*MuonIsoSelector)(ctrl,mu);
121 <      if(ctrl.debug) cout << "musel.status  after iso: " << musel.getStatus() << endl;
122 <
123 <      if( ctrl.debug ) {
124 <        cout << "muon:: pt: " << mu->pt
99 <             << "\teta: " << mu->eta
100 <             << "\tisorel: " <<  mu->pfIso03/mu->pt
101 <             << "\tstatus: " << hex << musel.getStatus() << dec
102 <             << endl;
103 <      }
115 >      musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates);
116 >      musel |= (*MuonIDSelector)(ctrl,mu,vtx,pfCandidates );
117 >      musel |= (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,photonsToVeto);
118 >
119 >      SimpleLepton tmplep;
120 >      float pt = mu->Pt();
121 >      tmplep.vec.SetPtEtaPhiM(pt,
122 >                               mu->Eta(),
123 >                               mu->Phi(),
124 >                               MUON_MASS);
125        
126 <      if ( musel.pass() ) {
126 >      tmplep.type    = 13;
127 >      tmplep.index   = i;
128 >      tmplep.charge  = mu->Charge();
129 >      tmplep.isoTrk  = mu->IsoR03SumPt();
130 >      tmplep.isoEcal = mu->IsoR03EmEt();
131 >      tmplep.isoHcal = mu->IsoR03HadEt();
132 >      tmplep.isoPF04 = musel.isoPF04;
133 >      tmplep.chisoPF04 = musel.chisoPF04;
134 >      tmplep.gaisoPF04 = musel.gaisoPF04;
135 >      tmplep.neisoPF04 = musel.neisoPF04;
136 >      // tmplep.isoPF03 = computePFMuonIso(mu,vtx,pfCandidates,0.3);
137 >      // tmplep.isoPF04 = computePFMuonIso(mu,vtx,pfCandidates,0.4);
138 >      tmplep.ip3dSig = mu->Ip3dPVSignificance();
139 >      tmplep.is4l    = false;
140 >      tmplep.isEB    = (fabs(mu->Eta()) < 1.479 ? 1 : 0 );
141 >      tmplep.isoMVA  = musel.isoMVA;
142 >      tmplep.isTight = musel.tight();
143 >      tmplep.isLoose = musel.loose();
144 >      tmplep.status  = musel;    
145 >      tmplep.fsrRecoveryAttempted = false;
146 >      SelectionStatus tmpstat = PassWwMuonSel(mu,vtx,pfCandidates);
147 >      tmplep.tightCutsApplied = tmpstat.tight();
148 >      lepvec.push_back(tmplep);
149 >      if( ctrl.debug ) cout << endl;
150 >    }
151  
152 <        SimpleLepton tmplep;
153 <        float pt = mu->pt;
154 <        tmplep.vecorig->SetPtEtaPhiM(pt,
155 <                                    mu->eta,
156 <                                    mu->phi,
157 <                                    MUON_MASS);
152 >    if( ctrl.debug ) { cout << "\tnElectron: " << electronArr->GetEntries() << endl; }
153 >    // --------------------------------------------------------------------------------
154 >    for(int i=0; i<electronArr->GetEntries(); i++)
155 >      {
156 >        const mithep::Electron *ele = (mithep::Electron*)((*electronArr)[i]);
157 >
158 >        SelectionStatus denomSel;
159 >        denomSel |= electronDenominatorSelection(ctrl,ele,vtx);
160 >        if( !(denomSel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
161          
162 <        if( ctrl.do_escale_up ) {
163 <          pt=scale_smear_muon_Up(pt, 1,  r);
164 <        }
165 <        if( ctrl.do_escale_down ) {
118 <          pt=scale_smear_muon_Down(pt, 1,  r);
119 <        }
162 >        SelectionStatus elesel;
163 >        elesel |= (*ElectronPreSelector)(ctrl,ele,vtx);
164 >        elesel |= (*ElectronIDSelector)(ctrl,ele,vtx);
165 >        elesel |= (*ElectronIsoSelector)(ctrl,ele,vtx,pfCandidates,puEnergyDensity,eraEle,photonsToVeto);
166          
167 <        tmplep.vec->SetPtEtaPhiM(pt,
168 <                                mu->eta,
169 <                                mu->phi,
170 <                                MUON_MASS);
167 >        SimpleLepton tmplep;
168 >        float pt = ele->Pt();
169 >        tmplep.vec.SetPtEtaPhiM( pt,
170 >                                 ele->Eta(),
171 >                                 ele->Phi(),
172 >                                 ELECTRON_MASS );
173          
174 <        tmplep.type    = 13;
174 >        tmplep.type    = 11;
175          tmplep.index   = i;
176 <        tmplep.charge  = mu->q;
177 <        tmplep.isoTrk  = mu->trkIso03;
178 <        tmplep.isoEcal = mu->emIso03;
179 <        tmplep.isoHcal = mu->hadIso03;
180 <        tmplep.isoPF03 = mu->pfIso03;
181 <        tmplep.isoPF04 = mu->pfIso04;
182 <        tmplep.ip3dSig = mu->ip3dSig;
176 >        tmplep.charge  = ele->Charge();
177 >        tmplep.isoTrk  = ele->TrackIsolationDr03();
178 >        tmplep.isoEcal = ele->EcalRecHitIsoDr03();
179 >        tmplep.isoHcal = ele->HcalTowerSumEtDr03();
180 >        tmplep.isoPF04 = elesel.isoPF04;
181 >        tmplep.chisoPF04 = elesel.chisoPF04;
182 >        tmplep.gaisoPF04 = elesel.gaisoPF04;
183 >        tmplep.neisoPF04 = elesel.neisoPF04;
184 >        // tmplep.isoPF03 = computePFEleIso(ele,vtx,pfCandidates,0.3);
185 >        // tmplep.isoPF04 = computePFEleIso(ele,vtx,pfCandidates,0.4);
186 >        tmplep.ip3dSig = ele->Ip3dPVSignificance();
187          tmplep.is4l    = false;
188 <        tmplep.isEB    = (fabs(mu->eta) < 1.479 ? 1 : 0 );
189 <        tmplep.isTight = musel.tight();
190 <        tmplep.isLoose = musel.loose();
188 >        tmplep.isEB    = ele->IsEB();
189 >        tmplep.scID    = ele->SCluster()->GetUniqueID();
190 >        tmplep.isTight = elesel.tight();
191 >        tmplep.isLoose = elesel.loose();
192 >        tmplep.status  = elesel;
193 >        tmplep.idMVA   = elesel.idMVA;
194 >        tmplep.isoMVA  = elesel.isoMVA;
195 >        tmplep.fsrRecoveryAttempted = false;
196 >        SelectionStatus tmpstat = electronTagSelection(ele,vtx,pfCandidates);
197 >        tmplep.tightCutsApplied   = tmpstat.tight();
198          lepvec.push_back(tmplep);
199 <        if( ctrl.debug ) { cout << "muon passes ... " << endl;}
199 >        if( ctrl.debug ) cout << endl;
200        }
142      //  }
143    }    
144  
145  
146    
147    //
148    if( ctrl.debug ) { cout << "\tnElectron: " << electronArr->GetEntries() << endl; }
149    // --------------------------------------------------------------------------------
150    for(Int_t i=0; i<electronArr->GetEntries(); i++)
151      {
152        const mithep::TElectron *ele = (mithep::TElectron*)((*electronArr)[i]);
153        
154        Bool_t isMuonOverlap = kFALSE;
155        for (int k=0; k<lepvec.size(); ++k) {
156          TVector3 tmplep;
157          tmplep.SetPtEtaPhi(ele->pt, ele->eta, ele->phi);
158          if ( abs(lepvec[k].type == 13) && lepvec[k].vec->Vect().DrEtaPhi(tmplep) < 0.15 ) {
159            if( ctrl.debug ) cout << "-----> isMuonOverlap! " << endl;
160            isMuonOverlap = kTRUE;
161            break;
162          }
163        }
164        
165        SelectionStatus elesel;
166        elesel |= (*ElectronPreSelector)(ctrl,ele);
167        elesel |= (*ElectronIDSelector)(ctrl,ele);
168        elesel |= (*ElectronIsoSelector)(ctrl,ele);
169        if( elesel.getStatus() & SelectionStatus::PRESELECTION )
170          elesel.setStatus(SelectionStatus::LOOSESELECTION);
171
172        if( ctrl.debug ){
173          cout << "\tscEt: " << ele->scEt
174               << "\tscEta: " << ele->scEta
175               << "\tncluster: " << ele->ncluster
176               << "\tisorel: " <<  ele->pfIso04/ele->pt
177               << "\tstatus: " << hex << elesel.getStatus() << dec
178               << endl;
179        }
201  
202 <        if ( elesel.pass() && !isMuonOverlap )
203 <          {
183 <            SimpleLepton tmplep;
184 <            
185 <            float pt = ele->pt;
186 <            tmplep.vecorig->SetPtEtaPhiM( pt,
187 <                                          ele->eta,
188 <                                          ele->phi,
189 <                                          ELECTRON_MASS );
190 <            
191 <            if( ctrl.do_escale ) {
192 <              pt=scale_smear_electron(pt, ele->isEB, r);
193 <            }
194 <            if( ctrl.do_escale_up ) {
195 <              pt=scale_smear_electron_Up(pt, ele->isEB,  r);
196 <            }
197 <            if( ctrl.do_escale_down ) {
198 <              pt=scale_smear_electron_Down(pt, ele->isEB,  r);
199 <            }
200 <
201 <            
202 <            tmplep.vec->SetPtEtaPhiM( pt,
203 <                                      ele->eta,
204 <                                      ele->phi,
205 <                                      ELECTRON_MASS );
206 <            
207 <            tmplep.type    = 11;
208 <            tmplep.index   = i;
209 <            tmplep.charge  = ele->q;
210 <            tmplep.isoTrk  = ele->trkIso03;
211 <            tmplep.isoEcal = ele->emIso03;
212 <            tmplep.isoHcal = ele->hadIso03;
213 <            tmplep.isoPF03 = ele->pfIso03;
214 <            tmplep.isoPF04 = ele->pfIso04;
215 <            tmplep.ip3dSig = ele->ip3dSig;
216 <            tmplep.is4l    = false;
217 <            tmplep.isEB    = ele->isEB;
218 <            tmplep.scID    = ele->scID;
219 <            tmplep.isTight = elesel.tight();
220 <            tmplep.isLoose = elesel.pass();
221 <            lepvec.push_back(tmplep);
222 <            if( ctrl.debug ) { cout << "\telectron passes ... " << endl; }
223 <          }
224 <      }
225 <    
226 <    
202 >    sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort );
203 >
204      //********************************************************
205 <    // Dump Stuff
205 >    // Step 2: Lepton Cleaning
206      //********************************************************
207 <    sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort );
208 <    int nmu=0, nele=0;
209 <    for( int i=0; i<lepvec.size(); i++ ) {
210 <      if(ctrl.debug) cout << "lepvec :: index: " << i
211 <                          << "\tpt: " << lepvec[i].vec->Pt()
212 <                          << "\ttype: " << lepvec[i].type
213 <                          << endl;
214 <      if( abs(lepvec[i].type) == 11 ) nele++;
215 <      else nmu++;
207 >    vector<vector<SimpleLepton>::iterator> electrons_to_erase;
208 >    for (vector<SimpleLepton>::iterator it1=lepvec.begin(); it1 != lepvec.end(); it1++ ) {
209 >      if ( abs(it1->type) != 11 ) continue;
210 >      TVector3 evec = it1->vec.Vect();
211 >      
212 >      bool erase_this_electron=false;
213 >      for (vector<SimpleLepton>::iterator it2=lepvec.begin(); it2 != lepvec.end(); it2++ ) {
214 >        if ( it2 == it1 )                       continue;
215 >        if ( abs(it2->type) != 13 )             continue;
216 >        // if( !(it2->status.looseIDAndPre()) )    continue;
217 >        TVector3 mvec = it2->vec.Vect();
218 >        
219 >        if ( evec.DrEtaPhi(mvec) < 0.05 ) {
220 >          erase_this_electron=true;
221 >          break;
222 >        }
223 >      }
224 >      if( erase_this_electron )
225 >        electrons_to_erase.push_back(it1);
226      }
227 <    if( ctrl.debug ) {
228 <      cout << "postsel nlep: " << lepvec.size()
242 <           << "\tnmuon: " << nmu
243 <           << "\tnelectron: " << nele
244 <           << endl;
227 >    for( int i=0; i<electrons_to_erase.size(); i++ ) {
228 >      lepvec.erase(electrons_to_erase[i]);
229      }
246    
247    
248    //******************************************************************************
249    // Selection
250    //******************************************************************************
251    float bestMass=-1; int best_mu_index=-1, best_ele_index=-1;
252    for(int i = 0; i<lepvec.size(); i++) {      // get a tight muon
253      if( abs(lepvec[i].type) != 13 ) continue;
254      if( !(lepvec[i].isTight) ) continue;
255      //      if( lepvec[i].vec->Pt() < 35 ) continue;
256      if( ctrl.debug ) cout << "got a muon, index: " << i << endl;
257
258      for(int j = 0; j<lepvec.size(); j++) {     // get a loose electron
259        if( j == i ) continue;
260        if( abs(lepvec[j].type) != 11 ) continue;
261        if( !(lepvec[j].isLoose) ) continue;
262        if (lepvec[i].charge == lepvec[j].charge) continue;          
263        //      if (lepvec[i].charge != lepvec[j].charge) continue;          
264        if( ctrl.debug ) cout << "got a electron, index: " << j << endl;
265
266        float tmpMass = ( *(lepvec[i].vec) + *(lepvec[j].vec) ).M();
267        if( ctrl.debug ) cout << "tmp vs best :: " << tmpMass << "," << bestMass << endl;
268        if( tmpMass > bestMass ) {
269          bestMass = tmpMass;
270          best_mu_index=i;
271          best_ele_index=j;
272        }
230  
231 +    //********************************************************
232 +    // Step 3: Good Leptons
233 +    //********************************************************
234 +    vector<double> pt_of_leptons_to_erase;
235 +    for (int i=0; i<lepvec.size(); i++ ) {
236 +      bool already_pushed=false;
237 +      if( !(lepvec[i].status.loose()) ) {
238 +        pt_of_leptons_to_erase.push_back(lepvec[i].vec.Pt());
239 +        already_pushed = true;
240 +        failingLeptons.push_back(lepvec[i]); // these should pass preselection
241 +      } else {
242 +        passingLeptons.push_back(lepvec[i]);
243        }
244 + #ifndef SYNC
245 +      if( !already_pushed && fabs(lepvec[i].ip3dSig)>4 )  
246 +        pt_of_leptons_to_erase.push_back(lepvec[i].vec.Pt());
247 + #endif      
248      }
249 <
250 <    if( bestMass > 0 ) {
251 <      if( ctrl.debug ) cout << "EMU candidate, mass : " << bestMass << endl;
252 <      if( lepvec[best_ele_index].isTight )
253 <        ret.status.setStatus(SelectionStatus::TIGHTSELECTION);
254 <      else
255 <        ret.status.setStatus(SelectionStatus::LOOSESELECTION);
283 <      ret.Z1leptons.push_back(lepvec[best_mu_index]);
284 <      ret.Z1leptons.push_back(lepvec[best_ele_index]);
285 <      ret.Z2leptons.push_back(lepvec[best_mu_index]);
286 <      ret.Z2leptons.push_back(lepvec[best_ele_index]);
287 <      return ret;
249 >    for( int i=0; i<pt_of_leptons_to_erase.size(); i++ ) {
250 >      for( vector<SimpleLepton>::iterator it=lepvec.begin(); it != lepvec.end(); it++ ) {
251 >        SimpleLepton flep = *it;
252 >        if( flep.vec.Pt() != pt_of_leptons_to_erase[i] ) continue;
253 >        lepvec.erase(it);
254 >        break;
255 >      }
256      }
257  
258 <    ret.status.setStatus(0);
258 >    //******************************************************************************
259 >    // W + (OF SS lepton) Selection
260 >    //******************************************************************************
261 >    if(has_ssof_lepton(ctrl)) {
262 >      ret.status.setStatus(SelectionStatus::EVTPASS);
263 >      ret.Z1leptons.push_back(passingLeptons[0]);
264 >      ret.Z1leptons.push_back(passingLeptons[0]);
265 >      ret.Z2leptons.push_back(passingLeptons[0]);
266 >      ret.Z2leptons.push_back(passingLeptons[0]);
267 >    } else {
268 >      ret.status.setStatus(SelectionStatus::FAIL);
269 >    }
270      return ret;
292
271   }
272 + //----------------------------------------------------------------------------------------
273 + bool has_ssof_lepton(ControlFlags &ctrl)
274 + {
275 +  bool has_ssof=false;
276 +  for(unsigned iw=0; iw<passingLeptons.size(); iw++) {
277 +    SimpleLepton w_lep = passingLeptons[iw];
278 +    //????????????????????????????????????????????????????????????????????????????????????????
279 +    // this is applied in skim (skim also applies ww muon id)
280 +    // if(abs(w_lep.type) == 11) {
281 +    //   if( !(w_lep.tightCutsApplied) )
282 +    //  continue;
283 +    // }
284 +    //????????????????????????????????????????????????????????????????????????????????????????
285 +    for(unsigned ifake=0; ifake<failingLeptons.size(); ifake++) {
286 +      SimpleLepton fake_lep = failingLeptons[ifake];
287 +      if(abs(fake_lep.type) == abs(w_lep.type)) continue;
288 +      if(fake_lep.charge != w_lep.charge) continue;
289 +      has_ssof = true;
290 +    }
291 +    for(unsigned ipass=0; ipass<passingLeptons.size(); ipass++) {
292 +      if(ipass == iw) continue;
293 +      SimpleLepton pass_lep = passingLeptons[ipass];
294 +      if(abs(pass_lep.type) == abs(w_lep.type)) continue;
295 +      if(pass_lep.charge != w_lep.charge) continue;
296 +      has_ssof = true;
297 +    }
298 +  }
299  
300 <
300 >  return has_ssof;
301 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines