From 087b3130c78774e335fe0d56162d68a7eae479cb Mon Sep 17 00:00:00 2001 From: Alice Date: Tue, 21 Mar 2017 12:05:41 +0100 Subject: [PATCH 1/6] reviewing auto statements --- examples/example_dag_pair.cpp | 6 ++-- examples/example_loop.cpp | 4 +-- examples/example_pdebug_python_comparer.cpp | 2 +- examples/example_plot.cpp | 2 +- examples/example_simple.cpp | 2 +- papas/datatypes/Event.h | 6 ++-- papas/datatypes/HistoryHelper.h | 2 +- papas/datatypes/src/Cluster.cpp | 4 +-- papas/datatypes/src/Event.cpp | 6 ++-- papas/datatypes/src/HistoryHelper.cpp | 10 +++---- papas/display/src/Display.cpp | 4 +-- papas/graphtools/DefinitionsNodes.h | 8 ++--- papas/graphtools/DirectedAcyclicGraph.h | 12 ++++---- papas/graphtools/FloodFill.h | 2 +- papas/graphtools/GraphBuilder.h | 2 +- papas/graphtools/src/GraphBuilder.cpp | 10 ++++--- papas/reconstruction/BlockBuilder.h | 2 +- papas/reconstruction/PFBlock.h | 4 +-- papas/reconstruction/PFBlockSplitter.h | 2 +- papas/reconstruction/src/BlockBuilder.cpp | 4 ++- .../src/MergedClusterBuilder.cpp | 12 +++----- papas/reconstruction/src/PFBlock.cpp | 4 ++- papas/reconstruction/src/PFBlockSplitter.cpp | 10 +++---- papas/reconstruction/src/PFEventDisplay.cpp | 6 ++-- papas/reconstruction/src/PFReconstructor.cpp | 30 +++++++++---------- papas/reconstruction/src/PapasManager.cpp | 13 ++++---- .../reconstruction/src/PapasManagerTester.cpp | 2 +- 27 files changed, 84 insertions(+), 87 deletions(-) diff --git a/examples/example_dag_pair.cpp b/examples/example_dag_pair.cpp index 082c090..d62d56b 100644 --- a/examples/example_dag_pair.cpp +++ b/examples/example_dag_pair.cpp @@ -42,18 +42,18 @@ int main() { // BFSVisitor uses an iterative method to traverse // output the Datatype of all children std::cout << std::endl << "TRAVERSE CHILDREN (start Node 0) 1 level" << std::endl; - for (auto n : bfs.traverseChildren(n0, 1)) { + for (const auto& n : bfs.traverseChildren(n0, 1)) { std::cout << n->value().itype << ":" << n->value().ivalue << std::endl; } std::cout << std::endl << "TRAVERSE UNDIRECTED (start Node 5) 2 levels " << std::endl; - for (auto n : bfs.traverseUndirected(n5, 2)) { + for (const auto& n : bfs.traverseUndirected(n5, 2)) { std::cout << n->value().itype << ":" << n->value().ivalue << std::endl; } std::cout << std::endl << "TRAVERSE CHILDREN (start Node 0) all levels" << std::endl; - for (auto n : bfs.traverseChildren(n0)) { + for (const auto& n : bfs.traverseChildren(n0)) { std::cout << n->value().itype << ":" << n->value().ivalue << std::endl; } diff --git a/examples/example_loop.cpp b/examples/example_loop.cpp index 6b03f86..5b463ca 100644 --- a/examples/example_loop.cpp +++ b/examples/example_loop.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { const char* fname = argv[1]; // open the Pythia file fname try { - auto pythiaConnector = PythiaConnector(fname); + PythiaConnector pythiaConnector(fname); #if WITHSORT std::cout << "doing sorting"; #else @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { #endif // Create CMS detector and PapasManager papas::CMS CMSDetector; - auto papasManager = papas::PapasManager(CMSDetector); + papas::PapasManager papasManager(CMSDetector); unsigned int eventNo = 0; unsigned int nEvents = 100; diff --git a/examples/example_pdebug_python_comparer.cpp b/examples/example_pdebug_python_comparer.cpp index 3a19de1..113ca6c 100644 --- a/examples/example_pdebug_python_comparer.cpp +++ b/examples/example_pdebug_python_comparer.cpp @@ -24,7 +24,7 @@ int main(int argc, char* argv[]) { return 1; } const char* fname = argv[1]; - auto pythiaConnector = PythiaConnector(fname); + PythiaConnector pythiaConnector(fname); if (argc == 3) { const char* lname = argv[2]; diff --git a/examples/example_plot.cpp b/examples/example_plot.cpp index bd0989a..7224fc9 100644 --- a/examples/example_plot.cpp +++ b/examples/example_plot.cpp @@ -25,7 +25,7 @@ int main(int argc, char* argv[]) { return 1; } const char* fname = argv[1]; - auto pythiaConnector = PythiaConnector(fname); + PythiaConnector pythiaConnector(fname); // Create CMS detector and PapasManager CMS CMSDetector; diff --git a/examples/example_simple.cpp b/examples/example_simple.cpp index 51411a5..26a4421 100644 --- a/examples/example_simple.cpp +++ b/examples/example_simple.cpp @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) { return 1; } const char* fname = argv[1]; - auto pythiaConnector = PythiaConnector(fname); + PythiaConnector pythiaConnector(fname); if (argc == 3) { const char* lname = argv[2]; diff --git a/papas/datatypes/Event.h b/papas/datatypes/Event.h index 2142f96..0e9ee8e 100644 --- a/papas/datatypes/Event.h +++ b/papas/datatypes/Event.h @@ -173,7 +173,7 @@ class Event { * @param[in] collection the collection */ template - Ids collectionIds(const T& collection) const; + Ids collectionIds(const T& collection, bool sort = false) const; /** * @brief takes all the history collection and merged them into one single history */ @@ -237,11 +237,13 @@ void Event::addCollectionInternal( } template -Ids Event::collectionIds(const T& collection) const { +Ids Event::collectionIds(const T& collection, bool sort) const { Ids ids; for (const auto& item : collection) { ids.push_back(item.first); } + if (sort) + ids.sort(std::greater()); return ids; } } diff --git a/papas/datatypes/HistoryHelper.h b/papas/datatypes/HistoryHelper.h index 5861dfd..8b591b3 100644 --- a/papas/datatypes/HistoryHelper.h +++ b/papas/datatypes/HistoryHelper.h @@ -17,7 +17,7 @@ namespace papas { @code Usage example: - auto hhelper = HistoryHelper(event); + HistoryHelper hhelper(event); //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' diff --git a/papas/datatypes/src/Cluster.cpp b/papas/datatypes/src/Cluster.cpp index 667cace..8b57f3a 100644 --- a/papas/datatypes/src/Cluster.cpp +++ b/papas/datatypes/src/Cluster.cpp @@ -49,7 +49,7 @@ Cluster::Cluster(Cluster&& c) if (c.subClusters().size() == 1 && c.id() == (*c.subClusters().begin())->id()) m_subClusters.push_back(this); // non merged cluster point to itself else - for (auto s : c.subClusters()) // merged clusters + for (const auto& s : c.subClusters()) // merged clusters m_subClusters.push_back(s); } @@ -100,7 +100,7 @@ std::ostream& operator<<(std::ostream& os, const Cluster& cluster) { os << "Cluster: " << std::setw(6) << std::left << Identifier::pretty(cluster.id()) << ":" << cluster.id() << ": " << cluster.info(); os << " sub("; - for (auto c : cluster.subClusters()) { + for (const auto& c : cluster.subClusters()) { os << Identifier::pretty(c->id()) << ", "; } os << ")"; diff --git a/papas/datatypes/src/Event.cpp b/papas/datatypes/src/Event.cpp index b0acf72..93972ee 100644 --- a/papas/datatypes/src/Event.cpp +++ b/papas/datatypes/src/Event.cpp @@ -69,7 +69,7 @@ const Blocks& Event::blocks(const Identifier::SubType subtype) const { } bool Event::hasCollection(Identifier::ItemType type, const Identifier::SubType subtype) const { // Check if this collection is present - auto found = false; + bool found =false; switch (type) { case Identifier::kEcalCluster: found = (m_ecalClustersCollection.find(subtype) != m_ecalClustersCollection.end()); @@ -98,7 +98,7 @@ bool Event::hasCollection(IdType id) const { bool Event::hasObject(IdType id) const { // check if this object id is present - auto found = false; + bool found =false; auto type = Identifier::itemType(id); if (hasCollection(id)) { switch (type) { @@ -125,7 +125,7 @@ bool Event::hasObject(IdType id) const { void Event::extendHistory(const Nodes& history) { // A separate history is created at each stage. // the following adds this history into the papasevent history - for (const auto node : history) { + for (const auto& node : history) { for (const auto& c : node.second.children()) { makeHistoryLink(node.first, c->value(), *m_history); } diff --git a/papas/datatypes/src/HistoryHelper.cpp b/papas/datatypes/src/HistoryHelper.cpp index 3f4d971..5da2be5 100644 --- a/papas/datatypes/src/HistoryHelper.cpp +++ b/papas/datatypes/src/HistoryHelper.cpp @@ -8,12 +8,12 @@ namespace papas { HistoryHelper::HistoryHelper(const Event& event) : m_event(event) {} Ids HistoryHelper::linkedIds(IdType id, DAG::enumVisitType direction) const { - const auto history = m_event.history(); - auto& startnode = history->at(id); - auto bfs = DAG::BFSRecurseVisitor(); - auto nodes = bfs.traverseNodes(startnode, direction); + const auto& history = m_event.history(); + const auto& startnode = history->at(id); + DAG::BFSRecurseVisitor bfs; + const auto& nodes = bfs.traverseNodes(startnode, direction); Ids ids; - for (auto node : nodes) { + for (const auto& node : nodes) { ids.push_back(node->value()); } return ids; diff --git a/papas/display/src/Display.cpp b/papas/display/src/Display.cpp index 964f63a..2036302 100644 --- a/papas/display/src/Display.cpp +++ b/papas/display/src/Display.cpp @@ -14,7 +14,7 @@ Display::Display(std::list views) { views = {ViewPane::Projection::xy, ViewPane::Projection::yz, ViewPane::Projection::xz}; } /// Creates viewpanes - for (auto view : views) { + for (auto& view : views) { if ((view == ViewPane::Projection::xy) | (view == ViewPane::Projection::yz) | (view == ViewPane::Projection::xz)) { m_views[ViewPane::ProjectionStrings[view]] = std::unique_ptr{new ViewPane(view, 100, -4, 4, 100, -4, 4)}; @@ -27,7 +27,7 @@ Display::Display(std::list views) { }; void Display::addToRegister(std::shared_ptr obj, int layer, bool clearable) { - for (auto const& view : m_views) { + for (auto& view : m_views) { view.second->addToRegister(obj, layer, clearable); } }; diff --git a/papas/graphtools/DefinitionsNodes.h b/papas/graphtools/DefinitionsNodes.h index ed72014..049d3fa 100644 --- a/papas/graphtools/DefinitionsNodes.h +++ b/papas/graphtools/DefinitionsNodes.h @@ -20,9 +20,7 @@ typedef std::list ListNodes; ///< collection of Nodes inline PFNode& findOrMakeNode(IdType id, Nodes& history) { if (history.empty() || (history.find(id) == history.end()) ) { - - auto newnode = PFNode(id); - + PFNode newnode(id); history.emplace(id, newnode); } return history.at(id); @@ -41,8 +39,8 @@ 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()) + for (const auto& node : history) + for (const auto& cnode : node.second.children()) std::cout << Identifier::pretty(node.first) << ":" << Identifier::pretty(cnode->value()) << " "; } diff --git a/papas/graphtools/DirectedAcyclicGraph.h b/papas/graphtools/DirectedAcyclicGraph.h index df5ff4e..cfbacb2 100644 --- a/papas/graphtools/DirectedAcyclicGraph.h +++ b/papas/graphtools/DirectedAcyclicGraph.h @@ -222,7 +222,7 @@ void BFSVisitor::traverse(const Nodeset& nodes, typename DAG::enumVisitTyp std::queue nodeDepth; // keeps track of the node depths so we can limit how deep we go if we wish // Mark the current node as visited and enqueue it - for (auto const& node : nodes) { + for (auto& node : nodes) { if (m_visited.find(node) == m_visited.end()) { // if node is not listed as already being visited node->accept(*this); // mark as visited and add to results nodeQueue.push(node); // put into the queue @@ -242,7 +242,7 @@ void BFSVisitor::traverse(const Nodeset& nodes, typename DAG::enumVisitTyp if ((depth < 0 || curdepth < depth) && // NB depth=-1 means we are visiting everything ((visittype == pt::CHILDREN) | (visittype == pt::UNDIRECTED))) { // use the children - for (auto node : nodeQueue.front()->children()) { + for (auto& node : nodeQueue.front()->children()) { if (m_visited.find(node) == m_visited.end()) { // check node is not already being visited node->accept(*this); nodeQueue.push(node); @@ -252,7 +252,7 @@ void BFSVisitor::traverse(const Nodeset& nodes, typename DAG::enumVisitTyp } if ((depth < 0 || curdepth < depth) && // NB depth=-1 means we are visiting everything ((visittype == pt::PARENTS) | (visittype == pt::UNDIRECTED))) { // use the parents - for (auto node : nodeQueue.front()->parents()) { + for (auto& node : nodeQueue.front()->parents()) { if (m_visited.find(node) == m_visited.end()) { // check node is not already being visited node->accept(*this); @@ -283,7 +283,7 @@ void BFSRecurseVisitor::traverse(const Nodeset& nodes, typename DAG::enumV return; // end of the recursion } - for (auto node : nodes) { + for (auto& node : nodes) { // Only process a node if not already visited if (BFSVisitor::m_visited.find(node) == BFSVisitor::m_visited.end()) { @@ -294,11 +294,11 @@ void BFSRecurseVisitor::traverse(const Nodeset& nodes, typename DAG::enumV // and store these into visitnextnodes // NB depth=-1 means we are visiting everything if (depth != 0 && (visittype == pt::CHILDREN | visittype == pt::UNDIRECTED)) - for (const auto child : node->children()) { + for (const auto& child : node->children()) { if (!this->alreadyVisited(child)) visitnextnodes.insert(child); } if (depth != 0 && (visittype == pt::PARENTS | visittype == pt::UNDIRECTED)) - for (const auto parent : node->parents()) { + for (const auto& parent : node->parents()) { if (!this->alreadyVisited(parent)) visitnextnodes.insert(parent); } } diff --git a/papas/graphtools/FloodFill.h b/papas/graphtools/FloodFill.h index 57faebc..992aca1 100644 --- a/papas/graphtools/FloodFill.h +++ b/papas/graphtools/FloodFill.h @@ -66,7 +66,7 @@ std::vector::Nodevector> FloodFill::traverse(FloodFill< m_visited.clear(); BFSVisitor bfs; - for (auto& elem : nodes) { + for (const auto& elem : nodes) { if (m_visited.find(&elem.second) != m_visited.end()) continue; // already done this node so skip the rest diff --git a/papas/graphtools/GraphBuilder.h b/papas/graphtools/GraphBuilder.h index 862df5c..b791e1e 100644 --- a/papas/graphtools/GraphBuilder.h +++ b/papas/graphtools/GraphBuilder.h @@ -20,7 +20,7 @@ namespace papas { Usage example: @code - auto builder = GraphBuilder(ids, edges); + GraphBuilder builder(ids, edges); for (b in builder.blocks()) { ... } diff --git a/papas/graphtools/src/GraphBuilder.cpp b/papas/graphtools/src/GraphBuilder.cpp index b8eb6e9..e0da687 100644 --- a/papas/graphtools/src/GraphBuilder.cpp +++ b/papas/graphtools/src/GraphBuilder.cpp @@ -20,21 +20,23 @@ GraphBuilder::GraphBuilder(const Ids& ids, Edges&& edges) : m_edges(edges), m_el } DAG::FloodFill FFill; // traverse does the work and returns a vector of connected node groups - for (auto& group : FFill.traverse(m_localNodes)) { + for (const auto& group : FFill.traverse(m_localNodes)) { // each of the nodevectors is about to become a separate block // we need the vector of ids and the map of edges in order to make the block Ids subgraph; - for (auto& node : group) { + for (const auto& node : group) { subgraph.push_back(node->value()); } + #if WITHSORT + sortIds(subgraph); //sort in descending order + #endif m_subGraphs.push_back(subgraph); } } void GraphBuilder::sortIds(Ids& ids) { -#if WITHSORT ids.sort(std::greater()); //sort in descending order -#endif + } } // end namespace papas diff --git a/papas/reconstruction/BlockBuilder.h b/papas/reconstruction/BlockBuilder.h index b7005fd..de709fa 100644 --- a/papas/reconstruction/BlockBuilder.h +++ b/papas/reconstruction/BlockBuilder.h @@ -16,7 +16,7 @@ namespace papas { Usage example: @code - auto builder = BlockBuilder (ids, edges, history, blocks, 'r'); + BlockBuilder builder(ids, edges, history, blocks, 'r'); } @endcode diff --git a/papas/reconstruction/PFBlock.h b/papas/reconstruction/PFBlock.h index 319c097..cf5b2b1 100644 --- a/papas/reconstruction/PFBlock.h +++ b/papas/reconstruction/PFBlock.h @@ -43,7 +43,7 @@ class PFBlock { PFBlock(const Ids& elementIds, Edges& edges, unsigned int index, char subtype = 'u'); // relevant parts of edges will be removed and become owned by PFBlock PFBlock(PFBlock&& pfblock) = default; // allow move - const Ids& elementIds() const { return m_elementIds; } ///< returns vector of all ids in the block + const Ids& elementIds(bool sort = false) const { return m_elementIds; } ///< returns vector of all ids in the block const Edge& findEdge(Edge::EdgeKey key) const; ///< return Edge corresponding to Edge key /** Returns list of all edges of a given edge type that are connected to a given id. @@ -60,7 +60,7 @@ class PFBlock { @param[in] edgetype : is an optional type of edge. If specified only links of the given edgetype will be returned @return vector of ids that are linked to the uniqueid */ - Ids linkedIds(IdType uniqueId, Edge::EdgeType edgetype = Edge::EdgeType::kUnknown) const; + Ids linkedIds(IdType uniqueId, Edge::EdgeType edgetype = Edge::EdgeType::kUnknown, bool sort = false) const; std::string shortName() const; ///< Short descriptor of block such as E3H1T2 (three Ecals, 1 Hcal, 2 tracks) int countEcal() const; ///< Counts how many ecal cluster ids are in the block diff --git a/papas/reconstruction/PFBlockSplitter.h b/papas/reconstruction/PFBlockSplitter.h index 29cfa9e..8b3fd94 100644 --- a/papas/reconstruction/PFBlockSplitter.h +++ b/papas/reconstruction/PFBlockSplitter.h @@ -21,7 +21,7 @@ Usage example: @code auto& simplifiedblocks = createBlocks(); auto& history = createHistory(); - auto blockBuilder = PFBlockSplitter(m_event, blockSubtype, simplifiedblocks, history); + PFBlockSplitter blockBuilder(m_event, blockSubtype, simplifiedblocks, history); //store a pointer to the ouputs into the event m_event.addCollection(simplifiedblocks); diff --git a/papas/reconstruction/src/BlockBuilder.cpp b/papas/reconstruction/src/BlockBuilder.cpp index 5e09afa..87582f3 100644 --- a/papas/reconstruction/src/BlockBuilder.cpp +++ b/papas/reconstruction/src/BlockBuilder.cpp @@ -25,10 +25,12 @@ void BlockBuilder::makeBlocks(char blockSubtype) { Each subGraph will be used to make a new PFBlock */ for (auto& elementIds : m_subGraphs) { + /*#if WITHSORT if (elementIds.size() > 1) { sortIds(elementIds); } - auto block = PFBlock(elementIds, m_edges, m_blocks.size(), blockSubtype); // make the block + #endif*/ + PFBlock block(elementIds, m_edges, m_blocks.size(), blockSubtype); // make the block PDebug::write("Made {}", block); // put the block in the unordered map of blocks using move IdType id = block.id(); diff --git a/papas/reconstruction/src/MergedClusterBuilder.cpp b/papas/reconstruction/src/MergedClusterBuilder.cpp index 159474d..2cb97d6 100644 --- a/papas/reconstruction/src/MergedClusterBuilder.cpp +++ b/papas/reconstruction/src/MergedClusterBuilder.cpp @@ -43,12 +43,9 @@ MergedClusterBuilder::MergedClusterBuilder(const Event& event, } // create a graph using the ids and the edges this will produces subgroups of ids each of which will form // a new merged cluster. - auto grBuilder = GraphBuilder(uniqueids, std::move(edges)); - for (auto ids : grBuilder.subGraphs()) { -#if WITHSORT - ids.sort(std::greater()); //sort in descending order -#endif - auto id = *ids.begin(); + GraphBuilder grBuilder(uniqueids, std::move(edges)); + for (const auto& ids : grBuilder.subGraphs()) { + const auto& id = *ids.begin(); double totalenergy = 0.; for (const auto& c : ids) { totalenergy += clusters.at(c).energy(); @@ -56,8 +53,7 @@ MergedClusterBuilder::MergedClusterBuilder(const Event& event, // create the merged Cluster // 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 mergedCluster(clusters.at(id), merged.size(), Identifier::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..394b7ec 100644 --- a/papas/reconstruction/src/PFBlock.cpp +++ b/papas/reconstruction/src/PFBlock.cpp @@ -92,7 +92,7 @@ std::list PFBlock::linkedEdgeKeys(IdType uniqueid, Edge::EdgeType return linkedEdgeKeys; //todo consider sorting } -Ids PFBlock::linkedIds(IdType uniqueid, Edge::EdgeType edgetype) const { +Ids PFBlock::linkedIds(IdType uniqueid, Edge::EdgeType edgetype, bool sort) const { /// Returns list of all linked ids of a given edge type that are connected to a given id - Ids linkedIds; for (auto key : linkedEdgeKeys(uniqueid, edgetype)) { @@ -100,6 +100,8 @@ Ids PFBlock::linkedIds(IdType uniqueid, Edge::EdgeType edgetype) const { if (found == m_edges.end()) throw std::range_error("Required EdgeKey is missing from Linked Edges collection"); linkedIds.push_back(found->second.otherId(uniqueid)); } + if (sort) + linkedIds.sort(std::greater()); return linkedIds; } diff --git a/papas/reconstruction/src/PFBlockSplitter.cpp b/papas/reconstruction/src/PFBlockSplitter.cpp index 6f79a80..2fa0ebe 100644 --- a/papas/reconstruction/src/PFBlockSplitter.cpp +++ b/papas/reconstruction/src/PFBlockSplitter.cpp @@ -14,10 +14,8 @@ PFBlockSplitter::PFBlockSplitter(const Event& event, char blockSubtype, Blocks& Nodes& history) : m_event(event), m_simplifiedBlocks(simplifiedblocks), m_history(history) { const auto& blocks = m_event.blocks(blockSubtype); - auto blockids = m_event.collectionIds(blocks); -#if WITHSORT - blockids.sort(std::greater()); -#endif + const auto& blockids = m_event.collectionIds(blocks, WITHSORT); + // go through each block and see if it can be simplified // in some cases it will end up being split into smaller blocks // Note that the old block will be marked as disactivated @@ -41,7 +39,7 @@ void PFBlockSplitter::simplifyBlock(const Edges& toUnlink, const PFBlock& block) // no change to this block // make a copy of the block and put it in the simplified blocks Edges newedges = block.edges(); // copy edges - auto newblock = PFBlock(block.elementIds(), newedges, m_simplifiedBlocks.size(), 's'); + PFBlock newblock(block.elementIds(), newedges, m_simplifiedBlocks.size(), 's'); PDebug::write("Made {}", newblock); m_simplifiedBlocks.emplace(newblock.id(), std::move(newblock)); // update history @@ -57,7 +55,7 @@ void PFBlockSplitter::simplifyBlock(const Edges& toUnlink, const PFBlock& block) modifiedEdges.emplace(e.key(), std::move(e)); } // Blockbuilder will add the blocks it creates into m_simplifiedBlocks - auto bbuilder = BlockBuilder(block.elementIds(), std::move(modifiedEdges), m_history, m_simplifiedBlocks, 's'); + BlockBuilder bbuilder(block.elementIds(), std::move(modifiedEdges), m_history, m_simplifiedBlocks, 's'); } } diff --git a/papas/reconstruction/src/PFEventDisplay.cpp b/papas/reconstruction/src/PFEventDisplay.cpp index de1cead..9f5194e 100644 --- a/papas/reconstruction/src/PFEventDisplay.cpp +++ b/papas/reconstruction/src/PFEventDisplay.cpp @@ -18,15 +18,15 @@ namespace papas { PFEventDisplay::PFEventDisplay(std::list views) : Display(views) {} void PFEventDisplay::drawEvent(const Event& event) { - for (auto& pr : event.particles('s')) { + for (const auto& pr : event.particles('s')) { std::shared_ptr gparticle(new GTrajectories(pr.second)); addToRegister(gparticle, 2); } - for (auto& cl : event.clusters("es")) { + for (const auto& cl : event.clusters("es")) { std::shared_ptr gcluster(new GTrajectories(cl.second)); addToRegister(gcluster, 2); } - for (auto& cl : event.clusters("hs")) { + for (const auto& cl : event.clusters("hs")) { std::shared_ptr gcluster(new GTrajectories(cl.second)); addToRegister(gcluster, 2); } diff --git a/papas/reconstruction/src/PFReconstructor.cpp b/papas/reconstruction/src/PFReconstructor.cpp index 5053c49..6c769bf 100644 --- a/papas/reconstruction/src/PFReconstructor.cpp +++ b/papas/reconstruction/src/PFReconstructor.cpp @@ -24,9 +24,7 @@ PFReconstructor::PFReconstructor(const Event& event, char blockSubtype, const De : m_event(event), m_detector(detector), m_particles(particles), m_history(history) { const auto& blocks = m_event.blocks(blockSubtype); auto blockids = m_event.collectionIds(blocks); -#if WITHSORT - blockids.sort(std::greater()); -#endif + for (auto bid : blockids) { const PFBlock& block = blocks.at(bid); PDebug::write("Processing {}", block); @@ -43,9 +41,9 @@ PFReconstructor::PFReconstructor(const Event& event, char blockSubtype, const De void PFReconstructor::reconstructBlock(const PFBlock& block) { // see class description for summary of reconstruction approach Ids ids = block.elementIds(); -#if WITHSORT - ids.sort(std::greater()); -#endif + //#if WITHSORT TODO check that the ids are already sorted by this stage + //ids.sort(std::greater()); + //#endif for (auto id : ids) { m_locked[id] = false; } @@ -98,9 +96,9 @@ void PFReconstructor::reconstructBlock(const PFBlock& block) { void PFReconstructor::reconstructMuons(const PFBlock& block) { /// Reconstruct muons in block. Ids ids = block.elementIds(); -#if WITHSORT +/*#if WITHSORT ids.sort(std::greater()); -#endif +#endif*/ for (auto id : ids) { if (Identifier::isTrack(id) && isFromParticle(id, "ps", 13)) { @@ -113,9 +111,9 @@ void PFReconstructor::reconstructMuons(const PFBlock& block) { void PFReconstructor::reconstructElectrons(const PFBlock& block) { /*Reconstruct electrons in block.*/ Ids ids = block.elementIds(); -#if WITHSORT +/*#if WITHSORT ids.sort(std::greater()); -#endif +#endif*/ /* the simulator does not simulate electron energy deposits in ecal. # therefore, one should not lock the ecal clusters linked to the @@ -209,12 +207,12 @@ void PFReconstructor::reconstructHcal(const PFBlock& block, IdType hcalId) { // TODO assert(len(block.linked_ids(hcalid, "hcal_hcal"))==0 ) Ids ecalIds; - Ids trackIds = block.linkedIds(hcalId, Edge::EdgeType::kHcalTrack); -#if WITHSORT + Ids trackIds = block.linkedIds(hcalId, Edge::EdgeType::kHcalTrack, WITHSORT); +/*#if WITHSORT trackIds.sort(std::greater()); -#endif +#endif*/ for (auto trackId : trackIds) { - for (auto ecalId : block.linkedIds(trackId, Edge::EdgeType::kEcalTrack)) { + for (auto ecalId : block.linkedIds(trackId, Edge::EdgeType::kEcalTrack, WITHSORT)) { /*the ecals get all grouped together for all tracks in the block # Maybe we want to link ecals to their closest track etc? # this might help with history work @@ -225,10 +223,10 @@ void PFReconstructor::reconstructHcal(const PFBlock& block, IdType hcalId) { } } } -#if WITHSORT +/*#if WITHSORT trackIds.sort(std::greater()); ecalIds.sort(std::greater()); -#endif +#endif*/ // hcal should be the only remaining linked hcal cluster (closest one) const Cluster& hcal = m_event.cluster(hcalId); double hcalEnergy = hcal.energy(); diff --git a/papas/reconstruction/src/PapasManager.cpp b/papas/reconstruction/src/PapasManager.cpp index 177f73a..e2559af 100644 --- a/papas/reconstruction/src/PapasManager.cpp +++ b/papas/reconstruction/src/PapasManager.cpp @@ -27,12 +27,12 @@ void PapasManager::simulate(const ListParticles& particles) { auto& smearedHcalClusters = createClusters(); auto& tracks = createTracks(); auto& smearedTracks = createTracks(); - auto history =createHistory(); + auto& history =createHistory(); m_event.setHistory(history); auto& simParticles = createParticles(); // run the simulator which will fill the above objects - auto simulator = Simulator(m_event, particles, m_detector, ecalClusters, hcalClusters, smearedEcalClusters, + Simulator simulator(m_event, particles, m_detector, ecalClusters, hcalClusters, smearedEcalClusters, smearedHcalClusters, tracks, smearedTracks, simParticles, history); // store the addresses of the filled collections to the Event @@ -51,7 +51,7 @@ void PapasManager::mergeClusters(const std::string& typeAndSubtype) { // create collections ready to receive outputs auto& mergedClusters = createClusters(); auto& history = createHistory(); - auto ecalmerger = MergedClusterBuilder(m_event, typeAndSubtype, ruler, mergedClusters, history); + MergedClusterBuilder ecalmerger(m_event, typeAndSubtype, ruler, mergedClusters, history); // add outputs into event m_event.addCollection(mergedClusters); m_event.extendHistory(history); @@ -62,8 +62,7 @@ void PapasManager::buildBlocks(const std::string& ecalTypeAndSubtype, const std: // create empty collections to hold the ouputs, the ouput will be added by the algorithm auto& blocks = createBlocks(); auto& history = createHistory(); - auto blockBuilder = - PFBlockBuilder(m_event, ecalTypeAndSubtype, hcalTypeAndSubtype, trackSubtype, blocks, history); + PFBlockBuilder blockBuilder(m_event, ecalTypeAndSubtype, hcalTypeAndSubtype, trackSubtype, blocks, history); // store a pointer to the ouputs into the event m_event.addCollection(blocks); m_event.extendHistory(history); @@ -73,7 +72,7 @@ void PapasManager::simplifyBlocks(char blockSubtype) { // create empty collections to hold the ouputs, the ouput will be added by the algorithm auto& simplifiedblocks = createBlocks(); auto& history = createHistory(); - auto blockBuilder = PFBlockSplitter(m_event, blockSubtype, simplifiedblocks, history); + PFBlockSplitter blockBuilder(m_event, blockSubtype, simplifiedblocks, history); // store a pointer to the outputs into the event m_event.addCollection(simplifiedblocks); @@ -84,7 +83,7 @@ void PapasManager::reconstruct(char blockSubtype) { auto& history = createHistory(); auto& recParticles = createParticles(); - auto pfReconstructor = PFReconstructor(m_event, blockSubtype, m_detector, recParticles, history); + PFReconstructor pfReconstructor (m_event, blockSubtype, m_detector, recParticles, history); m_event.addCollection(recParticles); m_event.extendHistory(history); } diff --git a/papas/reconstruction/src/PapasManagerTester.cpp b/papas/reconstruction/src/PapasManagerTester.cpp index 0f7efcf..1f48599 100644 --- a/papas/reconstruction/src/PapasManagerTester.cpp +++ b/papas/reconstruction/src/PapasManagerTester.cpp @@ -30,7 +30,7 @@ Simulator PapasManagerTester::setSimulator(const ListParticles& particles) { auto& simParticles = createParticles(); // run the simulator which will fill the above objects - const auto simulator = Simulator(m_event, particles, m_detector, ecalClusters, hcalClusters, smearedEcalClusters, + Simulator simulator(m_event, particles, m_detector, ecalClusters, hcalClusters, smearedEcalClusters, smearedHcalClusters, tracks, smearedTracks, simParticles, history); return simulator; } From f79c7fb8e7873a3c834c8f89278b42da920a5588 Mon Sep 17 00:00:00 2001 From: Alice Date: Tue, 21 Mar 2017 12:21:29 +0100 Subject: [PATCH 2/6] reviewing auto statements --- examples/PythiaConnector.cpp | 6 ++---- papas/graphtools/src/Ruler.cpp | 4 ++-- papas/reconstruction/PFReconstructor.h | 4 ++-- papas/reconstruction/src/BlockBuilder.cpp | 2 +- papas/reconstruction/src/MergedClusterBuilder.cpp | 2 +- papas/reconstruction/src/PFReconstructor.cpp | 10 +++++----- papas/simulation/src/Simulator.cpp | 12 ++++++------ 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/examples/PythiaConnector.cpp b/examples/PythiaConnector.cpp index 0ae4068..23cef9f 100644 --- a/examples/PythiaConnector.cpp +++ b/examples/PythiaConnector.cpp @@ -78,9 +78,7 @@ papas::ListParticles PythiaConnector::makePapasParticlesFromGeneratedParticles(c if (ptc.core().status == 1) { // only stable ones if (tlv.Pt() > 1e-5 && (abs(pdgid) != 12) && (abs(pdgid) != 14) && (abs(pdgid) != 16)) { - - auto particle = - papas::Particle(pdgid, (double)ptc.core().charge, tlv, ptc.core().status, startVertex, endVertex); + papas::Particle particle(pdgid, (double)ptc.core().charge, tlv, ptc.core().status, startVertex, endVertex); particles.push_back(std::move(particle)); // papas::PDebug::write("Selected Papas{}", particle); } @@ -213,7 +211,7 @@ papas::Clusters PythiaConnector::ConvertClustersToPapas(const fcc::CaloClusterCo for (const auto& c : fccClusters) { const auto position = c.core().position; const auto energy = c.core().energy; - auto cluster = papas::Cluster(energy, TVector3(position.x, position.y, position.z), size, clusters.size(), itemtype, subtype); + papas::Cluster cluster(energy, TVector3(position.x, position.y, position.z), size, clusters.size(), itemtype, subtype); clusters.emplace(cluster.id(), std::move(cluster)); } return clusters; diff --git a/papas/graphtools/src/Ruler.cpp b/papas/graphtools/src/Ruler.cpp index 0af74da..c2bcec8 100644 --- a/papas/graphtools/src/Ruler.cpp +++ b/papas/graphtools/src/Ruler.cpp @@ -19,8 +19,8 @@ Distance Ruler::clusterClusterDistance(const Cluster& cluster1, const Cluster& c std::list allDistances; std::list linkedDistances; bool isLinked = false; - for (const auto c1 : cluster1.subClusters()) { - for (const auto c2 : cluster2.subClusters()) { + for (const auto& c1 : cluster1.subClusters()) { + for (const auto& c2 : cluster2.subClusters()) { Distance d = clusterClusterDistance(*c1, *c2); // recursive call allDistances.push_back(d.distance()); if (d.isLinked()) { diff --git a/papas/reconstruction/PFReconstructor.h b/papas/reconstruction/PFReconstructor.h index ac7a78b..b694501 100644 --- a/papas/reconstruction/PFReconstructor.h +++ b/papas/reconstruction/PFReconstructor.h @@ -59,10 +59,10 @@ class PFReconstructor { Ids ids = m_pfEvent.mergedElementIds(); // create the blocks of linked ids - auto bBuilder = PFBlockBuilder(m_pfEvent, ids); + PFBlockBuilder bBuilder(m_pfEvent, ids); // do the reconstruction of the blocks - auto pfReconstructor = PFReconstructor(m_pfEvent); + PFReconstructor pfReconstructor(m_pfEvent); pfReconstructor.reconstruct(bBuilder.blocks()); m_pfEvent.setReconstructedParticles(std::move(pfReconstructor.particles())); @endcode diff --git a/papas/reconstruction/src/BlockBuilder.cpp b/papas/reconstruction/src/BlockBuilder.cpp index 87582f3..051f2f8 100644 --- a/papas/reconstruction/src/BlockBuilder.cpp +++ b/papas/reconstruction/src/BlockBuilder.cpp @@ -24,7 +24,7 @@ void BlockBuilder::makeBlocks(char blockSubtype) { /* uses the base class GraphBuilder to work out which elements are connected (a subGraph) Each subGraph will be used to make a new PFBlock */ - for (auto& elementIds : m_subGraphs) { + for (const auto& elementIds : m_subGraphs) { /*#if WITHSORT if (elementIds.size() > 1) { sortIds(elementIds); diff --git a/papas/reconstruction/src/MergedClusterBuilder.cpp b/papas/reconstruction/src/MergedClusterBuilder.cpp index 2cb97d6..6809565 100644 --- a/papas/reconstruction/src/MergedClusterBuilder.cpp +++ b/papas/reconstruction/src/MergedClusterBuilder.cpp @@ -47,7 +47,7 @@ MergedClusterBuilder::MergedClusterBuilder(const Event& event, for (const auto& ids : grBuilder.subGraphs()) { const auto& id = *ids.begin(); double totalenergy = 0.; - for (const auto& c : ids) { + for (auto c : ids) { totalenergy += clusters.at(c).energy(); } // create the merged Cluster diff --git a/papas/reconstruction/src/PFReconstructor.cpp b/papas/reconstruction/src/PFReconstructor.cpp index 6c769bf..5051913 100644 --- a/papas/reconstruction/src/PFReconstructor.cpp +++ b/papas/reconstruction/src/PFReconstructor.cpp @@ -207,7 +207,7 @@ void PFReconstructor::reconstructHcal(const PFBlock& block, IdType hcalId) { // TODO assert(len(block.linked_ids(hcalid, "hcal_hcal"))==0 ) Ids ecalIds; - Ids trackIds = block.linkedIds(hcalId, Edge::EdgeType::kHcalTrack, WITHSORT); + Ids trackIds(block.linkedIds(hcalId, Edge::EdgeType::kHcalTrack, WITHSORT)); /*#if WITHSORT trackIds.sort(std::greater()); #endif*/ @@ -312,9 +312,9 @@ void PFReconstructor::reconstructCluster(const Cluster& cluster, papas::Layer la else { momentum = sqrt(pow(energy, 2) - pow(mass, 2)); } - TVector3 p3 = cluster.position().Unit() * momentum; - TLorentzVector p4 = TLorentzVector(p3.Px(), p3.Py(), p3.Pz(), energy); // mass is not accurate here - auto particle = PFParticle(pdgId, 0., p4, m_particles.size(), 'r', vertex, 0); + TVector3 p3(cluster.position().Unit() * momentum); + TLorentzVector p4(p3.Px(), p3.Py(), p3.Pz(), energy); // mass is not accurate here + PFParticle particle(pdgId, 0., p4, m_particles.size(), 'r', vertex, 0); // TODO discuss with Colin particle.path()->addPoint(papas::Position::kEcalIn, cluster.position()); if (layer == papas::Layer::kHcal) { // alice not sure @@ -342,7 +342,7 @@ void PFReconstructor::reconstructTrack(const Track& track, int pdgId, const Ids& pdgId = pdgId * track.charge(); TLorentzVector p4 = TLorentzVector(); p4.SetVectM(track.p3(), ParticlePData::particleMass(pdgId)); - auto particle = PFParticle(pdgId, track.charge(), p4, track, m_particles.size(), 'r'); + PFParticle particle(pdgId, track.charge(), p4, track, m_particles.size(), 'r'); //#todo fix this so it picks up smeared track points (need to propagate smeared track) // particle.set_path(track.path) m_locked[track.id()] = true; diff --git a/papas/simulation/src/Simulator.cpp b/papas/simulation/src/Simulator.cpp index a670ca4..c54fa9a 100644 --- a/papas/simulation/src/Simulator.cpp +++ b/papas/simulation/src/Simulator.cpp @@ -203,7 +203,7 @@ const Cluster& Simulator::cluster(IdType clusterId) const { PFParticle& Simulator::makeAndStorePFParticle(int pdgid, double charge, const TLorentzVector& tlv, const TVector3& vertex) { double field = m_detector.field()->getMagnitude(); - auto simParticle = PFParticle(pdgid, charge, tlv, m_particles.size(), 's', vertex, field); + PFParticle simParticle(pdgid, charge, tlv, m_particles.size(), 's', vertex, field); auto id = simParticle.id(); PDebug::write("Made {}", simParticle); m_particles.emplace(id, std::move(simParticle)); @@ -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); + Cluster cluster(energy, pos, csize, m_ecalClusters.size(), Identifier::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); + Cluster cluster(energy, pos, csize, m_hcalClusters.size(), Identifier::kHcalCluster, subtype); IdType id = cluster.id(); addNode(id, ptc.id()); PDebug::write("Made {}", cluster); @@ -303,7 +303,7 @@ Cluster Simulator::smearCluster(const Cluster& parent, papas::Layer detectorLaye 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'); + Cluster cluster(energy, parent.position(), parent.size(), counter, Identifier::itemType(parent.id()), 's'); PDebug::write("Made Smeared{}", cluster); return cluster; } @@ -334,7 +334,7 @@ const Cluster& Simulator::storeSmearedHcalCluster(Cluster&& smearedCluster, IdTy } const Track& Simulator::makeAndStoreTrack(const PFParticle& ptc) { - auto track = Track(ptc.p3(), ptc.charge(), ptc.path(), m_tracks.size(), 't'); + Track track(ptc.p3(), ptc.charge(), ptc.path(), m_tracks.size(), 't'); IdType id = track.id(); PDebug::write("Made {}", track); @@ -351,7 +351,7 @@ void Simulator::storeSmearedTrack(Track&& track, IdType parentid) { Track Simulator::smearTrack(const Track& track, double resolution) const { double scale_factor = rootrandom::Random::gauss(1, resolution); - auto smeared = Track(track.p3() * scale_factor, track.charge(), track.path(), m_smearedTracks.size(), 's'); + Track smeared(track.p3() * scale_factor, track.charge(), track.path(), m_smearedTracks.size(), 's'); PDebug::write("Made Smeared{}", smeared); return smeared; } From 434d3857df8b5ebe20f70e7d991454a70fb13dab Mon Sep 17 00:00:00 2001 From: Alice Date: Tue, 21 Mar 2017 12:38:52 +0100 Subject: [PATCH 3/6] remove WITHSORTS that are no longer needed --- examples/example_pdebug_python_comparer.cpp | 2 +- papas/reconstruction/src/BlockBuilder.cpp | 5 ----- papas/reconstruction/src/PFReconstructor.cpp | 20 ++------------------ 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/examples/example_pdebug_python_comparer.cpp b/examples/example_pdebug_python_comparer.cpp index 113ca6c..3fb5e4a 100644 --- a/examples/example_pdebug_python_comparer.cpp +++ b/examples/example_pdebug_python_comparer.cpp @@ -37,7 +37,7 @@ int main(int argc, char* argv[]) { CMS CMSDetector; papas::PapasManager papasManager{CMSDetector}; unsigned int eventNo = 0; - unsigned int nEvents = 200; + unsigned int nEvents = 10; auto start = std::chrono::steady_clock::now(); diff --git a/papas/reconstruction/src/BlockBuilder.cpp b/papas/reconstruction/src/BlockBuilder.cpp index 051f2f8..2764d9a 100644 --- a/papas/reconstruction/src/BlockBuilder.cpp +++ b/papas/reconstruction/src/BlockBuilder.cpp @@ -25,11 +25,6 @@ void BlockBuilder::makeBlocks(char blockSubtype) { Each subGraph will be used to make a new PFBlock */ for (const auto& elementIds : m_subGraphs) { - /*#if WITHSORT - if (elementIds.size() > 1) { - sortIds(elementIds); - } - #endif*/ PFBlock block(elementIds, m_edges, m_blocks.size(), blockSubtype); // make the block PDebug::write("Made {}", block); // put the block in the unordered map of blocks using move diff --git a/papas/reconstruction/src/PFReconstructor.cpp b/papas/reconstruction/src/PFReconstructor.cpp index 5051913..342a917 100644 --- a/papas/reconstruction/src/PFReconstructor.cpp +++ b/papas/reconstruction/src/PFReconstructor.cpp @@ -23,8 +23,8 @@ PFReconstructor::PFReconstructor(const Event& event, char blockSubtype, const De PFParticles& particles, Nodes& history) : m_event(event), m_detector(detector), m_particles(particles), m_history(history) { const auto& blocks = m_event.blocks(blockSubtype); - auto blockids = m_event.collectionIds(blocks); - + auto blockids = m_event.collectionIds(blocks, WITHSORT); + for (auto bid : blockids) { const PFBlock& block = blocks.at(bid); PDebug::write("Processing {}", block); @@ -41,9 +41,6 @@ PFReconstructor::PFReconstructor(const Event& event, char blockSubtype, const De void PFReconstructor::reconstructBlock(const PFBlock& block) { // see class description for summary of reconstruction approach Ids ids = block.elementIds(); - //#if WITHSORT TODO check that the ids are already sorted by this stage - //ids.sort(std::greater()); - //#endif for (auto id : ids) { m_locked[id] = false; } @@ -96,9 +93,6 @@ void PFReconstructor::reconstructBlock(const PFBlock& block) { void PFReconstructor::reconstructMuons(const PFBlock& block) { /// Reconstruct muons in block. Ids ids = block.elementIds(); -/*#if WITHSORT - ids.sort(std::greater()); -#endif*/ for (auto id : ids) { if (Identifier::isTrack(id) && isFromParticle(id, "ps", 13)) { @@ -111,9 +105,6 @@ void PFReconstructor::reconstructMuons(const PFBlock& block) { void PFReconstructor::reconstructElectrons(const PFBlock& block) { /*Reconstruct electrons in block.*/ Ids ids = block.elementIds(); -/*#if WITHSORT - ids.sort(std::greater()); -#endif*/ /* the simulator does not simulate electron energy deposits in ecal. # therefore, one should not lock the ecal clusters linked to the @@ -208,9 +199,6 @@ void PFReconstructor::reconstructHcal(const PFBlock& block, IdType hcalId) { Ids ecalIds; Ids trackIds(block.linkedIds(hcalId, Edge::EdgeType::kHcalTrack, WITHSORT)); -/*#if WITHSORT - trackIds.sort(std::greater()); -#endif*/ for (auto trackId : trackIds) { for (auto ecalId : block.linkedIds(trackId, Edge::EdgeType::kEcalTrack, WITHSORT)) { /*the ecals get all grouped together for all tracks in the block @@ -223,10 +211,6 @@ void PFReconstructor::reconstructHcal(const PFBlock& block, IdType hcalId) { } } } -/*#if WITHSORT - trackIds.sort(std::greater()); - ecalIds.sort(std::greater()); -#endif*/ // hcal should be the only remaining linked hcal cluster (closest one) const Cluster& hcal = m_event.cluster(hcalId); double hcalEnergy = hcal.energy(); From e1126955914b4c9d34d5e016090415098fc53653 Mon Sep 17 00:00:00 2001 From: Alice Date: Tue, 21 Mar 2017 13:45:52 +0100 Subject: [PATCH 4/6] auto for unit tests --- papas/datatypes/src/Event.cpp | 4 +- papas/simulation/src/Simulator.cpp | 2 +- tests/unittest.cpp | 171 ++++++++++++++--------------- 3 files changed, 88 insertions(+), 89 deletions(-) diff --git a/papas/datatypes/src/Event.cpp b/papas/datatypes/src/Event.cpp index 93972ee..f298e4b 100644 --- a/papas/datatypes/src/Event.cpp +++ b/papas/datatypes/src/Event.cpp @@ -69,7 +69,7 @@ const Blocks& Event::blocks(const Identifier::SubType subtype) const { } bool Event::hasCollection(Identifier::ItemType type, const Identifier::SubType subtype) const { // Check if this collection is present - bool found =false; + bool found = false; switch (type) { case Identifier::kEcalCluster: found = (m_ecalClustersCollection.find(subtype) != m_ecalClustersCollection.end()); @@ -98,7 +98,7 @@ bool Event::hasCollection(IdType id) const { bool Event::hasObject(IdType id) const { // check if this object id is present - bool found =false; + bool found = false; auto type = Identifier::itemType(id); if (hasCollection(id)) { switch (type) { diff --git a/papas/simulation/src/Simulator.cpp b/papas/simulation/src/Simulator.cpp index c54fa9a..58ba970 100644 --- a/papas/simulation/src/Simulator.cpp +++ b/papas/simulation/src/Simulator.cpp @@ -28,7 +28,7 @@ Simulator::Simulator(const Event& papasevent, const ListParticles& particles, co m_particles(simParticles), m_history(history), m_propHelix(detector.field()->getMagnitude()) { - for (auto p : particles) { + for (const auto& p: particles) { simulateParticle(p); } } diff --git a/tests/unittest.cpp b/tests/unittest.cpp index 5342b25..662164c 100644 --- a/tests/unittest.cpp +++ b/tests/unittest.cpp @@ -83,7 +83,7 @@ TEST_CASE("Identifier") { } TEST_CASE("Helix") { /// Helix path test - TLorentzVector p4 = TLorentzVector(); + TLorentzVector p4; p4.SetPtEtaPhiM(1, 0, 0, 5.11e-4); Helix helix(p4, TVector3(0, 0, 0), 3.8, 1); double length = helix.pathLength(1.0e-9); @@ -97,11 +97,11 @@ TEST_CASE("Helix") { /// Helix path test } TEST_CASE("Helixpath") { /// Helix path test - auto cyl1 = SurfaceCylinder(papas::Position::kEcalIn, 1., 2.); - auto cyl2 = SurfaceCylinder(papas::Position::kEcalOut, 2., 1.); + SurfaceCylinder cyl1(papas::Position::kEcalIn, 1., 2.); + SurfaceCylinder cyl2(papas::Position::kEcalOut, 2., 1.); double field = 3.8; - auto particle = PFParticle(211, -1, TLorentzVector{2., 0, 1, 5}, 1, 'r', TVector3{0, 0, 0}, field); - auto helixprop = HelixPropagator(3.8); + PFParticle particle(211, -1, TLorentzVector{2., 0, 1, 5}, 1, 'r', TVector3{0, 0, 0}, field); + HelixPropagator helixprop(3.8); //(particle.p4(), {0,0,0}, 3.8, -1); helixprop.propagateOne(particle, cyl1); auto tvec = particle.pathPosition(cyl1.layer()); @@ -122,9 +122,9 @@ TEST_CASE("Structures") { TEST_CASE("Cylinder") { - auto cyl1 = SurfaceCylinder(papas::Position::kEcalIn, 1, 2); - auto cyl2 = SurfaceCylinder(papas::Position::kEcalIn, 0.7, 1.5); - auto subcyl = VolumeCylinder(papas::Layer::kEcal, 1, 2, 0.7, 1.5); + SurfaceCylinder cyl1(papas::Position::kEcalIn, 1, 2); + SurfaceCylinder cyl2(papas::Position::kEcalIn, 0.7, 1.5); + VolumeCylinder subcyl(papas::Layer::kEcal, 1, 2, 0.7, 1.5); REQUIRE(subcyl.inner().radius() == 0.7); REQUIRE(subcyl.inner().z() == 1.5); REQUIRE(subcyl.outer().radius() == 1.); @@ -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'); + Cluster cluster(10., TVector3(1, 0, 0), 1., 1, Identifier::ItemType::kEcalCluster, 't'); REQUIRE(cluster.pt() == Approx(10.000)); cluster.setEnergy(5.); REQUIRE(cluster.pt() == Approx(5.000)); @@ -145,10 +145,10 @@ TEST_CASE("ClusterSmear") { // Make a cluster double energy = 10.; - auto cluster = Cluster(energy, TVector3(1, 0, 0), 1., 2, Identifier::kEcalCluster); - auto CMSDetector = CMS(); + Cluster cluster(energy, TVector3(1, 0, 0), 1., 2, Identifier::kEcalCluster); + CMS CMSDetector; auto ecal = CMSDetector.ecal(); - auto tester = PapasManagerTester(CMSDetector); + PapasManagerTester tester(CMSDetector); // smear it 10000 times and store the energy of the smeared cluster std::vector energies; @@ -208,11 +208,11 @@ TEST_CASE("Canvas") { // change to concrete object or unique pointer is there i TEST_CASE("StraightLine") { TVector3 origin{0, 0, 0}; StraightLinePropagator propStraight; - auto cyl1 = SurfaceCylinder(papas::Position::kEcalIn, 1, 2); - auto cyl2 = SurfaceCylinder(papas::Position::kEcalOut, 2, 1); + SurfaceCylinder cyl1(papas::Position::kEcalIn, 1, 2); + SurfaceCylinder cyl2(papas::Position::kEcalOut, 2, 1); TLorentzVector tlv{1, 0, 1, 2.}; - PFParticle photon = PFParticle(22, 0, tlv, 1); + PFParticle photon(22, 0, tlv, 1); propStraight.propagateOne(photon, cyl1); propStraight.propagateOne(photon, cyl2); auto points = photon.path()->points(); @@ -227,7 +227,7 @@ TEST_CASE("StraightLine") { // testing extrapolation to -z tlv = TLorentzVector(1, 0, -1, 2.); - PFParticle photon2 = PFParticle(22, 0, tlv, 1); + PFParticle photon2(22, 0, tlv, 1); propStraight.propagateOne(photon2, cyl1); propStraight.propagateOne(photon2, cyl2); points = photon2.path()->points(); @@ -245,8 +245,8 @@ TEST_CASE("StraightLine") { REQUIRE(points[papas::Position::kEcalIn].Perp() == Approx(.5)); // extrapolating from a vertex close to -endcap - tlv = TLorentzVector(1, 0, -1, 2.); - PFParticle photon4 = PFParticle(22, 0, tlv, 4, 's', {0, 0, -1.5}, 0.); + tlv = TLorentzVector (1, 0, -1, 2.); + PFParticle photon4 (22, 0, tlv, 4, 's', {0, 0, -1.5}, 0.); propStraight.propagateOne(photon4, cyl1); points = photon4.path()->points(); REQUIRE(points[papas::Position::kEcalIn].Perp() == Approx(.5)); @@ -287,49 +287,48 @@ 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'); + Cluster c1(1, TVector3(1, 0, 0), 1., 1, Identifier::kEcalCluster, 't'); + Cluster c2(2, TVector3(1, 0, 0), 1., 2, Identifier::kHcalCluster, 't'); auto p3 = c1.position().Unit() * 100.; - auto p4 = TLorentzVector(); + TLorentzVector p4; p4.SetVectM(p3, 1.); auto path = std::make_shared(StraightLine(p4, TVector3(0, 0, 0))); path->addPoint(papas::Position::kEcalIn, c1.position()); path->addPoint(papas::Position::kHcalIn, c2.position()); double charge = 1.; - auto tr = Track(p3, charge, path, 't'); - auto dist1 = Distance(c1, tr); + Track tr(p3, charge, path, 't'); + Distance dist1(c1, tr); REQUIRE(dist1.isLinked()); - auto dist2 = Distance(c2, c1); + Distance dist2 = Distance(c2, c1); REQUIRE(dist2.isLinked()); } 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 dist1 = Distance(c1, c2); + Cluster c1(10, TVector3(1, 0, 0), 4., 1, Identifier::ItemType::kEcalCluster, 't'); + Cluster c2(20, TVector3(1, 0, 0), 4., 2, Identifier::ItemType::kHcalCluster, 't'); + Distance dist1(c1, c2); REQUIRE(dist1.isLinked()); REQUIRE(dist1.distance() == 0); - - auto pos3 = TVector3(c1.position()); + TVector3 pos3 (c1.position()); pos3.RotateZ(0.059); - auto c3 = Cluster(30, pos3, 5., 3, Identifier::ItemType::kHcalCluster, 't'); - auto dist2 = Distance(c1, c3); + Cluster c3(30, pos3, 5., 3, Identifier::ItemType::kHcalCluster, 't'); + Distance dist2(c1, c3); REQUIRE(dist2.isLinked()); REQUIRE(dist2.distance() == 0.059); - auto dist3 = Distance(c3, c1); + Distance dist3(c3, c1); REQUIRE(dist3.isLinked()); REQUIRE(dist3.distance() == 0.059); } // TODO void test_graphs() { // Testing graphics - Display display = Display({papas::ViewPane::Projection::xy, papas::ViewPane::Projection::yz}); + Display display({papas::ViewPane::Projection::xy, papas::ViewPane::Projection::yz}); // Display display = // Display({papas::ViewPane::Projection::xy,papas::ViewPane::Projection::yz,papas::ViewPane::Projection::ECAL_thetaphi // ,papas::ViewPane::Projection::HCAL_thetaphi }); TVector3 vpos(1., .5, .3); - Cluster cluster = Cluster(10., vpos, 1., 1, Identifier::ItemType::kEcalCluster, 't'); + Cluster cluster(10., vpos, 1., 1, Identifier::ItemType::kEcalCluster, 't'); std::vector tvec; tvec.push_back(TVector3(0., 0., 0.)); tvec.push_back(TVector3(1., 1., 1.)); @@ -373,8 +372,8 @@ TEST_CASE("Edges") { IdType id2 = Identifier::makeId(2, Identifier::kHcalCluster, 't'); IdType id3 = Identifier::makeId(3, Identifier::kTrack, 't'); - Edge edge = Edge(id1, id2, false, 0.0); - Edge edge1 = Edge(id1, id3, true, 0.0); + Edge edge(id1, id2, false, 0.0); + Edge edge1(id1, id3, true, 0.0); REQUIRE(edge1.isLinked() == true); REQUIRE(edge.isLinked() == false); @@ -396,13 +395,13 @@ TEST_CASE("PFBlocks") { Ids ids{id1, id2, id3}; Ids ids2{id4, id5, id6}; - Edge edge = Edge(id1, id2, false, 0.00023); - Edge edge1 = Edge(id1, id3, true, 10030.0); - Edge edge2 = Edge(id2, id3, true, 0.00005); + Edge edge(id1, id2, false, 0.00023); + Edge edge1(id1, id3, true, 10030.0); + Edge edge2(id2, id3, true, 0.00005); - Edge edge4 = Edge(id4, id5, false, 3.1234); - Edge edge5 = Edge(id4, id6, true, 0.1234); - Edge edge6 = Edge(id5, id6, true, 123.0); + Edge edge4(id4, id5, false, 3.1234); + Edge edge5(id4, id6, true, 0.1234); + Edge edge6(id5, id6, true, 123.0); Edges edges; REQUIRE(edge1.distance() == 10030); @@ -439,9 +438,9 @@ TEST_CASE("BlockSplitter") { IdType id3 = Identifier::makeId(3, Identifier::kTrack, 't'); Ids ids{id1, id2, id3}; - Edge edge = Edge(id1, id2, false, 0.00023); - Edge edge1 = Edge(id1, id3, true, 10030.0); - Edge edge2 = Edge(id2, id3, true, 0.00005); + Edge edge(id1, id2, false, 0.00023); + Edge edge1(id1, id3, true, 10030.0); + Edge edge2(id2, id3, true, 0.00005); Edges edges; @@ -456,35 +455,35 @@ TEST_CASE("BlockSplitter") { Nodes emptyNodes; Blocks blocks; - auto blockbuilder = BlockBuilder(ids, std::move(edges), historyNodes, blocks, 'r'); + BlockBuilder blockbuilder(ids, std::move(edges), historyNodes, blocks, 'r'); REQUIRE(blockbuilder.subGraphs().size() == 1); Edges to_unlink; to_unlink[edge1.key()] = edge1; - auto event = Event(); + Event event; event.addCollection(blocks); - Blocks simplifiedBlocks = Blocks(); - auto splitter = PFBlockSplitter(event, 'r', simplifiedBlocks, emptyNodes); + Blocks simplifiedBlocks; + PFBlockSplitter splitter(event, 'r', simplifiedBlocks, emptyNodes); REQUIRE(simplifiedBlocks.size() == 2); return; } 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'); + Cluster cluster1(10., TVector3(0., 1., 0.), 0.04, 1, Identifier::kEcalCluster, 't'); + Cluster cluster2(20., TVector3(0., 1., 0), 0.06, 2, Identifier::kEcalCluster, 't'); Clusters eclusters; eclusters.emplace(cluster1.id(), cluster1); eclusters.emplace(cluster2.id(), cluster2); Clusters mergedClusters; Nodes nodes; - auto event = Event(); + Event event; event.addCollection(eclusters); - auto ruler = papas::EventRuler(event); - auto builder = MergedClusterBuilder(event, "et", ruler, mergedClusters, nodes); + papas::EventRuler ruler(event); + MergedClusterBuilder builder(event, "et", ruler, mergedClusters, nodes); REQUIRE(mergedClusters.size() == 1); - for (auto mergedCluster : mergedClusters) { + for (auto& mergedCluster: mergedClusters) { REQUIRE_THROWS(mergedCluster.second.size()); // not valid for merged cluster REQUIRE_THROWS(mergedCluster.second.angularSize()); // not valid for merged cluster REQUIRE(mergedCluster.second.energy() == 30.); @@ -498,19 +497,19 @@ 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'); + Cluster cluster1(20, TVector3(1, 0, 0), 0.1, 1, Identifier::kHcalCluster, 't'); + Cluster cluster2(20., TVector3(1, 0.05, 0.), 0.1, 2, Identifier::kHcalCluster, 't'); Clusters hclusters; hclusters.emplace(cluster1.id(), cluster1); hclusters.emplace(cluster2.id(), cluster2); Clusters mergedClusters; ; Nodes nodes; - auto event = Event(); + Event event; event.addCollection(hclusters); - auto ruler = papas::EventRuler(event); - auto builder = MergedClusterBuilder(event, "ht", ruler, mergedClusters, nodes); + papas::EventRuler ruler(event); + MergedClusterBuilder builder(event, "ht", ruler, mergedClusters, nodes); REQUIRE(mergedClusters.size() == 1); return; @@ -518,19 +517,19 @@ 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'); + Cluster cluster1(20, TVector3(1, 0, 0), 0.04, 1, Identifier::kHcalCluster, 't'); + Cluster cluster2(20., TVector3(1, 1.1, 0.), 0.04, 2, Identifier::kHcalCluster, 't'); Clusters hclusters; hclusters.emplace(cluster1.id(), cluster1); hclusters.emplace(cluster2.id(), cluster2); Clusters mergedClusters; Nodes nodes; - auto event = Event(); + Event event; event.addCollection(hclusters); - auto ruler = papas::EventRuler(event); - auto builder = MergedClusterBuilder(event, "ht", ruler, mergedClusters, nodes); + papas::EventRuler ruler(event); + MergedClusterBuilder builder(event, "ht", ruler, mergedClusters, nodes); REQUIRE(mergedClusters.size() == 2); return; @@ -538,8 +537,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'); + Cluster cluster1(20, TVector3(1, 0, 0), 0.04, 1, Identifier::kEcalCluster, 't'); + Cluster cluster2(20., TVector3(1, 1.1, 0.), 0.04, 2, Identifier::kHcalCluster, 't'); Clusters hclusters; Clusters eclusters; hclusters.emplace(cluster1.id(), cluster1); @@ -548,24 +547,24 @@ TEST_CASE("merge_different_layers") { Clusters mergedClusters; Nodes nodes; - auto event = Event(); + Event event; REQUIRE_THROWS(event.addCollection(hclusters)); return; } TEST_CASE("test_papasevent") { - auto event = Event(); - auto ecals = Clusters(); - auto tracks = Tracks(); + Event event; + Clusters ecals; + Tracks tracks; IdType lastid = 0; IdType lastcluster = 0; for (int i = 0; i < 2; i++) { - auto cluster = Cluster(10., TVector3(0, 0, 1), 2., i, Identifier::kEcalCluster, 't'); + Cluster cluster(10., TVector3(0, 0, 1), 2., i, Identifier::kEcalCluster, 't'); ecals.emplace(cluster.id(), std::move(cluster)); lastcluster = cluster.id(); - auto track = Track(TVector3(0, 0, 0), i, std::make_shared(), 't'); + Track track(TVector3(0, 0, 0), i, std::make_shared(), 't'); tracks.emplace(track.id(), std::move(track)); lastid = track.id(); } @@ -587,31 +586,31 @@ TEST_CASE("test_papasevent") { } TEST_CASE("test_history") { - auto event = Event(); + Event event; Nodes history; - auto ecals = Clusters(); - auto particles = PFParticles(); + Clusters ecals; + PFParticles particles; IdType lastid = 0; IdType lastcluster = 0; // 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'); + Cluster cluster(10., TVector3(0, 0, 1), 2., 1, Identifier::kEcalCluster, 't'); ecals.emplace(cluster.id(), std::move(cluster)); lastcluster = cluster.id(); - auto cnode = PFNode(lastcluster); + PFNode cnode(lastcluster); history.emplace(lastcluster, std::move(cnode)); - auto particle = PFParticle(22, -1, TLorentzVector(1, 1, 1, 1), 1, 'r', TVector3(0., 0., 0.), 0.7); + PFParticle particle(22, -1, TLorentzVector(1, 1, 1, 1), 1, 'r', TVector3(0., 0., 0.), 0.7); particles.emplace(particle.id(), std::move(particle)); lastid = particle.id(); - auto pnode = PFNode(lastid); + PFNode pnode(lastid); history.emplace(lastid, std::move(pnode)); history.at(lastid).addChild(history.at(lastcluster)); } event.addCollection(ecals); event.addCollection(particles); event.extendHistory(history); - auto hhelper = HistoryHelper(event); + HistoryHelper hhelper(event); // find what is connected to the last particle created auto ids = hhelper.linkedIds(lastid); // filter the ecals from the linked ids @@ -627,8 +626,8 @@ TEST_CASE("test_history") { 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'); + Cluster cluster1(20, TVector3(1, 0, 0), 0.055, 1, Identifier::kHcalCluster, 't'); + Cluster cluster2(20., TVector3(1., 0.1, 0.0), 0.055, 2, Identifier::kHcalCluster, 't'); Clusters hclusters; hclusters.emplace(cluster1.id(), cluster1); hclusters.emplace(cluster2.id(), cluster2); @@ -638,13 +637,13 @@ TEST_CASE("merge_inside") { Event testevent; Clusters mergedClusters; testevent.addCollection(hclusters); - auto ruler = papas::EventRuler(testevent); - auto builder = MergedClusterBuilder(testevent, "ht", ruler, mergedClusters,nodes); + papas::EventRuler ruler(testevent); + MergedClusterBuilder builder(testevent, "ht", ruler, mergedClusters, nodes); REQUIRE(mergedClusters.size() == 1); /*for (auto c : mergedClusters) { // REQUIRE(c.second.isInside(TVector3(1, 0.06, 0))); } */ - return; + return; } /*TEST_CASE("merge_pair_away" From 41b2c5889670e274a7b1f598ebe6d20d6d76e67d Mon Sep 17 00:00:00 2001 From: Alice Date: Tue, 21 Mar 2017 13:55:03 +0100 Subject: [PATCH 5/6] addresses https://github.com/HEP-FCC/papas/issues/14 --- tests/unittest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unittest.cpp b/tests/unittest.cpp index 662164c..b9deaaf 100644 --- a/tests/unittest.cpp +++ b/tests/unittest.cpp @@ -239,7 +239,7 @@ TEST_CASE("StraightLine") { // extrapolating from a vertex close to +endcap tlv = TLorentzVector(1, 0, 1, 2.); - PFParticle photon3 = PFParticle(22, 0, tlv, 3, 's', {0, 0, 1.5}, 0.); + PFParticle photon3(22, 0, tlv, 3, 's', {0, 0, 1.5}, 0.); propStraight.propagateOne(photon3, cyl1); points = photon3.path()->points(); REQUIRE(points[papas::Position::kEcalIn].Perp() == Approx(.5)); From 04a1c07ddc58eb641441bbe7b1560560c1673e7e Mon Sep 17 00:00:00 2001 From: Alice Date: Tue, 21 Mar 2017 14:07:02 +0100 Subject: [PATCH 6/6] checking before pull request --- papas/graphtools/src/GraphBuilder.cpp | 1 - papas/reconstruction/src/MergedClusterBuilder.cpp | 2 +- papas/reconstruction/src/PFBlockSplitter.cpp | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/papas/graphtools/src/GraphBuilder.cpp b/papas/graphtools/src/GraphBuilder.cpp index e0da687..b87545c 100644 --- a/papas/graphtools/src/GraphBuilder.cpp +++ b/papas/graphtools/src/GraphBuilder.cpp @@ -36,7 +36,6 @@ GraphBuilder::GraphBuilder(const Ids& ids, Edges&& edges) : m_edges(edges), m_el void GraphBuilder::sortIds(Ids& ids) { ids.sort(std::greater()); //sort in descending order - } } // end namespace papas diff --git a/papas/reconstruction/src/MergedClusterBuilder.cpp b/papas/reconstruction/src/MergedClusterBuilder.cpp index 6809565..3984222 100644 --- a/papas/reconstruction/src/MergedClusterBuilder.cpp +++ b/papas/reconstruction/src/MergedClusterBuilder.cpp @@ -43,7 +43,7 @@ MergedClusterBuilder::MergedClusterBuilder(const Event& event, } // create a graph using the ids and the edges this will produces subgroups of ids each of which will form // a new merged cluster. - GraphBuilder grBuilder(uniqueids, std::move(edges)); + GraphBuilder grBuilder(uniqueids, std::move(edges)); for (const auto& ids : grBuilder.subGraphs()) { const auto& id = *ids.begin(); double totalenergy = 0.; diff --git a/papas/reconstruction/src/PFBlockSplitter.cpp b/papas/reconstruction/src/PFBlockSplitter.cpp index 2fa0ebe..eca2d41 100644 --- a/papas/reconstruction/src/PFBlockSplitter.cpp +++ b/papas/reconstruction/src/PFBlockSplitter.cpp @@ -14,7 +14,7 @@ PFBlockSplitter::PFBlockSplitter(const Event& event, char blockSubtype, Blocks& Nodes& history) : m_event(event), m_simplifiedBlocks(simplifiedblocks), m_history(history) { const auto& blocks = m_event.blocks(blockSubtype); - const auto& blockids = m_event.collectionIds(blocks, WITHSORT); + auto blockids = m_event.collectionIds(blocks, WITHSORT); // go through each block and see if it can be simplified // in some cases it will end up being split into smaller blocks