CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/SimG4Core/SaveSimTrackAction/src/SaveSimTrack.cc

Go to the documentation of this file.
00001 #include "SimG4Core/SaveSimTrackAction/interface/SaveSimTrack.h"
00002 
00003 #include "SimG4Core/Notification/interface/BeginOfTrack.h"
00004 #include "SimG4Core/Notification/interface/TrackInformation.h"
00005 
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 
00008 #include "G4Track.hh"
00009 
00010 SaveSimTrack::SaveSimTrack(edm::ParameterSet const & p) {
00011 
00012   pdgMin     = p.getUntrackedParameter<int>("MinimumPDGCode", 1000000);
00013   pdgMax     = p.getUntrackedParameter<int>("MaximumPDGCode", 2000000);
00014 
00015   edm::LogInfo("SaveSimTrack") << "SaveSimTrack:: Save Sim Track if PDG code "
00016                                << "lies between "  << pdgMin << " and " 
00017                                << pdgMax;
00018 }
00019 
00020 SaveSimTrack::~SaveSimTrack() {}
00021  
00022 void SaveSimTrack::update(const BeginOfTrack * trk) {
00023 
00024   G4Track* theTrack = (G4Track*)((*trk)());
00025   TrackInformation * trkInfo = (TrackInformation *)(theTrack->GetUserInformation());
00026   if (trkInfo) {
00027     int pdg = std::abs(theTrack->GetDefinition()->GetPDGEncoding());
00028     if (pdg >= pdgMin && pdg <= pdgMax) {
00029       trkInfo->storeTrack(true);
00030       LogDebug("SaveSimTrack") << "Save SimTrack the Track " 
00031                                << theTrack->GetTrackID() << " Type " 
00032                                << theTrack->GetDefinition()->GetParticleName()
00033                                << " Momentum " << theTrack->GetMomentum()/MeV 
00034                                << " MeV/c";
00035     }
00036   }
00037 }
00038