CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DataFormats/EgammaCandidates/src/GsfElectron.cc

Go to the documentation of this file.
00001 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00002 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00003 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00004 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00005 
00006 using namespace reco ;
00007 
00008 GsfElectronCoreRef GsfElectron::core() const { return core_ ; }
00009 
00010 void GsfElectron::init()
00011  {
00012   passCutBasedPreselection_ = false ;
00013   passMvaPreslection_ = false ;
00014   ambiguous_ = true ;
00015   fbrem_ = 0 ;
00016   class_ = UNKNOWN ;
00017  }
00018 
00019 GsfElectron::GsfElectron()
00020  { init() ; }
00021 
00022 GsfElectron::GsfElectron( const GsfElectronCoreRef & core )
00023  : core_(core)
00024  { init() ; }
00025 
00026 GsfElectron::GsfElectron
00027  ( int charge, const ChargeInfo & chargeInfo,
00028    const GsfElectronCoreRef & core,
00029    const TrackClusterMatching & tcm, const TrackExtrapolations & te,
00030    const ClosestCtfTrack & ctfInfo,
00031    const FiducialFlags & ff, const ShowerShape & ss,
00032    const ConversionRejection & crv,
00033    float fbrem
00034  )
00035  : chargeInfo_(chargeInfo),
00036    core_(core),
00037    trackClusterMatching_(tcm), trackExtrapolations_(te),
00038    //closestCtfTrack_(ctfInfo),
00039    fiducialFlags_(ff), showerShape_(ss), conversionRejection_(crv)
00040  {
00041   init() ;
00042   fbrem_ = fbrem ;
00043   setCharge(charge) ;
00044   setVertex(math::XYZPoint(te.positionAtVtx.x(),te.positionAtVtx.y(),te.positionAtVtx.z())) ;
00045   setPdgId(-11*charge) ;
00046   /*if (ecalDrivenSeed())*/ corrections_.ecalEnergy = superCluster()->energy() ;
00047   assert(ctfInfo.ctfTrack==(GsfElectron::core()->ctfTrack())) ;
00048   assert(ctfInfo.shFracInnerHits==(GsfElectron::core()->ctfGsfOverlap())) ;
00049  }
00050 
00051 GsfElectron::GsfElectron
00052  ( const GsfElectron & electron,
00053    const GsfElectronCoreRef & core )
00054  : RecoCandidate(electron),
00055    chargeInfo_(electron.chargeInfo_),
00056    core_(core),
00057    trackClusterMatching_(electron.trackClusterMatching_),
00058    trackExtrapolations_(electron.trackExtrapolations_),
00059    //closestCtfTrack_(electron.closestCtfTrack_),
00060    fiducialFlags_(electron.fiducialFlags_),
00061    showerShape_(electron.showerShape_),
00062    dr03_(electron.dr03_), dr04_(electron.dr04_),
00063    conversionRejection_(electron.conversionRejection_),
00064    pfShowerShape_(electron.pfShowerShape_),
00065    pfIso_(electron.pfIso_),
00066    mvaInput_(electron.mvaInput_),
00067    mvaOutput_(electron.mvaOutput_),
00068    passCutBasedPreselection_(electron.passCutBasedPreselection_),
00069    passMvaPreslection_(electron.passMvaPreslection_),
00070    ambiguous_(electron.ambiguous_),
00071    ambiguousGsfTracks_(electron.ambiguousGsfTracks_),
00072    //mva_(electron.mva_),
00073    fbrem_(electron.fbrem_),
00074    class_(electron.class_),
00075    corrections_(electron.corrections_)
00076  {
00077   assert(electron.core()->ctfTrack()==core->ctfTrack()) ;
00078   assert(electron.core()->ctfGsfOverlap()==core->ctfGsfOverlap()) ;
00079  }
00080 
00081 GsfElectron::GsfElectron
00082  ( const GsfElectron & electron,
00083    const GsfElectronCoreRef & core,
00084    const CaloClusterPtr & electronCluster,
00085    const TrackRef & closestCtfTrack,
00086    const TrackBaseRef & conversionPartner,
00087    const GsfTrackRefVector & ambiguousTracks )
00088  : RecoCandidate(electron),
00089    chargeInfo_(electron.chargeInfo_),
00090    core_(core),
00091    trackClusterMatching_(electron.trackClusterMatching_),
00092    trackExtrapolations_(electron.trackExtrapolations_),
00093    //closestCtfTrack_(electron.closestCtfTrack_),
00094    fiducialFlags_(electron.fiducialFlags_),
00095    showerShape_(electron.showerShape_),
00096    dr03_(electron.dr03_), dr04_(electron.dr04_),
00097    conversionRejection_(electron.conversionRejection_),
00098    pfShowerShape_(electron.pfShowerShape_),
00099    pfIso_(electron.pfIso_),
00100    mvaInput_(electron.mvaInput_),
00101    mvaOutput_(electron.mvaOutput_),
00102    passCutBasedPreselection_(electron.passCutBasedPreselection_),
00103    passMvaPreslection_(electron.passMvaPreslection_),
00104    ambiguous_(electron.ambiguous_),
00105    ambiguousGsfTracks_(ambiguousTracks),
00106    //mva_(electron.mva_),
00107    fbrem_(electron.fbrem_),
00108    class_(electron.class_),
00109    corrections_(electron.corrections_)
00110  {
00111   trackClusterMatching_.electronCluster = electronCluster ;
00112   //closestCtfTrack_.ctfTrack = closestCtfTrack ;
00113   conversionRejection_.partner = conversionPartner ;
00114   assert(closestCtfTrack==core->ctfTrack()) ;
00115   assert(electron.core()->ctfGsfOverlap()==core->ctfGsfOverlap()) ;
00116   // TO BE DONE
00117   // Check that the new edm references are really
00118   // the clones of the former references, and therefore other attributes
00119   // stay valid :
00120   // * electron.core_ ~ core ?
00121   // * electron.trackClusterMatching_.electronCluster ~ electronCluster ?
00122   // * electron.closestCtfTrack_.ctfTrack ~ closestCtfTrack ?
00123   // * electron.ambiguousGsfTracks_ ~ ambiguousTracks ?
00124  }
00125 
00126 bool GsfElectron::overlap( const Candidate & c ) const {
00127   const RecoCandidate * o = dynamic_cast<const RecoCandidate *>( & c );
00128   return ( o != 0 &&
00129            ( checkOverlap( gsfTrack(), o->gsfTrack() ) ||
00130              checkOverlap( superCluster(), o->superCluster() ) )
00131            );
00132   //?? return false;
00133 }
00134 
00135 GsfElectron * GsfElectron::clone() const
00136  { return new GsfElectron(*this) ; }
00137 
00138 GsfElectron * GsfElectron::clone
00139  (
00140   const GsfElectronCoreRef & core,
00141   const CaloClusterPtr & electronCluster,
00142   const TrackRef & closestCtfTrack,
00143   const TrackBaseRef & conversionPartner,
00144   const GsfTrackRefVector & ambiguousTracks
00145  ) const
00146  { return new GsfElectron(*this,core,electronCluster,closestCtfTrack,conversionPartner,ambiguousTracks) ; }
00147 
00148 bool GsfElectron::ecalDriven() const
00149  {
00150   if (!passingCutBasedPreselection()&&!passingMvaPreselection())
00151    {
00152     edm::LogWarning("GsfElectronAlgo|UndefinedPreselectionInfo")
00153       <<"All preselection flags are false,"
00154       <<" either the data is too old or electrons were not preselected." ;
00155    }
00156   return (ecalDrivenSeed()&&passingCutBasedPreselection()) ;
00157  }
00158 
00159 void GsfElectron::setEcalEnergyError( float energyError )
00160  { corrections_.ecalEnergyError = energyError ; }
00161 
00162 void GsfElectron::setCorrectedEcalEnergy( float newEnergy )
00163  {
00164   math::XYZTLorentzVectorD momentum = p4() ;
00165   momentum *= newEnergy/momentum.e() ;
00166   setP4(momentum) ;
00167   showerShape_.hcalDepth1OverEcal *= corrections_.ecalEnergy/newEnergy ;
00168   showerShape_.hcalDepth2OverEcal *= corrections_.ecalEnergy/newEnergy ;
00169   trackClusterMatching_.eSuperClusterOverP *= newEnergy/corrections_.ecalEnergy ;
00170   trackClusterMatching_.eSeedClusterOverP *= newEnergy/corrections_.ecalEnergy ;
00171   trackClusterMatching_.eEleClusterOverPout *= newEnergy/corrections_.ecalEnergy ;
00172   corrections_.ecalEnergyError *= newEnergy/corrections_.ecalEnergy ;
00173   corrections_.ecalEnergy = newEnergy ;
00174   corrections_.isEcalEnergyCorrected = true ;
00175  }
00176 
00177 void GsfElectron::setTrackMomentumError( float trackErr )
00178  { corrections_.trackMomentumError = trackErr ; }
00179 
00180 void GsfElectron::setP4
00181  ( P4Kind kind, const reco::Candidate::LorentzVector & p4, float error, bool setCandidate )
00182  {
00183   switch(kind)
00184    {
00185     case P4_FROM_SUPER_CLUSTER:
00186       corrections_.fromSuperClusterP4 = p4 ;
00187       corrections_.fromSuperClusterP4Error = error ;
00188       break ;
00189     case P4_COMBINATION:
00190       corrections_.combinedP4 = p4 ;
00191       corrections_.combinedP4Error = error ;
00192       break ;
00193     case P4_PFLOW_COMBINATION:
00194       corrections_.pflowP4 = p4 ;
00195       corrections_.pflowP4Error = error ;
00196       break ;
00197     default:
00198       throw cms::Exception("GsfElectron")<<"unexpected p4 kind: "<<kind ;
00199    }
00200   if (setCandidate)
00201    {
00202     setP4(p4) ;
00203     corrections_.candidateP4Kind = kind ;
00204    }
00205  }
00206 
00207 const Candidate::LorentzVector &  GsfElectron::p4( P4Kind kind ) const
00208  {
00209   switch(kind)
00210    {
00211     case P4_FROM_SUPER_CLUSTER: return corrections_.fromSuperClusterP4 ;
00212     case P4_COMBINATION: return corrections_.combinedP4 ;
00213     case P4_PFLOW_COMBINATION: return corrections_.pflowP4 ;
00214     default: throw cms::Exception("GsfElectron")<<"unexpected p4 kind: "<<kind ;
00215    }
00216  }
00217 
00218 
00219 float GsfElectron::p4Error( P4Kind kind ) const
00220  {
00221   switch(kind)
00222    {
00223     case P4_FROM_SUPER_CLUSTER: return corrections_.fromSuperClusterP4Error ;
00224     case P4_COMBINATION: return corrections_.combinedP4Error ;
00225     case P4_PFLOW_COMBINATION: return corrections_.pflowP4Error ;
00226     default: throw cms::Exception("GsfElectron")<<"unexpected p4 kind: "<<kind ;
00227    }
00228  }
00229