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.8 by dkralph, Thu Jun 21 21:25:38 2012 UTC vs.
Revision 1.14 by dkralph, Thu Jul 19 11:15:31 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 108 | Line 114 | EventData apply_HZZ4L_EMU_selection(Cont
114        
115  
116        SelectionStatus denomSel;
117 <      denomSel |= muonDenominatorSelection(ctrl,mu,vtx,pfCandidates);
118 <      if( !(denomSel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
117 >      denomSel |= muonPreSelectionNoD0IP(ctrl,mu,vtx,pfCandidates);
118 >      if( !denomSel.passPre() ) continue;
119  
120        SelectionStatus musel;
121        musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates);
# Line 126 | Line 132 | EventData apply_HZZ4L_EMU_selection(Cont
132        tmplep.type    = 13;
133        tmplep.index   = i;
134        tmplep.charge  = mu->Charge();
129      tmplep.isoTrk  = mu->IsoR03SumPt();
130      tmplep.isoEcal = mu->IsoR03EmEt();
131      tmplep.isoHcal = mu->IsoR03HadEt();
135        tmplep.isoPF04 = musel.isoPF04;
136        tmplep.chisoPF04 = musel.chisoPF04;
137        tmplep.gaisoPF04 = musel.gaisoPF04;
138        tmplep.neisoPF04 = musel.neisoPF04;
136      // tmplep.isoPF03 = computePFMuonIso(mu,vtx,pfCandidates,0.3);
137      // tmplep.isoPF04 = computePFMuonIso(mu,vtx,pfCandidates,0.4);
139        tmplep.ip3dSig = mu->Ip3dPVSignificance();
140        tmplep.is4l    = false;
141        tmplep.isEB    = (fabs(mu->Eta()) < 1.479 ? 1 : 0 );
142        tmplep.isoMVA  = musel.isoMVA;
142      tmplep.isTight = musel.tight();
143        tmplep.isLoose = musel.loose();
144 +
145 +      bitset<TRIGGER_BIG_NUMBER> hltMatchBits = fillHLTMatchBits( mu->Eta(), mu->Phi(), hltTable, hltObjArr, fTrigObjs);
146 +      tmplep.isTight = testBits(ctrl,triggerBits,muTriggers,hltMatchBits,muTrigObjs);
147 +
148 +      tmplep.bdtfail = 0;
149 +      if(triggerBits.test(kHLT_IsoMu24_eta2p1))        tmplep.bdtfail |= 1;
150 +      if(hltMatchBits.test(kHLT_IsoMu24_eta2p1_MuObj)) tmplep.bdtfail |= 2;
151 +      if(triggerBits.test(kHLT_IsoMu24))               tmplep.bdtfail |= 4;
152 +      if(hltMatchBits.test(kHLT_IsoMu24_MuObj))        tmplep.bdtfail |= 8;
153 +
154        tmplep.status  = musel;    
155        tmplep.fsrRecoveryAttempted = false;
156 <      SelectionStatus tmpstat = PassWwMuonSel(mu,vtx,pfCandidates);
157 <      tmplep.tightCutsApplied = tmpstat.tight();
156 >      tmplep.tightCutsApplied = muon2012CutBasedIDTightVersionWithOldIsoThatWorksOn2011(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu);
157 >      tmplep.d0      = mu->HasTrackerTrk() ? mu->TrackerTrk()->D0Corrected(*vtx) : 0;
158 >      tmplep.dz      = mu->HasTrackerTrk() ? mu->TrackerTrk()->DzCorrected(*vtx) : 0;
159 >
160        lepvec.push_back(tmplep);
161        if( ctrl.debug ) cout << endl;
162      }
# Line 156 | Line 168 | EventData apply_HZZ4L_EMU_selection(Cont
168          const mithep::Electron *ele = (mithep::Electron*)((*electronArr)[i]);
169  
170          SelectionStatus denomSel;
171 <        denomSel |= electronDenominatorSelection(ctrl,ele,vtx);
172 <        if( !(denomSel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
171 >        denomSel |= electronPreSelectionNoD0IP(ctrl,ele,vtx);
172 >        if( !denomSel.passPre() ) continue;
173          
174          SelectionStatus elesel;
175          elesel |= (*ElectronPreSelector)(ctrl,ele,vtx);
# Line 174 | Line 186 | EventData apply_HZZ4L_EMU_selection(Cont
186          tmplep.type    = 11;
187          tmplep.index   = i;
188          tmplep.charge  = ele->Charge();
177        tmplep.isoTrk  = ele->TrackIsolationDr03();
178        tmplep.isoEcal = ele->EcalRecHitIsoDr03();
179        tmplep.isoHcal = ele->HcalTowerSumEtDr03();
189          tmplep.isoPF04 = elesel.isoPF04;
190          tmplep.chisoPF04 = elesel.chisoPF04;
191          tmplep.gaisoPF04 = elesel.gaisoPF04;
192          tmplep.neisoPF04 = elesel.neisoPF04;
184        // tmplep.isoPF03 = computePFEleIso(ele,vtx,pfCandidates,0.3);
185        // tmplep.isoPF04 = computePFEleIso(ele,vtx,pfCandidates,0.4);
193          tmplep.ip3dSig = ele->Ip3dPVSignificance();
194          tmplep.is4l    = false;
195          tmplep.isEB    = ele->IsEB();
196          tmplep.scID    = ele->SCluster()->GetUniqueID();
197 +
198 +        bitset<TRIGGER_BIG_NUMBER> hltMatchBits = fillHLTMatchBits( ele->Eta(), ele->Phi(), hltTable, hltObjArr, fTrigObjs);
199 +        tmplep.isTight = testBits(ctrl,triggerBits,eleTriggers,hltMatchBits,eleTrigObjs);
200 +
201          tmplep.isTight = elesel.tight();
202          tmplep.isLoose = elesel.loose();
203          tmplep.status  = elesel;
204          tmplep.idMVA   = elesel.idMVA;
205          tmplep.isoMVA  = elesel.isoMVA;
206          tmplep.fsrRecoveryAttempted = false;
207 <        SelectionStatus tmpstat = electronTagSelection(ele,vtx,pfCandidates);
208 <        tmplep.tightCutsApplied   = tmpstat.tight();
207 >        tmplep.tightCutsApplied = electron2012CutBasedIDMediumVersionThatWorksOn2011(ctrl,ele,vtx,pfCandidates,fConversions,puEnergyDensity,eraEle);
208 >        tmplep.d0      = ele->BestTrk()->D0Corrected(*vtx);
209 >        tmplep.dz      = ele->BestTrk()->DzCorrected(*vtx);
210 >
211          lepvec.push_back(tmplep);
212          if( ctrl.debug ) cout << endl;
213        }
# Line 231 | Line 244 | EventData apply_HZZ4L_EMU_selection(Cont
244      //********************************************************
245      // Step 3: Good Leptons
246      //********************************************************
234    vector<double> pt_of_leptons_to_erase;
247      for (int i=0; i<lepvec.size(); i++ ) {
236      bool already_pushed=false;
248        if( !(lepvec[i].status.loose()) ) {
249 <        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
249 >        failingLeptons.push_back(lepvec[i]);
250        } else {
251          passingLeptons.push_back(lepvec[i]);
252        }
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    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      }
253      }
254  
255      //******************************************************************************

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines