File indexing completed on 2023-03-17 11:23:58
0001 #include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h"
0002
0003 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0004
0005 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0006
0007 #include "SimDataFormats/CaloAnalysis/interface/SimCluster.h"
0008
0009 const unsigned int CaloParticle::longLivedTag = 65536;
0010
0011 CaloParticle::CaloParticle() {
0012
0013 }
0014
0015 CaloParticle::CaloParticle(const SimTrack &simtrk) {
0016 addG4Track(simtrk);
0017 event_ = simtrk.eventId();
0018 particleId_ = simtrk.trackId();
0019 theMomentum_.SetPxPyPzE(
0020 simtrk.momentum().px(), simtrk.momentum().py(), simtrk.momentum().pz(), simtrk.momentum().E());
0021 }
0022
0023 CaloParticle::CaloParticle(EncodedEventId eventID, uint32_t particleID) {
0024 event_ = eventID;
0025 particleId_ = particleID;
0026 }
0027
0028 CaloParticle::~CaloParticle() {}
0029
0030 std::ostream &operator<<(std::ostream &s, CaloParticle const &tp) {
0031 s << "Calo Particle:" << std::endl;
0032 s << "CP momentum, q, ID, & Event #: " << tp.p4() << " " << tp.charge() << " " << tp.pdgId() << " "
0033 << tp.eventId().bunchCrossing() << "." << tp.eventId().event() << std::endl;
0034
0035 for (CaloParticle::genp_iterator hepT = tp.genParticle_begin(); hepT != tp.genParticle_end(); ++hepT) {
0036 s << " HepMC Track Momentum " << (*hepT)->momentum().rho() << std::endl;
0037 }
0038
0039 for (CaloParticle::g4t_iterator g4T = tp.g4Track_begin(); g4T != tp.g4Track_end(); ++g4T) {
0040 s << " Geant Track Momentum " << g4T->momentum() << std::endl;
0041 s << " Geant Track ID & type " << g4T->trackId() << " " << g4T->type() << std::endl;
0042 if (g4T->type() != tp.pdgId()) {
0043 s << " Mismatch b/t CaloParticle and Geant types" << std::endl;
0044 }
0045 }
0046 s << "SimClusters in this CaloParticle: " << std::endl;
0047 for (auto itr = tp.simClusters_.begin(); itr != tp.simClusters_.end(); ++itr) {
0048 s << **itr;
0049 }
0050 s << std::endl;
0051 return s;
0052 }