00001 #include "DataFormats/HepMCCandidate/interface/FlavorHistory.h" 00002 00003 using namespace reco; 00004 using namespace edm; 00005 using namespace std; 00006 00007 FlavorHistory::FlavorHistory() 00008 { 00009 flavorSource_ = FLAVOR_NULL; 00010 } 00011 00012 FlavorHistory::FlavorHistory( FLAVOR_T flavorSource, 00013 CandidatePtr const & parton, 00014 CandidatePtr const & progenitor, 00015 CandidatePtr const & sister, 00016 reco::ShallowClonePtrCandidate const & matchedJet, 00017 reco::ShallowClonePtrCandidate const & sisterJet ) : 00018 flavorSource_(flavorSource), 00019 parton_(parton), 00020 progenitor_(progenitor), 00021 sister_(sister), 00022 matchedJet_(matchedJet), 00023 sisterJet_(sisterJet) 00024 { 00025 00026 } 00027 00028 FlavorHistory::FlavorHistory( FLAVOR_T flavorSource, 00029 Handle<View<Candidate> > h_partons, 00030 int parton, 00031 int progenitor, 00032 int sister, 00033 reco::ShallowClonePtrCandidate const & matchedJet, 00034 reco::ShallowClonePtrCandidate const & sisterJet ) : 00035 flavorSource_(flavorSource), 00036 parton_ ( parton >= 0 && static_cast<unsigned int>(parton) < h_partons->size() ? CandidatePtr(h_partons,parton) : CandidatePtr()), 00037 progenitor_( progenitor >= 0 && static_cast<unsigned int>(progenitor) < h_partons->size() ? CandidatePtr(h_partons,progenitor) : CandidatePtr()), 00038 sister_ ( sister >= 0 && static_cast<unsigned int>(sister) < h_partons->size() ? CandidatePtr(h_partons,sister) : CandidatePtr()), 00039 matchedJet_( matchedJet ), 00040 sisterJet_ ( sisterJet ) 00041 { 00042 00043 } 00044 00045 FlavorHistory::FlavorHistory( FLAVOR_T flavorSource, 00046 Handle<CandidateCollection> h_partons, 00047 int parton, 00048 int progenitor, 00049 int sister, 00050 reco::ShallowClonePtrCandidate const & matchedJet, 00051 reco::ShallowClonePtrCandidate const & sisterJet ) : 00052 flavorSource_(flavorSource), 00053 parton_ ( parton >= 0 && static_cast<unsigned int>(parton) < h_partons->size() ? CandidatePtr(h_partons,parton) : CandidatePtr()), 00054 progenitor_( progenitor >= 0 && static_cast<unsigned int>(progenitor) < h_partons->size() ? CandidatePtr(h_partons,progenitor) : CandidatePtr()), 00055 sister_ ( sister >= 0 && static_cast<unsigned int>(sister) < h_partons->size() ? CandidatePtr(h_partons,sister) : CandidatePtr()), 00056 matchedJet_( matchedJet ), 00057 sisterJet_ ( sisterJet ) 00058 { 00059 00060 } 00061 00062 00063 00064 ostream & operator<<( ostream & out, Candidate const & cand) 00065 { 00066 char buff[1000]; 00067 sprintf(buff, "%5d, status = %5d, nmo = %5d, nda = %5d, pt = %6.2f, eta = %6.2f, phi = %6.2f, m = %6.2f", 00068 cand.pdgId(), cand.status(), 00069 static_cast<int>(cand.numberOfMothers()), 00070 static_cast<int>(cand.numberOfDaughters()), 00071 cand.pt(), cand.eta(), cand.phi(), cand.mass() ); 00072 out << buff; 00073 return out; 00074 } 00075 00076 ostream & operator<<( ostream & out, FlavorHistory const & cand) 00077 { 00078 out << "Source = " << cand.flavorSource() << endl; 00079 if ( cand.hasParton() ) 00080 out << "Parton = " << cand.parton().key() << " : " << *(cand.parton()) << endl; 00081 if ( cand.hasProgenitor() ) 00082 out << "Progenitor = " << cand.progenitor().key() << " : " << *(cand.progenitor()) << endl; 00083 if ( cand.hasSister() ) 00084 out << "Sister = " << cand.sister().key() << " : " << *(cand.sister()) << endl; 00085 if ( cand.hasMatchedJet() ) 00086 out << "jet = " << cand.matchedJet() << endl; 00087 if ( cand.hasSisterJet() ) 00088 out << "sister jet = " << cand.sisterJet() << endl; 00089 if ( cand.hasParton() ) { 00090 out << "Ancestry: " << endl; 00091 Candidate const * ipar = cand.parton()->mother(); 00092 while ( ipar->numberOfMothers() > 0 ) { 00093 out << *ipar << endl; 00094 ipar = ipar->mother(); 00095 } 00096 } 00097 return out; 00098 }