Skip to content

Commit

Permalink
Merge pull request #23310 from civanch/sim_long_lived_exotics
Browse files Browse the repository at this point in the history
Backport fixes for simulation of long lived exotics
  • Loading branch information
cmsbuild committed Jun 22, 2018
2 parents 40bc1d6 + b822146 commit f3d7291
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 207 deletions.
39 changes: 21 additions & 18 deletions SimG4Core/CustomPhysics/interface/CustomParticleFactory.h
@@ -1,34 +1,37 @@
#ifndef CustomParticleFactory_h
#define CustomParticleFactory_h 1
#ifndef SimG4Core_CustomPhysics_CustomParticleFactory_h
#define SimG4Core_CustomPhysics_CustomParticleFactory_h 1

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

#include "SimG4Core/CustomPhysics/interface/CustomParticle.h"
#include "G4Threading.hh"
#include <vector>
#include <string>
#include <fstream>

class G4DecayTable;
// ######################################################################
// ### CustomParticle ###
// ######################################################################
class G4ParticleDefinition;

class CustomParticleFactory {

public:
static void loadCustomParticles(const std::string & filePath);
static const std::vector<G4ParticleDefinition *>& GetCustomParticles();
public:

explicit CustomParticleFactory();
~CustomParticleFactory();

void loadCustomParticles(const std::string & filePath);
const std::vector<G4ParticleDefinition *>& GetCustomParticles();

private:
private:

static void addCustomParticle(int pdgCode, double mass, const std::string & name );
static void getMassTable(std::ifstream *configFile);
static G4DecayTable* getDecayTable(std::ifstream *configFile, int pdgId);
static G4DecayTable* getAntiDecayTable(int pdgId, G4DecayTable *theDecayTable);
void addCustomParticle(int pdgCode, double mass, const std::string & name );
void getMassTable(std::ifstream *configFile);
G4DecayTable* getDecayTable(std::ifstream *configFile, int pdgId);
G4DecayTable* getAntiDecayTable(int pdgId, G4DecayTable *theDecayTable);
std::string ToLower(std::string str);

static bool loaded;
static std::vector<G4ParticleDefinition *> m_particles;

static std::string ToLower(std::string str);
#ifdef G4MULTITHREADED
static G4Mutex customParticleFactoryMutex;
#endif

};

Expand Down
25 changes: 11 additions & 14 deletions SimG4Core/CustomPhysics/interface/CustomPhysicsList.h
@@ -1,30 +1,27 @@
#ifndef SimG4Core_CustomPhysicsList_H
#define SimG4Core_CustomPhysicsList_H
#ifndef SimG4Core_CustomPhysics_CustomPhysicsList_H
#define SimG4Core_CustomPhysics_CustomPhysicsList_H

#include "SimG4Core/CustomPhysics/interface/HadronicProcessHelper.hh"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "G4VPhysicsConstructor.hh"

#include <string>

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

#include "G4VPhysicsConstructor.hh"

class G4ProcessHelper;
class G4Decay;
class CustomParticleFactory;

class CustomPhysicsList : public G4VPhysicsConstructor
{
public:
CustomPhysicsList(std::string name, const edm::ParameterSet & p);
virtual ~CustomPhysicsList();
CustomPhysicsList(const std::string& name, const edm::ParameterSet & p);
~CustomPhysicsList() override;

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

private:

static G4ThreadLocal G4Decay* fDecayProcess;
static G4ThreadLocal G4ProcessHelper* myHelper;
static G4ThreadLocal std::unique_ptr<G4ProcessHelper> myHelper;
std::unique_ptr<CustomParticleFactory> fParticleFactory;

bool fHadronicInteraction;

Expand Down
29 changes: 14 additions & 15 deletions SimG4Core/CustomPhysics/interface/CustomPhysicsListSS.h
@@ -1,38 +1,37 @@
#ifndef SimG4Core_CustomPhysicsListSS_H
#define SimG4Core_CustomPhysicsListSS_H
#ifndef SimG4Core_CustomPhysics_CustomPhysicsListSS_H
#define SimG4Core_CustomPhysics_CustomPhysicsListSS_H

#include "SimG4Core/CustomPhysics/interface/HadronicProcessHelper.hh"

#include <string>

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

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "G4VPhysicsConstructor.hh"
#include <string>

class G4ProcessHelper;
class G4Decay;
class CustomParticleFactory;

class CustomPhysicsListSS : public G4VPhysicsConstructor
{
public:
CustomPhysicsListSS(std::string name, const edm::ParameterSet & p);
virtual ~CustomPhysicsListSS();
CustomPhysicsListSS(const std::string& name, const edm::ParameterSet & p);
~CustomPhysicsListSS() override;

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

private:

static G4ThreadLocal G4Decay* fDecayProcess;
static G4ThreadLocal G4ProcessHelper* myHelper;
static G4ThreadLocal std::unique_ptr<G4Decay> fDecayProcess;
static G4ThreadLocal std::unique_ptr<G4ProcessHelper> myHelper;

std::unique_ptr<CustomParticleFactory> fParticleFactory;

bool fHadronicInteraction;

edm::ParameterSet myConfig;

std::string particleDefFilePath;
std::string processDefFilePath;

double dfactor;
};

#endif
@@ -1,3 +1,6 @@
#ifndef SimG4Core_CustomPhysics_G4ProcessHelper_H
#define SimG4Core_CustomPhysics_G4ProcessHelper_H

#include"globals.hh"
#include"G4ParticleDefinition.hh"
#include"G4DynamicParticle.hh"
Expand All @@ -15,6 +18,7 @@ typedef std::vector<ReactionProduct > ReactionProductList;
typedef std::map<G4int , ReactionProductList> ReactionMap;

class G4ParticleTable;
class CustomParticleFactory;
class HistoHelper;
class TProfile;
class TH1D;
Expand All @@ -23,9 +27,9 @@ class G4ProcessHelper {

public:

static G4ProcessHelper* Instance();
G4ProcessHelper(const edm::ParameterSet & p, CustomParticleFactory* ptr);

G4ProcessHelper(const edm::ParameterSet & p);
~G4ProcessHelper();

G4bool ApplicabilityTester(const G4ParticleDefinition& aPart);

Expand All @@ -35,14 +39,10 @@ class G4ProcessHelper {
//Make sure the element is known (for n/p-decision)
ReactionProduct GetFinalState(const G4Track& aTrack,G4ParticleDefinition*& aTarget);

protected:

G4ProcessHelper(const G4ProcessHelper&);
G4ProcessHelper& operator= (const G4ProcessHelper&);

private:

//static G4ProcessHelper* pinstance;
G4ProcessHelper(const G4ProcessHelper&) = delete;
G4ProcessHelper& operator= (const G4ProcessHelper&) = delete;

G4double Regge(const double boost);
G4double Pom(const double boost);
Expand Down Expand Up @@ -94,6 +94,7 @@ class G4ProcessHelper {
//Neutron-scattering processes
ReactionMap nReactionMap;

CustomParticleFactory* fParticleFactory;
G4ParticleTable* particleTable;
HistoHelper* theHistoHelper;
TProfile* h_xsec_lab;
Expand All @@ -103,3 +104,4 @@ class G4ProcessHelper {
TProfile* h_q_gamma;

};
#endif

0 comments on commit f3d7291

Please sign in to comment.