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

Comparing UserCode/MitHzz4l/Selection/src/Selection.cc (file contents):
Revision 1.19 by khahn, Mon Feb 13 09:47:12 2012 UTC vs.
Revision 1.20 by khahn, Thu Apr 26 06:56:30 2012 UTC

# Line 3 | Line 3
3   #include "SimpleLepton.h"
4   #include "EfficiencyWeightsInterface.h"
5  
6 < #include "HZZBDTElectronSelection.h"
6 > #include "ElectronSelection.h"
7 > #include "MuonSelection.h"
8   #include "IsolationSelection.h"
9 < #include "PassHLT.h"
9 > //#include "PassHLT.h"
10   #include "Selection.h"
11  
12   #include "ExternData.h"
# Line 16 | Line 17
17   // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
18   // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19   EventData apply_HZZ4L_selection(ControlFlags &ctrl,           // input control
20 <                                mithep::TEventInfo *info,     // input event info
21 <                                TClonesArray *electronArr,    // input electrons
22 <                                SelectionStatus (*ElectronPreSelector)( ControlFlags &, const mithep::TElectron*),
23 <                                SelectionStatus (*ElectronIDSelector)( ControlFlags &, const mithep::TElectron*),
24 <                                SelectionStatus (*ElectronIsoSelector)( ControlFlags &, const mithep::TElectron*),
25 <                                TClonesArray *muonArr,         // input muons
26 <                                SelectionStatus (*MuonPreSelector)( ControlFlags &, const mithep::TMuon*),
27 <                                SelectionStatus (*MuonIDSelector)( ControlFlags &, const mithep::TMuon*),
28 <                                SelectionStatus (*MuonIsoSelector)( ControlFlags &, const mithep::TMuon*) )
20 >                                const mithep::EventHeader *info,     // input event info
21 >                                const mithep::Vertex & vtx,
22 >                                const mithep::Array<mithep::PFCandidate>  *pfCandidates,
23 >                                const mithep::Array<mithep::PileupEnergyDensity>  *puEnergyDensity,
24 >                                const mithep::Array<mithep::Electron> *electronArr,    // input electrons
25 >                                SelectionStatus (*ElectronPreSelector)( ControlFlags &,
26 >                                                                        const mithep::Electron*,
27 >                                                                        const mithep::Vertex &),
28 >                                SelectionStatus (*ElectronIDSelector)( ControlFlags &,
29 >                                                                       const mithep::Electron*,
30 >                                                                       const mithep::Vertex &),
31 >                                SelectionStatus (*ElectronIsoSelector)( ControlFlags &,
32 >                                                                        const mithep::Electron*,
33 >                                                                        const mithep::Vertex &,
34 >                                                                        const mithep::Array<mithep::PFCandidate> *,
35 >                                                                        const mithep::Array<mithep::PileupEnergyDensity> *,
36 >                                                                        mithep::ElectronTools::EElectronEffectiveAreaTarget,
37 >                                                                        vector<const mithep::Muon*>,
38 >                                                                        vector<const mithep::Electron*> ),
39 >                                const mithep::Array<mithep::Muon> *muonArr,    // input muons
40 >                                SelectionStatus (*MuonPreSelector)( ControlFlags &,
41 >                                                                    const mithep::Muon*,
42 >                                                                    const mithep::Vertex &,
43 >                                                                    const mithep::Array<mithep::PFCandidate> *),
44 >                                SelectionStatus (*MuonIDSelector)( ControlFlags &,
45 >                                                                   const mithep::Muon*,
46 >                                                                   const mithep::Vertex &),
47 >                                SelectionStatus (*MuonIsoSelector)( ControlFlags &,
48 >                                                                    const mithep::Muon*,
49 >                                                                    const mithep::Vertex &,
50 >                                                                    const mithep::Array<mithep::PFCandidate> *,
51 >                                                                    const mithep::Array<mithep::PileupEnergyDensity> *,
52 >                                                                    mithep::MuonTools::EMuonEffectiveAreaTarget,
53 >                                                                    vector<const mithep::Muon*>,
54 >                                                                    vector<const mithep::Electron*> )
55 >                                )
56    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
57   {      
58  
# Line 33 | Line 61 | EventData apply_HZZ4L_selection(ControlF
61    TRandom3 r;
62    
63    if( ctrl.debug ) {
64 <    cout << "Run: " << info->runNum
65 <         << "\tEvt: " << info->evtNum
66 <         << "\tLumi: " << info->lumiSec
64 >    cout << "Run: " << info->RunNum()
65 >         << "\tEvt: " << info->EvtNum()
66 >         << "\tLumi: " << info->LumiSec()
67           << endl;
68    }
69  
70    if( !ctrl.mc ) {
71      // not accounting for overlap atm
72 <    RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec);      
72 >    RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec());      
73      if( !(rlrm.HasRunLumi(rl)) )  {
74        if( ctrl.debug ) cout << "\tfails JSON" << endl;
75        ret.status.setStatus(0);
76        return ret;
77      }
78    }
79 +
80 +  mithep::MuonTools::EMuonEffectiveAreaTarget         eraMu  = mithep::MuonTools::kMuEAData2011;
81 +  mithep::ElectronTools::EElectronEffectiveAreaTarget eraEle = mithep::ElectronTools::kEleEAData2011;
82 +  if( ctrl.mc ) {
83 +    eraMu  = mithep::MuonTools::kMuEAFall11MC;
84 +    eraEle = mithep::ElectronTools::kEleEAFall11MC;
85 +  }
86    
87    
88    //********************************************************
89    // Trigger
90    //********************************************************
91 +  //
92 +  // still have to port this part to bambu
93 +  //
94 +  /*
95    if( !ctrl.mc ) {
96      //if( !(passHLT(info->triggerBits, info->runNum, channel) )  ) {
97      if( !(passHLT(info->triggerBits, info->runNum, 999) )  ) {
# Line 68 | Line 107 | EventData apply_HZZ4L_selection(ControlF
107           << "\tnelectron: " << electronArr->GetEntries()
108           << endl;
109    }
110 +  */
111  
112    //********************************************************
113    // Lepton Selection
114    //********************************************************
115    vector<SimpleLepton> lepvec;
116 <  
116 >
117 >  // do something hacky for vetos for now
118 >  vector<const mithep::Muon*> muonsToVeto;
119 >  vector<const mithep::Electron*> electronsToVeto;
120 >  for(Int_t i=0; i<muonArr->GetEntries(); i++)
121 >    {
122 >      const mithep::Muon *mu = (mithep::Muon*)((*muonArr)[i]);      
123 >      SelectionStatus musel;
124 >      musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates);
125 >      if( !(musel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
126 >      musel |= (*MuonIDSelector)(ctrl,mu,vtx );
127 >      if( musel.getStatus() == SelectionStatus::TIGHTIDANDPRE )
128 >        muonsToVeto.push_back( mu );
129 >    }
130 >  for(Int_t i=0; i<electronArr->GetEntries(); i++)
131 >    {
132 >      const mithep::Electron *ele = (mithep::Electron*)((*electronArr)[i]);      
133 >      SelectionStatus esel;
134 >      esel |= (*ElectronPreSelector)(ctrl,ele,vtx);
135 >      if( !(esel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
136 >      esel |= (*ElectronIDSelector)(ctrl,ele,vtx );
137 >      if( esel.getStatus() == SelectionStatus::TIGHTIDANDPRE )
138 >        electronsToVeto.push_back( ele );
139 >    }
140 >
141    //    
142    if( ctrl.debug ) cout << "\tnMuons: " << muonArr->GetEntries() << endl;
143    //----------------------------------------------------
144    for(Int_t i=0; i<muonArr->GetEntries(); i++)
145      {
146 <      const mithep::TMuon *mu = (mithep::TMuon*)((*muonArr)[i]);      
146 >      const mithep::Muon *mu = (mithep::Muon*)((*muonArr)[i]);      
147        
148        SelectionStatus musel;
149        if(ctrl.debug) cout << "musel.status  before anything: " << musel.getStatus() << endl;
150 <      musel |= (*MuonPreSelector)(ctrl,mu);
150 >      musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates);
151        if(ctrl.debug) cout << "musel.status  after presel: " << musel.getStatus() << endl;
152 <      musel |= (*MuonIDSelector)(ctrl,mu);
152 >      if( !(musel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
153 >      musel |= (*MuonIDSelector)(ctrl,mu,vtx );
154        if(ctrl.debug) cout << "musel.status  after ID: " << musel.getStatus() << endl;
155 <      musel |= (*MuonIsoSelector)(ctrl,mu);
155 >      musel |= (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,muonsToVeto,electronsToVeto);
156        if(ctrl.debug) cout << "musel.status  after iso: " << musel.getStatus() << endl;
157  
158        if( ctrl.debug ) {
159 <        cout << "muon:: pt: " << mu->pt
160 <             << "\teta: " << mu->eta
96 <             << "\tisorel: " <<  mu->pfIso03/mu->pt
159 >        cout << "muon:: pt: " << mu->Pt()
160 >             << "\teta: " << mu->Eta()
161               << "\tstatus: " << hex << musel.getStatus() << dec
162               << endl;
163        }
# Line 101 | Line 165 | EventData apply_HZZ4L_selection(ControlF
165        if ( musel.pass() ) {
166  
167          SimpleLepton tmplep;
168 <        float pt = mu->pt;
168 >        float pt = mu->Pt();
169          tmplep.vecorig->SetPtEtaPhiM(pt,
170 <                                    mu->eta,
171 <                                    mu->phi,
172 <                                    MUON_MASS);
170 >                                     mu->Eta(),
171 >                                     mu->Phi(),
172 >                                     MUON_MASS);
173          
174          if( ctrl.do_escale_up ) {
175            pt=scale_smear_muon_Up(pt, 1,  r);
# Line 115 | Line 179 | EventData apply_HZZ4L_selection(ControlF
179          }
180          
181          tmplep.vec->SetPtEtaPhiM(pt,
182 <                                mu->eta,
183 <                                mu->phi,
184 <                                MUON_MASS);
182 >                                 mu->Eta(),
183 >                                 mu->Phi(),
184 >                                 MUON_MASS);
185          
186          tmplep.type    = 13;
187          tmplep.index   = i;
188 <        tmplep.charge  = mu->q;
189 <        tmplep.isoTrk  = mu->trkIso03;
190 <        tmplep.isoEcal = mu->emIso03;
191 <        tmplep.isoHcal = mu->hadIso03;
192 <        tmplep.isoPF03 = mu->pfIso03;
193 <        tmplep.isoPF04 = mu->pfIso04;
194 <        tmplep.ip3dSig = mu->ip3dSig;
188 >        tmplep.charge  = mu->Charge();
189 >        tmplep.isoTrk  = mu->IsoR03SumPt();
190 >        tmplep.isoEcal = mu->IsoR03EmEt();
191 >        tmplep.isoHcal = mu->IsoR03HadEt();
192 >        tmplep.isoPF03 = computePFMuonIso(mu,vtx,pfCandidates,0.3);
193 >        tmplep.isoPF04 = computePFMuonIso(mu,vtx,pfCandidates,0.4);
194 >        tmplep.ip3dSig = mu->Ip3dPVSignificance();
195          tmplep.is4l    = false;
196 <        tmplep.isEB    = (fabs(mu->eta) < 1.479 ? 1 : 0 );
196 >        tmplep.isEB    = (fabs(mu->Eta()) < 1.479 ? 1 : 0 );
197          tmplep.isTight = musel.tight();
198          tmplep.isLoose = musel.loose();
199          lepvec.push_back(tmplep);
# Line 145 | Line 209 | EventData apply_HZZ4L_selection(ControlF
209      // --------------------------------------------------------------------------------
210      for(Int_t i=0; i<electronArr->GetEntries(); i++)
211        {
212 <        const mithep::TElectron *ele = (mithep::TElectron*)((*electronArr)[i]);
212 >        const mithep::Electron *ele = (mithep::Electron*)((*electronArr)[i]);
213          
214          Bool_t isMuonOverlap = kFALSE;
215          for (int k=0; k<lepvec.size(); ++k) {
216            TVector3 tmplep;
217 <          tmplep.SetPtEtaPhi(ele->pt, ele->eta, ele->phi);
217 >          tmplep.SetPtEtaPhi(ele->Pt(), ele->Eta(), ele->Phi());
218            if ( lepvec[k].isLoose && lepvec[k].type == 13 && lepvec[k].vec->Vect().DrEtaPhi(tmplep) < 0.1 ) {
219              if( ctrl.debug ) cout << "-----> isMuonOverlap! " << endl;
220              isMuonOverlap = kTRUE;
# Line 160 | Line 224 | EventData apply_HZZ4L_selection(ControlF
224          
225          SelectionStatus elesel;
226          if( ctrl.debug ) cout << "--> status before anything: " << hex << elesel.getStatus() << dec << endl;
227 <        elesel |= (*ElectronPreSelector)(ctrl,ele);
227 >        elesel |= (*ElectronPreSelector)(ctrl,ele,vtx);
228          if( ctrl.debug ) cout << "--> status after presel: " << hex << elesel.getStatus() << dec << endl;
229 <        elesel |= (*ElectronIDSelector)(ctrl,ele);
229 >        elesel |= (*ElectronIDSelector)(ctrl,ele,vtx);
230          if( ctrl.debug ) cout << "--> status after ID: " << hex << elesel.getStatus() << dec << endl;
231 <        elesel |= (*ElectronIsoSelector)(ctrl,ele);
231 >        elesel |= (*ElectronIsoSelector)(ctrl,ele,vtx,pfCandidates,puEnergyDensity,eraEle,muonsToVeto,electronsToVeto);
232          if( ctrl.debug ) cout << "--> status after iso: " << hex << elesel.getStatus() << dec << endl;
233          
234          if( ctrl.debug ){
235 <          cout << "\tscEt: " << ele->scEt
236 <               << "\tscEta: " << ele->scEta
173 <               << "\tncluster: " << ele->ncluster
174 <               << "\tisorel: " <<  ele->pfIso04/ele->pt
235 >          cout << "\tscEt: " << ele->SCluster()->Et()
236 >               << "\tscEta: " << ele->SCluster()->Eta()
237                 << "\tstatus: " << hex << elesel.getStatus() << dec
238                 << endl;
239          }
# Line 180 | Line 242 | EventData apply_HZZ4L_selection(ControlF
242            {
243              SimpleLepton tmplep;
244              
245 <            float pt = ele->pt;
245 >            float pt = ele->Pt();
246              tmplep.vecorig->SetPtEtaPhiM( pt,
247 <                                          ele->eta,
248 <                                          ele->phi,
247 >                                          ele->Eta(),
248 >                                          ele->Phi(),
249                                            ELECTRON_MASS );
250              
251              if( ctrl.do_escale ) {
252 <              pt=scale_smear_electron(pt, ele->isEB, r);
252 >              pt=scale_smear_electron(pt, ele->IsEB(), r);
253              }
254              if( ctrl.do_escale_up ) {
255 <              pt=scale_smear_electron_Up(pt, ele->isEB,  r);
255 >              pt=scale_smear_electron_Up(pt, ele->IsEB(),  r);
256              }
257              if( ctrl.do_escale_down ) {
258 <              pt=scale_smear_electron_Down(pt, ele->isEB,  r);
258 >              pt=scale_smear_electron_Down(pt, ele->IsEB(),  r);
259              }
260  
261              
262              tmplep.vec->SetPtEtaPhiM( pt,
263 <                                      ele->eta,
264 <                                      ele->phi,
263 >                                      ele->Eta(),
264 >                                      ele->Phi(),
265                                        ELECTRON_MASS );
266              
267              tmplep.type    = 11;
268              tmplep.index   = i;
269 <            tmplep.charge  = ele->q;
270 <            tmplep.isoTrk  = ele->trkIso03;
271 <            tmplep.isoEcal = ele->emIso03;
272 <            tmplep.isoHcal = ele->hadIso03;
273 <            tmplep.isoPF03 = ele->pfIso03;
274 <            tmplep.isoPF04 = ele->pfIso04;
275 <            tmplep.ip3dSig = ele->ip3dSig;
269 >            tmplep.charge  = ele->Charge();
270 >            tmplep.isoTrk  = ele->TrackIsolationDr03();
271 >            tmplep.isoEcal = ele->EcalRecHitIsoDr03();
272 >            tmplep.isoHcal = ele->HcalTowerSumEtDr03();
273 >            tmplep.isoPF03 = computePFEleIso(ele,vtx,pfCandidates,0.3);
274 >            tmplep.isoPF04 = computePFEleIso(ele,vtx,pfCandidates,0.4);
275 >            tmplep.ip3dSig = ele->Ip3dPVSignificance();
276              tmplep.is4l    = false;
277 <            tmplep.isEB    = ele->isEB;
278 <            tmplep.scID    = ele->scID;
277 >            tmplep.isEB    = ele->IsEB();
278 >            tmplep.scID    = ele->SCluster()->GetUniqueID();
279              tmplep.isTight = elesel.tight();
280              tmplep.isLoose = elesel.loose();
281              lepvec.push_back(tmplep);
# Line 300 | Line 362 | EventData apply_HZZ4L_selection(ControlF
362        ret.status.setStatus(0);
363        return ret;
364      }
365 <    if( ctrl.debug ) cout << "\tgot a Z1 ... run: " << info->runNum << "\tevt: " << info->evtNum  << endl;
365 >    if( ctrl.debug ) cout << "\tgot a Z1 ... run: " << info->RunNum() << "\tevt: " << info->EvtNum()  << endl;
366      if( ctrl.debug ) cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl;
367      TLorentzVector Z1LeptonPlus  = *(lepvec[Z1LeptonPlusIndex].vec);
368      TLorentzVector Z1LeptonMinus = *(lepvec[Z1LeptonMinusIndex].vec);
# Line 495 | Line 557 | EventData apply_HZZ4L_selection(ControlF
557    
558    
559    
560 <    if( ctrl.debug ) cout  << "run: " << info->runNum  
561 <                           << "\tevt: " << info->evtNum
560 >    if( ctrl.debug ) cout  << "run: " << info->RunNum()  
561 >                           << "\tevt: " << info->EvtNum()
562                             << "\tZ1channel: " << lepvec[Z1LeptonMinusIndex].type
563                             << "\tZ2channel: " << lepvec[Z2LeptonMinusIndex].type
564                             << "\tmZ1: " << Z1Candidate.M()
565                             << "\tmZ2: " << Z2Candidate.M()
566                             << "\tm4l: " << ZZSystem.M()
567                             << "\tevtfail: " << hex << evtfail << dec
568 <                           << "\ttrigbits: " << hex << info->triggerBits << dec
568 >      //                           << "\ttrigbits: " << hex << info->triggerBits << dec
569        //              << "\ttree: " << inputFiles[q][f]
570                             << endl;
571    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines