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.50 by veverka, Fri Aug 30 23:25:24 2013 UTC vs.
Revision 1.51 by veverka, Sat Aug 31 05:37:04 2013 UTC

# Line 52 | Line 52 | PhotonTreeWriter::PhotonTreeWriter(const
52    fGenJetName             ("AKT5GenJets"),
53    fLeptonTagElectronsName ("HggLeptonTagElectrons"),
54    fLeptonTagMuonsName     ("HggLeptonTagMuons"),
55 +  fLeptonTagSoftElectronsName ("HggLeptonTagSoftElectrons"),
56 +  fLeptonTagSoftMuonsName     ("HggLeptonTagSoftMuons"),
57  
58    fIsData                 (false),
59    fPhotonsFromBranch      (kTRUE),  
# Line 99 | Line 101 | PhotonTreeWriter::PhotonTreeWriter(const
101    fEnableGenJets          (kFALSE),
102    fApplyJetId             (kFALSE),
103    fApplyLeptonTag         (kFALSE),
104 <  fApplyLeptonTag2        (kFALSE),
104 >  fApplyVHLepTag        (kFALSE),
105    fApplyVBFTag            (kFALSE),
106    fApplyTTHTag            (kFALSE),
107    fApplyBTag              (kFALSE),
# Line 112 | Line 114 | PhotonTreeWriter::PhotonTreeWriter(const
114                             TString("/src/MitPhysics/data/PhotonFixSTART42V13.dat")),
115    fBeamspotWidth          (5.8),
116    fTmpFile                (0),
117 <
117 >  
118    // JV: moved up the initializtion of fTupleName to avoid compilation warning
119    fTupleName              ("hPhotonTree"),
120  
# Line 156 | Line 158 | void PhotonTreeWriter::Process()
158    LoadEventObject(fGoodElectronName,   fGoodElectrons);
159  
160    // lepton tag collections
161 <  if( fApplyLeptonTag || fApplyLeptonTag2 ) {
161 >  if( fApplyLeptonTag || fApplyVHLepTag ) {
162      LoadEventObject(fLeptonTagElectronsName, fLeptonTagElectrons);
163      LoadEventObject(fLeptonTagMuonsName,     fLeptonTagMuons);
164    }
165 <
165 >  
166 >  if( fApplyVHLepTag ) {
167 >    LoadEventObject(fLeptonTagSoftElectronsName, fLeptonTagSoftElectrons);
168 >    LoadEventObject(fLeptonTagSoftMuonsName,     fLeptonTagSoftMuons);
169 >  }
170 >  
171    const BaseCollection *egcol = 0;
172    if (fLoopOnGoodElectrons)
173      egcol = fGoodElectrons;
# Line 243 | Line 250 | void PhotonTreeWriter::Process()
250    Double_t _spfMet = fPFMet->At(0)->SumEt();
251  
252    fDiphotonEvent->leptonTag = -1; // disabled
253 <  fDiphotonEvent->leptonTag2 = -1; // disabled
253 >  fDiphotonEvent->VHLepTag = -1; // disabled
254  
255    // ====================================================
256    // Vtx synching stuff...
# Line 938 | Line 945 | void PhotonTreeWriter::Process()
945        ApplyLeptonTag(phHard, phSoft, selvtx);
946      }
947  
948 <    if( fApplyLeptonTag2 ) {
949 <      ApplyLeptonTag2(phHard, phSoft, selvtx);
948 >    if( fApplyVHLepTag ) {
949 >      ApplyVHLepTag(phHard, phSoft, selvtx);
950      }
951        
952      //vbf tag
# Line 1057 | Line 1064 | void PhotonTreeWriter::SlaveBegin()
1064    // Run startup code on the computer (slave) doing the actual analysis. Here,
1065    // we just request the photon collection branch.
1066  
1067 <  if( fApplyLeptonTag ) {
1067 >  if( fApplyLeptonTag || fApplyVHLepTag ) {
1068      ReqEventObject(fLeptonTagElectronsName,    fLeptonTagElectrons,    false);  
1069      ReqEventObject(fLeptonTagMuonsName,        fLeptonTagMuons,        false);  
1070    }
1071  
1072 +  if( fApplyVHLepTag ) {
1073 +    ReqEventObject(fLeptonTagSoftElectronsName,    fLeptonTagSoftElectrons,    false);  
1074 +    ReqEventObject(fLeptonTagSoftMuonsName,        fLeptonTagSoftMuons,        false);  
1075 +  }
1076 +
1077   //   ReqEventObject(fPFNoPileUpName,     fPFNoPileUpCands,    false);
1078   //   ReqEventObject(fPFPileUpName,     fPFPileUpCands,    false);
1079  
# Line 2164 | Line 2176 | void PhotonTreeWriter::ApplyLeptonTag(co
2176    //           = +2   -> event tagged as electron-event
2177    fDiphotonEvent->leptonTag = 0;
2178    Int_t closestVtx = 0;
2179 <  if ( fLeptonTagMuons->GetEntries() > 0 ) {
2180 <    // need to have dR > 1 for with respect to both photons ***changed to 0.7 for 2012
2181 <    if( (MathUtils::DeltaR(fLeptonTagMuons->At(0),phHard) >= 1.0) &&
2182 <        (MathUtils::DeltaR(fLeptonTagMuons->At(0),phSoft) >= 1.0)  
2183 <        ){
2184 <      
2185 <      fDiphotonEvent->leptonTag = 2;
2186 <      
2187 <      fDiphotonEvent-> muonPt  = fLeptonTagMuons->At(0)->Pt();
2188 <      fDiphotonEvent-> muonEta = fLeptonTagMuons->At(0)->Eta();
2189 <      fDiphotonEvent-> muDR1   = MathUtils::DeltaR(fLeptonTagMuons->At(0),phHard);
2190 <      fDiphotonEvent-> muDR2   = MathUtils::DeltaR(fLeptonTagMuons->At(0),phSoft);
2191 <      
2192 <      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();
2193 <      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();
2194 <      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();
2195 <      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();
2196 <      fDiphotonEvent-> muD0  = TMath::Abs(fLeptonTagMuons->At(0)->BestTrk()->D0Corrected(*fPV->At(0)));
2197 <      fDiphotonEvent-> muDZ  = TMath::Abs(fLeptonTagMuons->At(0)->BestTrk()->DzCorrected(*fPV->At(0)));
2198 <      fDiphotonEvent-> muChi2  = fLeptonTagMuons->At(0)->GlobalTrk()->Chi2()/fLeptonTagMuons->At(0)->GlobalTrk()->Ndof();
2199 <      
2200 <      fDiphotonEvent-> muNhits = fLeptonTagMuons->At(0)->BestTrk()->NHits();
2201 <      fDiphotonEvent-> muNpixhits = fLeptonTagMuons->At(0)->BestTrk()->NPixelHits();
2202 <      fDiphotonEvent-> muNegs = fLeptonTagMuons->At(0)->NSegments();
2203 <      fDiphotonEvent-> muNMatch = fLeptonTagMuons->At(0)->NMatches();
2204 <    }
2205 <  }
2206 <  
2207 <  if ( fDiphotonEvent->leptonTag < 1 && fLeptonTagElectrons->GetEntries() > 0 ) {
2208 <    if( (MathUtils::DeltaR(fLeptonTagElectrons->At(0),phHard) >= 1) &&
2209 <        (MathUtils::DeltaR(fLeptonTagElectrons->At(0),phSoft) >= 1) &&
2210 <        (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));
2179 >  const Muon *muon = GetLeptonTagMuon(phHard, phSoft);
2180 >  if (muon) {
2181 >    // muon tagged
2182 >    fDiphotonEvent->leptonTag = 2;
2183 >    SetLeptonTagMuonVars(phHard, phSoft, muon);
2184 >  }
2185 >  
2186 >  const Electron *electron = 0;
2187 >  if (fDiphotonEvent->leptonTag < 1) {
2188 >    electron = GetLeptonTagElectron(phHard, phSoft);
2189 >  }
2190 >  
2191 >  if (electron &&
2192 >      MassOfPairIsWithinWindowAroundMZ(phHard, electron, 10) == false &&
2193 >      MassOfPairIsWithinWindowAroundMZ(phSoft, electron, 10) == false) {
2194 >    // electron tagged
2195 >    fDiphotonEvent->leptonTag = 1;
2196 >    
2197 >    fDiphotonEvent-> elePt = fLeptonTagElectrons->At(0)->Pt();
2198 >    fDiphotonEvent-> eleEta = fLeptonTagElectrons->At(0)->Eta();
2199 >    fDiphotonEvent-> eleSCEta = fLeptonTagElectrons->At(0)->SCluster()->Eta();
2200 >    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;
2201 >    
2202 >    fDiphotonEvent-> eleIso2 = -99.;
2203 >    
2204 >    if ( fDoSynching ) {
2205 >      Double_t distVtx = 999.0;
2206 >      for(UInt_t nv=0; nv<fPV->GetEntries(); nv++){
2207 >        double dz = TMath::Abs(fLeptonTagElectrons->At(0)->GsfTrk()->DzCorrected(*fPV->At(nv)));
2208 >        if(dz < distVtx) {
2209 >          distVtx    = dz;
2210 >          closestVtx = nv;
2211          }
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();
2212        }
2213 +      fDiphotonEvent-> eleIdMva = fElectronIDMVA->MVAValue(fLeptonTagElectrons->At(0), fPV->At(closestVtx));
2214      }
2215 <  }
2215 >    
2216 >    
2217 >    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;
2218 >    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;
2219 >    fDiphotonEvent-> eleDist = fLeptonTagElectrons->At(0)->ConvPartnerDist();
2220 >    fDiphotonEvent-> eleDcot = fLeptonTagElectrons->At(0)->ConvPartnerDCotTheta();
2221 >    fDiphotonEvent-> eleCoviee = fLeptonTagElectrons->At(0)->CoviEtaiEta();
2222 >    fDiphotonEvent-> eleDphiin = TMath::Abs(fLeptonTagElectrons->At(0)->DeltaPhiSuperClusterTrackAtVtx());
2223 >    fDiphotonEvent-> eleDetain = TMath::Abs(fLeptonTagElectrons->At(0)->DeltaEtaSuperClusterTrackAtVtx());
2224 >    fDiphotonEvent-> eleDR1 = MathUtils::DeltaR(fLeptonTagElectrons->At(0),phHard);
2225 >    fDiphotonEvent-> eleDR2 = MathUtils::DeltaR(fLeptonTagElectrons->At(0),phSoft);
2226 >    fDiphotonEvent-> eleMass1 = (phHard->Mom()+fLeptonTagElectrons->At(0)->Mom()).M();
2227 >    fDiphotonEvent-> eleMass2 = (phSoft->Mom()+fLeptonTagElectrons->At(0)->Mom()).M();
2228 >    fDiphotonEvent-> eleNinnerHits =      fLeptonTagElectrons->At(0)->Trk()->NExpectedHitsInner();
2229 >  } // electron tagged
2230    
2231    if(false){
2232      if(fDiphotonEvent->evt==79737729 || fDiphotonEvent->evt== 871378986  || fDiphotonEvent->evt==528937923 || fDiphotonEvent->evt== 261543921){
# Line 2274 | Line 2242 | void PhotonTreeWriter::ApplyLeptonTag(co
2242  
2243  
2244   //_____________________________________________________________________________
2245 < void PhotonTreeWriter::ApplyLeptonTag2(const Photon *phHard,
2246 <                                       const Photon *phSoft,
2247 <                                       const Vertex *selvtx)
2245 > const Muon* PhotonTreeWriter::GetLeptonTagMuon(const Photon *phHard,
2246 >                                               const Photon *phSoft)
2247 > {
2248 >  // need to have dR > 1 for with respect to both photons ***changed to 0.7 for 2012
2249 >  if (fLeptonTagMuons->GetEntries() > 0                       &&
2250 >      fLeptonTagMuons->At(0) != 0                             &&
2251 >      MathUtils::DeltaR(fLeptonTagMuons->At(0), phHard) >= 1.0 &&
2252 >      MathUtils::DeltaR(fLeptonTagMuons->At(0), phSoft) >= 1.0) {
2253 >    return fLeptonTagMuons->At(0);
2254 >  } else {
2255 >    return 0;
2256 >  }
2257 > } // const Muon* PhotonTreeWriter::GetLeptonTagMuon(..)
2258 >  
2259 >  
2260 > //_____________________________________________________________________________
2261 > void PhotonTreeWriter::SetLeptonTagMuonVars(const Photon *phHard,
2262 >                                            const Photon *phSoft,
2263 >                                            const Muon *muon)
2264 > {
2265 >  fDiphotonEvent-> muonPt  = muon->Pt();
2266 >  fDiphotonEvent-> muonEta = muon->Eta();
2267 >  fDiphotonEvent-> muDR1   = MathUtils::DeltaR(muon, phHard);
2268 >  fDiphotonEvent-> muDR2   = MathUtils::DeltaR(muon, phSoft);
2269 >  
2270 >  Float_t combinedIso = (muon->IsoR03SumPt() +
2271 >                         muon->IsoR03EmEt() +
2272 >                         muon->IsoR03HadEt());
2273 >  
2274 >  Float_t coneArea = TMath::Pi() * 0.3 * 0.3;
2275 >  
2276 >  Float_t rho1 = fPileUpDen->At(0)->RhoRandomLowEta();
2277 >  Float_t rho2 = fPileUpDen->At(0)->RhoRandom();
2278 >  Float_t rho3 = fPileUpDen->At(0)->RhoLowEta();
2279 >  Float_t rho4 = fPileUpDen->At(0)->Rho();
2280 >  
2281 >  fDiphotonEvent-> muIso1 = (combinedIso - rho1 * coneArea) / muon->Pt();
2282 >  fDiphotonEvent-> muIso2 = (combinedIso - rho2 * coneArea) / muon->Pt();
2283 >  fDiphotonEvent-> muIso3 = (combinedIso - rho3 * coneArea) / muon->Pt();
2284 >  fDiphotonEvent-> muIso4 = (combinedIso - rho4 * coneArea) / muon->Pt();
2285 >  
2286 >  fDiphotonEvent-> muD0  = TMath::Abs(muon->BestTrk()->D0Corrected(*fPV->At(0)));
2287 >  fDiphotonEvent-> muDZ  = TMath::Abs(muon->BestTrk()->DzCorrected(*fPV->At(0)));
2288 >  fDiphotonEvent-> muChi2  = muon->GlobalTrk()->Chi2()/muon->GlobalTrk()->Ndof();
2289 >  
2290 >  fDiphotonEvent-> muNhits = muon->BestTrk()->NHits();
2291 >  fDiphotonEvent-> muNpixhits = muon->BestTrk()->NPixelHits();
2292 >  fDiphotonEvent-> muNegs = muon->NSegments();
2293 >  fDiphotonEvent-> muNMatch = muon->NMatches();
2294 > } // void PhotonTreeWriter::SetLeptonTagMuonVars(..)
2295 >
2296 >
2297 > //_____________________________________________________________________________
2298 > const Electron* PhotonTreeWriter::GetLeptonTagElectron(const Photon *phHard,
2299 >                                                       const Photon *phSoft)
2300 > {
2301 >  // need to have dR > 1 for with respect to both photons ***changed to 0.7 for 2012
2302 >  if (fLeptonTagElectrons->GetEntries() > 0                          &&
2303 >      fLeptonTagElectrons->At(0) != 0                                &&
2304 >      PhotonTools::ElectronVetoCiC(phHard, fLeptonTagElectrons) >= 1 &&
2305 >      PhotonTools::ElectronVetoCiC(phSoft, fLeptonTagElectrons) >= 1 &&
2306 >      PhotonTools::ElectronVetoCiC(phHard, fElectrons) >= 1          &&
2307 >      PhotonTools::ElectronVetoCiC(phSoft, fElectrons) >= 1          &&    
2308 >      MathUtils::DeltaR(fLeptonTagElectrons->At(0), phHard) >= 1     &&
2309 >      MathUtils::DeltaR(fLeptonTagElectrons->At(0), phSoft) >= 1){
2310 >    return fLeptonTagElectrons->At(0);
2311 >  } else {
2312 >    return 0;
2313 >  }
2314 > } // const Electron* PhotonTreeWriter::GetLeptonTagElectron(..)
2315 >
2316 >  
2317 > //_____________________________________________________________________________
2318 > bool PhotonTreeWriter::MassOfPairIsWithinWindowAroundMZ(
2319 >  const Particle * particle1,
2320 >  const Particle * particle2,
2321 >  Float_t halfWindowSize,
2322 >  Float_t MZ
2323 > ) {
2324 >  Float_t mass = (particle1->Mom() + particle2->Mom()).M();
2325 >  return TMath::Abs(mass - MZ) < halfWindowSize;
2326 > } // bool PhotonTreeWriter::MassOfPairIsWithinWindowAroundMZ(..)
2327 >
2328 >
2329 > //_____________________________________________________________________________
2330 > void PhotonTreeWriter::ApplyVHLepTag(const Photon *phHard,
2331 >                                     const Photon *phSoft,
2332 >                                     const Vertex *selvtx)
2333   {
2334    
2335    // perform flavor-based lepton tagging (used since the legacy paper of 2013)
2336    // the diphoton event record will have one more entry; i.e. leptonTag
2337 <  // leptonTag2 = -1   -> lepton-taggng was swicthed off
2338 <  //            =  0   -> event tagged as 'non-lepton-event'
2339 <  //            = +1   -> event tagged as a high-MET high-S/sqrt(B) event
2340 <  //            = +2   -> event tagged as a low-MET low-S/sqrt(B) event
2341 <
2337 >  // VHLepTag = -1   -> lepton-taggng was swicthed off
2338 >  //            =  0   -> event tagged as 'non-lepton event'
2339 >  //            = +1   -> event tagged as a low-MET high-S/sqrt(B) event
2340 >  //            = +2   -> event tagged as a high-MET low-S/sqrt(B) event
2341 >  // TODO: Set the selected vertex to the lepton vertex if tagged as a
2342 >  //       VH(lep) event.
2343 >  
2344 >  fDiphotonEvent->VHLepTag = 0; // non-lepton event
2345 >  
2346 >  if (VHHasDielectron(phHard, phSoft)) {
2347 >    fDiphotonEvent->VHLepTag = 2; // high MET
2348 >    return;
2349 >  }
2350 >  
2351 >  if (VHHasDimuon(phHard, phSoft)) {
2352 >    fDiphotonEvent->VHLepTag = 2; // high MET
2353 >    return;
2354 >  }
2355 >  
2356    if (fDiphotonEvent->leptonTag < 0) {
2357      ApplyLeptonTag(phHard, phSoft, selvtx);
2358    }
2359  
2360 <  switch (fDiphotonEvent->leptonTag) {
2361 <    case 0:
2362 <      fDiphotonEvent->leptonTag2 = 0;
2363 <      break;
2364 <    case 1:
2365 <    case 2:
2366 <      // TODO: find reference for the MET cut value
2367 <      if (fDiphotonEvent->corrpfmet > 45.) {
2368 <        fDiphotonEvent->leptonTag2 = 1;
2360 >  const Muon *muon = GetLeptonTagMuon(phHard, phSoft);
2361 >  if (muon &&
2362 >      VHNumberOfJets(phHard, phSoft, selvtx, muon) <= 2) {
2363 >    // Found a good VH(lep) tag muon.
2364 >    if (fDiphotonEvent->corrpfmet > 45.) {
2365 >      fDiphotonEvent->VHLepTag = 2; // high MET event
2366 >    } else {
2367 >      fDiphotonEvent->VHLepTag = 1; // low MET event
2368 >    }
2369 >    return;  
2370 >  } // Found a good VH(lep) tag muon.
2371 >  
2372 >  const Electron *electron = GetLeptonTagElectron(phHard, phSoft);
2373 >  if (electron &&
2374 >      VHNumberOfJets(phHard, phSoft, selvtx, electron) <= 2) {
2375 >    // Found a good VH(lep) tag electron.
2376 >    if (fDiphotonEvent->corrpfmet > 45.) {
2377 >      // High MET event.
2378 >      fDiphotonEvent->VHLepTag = 2;
2379 >    } else {
2380 >      // Low MET event. Exclude Z->ee(->gamma) candidates based on mass
2381 >      if (MassOfPairIsWithinWindowAroundMZ(phHard, electron, 10) == false &&
2382 >          MassOfPairIsWithinWindowAroundMZ(phSoft, electron, 10) == false) {
2383 >        fDiphotonEvent->VHLepTag = 1; // low MET event
2384        } else {
2385 <        fDiphotonEvent->leptonTag2 = 2;
2386 <      } // if (MET < 45.)
2387 <      break;
2388 <    default:
2389 <      // this should never happen!
2308 <      cout << "Illegal value of leptonTag=" << fDiphotonEvent->leptonTag
2309 <           << endl << flush;
2310 <      assert(false);
2311 <  }  // switch(leptonTag)
2385 >        // Reject because m(e,g) is within 10 GeV of MZ
2386 >        fDiphotonEvent->VHLepTag = 0; // non-lepton event
2387 >      }
2388 >    } // Low MET event.
2389 >  } // Found a good VH(lep) tag electron.
2390  
2391 < } // void PhotonTreeWriter::ApplyLeptonTag2(..)
2391 > } // void PhotonTreeWriter::ApplyVHLepTag(..)
2392 >
2393 >
2394 > //_____________________________________________________________________________
2395 > bool PhotonTreeWriter::VHHasDielectron(const Photon *phHard,
2396 >                                       const Photon *phSoft) {
2397 >  if (fLeptonTagSoftElectrons->GetEntries() < 2) return false;
2398 >  
2399 >  if (fVerbosityLevel > 0) {
2400 >    cout << "JV PhotonTreeWriter::VHHasDielectron: Found >= 2 electrons!"
2401 >         << endl;
2402 >  }
2403 >  
2404 >  vector<UInt_t> goodElectrons;
2405 >  
2406 >  // Loop over electrons.
2407 >  for (UInt_t iele=0; iele < fLeptonTagSoftElectrons->GetEntries(); ++iele){
2408 >    const Electron *ele = fLeptonTagSoftElectrons->At(iele);
2409 >    if (MathUtils::DeltaR(ele, phHard) < 0.5) continue;
2410 >    if (MathUtils::DeltaR(ele, phSoft) < 0.5) continue;
2411 >    goodElectrons.push_back(iele);
2412 >  }
2413 >  
2414 >  // Loop over electron pairs.
2415 >  for (UInt_t iele1 = 0; iele1 < goodElectrons.size() - 1; ++iele1) {
2416 >    const Electron *ele1 = fLeptonTagSoftElectrons->At(iele1);
2417 >    for (UInt_t iele2 = iele1; iele2 < goodElectrons.size(); ++iele2) {
2418 >      const Electron *ele2 = fLeptonTagSoftElectrons->At(iele2);
2419 >      Double_t mass12 = (ele1->Mom() + ele2->Mom()).M();
2420 >      if (mass12 < 70. || 110. < mass12) continue;
2421 >      return true;
2422 >    }
2423 >  }
2424 >  
2425 >  return false;
2426 >  
2427 > } // bool PhotonTreeWriter::VHHasDielectron(..)
2428 >
2429 >
2430 > //_____________________________________________________________________________
2431 > bool PhotonTreeWriter::VHHasDimuon(const Photon *phHard,
2432 >                                   const Photon *phSoft) {
2433 >  if (fLeptonTagSoftMuons->GetEntries() < 2) return false;
2434 >  
2435 >  if (fVerbosityLevel > 0) {
2436 >    cout << "JV PhotonTreeWriter::VHHasDimuon: Found >= 2 muons!" << endl;
2437 >  }
2438 >  
2439 >  vector<UInt_t> goodMuons;
2440 >  
2441 >  // Loop over muons and apply the cut Delta R (mu, pho) > 0.5 .
2442 >  for (UInt_t imu=0; imu < fLeptonTagSoftMuons->GetEntries(); ++imu){
2443 >    const Muon *mu = fLeptonTagSoftMuons->At(imu);
2444 >    if (MathUtils::DeltaR(mu, phHard) < 0.5) continue;
2445 >    if (MathUtils::DeltaR(mu, phSoft) < 0.5) continue;
2446 >    goodMuons.push_back(imu);
2447 >  }
2448 >  
2449 >  // Loop over muon pairs and apply the cut 70 < mass(mu1, mu2) < 110.
2450 >  for (UInt_t imu1 = 0; imu1 < goodMuons.size() - 1; ++imu1) {
2451 >    const Muon *mu1 = fLeptonTagSoftMuons->At(imu1);
2452 >    for (UInt_t imu2 = imu1; imu2 < goodMuons.size(); ++imu2) {
2453 >      const Muon *mu2 = fLeptonTagSoftMuons->At(imu2);
2454 >      Double_t mass12 = (mu1->Mom() + mu2->Mom()).M();
2455 >      if (mass12 < 70. || 110. < mass12) continue;
2456 >      return true;
2457 >    }
2458 >  }
2459 >  
2460 >  return false;
2461 >  
2462 > } // PhotonTreeWriter::VHHasDimuon(..)
2463 >
2464 >
2465 > //_____________________________________________________________________________
2466 > UInt_t PhotonTreeWriter::VHNumberOfJets(const Photon *phHard,
2467 >                                        const Photon *phSoft,
2468 >                                        const Vertex *selvtx,
2469 >                                        const Particle *lepton) {
2470 >
2471 >  UInt_t nJets = 0;
2472 >  
2473 >  // Loop over jets, count those passing selection
2474 >  // Use same ID as for the tth tag
2475 >  for(UInt_t ijet=0; ijet < fPFJets->GetEntries(); ++ijet){
2476 >    const Jet *jet = fPFJets->At(ijet);
2477 >    // Apply jet selection, see L116 and L125 of the AN
2478 >    if (jet->Pt() < 20. || jet->AbsEta() > 2.4) continue;
2479 >    // Apply the cut Delta R(photon, jet) < 0.5.
2480 >    if (MathUtils::DeltaR(jet, phHard) < 0.5) continue;
2481 >    if (MathUtils::DeltaR(jet, phSoft) < 0.5) continue;
2482 >    // Apply the cut Delta R(photon, lepton) < 0.5.
2483 >    if (MathUtils::DeltaR(jet, lepton) < 0.5) continue;    
2484 >    // Make sure we have a PF jet
2485 >    const PFJet *pfjet = dynamic_cast<const PFJet*>(jet);
2486 >    if (!pfjet) continue;
2487 >    if (!JetTools::passPFLooseId(pfjet)) continue;
2488 >    // Apply the jet ID / pileup removal as given in Table 4
2489 >    Double_t betaStar = JetTools::betaStarClassic(pfjet, selvtx, fPV);
2490 >    if (betaStar > 0.2 * log(fPV->GetEntries() - 0.64)) continue;
2491 >    if (JetTools::dR2Mean(pfjet, -1) > 0.065) continue;
2492 >    // this jet passes, count it in
2493 >    ++nJets;
2494 >  } // End of loop over jets  
2495 >                                                  
2496 >  return nJets;
2497 >  
2498 > } // PhotonTreeWriter::VHNumberOfJets(..)
2499  
2500  
2501   //_____________________________________________________________________________
# Line 2416 | Line 2601 | void PhotonTreeWriter::Terminate()
2601   }
2602  
2603  
2419

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines