Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated G4FLowE method #39494

Merged
merged 2 commits into from Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 19 additions & 11 deletions SimG4Core/Application/src/LowEnergyFastSimModel.cc
Expand Up @@ -3,6 +3,7 @@

#include "SimG4Core/Application/interface/LowEnergyFastSimModel.h"
#include "SimG4Core/Application/interface/TrackingAction.h"
#include "SimG4Core/Notification/interface/TrackInformation.h"

#include "G4VFastSimulationModel.hh"
#include "G4EventManager.hh"
Expand All @@ -15,13 +16,13 @@
#include "G4PhysicalConstants.hh"

constexpr G4double twomass = 2 * CLHEP::electron_mass_c2;
constexpr G4double scaleFactor = 1.015;
constexpr G4double scaleFactor = 1.05;

LowEnergyFastSimModel::LowEnergyFastSimModel(const G4String& name, G4Region* region, const edm::ParameterSet& parSet)
: G4VFastSimulationModel(name, region),
fRegion(region),
fTrackingAction(nullptr),
fCheck(false),
fCheck(true),
fTailPos(0., 0., 0.) {
fEmax = parSet.getParameter<double>("LowEnergyGflashEcalEmax") * CLHEP::GeV;
fPositron = G4Positron::Positron();
Expand All @@ -48,21 +49,28 @@ G4bool LowEnergyFastSimModel::IsApplicable(const G4ParticleDefinition& particle)

G4bool LowEnergyFastSimModel::ModelTrigger(const G4FastTrack& fastTrack) {
const G4Track* track = fastTrack.GetPrimaryTrack();
if (fCheck) {
if (nullptr == fTrackingAction) {
fTrackingAction = static_cast<const TrackingAction*>(G4EventManager::GetEventManager()->GetUserTrackingAction());
}
int pdgMother = std::abs(fTrackingAction->geant4Track()->GetDefinition()->GetPDGEncoding());
if (pdgMother == 11 || pdgMother == 22)
return false;
}
G4double energy = track->GetKineticEnergy();
if (fMaterial != track->GetMaterial() || energy >= fEmax)
return false;

/*
edm::LogVerbatim("LowEnergyFastSimModel") << track->GetDefinition()->GetParticleName()
<< " Ekin(MeV)=" << energy << " material: <"
<< track->GetMaterial()->GetName() << ">";
*/
return (energy < fEmax && fMaterial == track->GetMaterial());
if (fCheck) {
if (nullptr == fTrackingAction) {
fTrackingAction = static_cast<const TrackingAction*>(G4EventManager::GetEventManager()->GetUserTrackingAction());
}
const G4Track* mother = fTrackingAction->geant4Track();
const TrackInformation* ptr = static_cast<TrackInformation*>(mother->GetUserInformation());
if (ptr->isPrimary()) {
int pdgMother = mother->GetDefinition()->GetPDGEncoding();
if (std::abs(pdgMother) == 11 || pdgMother == 22)
return false;
}
}
return true;
}

void LowEnergyFastSimModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep) {
Expand Down
4 changes: 2 additions & 2 deletions SimG4Core/Application/src/StackingAction.cc
Expand Up @@ -457,8 +457,8 @@ bool StackingAction::rrApplicable(const G4Track* aTrack, const G4Track& mother)
int StackingAction::isItFromPrimary(const G4Track& mother, int flagIn) const {
int flag = flagIn;
if (flag != 1) {
const TrackInformation& motherInfo(extractor(mother));
if (motherInfo.isPrimary()) {
const TrackInformation* ptr = static_cast<TrackInformation*>(mother.GetUserInformation());
if (ptr->isPrimary()) {
flag = 3;
}
}
Expand Down