16 #include "G4SystemOfUnits.hh" 17 #include "G4ParticleTable.hh" 18 #include "G4ParticleDefinition.hh" 28 produces<std::vector<std::string> >(
"StoppedParticlesName");
29 produces<std::vector<float> >(
"StoppedParticlesX");
30 produces<std::vector<float> >(
"StoppedParticlesY");
31 produces<std::vector<float> >(
"StoppedParticlesZ");
32 produces<std::vector<float> >(
"StoppedParticlesTime");
33 produces<std::vector<int> >(
"StoppedParticlesPdgId");
34 produces<std::vector<float> >(
"StoppedParticlesMass");
35 produces<std::vector<float> >(
"StoppedParticlesCharge");
40 edm::LogInfo(
"SimG4CoreCustomPhysics") <<
"RHStopTracer::RHStopTracer " << mTraceParticleName
47 LogDebug(
"SimG4CoreCustomPhysics") <<
"RHStopTracer::update-> begin of the run " << (*fRun)()->GetRunID();
51 LogDebug(
"SimG4CoreCustomPhysics") <<
"RHStopTracer::update-> begin of the event " << (*fEvent)()->GetEventID();
55 const G4Track*
track = (*fTrack)();
56 const G4ParticleDefinition*
part = track->GetDefinition();
57 const std::string& stringPartName = part->GetParticleName();
61 matched = std::regex_match(stringPartName,
rePartName);
62 if (matched || track->GetKineticEnergy() >
mTraceEnergy) {
63 LogDebug(
"SimG4CoreCustomPhysics") <<
"RHStopTracer::update-> new track: ID/Name/pdgId/mass/charge/Parent: " 64 << track->GetTrackID() <<
'/' << part->GetParticleName() <<
'/' 65 << part->GetPDGEncoding() <<
'/' << part->GetPDGMass() /
GeV <<
" GeV/" 66 << part->GetPDGCharge() <<
'/' << track->GetParentID()
67 <<
" Position: " << track->GetPosition() <<
' ' 68 <<
" R/phi: " << track->GetPosition().perp() <<
'/' << track->GetPosition().phi()
69 <<
" 4vec " << track->GetMomentum();
71 const_cast<G4Track*
>(
track)->SetTrackStatus(fStopAndKill);
76 const G4Track*
track = (*fTrack)();
77 const G4ParticleDefinition*
part = track->GetDefinition();
78 const std::string& stringPartName = part->GetParticleName();
82 matched = std::regex_match(stringPartName,
rePartName);
83 if (matched || track->GetKineticEnergy() >
mTraceEnergy) {
84 LogDebug(
"SimG4CoreCustomPhysics") <<
"RHStopTracer::update-> stop track: ID/Name/pdgId/mass/charge/Parent: " 85 << track->GetTrackID() <<
'/' << part->GetParticleName() <<
'/' 86 << part->GetPDGEncoding() <<
'/' << part->GetPDGMass() /
GeV <<
" GeV/" 87 << part->GetPDGCharge() <<
'/' << track->GetParentID()
88 <<
" Position: " << track->GetPosition() <<
' ' 89 <<
" R/phi: " << track->GetPosition().perp() <<
'/' << track->GetPosition().phi()
90 <<
" 4vec " << track->GetMomentum();
91 if (track->GetMomentum().mag() < 0.001) {
92 LogDebug(
"SimG4CoreCustomPhysics") <<
"RHStopTracer:: track has stopped, so making StopPoint";
94 track->GetPosition().x(),
95 track->GetPosition().y(),
96 track->GetPosition().z(),
97 track->GetGlobalTime(),
98 track->GetDefinition()->GetPDGEncoding(),
99 track->GetDefinition()->GetPDGMass() /
GeV,
100 track->GetDefinition()->GetPDGCharge()));
106 LogDebug(
"SimG4CoreCustomPhysics") <<
"RHStopTracer::produce->";
108 std::unique_ptr<std::vector<std::string> >
names(
new std::vector<std::string>);
109 std::unique_ptr<std::vector<float> > xs(
new std::vector<float>);
110 std::unique_ptr<std::vector<float> > ys(
new std::vector<float>);
111 std::unique_ptr<std::vector<float> > zs(
new std::vector<float>);
112 std::unique_ptr<std::vector<float> > ts(
new std::vector<float>);
113 std::unique_ptr<std::vector<int> >
ids(
new std::vector<int>);
114 std::unique_ptr<std::vector<float> >
masses(
new std::vector<float>);
115 std::unique_ptr<std::vector<float> >
charges(
new std::vector<float>);
117 std::vector<StopPoint>::const_iterator stopPoint =
mStopPoints.begin();
118 for (; stopPoint !=
mStopPoints.end(); ++stopPoint) {
119 names->push_back(stopPoint->name);
120 xs->push_back(stopPoint->x);
121 ys->push_back(stopPoint->y);
122 zs->push_back(stopPoint->z);
123 ts->push_back(stopPoint->t);
124 ids->push_back(stopPoint->id);
125 masses->push_back(stopPoint->mass);
126 charges->push_back(stopPoint->charge);
135 fEvent.
put(
std::move(charges),
"StoppedParticlesCharge");
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const std::string names[nVars_]
void produce(edm::Event &, const edm::EventSetup &) override
void update(const BeginOfRun *) override
This routine will be called when the appropriate signal arrives.
Abs< T >::type abs(const T &t)
std::string mTraceParticleName
RHStopTracer(edm::ParameterSet const &p)
charges
only generated particles of these IDs are considered
std::vector< StopPoint > mStopPoints