Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-03 23:52:24

0001 #include <memory>
0002 
0003 #include "SimG4Core/CustomPhysics/interface/CustomPhysicsList.h"
0004 #include "SimG4Core/CustomPhysics/interface/CustomParticleFactory.h"
0005 #include "SimG4Core/CustomPhysics/interface/CustomParticle.h"
0006 #include "SimG4Core/CustomPhysics/interface/DummyChargeFlipProcess.h"
0007 #include "SimG4Core/CustomPhysics/interface/G4ProcessHelper.h"
0008 #include "SimG4Core/CustomPhysics/interface/CustomPDGParser.h"
0009 
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/ParameterSet/interface/FileInPath.h"
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013 
0014 #include "G4hMultipleScattering.hh"
0015 #include "G4hIonisation.hh"
0016 #include "G4ProcessManager.hh"
0017 
0018 #include "SimG4Core/CustomPhysics/interface/FullModelHadronicProcess.h"
0019 #include "SimG4Core/CustomPhysics/interface/CMSDarkPairProductionProcess.h"
0020 #include "SimG4Core/CustomPhysics/interface/CMSQGSPSIMPBuilder.h"
0021 #include "SimG4Core/CustomPhysics/interface/CMSSIMPInelasticProcess.h"
0022 
0023 using namespace CLHEP;
0024 
0025 G4ThreadLocal std::unique_ptr<G4ProcessHelper> CustomPhysicsList::myHelper;
0026 
0027 CustomPhysicsList::CustomPhysicsList(const std::string& name, const edm::ParameterSet& p, bool apinew)
0028     : G4VPhysicsConstructor(name) {
0029   myConfig = p;
0030   if (apinew) {
0031     dfactor = p.getParameter<double>("DarkMPFactor");
0032     fHadronicInteraction = p.getParameter<bool>("RhadronPhysics");
0033   } else {
0034     // this is left for backward compatibility
0035     dfactor = p.getParameter<double>("dark_factor");
0036     fHadronicInteraction = p.getParameter<bool>("rhadronPhysics");
0037   }
0038   edm::FileInPath fp = p.getParameter<edm::FileInPath>("particlesDef");
0039   particleDefFilePath = fp.fullPath();
0040   fParticleFactory = std::make_unique<CustomParticleFactory>();
0041   myHelper.reset(nullptr);
0042 
0043   edm::LogVerbatim("SimG4CoreCustomPhysics") << "CustomPhysicsList: Path for custom particle definition file: \n"
0044                                              << particleDefFilePath << "\n"
0045                                              << "      dark_factor= " << dfactor;
0046 }
0047 
0048 CustomPhysicsList::~CustomPhysicsList() {}
0049 
0050 void CustomPhysicsList::ConstructParticle() {
0051   edm::LogVerbatim("SimG4CoreCustomPhysics") << "===== CustomPhysicsList::ConstructParticle ";
0052   fParticleFactory.get()->loadCustomParticles(particleDefFilePath);
0053 }
0054 
0055 void CustomPhysicsList::ConstructProcess() {
0056   edm::LogVerbatim("SimG4CoreCustomPhysics") << "CustomPhysicsList: adding CustomPhysics processes "
0057                                              << "for the list of particles";
0058 
0059   G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
0060 
0061   for (auto particle : fParticleFactory.get()->getCustomParticles()) {
0062     if (particle->GetParticleType() == "simp") {
0063       G4ProcessManager* pmanager = particle->GetProcessManager();
0064       if (pmanager) {
0065         CMSSIMPInelasticProcess* simpInelPr = new CMSSIMPInelasticProcess();
0066         CMSQGSPSIMPBuilder* theQGSPSIMPB = new CMSQGSPSIMPBuilder();
0067         theQGSPSIMPB->Build(simpInelPr);
0068         pmanager->AddDiscreteProcess(simpInelPr);
0069       } else
0070         edm::LogVerbatim("CustomPhysics") << "   No pmanager";
0071     }
0072 
0073     CustomParticle* cp = dynamic_cast<CustomParticle*>(particle);
0074     if (cp) {
0075       G4ProcessManager* pmanager = particle->GetProcessManager();
0076       edm::LogVerbatim("SimG4CoreCustomPhysics")
0077           << "CustomPhysicsList: " << particle->GetParticleName() << "  PDGcode= " << particle->GetPDGEncoding()
0078           << "  Mass= " << particle->GetPDGMass() / GeV << " GeV.";
0079       if (pmanager) {
0080         if (particle->GetPDGCharge() != 0.0) {
0081           ph->RegisterProcess(new G4hMultipleScattering, particle);
0082           ph->RegisterProcess(new G4hIonisation, particle);
0083         }
0084         if (cp->GetCloud() && fHadronicInteraction &&
0085             (CustomPDGParser::s_isgluinoHadron(particle->GetPDGEncoding()) ||
0086              (CustomPDGParser::s_isstopHadron(particle->GetPDGEncoding())) ||
0087              (CustomPDGParser::s_issbottomHadron(particle->GetPDGEncoding())))) {
0088           edm::LogVerbatim("SimG4CoreCustomPhysics")
0089               << "CustomPhysicsList: " << particle->GetParticleName()
0090               << " CloudMass= " << cp->GetCloud()->GetPDGMass() / GeV
0091               << " GeV; SpectatorMass= " << cp->GetSpectator()->GetPDGMass() / GeV << " GeV.";
0092 
0093           if (!myHelper.get()) {
0094             myHelper = std::make_unique<G4ProcessHelper>(myConfig, fParticleFactory.get());
0095           }
0096           pmanager->AddDiscreteProcess(new FullModelHadronicProcess(myHelper.get()));
0097         }
0098         if (particle->GetParticleType() == "darkpho") {
0099           CMSDarkPairProductionProcess* darkGamma = new CMSDarkPairProductionProcess(dfactor);
0100           pmanager->AddDiscreteProcess(darkGamma);
0101         }
0102       }
0103     }
0104   }
0105 }