00001 #include "DataFormats/TauReco/interface/PFTau.h"
00002 #include "DataFormats/Common/interface/RefToPtr.h"
00003
00004 using namespace reco;
00005 using namespace std;
00006
00007
00008 PFTau::PFTau(){
00009 PFCandidateRef pfLead;
00010 TrackRef tmp;
00011 leadPFChargedHadrCand_=pfLead;
00012 leadPFNeutralCand_=pfLead;
00013 leadPFCand_=pfLead;
00014 leadPFChargedHadrCandsignedSipt_=NAN;
00015
00016 PFCandidateRefVector pfTmp;
00017 selectedSignalPFChargedHadrCands_=pfTmp;
00018 selectedSignalPFNeutrHadrCands_=pfTmp;
00019 selectedSignalPFGammaCands_=pfTmp;
00020
00021 selectedIsolationPFChargedHadrCands_=pfTmp;
00022 selectedIsolationPFNeutrHadrCands_=pfTmp;
00023 selectedIsolationPFGammaCands_=pfTmp;
00024
00025 isolationPFChargedHadrCandsPtSum_=NAN;
00026 isolationPFGammaCandsEtSum_=NAN;
00027 maximumHCALPFClusterEt_=NAN;
00028 emFraction_ = NAN;
00029 hcalTotOverPLead_ = NAN;
00030 hcalMaxOverPLead_ = NAN;
00031 hcal3x3OverPLead_ = NAN;
00032 ecalStripSumEOverPLead_= NAN;
00033 bremsRecoveryEOverPLead_ = NAN;
00034 electronPreIDTrack_ = tmp;
00035 electronPreIDOutput_ = NAN;
00036 electronPreIDDecision_= NAN;
00037
00038 caloComp_ = NAN;
00039 segComp_ = NAN;
00040 muonDecision_ = NAN;
00041 }
00042
00043 PFTau::PFTau(Charge q,const LorentzVector& p4,const Point& vtx) : BaseTau(q,p4,vtx){
00044 PFCandidateRef pfLead;
00045 TrackRef tmp;
00046 leadPFChargedHadrCand_=pfLead;
00047 leadPFChargedHadrCandsignedSipt_=NAN;
00048 leadPFNeutralCand_=pfLead;
00049 leadPFCand_=pfLead;
00050
00051 PFCandidateRefVector pfTmp;
00052 selectedSignalPFChargedHadrCands_=pfTmp;
00053 selectedSignalPFNeutrHadrCands_=pfTmp;
00054 selectedSignalPFGammaCands_=pfTmp;
00055
00056 selectedIsolationPFChargedHadrCands_=pfTmp;
00057 selectedIsolationPFNeutrHadrCands_=pfTmp;
00058 selectedIsolationPFGammaCands_=pfTmp;
00059
00060 isolationPFChargedHadrCandsPtSum_=NAN;
00061 isolationPFGammaCandsEtSum_=NAN;
00062 maximumHCALPFClusterEt_=NAN;
00063
00064 emFraction_ = NAN;
00065 hcalTotOverPLead_ = NAN;
00066 hcalMaxOverPLead_ = NAN;
00067 hcal3x3OverPLead_ = NAN;
00068 ecalStripSumEOverPLead_= NAN;
00069 bremsRecoveryEOverPLead_ = NAN;
00070 electronPreIDTrack_ = tmp;
00071 electronPreIDOutput_ = NAN;
00072 electronPreIDDecision_= NAN;
00073
00074 caloComp_ = NAN;
00075 segComp_ = NAN;
00076 muonDecision_ = NAN;
00077 }
00078
00079 PFTau* PFTau::clone()const{return new PFTau(*this);}
00080
00081
00082
00083 const PFTauTagInfoRef& PFTau::pfTauTagInfoRef()const{return PFTauTagInfoRef_;}
00084 void PFTau::setpfTauTagInfoRef(const PFTauTagInfoRef x) {PFTauTagInfoRef_=x;}
00085
00086 const PFCandidateRef& PFTau::leadPFChargedHadrCand()const {return leadPFChargedHadrCand_;}
00087 const PFCandidateRef& PFTau::leadPFNeutralCand()const {return leadPFNeutralCand_;}
00088 const PFCandidateRef& PFTau::leadPFCand()const {return leadPFCand_;}
00089
00090 void PFTau::setleadPFChargedHadrCand(const PFCandidateRef& myLead) { leadPFChargedHadrCand_=myLead;}
00091 void PFTau::setleadPFNeutralCand(const PFCandidateRef& myLead) { leadPFNeutralCand_=myLead;}
00092 void PFTau::setleadPFCand(const PFCandidateRef& myLead) { leadPFCand_=myLead;}
00093
00094 float PFTau::leadPFChargedHadrCandsignedSipt()const{return leadPFChargedHadrCandsignedSipt_;}
00095 void PFTau::setleadPFChargedHadrCandsignedSipt(const float& x){leadPFChargedHadrCandsignedSipt_=x;}
00096
00097 const PFCandidateRefVector& PFTau::signalPFCands()const {return selectedSignalPFCands_;}
00098 void PFTau::setsignalPFCands(const PFCandidateRefVector& myParts) { selectedSignalPFCands_ = myParts;}
00099 const PFCandidateRefVector& PFTau::signalPFChargedHadrCands()const {return selectedSignalPFChargedHadrCands_;}
00100 void PFTau::setsignalPFChargedHadrCands(const PFCandidateRefVector& myParts) { selectedSignalPFChargedHadrCands_ = myParts;}
00101 const PFCandidateRefVector& PFTau::signalPFNeutrHadrCands()const {return selectedSignalPFNeutrHadrCands_;}
00102 void PFTau::setsignalPFNeutrHadrCands(const PFCandidateRefVector& myParts) { selectedSignalPFNeutrHadrCands_ = myParts;}
00103 const PFCandidateRefVector& PFTau::signalPFGammaCands()const {return selectedSignalPFGammaCands_;}
00104 void PFTau::setsignalPFGammaCands(const PFCandidateRefVector& myParts) { selectedSignalPFGammaCands_ = myParts;}
00105
00106 const PFCandidateRefVector& PFTau::isolationPFCands()const {return selectedIsolationPFCands_;}
00107 void PFTau::setisolationPFCands(const PFCandidateRefVector& myParts) { selectedIsolationPFCands_ = myParts;}
00108 const PFCandidateRefVector& PFTau::isolationPFChargedHadrCands()const {return selectedIsolationPFChargedHadrCands_;}
00109 void PFTau::setisolationPFChargedHadrCands(const PFCandidateRefVector& myParts) { selectedIsolationPFChargedHadrCands_ = myParts;}
00110 const PFCandidateRefVector& PFTau::isolationPFNeutrHadrCands()const {return selectedIsolationPFNeutrHadrCands_;}
00111 void PFTau::setisolationPFNeutrHadrCands(const PFCandidateRefVector& myParts) { selectedIsolationPFNeutrHadrCands_ = myParts;}
00112 const PFCandidateRefVector& PFTau::isolationPFGammaCands()const {return selectedIsolationPFGammaCands_;}
00113 void PFTau::setisolationPFGammaCands(const PFCandidateRefVector& myParts) { selectedIsolationPFGammaCands_ = myParts;}
00114
00115 float PFTau::isolationPFChargedHadrCandsPtSum()const{return isolationPFChargedHadrCandsPtSum_;}
00116 void PFTau::setisolationPFChargedHadrCandsPtSum(const float& x){isolationPFChargedHadrCandsPtSum_=x;}
00117
00118 float PFTau::isolationPFGammaCandsEtSum()const{return isolationPFGammaCandsEtSum_;}
00119 void PFTau::setisolationPFGammaCandsEtSum(const float& x){isolationPFGammaCandsEtSum_=x;}
00120
00121 float PFTau::maximumHCALPFClusterEt()const{return maximumHCALPFClusterEt_;}
00122 void PFTau::setmaximumHCALPFClusterEt(const float& x){maximumHCALPFClusterEt_=x;}
00123
00124 float PFTau::emFraction() const {return emFraction_;}
00125 float PFTau::hcalTotOverPLead() const {return hcalTotOverPLead_;}
00126 float PFTau::hcalMaxOverPLead() const {return hcalMaxOverPLead_;}
00127 float PFTau::hcal3x3OverPLead() const {return hcal3x3OverPLead_;}
00128 float PFTau::ecalStripSumEOverPLead() const {return ecalStripSumEOverPLead_;}
00129 float PFTau::bremsRecoveryEOverPLead() const {return bremsRecoveryEOverPLead_;}
00130 reco::TrackRef PFTau::electronPreIDTrack() const {return electronPreIDTrack_;}
00131 float PFTau::electronPreIDOutput() const {return electronPreIDOutput_;}
00132 bool PFTau::electronPreIDDecision() const {return electronPreIDDecision_;}
00133
00134 void PFTau::setemFraction(const float& x) {emFraction_ = x;}
00135 void PFTau::sethcalTotOverPLead(const float& x) {hcalTotOverPLead_ = x;}
00136 void PFTau::sethcalMaxOverPLead(const float& x) {hcalMaxOverPLead_ = x;}
00137 void PFTau::sethcal3x3OverPLead(const float& x) {hcal3x3OverPLead_ = x;}
00138 void PFTau::setecalStripSumEOverPLead(const float& x) {ecalStripSumEOverPLead_ = x;}
00139 void PFTau::setbremsRecoveryEOverPLead(const float& x) {bremsRecoveryEOverPLead_ = x;}
00140 void PFTau::setelectronPreIDTrack(const reco::TrackRef& x) {electronPreIDTrack_ = x;}
00141 void PFTau::setelectronPreIDOutput(const float& x) {electronPreIDOutput_ = x;}
00142 void PFTau::setelectronPreIDDecision(const bool& x) {electronPreIDDecision_ = x;}
00143
00144 bool PFTau::hasMuonReference()const{
00145 if( leadPFChargedHadrCand_.isNull() ) return false;
00146 else if( leadPFChargedHadrCand_.isNonnull() ){
00147 reco::MuonRef muonRef = leadPFChargedHadrCand_->muonRef();
00148 if( muonRef.isNull() ) return false;
00149 else if( muonRef.isNonnull() ) return true;
00150 }
00151 return false;
00152 }
00153
00154 float PFTau::caloComp() const {return caloComp_;}
00155 float PFTau::segComp() const {return segComp_;}
00156 bool PFTau::muonDecision() const {return muonDecision_;}
00157 void PFTau::setCaloComp(const float& x) {caloComp_ = x;}
00158 void PFTau::setSegComp (const float& x) {segComp_ = x;}
00159 void PFTau::setMuonDecision(const bool& x) {muonDecision_ = x;}
00160
00161
00162
00163 CandidatePtr PFTau::sourceCandidatePtr( size_type i ) const {
00164 if( i!=0 ) return CandidatePtr();
00165
00166 const PFJetRef& pfJetRef = pfTauTagInfoRef()->pfjetRef();
00167 return refToPtr( pfJetRef );
00168 }
00169
00170
00171 bool PFTau::overlap(const Candidate& theCand)const{
00172 const RecoCandidate* theRecoCand=dynamic_cast<const RecoCandidate *>(&theCand);
00173 return (theRecoCand!=0 && (checkOverlap(track(),theRecoCand->track())));
00174 }
00175
00176 void PFTau::dump(std::ostream& out) const {
00177
00178 if(!out) return;
00179
00180 out << "Its constituents :"<<std::endl;
00181 out<<"# Tracks "<<pfTauTagInfoRef()->Tracks().size()<<std::endl;
00182 out<<"# PF charged hadr. cand's "<<pfTauTagInfoRef()->PFChargedHadrCands().size()<<std::endl;
00183 out<<"# PF neutral hadr. cand's "<<pfTauTagInfoRef()->PFNeutrHadrCands().size()<<std::endl;
00184 out<<"# PF gamma cand's "<<pfTauTagInfoRef()->PFGammaCands().size()<<std::endl;
00185 out<<"in detail :"<<std::endl;
00186
00187 out<<"Pt of the PFTau "<<pt()<<std::endl;
00188 PFCandidateRef theLeadPFCand = leadPFChargedHadrCand();
00189 if(!theLeadPFCand){
00190 out<<"No Lead PFCand "<<std::endl;
00191 }else{
00192 out<<"Lead PFCand Pt "<<(*theLeadPFCand).pt()<<std::endl;
00193 out<<"Inner point position (x,y,z) of the PFTau ("<<vx()<<","<<vy()<<","<<vz()<<")"<<std::endl;
00194 out<<"Charge of the PFTau "<<charge()<<std::endl;
00195 out<<"Et of the highest Et HCAL PFCluster "<<maximumHCALPFClusterEt()<<std::endl;
00196 out<<"Number of SignalPFChargedHadrCands = "<<signalPFChargedHadrCands().size()<<std::endl;
00197 out<<"Number of SignalPFGammaCands = "<<signalPFGammaCands().size()<<std::endl;
00198 out<<"Number of IsolationPFChargedHadrCands = "<<isolationPFChargedHadrCands().size()<<std::endl;
00199 out<<"Number of IsolationPFGammaCands = "<<isolationPFGammaCands().size()<<std::endl;
00200 out<<"Sum of Pt of charged hadr. PFCandidates in isolation annulus around Lead PF = "<<isolationPFChargedHadrCandsPtSum()<<std::endl;
00201 out<<"Sum of Et of gamma PFCandidates in other isolation annulus around Lead PF = "<<isolationPFGammaCandsEtSum()<<std::endl;
00202
00203 }
00204
00205
00206 }
00207
00208 namespace reco {
00209
00210
00211 std::ostream& operator<<(std::ostream& out, const reco::PFTau& tau) {
00212
00213 if(!out) return out;
00214
00215 out<<"PFTau "
00216 <<tau.pt()<<","
00217 <<tau.eta()<<","
00218 <<tau.phi()<<" "
00219 <<tau.signalPFCands().size()<<","
00220 <<tau.signalPFChargedHadrCands().size()<<","
00221 <<tau.signalPFGammaCands().size()<<","
00222 <<tau.signalPFNeutrHadrCands().size()<<" "
00223 <<tau.isolationPFCands().size()<<","
00224 <<tau.isolationPFChargedHadrCands().size()<<","
00225 <<tau.isolationPFGammaCands().size()<<","
00226 <<tau.isolationPFNeutrHadrCands().size();
00227
00228 return out;
00229 }
00230
00231 }