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

Comparing UserCode/MitHzz4l/Selection/src/ReferenceSelection.cc (file contents):
Revision 1.23 by dkralph, Mon Dec 17 17:12:07 2012 UTC vs.
Revision 1.24 by anlevin, Wed Jan 16 16:10:05 2013 UTC

# Line 10 | Line 10 | extern ElectronMomentumCorrection electr
10   extern MuCorr *muCorr;
11   extern TrigInfo ti;
12  
13 +
14 + //we need to store the fsr photons because they are used to veto jets in the vbf selection
15 + //the leptons in the lepton pair include the fsr photons
16 + struct ZCandidate
17 + {
18 +  pair<SimpleLepton,SimpleLepton> lepton_pair;
19 +  unsigned int which_lepton_has_fsr; //0 means neither lepton has an fsr photon, 1 means the first lepton in the pair has the fsr photon, 2 means second lepton in the pair has the fsr photon
20 +  PFCandidate fsr_photon;
21 + };
22 +
23   //----------------------------------------------------------------------------------------
24   void updateSimpleLepton(SimpleLepton &tmplep);
25   //--------------------------------------------------------------------------------------------------
# Line 74 | Line 84 | EventData apply_HZZ4L_reference_selectio
84      for(int i=0; i<muonArr->GetEntries(); i++) {
85        const Muon *const_mu = (Muon*)((*muonArr)[i]);
86        Muon *mu = const_cast<Muon*>(const_mu);
87 <      float ptBefore = mu->Pt();
87 >      double ptBefore = mu->Pt();
88        correct_muon_momentum(ctrl,muCorr,mu,info->RunNum());
89        if(ctrl.debug) cout << "    " << setw(12) << ptBefore << " --> " << setw(12) << mu->Pt() << " (" << fabs(ptBefore-mu->Pt())/ptBefore << ")" << endl;
90      }
# Line 340 | Line 350 | EventData apply_HZZ4L_reference_selectio
350      // Step 4: Z candidate preselection
351      //********************************************************
352      vector<pair<int,int> > ZCandidates;                          // indices in lepvec of the two leptons
353 <    vector<pair<SimpleLepton,SimpleLepton> > ZCandidatesLeptons; // fsr-corrected leptons that form the Z
353 >    vector<ZCandidate > ZCandidatesLeptons; // fsr-corrected leptons that form the Z
354      vector<pair<SelectionStatus,SelectionStatus> > ZCandidatesSelectionStatus;
355      for(int i = 0; i < lepvec.size(); ++i) {
356        for(int j = i+1; j < lepvec.size(); ++j) {
# Line 349 | Line 359 | EventData apply_HZZ4L_reference_selectio
359  
360          TLorentzVector Zvec = (lepvec[i].vec+lepvec[j].vec);
361  
362 +          // copies of lepvec that have 1) the photons added to the momenta and 2) the fsrRecoveryAttempted flag set
363          vector<SimpleLepton> lepvec_i = lepvec;
364          vector<SimpleLepton> lepvec_j = lepvec;
365  
366 +        ZCandidate cand;
367 +        cand.which_lepton_has_fsr = 0; //default value for when neither photon has an fsr photon
368 +
369          if( ctrl.doFSR ) {
370            if(ctrl.debug) cout << endl << "----------------> FSR ("<<i<<","<<j<<") <----------------------" << endl;
371            photonsToVeto.clear();
358          // copies of lepvec that have 1) the photons added to the momenta and 2) the fsrRecoveryAttempted flag set
372            float old_pt_i = lepvec[i].vec.Pt();
373            float old_pt_j = lepvec[j].vec.Pt();
374            float old_M  =  Zvec.M();
# Line 396 | Line 409 | EventData apply_HZZ4L_reference_selectio
409  
410            assert(!(useI && useJ));
411            if(useI) {
412 <            addPhotonToEventData(ret,photon_i.first);
412 >            cand.fsr_photon =  *((const PFCandidate*) pfCandidates->At(photon_i.second));
413 >            cand.which_lepton_has_fsr = 1;
414              lepvec_i[i].vec += photon_i.first;
415              lepvec_i[i].fsrRecoveryAttempted = true;
416              photonsToVeto.push_back((const PFCandidate*)(pfCandidates->At(photon_i.second)));
417            } else if(useJ) {
418 <            addPhotonToEventData(ret,photon_j.first);
418 >            cand.fsr_photon = *((const PFCandidate*) pfCandidates->At(photon_j.second));
419 >            cand.which_lepton_has_fsr = 2;
420              lepvec_j[j].vec += photon_j.first;
421              lepvec_j[j].fsrRecoveryAttempted = true;
422              photonsToVeto.push_back((const PFCandidate*)(pfCandidates->At(photon_j.second)));
# Line 449 | Line 464 | EventData apply_HZZ4L_reference_selectio
464          }
465  
466          ZCandidates.push_back(pair<int,int> (i,j) );
467 <        ZCandidatesLeptons.push_back(pair<SimpleLepton,SimpleLepton> (lepvec_i[i],lepvec_j[j]) );
467 >        cand.lepton_pair = pair<SimpleLepton,SimpleLepton> (lepvec_i[i],lepvec_j[j]);
468 >        
469 >        ZCandidatesLeptons.push_back(cand );
470          if( ctrl.debug ) cout << "Z candidate ("<< i << "," << j << ")" << "\tmass: " << (lepvec_i[i].vec+lepvec_j[j].vec).M() << endl;
471        }
472      }
473  
474 <    if( ZCandidates.size() > 0 ) {
474 >    if( ZCandidates.size() > 0 ) {
475        ret.status.selectionBits.flip(PASS_ZCANDIDATE);
476        if( ctrl.debug ) cout << "event has >0  Z candidates (" << ZCandidates.size() << " of em)" << endl;
477      } else {
# Line 469 | Line 486 | EventData apply_HZZ4L_reference_selectio
486      float best_Z1_mass = 9999.;
487      TLorentzVector Z1vec;
488      for( int i=0; i<ZCandidates.size(); i++ ) {
489 <      TLorentzVector tmpZ1vec = (ZCandidatesLeptons[i].first.vec) + (ZCandidatesLeptons[i].second.vec);
489 >      TLorentzVector tmpZ1vec = (ZCandidatesLeptons[i].lepton_pair.first.vec) + (ZCandidatesLeptons[i].lepton_pair.second.vec);
490        if( fabs(tmpZ1vec.M()-Z_MASS) < fabs(best_Z1_mass-Z_MASS) ) {
491          best_Z1_index=i;
492          best_Z1_mass=tmpZ1vec.M();
493          Z1vec = tmpZ1vec;
494        }
495      }
496 <    ret.Z1leptons.push_back(ZCandidatesLeptons[best_Z1_index].first);
497 <    ret.Z1leptons.push_back(ZCandidatesLeptons[best_Z1_index].second);
498 <
496 >    ret.Z1leptons.push_back(ZCandidatesLeptons[best_Z1_index].lepton_pair.first);
497 >    ret.Z1leptons.push_back(ZCandidatesLeptons[best_Z1_index].lepton_pair.second);
498 >    if(ZCandidatesLeptons[best_Z1_index].which_lepton_has_fsr != 0){
499 >      SimpleLepton photon;
500 >      photon.vec.SetPtEtaPhiM( ZCandidatesLeptons[best_Z1_index].fsr_photon.Pt(), ZCandidatesLeptons[best_Z1_index].fsr_photon.Eta(), ZCandidatesLeptons[best_Z1_index].fsr_photon.Phi(), 0);
501 >      ret.fsrPhotons.push_back(photon);
502 >    }
503 >    
504      if(ctrl.debug)
505        cout << "best mZ1:  " << best_Z1_mass << " from ("  << ZCandidates[best_Z1_index].first << "," << ZCandidates[best_Z1_index].second << ")" << endl;
506  
# Line 526 | Line 548 | EventData apply_HZZ4L_reference_selectio
548          cout << "-------------------------------------------------------" << endl;
549          // for( int l=0; l<lepvec.size(); l++ ) lepvec[l].print();
550          for(unsigned ican=0; ican<ZCandidatesLeptons.size(); ican++) {
551 <          ZCandidatesLeptons[ican].first.print();
552 <          ZCandidatesLeptons[ican].second.print();
551 >          ZCandidatesLeptons[ican].lepton_pair.first.print();
552 >          ZCandidatesLeptons[ican].lepton_pair.second.print();
553          }
554          cout << "-------------------------------------------------------" << endl;
555          if(ctrl.debug)
# Line 547 | Line 569 | EventData apply_HZZ4L_reference_selectio
569      // Select z2
570      //
571      int best_Z2_index;
572 <    float best_Z2_pt = -1.;
572 >    float best_Z2_pt_sum = -1.;
573      for( int i=0; i<ZZCandidates.size(); i++ ) {
574        int z2index = ZZCandidates[i].second;
575 <      TLorentzVector Z2 = (ZCandidatesLeptons[z2index].first.vec) +
576 <        (ZCandidatesLeptons[z2index].second.vec);
577 <      if( Z2.Pt() > best_Z2_pt ) {
575 >      double pt_sum = ZCandidatesLeptons[z2index].lepton_pair.first.vec.Pt() +
576 >        ZCandidatesLeptons[z2index].lepton_pair.second.vec.Pt();
577 >      if( pt_sum > best_Z2_pt_sum ) {
578          best_Z2_index=z2index;
579 <        best_Z2_pt=Z2.Pt();
579 >        best_Z2_pt_sum=pt_sum;
580        }
581      }
582 <    ret.Z2leptons.push_back(ZCandidatesLeptons[best_Z2_index].first); // push back the *fsr-corrected* leptons
583 <    ret.Z2leptons.push_back(ZCandidatesLeptons[best_Z2_index].second);
582 >    ret.Z2leptons.push_back(ZCandidatesLeptons[best_Z2_index].lepton_pair.first); // push back the *fsr-corrected* leptons
583 >    ret.Z2leptons.push_back(ZCandidatesLeptons[best_Z2_index].lepton_pair.second);
584 >    if(ZCandidatesLeptons[best_Z2_index].which_lepton_has_fsr != 0){
585 >      SimpleLepton photon;
586 >      photon.vec.SetPtEtaPhiM( ZCandidatesLeptons[best_Z2_index].fsr_photon.Pt(), ZCandidatesLeptons[best_Z2_index].fsr_photon.Eta(), ZCandidatesLeptons[best_Z2_index].fsr_photon.Phi(), 0);
587 >      ret.fsrPhotons.push_back(photon);
588 >    }
589  
590 <    int theZ1type = abs(ZCandidatesLeptons[best_Z1_index].first.type);
591 <    int theZ2type = abs(ZCandidatesLeptons[best_Z2_index].first.type);
590 >
591 >    int theZ1type = abs(ZCandidatesLeptons[best_Z1_index].lepton_pair.first.type);
592 >    int theZ2type = abs(ZCandidatesLeptons[best_Z2_index].lepton_pair.first.type);
593  
594      if(ctrl.debug) cout << "best mZ2:  " << (ret.Z2leptons[0].vec+ret.Z2leptons[1].vec).M() << " from ("
595                          << ZCandidates[best_Z2_index].first << "," << ZCandidates[best_Z2_index].second << ")" << endl;
# Line 577 | Line 605 | EventData apply_HZZ4L_reference_selectio
605      //******************************************************************************
606      // Step 6.4 : require Z2 with  4<m<120
607      //******************************************************************************
608 <    TLorentzVector Z2vec = (ZCandidatesLeptons[best_Z2_index].first.vec) +
609 <      (ZCandidatesLeptons[best_Z2_index].second.vec);
608 >    TLorentzVector Z2vec = (ZCandidatesLeptons[best_Z2_index].lepton_pair.first.vec) +
609 >      (ZCandidatesLeptons[best_Z2_index].lepton_pair.second.vec);
610      if( Z2vec.M() > 4 && Z2vec.M() < 120 ) {
611        ret.status.selectionBits.flip(PASS_GOODZ2);
612        increment(counts,"4<mZ2<120",theZ1type,theZ2type);
# Line 592 | Line 620 | EventData apply_HZZ4L_reference_selectio
620      // Step 6.1 : any two leptons 20/10
621      //******************************************************************************
622      vector<SimpleLepton> zzleptons;
623 <    zzleptons.push_back( ZCandidatesLeptons[best_Z1_index].first );
624 <    zzleptons.push_back( ZCandidatesLeptons[best_Z1_index].second );
625 <    zzleptons.push_back( ZCandidatesLeptons[best_Z2_index].first );
626 <    zzleptons.push_back( ZCandidatesLeptons[best_Z2_index].second );
623 >    zzleptons.push_back( ZCandidatesLeptons[best_Z1_index].lepton_pair.first );
624 >    zzleptons.push_back( ZCandidatesLeptons[best_Z1_index].lepton_pair.second );
625 >    zzleptons.push_back( ZCandidatesLeptons[best_Z2_index].lepton_pair.first );
626 >    zzleptons.push_back( ZCandidatesLeptons[best_Z2_index].lepton_pair.second );
627      int nlep_above_10=0,nlep_above_20=0;
628      for( int i=0; i<zzleptons.size(); i++ ) {
629        if( zzleptons[i].vec.Pt() > 10 ) nlep_above_10++;
# Line 616 | Line 644 | EventData apply_HZZ4L_reference_selectio
644      //******************************************************************************
645      // Step 6.5 : resonance killing (4/4)
646      //******************************************************************************
647 +
648 +    //the resonance killing is done based on the leptons without fsr recovered to them
649 +    vector<SimpleLepton > zzleptons_nofsr;
650 +
651 +    //add all of the leptons to a vector and remove the fsr photon if there is one
652 +    if(ZCandidatesLeptons[best_Z1_index].which_lepton_has_fsr == 1){
653 +      SimpleLepton no_fsr_lepton = ZCandidatesLeptons[best_Z1_index].lepton_pair.first;
654 +      TLorentzVector photon_vec;
655 +      photon_vec.SetPtEtaPhiM(ZCandidatesLeptons[best_Z1_index].fsr_photon.Pt(),ZCandidatesLeptons[best_Z1_index].fsr_photon.Eta(),ZCandidatesLeptons[best_Z1_index].fsr_photon.Phi(),0);
656 +      no_fsr_lepton.vec = no_fsr_lepton.vec - photon_vec;
657 +      zzleptons_nofsr.push_back( no_fsr_lepton );
658 +      ret.Z1leptons_without_fsr.push_back(no_fsr_lepton);
659 +    }
660 +    else {
661 +      zzleptons_nofsr.push_back( ZCandidatesLeptons[best_Z1_index].lepton_pair.first);
662 +      ret.Z1leptons_without_fsr.push_back(ZCandidatesLeptons[best_Z1_index].lepton_pair.first);
663 +    }
664 +    
665 +    if(ZCandidatesLeptons[best_Z1_index].which_lepton_has_fsr == 2){
666 +      SimpleLepton no_fsr_lepton = ZCandidatesLeptons[best_Z1_index].lepton_pair.second;
667 +      TLorentzVector photon_vec;
668 +      photon_vec.SetPtEtaPhiM(ZCandidatesLeptons[best_Z1_index].fsr_photon.Pt(),ZCandidatesLeptons[best_Z1_index].fsr_photon.Eta(),ZCandidatesLeptons[best_Z1_index].fsr_photon.Phi(),0);
669 +      no_fsr_lepton.vec = no_fsr_lepton.vec - photon_vec;
670 +      zzleptons_nofsr.push_back( no_fsr_lepton );
671 +      ret.Z1leptons_without_fsr.push_back(no_fsr_lepton);
672 +    }
673 +    else{
674 +       zzleptons_nofsr.push_back( ZCandidatesLeptons[best_Z1_index].lepton_pair.second);
675 +       ret.Z1leptons_without_fsr.push_back(ZCandidatesLeptons[best_Z1_index].lepton_pair.second);
676 +    }
677 +
678 +    if(ZCandidatesLeptons[best_Z2_index].which_lepton_has_fsr == 1){
679 +      SimpleLepton no_fsr_lepton = ZCandidatesLeptons[best_Z2_index].lepton_pair.first;
680 +      TLorentzVector photon_vec;
681 +      photon_vec.SetPtEtaPhiM(ZCandidatesLeptons[best_Z2_index].fsr_photon.Pt(),ZCandidatesLeptons[best_Z2_index].fsr_photon.Eta(),ZCandidatesLeptons[best_Z2_index].fsr_photon.Phi(),0);
682 +      no_fsr_lepton.vec = no_fsr_lepton.vec - photon_vec;
683 +      zzleptons_nofsr.push_back( no_fsr_lepton );
684 +      ret.Z2leptons_without_fsr.push_back(no_fsr_lepton);
685 +    }
686 +    else {
687 +      zzleptons_nofsr.push_back( ZCandidatesLeptons[best_Z2_index].lepton_pair.first);
688 +      ret.Z2leptons_without_fsr.push_back(ZCandidatesLeptons[best_Z2_index].lepton_pair.first);
689 +    }
690 +
691 +    if(ZCandidatesLeptons[best_Z2_index].which_lepton_has_fsr == 2){
692 +      SimpleLepton no_fsr_lepton = ZCandidatesLeptons[best_Z2_index].lepton_pair.second;
693 +      TLorentzVector photon_vec;
694 +      photon_vec.SetPtEtaPhiM(ZCandidatesLeptons[best_Z2_index].fsr_photon.Pt(),ZCandidatesLeptons[best_Z2_index].fsr_photon.Eta(),ZCandidatesLeptons[best_Z2_index].fsr_photon.Phi(),0);
695 +      no_fsr_lepton.vec = no_fsr_lepton.vec - photon_vec;
696 +      zzleptons_nofsr.push_back( no_fsr_lepton );
697 +      ret.Z2leptons_without_fsr.push_back(no_fsr_lepton);
698 +    }
699 +    else{
700 +      zzleptons_nofsr.push_back( ZCandidatesLeptons[best_Z2_index].lepton_pair.second);
701 +      ret.Z2leptons_without_fsr.push_back( ZCandidatesLeptons[best_Z2_index].lepton_pair.second);
702 +    }
703 +
704      bool resonance = false;
705 <    for( int i=0; i<zzleptons.size(); i++ ) {
706 <      for( int j=i+1; j<zzleptons.size(); j++ ) {
707 <        if( zzleptons[i].charge == zzleptons[j].charge ) continue; // 4/4
708 <        if( (zzleptons[i].vec+zzleptons[j].vec).M() <= 4. ) {
705 >    for( int i=0; i<zzleptons_nofsr.size(); i++ ) {
706 >      for( int j=i+1; j<zzleptons_nofsr.size(); j++ ) {
707 >        if( zzleptons_nofsr[i].charge == zzleptons_nofsr[j].charge ) continue; // 4/4
708 >        
709 >        if( (zzleptons_nofsr[i].vec+zzleptons_nofsr[j].vec).M() <= 4. ) {
710            resonance = true;
711            break;
712          }
# Line 640 | Line 726 | EventData apply_HZZ4L_reference_selectio
726      //******************************************************************************
727      // Step 6.6 : m(4l) > 70 , m(4l) > 100
728      //******************************************************************************
729 <    TLorentzVector zzvec = (ZCandidatesLeptons[best_Z1_index].first.vec) +
730 <      (ZCandidatesLeptons[best_Z1_index].second.vec) +
731 <      (ZCandidatesLeptons[best_Z2_index].first.vec) +
732 <      (ZCandidatesLeptons[best_Z2_index].second.vec);
729 >    TLorentzVector zzvec = (ZCandidatesLeptons[best_Z1_index].lepton_pair.first.vec) +
730 >      (ZCandidatesLeptons[best_Z1_index].lepton_pair.second.vec) +
731 >      (ZCandidatesLeptons[best_Z2_index].lepton_pair.first.vec) +
732 >      (ZCandidatesLeptons[best_Z2_index].lepton_pair.second.vec);
733      
734      if(ctrl.debug)
735        cout << "forming zz from: "
736 <           << setw(9) << (ZCandidatesLeptons[best_Z1_index].first.vec).Pt()
737 <           << setw(9) << (ZCandidatesLeptons[best_Z1_index].second.vec).Pt()
738 <           << setw(9) << (ZCandidatesLeptons[best_Z2_index].first.vec).Pt()
739 <           << setw(9) << (ZCandidatesLeptons[best_Z2_index].second.vec).Pt() << endl;
736 >           << setw(9) << (ZCandidatesLeptons[best_Z1_index].lepton_pair.first.vec).Pt()
737 >           << setw(9) << (ZCandidatesLeptons[best_Z1_index].lepton_pair.second.vec).Pt()
738 >           << setw(9) << (ZCandidatesLeptons[best_Z2_index].lepton_pair.first.vec).Pt()
739 >           << setw(9) << (ZCandidatesLeptons[best_Z2_index].lepton_pair.second.vec).Pt() << endl;
740  
741      if( zzvec.M() > 70. ) {
742        if(ctrl.debug) cout << "passes mzz > 70, mzz: " << zzvec.M() << endl;
# Line 673 | Line 759 | EventData apply_HZZ4L_reference_selectio
759        if(ctrl.debug) cout << "passes mzz > 100, mzz: " << zzvec.M() << endl;
760        increment(counts,"m4l>100",theZ1type,theZ2type);
761      } else {
762 +      ret.status.setStatus(SelectionStatus::FAIL);
763 +      //return ret;
764        // cout << "NOTE: failed m4l>100 (" << zzvec.M() << "), but saving to ntuple anyway" << endl;
765      }
766  
# Line 680 | Line 768 | EventData apply_HZZ4L_reference_selectio
768      // finish
769      //***************************************************************
770      
771 <    TLorentzVector theZ1 = (ZCandidatesLeptons[best_Z1_index].first.vec) +
772 <        (ZCandidatesLeptons[best_Z1_index].second.vec);
773 <    TLorentzVector theZ2 = (ZCandidatesLeptons[best_Z2_index].first.vec) +
774 <        (ZCandidatesLeptons[best_Z2_index].second.vec);
771 >    TLorentzVector theZ1 = (ZCandidatesLeptons[best_Z1_index].lepton_pair.first.vec) +
772 >        (ZCandidatesLeptons[best_Z1_index].lepton_pair.second.vec);
773 >    TLorentzVector theZ2 = (ZCandidatesLeptons[best_Z2_index].lepton_pair.first.vec) +
774 >        (ZCandidatesLeptons[best_Z2_index].lepton_pair.second.vec);
775      TLorentzVector theZZ = theZ1 + theZ2;
776      
777      // if(ret.fsrPhotons.size() > 0) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines