Skip to content

Commit

Permalink
Merge pull request #39494 from civanch/lowe_gflash
Browse files Browse the repository at this point in the history
Updated G4FLowE method
  • Loading branch information
cmsbuild authored Sep 25, 2022
2 parents fbfd2d7 + 6b115b6 commit c26f919
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
30 changes: 19 additions & 11 deletions SimG4Core/Application/src/LowEnergyFastSimModel.cc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit c26f919

Please sign in to comment.