29 #include "core/kernel/WKernel.h"
30 #include "WFilterPropertyHandler.h"
36 m_protonData( protonData ),
37 m_properties( properties ),
38 m_dataUpdate( dataUpdate )
96 "Show or hide primaries. One can either hide primaries or secondaries, but not both at the same time.",
97 true, notifierCheckBox );
99 "Show or hide secondaries. One can either hide primaries or secondaries, but not both at the same time.",
100 true, notifierCheckBox );
105 int pdgColumnIndex =
m_protonData->getColumnIndexBySelection(
"Particle Data Group" );
107 if( pdgColumnIndex < 0 )
112 for(
size_t idx = 0; idx <
m_protonData->getCSVData()->size(); idx++ )
114 std::vector< std::string > row =
m_protonData->getCSVData()->at( idx );
115 std::string rowContent = row.at( pdgColumnIndex );
117 int currentParticleID = -1;
121 currentParticleID = ( int ) boost::lexical_cast< double >( rowContent );
123 catch(
const boost::bad_lexical_cast &e )
125 std::string errorMessage =
"The selected column has an incorrect format. Received: " +
126 rowContent +
". Required: Numbers are expected. " +
127 std::string( e.what() );
181 "Filtering/Rename or Delete Particle-Name" );
187 "To submit your entry press enter while you are in the textbox.",
199 if( selectedPdg.
empty() )
204 std::string particleName = selectedPdg.
at( 0 )->getName();
205 return particleName.substr( 0, particleName.find(
" (" ) );
214 "To submit your entry press enter while you are in the textbox.",
229 for(
size_t i = 0; i < selectedItems.
size(); ++i )
272 std::fstream pdgSignFile;
274 std::string particleName;
279 if( !pdgSignFile.is_open() )
283 throw WException(
"Failed to copy particle name file into homedir" );
288 std::getline( pdgSignFile, dataRow );
289 while( std::getline( pdgSignFile, dataRow ) )
291 std::istringstream iss( dataRow );
292 iss >> particleName >> pdg;
301 BM_PDG::right_const_iterator pdg_iter =
m_PdgNamesByID.right.find( pdg );
303 return pdg_iter !=
m_PdgNamesByID.right.end() ? pdg_iter->second :
"Unknown";
308 BM_PDG::left_const_iterator pdg_iter =
m_PdgNamesByID.left.find( particleName.substr( 0, particleName.find(
" (" ) ) );
315 std::regex regexp(
"[-+0-9]+" );
317 std::regex_search( particleName, m, regexp );
319 return std::stoi( m[0] );
324 BM_PDG::right_iterator pdg_iter =
m_PdgNamesByID.right.find( pdg );
328 bool success_replace =
m_PdgNamesByID.right.replace_data( pdg_iter, newParticleName );
329 if( !success_replace )
331 throw WException(
"You cannot choose the same particle name twice" );
344 std::ofstream pdgSignFile;
347 if( !pdgSignFile.is_open() )
349 throw WException(
"File could not be opened!" );
353 pdgSignFile << pdgNameIterator->left <<
" " << pdgNameIterator->right <<
"\n";
365 std::ifstream src( shareDirFile, std::ios::binary );
366 std::ofstream dest( homeDirFile, std::ios::binary );
WPropBool getShowSecondaries()
Getter.
void createCheckBoxForPrimaryAndSecondary()
Create the Checkbox for primaries and secondaries.
BM_PDG m_PdgNamesByID
A Map of the PDG and their names.
WPropBool getShowPrimaries()
Getter.
void createPDGMap(std::string path)
creates a bimap out of the names and ids of PDG txt
std::string getParticleNameFilePath()
WPropBool m_showPrimaries
Decides whether to hide or show primaries.
void createMultiSelectionForPDG()
Create the multiselection for the option of PDG.
void writePdgMapInParticleNameFile()
write the BiMap in the Pdg particle name file
WPropSelection m_multiSelection
Stores users selected items.
WPropGroup m_filteringsubGroup
Stores subgroup for change the pdg-Name.
void updateProperty()
update current group property and subproperty
WPropSelection m_PdgForRenameSelection
A property to select one pdg to change.
boost::function< void() > CallbackPtr
shared_ptr that points to itself
WFilterPropertyHandler::CallbackPtr m_dataUpdate
A function variable that reinitializes the WDataSets.
WFilterPropertyHandler(WProtonData::SPtr protonData, WPropertyGroup::SPtr properties, WFilterPropertyHandler::CallbackPtr dataUpdate)
constructor
void createProperties()
creates the group property and the subproperty
std::string setDefaultForRenameField()
Set the default string for the string property textfield.
int getPdgFromName(std::string particleName)
Search the pdg in the map with a given particlename.
void changePdgBiMap(int pdg, std::string newParticleName)
set or replace a particlename and pdg in the bimap
WPropBool m_showSecondaries
Decides whether to hide or show secondaries.
int m_currentColumnIndex
The current column that is selected as particle data group.
void updatePDGProperties()
Update PDG Properties (Multiselector and change-Name-Properties)
WPropGroup m_filteringGroup
Property group for filtering options.
void searchPDGTypes()
Collect all particle types from your input data.
bool copyFileToHomePath(std::string shareDirFile, std::string homeDirFile)
Helperfunction to copy the particlename file.
WPropString m_inputNewParticleName
A string for the new particle name.
WProtonData::SPtr m_protonData
Pointer to the content and header of the CSV.
void createPropToSetParticleNames()
Create the Subgroup for change of PDG names.
WPropertyBase::PropertyChangeNotifierType m_notifierSetParticleName
A notifier for the Changeevents of the Rename PDG property.
std::shared_ptr< WItemSelection > m_particleItemSelectionList
Stores selectable items.
void selectPdgAndSaveEvent(WPropertyBase::SPtr property)
Event of the save button in the rename pdg subgroup.
std::string getParticleNameFromPdg(int pdg)
Seatch the ParticleName in the map with a given pdg.
void updateCheckboxProperty(WPropertyBase::SPtr property)
Reload data when properties for selection of primaries and secondaries changed.
int getPdgFromUnkownParticle(std::string particleName)
get the PDG number of an unknown particle element with the help of regex
void updateSelectedPDGTypes()
Update the m_selectedPDGTypes.
WPropertyGroup::SPtr m_properties
A property variable that is generated by the WModul.
BM_PDG::value_type PdgElement
represent an Element of a pdg and a particlename for the map
std::vector< int > m_pdgTypes
Stores every unique particle id.
bool isPDGTypeSelected(int pdgType)
Check whether the PDG type is contained in the m_selectedPDGTypes.
A class containing a list of named items.
std::shared_ptr< WItemSelection > SPtr
Convenience typedef for a std::shared_ptr< WItemSelection >
This class represents a subset of a WItemSelection.
virtual bool empty() const
True if the selection is empty.
virtual const std::shared_ptr< WItemSelectionItem > at(size_t index) const
Gets the selected item with the given index.
virtual size_t size() const
The number of selected items.
static boost::filesystem::path getHomePath()
The path to the OW dir in the user's home.
boost::function< void(std::shared_ptr< WPropertyBase >)> PropertyChangeNotifierType
Signal signature emitted during set operations.
std::shared_ptr< WPropertyBase > SPtr
Convenience typedef for a std::shared_ptr< WPropertyBase >
std::shared_ptr< WPropertyGroup > SPtr
shared pointer to object of this type
std::shared_ptr< WProtonData > SPtr
shared_ptr that points to itself
static std::string getPDG()
getter
static std::string getParentId()
getter
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.