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

Comparing UserCode/LJMet/Utils/src/CutFlow.cc (file contents):
Revision 1.3 by kukartse, Mon Oct 12 22:45:48 2009 UTC vs.
Revision 1.4 by kukartse, Tue Oct 27 22:39:44 2009 UTC

# Line 27 | Line 27
27   #include "DataFormats/PatCandidates/interface/TriggerPath.h"
28   #include "DataFormats/BeamSpot/interface/BeamSpot.h"
29   #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
30 + #include "DataFormats/Math/interface/deltaR.h"
31  
32   using namespace edm;
33  
# Line 68 | Line 69 | CutFlow::analyze(const edm::Event& iEven
69    //
70    /*
71    while(1){
72 <    if ( is_trigger("HLT_Mu9", iEvent) ){
72 >  //
73 >  //_____ stage 1
74 >  //
75 >  if ( is_trigger("HLT_Mu9", iEvent) ){
76      }
77      else break;
78      if ( has_global_muon("selectedLayer1Muons", iEvent) ){
79        c_1->count();
80      }
81      else break;
82 +    
83      if ( is_muon("selectedLayer1Muons",
84                   20.0,
85                   2.1,
# Line 119 | Line 124 | CutFlow::analyze(const edm::Event& iEven
124    //_____ e+jets cut flow
125    //
126    while(1){
127 +    //
128 +    //_____ stage 1
129 +    //
130      if ( is_trigger("HLT_Ele15_LW_L1R", iEvent) ){
131      }
132      else break;
# Line 126 | Line 134 | CutFlow::analyze(const edm::Event& iEven
134        c_1->count();
135      }
136      else break;
137 +    //
138 +    //_____ stage 2
139 +    //
140 +    cout << "CutFlow: passed stage 1: ";
141      if ( is_electron("selectedLayer1Electrons",
142 <                     20.0,
143 <                     2.1,
142 >                     30.0,
143 >                     2.4,
144                       0.02,
145                       0.1,
146                       iEvent) ){
147        c_2->count();
148 +      cout << endl;
149      }
150 <    else break;
151 <    if ( is_jets("selectedLayer1Jets",
152 <                 30.0,
153 <                 2.4,
154 <                 iEvent) ){
150 >    else{
151 >      cout << endl;
152 >      break;
153 >    }      
154 >    //
155 >    //_____ stage 3
156 >    //
157 >    cout << "CutFlow: passed stage 2: ";
158 >    if ( !is_muon("selectedLayer1Muons",
159 >                  30.0,
160 >                  2.1,
161 >                  11,
162 >                  0.02,
163 >                  10,
164 >                  4000000.0,
165 >                  6000000.0,
166 >                  0.05,
167 >                  iEvent) ){
168        c_3->count();
169 +      cout << endl;
170      }
171 <    else break;
172 <    if ( no_loose_muon("selectedLayer1Muons",
173 <                       2.5,
174 <                       10.0,
175 <                       0.2,
176 <                       iEvent) ){
171 >    else{
172 >      cout << endl;
173 >      break;
174 >    }
175 >    //
176 >    //_____ stage 4
177 >    //
178 >    cout << "CutFlow: passed stage 3: ";
179 >    int n_jets = count_jets("selectedLayer1Jets",
180 >                            30.0,
181 >                            2.4,
182 >                            "selectedLayer1Electrons",
183 >                            30.0,
184 >                            2.4,
185 >                            0.02,
186 >                            0.3,
187 >                            iEvent);
188 >    if ( n_jets >= 0){
189        c_4->count();
190 +      cout << endl;
191      }
192 <    else break;
193 <    if ( no_loose_electron("selectedLayer1Electrons",
194 <                           2.5,
195 <                           15.0,
196 <                           0.2,
197 <                           iEvent) ){
192 >    else{
193 >      cout << endl;
194 >      break;
195 >    }
196 >    //
197 >    //_____ stage 5
198 >    //
199 >    cout << "CutFlow: passed stage 4: ";
200 >    if ( n_jets >= 4 ){
201        c_5->count();
202 +      cout << endl;
203 +    }
204 +    else{
205 +      cout << endl;
206 +      break;
207      }
160    else break;
208      cout << "Cut Flow: passed stage 5 " << endl;
209      break;
210    }
# Line 174 | Line 221 | void
221   CutFlow::endJob() {
222    cout << "========= Cut Flow Report ==========================================" << endl;
223    cout << "Total events: " << c_total->getCount() << endl;
224 <  cout << "Pass stage 1 (trigger+global): " << c_1->getCount() << endl;
225 <  cout << "Pass stage 2 (muon kinematics): " << c_2->getCount() << endl;
226 <  cout << "Pass stage 3 (jets): " << c_3->getCount() << endl;
227 <  cout << "Pass stage 4 (no loose muon): " << c_4->getCount() << endl;
228 <  cout << "Pass stage 5 (no loose electron): " << c_5->getCount() << endl;
224 >  cout << "Pass stage 1: " << c_1->getCount() << endl;
225 >  cout << "Pass stage 2: " << c_2->getCount() << endl;
226 >  cout << "Pass stage 3: " << c_3->getCount() << endl;
227 >  cout << "Pass stage 4: " << c_4->getCount() << endl;
228 >  cout << "Pass stage 5: " << c_5->getCount() << endl;
229    cout << "================================================================" << endl;
230   }
231  
# Line 200 | Line 247 | bool CutFlow::is_trigger(std::string mTr
247   bool CutFlow::has_global_muon(std::string mLabel,
248                                const edm::Event& iEvent){
249    bool result = false;
250 <  cout << "Cut Flow: passed trigger ";
250 >  //cout << "Cut Flow: passed trigger ";
251    Handle< vector< pat::Muon > >     muons;
252    iEvent . getByLabel( mLabel, muons );
253    //
# Line 213 | Line 260 | bool CutFlow::has_global_muon(std::strin
260      }
261    }
262    result = passed_muons.getCount()>0;
263 <  cout << endl;
263 >  //cout << endl;
264    return result;
265   }
266    
# Line 229 | Line 276 | bool CutFlow::is_muon(std::string mLabel
276                        double mRelIso,
277                        const edm::Event& iEvent){
278    bool result = false;
279 <  cout << "Cut Flow: passed stage 1: ";
279 >  //cout << "Cut Flow: passed stage 1 (mu+jets) or stage 2 (e+jets): ";
280    Handle< vector< pat::Muon > >     muons;
281    iEvent . getByLabel( "selectedLayer1Muons", muons );
282    Handle< reco::BeamSpot >          beamSpotHandle;
# Line 304 | Line 351 | bool CutFlow::is_muon(std::string mLabel
351          cout << _hadveto << ", ";
352          cout << _trackiso << ", ";
353          cout << _caloiso << ", ";
354 <        cout << _reliso << ", ";
355 <        cout << endl;
354 >        cout << _reliso;
355 >        //cout << endl;
356        }
357      }
358    }
359 +  cout << "Number of good muons: " << passed_muons.getCount();
360    result = passed_muons.getCount()==1;
361    return result;
362   }
# Line 320 | Line 368 | bool CutFlow::is_jets(std::string mLabel
368                        const edm::Event& iEvent){
369    bool result = false;
370  
371 <  cout << "Cut Flow: passed stage 2: ";
371 >  //cout << "Cut Flow: passed stage 2: ";
372  
373    Handle< vector< pat::Jet > >      jets;
374    iEvent . getByLabel( mLabel, jets );
# Line 339 | Line 387 | bool CutFlow::is_jets(std::string mLabel
387        }
388      if (c_jets.getCount()<=4){
389        cout << _pt << ", ";
390 <      cout << _eta << ", ";
390 >      cout << _eta;
391      }
392    }
393 <  cout << endl;
393 >  //cout << endl;
394    result = passed_jets.getCount() >=4;
395    return result;
396   }
# Line 354 | Line 402 | bool CutFlow::no_loose_muon(std::string
402                              double mRelIso,
403                              const edm::Event& iEvent){
404    bool result = false;
405 <  cout << "Cut Flow: passed stage 3: ";
405 >  //cout << "Cut Flow: passed stage 3: ";
406    Handle< vector< pat::Muon > >     muons;
407    iEvent . getByLabel( "selectedLayer1Muons", muons );
408    //
# Line 386 | Line 434 | bool CutFlow::no_loose_muon(std::string
434      }
435    }
436    result = passed_muons.getCount()==0;
437 <  cout << endl;
437 >  //cout << endl;
438    return result;
439   }
440  
# Line 397 | Line 445 | bool CutFlow::no_loose_electron(std::str
445                                  double mRelIso,
446                                  const edm::Event& iEvent){
447    bool result = false;
448 <  cout << "Cut Flow: passed stage 4: ";
448 >  //cout << "Cut Flow: passed stage 4: ";
449    Handle< vector< pat::Electron > >     electrons;
450    iEvent . getByLabel( "selectedLayer1Electrons", electrons );
451    //
# Line 425 | Line 473 | bool CutFlow::no_loose_electron(std::str
473      }
474    }
475    result = passed_electrons.getCount()==0;
476 <  cout << endl;
476 >  //cout << endl;
477    return result;
478   }
479  
# Line 447 | Line 495 | bool CutFlow::is_electron(std::string mL
495                        double mRelIso,
496                        const edm::Event& iEvent){
497    bool result = false;
498 <  cout << "Cut Flow: passed stage 1: ";
498 >  //cout << "Cut Flow: passed stage 1: ";
499    Handle< vector< pat::Electron > >     electrons;
500    iEvent . getByLabel( "selectedLayer1Electrons", electrons );
501    Handle< reco::BeamSpot >          beamSpotHandle;
# Line 469 | Line 517 | bool CutFlow::is_electron(std::string mL
517    //
518    double _pt = 0.0;
519    double _abseta = 0.0;
472  int _nhits = 0;
520    double _d0 = 0.0;
521 <  double _chi2ndof = 0.0;
475 <  double _emveto = 10000.0;
476 <  double _hadveto = 10000.0;
521 >  double _d0_pat = 0.0;
522    double _trackiso = 10000.0;
523 +  double _ecaloiso = 10000.0;
524 +  double _ecaloiso2 = 10000.0;
525 +  double _pat_ecaloiso = 10000.0;
526 +  double _hcaloiso1 = 10000.0;
527 +  double _hcaloiso2 = 10000.0;
528    double _caloiso = 10000.0;
529    double _reliso = 10000.0;
530    MeanCounter passed_electrons("");
531    for ( vector<pat::Electron>::const_iterator e = electrons -> begin(); e != electrons -> end(); e++){
532 <    //_____ check that the electron is global
533 <    if( !(e->isGlobalElectron()) ) continue;
532 >    //_____ check that the electron is robust-tight
533 >    if( !(e->electronID("eidRobustTight")) ) continue;
534      _pt = e->pt();
535      _abseta = fabs(e->eta());
536 <    //_d0 = e->dB(); // global track
537 <    _d0 = -(e->innerTrack()->dxy(_bs));
538 <    _chi2ndof = e->normChi2();
539 <    _nhits = e->numberOfValidHits();
540 <    reco::TrackRef _track = e->track();
541 <    //_____ check that there is a track
542 <    if(_track.isNull()) continue;
543 <    //_nhits = _track->numberOfValidHits();
544 <    //_d0 = -(_track->dxy(_bs));
545 <    //_chi2ndof = _track->normalizedChi2();
496 <    //_chi2ndof = (_track->chi2())/(_track->ndof());
497 <    //_____ check that isolation is valid
498 <    if ( !(e->isIsolationValid()) ) continue;
499 <    _emveto = e->isolationR03().emVetoEt;
500 <    _hadveto = e->isolationR03().hadVetoEt;
501 <    _trackiso = e->isolationR03().sumPt;
502 <    _caloiso = e->isolationR03().emEt + e->isolationR03().hadEt;
536 >    _d0_pat = e->dB();
537 >    _d0 = -(e->gsfTrack()->dxy(_bs));
538 >    _trackiso = e->dr03IsolationVariables().tkSumPt;
539 >    _ecaloiso = e->dr04IsolationVariables().ecalRecHitSumEt;
540 >    _ecaloiso2 = e->dr03IsolationVariables().ecalRecHitSumEt;
541 >    _pat_ecaloiso = e->isolation(pat::ECalIso);
542 >    _hcaloiso1 = e->dr04IsolationVariables().hcalDepth1TowerSumEt;
543 >    _hcaloiso2 = e->dr04IsolationVariables().hcalDepth2TowerSumEt;
544 >    _caloiso = _ecaloiso + _hcaloiso1 + _hcaloiso2;
545 >    //_caloiso = _pat_ecaloiso +_hcaloiso1 + _hcaloiso2;
546      _reliso = (_trackiso + _caloiso)/_pt;
547      if (_pt > mPt &&
548          _abseta < mEta &&
506        _nhits >= mNHits &&
549          fabs(_d0) < mD0 &&
508        _chi2ndof < mChi2Ndof &&
509        fabs(_emveto) < mEmVeto &&
510        fabs(_hadveto) < mHadVeto &&
550          fabs(_reliso) < mRelIso
551          ){
552        passed_electrons.count();
553        electron_index = (int)(e - electrons->begin());
554        if (passed_electrons.getCount()==1){
555 <        cout << _pt << ", ";
556 <        cout << _abseta << ", ";
557 <        cout << _nhits << ", ";
558 <        cout << _d0 << ", ";
559 <        cout << _chi2ndof << ", ";
560 <        cout << _emveto << ", ";
561 <        cout << _hadveto << ", ";
562 <        cout << _trackiso << ", ";
563 <        cout << _caloiso << ", ";
564 <        cout << _reliso << ", ";
565 <        cout << endl;
555 >        cout << "pt=" << _pt << ", abseta=";
556 >        cout << _abseta << ", d0=";
557 >        cout << _d0 << ", trackiso=";
558 >        cout << _trackiso << ", ecaloiso04=";
559 >        cout << _ecaloiso << ", ecaloiso03=";
560 >        cout << _ecaloiso2 << ", pat_ecaloiso=";
561 >        cout << _pat_ecaloiso << ", hcaloiso1=";
562 >        cout << _hcaloiso1 << ", hcaloiso2=";
563 >        cout << _hcaloiso2 << ", caloiso04=";
564 >        cout << _caloiso << ", reliso=";
565 >        cout << _reliso;
566 >        //cout << endl;
567        }
568      }
569    }
570 +  //cout << "Number of good electrons: " << passed_electrons.getCount();
571    result = passed_electrons.getCount()==1;
572    return result;
573   }
574    
575  
576 + int CutFlow::count_jets(std::string jLabel,
577 +                        double jPt,
578 +                        double jEta,
579 +                        std::string lLabel,
580 +                        double lPt,
581 +                        double lEta,
582 +                        double lD0,
583 +                        double lDR,
584 +                        const edm::Event & iEvent){
585 +  MeanCounter _njets("");
586 +  Handle< vector< pat::Jet > >     jets;
587 +  iEvent . getByLabel( jLabel, jets );
588 +  Handle< vector< pat::Electron > >     electrons;
589 +  iEvent . getByLabel( lLabel, electrons );
590 +  Handle< reco::BeamSpot >          beamSpotHandle;
591 +  iEvent . getByLabel( "offlineBeamSpot", beamSpotHandle);
592 +  //
593 +  //_____ Beam spot _____________________________________________________
594 +  //
595 +  reco::BeamSpot beamSpot;
596 +  if ( beamSpotHandle.isValid() ){
597 +    beamSpot = *beamSpotHandle;
598 +  }
599 +  else{
600 +    edm::LogInfo("TtLJetsAnalyzer")
601 +      << "No beam spot available from EventSetup \n";
602 +  }
603 +  const reco::BeamSpot::Point _bs(beamSpot.x0(), beamSpot.y0(),beamSpot.z0());
604 +  //
605 +  //_____ loop over jets _______________________________________________
606 +  //
607 +  double j_pt = 0.0;
608 +  double j_eta = 0.0;
609 +  for ( vector<pat::Jet>::const_iterator jet = jets -> begin(); jet != jets -> end(); ++jet){
610 +    j_pt = jet->pt();
611 +    j_eta = jet->eta();
612 +    //
613 +    //_____ loop over electrons _______________________________________________
614 +    //
615 +    double e_pt = 0.0;
616 +    double e_abseta = 0.0;
617 +    double e_d0 = 0.0;
618 +    double e_dr = 0.0;
619 +    bool jet_removed = false;
620 +    for ( vector<pat::Electron>::const_iterator e = electrons -> begin(); e != electrons -> end(); e++){
621 +      //_____ check that the electron is robust-tight
622 +      if( !(e->electronID("eidRobustTight")) ) continue;
623 +      e_pt = e->pt();
624 +      e_abseta = fabs(e->eta());
625 +      e_d0 = -(e->gsfTrack()->dxy(_bs));
626 +      e_dr = reco::deltaR(*jet, *e);
627 +      if ( e_pt > lPt && e_abseta < lEta && fabs(e_d0)<lD0 && e_dr<lDR){
628 +        jet_removed = true;
629 +      }
630 +    }
631 +    if (j_pt>jPt && fabs(j_eta)<jEta && !jet_removed) _njets.count();
632 +  }
633 +  cout << "Number of jets after cleaning: " << _njets.getCount();
634 +  return _njets.getCount();
635 + }
636  
637   //define this as a plug-in
638   DEFINE_FWK_MODULE(CutFlow);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines