Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:40

0001 #include "SimDataFormats/CaloAnalysis/interface/MtdSimCluster.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include <numeric>
0006 
0007 MtdSimCluster::MtdSimCluster() {
0008   // No operation
0009 }
0010 
0011 MtdSimCluster::MtdSimCluster(const SimTrack &simtrk) {
0012   addG4Track(simtrk);
0013   event_ = simtrk.eventId();
0014   particleId_ = simtrk.trackId();
0015 
0016   theMomentum_.SetPxPyPzE(
0017       simtrk.momentum().px(), simtrk.momentum().py(), simtrk.momentum().pz(), simtrk.momentum().E());
0018 }
0019 
0020 MtdSimCluster::MtdSimCluster(EncodedEventId eventID, uint32_t particleID) {
0021   event_ = eventID;
0022   particleId_ = particleID;
0023 }
0024 
0025 MtdSimCluster::~MtdSimCluster() {}
0026 
0027 std::ostream &operator<<(std::ostream &s, MtdSimCluster const &tp) {
0028   s << "CP momentum, q, ID, & Event #: " << tp.p4() << " " << tp.charge() << " " << tp.pdgId() << " "
0029     << tp.eventId().bunchCrossing() << "." << tp.eventId().event() << std::endl;
0030 
0031   for (MtdSimCluster::genp_iterator hepT = tp.genParticle_begin(); hepT != tp.genParticle_end(); ++hepT) {
0032     s << " HepMC Track Momentum " << (*hepT)->momentum().rho() << std::endl;
0033   }
0034 
0035   for (MtdSimCluster::g4t_iterator g4T = tp.g4Track_begin(); g4T != tp.g4Track_end(); ++g4T) {
0036     s << " Geant Track Momentum  " << g4T->momentum() << std::endl;
0037     s << " Geant Track ID & type " << g4T->trackId() << " " << g4T->type() << std::endl;
0038     if (g4T->type() != tp.pdgId()) {
0039       s << " Mismatch b/t MtdSimCluster and Geant types" << std::endl;
0040     }
0041   }
0042   s << " # of cells = " << tp.hits_.size()
0043     << ", effective cells = " << std::accumulate(tp.fractions_.begin(), tp.fractions_.end(), 0.f) << std::endl;
0044   return s;
0045 }