-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Implemented optional Dark Bremsstrahlung process into custom physics #38888
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef SIMAPPLICATION_APRIMEPHYSICS_H_ | ||
#define SIMAPPLICATION_APRIMEPHYSICS_H 1_ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same issue as reported in original PR and fixed in #38862. |
||
|
||
// Geant4 | ||
#include "G4VPhysicsConstructor.hh" | ||
|
||
class APrimePhysics : public G4VPhysicsConstructor { | ||
public: | ||
/** | ||
* Class constructor. | ||
* @param name The name of the physics. | ||
*/ | ||
APrimePhysics(double APMass, const G4String& scalefile, const G4double cxBias, const G4String& name = "APrime"); | ||
|
||
/** | ||
* Class destructor. | ||
*/ | ||
~APrimePhysics() override; | ||
|
||
/** | ||
* Construct particles. | ||
*/ | ||
void ConstructParticle() override; | ||
|
||
/** | ||
* Construct the process. | ||
*/ | ||
void ConstructProcess() override; | ||
|
||
private: | ||
/** | ||
* Definition of the APrime particle. | ||
*/ | ||
G4ParticleDefinition* aprimeDef_; | ||
double apmass; | ||
G4String mgfile; | ||
G4double biasFactor; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef SimG4Core_DBremWatcher_H | ||
#define SimG4Core_DBremWatcher_H | ||
|
||
#include "SimG4Core/Notification/interface/Observer.h" | ||
#include "SimG4Core/Notification/interface/BeginOfTrack.h" | ||
#include "SimG4Core/Notification/interface/EndOfTrack.h" | ||
#include "SimG4Core/Notification/interface/BeginOfEvent.h" | ||
#include "SimG4Core/Notification/interface/BeginOfRun.h" | ||
#include "SimG4Core/Notification/interface/EndOfEvent.h" | ||
#include "SimG4Core/Watcher/interface/SimProducer.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "G4ThreeVector.hh" | ||
|
||
#include <vector> | ||
#include <tuple> | ||
|
||
class DBremWatcher : public SimProducer, | ||
public Observer<const BeginOfTrack *>, | ||
public Observer<const BeginOfEvent *>, | ||
public Observer<const BeginOfRun *>, | ||
public Observer<const EndOfEvent *>, | ||
public Observer<const EndOfTrack *> { | ||
public: | ||
DBremWatcher(edm::ParameterSet const &p); | ||
~DBremWatcher() override; | ||
void update(const BeginOfTrack *trk) override; | ||
void update(const BeginOfEvent *event) override; | ||
void update(const EndOfEvent *event) override; | ||
void update(const BeginOfRun *run) override; | ||
void update(const EndOfTrack *trk) override; | ||
void produce(edm::Event &, const edm::EventSetup &) override; | ||
|
||
private: | ||
std::vector<int> pdgs_; | ||
int MotherId; | ||
float m_weight; | ||
double biasFactor; | ||
bool foundbrem; | ||
G4ThreeVector aPrimeTraj; | ||
G4ThreeVector finaltraj; | ||
G4ThreeVector VertexPos; | ||
float f_energy; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @file G4APrime.h | ||
* @brief Class creating the A' particle in Geant. | ||
* @author Michael Revering, University of Minnesota | ||
*/ | ||
|
||
#ifndef G4APrime_h | ||
#define G4APrime_h | ||
|
||
// Geant | ||
#include "G4ParticleDefinition.hh" | ||
|
||
class G4APrime : public G4ParticleDefinition { | ||
private: | ||
static G4APrime* theAPrime; | ||
|
||
G4APrime(const G4String& Name, | ||
G4double mass, | ||
G4double width, | ||
G4double charge, | ||
G4int iSpin, | ||
G4int iParity, | ||
G4int iConjugation, | ||
G4int iIsospin, | ||
G4int iIsospin3, | ||
G4int gParity, | ||
const G4String& pType, | ||
G4int lepton, | ||
G4int baryon, | ||
G4int encoding, | ||
G4bool stable, | ||
G4double lifetime, | ||
G4DecayTable* decaytable); | ||
|
||
~G4APrime() override; | ||
|
||
public: | ||
static G4APrime* APrime(double apmass = 1000); | ||
}; | ||
|
||
#endif |
40 changes: 40 additions & 0 deletions
40
SimG4Core/CustomPhysics/interface/G4muDarkBremsstrahlung.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @file G4muDarkBremsstrahlung.h | ||
* @brief Class providing the Dark Bremsstrahlung process class. | ||
* @author Michael Revering, University of Minnesota | ||
*/ | ||
|
||
#ifndef G4muDarkBremsstrahlung_h | ||
#define G4muDarkBremsstrahlung_h | ||
|
||
// Geant | ||
#include "G4VEmProcess.hh" | ||
|
||
class G4Material; | ||
|
||
class G4muDarkBremsstrahlung : public G4VEmProcess { | ||
public: | ||
G4muDarkBremsstrahlung(const G4String& scalefile, const G4double biasFactor, const G4String& name = "muDBrem"); | ||
|
||
~G4muDarkBremsstrahlung() override; | ||
|
||
G4bool IsApplicable(const G4ParticleDefinition& p) override; | ||
|
||
void PrintInfo() override; | ||
|
||
void SetMethod(std::string method_in); | ||
|
||
G4bool IsEnabled(); | ||
void SetEnable(bool active); | ||
G4muDarkBremsstrahlung& operator=(const G4muDarkBremsstrahlung& right) = delete; | ||
G4muDarkBremsstrahlung(const G4muDarkBremsstrahlung&) = delete; | ||
|
||
protected: | ||
void InitialiseProcess(const G4ParticleDefinition*) override; | ||
G4bool isInitialised; | ||
const G4String& mgfile; | ||
const G4double cxBias; | ||
G4bool isEnabled; | ||
}; | ||
|
||
#endif |
98 changes: 98 additions & 0 deletions
98
SimG4Core/CustomPhysics/interface/G4muDarkBremsstrahlungModel.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* @file G4muDarkBremsstrahlungModel.h | ||
* @brief Class provided to simulate the dark brem cross section and interaction. | ||
* @author Michael Revering, University of Minnesota | ||
*/ | ||
|
||
#ifndef G4muDarkBremsstrahlungModel_h | ||
#define G4muDarkBremsstrahlungModel_h | ||
|
||
// Geant | ||
#include "G4VEmModel.hh" | ||
#include "G4Material.hh" | ||
#include "G4Element.hh" | ||
#include "G4DataVector.hh" | ||
#include "G4ParticleChangeForLoss.hh" | ||
|
||
// ROOT | ||
#include "TLorentzVector.h" | ||
|
||
struct ParamsForChi { | ||
double AA; | ||
double ZZ; | ||
double MMA; | ||
double EE0; | ||
}; | ||
struct frame { | ||
TLorentzVector* fEl; | ||
TLorentzVector* cm; | ||
G4double E; | ||
}; | ||
|
||
class G4Element; | ||
class G4ParticleChangeForLoss; | ||
|
||
class G4muDarkBremsstrahlungModel : public G4VEmModel { | ||
public: | ||
G4muDarkBremsstrahlungModel(const G4String& scalefile, | ||
const G4double biasFactor, | ||
const G4ParticleDefinition* p = nullptr, | ||
const G4String& nam = "eDBrem"); | ||
|
||
~G4muDarkBremsstrahlungModel() override; | ||
|
||
void Initialise(const G4ParticleDefinition*, const G4DataVector&) override; | ||
|
||
G4double ComputeCrossSectionPerAtom( | ||
const G4ParticleDefinition*, G4double tkin, G4double Z, G4double, G4double cut, G4double maxE = DBL_MAX) override; | ||
|
||
G4DataVector* ComputePartialSumSigma(const G4Material* material, G4double tkin, G4double cut); | ||
|
||
void SampleSecondaries(std::vector<G4DynamicParticle*>*, | ||
const G4MaterialCutsCouple*, | ||
const G4DynamicParticle*, | ||
G4double tmin, | ||
G4double maxEnergy) override; | ||
|
||
void LoadMG(); | ||
|
||
void MakePlaceholders(); | ||
|
||
void SetMethod(std::string); | ||
|
||
frame GetMadgraphData(double E0); | ||
G4muDarkBremsstrahlungModel& operator=(const G4muDarkBremsstrahlungModel& right) = delete; | ||
G4muDarkBremsstrahlungModel(const G4muDarkBremsstrahlungModel&) = delete; | ||
|
||
protected: | ||
const G4Element* SelectRandomAtom(const G4MaterialCutsCouple* couple); | ||
|
||
private: | ||
void SetParticle(const G4ParticleDefinition* p); | ||
|
||
static G4double chi(double t, void* pp); | ||
|
||
static G4double DsigmaDx(double x, void* pp); | ||
|
||
protected: | ||
const G4String& mgfile; | ||
const G4double cxBias; | ||
const G4ParticleDefinition* particle; | ||
G4ParticleDefinition* theAPrime; | ||
G4ParticleChangeForLoss* fParticleChange; | ||
G4double MA; | ||
G4bool isMuon; | ||
|
||
private: | ||
G4double highKinEnergy; | ||
G4double lowKinEnergy; | ||
G4double probsup; | ||
G4bool isInitialised; | ||
std::string method; | ||
G4bool mg_loaded; | ||
std::map<double, std::vector<frame> > mgdata; | ||
std::vector<std::pair<double, int> > energies; | ||
std::vector<G4DataVector*> partialSumSigma; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#To use, add the following to the python configuration: | ||
#process.load('SimG4Core.CustomPhysics.DarkBrem_SIM_cfi') | ||
#process.g4SimHits.Physics.type = 'SimG4Core/Physics/CustomPhysics' | ||
#process.g4SimHits.Physics = cms.PSet( | ||
#process.g4SimHits.Physics, | ||
#process.customPhysicsSetup | ||
#) | ||
#process.g4SimHits.Watchers = cms.VPSet(cms.PSet( | ||
# DBremWatcher = cms.PSet( | ||
# PDGCodes = cms.untracked.vint32([9994]), | ||
# DBremBiasFactor = process.customPhysicsSetup.DBremBiasFactor | ||
# ), | ||
# type = cms.string('DBremWatcher') | ||
#) ) | ||
|
||
import FWCore.ParameterSet.Config as cms | ||
|
||
customPhysicsSetup = cms.PSet( | ||
DBrem = cms.untracked.bool(True), | ||
DBremMass = cms.untracked.double(1000.0), #Mass in MeV | ||
DBremScaleFile = cms.untracked.string("root://cmseos.fnal.gov//store/user/revering/MuDBrem_Cu_mA1p0.root"), | ||
DBremBiasFactor = cms.untracked.double(100) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "SimG4Core/CustomPhysics/interface/APrimePhysics.h" | ||
#include "SimG4Core/CustomPhysics/interface/G4APrime.h" | ||
#include "SimG4Core/CustomPhysics/interface/G4muDarkBremsstrahlung.h" | ||
// Geant 4 | ||
#include "G4Electron.hh" | ||
#include "G4MuonMinus.hh" | ||
#include "G4MuonPlus.hh" | ||
#include "G4ProcessManager.hh" | ||
#include "G4SystemOfUnits.hh" | ||
|
||
APrimePhysics::APrimePhysics(double APMass, const G4String& scalefile, const G4double cxBias, const G4String& name) | ||
: G4VPhysicsConstructor(name), aprimeDef_(nullptr) { | ||
apmass = APMass; | ||
mgfile = scalefile; | ||
biasFactor = cxBias; | ||
} | ||
|
||
APrimePhysics::~APrimePhysics() {} | ||
|
||
void APrimePhysics::ConstructParticle() { | ||
/** | ||
* Insert A-prime into the Geant4 particle table. | ||
* For now we flag it as stable. | ||
*/ | ||
aprimeDef_ = G4APrime::APrime(apmass); | ||
//aprimeDef->SetProcessManager(new G4ProcessManager(aprimeDef)); | ||
} | ||
|
||
void APrimePhysics::ConstructProcess() { | ||
G4ParticleDefinition* muonminus = G4MuonMinus::MuonMinusDefinition(); | ||
G4ParticleDefinition* muonplus = G4MuonPlus::MuonPlusDefinition(); | ||
G4ProcessManager* pmplus = muonplus->GetProcessManager(); | ||
G4ProcessManager* pmminus = muonminus->GetProcessManager(); | ||
pmplus->AddDiscreteProcess(new G4muDarkBremsstrahlung(mgfile, biasFactor), 6); | ||
pmminus->AddDiscreteProcess(new G4muDarkBremsstrahlung(mgfile, biasFactor), 6); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@revering , there was a fix in #38329 on top of your PR, please use it.