CMS 3D CMS Logo

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