LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
UTIL::PIDHandler Class Reference

Convenient class for setting and retrieving particle id information attached to ReconstructedParticles. More...

#include <PIDHandler.h>

Public Member Functions

 PIDHandler ()=default
 
 PIDHandler (const PIDHandler &)=delete
 
PIDHandleroperator= (const PIDHandler &)=delete
 
 PIDHandler (const EVENT::LCCollection *col)
 Create PIDHandler for reading from the given collection - read the collection parameters PIDAlgorithmTypeName, PIDAlgorithmTypeID and the corresponding ParameterNames_PIDAlgorithmTypeName if they exist. More...
 
 PIDHandler (EVENT::LCCollection *col)
 Create PIDHandler for setting PID information in the given collection. More...
 
 ~PIDHandler ()
 Update the collection parameter when going out of scope. More...
 
int addAlgorithm (const std::string &algoName, const EVENT::StringVec &parameterNames)
 Add a new algorithm and return the corresponding algorithm id. More...
 
int getAlgorithmID (const std::string &algoName)
 Return the typeID of algorithm algoName - throws UnknownAlgorithm. More...
 
const std::stringgetAlgorithmName (int algoID)
 Return the name of the algorithm with id - throws UnknownAlgorithm. More...
 
int getParameterIndex (int algorithmID, const std::string &pName)
 The index of parameter pName for the algorithm with algorithmID - throws UnknownAlgoritm. More...
 
const EVENT::ParticleIDgetParticleID (EVENT::LCObject *particle, int algorithmID)
 Return the (first) ParticleID object for the given algorithm and particle (or cluster) - throws UnknownAlgorithm. More...
 
EVENT::ParticleIDVec getParticleIDs (EVENT::LCObject *p, int id)
 Return all PID objects for a given algorithm - ordered with decreasing likelihood - throws UnknownAlgorithm. More...
 
void setParticleIDUsed (IMPL::ReconstructedParticleImpl *particle, int algorithmID)
 Set the particleID algorithm that is used for this particle's kinematic variables. More...
 
const EVENT::StringVecgetParameterNames (int algorithmID)
 The names of parameters for the algorithm with algorithmID - throws UnknownAlgoritm. More...
 
const EVENT::IntVecgetAlgorithmIDs ()
 Return the IDs of all known Algorithms. More...
 
void setParticleID (EVENT::LCObject *p, int userType, int PDG, float likelihood, int algorithmID, const EVENT::FloatVec &params)
 Set the particleID information for this particle (or cluster) - throws UnknownAlgorithm. More...
 

Protected Member Functions

int nextID ()
 
void init (const EVENT::LCCollection *col)
 

Protected Attributes

EVENT::LCCollection_col {NULL}
 
CPM _cpm {}
 
int _type {0}
 
int _maxID {0}
 
PNM _pNames {}
 
CPMINV _cpmInv {}
 
EVENT::IntVec _ids {}
 

Private Types

typedef CollectionParameterMap CPM
 
typedef std::map< int,
EVENT::StringVec
PNM
 
typedef std::map
< CPM::map_type::mapped_type,
CPM::map_type::key_type > 
CPMINV
 

Detailed Description

Convenient class for setting and retrieving particle id information attached to ReconstructedParticles.

Use one instance of PIDHandler for one LCCollection only. When used for setting particle id information the scope of the PIDHandler must match that of the collection, as the collection parameters are updated automatically when the PIDHandler object goes out of scope. Reads (and updates) the collection parameters PIDAlgorithmTypeName, PIDAlgorithmTypeID and the corresponding ParameterNames_PIDAlgorithmTypeName for every algorithm used.

See Also
ReconstructedParticle
ParticleID
Author
F.Gaede, DESY
Version
Id:
PIDHandler.h,v 1.2 2010-01-21 16:28:25 gaede Exp

Definition at line 33 of file PIDHandler.h.

Member Typedef Documentation

Definition at line 35 of file PIDHandler.h.

typedef std::map< CPM::map_type::mapped_type , CPM::map_type::key_type > UTIL::PIDHandler::CPMINV
private

Definition at line 37 of file PIDHandler.h.

Definition at line 36 of file PIDHandler.h.

Constructor & Destructor Documentation

UTIL::PIDHandler::PIDHandler ( )
default
UTIL::PIDHandler::PIDHandler ( const PIDHandler )
delete
UTIL::PIDHandler::PIDHandler ( const EVENT::LCCollection col)

Create PIDHandler for reading from the given collection - read the collection parameters PIDAlgorithmTypeName, PIDAlgorithmTypeID and the corresponding ParameterNames_PIDAlgorithmTypeName if they exist.

Definition at line 31 of file PIDHandler.cc.

References init().

UTIL::PIDHandler::PIDHandler ( EVENT::LCCollection col)

Create PIDHandler for setting PID information in the given collection.

  • read and update the collection parameters PIDAlgorithmTypeName, PIDAlgorithmTypeID and the corresponding ParameterNames_PIDAlgorithmTypeName if they exist.

Definition at line 21 of file PIDHandler.cc.

References init().

UTIL::PIDHandler::~PIDHandler ( )

Update the collection parameter when going out of scope.

Definition at line 110 of file PIDHandler.cc.

References _col, _cpmInv, _pNames, std::map< K, T >::begin(), std::map< K, T >::end(), EVENT::LCCollection::parameters(), and EVENT::LCParameters::setValues().

Member Function Documentation

int UTIL::PIDHandler::addAlgorithm ( const std::string algoName,
const EVENT::StringVec parameterNames 
)
int UTIL::PIDHandler::getAlgorithmID ( const std::string algoName)

Return the typeID of algorithm algoName - throws UnknownAlgorithm.

Definition at line 158 of file PIDHandler.cc.

References _cpm, std::map< K, T >::end(), std::map< K, T >::find(), and UTIL::CollectionParameterMap::map().

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

Return the IDs of all known Algorithms.

Definition at line 225 of file PIDHandler.cc.

References _ids.

Referenced by UTIL::LCTOOLS::printClusters(), and UTIL::LCTOOLS::printReconstructedParticles().

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

Return the name of the algorithm with id - throws UnknownAlgorithm.

Definition at line 170 of file PIDHandler.cc.

References _cpmInv, std::map< K, T >::end(), std::map< K, T >::find(), and std::stringstream::str().

Referenced by UTIL::LCTOOLS::printClusters(), and UTIL::LCTOOLS::printReconstructedParticles().

int UTIL::PIDHandler::getParameterIndex ( int  algorithmID,
const std::string pName 
)

The index of parameter pName for the algorithm with algorithmID - throws UnknownAlgoritm.

Definition at line 185 of file PIDHandler.cc.

References _pNames, std::map< K, T >::end(), std::map< K, T >::find(), std::vector< T >::size(), and std::stringstream::str().

const StringVec & UTIL::PIDHandler::getParameterNames ( int  algorithmID)

The names of parameters for the algorithm with algorithmID - throws UnknownAlgoritm.

Definition at line 212 of file PIDHandler.cc.

References _pNames, std::map< K, T >::end(), std::map< K, T >::find(), and std::stringstream::str().

Referenced by UTIL::LCTOOLS::printClusters(), and UTIL::LCTOOLS::printReconstructedParticles().

const ParticleID & UTIL::PIDHandler::getParticleID ( EVENT::LCObject particle,
int  algorithmID 
)

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.

Definition at line 323 of file PIDHandler.cc.

References _pNames, _type, std::map< K, T >::end(), std::map< K, T >::find(), getParticleIDs(), std::vector< T >::size(), and std::stringstream::str().

ParticleIDVec UTIL::PIDHandler::getParticleIDs ( EVENT::LCObject p,
int  id 
)

Return all PID objects for a given algorithm - ordered with decreasing likelihood - throws UnknownAlgorithm.

Definition at line 280 of file PIDHandler.cc.

References _pNames, _type, std::map< K, T >::end(), std::map< K, T >::find(), std::vector< T >::push_back(), std::vector< T >::size(), and std::stringstream::str().

Referenced by getParticleID(), and setParticleID().

void UTIL::PIDHandler::init ( const EVENT::LCCollection col)
protected
int UTIL::PIDHandler::nextID ( )
inlineprotected

Definition at line 119 of file PIDHandler.h.

References _maxID.

Referenced by addAlgorithm().

PIDHandler& UTIL::PIDHandler::operator= ( const PIDHandler )
delete
void UTIL::PIDHandler::setParticleID ( EVENT::LCObject p,
int  userType,
int  PDG,
float  likelihood,
int  algorithmID,
const EVENT::FloatVec params 
)
void UTIL::PIDHandler::setParticleIDUsed ( IMPL::ReconstructedParticleImpl particle,
int  algorithmID 
)

Member Data Documentation

EVENT::LCCollection* UTIL::PIDHandler::_col {NULL}
protected

Definition at line 123 of file PIDHandler.h.

Referenced by ~PIDHandler().

CPM UTIL::PIDHandler::_cpm {}
protected

Definition at line 124 of file PIDHandler.h.

Referenced by addAlgorithm(), getAlgorithmID(), and init().

CPMINV UTIL::PIDHandler::_cpmInv {}
protected

Definition at line 128 of file PIDHandler.h.

Referenced by addAlgorithm(), getAlgorithmName(), init(), and ~PIDHandler().

EVENT::IntVec UTIL::PIDHandler::_ids {}
protected

Definition at line 129 of file PIDHandler.h.

Referenced by addAlgorithm(), getAlgorithmIDs(), and init().

int UTIL::PIDHandler::_maxID {0}
protected

Definition at line 126 of file PIDHandler.h.

Referenced by init(), and nextID().

PNM UTIL::PIDHandler::_pNames {}
protected
int UTIL::PIDHandler::_type {0}
protected

Definition at line 125 of file PIDHandler.h.

Referenced by getParticleID(), getParticleIDs(), init(), and setParticleID().


The documentation for this class was generated from the following files: