Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-26 00:19:02

0001 #include "DataFormats/L1TParticleFlow/interface/HPSPFTau.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 
0004 // default constructor
0005 l1t::HPSPFTau::HPSPFTau()
0006     : tauType_(kUndefined),
0007       sumChargedIso_(0.),
0008       sumNeutralIso_(0.),
0009       sumCombinedIso_(0.),
0010       sumChargedIsoPileup_(0.),
0011       passTightIso_(false),
0012       passMediumIso_(false),
0013       passLooseIso_(false),
0014       passVLooseIso_(false),
0015       passTightRelIso_(false),
0016       passMediumRelIso_(false),
0017       passLooseRelIso_(false),
0018       passVLooseRelIso_(false) {}
0019 
0020 // destructor
0021 l1t::HPSPFTau::~HPSPFTau() {}
0022 
0023 // print to stream
0024 ostream& operator<<(ostream& os, const l1t::HPSPFTau& l1PFTau) {
0025   os << "pT = " << l1PFTau.pt() << ", eta = " << l1PFTau.eta() << ", phi = " << l1PFTau.phi()
0026      << " (type = " << l1PFTau.tauType() << ")" << std::endl;
0027   os << "lead. ChargedPFCand:" << std::endl;
0028   if (l1PFTau.leadChargedPFCand().isNonnull()) {
0029     printPFCand(os, *l1PFTau.leadChargedPFCand(), l1PFTau.primaryVertex());
0030   } else {
0031     os << " N/A" << std::endl;
0032   }
0033   os << "seed:";
0034   if (l1PFTau.isChargedPFCandSeeded()) {
0035     os << " chargedPFCand";
0036   } else if (l1PFTau.isJetSeeded()) {
0037     os << " CaloJet";
0038   } else {
0039     cms::Exception ex("InconsistentTau");
0040     ex.addContext("Calling HPSPFTau::operator <<");
0041     ex.addAdditionalInfo("This tau is not seed by either a chargedPFCand or a PFJet!");
0042     throw ex;
0043   }
0044   os << std::endl;
0045   os << "signalPFCands:" << std::endl;
0046   for (const auto& l1PFCand : l1PFTau.signalAllL1PFCandidates()) {
0047     printPFCand(os, *l1PFCand, l1PFTau.primaryVertex());
0048   }
0049   os << "stripPFCands:" << std::endl;
0050   for (const auto& l1PFCand : l1PFTau.stripAllL1PFCandidates()) {
0051     printPFCand(os, *l1PFCand, l1PFTau.primaryVertex());
0052   }
0053   os << "strip pT = " << l1PFTau.stripP4().pt() << std::endl;
0054   os << "isolationPFCands:" << std::endl;
0055   for (const auto& l1PFCand : l1PFTau.isoAllL1PFCandidates()) {
0056     printPFCand(os, *l1PFCand, l1PFTau.primaryVertex());
0057   }
0058   os << "isolation pT-sum: charged = " << l1PFTau.sumChargedIso() << ", neutral = " << l1PFTau.sumNeutralIso()
0059      << " (charged from pileup = " << l1PFTau.sumChargedIsoPileup() << ")" << std::endl;
0060   return os;
0061 }
0062 
0063 void printPFCand(ostream& os, const l1t::PFCandidate& l1PFCand, const l1t::VertexWordRef& primaryVertex) {
0064   float primaryVertexZ = (primaryVertex.isNonnull()) ? primaryVertex->z0() : 0.;
0065   printPFCand(os, l1PFCand, primaryVertexZ);
0066 }
0067 
0068 void printPFCand(ostream& os, const l1t::PFCandidate& l1PFCand, float primaryVertexZ) {
0069   std::string typeString;
0070   if (l1PFCand.id() == l1t::PFCandidate::ChargedHadron)
0071     typeString = "PFChargedHadron";
0072   else if (l1PFCand.id() == l1t::PFCandidate::Electron)
0073     typeString = "PFElectron";
0074   else if (l1PFCand.id() == l1t::PFCandidate::NeutralHadron)
0075     typeString = "PFNeutralHadron";
0076   else if (l1PFCand.id() == l1t::PFCandidate::Photon)
0077     typeString = "PFPhoton";
0078   else if (l1PFCand.id() == l1t::PFCandidate::Muon)
0079     typeString = "PFMuon";
0080   else
0081     typeString = "N/A";
0082   os << " " << typeString << " with pT = " << l1PFCand.pt() << ", eta = " << l1PFCand.eta()
0083      << ", phi = " << l1PFCand.phi() << ","
0084      << " mass = " << l1PFCand.mass() << ", charge = " << l1PFCand.charge();
0085   if (l1PFCand.charge() != 0 && primaryVertexZ != 0.) {
0086     os << " (dz = " << std::fabs(l1PFCand.pfTrack()->vertex().z() - primaryVertexZ) << ")";
0087   }
0088   os << std::endl;
0089 }