From a9470c19d546a6d4cff2e9feb339f50ffa080cd0 Mon Sep 17 00:00:00 2001 From: philten <philten@cern.ch> Date: Thu, 15 Feb 2018 15:20:48 +0000 Subject: [PATCH 1/4] Initial fix for mass width bug. --- Gen/LbPythia8/LbPythia8/Pythia8Production.h | 18 ++-- Gen/LbPythia8/src/Lib/Pythia8Production.cpp | 109 ++++++++++---------- 2 files changed, 61 insertions(+), 66 deletions(-) diff --git a/Gen/LbPythia8/LbPythia8/Pythia8Production.h b/Gen/LbPythia8/LbPythia8/Pythia8Production.h index 770fb3358..d83cf80f1 100755 --- a/Gen/LbPythia8/LbPythia8/Pythia8Production.h +++ b/Gen/LbPythia8/LbPythia8/Pythia8Production.h @@ -4,6 +4,7 @@ // LbPythia8. #include "LbPythia8/GaudiRandomForPythia8.h" #include "LbPythia8/BeamToolForPythia8.h" +#include "LbPythia8/ILHAupFortranTool.h" #include "LbPythia8/LhcbHooks.h" // Gaudi. @@ -13,10 +14,8 @@ // Pythia8. #include "Pythia8/Pythia.h" -#include "Pythia8Plugins/LHAFortran.h" -#include "Pythia8Plugins/HepMC2.h" - -using namespace std; +#include "Pythia8/LHAFortran.h" +#include "Pythia8/Pythia8ToHepMC.h" /** * Production tool to generate events with Pythia 8. @@ -37,10 +36,10 @@ using namespace std; */ class Pythia8Production : public GaudiTool, virtual public IProductionTool { public: - typedef vector<string> CommandVector ; + typedef std::vector<std::string> CommandVector ; /// Default constructor. - Pythia8Production(const string& type, const string& name, + Pythia8Production(const std::string& type, const std::string& name, const IInterface* parent); /// Default destructor. @@ -136,7 +135,7 @@ public: Pythia8::Event m_event; ///< The Pythia 8 event record. // Members needed externally. - string m_beamToolName; ///< The name of the beam tool. + std::string m_beamToolName; ///< The name of the beam tool. protected: @@ -159,14 +158,15 @@ protected: GaudiRandomForPythia8* m_randomEngine; ///< Random number generator. int m_nEvents; ///< Number of generated events. CommandVector m_userSettings; ///< The user settings vector. - string m_tuningFile; ///< The global tuning file. - string m_tuningUserFile; ///< The user tuning file. + std::string m_tuningFile; ///< The global tuning file. + std::string m_tuningUserFile; ///< The user tuning file. bool m_validate_HEPEVT; ///< Flag to validate the event. bool m_listAllParticles; ///< Flag to list all the particles. bool m_checkParticleProperties ; ///< Flag to check particle properties. bool m_showBanner; ///< Flag to print the Pythia 8 banner. ICounterLogFile* m_xmlLogTool; ///< The XML log file. set<unsigned int> m_special; ///< The set of special particles. + set<int> m_bws; ///< Set of particles with a valid BW. }; #endif // LBPYTHIA8_PYTHIA8PRODUCTION_H diff --git a/Gen/LbPythia8/src/Lib/Pythia8Production.cpp b/Gen/LbPythia8/src/Lib/Pythia8Production.cpp index 80ce91e5d..0a09d471f 100755 --- a/Gen/LbPythia8/src/Lib/Pythia8Production.cpp +++ b/Gen/LbPythia8/src/Lib/Pythia8Production.cpp @@ -7,9 +7,6 @@ // Event. #include "Event/GenCollision.h" -#include "Event/GenFSR.h" -#include "Event/GenCountersFSR.h" -#include "Event/CrossSectionsFSR.h" // Generators. #include "Generators/IBeamTool.h" @@ -30,7 +27,8 @@ //============================================================================= // Default constructor. //============================================================================= -Pythia8Production::Pythia8Production(const string& type, const string& name, +Pythia8Production::Pythia8Production(const std::string& type, + const std::string& name, const IInterface* parent) : GaudiTool(type, name, parent), m_pythia(0), m_hooks(0), m_lhaup(0), m_beamTool(0), m_pythiaBeamTool(0), m_randomEngine(0), m_nEvents(0), @@ -123,11 +121,22 @@ StatusCode Pythia8Production::initialize() { m_xmlLogTool = tool<ICounterLogFile >("XmlCounterLogFile"); // Create the Pythia 8 generator. - string xmlpath("UNKNOWN" != System::getEnv("PYTHIA8XML") ? - System::getEnv("PYTHIA8XML") : ""); + std::string xmlpath("UNKNOWN" != System::getEnv("PYTHIA8XML") ? + System::getEnv("PYTHIA8XML") : ""); m_pythia = new Pythia8::Pythia(xmlpath, m_showBanner); if (!m_pythia) return StatusCode::FAILURE; + // Create the Breit-Wigner map for checking particle widths later. + m_bws.clear(); + int id = m_pythia->particleData.nextId(1); + while (id != 0) { + if (!m_pythia->particleData.isResonance(id)) { + m_pythia->particleData.particleDataEntryPtr(id)->initBWmass(); + if (m_pythia->particleData.useBreitWigner(id)) m_bws.insert(id); + } + id = m_pythia->particleData.nextId(id); + } + // Add LhcbHooks parameters. Pythia8::Settings &set = m_pythia->settings; string sm("StandardModel:"), mpi("MultiPartonInteractions:"), @@ -158,9 +167,8 @@ StatusCode Pythia8Production::initializeGenerator() { // Initialize the external pointers. m_pythia->setRndmEnginePtr(m_randomEngine); + m_pythia->setUserHooksPtr(m_hooks); m_pythia->setBeamShapePtr(m_pythiaBeamTool); - if (m_hooks) m_pythia->setUserHooksPtr(m_hooks); - if (m_lhaup) m_pythia->setLHAupPtr(m_lhaup); // Set the beam configuration. Gaudi::XYZVector beamA, beamB; @@ -212,7 +220,7 @@ StatusCode Pythia8Production::initializeGenerator() { // Check particle properties if requested. if (m_checkParticleProperties) { - int id = m_pythia->particleData.nextId(0); + int id = m_pythia->particleData.nextId(1); while (id != 0) { if (!m_pythia->particleData.hasChanged(id)) warning() << "Data for particle with ID " << id @@ -222,9 +230,37 @@ StatusCode Pythia8Production::initializeGenerator() { } } + // Check the Breit-Wigner mass thresholds. + for (set<int>::iterator id = m_bws.begin(); id != m_bws.end(); ++id) { + Pythia8::ParticleDataEntry *pde = + m_pythia->particleData.particleDataEntryPtr(*id); + if (pde->isResonance()) continue; + pde->initBWmass(); + if (pde->useBreitWigner()) continue; + double mThr(0), bRatSum(0), mThrSum(0); + for (int i = 0; i < int(pde->sizeChannels()); ++i) + if (pde->channel(i).onMode() > 0) { + bRatSum += pde->channel(i).bRatio(); + double mChannelSum = 0.; + for (int j = 0; j < pde->channel(i).multiplicity(); ++j) + mChannelSum += m_pythia->particleData.m0(pde->channel(i).product(j)); + mThrSum += pde->channel(i).bRatio() * mChannelSum; + } + mThr = (bRatSum == 0.) ? 0. : mThrSum / bRatSum; + if (mThr > pde->m0()) { + warning() << "The threshold mass for particle with ID " << *id << " is " + << mThr << " GeV but its nominal mass is " << pde->m0() + << " GeV; clearing its decay channels." << endmsg; + pde->clearChannels(); + } + } + // Initialize. - if (m_pythia->init()) return StatusCode::SUCCESS; - else return Error("Failed to initialize Pythia 8."); + if (m_lhaup) { + if (m_pythia->init(m_lhaup)) return StatusCode::SUCCESS; + else return Error("Failed to initialize Pythia 8 with LHAUP pointer."); + } else if (m_pythia->init()) {return StatusCode::SUCCESS; + } else return Error("Failed to initialize Pythia 8."); } //============================================================================= @@ -233,7 +269,7 @@ StatusCode Pythia8Production::initializeGenerator() { StatusCode Pythia8Production::finalize() { // Print the statistics. - m_pythia->stat(); + m_pythia->statistics(); // Write the cross-sections to the XML log. vector<int> codes = m_pythia->info.codesHard(); @@ -265,46 +301,6 @@ StatusCode Pythia8Production::generateEvent(HepMC::GenEvent* theEvent, if (!m_pythia->flag("HadronLevel:all")) m_event = m_pythia->event; ++m_nEvents; - IDataProviderSvc* fileRecordSvc = svc<IDataProviderSvc>("FileRecordDataSvc", true); - std::string FSRName = LHCb::GenFSRLocation::Default; - LHCb::GenFSR* genFSR = getIfExists<LHCb::GenFSR>(fileRecordSvc, FSRName); - int key = 0; - - vector<int> codes = m_pythia->info.codesHard(); - - // Store the minimum bias cross-section in the GenFSR - key = LHCb::CrossSectionsFSR::CrossSectionKeyToType("MBCrossSection"); - - if(genFSR->hasGenCounter(key+100)) - { - longlong count = genFSR->getGenCounterInfo(100+key).second; - count = m_pythia->info.nAccepted(key) - count; - if(count > 0) genFSR->incrementGenCounter(key+100, count); - } - else if (m_pythia->info.nAccepted(key) != 0) - genFSR->addGenCounter(100+key, m_pythia->info.nAccepted(key)); - - if(genFSR->hasCrossSection(key)) genFSR->eraseCrossSection(key); - genFSR->addCrossSection(key,LHCb::GenFSR::CrossValues("Total cross-section", m_pythia->info.sigmaGen(key))); - - // Store the others cross-sections in the GenFSR - for (unsigned int code = 0; code < codes.size(); ++code) - { - key = codes[code]; - - if(genFSR->hasGenCounter(key+100)) - { - longlong count = genFSR->getGenCounterInfo(100+key).second; - count = m_pythia->info.nAccepted(key) - count; - if(count > 0) genFSR->incrementGenCounter(key+100, count); - } - else if (m_pythia->info.nAccepted(key) != 0) - genFSR->addGenCounter(100+key, m_pythia->info.nAccepted(key)); - - if(genFSR->hasCrossSection(key)) genFSR->eraseCrossSection(key); - genFSR->addCrossSection(key,LHCb::GenFSR::CrossValues(m_pythia->info.nameProc(key),m_pythia->info.sigmaGen(key))); - } - // Convert the event to HepMC and return. if (theCollision->isSignal() || m_pythia->flag("HadronLevel:all")) return toHepMC(theEvent, theCollision); @@ -397,13 +393,12 @@ void Pythia8Production::updateParticleProperties(const LHCb::ParticleProperty* pd.m0(id, thePP->mass() / Gaudi::Units::GeV); if (id == 6 || (id >= 23 && id <= 37)) return; double lifetime = thePP->lifetime()*Gaudi::Units::c_light; - if (lifetime <= 1.e-4 * Gaudi::Units::mm || - lifetime >= 1.e16 * Gaudi::Units::mm) lifetime = 0; + if (lifetime >= 1.e16 * Gaudi::Units::mm) lifetime = 0; double width = lifetime == 0 ? 0 : Gaudi::Units::hbarc / lifetime; - if (width < 1.5e-6*Gaudi::Units::GeV) {width = 0; pd.mMin(id, 0);} - else pd.mMin(id, (thePP->mass() - thePP->maxWidth()) / Gaudi::Units::GeV); + pd.mMin(id, (thePP->mass() - (thePP->maxWidth() ? thePP->maxWidth() : + 15*width)) / Gaudi::Units::GeV); + pd.mMax(id, (thePP->mass() + 15*width) / Gaudi::Units::GeV); pd.mWidth(id, width / Gaudi::Units::GeV); - pd.mMax(id, 0); pd.tau0(id, lifetime / Gaudi::Units::mm); } -- GitLab From de0926048e644b3dbe87c92d307ce6abdf8c52e3 Mon Sep 17 00:00:00 2001 From: philten <philten@cern.ch> Date: Fri, 23 Mar 2018 11:39:24 +0000 Subject: [PATCH 2/4] Ported to master branch. --- Gen/LbPythia8/LbPythia8/Pythia8Production.h | 17 +++--- Gen/LbPythia8/src/Lib/Pythia8Production.cpp | 62 +++++++++++++++++---- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/Gen/LbPythia8/LbPythia8/Pythia8Production.h b/Gen/LbPythia8/LbPythia8/Pythia8Production.h index d83cf80f1..d3df95052 100755 --- a/Gen/LbPythia8/LbPythia8/Pythia8Production.h +++ b/Gen/LbPythia8/LbPythia8/Pythia8Production.h @@ -4,7 +4,6 @@ // LbPythia8. #include "LbPythia8/GaudiRandomForPythia8.h" #include "LbPythia8/BeamToolForPythia8.h" -#include "LbPythia8/ILHAupFortranTool.h" #include "LbPythia8/LhcbHooks.h" // Gaudi. @@ -14,8 +13,10 @@ // Pythia8. #include "Pythia8/Pythia.h" -#include "Pythia8/LHAFortran.h" -#include "Pythia8/Pythia8ToHepMC.h" +#include "Pythia8Plugins/LHAFortran.h" +#include "Pythia8Plugins/HepMC2.h" + +using namespace std; /** * Production tool to generate events with Pythia 8. @@ -36,10 +37,10 @@ */ class Pythia8Production : public GaudiTool, virtual public IProductionTool { public: - typedef std::vector<std::string> CommandVector ; + typedef vector<string> CommandVector ; /// Default constructor. - Pythia8Production(const std::string& type, const std::string& name, + Pythia8Production(const string& type, const string& name, const IInterface* parent); /// Default destructor. @@ -135,7 +136,7 @@ public: Pythia8::Event m_event; ///< The Pythia 8 event record. // Members needed externally. - std::string m_beamToolName; ///< The name of the beam tool. + string m_beamToolName; ///< The name of the beam tool. protected: @@ -158,8 +159,8 @@ protected: GaudiRandomForPythia8* m_randomEngine; ///< Random number generator. int m_nEvents; ///< Number of generated events. CommandVector m_userSettings; ///< The user settings vector. - std::string m_tuningFile; ///< The global tuning file. - std::string m_tuningUserFile; ///< The user tuning file. + string m_tuningFile; ///< The global tuning file. + string m_tuningUserFile; ///< The user tuning file. bool m_validate_HEPEVT; ///< Flag to validate the event. bool m_listAllParticles; ///< Flag to list all the particles. bool m_checkParticleProperties ; ///< Flag to check particle properties. diff --git a/Gen/LbPythia8/src/Lib/Pythia8Production.cpp b/Gen/LbPythia8/src/Lib/Pythia8Production.cpp index 0a09d471f..afe707295 100755 --- a/Gen/LbPythia8/src/Lib/Pythia8Production.cpp +++ b/Gen/LbPythia8/src/Lib/Pythia8Production.cpp @@ -7,6 +7,9 @@ // Event. #include "Event/GenCollision.h" +#include "Event/GenFSR.h" +#include "Event/GenCountersFSR.h" +#include "Event/CrossSectionsFSR.h" // Generators. #include "Generators/IBeamTool.h" @@ -27,8 +30,7 @@ //============================================================================= // Default constructor. //============================================================================= -Pythia8Production::Pythia8Production(const std::string& type, - const std::string& name, +Pythia8Production::Pythia8Production(const string& type, const string& name, const IInterface* parent) : GaudiTool(type, name, parent), m_pythia(0), m_hooks(0), m_lhaup(0), m_beamTool(0), m_pythiaBeamTool(0), m_randomEngine(0), m_nEvents(0), @@ -121,8 +123,8 @@ StatusCode Pythia8Production::initialize() { m_xmlLogTool = tool<ICounterLogFile >("XmlCounterLogFile"); // Create the Pythia 8 generator. - std::string xmlpath("UNKNOWN" != System::getEnv("PYTHIA8XML") ? - System::getEnv("PYTHIA8XML") : ""); + string xmlpath("UNKNOWN" != System::getEnv("PYTHIA8XML") ? + System::getEnv("PYTHIA8XML") : ""); m_pythia = new Pythia8::Pythia(xmlpath, m_showBanner); if (!m_pythia) return StatusCode::FAILURE; @@ -167,8 +169,9 @@ StatusCode Pythia8Production::initializeGenerator() { // Initialize the external pointers. m_pythia->setRndmEnginePtr(m_randomEngine); - m_pythia->setUserHooksPtr(m_hooks); m_pythia->setBeamShapePtr(m_pythiaBeamTool); + if (m_hooks) m_pythia->setUserHooksPtr(m_hooks); + if (m_lhaup) m_pythia->setLHAupPtr(m_lhaup); // Set the beam configuration. Gaudi::XYZVector beamA, beamB; @@ -256,11 +259,8 @@ StatusCode Pythia8Production::initializeGenerator() { } // Initialize. - if (m_lhaup) { - if (m_pythia->init(m_lhaup)) return StatusCode::SUCCESS; - else return Error("Failed to initialize Pythia 8 with LHAUP pointer."); - } else if (m_pythia->init()) {return StatusCode::SUCCESS; - } else return Error("Failed to initialize Pythia 8."); + if (m_pythia->init()) return StatusCode::SUCCESS; + else return Error("Failed to initialize Pythia 8."); } //============================================================================= @@ -269,7 +269,7 @@ StatusCode Pythia8Production::initializeGenerator() { StatusCode Pythia8Production::finalize() { // Print the statistics. - m_pythia->statistics(); + m_pythia->stat(); // Write the cross-sections to the XML log. vector<int> codes = m_pythia->info.codesHard(); @@ -301,6 +301,46 @@ StatusCode Pythia8Production::generateEvent(HepMC::GenEvent* theEvent, if (!m_pythia->flag("HadronLevel:all")) m_event = m_pythia->event; ++m_nEvents; + IDataProviderSvc* fileRecordSvc = svc<IDataProviderSvc>("FileRecordDataSvc", true); + std::string FSRName = LHCb::GenFSRLocation::Default; + LHCb::GenFSR* genFSR = getIfExists<LHCb::GenFSR>(fileRecordSvc, FSRName); + int key = 0; + + vector<int> codes = m_pythia->info.codesHard(); + + // Store the minimum bias cross-section in the GenFSR + key = LHCb::CrossSectionsFSR::CrossSectionKeyToType("MBCrossSection"); + + if(genFSR->hasGenCounter(key+100)) + { + longlong count = genFSR->getGenCounterInfo(100+key).second; + count = m_pythia->info.nAccepted(key) - count; + if(count > 0) genFSR->incrementGenCounter(key+100, count); + } + else if (m_pythia->info.nAccepted(key) != 0) + genFSR->addGenCounter(100+key, m_pythia->info.nAccepted(key)); + + if(genFSR->hasCrossSection(key)) genFSR->eraseCrossSection(key); + genFSR->addCrossSection(key,LHCb::GenFSR::CrossValues("Total cross-section", m_pythia->info.sigmaGen(key))); + + // Store the others cross-sections in the GenFSR + for (unsigned int code = 0; code < codes.size(); ++code) + { + key = codes[code]; + + if(genFSR->hasGenCounter(key+100)) + { + longlong count = genFSR->getGenCounterInfo(100+key).second; + count = m_pythia->info.nAccepted(key) - count; + if(count > 0) genFSR->incrementGenCounter(key+100, count); + } + else if (m_pythia->info.nAccepted(key) != 0) + genFSR->addGenCounter(100+key, m_pythia->info.nAccepted(key)); + + if(genFSR->hasCrossSection(key)) genFSR->eraseCrossSection(key); + genFSR->addCrossSection(key,LHCb::GenFSR::CrossValues(m_pythia->info.nameProc(key),m_pythia->info.sigmaGen(key))); + } + // Convert the event to HepMC and return. if (theCollision->isSignal() || m_pythia->flag("HadronLevel:all")) return toHepMC(theEvent, theCollision); -- GitLab From 1ad2dcb5c691f7fe74d5e38988c877adc24b0c7c Mon Sep 17 00:00:00 2001 From: philten <philten@cern.ch> Date: Tue, 24 Apr 2018 11:33:00 +0100 Subject: [PATCH 3/4] Cleaned up formatting and removed using namespace std. --- Gen/LbPythia8/LbPythia8/Pythia8Production.h | 16 ++-- Gen/LbPythia8/src/Lib/Pythia8Production.cpp | 90 ++++++++++----------- 2 files changed, 50 insertions(+), 56 deletions(-) diff --git a/Gen/LbPythia8/LbPythia8/Pythia8Production.h b/Gen/LbPythia8/LbPythia8/Pythia8Production.h index d3df95052..04c83dfd7 100755 --- a/Gen/LbPythia8/LbPythia8/Pythia8Production.h +++ b/Gen/LbPythia8/LbPythia8/Pythia8Production.h @@ -16,8 +16,6 @@ #include "Pythia8Plugins/LHAFortran.h" #include "Pythia8Plugins/HepMC2.h" -using namespace std; - /** * Production tool to generate events with Pythia 8. * @@ -37,10 +35,10 @@ using namespace std; */ class Pythia8Production : public GaudiTool, virtual public IProductionTool { public: - typedef vector<string> CommandVector ; + typedef std::vector<std::string> CommandVector ; /// Default constructor. - Pythia8Production(const string& type, const string& name, + Pythia8Production(const std::string& type, const std::string& name, const IInterface* parent); /// Default destructor. @@ -136,7 +134,7 @@ public: Pythia8::Event m_event; ///< The Pythia 8 event record. // Members needed externally. - string m_beamToolName; ///< The name of the beam tool. + std::string m_beamToolName; ///< The name of the beam tool. protected: @@ -159,15 +157,15 @@ protected: GaudiRandomForPythia8* m_randomEngine; ///< Random number generator. int m_nEvents; ///< Number of generated events. CommandVector m_userSettings; ///< The user settings vector. - string m_tuningFile; ///< The global tuning file. - string m_tuningUserFile; ///< The user tuning file. + std::string m_tuningFile; ///< The global tuning file. + std::string m_tuningUserFile; ///< The user tuning file. bool m_validate_HEPEVT; ///< Flag to validate the event. bool m_listAllParticles; ///< Flag to list all the particles. bool m_checkParticleProperties ; ///< Flag to check particle properties. bool m_showBanner; ///< Flag to print the Pythia 8 banner. ICounterLogFile* m_xmlLogTool; ///< The XML log file. - set<unsigned int> m_special; ///< The set of special particles. - set<int> m_bws; ///< Set of particles with a valid BW. + std::set<unsigned int> m_special; ///< The set of special particles. + std::set<int> m_bws; ///< Set of particles with a valid BW. }; #endif // LBPYTHIA8_PYTHIA8PRODUCTION_H diff --git a/Gen/LbPythia8/src/Lib/Pythia8Production.cpp b/Gen/LbPythia8/src/Lib/Pythia8Production.cpp index afe707295..d5004ef2b 100755 --- a/Gen/LbPythia8/src/Lib/Pythia8Production.cpp +++ b/Gen/LbPythia8/src/Lib/Pythia8Production.cpp @@ -30,7 +30,8 @@ //============================================================================= // Default constructor. //============================================================================= -Pythia8Production::Pythia8Production(const string& type, const string& name, +Pythia8Production::Pythia8Production(const std::string& type, + const std::string& name, const IInterface* parent) : GaudiTool(type, name, parent), m_pythia(0), m_hooks(0), m_lhaup(0), m_beamTool(0), m_pythiaBeamTool(0), m_randomEngine(0), m_nEvents(0), @@ -123,7 +124,7 @@ StatusCode Pythia8Production::initialize() { m_xmlLogTool = tool<ICounterLogFile >("XmlCounterLogFile"); // Create the Pythia 8 generator. - string xmlpath("UNKNOWN" != System::getEnv("PYTHIA8XML") ? + std::string xmlpath("UNKNOWN" != System::getEnv("PYTHIA8XML") ? System::getEnv("PYTHIA8XML") : ""); m_pythia = new Pythia8::Pythia(xmlpath, m_showBanner); if (!m_pythia) return StatusCode::FAILURE; @@ -141,7 +142,7 @@ StatusCode Pythia8Production::initialize() { // Add LhcbHooks parameters. Pythia8::Settings &set = m_pythia->settings; - string sm("StandardModel:"), mpi("MultiPartonInteractions:"), + std::string sm("StandardModel:"), mpi("MultiPartonInteractions:"), pre("LhcbHooks:"), parm("pT0Ref"); set.addParm(pre + parm, set.parm(mpi + parm), false, false, 0, 0); parm = "ecmRef"; @@ -196,19 +197,19 @@ StatusCode Pythia8Production::initializeGenerator() { // Turn off minimum bias if using LHAup. if (m_lhaup) { - vector<string> procs; procs.push_back("SoftQCD:"); + std::vector<std::string> procs; procs.push_back("SoftQCD:"); procs.push_back("HardQCD:"); procs.push_back("Onia:"); procs.push_back("Charmonium:"); procs.push_back("Bottomonium:"); for (unsigned int proc = 0; proc < procs.size(); ++proc) { - map<string, Pythia8::FVec> fvecs = + std::map<std::string, Pythia8::FVec> fvecs = m_pythia->settings.getFVecMap(procs[proc]); - map<string, Pythia8::Flag> flags = + std::map<std::string, Pythia8::Flag> flags = m_pythia->settings.getFlagMap(procs[proc]); - for(map<string, Pythia8::FVec>::iterator itr = fvecs.begin(); + for(std::map<std::string, Pythia8::FVec>::iterator itr = fvecs.begin(); itr != fvecs.end(); ++itr) - m_pythia->settings.fvec(itr->first, vector<bool> + m_pythia->settings.fvec(itr->first, std::vector<bool> (itr->second.valNow.size(), false)); - for(map<string, Pythia8::Flag>::iterator itr = flags.begin(); + for(std::map<std::string, Pythia8::Flag>::iterator itr = flags.begin(); itr != flags.end(); ++itr) m_pythia->settings.flag(itr->first, false); } @@ -234,7 +235,7 @@ StatusCode Pythia8Production::initializeGenerator() { } // Check the Breit-Wigner mass thresholds. - for (set<int>::iterator id = m_bws.begin(); id != m_bws.end(); ++id) { + for (std::set<int>::iterator id = m_bws.begin(); id != m_bws.end(); ++id) { Pythia8::ParticleDataEntry *pde = m_pythia->particleData.particleDataEntryPtr(*id); if (pde->isResonance()) continue; @@ -272,7 +273,7 @@ StatusCode Pythia8Production::finalize() { m_pythia->stat(); // Write the cross-sections to the XML log. - vector<int> codes = m_pythia->info.codesHard(); + std::vector<int> codes = m_pythia->info.codesHard(); for (unsigned int code = 0; code < codes.size(); ++code) m_xmlLogTool->addCrossSection(m_pythia->info.nameProc(codes[code]), codes[code], @@ -301,44 +302,39 @@ StatusCode Pythia8Production::generateEvent(HepMC::GenEvent* theEvent, if (!m_pythia->flag("HadronLevel:all")) m_event = m_pythia->event; ++m_nEvents; - IDataProviderSvc* fileRecordSvc = svc<IDataProviderSvc>("FileRecordDataSvc", true); - std::string FSRName = LHCb::GenFSRLocation::Default; - LHCb::GenFSR* genFSR = getIfExists<LHCb::GenFSR>(fileRecordSvc, FSRName); - int key = 0; - - vector<int> codes = m_pythia->info.codesHard(); - - // Store the minimum bias cross-section in the GenFSR - key = LHCb::CrossSectionsFSR::CrossSectionKeyToType("MBCrossSection"); - - if(genFSR->hasGenCounter(key+100)) - { - longlong count = genFSR->getGenCounterInfo(100+key).second; + // Grab the file service. + IDataProviderSvc* fileRecordSvc = svc<IDataProviderSvc> + ("FileRecordDataSvc", true); + LHCb::GenFSR* genFSR = getIfExists<LHCb::GenFSR> + (fileRecordSvc, LHCb::GenFSRLocation::Default); + + // Store the minimum bias cross-section in the GenFSR. + std::vector<int> codes = m_pythia->info.codesHard(); + int key = LHCb::CrossSectionsFSR::CrossSectionKeyToType("MBCrossSection"); + if (genFSR->hasGenCounter(key+100)) { + longlong count = genFSR->getGenCounterInfo(100 + key).second; count = m_pythia->info.nAccepted(key) - count; - if(count > 0) genFSR->incrementGenCounter(key+100, count); - } - else if (m_pythia->info.nAccepted(key) != 0) - genFSR->addGenCounter(100+key, m_pythia->info.nAccepted(key)); - - if(genFSR->hasCrossSection(key)) genFSR->eraseCrossSection(key); - genFSR->addCrossSection(key,LHCb::GenFSR::CrossValues("Total cross-section", m_pythia->info.sigmaGen(key))); - - // Store the others cross-sections in the GenFSR - for (unsigned int code = 0; code < codes.size(); ++code) - { + if (count > 0) genFSR->incrementGenCounter(key + 100, count); + } else if (m_pythia->info.nAccepted(key) != 0) + genFSR->addGenCounter(100 + key, m_pythia->info.nAccepted(key)); + if (genFSR->hasCrossSection(key)) genFSR->eraseCrossSection(key); + genFSR->addCrossSection + (key, LHCb::GenFSR::CrossValues("Total cross-section", + m_pythia->info.sigmaGen(key))); + + // Store the others cross-sections in the GenFSR. + for (unsigned int code = 0; code < codes.size(); ++code) { key = codes[code]; - - if(genFSR->hasGenCounter(key+100)) - { - longlong count = genFSR->getGenCounterInfo(100+key).second; + if (genFSR->hasGenCounter(key + 100)) { + longlong count = genFSR->getGenCounterInfo(100 + key).second; count = m_pythia->info.nAccepted(key) - count; - if(count > 0) genFSR->incrementGenCounter(key+100, count); - } - else if (m_pythia->info.nAccepted(key) != 0) - genFSR->addGenCounter(100+key, m_pythia->info.nAccepted(key)); - - if(genFSR->hasCrossSection(key)) genFSR->eraseCrossSection(key); - genFSR->addCrossSection(key,LHCb::GenFSR::CrossValues(m_pythia->info.nameProc(key),m_pythia->info.sigmaGen(key))); + if (count > 0) genFSR->incrementGenCounter(key + 100, count); + } else if (m_pythia->info.nAccepted(key) != 0) + genFSR->addGenCounter(100 + key, m_pythia->info.nAccepted(key)); + if (genFSR->hasCrossSection(key)) genFSR->eraseCrossSection(key); + genFSR->addCrossSection + (key, LHCb::GenFSR::CrossValues(m_pythia->info.nameProc(key), + m_pythia->info.sigmaGen(key))); } // Convert the event to HepMC and return. @@ -415,7 +411,7 @@ void Pythia8Production::updateParticleProperties(const LHCb::ParticleProperty* // Create the particle if needed. int id = pythia8Id(thePP); - string name = thePP->name(); + std::string name = thePP->name(); Pythia8::ParticleData &pd = m_pythia->particleData; if (id == 0) { const LHCb::ParticleID pid = thePP->pid(); -- GitLab From 1212dc7a7626a86c18e6aa56686f98306ebfbd9b Mon Sep 17 00:00:00 2001 From: philten <philten@cern.ch> Date: Thu, 26 Apr 2018 16:49:29 +0100 Subject: [PATCH 4/4] Fixed removal of namespace std for LbPowheg. --- Gen/LbPowheg/src/component/PowhegProduction.cpp | 2 +- Gen/LbPowheg/src/component/PowhegProduction.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gen/LbPowheg/src/component/PowhegProduction.cpp b/Gen/LbPowheg/src/component/PowhegProduction.cpp index 52298cbd0..10c9e6c4a 100644 --- a/Gen/LbPowheg/src/component/PowhegProduction.cpp +++ b/Gen/LbPowheg/src/component/PowhegProduction.cpp @@ -90,7 +90,7 @@ StatusCode PowhegProduction::hardInitialize() { if (!m_beamTool) return Error("Beam tool not initialized."); Gaudi::XYZVector pBeam1, pBeam2; m_beamTool->getMeanBeams(pBeam1, pBeam2); - stringstream eBeam1("ebeam1 "), eBeam2("ebeam2 "); + std::stringstream eBeam1("ebeam1 "), eBeam2("ebeam2 "); eBeam1 << sqrt(pBeam1.Mag2()) / Gaudi::Units::GeV; eBeam2 << sqrt(pBeam2.Mag2()) / Gaudi::Units::GeV; m_defaultSettings.push_back(eBeam1.str()); diff --git a/Gen/LbPowheg/src/component/PowhegProduction.h b/Gen/LbPowheg/src/component/PowhegProduction.h index aba65928a..20ef72b18 100644 --- a/Gen/LbPowheg/src/component/PowhegProduction.h +++ b/Gen/LbPowheg/src/component/PowhegProduction.h @@ -60,10 +60,10 @@ public: private: // Members. - CommandVector m_defaultSettings; ///< The default settings. - string m_proc; ///< The POWHEG process. - map<string, int> m_procs; ///< The POWHEG process map (int is nFinal). - Pythia8::PowhegProcs *m_powheg; ///< The actual POWHEG process container. + CommandVector m_defaultSettings; ///< The default settings. + std::string m_proc; ///< The POWHEG process. + std::map<std::string, int> m_procs; /// The POWHEG process map for nFinal. + Pythia8::PowhegProcs *m_powheg; ///< The actual POWHEG process container. }; #endif // LBPOWHEG_POWHEGPRODUCTION_H -- GitLab