Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "SimDataFormats/CaloAnalysis/interface/SimCluster.h"
0002 
0003 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0004 
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 
0007 #include <numeric>
0008 
0009 const unsigned int SimCluster::longLivedTag = 65536;
0010 
0011 SimCluster::SimCluster() {
0012   // No operation
0013 }
0014 
0015 SimCluster::SimCluster(const SimTrack &simtrk) {
0016   addG4Track(simtrk);
0017   event_ = simtrk.eventId();
0018   particleId_ = simtrk.trackId();
0019 
0020   theMomentum_.SetPxPyPzE(
0021       simtrk.momentum().px(), simtrk.momentum().py(), simtrk.momentum().pz(), simtrk.momentum().E());
0022 }
0023 
0024 SimCluster::SimCluster(EncodedEventId eventID, uint32_t particleID) {
0025   event_ = eventID;
0026   particleId_ = particleID;
0027 }
0028 
0029 SimCluster::~SimCluster() {}
0030 
0031 std::ostream &operator<<(std::ostream &s, SimCluster const &tp) {
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 (SimCluster::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 (SimCluster::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 SimCluster and Geant types" << std::endl;
0044     }
0045   }
0046   s << " # of cells = " << tp.hits_.size()
0047     << ", effective cells = " << std::accumulate(tp.fractions_.begin(), tp.fractions_.end(), 0.f) << std::endl;
0048   return s;
0049 }