From c191ac967a5dd6c9433563f21835b597716058a4 Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Mon, 27 Feb 2017 13:11:44 +0100 Subject: [PATCH] Update to allow the externalization of the XML and the ComponentProperty sub-packages --- DDCore/include/DD4hep/BasicGrammar_inl.h | 4 +- .../include/DD4hep/ComponentProperties_inl.h | 12 +- DDCore/include/DD4hep/Parsers.h | 389 +++++++++--------- DDCore/src/BasicGrammarTypes.cpp | 1 - DDCore/src/ComponentProperties.cpp | 45 +- DDCore/src/parsers/Evaluators.cpp | 1 - DDCore/src/parsers/GrammarsV2.h | 1 - .../parsers/ParserStandardList_vector_int.cpp | 1 - .../ParserStandardList_vector_long.cpp | 1 - .../ParserStandardList_vector_string.cpp | 1 - DDCore/src/parsers/ParsersFactory.h | 12 +- .../parsers/ParsersObjects_PxPyPzEVector.cpp | 1 - .../src/parsers/ParsersObjects_XYZPoint.cpp | 1 - .../src/parsers/ParsersObjects_XYZVector.cpp | 1 - DDCore/src/parsers/UsedParser.h | 1 - DetSegmentation/CMakeLists.txt | 25 ++ .../include/DetSegmentation/GridPhiEta.h | 166 ++++++++ .../DetSegmentation/GridPhiEtaHandle.h | 103 +++++ .../include/DetSegmentation/GridRPhiEta.h | 213 ++++++++++ .../include/DetSegmentation/LinkDef.h | 6 + DetSegmentation/src/Factories.cpp | 17 + DetSegmentation/src/GridPhiEta.cpp | 84 ++++ DetSegmentation/src/GridPhiEtaHandle.cpp | 86 ++++ DetSegmentation/src/GridRPhiEta.cpp | 87 ++++ doc/externalize/ExtraParsers.cpp | 31 ++ doc/externalize/ExtraProperties.cpp | 38 +- doc/externalize/externalize_properties.sh | 25 +- 27 files changed, 1087 insertions(+), 266 deletions(-) create mode 100644 DetSegmentation/CMakeLists.txt create mode 100644 DetSegmentation/include/DetSegmentation/GridPhiEta.h create mode 100644 DetSegmentation/include/DetSegmentation/GridPhiEtaHandle.h create mode 100644 DetSegmentation/include/DetSegmentation/GridRPhiEta.h create mode 100644 DetSegmentation/include/DetSegmentation/LinkDef.h create mode 100644 DetSegmentation/src/Factories.cpp create mode 100644 DetSegmentation/src/GridPhiEta.cpp create mode 100644 DetSegmentation/src/GridPhiEtaHandle.cpp create mode 100644 DetSegmentation/src/GridRPhiEta.cpp create mode 100644 doc/externalize/ExtraParsers.cpp diff --git a/DDCore/include/DD4hep/BasicGrammar_inl.h b/DDCore/include/DD4hep/BasicGrammar_inl.h index 33d1a201e..9f629aecd 100644 --- a/DDCore/include/DD4hep/BasicGrammar_inl.h +++ b/DDCore/include/DD4hep/BasicGrammar_inl.h @@ -116,7 +116,7 @@ namespace DD4hep { int sc = 0; TYPE temp; #ifdef DD4HEP_USE_BOOST - sc = Parsers::parse(temp,string_val); + sc = ::DD4hep::Parsers::parse(temp,string_val); #endif if ( !sc ) sc = evaluate(&temp,string_val); #if 0 @@ -252,7 +252,7 @@ namespace DD4hep { else { TYPE temp; std::string temp_str = pre_parse_obj(str); - sc = Parsers::parse(temp,temp_str); + sc = ::DD4hep::Parsers::parse(temp,temp_str); if ( sc ) { *p = temp; return 1; diff --git a/DDCore/include/DD4hep/ComponentProperties_inl.h b/DDCore/include/DD4hep/ComponentProperties_inl.h index 2a55b02de..bef8c8604 100644 --- a/DDCore/include/DD4hep/ComponentProperties_inl.h +++ b/DDCore/include/DD4hep/ComponentProperties_inl.h @@ -69,18 +69,18 @@ namespace DD4hep { } // End namespace DD4hep // Instantiate single property -#define DD4HEP_DEFINE_PROPERTY_TYPE(x) \ +#define DD4HEP_DEFINE_PROPERTY_TYPE(x) namespace DD4hep { \ template x Property::value() const; \ template void Property::value(x& value) const; \ template void Property::set(const x& value); \ template Property& Property::operator=(const x& value); \ - template void Property::make(x& value) + template void Property::make(x& value); } // Instantiate single property with support for STL containers #define DD4HEP_DEFINE_PROPERTY_CONT(x) \ - DD4HEP_DEFINE_PROPERTY_TYPE(x); \ - DD4HEP_DEFINE_PROPERTY_TYPE(std::vector<x>); \ - DD4HEP_DEFINE_PROPERTY_TYPE(std::list<x>); \ + DD4HEP_DEFINE_PROPERTY_TYPE(x) \ + DD4HEP_DEFINE_PROPERTY_TYPE(std::vector<x>) \ + DD4HEP_DEFINE_PROPERTY_TYPE(std::list<x>) \ DD4HEP_DEFINE_PROPERTY_TYPE(std::set<x>) #if defined(DD4HEP_HAVE_ALL_PARSERS) @@ -89,7 +89,7 @@ namespace DD4hep { //// // Instantiate single property with support for STL containers + same for unsigned #define DD4HEP_DEFINE_PROPERTY_U_CONT(x) \ - DD4HEP_DEFINE_PROPERTY_CONT(x); \ + DD4HEP_DEFINE_PROPERTY_CONT(x) \ DD4HEP_DEFINE_PROPERTY_CONT(unsigned x) #else diff --git a/DDCore/include/DD4hep/Parsers.h b/DDCore/include/DD4hep/Parsers.h index e50b45b92..a84592709 100644 --- a/DDCore/include/DD4hep/Parsers.h +++ b/DDCore/include/DD4hep/Parsers.h @@ -25,35 +25,40 @@ #include <deque> // ============================================================================ -#define PARSERS_DECL_FOR_SINGLE(Type) \ - int parse(Type& result, const std::string& input); +#define PARSERS_DECL_FOR_SINGLE(Type) \ + namespace DD4hep { namespace Parsers { \ + int parse(Type& result, const std::string& input); }} #define PARSERS_DECL_FOR_PAIR(FirstType, SecondType) \ - int parse(std::pair<FirstType, SecondType >& result,const std::string& input); + namespace DD4hep { namespace Parsers { \ + int parse(std::pair<FirstType, SecondType >& result,const std::string& input); }} #if defined(DD4HEP_HAVE_ALL_PARSERS) #define PARSERS_DECL_FOR_LIST(InnerType) \ - int parse(std::vector<InnerType >& result,const std::string& input); \ - int parse(std::list<InnerType >& result,const std::string& input); \ - int parse(std::set<InnerType >& result,const std::string& input); \ - int parse(std::deque<InnerType >& result,const std::string& input); \ - int parse(std::map<std::string,InnerType >& result,const std::string& input); \ - int parse(std::map<int,InnerType >& result,const std::string& input); \ - int parse(std::map<unsigned long,InnerType >& result,const std::string& input); \ - int parse(std::pair<std::string,InnerType >& result,const std::string& input); \ - int parse(std::pair<int,InnerType >& result,const std::string& input); \ - int parse(std::pair<unsigned long,InnerType >& result,const std::string& input); - + namespace DD4hep { namespace Parsers { \ + int parse(std::vector<InnerType >& result,const std::string& input); \ + int parse(std::list<InnerType >& result,const std::string& input); \ + int parse(std::set<InnerType >& result,const std::string& input); \ + int parse(std::deque<InnerType >& result,const std::string& input); \ + int parse(std::map<std::string,InnerType >& result,const std::string& input); \ + int parse(std::map<int,InnerType >& result,const std::string& input); \ + int parse(std::map<unsigned long,InnerType >& result,const std::string& input); \ + int parse(std::pair<std::string,InnerType >& result,const std::string& input); \ + int parse(std::pair<int,InnerType >& result,const std::string& input); \ + int parse(std::pair<unsigned long,InnerType >& result,const std::string& input); \ + }} #else -#define PARSERS_DECL_FOR_LIST(InnerType) \ - int parse(std::vector<InnerType >& result,const std::string& input); \ - int parse(std::list<InnerType >& result,const std::string& input); \ - int parse(std::set<InnerType >& result,const std::string& input); \ - int parse(std::map<std::string,InnerType >& result,const std::string& input); \ - int parse(std::map<int,InnerType >& result,const std::string& input); \ - int parse(std::pair<std::string,InnerType >& result,const std::string& input); \ - int parse(std::pair<int,InnerType >& result,const std::string& input); +#define PARSERS_DECL_FOR_LIST(InnerType) \ + namespace DD4hep { namespace Parsers { \ + int parse(std::vector<InnerType >& result,const std::string& input); \ + int parse(std::list<InnerType >& result,const std::string& input); \ + int parse(std::set<InnerType >& result,const std::string& input); \ + int parse(std::map<std::string,InnerType >& result,const std::string& input); \ + int parse(std::map<int,InnerType >& result,const std::string& input); \ + int parse(std::pair<std::string,InnerType >& result,const std::string& input); \ + int parse(std::pair<int,InnerType >& result,const std::string& input); \ + }} #endif // DD4HEP_HAVE_ALL_PARSERS @@ -91,156 +96,156 @@ */ // ============================================================================ -/// Namespace for the AIDA detector description toolkit -namespace DD4hep { - /// Namespace for the AIDA detector for utilities using boost::spirit parsers - namespace Parsers { - - // ======================================================================== - /// parse the <c>bool</c> value - /** @see DD4hep::Parsers::BoolGrammar - * @param result (output) boolean result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-12 - */ - PARSERS_DECL_FOR_SINGLE(bool) - // ======================================================================== - /// parse the <c>char</c> value - /** - * @see DD4hep::Parsers::CharGrammar - * @param result (output) boolean result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-12 - */ +// ======================================================================== +/// parse the <c>bool</c> value +/** @see DD4hep::Parsers::BoolGrammar + * @param result (output) boolean result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-12 + */ +PARSERS_DECL_FOR_SINGLE(bool) +// ======================================================================== +/// parse the <c>char</c> value +/** + * @see DD4hep::Parsers::CharGrammar + * @param result (output) boolean result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-12 + */ #if defined(DD4HEP_HAVE_ALL_PARSERS) - PARSERS_DECL_FOR_SINGLE(char) - /// @see DD4hep::Parsers::parser(char&,std::string&) - PARSERS_DECL_FOR_SINGLE(unsigned char) - /// @see DD4hep::Parsers::parser(char&,std::string&) - PARSERS_DECL_FOR_SINGLE(signed char) +PARSERS_DECL_FOR_SINGLE(char) +/// @see DD4hep::Parsers::parser(char&,std::string&) +PARSERS_DECL_FOR_SINGLE(unsigned char) +/// @see DD4hep::Parsers::parser(char&,std::string&) +PARSERS_DECL_FOR_SINGLE(signed char) #endif - // ======================================================================== - /// parse the <c>int</c> value - /** - * @see DD4hep::Parsers::IntGrammar - * @param result (output) integer result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(int) - PARSERS_DECL_FOR_SINGLE(long) +// ======================================================================== +/// parse the <c>int</c> value +/** + * @see DD4hep::Parsers::IntGrammar + * @param result (output) integer result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ +/// @see DD4hep::Parsers::parser( int&, const std::string& ) +PARSERS_DECL_FOR_SINGLE(int) +PARSERS_DECL_FOR_SINGLE(long) #if defined(DD4HEP_HAVE_ALL_PARSERS) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(short) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(unsigned short) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(unsigned int) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(unsigned long) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(long long) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(unsigned long long) +/// @see DD4hep::Parsers::parser( int&, const std::string& ) +PARSERS_DECL_FOR_SINGLE(short) +/// @see DD4hep::Parsers::parser( int&, const std::string& ) +PARSERS_DECL_FOR_SINGLE(unsigned short) +/// @see DD4hep::Parsers::parser( int&, const std::string& ) +PARSERS_DECL_FOR_SINGLE(unsigned int) +/// @see DD4hep::Parsers::parser( int&, const std::string& ) +PARSERS_DECL_FOR_SINGLE(unsigned long) +/// @see DD4hep::Parsers::parser( int&, const std::string& ) +PARSERS_DECL_FOR_SINGLE(long long) +/// @see DD4hep::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE(unsigned long long) #endif - // ======================================================================== - /// parse the <c>double</c> value - /** - * @see DD4hep::Parsers::RealGrammar - * @param result (output) double result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_SINGLE(double) - /// @see DD4hep::Parsers::parser( double&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(float) +// ======================================================================== +/// parse the <c>double</c> value +/** + * @see DD4hep::Parsers::RealGrammar + * @param result (output) double result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ +PARSERS_DECL_FOR_SINGLE(double) +/// @see DD4hep::Parsers::parser( double&, const std::string& ) +PARSERS_DECL_FOR_SINGLE(float) #if defined(DD4HEP_HAVE_ALL_PARSERS) - /// @see DD4hep::Parsers::parser( double&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(long double) +/// @see DD4hep::Parsers::parser( double&, const std::string& ) +PARSERS_DECL_FOR_SINGLE(long double) #endif - // ======================================================================== - /** parse the <c>std::string</c> value - * - * @see DD4hep::Parsers::StringGrammar - * @param result (output) string result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_SINGLE(std::string) - // ======================================================================== +// ======================================================================== +/** parse the <c>std::string</c> value + * + * @see DD4hep::Parsers::StringGrammar + * @param result (output) string result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ +PARSERS_DECL_FOR_SINGLE(std::string) +// ======================================================================== - PARSERS_DECL_FOR_LIST(int) - PARSERS_DECL_FOR_LIST(long) - PARSERS_DECL_FOR_LIST(bool) - PARSERS_DECL_FOR_LIST(double) - PARSERS_DECL_FOR_LIST(float) - PARSERS_DECL_FOR_LIST(std::string) +PARSERS_DECL_FOR_LIST(int) +PARSERS_DECL_FOR_LIST(long) +PARSERS_DECL_FOR_LIST(bool) +PARSERS_DECL_FOR_LIST(double) +PARSERS_DECL_FOR_LIST(float) +PARSERS_DECL_FOR_LIST(std::string) #if defined(DD4HEP_HAVE_ALL_PARSERS) - PARSERS_DECL_FOR_LIST(char) - PARSERS_DECL_FOR_LIST(unsigned char) - PARSERS_DECL_FOR_LIST(signed char) - PARSERS_DECL_FOR_LIST(short) - PARSERS_DECL_FOR_LIST(unsigned short) - PARSERS_DECL_FOR_LIST(unsigned int) - PARSERS_DECL_FOR_LIST(unsigned long) - PARSERS_DECL_FOR_LIST(long long) - PARSERS_DECL_FOR_LIST(unsigned long long) - PARSERS_DECL_FOR_LIST(long double) +PARSERS_DECL_FOR_LIST(char) +PARSERS_DECL_FOR_LIST(unsigned char) +PARSERS_DECL_FOR_LIST(signed char) +PARSERS_DECL_FOR_LIST(short) +PARSERS_DECL_FOR_LIST(unsigned short) +PARSERS_DECL_FOR_LIST(unsigned int) +PARSERS_DECL_FOR_LIST(unsigned long) +PARSERS_DECL_FOR_LIST(long long) +PARSERS_DECL_FOR_LIST(unsigned long long) +PARSERS_DECL_FOR_LIST(long double) #endif - // ======================================================================== - // Advanced parses - // ======================================================================== - /// parse the <c>std::pair\<double,double\></c> value - /** - * @see DD4hep::Parsers::PairGrammar - * @see DD4hep::Parsers::RealGrammar - * @param result (output) pair of doubles - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_PAIR(double, double) - // ======================================================================== - /** parse the <c>std::pair\<int,int\></c> value - * - * @see DD4hep::Parsers::PairGrammar - * @see DD4hep::Parsers::IntGrammar - * @param result (output) pair of integers - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_PAIR(int, int) - // ======================================================================== +// ======================================================================== +// Advanced parses +// ======================================================================== +/// parse the <c>std::pair\<double,double\></c> value +/** + * @see DD4hep::Parsers::PairGrammar + * @see DD4hep::Parsers::RealGrammar + * @param result (output) pair of doubles + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ +PARSERS_DECL_FOR_PAIR(double, double) +// ======================================================================== +/** parse the <c>std::pair\<int,int\></c> value + * + * @see DD4hep::Parsers::PairGrammar + * @see DD4hep::Parsers::IntGrammar + * @param result (output) pair of integers + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ +PARSERS_DECL_FOR_PAIR(int, int) +// ======================================================================== + +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + /// Namespace for the AIDA detector for utilities using boost::spirit parsers + namespace Parsers { /// parse the <c>std::vector\<std::pair\<double,double\> \></c> value /** @@ -553,10 +558,8 @@ namespace DD4hep { // return 1; // RETURN } - // ======================================================================== - }// end of namespace Parsers - // ========================================================================== -}// end of namespace DD4hep + } // end of namespace Parsers +} // end of namespace DD4hep #ifndef DD4HEP_PARSERS_NO_ROOT @@ -726,37 +729,37 @@ namespace DD4hep { * @date 2009-09-05 */ int parse(ROOT::Math::PxPyPzEVector& result, const std::string& input); + } // end of namespace Parsers +} // end of namespace DD4hep - // ======================================================================== - /// parse the vector of points - /** @param result (OUTPUT) the parser vector - * @param input (INPUT) the string to be parsed - * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl - * @date 2009-09-05 - */ - PARSERS_DECL_FOR_LIST(ROOT::Math::XYZPoint) - // ======================================================================== - /// parse the vector of vectors - /** @param result (OUTPUT) the parser vector - * @param input (INPIUT) the string to be parsed - * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl - * @date 2009-09-05 - */ - PARSERS_DECL_FOR_LIST(ROOT::Math::XYZVector) +// ======================================================================== +/// parse the vector of points +/** @param result (OUTPUT) the parser vector + * @param input (INPUT) the string to be parsed + * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl + * @date 2009-09-05 + */ +PARSERS_DECL_FOR_LIST(ROOT::Math::XYZPoint) + +// ======================================================================== +/// parse the vector of vectors +/** @param result (OUTPUT) the parser vector + * @param input (INPIUT) the string to be parsed + * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl + * @date 2009-09-05 + */ +PARSERS_DECL_FOR_LIST(ROOT::Math::XYZVector) + +// ======================================================================== +/// parse the vector of vectors +/** @param result (OUTPUT) the parser vector + * @param input (INPUT) the string to be parsed + * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl + * @date 2009-09-05 + */ +PARSERS_DECL_FOR_LIST(ROOT::Math::PxPyPzEVector) - // ======================================================================== - /// parse the vector of vectors - /** @param result (OUTPUT) the parser vector - * @param input (INPUT) the string to be parsed - * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl - * @date 2009-09-05 - */ - PARSERS_DECL_FOR_LIST(ROOT::Math::PxPyPzEVector) - // ======================================================================== - }// end of namespace Parsers - // ========================================================================== -}// end of namespace DD4hep #endif // ============================================================================ // The END diff --git a/DDCore/src/BasicGrammarTypes.cpp b/DDCore/src/BasicGrammarTypes.cpp index efbb5df48..4a4ec91a3 100644 --- a/DDCore/src/BasicGrammarTypes.cpp +++ b/DDCore/src/BasicGrammarTypes.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDCore/src/ComponentProperties.cpp b/DDCore/src/ComponentProperties.cpp index bcca31f83..954849e2a 100644 --- a/DDCore/src/ComponentProperties.cpp +++ b/DDCore/src/ComponentProperties.cpp @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -252,44 +251,40 @@ DD4HEP_DEFINE_PARSER_GRAMMAR_TYPE(Property) namespace DD4hep { - //DD4HEP_DEFINE_PROPERTY_TYPE(Property); template Property Property::value() const; template void Property::value(Property& value) const; template void Property::set(const Property& value); template void Property::make(Property& value); +} - - #if defined(DD4HEP_HAVE_ALL_PARSERS) - DD4HEP_DEFINE_PROPERTY_U_CONT(char); - DD4HEP_DEFINE_PROPERTY_U_CONT(short); - DD4HEP_DEFINE_PROPERTY_U_CONT(long long); +#if defined(DD4HEP_HAVE_ALL_PARSERS) +DD4HEP_DEFINE_PROPERTY_U_CONT(char) +DD4HEP_DEFINE_PROPERTY_U_CONT(short) +DD4HEP_DEFINE_PROPERTY_U_CONT(long long) #endif // DD4HEP_HAVE_ALL_PARSERS - DD4HEP_DEFINE_PROPERTY_CONT(bool); - DD4HEP_DEFINE_PROPERTY_U_CONT(int); - DD4HEP_DEFINE_PROPERTY_U_CONT(long); - DD4HEP_DEFINE_PROPERTY_CONT(float); - DD4HEP_DEFINE_PROPERTY_CONT(double); +DD4HEP_DEFINE_PROPERTY_CONT(bool) +DD4HEP_DEFINE_PROPERTY_U_CONT(int) +DD4HEP_DEFINE_PROPERTY_U_CONT(long) +DD4HEP_DEFINE_PROPERTY_CONT(float) +DD4HEP_DEFINE_PROPERTY_CONT(double) - // STL objects - DD4HEP_DEFINE_PROPERTY_CONT(string); +// STL objects +DD4HEP_DEFINE_PROPERTY_CONT(string) - typedef map<string, int> map_string_int; - DD4HEP_DEFINE_PROPERTY_TYPE(map_string_int); +typedef map<string, int> map_string_int; +DD4HEP_DEFINE_PROPERTY_TYPE(map_string_int) - typedef map<string, string> map_string_string; - DD4HEP_DEFINE_PROPERTY_TYPE(map_string_string); -} +typedef map<string, string> map_string_string; +DD4HEP_DEFINE_PROPERTY_TYPE(map_string_string) #ifndef DD4HEP_PARSERS_NO_ROOT #include "Math/Point3D.h" #include "Math/Vector3D.h" #include "Math/Vector4D.h" -namespace DD4hep { - // ROOT::Math Object instances - DD4HEP_DEFINE_PROPERTY_TYPE(ROOT::Math::XYZPoint); - DD4HEP_DEFINE_PROPERTY_TYPE(ROOT::Math::XYZVector); - DD4HEP_DEFINE_PROPERTY_TYPE(ROOT::Math::PxPyPzEVector); -} +// ROOT::Math Object instances +DD4HEP_DEFINE_PROPERTY_TYPE(ROOT::Math::XYZPoint) +DD4HEP_DEFINE_PROPERTY_TYPE(ROOT::Math::XYZVector) +DD4HEP_DEFINE_PROPERTY_TYPE(ROOT::Math::PxPyPzEVector) #endif diff --git a/DDCore/src/parsers/Evaluators.cpp b/DDCore/src/parsers/Evaluators.cpp index 247c1be26..47fc0c781 100644 --- a/DDCore/src/parsers/Evaluators.cpp +++ b/DDCore/src/parsers/Evaluators.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDCore/src/parsers/GrammarsV2.h b/DDCore/src/parsers/GrammarsV2.h index f06bcb5be..89cd396cc 100644 --- a/DDCore/src/parsers/GrammarsV2.h +++ b/DDCore/src/parsers/GrammarsV2.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDCore/src/parsers/ParserStandardList_vector_int.cpp b/DDCore/src/parsers/ParserStandardList_vector_int.cpp index ae6503de4..39f8ce770 100644 --- a/DDCore/src/parsers/ParserStandardList_vector_int.cpp +++ b/DDCore/src/parsers/ParserStandardList_vector_int.cpp @@ -1,4 +1,3 @@ -// $Id: ParserStandardList_vector_int.cpp 2166 2016-03-17 16:37:06Z /DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=sailer/CN=683529/CN=Andre Sailer $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDCore/src/parsers/ParserStandardList_vector_long.cpp b/DDCore/src/parsers/ParserStandardList_vector_long.cpp index e35adedce..d7772379d 100644 --- a/DDCore/src/parsers/ParserStandardList_vector_long.cpp +++ b/DDCore/src/parsers/ParserStandardList_vector_long.cpp @@ -1,4 +1,3 @@ -// $Id: ParserStandardList_vector_long.cpp 2166 2016-03-17 16:37:06Z /DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=sailer/CN=683529/CN=Andre Sailer $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDCore/src/parsers/ParserStandardList_vector_string.cpp b/DDCore/src/parsers/ParserStandardList_vector_string.cpp index 9c335ed37..f5ab9c627 100644 --- a/DDCore/src/parsers/ParserStandardList_vector_string.cpp +++ b/DDCore/src/parsers/ParserStandardList_vector_string.cpp @@ -1,4 +1,3 @@ -// $Id: ParserStandardList_vector_string.cpp 2166 2016-03-17 16:37:06Z /DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=sailer/CN=683529/CN=Andre Sailer $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDCore/src/parsers/ParsersFactory.h b/DDCore/src/parsers/ParsersFactory.h index 5080ff88f..ea16ecabc 100644 --- a/DDCore/src/parsers/ParsersFactory.h +++ b/DDCore/src/parsers/ParsersFactory.h @@ -29,8 +29,11 @@ #include "UsedParser.h" #include "GrammarsV2.h" // ============================================================================ -namespace DD4hep { +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + /// Namespace for the AIDA detector for utilities using boost::spirit parsers namespace Parsers { + // ======================================================================== typedef std::string::const_iterator IteratorT; //typedef boost::spirit::ascii::space_type Skipper; @@ -56,12 +59,15 @@ namespace DD4hep { return true; } //========================================================================= - }/* Parsers */ -} /* DD4hep */ + + } // end of namespace Parsers +} // end of namespace DD4hep + //============================================================================= // ============================================================================ #define PARSERS_DEF_FOR_SINGLE(Type) \ + PARSERS_DECL_FOR_SINGLE(Type) \ int DD4hep::Parsers::parse(Type& result, const std::string& input) \ { return DD4hep::Parsers::parse_(result, input); } // ============================================================================ diff --git a/DDCore/src/parsers/ParsersObjects_PxPyPzEVector.cpp b/DDCore/src/parsers/ParsersObjects_PxPyPzEVector.cpp index df25ba763..bd1940e43 100644 --- a/DDCore/src/parsers/ParsersObjects_PxPyPzEVector.cpp +++ b/DDCore/src/parsers/ParsersObjects_PxPyPzEVector.cpp @@ -1,4 +1,3 @@ -// $Id: ParsersObjects_PxPyPzEVector.cpp 2190 2016-04-08 08:31:42Z /DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=sailer/CN=683529/CN=Andre Sailer $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDCore/src/parsers/ParsersObjects_XYZPoint.cpp b/DDCore/src/parsers/ParsersObjects_XYZPoint.cpp index a7477851c..0ab9f44cb 100644 --- a/DDCore/src/parsers/ParsersObjects_XYZPoint.cpp +++ b/DDCore/src/parsers/ParsersObjects_XYZPoint.cpp @@ -1,4 +1,3 @@ -// $Id: ParsersObjects_XYZPoint.cpp 2119 2016-03-03 14:10:32Z markus.frank@cern.ch $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDCore/src/parsers/ParsersObjects_XYZVector.cpp b/DDCore/src/parsers/ParsersObjects_XYZVector.cpp index b55a77b76..eda3a701e 100644 --- a/DDCore/src/parsers/ParsersObjects_XYZVector.cpp +++ b/DDCore/src/parsers/ParsersObjects_XYZVector.cpp @@ -1,4 +1,3 @@ -// $Id: ParsersObjects_XYZVector.cpp 2119 2016-03-03 14:10:32Z markus.frank@cern.ch $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDCore/src/parsers/UsedParser.h b/DDCore/src/parsers/UsedParser.h index f83260325..978e82a7f 100644 --- a/DDCore/src/parsers/UsedParser.h +++ b/DDCore/src/parsers/UsedParser.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DetSegmentation/CMakeLists.txt b/DetSegmentation/CMakeLists.txt new file mode 100644 index 000000000..e34497a4c --- /dev/null +++ b/DetSegmentation/CMakeLists.txt @@ -0,0 +1,25 @@ +#================================================================================= +# +# AIDA Detector description implementation for LCD +#--------------------------------------------------------------------------------- +# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +# All rights reserved. +# +# For the licensing terms see $DD4hepINSTALL/LICENSE. +# For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +# +#================================================================================= +dd4hep_package( DetSegmentation + USES [ROOT REQUIRED COMPONENTS Geom GenVector] + DDSegmentation + DDCore + INCLUDE_DIRS include + INSTALL_INCLUDES include/DetSegmentation) + +#dd4hep_add_package_library ( DetSegmentation +# INCLUDE_DIRS +# LINK_LIBRARIES +# SOURCES src/*.cpp +# ) + +dd4hep_add_plugin(DetSegmentation SOURCES src/*.cpp ) diff --git a/DetSegmentation/include/DetSegmentation/GridPhiEta.h b/DetSegmentation/include/DetSegmentation/GridPhiEta.h new file mode 100644 index 000000000..4720dcc55 --- /dev/null +++ b/DetSegmentation/include/DetSegmentation/GridPhiEta.h @@ -0,0 +1,166 @@ +#ifndef DETSEGMENTATION_GRIDPHIETA_H +#define DETSEGMENTATION_GRIDPHIETA_H + +#include "DDSegmentation/Segmentation.h" + +/* #include "DDSegmentation/SegmentationUtil.h" */ +#include "TVector3.h" +#include <cmath> + +/** GridPhiEta Detector/DetSegmentation/DetSegmentation/GridPhiEta.h GridPhiEta.h + * + * Segmentation in eta and phi. + * It requires 'export LD_PRELOAD_PATH=$LD_PRELOAD_PATH:build.$BINARY_TAG/lib/libDetSegmentation.so' + * + * @author Anna Zaborowska + */ + +namespace DD4hep { +namespace DDSegmentation { +class GridPhiEta: public Segmentation { +public: + /// default constructor using an arbitrary type + GridPhiEta(BitField64* decoder); + /// default constructor using an arbitrary type + GridPhiEta(const std::string& aCellEncoding); + /// destructor + virtual ~GridPhiEta(); + + /** Determine the global position based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Position. + */ + virtual Vector3D position(const CellID& aCellID) const; + /** Determine the cell ID based on the position. + * @param[in] aLocalPosition (not used). + * @param[in] aGlobalPosition position in the global coordinates. + * @param[in] aVolumeId ID of a volume. + * return Cell ID. + */ + virtual CellID cellID(const Vector3D& aLocalPosition, const Vector3D& aGlobalPosition, const VolumeID& aVolumeID) const; + /** Determine the pseudorapidity based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Pseudorapidity. + */ + double eta(const CellID& aCellID) const; + /** Determine the azimuthal angle based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Phi. + */ + double phi(const CellID& aCellID) const; + /** Get the grid size in pseudorapidity. + * return Grid size in eta. + */ + inline double gridSizeEta() const { + return m_gridSizeEta; + } + /** Get the number of bins in azimuthal angle. + * return Number of bins in phi. + */ + inline int phiBins() const { + return m_phiBins; + } + /** Get the coordinate offset in pseudorapidity. + * return The offset in eta. + */ + inline double offsetEta() const { + return m_offsetEta; + } + /** Get the coordinate offset in azimuthal angle. + * return The offset in phi. + */ + inline double offsetPhi() const { + return m_offsetPhi; + } + /** Get the field name used for pseudorapidity + * return The field name for eta. + */ + inline std::string fieldNameEta() const { + return m_etaID; + } + /** Get the field name for azimuthal angle. + * return The field name for phi. + */ + inline std::string fieldNamePhi() const { + return m_phiID; + } + /** Set the grid size in pseudorapidity. + * @param[in] aCellSize Cell size in eta. + */ + void setGridSizeEta(double aCellSize) { + m_gridSizeEta = aCellSize; + } + /** Set the number of bins in azimuthal angle. + * @param[in] aNumberBins Number of bins in phi. + */ + inline void setPhiBins(int bins) { + m_phiBins = bins; + } + /** Set the coordinate offset in pseudorapidity. + * @param[in] aOffset Offset in eta. + */ + inline void setOffsetEta(double offset) { + m_offsetEta = offset; + } + /** Set the coordinate offset in azimuthal angle. + * @param[in] aOffset Offset in phi. + */ + inline void setOffsetPhi(double offset) { + m_offsetPhi = offset; + } + /** Set the field name used for pseudorapidity. + * @param[in] aFieldName Field name for eta. + */ + inline void setFieldNameEta(const std::string& fieldName) { + m_etaID = fieldName; + } + /** Set the field name used for azimuthal angle. + * @param[in] aFieldName Field name for phi. + */ + inline void setFieldNamePhi(const std::string& fieldName) { + m_phiID = fieldName; + } + /// calculates the Cartesian position from spherical coordinates (r, phi, eta) + inline Vector3D positionFromREtaPhi(double ar, double aeta, double aphi) const { + return Vector3D(ar * std::cos(aphi), ar * std::sin(aphi), ar * std::sinh(aeta)); + } + /// calculates the pseudorapidity from Cartesian coordinates + inline double etaFromXYZ(const Vector3D& aposition) const { + TVector3 vec(aposition.X, aposition.Y, aposition.Z); + return vec.Eta(); + } + /// from SegmentationUtil + /// to be removed once SegmentationUtil can be included w/o linker error + /// calculates the azimuthal angle phi from Cartesian coordinates + inline double phiFromXYZ(const Vector3D& aposition) const { + return std::atan2(aposition.Y, aposition.X); + } + /// from SegmentationUtil + /// to be removed once SegmentationUtil can be included w/o linker error + /// calculates the radius in the xy-plane from Cartesian coordinates + inline double radiusFromXYZ(const Vector3D& aposition) const { + return std::sqrt(aposition.X * aposition.X + aposition.Y * aposition.Y); + } + +private: + /// determine the pseudorapidity based on the current cell ID + double eta() const; + /// determine the azimuthal angle phi based on the current cell ID + double phi() const; + + /// the grid size in eta + double m_gridSizeEta; + /// the number of bins in phi + int m_phiBins; + /// the coordinate offset in eta + double m_offsetEta; + /// the coordinate offset in phi + double m_offsetPhi; + /// the field name used for eta + std::string m_etaID; + /// the field name used for phi + std::string m_phiID; +}; +} +} +#endif /* DETSEGMENTATION_GRIDPHIETA_H */ diff --git a/DetSegmentation/include/DetSegmentation/GridPhiEtaHandle.h b/DetSegmentation/include/DetSegmentation/GridPhiEtaHandle.h new file mode 100644 index 000000000..ba5481cb8 --- /dev/null +++ b/DetSegmentation/include/DetSegmentation/GridPhiEtaHandle.h @@ -0,0 +1,103 @@ +#ifndef DD4HEP_DDCORE_GRIDPHIETA_H +#define DD4HEP_DDCORE_GRIDPHIETA_H 1 + +// Framework include files +#include "DD4hep/Segmentations.h" + +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + + /// Namespace for base segmentations + namespace DDSegmentation { class GridPhiEta; } + + /// Namespace for the geometry part of the AIDA detector description toolkit + namespace Geometry { + + // Forward declarations + class Segmentation; + template <typename T> class SegmentationWrapper; + + /// We need some abbreviation to make the code more readable. + typedef Handle<SegmentationWrapper<DDSegmentation::GridPhiEta> > GridPhiEtaHandle; + + /// Implementation class for the grid XZ segmentation. + /** + * Concrete user handle to serve specific needs of client code + * which requires access to the base functionality not served + * by the super-class Segmentation. + * + * Note: + * We only check the validity of the underlying handle. + * If for whatever reason the implementation object is not valid + * This is not checked. + * In principle this CANNOT happen unless some brain-dead has + * fiddled with the handled object directly..... + * + * Note: + * The handle base corrsponding to this object in for + * conveniance reasons instantiated in DD4hep/src/Segmentations.cpp. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY + */ + class GridPhiEta : public GridPhiEtaHandle { + public: + /// Defintiion of the basic handled object + typedef GridPhiEtaHandle::Implementation Object; + + public: + /// Default constructor + GridPhiEta() = default; + /// Copy constructor + GridPhiEta(const GridPhiEta& e) = default; + /// Copy Constructor from segmentation base object + GridPhiEta(const Segmentation& e) : Handle<Object>(e) {} + /// Copy constructor from handle + GridPhiEta(const Handle<Object>& e) : Handle<Object>(e) {} + /// Copy constructor from other polymorph/equivalent handle + template <typename Q> GridPhiEta(const Handle<Q>& e) : Handle<Object>(e) {} + /// Assignment operator + GridPhiEta& operator=(const GridPhiEta& seg) = default; + /// Equality operator + bool operator==(const GridPhiEta& seg) const + { return m_element == seg.m_element; } + /// determine the position based on the cell ID + Position position(const CellID& cellID) const; + /// determine the cell ID based on the position + CellID cellID(const Position& local, const Position& global, const VolumeID& volID) const; + /// access the grid size in R + double gridSizeEta() const; + /// access the grid size in Phi + int phiBins() const; + /// set the grid size in R + void setGridSizeEta(double cellSize) const; + /// set the grid size in Phi + void setPhiBins(int cellSize) const; + /// access the coordinate offset in R + double offsetEta() const; + /// access the coordinate offset in Phi + double offsetPhi() const; + /// set the coordinate offset in R + void setOffsetEta(double offset) const; + /// set the coordinate offset in Phi + void setOffsetPhi(double offset) const; + /// access the field name used for R + const std::string& fieldNameEta() const; + /// access the field name used for Phi + const std::string& fieldNamePhi() const; + /** \brief Returns a vector<double> of the cellDimensions of the given cell ID + in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + + Returns a vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return std::vector<double> size 2: + -# size in x + -# size in z + */ + std::vector<double> cellDimensions(const CellID& cellID) const; + }; + + } /* End namespace Geometry */ +} /* End namespace DD4hep */ +#endif // DD4HEP_DDCORE_POLARGRIDRPHI_H diff --git a/DetSegmentation/include/DetSegmentation/GridRPhiEta.h b/DetSegmentation/include/DetSegmentation/GridRPhiEta.h new file mode 100644 index 000000000..79b898fbf --- /dev/null +++ b/DetSegmentation/include/DetSegmentation/GridRPhiEta.h @@ -0,0 +1,213 @@ +#ifndef DETSEGMENTATION_GRIDRPHIETA_H +#define DETSEGMENTATION_GRIDRPHIETA_H + +#include "DDSegmentation/Segmentation.h" + +/* #include "DDSegmentation/SegmentationUtil.h" */ +#include "TVector3.h" +#include <cmath> + +/** GridRPhiEta Detector/DetSegmentation/DetSegmentation/GridRPhiEta.h GridRPhiEta.h + * + * Segmentation in eta and phi. + * It requires 'export LD_PRELOAD_PATH=$LD_PRELOAD_PATH:build.$BINARY_TAG/lib/libDetSegmentation.so' + * + * @author Anna Zaborowska + */ + +namespace DD4hep { +namespace DDSegmentation { +class GridRPhiEta: public Segmentation { +public: + /// default constructor using an arbitrary type + GridRPhiEta(const std::string& aCellEncoding); + /// destructor + virtual ~GridRPhiEta(); + + /** Determine the global position based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Position. + */ + virtual Vector3D position(const CellID& aCellID) const; + /** Determine the cell ID based on the position. + * @param[in] aLocalPosition (not used). + * @param[in] aGlobalPosition position in the global coordinates. + * @param[in] aVolumeId ID of a volume. + * return Cell ID. + */ + virtual CellID cellID(const Vector3D& aLocalPosition, const Vector3D& aGlobalPosition, const VolumeID& aVolumeID) const; + /** Determine the pseudorapidity based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Pseudorapidity. + */ + double eta(const CellID& aCellID) const; + /** Determine the azimuthal angle based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Phi. + */ + double phi(const CellID& aCellID) const; + /** Determine the radius based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Radius. + */ + double r(const CellID& aCellID) const; + /** Get the grid size in pseudorapidity. + * return Grid size in eta. + */ + inline double gridSizeEta() const { + return m_gridSizeEta; + } + /** Get the grid size in radial distance from the detector centre. + * return Grid size in radial distance. + */ + inline double gridSizeR() const { + return m_gridSizeR; + } + /** Get the number of bins in azimuthal angle. + * return Number of bins in phi. + */ + inline int phiBins() const { + return m_phiBins; + } + /** Get the coordinate offset in pseudorapidity. + * return The offset in eta. + */ + inline double offsetEta() const { + return m_offsetEta; + } + /** Get the coordinate offset in azimuthal angle. + * return The offset in phi. + */ + inline double offsetPhi() const { + return m_offsetPhi; + } + /** Get the coordinate offset in radial distance. + * return The offset in R. + */ + inline double offsetR() const { + return m_offsetR; + } + /** Get the field name used for pseudorapidity + * return The field name for eta. + */ + inline std::string fieldNameEta() const { + return m_etaID; + } + /** Get the field name for azimuthal angle. + * return The field name for phi. + */ + inline std::string fieldNamePhi() const { + return m_phiID; + } + /** Get the field name for radial distance. + * return The field name for radial distance. + */ + inline std::string fieldNameR() const { + return m_rID; + } + /** Set the grid size in pseudorapidity. + * @param[in] aCellSize Cell size in eta. + */ + void setGridSizeEta(double aCellSize) { + m_gridSizeEta = aCellSize; + } + /** Set the number of bins in azimuthal angle. + * @param[in] aNumberBins Number of bins in phi. + */ + inline void setPhiBins(int bins) { + m_phiBins = bins; + } + /** Set the grid size in radial distance. + * @param[in] aCellSize Cell size in radial distance. + */ + void setGridSizeR(double aCellSize) { + m_gridSizeR = aCellSize; + } + /** Set the coordinate offset in pseudorapidity. + * @param[in] aOffset Offset in eta. + */ + inline void setOffsetEta(double offset) { + m_offsetEta = offset; + } + /** Set the coordinate offset in azimuthal angle. + * @param[in] aOffset Offset in phi. + */ + inline void setOffsetPhi(double offset) { + m_offsetPhi = offset; + } + /** Set the coordinate offset in radial distance. + * @param[in] aOffset Offset in radial distance. + */ + inline void setOffsetR(double offset) { + m_offsetR = offset; + } + /** Set the field name used for pseudorapidity. + * @param[in] aFieldName Field name for eta. + */ + inline void setFieldNameEta(const std::string& fieldName) { + m_etaID = fieldName; + } + /** Set the field name used for azimuthal angle. + * @param[in] aFieldName Field name for phi. + */ + inline void setFieldNamePhi(const std::string& fieldName) { + m_phiID = fieldName; + } + /** Set the field name used for radial distance. + * @param[in] aFieldName Field name for R. + */ + inline void setFieldNameR(const std::string& fieldName) { + m_rID = fieldName; + } + /// calculates the Cartesian position from spherical coordinates (r, phi, eta) + inline Vector3D positionFromREtaPhi(double ar, double aeta, double aphi) const { + return Vector3D(ar * std::cos(aphi), ar * std::sin(aphi), ar * std::sinh(aeta)); + } + /// calculates the pseudorapidity from Cartesian coordinates + inline double etaFromXYZ(const Vector3D& aposition) const { + TVector3 vec(aposition.X, aposition.Y, aposition.Z); + return vec.Eta(); + } + /// from SegmentationUtil + /// to be removed once SegmentationUtil can be included w/o linker error + /// calculates the azimuthal angle phi from Cartesian coordinates + inline double phiFromXYZ(const Vector3D& aposition) const { + return std::atan2(aposition.Y, aposition.X); + } + /// from SegmentationUtil + /// to be removed once SegmentationUtil can be included w/o linker error + /// calculates the radius in the xy-plane from Cartesian coordinates + inline double radiusFromXYZ(const Vector3D& aposition) const { + return std::sqrt(aposition.X * aposition.X + aposition.Y * aposition.Y); + } + +private: + /// determine the pseudorapidity based on the current cell ID + double eta() const; + /// determine the azimuthal angle phi based on the current cell ID + double phi() const; + /// determine the radial distance R based on the current cell ID + double r() const; + + /// the grid size in eta + double m_gridSizeEta; + /// the number of bins in phi + int m_phiBins; + /// the grid size in r + double m_gridSizeR; + /// the coordinate offset in eta + double m_offsetEta; + /// the coordinate offset in phi + double m_offsetPhi; + /// the coordinate offset in r + double m_offsetR; + /// the field name used for eta + std::string m_etaID; + /// the field name used for phi + std::string m_phiID; + /// the field name used for r + std::string m_rID; +}; +} +} +#endif /* DETSEGMENTATION_GRIDRPHIETA_H */ diff --git a/DetSegmentation/include/DetSegmentation/LinkDef.h b/DetSegmentation/include/DetSegmentation/LinkDef.h new file mode 100644 index 000000000..b6dda562f --- /dev/null +++ b/DetSegmentation/include/DetSegmentation/LinkDef.h @@ -0,0 +1,6 @@ +#include "DDSegmentation/Segmentation.h" +#include "DetSegmentation/GridPhiEta.h" +/* #pragma link off all globals; */ +/* #pragma link off all classes; */ +/* #pragma link off all functions; */ +#pragma link C++ class DD4hep::DDSegmentation::GridPhiEta+; diff --git a/DetSegmentation/src/Factories.cpp b/DetSegmentation/src/Factories.cpp new file mode 100644 index 000000000..8f4ea2082 --- /dev/null +++ b/DetSegmentation/src/Factories.cpp @@ -0,0 +1,17 @@ + +// Framework includes +#include "DD4hep/objects/SegmentationsInterna.h" +#include "DD4hep/Factories.h" + +using namespace DD4hep::Geometry; +using namespace DD4hep::DDSegmentation; + +namespace { + template<typename T> DD4hep::Geometry::SegmentationObject* + create_segmentation(DD4hep::Geometry::BitField64* decoder) { + return new DD4hep::Geometry::SegmentationWrapper<T>(decoder); + } +} + +#include "DetSegmentation/GridPhiEta.h" +DECLARE_SEGMENTATION(GridPhiEta,create_segmentation<DD4hep::DDSegmentation::GridPhiEta>) diff --git a/DetSegmentation/src/GridPhiEta.cpp b/DetSegmentation/src/GridPhiEta.cpp new file mode 100644 index 000000000..ba7b5e90d --- /dev/null +++ b/DetSegmentation/src/GridPhiEta.cpp @@ -0,0 +1,84 @@ +#include "DetSegmentation/GridPhiEta.h" + +namespace DD4hep { +namespace DDSegmentation { + + /// Default constructor used by derived classes passing an existing decoder + GridPhiEta::GridPhiEta(BitField64* decode) : Segmentation(decode) { + // define type and description + _type = "GridPhiEta"; + _description = "Projective segmentation in the global coordinates"; + + // register all necessary parameters + registerParameter("grid_size_eta", "Cell size in Eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit); + registerParameter("phi_bins", "Number of bins phi", m_phiBins, 1); + registerParameter("offset_eta", "Angular offset in eta", m_offsetEta, 0., SegmentationParameter::AngleUnit, true); + registerParameter("offset_phi", "Angular offset in phi", m_offsetPhi, 0., SegmentationParameter::AngleUnit, true); + registerIdentifier("identifier_eta", "Cell ID identifier for eta", m_etaID, "eta"); + registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "phi"); + } + +/// default constructor using an encoding string +GridPhiEta::GridPhiEta(const std::string& cellEncoding) : + Segmentation(cellEncoding) { + // define type and description + _type = "GridPhiEta"; + _description = "Projective segmentation in the global coordinates"; + + // register all necessary parameters + registerParameter("grid_size_eta", "Cell size in Eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit); + registerParameter("phi_bins", "Number of bins phi", m_phiBins, 1); + registerParameter("offset_eta", "Angular offset in eta", m_offsetEta, 0., SegmentationParameter::AngleUnit, true); + registerParameter("offset_phi", "Angular offset in phi", m_offsetPhi, 0., SegmentationParameter::AngleUnit, true); + registerIdentifier("identifier_eta", "Cell ID identifier for eta", m_etaID, "eta"); + registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "phi"); +} + +/// destructor +GridPhiEta::~GridPhiEta() { + +} + +/// determine the local based on the cell ID +Vector3D GridPhiEta::position(const CellID& cID) const { + _decoder->setValue(cID); + return positionFromREtaPhi(1.0, eta(), phi()); +} + +/// determine the cell ID based on the position +CellID GridPhiEta::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const { + _decoder->setValue(vID); + double lEta = etaFromXYZ(globalPosition); + double lPhi = phiFromXYZ(globalPosition); + (*_decoder)[m_etaID] = positionToBin(lEta, m_gridSizeEta, m_offsetEta); + (*_decoder)[m_phiID] = positionToBin(lPhi, 2 * M_PI / (double) m_phiBins, m_offsetPhi); + return _decoder->getValue(); +} + +/// determine the pseudorapidity based on the current cell ID +double GridPhiEta::eta() const { + CellID etaValue = (*_decoder)[m_etaID].value(); + return binToPosition(etaValue, m_gridSizeEta, m_offsetEta); +} +/// determine the azimuthal angle phi based on the current cell ID +double GridPhiEta::phi() const { + CellID phiValue = (*_decoder)[m_phiID].value(); + return binToPosition(phiValue, 2.*M_PI/(double)m_phiBins, m_offsetPhi); +} + +/// determine the polar angle theta based on the cell ID +double GridPhiEta::eta(const CellID& cID) const { + _decoder->setValue(cID); + CellID etaValue = (*_decoder)[m_etaID].value(); + return binToPosition(etaValue, m_gridSizeEta, m_offsetEta); +} +/// determine the azimuthal angle phi based on the cell ID +double GridPhiEta::phi(const CellID& cID) const { + _decoder->setValue(cID); + CellID phiValue = (*_decoder)[m_phiID].value(); + return binToPosition(phiValue, 2.*M_PI/(double)m_phiBins, m_offsetPhi); +} +REGISTER_SEGMENTATION(GridPhiEta) +} +} + diff --git a/DetSegmentation/src/GridPhiEtaHandle.cpp b/DetSegmentation/src/GridPhiEtaHandle.cpp new file mode 100644 index 000000000..36f60b959 --- /dev/null +++ b/DetSegmentation/src/GridPhiEtaHandle.cpp @@ -0,0 +1,86 @@ +// Framework include files +#include "DetSegmentation/GridPhiEtaHandle.h" +#include "DD4hep/objects/SegmentationsInterna.h" +#include "DetSegmentation/GridPhiEta.h" +#include "DD4hep/Handle.inl" + +using namespace std; +using namespace DD4hep::Geometry; + +/// determine the position based on the cell ID +Position GridPhiEta::position(const CellID& id) const { + return Position(access()->implementation->position(id)); +} + +/// determine the cell ID based on the position +DD4hep::CellID GridPhiEta::cellID(const Position& local, + const Position& global, + const VolumeID& volID) const +{ + return access()->implementation->cellID(local, global, volID); +} + +/// access the grid size in R +double GridPhiEta::gridSizeEta() const { + return access()->implementation->gridSizeEta(); +} + +/// access the grid size in Phi +int GridPhiEta::phiBins() const { + return access()->implementation->phiBins(); +} + +/// access the coordinate offset in R +double GridPhiEta::offsetEta() const { + return access()->implementation->offsetEta(); +} + +/// access the coordinate offset in Phi +double GridPhiEta::offsetPhi() const { + return access()->implementation->offsetPhi(); +} + +/// set the coordinate offset in R +void GridPhiEta::setOffsetEta(double offset) const { + access()->implementation->setOffsetEta(offset); +} + +/// set the coordinate offset in Phi +void GridPhiEta::setOffsetPhi(double offset) const { + access()->implementation->setOffsetPhi(offset); +} + +/// set the grid size in R +void GridPhiEta::setGridSizeEta(double cellSize) const { + access()->implementation->setGridSizeEta(cellSize); +} + +/// set the grid size in Phi +void GridPhiEta::setPhiBins(int cellSize) const { + access()->implementation->setPhiBins(cellSize); +} + +/// access the field name used for R +const string& GridPhiEta::fieldNameEta() const { + return access()->implementation->fieldNameEta(); +} + +/// access the field name used for Phi +const string& GridPhiEta::fieldNamePhi() const { + return access()->implementation->fieldNamePhi(); +} + +/** \brief Returns a vector<double> of the cellDimensions of the given cell ID + in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + + Returns a vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return vector<double> size 2: + -# size in x + -# size in z +*/ +vector<double> GridPhiEta::cellDimensions(const CellID& id) const { + return {0};// access()->implementation->cellDimensions(id); +} + +DD4HEP_INSTANTIATE_HANDLE_UNNAMED(DD4hep::DDSegmentation::GridPhiEta); diff --git a/DetSegmentation/src/GridRPhiEta.cpp b/DetSegmentation/src/GridRPhiEta.cpp new file mode 100644 index 000000000..e4221e479 --- /dev/null +++ b/DetSegmentation/src/GridRPhiEta.cpp @@ -0,0 +1,87 @@ +#include "DetSegmentation/GridRPhiEta.h" + +namespace DD4hep { +namespace DDSegmentation { + +/// default constructor using an encoding string +GridRPhiEta::GridRPhiEta(const std::string& cellEncoding) : + Segmentation(cellEncoding) { + // define type and description + _type = "GridRPhiEta"; + _description = "Projective segmentation in the global coordinates"; + + // register all necessary parameters + registerParameter("grid_size_eta", "Cell size in eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit); + registerParameter("phi_bins", "Number of bins phi", m_phiBins, 1); + registerParameter("grid_size_r", "Cell size in radial distance", m_gridSizeR, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_eta", "Angular offset in eta", m_offsetEta, 0., SegmentationParameter::AngleUnit, true); + registerParameter("offset_phi", "Angular offset in phi", m_offsetPhi, 0., SegmentationParameter::AngleUnit, true); + registerParameter("offset_r", "Angular offset in radial distance", m_offsetR, 0., SegmentationParameter::LengthUnit, true); + registerIdentifier("identifier_eta", "Cell ID identifier for eta", m_etaID, "eta"); + registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "phi"); + registerIdentifier("identifier_r", "Cell ID identifier for R", m_rID, "r"); +} + +/// destructor +GridRPhiEta::~GridRPhiEta() {} + +/// determine the local based on the cell ID +Vector3D GridRPhiEta::position(const CellID& cID) const { + _decoder->setValue(cID); + return positionFromREtaPhi(r(), eta(), phi()); +} + +/// determine the cell ID based on the position +CellID GridRPhiEta::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const { + _decoder->setValue(vID); + double lRadius = radiusFromXYZ(globalPosition); + double lEta = etaFromXYZ(globalPosition); + double lPhi = phiFromXYZ(globalPosition); + (*_decoder)[m_etaID] = positionToBin(lEta, m_gridSizeEta, m_offsetEta); + (*_decoder)[m_phiID] = positionToBin(lPhi, 2 * M_PI / (double) m_phiBins, m_offsetPhi); + (*_decoder)[m_rID] = positionToBin(lRadius, m_gridSizeR, m_offsetR); + if ( (*_decoder)[m_rID] != (*_decoder)["active_layer"] ) { + std::cout <<" Position = ( " << globalPosition.x() << " , " << globalPosition.y() << " , " << globalPosition.z() << " )\t "; + std::cout << "Radius: " << lRadius << " \tcellsize: " << m_gridSizeR << " \toffset: " << m_offsetR << " -> " << (*_decoder)[m_rID] << " != " << (*_decoder)["active_layer"] << std::endl; + } + return _decoder->getValue(); +} + +/// determine the pseudorapidity based on the current cell ID +double GridRPhiEta::eta() const { + CellID etaValue = (*_decoder)[m_etaID].value(); + return binToPosition(etaValue, m_gridSizeEta, m_offsetEta); +} +/// determine the azimuthal angle phi based on the current cell ID +double GridRPhiEta::phi() const { + CellID phiValue = (*_decoder)[m_phiID].value(); + return binToPosition(phiValue, 2.*M_PI/(double)m_phiBins, m_offsetPhi); +} +/// determine the radial distance R based on the current cell ID +double GridRPhiEta::r() const { + CellID rValue = (*_decoder)[m_rID].value(); + return binToPosition(rValue, m_gridSizeR, m_offsetR); +} + +/// determine the polar angle theta based on the cell ID +double GridRPhiEta::eta(const CellID& cID) const { + _decoder->setValue(cID); + CellID etaValue = (*_decoder)[m_etaID].value(); + return binToPosition(etaValue, m_gridSizeEta, m_offsetEta); +} +/// determine the azimuthal angle phi based on the cell ID +double GridRPhiEta::phi(const CellID& cID) const { + _decoder->setValue(cID); + CellID phiValue = (*_decoder)[m_phiID].value(); + return binToPosition(phiValue, 2.*M_PI/(double)m_phiBins, m_offsetPhi); +} +/// determine the radial distance R based on the cell ID +double GridRPhiEta::r(const CellID& cID) const { + _decoder->setValue(cID); + CellID rValue = (*_decoder)[m_rID].value(); + return binToPosition(rValue, m_gridSizeR, m_offsetR); +} +REGISTER_SEGMENTATION(GridRPhiEta) +} +} + diff --git a/doc/externalize/ExtraParsers.cpp b/doc/externalize/ExtraParsers.cpp new file mode 100644 index 000000000..9591523f1 --- /dev/null +++ b/doc/externalize/ExtraParsers.cpp @@ -0,0 +1,31 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +//-------------------------------------------------------------------------- +// ExtraProperties.cpp +//-------------------------------------------------------------------------- +// +// Package : Dataflow +// +// Author : Markus Frank +//========================================================================== +// Note: +// +// This is an example file, which shows how to instantiate extera parsers, +// which are not part of DD4hep, but may be interesting for a +// client application. +// +//========================================================================== + +/// Framework includes +#include "ParsersFactory.h" + +PARSERS_DEF_FOR_SINGLE(unsigned int) +PARSERS_DEF_FOR_SINGLE(unsigned long) +PARSERS_DEF_FOR_SINGLE(long long) +PARSERS_DEF_FOR_SINGLE(unsigned long long) diff --git a/doc/externalize/ExtraProperties.cpp b/doc/externalize/ExtraProperties.cpp index 3f226b9ef..a813fd502 100644 --- a/doc/externalize/ExtraProperties.cpp +++ b/doc/externalize/ExtraProperties.cpp @@ -24,30 +24,30 @@ /// Framework includes #include "DD4hep/Parsers.h" -/// Namespace for the AIDA detector description toolkit -namespace DD4hep { - /// Namespace for the AIDA detector for utilities using boost::spirit parsers - namespace Parsers { - PARSERS_DECL_FOR_SINGLE(unsigned int) - PARSERS_DECL_FOR_SINGLE(unsigned long) - } -} + +#if !defined(DD4HEP_HAVE_ALL_PARSERS) +PARSERS_DECL_FOR_SINGLE(unsigned int) +PARSERS_DECL_FOR_SINGLE(unsigned long) +PARSERS_DECL_FOR_SINGLE(long long) +PARSERS_DECL_FOR_SINGLE(unsigned long long) +#endif + #include "DD4hep/BasicGrammar_inl.h" #include "DD4hep/ComponentProperties_inl.h" -// C/C++ include files -#include <map> - typedef std::map<std::string, std::vector<std::string> > map_t; DD4HEP_DEFINE_PARSER_GRAMMAR(map_t,eval_obj) -namespace DD4hep { - DD4HEP_DEFINE_PROPERTY_TYPE(map_t); -} +DD4HEP_DEFINE_PROPERTY_TYPE(map_t) +#if !defined(DD4HEP_HAVE_ALL_PARSERS) DD4HEP_DEFINE_PARSER_GRAMMAR(unsigned int,eval_item) DD4HEP_DEFINE_PARSER_GRAMMAR(unsigned long,eval_item) -/// Namespace for the AIDA detector description toolkit -namespace DD4hep { - DD4HEP_DEFINE_PROPERTY_TYPE(unsigned int); - DD4HEP_DEFINE_PROPERTY_TYPE(unsigned long); -} +DD4HEP_DEFINE_PROPERTY_TYPE(unsigned int) +DD4HEP_DEFINE_PROPERTY_TYPE(unsigned long) + +DD4HEP_DEFINE_PARSER_GRAMMAR(long long,eval_item) +DD4HEP_DEFINE_PARSER_GRAMMAR(unsigned long long,eval_item) + +DD4HEP_DEFINE_PROPERTY_TYPE(long long) +DD4HEP_DEFINE_PROPERTY_TYPE(unsigned long long) +#endif diff --git a/doc/externalize/externalize_properties.sh b/doc/externalize/externalize_properties.sh index f4f9d4bd1..0ca4ddf7e 100755 --- a/doc/externalize/externalize_properties.sh +++ b/doc/externalize/externalize_properties.sh @@ -9,23 +9,32 @@ # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. # #========================================================================== +do_scp() { + echo "Copy files: scp $*"; + scp $*; +} # copy_files() { target=${1}; cd DDCore/include/DD4hep echo "+++ Copy header files from `pwd` to: ${target}/DD4hep ...."; - scp BasicGrammar.h ComponentProperties.h Exceptions.h Plugins.h Printout.h \ - BasicGrammar_inl.h ComponentProperties_inl.h Parsers.h Primitives.h ToStream.h \ - ${target}/DD4hep; + do_scp BasicGrammar.h ComponentProperties.h \ + Exceptions.h Plugins.h Printout.h \ + BasicGrammar_inl.h ComponentProperties_inl.h \ + Parsers.h Primitives.h ToStream.h \ + ${target}/DD4hep; cd -; cd DDCore/src; echo "+++ Copy source files from `pwd` to: ${target}/src/DD4hep ...."; - scp -r parsers BasicGrammar.cpp ComponentProperties.cpp Plugins.cpp Printout.cpp \ - BasicGrammarTypes.cpp Exceptions.cpp Primitives.cpp ToStream.cpp \ - ${target}/src/DD4hep/; + do_scp -r parsers BasicGrammar.cpp \ + ComponentProperties.cpp Plugins.cpp Printout.cpp \ + BasicGrammarTypes.cpp Exceptions.cpp \ + Primitives.cpp ToStream.cpp \ + ${target}/src/DD4hep/; cd -; - scp doc/externalize/PluginManager.cpp ${target}/src/DD4hep/; - scp doc/externalize/ExtraProperties.cpp ${target}/src/DD4hep/; + do_scp doc/externalize/PluginManager.cpp ${target}/src/DD4hep/; + do_scp doc/externalize/ExtraParsers.cpp ${target}/src/DD4hep/parsers/; + do_scp doc/externalize/ExtraProperties.cpp ${target}/src/DD4hep/; } TARGET=${1}; -- GitLab