Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F19247324
D127.1759119817.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D127.1759119817.diff
View Options
diff --git a/History.md b/History.md
--- a/History.md
+++ b/History.md
@@ -11,6 +11,9 @@
===
## R02-0X-00
+1 Aug 2024 Fernando Abudinen
+* D127: Improve FSR mutexing by using `std::lock_guard`.
+
3 July 2024 Fernando Abudinen
* D126: Fix FSR initialisation for thread safety.
- Modified PHOTOS and Sherpa instances to become global static members
diff --git a/src/EvtGenExternal/EvtPHOTOS.cpp b/src/EvtGenExternal/EvtPHOTOS.cpp
--- a/src/EvtGenExternal/EvtPHOTOS.cpp
+++ b/src/EvtGenExternal/EvtPHOTOS.cpp
@@ -50,7 +50,7 @@
void EvtPHOTOS::initialise()
{
- m_photos_mutex.lock();
+ const std::lock_guard<std::mutex> lock( m_photos_mutex );
m_gammaId = EvtPDL::getId( m_photonType );
if ( m_gammaId == EvtId( -1, -1 ) ) {
@@ -62,7 +62,6 @@
m_gammaPDG = EvtPDL::getStdHep( m_gammaId );
if ( m_initialised ) {
- m_photos_mutex.unlock();
return;
}
@@ -100,8 +99,6 @@
#endif
m_initialised = true;
-
- m_photos_mutex.unlock();
}
void EvtPHOTOS::doRadCorr( EvtParticle* theParticle )
@@ -153,20 +150,19 @@
}
}
- m_photos_mutex.lock();
-
- /* Now pass the event to Photos for processing
+ {
+ const std::lock_guard<std::mutex> lock( m_photos_mutex );
+ /* Now pass the event to Photos for processing
* Create a Photos event object */
#ifdef EVTGEN_HEPMC3
- Photospp::PhotosHepMC3Event photosEvent( theEvent.get() );
+ Photospp::PhotosHepMC3Event photosEvent( theEvent.get() );
#else
- Photospp::PhotosHepMCEvent photosEvent( theEvent.get() );
+ Photospp::PhotosHepMCEvent photosEvent( theEvent.get() );
#endif
- // Run the Photos algorithm
- photosEvent.process();
-
- m_photos_mutex.unlock();
+ // Run the Photos algorithm
+ photosEvent.process();
+ }
// Find the number of (outgoing) photons in the event
const int nPhotons = this->getNumberOfPhotons( theVertex );
diff --git a/src/EvtGenExternal/EvtSherpaPhotons.cpp b/src/EvtGenExternal/EvtSherpaPhotons.cpp
--- a/src/EvtGenExternal/EvtSherpaPhotons.cpp
+++ b/src/EvtGenExternal/EvtSherpaPhotons.cpp
@@ -54,13 +54,13 @@
void EvtSherpaPhotons::initialise()
{
- m_sherpa_mutex.lock();
+ // Sherpa initialisation is not thread safe, so we mutex it
+ const std::lock_guard<std::mutex> lock( m_sherpa_mutex );
m_gammaId = EvtPDL::getId( m_photonType );
m_gammaPDG = EvtPDL::getStdHep( m_gammaId );
if ( m_initialised ) {
- m_sherpa_mutex.unlock();
return;
}
@@ -127,8 +127,6 @@
this->updateParticleLists();
m_initialised = true;
-
- m_sherpa_mutex.unlock();
}
std::vector<char*> EvtSherpaPhotons::addParameters()
@@ -257,17 +255,18 @@
blob->AddToOutParticles( daughter_part );
}
- m_sherpa_mutex.lock();
-
- const SHERPA::Initialization_Handler* inithandler =
- m_sherpaGen->GetInitHandler();
- SHERPA::Soft_Photon_Handler* softphotonhandler =
- inithandler->GetSoftPhotonHandler();
+ {
+ // AddRadiation function is not yet thread_safe, so we mutex it
+ const std::lock_guard<std::mutex> lock( m_sherpa_mutex );
- // Simulate the radiation
- softphotonhandler->AddRadiation( blob.get() );
+ const SHERPA::Initialization_Handler* inithandler =
+ m_sherpaGen->GetInitHandler();
+ SHERPA::Soft_Photon_Handler* softphotonhandler =
+ inithandler->GetSoftPhotonHandler();
- m_sherpa_mutex.unlock();
+ // Simulate the radiation
+ softphotonhandler->AddRadiation( blob.get() );
+ }
// Get number of final-state particles
const int nFinal( blob->NOutP() );
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Sep 29, 5:23 AM (18 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6546401
Default Alt Text
D127.1759119817.diff (3 KB)
Attached To
Mode
D127: Use std::lock_guard instead of mutex lock for FSR generators
Attached
Detach File
Event Timeline
Log In to Comment