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

minor changes in Setup

parent 2593f46f
No related branches found
No related tags found
No related merge requests found
#ifndef DECAYTREE_HH
#define DECAYTREE_HH
#pragma once
#include <iostream>
#include <cstdlib>
......@@ -43,7 +42,8 @@ namespace decayGraph
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++)
for (nameIter = particleNames.begin();
nameIter != particleNames.end(); nameIter++)
o << nameIter->first << " " << nameIter->second << std::endl;
}
};
......@@ -69,5 +69,3 @@ private:
std::map<int, std::string> *nameMap;
std::map<int, const Particle*> *particleMap;
};
#endif
......@@ -5,19 +5,16 @@ BOOSTLIBS = -lboost_date_time -lboost_filesystem -lboost_program_options -lboos
project :
requirements <include>./
# <include>$(extern)/log4cpp/include
<include>$(extern)/include
<include>$(ROOTSYS)/include
<include>$(GENEVA)/include
<link>static
<cxxflags>-pthread
# <cxxflags>-fopenmp
<linkflags>$(ROOTLIBS)
<linkflags>$(BOOSTLIBS)
<linkflags>-lMinuit2
<linkflags>-lgomp
<linkflags>-pthread
# <linkflags>-fopenmp
;
actions rootlibs
......@@ -41,6 +38,6 @@ build-project PwaUtils ;
build-project Particle ;
build-project Event ;
build-project DecayTree ;
# build-project Setup ;
build-project Setup ;
build-project PspGen ;
build-project Examples ;
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.3 FATAL_ERROR)
set(PACKAGE_NAME Setup)
MESSAGE("cmake installation for package: " ${PACKAGE_NAME})
set(INCLUDE_DIRECTORIES
${Boost_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${log4cpp_INCLUDE_DIRS}
)
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 SetupTestApp)
ADD_EXECUTABLE( ${EXECUTABLENAME}
SetupTestApp.cc
)
target_link_libraries(${EXECUTABLENAME} Setup)
target_link_libraries(${EXECUTABLENAME} DecayTree)
target_link_libraries(${EXECUTABLENAME} Event)
target_link_libraries(${EXECUTABLENAME} Particle)
target_link_libraries(${EXECUTABLENAME} ErrLogger)
target_link_libraries(${EXECUTABLENAME} Utils)
target_link_libraries(${EXECUTABLENAME} qft++)
target_link_libraries(${EXECUTABLENAME} ${log4cpp_LIBRARIES})
INSTALL ( TARGETS ${EXECUTABLENAME} DESTINATION bin/${EXECUTABLENAME})
project :
;
project : ;
lib Setup :
[ glob *.cc : *App.cc ]
$(TOP)/Event//Event
$(TOP)/DecayTree//DecayTree : : : ;
lib Setup : [ glob *.cc : *App.cc ] $(TOP)/Event//Event $(TOP)/DecayTree//DecayTree : : : ;
exe SetupTestApp : SetupTestApp.cc Setup : ;
#ifndef PWAENV_HH
#define PWAENV_HH
#pragma once
#include <string>
......@@ -9,7 +8,6 @@ class DecayTree;
class PwaEnv
{
public:
static PwaEnv& instance();
~PwaEnv();
......@@ -27,7 +25,4 @@ private:
DecayTree* theDecayTree;
EventList* theBeamEventList;
EventList* theMcEventList;
};
#endif
#ifndef SETUPGRAMMAR_HH
#define SETUPGRAMMAR_HH
#pragma once
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
......@@ -99,20 +98,16 @@ namespace setupGrammar
int indent;
};
struct decay_node_printer : boost::static_visitor<>
{
struct decay_node_printer : boost::static_visitor<> {
decay_node_printer(int indent = 0)
: indent(indent)
{
}
{}
void operator()(decay_tree const& decay) const
{
void operator()(decay_tree const& decay) const {
decay_tree_printer(indent+tabsize)(decay);
}
void operator()(std::string const& text) const
{
void operator()(std::string const& text) const {
tab(indent+tabsize);
std::cout << "final state particle " << text << std::endl;
finalToEdgeList(text);
......@@ -121,8 +116,7 @@ namespace setupGrammar
int indent;
};
void decay_tree_printer::operator()(decay_tree const& decay) const
{
void decay_tree_printer::operator()(decay_tree const& decay) const {
tab(indent);
std::cout << decay.name << " -> " << std::endl;
vertexToEdgeList(decay.name);
......@@ -161,56 +155,60 @@ namespace setupGrammar
///////////////////////////////////////////////////////////////////////////
//[tutorial_decay1_grammar
template <typename Iterator>
struct setup_file_grammar : qi::grammar<Iterator, decay_tree(), ascii::space_type>
{
setup_file_grammar() : setup_file_grammar::base_type(decay)
{
using qi::lit;
using qi::lexeme;
using ascii::char_;
using ascii::string;
using namespace qi::labels;
using phoenix::at_c;
using phoenix::push_back;
using boost::phoenix::ref;
restOfLine = lexeme[*(char_ -'\n') [_val += _1]];
comment = (char_('#') >> lexeme[*(char_ -'\n')]);
particleName = lexeme[+(char_('!','z') -',') [_val += _1]];
decNode = (decay | particleName);
goesTo = char_('-') >> char_('>');
decay = +( comment ||
"addParticle" >> restOfLine[push_back(at_c<2>(_val), _1)] ||
"cloneParticle" >> restOfLine[push_back(at_c<3>(_val), _1)] ||
"modParticle" >> restOfLine[push_back(at_c<4>(_val), _1)] ||
"beamInput" >> restOfLine[push_back(at_c<5>(_val), _1)] ||
"mcInput" >> restOfLine[push_back(at_c<6>(_val), _1)] ||
"defineTuple" >> restOfLine[push_back(at_c<7>(_val), _1)] ||
"fitVariables" >> restOfLine[push_back(at_c<8>(_val), _1)] ||
"initialProperties" >> restOfLine[push_back(at_c<9>(_val), _1)] ||
( char_('{')
>> (decay[push_back(at_c<1>(_val), _1)] || particleName[at_c<0>(_val) = _1])
>> goesTo
>> decNode [push_back(at_c<1>(_val), _1)]
>> ','
>> decNode [push_back(at_c<1>(_val), _1)]
>> char_('}') )
);
}
struct setup_file_grammar : qi::grammar<Iterator, decay_tree(),
ascii::space_type> {
setup_file_grammar() : setup_file_grammar::base_type(decay) {
using qi::lit;
using qi::lexeme;
using ascii::char_;
using ascii::string;
using namespace qi::labels;
using phoenix::at_c;
using phoenix::push_back;
using boost::phoenix::ref;
restOfLine = lexeme[*(char_ -'\n') [_val += _1]];
comment = (char_('#') >> lexeme[*(char_ -'\n')]);
particleName = lexeme[+(char_('!','z') -',') [_val += _1]];
decNode = (decay | particleName);
goesTo = char_('-') >> char_('>');
decay = +( comment ||
"addParticle"
>> restOfLine[push_back(at_c<2>(_val), _1)] ||
"cloneParticle"
>> restOfLine[push_back(at_c<3>(_val), _1)] ||
"modParticle"
>> restOfLine[push_back(at_c<4>(_val), _1)] ||
"beamInput"
>> restOfLine[push_back(at_c<5>(_val), _1)] ||
"mcInput"
>> restOfLine[push_back(at_c<6>(_val), _1)] ||
"defineTuple"
>> restOfLine[push_back(at_c<7>(_val), _1)] ||
"fitVariables"
>> restOfLine[push_back(at_c<8>(_val), _1)] ||
"initialProperties"
>> restOfLine[push_back(at_c<9>(_val), _1)] ||
( char_('{')
>> (decay[push_back(at_c<1>(_val), _1)]
|| particleName[at_c<0>(_val) = _1])
>> goesTo
>> decNode [push_back(at_c<1>(_val), _1)]
>> ','
>> decNode [push_back(at_c<1>(_val), _1)]
>> char_('}') )
);
}
qi::rule<Iterator, decay_tree(), ascii::space_type> decay;
qi::rule<Iterator, decay_node(), ascii::space_type> decNode;
qi::rule<Iterator, std::string(), ascii::space_type> goesTo;
qi::rule<Iterator, std::string(), ascii::space_type> comment;
qi::rule<Iterator, std::string(), ascii::space_type> restOfLine;
qi::rule<Iterator, std::string(), ascii::space_type> particleName;
qi::rule<Iterator, decay_tree(), ascii::space_type> decay;
qi::rule<Iterator, decay_node(), ascii::space_type> decNode;
qi::rule<Iterator, std::string(), ascii::space_type> goesTo;
qi::rule<Iterator, std::string(), ascii::space_type> comment;
qi::rule<Iterator, std::string(), ascii::space_type> restOfLine;
qi::rule<Iterator, std::string(), ascii::space_type> particleName;
};
}
#endif
}
......@@ -61,11 +61,11 @@ bool SetupParser::parse(std::string& fileName, ParticleTable* pdtTable)
std::string::const_iterator end = storage.end();
bool r = phrase_parse(iter, end, setupGrammar, space, *thisDecay);
if (r && iter == end) {
if (r && iter == end) {
Info << "\n\n"
<< "-------------------------\n"
<< "Parsing succeeded\n"
<< "-------------------------\n" << endmsg;
<< "-------------------------\n"
<< "Parsing succeeded\n"
<< "-------------------------\n" << endmsg;
setupGrammar::decay_tree_printer printer;
printer(*thisDecay);
setupGrammar::edgeList.print(std::cout);
......@@ -77,30 +77,30 @@ bool SetupParser::parse(std::string& fileName, ParticleTable* pdtTable)
std::cout << "add: " << *cmdLine << std::endl;
pData = new ParticleData;
if (pdtParser.parse(cmdLine->begin(), cmdLine->end(), *pData)) { // success
Particle* newParticle = new Particle(*pData);
newParticle->print(std::cout);
if (0 != pdtTable)
pdtTable->addParticle(newParticle);
Particle* newParticle = new Particle(*pData);
newParticle->print(std::cout);
if (0 != pdtTable)
pdtTable->addParticle(newParticle);
}
}
if (0 != pdtTable)
pdtTable->print(std::cout);
return true; // true means success
}
else {
std::string::const_iterator some = iter+30;
std::string context(iter, (some>end)?end:some);
ErrMsg << "\n\n"
<< "-------------------------\n"
<< "Parsing failed\n"
<< "stopped at: \": " << context << "...\"\n"
<< "-------------------------\n" << endmsg;
return false;
}
}
return false; // success
else {
std::string::const_iterator some = iter+30;
std::string context(iter, (some>end)?end:some);
ErrMsg << "\n\n"
<< "-------------------------\n"
<< "Parsing failed\n"
<< "stopped at: \": " << context << "...\"\n"
<< "-------------------------\n" << endmsg;
return false;
}
return false; // success
}
#ifndef SETUPPARSER_HH
#define SETUPPARSER_HH
#pragma once
#include <vector>
#include <string>
......@@ -8,13 +7,12 @@
#include <boost/variant/recursive_variant.hpp>
class ParticleTable;
namespace decayGraph
{
namespace decayGraph {
struct EdgeList;
}
namespace setupGrammar
{
namespace setupGrammar {
struct decay_tree;
......@@ -25,8 +23,7 @@ namespace setupGrammar
>
decay_node;
struct decay_tree
{
struct decay_tree {
std::string name; // mother particle name
std::vector<decay_node> children; // children
std::vector<std::string> addParticle;
......@@ -55,7 +52,4 @@ public:
private:
setupGrammar::decay_tree* thisDecay;
};
#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