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

Comparing UserCode/MitPhysics/Utils/src/ElectronTools.cc (file contents):
Revision 1.49 by mingyang, Mon Oct 8 17:22:59 2012 UTC vs.
Revision 1.52 by pharris, Sat Jan 12 11:49:50 2013 UTC

# Line 355 | Line 355 | Bool_t ElectronTools::PassConversionFilt
355   }
356  
357   //--------------------------------------------------------------------------------------------------
358 + Bool_t ElectronTools::PassConversionFilterPFAOD(const Electron *ele,
359 +                                           const DecayParticleCol *conversions,
360 +                                           const BaseVertex *vtx,
361 +                                           UInt_t nWrongHitsMax,
362 +                                           Double_t probMin,
363 +                                           Double_t lxyMin,
364 +                                           Bool_t matchCkf,
365 +                                           Bool_t requireArbitratedMerged,
366 +                                           Double_t trkptMin)
367 + {
368 +
369 +  Bool_t isGoodConversion = kFALSE;
370 +
371 +  for (UInt_t ifc=0; ifc<conversions->GetEntries(); ifc++) {
372 +    Bool_t ConversionMatchFound = kFALSE;
373 +    for (UInt_t d=0; d<conversions->At(ifc)->NDaughters(); d++) {
374 +      const ChargedParticle *pParticle = 0;
375 +      pParticle = dynamic_cast<const ChargedParticle*>(conversions->At(ifc)->Daughter(d));
376 +      if(pParticle == 0) continue;
377 +      const Track* trk = 0;
378 +      trk = pParticle->Trk();
379 +      if(trk == 0) continue;
380 +      if (ele->GsfTrk() == trk || (matchCkf && ele->TrackerTrk()==trk) ) {
381 +        ConversionMatchFound = kTRUE;
382 +        break;
383 +      }
384 +    }
385 +
386 +    // if match between the e-track and one of the conversion legs
387 +    if (ConversionMatchFound == kTRUE){
388 +      isGoodConversion =  (conversions->At(ifc)->Prob() > probMin) &&
389 +        (!requireArbitratedMerged || conversions->At(ifc)->Quality().Quality(ConversionQuality::arbitratedMerged)) &&
390 +        (conversions->At(ifc)->LxyCorrected(vtx) > lxyMin);
391 +
392 +      if (isGoodConversion == kTRUE) {
393 +        for (UInt_t d=0; d<conversions->At(ifc)->NDaughters(); d++) {
394 +          const ChargedParticle *pParticle = 0;
395 +          pParticle = dynamic_cast<const ChargedParticle*>(conversions->At(ifc)->Daughter(d));
396 +          if(pParticle == 0) continue;
397 +          const Track* trk = 0;
398 +          trk = pParticle->Trk();
399 +          if(trk == 0) continue;
400 +          if (trk) {
401 +            if (trk->Pt()<trkptMin) isGoodConversion = kFALSE;
402 +            const StableData *sd = dynamic_cast<const StableData*>
403 +              (conversions->At(ifc)->DaughterDat(d));
404 +            if (sd->NWrongHits() > nWrongHitsMax)
405 +              isGoodConversion = kFALSE;
406 +          } else {
407 +            isGoodConversion = kFALSE;
408 +          }
409 +        }
410 +      }
411 +    }
412 +    
413 +    if (isGoodConversion == kTRUE) break;
414 +    
415 +  } // loop over all conversions
416 +  
417 +  return !isGoodConversion;
418 + }
419 + //--------------------------------------------------------------------------------------------------
420   Bool_t ElectronTools::PassD0Cut(const Electron *ele, const VertexCol *vertices, Double_t fD0Cut, Int_t nVertex)
421   {
422    Bool_t d0cut = kFALSE;
# Line 1650 | Line 1712 | Bool_t ElectronTools::PassHggLeptonTagID
1712    return true;
1713   }
1714  
1715 + std::pair<Double_t,Double_t> ElectronTools::ComputeEPCombination( const Electron * ele, const float regression_energy,
1716 +                                                  const float regression_energy_error) {
1717 +
1718 +  enum Classification { GSF_ELECTRON_UNKNOWN=-1,
1719 +                        GSF_ELECTRON_GOLDEN=0,
1720 +                        GSF_ELECTRON_BIGBREM=1,
1721 +                        GSF_ELECTRON_BADTRACK=2,
1722 +                        GSF_ELECTRON_SHOWERING=3,
1723 +                        GSF_ELECTRON_GAP=4 } ;
1724 +
1725 +  float newEnergyError_ = regression_energy_error;
1726 +  float scEnergy = regression_energy;
1727 +
1728 +  int elClass = ele->Classification();
1729 +
1730 +  float trackMomentum  = ele->PIn() ;
1731 +  float errorTrackMomentum_ = 999. ;
1732 +  
1733 +  // the electron's track momentum error was not available in bambu versions less than 029
1734 +  if(ele->TrackMomentumError() > 0)
1735 +    errorTrackMomentum_ = ele->TrackMomentumError();
1736 +  else if ( ele->GsfTrk()->PtErr() > 0)
1737 +    errorTrackMomentum_ = ele->GsfTrk()->PtErr()*cosh(ele->GsfTrk()->Eta());
1738 +  else
1739 +    assert(0);
1740 +
1741 +  float finalMomentum = ele->E(); // initial
1742 +  float finalMomentumError = 999.;
1743 +  
1744 +  // first check for large errors
1745 +
1746 +  if (errorTrackMomentum_/trackMomentum > 0.5 && regression_energy_error/regression_energy <= 0.5) {
1747 +    finalMomentum = regression_energy;    finalMomentumError = regression_energy_error;
1748 +  }
1749 +  else if (errorTrackMomentum_/trackMomentum <= 0.5 && regression_energy_error/regression_energy > 0.5){  
1750 +    finalMomentum = trackMomentum;  finalMomentumError = errorTrackMomentum_;
1751 +  }
1752 +  else if (errorTrackMomentum_/trackMomentum > 0.5 && regression_energy_error/regression_energy > 0.5){
1753 +    if (errorTrackMomentum_/trackMomentum < regression_energy_error/regression_energy) {
1754 +      finalMomentum = trackMomentum; finalMomentumError = errorTrackMomentum_;
1755 +    }
1756 +    else{
1757 +      finalMomentum = regression_energy; finalMomentumError = regression_energy_error;
1758 +    }
1759 +  }
1760 +  // then apply the combination algorithm
1761 +  else {
1762 +     // calculate E/p and corresponding error
1763 +    float eOverP = regression_energy / trackMomentum;
1764 +    float errorEOverP = sqrt(
1765 +                             (regression_energy_error/trackMomentum)*(regression_energy_error/trackMomentum) +
1766 +                             (regression_energy*errorTrackMomentum_/trackMomentum/trackMomentum)*
1767 +                             (regression_energy*errorTrackMomentum_/trackMomentum/trackMomentum));
1768 +
1769 +
1770 +    bool eleIsNotInCombination = false ;
1771 +    if ( (eOverP  > 1 + 2.5*errorEOverP) || (eOverP  < 1 - 2.5*errorEOverP) || (eOverP < 0.8) || (eOverP > 1.3) )
1772 +      { eleIsNotInCombination = true ; }
1773 +     if (eleIsNotInCombination)
1774 +       {
1775 +         if (eOverP > 1)
1776 +           { finalMomentum = regression_energy ; finalMomentumError = regression_energy_error ; }
1777 +         else
1778 +           {
1779 +             if (elClass == GSF_ELECTRON_GOLDEN)
1780 +               { finalMomentum = regression_energy; finalMomentumError = regression_energy_error; }
1781 +             if (elClass == GSF_ELECTRON_BIGBREM)
1782 +               {
1783 +                 if (regression_energy<36)
1784 +                   { finalMomentum = trackMomentum ; finalMomentumError = errorTrackMomentum_ ; }
1785 +                 else
1786 +                   { finalMomentum = regression_energy ; finalMomentumError = regression_energy_error ; }
1787 +               }
1788 +             if (elClass == GSF_ELECTRON_BADTRACK)
1789 +               { finalMomentum = regression_energy; finalMomentumError = regression_energy_error ; }
1790 +             if (elClass == GSF_ELECTRON_SHOWERING)
1791 +               {
1792 +                 if (regression_energy<30)
1793 +                   { finalMomentum = trackMomentum ; finalMomentumError = errorTrackMomentum_; }
1794 +                 else
1795 +                   { finalMomentum = regression_energy; finalMomentumError = regression_energy_error;}
1796 +               }
1797 +             if (elClass == GSF_ELECTRON_GAP)
1798 +               {
1799 +                 if (regression_energy<60)
1800 +                   { finalMomentum = trackMomentum ; finalMomentumError = errorTrackMomentum_ ; }
1801 +                 else
1802 +                   { finalMomentum = regression_energy; finalMomentumError = regression_energy_error ; }
1803 +               }
1804 +           }
1805 +       }    
1806 +     else
1807 +       {
1808 +         // combination
1809 +         finalMomentum = (regression_energy/regression_energy_error/regression_energy_error + trackMomentum/errorTrackMomentum_/errorTrackMomentum_) /
1810 +           (1/regression_energy_error/regression_energy_error + 1/errorTrackMomentum_/errorTrackMomentum_);
1811 +         float finalMomentumVariance = 1 / (1/regression_energy_error/regression_energy_error + 1/errorTrackMomentum_/errorTrackMomentum_);
1812 +         finalMomentumError = sqrt(finalMomentumVariance);
1813 +       }
1814 +  }  
1815 +
1816 +  std::pair<Double_t,Double_t> value;
1817 +  value.first = finalMomentum;
1818 +  value.second = finalMomentumError;
1819 +  return value;
1820 +
1821 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines