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

Comparing UserCode/MitPhysics/Mods/src/PhotonTreeWriter.cc (file contents):
Revision 1.49 by veverka, Fri Aug 30 12:02:37 2013 UTC vs.
Revision 1.50 by veverka, Fri Aug 30 23:25:24 2013 UTC

# Line 1 | Line 1
1 #include <sstream>
1   #include "MitPhysics/Mods/interface/PhotonTreeWriter.h"
2   #include "MitAna/DataTree/interface/PhotonCol.h"
3   #include "MitAna/DataTree/interface/PFCandidateCol.h"
# Line 100 | Line 99 | PhotonTreeWriter::PhotonTreeWriter(const
99    fEnableGenJets          (kFALSE),
100    fApplyJetId             (kFALSE),
101    fApplyLeptonTag         (kFALSE),
102 +  fApplyLeptonTag2        (kFALSE),
103    fApplyVBFTag            (kFALSE),
104    fApplyTTHTag            (kFALSE),
105    fApplyBTag              (kFALSE),
# Line 156 | Line 156 | void PhotonTreeWriter::Process()
156    LoadEventObject(fGoodElectronName,   fGoodElectrons);
157  
158    // lepton tag collections
159 <  if( fApplyLeptonTag ) {
159 >  if( fApplyLeptonTag || fApplyLeptonTag2 ) {
160      LoadEventObject(fLeptonTagElectronsName, fLeptonTagElectrons);
161      LoadEventObject(fLeptonTagMuonsName,     fLeptonTagMuons);
162    }
# Line 243 | Line 243 | void PhotonTreeWriter::Process()
243    Double_t _spfMet = fPFMet->At(0)->SumEt();
244  
245    fDiphotonEvent->leptonTag = -1; // disabled
246 +  fDiphotonEvent->leptonTag2 = -1; // disabled
247  
248    // ====================================================
249    // Vtx synching stuff...
# Line 934 | Line 935 | void PhotonTreeWriter::Process()
935      
936      
937      if( fApplyLeptonTag ) {
938 <      
939 <      // perform lepton tagging
940 <      // the diphoton event record will have one more entry; i.e. leptonTag
941 <      // leptonTag = -1   -> lepton-taggng was swicthed off
942 <      //           =  0   -> event tagged as 'non-lepton-event'
942 <      //           = +1   -> event tagged as muon-event
943 <      //           = +2   -> event tagged as electron-event
944 <      fDiphotonEvent->leptonTag = 0;
945 <      Int_t closestVtx = 0;
946 <      if ( fLeptonTagMuons->GetEntries() > 0 ) {
947 <        // need to have dR > 1 for with respect to both photons ***changed to 0.7 for 2012
948 <        if( (MathUtils::DeltaR(fLeptonTagMuons->At(0),phHard) >= 1.0) &&
949 <            (MathUtils::DeltaR(fLeptonTagMuons->At(0),phSoft) >= 1.0)  
950 <            ){
951 <          
952 <          fDiphotonEvent->leptonTag = 2;
953 <          
954 <          fDiphotonEvent-> muonPt  = fLeptonTagMuons->At(0)->Pt();
955 <          fDiphotonEvent-> muonEta = fLeptonTagMuons->At(0)->Eta();
956 <          fDiphotonEvent-> muDR1   = MathUtils::DeltaR(fLeptonTagMuons->At(0),phHard);
957 <          fDiphotonEvent-> muDR2   = MathUtils::DeltaR(fLeptonTagMuons->At(0),phSoft);
958 <          
959 <          fDiphotonEvent-> muIso1   = (fLeptonTagMuons->At(0)->IsoR03SumPt() + fLeptonTagMuons->At(0)->IsoR03EmEt() + fLeptonTagMuons->At(0)->IsoR03HadEt() - fPileUpDen->At(0)->RhoRandomLowEta() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(0)->Pt();
960 <          fDiphotonEvent-> muIso2   = (fLeptonTagMuons->At(0)->IsoR03SumPt() + fLeptonTagMuons->At(0)->IsoR03EmEt() + fLeptonTagMuons->At(0)->IsoR03HadEt() - fPileUpDen->At(0)->RhoRandom() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(0)->Pt();
961 <          fDiphotonEvent-> muIso3   = (fLeptonTagMuons->At(0)->IsoR03SumPt() + fLeptonTagMuons->At(0)->IsoR03EmEt() + fLeptonTagMuons->At(0)->IsoR03HadEt() - fPileUpDen->At(0)->RhoLowEta() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(0)->Pt();
962 <          fDiphotonEvent-> muIso4   = (fLeptonTagMuons->At(0)->IsoR03SumPt() + fLeptonTagMuons->At(0)->IsoR03EmEt() + fLeptonTagMuons->At(0)->IsoR03HadEt() - fPileUpDen->At(0)->Rho() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(0)->Pt();
963 <          fDiphotonEvent-> muD0  = TMath::Abs(fLeptonTagMuons->At(0)->BestTrk()->D0Corrected(*fPV->At(0)));
964 <          fDiphotonEvent-> muDZ  = TMath::Abs(fLeptonTagMuons->At(0)->BestTrk()->DzCorrected(*fPV->At(0)));
965 <          fDiphotonEvent-> muChi2  = fLeptonTagMuons->At(0)->GlobalTrk()->Chi2()/fLeptonTagMuons->At(0)->GlobalTrk()->Ndof();
966 <          
967 <          fDiphotonEvent-> muNhits = fLeptonTagMuons->At(0)->BestTrk()->NHits();
968 <          fDiphotonEvent-> muNpixhits = fLeptonTagMuons->At(0)->BestTrk()->NPixelHits();
969 <          fDiphotonEvent-> muNegs = fLeptonTagMuons->At(0)->NSegments();
970 <          fDiphotonEvent-> muNMatch = fLeptonTagMuons->At(0)->NMatches();
971 <        }
972 <      }
973 <      
974 <      if ( fDiphotonEvent->leptonTag < 1 && fLeptonTagElectrons->GetEntries() > 0 ) {
975 <        if( (MathUtils::DeltaR(fLeptonTagElectrons->At(0),phHard) >= 1) &&
976 <            (MathUtils::DeltaR(fLeptonTagElectrons->At(0),phSoft) >= 1) &&
977 <            (PhotonTools::ElectronVetoCiC(phHard,fLeptonTagElectrons) >= 1) &&
978 <            (PhotonTools::ElectronVetoCiC(phSoft,fLeptonTagElectrons) >= 1) &&
979 <            (TMath::Abs( (phHard->Mom()+fLeptonTagElectrons->At(0)->Mom()).M()-91.19 ) >= 10) &&
980 <            (TMath::Abs( (phSoft->Mom()+fLeptonTagElectrons->At(0)->Mom()).M()-91.19 ) >= 10)  
981 <            //((phHard->Pt()/(phHard->Mom() + phSoft->Mom()).M())>(45./120.)) &&
982 <            //((phSoft->Pt()/(phHard->Mom() + phSoft->Mom()).M())>(30./120.))){
983 <            ){
984 <          
985 <          /*int ph1passeveto=1;
986 <            int ph2passeveto=1;
987 <            
988 <            for(UInt_t k=0;k<fElectrons->GetEntries();k++){
989 <            if(fElectrons->At(k)->BestTrk()->NMissingHits()==0){
990 <            if((fElectrons->At(k)->SCluster()==phHard->SCluster()) && (MathUtils::DeltaR(*fElectrons->At(k)->BestTrk(),*phHard) < 1)){
991 <            ph1passeveto=0;
992 <            }
993 <            if((fElectrons->At(k)->SCluster()==phSoft->SCluster()) && (MathUtils::DeltaR(*fElectrons->At(k)->BestTrk(),*phSoft) < 1)){
994 <            ph2passeveto=0;
995 <            }
996 <            }
997 <            }
998 <            
999 <            if(ph1passeveto==1 && ph2passeveto==1){*/
1000 <          
1001 <          if(PhotonTools::ElectronVetoCiC(phHard, fElectrons)>=1 && PhotonTools::ElectronVetoCiC(phSoft, fElectrons)>=1){
1002 <            
1003 <            fDiphotonEvent->leptonTag = 1;
1004 <            
1005 <            fDiphotonEvent-> elePt = fLeptonTagElectrons->At(0)->Pt();
1006 <            fDiphotonEvent-> eleEta = fLeptonTagElectrons->At(0)->Eta();
1007 <            fDiphotonEvent-> eleSCEta = fLeptonTagElectrons->At(0)->SCluster()->Eta();
1008 <            fDiphotonEvent-> eleIso1 = (fLeptonTagElectrons->At(0)->TrackIsolationDr03() + fLeptonTagElectrons->At(0)->EcalRecHitIsoDr03() + fLeptonTagElectrons->At(0)->HcalTowerSumEtDr03() - fPileUpDen->At(0)->RhoRandomLowEta() * TMath::Pi() * 0.3 * 0.3)/fDiphotonEvent-> elePt;
1009 <            
1010 <            fDiphotonEvent-> eleIso2 = -99.;
1011 <            
1012 <            if ( fDoSynching ) {
1013 <              Double_t distVtx = 999.0;
1014 <              for(UInt_t nv=0; nv<fPV->GetEntries(); nv++){
1015 <                double dz = TMath::Abs(fLeptonTagElectrons->At(0)->GsfTrk()->DzCorrected(*fPV->At(nv)));
1016 <                if(dz < distVtx) {
1017 <                  distVtx    = dz;
1018 <                  closestVtx = nv;
1019 <                }
1020 <              }
1021 <              fDiphotonEvent-> eleIdMva = fElectronIDMVA->MVAValue(fLeptonTagElectrons->At(0), fPV->At(closestVtx));
1022 <            }
1023 <            
1024 <            //    fDiphotonEvent-> eleIso2 = ElectronTools::ElectronEffectiveArea(ElectronTools::kEleGammaIso03,fLeptonTagElectrons->At(0)->SCluster()->Eta(), ElectronTools::kEleEAData2012) + ElectronTools::ElectronEffectiveArea(ElectronTools::kEleNeutralHadronIso03, fLeptonTagElectrons->At(0)->SCluster()->Eta(), ElectronTools::kEleEAData2012) ;
1025 <            
1026 <            fDiphotonEvent-> eleIso3 = (fLeptonTagElectrons->At(0)->TrackIsolationDr03() + fLeptonTagElectrons->At(0)->EcalRecHitIsoDr03() + fLeptonTagElectrons->At(0)->HcalTowerSumEtDr03() - fPileUpDen->At(0)->RhoLowEta() * TMath::Pi() * 0.3 * 0.3)/fDiphotonEvent-> elePt;
1027 <            fDiphotonEvent-> eleIso4 = (fLeptonTagElectrons->At(0)->TrackIsolationDr03() + fLeptonTagElectrons->At(0)->EcalRecHitIsoDr03() + fLeptonTagElectrons->At(0)->HcalTowerSumEtDr03() - fPileUpDen->At(0)->Rho() * TMath::Pi() * 0.3 * 0.3)/fDiphotonEvent-> elePt;
1028 <            fDiphotonEvent-> eleDist = fLeptonTagElectrons->At(0)->ConvPartnerDist();
1029 <            fDiphotonEvent-> eleDcot = fLeptonTagElectrons->At(0)->ConvPartnerDCotTheta();
1030 <            fDiphotonEvent-> eleCoviee = fLeptonTagElectrons->At(0)->CoviEtaiEta();
1031 <            fDiphotonEvent-> eleDphiin = TMath::Abs(fLeptonTagElectrons->At(0)->DeltaPhiSuperClusterTrackAtVtx());
1032 <            fDiphotonEvent-> eleDetain = TMath::Abs(fLeptonTagElectrons->At(0)->DeltaEtaSuperClusterTrackAtVtx());
1033 <            fDiphotonEvent-> eleDR1 = MathUtils::DeltaR(fLeptonTagElectrons->At(0),phHard);
1034 <            fDiphotonEvent-> eleDR2 = MathUtils::DeltaR(fLeptonTagElectrons->At(0),phSoft);
1035 <            fDiphotonEvent-> eleMass1 = (phHard->Mom()+fLeptonTagElectrons->At(0)->Mom()).M();
1036 <            fDiphotonEvent-> eleMass2 = (phSoft->Mom()+fLeptonTagElectrons->At(0)->Mom()).M();
1037 <            fDiphotonEvent-> eleNinnerHits =      fLeptonTagElectrons->At(0)->Trk()->NExpectedHitsInner();
1038 <          }
1039 <        }
1040 <      }
1041 <    
1042 <      if(false){
1043 <        if(fDiphotonEvent->evt==79737729 || fDiphotonEvent->evt== 871378986  || fDiphotonEvent->evt==528937923 || fDiphotonEvent->evt== 261543921){
1044 <          printf("ming sync check ele:  run:%d  evt:%d  lumi:%d  leptonTag:%d  numelectrons:%d  idmva:%f  mass:%f\n  elePt:%f  eleEta:%f  eleSCEta:%f  vtx:%d\n",fDiphotonEvent->run,fDiphotonEvent->evt,fDiphotonEvent->lumi,fDiphotonEvent->leptonTag,fLeptonTagElectrons->GetEntries(),fDiphotonEvent->eleIdMva,_mass,fDiphotonEvent->elePt,fDiphotonEvent->eleEta,fDiphotonEvent->eleSCEta,closestVtx);
1045 <          //return;
1046 <        }
1047 <        if(fDiphotonEvent->evt==333643114 || fDiphotonEvent->evt==89022540 || fDiphotonEvent->evt==8983064 || fDiphotonEvent->evt==876316897 || fDiphotonEvent->evt==541603559  || fDiphotonEvent->evt==223740859) {
1048 <          printf("ming sync check muon:  run:%d  evt:%d  lumi:%d  leptonTag:%d  numMuons:%d  mass:%f\n  muonPt:%f  muonEta:%f\n\n",fDiphotonEvent->run,fDiphotonEvent->evt,fDiphotonEvent->lumi,fDiphotonEvent->leptonTag,fLeptonTagMuons->GetEntries(),_mass,fDiphotonEvent->muonPt,fDiphotonEvent->muonEta);
1049 <          //return;
1050 <        }
1051 <      }
938 >      ApplyLeptonTag(phHard, phSoft, selvtx);
939 >    }
940 >
941 >    if( fApplyLeptonTag2 ) {
942 >      ApplyLeptonTag2(phHard, phSoft, selvtx);
943      }
944 +      
945      //vbf tag
946      fDiphotonEvent->vbfTag = -1;
947      fDiphotonEvent->vbfbdt = -99;
# Line 1081 | Line 973 | void PhotonTreeWriter::Process()
973      fDiphotonEvent->tthTag = -1;
974      if (fApplyTTHTag && phHard && phSoft && selvtx) {
975        ApplyTTHTag(phHard, phSoft, selvtx);
1084      PrintTTHDebugInfo();
976      }
977      
978      //printf("vbfbdt:%f\n",fDiphotonEvent->vbfbdt);
# Line 1510 | Line 1401 | void PhotonTreeWriterPhoton<NClus>::SetV
1401      // -----------------------------------------------------
1402      // PF-CiC4 Debug Stuff
1403      std::vector<double> debugVals;
1513    // bool tmpPass = PhotonTools::PassCiCPFIsoSelection(p, vtx, fPFCands, vtxCol, rho, 20., &debugVals);
1404      PhotonTools::PassCiCPFIsoSelection(p, vtx, fPFCands, vtxCol, rho, 20., &debugVals);
1405      if( debugVals.size() == 13 ) {
1406        pfcic4_tIso1   = debugVals[0];
# Line 2262 | Line 2152 | void PhotonTreeWriterVtx::SetVars(const
2152  
2153  
2154   //_____________________________________________________________________________
2155 + void PhotonTreeWriter::ApplyLeptonTag(const Photon *phHard,
2156 +                                      const Photon *phSoft,
2157 +                                      const Vertex *selvtx)
2158 + {
2159 +  // perform flavor-based lepton tagging (used before the legacy paper of 2013)
2160 +  // the diphoton event record will have one more entry; i.e. leptonTag
2161 +  // leptonTag = -1   -> lepton-taggng was swicthed off
2162 +  //           =  0   -> event tagged as 'non-lepton-event'
2163 +  //           = +1   -> event tagged as muon-event
2164 +  //           = +2   -> event tagged as electron-event
2165 +  fDiphotonEvent->leptonTag = 0;
2166 +  Int_t closestVtx = 0;
2167 +  if ( fLeptonTagMuons->GetEntries() > 0 ) {
2168 +    // need to have dR > 1 for with respect to both photons ***changed to 0.7 for 2012
2169 +    if( (MathUtils::DeltaR(fLeptonTagMuons->At(0),phHard) >= 1.0) &&
2170 +        (MathUtils::DeltaR(fLeptonTagMuons->At(0),phSoft) >= 1.0)  
2171 +        ){
2172 +      
2173 +      fDiphotonEvent->leptonTag = 2;
2174 +      
2175 +      fDiphotonEvent-> muonPt  = fLeptonTagMuons->At(0)->Pt();
2176 +      fDiphotonEvent-> muonEta = fLeptonTagMuons->At(0)->Eta();
2177 +      fDiphotonEvent-> muDR1   = MathUtils::DeltaR(fLeptonTagMuons->At(0),phHard);
2178 +      fDiphotonEvent-> muDR2   = MathUtils::DeltaR(fLeptonTagMuons->At(0),phSoft);
2179 +      
2180 +      fDiphotonEvent-> muIso1   = (fLeptonTagMuons->At(0)->IsoR03SumPt() + fLeptonTagMuons->At(0)->IsoR03EmEt() + fLeptonTagMuons->At(0)->IsoR03HadEt() - fPileUpDen->At(0)->RhoRandomLowEta() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(0)->Pt();
2181 +      fDiphotonEvent-> muIso2   = (fLeptonTagMuons->At(0)->IsoR03SumPt() + fLeptonTagMuons->At(0)->IsoR03EmEt() + fLeptonTagMuons->At(0)->IsoR03HadEt() - fPileUpDen->At(0)->RhoRandom() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(0)->Pt();
2182 +      fDiphotonEvent-> muIso3   = (fLeptonTagMuons->At(0)->IsoR03SumPt() + fLeptonTagMuons->At(0)->IsoR03EmEt() + fLeptonTagMuons->At(0)->IsoR03HadEt() - fPileUpDen->At(0)->RhoLowEta() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(0)->Pt();
2183 +      fDiphotonEvent-> muIso4   = (fLeptonTagMuons->At(0)->IsoR03SumPt() + fLeptonTagMuons->At(0)->IsoR03EmEt() + fLeptonTagMuons->At(0)->IsoR03HadEt() - fPileUpDen->At(0)->Rho() * TMath::Pi() * 0.3 * 0.3)/ fLeptonTagMuons->At(0)->Pt();
2184 +      fDiphotonEvent-> muD0  = TMath::Abs(fLeptonTagMuons->At(0)->BestTrk()->D0Corrected(*fPV->At(0)));
2185 +      fDiphotonEvent-> muDZ  = TMath::Abs(fLeptonTagMuons->At(0)->BestTrk()->DzCorrected(*fPV->At(0)));
2186 +      fDiphotonEvent-> muChi2  = fLeptonTagMuons->At(0)->GlobalTrk()->Chi2()/fLeptonTagMuons->At(0)->GlobalTrk()->Ndof();
2187 +      
2188 +      fDiphotonEvent-> muNhits = fLeptonTagMuons->At(0)->BestTrk()->NHits();
2189 +      fDiphotonEvent-> muNpixhits = fLeptonTagMuons->At(0)->BestTrk()->NPixelHits();
2190 +      fDiphotonEvent-> muNegs = fLeptonTagMuons->At(0)->NSegments();
2191 +      fDiphotonEvent-> muNMatch = fLeptonTagMuons->At(0)->NMatches();
2192 +    }
2193 +  }
2194 +  
2195 +  if ( fDiphotonEvent->leptonTag < 1 && fLeptonTagElectrons->GetEntries() > 0 ) {
2196 +    if( (MathUtils::DeltaR(fLeptonTagElectrons->At(0),phHard) >= 1) &&
2197 +        (MathUtils::DeltaR(fLeptonTagElectrons->At(0),phSoft) >= 1) &&
2198 +        (PhotonTools::ElectronVetoCiC(phHard,fLeptonTagElectrons) >= 1) &&
2199 +        (PhotonTools::ElectronVetoCiC(phSoft,fLeptonTagElectrons) >= 1) &&
2200 +        (TMath::Abs( (phHard->Mom()+fLeptonTagElectrons->At(0)->Mom()).M()-91.19 ) >= 10) &&
2201 +        (TMath::Abs( (phSoft->Mom()+fLeptonTagElectrons->At(0)->Mom()).M()-91.19 ) >= 10)  
2202 +        //((phHard->Pt()/(phHard->Mom() + phSoft->Mom()).M())>(45./120.)) &&
2203 +        //((phSoft->Pt()/(phHard->Mom() + phSoft->Mom()).M())>(30./120.))){
2204 +        ){
2205 +      
2206 +      /*int ph1passeveto=1;
2207 +        int ph2passeveto=1;
2208 +        
2209 +        for(UInt_t k=0;k<fElectrons->GetEntries();k++){
2210 +        if(fElectrons->At(k)->BestTrk()->NMissingHits()==0){
2211 +        if((fElectrons->At(k)->SCluster()==phHard->SCluster()) && (MathUtils::DeltaR(*fElectrons->At(k)->BestTrk(),*phHard) < 1)){
2212 +        ph1passeveto=0;
2213 +        }
2214 +        if((fElectrons->At(k)->SCluster()==phSoft->SCluster()) && (MathUtils::DeltaR(*fElectrons->At(k)->BestTrk(),*phSoft) < 1)){
2215 +        ph2passeveto=0;
2216 +        }
2217 +        }
2218 +        }
2219 +        
2220 +        if(ph1passeveto==1 && ph2passeveto==1){*/
2221 +      
2222 +      if(PhotonTools::ElectronVetoCiC(phHard, fElectrons)>=1 && PhotonTools::ElectronVetoCiC(phSoft, fElectrons)>=1){
2223 +        
2224 +        fDiphotonEvent->leptonTag = 1;
2225 +        
2226 +        fDiphotonEvent-> elePt = fLeptonTagElectrons->At(0)->Pt();
2227 +        fDiphotonEvent-> eleEta = fLeptonTagElectrons->At(0)->Eta();
2228 +        fDiphotonEvent-> eleSCEta = fLeptonTagElectrons->At(0)->SCluster()->Eta();
2229 +        fDiphotonEvent-> eleIso1 = (fLeptonTagElectrons->At(0)->TrackIsolationDr03() + fLeptonTagElectrons->At(0)->EcalRecHitIsoDr03() + fLeptonTagElectrons->At(0)->HcalTowerSumEtDr03() - fPileUpDen->At(0)->RhoRandomLowEta() * TMath::Pi() * 0.3 * 0.3)/fDiphotonEvent-> elePt;
2230 +        
2231 +        fDiphotonEvent-> eleIso2 = -99.;
2232 +        
2233 +        if ( fDoSynching ) {
2234 +          Double_t distVtx = 999.0;
2235 +          for(UInt_t nv=0; nv<fPV->GetEntries(); nv++){
2236 +            double dz = TMath::Abs(fLeptonTagElectrons->At(0)->GsfTrk()->DzCorrected(*fPV->At(nv)));
2237 +            if(dz < distVtx) {
2238 +              distVtx    = dz;
2239 +              closestVtx = nv;
2240 +            }
2241 +          }
2242 +          fDiphotonEvent-> eleIdMva = fElectronIDMVA->MVAValue(fLeptonTagElectrons->At(0), fPV->At(closestVtx));
2243 +        }
2244 +        
2245 +        //        fDiphotonEvent-> eleIso2 = ElectronTools::ElectronEffectiveArea(ElectronTools::kEleGammaIso03,fLeptonTagElectrons->At(0)->SCluster()->Eta(), ElectronTools::kEleEAData2012) + ElectronTools::ElectronEffectiveArea(ElectronTools::kEleNeutralHadronIso03, fLeptonTagElectrons->At(0)->SCluster()->Eta(), ElectronTools::kEleEAData2012) ;
2246 +        
2247 +        fDiphotonEvent-> eleIso3 = (fLeptonTagElectrons->At(0)->TrackIsolationDr03() + fLeptonTagElectrons->At(0)->EcalRecHitIsoDr03() + fLeptonTagElectrons->At(0)->HcalTowerSumEtDr03() - fPileUpDen->At(0)->RhoLowEta() * TMath::Pi() * 0.3 * 0.3)/fDiphotonEvent-> elePt;
2248 +        fDiphotonEvent-> eleIso4 = (fLeptonTagElectrons->At(0)->TrackIsolationDr03() + fLeptonTagElectrons->At(0)->EcalRecHitIsoDr03() + fLeptonTagElectrons->At(0)->HcalTowerSumEtDr03() - fPileUpDen->At(0)->Rho() * TMath::Pi() * 0.3 * 0.3)/fDiphotonEvent-> elePt;
2249 +        fDiphotonEvent-> eleDist = fLeptonTagElectrons->At(0)->ConvPartnerDist();
2250 +        fDiphotonEvent-> eleDcot = fLeptonTagElectrons->At(0)->ConvPartnerDCotTheta();
2251 +        fDiphotonEvent-> eleCoviee = fLeptonTagElectrons->At(0)->CoviEtaiEta();
2252 +        fDiphotonEvent-> eleDphiin = TMath::Abs(fLeptonTagElectrons->At(0)->DeltaPhiSuperClusterTrackAtVtx());
2253 +        fDiphotonEvent-> eleDetain = TMath::Abs(fLeptonTagElectrons->At(0)->DeltaEtaSuperClusterTrackAtVtx());
2254 +        fDiphotonEvent-> eleDR1 = MathUtils::DeltaR(fLeptonTagElectrons->At(0),phHard);
2255 +        fDiphotonEvent-> eleDR2 = MathUtils::DeltaR(fLeptonTagElectrons->At(0),phSoft);
2256 +        fDiphotonEvent-> eleMass1 = (phHard->Mom()+fLeptonTagElectrons->At(0)->Mom()).M();
2257 +        fDiphotonEvent-> eleMass2 = (phSoft->Mom()+fLeptonTagElectrons->At(0)->Mom()).M();
2258 +        fDiphotonEvent-> eleNinnerHits =      fLeptonTagElectrons->At(0)->Trk()->NExpectedHitsInner();
2259 +      }
2260 +    }
2261 +  }
2262 +  
2263 +  if(false){
2264 +    if(fDiphotonEvent->evt==79737729 || fDiphotonEvent->evt== 871378986  || fDiphotonEvent->evt==528937923 || fDiphotonEvent->evt== 261543921){
2265 +      printf("ming sync check ele:  run:%d  evt:%d  lumi:%d  leptonTag:%d  numelectrons:%d  idmva:%f  mass:%f\n  elePt:%f  eleEta:%f  eleSCEta:%f  vtx:%d\n",fDiphotonEvent->run,fDiphotonEvent->evt,fDiphotonEvent->lumi,fDiphotonEvent->leptonTag,fLeptonTagElectrons->GetEntries(),fDiphotonEvent->eleIdMva,fDiphotonEvent->mass,fDiphotonEvent->elePt,fDiphotonEvent->eleEta,fDiphotonEvent->eleSCEta,closestVtx);
2266 +      //return;
2267 +    }
2268 +    if(fDiphotonEvent->evt==333643114 || fDiphotonEvent->evt==89022540 || fDiphotonEvent->evt==8983064 || fDiphotonEvent->evt==876316897 || fDiphotonEvent->evt==541603559  || fDiphotonEvent->evt==223740859) {
2269 +      printf("ming sync check muon:  run:%d  evt:%d  lumi:%d  leptonTag:%d  numMuons:%d  mass:%f\n  muonPt:%f  muonEta:%f\n\n",fDiphotonEvent->run,fDiphotonEvent->evt,fDiphotonEvent->lumi,fDiphotonEvent->leptonTag,fLeptonTagMuons->GetEntries(),fDiphotonEvent->mass,fDiphotonEvent->muonPt,fDiphotonEvent->muonEta);
2270 +      //return;
2271 +    }
2272 +  }
2273 + } // void PhotonTreeWriter::ApplyLeptonTag(..)
2274 +
2275 +
2276 + //_____________________________________________________________________________
2277 + void PhotonTreeWriter::ApplyLeptonTag2(const Photon *phHard,
2278 +                                       const Photon *phSoft,
2279 +                                       const Vertex *selvtx)
2280 + {
2281 +  
2282 +  // perform flavor-based lepton tagging (used since the legacy paper of 2013)
2283 +  // the diphoton event record will have one more entry; i.e. leptonTag
2284 +  // leptonTag2 = -1   -> lepton-taggng was swicthed off
2285 +  //            =  0   -> event tagged as 'non-lepton-event'
2286 +  //            = +1   -> event tagged as a high-MET high-S/sqrt(B) event
2287 +  //            = +2   -> event tagged as a low-MET low-S/sqrt(B) event
2288 +
2289 +  if (fDiphotonEvent->leptonTag < 0) {
2290 +    ApplyLeptonTag(phHard, phSoft, selvtx);
2291 +  }
2292 +
2293 +  switch (fDiphotonEvent->leptonTag) {
2294 +    case 0:
2295 +      fDiphotonEvent->leptonTag2 = 0;
2296 +      break;
2297 +    case 1:
2298 +    case 2:
2299 +      // TODO: find reference for the MET cut value
2300 +      if (fDiphotonEvent->corrpfmet > 45.) {
2301 +        fDiphotonEvent->leptonTag2 = 1;
2302 +      } else {
2303 +        fDiphotonEvent->leptonTag2 = 2;
2304 +      } // if (MET < 45.)
2305 +      break;
2306 +    default:
2307 +      // this should never happen!
2308 +      cout << "Illegal value of leptonTag=" << fDiphotonEvent->leptonTag
2309 +           << endl << flush;
2310 +      assert(false);
2311 +  }  // switch(leptonTag)
2312 +
2313 + } // void PhotonTreeWriter::ApplyLeptonTag2(..)
2314 +
2315 +
2316 + //_____________________________________________________________________________
2317   // Applies the ttH tag given precelected leading and trailing photons
2318   // phHard and phSoft and the corresponding (pre?) selected vertex selvtx.
2319   // The result is stored as an integer value of the tthTag variable
# Line 2276 | Line 2328 | void PhotonTreeWriter::ApplyTTHTag(const
2328    //            2 .. tagged as a hadronic ttH event
2329    fDiphotonEvent->tthTag = 0;
2330    
2331 <  // The selection taken from the AN2012_480_V6 of 24 April 2013, further
2332 <  // referred to as "the AN", and the approval slides at
2281 <  // https://twiki.cern.ch/twiki/pub/CMS/JanVeverkaHgg/micheli_ttH_approval_20130508_2_reduced.pdf,
2282 <  // further referred to as "the slides" or "the slide n" (n = 1, 2, ..)
2331 >  // Selection taken from the AN2012_480_V6 of 24 April 2013, further
2332 >  // refferred to as "the AN"
2333  
2334    // Check the pt of the photons, see L141 and L142 of the AN
2335 <  if (fDiphotonEvent->photons[0].Pt() < 33.) return;
2336 <  if (fDiphotonEvent->photons[1].Pt() < 25.) return;
2335 >  if (phHard->Pt() < 33.) return;
2336 >  if (phSoft->Pt() < 25.) return;
2337  
2338    // Init final-state object counters
2339    UInt_t nJets = 0;
# Line 2291 | Line 2341 | void PhotonTreeWriter::ApplyTTHTag(const
2341    UInt_t nElectrons = 0;
2342    UInt_t nMuons = 0;
2343      
2294  // Get the selected vertex
2295  
2344    // Loop over jets, count those passing selection.
2345    // No Delta R(gamma, j) requirement!?  
2346    for(UInt_t ijet=0; ijet < fPFJets->GetEntries(); ++ijet){
# Line 2302 | Line 2350 | void PhotonTreeWriter::ApplyTTHTag(const
2350      // Make sure we have a PF jet
2351      const PFJet *pfjet = dynamic_cast<const PFJet*>(jet);
2352      if (!pfjet) continue;
2305    // TODO: Assume that this is implicitly implied in the AN,
2306    // copied from JetIDMVA::passCut(...). Is this correct?
2307    // (Aram & Valentina say so)
2353      if (!JetTools::passPFLooseId(pfjet)) continue;
2354      // Apply the jet ID as given in Table 4
2310    // TODO: JetTools::betaStar or JetTools::betaStarClassic? (yes, classic)
2311    // Go for the latter now as it is used in the JetIDMVA::passCut(..) which in turn
2312    // is used for the VBF tag.
2355      Double_t betaStar = JetTools::betaStarClassic(pfjet, selvtx, fPV);
2356 <    // TODO: Really 0.67? JetIDMVA::passCut(..) and AN-13-008 use 0.64 insted.
2315 <    if (betaStar > 0.2 * log(fPV->GetEntries() - 0.67)) continue;
2316 <    // TODO: is the second argument iPFType = -1 correct? yes
2356 >    if (betaStar > 0.2 * log(fPV->GetEntries() - 0.64)) continue;
2357      if (JetTools::dR2Mean(pfjet, -1) > 0.065) continue;
2358      // this jet passes, count it in
2359      ++nJets;
2360 +    // Select b-jets that pass the CSV medium working point, see L128 of the AN
2361 +    // and https://twiki.cern.ch/twiki/bin/viewauth/CMS/BTagPerformanceOP
2362 +    if (jet->CombinedSecondaryVertexBJetTagsDisc() < 0.679) continue;
2363 +    ++nBJets;
2364    } // End of loop over jets
2365    
2366    // Check the number of selected jets, see Table 7 near L196 of the AN
2367    if (nJets < 2) return;
2368    
2325  // Loop over jets again and count those that pass the b-tag defined as the
2326  // CSV medium working point, see L128 of the AN
2327  // and https://twiki.cern.ch/twiki/bin/viewauth/CMS/BTagPerformanceOP
2328  // TODO: Are there any other cuts applied to the b-jet candidates beyond the
2329  for(UInt_t ijet=0; ijet < fPFJets->GetEntries(); ++ijet){
2330    // Assume that this is implicitly used in the AN.    
2331    // (Aram & Valentina say so)
2332
2333    // Make sure we have a PF jet
2334    const Jet *jet = fPFJets->At(ijet);
2335    if (jet->Pt() < 20. || jet->AbsEta() > 2.4) continue;
2336    const PFJet *pfjet = dynamic_cast<const PFJet*>(jet);
2337    if (!pfjet) continue;
2338    if (!JetTools::passPFLooseId(pfjet)) continue;
2339    // This is explicit in the AN.
2340    if (jet->CombinedSecondaryVertexBJetTagsDisc() < 0.679) continue;
2341    // TODO: It could be also the MVA flavor of the CSV:
2342    // if (jet->CombinedSecondaryVertexMVABJetTagsDisc() < 0.679) continue;
2343    // Which one is the correct one?
2344    ++nBJets;
2345  } // End of the loop over jets
2346  
2369    // Check the number of b-tagged jets, see Table 7 near L196 of the AN
2370    if (nBJets < 1) return;
2371  
# Line 2351 | Line 2373 | void PhotonTreeWriter::ApplyTTHTag(const
2373    for (UInt_t iele=0; iele < fLeptonTagElectrons->GetEntries(); ++iele) {
2374      const Electron *ele = fLeptonTagElectrons->At(iele);
2375      // Apply kinematic cuts, see L133 and L134 of the AN
2376 <    if (ele->Pt() < 20. || ele->AbsEta() > 2.5) continue;
2355 <    // Require separation between this electron and both photons,
2356 <    // see the slide 7, bullet 5
2357 <    if (MathUtils::DeltaR(ele, phHard) < 1.0) continue;
2358 <    if (MathUtils::DeltaR(ele, phSoft) < 1.0) continue;
2376 >    if (ele->Pt() < 20. || ele->AbsEta() < 2.5) continue;
2377      ++nElectrons;
2378    }
2379    
# Line 2364 | Line 2382 | void PhotonTreeWriter::ApplyTTHTag(const
2382      const Muon *mu = fLeptonTagMuons->At(imu);
2383      // Apply kinematic cuts, see L132 and L134 of the AN
2384      if (mu->Pt() < 20. || mu->AbsEta() > 2.4) continue;
2385 <    // Require separation between this electron and both photons,
2385 >    // Require separation between this muon and both photons,
2386      // see the slide 7, bullet 2
2387 <    // TODO: Check with authors that this is indeed applied.
2387 >    // Also confirmed by Francesco Micheli in an e-mail from 15 July 2013
2388      if (MathUtils::DeltaR(mu, phHard) < 1.0) continue;
2389      if (MathUtils::DeltaR(mu, phSoft) < 1.0) continue;
2390      ++nMuons;
2391    }
2392  
2393    // Check the lepton tag, see Table 7 near L196 of the AN
2394 <  // TODO: Does the leptonic tag have a precedence if both the leptonic and
2395 <  // hadronic tags pass?
2394 >  // It has a precedence if both the leptonic and hadronic tags pass.
2395 >  // (private e-mail from Francesco Micheli on 15 July 2013).
2396    if (nElectrons + nMuons >= 1) {
2397      // apply the leptonic tth tag
2398      fDiphotonEvent->tthTag = 1;
# Line 2398 | Line 2416 | void PhotonTreeWriter::Terminate()
2416   }
2417  
2418  
2401 //_____________________________________________________________________________
2402 void PhotonTreeWriter::PrintTTHDebugInfo()
2403 {
2404  if (fVerbosityLevel > 0) {
2405    cout << "JV: Processing run " << fDiphotonEvent->run
2406          << " event " << fDiphotonEvent->evt << " .. " << endl;
2407    PrintTTHDecay();
2408  }
2409
2410  if (fVerbosityLevel > 1) {
2411    PrintGenElectrons();
2412    PrintElectrons("reco electrons", fElectrons);
2413    PrintElectrons("lepton-tag electrons", fLeptonTagElectrons);
2414  }
2415 } // void PhotonTreeWriter::PrintTTHDebugInfo()
2416
2417
2418 //_____________________________________________________________________________
2419 void PhotonTreeWriter::PrintTTHDecay()
2420 {
2421  // Initialize W decay type counters
2422  UInt_t nLeptonic = 0;
2423  UInt_t nHadronic = 0;
2424  Int_t WplusDau1PID = 0;
2425  Int_t WminusDau1PID = 0;
2426  // loop over all GEN particles and look for W bosons
2427  for(UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
2428    const MCParticle* p = fMCParticles->At(i);
2429    if (p->Is(MCParticle::kW) && p->Status() == 3 && p->NDaughters() > 0) {
2430      // found a W in the ME
2431      cout << "JV: " << p->PdgEntry()->GetName()
2432           << "[" << i << "] -> ";
2433
2434      // Set the PID of the first daughter
2435      if (p->PdgId() > 0) {
2436        WplusDau1PID = p->Daughter(0)->PdgId();
2437      } else {
2438        WminusDau1PID = p->Daughter(0)->PdgId();
2439      }
2440
2441      // loop over W daughters
2442      for (UInt_t j=0; j < p->NDaughters(); ++j) {
2443        const MCParticle *d = p->Daughter(j);
2444        if (d->Status() == 2) continue;
2445        cout << d->PdgEntry()->GetName() << " ";
2446      } // loop over W daughters
2447      cout << endl;
2448
2449      // Check the decay type    
2450      if (p->NDaughters() > 0 && p->Daughter(0)->IsQuark()) {
2451        ++nHadronic;
2452      } else {
2453        ++nLeptonic;
2454      }
2455    } // found the W
2456  } // loop over all GEN particles
2457  
2458  cout << "JV: ttbar decay is ";
2459  switch (nHadronic) {
2460    case 0: cout << "leptonic"; break;
2461    case 1: cout << "semi-leptonic"; break;
2462    case 2: cout << "hadronic"; break;
2463    default: cout << "ERROR";
2464  }
2465  cout << endl;
2466  
2467  cout << "JV: tthTag WplusDau1PID WminusDau1PID:\t"
2468       << fDiphotonEvent->tthTag << "\t"
2469       << WplusDau1PID << "\t"
2470       << WminusDau1PID << endl;
2471  return;
2472 } // void PrintTTHDecay()
2473
2474
2475 //_____________________________________________________________________________
2476 void PhotonTreeWriter::PrintGenElectrons()
2477 {
2478  ostringstream report;
2479  report << "JV: gen electrons" << endl;
2480  UInt_t nEl = 0;
2481  for (UInt_t i=0; i < fMCParticles->GetEntries(); ++i){
2482    const MCParticle *p = fMCParticles->At(i);
2483    if (p->Is(MCParticle::kEl) &&
2484        p->Status() == 1 &&
2485        p->Pt() > 15 &&
2486        p->AbsEta() < 2.6) {
2487      ++nEl;
2488      report << "  " << p->PdgEntry()->GetName() << ": "
2489             << "pt=" << p->Pt() << ", "
2490             << "eta=" << p->AbsEta() << endl;
2491    } // Electron preselection
2492  } // End of loop over MC particles
2493  if (nEl > 0) cout << report.str();
2494 } // void PhotonTreeWriter::PrintGenElectrons()
2495
2496
2497 //_____________________________________________________________________________
2498 void PhotonTreeWriter::PrintElectrons(const char *tag,
2499                                      const ElectronCol *electrons)
2500 {
2501  ostringstream report;
2502  report << "JV: " << tag << endl;
2503  UInt_t nEl = 0;
2504  for (UInt_t i=0; i < electrons->GetEntries(); ++i){
2505    const Electron *e = electrons->At(i);
2506    if (e->Pt() > 20 && e->AbsEta() < 2.5) {
2507      ++nEl;
2508      report << "  q=" << e->Charge() << ", "
2509             << "pt=" << e->Pt() << ", "
2510             << "eta=" << e->AbsEta() << endl;
2511    } // Electron preselection
2512  } // End of loop over reco electrons
2513  if (nEl > 0) cout << report.str();
2514 } // void PhotonTreeWriter::PrintRecoElectrons()
2515
2419  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines