LCIO
02.17
|
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 | |
PIDHandler & | operator= (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 ¶meterNames) |
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::string & | getAlgorithmName (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::ParticleID & | getParticleID (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::StringVec & | getParameterNames (int algorithmID) |
The names of parameters for the algorithm with algorithmID - throws UnknownAlgoritm. More... | |
const EVENT::IntVec & | getAlgorithmIDs () |
Return the IDs of all known Algorithms. More... | |
void | setParticleID (EVENT::LCObject *p, int userType, int PDG, float likelihood, int algorithmID, const EVENT::FloatVec ¶ms) |
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 |
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.
Definition at line 33 of file PIDHandler.h.
|
private |
Definition at line 35 of file PIDHandler.h.
|
private |
Definition at line 37 of file PIDHandler.h.
|
private |
Definition at line 36 of file PIDHandler.h.
|
default |
|
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.
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().
int UTIL::PIDHandler::addAlgorithm | ( | const std::string & | algoName, |
const EVENT::StringVec & | parameterNames | ||
) |
Add a new algorithm and return the corresponding algorithm id.
Definition at line 127 of file PIDHandler.cc.
References _cpm, _cpmInv, _ids, _pNames, std::map< K, T >::end(), std::map< K, T >::find(), std::map< K, T >::insert(), std::make_pair(), UTIL::CollectionParameterMap::map(), nextID(), std::vector< T >::push_back(), and std::stringstream::str().
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().
|
protected |
Definition at line 41 of file PIDHandler.cc.
References _cpm, _cpmInv, _ids, _maxID, _pNames, _type, std::map< K, T >::begin(), UTIL::Cluster, std::map< K, T >::end(), std::map< K, T >::find(), EVENT::LCCollection::getParameters(), EVENT::LCParameters::getStringVals(), EVENT::LCCollection::getTypeName(), std::map< K, T >::insert(), std::make_pair(), UTIL::CollectionParameterMap::map(), std::vector< T >::push_back(), UTIL::ReconstructedParticle, and std::stringstream::str().
Referenced by PIDHandler().
|
inlineprotected |
|
delete |
void UTIL::PIDHandler::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.
Definition at line 367 of file PIDHandler.cc.
References _pNames, _type, std::map< K, T >::end(), std::map< K, T >::find(), getParticleIDs(), IMPL::ParticleIDImpl::parameters(), std::vector< T >::resize(), IMPL::ParticleIDImpl::setAlgorithmType(), IMPL::ParticleIDImpl::setLikelihood(), IMPL::ParticleIDImpl::setPDG(), IMPL::ParticleIDImpl::setType(), std::vector< T >::size(), std::map< K, T >::size(), and std::stringstream::str().
void UTIL::PIDHandler::setParticleIDUsed | ( | IMPL::ReconstructedParticleImpl * | particle, |
int | algorithmID | ||
) |
Set the particleID algorithm that is used for this particle's kinematic variables.
Definition at line 232 of file PIDHandler.cc.
References _pNames, std::map< K, T >::end(), std::map< K, T >::find(), IMPL::ReconstructedParticleImpl::getParticleIDs(), IMPL::ReconstructedParticleImpl::setParticleIDUsed(), std::vector< T >::size(), and std::stringstream::str().
|
protected |
Definition at line 123 of file PIDHandler.h.
Referenced by ~PIDHandler().
|
protected |
Definition at line 124 of file PIDHandler.h.
Referenced by addAlgorithm(), getAlgorithmID(), and init().
|
protected |
Definition at line 128 of file PIDHandler.h.
Referenced by addAlgorithm(), getAlgorithmName(), init(), and ~PIDHandler().
|
protected |
Definition at line 129 of file PIDHandler.h.
Referenced by addAlgorithm(), getAlgorithmIDs(), and init().
|
protected |
Definition at line 126 of file PIDHandler.h.
|
protected |
Definition at line 127 of file PIDHandler.h.
Referenced by addAlgorithm(), getParameterIndex(), getParameterNames(), getParticleID(), getParticleIDs(), init(), setParticleID(), setParticleIDUsed(), and ~PIDHandler().
|
protected |
Definition at line 125 of file PIDHandler.h.
Referenced by getParticleID(), getParticleIDs(), init(), and setParticleID().