From 16b8d23a89728c375bb22c6b5c4ed38d5a363a41 Mon Sep 17 00:00:00 2001 From: Alice Date: Tue, 21 Mar 2017 15:08:29 +0100 Subject: [PATCH] Identifier class now called IdCoder --- examples/PythiaConnector.cpp | 4 +- examples/PythiaConnector.h | 4 +- papas/datatypes/Cluster.h | 12 +-- papas/datatypes/DefinitionsCollections.h | 10 +- papas/datatypes/Event.h | 66 ++++++------ papas/datatypes/HistoryHelper.h | 12 +-- papas/datatypes/{Identifier.h => IdCoder.h} | 34 +++--- papas/datatypes/PFParticle.h | 10 +- papas/datatypes/src/Cluster.cpp | 22 ++-- papas/datatypes/src/Event.cpp | 48 ++++----- papas/datatypes/src/HistoryHelper.cpp | 6 +- .../src/{Identifier.cpp => IdCoder.cpp} | 62 +++++------ papas/datatypes/src/PFParticle.cpp | 4 +- papas/datatypes/src/Particle.cpp | 2 +- papas/datatypes/src/Track.cpp | 6 +- papas/display/src/GTrajectories.cpp | 2 +- papas/graphtools/DefinitionsNodes.h | 4 +- papas/graphtools/Edge.h | 2 +- papas/graphtools/EventRuler.h | 2 +- papas/graphtools/src/Distance.cpp | 4 +- papas/graphtools/src/Edge.cpp | 8 +- papas/graphtools/src/EventRuler.cpp | 12 +-- papas/reconstruction/BlockBuilder.h | 2 +- papas/reconstruction/PFBlock.h | 4 +- papas/reconstruction/PFReconstructor.h | 2 +- .../src/MergedClusterBuilder.cpp | 4 +- papas/reconstruction/src/PFBlock.cpp | 22 ++-- papas/reconstruction/src/PFBlockBuilder.cpp | 2 +- papas/reconstruction/src/PFBlockSplitter.cpp | 4 +- papas/reconstruction/src/PFReconstructor.cpp | 14 +-- papas/reconstruction/src/PapasManager.cpp | 2 +- papas/simulation/Simulator.h | 10 +- papas/simulation/src/Simulator.cpp | 22 ++-- tests/unittest.cpp | 100 +++++++++--------- 34 files changed, 262 insertions(+), 262 deletions(-) rename papas/datatypes/{Identifier.h => IdCoder.h} (82%) rename papas/datatypes/src/{Identifier.cpp => IdCoder.cpp} (70%) diff --git a/examples/PythiaConnector.cpp b/examples/PythiaConnector.cpp index 0ae4068..6353e28 100644 --- a/examples/PythiaConnector.cpp +++ b/examples/PythiaConnector.cpp @@ -197,7 +197,7 @@ void PythiaConnector::writeClustersROOT(const char* fname, const papas::Clusters auto checkClusters = ConvertClustersToPapas(ccoll, 0, // size or 0 for merged - papas::Identifier::ItemType::kEcalCluster, + papas::IdCoder::ItemType::kEcalCluster, 's'); writer.writeEvent(); @@ -207,7 +207,7 @@ void PythiaConnector::writeClustersROOT(const char* fname, const papas::Clusters papas::Clusters PythiaConnector::ConvertClustersToPapas(const fcc::CaloClusterCollection& fccClusters, float size, - papas::Identifier::ItemType itemtype, + papas::IdCoder::ItemType itemtype, char subtype) const { papas::Clusters clusters; for (const auto& c : fccClusters) { diff --git a/examples/PythiaConnector.h b/examples/PythiaConnector.h index 1980d10..489e443 100644 --- a/examples/PythiaConnector.h +++ b/examples/PythiaConnector.h @@ -32,7 +32,7 @@ #include "papas/datatypes/Cluster.h" #include "papas/datatypes/DefinitionsCollections.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/datatypes/Particle.h" #include "papas/reconstruction/PapasManager.h" @@ -52,7 +52,7 @@ class PythiaConnector { papas::ListParticles makePapasParticlesFromGeneratedParticles( const fcc::MCParticleCollection* ptcs); ///< converts pythia particles into Papas type particles papas::Clusters ConvertClustersToPapas(const fcc::CaloClusterCollection& fccClusters, float size, - papas::Identifier::ItemType itemtype, char subtype) const; + papas::IdCoder::ItemType itemtype, char subtype) const; void AddClustersToEDM(const papas::Clusters& papasClusters, fcc::CaloClusterCollection& fccClusters); diff --git a/papas/datatypes/Cluster.h b/papas/datatypes/Cluster.h index 9d9f7b5..215493e 100644 --- a/papas/datatypes/Cluster.h +++ b/papas/datatypes/Cluster.h @@ -3,7 +3,7 @@ #include "TVector3.h" #include "papas/datatypes/Definitions.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include #include @@ -20,20 +20,20 @@ class Cluster { @param[in] energy Cluster energy @param[in] position location of Cluster @param[in] size_m size of cluster (units?) - @param[in] id Identifier type of cluster eg kEcalCluster or kHcalCluster + @param[in] id IdCoder type of cluster eg kEcalCluster or kHcalCluster @param[in] subtype single char describing type of cluster eg s = smeared, t= true, m = merged */ - Cluster(double energy, const TVector3& position, double size_m, unsigned int index, Identifier::ItemType id, + Cluster(double energy, const TVector3& position, double size_m, unsigned int index, IdCoder::ItemType id, char subtype = 't'); /** Constructor: makes new cluster with a new id based on a copy of an existing cluster. The new id must be provided. @param[in] cluster the cluster that is to be "copied" - @param[in] type eg Identifier::kHcalCluster the Identifier type + @param[in] type eg IdCoder::kHcalCluster the IdCoder type @param[in] subtype subtype of cluster eg 'm' for merged, 's' for smeared. Defaults to 'u' for unset. @param[in] val the value that will be used when creating the Cluster identifier and which is used for sorting. When creating a merged cluster it should ideally be set to the total eneergy of the cluster */ - Cluster(const Cluster& cluster, unsigned int index, Identifier::ItemType type, char subtype = 'u', float val = 0.0); + Cluster(const Cluster& cluster, unsigned int index, IdCoder::ItemType type, char subtype = 'u', float val = 0.0); Cluster() = default; Cluster(Cluster&& c); // needed for unordered_map Cluster(const Cluster& cluster) = default; // needed for unordered_map @@ -55,7 +55,7 @@ class Cluster { return s_maxEnergy; }; ///< static that returns max cluster energy (intended for display purposes) protected: - IdType m_uniqueId; ///< Unique Identifier for Cluster + IdType m_uniqueId; ///< Unique IdCoder for Cluster double m_size; ///< Cluster size (radius?) double m_angularSize; ///< Cluster angular size (only valid for non-merged clusters) double m_pt; ///< Transverse momentum (magnitude of p3 in transverse plane) diff --git a/papas/datatypes/DefinitionsCollections.h b/papas/datatypes/DefinitionsCollections.h index dc16e4b..e5614bf 100644 --- a/papas/datatypes/DefinitionsCollections.h +++ b/papas/datatypes/DefinitionsCollections.h @@ -9,7 +9,7 @@ #define DefinitionsCollections_h #include "papas/datatypes/Cluster.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/datatypes/PFParticle.h" #include "papas/datatypes/Particle.h" #include "papas/datatypes/Track.h" @@ -35,9 +35,9 @@ typedef std::unordered_map Tracks; ///< collection of typedef std::unordered_map Blocks; ///< collection of Blocks typedef std::unordered_map Clusters; ///< collection of Clusters -typedef std::unordered_map CollectionPFParticles; ///< collection of PFParticles -typedef std::unordered_map CollectionTracks; ///< collection of Tracks -typedef std::unordered_map CollectionClusters; ///< collection of Clusters -typedef std::unordered_map CollectionBlocks; ///< collection of Clusters +typedef std::unordered_map CollectionPFParticles; ///< collection of PFParticles +typedef std::unordered_map CollectionTracks; ///< collection of Tracks +typedef std::unordered_map CollectionClusters; ///< collection of Clusters +typedef std::unordered_map CollectionBlocks; ///< collection of Clusters } #endif /* DefinitionsCollections_h */ diff --git a/papas/datatypes/Event.h b/papas/datatypes/Event.h index 2142f96..c693583 100644 --- a/papas/datatypes/Event.h +++ b/papas/datatypes/Event.h @@ -2,7 +2,7 @@ #define Event_h #include "papas/datatypes/DefinitionsCollections.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/graphtools/DefinitionsNodes.h" #include "papas/reconstruction/PFBlock.h" @@ -22,7 +22,7 @@ namespace papas { * Examples of typeAndSubtype are: * "es" ecal-smeared * "ps" particle-simulated - * etc see also Identifier class + * etc see also IdCoder class * The types are * e = ecal * h = hcal @@ -51,25 +51,25 @@ class Event { Event(std::shared_ptr hist = std::make_shared(Nodes())); /** * @brief adds a pointer to a Clusters collection (unordered map) into the Event - * @param[in] clusters unordered map of Clusters, all of which have the same Identifier typeAndSubtype. + * @param[in] clusters unordered map of Clusters, all of which have the same IdCoder typeAndSubtype. * The typeAndSubtype will be used as the map index, eg "em" for ecals-merged. */ void addCollection(const Clusters& clusters); /** * @brief adds a pointer to a Tracks collection (unordered map) into the Event - * @param[in] tracks unordered map of Tracks, all of which have the same Identifier typeAndSubtype + * @param[in] tracks unordered map of Tracks, all of which have the same IdCoder typeAndSubtype * The typeAndSubtype will be used as the map index, eg "tt" for track-true. */ void addCollection(const Tracks& tracks); /** * @brief adds a pointer to a Blocks collection (unordered map) into the Event - * @param[in] blocks unordered map of Blocks, all of which have the same Identifier typeAndSubtype + * @param[in] blocks unordered map of Blocks, all of which have the same IdCoder typeAndSubtype * The typeAndSubtype will be used as the map index, eg "br" for blocks-raw. */ void addCollection(const Blocks& blocks); /** * @brief adds a pointer to a PFParticles collection (unordered map) into the Event - * @param[in] blocks unordered map of PFParticles, all of which have the same Identifier typeAndSubtype + * @param[in] blocks unordered map of PFParticles, all of which have the same IdCoder typeAndSubtype * The typeAndSubtype will be used as the map index, eg "pr" for particles-reconstructed. */ void addCollection(const PFParticles& particles); @@ -87,31 +87,31 @@ class Event { void extendHistory(const Nodes& history); /** * @brief returns true if a collection with type and subtype of id is found - * @param[in] id the Identifier of an object + * @param[in] id the IdCoder of an object */ bool hasCollection(IdType id) const; /** * @brief returns true if a collection with matching type and subtype is found - * @param[in] type The type of an object eg Identifier::kEcalCluster + * @param[in] type The type of an object eg IdCoder::kEcalCluster * @param[in] subtype The subtype of an object eg 'm' for merged */ - bool hasCollection(const Identifier::ItemType type, const Identifier::SubType subtype) const; + bool hasCollection(const IdCoder::ItemType type, const IdCoder::SubType subtype) const; /** - * @brief returns true if an object matching the Identifier is found in the Event collections - * @param[in] id the Identifier of an object + * @brief returns true if an object matching the IdCoder is found in the Event collections + * @param[in] id the IdCoder of an object */ bool hasObject(IdType id) const; /** * @brief returns a Clusters collection with typeAndSubtype that match the identifier - * @param[in] id the Identifier of an object + * @param[in] id the IdCoder of an object */ const Clusters& clusters(IdType id) const; /** * @brief returns a Clusters collection matching type and subtype - * @param[in] type The type of an object eg Identifier::kEcalCluster + * @param[in] type The type of an object eg IdCoder::kEcalCluster * @param[in] subtype The subtype of an object eg 'm' for merged */ - const Clusters& clusters(const Identifier::ItemType type, const Identifier::SubType subtype) const; + const Clusters& clusters(const IdCoder::ItemType type, const IdCoder::SubType subtype) const; /** * @brief returns a Clusters collection matching type and subtype as a string * @param[in] typeAndSubtype The type and subtype of an object as a string eg "em" for ecals-merged. @@ -119,7 +119,7 @@ class Event { const Clusters& clusters(const std::string& typeAndSubtype) const; /** * @brief returns a Cluster with the required id - * @param[in] id the Identifier of an object + * @param[in] id the IdCoder of an object */ const Cluster& cluster(IdType id) const { return clusters(id).at(id); }; @@ -127,45 +127,45 @@ class Event { * @brief returns a Tracks collection matching type and subtype * @param[in] subtype The subtype of the track eg 's' for smeared */ - const Tracks& tracks(const Identifier::SubType subtype) const; + const Tracks& tracks(const IdCoder::SubType subtype) const; /** * @brief returns a Tracks collection with typeAndSubtype that match the identifier - * @param[in] id the Identifier of an object + * @param[in] id the IdCoder of an object */ - const Tracks& tracks(IdType id) const { return tracks(Identifier::subtype(id)); }; + const Tracks& tracks(IdType id) const { return tracks(IdCoder::subtype(id)); }; /** * @brief returns a Track with the required id - * @param[in] id the Identifier of an object + * @param[in] id the IdCoder of an object */ const Track& track(IdType id) const { return tracks(id).at(id); }; /** * @brief returns a Particles collection matching type and subtype * @param[in] subtype The subtype of the particle eg 'r' for reconstructed */ - const PFParticles& particles(const Identifier::SubType subtype) const; + const PFParticles& particles(const IdCoder::SubType subtype) const; /** * @brief returns a PFParticles collection with typeAndSubtype that match the identifier - * @param[in] id the Identifier of an object + * @param[in] id the IdCoder of an object */ - const PFParticles& particles(IdType id) const { return particles(Identifier::subtype(id)); }; + const PFParticles& particles(IdType id) const { return particles(IdCoder::subtype(id)); }; /** * @brief returns a PFParticle with the required id - * @param[in] id the Identifier of an object + * @param[in] id the IdCoder of an object */ const PFParticle& particle(IdType id) const { return particles(id).at(id); }; /** * @brief returns a Blocks collection matching type and subtype * @param[in] subtype The subtype of the block eg 'r' for reconstructed */ - const Blocks& blocks(const Identifier::SubType subtype) const; + const Blocks& blocks(const IdCoder::SubType subtype) const; /** * @brief returns a Blocks collection with typeAndSubtype that match the identifier - * @param[in] id the Identifier of an object + * @param[in] id the IdCoder of an object */ - const Blocks& blocks(IdType id) const { return blocks(Identifier::subtype(id)); }; + const Blocks& blocks(IdType id) const { return blocks(IdCoder::subtype(id)); }; /** * @brief returns a Block with the required id - * @param[in] id the Identifier of an object + * @param[in] id the IdCoder of an object */ const PFBlock& block(IdType id) const { return blocks(id).at(id); }; /** @@ -184,7 +184,7 @@ class Event { std::shared_ptr history() const { return m_history; } /** - * @brief resets everything, deletes all the clusters, tracks etc etc and resets the Identifier counter + * @brief resets everything, deletes all the clusters, tracks etc etc and resets the IdCoder counter */ void clear(); void setEventNo(unsigned int eventNo) { m_eventNo = eventNo;} @@ -198,7 +198,7 @@ class Event { template void addCollectionInternal(const std::unordered_map& collection, - std::unordered_map*>& collections); + std::unordered_map*>& collections); /// Unordered map of pointers to unordered map of (concrete) Ecal Clusters CollectionClusters m_ecalClustersCollection; /// Unordered map of pointers to unordered map of (concrete) Hcal Clusters @@ -220,7 +220,7 @@ class Event { template void Event::addCollectionInternal( const std::unordered_map& collection, - std::unordered_map*>& collections) { + std::unordered_map*>& collections) { IdType firstId = 0; if (collection.size() == 0) return; for (const auto& it : collection) { @@ -228,12 +228,12 @@ void Event::addCollectionInternal( firstId = it.first; if (hasCollection(firstId)) throw "Collection already exists"; } - if (Identifier::typeAndSubtype(it.first) != Identifier::typeAndSubtype(firstId)) { - std::cout << Identifier::pretty(it.first) << " : " << Identifier::pretty(firstId) << std::endl; + if (IdCoder::typeAndSubtype(it.first) != IdCoder::typeAndSubtype(firstId)) { + std::cout << IdCoder::pretty(it.first) << " : " << IdCoder::pretty(firstId) << std::endl; throw "more than one typeandSubtype found in collection"; } } - collections.emplace(Identifier::subtype(firstId), &collection); + collections.emplace(IdCoder::subtype(firstId), &collection); } template diff --git a/papas/datatypes/HistoryHelper.h b/papas/datatypes/HistoryHelper.h index 5861dfd..8aa6c19 100644 --- a/papas/datatypes/HistoryHelper.h +++ b/papas/datatypes/HistoryHelper.h @@ -2,7 +2,7 @@ #define HistoryHelper_h #include "papas/datatypes/DefinitionsCollections.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/datatypes/Event.h" #include "papas/graphtools/DirectedAcyclicGraph.h" @@ -21,7 +21,7 @@ namespace papas { //find what is connected to (say) a reconstructed particle auto ids =hhelper.linkedIds(id); //filter the connected ids selecting only the ecals of subtype 'm' - auto fids = hhelper.filteredIds(ids, Identifier::kEcalCluster, 'm'); + auto fids = hhelper.filteredIds(ids, IdCoder::kEcalCluster, 'm'); ... @endcode */ @@ -33,12 +33,12 @@ class HistoryHelper { HistoryHelper(const Event& event); /** * @brief Finds all ids which have a history link with the input id - * @param[in] id Identifier for which we want to find connected items + * @param[in] id IdCoder for which we want to find connected items * @param[in] direction whether to search parents, children or both */ Ids linkedIds(IdType id, DAG::enumVisitType direction = DAG::enumVisitType::UNDIRECTED) const; /** - * @brief Finds all ids which have a history link with the input id and have specified typeAndSubtype * @param[in] id Identifier for which we want to find connected items + * @brief Finds all ids which have a history link with the input id and have specified typeAndSubtype * @param[in] id IdCoder for which we want to find connected items * @param[in] typeAndSubType The identifier type and subtype for which we are searching eg "pr" for a reconstructed particle, should be a string of length 2 * @param[in] direction whether to search parents, children or both @@ -49,10 +49,10 @@ class HistoryHelper { * @brief Filters a vector of ids to find a subset which have the required type and subtype * for example could be used to identify all ids which are merged Ecal clusters. * @param[in] ids vector of identifiers that is to be filtered - * @param[in] type Itemtype for which we are filtering eg Identifier::kEcalCluster + * @param[in] type Itemtype for which we are filtering eg IdCoder::kEcalCluster * @param[in] subtype Subtype for the filtered items eg 'm' for merged */ - Ids filteredIds(Ids ids, const Identifier::ItemType type, const Identifier::SubType subtype) const; + Ids filteredIds(Ids ids, const IdCoder::ItemType type, const IdCoder::SubType subtype) const; /** * @brief Filters a vector of ids to find a subset which have the required typeAndSubtype * for example could be used to identify all ids which are merged Ecal clusters. diff --git a/papas/datatypes/Identifier.h b/papas/datatypes/IdCoder.h similarity index 82% rename from papas/datatypes/Identifier.h rename to papas/datatypes/IdCoder.h index 0ce8b1b..e05d984 100644 --- a/papas/datatypes/Identifier.h +++ b/papas/datatypes/IdCoder.h @@ -1,5 +1,5 @@ -#ifndef Identifier_h -#define Identifier_h +#ifndef IdCoder_h +#define IdCoder_h #include "papas/datatypes/Definitions.h" #include @@ -8,15 +8,15 @@ namespace papas { /** - @brief An Identifier is a uniqueid that contains encoded information about an element + @brief An IdCoder is a uniqueid that contains encoded information about an element - Identifiers are used to uniquely identify all clusters, tracks, blocks etc in PAPAS + IdCoders are used to uniquely identify all clusters, tracks, blocks etc in PAPAS They are also used in Nodes which store the history (linkages) between items. Given an identifier, we can determine the type of an object, for example an ecal_cluster. and then use this to retrieve the cluster from a cluster collection. - The Identifier class consists of a set of static methods that can be used + The IdCoder class consists of a set of static methods that can be used to create(encode) and to dissect(decode) identifiers. The identifier is 64 bits wide and stores info as follows @@ -35,21 +35,21 @@ namespace papas { Usage example: @code - IdType uid=Identifier::MakeId(kEcalCluster, 's', 4.35); + IdType uid=IdCoder::MakeId(kEcalCluster, 's', 4.35); @endcode * * @author Alice Robson * @date 2016-04-06 */ -class Identifier { +class IdCoder { public: - Identifier(){}; + IdCoder(){}; /// @enum the type of the item eg Particle, Cluster etc enum ItemType { kNone = 0, kEcalCluster = 1, kHcalCluster, kTrack, kParticle, kBlock }; typedef char SubType; /** Makes new identifier. - @param[in] type is an enum Identifier::ItemType to say whether this id is for a cluster, particle etc + @param[in] type is an enum IdCoder::ItemType to say whether this id is for a cluster, particle etc @param[in] subtype is a single letter subtype code eg 'm' for merged @param[in] value: a float representing energy or momentum etc @param[in] uniqueid: not used in normal use @@ -60,7 +60,7 @@ class Identifier { /** returns the item type of the the identifier This is one of: None = 0, kEcalCluster = 1, kHcalCluster, kTrack, kParticle, kBlock @param[in] id: the unique identifier - @return an enum Identifier::ItemType + @return an enum IdCoder::ItemType */ static ItemType itemType(IdType id); ///< Returns encoded ItemType eg kParticle etc; @@ -104,32 +104,32 @@ class Identifier { /** boolean test of whether identifier is from an ecal cluster @param ident: unique identifier */ - static bool isEcal(IdType id) { return (Identifier::itemType(id) == kEcalCluster); } + static bool isEcal(IdType id) { return (IdCoder::itemType(id) == kEcalCluster); } /** boolean test of whether identifier is from an hcal cluster @param ident: unique identifier */ - static bool isHcal(IdType id) { return (Identifier::itemType(id) == kHcalCluster); } + static bool isHcal(IdType id) { return (IdCoder::itemType(id) == kHcalCluster); } /** boolean test of whether identifier is from a cluster @param ident: unique identifier */ - static bool isCluster(IdType id) { return (Identifier::isEcal(id) || Identifier::isHcal(id)); } + static bool isCluster(IdType id) { return (IdCoder::isEcal(id) || IdCoder::isHcal(id)); } /** boolean test of whether identifier is from an track @param ident: unique identifier */ - static bool isTrack(IdType id) { return (Identifier::itemType(id) == kTrack); } + static bool isTrack(IdType id) { return (IdCoder::itemType(id) == kTrack); } /** boolean test of whether identifier is from a particle @param ident: unique identifier */ - static bool isParticle(IdType id) { return (Identifier::itemType(id) == kParticle); } + static bool isParticle(IdType id) { return (IdCoder::itemType(id) == kParticle); } /** boolean test of whether identifier is from a block @param ident: unique identifier */ - static bool isBlock(IdType id) { return (Identifier::itemType(id) == kBlock); } + static bool isBlock(IdType id) { return (IdCoder::itemType(id) == kBlock); } /** Uses detector layer to work out what itemType is appropriate @param layer: detector layer as an enumeration eg kEcal @@ -158,4 +158,4 @@ class Identifier { static float bitsToFloat(uint64_t bits); /// convert binary into float }; } // end namespace -#endif /* Identifier_h */ +#endif /* IdCoder_h */ diff --git a/papas/datatypes/PFParticle.h b/papas/datatypes/PFParticle.h index fe7a8ad..8a2a8cb 100644 --- a/papas/datatypes/PFParticle.h +++ b/papas/datatypes/PFParticle.h @@ -4,7 +4,7 @@ #ifndef PFParticle_H #define PFParticle_H -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/datatypes/Particle.h" #include "papas/datatypes/Path.h" @@ -25,7 +25,7 @@ class PFParticle : public Particle { @param[in] vertex start vertex (3d point) @param[in] index index to the collection to which thie particle will belown @param[in] field Magnetic field - @param[in] subtype Identifier subtype to be used when creating unique Identifier eg 'r' for reconstructed + @param[in] subtype IdCoder subtype to be used when creating unique IdCoder eg 'r' for reconstructed */ PFParticle(int pdgid, double charge, const TLorentzVector& tlv, unsigned int index, char subtype = 's', const TVector3& vertex = TVector3(0., 0., 0.), double field = 0. ); /** Constructor @@ -34,7 +34,7 @@ class PFParticle : public Particle { @param[in] tlv 4-momentum, px, py, pz, E @param[in] track The track to use in creating a particle @param[in] index index to the collection to which thie particle will belown - @param[in] subtype Identifier subtype to be used when creating unique Identifier eg 'r' for reconstructed + @param[in] subtype IdCoder subtype to be used when creating unique IdCoder eg 'r' for reconstructed */ PFParticle(int pdgid, double charge, const TLorentzVector& tlv, const Track& track, unsigned int index , char subtype = 'r'); /** check id this position exists in particle path @@ -48,11 +48,11 @@ class PFParticle : public Particle { //void setPath(Path::Ptr path) { m_path = path; } ///< Set ponter to path of particle bool isHelix() const { return m_isHelix; } ///< Helix or straighline const Path::Ptr path() const { return m_path; } ///< Return pointer to path - IdType id() const { return m_uniqueId; } ///< unique Identifier for object + IdType id() const { return m_uniqueId; } ///< unique IdCoder for object bool isElectroMagnetic() const; ///< Is it electroMagnetic const TVector3& vertex() const { return m_vertex; } private: - IdType m_uniqueId; ///< unique Identifier + IdType m_uniqueId; ///< unique IdCoder TVector3 m_vertex; ///< start vertex (3d) Path::Ptr m_path; ///< pointer to path object bool m_isHelix; ///< Boolean to say if path is Helix or straightline diff --git a/papas/datatypes/src/Cluster.cpp b/papas/datatypes/src/Cluster.cpp index 667cace..72691a7 100644 --- a/papas/datatypes/src/Cluster.cpp +++ b/papas/datatypes/src/Cluster.cpp @@ -7,22 +7,22 @@ // #include "papas/datatypes/Cluster.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/utility/PDebug.h" namespace papas { double Cluster::s_maxEnergy = 0; -Cluster::Cluster(double energy, const TVector3& position, double size_m, unsigned int index, Identifier::ItemType idtype, char subtype) - : m_uniqueId(Identifier::makeId(index, idtype, subtype, fmax(0, energy))), m_p3(position), m_subClusters() { +Cluster::Cluster(double energy, const TVector3& position, double size_m, unsigned int index, IdCoder::ItemType idtype, char subtype) + : m_uniqueId(IdCoder::makeId(index, idtype, subtype, fmax(0, energy))), m_p3(position), m_subClusters() { setSize(size_m); setEnergy(energy); m_subClusters.push_back(this); } -Cluster::Cluster(const Cluster& c, unsigned int index, Identifier::ItemType type, char subtype, float val) - : m_uniqueId(Identifier::makeId(index, type, subtype, val)), +Cluster::Cluster(const Cluster& c, unsigned int index, IdCoder::ItemType type, char subtype, float val) + : m_uniqueId(IdCoder::makeId(index, type, subtype, val)), m_size(c.m_size), m_angularSize(c.m_angularSize), m_pt(c.m_pt), @@ -78,7 +78,7 @@ void Cluster::setEnergy(double energy) { } Cluster& Cluster::operator+=(const Cluster& rhs) { - if (Identifier::itemType(m_uniqueId) != Identifier::itemType(rhs.id())) { + if (IdCoder::itemType(m_uniqueId) != IdCoder::itemType(rhs.id())) { throw "can only add a cluster from the same layer"; } m_p3 = m_p3 * m_energy + rhs.position() * rhs.energy(); @@ -97,11 +97,11 @@ Cluster& Cluster::operator+=(const Cluster& rhs) { std::string Cluster::info() const { return string_format("%7.2f %5.2f %5.2f", energy(), theta(), position().Phi()); } std::ostream& operator<<(std::ostream& os, const Cluster& cluster) { - os << "Cluster: " << std::setw(6) << std::left << Identifier::pretty(cluster.id()) << ":" << cluster.id() << ": " + os << "Cluster: " << std::setw(6) << std::left << IdCoder::pretty(cluster.id()) << ":" << cluster.id() << ": " << cluster.info(); os << " sub("; for (auto c : cluster.subClusters()) { - os << Identifier::pretty(c->id()) << ", "; + os << IdCoder::pretty(c->id()) << ", "; } os << ")"; return os; @@ -143,13 +143,13 @@ return *this; }; Cluster::Cluster(const Cluster&) { - PDebug::write("copy cluster {}" , Identifier::pretty(m_uniqueId)); + PDebug::write("copy cluster {}" , IdCoder::pretty(m_uniqueId)); std::cout<< "copy cluster" ; } ;*/ /*Cluster::~Cluster() { - PDebug::write("delete cluster {}" , Identifier::pretty(m_uniqueId)); - std::cout<< " delete cluster " << Identifier::pretty(m_uniqueId) ; + PDebug::write("delete cluster {}" , IdCoder::pretty(m_uniqueId)); + std::cout<< " delete cluster " << IdCoder::pretty(m_uniqueId) ; } ;*/ } // end namespace papas diff --git a/papas/datatypes/src/Event.cpp b/papas/datatypes/src/Event.cpp index b0acf72..a3de8e8 100644 --- a/papas/datatypes/src/Event.cpp +++ b/papas/datatypes/src/Event.cpp @@ -21,7 +21,7 @@ namespace papas { void Event::addCollection(const Clusters& clusters) { // decide if the clusters are from Ecal or Hcal and add to appropriate collection if (clusters.size() == 0) return; - if (Identifier::isEcal(clusters.begin()->first)) + if (IdCoder::isEcal(clusters.begin()->first)) addCollectionInternal(clusters, m_ecalClustersCollection); else addCollectionInternal(clusters, m_hcalClustersCollection); @@ -35,10 +35,10 @@ void Event::addCollection(const PFParticles& particles) { void Event::addCollection(const Blocks& blocks) { addCollectionInternal(blocks, m_blocksCollection); }; -const Clusters& Event::clusters(Identifier::ItemType type, const Identifier::SubType subtype) const { +const Clusters& Event::clusters(IdCoder::ItemType type, const IdCoder::SubType subtype) const { // return the corresponding collection if (!hasCollection(type, subtype)) return m_emptyClusters; - if (type == Identifier::ItemType::kEcalCluster) + if (type == IdCoder::ItemType::kEcalCluster) return *(m_ecalClustersCollection.at(subtype)); else return *(m_hcalClustersCollection.at(subtype)); @@ -46,44 +46,44 @@ const Clusters& Event::clusters(Identifier::ItemType type, const Identifier::Sub const Clusters& Event::clusters(IdType id) const { // return the corresponding collection with the same type and subtype as this id - return clusters(Identifier::itemType(id), Identifier::subtype(id)); + return clusters(IdCoder::itemType(id), IdCoder::subtype(id)); }; const Clusters& Event::clusters(const std::string& typeAndSubtype) const { // return the corresponding collection with this type and subtype - return clusters(Identifier::itemType(typeAndSubtype[0]), typeAndSubtype[1]); + return clusters(IdCoder::itemType(typeAndSubtype[0]), typeAndSubtype[1]); } -const Tracks& Event::tracks(const Identifier::SubType subtype) const { - if (!hasCollection(Identifier::ItemType::kTrack, subtype)) return m_emptyTracks; +const Tracks& Event::tracks(const IdCoder::SubType subtype) const { + if (!hasCollection(IdCoder::ItemType::kTrack, subtype)) return m_emptyTracks; return *m_tracksCollection.at(subtype); } -const PFParticles& Event::particles(const Identifier::SubType subtype) const { - if (!hasCollection(Identifier::ItemType::kParticle, subtype)) return m_emptyPFParticles; +const PFParticles& Event::particles(const IdCoder::SubType subtype) const { + if (!hasCollection(IdCoder::ItemType::kParticle, subtype)) return m_emptyPFParticles; return *m_particlesCollection.at(subtype); } -const Blocks& Event::blocks(const Identifier::SubType subtype) const { - if (!hasCollection(Identifier::ItemType::kBlock, subtype)) return m_emptyBlocks; +const Blocks& Event::blocks(const IdCoder::SubType subtype) const { + if (!hasCollection(IdCoder::ItemType::kBlock, subtype)) return m_emptyBlocks; return *m_blocksCollection.at(subtype); } -bool Event::hasCollection(Identifier::ItemType type, const Identifier::SubType subtype) const { +bool Event::hasCollection(IdCoder::ItemType type, const IdCoder::SubType subtype) const { // Check if this collection is present auto found = false; switch (type) { - case Identifier::kEcalCluster: + case IdCoder::kEcalCluster: found = (m_ecalClustersCollection.find(subtype) != m_ecalClustersCollection.end()); break; - case Identifier::kHcalCluster: + case IdCoder::kHcalCluster: found = (m_hcalClustersCollection.find(subtype) != m_hcalClustersCollection.end()); break; - case Identifier::kTrack: + case IdCoder::kTrack: found = (m_tracksCollection.find(subtype) != m_tracksCollection.end()); break; - case Identifier::kBlock: + case IdCoder::kBlock: found = (m_blocksCollection.find(subtype) != m_blocksCollection.end()); break; - case Identifier::kParticle: + case IdCoder::kParticle: found = (m_particlesCollection.find(subtype) != m_particlesCollection.end()); break; default: @@ -93,26 +93,26 @@ bool Event::hasCollection(Identifier::ItemType type, const Identifier::SubType s }; bool Event::hasCollection(IdType id) const { - return hasCollection(Identifier::itemType(id), Identifier::subtype(id)); + return hasCollection(IdCoder::itemType(id), IdCoder::subtype(id)); }; bool Event::hasObject(IdType id) const { // check if this object id is present auto found = false; - auto type = Identifier::itemType(id); + auto type = IdCoder::itemType(id); if (hasCollection(id)) { switch (type) { - case Identifier::kEcalCluster: - case Identifier::kHcalCluster: + case IdCoder::kEcalCluster: + case IdCoder::kHcalCluster: found = (clusters(id).find(id) != clusters(id).end()); break; - case Identifier::kTrack: + case IdCoder::kTrack: found = (tracks(id).find(id) != tracks(id).end()); break; - case Identifier::kBlock: + case IdCoder::kBlock: found = (blocks(id).find(id) != blocks(id).end()); break; - case Identifier::kParticle: + case IdCoder::kParticle: found = (particles(id).find(id) != particles(id).end()); break; default: diff --git a/papas/datatypes/src/HistoryHelper.cpp b/papas/datatypes/src/HistoryHelper.cpp index 3f4d971..be64929 100644 --- a/papas/datatypes/src/HistoryHelper.cpp +++ b/papas/datatypes/src/HistoryHelper.cpp @@ -25,10 +25,10 @@ Ids HistoryHelper::linkedIds(IdType id, const std::string& typeAndSubtype, DAG:: return fids; } -Ids HistoryHelper::filteredIds(Ids ids, const Identifier::ItemType type, const Identifier::SubType subtype) const { +Ids HistoryHelper::filteredIds(Ids ids, const IdCoder::ItemType type, const IdCoder::SubType subtype) const { Ids matchedIds; for (auto id : ids) { - if (Identifier::itemType(id) == type && Identifier::subtype(id) == subtype) { + if (IdCoder::itemType(id) == type && IdCoder::subtype(id) == subtype) { matchedIds.push_back(id); } } @@ -38,7 +38,7 @@ Ids HistoryHelper::filteredIds(Ids ids, const Identifier::ItemType type, const I Ids HistoryHelper::filteredIds(Ids ids, const std::string& typeAndSubtype) const { Ids matchedIds; for (auto id : ids) { - if (Identifier::typeAndSubtype(id) == typeAndSubtype) { + if (IdCoder::typeAndSubtype(id) == typeAndSubtype) { matchedIds.push_back(id); } } diff --git a/papas/datatypes/src/Identifier.cpp b/papas/datatypes/src/IdCoder.cpp similarity index 70% rename from papas/datatypes/src/Identifier.cpp rename to papas/datatypes/src/IdCoder.cpp index 123637e..48981ea 100644 --- a/papas/datatypes/src/Identifier.cpp +++ b/papas/datatypes/src/IdCoder.cpp @@ -1,4 +1,4 @@ -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/utility/StringFormatter.h" #include #include @@ -16,20 +16,20 @@ namespace papas { // max index value is 2** m_bitshift -IdType Identifier::makeId(unsigned int index, ItemType type, char subt, float val) { +IdType IdCoder::makeId(unsigned int index, ItemType type, char subt, float val) { if (type == kNone) { throw "Id must have a valid type"; } - if (index >= pow(2, m_bitshift) - 1) throw "Identifier unique id is too big: too many identifiers"; + if (index >= pow(2, m_bitshift) - 1) throw "IdCoder unique id is too big: too many identifiers"; // Shift all the parts and join together // NB uint64_t is needed to make sure the shift is carried out over 64 bits, otherwise // if the m_bitshift is 32 or more the shift is undefined and can return 0 IdType typeShift = (uint64_t)type << m_bitshift1; - IdType valueShift = (uint64_t)Identifier::floatToBits(val) << m_bitshift; + IdType valueShift = (uint64_t)IdCoder::floatToBits(val) << m_bitshift; IdType subtypeShift = (uint64_t) static_cast(tolower(subt)) << m_bitshift2; IdType uid = (uint64_t)subtypeShift | (uint64_t)valueShift | (uint64_t)typeShift | index; @@ -37,49 +37,49 @@ IdType Identifier::makeId(unsigned int index, ItemType type, char subt, float va return uid; } -Identifier::ItemType Identifier::itemType(IdType id) { +IdCoder::ItemType IdCoder::itemType(IdType id) { return static_cast((id >> m_bitshift1) & (uint64_t)(pow(2, 3) - 1)); } -char Identifier::subtype(IdType id) { +char IdCoder::subtype(IdType id) { return static_cast((id >> m_bitshift2) & (uint64_t)(pow(2, m_bitshift1 - m_bitshift2) - 1)); } -float Identifier::value(IdType id) { +float IdCoder::value(IdType id) { // shift to extract the required bits int bitvalue = id >> m_bitshift & (uint64_t)(pow(2, m_bitshift2 - m_bitshift) - 1); // convert bits back to float return bitsToFloat(bitvalue); } -unsigned int Identifier::index(IdType id) { return id & (uint64_t)(pow(2, m_bitshift) - 1); } +unsigned int IdCoder::index(IdType id) { return id & (uint64_t)(pow(2, m_bitshift) - 1); } -unsigned int Identifier::uniqueId(IdType id) { +unsigned int IdCoder::uniqueId(IdType id) { //For some purposes we want a smaller uniqueid without the value information //here we consruct a 32 bit uniqueid out of the index and the type and subtype unsigned int bitshift = m_bitshift + m_bitshift1 - m_bitshift2; - IdType typeShift = (uint32_t)Identifier::itemType(id) << bitshift; - IdType subtypeShift = (uint32_t) static_cast(tolower(Identifier::subtype(id))) << m_bitshift; - //binary printout std::cout <<"Index" << std::bitset<32>(Identifier::index(id)) <(tolower(IdCoder::subtype(id))) << m_bitshift; + //binary printout std::cout <<"Index" << std::bitset<32>(IdCoder::index(id)) <((uniqueid >> bitshift) & (uint32_t)(pow(2, 3) - 1)); @@ -142,7 +142,7 @@ bool Identifier::checkValid(IdType uid, ItemType type, char subt, float val, uns -uint64_t Identifier::floatToBits(float value) { +uint64_t IdCoder::floatToBits(float value) { // CHAR_BIT not known on lxplus assert(CHAR_BIT * sizeof(float) == 32); // TODO think of somewhere better to put this union { float value; // assumes sizeof(float) == sizeof(int) @@ -152,7 +152,7 @@ uint64_t Identifier::floatToBits(float value) { return (uint64_t)(data.bits); }; -float Identifier::bitsToFloat(uint64_t bits) { +float IdCoder::bitsToFloat(uint64_t bits) { union { float value; // assumes sizeof(float) == sizeof(int) int bits; diff --git a/papas/datatypes/src/PFParticle.cpp b/papas/datatypes/src/PFParticle.cpp index 0fe2a83..672371e 100644 --- a/papas/datatypes/src/PFParticle.cpp +++ b/papas/datatypes/src/PFParticle.cpp @@ -15,7 +15,7 @@ namespace papas { PFParticle::PFParticle(int pdgid, double charge, const TLorentzVector& tlv, unsigned int index, char subtype, const TVector3& vertex, double field) : Particle(pdgid, charge, tlv), - m_uniqueId(Identifier::makeId(index, Identifier::kParticle, subtype, tlv.E())), + m_uniqueId(IdCoder::makeId(index, IdCoder::kParticle, subtype, tlv.E())), m_vertex(vertex), m_isHelix(fabs(charge) > 0.5) { @@ -45,7 +45,7 @@ bool PFParticle::isElectroMagnetic() const { }; std::ostream& operator<<(std::ostream& os, const PFParticle& particle) { - os << "Particle :" << std::setw(6) << std::left << Identifier::pretty(particle.id()) << ":" << particle.id() << ": " + os << "Particle :" << std::setw(6) << std::left << IdCoder::pretty(particle.id()) << ":" << particle.id() << ": " << particle.info(); return os; } diff --git a/papas/datatypes/src/Particle.cpp b/papas/datatypes/src/Particle.cpp index e628730..6fb4a65 100644 --- a/papas/datatypes/src/Particle.cpp +++ b/papas/datatypes/src/Particle.cpp @@ -10,7 +10,7 @@ */ #include "papas/datatypes/Definitions.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "spdlog/details/format.h" #include //#include //AJRTODO temp diff --git a/papas/datatypes/src/Track.cpp b/papas/datatypes/src/Track.cpp index 2964203..38c0fcf 100644 --- a/papas/datatypes/src/Track.cpp +++ b/papas/datatypes/src/Track.cpp @@ -1,12 +1,12 @@ #include "papas/datatypes/Track.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/utility/PDebug.h" namespace papas { Track::Track(const TVector3& p3, double charge,const Path::Ptr path, unsigned int index, char subtype) - : m_uniqueId(Identifier::makeId(index, Identifier::ItemType::kTrack, subtype, p3.Mag())), + : m_uniqueId(IdCoder::makeId(index, IdCoder::ItemType::kTrack, subtype, p3.Mag())), m_p3(p3), m_charge(charge), m_path(path) {} @@ -16,7 +16,7 @@ std::string Track::info() const { } std::ostream& operator<<(std::ostream& os, const Track& track) { - os << "Track: " << std::setw(6) << std::left << Identifier::pretty(track.id()) << ":" << track.id() << ": " + os << "Track: " << std::setw(6) << std::left << IdCoder::pretty(track.id()) << ":" << track.id() << ": " << track.info(); return os; } diff --git a/papas/display/src/GTrajectories.cpp b/papas/display/src/GTrajectories.cpp index 4236a17..e201b6f 100644 --- a/papas/display/src/GTrajectories.cpp +++ b/papas/display/src/GTrajectories.cpp @@ -8,7 +8,7 @@ #include "papas/datatypes/PFParticle.h" #include "papas/datatypes/Path.h" #include "papas/datatypes/Track.h" -//#include "papas/datatypes/Identifier.h" +//#include "papas/datatypes/IdCoder.h" namespace papas { diff --git a/papas/graphtools/DefinitionsNodes.h b/papas/graphtools/DefinitionsNodes.h index ed72014..923345b 100644 --- a/papas/graphtools/DefinitionsNodes.h +++ b/papas/graphtools/DefinitionsNodes.h @@ -9,7 +9,7 @@ #ifndef DefinitionsNodes_h #define DefinitionsNodes_h -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/graphtools/DirectedAcyclicGraph.h" #include namespace papas { @@ -43,7 +43,7 @@ inline void makeHistoryLinks(const Ids& parentids, const Ids& childids, Nodes& h inline void printHistory(const Nodes& history) { for (auto node : history) for (auto cnode : node.second.children()) - std::cout << Identifier::pretty(node.first) << ":" << Identifier::pretty(cnode->value()) << " "; + std::cout << IdCoder::pretty(node.first) << ":" << IdCoder::pretty(cnode->value()) << " "; } } // end namespace papas diff --git a/papas/graphtools/Edge.h b/papas/graphtools/Edge.h index 7967d26..4f4f16f 100644 --- a/papas/graphtools/Edge.h +++ b/papas/graphtools/Edge.h @@ -1,7 +1,7 @@ #ifndef RECONSTRUCTION_EDGE_H #define RECONSTRUCTION_EDGE_H -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "array" #include diff --git a/papas/graphtools/EventRuler.h b/papas/graphtools/EventRuler.h index 7a8b1af..22236ac 100644 --- a/papas/graphtools/EventRuler.h +++ b/papas/graphtools/EventRuler.h @@ -9,7 +9,7 @@ #define EventRuler_h #include "papas/datatypes/Cluster.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/datatypes/Track.h" #include "papas/graphtools/Ruler.h" #include diff --git a/papas/graphtools/src/Distance.cpp b/papas/graphtools/src/Distance.cpp index a33fe55..133dad1 100644 --- a/papas/graphtools/src/Distance.cpp +++ b/papas/graphtools/src/Distance.cpp @@ -7,7 +7,7 @@ // #include "papas/graphtools/Distance.h" -//#include "papas/datatypes/Identifier.h" +//#include "papas/datatypes/IdCoder.h" #include "papas/datatypes/Cluster.h" #include "papas/datatypes/Path.h" #include "papas/datatypes/Track.h" @@ -28,7 +28,7 @@ Distance::Distance(bool islinked, double dist) : m_distance(dist), m_isLinked(is Distance::Distance(const Cluster& cluster, const Track& track) : m_distance(-1), m_isLinked(false) { papas::Position cyl_layer = papas::Position::kEcalIn; - if (Identifier::isHcal(cluster.id())) { + if (IdCoder::isHcal(cluster.id())) { cyl_layer = papas::Position::kHcalIn; } if (track.path()->hasNamedPoint(cyl_layer)) { // check exists diff --git a/papas/graphtools/src/Edge.cpp b/papas/graphtools/src/Edge.cpp index 2934495..39a2904 100644 --- a/papas/graphtools/src/Edge.cpp +++ b/papas/graphtools/src/Edge.cpp @@ -13,8 +13,8 @@ Edge::Edge(IdType endId1, IdType endId2, bool isLinked, double distance) */ Edge::EdgeKey Edge::makeKey(IdType id1, IdType id2) { EdgeKey key; - IdType uid1 = Identifier::uniqueId(id1); - IdType uid2 = Identifier::uniqueId(id2); + IdType uid1 = IdCoder::uniqueId(id1); + IdType uid2 = IdCoder::uniqueId(id2); if (id1 < id2) // ensure that the order of the ids does not matter std::swap(uid1, uid2); @@ -36,8 +36,8 @@ Edge::EdgeType Edge::edgeType() const{ // NB for one track and one ecal the type will always be kEcalTrack (and never be a kTrackEcal) // get one letter abbreviation of type eg 't' for a track - auto shortid1 = Identifier::typeLetter(m_endIds[0]); - auto shortid2 = Identifier::typeLetter(m_endIds[1]); + auto shortid1 = IdCoder::typeLetter(m_endIds[0]); + auto shortid2 = IdCoder::typeLetter(m_endIds[1]); if (shortid1 == shortid2) { if (shortid1 == 'h') diff --git a/papas/graphtools/src/EventRuler.cpp b/papas/graphtools/src/EventRuler.cpp index 6129552..3488b33 100644 --- a/papas/graphtools/src/EventRuler.cpp +++ b/papas/graphtools/src/EventRuler.cpp @@ -10,18 +10,18 @@ EventRuler::EventRuler(const Event& papasevent) : m_ruler(), m_event(papasevent) Distance EventRuler::distance(IdType id1, IdType id2) const { //figure out the object types and then call ClusterCluster or ClusterTrack distance measures - if (Identifier::isCluster(id1) && Identifier::isCluster(id2)) - if (Identifier::itemType(id1) == Identifier::itemType(id2)) + if (IdCoder::isCluster(id1) && IdCoder::isCluster(id2)) + if (IdCoder::itemType(id1) == IdCoder::itemType(id2)) return std::move(clusterClusterDistance(id1, id2)); else // hcal ecal not linked return Distance(); - else if (Identifier::isTrack(id2) && Identifier::isCluster(id1)) + else if (IdCoder::isTrack(id2) && IdCoder::isCluster(id1)) return std::move(clusterTrackDistance(id1, id2)); - else if (Identifier::isTrack(id1) && Identifier::isCluster(id2)) + else if (IdCoder::isTrack(id1) && IdCoder::isCluster(id2)) return std::move(clusterTrackDistance(id2, id1)); - else if (Identifier::isTrack(id1) && Identifier::isTrack(id2)) + else if (IdCoder::isTrack(id1) && IdCoder::isTrack(id2)) return std::move(Distance()); - std::cout << Identifier::itemType(id1) << ":" << Identifier::itemType(id2) << std::endl; + std::cout << IdCoder::itemType(id1) << ":" << IdCoder::itemType(id2) << std::endl; throw "Distance between ids could not be computed"; return std::move(Distance()); } diff --git a/papas/reconstruction/BlockBuilder.h b/papas/reconstruction/BlockBuilder.h index b7005fd..343ce45 100644 --- a/papas/reconstruction/BlockBuilder.h +++ b/papas/reconstruction/BlockBuilder.h @@ -12,7 +12,7 @@ namespace papas { * Each element will end up in one (and only one) block. * Blocks retain information of the elements and the distances between elements. * The blocks can be used for future particle reconstruction. - * The ids must be unique and are expected to come from the Identifier class. + * The ids must be unique and are expected to come from the IdCoder class. Usage example: @code diff --git a/papas/reconstruction/PFBlock.h b/papas/reconstruction/PFBlock.h index 319c097..be2e247 100644 --- a/papas/reconstruction/PFBlock.h +++ b/papas/reconstruction/PFBlock.h @@ -2,7 +2,7 @@ #define RECONSTRUCTION_PFBLOCK_H #include "papas/datatypes/DefinitionsCollections.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/graphtools/DefinitionsNodes.h" #include "papas/graphtools/Edge.h" #include @@ -38,7 +38,7 @@ class PFBlock { @param[inout] edges is an unordered map of edges, it must contain at least all needed edges. It is not a problem if it contains additional edges as only the ones needed will be extracted. Note that edges that are extracted will be removed from the Edges object and will become owned by the PFBlock - @param[in] subtype The subtype for the Identifier of the block eg 's' for split block + @param[in] subtype The subtype for the IdCoder of the block eg 's' for split block */ PFBlock(const Ids& elementIds, Edges& edges, unsigned int index, char subtype = 'u'); // relevant parts of edges will be removed and become owned by PFBlock diff --git a/papas/reconstruction/PFReconstructor.h b/papas/reconstruction/PFReconstructor.h index ac7a78b..6e0b0de 100644 --- a/papas/reconstruction/PFReconstructor.h +++ b/papas/reconstruction/PFReconstructor.h @@ -124,7 +124,7 @@ class PFReconstructor { /** Checks if object unique_id comes, directly or indirectly, from a particle of type typeAndSubtype, with this absolute pdgid. - @param id Unique Identifier of object + @param id Unique IdCoder of object @param typeAndSubtype type and subtype of particle eg 'ps' for simulated particle @param pdgid particle type eg muon @return True if there is a direct /indirect link between object and particle of this typeAndSubtype and absolute pdgid diff --git a/papas/reconstruction/src/MergedClusterBuilder.cpp b/papas/reconstruction/src/MergedClusterBuilder.cpp index 159474d..bbb2859 100644 --- a/papas/reconstruction/src/MergedClusterBuilder.cpp +++ b/papas/reconstruction/src/MergedClusterBuilder.cpp @@ -2,7 +2,7 @@ #include "papas/datatypes/Cluster.h" #include "papas/datatypes/Definitions.h" #include "papas/datatypes/DefinitionsCollections.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/graphtools/Distance.h" #include "papas/graphtools/Edge.h" #include "papas/graphtools/GraphBuilder.h" @@ -57,7 +57,7 @@ MergedClusterBuilder::MergedClusterBuilder(const Event& event, // Note we could try to do this in one shot as in the latest Python version... but its a little complicated //for several reasons so this is probably more straightforward auto mergedCluster = - Cluster(clusters.at(id), merged.size(), Identifier::itemType(id), 'm', totalenergy); // create a new cluster based on old one + Cluster(clusters.at(id), merged.size(), IdCoder::itemType(id), 'm', totalenergy); // create a new cluster based on old one if (id == mergedCluster.id()) { throw "MergedCluster has same id as existing cluster"; } diff --git a/papas/reconstruction/src/PFBlock.cpp b/papas/reconstruction/src/PFBlock.cpp index e4e1256..119d547 100644 --- a/papas/reconstruction/src/PFBlock.cpp +++ b/papas/reconstruction/src/PFBlock.cpp @@ -8,7 +8,7 @@ #include #include -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/graphtools/Edge.h" #include "papas/utility/PDebug.h" #include "spdlog/details/format.h" @@ -18,13 +18,13 @@ namespace papas { int PFBlock::tempBlockCount = 0; bool blockIdComparer (IdType id1, IdType id2) { - if (Identifier::itemType(id1) ==Identifier::itemType(id2)) + if (IdCoder::itemType(id1) ==IdCoder::itemType(id2)) return id1>id2; else - return Identifier::itemType(id1) < Identifier::itemType(id2);} + return IdCoder::itemType(id1) < IdCoder::itemType(id2);} PFBlock::PFBlock(const Ids& element_ids, Edges& edges, unsigned int index, char subtype) - : m_uniqueId(Identifier::makeId(index, Identifier::kBlock, subtype, element_ids.size())), + : m_uniqueId(IdCoder::makeId(index, IdCoder::kBlock, subtype, element_ids.size())), m_elementIds(element_ids) { PFBlock::tempBlockCount += 1; m_elementIds.sort(blockIdComparer); @@ -44,17 +44,17 @@ PFBlock::PFBlock(const Ids& element_ids, Edges& edges, unsigned int index, char int PFBlock::countEcal() const { // Counts how many ecal cluster ids are in the block - return std::count_if(m_elementIds.begin(), m_elementIds.end(), [](IdType elem) { return Identifier::isEcal(elem); }); + return std::count_if(m_elementIds.begin(), m_elementIds.end(), [](IdType elem) { return IdCoder::isEcal(elem); }); } int PFBlock::countHcal() const { // Counts how many hcal cluster ids are in the block - return std::count_if(m_elementIds.begin(), m_elementIds.end(), [](IdType elem) { return Identifier::isHcal(elem); }); + return std::count_if(m_elementIds.begin(), m_elementIds.end(), [](IdType elem) { return IdCoder::isHcal(elem); }); } int PFBlock::countTracks() const { // Counts how many track ids are in the block - return std::count_if(m_elementIds.begin(), m_elementIds.end(), [](IdType elem) { return Identifier::isTrack(elem); }); + return std::count_if(m_elementIds.begin(), m_elementIds.end(), [](IdType elem) { return IdCoder::isTrack(elem); }); } std::string PFBlock::shortName() const { @@ -116,7 +116,7 @@ std::string PFBlock::elementsString() const { fmt::MemoryWriter out; out.write(" elements:\n"); for (auto id : m_elementIds) { - out.write("{:>7}{} = {:9} value={:5.1f} ({})\n", Identifier::typeLetter(id), count, Identifier::pretty(id), Identifier::value(id), id); + out.write("{:>7}{} = {:9} value={:5.1f} ({})\n", IdCoder::typeLetter(id), count, IdCoder::pretty(id), IdCoder::value(id), id); count = count + 1; } return out.str(); @@ -143,7 +143,7 @@ std::string PFBlock::edgeMatrixString() const { out.write(" distances:\n "); for (auto e1 : m_elementIds) { // will produce short id of form E2 H3, T4 etc in tidy format - shortid = Identifier::typeLetter(e1) + std::to_string(count); + shortid = IdCoder::typeLetter(e1) + std::to_string(count); out.write("{:>8}", shortid); count += 1; } @@ -152,7 +152,7 @@ std::string PFBlock::edgeMatrixString() const { int countrow = 0; for (auto e1 : m_elementIds) { // each iteration produces the next row of the matrix // make short name for the row element eg E3, H5 etc - shortid = Identifier::typeLetter(e1) + std::to_string(countrow); + shortid = IdCoder::typeLetter(e1) + std::to_string(countrow); out.write("\n{:>8}", shortid); countrow += 1; for (auto e2 : m_elementIds) { // these will be the columns @@ -183,7 +183,7 @@ const Edge& PFBlock::edge(IdType id1, IdType id2) const { } std::string PFBlock::info() const { //One liner summary of PFBlock fmt::MemoryWriter out; - out.write("{:8} :{:6}: ecals = {} hcals = {} tracks = {}", shortName(), Identifier::pretty(m_uniqueId), countEcal(), + out.write("{:8} :{:6}: ecals = {} hcals = {} tracks = {}", shortName(), IdCoder::pretty(m_uniqueId), countEcal(), countHcal(), countTracks()); return out.str(); } diff --git a/papas/reconstruction/src/PFBlockBuilder.cpp b/papas/reconstruction/src/PFBlockBuilder.cpp index c8ac512..9066f44 100644 --- a/papas/reconstruction/src/PFBlockBuilder.cpp +++ b/papas/reconstruction/src/PFBlockBuilder.cpp @@ -5,7 +5,7 @@ #include "papas/graphtools/EventRuler.h" #include "papas/reconstruction/BlockBuilder.h" #include "papas/reconstruction/PFBlock.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" namespace papas { diff --git a/papas/reconstruction/src/PFBlockSplitter.cpp b/papas/reconstruction/src/PFBlockSplitter.cpp index 6f79a80..cda87c9 100644 --- a/papas/reconstruction/src/PFBlockSplitter.cpp +++ b/papas/reconstruction/src/PFBlockSplitter.cpp @@ -6,7 +6,7 @@ #include "papas/graphtools/EventRuler.h" #include "papas/reconstruction/BlockBuilder.h" #include "papas/reconstruction/PFBlockSplitter.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" namespace papas { @@ -69,7 +69,7 @@ Edges PFBlockSplitter::findEdgesToUnlink(const PFBlock& block) const { bool firstHCAL; double minDist = -1; for (auto id : ids) { - if (Identifier::isTrack(id)) { + if (IdCoder::isTrack(id)) { linkedIds = block.linkedIds(id, Edge::EdgeType::kHcalTrack); if (linkedIds.size() > 0) { firstHCAL = true; diff --git a/papas/reconstruction/src/PFReconstructor.cpp b/papas/reconstruction/src/PFReconstructor.cpp index 5053c49..d62f9ca 100644 --- a/papas/reconstruction/src/PFReconstructor.cpp +++ b/papas/reconstruction/src/PFReconstructor.cpp @@ -59,23 +59,23 @@ void PFReconstructor::reconstructBlock(const PFBlock& block) { if (uids.size() == 1) { //#TODO WARNING!!! LOTS OF MISSING CASES IdType id = *uids.begin(); auto parentIds = Ids{block.id(), id}; - if (Identifier::isEcal(id)) { + if (IdCoder::isEcal(id)) { reconstructCluster(m_event.cluster(id), papas::Layer::kEcal, parentIds); - } else if (Identifier::isHcal(id)) { + } else if (IdCoder::isHcal(id)) { reconstructCluster(m_event.cluster(id), papas::Layer::kHcal, parentIds); - } else if (Identifier::isTrack(id)) { + } else if (IdCoder::isTrack(id)) { reconstructTrack(m_event.track(id), 211, parentIds); } else { // ask Colin about energy balance - what happened to the associated clusters that one would expect? // TODO } } else { for (auto id : uids) { - if (Identifier::isHcal(id)) { + if (IdCoder::isHcal(id)) { reconstructHcal(block, id); } } for (auto id : ids) { - if (Identifier::isTrack(id) && !m_locked[id]) { + if (IdCoder::isTrack(id) && !m_locked[id]) { /* unused tracks, so not linked to HCAL # reconstructing charged hadrons*/ auto parentIds = Ids{block.id(), id}; @@ -102,7 +102,7 @@ void PFReconstructor::reconstructMuons(const PFBlock& block) { ids.sort(std::greater()); #endif for (auto id : ids) { - if (Identifier::isTrack(id) && isFromParticle(id, "ps", 13)) { + if (IdCoder::isTrack(id) && isFromParticle(id, "ps", 13)) { auto parentIds = Ids{block.id(), id}; reconstructTrack(m_event.track(id), 13, parentIds); @@ -121,7 +121,7 @@ void PFReconstructor::reconstructElectrons(const PFBlock& block) { # therefore, one should not lock the ecal clusters linked to the # electron track as these clusters are coming from other particles.*/ for (auto id : ids) { - if (Identifier::isTrack(id) && isFromParticle(id, "ps", 11)) { + if (IdCoder::isTrack(id) && isFromParticle(id, "ps", 11)) { auto parentIds = Ids{block.id(), id}; reconstructTrack(m_event.track(id), 11, parentIds); diff --git a/papas/reconstruction/src/PapasManager.cpp b/papas/reconstruction/src/PapasManager.cpp index 177f73a..d685f3e 100644 --- a/papas/reconstruction/src/PapasManager.cpp +++ b/papas/reconstruction/src/PapasManager.cpp @@ -1,5 +1,5 @@ #include "papas/reconstruction/PapasManager.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/datatypes/Event.h" #include "papas/reconstruction/MergedClusterBuilder.h" #include "papas/reconstruction/PFBlockBuilder.h" diff --git a/papas/simulation/Simulator.h b/papas/simulation/Simulator.h index 37bfcef..d78bad1 100644 --- a/papas/simulation/Simulator.h +++ b/papas/simulation/Simulator.h @@ -53,7 +53,7 @@ class Simulator { @param[in] ptc the gen particle to be simulated */ void simulateParticle(const Particle& ptc); - /* Find the cluster with the specified unique Identifier + /* Find the cluster with the specified unique IdCoder @param[in] clusterId the identifier of the cluster */ const Cluster& cluster(IdType clusterId) const; @@ -70,7 +70,7 @@ class Simulator { Smears a Cluster @param[in] cluster the cluster that is to be smeared @param[in] detectorLayer the layer to be used for smearing. Note this is not always the same as the layer to which - the cluster belongs Identifier for parent (used for history) + the cluster belongs IdCoder for parent (used for history) @return the smeared Cluster (moved) */ Cluster smearCluster(const Cluster& cluster, @@ -133,7 +133,7 @@ class Simulator { /** Makes a new Ecal Cluster, stored it in the Ecals collection and updates the history @param[in] ptc The parent particle - @param[in] parentId Identifier for parent (used for history) + @param[in] parentId IdCoder for parent (used for history) @return the stored Cluster (nb this is not the same as the original smearedCluster which has been moved) */ Cluster makeAndStoreEcalCluster(const PFParticle& ptc, double fraction, double csize, char subtype); @@ -142,14 +142,14 @@ class Simulator { /** Moves the smearedCluster into the smeared Ecals collection and updates the history @param[in] smearedCluster cluster to be stored - @param[in] parentId Identifier for parent (used for history) + @param[in] parentId IdCoder for parent (used for history) @return the stored Cluster (nb this is not the same as the original smearedCluster which has been moved) */ const Cluster& storeSmearedEcalCluster(Cluster&& smearedCluster, IdType parentId); /** Moves the smearedCluster into the smeared Hcals collection and updates the history @param[in] smearedCluster cluster to be stored - @param[in] parentId Identifier for parent (used for history) + @param[in] parentId IdCoder for parent (used for history) @return the stored Cluster (nb this is not the same as the original smearedCluster which has been moved) */ const Cluster& storeSmearedHcalCluster(Cluster&& smearedCluster, IdType parentId); diff --git a/papas/simulation/src/Simulator.cpp b/papas/simulation/src/Simulator.cpp index a670ca4..bc83cf0 100644 --- a/papas/simulation/src/Simulator.cpp +++ b/papas/simulation/src/Simulator.cpp @@ -1,6 +1,6 @@ #include "papas/datatypes/Cluster.h" #include "papas/datatypes/Definitions.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/datatypes/PFParticle.h" #include "papas/datatypes/ParticlePData.h" #include "papas/datatypes/Path.h" @@ -40,8 +40,8 @@ void Simulator::simulateParticle(const Particle& ptc) { return; } PFParticle& storedParticle = makeAndStorePFParticle(pdgid, ptc.charge(), ptc.p4(), ptc.startVertex()); - //if (Identifier::pretty(storedParticle.id()) == "ps3") - // std::cout << Identifier::pretty(storedParticle.id()) << std::endl; + //if (IdCoder::pretty(storedParticle.id()) == "ps3") + // std::cout << IdCoder::pretty(storedParticle.id()) << std::endl; if (pdgid == 22) { simulatePhoton(storedParticle); @@ -193,9 +193,9 @@ void Simulator::propagate(const SurfaceCylinder& cylinder, PFParticle& ptc) { } const Cluster& Simulator::cluster(IdType clusterId) const { - if (Identifier::isEcal(clusterId)) + if (IdCoder::isEcal(clusterId)) return m_ecalClusters.at(clusterId); - else if (Identifier::isHcal(clusterId)) + else if (IdCoder::isHcal(clusterId)) return m_hcalClusters.at(clusterId); throw std::out_of_range("Cluster not found"); } @@ -248,7 +248,7 @@ Cluster Simulator::makeAndStoreEcalCluster(const PFParticle& ptc, double fractio if (csize == -1.) { // ie value not provided csize = m_detector.calorimeter(papas::Layer::kEcal)->clusterSize(ptc); } - auto cluster = Cluster(energy, pos, csize, m_ecalClusters.size(), Identifier::kEcalCluster, subtype); + auto cluster = Cluster(energy, pos, csize, m_ecalClusters.size(), IdCoder::kEcalCluster, subtype); IdType id = cluster.id(); addNode(id, ptc.id()); PDebug::write("Made {}", cluster); @@ -271,7 +271,7 @@ Cluster Simulator::makeAndStoreHcalCluster(const PFParticle& ptc, double fractio if (csize == -1.) { // ie value not provided csize = m_detector.calorimeter(papas::Layer::kHcal)->clusterSize(ptc); } - auto cluster = Cluster(energy, pos, csize, m_hcalClusters.size(), Identifier::kHcalCluster, subtype); + auto cluster = Cluster(energy, pos, csize, m_hcalClusters.size(), IdCoder::kHcalCluster, subtype); IdType id = cluster.id(); addNode(id, ptc.id()); PDebug::write("Made {}", cluster); @@ -292,25 +292,25 @@ Cluster Simulator::smearCluster(const Cluster& parent, papas::Layer detectorLaye // NB It is not always the same layer as the new smeared cluster // The smeared cluster will have the same layer as the parent cluster if (detectorLayer == papas::Layer::kNone) - detectorLayer = Identifier::layer(parent.id()); // default to same layer as cluster + detectorLayer = IdCoder::layer(parent.id()); // default to same layer as cluster std::shared_ptr sp_calorimeter = m_detector.calorimeter(detectorLayer); double energyresolution = sp_calorimeter->energyResolution(parent.energy(), parent.eta()); double response = sp_calorimeter->energyResponse(parent.energy(), parent.eta()); double energy = parent.energy() * rootrandom::Random::gauss(response, energyresolution); unsigned int counter; - if (Identifier::layer(parent.id()) == Layer::kEcal) + if (IdCoder::layer(parent.id()) == Layer::kEcal) counter = m_smearedEcalClusters.size(); else counter = m_smearedHcalClusters.size(); // energy = fmax(0., energy); // energy always positive - auto cluster = Cluster(energy, parent.position(), parent.size(), counter, Identifier::itemType(parent.id()), 's'); + auto cluster = Cluster(energy, parent.position(), parent.size(), counter, IdCoder::itemType(parent.id()), 's'); PDebug::write("Made Smeared{}", cluster); return cluster; } bool Simulator::acceptSmearedCluster(const Cluster& smearedCluster, papas::Layer acceptLayer, bool accept) const { // Determine if this smeared cluster will be detected - if (acceptLayer == papas::Layer::kNone) acceptLayer = Identifier::layer(smearedCluster.id()); + if (acceptLayer == papas::Layer::kNone) acceptLayer = IdCoder::layer(smearedCluster.id()); if (m_detector.calorimeter(acceptLayer)->acceptance(smearedCluster) || accept) { return true; } else { diff --git a/tests/unittest.cpp b/tests/unittest.cpp index 5342b25..d9ba98c 100644 --- a/tests/unittest.cpp +++ b/tests/unittest.cpp @@ -32,7 +32,7 @@ #include "papas/datatypes/Event.h" #include "papas/datatypes/Helix.h" #include "papas/datatypes/HistoryHelper.h" -#include "papas/datatypes/Identifier.h" +#include "papas/datatypes/IdCoder.h" #include "papas/datatypes/PFParticle.h" #include "papas/datatypes/Particle.h" #include "papas/datatypes/Path.h" @@ -53,31 +53,31 @@ using namespace papas; -TEST_CASE("Identifier") { +TEST_CASE("IdCoder") { - auto uid = Identifier::makeId(1, Identifier::ItemType::kTrack, 's', 1.23456); - auto id1 = Identifier::makeId(2, Identifier::ItemType::kTrack, 's', 12.782); - REQUIRE(Identifier::pretty(id1) == "ts2"); + auto uid = IdCoder::makeId(1, IdCoder::ItemType::kTrack, 's', 1.23456); + auto id1 = IdCoder::makeId(2, IdCoder::ItemType::kTrack, 's', 12.782); + REQUIRE(IdCoder::pretty(id1) == "ts2"); std::vector idvec; for (int i = -2; i < 2; i++) { - uid = Identifier::makeId(i + 6, Identifier::ItemType::kTrack, 's', pow(2, i)); + uid = IdCoder::makeId(i + 6, IdCoder::ItemType::kTrack, 's', pow(2, i)); idvec.push_back(uid); } std::sort(idvec.begin(), idvec.end(), std::greater()); - REQUIRE(Identifier::pretty(idvec[0]) == "ts7"); - REQUIRE(Identifier::value(idvec[0]) == 2.0); - REQUIRE(Identifier::pretty(idvec[3]) == "ts4"); - REQUIRE(Identifier::value(idvec[3]) == 0.25); + REQUIRE(IdCoder::pretty(idvec[0]) == "ts7"); + REQUIRE(IdCoder::value(idvec[0]) == 2.0); + REQUIRE(IdCoder::pretty(idvec[3]) == "ts4"); + REQUIRE(IdCoder::value(idvec[3]) == 0.25); - auto id = Identifier::makeId(1, Identifier::ItemType::kEcalCluster, 'g', 3.1); - REQUIRE(Identifier::itemType('e') == Identifier::kEcalCluster); + auto id = IdCoder::makeId(1, IdCoder::ItemType::kEcalCluster, 'g', 3.1); + REQUIRE(IdCoder::itemType('e') == IdCoder::kEcalCluster); for (int j = 0; j < 6; j++) { - Identifier::ItemType e = Identifier::ItemType::kEcalCluster; + IdCoder::ItemType e = IdCoder::ItemType::kEcalCluster; for (int i = 1; i < 21; i++) { int n = pow(2, i); // makeId is self testing - id = Identifier::makeId(i, e, 't', (float)(1. / n)); + id = IdCoder::makeId(i, e, 't', (float)(1. / n)); } } } @@ -135,7 +135,7 @@ TEST_CASE("Cylinder") { TEST_CASE("ClusterPT") { /// Test that pT is correctly set - auto cluster = Cluster(10., TVector3(1, 0, 0), 1., 1, Identifier::ItemType::kEcalCluster, 't'); + auto cluster = Cluster(10., TVector3(1, 0, 0), 1., 1, IdCoder::ItemType::kEcalCluster, 't'); REQUIRE(cluster.pt() == Approx(10.000)); cluster.setEnergy(5.); REQUIRE(cluster.pt() == Approx(5.000)); @@ -145,7 +145,7 @@ TEST_CASE("ClusterSmear") { // Make a cluster double energy = 10.; - auto cluster = Cluster(energy, TVector3(1, 0, 0), 1., 2, Identifier::kEcalCluster); + auto cluster = Cluster(energy, TVector3(1, 0, 0), 1., 2, IdCoder::kEcalCluster); auto CMSDetector = CMS(); auto ecal = CMSDetector.ecal(); auto tester = PapasManagerTester(CMSDetector); @@ -287,8 +287,8 @@ TEST_CASE("dummy") { } TEST_CASE("Distance") { - auto c1 = Cluster(1, TVector3(1, 0, 0), 1., 1, Identifier::kEcalCluster, 't'); - auto c2 = Cluster(2, TVector3(1, 0, 0), 1., 2, Identifier::kHcalCluster, 't'); + auto c1 = Cluster(1, TVector3(1, 0, 0), 1., 1, IdCoder::kEcalCluster, 't'); + auto c2 = Cluster(2, TVector3(1, 0, 0), 1., 2, IdCoder::kHcalCluster, 't'); auto p3 = c1.position().Unit() * 100.; auto p4 = TLorentzVector(); p4.SetVectM(p3, 1.); @@ -304,15 +304,15 @@ TEST_CASE("Distance") { } TEST_CASE("Distance2") { - auto c1 = Cluster(10, TVector3(1, 0, 0), 4., 1, Identifier::ItemType::kEcalCluster, 't'); - auto c2 = Cluster(20, TVector3(1, 0, 0), 4., 2, Identifier::ItemType::kHcalCluster, 't'); + auto c1 = Cluster(10, TVector3(1, 0, 0), 4., 1, IdCoder::ItemType::kEcalCluster, 't'); + auto c2 = Cluster(20, TVector3(1, 0, 0), 4., 2, IdCoder::ItemType::kHcalCluster, 't'); auto dist1 = Distance(c1, c2); REQUIRE(dist1.isLinked()); REQUIRE(dist1.distance() == 0); auto pos3 = TVector3(c1.position()); pos3.RotateZ(0.059); - auto c3 = Cluster(30, pos3, 5., 3, Identifier::ItemType::kHcalCluster, 't'); + auto c3 = Cluster(30, pos3, 5., 3, IdCoder::ItemType::kHcalCluster, 't'); auto dist2 = Distance(c1, c3); REQUIRE(dist2.isLinked()); REQUIRE(dist2.distance() == 0.059); @@ -329,7 +329,7 @@ void test_graphs() { // Testing graphics // ,papas::ViewPane::Projection::HCAL_thetaphi }); TVector3 vpos(1., .5, .3); - Cluster cluster = Cluster(10., vpos, 1., 1, Identifier::ItemType::kEcalCluster, 't'); + Cluster cluster = Cluster(10., vpos, 1., 1, IdCoder::ItemType::kEcalCluster, 't'); std::vector tvec; tvec.push_back(TVector3(0., 0., 0.)); tvec.push_back(TVector3(1., 1., 1.)); @@ -369,9 +369,9 @@ void test_graphs() { // Testing graphics TEST_CASE("Edges") { using namespace papas; - IdType id1 = Identifier::makeId(1, Identifier::kEcalCluster, 't'); - IdType id2 = Identifier::makeId(2, Identifier::kHcalCluster, 't'); - IdType id3 = Identifier::makeId(3, Identifier::kTrack, 't'); + IdType id1 = IdCoder::makeId(1, IdCoder::kEcalCluster, 't'); + IdType id2 = IdCoder::makeId(2, IdCoder::kHcalCluster, 't'); + IdType id3 = IdCoder::makeId(3, IdCoder::kTrack, 't'); Edge edge = Edge(id1, id2, false, 0.0); Edge edge1 = Edge(id1, id3, true, 0.0); @@ -385,13 +385,13 @@ TEST_CASE("Edges") { TEST_CASE("PFBlocks") { using namespace papas; - IdType id1 = Identifier::makeId(1, Identifier::kEcalCluster, 't'); - IdType id2 = Identifier::makeId(2, Identifier::kHcalCluster, 't'); - IdType id3 = Identifier::makeId(3, Identifier::kTrack, 't'); + IdType id1 = IdCoder::makeId(1, IdCoder::kEcalCluster, 't'); + IdType id2 = IdCoder::makeId(2, IdCoder::kHcalCluster, 't'); + IdType id3 = IdCoder::makeId(3, IdCoder::kTrack, 't'); - IdType id4 = Identifier::makeId(4, Identifier::kEcalCluster, 't'); - IdType id5 = Identifier::makeId(5, Identifier::kHcalCluster, 't'); - IdType id6 = Identifier::makeId(6, Identifier::kTrack, 't'); + IdType id4 = IdCoder::makeId(4, IdCoder::kEcalCluster, 't'); + IdType id5 = IdCoder::makeId(5, IdCoder::kHcalCluster, 't'); + IdType id6 = IdCoder::makeId(6, IdCoder::kTrack, 't'); Ids ids{id1, id2, id3}; Ids ids2{id4, id5, id6}; @@ -423,7 +423,7 @@ TEST_CASE("PFBlocks") { REQUIRE(block2.shortName() == "E1H1T1"); REQUIRE(block2.elementIds() == ids2); REQUIRE(block2.size() == 3); - REQUIRE(Identifier::isBlock(block2.id()) == true); + REQUIRE(IdCoder::isBlock(block2.id()) == true); REQUIRE(block2.findEdge(edge4.key()).key() == edge4.key()); REQUIRE_THROWS(block2.findEdge(edge1.key()).key()); REQUIRE_THROWS(block2.findEdge(edge1.key())); @@ -434,9 +434,9 @@ TEST_CASE("PFBlocks") { } TEST_CASE("BlockSplitter") { - IdType id1 = Identifier::makeId(1, Identifier::kHcalCluster, 't'); - IdType id2 = Identifier::makeId(2, Identifier::kHcalCluster, 't'); - IdType id3 = Identifier::makeId(3, Identifier::kTrack, 't'); + IdType id1 = IdCoder::makeId(1, IdCoder::kHcalCluster, 't'); + IdType id2 = IdCoder::makeId(2, IdCoder::kHcalCluster, 't'); + IdType id3 = IdCoder::makeId(3, IdCoder::kTrack, 't'); Ids ids{id1, id2, id3}; Edge edge = Edge(id1, id2, false, 0.00023); @@ -470,8 +470,8 @@ TEST_CASE("BlockSplitter") { } TEST_CASE("Merge") { - auto cluster1 = Cluster(10., TVector3(0., 1., 0.), 0.04, 1, Identifier::kEcalCluster, 't'); - auto cluster2 = Cluster(20., TVector3(0., 1., 0), 0.06, 2, Identifier::kEcalCluster, 't'); + auto cluster1 = Cluster(10., TVector3(0., 1., 0.), 0.04, 1, IdCoder::kEcalCluster, 't'); + auto cluster2 = Cluster(20., TVector3(0., 1., 0), 0.06, 2, IdCoder::kEcalCluster, 't'); Clusters eclusters; eclusters.emplace(cluster1.id(), cluster1); eclusters.emplace(cluster2.id(), cluster2); @@ -498,8 +498,8 @@ TEST_CASE("Merge") { TEST_CASE("merge_pair") { - auto cluster1 = Cluster(20, TVector3(1, 0, 0), 0.1, 1, Identifier::kHcalCluster, 't'); - auto cluster2 = Cluster(20., TVector3(1, 0.05, 0.), 0.1, 2, Identifier::kHcalCluster, 't'); + auto cluster1 = Cluster(20, TVector3(1, 0, 0), 0.1, 1, IdCoder::kHcalCluster, 't'); + auto cluster2 = Cluster(20., TVector3(1, 0.05, 0.), 0.1, 2, IdCoder::kHcalCluster, 't'); Clusters hclusters; hclusters.emplace(cluster1.id(), cluster1); hclusters.emplace(cluster2.id(), cluster2); @@ -518,8 +518,8 @@ TEST_CASE("merge_pair") { TEST_CASE("merge_pair_away") { - auto cluster1 = Cluster(20, TVector3(1, 0, 0), 0.04, 1, Identifier::kHcalCluster, 't'); - auto cluster2 = Cluster(20., TVector3(1, 1.1, 0.), 0.04, 2, Identifier::kHcalCluster, 't'); + auto cluster1 = Cluster(20, TVector3(1, 0, 0), 0.04, 1, IdCoder::kHcalCluster, 't'); + auto cluster2 = Cluster(20., TVector3(1, 1.1, 0.), 0.04, 2, IdCoder::kHcalCluster, 't'); Clusters hclusters; hclusters.emplace(cluster1.id(), cluster1); hclusters.emplace(cluster2.id(), cluster2); @@ -538,8 +538,8 @@ TEST_CASE("merge_pair_away") { TEST_CASE("merge_different_layers") { - auto cluster1 = Cluster(20, TVector3(1, 0, 0), 0.04, 1, Identifier::kEcalCluster, 't'); - auto cluster2 = Cluster(20., TVector3(1, 1.1, 0.), 0.04, 2, Identifier::kHcalCluster, 't'); + auto cluster1 = Cluster(20, TVector3(1, 0, 0), 0.04, 1, IdCoder::kEcalCluster, 't'); + auto cluster2 = Cluster(20., TVector3(1, 1.1, 0.), 0.04, 2, IdCoder::kHcalCluster, 't'); Clusters hclusters; Clusters eclusters; hclusters.emplace(cluster1.id(), cluster1); @@ -562,7 +562,7 @@ TEST_CASE("test_papasevent") { IdType lastcluster = 0; for (int i = 0; i < 2; i++) { - auto cluster = Cluster(10., TVector3(0, 0, 1), 2., i, Identifier::kEcalCluster, 't'); + auto cluster = Cluster(10., TVector3(0, 0, 1), 2., i, IdCoder::kEcalCluster, 't'); ecals.emplace(cluster.id(), std::move(cluster)); lastcluster = cluster.id(); auto track = Track(TVector3(0, 0, 0), i, std::make_shared(), 't'); @@ -577,7 +577,7 @@ TEST_CASE("test_papasevent") { // check we can get back collections OK REQUIRE(event.clusters("et").size() == 2); REQUIRE(event.hasCollection(499) == false); - REQUIRE(event.hasCollection(Identifier::kEcalCluster, 't') == true); + REQUIRE(event.hasCollection(IdCoder::kEcalCluster, 't') == true); REQUIRE(event.hasCollection(lastid) == true); REQUIRE_NOTHROW(event.track(lastid)); REQUIRE_NOTHROW(event.cluster(lastcluster)); @@ -596,7 +596,7 @@ TEST_CASE("test_history") { // make a dummy papasevent including some history for (int i = 0; i < 2; i++) { - auto cluster = Cluster(10., TVector3(0, 0, 1), 2., 1, Identifier::kEcalCluster, 't'); + auto cluster = Cluster(10., TVector3(0, 0, 1), 2., 1, IdCoder::kEcalCluster, 't'); ecals.emplace(cluster.id(), std::move(cluster)); lastcluster = cluster.id(); auto cnode = PFNode(lastcluster); @@ -616,19 +616,19 @@ TEST_CASE("test_history") { auto ids = hhelper.linkedIds(lastid); // filter the ecals from the linked ids REQUIRE(ids.size() == 2); - auto fids = hhelper.filteredIds(ids, Identifier::kEcalCluster, 't'); + auto fids = hhelper.filteredIds(ids, IdCoder::kEcalCluster, 't'); REQUIRE(fids.size() == 1); REQUIRE(*fids.begin() == lastcluster); // filter the particle from the linked ids - fids = hhelper.filteredIds(ids, Identifier::kParticle, 'r'); + fids = hhelper.filteredIds(ids, IdCoder::kParticle, 'r'); REQUIRE(fids.size() == 1); REQUIRE(*fids.begin() == lastid); } TEST_CASE("merge_inside") { - auto cluster1 = Cluster(20, TVector3(1, 0, 0), 0.055, 1, Identifier::kHcalCluster, 't'); - auto cluster2 = Cluster(20., TVector3(1., 0.1, 0.0), 0.055, 2, Identifier::kHcalCluster, 't'); + auto cluster1 = Cluster(20, TVector3(1, 0, 0), 0.055, 1, IdCoder::kHcalCluster, 't'); + auto cluster2 = Cluster(20., TVector3(1., 0.1, 0.0), 0.055, 2, IdCoder::kHcalCluster, 't'); Clusters hclusters; hclusters.emplace(cluster1.id(), cluster1); hclusters.emplace(cluster2.id(), cluster2);