Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:50:06

0001 #include "DataFormats/HepMCCandidate/interface/FlavorHistory.h"
0002 
0003 using namespace reco;
0004 using namespace edm;
0005 using namespace std;
0006 
0007 FlavorHistory::FlavorHistory() { flavorSource_ = FLAVOR_NULL; }
0008 
0009 FlavorHistory::FlavorHistory(FLAVOR_T flavorSource,
0010                              CandidatePtr const& parton,
0011                              CandidatePtr const& progenitor,
0012                              CandidatePtr const& sister,
0013                              reco::ShallowClonePtrCandidate const& matchedJet,
0014                              reco::ShallowClonePtrCandidate const& sisterJet)
0015     : flavorSource_(flavorSource),
0016       parton_(parton),
0017       progenitor_(progenitor),
0018       sister_(sister),
0019       matchedJet_(matchedJet),
0020       sisterJet_(sisterJet) {}
0021 
0022 FlavorHistory::FlavorHistory(FLAVOR_T flavorSource,
0023                              Handle<View<Candidate> > h_partons,
0024                              int parton,
0025                              int progenitor,
0026                              int sister,
0027                              reco::ShallowClonePtrCandidate const& matchedJet,
0028                              reco::ShallowClonePtrCandidate const& sisterJet)
0029     : flavorSource_(flavorSource),
0030       parton_(parton >= 0 && static_cast<unsigned int>(parton) < h_partons->size() ? CandidatePtr(h_partons, parton)
0031                                                                                    : CandidatePtr()),
0032       progenitor_(progenitor >= 0 && static_cast<unsigned int>(progenitor) < h_partons->size()
0033                       ? CandidatePtr(h_partons, progenitor)
0034                       : CandidatePtr()),
0035       sister_(sister >= 0 && static_cast<unsigned int>(sister) < h_partons->size() ? CandidatePtr(h_partons, sister)
0036                                                                                    : CandidatePtr()),
0037       matchedJet_(matchedJet),
0038       sisterJet_(sisterJet) {}
0039 
0040 FlavorHistory::FlavorHistory(FLAVOR_T flavorSource,
0041                              Handle<CandidateCollection> h_partons,
0042                              int parton,
0043                              int progenitor,
0044                              int sister,
0045                              reco::ShallowClonePtrCandidate const& matchedJet,
0046                              reco::ShallowClonePtrCandidate const& sisterJet)
0047     : flavorSource_(flavorSource),
0048       parton_(parton >= 0 && static_cast<unsigned int>(parton) < h_partons->size() ? CandidatePtr(h_partons, parton)
0049                                                                                    : CandidatePtr()),
0050       progenitor_(progenitor >= 0 && static_cast<unsigned int>(progenitor) < h_partons->size()
0051                       ? CandidatePtr(h_partons, progenitor)
0052                       : CandidatePtr()),
0053       sister_(sister >= 0 && static_cast<unsigned int>(sister) < h_partons->size() ? CandidatePtr(h_partons, sister)
0054                                                                                    : CandidatePtr()),
0055       matchedJet_(matchedJet),
0056       sisterJet_(sisterJet) {}
0057 
0058 ostream& operator<<(ostream& out, Candidate const& cand) {
0059   char buff[1000];
0060   sprintf(buff,
0061           "%5d, status = %5d, nmo = %5d, nda = %5d, pt = %6.2f, eta = %6.2f, phi = %6.2f, m = %6.2f",
0062           cand.pdgId(),
0063           cand.status(),
0064           static_cast<int>(cand.numberOfMothers()),
0065           static_cast<int>(cand.numberOfDaughters()),
0066           cand.pt(),
0067           cand.eta(),
0068           cand.phi(),
0069           cand.mass());
0070   out << buff;
0071   return out;
0072 }
0073 
0074 ostream& operator<<(ostream& out, FlavorHistory const& cand) {
0075   out << "Source     = " << cand.flavorSource() << endl;
0076   if (cand.hasParton())
0077     out << "Parton     = " << cand.parton().key() << " : " << *(cand.parton()) << endl;
0078   if (cand.hasProgenitor())
0079     out << "Progenitor = " << cand.progenitor().key() << " : " << *(cand.progenitor()) << endl;
0080   if (cand.hasSister())
0081     out << "Sister     = " << cand.sister().key() << " : " << *(cand.sister()) << endl;
0082   if (cand.hasMatchedJet())
0083     out << "jet        = " << cand.matchedJet() << endl;
0084   if (cand.hasSisterJet())
0085     out << "sister jet = " << cand.sisterJet() << endl;
0086   if (cand.hasParton()) {
0087     out << "Ancestry: " << endl;
0088     Candidate const* ipar = cand.parton()->mother();
0089     while (ipar->numberOfMothers() > 0) {
0090       out << *ipar << endl;
0091       ipar = ipar->mother();
0092     }
0093   }
0094   return out;
0095 }