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.6 by khahn, Wed May 30 05:41:58 2012 UTC vs.
Revision 1.7 by khahn, Sun Jun 3 16:12:53 2012 UTC

# Line 35 | Line 35 | extern vector<vector<unsigned> > zzcutve
35   extern map<unsigned,float>       evtrhoMap;
36   extern bool passes_HLT_MC;
37  
38 + //
39 + // prototypes
40   //--------------------------------------------------------------------------------------------------
41   bool setPV(ControlFlags, const mithep::Array<mithep::Vertex> *, const mithep::Vertex* &);
42 + void updateSimpleLepton(SimpleLepton &tmplep);
43   void fillVetoArrays( ControlFlags & ctrl,
44                       const mithep::Array<mithep::Muon> *muonArr,    
45                       vector< const mithep::Muon*>     & muonsToVeto,
46                       const mithep::Array<mithep::Electron> *electronArr,    
47                       vector< const mithep::Electron*> & electronsToVeto,
48 <                     const mithep::Vertex * vtx )
48 >                     const mithep::Vertex * vtx ) ;
49   //--------------------------------------------------------------------------------------------------
47 {
48
49  if( ctrl.debug ) cout << "looping for isolation ..." << endl;
50  /*
51  for(int i=0; i<muonArr->GetEntries(); i++)
52    {
53      const mithep::Muon *mu = (const mithep::Muon*)((*muonArr)[i]);      
54      SelectionStatus musel;
55      //      musel |= muonCutBasedVeto(ctrl,mu,vtx);
56      musel |= muonDummyVeto(ctrl,mu,vtx);
57      if( !(musel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
58      if(ctrl.debug) cout << "pushing mu for isol veto ... " << endl;
59      muonsToVeto.push_back( mu );
60    }
61  */
62  for(int i=0; i<electronArr->GetEntries(); i++)
63    {
64      const mithep::Electron *ele = (const mithep::Electron*)((*electronArr)[i]);      
65      SelectionStatus esel;
66      //      esel |= electronCutBasedVeto(ctrl,ele,vtx);
67      esel |= electronDummyVeto(ctrl,ele,vtx);
68      if( !(esel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
69      if(ctrl.debug) cout << "pushing ele for isol veto ... " << endl;
70      electronsToVeto.push_back( ele );
71    }
72  if( ctrl.debug ) cout << "done selecting for isolation veto ..." << endl << endl;;
73 }
74
50  
51 < //const mithep::Vertex * vtx = 0;
51 > // TMPTMPTMP -- global for FSR study
52 > // std::vector< std::vector<int> > gammaMatches;
53 > // TMPTMPTMP -- global for FSR study
54  
55   //--------------------------------------------------------------------------------------------------
56   EventData apply_HZZ4L_reference_selection(ControlFlags &ctrl,           // input control
# Line 137 | Line 114 | EventData apply_HZZ4L_reference_selectio
114    failingLeptons.clear();
115    passingLeptons.clear();
116  
117 +  /*
118 +  // TMPTMPTMP -- global for FSR study
119 +  gammaMatches.clear();
120 +  for( int i=0; i<pfCandidates->GetEntries(); i++ ) {
121 +    gammaMatches.push_back(std::vector<int> ());
122 +  }
123 +  // TMPTMPTMP -- global for FSR study
124 +  */
125 +
126    if( ctrl.debug ) {
127      cout << "-----------------------------------------------------------------" << endl;
128      cout << "-----------------------------------------------------------------" << endl;
# Line 309 | Line 295 | EventData apply_HZZ4L_reference_selectio
295        if(ctrl.debug) cout << "musel.status  after ID: " << musel.getStatus() << endl;
296        if( ctrl.debug ) cout << endl;
297  
298 <      if( ctrl.doFSR ) {
299 <        float old_pt = mu->Pt();
314 <        mithep::Muon * newmu =  const_cast<mithep::Muon *>(mu);
315 <        if( recover_typeI_Photon( ctrl, newmu, pfCandidates ) ) {
316 <          if(ctrl.debug) cout << "FSR TYPEI :: oldpt: " << old_pt << "\tnewpt: " << mu->Pt() << endl;
317 <          old_pt = mu->Pt();
318 <        }
319 <        if( recover_typeII_Photon( ctrl, newmu, pfCandidates ) ) {
320 <          if(ctrl.debug) cout << "FSR TYPEII :: oldpt: " << old_pt << "\tnewpt: " << mu->Pt() << endl;
321 <          old_pt = mu->Pt();
322 <        }
323 <      }
324 <
298 >    
299 >      if( !(ctrl.doFSR) ) {
300   #ifdef HACKED_RHOS
301 <      musel |=  (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,rho,eraMu,muonsToVeto,electronsToVeto);
301 >        musel |=  (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,rho,eraMu,muonsToVeto,electronsToVeto);
302   #else
303 <      musel |=  (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,muonsToVeto,electronsToVeto);
303 >        musel |=  (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,muonsToVeto,electronsToVeto);
304   #endif
305 <      if(ctrl.debug) cout << "musel.status  after iso: " << musel.getStatus() << endl;
306 <      if( ctrl.debug ) cout << "isomva : " << musel.isoMVA << endl;
307 <      if( ctrl.debug ) cout << endl;
305 >        if(ctrl.debug) cout << "musel.status  after iso: " << musel.getStatus() << endl;
306 >        if( ctrl.debug ) cout << "isomva : " << musel.isoMVA << endl;
307 >        if( ctrl.debug ) cout << endl;
308 >      }
309  
310        if( ctrl.debug ) {
311          cout << "muon:: pt: " << mu->Pt()
# Line 341 | Line 317 | EventData apply_HZZ4L_reference_selectio
317  
318        SimpleLepton tmplep;
319        float pt = mu->Pt();
344      /*
345      for( int p=0; p<pfCandidates->GetEntries(); p++ ) {
346        const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*pfCandidates)[p]);
347        if (pf->HasTrackerTrk() && (pf->TrackerTrk() == mu->TrackerTrk()) ) {
348          pt = pf->Pt();
349          break;
350        }
351      }
352      */
320        tmplep.vec.SetPtEtaPhiM(pt,
321                                 mu->Eta(),
322                                 mu->Phi(),
# Line 374 | Line 341 | EventData apply_HZZ4L_reference_selectio
341        tmplep.isTight = musel.tight();
342        tmplep.isLoose = musel.loose();
343        tmplep.status  = musel;    
344 +      tmplep.fsrRecoveryAttempted = false;
345        lepvec.push_back(tmplep);
346        if( ctrl.debug ) cout << endl;
347      }
# Line 400 | Line 368 | EventData apply_HZZ4L_reference_selectio
368          if( ctrl.debug ) cout << "--> status after ID: " << hex << elesel.getStatus() << dec << endl;
369          if( ctrl.debug ) cout << endl;
370  
371 +      if( !(ctrl.doFSR) ) {
372   #ifdef HACKED_RHOS
373          elesel |= (*ElectronIsoSelector)(ctrl,ele,vtx,pfCandidates,rho,eraEle,muonsToVeto,electronsToVeto);
374   #else
# Line 407 | Line 376 | EventData apply_HZZ4L_reference_selectio
376   #endif
377          if( ctrl.debug ) cout << "--> status after iso: " << hex << elesel.getStatus() << dec << endl;
378          if( ctrl.debug ) cout << endl;
379 +      }
380          
381          if( ctrl.debug ){
382            cout << "\tscEt: " << ele->SCluster()->Et()
# Line 444 | Line 414 | EventData apply_HZZ4L_reference_selectio
414          tmplep.status  = elesel;
415          tmplep.idMVA   = elesel.idMVA;
416          tmplep.isoMVA  = elesel.isoMVA;
417 +        tmplep.fsrRecoveryAttempted = false;
418          lepvec.push_back(tmplep);
419          if( ctrl.debug ) cout << endl;
420        }
# Line 452 | Line 423 | EventData apply_HZZ4L_reference_selectio
423      // Dump Stuff
424      //********************************************************
425      sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort );
426 +    //    sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_reversept_sort );
427      int nmu=0, nele=0;
428      for( int i=0; i<lepvec.size(); i++ ) {
429        if(ctrl.debug) {
# Line 496 | Line 468 | EventData apply_HZZ4L_reference_selectio
468             it2 != lepvec.end(); it2++ ) {
469          if ( it2 == it1 ) continue;
470          if ( abs(it2->type) != 13 ) continue;
471 <        if( !(it2->isLoose) )       continue;
471 >        if( !(it2->status.looseIDAndPre()) )       continue;
472          TVector3 mvec = it2->vec.Vect();
473          
474          if ( evec.DrEtaPhi(mvec) < 0.05 ) {
# Line 527 | Line 499 | EventData apply_HZZ4L_reference_selectio
499      vector<double> pt_of_leptons_to_erase;
500      for (int i=0; i<lepvec.size(); i++ ) {
501        bool already_pushed=false;
502 <      if( !(lepvec[i].isLoose) ) {
502 >      if( !(lepvec[i].status.looseIDAndPre()) ) {
503          pt_of_leptons_to_erase.push_back(lepvec[i].vec.Pt());
504          already_pushed = true;
505          if(ctrl.debug)
# Line 567 | Line 539 | EventData apply_HZZ4L_reference_selectio
539      //********************************************************
540      std::vector<std::pair<int,int> > ZCandidates;
541      for(int i = 0; i < lepvec.size(); ++i) {
542 <      cout << "i: " << i << "\ttype: " << lepvec[i].type << "\tcharge: " << lepvec[i].charge << "\tpt: " << lepvec[i].vec.Pt() << endl;
542 >
543        for(int j = i+1; j < lepvec.size(); ++j) {
572        cout << "\tj: " << j << "\ttype: " << lepvec[j].type << "\tcharge: " << lepvec[j].charge << "\tpt: " << lepvec[j].vec.Pt()  << endl;
544          if( abs(lepvec[i].type) != abs(lepvec[j].type) )      continue;
574        cout << "\tpasses type ..." << endl;
545          if( lepvec[i].charge == lepvec[j].charge )            continue;
546 <        cout << "\tpasses q ..." << endl;
547 <        cout << "\ti_loose: " << lepvec[i].isLoose << endl;
548 <        cout << "\tj_loose: " << lepvec[j].isLoose << endl;
549 <        if( !(lepvec[i].isLoose) || !(lepvec[j].isLoose) )    continue;
550 <        cout << "passes loose ..." << endl;
546 >
547 >        TLorentzVector Zvec = (lepvec[i].vec+lepvec[j].vec);
548 >
549 >        if( ctrl.doFSR ) {
550 >          cout << endl;
551 >          cout << "----------------> FSR ("<<i<<","<<j<<") <----------------------" << endl;
552 >        }
553 >
554 >        if( ctrl.doFSR ) {  // && !(lepvec[i].fsrRecoveryAttempted)
555 >          cout << "i: " << i << endl;
556 >          float old_pt = lepvec[i].vec.Pt();
557 >          float old_M  =  Zvec.M();
558 >          if( abs(lepvec[i].type) == 13 ) {
559 >            const mithep::Muon *mu = (mithep::Muon*)((*muonArr)[lepvec[i].index]);      
560 >            mithep::Muon * newmu = const_cast<mithep::Muon *>(mu);
561 >            //      if( recover_typeI_Photon( ctrl, newmu, lepvec[i], pfCandidates, electronArr, &Zvec ) ) {
562 >            if( recover_typeI_Photon( ctrl, newmu, i, lepvec, pfCandidates, electronArr, &Zvec ) ) {
563 >              if(ctrl.debug) cout << "FSR TYPEI :: oldpt: " << old_pt
564 >                                  << "\tnewpt: " << lepvec[i].vec.Pt()
565 >                                  << "\tindex: " << i
566 >                                  << endl;
567 >              old_pt = mu->Pt();
568 >            }
569 >            if( recover_typeII_Photon( ctrl, newmu, i, lepvec, pfCandidates ) ) {
570 >              if(ctrl.debug) cout << "FSR TYPEII :: oldpt: " << old_pt
571 >                                  << "\tnewpt: " << lepvec[i].vec.Pt()
572 >                                  << "\tindex: " << i
573 >                                  << endl;
574 >            }
575 >            lepvec[i].status |=
576 >              (*MuonIsoSelector)(ctrl,newmu,vtx,pfCandidates,puEnergyDensity,eraMu,muonsToVeto,electronsToVeto);          
577 >            updateSimpleLepton(lepvec[i]);
578 >            float new_M =   (lepvec[i].vec+lepvec[j].vec).M();
579 >            if( ctrl.debug ) cout << "\toldM: " << old_M << "\tnewM:" << new_M << endl;
580 >
581 >          } else {
582 >
583 >            const mithep::Electron *el = (mithep::Electron*)((*electronArr)[lepvec[i].index]);      
584 >            mithep::Electron* newel = const_cast<mithep::Electron*>(el);
585 >            if( recover_typeI_Photon( ctrl, newel, i, lepvec, pfCandidates, electronArr, &Zvec ) ) {
586 >              if(ctrl.debug) cout << "FSR TYPEI :: oldpt: " << old_pt
587 >                                  << "\tnewpt: " << lepvec[i].vec.Pt()
588 >                                  << "\tindex: " << i
589 >                                  << endl;
590 >            }
591 >            lepvec[i].status |=
592 >              (*ElectronIsoSelector)(ctrl,newel,vtx,pfCandidates,puEnergyDensity,eraEle,muonsToVeto,electronsToVeto);    
593 >            updateSimpleLepton(lepvec[i]);
594 >          }
595 >        } // doFSR
596 >        
597 >
598 >        if( ctrl.doFSR  ) {  // && !(lepvec[j].fsrRecoveryAttempted
599 >          cout << "j: " << j << endl;
600 >          mithep::ChargedParticle *cp;
601 >          float old_pt = lepvec[j].vec.Pt();
602 >          float old_M  =  Zvec.M();      
603 >          if( abs(lepvec[j].type) == 13 ) {
604 >            const mithep::Muon *mu = (mithep::Muon*)((*muonArr)[lepvec[j].index]);      
605 >            mithep::Muon * newmu = const_cast<mithep::Muon *>(mu);
606 >            if( recover_typeI_Photon( ctrl, newmu, j, lepvec, pfCandidates, electronArr, &Zvec ) ) {
607 >              if(ctrl.debug) cout << "FSR TYPEI :: oldpt: " << old_pt
608 >                                  << "\tnewpt: " << lepvec[j].vec.Pt()
609 >                                  << "\tindex: " << j
610 >                                  << endl;
611 >              old_pt = mu->Pt();
612 >            }
613 >            if( recover_typeII_Photon( ctrl, newmu, j, lepvec, pfCandidates ) ) {
614 >              if(ctrl.debug) cout << "FSR TYPEII :: oldpt: " << old_pt
615 >                                  << "\tnewpt: " << lepvec[j].vec.Pt()
616 >                                  << "\tindex: " << j
617 >                                  << endl;
618 >            }
619 >            lepvec[j].status |=
620 >              (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,muonsToVeto,electronsToVeto);    
621 >            updateSimpleLepton(lepvec[j]);
622 >            float new_M =   (lepvec[i].vec+lepvec[j].vec).M();
623 >            if( ctrl.debug ) cout << "\toldM: " << old_M << "\tnewM:" << new_M << endl;
624 >
625 >          } else {
626 >
627 >            const mithep::Electron *el = (mithep::Electron*)((*electronArr)[lepvec[j].index]);      
628 >            mithep::Electron* newel = const_cast<mithep::Electron*>(el);
629 >            if( recover_typeI_Photon( ctrl, newel, j, lepvec, pfCandidates, electronArr, &Zvec ) ) {
630 >              if(ctrl.debug) cout << "FSR TYPEI :: oldpt: " << old_pt
631 >                                  << "\tnewpt: " << lepvec[j].vec.Pt()
632 >                                  << "\tindex: " << j
633 >                                  << endl;
634 >            }
635 >            lepvec[j].status |=
636 >              (*ElectronIsoSelector)(ctrl,newel,vtx,pfCandidates,puEnergyDensity,eraEle,muonsToVeto,electronsToVeto);    
637 >            updateSimpleLepton(lepvec[j]);
638 >          }
639 >        } // doFSR
640 >          
641 >
642 >        if( !(lepvec[i].status.loose()) || !(lepvec[j].status.loose()) )    continue;
643          ZCandidates.push_back(std::pair<int,int> (i,j) );
644          if( ctrl.debug ) cout << "Z candidate ("<< i << "," << j << ")"
645                                << "\tmass: " << (lepvec[i].vec+lepvec[j].vec).M() << endl;
# Line 592 | Line 654 | EventData apply_HZZ4L_reference_selectio
654        return ret;
655      }
656  
657 +    /*
658 +    // TMPTMPTMP -- fsr study
659 +    for (int pp=0; pp<gammaMatches.size(); pp++ ) {
660 +      if ( (gammaMatches[pp]).size() > 1 ) {
661 +        cerr << "multiple gamma match : ";
662 +        for( int ll=0; ll<(gammaMatches[pp]).size(); ll++ ) {
663 +          cerr <<  (gammaMatches[pp])[ll] << " ";
664 +        }
665 +        cerr << endl;
666 +      } else if ( (gammaMatches[pp]).size() ) {
667 +        cerr << "single gamma match" << endl;
668 +      }
669 +    }
670 +    // TMPTMPTMP -- fsr study
671 +    */
672 +
673 +
674      //
675      // !!!!!!!!!!!!!! Z1 SELECTED HERE
676      //
# Line 609 | Line 688 | EventData apply_HZZ4L_reference_selectio
688      }
689      ret.Z1leptons.push_back(lepvec[ZCandidates[best_Z1_index].first]);
690      ret.Z1leptons.push_back(lepvec[ZCandidates[best_Z1_index].second]);
691 <    cout << "best mZ1:  " << best_Z1_mass << endl;
691 >    cout << "best mZ1:  " << best_Z1_mass << " from ("  <<
692 >      ZCandidates[best_Z1_index].first << "," << ZCandidates[best_Z1_index].second << ")" << endl;
693      int Z1type;
694      if( abs(ret.Z1leptons[0].type) == 11 ) Z1type=0;
695      else Z1type=1;
# Line 631 | Line 711 | EventData apply_HZZ4L_reference_selectio
711      // Step 6.3 : 4 good leptons
712      //******************************************************************************
713      if( lepvec.size() >= 4 ) {
634
714        if( ctrl.debug) cout << "pass4L: "  << info->EvtNum() << endl;
715        ret.status.selectionBits.flip(PASS_4L);
716        cutvec[PASS_4L] +=1;
717        zcutvec[Z1type][PASS_4L] +=1;
718      } else {
640
719        ret.status.setStatus(SelectionStatus::FAIL);
720        return ret;
721      }
# Line 685 | Line 763 | EventData apply_HZZ4L_reference_selectio
763        return ret;
764      }
765  
688
766      //
767      // !!!!!!!!!!!!!! Z2 SELECTED HERE
768      //
# Line 709 | Line 786 | EventData apply_HZZ4L_reference_selectio
786      else ZZtype=2;
787      zzcutvec[ZZtype][PASS_ZZCANDIDATE] += 1;
788  
789 +    if(ctrl.debug)cout << "ZZ :: evt: " << info->EvtNum()
790 +                       << "\tmZ1: " << (ret.Z1leptons[0].vec+ret.Z1leptons[1].vec).M()  
791 +                       << "\tmZ2: " << (ret.Z2leptons[0].vec+ret.Z2leptons[1].vec).M()  
792 +                       << endl;
793 +
794      //******************************************************************************
795      // Step 6.4 : require Z2 with  4<m<120
796      //******************************************************************************
# Line 751 | Line 833 | EventData apply_HZZ4L_reference_selectio
833  
834  
835      //******************************************************************************
836 <    // Step 6.5 : resonance killing
836 >    // Step 6.5 : resonance killing (4/4)
837      //******************************************************************************
838      bool resonance = false;
839      for( int i=0; i<zzleptons.size(); i++ ) {
840        for( int j=i+1; j<zzleptons.size(); j++ ) {
841 +        //      if( zzleptons[i].charge == zzleptons[j].charge ) continue; // 4/4
842          if( (zzleptons[i]+zzleptons[j]).M() < 4. ) {
843            resonance = true;
844            break;
# Line 894 | Line 977 | bool setPV(ControlFlags ctrl,
977    }    
978   };
979  
980 + //--------------------------------------------------------------------------------------------------
981 + void fillVetoArrays( ControlFlags & ctrl,
982 +                     const mithep::Array<mithep::Muon> *muonArr,    
983 +                     vector< const mithep::Muon*>     & muonsToVeto,
984 +                     const mithep::Array<mithep::Electron> *electronArr,    
985 +                     vector< const mithep::Electron*> & electronsToVeto,
986 +                     const mithep::Vertex * vtx )
987 + //--------------------------------------------------------------------------------------------------
988 + {
989 +
990 +  if( ctrl.debug ) cout << "looping for isolation ..." << endl;
991 +  /*
992 +  for(int i=0; i<muonArr->GetEntries(); i++)
993 +    {
994 +      const mithep::Muon *mu = (const mithep::Muon*)((*muonArr)[i]);      
995 +      SelectionStatus musel;
996 +      //      musel |= muonCutBasedVeto(ctrl,mu,vtx);
997 +      musel |= muonDummyVeto(ctrl,mu,vtx);
998 +      if( !(musel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
999 +      if(ctrl.debug) cout << "pushing mu for isol veto ... " << endl;
1000 +      muonsToVeto.push_back( mu );
1001 +    }
1002 +  */
1003 +  for(int i=0; i<electronArr->GetEntries(); i++)
1004 +    {
1005 +      const mithep::Electron *ele = (const mithep::Electron*)((*electronArr)[i]);      
1006 +      SelectionStatus esel;
1007 +      //      esel |= electronCutBasedVeto(ctrl,ele,vtx);
1008 +      esel |= electronDummyVeto(ctrl,ele,vtx);
1009 +      if( !(esel.getStatus() & SelectionStatus::PRESELECTION) ) continue;
1010 +      if(ctrl.debug) cout << "pushing ele for isol veto ... " << endl;
1011 +      electronsToVeto.push_back( ele );
1012 +    }
1013 +  if( ctrl.debug ) cout << "done selecting for isolation veto ..." << endl << endl;;
1014 + }
1015 +
1016 +
1017 +
1018 +
1019 + //----------------------------------------------------------------------------
1020 + void updateSimpleLepton(SimpleLepton &tmplep)
1021 + //----------------------------------------------------------------------------
1022 + {
1023 +  tmplep.isoPF04   = tmplep.status.isoPF04;
1024 +  tmplep.chisoPF04 = tmplep.status.chisoPF04;
1025 +  tmplep.gaisoPF04 = tmplep.status.gaisoPF04;
1026 +  tmplep.neisoPF04 = tmplep.status.neisoPF04;
1027 +  tmplep.isTight = tmplep.status.tight();
1028 +  tmplep.isLoose = tmplep.status.loose();
1029 +  tmplep.fsrRecoveryAttempted = true;
1030 + }
1031  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines