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.4 by dkralph, Tue Jun 12 22:04:06 2012 UTC vs.
Revision 1.9 by dkralph, Mon Jun 25 18:08:04 2012 UTC

# Line 25 | Line 25
25   #include "CommonDefs.h"
26   #include "SelectionDefs.h"
27   #include "FSR.h"
28 < #include "UtilFuncs.h"
28 > #include "SelectionFuncs.h"
29  
30  
31   extern vector<SimpleLepton> failingLeptons;
32   extern vector<SimpleLepton> passingLeptons;
33 + extern vector<int> muTrigObjs,eleTrigObjs,muTriggers,eleTriggers;
34 + extern bitset<TRIGGER_BIG_NUMBER> triggerBits;
35  
36   //--------------------------------------------------------------------------------------------------
37   EventData apply_HZZ4L_EMU_selection(ControlFlags &ctrl,           // input control
38 <                                        const mithep::EventHeader *info,     // input event info
39 <                                        const mithep::Array<mithep::Vertex>       * vtxArr ,
40 <                                        const mithep::Array<mithep::PFCandidate>  *pfCandidates,
41 <                                        const mithep::Array<mithep::PileupEnergyDensity>  *puEnergyDensity,
42 <                                        const mithep::Array<mithep::Electron> *electronArr,    // input electrons
43 <                                        SelectionStatus (*ElectronPreSelector)( ControlFlags &,
44 <                                                                                const mithep::Electron*,
45 <                                                                                const mithep::Vertex *),
46 <                                        SelectionStatus (*ElectronIDSelector)( ControlFlags &,
47 <                                                                               const mithep::Electron*,
48 <                                                                               const mithep::Vertex *),
49 <                                        SelectionStatus (*ElectronIsoSelector)( ControlFlags &,
50 <                                                                                const mithep::Electron*,
51 <                                                                                const mithep::Vertex *,
52 <                                                                                const mithep::Array<mithep::PFCandidate> *,
53 <                                                                                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*,
38 >                                    const mithep::EventHeader *info,     // input event info
39 >                                    mithep::TriggerTable *hltTable,
40 >                                    mithep::Array<mithep::TriggerObject> *hltObjArr,
41 >                                    mithep::TriggerObjectsTable *fTrigObjs,
42 >                                    const mithep::Array<mithep::Vertex>       * vtxArr ,
43 >                                    const mithep::Array<mithep::PFCandidate>  *pfCandidates,
44 >                                    const mithep::Array<mithep::PileupEnergyDensity>  *puEnergyDensity,
45 >                                    const mithep::Array<mithep::Electron> *electronArr,    // input electrons
46 >                                    SelectionStatus (*ElectronPreSelector)( ControlFlags &,
47 >                                                                            const mithep::Electron*,
48 >                                                                            const mithep::Vertex *),
49 >                                    SelectionStatus (*ElectronIDSelector)( ControlFlags &,
50 >                                                                           const mithep::Electron*,
51 >                                                                           const mithep::Vertex *),
52 >                                    SelectionStatus (*ElectronIsoSelector)( ControlFlags &,
53 >                                                                            const mithep::Electron*,
54                                                                              const mithep::Vertex *,
55 <                                                                            const mithep::Array<mithep::PFCandidate> *,
55 >                                                                            const mithep::Array<mithep::PFCandidate> *,
56                                                                              const mithep::Array<mithep::PileupEnergyDensity> *,
57 <                                                                            mithep::MuonTools::EMuonEffectiveAreaTarget,
58 <                                                                            vector<const mithep::PFCandidate*>)
59 <                                        )
57 >                                                                            mithep::ElectronTools::EElectronEffectiveAreaTarget,
58 >                                                                            vector<const mithep::PFCandidate*>),
59 >                                    const mithep::Array<mithep::Muon> *muonArr,    // input muons
60 >                                    SelectionStatus (*MuonPreSelector)( ControlFlags &,
61 >                                                                        const mithep::Muon*,
62 >                                                                        const mithep::Vertex *,
63 >                                                                        const mithep::Array<mithep::PFCandidate> *),
64 >                                    SelectionStatus (*MuonIDSelector)( ControlFlags &,
65 >                                                                       const mithep::Muon*,
66 >                                                                       // const mithep::Vertex &),
67 >                                                                       const mithep::Vertex *,
68 >                                                                       const mithep::Array<mithep::PFCandidate> *),
69 >                                    SelectionStatus (*MuonIsoSelector)( ControlFlags &,
70 >                                                                        const mithep::Muon*,
71 >                                                                        const mithep::Vertex *,
72 >                                                                        const mithep::Array<mithep::PFCandidate> *,
73 >                                                                        const mithep::Array<mithep::PileupEnergyDensity> *,
74 >                                                                        mithep::MuonTools::EMuonEffectiveAreaTarget,
75 >                                                                        vector<const mithep::PFCandidate*>)
76 >                                    )
77   //--------------------------------------------------------------------------------------------------
78   {      
79  
# Line 106 | Line 111 | EventData apply_HZZ4L_EMU_selection(Cont
111      {
112        const mithep::Muon *mu = (mithep::Muon*)((*muonArr)[i]);      
113        
109      SelectionStatus musel;
114  
115 <      musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates);
116 <      if( !(musel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
115 >      SelectionStatus denomSel;
116 >      denomSel |= muonPreSelectionNoD0DzIP(ctrl,mu,vtx,pfCandidates);
117 >      if( !denomSel.passPre() ) continue;
118  
119 +      SelectionStatus musel;
120 +      musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates);
121        musel |= (*MuonIDSelector)(ctrl,mu,vtx,pfCandidates );
122 <
116 <      if( !(ctrl.doFSR) ) {
117 <        musel |=  (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,photonsToVeto);
118 <      }
122 >      musel |= (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,photonsToVeto);
123  
124        SimpleLepton tmplep;
125        float pt = mu->Pt();
# Line 140 | Line 144 | EventData apply_HZZ4L_EMU_selection(Cont
144        tmplep.is4l    = false;
145        tmplep.isEB    = (fabs(mu->Eta()) < 1.479 ? 1 : 0 );
146        tmplep.isoMVA  = musel.isoMVA;
143      tmplep.isTight = musel.tight();
147        tmplep.isLoose = musel.loose();
148 +
149 +      bitset<TRIGGER_BIG_NUMBER> hltMatchBits = fillHLTMatchBits( mu->Eta(), mu->Phi(), hltTable, hltObjArr, fTrigObjs);
150 +      tmplep.isTight = testBits(ctrl,triggerBits,muTriggers,hltMatchBits,muTrigObjs);
151 +
152 +      tmplep.bdtfail = 0;
153 +      if(triggerBits.test(kHLT_IsoMu24_eta2p1))        tmplep.bdtfail |= 1;
154 +      if(hltMatchBits.test(kHLT_IsoMu24_eta2p1_MuObj)) tmplep.bdtfail |= 2;
155 +      if(triggerBits.test(kHLT_IsoMu24))               tmplep.bdtfail |= 4;
156 +      if(hltMatchBits.test(kHLT_IsoMu24_MuObj))        tmplep.bdtfail |= 8;
157 +
158        tmplep.status  = musel;    
159        tmplep.fsrRecoveryAttempted = false;
160 <      tmplep.tightCutsApplied   = false;
160 >      SelectionStatus tmpstat = PassWwMuonSel(mu,vtx,pfCandidates);
161 >      tmplep.tightCutsApplied = tmpstat.tight();
162        lepvec.push_back(tmplep);
163        if( ctrl.debug ) cout << endl;
164      }
# Line 155 | Line 169 | EventData apply_HZZ4L_EMU_selection(Cont
169        {
170          const mithep::Electron *ele = (mithep::Electron*)((*electronArr)[i]);
171  
172 <        SelectionStatus elesel;
172 >        SelectionStatus denomSel;
173 >        denomSel |= electronPreSelectionNoD0DzIP(ctrl,ele,vtx);
174 >        if( !(denomSel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
175          
176 +        SelectionStatus elesel;
177          elesel |= (*ElectronPreSelector)(ctrl,ele,vtx);
161        if( !(elesel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
162        
178          elesel |= (*ElectronIDSelector)(ctrl,ele,vtx);
179 <        
165 <        if( !(ctrl.doFSR) ) {
166 <          elesel |= (*ElectronIsoSelector)(ctrl,ele,vtx,pfCandidates,puEnergyDensity,eraEle,photonsToVeto);
167 <        }
179 >        elesel |= (*ElectronIsoSelector)(ctrl,ele,vtx,pfCandidates,puEnergyDensity,eraEle,photonsToVeto);
180          
181          SimpleLepton tmplep;
182          float pt = ele->Pt();
# Line 189 | Line 201 | EventData apply_HZZ4L_EMU_selection(Cont
201          tmplep.is4l    = false;
202          tmplep.isEB    = ele->IsEB();
203          tmplep.scID    = ele->SCluster()->GetUniqueID();
204 +
205 +        bitset<TRIGGER_BIG_NUMBER> hltMatchBits = fillHLTMatchBits( ele->Eta(), ele->Phi(), hltTable, hltObjArr, fTrigObjs);
206 +        tmplep.isTight = testBits(ctrl,triggerBits,eleTriggers,hltMatchBits,eleTrigObjs);
207 +
208          tmplep.isTight = elesel.tight();
209          tmplep.isLoose = elesel.loose();
210          tmplep.status  = elesel;
# Line 215 | Line 231 | EventData apply_HZZ4L_EMU_selection(Cont
231        for (vector<SimpleLepton>::iterator it2=lepvec.begin(); it2 != lepvec.end(); it2++ ) {
232          if ( it2 == it1 )                       continue;
233          if ( abs(it2->type) != 13 )             continue;
234 <        if( !(it2->status.looseIDAndPre()) )    continue;
234 >        // if( !(it2->status.looseIDAndPre()) )    continue;
235          TVector3 mvec = it2->vec.Vect();
236          
237          if ( evec.DrEtaPhi(mvec) < 0.05 ) {
# Line 260 | Line 276 | EventData apply_HZZ4L_EMU_selection(Cont
276      //******************************************************************************
277      // W + (OF SS lepton) Selection
278      //******************************************************************************
279 <    if(ctrl.fakeScheme.Contains("emu-")) {
280 <      if(has_ssof_lepton(ctrl)) {
281 <        ret.status.setStatus(SelectionStatus::EVTPASS);
282 <        ret.Z1leptons.push_back(passingLeptons[0]);
283 <        ret.Z1leptons.push_back(passingLeptons[0]);
284 <        ret.Z2leptons.push_back(passingLeptons[0]);
285 <        ret.Z2leptons.push_back(passingLeptons[0]);
286 <      } else {
271 <        ret.status.setStatus(SelectionStatus::FAIL);
272 <      }
273 <      return ret;
279 >    if(has_ssof_lepton(ctrl)) {
280 >      ret.status.setStatus(SelectionStatus::EVTPASS);
281 >      ret.Z1leptons.push_back(passingLeptons[0]);
282 >      ret.Z1leptons.push_back(passingLeptons[0]);
283 >      ret.Z2leptons.push_back(passingLeptons[0]);
284 >      ret.Z2leptons.push_back(passingLeptons[0]);
285 >    } else {
286 >      ret.status.setStatus(SelectionStatus::FAIL);
287      }
288 +    return ret;
289   }
276
277 // //----------------------------------------------------------------------------
278 // //
279 // // Get primary vertices
280 // // Assumes primary vertices are ordered by sum-pT^2 (as should be in CMSSW)
281 // // NOTE: if no PV is found from fitting tracks, the beamspot is used
282 // //
283 // //----------------------------------------------------------------------------
284 // bool setPV(ControlFlags ctrl,
285 //         const mithep::Array<mithep::Vertex> * vtxArr,
286 //         const mithep::Vertex* &vtx)
287 // //----------------------------------------------------------------------------
288 // {
289
290 //   const mithep::Vertex *bestPV = 0;    
291 //   float best_sumpt=-1;
292
293 //   // good PV requirements
294 //   const UInt_t   fMinNTracksFit = 0;
295 //   const Double_t fMinNdof       = 4;
296 //   const Double_t fMaxAbsZ       = 24;
297 //   const Double_t fMaxRho        = 2;
298  
299 //   for(int i=0; i<vtxArr->GetEntries(); ++i) {
300 //     const mithep::Vertex *pv = (mithep::Vertex*)(vtxArr->At(i));
301 //     if( ctrl.debug ) cout << "vertex :: " << i << "\tntrks: " << pv->NTracks() << endl;
302    
303 //     // Select best PV for corrected d0; if no PV passing cuts, the first PV in the collection will be used
304 //     if(!pv->IsValid())                                continue;
305 //     if(pv->NTracksFit()       < fMinNTracksFit)       continue;
306 //     if(pv->Ndof()              < fMinNdof)         continue;
307 //     if(fabs(pv->Z()) > fMaxAbsZ)                   continue;
308 //     if(pv->Position().Rho()   > fMaxRho)           continue;    
309    
310 //     // take the first ...
311 //     bestPV = pv;
312 //     break;
313
314 //     // this never reached ...    
315 //     float tmp_sumpt=0;
316 //     for( int t=0; t<pv->NTracks(); t++ )
317 //       tmp_sumpt += pv->Trk(t)->Pt();
318    
319 //     if( tmp_sumpt > best_sumpt  ) {
320 //       bestPV = pv;
321 //       best_sumpt = tmp_sumpt;
322 //       if( ctrl.debug) cout << "new PV set, pt : " << best_sumpt << endl;
323 //     }
324 //   }
325        
326 //   // sync
327 //   if(!bestPV)
328 //     return false;
329 //   else {    
330 //     vtx = bestPV;
331 //     return true;
332 //   }  
333 // };
290   //----------------------------------------------------------------------------------------
291   bool has_ssof_lepton(ControlFlags &ctrl)
292   {
# Line 361 | Line 317 | bool has_ssof_lepton(ControlFlags &ctrl)
317  
318    return has_ssof;
319   }
364 // //----------------------------------------------------------------------------------------
365 // void getEATargets(ControlFlags &ctrl, mithep::MuonTools::EMuonEffectiveAreaTarget &eraMu, mithep::ElectronTools::EElectronEffectiveAreaTarget &eraEle)
366 // {
367 //   if( !ctrl.mc && ctrl.era == 2011 ) {
368 //     eraMu  = mithep::MuonTools::kMuEAData2011;
369 //     eraEle = mithep::ElectronTools::kEleEAData2011;
370 //   } else if( !ctrl.mc && ctrl.era == 2012 ) {
371 //     eraMu  = mithep::MuonTools::kMuEAData2012;
372 //     eraEle = mithep::ElectronTools::kEleEAData2012;
373 //   } else if( ctrl.mc && ctrl.era == 2011 ) {
374 //     eraMu  = mithep::MuonTools::kMuEAFall11MC;
375 //     eraEle = mithep::ElectronTools::kEleEAFall11MC;
376 //   } else if( ctrl.mc && ctrl.era == 2012 ) {
377 //     eraMu  = mithep::MuonTools::kMuEAData2012;
378 //     eraEle = mithep::ElectronTools::kEleEAData2012;
379 //   } else {
380 //     cerr << "unknown era for effective areas ... quitting." << endl;
381 //     exit(1);
382 //   }
383 // }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines