diff --git a/examples/PythiaConnector.cpp b/examples/PythiaConnector.cpp index 6353e28..29d6743 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/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 ee75d0a..3fb5e4a 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]; @@ -37,7 +37,7 @@ int main(int argc, char* argv[]) { CMS CMSDetector; papas::PapasManager papasManager{CMSDetector}; unsigned int eventNo = 0; - unsigned int nEvents = 5; + unsigned int nEvents = 10; auto start = std::chrono::steady_clock::now(); 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/Cluster.h b/papas/datatypes/Cluster.h index c15f38c..6385bff 100644 --- a/papas/datatypes/Cluster.h +++ b/papas/datatypes/Cluster.h @@ -28,6 +28,7 @@ class Cluster { /** 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] index of the collection into which the cluster is to be stored @param[in] type eg IdCoder::kHcalCluster the identifier 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. diff --git a/papas/datatypes/Event.h b/papas/datatypes/Event.h index 9b64a60..f2fba0f 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 98c519f..81715a7 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 b2844a8..23b7bd4 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 << IdCoder::pretty(cluster.id()) << ":" << cluster.id() << ": " << cluster.info(); os << " sub("; - for (auto c : cluster.subClusters()) { + for (const auto& c : cluster.subClusters()) { os << IdCoder::pretty(c->id()) << ", "; } os << ")"; diff --git a/papas/datatypes/src/Event.cpp b/papas/datatypes/src/Event.cpp index c7b5c34..383e1cb 100644 --- a/papas/datatypes/src/Event.cpp +++ b/papas/datatypes/src/Event.cpp @@ -69,7 +69,7 @@ const Blocks& Event::blocks(const IdCoder::SubType subtype) const { } bool Event::hasCollection(IdCoder::ItemType type, const IdCoder::SubType subtype) const { // Check if this collection is present - auto found = false; + bool found = false; switch (type) { case IdCoder::kEcalCluster: found = (m_ecalClustersCollection.find(subtype) != m_ecalClustersCollection.end()); @@ -125,7 +125,7 @@ bool Event::hasObject(Identifier 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 d56746d..7e645ac 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(Identifier 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 7bff0f2..bfc7c27 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(Identifier 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 << IdCoder::pretty(node.first) << ":" << IdCoder::pretty(cnode->value()) << " "; } diff --git a/papas/graphtools/DirectedAcyclicGraph.h b/papas/graphtools/DirectedAcyclicGraph.h index 606f500..e8e3984 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 2a92cae..2986657 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 ec4fdec..61b03da 100644 --- a/papas/graphtools/src/GraphBuilder.cpp +++ b/papas/graphtools/src/GraphBuilder.cpp @@ -20,21 +20,22 @@ 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/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/BlockBuilder.h b/papas/reconstruction/BlockBuilder.h index c1fa838..6536ca6 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 551040b..0c3c4d0 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,8 @@ 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 id */ - Ids linkedIds(Identifier id, Edge::EdgeType edgetype = Edge::EdgeType::kUnknown) const; + + Ids linkedIds(Identifier id, 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/PFReconstructor.h b/papas/reconstruction/PFReconstructor.h index 8c400d3..bc79e55 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 8491ef1..8cf49ee 100644 --- a/papas/reconstruction/src/BlockBuilder.cpp +++ b/papas/reconstruction/src/BlockBuilder.cpp @@ -24,11 +24,8 @@ 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) { - if (elementIds.size() > 1) { - sortIds(elementIds); - } - auto block = PFBlock(elementIds, m_edges, m_blocks.size(), blockSubtype); // make the block + for (const auto& elementIds : m_subGraphs) { + 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 Identifier id = block.id(); diff --git a/papas/reconstruction/src/MergedClusterBuilder.cpp b/papas/reconstruction/src/MergedClusterBuilder.cpp index 40dca95..c2722f0 100644 --- a/papas/reconstruction/src/MergedClusterBuilder.cpp +++ b/papas/reconstruction/src/MergedClusterBuilder.cpp @@ -43,21 +43,18 @@ 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(ids, std::move(edges)); - for (auto subgraph : grBuilder.subGraphs()) { -#if WITHSORT - subgraph.sort(std::greater()); //sort in descending order -#endif - auto id = *subgraph.begin(); + GraphBuilder grBuilder(ids, std::move(edges)); + for (const auto& subgraph : grBuilder.subGraphs()) { + const auto& id = *subgraph.begin(); double totalenergy = 0.; - for (const auto& c : subgraph) { + for (auto c : subgraph) { totalenergy += clusters.at(c).energy(); } // 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(), IdCoder::type(id), 'm', totalenergy); // create a new cluster based on old one + + Cluster mergedCluster(clusters.at(id), merged.size(), IdCoder::type(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 72a9853..c024dfc 100644 --- a/papas/reconstruction/src/PFBlock.cpp +++ b/papas/reconstruction/src/PFBlock.cpp @@ -92,7 +92,8 @@ std::list PFBlock::linkedEdgeKeys(Identifier id, Edge::EdgeType m return linkedEdgeKeys; //todo consider sorting } -Ids PFBlock::linkedIds(Identifier id, Edge::EdgeType edgetype) const { + +Ids PFBlock::linkedIds(Identifier id, 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(id, edgetype)) { @@ -100,6 +101,8 @@ Ids PFBlock::linkedIds(Identifier id, 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(id)); } + if (sort) + linkedIds.sort(std::greater()); return linkedIds; } diff --git a/papas/reconstruction/src/PFBlockSplitter.cpp b/papas/reconstruction/src/PFBlockSplitter.cpp index cda87c9..fef3ed8 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 + 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 a4ad128..bb28373 100644 --- a/papas/reconstruction/src/PFReconstructor.cpp +++ b/papas/reconstruction/src/PFReconstructor.cpp @@ -23,10 +23,7 @@ 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); -#if WITHSORT - blockids.sort(std::greater()); -#endif + auto blockids = m_event.collectionIds(blocks, WITHSORT); for (auto bid : blockids) { const PFBlock& block = blocks.at(bid); PDebug::write("Processing {}", block); @@ -43,9 +40,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 - ids.sort(std::greater()); -#endif for (auto id : ids) { m_locked[id] = false; } @@ -98,9 +92,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 (IdCoder::isTrack(id) && isFromParticle(id, "ps", 13)) { @@ -113,9 +104,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 @@ -209,12 +197,9 @@ void PFReconstructor::reconstructHcal(const PFBlock& block, Identifier hcalId) { // TODO assert(len(block.linked_ids(hcalid, "hcal_hcal"))==0 ) Ids ecalIds; - Ids trackIds = block.linkedIds(hcalId, Edge::EdgeType::kHcalTrack); -#if WITHSORT - trackIds.sort(std::greater()); -#endif + Ids trackIds(block.linkedIds(hcalId, Edge::EdgeType::kHcalTrack, WITHSORT)); 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 +210,6 @@ void PFReconstructor::reconstructHcal(const PFBlock& block, Identifier 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(); @@ -314,9 +295,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 @@ -344,7 +325,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/reconstruction/src/PapasManager.cpp b/papas/reconstruction/src/PapasManager.cpp index d685f3e..6c373c0 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; } diff --git a/papas/simulation/src/Simulator.cpp b/papas/simulation/src/Simulator.cpp index b3c2e8d..4504bbc 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); } } @@ -203,7 +203,7 @@ const Cluster& Simulator::cluster(Identifier 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(), IdCoder::kEcalCluster, subtype); + Cluster cluster(energy, pos, csize, m_ecalClusters.size(), IdCoder::kEcalCluster, subtype); Identifier 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(), IdCoder::kHcalCluster, subtype); + Cluster cluster(energy, pos, csize, m_hcalClusters.size(), IdCoder::kHcalCluster, subtype); Identifier 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, IdCoder::type(parent.id()), 's'); + Cluster cluster(energy, parent.position(), parent.size(), counter, IdCoder::type(parent.id()), 's'); PDebug::write("Made Smeared{}", cluster); return cluster; } @@ -334,7 +334,8 @@ const Cluster& Simulator::storeSmearedHcalCluster(Cluster&& smearedCluster, Iden } 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'); Identifier id = track.id(); PDebug::write("Made {}", track); @@ -351,7 +352,7 @@ void Simulator::storeSmearedTrack(Track&& track, Identifier 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; } diff --git a/tests/unittest.cpp b/tests/unittest.cpp index 9847c22..ef1f510 100644 --- a/tests/unittest.cpp +++ b/tests/unittest.cpp @@ -83,7 +83,7 @@ TEST_CASE("IdCoder") { } 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, IdCoder::ItemType::kEcalCluster, 't'); + 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,10 +145,10 @@ TEST_CASE("ClusterSmear") { // Make a cluster double energy = 10.; - auto cluster = Cluster(energy, TVector3(1, 0, 0), 1., 2, IdCoder::kEcalCluster); - auto CMSDetector = CMS(); + Cluster cluster(energy, TVector3(1, 0, 0), 1., 2, IdCoder::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(); @@ -239,14 +239,14 @@ 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)); // 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,49 @@ TEST_CASE("dummy") { } TEST_CASE("Distance") { - 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'); + Cluster c1(1, TVector3(1, 0, 0), 1., 1, IdCoder::kEcalCluster, 't'); + Cluster c2(2, TVector3(1, 0, 0), 1., 2, IdCoder::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, IdCoder::ItemType::kEcalCluster, 't'); - auto c2 = Cluster(20, TVector3(1, 0, 0), 4., 2, IdCoder::ItemType::kHcalCluster, 't'); - auto dist1 = Distance(c1, c2); + + Cluster c1(10, TVector3(1, 0, 0), 4., 1, IdCoder::ItemType::kEcalCluster, 't'); + Cluster c2(20, TVector3(1, 0, 0), 4., 2, IdCoder::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, IdCoder::ItemType::kHcalCluster, 't'); - auto dist2 = Distance(c1, c3); + Cluster c3(30, pos3, 5., 3, IdCoder::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, IdCoder::ItemType::kEcalCluster, 't'); + 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.)); @@ -373,8 +373,8 @@ TEST_CASE("Edges") { Identifier id2 = IdCoder::makeId(2, IdCoder::kHcalCluster, 't'); Identifier id3 = IdCoder::makeId(3, IdCoder::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 +396,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 +439,9 @@ TEST_CASE("BlockSplitter") { Identifier id3 = IdCoder::makeId(3, IdCoder::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 +456,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, IdCoder::kEcalCluster, 't'); - auto cluster2 = Cluster(20., TVector3(0., 1., 0), 0.06, 2, IdCoder::kEcalCluster, 't'); + Cluster cluster1(10., TVector3(0., 1., 0.), 0.04, 1, IdCoder::kEcalCluster, 't'); + Cluster cluster2(20., TVector3(0., 1., 0), 0.06, 2, IdCoder::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.); @@ -497,20 +497,18 @@ TEST_CASE("Merge") { } TEST_CASE("merge_pair") { - - 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'); + Cluster cluster1(20, TVector3(1, 0, 0), 0.1, 1, IdCoder::kHcalCluster, 't'); + Cluster cluster2(20., TVector3(1, 0.05, 0.), 0.1, 2, IdCoder::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 +516,19 @@ TEST_CASE("merge_pair") { TEST_CASE("merge_pair_away") { - 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'); + Cluster cluster1(20, TVector3(1, 0, 0), 0.04, 1, IdCoder::kHcalCluster, 't'); + Cluster cluster2(20., TVector3(1, 1.1, 0.), 0.04, 2, IdCoder::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 +536,8 @@ TEST_CASE("merge_pair_away") { TEST_CASE("merge_different_layers") { - 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'); + Cluster cluster1(20, TVector3(1, 0, 0), 0.04, 1, IdCoder::kEcalCluster, 't'); + Cluster cluster2(20., TVector3(1, 1.1, 0.), 0.04, 2, IdCoder::kHcalCluster, 't'); Clusters hclusters; Clusters eclusters; hclusters.emplace(cluster1.id(), cluster1); @@ -548,24 +546,25 @@ 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; Identifier lastid = 0; Identifier lastcluster = 0; for (int i = 0; i < 2; i++) { - auto cluster = Cluster(10., TVector3(0, 0, 1), 2., i, IdCoder::kEcalCluster, 't'); + 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'); + 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; Identifier lastid = 0; Identifier 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, IdCoder::kEcalCluster, 't'); + 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); + 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, IdCoder::kHcalCluster, 't'); - auto cluster2 = Cluster(20., TVector3(1., 0.1, 0.0), 0.055, 2, IdCoder::kHcalCluster, 't'); + Cluster cluster1(20, TVector3(1, 0, 0), 0.055, 1, IdCoder::kHcalCluster, 't'); + Cluster cluster2(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); @@ -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"