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.7 by dkralph, Mon Jun 18 06:56:17 2012 UTC vs.
Revision 1.12 by dkralph, Mon Jul 16 10:21:13 2012 UTC

# Line 30 | Line 30
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> *,
54 <                                                                                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::DecayParticleCol *fConversions,
46 >                                    const mithep::Array<mithep::Electron> *electronArr,    // input electrons
47 >                                    SelectionStatus (*ElectronPreSelector)( ControlFlags &,
48 >                                                                            const mithep::Electron*,
49 >                                                                            const mithep::Vertex *),
50 >                                    SelectionStatus (*ElectronIDSelector)( ControlFlags &,
51 >                                                                           const mithep::Electron*,
52 >                                                                           const mithep::Vertex *),
53 >                                    SelectionStatus (*ElectronIsoSelector)( ControlFlags &,
54 >                                                                            const mithep::Electron*,
55                                                                              const mithep::Vertex *,
56 <                                                                            const mithep::Array<mithep::PFCandidate> *,
56 >                                                                            const mithep::Array<mithep::PFCandidate> *,
57                                                                              const mithep::Array<mithep::PileupEnergyDensity> *,
58 <                                                                            mithep::MuonTools::EMuonEffectiveAreaTarget,
59 <                                                                            vector<const mithep::PFCandidate*>)
60 <                                        )
58 >                                                                            mithep::ElectronTools::EElectronEffectiveAreaTarget,
59 >                                                                            vector<const mithep::PFCandidate*>),
60 >                                    const mithep::Array<mithep::Muon> *muonArr,    // input muons
61 >                                    SelectionStatus (*MuonPreSelector)( ControlFlags &,
62 >                                                                        const mithep::Muon*,
63 >                                                                        const mithep::Vertex *,
64 >                                                                        const mithep::Array<mithep::PFCandidate> *),
65 >                                    SelectionStatus (*MuonIDSelector)( ControlFlags &,
66 >                                                                       const mithep::Muon*,
67 >                                                                       // const mithep::Vertex &),
68 >                                                                       const mithep::Vertex *,
69 >                                                                       const mithep::Array<mithep::PFCandidate> *),
70 >                                    SelectionStatus (*MuonIsoSelector)( ControlFlags &,
71 >                                                                        const mithep::Muon*,
72 >                                                                        const mithep::Vertex *,
73 >                                                                        const mithep::Array<mithep::PFCandidate> *,
74 >                                                                        const mithep::Array<mithep::PileupEnergyDensity> *,
75 >                                                                        mithep::MuonTools::EMuonEffectiveAreaTarget,
76 >                                                                        vector<const mithep::PFCandidate*>)
77 >                                    )
78   //--------------------------------------------------------------------------------------------------
79   {      
80  
# Line 106 | Line 112 | EventData apply_HZZ4L_EMU_selection(Cont
112      {
113        const mithep::Muon *mu = (mithep::Muon*)((*muonArr)[i]);      
114        
109      SelectionStatus musel;
115  
116 <      musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates);
117 <      if( !(musel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
116 >      SelectionStatus denomSel;
117 >      denomSel |= muonPreSelectionNoIP(ctrl,mu,vtx,pfCandidates);
118 >      if( !denomSel.passPre() ) continue;
119  
120 +      SelectionStatus musel;
121 +      musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates);
122        musel |= (*MuonIDSelector)(ctrl,mu,vtx,pfCandidates );
123 <
116 <      if( !(ctrl.doFSR) ) {
117 <        musel |=  (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,photonsToVeto);
118 <      }
123 >      musel |= (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,photonsToVeto);
124  
125        SimpleLepton tmplep;
126        float pt = mu->Pt();
# Line 140 | Line 145 | EventData apply_HZZ4L_EMU_selection(Cont
145        tmplep.is4l    = false;
146        tmplep.isEB    = (fabs(mu->Eta()) < 1.479 ? 1 : 0 );
147        tmplep.isoMVA  = musel.isoMVA;
143      tmplep.isTight = musel.tight();
148        tmplep.isLoose = musel.loose();
149 +
150 +      bitset<TRIGGER_BIG_NUMBER> hltMatchBits = fillHLTMatchBits( mu->Eta(), mu->Phi(), hltTable, hltObjArr, fTrigObjs);
151 +      tmplep.isTight = testBits(ctrl,triggerBits,muTriggers,hltMatchBits,muTrigObjs);
152 +
153 +      tmplep.bdtfail = 0;
154 +      if(triggerBits.test(kHLT_IsoMu24_eta2p1))        tmplep.bdtfail |= 1;
155 +      if(hltMatchBits.test(kHLT_IsoMu24_eta2p1_MuObj)) tmplep.bdtfail |= 2;
156 +      if(triggerBits.test(kHLT_IsoMu24))               tmplep.bdtfail |= 4;
157 +      if(hltMatchBits.test(kHLT_IsoMu24_MuObj))        tmplep.bdtfail |= 8;
158 +
159        tmplep.status  = musel;    
160        tmplep.fsrRecoveryAttempted = false;
161 <      SelectionStatus tmpstat = PassWwMuonSel(mu,vtx,pfCandidates);
148 <      tmplep.tightCutsApplied = tmpstat.tight();
161 >      tmplep.tightCutsApplied = muon2012CutBasedIDTightVersionWithOldIsoThatWorksOn2011(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu);
162        lepvec.push_back(tmplep);
163        if( ctrl.debug ) cout << endl;
164      }
# Line 156 | 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 |= electronPreSelectionNoIP(ctrl,ele,vtx);
174 >        if( !denomSel.passPre() ) continue;
175          
176 +        SelectionStatus elesel;
177          elesel |= (*ElectronPreSelector)(ctrl,ele,vtx);
162        if( !(elesel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
163        
178          elesel |= (*ElectronIDSelector)(ctrl,ele,vtx);
179 <        
166 <        if( !(ctrl.doFSR) ) {
167 <          elesel |= (*ElectronIsoSelector)(ctrl,ele,vtx,pfCandidates,puEnergyDensity,eraEle,photonsToVeto);
168 <        }
179 >        elesel |= (*ElectronIsoSelector)(ctrl,ele,vtx,pfCandidates,puEnergyDensity,eraEle,photonsToVeto);
180          
181          SimpleLepton tmplep;
182          float pt = ele->Pt();
# Line 190 | 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;
211          tmplep.idMVA   = elesel.idMVA;
212          tmplep.isoMVA  = elesel.isoMVA;
213          tmplep.fsrRecoveryAttempted = false;
214 <        SelectionStatus tmpstat = electronTagSelection(ele,vtx,pfCandidates);
200 <        tmplep.tightCutsApplied   = tmpstat.tight();
214 >        tmplep.tightCutsApplied = electron2012CutBasedIDMediumVersionThatWorksOn2011(ctrl,ele,vtx,pfCandidates,fConversions,puEnergyDensity,eraEle);
215          lepvec.push_back(tmplep);
216          if( ctrl.debug ) cout << endl;
217        }
# Line 234 | Line 248 | EventData apply_HZZ4L_EMU_selection(Cont
248      //********************************************************
249      // Step 3: Good Leptons
250      //********************************************************
237    vector<double> pt_of_leptons_to_erase;
251      for (int i=0; i<lepvec.size(); i++ ) {
239      bool already_pushed=false;
252        if( !(lepvec[i].status.loose()) ) {
253 <        pt_of_leptons_to_erase.push_back(lepvec[i].vec.Pt());
242 <        already_pushed = true;
243 <        failingLeptons.push_back(lepvec[i]); // these should pass preselection
253 >        failingLeptons.push_back(lepvec[i]);
254        } else {
255          passingLeptons.push_back(lepvec[i]);
256        }
247 #ifndef SYNC
248      if( !already_pushed && fabs(lepvec[i].ip3dSig)>4 )  
249        pt_of_leptons_to_erase.push_back(lepvec[i].vec.Pt());
250 #endif      
251    }
252    for( int i=0; i<pt_of_leptons_to_erase.size(); i++ ) {
253      for( vector<SimpleLepton>::iterator it=lepvec.begin(); it != lepvec.end(); it++ ) {
254        SimpleLepton flep = *it;
255        if( flep.vec.Pt() != pt_of_leptons_to_erase[i] ) continue;
256        lepvec.erase(it);
257        break;
258      }
257      }
258  
259      //******************************************************************************

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines