Skip to content

Commit

Permalink
Add G4HepEm to CMSSW
Browse files Browse the repository at this point in the history
The new EMH physics list replaces the EM processes for electrons,
positrons, and gammas with G4HepEm. Note that gamma-lepto-nuclear
interactions are NOT implemented yet, and disabled for this physics
list (by removing G4EmExtraPhysics).
  • Loading branch information
hahnjo committed Nov 9, 2022
1 parent 51c0981 commit 9edb037
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 0 deletions.
2 changes: 2 additions & 0 deletions BigProducts/Simulation/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
<use name="Validation/HcalHits"/>
<use name="Validation/HGCalValidation"/>
<use name="geant4static"/>
<use name="g4hepemstatic"/>
<flags DROP_DEP="geant4core"/>
<flags DROP_DEP="g4hepemcore"/>
<ifrelease name="!_LTO_">
<!-- Disable LTO in BigLibs, as it seems to clash with debugging symbols with gcc 4.9.X -->
<flags REM_BIGOBJ_CXXFLAGS="-flto"/>
Expand Down
1 change: 1 addition & 0 deletions SimG4Core/PhysicsLists/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<use name="boost"/>
<use name="clhep"/>
<use name="geant4core"/>
<use name="g4hepemcore"/>
<use name="heppdt"/>
<use name="FWCore/MessageLogger"/>
<use name="SimG4Core/MagneticField"/>
Expand Down
26 changes: 26 additions & 0 deletions SimG4Core/PhysicsLists/interface/CMSEmStandardPhysicsEMH.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef SimG4Core_PhysicsLists_CMSEmStandardPhysicsEMH_h
#define SimG4Core_PhysicsLists_CMSEmStandardPhysicsEMH_h

#include "G4VPhysicsConstructor.hh"
#include "globals.hh"
#include "G4MscStepLimitType.hh"

#include "FWCore/ParameterSet/interface/ParameterSet.h"

class CMSEmStandardPhysicsEMH : public G4VPhysicsConstructor {
public:
CMSEmStandardPhysicsEMH(G4int ver, const edm::ParameterSet& p);
~CMSEmStandardPhysicsEMH() override;

void ConstructParticle() override;
void ConstructProcess() override;

private:
G4double fRangeFactor;
G4double fGeomFactor;
G4double fSafetyFactor;
G4double fLambdaLimit;
G4MscStepLimitType fStepLimitType;
};

#endif
44 changes: 44 additions & 0 deletions SimG4Core/PhysicsLists/plugins/FTFPCMS_BERT_EMH.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "FTFPCMS_BERT_EMH.h"
#include "SimG4Core/PhysicsLists/interface/CMSEmStandardPhysicsEMH.h"
#include "SimG4Core/PhysicsLists/interface/CMSHadronPhysicsFTFP_BERT.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "G4DecayPhysics.hh"
#include "G4IonPhysics.hh"
#include "G4StoppingPhysics.hh"
#include "G4HadronElasticPhysics.hh"

FTFPCMS_BERT_EMH::FTFPCMS_BERT_EMH(const edm::ParameterSet& p) : PhysicsList(p) {
int ver = p.getUntrackedParameter<int>("Verbosity", 0);
bool emPhys = p.getUntrackedParameter<bool>("EMPhysics", true);
bool hadPhys = p.getUntrackedParameter<bool>("HadPhysics", true);
double minFTFP = p.getParameter<double>("EminFTFP") * CLHEP::GeV;
double maxBERT = p.getParameter<double>("EmaxBERT") * CLHEP::GeV;
double maxBERTpi = p.getParameter<double>("EmaxBERTpi") * CLHEP::GeV;
edm::LogVerbatim("PhysicsList") << "CMS Physics List FTFP_BERT_EMH: "
<< "\n Flags for EM Physics: " << emPhys << "; Hadronic Physics: " << hadPhys
<< "\n Transition energy Bertini/FTFP from " << minFTFP / CLHEP::GeV << " to "
<< maxBERT / CLHEP::GeV << "; for pions to " << maxBERTpi / CLHEP::GeV << " GeV";

if (emPhys) {
// EM Physics
RegisterPhysics(new CMSEmStandardPhysicsEMH(ver, p));
}

// Decays
this->RegisterPhysics(new G4DecayPhysics(ver));

if (hadPhys) {
// Hadron Elastic scattering
RegisterPhysics(new G4HadronElasticPhysics(ver));

// Hadron Physics
RegisterPhysics(new CMSHadronPhysicsFTFP_BERT(minFTFP, maxBERT, maxBERTpi, minFTFP, maxBERT));

// Stopping Physics
RegisterPhysics(new G4StoppingPhysics(ver));

// Ion Physics
RegisterPhysics(new G4IonPhysics(ver));
}
}
12 changes: 12 additions & 0 deletions SimG4Core/PhysicsLists/plugins/FTFPCMS_BERT_EMH.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef SimG4Core_PhysicsLists_FTFPCMS_BERT_EMH_H
#define SimG4Core_PhysicsLists_FTFPCMS_BERT_EMH_H

#include "SimG4Core/Physics/interface/PhysicsList.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

class FTFPCMS_BERT_EMH : public PhysicsList {
public:
FTFPCMS_BERT_EMH(const edm::ParameterSet& p);
};

#endif
3 changes: 3 additions & 0 deletions SimG4Core/PhysicsLists/plugins/module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "DummyPhysics.h"
#include "FTFCMS_BIC.h"
#include "FTFPCMS_BERT.h"
#include "FTFPCMS_BERT_EMH.h"
#include "FTFPCMS_BERT_EML.h"
#include "FTFPCMS_BERT_EMM.h"
#include "G4Version.hh"
Expand Down Expand Up @@ -33,6 +34,8 @@ typedef FTFCMS_BIC FTF_BIC;
DEFINE_PHYSICSLIST(FTF_BIC);
typedef FTFPCMS_BERT FTFP_BERT;
DEFINE_PHYSICSLIST(FTFP_BERT);
typedef FTFPCMS_BERT_EMH FTFP_BERT_EMH;
DEFINE_PHYSICSLIST(FTFP_BERT_EMH);
typedef FTFPCMS_BERT_EML FTFP_BERT_EML;
DEFINE_PHYSICSLIST(FTFP_BERT_EML);
typedef FTFPCMS_BERT_EMM FTFP_BERT_EMM;
Expand Down
94 changes: 94 additions & 0 deletions SimG4Core/PhysicsLists/src/CMSEmStandardPhysicsEMH.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include "SimG4Core/PhysicsLists/interface/CMSEmStandardPhysicsEMH.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "G4SystemOfUnits.hh"
#include "G4ParticleDefinition.hh"
#include "G4EmParameters.hh"
#include "G4EmBuilder.hh"

#include "G4MscStepLimitType.hh"

#include "G4hIonisation.hh"
#include "G4hMultipleScattering.hh"
#include "G4ionIonisation.hh"

#include "G4ParticleTable.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4GenericIon.hh"

#include "G4PhysicsListHelper.hh"
#include "G4BuilderType.hh"
#include "G4ProcessManager.hh"

#include "G4HepEmProcess.hh"

#include <string>

CMSEmStandardPhysicsEMH::CMSEmStandardPhysicsEMH(G4int ver, const edm::ParameterSet& p)
: G4VPhysicsConstructor("CMSEmStandard_emh") {
SetVerboseLevel(ver);
G4EmParameters* param = G4EmParameters::Instance();
param->SetDefaults();
param->SetVerbose(ver);
param->SetApplyCuts(true);
param->SetStepFunction(0.8, 1 * CLHEP::mm);
param->SetMscRangeFactor(0.2);
param->SetMscStepLimitType(fUseSafety);
param->SetFluo(false);
SetPhysicsType(bElectromagnetic);
fRangeFactor = p.getParameter<double>("G4MscRangeFactor");
fGeomFactor = p.getParameter<double>("G4MscGeomFactor");
fSafetyFactor = p.getParameter<double>("G4MscSafetyFactor");
fLambdaLimit = p.getParameter<double>("G4MscLambdaLimit") * CLHEP::mm;
std::string msc = p.getParameter<std::string>("G4MscStepLimit");
fStepLimitType = fUseSafety;
if (msc == "UseSafetyPlus") {
fStepLimitType = fUseSafetyPlus;
}
if (msc == "Minimal") {
fStepLimitType = fMinimal;
}
double tcut = p.getParameter<double>("G4TrackingCut") * CLHEP::MeV;
param->SetLowestElectronEnergy(tcut);
param->SetLowestMuHadEnergy(tcut);
}

CMSEmStandardPhysicsEMH::~CMSEmStandardPhysicsEMH() {}

void CMSEmStandardPhysicsEMH::ConstructParticle() {
// minimal set of particles for EM physics
G4EmBuilder::ConstructMinimalEmSet();
}

void CMSEmStandardPhysicsEMH::ConstructProcess() {
if (verboseLevel > 0) {
edm::LogVerbatim("PhysicsList") << "### " << GetPhysicsName() << " Construct EM Processes";
}

// This EM builder takes default models of Geant4 10 EMV.
// Multiple scattering by WentzelVI for all particles except:
// a) e+e- below 100 MeV for which the Urban model is used
// b) ions for which Urban model is used
G4EmBuilder::PrepareEMPhysics();

G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
// processes used by several particles
G4hMultipleScattering* hmsc = new G4hMultipleScattering("ionmsc");
G4NuclearStopping* pnuc(nullptr);

G4HepEmProcess* hepEmProcess = new G4HepEmProcess();
G4Electron::Electron()->GetProcessManager()->AddProcess(hepEmProcess, -1, -1, 1);
G4Positron::Positron()->GetProcessManager()->AddProcess(hepEmProcess, -1, -1, 1);
G4Gamma::Gamma()->GetProcessManager()->AddProcess(hepEmProcess, -1, -1, 1);

// generic ion
G4ParticleDefinition* particle = G4GenericIon::GenericIon();
G4ionIonisation* ionIoni = new G4ionIonisation();
ph->RegisterProcess(hmsc, particle);
ph->RegisterProcess(ionIoni, particle);

// muons, hadrons ions
G4EmBuilder::ConstructCharged(hmsc, pnuc);
}

0 comments on commit 9edb037

Please sign in to comment.