CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/DataFormats/TauReco/src/PFTau.cc

Go to the documentation of this file.
00001 #include "DataFormats/TauReco/interface/PFTau.h"
00002 #include "DataFormats/Common/interface/RefToPtr.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 //using namespace std;
00006 namespace reco {
00007 
00008 PFTau::PFTau() {
00009     leadPFChargedHadrCandsignedSipt_=NAN;
00010     isolationPFChargedHadrCandsPtSum_=NAN;
00011     isolationPFGammaCandsEtSum_=NAN;
00012     maximumHCALPFClusterEt_=NAN;
00013     emFraction_ = NAN;
00014     hcalTotOverPLead_ = NAN;
00015     hcalMaxOverPLead_ = NAN;
00016     hcal3x3OverPLead_ = NAN;
00017     ecalStripSumEOverPLead_= NAN;
00018     bremsRecoveryEOverPLead_ = NAN;
00019     electronPreIDOutput_ = NAN;
00020     electronPreIDDecision_= NAN;
00021     caloComp_ = NAN;
00022     segComp_ = NAN;
00023     muonDecision_ = NAN;
00024 }
00025 
00026 PFTau::PFTau(Charge q,const LorentzVector& p4,const Point& vtx) : BaseTau(q,p4,vtx)
00027 {
00028    leadPFChargedHadrCandsignedSipt_=NAN;
00029    isolationPFChargedHadrCandsPtSum_=NAN;
00030    isolationPFGammaCandsEtSum_=NAN;
00031    maximumHCALPFClusterEt_=NAN;
00032 
00033    emFraction_ = NAN;
00034    hcalTotOverPLead_ = NAN;
00035    hcalMaxOverPLead_ = NAN;
00036    hcal3x3OverPLead_ = NAN;
00037    ecalStripSumEOverPLead_= NAN;
00038    bremsRecoveryEOverPLead_ = NAN;
00039    electronPreIDOutput_ = NAN;
00040    electronPreIDDecision_= NAN;
00041 
00042    caloComp_ = NAN;
00043    segComp_ = NAN;
00044    muonDecision_ = NAN;
00045 }
00046 
00047 PFTau* PFTau::clone() const { return new PFTau(*this); }
00048 
00049 // Constituent getters and setters
00050 const PFJetRef& PFTau::jetRef() const {return jetRef_;}
00051 void PFTau::setjetRef(const PFJetRef& x) {jetRef_=x;}
00052 
00053 const PFTauTagInfoRef& PFTau::pfTauTagInfoRef() const {
00054 //  edm::LogWarning("DeprecatedPFTauMember")
00055 //      << "The PFTauTagInfoRef member is deprecated in the PFTau."
00056 //      << " For access to the underlying PFJet, please use the jetRef() method";
00057   return PFTauTagInfoRef_;
00058 }
00059 
00060 void PFTau::setpfTauTagInfoRef(const PFTauTagInfoRef x) {PFTauTagInfoRef_=x;}
00061 
00062 const PFCandidateRef& PFTau::leadPFChargedHadrCand() const {return leadPFChargedHadrCand_;}
00063 const PFCandidateRef& PFTau::leadPFNeutralCand() const {return leadPFNeutralCand_;}
00064 const PFCandidateRef& PFTau::leadPFCand() const {return leadPFCand_;}
00065 
00066 void PFTau::setleadPFChargedHadrCand(const PFCandidateRef& myLead) { leadPFChargedHadrCand_=myLead;}
00067 void PFTau::setleadPFNeutralCand(const PFCandidateRef& myLead) { leadPFNeutralCand_=myLead;}
00068 void PFTau::setleadPFCand(const PFCandidateRef& myLead) { leadPFCand_=myLead;}
00069 
00070 float PFTau::leadPFChargedHadrCandsignedSipt() const {return leadPFChargedHadrCandsignedSipt_;}
00071 void PFTau::setleadPFChargedHadrCandsignedSipt(const float& x){leadPFChargedHadrCandsignedSipt_=x;}
00072 
00073 const PFCandidateRefVector& PFTau::signalPFCands() const {return selectedSignalPFCands_;}
00074 void PFTau::setsignalPFCands(const PFCandidateRefVector& myParts)  { selectedSignalPFCands_ = myParts;}
00075 const PFCandidateRefVector& PFTau::signalPFChargedHadrCands() const {return selectedSignalPFChargedHadrCands_;}
00076 void PFTau::setsignalPFChargedHadrCands(const PFCandidateRefVector& myParts)  { selectedSignalPFChargedHadrCands_ = myParts;}
00077 const PFCandidateRefVector& PFTau::signalPFNeutrHadrCands() const {return selectedSignalPFNeutrHadrCands_;}
00078 void PFTau::setsignalPFNeutrHadrCands(const PFCandidateRefVector& myParts)  { selectedSignalPFNeutrHadrCands_ = myParts;}
00079 const PFCandidateRefVector& PFTau::signalPFGammaCands() const {return selectedSignalPFGammaCands_;}
00080 void PFTau::setsignalPFGammaCands(const PFCandidateRefVector& myParts)  { selectedSignalPFGammaCands_ = myParts;}
00081 
00082 const PFCandidateRefVector& PFTau::isolationPFCands() const {return selectedIsolationPFCands_;}
00083 void PFTau::setisolationPFCands(const PFCandidateRefVector& myParts)  { selectedIsolationPFCands_ = myParts;}
00084 const PFCandidateRefVector& PFTau::isolationPFChargedHadrCands() const {return selectedIsolationPFChargedHadrCands_;}
00085 void PFTau::setisolationPFChargedHadrCands(const PFCandidateRefVector& myParts)  { selectedIsolationPFChargedHadrCands_ = myParts;}
00086 const PFCandidateRefVector& PFTau::isolationPFNeutrHadrCands() const {return selectedIsolationPFNeutrHadrCands_;}
00087 void PFTau::setisolationPFNeutrHadrCands(const PFCandidateRefVector& myParts)  { selectedIsolationPFNeutrHadrCands_ = myParts;}
00088 const PFCandidateRefVector& PFTau::isolationPFGammaCands() const {return selectedIsolationPFGammaCands_;}
00089 void PFTau::setisolationPFGammaCands(const PFCandidateRefVector& myParts)  { selectedIsolationPFGammaCands_ = myParts;}
00090 
00091 // PiZero and decay mode information
00092 const std::vector<RecoTauPiZero>& PFTau::signalPiZeroCandidates() const {
00093   // Check if the signal pi zeros are already filled
00094   if (signalPiZeroCandidates_.size() < signalPiZeroCandidatesRefs_.size()) {
00095     // Fill them from the refs
00096     for (size_t i = 0; i < signalPiZeroCandidatesRefs_.size(); ++i) {
00097       signalPiZeroCandidates_.push_back(*signalPiZeroCandidatesRefs_[i]);
00098     }
00099   }
00100   return signalPiZeroCandidates_;
00101 }
00102 
00103 void PFTau::setsignalPiZeroCandidates(const std::vector<RecoTauPiZero>& cands) {
00104    signalPiZeroCandidates_ = cands;
00105 }
00106 
00107 void PFTau::setSignalPiZeroCandidatesRefs(const RecoTauPiZeroRefVector& cands) {
00108    signalPiZeroCandidatesRefs_ = cands;
00109 }
00110 
00111 void PFTau::setIsolationPiZeroCandidatesRefs(const RecoTauPiZeroRefVector& cands) {
00112    isolationPiZeroCandidatesRefs_ = cands;
00113 }
00114 
00115 const std::vector<RecoTauPiZero>& PFTau::isolationPiZeroCandidates() const {
00116   // Check if the signal pi zeros are already filled
00117   if (isolationPiZeroCandidates_.size() < isolationPiZeroCandidatesRefs_.size()) {
00118     // Fill them from the refs
00119     for (size_t i = 0; i < isolationPiZeroCandidatesRefs_.size(); ++i) {
00120       isolationPiZeroCandidates_.push_back(*isolationPiZeroCandidatesRefs_[i]);
00121     }
00122   }
00123   return isolationPiZeroCandidates_;
00124 }
00125 
00126 void PFTau::setisolationPiZeroCandidates(const std::vector<RecoTauPiZero>& cands){
00127    signalPiZeroCandidates_ = cands;
00128 }
00129 
00130 PFTau::hadronicDecayMode PFTau::decayMode() const {
00131   unsigned int nCharged = signalPFChargedHadrCands().size();
00132   unsigned int nPiZeros = signalPiZeroCandidates().size();
00133   // If no tracks exist, this is definitely not a tau!
00134   if(!nCharged) return kNull;
00135   // Find the maximum number of PiZeros our parameterization can hold
00136   const unsigned int maxPiZeros = kOneProngNPiZero;
00137   // Determine our track index
00138   unsigned int trackIndex = (nCharged-1)*(maxPiZeros+1);
00139   // Check if we handle the given number of tracks
00140   if(trackIndex >= kRareDecayMode) return kRareDecayMode;
00141 
00142   nPiZeros = (nPiZeros <= maxPiZeros) ? nPiZeros : maxPiZeros;
00143   return static_cast<PFTau::hadronicDecayMode>(trackIndex + nPiZeros);
00144 }
00145 
00146 
00147 // Setting information about the isolation region
00148 float PFTau::isolationPFChargedHadrCandsPtSum() const {return isolationPFChargedHadrCandsPtSum_;}
00149 void PFTau::setisolationPFChargedHadrCandsPtSum(const float& x){isolationPFChargedHadrCandsPtSum_=x;}
00150 
00151 float PFTau::isolationPFGammaCandsEtSum() const {return isolationPFGammaCandsEtSum_;}
00152 void PFTau::setisolationPFGammaCandsEtSum(const float& x){isolationPFGammaCandsEtSum_=x;}
00153 
00154 float PFTau::maximumHCALPFClusterEt() const {return maximumHCALPFClusterEt_;}
00155 void PFTau::setmaximumHCALPFClusterEt(const float& x){maximumHCALPFClusterEt_=x;}
00156 
00157 // Electron variables
00158 float PFTau::emFraction() const {return emFraction_;}
00159 float PFTau::hcalTotOverPLead() const {return hcalTotOverPLead_;}
00160 float PFTau::hcalMaxOverPLead() const {return hcalMaxOverPLead_;}
00161 float PFTau::hcal3x3OverPLead() const {return hcal3x3OverPLead_;}
00162 float PFTau::ecalStripSumEOverPLead() const {return ecalStripSumEOverPLead_;}
00163 float PFTau::bremsRecoveryEOverPLead() const {return bremsRecoveryEOverPLead_;}
00164 reco::TrackRef PFTau::electronPreIDTrack() const {return electronPreIDTrack_;}
00165 float PFTau::electronPreIDOutput() const {return electronPreIDOutput_;}
00166 bool PFTau::electronPreIDDecision() const {return electronPreIDDecision_;}
00167 
00168 void PFTau::setemFraction(const float& x) {emFraction_ = x;}
00169 void PFTau::sethcalTotOverPLead(const float& x) {hcalTotOverPLead_ = x;}
00170 void PFTau::sethcalMaxOverPLead(const float& x) {hcalMaxOverPLead_ = x;}
00171 void PFTau::sethcal3x3OverPLead(const float& x) {hcal3x3OverPLead_ = x;}
00172 void PFTau::setecalStripSumEOverPLead(const float& x) {ecalStripSumEOverPLead_ = x;}
00173 void PFTau::setbremsRecoveryEOverPLead(const float& x) {bremsRecoveryEOverPLead_ = x;}
00174 void PFTau::setelectronPreIDTrack(const reco::TrackRef& x) {electronPreIDTrack_ = x;}
00175 void PFTau::setelectronPreIDOutput(const float& x) {electronPreIDOutput_ = x;}
00176 void PFTau::setelectronPreIDDecision(const bool& x) {electronPreIDDecision_ = x;}
00177 
00178 // Muon variables
00179 bool PFTau::hasMuonReference() const { // check if muon ref exists
00180     if( leadPFChargedHadrCand_.isNull() ) return false;
00181     else if( leadPFChargedHadrCand_.isNonnull() ){
00182         reco::MuonRef muonRef = leadPFChargedHadrCand_->muonRef();
00183         if( muonRef.isNull() )   return false;
00184         else if( muonRef.isNonnull() ) return  true;
00185     }
00186     return false;
00187 }
00188 
00189 float PFTau::caloComp() const {return caloComp_;}
00190 float PFTau::segComp() const {return segComp_;}
00191 bool  PFTau::muonDecision() const {return muonDecision_;}
00192 void PFTau::setCaloComp(const float& x) {caloComp_ = x;}
00193 void PFTau::setSegComp (const float& x) {segComp_  = x;}
00194 void PFTau::setMuonDecision(const bool& x) {muonDecision_ = x;}
00195 //
00196 
00197 
00198 CandidatePtr PFTau::sourceCandidatePtr( size_type i ) const {
00199     if( i!=0 ) return CandidatePtr();
00200     return  refToPtr( jetRef() );
00201 }
00202 
00203 
00204 bool PFTau::overlap(const Candidate& theCand) const {
00205     const RecoCandidate* theRecoCand=dynamic_cast<const RecoCandidate *>(&theCand);
00206     return (theRecoCand!=0 && (checkOverlap(track(),theRecoCand->track())));
00207 }
00208 
00209 void PFTau::dump(std::ostream& out) const {
00210 
00211     if(!out) return;
00212 
00213     if (pfTauTagInfoRef().isNonnull()) {
00214       out << "Its TauTagInfo constituents :"<<std::endl;
00215       out<<"# Tracks "<<pfTauTagInfoRef()->Tracks().size()<<std::endl;
00216       out<<"# PF charged hadr. cand's "<<pfTauTagInfoRef()->PFChargedHadrCands().size()<<std::endl;
00217       out<<"# PF neutral hadr. cand's "<<pfTauTagInfoRef()->PFNeutrHadrCands().size()<<std::endl;
00218       out<<"# PF gamma cand's "<<pfTauTagInfoRef()->PFGammaCands().size()<<std::endl;
00219     }
00220     if (jetRef().isNonnull()) {
00221       out << "Its constituents :"<< std::endl;
00222       out<<"# PF charged hadr. cand's "<< jetRef()->chargedHadronMultiplicity()<<std::endl;
00223       out<<"# PF neutral hadr. cand's "<< jetRef()->neutralHadronMultiplicity()<<std::endl;
00224       out<<"# PF gamma cand's "<< jetRef()->photonMultiplicity()<<std::endl;
00225       out<<"# Electron cand's "<< jetRef()->electronMultiplicity()<<std::endl;
00226     }
00227     out<<"in detail :"<<std::endl;
00228 
00229     out<<"Pt of the PFTau "<<pt()<<std::endl;
00230     PFCandidateRef theLeadPFCand = leadPFChargedHadrCand();
00231     if(!theLeadPFCand){
00232         out<<"No Lead PFCand "<<std::endl;
00233     }else{
00234         out<<"Lead PFCand Particle Id " << (*theLeadPFCand).particleId() << std::endl;
00235         out<<"Lead PFCand Pt "<<(*theLeadPFCand).pt()<<std::endl;
00236         out<<"Lead PFCand Charge "<<(*theLeadPFCand).charge()<<std::endl;
00237         out<<"Lead PFCand TrkRef "<<(*theLeadPFCand).trackRef().isNonnull()<<std::endl;
00238         out<<"Inner point position (x,y,z) of the PFTau ("<<vx()<<","<<vy()<<","<<vz()<<")"<<std::endl;
00239         out<<"Charge of the PFTau "<<charge()<<std::endl;
00240         out<<"Et of the highest Et HCAL PFCluster "<<maximumHCALPFClusterEt()<<std::endl;
00241         out<<"Number of SignalPFChargedHadrCands = "<<signalPFChargedHadrCands().size()<<std::endl;
00242         out<<"Number of SignalPFGammaCands = "<<signalPFGammaCands().size()<<std::endl;
00243         out<<"Number of IsolationPFChargedHadrCands = "<<isolationPFChargedHadrCands().size()<<std::endl;
00244         out<<"Number of IsolationPFGammaCands = "<<isolationPFGammaCands().size()<<std::endl;
00245         out<<"Sum of Pt of charged hadr. PFCandidates in isolation annulus around Lead PF = "<<isolationPFChargedHadrCandsPtSum()<<std::endl;
00246         out<<"Sum of Et of gamma PFCandidates in other isolation annulus around Lead PF = "<<isolationPFGammaCandsEtSum()<<std::endl;
00247 
00248     }
00249     // return out;
00250 }
00251 
00252 std::ostream& operator<<(std::ostream& out, const reco::PFTau& tau) {
00253 
00254    if(!out) return out;
00255 
00256    out << std::setprecision(3)
00257      <<"PFTau "
00258      << " charge: " << tau.charge() << " "
00259      << " pt:" <<tau.pt()<<" "
00260      << " eta:" <<tau.eta()<<" "
00261      << " phi:" <<tau.phi()<<" "
00262      << " mass:" << tau.mass() << " "
00263      << " dm: " << tau.decayMode() << " "
00264      <<tau.signalPFCands().size()<<","
00265      <<tau.signalPFChargedHadrCands().size()<<","
00266      <<tau.signalPFGammaCands().size()<<","
00267      <<tau.signalPiZeroCandidates().size()<<","
00268      <<tau.signalPFNeutrHadrCands().size()<<"  "
00269 
00270      <<tau.isolationPFCands().size()<<","
00271      <<tau.isolationPFChargedHadrCands().size()<<","
00272      <<tau.isolationPFGammaCands().size()<<","
00273      <<tau.isolationPiZeroCandidates().size()<<","
00274      <<tau.isolationPFNeutrHadrCands().size();
00275 
00276    return out;
00277 }
00278 
00279 }