Skip to content

Commit

Permalink
Make PIDHandler usable as a const object
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Apr 12, 2024
1 parent 53c37ea commit c4b8d80
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/cpp/include/UTIL/CollectionParameterMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace UTIL{
*/
map_type& map() { return _map ; }

const map_type& map() const { return _map; }

protected:

Expand Down
14 changes: 7 additions & 7 deletions src/cpp/include/UTIL/PIDHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,27 @@ namespace UTIL{

/** Return the typeID of algorithm algoName - throws UnknownAlgorithm.
*/
int getAlgorithmID( const std::string& algoName ) ;
int getAlgorithmID( const std::string& algoName ) const ;

/** Return the name of the algorithm with id - throws UnknownAlgorithm.
*/
const std::string& getAlgorithmName( int algoID ) ;
const std::string& getAlgorithmName( int algoID ) const ;

/** The index of parameter pName for the algorithm with algorithmID - throws UnknownAlgoritm.
*/
int getParameterIndex( int algorithmID, const std::string& pName ) ;
int getParameterIndex( int algorithmID, const std::string& pName ) const;

/** Return the (first) ParticleID object for the given algorithm and particle (or cluster) - throws UnknownAlgorithm.
* If no object is found for the given algorithmID a default initialized dummy object is returned.
* Only use if you know there is only one PID object for the algorithms or if you simply want the most likely
* PID for this algorithm.
*/
const EVENT::ParticleID& getParticleID( EVENT::LCObject* particle , int algorithmID ) ;
const EVENT::ParticleID& getParticleID( EVENT::LCObject* particle , int algorithmID ) const ;


/** Return all PID objects for a given algorithm - ordered with decreasing likelihood - throws UnknownAlgorithm.
*/
EVENT::ParticleIDVec getParticleIDs( EVENT::LCObject* p , int id ) ;
EVENT::ParticleIDVec getParticleIDs( EVENT::LCObject* p , int id ) const ;


/** Set the particleID algorithm that is used for this particle's kinematic variables
Expand All @@ -97,11 +97,11 @@ namespace UTIL{

/** The names of parameters for the algorithm with algorithmID - throws UnknownAlgoritm.
*/
const EVENT::StringVec& getParameterNames( int algorithmID ) ;
const EVENT::StringVec& getParameterNames( int algorithmID ) const;

/** Return the IDs of all known Algorithms.
*/
const EVENT::IntVec& getAlgorithmIDs() ;
const EVENT::IntVec& getAlgorithmIDs() const;


/** Set the particleID information for this particle (or cluster) - throws UnknownAlgorithm.
Expand Down
28 changes: 14 additions & 14 deletions src/cpp/src/UTIL/PIDHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ namespace UTIL{
return id ;
}

int PIDHandler::getAlgorithmID( const std::string& algoName ) {
int PIDHandler::getAlgorithmID( const std::string& algoName ) const {

CPM::map_type::iterator it = _cpm.map().find( algoName ) ;
const auto it = _cpm.map().find( algoName ) ;

if( it == _cpm.map().end() ){

Expand All @@ -167,9 +167,9 @@ namespace UTIL{
return it->second ;
}

const std::string& PIDHandler::getAlgorithmName( int algoID ) {
const std::string& PIDHandler::getAlgorithmName( int algoID ) const {

CPMINV::iterator it = _cpmInv.find( algoID ) ;
const auto it = _cpmInv.find( algoID ) ;

if( it == _cpmInv.end() ){

Expand All @@ -182,10 +182,10 @@ namespace UTIL{



int PIDHandler::getParameterIndex( int algorithmID, const std::string& name ) {
int PIDHandler::getParameterIndex( int algorithmID, const std::string& name ) const {


PNM::iterator nit = _pNames.find( algorithmID ) ;
const auto nit = _pNames.find( algorithmID ) ;

if( nit == _pNames.end() ){

Expand All @@ -209,9 +209,9 @@ namespace UTIL{
}


const StringVec& PIDHandler::getParameterNames( int id ) {
const StringVec& PIDHandler::getParameterNames( int id ) const {

PNM::iterator nit = _pNames.find( id ) ;
const auto nit = _pNames.find( id ) ;

if( nit == _pNames.end() ){

Expand All @@ -222,7 +222,7 @@ namespace UTIL{
return nit->second ;
}

const IntVec& PIDHandler::getAlgorithmIDs() {
const IntVec& PIDHandler::getAlgorithmIDs() const {

return _ids ;
}
Expand All @@ -231,7 +231,7 @@ namespace UTIL{

void PIDHandler::setParticleIDUsed( ReconstructedParticleImpl* p , int id ) {

PNM::iterator nit = _pNames.find( id ) ;
const auto nit = _pNames.find( id ) ;

if( nit == _pNames.end() ){

Expand Down Expand Up @@ -277,9 +277,9 @@ namespace UTIL{
}


ParticleIDVec PIDHandler::getParticleIDs( LCObject* p , int id ) {
ParticleIDVec PIDHandler::getParticleIDs( LCObject* p , int id ) const {

PNM::iterator nit = _pNames.find( id ) ;
const auto nit = _pNames.find( id ) ;

if( nit == _pNames.end() ){

Expand Down Expand Up @@ -320,9 +320,9 @@ namespace UTIL{
return pidVID ;
}

const ParticleID& PIDHandler::getParticleID( LCObject* p , int id ) {
const ParticleID& PIDHandler::getParticleID( LCObject* p , int id ) const {

PNM::iterator nit = _pNames.find( id ) ;
const auto nit = _pNames.find( id ) ;

if( nit == _pNames.end() ){

Expand Down

0 comments on commit c4b8d80

Please sign in to comment.