Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "SimDataFormats/CaloAnalysis/interface/MtdSimTrackster.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 MtdSimTrackster::MtdSimTrackster() {
0006   // No operation
0007 }
0008 
0009 MtdSimTrackster::MtdSimTrackster(const SimCluster &sc) {
0010   auto simtrk = sc.g4Tracks()[0];
0011   addG4Track(simtrk);
0012   event_ = simtrk.eventId();
0013   particleId_ = simtrk.trackId();
0014 
0015   theMomentum_.SetPxPyPzE(
0016       simtrk.momentum().px(), simtrk.momentum().py(), simtrk.momentum().pz(), simtrk.momentum().E());
0017 }
0018 
0019 MtdSimTrackster::MtdSimTrackster(EncodedEventId eventID, uint32_t particleID) {
0020   event_ = eventID;
0021   particleId_ = particleID;
0022 }
0023 
0024 MtdSimTrackster::MtdSimTrackster(const SimCluster &sc,
0025                                  const std::vector<uint32_t> SCs,
0026                                  const float time,
0027                                  const GlobalPoint pos) {
0028   auto simtrk = sc.g4Tracks()[0];
0029   addG4Track(simtrk);
0030   event_ = simtrk.eventId();
0031   particleId_ = simtrk.trackId();
0032 
0033   theMomentum_.SetPxPyPzE(
0034       simtrk.momentum().px(), simtrk.momentum().py(), simtrk.momentum().pz(), simtrk.momentum().E());
0035 
0036   clusters_ = SCs;
0037   timeAtEntrance_ = time;
0038   posAtEntrance_ = pos;
0039 }
0040 
0041 MtdSimTrackster::~MtdSimTrackster() {}
0042 
0043 std::ostream &operator<<(std::ostream &s, MtdSimTrackster const &tp) {
0044   s << "CP momentum, q, ID, & Event #: " << tp.p4() << " " << tp.charge() << " " << tp.pdgId() << " "
0045     << tp.eventId().bunchCrossing() << "." << tp.eventId().event() << std::endl;
0046 
0047   for (MtdSimTrackster::genp_iterator hepT = tp.genParticle_begin(); hepT != tp.genParticle_end(); ++hepT) {
0048     s << " HepMC Track Momentum " << (*hepT)->momentum().rho() << std::endl;
0049   }
0050 
0051   for (MtdSimTrackster::g4t_iterator g4T = tp.g4Track_begin(); g4T != tp.g4Track_end(); ++g4T) {
0052     s << " Geant Track Momentum  " << g4T->momentum() << std::endl;
0053     s << " Geant Track ID & type " << g4T->trackId() << " " << g4T->type() << std::endl;
0054     if (g4T->type() != tp.pdgId()) {
0055       s << " Mismatch b/t MtdSimTrackster and Geant types" << std::endl;
0056     }
0057   }
0058   s << " # of clusters = " << tp.clusters_.size() << std::endl;
0059   return s;
0060 }