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.16 by khahn, Mon Nov 7 05:28:06 2011 UTC vs.
Revision 1.24 by khahn, Wed May 9 14:57:20 2012 UTC

# Line 1 | Line 1
1 < #include "Selection.h"
2 < #include "PassHLT.h"
3 <
4 < #include "SiMVAElectronSelection.h"
5 <
6 < #include "HZZCiCElectronSelection.h"
7 < #include "HZZLikelihoodElectronSelection.h"
8 < #include "HZZBDTElectronSelection.h"
9 < #include "RunLumiRangeMap.h"
1 > #include "SelectionStatus.h"
2 > #include "EventData.h"
3 > #include "SimpleLepton.h"
4   #include "EfficiencyWeightsInterface.h"
5  
6 < RunLumiRangeMap rlrm;
7 < TH1D * hpu;
6 > #include "ElectronSelection.h"
7 > #include "MuonSelection.h"
8 > #include "IsolationSelection.h"
9 > //#include "PassHLT.h"
10 > #include "Selection.h"
11  
12 + #include "ExternData.h"
13 + #include "SelectionDefs.h"
14  
15 < // #include "TH2D.h"
16 < // extern TH2D * h_mu_eff_idiso_2011a;
17 < // extern TH2D * h_mu_eff_idiso_s11;
18 < // extern TH2D * h_mu_effdata_trigger_doublemu7_2011a;
19 < // extern TH2D * h_mu_effdata_trigger_doublemu13_8_leading_2011a;
20 < // extern TH2D * h_mu_effdata_trigger_doublemu13_8_trailing_2011a;
21 <
22 < // unsigned getGenChannel(mithep::TGenInfo * ginfo) {
23 < //   int gchannel=-1;
24 < //   if( abs(ginfo->id_1_a) == EGenType::kElectron && abs(ginfo->id_1_b) == EGenType::kElectron )  gchannel=0;
25 < //   else if( abs(ginfo->id_1_a) == EGenType::kMuon && abs(ginfo->id_1_b) == EGenType::kMuon ) gchannel=1;
26 < //   else if( (abs(ginfo->id_1_a) == EGenType::kElectron && abs(ginfo->id_1_b) == EGenType::kMuon) ||
27 < //         (abs(ginfo->id_1_a) == EGenType::kMuon && abs(ginfo->id_1_b) == EGenType::kElectron) ) gchannel=2;
28 <  
29 < //   return gchannel;
30 < // };
31 <
32 < void initRunLumiRangeMap() {
33 <  rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt"));
34 <  //  rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
35 <  rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt"));
36 <  rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt"));  
37 <  rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt"));  
38 <  TFile * puf = new TFile("data/PileupReweighting.Summer11DYmm_To_Run2011A.root");
39 <  hpu = (TH1D*)(puf->Get("puWeights"));
40 < };
41 <
42 < void initRunLumiRangeMap(RunLumiRangeMap &rlrm) {
43 <  cout << "adding JSONS ... "  << endl;
44 <  rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt"));
45 <  //  rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
47 <  rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt"));
48 <  rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt"));  
49 <  rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt"));  
50 < };
51 <
52 < // unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
53 < //                             mithep::TEventInfo *info,     // input event inof
54 < //                             TClonesArray *electronArr,    // input electrons
55 < //                             TClonesArray *muonArr,        // input muons
56 < //                             double eventweight,           // weight
57 < //                             TTree * passtuple ) {
58 <
59 < //   fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL );
60 <
61 < // };
62 <
63 <
64 <
65 < // unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
66 < //                             mithep::TEventInfo *info,     // input event inof
67 < //                             TClonesArray *electronArr,    // input electrons
68 < //                             TClonesArray *muonArr,        // input muons
69 < //                             double eventweight,           // weight
70 < //                             LabVectors  *l ) {
71 <
72 < //   fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, NULL, l );
73 <
74 < // };
75 <
76 <
77 < unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
78 <                               mithep::TGenInfo *ginfo ,     // input gen info
79 <                               mithep::TEventInfo *info,     // input event info
80 <                               TClonesArray *electronArr,    // input electrons
81 <                               TClonesArray *muonArr,        // input muons
82 <                               double eventweight,           // weight
83 <                               TTree * passtuple ) {
84 <
85 <  fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL, NULL );
86 <
87 < };
88 <
89 < unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
90 <                               mithep::TEventInfo *info,     // input event info
91 <                               TClonesArray *electronArr,    // input electrons
92 <                               TClonesArray *muonArr,        // input muons
93 <                               double eventweight,           // weight
94 <                               TTree * passtuple,
95 <                               LabVectors * l ) {
96 <  fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, l, NULL );
15 > //--------------------------------------------------------------------------------------------------
16 > void fillVetoArrays( ControlFlags & ctrl,
17 >                     const mithep::Array<mithep::Muon> *muonArr,    
18 >                     vector< const mithep::Muon*>     & muonsToVeto,
19 >                     const mithep::Array<mithep::Electron> *electronArr,    
20 >                     vector< const mithep::Electron*> & electronsToVeto,
21 >                     const mithep::Vertex & vtx )
22 > //--------------------------------------------------------------------------------------------------
23 > {
24 >  if( ctrl.debug ) cout << "looping for isolation ..." << endl;
25 >  for(int i=0; i<muonArr->GetEntries(); i++)
26 >    {
27 >      const mithep::Muon *mu = (const mithep::Muon*)((*muonArr)[i]);      
28 >      SelectionStatus musel;
29 >      //      musel |= muonCutBasedVeto(ctrl,mu,vtx);
30 >      musel |= muonDummyVeto(ctrl,mu,vtx);
31 >      if( !(musel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
32 >      if(ctrl.debug) cout << "pushing mu for isol veto ... " << endl;
33 >      muonsToVeto.push_back( mu );
34 >    }
35 >  for(int i=0; i<electronArr->GetEntries(); i++)
36 >    {
37 >      const mithep::Electron *ele = (const mithep::Electron*)((*electronArr)[i]);      
38 >      SelectionStatus esel;
39 >      //      esel |= electronCutBasedVeto(ctrl,ele,vtx);
40 >      esel |= electronDummyVeto(ctrl,ele,vtx);
41 >      if( !(esel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
42 >      if(ctrl.debug) cout << "pushing ele for isol veto ... " << endl;
43 >      electronsToVeto.push_back( ele );
44 >    }
45 >  if( ctrl.debug ) cout << "done selecting for isolation veto ..." << endl << endl;;
46   }
47  
48  
49 < unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
50 <                               mithep::TEventInfo *info,     // input event info
51 <                               TClonesArray *electronArr,    // input electrons
52 <                               TClonesArray *muonArr,        // input muons
53 <                               double eventweight,           // weight
54 <                               TTree * passtuple,
55 <                               LabVectors * l=NULL,
56 <                               TClonesArray *jetArr=NULL ) {       // output ntuple
49 > //--------------------------------------------------------------------------------------------------
50 > EventData apply_HZZ4L_selection(ControlFlags &ctrl,           // input control
51 >                                const mithep::EventHeader *info,     // input event info
52 >                                const mithep::Vertex & vtx,
53 >                                const mithep::Array<mithep::PFCandidate>  *pfCandidates,
54 >                                const mithep::Array<mithep::PileupEnergyDensity>  *puEnergyDensity,
55 >                                const mithep::Array<mithep::Electron> *electronArr,    // input electrons
56 >                                SelectionStatus (*ElectronPreSelector)( ControlFlags &,
57 >                                                                        const mithep::Electron*,
58 >                                                                        const mithep::Vertex &),
59 >                                SelectionStatus (*ElectronIDSelector)( ControlFlags &,
60 >                                                                       const mithep::Electron*,
61 >                                                                       const mithep::Vertex &),
62 >                                SelectionStatus (*ElectronIsoSelector)( ControlFlags &,
63 >                                                                        const mithep::Electron*,
64 >                                                                        const mithep::Vertex &,
65 >                                                                        const mithep::Array<mithep::PFCandidate> *,
66 >                                                                        const mithep::Array<mithep::PileupEnergyDensity> *,
67 >                                                                        mithep::ElectronTools::EElectronEffectiveAreaTarget,
68 >                                                                        vector<const mithep::Muon*>,
69 >                                                                        vector<const mithep::Electron*> ),
70 >                                const mithep::Array<mithep::Muon> *muonArr,    // input muons
71 >                                SelectionStatus (*MuonPreSelector)( ControlFlags &,
72 >                                                                    const mithep::Muon*,
73 >                                                                    const mithep::Vertex &,
74 >                                                                    const mithep::Array<mithep::PFCandidate> *),
75 >                                SelectionStatus (*MuonIDSelector)( ControlFlags &,
76 >                                                                   const mithep::Muon*,
77 >                                                                   // const mithep::Vertex &),
78 >                                                                   const mithep::Vertex &,
79 >                                                                   const mithep::Array<mithep::PFCandidate> *),
80 >                                SelectionStatus (*MuonIsoSelector)( ControlFlags &,
81 >                                                                    const mithep::Muon*,
82 >                                                                    const mithep::Vertex &,
83 >                                                                    const mithep::Array<mithep::PFCandidate> *,
84 >                                                                    const mithep::Array<mithep::PileupEnergyDensity> *,
85 >                                                                    mithep::MuonTools::EMuonEffectiveAreaTarget,
86 >                                                                    vector<const mithep::Muon*>,
87 >                                                                    vector<const mithep::Electron*> )
88 >                                )
89 > //--------------------------------------------------------------------------------------------------
90 > {      
91  
92 +  EventData ret;
93    unsigned evtfail = 0x0;
94 <  unsigned gchannel=0xdeaddead;
95 <
112 < //   if( ctrl.mc && ginfo != NULL ) {
113 < //     gchannel = getGenChannel(ginfo);
114 < //   }
115 <
116 <
94 >  TRandom3 r;
95 >  
96    if( ctrl.debug ) {
97 <    cout << "Run: " << info->runNum
98 <         << "\tEvt: " << info->evtNum
99 <         << "\tLumi: " << info->lumiSec
97 >    cout << "-----------------------------------------------------------------" << endl;
98 >    cout << "-----------------------------------------------------------------" << endl;
99 >    cout << "Run: " << info->RunNum()
100 >         << "\tEvt: " << info->EvtNum()
101 >         << "\tLumi: " << info->LumiSec()
102           << endl;
103 +    cout << "-----------------------------------------------------------------" << endl;
104    }
105  
124  unsigned npu; double npuw;
106    if( !ctrl.mc ) {
107      // not accounting for overlap atm
108 <    RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec);      
108 >    RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec());      
109      if( !(rlrm.HasRunLumi(rl)) )  {
110        if( ctrl.debug ) cout << "\tfails JSON" << endl;
111 <      evtfail |= (1<<EVTFAIL_JSON);
112 <      return evtfail;
111 >      ret.status.setStatus(0);
112 >      return ret;
113      }
133  } else {
134    npu = info->nPU;
135    npuw = hpu->GetBinContent(hpu->FindBin(npu));
114    }
137  
138  
115  
116 +  mithep::MuonTools::EMuonEffectiveAreaTarget         eraMu  = mithep::MuonTools::kMuEAFall11MC;
117 +  mithep::ElectronTools::EElectronEffectiveAreaTarget eraEle = mithep::ElectronTools::kEleEAFall11MC;
118 +  if( !ctrl.mc ) {
119 +    eraMu  = mithep::MuonTools::kMuEAData2011;
120 +    eraEle = mithep::ElectronTools::kEleEAData2011;
121 +  }
122    
123    
124    //********************************************************
125    // Trigger
126    //********************************************************
127 +  //
128 +  // still have to port this part to bambu
129 +  //
130 +  /*
131    if( !ctrl.mc ) {
132 <    //  if( !(passHLT(info->triggerBits, info->runNum, channel) )  ) {
133 < //     if( !(passHLT(info->triggerBits, info->runNum, 999) )  ) {
134 < //       evtfail |= (1<<EVTFAIL_TRIGGER);
149 < //       return evtfail;
150 < //     }        
151 <  } else {
152 <    if( !(passHLTMC(info->triggerBits)) ) {
132 >    //if( !(passHLT(info->triggerBits, info->runNum, channel) )  ) {
133 >    if( !(passHLT(info->triggerBits, info->runNum, 999) )  ) {
134 >      if( ctrl.debug ) cout << "\tfails trigger" << endl;
135        evtfail |= (1<<EVTFAIL_TRIGGER);
136 <      return evtfail;
137 <    }      
138 <    //    cout << "MC trigger bits: " << hex << info->triggerBits << dec << endl;
139 <  }
136 >      ret.status.setStatus(0);
137 >      return ret;
138 >    }  
139 >  }
140 >  */
141  
142    if( ctrl.debug ) {
143      cout << "presel nlep: " << muonArr->GetEntries() + electronArr->GetEntries()
# Line 163 | Line 146 | unsigned fails_HZZ4L_selection(ControlFl
146           << endl;
147    }
148  
149 +
150    //********************************************************
151    // Lepton Selection
152    //********************************************************
153    vector<SimpleLepton> lepvec;
170  
171  //    
172  if( ctrl.debug ) cout << "\tnMuons: " << muonArr->GetEntries() << endl;
173  //----------------------------------------------------
174  for(Int_t i=0; i<muonArr->GetEntries(); i++) {
175    const mithep::TMuon *mu = (mithep::TMuon*)((*muonArr)[i]);      
176    unsigned muonfail;
177    if( ctrl.muSele == "ksWW" )
178      muonfail = passKSMuonSelection(mu);
179    else
180      muonfail = passMuonSelectionZZ(mu);
181    if( ctrl.debug ) {
182      cout << "muon:: pt: " << mu->pt
183           << "\teta: " << mu->eta
184           << "\tmask: 0x" << hex << muonfail << dec
185           << endl;
186    }
187    if ( !muonfail ) {
188      SimpleLepton tmplep;
154  
155 <      float pt = mu->pt;
156 <      if( ctrl.do_escale_up   ) pt*=(1.01);
157 <      if( ctrl.do_escale_down ) pt*=(0.99);
193 <
194 <      tmplep.vec.SetPtEtaPhiM(pt,
195 <                              mu->eta,
196 <                              mu->phi,
197 <                              105.658369e-3);
198 <
199 <      tmplep.type    = 13;
200 <      tmplep.index   = i;
201 <      tmplep.charge  = mu->q;
202 <      tmplep.isoTrk  = mu->trkIso03;
203 <      tmplep.isoEcal = mu->emIso03;
204 <      tmplep.isoHcal = mu->hadIso03;
205 <      tmplep.isoPF03 = mu->pfIso03;
206 <      tmplep.isoPF04 = mu->pfIso04;
207 <      tmplep.ip3dSig = mu->ip3dSig;
208 <      tmplep.is4l    = false;
209 <      tmplep.isEB    = (fabs(mu->eta) < 1.479 ? 1 : 0 );
210 <      lepvec.push_back(tmplep);
211 <      if( ctrl.debug ) { cout << "muon passes ... " << endl;}
212 <    }
213 <  }
214 <  
215 <  if( ctrl.debug ) { cout << "\tnElectron: " << electronArr->GetEntries() << endl; }
155 >  vector<const mithep::Muon*> muonsToVeto;
156 >  vector<const mithep::Electron*> electronsToVeto;
157 >  fillVetoArrays( ctrl, muonArr, muonsToVeto, electronArr, electronsToVeto, vtx );
158  
159 +  //    
160 +  if( ctrl.debug ) cout << "\tnMuons: " << muonArr->GetEntries() << endl;
161    //----------------------------------------------------
162 <  for(Int_t i=0; i<electronArr->GetEntries(); i++) {
163 <    const mithep::TElectron *ele = (mithep::TElectron*)((*electronArr)[i]);
164 <
165 <    if( !(isEleFO(ctrl,ele) ) ) continue;
166 <    if( ele->pt < 7 ) continue; //move this to ID
167 <
168 <    Bool_t isMuonOverlap = kFALSE;
169 <    for (int k=0; k<lepvec.size(); ++k) {
170 <      TVector3 tmplep;
171 <      tmplep.SetPtEtaPhi(ele->pt, ele->eta, ele->phi);
172 <      if ( lepvec[k].type == 13 && lepvec[k].vec.Vect().DrEtaPhi(tmplep) < 0.1 ) {
173 <        if( ctrl.debug ) cout << "-----> isMuonOverlap! " << endl;
174 <        isMuonOverlap = kTRUE;
175 <        break;
176 <      }
177 <    }
178 <
179 <    unsigned FAIL=0, isEleTight=0;
180 <
181 <    unsigned  failsCIC=0;
238 <    CICStruct ciccuts_tight, ciccuts_medium, ciccuts_loose;
239 <    if(ctrl.eleSele=="cic") {
240 <      if( ctrl.eleSeleScheme == "mediumloose" ) {
241 <        ciccuts_medium = getCiCCuts("medium");
242 <        unsigned failsCICMedium = failsCicSelection(ctrl, ele, ciccuts_medium, ctrl.kinematics);
243 <        ciccuts_loose = getCiCCuts("loose");
244 <        unsigned failsCICLoose = failsCicSelection(ctrl, ele, ciccuts_loose, ctrl.kinematics);
245 <        failsCIC = ( failsCICLoose > 0 && failsCICMedium > 0 );
246 <        if( !failsCICMedium ) isEleTight=1;
162 >  for(Int_t i=0; i<muonArr->GetEntries(); i++)
163 >    {
164 >      const mithep::Muon *mu = (mithep::Muon*)((*muonArr)[i]);      
165 >      
166 >      SelectionStatus musel;
167 >      if(ctrl.debug) cout << "musel.status  before anything: " << musel.getStatus() << endl;
168 >      musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates);
169 >      if(ctrl.debug) cout << "musel.status  after presel: " << musel.getStatus() << endl;
170 >      if( !(musel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
171 >      //      musel |= (*MuonIDSelector)(ctrl,mu,vtx );
172 >      musel |= (*MuonIDSelector)(ctrl,mu,vtx,pfCandidates );
173 >      if(ctrl.debug) cout << "musel.status  after ID: " << musel.getStatus() << endl;
174 >      musel |= (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,muonsToVeto,electronsToVeto);
175 >      if(ctrl.debug) cout << "musel.status  after iso: " << musel.getStatus() << endl;
176 >
177 >      if( ctrl.debug ) {
178 >        cout << "muon:: pt: " << mu->Pt()
179 >             << "\teta: " << mu->Eta()
180 >             << "\tstatus: " << hex << musel.getStatus() << dec
181 >             << endl;
182        }
183 <      else {
184 <        ciccuts_tight = getCiCCuts(ctrl.eleSeleScheme);
185 <        failsCIC = failsCicSelection(ctrl, ele, ciccuts_tight, ctrl.kinematics);
186 <        if( !failsCIC ) isEleTight=1;
183 >      
184 >      if ( musel.pass() ) {
185 >        
186 >        SimpleLepton tmplep;
187 >        float pt = mu->Pt();
188 >        tmplep.vecorig->SetPtEtaPhiM(pt,
189 >                                     mu->Eta(),
190 >                                     mu->Phi(),
191 >                                     MUON_MASS);
192 >        
193 >        /*
194 >        if( ctrl.do_escale_up ) {
195 >          pt=scale_smear_muon_Up(pt, 1,  r);
196 >        }
197 >        if( ctrl.do_escale_down ) {
198 >          pt=scale_smear_muon_Down(pt, 1,  r);
199 >        }
200 >        */
201 >
202 >        tmplep.vec->SetPtEtaPhiM(pt,
203 >                                 mu->Eta(),
204 >                                 mu->Phi(),
205 >                                 MUON_MASS);
206 >        
207 >        tmplep.type    = 13;
208 >        tmplep.index   = i;
209 >        tmplep.charge  = mu->Charge();
210 >        tmplep.isoTrk  = mu->IsoR03SumPt();
211 >        tmplep.isoEcal = mu->IsoR03EmEt();
212 >        tmplep.isoHcal = mu->IsoR03HadEt();
213 >        tmplep.isoPF03 = computePFMuonIso(mu,vtx,pfCandidates,0.3);
214 >        tmplep.isoPF04 = computePFMuonIso(mu,vtx,pfCandidates,0.4);
215 >        tmplep.ip3dSig = mu->Ip3dPVSignificance();
216 >        tmplep.is4l    = false;
217 >        tmplep.isEB    = (fabs(mu->Eta()) < 1.479 ? 1 : 0 );
218 >        tmplep.isTight = musel.tight();
219 >        tmplep.isLoose = musel.loose();
220 >        lepvec.push_back(tmplep);
221 >        if( ctrl.debug ) { cout << "muon passes ... " << endl;}
222        }
223 <      FAIL = failsCIC;
224 <    }
223 >      //  }
224 >    }    
225 >  
226 >  
227 >    
228 >    //
229 >    if( ctrl.debug ) { cout << "\tnElectron: " << electronArr->GetEntries() << endl; }
230 >    // --------------------------------------------------------------------------------
231 >    for(Int_t i=0; i<electronArr->GetEntries(); i++)
232 >      {
233 >        const mithep::Electron *ele = (mithep::Electron*)((*electronArr)[i]);
234 >        
235 >        Bool_t isMuonOverlap = kFALSE;
236 >        for (int k=0; k<lepvec.size(); ++k) {
237 >          TVector3 tmplep;
238 >          tmplep.SetPtEtaPhi(ele->Pt(), ele->Eta(), ele->Phi());
239 >          if ( lepvec[k].isLoose && lepvec[k].type == 13 && lepvec[k].vec->Vect().DrEtaPhi(tmplep) < 0.1 ) {
240 >            if( ctrl.debug ) cout << "-----> isMuonOverlap! " << endl;
241 >            isMuonOverlap = kTRUE;
242 >            break;
243 >          }
244 >        }
245 >        
246 >        SelectionStatus elesel;
247 >        if( ctrl.debug ) cout << "--> status before anything: " << hex << elesel.getStatus() << dec << endl;
248 >        elesel |= (*ElectronPreSelector)(ctrl,ele,vtx);
249 >        if( ctrl.debug ) cout << "--> status after presel: " << hex << elesel.getStatus() << dec << endl;
250 >        elesel |= (*ElectronIDSelector)(ctrl,ele,vtx);
251 >        if( ctrl.debug ) cout << "--> status after ID: " << hex << elesel.getStatus() << dec << endl;
252 >        elesel |= (*ElectronIsoSelector)(ctrl,ele,vtx,pfCandidates,puEnergyDensity,eraEle,muonsToVeto,electronsToVeto);
253 >        if( ctrl.debug ) cout << "--> status after iso: " << hex << elesel.getStatus() << dec << endl;
254 >        
255 >        if( ctrl.debug ){
256 >          cout << "\tscEt: " << ele->SCluster()->Et()
257 >               << "\tscEta: " << ele->SCluster()->Eta()
258 >               << "\tstatus: " << hex << elesel.getStatus() << dec
259 >               << endl;
260 >        }
261  
262 <    LikStruct likcuts;
263 <    unsigned failsLike=0;
264 <    if(ctrl.eleSele=="lik") {
265 <      likcuts = getLikCuts(ctrl.eleSeleScheme);
266 <      failsLike = failsLikelihoodSelection(ele, likcuts, ctrl.kinematics);
267 <      FAIL = failsLike;
268 <    }
269 <    unsigned failsBDT=0;
270 <    if(ctrl.eleSele=="bdt") {
271 <      if( ctrl.eleSeleScheme == "mediumloose" ) {
272 <        unsigned failsBDTMedium = failsBDTSelection(ctrl,"medium",ele);
273 <        unsigned failsBDTLoose  = failsBDTSelection(ctrl,"loose",ele);
274 <        failsBDT = ( failsBDTLoose > 0 && failsBDTMedium > 0 );
275 <        if( !failsBDTMedium ) isEleTight=1;
276 <      } else {
277 <        failsBDT = failsBDTSelection(ctrl,"tight",ele);
278 <        if( !failsBDT ) isEleTight=1;
262 >        if ( elesel.pass() && !isMuonOverlap )
263 >          {
264 >            SimpleLepton tmplep;
265 >            
266 >            float pt = ele->Pt();
267 >            tmplep.vecorig->SetPtEtaPhiM( pt,
268 >                                          ele->Eta(),
269 >                                          ele->Phi(),
270 >                                          ELECTRON_MASS );
271 >            /*
272 >            if( ctrl.do_escale ) {
273 >              pt=scale_smear_electron(pt, ele->IsEB(), r);
274 >            }
275 >            if( ctrl.do_escale_up ) {
276 >              pt=scale_smear_electron_Up(pt, ele->IsEB(),  r);
277 >            }
278 >            if( ctrl.do_escale_down ) {
279 >              pt=scale_smear_electron_Down(pt, ele->IsEB(),  r);
280 >            }
281 >            */
282 >            
283 >            tmplep.vec->SetPtEtaPhiM( pt,
284 >                                      ele->Eta(),
285 >                                      ele->Phi(),
286 >                                      ELECTRON_MASS );
287 >            
288 >            tmplep.type    = 11;
289 >            tmplep.index   = i;
290 >            tmplep.charge  = ele->Charge();
291 >            tmplep.isoTrk  = ele->TrackIsolationDr03();
292 >            tmplep.isoEcal = ele->EcalRecHitIsoDr03();
293 >            tmplep.isoHcal = ele->HcalTowerSumEtDr03();
294 >            tmplep.isoPF03 = computePFEleIso(ele,vtx,pfCandidates,0.3);
295 >            tmplep.isoPF04 = computePFEleIso(ele,vtx,pfCandidates,0.4);
296 >            tmplep.ip3dSig = ele->Ip3dPVSignificance();
297 >            tmplep.is4l    = false;
298 >            tmplep.isEB    = ele->IsEB();
299 >            tmplep.scID    = ele->SCluster()->GetUniqueID();
300 >            tmplep.isTight = elesel.tight();
301 >            tmplep.isLoose = elesel.loose();
302 >            lepvec.push_back(tmplep);
303 >            if( ctrl.debug ) { cout << "\telectron passes ... " << endl; }
304 >          }
305        }
306 <      FAIL = failsBDT;
306 >    
307 >    
308 >    //********************************************************
309 >    // Dump Stuff
310 >    //********************************************************
311 >    sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort );
312 >    int nmu=0, nele=0;
313 >    for( int i=0; i<lepvec.size(); i++ ) {
314 >      if(ctrl.debug) cout << "lepvec :: index: " << i
315 >                          << "\tpt: " << lepvec[i].vec->Pt()
316 >                          << "\ttype: " << lepvec[i].type
317 >                          << endl;
318 >      if( abs(lepvec[i].type) == 11 ) nele++;
319 >      else nmu++;
320      }
321 <
322 <
323 <    if( ctrl.debug ){
324 <      cout << "CIC category: " << cicCategory(ele)
280 <           << "\tlikelihood: " << ele->likelihood
281 <           << "\tFAIL:  0x"     << hex << FAIL      << dec
282 <           << "\tfailsCIC:  0x" << hex << failsCIC  << dec
283 <           << "\tfailsLike: 0x" << hex << failsLike << dec
284 <           << "\tfailsBDT:  0x" << hex << failsBDT << dec
285 <           << "\tscEt: " << ele->scEt
286 <           << "\tscEta: " << ele->scEta
287 <           << "\tncluster: " << ele->ncluster
321 >    if( ctrl.debug ) {
322 >      cout << "postsel nlep: " << lepvec.size()
323 >           << "\tnmuon: " << nmu
324 >           << "\tnelectron: " << nele
325             << endl;
326      }
327 <    if ( !FAIL && !isMuonOverlap ) {
328 <      SimpleLepton tmplep;
329 <
330 <      float pt = ele->pt;
331 <      if( ctrl.do_escale_up   ) pt*=(1.02);
332 <      if( ctrl.do_escale_down ) pt*=(0.98);
333 <
334 <      tmplep.vec.SetPtEtaPhiM( pt,
335 <                               ele->eta,
336 <                               ele->phi,
337 <                               0.51099892e-3 );
338 <      tmplep.type    = 11;
339 <      tmplep.index   = i;
340 <      tmplep.charge  = ele->q;
341 <      tmplep.isoTrk  = ele->trkIso03;
342 <      tmplep.isoEcal = ele->emIso03;
343 <      tmplep.isoHcal = ele->hadIso03;
344 <      tmplep.isoPF03 = ele->pfIso03;
345 <      tmplep.isoPF04 = ele->pfIso04;
346 <      tmplep.ip3dSig = ele->ip3dSig;
347 <      tmplep.is4l    = false;
348 <      tmplep.isTight = isEleTight;
349 <      tmplep.isEB    = ele->isEB;
350 <      lepvec.push_back(tmplep);
351 <      if( ctrl.debug ) { cout << "\telectron passes ... " << endl; }
352 <    }
353 <  }
354 <  
355 <  sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort );
356 <
357 <  for( int i=0; i<lepvec.size(); i++ ) {
358 <    //
359 <    //  check for a matched btagged jet
360 <    //
361 <    lepvec[i].tche = -1;
362 <    lepvec[i].tchp = -1;
363 <    lepvec[i].csv = -1;
364 <    lepvec[i].csvMva = -1;
365 <
366 <    if( jetArr != NULL ) {
367 <      for(int k=0; k<jetArr->GetEntries(); k++) {
368 <        const mithep::TJet *jet = (mithep::TJet*)((*jetArr)[k]);      
369 <        TVector3 jvec;
370 <        jvec.SetPtEtaPhi(jet->pt, jet->eta, jet->phi);
371 <        if( jvec.DrEtaPhi( lepvec[i].vec.Vect()) < 0.2 ) {
372 <          lepvec[i].tche = jet->tche;
373 <          lepvec[i].tchp = jet->tchp;
374 <          lepvec[i].csv = jet->csv;
375 <          lepvec[i].csvMva = jet->csvMva;
327 >    
328 >    
329 >    //******************************************************************************
330 >    // Z1 Selection
331 >    //******************************************************************************
332 >    int Z1LeptonPlusIndex = -1;
333 >    int Z1LeptonMinusIndex = -1;
334 >    double BestZ1Mass = -999;
335 >    if( ctrl.debug ) { cout << "looking for a Z1 ..." << endl; }
336 >    for(int i = 0; i < lepvec.size(); ++i) {
337 >      if( !(lepvec[i].isLoose) ) continue;
338 >      for(int j = i+1; j < lepvec.size(); ++j) {
339 >        if( !(lepvec[j].isLoose) ) continue;
340 >        if( ctrl.debug ) { cout << "\tconsidering leptons " << i << " & " << j << endl; }
341 >        if (!(lepvec[i].vec->Pt() > 20.0 || lepvec[j].vec->Pt() > 20.0)) continue;
342 >        if( ctrl.debug ) { cout << "\tat least one is > 20 GeV" << endl; }
343 >        if (!(lepvec[i].vec->Pt() > 10.0 && lepvec[j].vec->Pt() > 10.0)) continue;
344 >        if( ctrl.debug ) { cout << "\tthe other  is > 10 GeV" << endl; }
345 >        if (lepvec[i].charge == lepvec[j].charge) continue;          
346 >        if( ctrl.debug ) { cout << "\tthey're opposite charge" << endl; }
347 >        if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) continue;  
348 >        if( ctrl.debug ) { cout << "\tthey're same flavor" << endl; }
349 >        
350 >        //Make Z1 hypothesis
351 >        TLorentzVector *leptonPlus, *leptonMinus;
352 >        if ( lepvec[i].charge > 0 ) {
353 >          leptonPlus  = lepvec[i].vec;
354 >          leptonMinus = lepvec[j].vec;
355 >        } else {
356 >          leptonPlus  = lepvec[j].vec;
357 >          leptonMinus = lepvec[i].vec;
358 >        }
359 >        
360 >        float tmpZ1Mass = (*leptonPlus + *leptonMinus).M();
361 >        if( ctrl.debug ) cout << "Z1 selection, tmpZ1Mass: " << tmpZ1Mass << endl;
362 >        if( tmpZ1Mass > 50 ) {
363 >          if (fabs(tmpZ1Mass - Z_MASS) < fabs(BestZ1Mass - Z_MASS)) {
364 >            BestZ1Mass = tmpZ1Mass;
365 >            if( ctrl.debug ) cout << "Z1 selection, new BestZ1Mass: " << BestZ1Mass
366 >                                  << "\tdM: " << fabs(BestZ1Mass - Z_MASS)
367 >                                  << endl;
368 >            if (lepvec[i].charge > 0) {
369 >              Z1LeptonPlusIndex = i;
370 >              Z1LeptonMinusIndex = j;
371 >            } else {
372 >              Z1LeptonPlusIndex = j;
373 >              Z1LeptonMinusIndex = i;
374 >            }
375 >          }
376          }
377        }
378      }
379 <  }
380 <
381 <  int nmu=0, nele=0;
382 <  for( int i=0; i<lepvec.size(); i++ ) {
383 <    if( abs(lepvec[i].type) == 11 ) nele++;
384 <    else nmu++;
385 <  }
386 <  if( ctrl.debug ) {
387 <    cout << "postsel nlep: " << lepvec.size()
388 <         << "\tnmuon: " << nmu
389 <         << "\tnelectron: " << nele
390 <         << endl;
391 <  }
392 <
393 <  //******************************************************************************
394 <  //Z1 Selection
395 <  //******************************************************************************
396 <  int Z1LeptonPlusIndex = -1;
397 <  int Z1LeptonMinusIndex = -1;
398 <  double BestZ1Mass = -999;
399 <  if( ctrl.debug ) { cout << "looking for a Z1 ..." << endl; }
400 <  for(int i = 0; i < lepvec.size(); ++i) {
401 <    for(int j = i+1; j < lepvec.size(); ++j) {
402 <      if( ctrl.debug ) { cout << "\tconsidering leptons " << i << " & " << j << endl; }
403 <      if (!(lepvec[i].vec.Pt() > 20.0 || lepvec[j].vec.Pt() > 20.0)) continue;
404 <      if( ctrl.debug ) { cout << "\tat least one is > 20 GeV" << endl; }
405 <      if (!(lepvec[i].vec.Pt() > 10.0 && lepvec[j].vec.Pt() > 10.0)) continue;
406 <      if( ctrl.debug ) { cout << "\tthe other  is > 10 GeV" << endl; }
407 <      if (lepvec[i].charge == lepvec[j].charge) continue;          
408 <      if( ctrl.debug ) { cout << "\tthey're opposite charge" << endl; }
409 <      if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) continue;  
410 <      if( ctrl.debug ) { cout << "\tthey're same flavor" << endl; }
379 >    // stop if no Z1 candidate is found
380 >    if( BestZ1Mass < 0 ) {
381 >      evtfail |= (1<<EVTFAIL_Z1);
382 >      //ret.status = evtfail;
383 >      ret.status.setStatus(0);
384 >      return ret;
385 >    }
386 >    if( ctrl.debug ) cout << "\tgot a Z1 ... run: " << info->RunNum() << "\tevt: " << info->EvtNum()  << endl;
387 >    if( ctrl.debug ) cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl;
388 >    TLorentzVector Z1LeptonPlus  = *(lepvec[Z1LeptonPlusIndex].vec);
389 >    TLorentzVector Z1LeptonMinus = *(lepvec[Z1LeptonMinusIndex].vec);
390 >    TLorentzVector Z1Candidate   =  Z1LeptonPlus + Z1LeptonMinus;
391 >    
392 >    
393 >    //******************************************************************************
394 >    // Z1 + l
395 >    //******************************************************************************
396 >    if( lepvec.size() < 3 ) {
397 >      evtfail |= (1<<EVTFAIL_Z1_PLUSL);
398 >      //ret.status = evtfail;
399 >      ret.status.setStatus(0);
400 >      return ret;
401 >    }
402 >    
403 >    //******************************************************************************
404 >    // 4l/Z2 Selection
405 >    //******************************************************************************
406 >    Int_t Z2LeptonPlusIndex = -1;
407 >    Int_t Z2LeptonMinusIndex = -1;
408 >    Double_t BestZ2Mass = -1;
409 >    if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
410 >    for(int i = 0; i < lepvec.size(); ++i) {
411 >      
412 >      if( ctrl.debug)  cout << "i: " << i
413 >                            << "\tpt: " << lepvec[i].vec->Pt()
414 >                            << "\ttype: " << lepvec[i].type
415 >                            << endl;
416        
417 <      //Make Z1 hypothesis
418 <      TLorentzVector leptonPlus, leptonMinus;
419 <      if ( lepvec[i].charge > 0 ) {
420 <        leptonPlus  = lepvec[i].vec;
379 <        leptonMinus = lepvec[j].vec;
380 <      } else {
381 <        leptonPlus  = lepvec[j].vec;
382 <        leptonMinus = lepvec[i].vec;
417 >      if( ctrl.eleSeleScheme == "mediumloose" &&
418 >          !(lepvec[i].isTight) ) {
419 >        if( ctrl.debug)  cout << "it's not tight, skipping ... " << endl;
420 >        continue;
421        }
422        
423 <      float tmpZ1Mass = (leptonPlus+leptonMinus).M();
424 <      if( ctrl.debug ) cout << "Z1 selection, tmpZ1Mass: " << tmpZ1Mass << endl;
425 <      if( tmpZ1Mass > 60 ) {
426 <        if (fabs(tmpZ1Mass - 91.1876) < fabs(BestZ1Mass - 91.1876)) {
427 <          BestZ1Mass = tmpZ1Mass;
428 <          if( ctrl.debug ) cout << "Z1 selection, new BestZ1Mass: " << BestZ1Mass
429 <               << "\tdM: " << fabs(BestZ1Mass - 91.1876)
430 <               << endl;
423 >      for(int j = i+1; j < lepvec.size(); ++j) {
424 >        if( ctrl.debug)  cout << "\t\tj: " << j
425 >                              << "\tpt: " << lepvec[j].vec->Pt()
426 >                              << "\ttype: " << lepvec[j].type
427 >                              << endl;
428 >        
429 >        if( ctrl.eleSeleScheme == "mediumloose" &&
430 >            !(lepvec[j].isTight) ) {
431 >          if( ctrl.debug)  cout << "it's not tight, skipping ... " << endl;
432 >          continue;
433 >        }
434 >        
435 >        
436 >        if (i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex) {
437 >          if( ctrl.debug)  cout << "\ti matches a Z1 index, skipping ..." << endl;
438 >          continue; //skip Z1 leptons
439 >        }
440 >        if (j == Z1LeptonPlusIndex || j == Z1LeptonMinusIndex) {
441 >          if( ctrl.debug)  cout << "\tj matches a Z1 index, skipping ..." << endl;
442 >          continue; //skip Z1 leptons
443 >        }
444 >        if (lepvec[i].charge == lepvec[j].charge) {
445 >          if( ctrl.debug)  cout << "\ti and j are same sign, skipping ..." << endl;
446 >          continue;         //require opp sign
447 >        }
448 >        if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) {
449 >          if( ctrl.debug) cout << "\ti and j are not same flavor, skipping ..." << endl;
450 >          continue; //require same flavor
451 >        }
452 >        
453 >        
454 >        //Make Z2 hypothesis
455 >        TLorentzVector *leptonPlus, *leptonMinus;
456 >        
457 >        if (lepvec[i].charge > 0 ) {
458 >          leptonPlus  = lepvec[i].vec;
459 >          leptonMinus = lepvec[j].vec;
460 >        } else {
461 >          leptonPlus  = lepvec[j].vec;
462 >          leptonMinus = lepvec[i].vec;
463 >        }
464 >        
465 >        TLorentzVector dilepton = *leptonPlus + *leptonMinus;
466 >        TLorentzVector fourLepton = Z1Candidate + dilepton;
467 >        
468 >        if( ctrl.debug ) cout << "dilepton.M() : " << dilepton.M() << endl;
469 >        if( ctrl.debug ) cout << "fourLepton.M() : " << fourLepton.M() << endl;
470 >        
471 >        if (!(dilepton.M() > 12.0)) continue;
472 >        if (!(fourLepton.M() > 100.0)) continue;
473 >        
474 >        //for 4e and 4mu, require at least 1 of the other opp sign lepton pairs have mass > 12
475 >        if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) {
476 >          TLorentzVector pair1 = Z1LeptonPlus + *leptonMinus;
477 >          TLorentzVector pair2 = Z1LeptonMinus + *leptonPlus;
478 >          if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
479 >          if (!(pair1.M() > 12 || pair2.M() > 12)) continue;
480 >        }
481 >      
482 >      
483 >        //Disambiguiation is done by choosing the pair with the largest ptMax and largest ptMin
484 >        if (Z2LeptonPlusIndex < 0) {
485            if (lepvec[i].charge > 0) {
486 <            Z1LeptonPlusIndex = i;
487 <            Z1LeptonMinusIndex = j;
486 >            Z2LeptonPlusIndex = i;
487 >            Z2LeptonMinusIndex = j;
488            } else {
489 <            Z1LeptonPlusIndex = j;
490 <            Z1LeptonMinusIndex = i;
489 >            Z2LeptonPlusIndex = j;
490 >            Z2LeptonMinusIndex = i;
491 >          }
492 >        } else {
493 >          Double_t BestPairPtMax = lepvec[Z2LeptonPlusIndex].vec->Pt();              
494 >          Double_t BestPairPtMin = lepvec[Z2LeptonMinusIndex].vec->Pt();
495 >          if (lepvec[Z2LeptonMinusIndex].vec->Pt() > BestPairPtMax) {
496 >            BestPairPtMax = lepvec[Z2LeptonMinusIndex].vec->Pt();
497 >            BestPairPtMin = lepvec[Z2LeptonPlusIndex].vec->Pt();
498            }
400        }
401      }
402    }
403  }
404  // stop if no Z1 candidate is found
405  if( BestZ1Mass < 0 ) {
406    evtfail |= (1<<EVTFAIL_Z1);
407    return evtfail;
408  }
409  if( ctrl.debug ) cout << "\tgot a Z1 ... run: " << info->runNum << "\tevt: " << info->evtNum  << endl;
410  if( ctrl.debug ) cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl;
411  TLorentzVector Z1LeptonPlus  = lepvec[Z1LeptonPlusIndex].vec;
412  TLorentzVector Z1LeptonMinus = lepvec[Z1LeptonMinusIndex].vec;
413  TLorentzVector Z1Candidate   =  Z1LeptonPlus + Z1LeptonMinus;
414  if( l != NULL ) {
415    l->vecz1 = Z1Candidate;
416    l->vecl1p = Z1LeptonPlus;
417    l->vecl1m = Z1LeptonMinus;
418  }
419  
420  //******************************************************************************
421  // Z1 + l
422  //******************************************************************************
423  if( lepvec.size() < 3 ) {
424    evtfail |= (1<<EVTFAIL_Z1_PLUSL);
425    return evtfail;
426  }
499          
500 <  //******************************************************************************
501 <  // 4l/Z2 Selection
502 <  //******************************************************************************
503 <  Int_t Z2LeptonPlusIndex = -1;
504 <  Int_t Z2LeptonMinusIndex = -1;
505 <  Double_t BestZ2Mass = -1;
506 <  if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
507 <  for(int i = 0; i < lepvec.size(); ++i) {
508 <    if( abs(lepvec[i].type) == 11 &&
509 <        ctrl.eleSeleScheme == "mediumloose" &&
510 <        !(lepvec[i].isTight) ) continue;
439 <
440 <    for(int j = i+1; j < lepvec.size(); ++j) {
441 <      if( abs(lepvec[j].type) == 11 &&
442 <          ctrl.eleSeleScheme == "mediumloose" &&
443 <          !(lepvec[j].isTight) ) continue;
444 <
445 <      //            cout << "i: " << i << "\tj: " << j << endl;
446 <      if (i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex) {
447 <        //            cout << "\ti matches a Z1 index, skipping ..." << endl;
448 <        continue; //skip Z1 leptons
449 <      }
450 <      if (j == Z1LeptonPlusIndex || j == Z1LeptonMinusIndex) {
451 <        //            cout << "\tj matches a Z1 index, skipping ..." << endl;
452 <              continue; //skip Z1 leptons
453 <            }
454 <            if (lepvec[i].charge == lepvec[j].charge) {
455 <              //              cout << "\ti and j are same sign, skipping ..." << endl;
456 <              continue;         //require opp sign
457 <            }
458 <            if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) {
459 <              //              cout << "\ti and j are not same flavor, skipping ..." << endl;
460 <              continue; //require same flavor
461 <            }
462 <            
463 <            
464 <            //Make Z2 hypothesis
465 <            TLorentzVector leptonPlus, leptonMinus;
466 <            
467 <            if (lepvec[i].charge > 0 ) {
468 <              leptonPlus  = lepvec[i].vec;
469 <              leptonMinus = lepvec[j].vec;
470 <            } else {
471 <              leptonPlus  = lepvec[j].vec;
472 <              leptonMinus = lepvec[i].vec;
473 <            }
474 <
475 <            TLorentzVector dilepton = leptonPlus+leptonMinus;
476 <            TLorentzVector fourLepton = Z1Candidate + dilepton;
477 <
478 <            if( ctrl.debug ) cout << "dilepton.M() : " << dilepton.M() << endl;
479 <            if( ctrl.debug ) cout << "fourLepton.M() : " << fourLepton.M() << endl;
480 <
481 <            if (!(dilepton.M() > 12.0)) continue;
482 <            if (!(fourLepton.M() > 100.0)) continue;
483 <
484 <            /*
485 <            //for 4e and 4mu, require at least 1 of the other opp sign lepton pairs have mass > 12
486 <            if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) {
487 <              TLorentzVector pair1 = Z1LeptonPlus+leptonMinus;
488 <              TLorentzVector pair2 = Z1LeptonMinus+leptonPlus;
489 <              if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
490 <              if (!(pair1.M() > 12 || pair2.M() > 12)) continue;
491 <            }
492 <            */
493 <
494 <            //Disambiguiation is done by choosing the pair with the largest ptMax and largest ptMin
495 <            if (Z2LeptonPlusIndex < 0) {
496 <              if (lepvec[i].charge > 0) {
497 <                Z2LeptonPlusIndex = i;
498 <                Z2LeptonMinusIndex = j;
499 <              } else {
500 <                Z2LeptonPlusIndex = j;
501 <                Z2LeptonMinusIndex = i;
502 <              }
503 <            } else {
504 <              Double_t BestPairPtMax = lepvec[Z2LeptonPlusIndex].vec.Pt();              
505 <              Double_t BestPairPtMin = lepvec[Z2LeptonMinusIndex].vec.Pt();
506 <              if (lepvec[Z2LeptonMinusIndex].vec.Pt() > BestPairPtMax) {
507 <                BestPairPtMax = lepvec[Z2LeptonMinusIndex].vec.Pt();
508 <                BestPairPtMin = lepvec[Z2LeptonPlusIndex].vec.Pt();
509 <              }
510 <
511 <              Double_t CurrentPairPtMax = lepvec[i].vec.Pt();              
512 <              Double_t CurrentPairPtMin = lepvec[j].vec.Pt();
513 <              if (lepvec[j].vec.Pt() > CurrentPairPtMax) {
514 <                CurrentPairPtMax = lepvec[j].vec.Pt();
515 <                CurrentPairPtMin = lepvec[i].vec.Pt();
516 <              }
517 <
518 <              if (CurrentPairPtMax > BestPairPtMax) {
519 <                if (lepvec[i].charge > 0) {
520 <                  Z2LeptonPlusIndex = i;
521 <                  Z2LeptonMinusIndex = j;
522 <                } else {
523 <                  Z2LeptonPlusIndex = j;
524 <                  Z2LeptonMinusIndex = i;
525 <                }
526 <              } else if (CurrentPairPtMax  == BestPairPtMax) {
527 <                if (CurrentPairPtMin > BestPairPtMin) {
528 <                  if (lepvec[i].charge > 0) {
529 <                    Z2LeptonPlusIndex = i;
530 <                    Z2LeptonMinusIndex = j;
531 <                  } else {
532 <                    Z2LeptonPlusIndex = j;
533 <                    Z2LeptonMinusIndex = i;
534 <                  }                  
535 <                }
536 <              }
537 <            }            
538 <          }
539 <        }
540 <
541 <        // stop if no Z2 candidate is found
542 <        if (Z2LeptonPlusIndex == -1) {
543 <          evtfail |= ( 1<<EVTFAIL_4L );
544 <          return evtfail;
545 <          //      h_evtfail->Fill( evtfail );
546 <          //      cout << "evtfail: " << hex << evtfail << dec << endl;
547 <          //      continue;
548 <        }
549 <        if( ctrl.debug ) cout << "\tgot a Z2 ..." << endl;
550 <        if( ctrl.debug ) cout << "\tZ2 plusindex: " << Z2LeptonPlusIndex
551 <                              << "\tminusindex: " << Z2LeptonMinusIndex << endl;
552 <        TLorentzVector  Z2LeptonPlus  = lepvec[Z2LeptonPlusIndex].vec;
553 <        TLorentzVector  Z2LeptonMinus = lepvec[Z2LeptonMinusIndex].vec;
554 <        TLorentzVector  Z2Candidate   = Z2LeptonPlus+Z2LeptonMinus;
555 <        TLorentzVector  ZZSystem      = Z1Candidate + Z2Candidate;
556 <        if( l != NULL ) {
557 <          l->vecz2 = Z2Candidate;
558 <          l->vecl2p = Z2LeptonPlus;
559 <          l->vecl2m = Z2LeptonMinus;
560 <          l->vec4l = ZZSystem;
561 <        }
562 <        lepvec[Z1LeptonPlusIndex].is4l = true;
563 <        lepvec[Z1LeptonMinusIndex].is4l = true;
564 <        lepvec[Z2LeptonPlusIndex].is4l = true;
565 <        lepvec[Z2LeptonMinusIndex].is4l = true;
566 <
567 <        //***************************************************************
568 <        // Isolation
569 <        //***************************************************************
570 <        bool failiso=false;
571 <
572 <        if( ctrl.isoScheme == "pf" ) {
573 <
574 <          for( int i=0; i<lepvec.size(); i++ ) {
575 <
576 <            if( !(lepvec[i].is4l) ) continue;
577 <
578 <            if( abs(lepvec[i].type) == 11 ) {
579 <              float reliso = lepvec[i].isoPF04/lepvec[i].vec.Pt();
580 <              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EB_HIGHPT ) {
581 <                failiso = true;
582 <                break;
583 <              }
584 <              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EB_LOWPT ) {
585 <                failiso = true;
586 <                break;
587 <              }
588 <              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EE_HIGHPT ) {
589 <                failiso = true;
590 <                break;
591 <              }
592 <              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EE_LOWPT ) {
593 <                failiso = true;
594 <                break;
595 <              }
596 <            }
597 <
598 <            if( abs(lepvec[i].type) == 13 ) {
599 <
600 <              /*
601 <              float reliso = lepvec[i].isoPF03/lepvec[i].vec.Pt();
602 <              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_LOOSE_EB_HIGHPT ) {  //0.13
603 <                failiso = true;
604 <                break;
605 <              }
606 <              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_LOOSE_EB_LOWPT ) { //0.06
607 <                failiso = true;
608 <                break;
609 <              }
610 <              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_LOOSE_EE_HIGHPT ) { //0.09
611 <                failiso = true;
612 <                break;
613 <              }
614 <              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_LOOSE_EE_LOWPT ) { //0.05
615 <                failiso = true;
616 <                break;
617 <              }
618 <              */
619 <            }
620 <          }  
621 <        } else if ( ctrl.isoScheme == "pairwise" ) {
622 <          float rho = info->rho;
623 <          for( int i=0; i<lepvec.size(); i++ ) {
624 <            if( !(lepvec[i].is4l) ) continue;
625 <            float effArea_ecal_i, effArea_hcal_i;
626 <            if( lepvec[i].isEB ) {
627 <              if( lepvec[i].type == 11 ) {
628 <                effArea_ecal_i = 0.101;
629 <                effArea_hcal_i = 0.021;
630 <              } else {
631 <                effArea_ecal_i = 0.074;
632 <                effArea_hcal_i = 0.022;
633 <              }
500 >          Double_t CurrentPairPtMax = lepvec[i].vec->Pt();              
501 >          Double_t CurrentPairPtMin = lepvec[j].vec->Pt();
502 >          if (lepvec[j].vec->Pt() > CurrentPairPtMax) {
503 >            CurrentPairPtMax = lepvec[j].vec->Pt();
504 >            CurrentPairPtMin = lepvec[i].vec->Pt();
505 >          }
506 >        
507 >          if (CurrentPairPtMax > BestPairPtMax) {
508 >            if (lepvec[i].charge > 0) {
509 >              Z2LeptonPlusIndex = i;
510 >              Z2LeptonMinusIndex = j;
511              } else {
512 <              if( lepvec[i].type == 11 ) {
513 <                effArea_ecal_i = 0.046;
637 <                effArea_hcal_i = 0.040;
638 <              } else {
639 <                effArea_ecal_i = 0.045;
640 <                effArea_hcal_i = 0.030;
641 <              }
512 >              Z2LeptonPlusIndex = j;
513 >              Z2LeptonMinusIndex = i;
514              }
515 <            float isoEcal_corr_i = lepvec[i].isoEcal - (effArea_ecal_i*rho);
516 <            float isoHcal_corr_i = lepvec[i].isoHcal - (effArea_hcal_i*rho);
517 <            for( int j=i+1; j<lepvec.size(); j++ ) {
518 <              if( !(lepvec[j].is4l) ) continue;
519 <              float effArea_ecal_j, effArea_hcal_j;
648 <              if( lepvec[j].isEB ) {
649 <                if( lepvec[j].type == 11 ) {
650 <                  effArea_ecal_j = 0.101;
651 <                  effArea_hcal_j = 0.021;
652 <                } else {
653 <                  effArea_ecal_j = 0.074;
654 <                  effArea_hcal_j = 0.022;
655 <                }
515 >          } else if (CurrentPairPtMax  == BestPairPtMax) {
516 >            if (CurrentPairPtMin > BestPairPtMin) {
517 >              if (lepvec[i].charge > 0) {
518 >                Z2LeptonPlusIndex = i;
519 >                Z2LeptonMinusIndex = j;
520                } else {
521 <                if( lepvec[j].type == 11 ) {
522 <                  effArea_ecal_j = 0.046;
523 <                  effArea_hcal_j = 0.040;
660 <                } else {
661 <                  effArea_ecal_j = 0.045;
662 <                  effArea_hcal_j = 0.030;
663 <                }
664 <              }
665 <              float isoEcal_corr_j = lepvec[j].isoEcal - (effArea_ecal_j*rho);
666 <              float isoHcal_corr_j = lepvec[j].isoHcal - (effArea_hcal_j*rho);
667 <              float RIso_i = (lepvec[i].isoTrk+isoEcal_corr_i+isoHcal_corr_i)/lepvec[i].vec.Pt();
668 <              float RIso_j = (lepvec[j].isoTrk+isoEcal_corr_j+isoHcal_corr_j)/lepvec[j].vec.Pt();          
669 <              float comboIso = RIso_i + RIso_j;
670 <              if( info->evtNum == 1038911933 ) {
671 <                float tmpdR = lepvec[i].vec.DrEtaPhi(lepvec[j].vec);
672 <                cout << "i: " << i
673 <                     << "\tdR: " << tmpdR
674 <                     << "\trho: " << rho
675 <                     << "\tRIso_i: " << RIso_i  
676 <                     << "\ttkrel: " << lepvec[i].isoTrk/lepvec[i].vec.Pt()
677 <                     << "\tecalrel: " << lepvec[i].isoEcal/lepvec[i].vec.Pt()
678 <                     << "\tecalrelcor: " << isoEcal_corr_i/lepvec[i].vec.Pt()
679 <                     << "\thcalrel: " << lepvec[i].isoHcal/lepvec[i].vec.Pt()
680 <                     << "\thcalrelcor: " << isoHcal_corr_i/lepvec[i].vec.Pt()
681 <                     << "\tpt_i: " << lepvec[i].vec.Pt()
682 <                     << "\tj: " << j
683 <                     << "\tRIso_j: " << RIso_j  
684 <                     << "\ttkrel: "  << lepvec[j].isoTrk/lepvec[j].vec.Pt()
685 <                     << "\tecalrel: " << lepvec[j].isoEcal/lepvec[j].vec.Pt()
686 <                     << "\tecalrelcor: " << isoEcal_corr_j/lepvec[j].vec.Pt()
687 <                     << "\thcalrel: " << lepvec[j].isoHcal/lepvec[j].vec.Pt()
688 <                     << "\thcalrelcor: " << isoHcal_corr_j/lepvec[j].vec.Pt()
689 <                     << "\tpt_j: " << lepvec[j].vec.Pt()
690 <                     << "\tcombo: " << comboIso
691 <                     << endl;
692 <                cout.flush();
693 <              }
694 <              if( comboIso > 0.35 ) {
695 <                if( ctrl.debug ) cout << "combo failing for indices: " << i << "," << j << endl;
696 <                failiso = true;
697 <                //            break;
698 <              }
521 >                Z2LeptonPlusIndex = j;
522 >                Z2LeptonMinusIndex = i;
523 >              }                  
524              }
525            }
526 <        }
527 <
528 <
529 <        if( failiso ) {
530 <          evtfail |= ( 1<<EVTFAIL_ISOLATION );
531 <          return evtfail;
532 <          //h_evtfail->Fill( evtfail, eventweight );
533 <          //      h_evtfail->Fill( evtfail );
534 <          //      cout << "evtfail: " << hex << evtfail << dec << endl;
535 <          //      continue;
536 <        }
537 <
538 <        //***************************************************************
539 <        // IP significance
540 <        //***************************************************************
541 <        bool failip = false;
542 <        for( int i=0; i<lepvec.size(); i++ ) {
543 <          if( !(lepvec[i].is4l) ) continue;
544 <          if( lepvec[i].ip3dSig > 4 ) {
545 <            failip=true;
546 <            break;
547 <          }
548 <        }
724 <        if( failip ) {
725 <          evtfail |= (1<<EVTFAIL_IP );
726 <          return evtfail;
727 <          //h_evtfail->Fill( evtfail, eventweight );
728 <          //      h_evtfail->Fill( evtfail );
729 <          //      cout << "evtfail: " << hex << evtfail << dec << endl;
730 <          //      continue;
731 <        }
732 <
733 <        //***************************************************************
734 <        // remaining kinematic cuts
735 <        //***************************************************************
736 <        double Z2massCut=0;
737 <        if      ( ctrl.kinematics == "loose" ) Z2massCut = 12;
738 <        else if ( ctrl.kinematics == "tight" ) Z2massCut = 20;
739 <        else { cout <<  "error! kinematic tightness not defined!" << endl; assert(0); }
740 <
741 <        if ( Z1Candidate.M() > 120        ||
742 <             Z2Candidate.M() < Z2massCut  ||
743 <             Z2Candidate.M() > 120        ||
744 <             !(lepvec[Z1LeptonPlusIndex].vec.Pt() > 20.0 || lepvec[Z1LeptonMinusIndex].vec.Pt() > 20.0) ||
745 <             !(lepvec[Z1LeptonPlusIndex].vec.Pt() > 10.0 && lepvec[Z1LeptonMinusIndex].vec.Pt() > 10.0)
746 <             ) {
747 <          evtfail |= (1<<EVTFAIL_KINEMATICS );
748 <          return evtfail;
749 <          //h_evtfail->Fill( evtfail, eventweight );
750 <          //      h_evtfail->Fill( evtfail );
751 <          //      cout << "evtfail: " << hex << evtfail << dec << endl;
752 <          //      continue;
753 <        }
754 <        
755 <        unsigned channel;
756 <        if( lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 11 ) channel=0;
757 <        if( lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 13 ) channel=1;
758 <        if( (lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 13) ||
759 <            (lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2;
760 <        
761 <
762 <        double w_offline=-1, werr_offline=0;
763 <        double w_online=-1, werr_online=0;
764 <
765 <        if( ctrl.mc ) {
766 <
767 <          vector< pair <double,double> > wlegs; // pair here is eff & err
768 <          vector< pair <float,float> > mvec;  // pair here is eta & pt
769 <          // now deal with medium vs loose
770 <          //      vector< pair <float,float> > evec;  // pair here is eta & pt
771 <          vector< pair< bool, pair <float,float> > > evec;  // pair here is eta & pt
772 <
773 <          for( int k=0; k<lepvec.size(); k++ ) {
774 <            if( !(lepvec[k].is4l) ) continue;
775 <            if( abs(lepvec[k].type) == 13 ) {
776 <              mvec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) );
777 <              wlegs.push_back( muonPerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()),
778 <                                                                  lepvec[k].vec.Pt() ) );
779 <            } else {
780 <
781 <              // now deal with medium vs loose
782 <              //              evec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) );
526 >        }            
527 >      }
528 >    }
529 >  
530 >    // stop if no Z2 candidate is found
531 >    if (Z2LeptonPlusIndex == -1) {
532 >      evtfail |= ( 1<<EVTFAIL_4L );
533 >      //      ret.status = evtfail;
534 >      ret.status.setStatus(0);
535 >      return ret;
536 >    }
537 >    if( ctrl.debug ) cout << "\tgot a Z2 ..." << endl;
538 >    if( ctrl.debug ) cout << "\tZ2 plusindex: " << Z2LeptonPlusIndex
539 >                          << "\tminusindex: " << Z2LeptonMinusIndex << endl;
540 >    TLorentzVector  Z2LeptonPlus  = *(lepvec[Z2LeptonPlusIndex].vec);
541 >    TLorentzVector  Z2LeptonMinus = *(lepvec[Z2LeptonMinusIndex].vec);
542 >    TLorentzVector  Z2Candidate   = Z2LeptonPlus+Z2LeptonMinus;
543 >    TLorentzVector  ZZSystem      = Z1Candidate + Z2Candidate;
544 >    lepvec[Z1LeptonPlusIndex].is4l = true;
545 >    lepvec[Z1LeptonMinusIndex].is4l = true;
546 >    lepvec[Z2LeptonPlusIndex].is4l = true;
547 >    lepvec[Z2LeptonMinusIndex].is4l = true;
548 >  
549  
784              std::pair<float,float> tmppair(fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt());
785              evec.push_back( std::pair<bool, std::pair<float,float> > (lepvec[k].isTight, tmppair) );
550  
551 <              wlegs.push_back( elePerLegOfflineEfficiencyWeight(  fabs(lepvec[k].vec.Eta()),
552 <                                                                 lepvec[k].vec.Pt() ) );
553 <            }
554 <          }
555 <
556 <          pair<double,double> offpair = getOfflineEfficiencyWeight( wlegs );
557 <          w_offline    = offpair.first;
558 <          werr_offline = offpair.second;
559 <
560 <          pair<double,double> onpair  = getOnlineEfficiencyWeight( mvec, evec );
561 <          w_online    = onpair.first;
562 <          werr_online = onpair.second;
563 <
564 <        } // if mc
565 <
566 <
567 <        if( l != NULL ) {
568 <          l->vec4l  = ZZSystem;
569 <          l->vecz1  = Z1Candidate;
570 <          l->vecz2  = Z2Candidate;
571 <          l->vecl1p = lepvec[Z1LeptonPlusIndex].vec;
572 <          l->vecl1m = lepvec[Z1LeptonMinusIndex].vec;
573 <          l->vecl2p = lepvec[Z2LeptonPlusIndex].vec;
574 <          l->vecl2m = lepvec[Z2LeptonMinusIndex].vec;
575 <        }
576 <        if( passtuple != NULL ) {
577 <          unsigned run   = info->runNum;
578 <          unsigned evt   = info->evtNum;
579 <          unsigned lumi  = info->lumiSec;
580 <          unsigned chan  = channel;
581 <          double   w     = eventweight;
582 <          float mZ1      = Z1Candidate.M() ;
583 <          float mZ2      = Z2Candidate.M() ;
584 <          float m4l      = ZZSystem.M() ;
585 <          float pt4l     = ZZSystem.Pt() ;
586 <          unsigned tZ1   = abs(lepvec[Z1LeptonMinusIndex].type);
587 <          unsigned tZ2   = abs(lepvec[Z2LeptonMinusIndex].type);
588 <          float l3tche   = lepvec[Z2LeptonMinusIndex].tche;
589 <          float l4tche   = lepvec[Z2LeptonPlusIndex].tche;
590 <          float l3tchp   = lepvec[Z2LeptonMinusIndex].tchp;
591 <          float l4tchp   = lepvec[Z2LeptonPlusIndex].tchp;
592 <          float l3csv    = lepvec[Z2LeptonMinusIndex].csv;
829 <          float l4csv    = lepvec[Z2LeptonPlusIndex].csv;
830 <          float l3csvMva = lepvec[Z2LeptonMinusIndex].csvMva;
831 <          float l4csvMva = lepvec[Z2LeptonPlusIndex].csvMva;
832 <
833 <
834 <          passtuple->SetBranchAddress("channel",  &channel);
835 <          passtuple->SetBranchAddress("run",  &run);
836 <          passtuple->SetBranchAddress("evt",  &evt);
837 <          passtuple->SetBranchAddress("lumi", &lumi);
838 <          passtuple->SetBranchAddress("mZ1",  &mZ1);
839 <          passtuple->SetBranchAddress("mZ2",  &mZ2);
840 <          passtuple->SetBranchAddress("tZ1",  &tZ1);
841 <          passtuple->SetBranchAddress("tZ2",  &tZ2);
842 <          passtuple->SetBranchAddress("m4l",  &m4l);
843 <          passtuple->SetBranchAddress("pt4l", &pt4l);
844 <          passtuple->SetBranchAddress("w",    &w);
845 <          if( ctrl.mc ) {
846 <            passtuple->SetBranchAddress("woff", &w_offline );
847 <            passtuple->SetBranchAddress("werroff", &werr_offline );
848 <            passtuple->SetBranchAddress("won", &w_online );
849 <            passtuple->SetBranchAddress("werron", &werr_online );
850 <            passtuple->SetBranchAddress("npu", &npu );
851 <            passtuple->SetBranchAddress("npuw", &npuw );
852 <            passtuple->SetBranchAddress("gchannel",  &gchannel);
853 <          }
854 <          if( ctrl.btag ) {
855 <          passtuple->SetBranchAddress("l3tche",    &l3tche);
856 <          passtuple->SetBranchAddress("l4tche",    &l4tche);
857 <          passtuple->SetBranchAddress("l3tchp",    &l3tchp);
858 <          passtuple->SetBranchAddress("l4tchp",    &l4tchp);
859 <          passtuple->SetBranchAddress("l3csv",     &l3csv);
860 <          passtuple->SetBranchAddress("l4csv",     &l4csv);
861 <          passtuple->SetBranchAddress("l3csvMva",  &l3csvMva);
862 <          passtuple->SetBranchAddress("l4csvMva",  &l4csvMva);
863 <          }
551 >  
552 >    //***************************************************************
553 >    // remaining kinematic cuts
554 >    //***************************************************************
555 >    double Z2massCut=0;
556 >    if      ( ctrl.kinematics == "loose" ) Z2massCut = 12;
557 >    else if ( ctrl.kinematics == "tight" ) Z2massCut = 20;
558 >    else { cout <<  "error! kinematic tightness not defined!" << endl; assert(0); }
559 >  
560 >    if ( Z1Candidate.M() > 120        ||
561 >         Z2Candidate.M() < Z2massCut  ||
562 >         Z2Candidate.M() > 120        ||
563 >         !(lepvec[Z1LeptonPlusIndex].vec->Pt() > 20.0 || lepvec[Z1LeptonMinusIndex].vec->Pt() > 20.0) ||
564 >         !(lepvec[Z1LeptonPlusIndex].vec->Pt() > 10.0 && lepvec[Z1LeptonMinusIndex].vec->Pt() > 10.0)
565 >         ) {
566 >      evtfail |= (1<<EVTFAIL_KINEMATICS );
567 >      //      ret.status = evtfail;
568 >      ret.status.setStatus(0);
569 >      return ret;
570 >    }
571 >  
572 >    unsigned channel;
573 >    if( lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 11 ) channel=0;
574 >    if( lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 13 ) channel=1;
575 >    if( (lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 13) ||
576 >        (lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2;
577 >  
578 >  
579 >  
580 >  
581 >    if( ctrl.debug ) cout  << "run: " << info->RunNum()  
582 >                           << "\tevt: " << info->EvtNum()
583 >                           << "\tZ1channel: " << lepvec[Z1LeptonMinusIndex].type
584 >                           << "\tZ2channel: " << lepvec[Z2LeptonMinusIndex].type
585 >                           << "\tmZ1: " << Z1Candidate.M()
586 >                           << "\tmZ2: " << Z2Candidate.M()
587 >                           << "\tm4l: " << ZZSystem.M()
588 >                           << "\tevtfail: " << hex << evtfail << dec
589 >      //                           << "\ttrigbits: " << hex << info->triggerBits << dec
590 >      //              << "\ttree: " << inputFiles[q][f]
591 >                           << endl;
592 >  
593  
865          passtuple->Fill( );
866        }
594  
595 <        if( ctrl.debug ) cout  << "run: " << info->runNum  
596 <              << "\tevt: " << info->evtNum
597 <              << "\tZ1channel: " << lepvec[Z1LeptonMinusIndex].type
598 <              << "\tZ2channel: " << lepvec[Z2LeptonMinusIndex].type
599 <              << "\tmZ1: " << Z1Candidate.M()
600 <              << "\tmZ2: " << Z2Candidate.M()
601 <              << "\tm4l: " << ZZSystem.M()
602 <              << "\tevtfail: " << hex << evtfail << dec
603 <              << "\ttrigbits: " << hex << info->triggerBits << dec
604 <          //          << "\ttree: " << inputFiles[q][f]
605 <              << endl;
595 >    //***************************************************************
596 >    // finish
597 >    //***************************************************************
598 >
599 >    if( !evtfail ) {
600 >      ret.status.setStatus(SelectionStatus::EVTPASS);
601 >      ret.Z1leptons.push_back(lepvec[Z1LeptonMinusIndex]);
602 >      ret.Z1leptons.push_back(lepvec[Z1LeptonPlusIndex]);
603 >      ret.Z2leptons.push_back(lepvec[Z2LeptonMinusIndex]);
604 >      ret.Z2leptons.push_back(lepvec[Z2LeptonPlusIndex]);
605 >    }
606  
607 <        return evtfail;
881 <          
607 >    return ret;
608   }
609  
610  
885
886
887

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines