Skip to content
Snippets Groups Projects
Commit 94fb6666 authored by Matthias Steinke's avatar Matthias Steinke
Browse files

added DecayTree package and class, and modified SetupTestApp

parent 582f0173
No related branches found
No related tags found
No related merge requests found
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.3 FATAL_ERROR)
set(PACKAGE_NAME DecayTree)
MESSAGE("cmake installation for package: " ${PACKAGE_NAME})
set(INCLUDE_DIRECTORIES
${Boost_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
)
include_directories( ${INCLUDE_DIRECTORIES})
AUX_SOURCE_DIRECTORY("." SRC)
Set(CCSRC "")
FOREACH (THEFILE ${SRC})
IF (NOT ${THEFILE} MATCHES "(.*)App(.*)")
SET (CCSRC ${CCSRC} ${THEFILE})
ENDIF()
ENDFOREACH(THEFILE)
# BUILD_SHARED_LIBS controls the behavior of ADD_LIBRARY if STATIC/SHARED omitted
IF( PAWIAN_STATIC )
ADD_LIBRARY ( ${PACKAGE_NAME} STATIC ${CCSRC} )
ELSE()
ADD_LIBRARY ( ${PACKAGE_NAME} SHARED ${CCSRC} )
ENDIF( PAWIAN_STATIC )
INSTALL (TARGETS ${PACKAGE_NAME} DESTINATION ${CMAKE_BINARY_DIR}/lib)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
# SET (EXECUTABLENAME PdtTestApp)
# ADD_EXECUTABLE( ${EXECUTABLENAME}
# PdtTestApp.cc
# )
target_link_libraries(${EXECUTABLENAME} ErrLogger)
target_link_libraries(${EXECUTABLENAME} Utils)
# INSTALL ( TARGETS ${EXECUTABLENAME} DESTINATION bin/${EXECUTABLENAME})
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.3 FATAL_ERROR)
set(PACKAGE_NAME Particle)
MESSAGE("cmake installation for package: " ${PACKAGE_NAME})
set(INCLUDE_DIRECTORIES
${Boost_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
)
include_directories( ${INCLUDE_DIRECTORIES})
AUX_SOURCE_DIRECTORY("." SRC)
Set(CCSRC "")
FOREACH (THEFILE ${SRC})
IF (NOT ${THEFILE} MATCHES "(.*)App(.*)")
SET (CCSRC ${CCSRC} ${THEFILE})
ENDIF()
ENDFOREACH(THEFILE)
# BUILD_SHARED_LIBS controls the behavior of ADD_LIBRARY if STATIC/SHARED omitted
IF( PAWIAN_STATIC )
ADD_LIBRARY ( ${PACKAGE_NAME} STATIC ${CCSRC} )
ELSE()
ADD_LIBRARY ( ${PACKAGE_NAME} SHARED ${CCSRC} )
ENDIF( PAWIAN_STATIC )
INSTALL (TARGETS ${PACKAGE_NAME} DESTINATION ${CMAKE_BINARY_DIR}/lib)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
SET (EXECUTABLENAME PdtTestApp)
ADD_EXECUTABLE( ${EXECUTABLENAME}
PdtTestApp.cc
)
target_link_libraries(${EXECUTABLENAME} Particle)
target_link_libraries(${EXECUTABLENAME} ErrLogger)
target_link_libraries(${EXECUTABLENAME} Utils)
INSTALL ( TARGETS ${EXECUTABLENAME} DESTINATION bin/${EXECUTABLENAME})
#include "DecayTree/DecayTree.hh"
#include "Particle/Particle.hh"
#include "Particle/ParticleTable.hh"
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <map>
using namespace decayGraph;
DecayTree::DecayTree()
{
}
DecayTree::~DecayTree()
{
}
DecayTree::DecayTree(const EdgeList* edgeList)
{
Edge edges[edgeList->decays.size() * 2];
int counter;
for (counter = 0; counter < edgeList->decays.size(); counter++) {
edges[2*counter] = std::pair<int,int>(edgeList->decays[counter]->mother,
edgeList->decays[counter]->daughters[0]);
edges[2*counter+1] = std::pair<int,int>(edgeList->decays[counter]->mother,
edgeList->decays[counter]->daughters[1]);
}
const std::size_t nedges = sizeof(edges)/sizeof(Edge);
theDecayTree = new Graph(edges, edges+nedges, edgeList->lastVertexNumber);
nameMap = &(const_cast<EdgeList*>(edgeList)->particleNames);
for (counter = 1; counter <= nameMap->size(); ++counter)
std::cout <<
" name " << counter << " " << nameMap->find(counter)->second << std::endl;
}
bool DecayTree::fillParticleRefs(ParticleTable& ptable)
{
particleMap = new std::map<int, const Particle*>;
std::map<int, std::string>::const_iterator nameIter;
for (nameIter = nameMap->begin(); nameIter != nameMap->end(); ++nameIter) {
if (nameIter->second.size() > 0)
particleMap->insert(std::pair<int, const Particle*>(nameIter->first,
ptable.particle(nameIter->second)));
}
return true;
}
void DecayTree::print(std::ostream& o) const
{
o << "a decay" << std::endl;
return;
}
#include "DecayTree/DecayTree.hh"
#include "Particle/Particle.hh"
#include "Particle/ParticleTable.hh"
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <map>
using namespace decayGraph;
DecayTree::DecayTree()
{
}
DecayTree::~DecayTree()
{
}
DecayTree::DecayTree(const EdgeList* edgeList)
{
Edge edges[edgeList->decays.size() * 2];
int counter;
for (counter = 0; counter < edgeList->decays.size(); counter++) {
edges[2*counter] = std::pair<int,int>(edgeList->decays[counter]->mother,
edgeList->decays[counter]->daughters[0]);
edges[2*counter+1] = std::pair<int,int>(edgeList->decays[counter]->mother,
edgeList->decays[counter]->daughters[1]);
}
const std::size_t nedges = sizeof(edges)/sizeof(Edge);
theDecayTree = new Graph(edges, edges+nedges, edgeList->lastVertexNumber);
nameMap = &(const_cast<EdgeList*>(edgeList)->particleNames);
std::cout << "name 0 " << nameMap->find(0)->second <<
" name 1 " << nameMap->find(1)->second << std::endl;
}
bool DecayTree::fillParticleRefs(ParticleTable& ptable)
{
particleMap = new std::map<int, const Particle*>;
std::map<int, std::string>::const_iterator nameIter;
for (nameIter = nameMap->begin(); nameIter != nameMap->end(); ++nameIter) {
if (nameIter->second.size() > 0)
particleMap->insert(std::pair<int, const Particle*>(nameIter->first,
ptable.particle(nameIter->second)));
}
return true;
}
void DecayTree::print(std::ostream& o) const
{
o << "a decay" << std::endl;
return;
}
#ifndef DECAYTREE_HH
#define DECAYTREE_HH
#include <iostream>
#include <cstdlib>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <boost/utility.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/topological_sort.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/visitors.hpp>
class ParticleTable;
class Particle;
namespace decayGraph
{
struct Decay {
int mother;
std::vector<int> daughters;
Decay(int mom) {mother = mom;};
void print(std::ostream& o) const {
std::vector<int>::const_iterator iter;
o << mother << " -> ";
for (iter = daughters.begin(); iter != daughters.end(); iter++)
o << *iter << " ";
o << std::endl;
}
};
struct EdgeList {
std::vector<Decay*> decays;
std::vector<Decay*>::reverse_iterator lastVertex;
std::map<int, std::string> particleNames;
int lastVertexNumber;
void print(std::ostream& o) const {
std::vector<Decay*>::const_iterator iter;
for (iter = decays.begin(); iter != decays.end(); iter++)
(*iter)->print(o);
std::map<int, std::string>::const_iterator nameIter;
for (nameIter = particleNames.begin(); nameIter != particleNames.end(); nameIter++)
o << nameIter->first << " " << nameIter->second << std::endl;
}
};
using namespace boost;
typedef std::pair<int, int> Edge;
typedef adjacency_list<vecS, vecS, bidirectionalS> Graph;
typedef graph_traits<Graph>::vertex_descriptor Vertex;
}
class DecayTree
{
public:
DecayTree();
~DecayTree();
DecayTree(const decayGraph::EdgeList* edgeList);
bool fillParticleRefs(ParticleTable& ptable);
void print(std::ostream& o) const;
private:
decayGraph::Graph *theDecayTree;
std::map<int, std::string> *nameMap;
std::map<int, const Particle*> *particleMap;
};
#endif
#ifndef DECAYTREE_HH
#define DECAYTREE_HH
#include <iostream>
#include <cstdlib>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <boost/utility.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/topological_sort.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/visitors.hpp>
#include <boost/property_map/dynamic_property_map.hpp>
#include <boost/property_map/property_map.hpp>
class ParticleTable;
class Particle;
namespace decayGraph
{
struct Decay {
int mother;
std::vector<int> daughters;
Decay(int mom) {mother = mom;};
void print(std::ostream& o) const {
std::vector<int>::const_iterator iter;
o << mother << " -> ";
for (iter = daughters.begin(); iter != daughters.end(); iter++)
o << *iter << " ";
o << std::endl;
}
};
struct EdgeList {
std::vector<Decay*> decays;
std::vector<Decay*>::reverse_iterator lastVertex;
std::map<int, std::string> particleNames;
int lastVertexNumber;
void print(std::ostream& o) const {
std::vector<Decay*>::const_iterator iter;
for (iter = decays.begin(); iter != decays.end(); iter++)
(*iter)->print(o);
std::map<int, std::string>::const_iterator nameIter;
for (nameIter = particleNames.begin(); nameIter != particleNames.end(); nameIter++)
o << nameIter->first << " " << nameIter->second << std::endl;
}
};
using namespace boost;
typedef std::pair<int, int> Edge;
typedef adjacency_list<vecS, vecS, bidirectionalS> Graph;
// property<vertex_name_t, std::string>
// > Graph;
typedef graph_traits<Graph>::vertex_descriptor Vertex;
}
class DecayTree
{
public:
DecayTree();
~DecayTree();
DecayTree(const decayGraph::EdgeList* edgeList);
bool fillParticleRefs(ParticleTable& ptable);
void print(std::ostream& o) const;
private:
decayGraph::Graph *theDecayTree;
boost::dynamic_properties dp;
std::map<int, std::string> *nameMap;
boost::associative_property_map< std::map<int, std::string> > *namePropMap;
std::map<int, Particle> *particleMap;
boost::associative_property_map< std::map<int, Particle> > *particlePropMap;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment