diff --git a/CHANGELOG.md b/CHANGELOG.md index fb75659ce9..407009a2bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,12 +31,14 @@ it in future. ### Changed * shipStrawTracking: Move to argparse +* CMake: Require external genfit2 ### Removed * Remove obsolete renaming scripts * Remove online, please see charmdet and muflux branches for respective versions * Remove charmdet, please see charmdet branch for latest version +* Remove bundled genfit ## 24.10 - Freiburg diff --git a/CMakeLists.txt b/CMakeLists.txt index b81c562fac..7a66662b81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,7 @@ find_package2(PUBLIC fmt) find_package2(PUBLIC FairRoot REQUIRED) find_package2(PUBLIC FairLogger REQUIRED) find_package2(PUBLIC VMC REQUIRED) +find_package(genfit2 REQUIRED) IF(DEFINED ${BOOST_ROOT}) Set(Boost_NO_SYSTEM_PATHS TRUE) @@ -223,7 +224,6 @@ add_subdirectory (strawtubes) add_subdirectory (muon) add_subdirectory (shipgen) add_subdirectory (field) -add_subdirectory (genfit) add_subdirectory (pid) add_subdirectory (muonShieldOptimization) add_subdirectory (millepede) diff --git a/field/CMakeLists.txt b/field/CMakeLists.txt index 810f700ea3..f65668742e 100644 --- a/field/CMakeLists.txt +++ b/field/CMakeLists.txt @@ -9,6 +9,7 @@ ${GEANT4_VMC_INCLUDE_DIR} ${GEANT4_INCLUDE_DIR} ${FAIRROOT_INCLUDE_DIR} ${VMC_INCLUDE_DIRS} +${genfit2_INCDIR} ) include_directories( ${INCLUDE_DIRECTORIES} @@ -20,7 +21,7 @@ ${ROOT_LIBRARY_DIR} ${FAIRROOT_LIBRARY_DIR} ${GEANT4VMC_LIBRARY_DIR} ${GEANT4_LIBRARY_DIR} - +${genfit2_LIBDIR} ) link_directories( ${LINK_DIRECTORIES}) @@ -34,6 +35,7 @@ ShipBFieldMap.cxx ShipCompField.cxx ShipFieldMaker.cxx ShipGoliathField.cxx +FairShipFields.cxx ) set(LINKDEF FieldLinkDef.h) @@ -41,6 +43,7 @@ Set(LIBRARY_NAME ShipField) Set(DEPENDENCIES Base FairLogger::FairLogger + genfit2 ) GENERATE_LIBRARY() diff --git a/genfit/fields/src/FairShipFields.cc b/field/FairShipFields.cxx similarity index 100% rename from genfit/fields/src/FairShipFields.cc rename to field/FairShipFields.cxx diff --git a/genfit/fields/include/FairShipFields.h b/field/FairShipFields.h similarity index 100% rename from genfit/fields/include/FairShipFields.h rename to field/FairShipFields.h diff --git a/field/FieldLinkDef.h b/field/FieldLinkDef.h index 23bcbbb85e..10cea9c73a 100644 --- a/field/FieldLinkDef.h +++ b/field/FieldLinkDef.h @@ -12,4 +12,5 @@ #pragma link C++ class ShipCompField+; #pragma link C++ class ShipFieldMaker+; #pragma link C++ class ShipGoliathField+; +#pragma link C++ class FairShipFields+; #endif diff --git a/genfit/CMakeLists-original.txt b/genfit/CMakeLists-original.txt deleted file mode 100644 index 497f20ef7a..0000000000 --- a/genfit/CMakeLists-original.txt +++ /dev/null @@ -1,342 +0,0 @@ -If (Boost_Avail) - INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR}) - MESSAGE("-- Boost is found at: ${Boost_INCLUDE_DIR}") -Else (Boost_Avail) - MESSAGE("-- Boost is not found at... ERROR") -EndIf (Boost_Avail) - -# Set the build type. Possibilities are None, Debug, Release, -# RelWithDebInfo and MinSizeRel -SET(CMAKE_BUILD_TYPE Release) - -# either, the environment variable RAVEPATH has to be specified, and RAVE's pkgConfig will be used to determine everything we need -# or, RAVE_LDFLAGS, RAVE_INCLUDE_DIRS and RAVE_CFLAGS have to be set via the command-line - -IF(DEFINED ENV{RAVEPATH}) - MESSAGE("Environment variable RAVEPATH is set. Try to build GFRave.") - # get compiler flags from rave - INCLUDE(FindPkgConfig) - SET(ENV{PKG_CONFIG_PATH} $ENV{RAVEPATH}) - pkg_search_module(RAVE rave REQUIRED) - - SET(RAVE True) -ELSEIF(DEFINED RAVE_LDFLAGS) - IF(DEFINED RAVE_INCLUDE_DIRS) - IF(DEFINED RAVE_CFLAGS) - MESSAGE("RAVE_LDFLAGS, RAVE_INCLUDE_DIRS and RAVE_CFLAGS are set. Try to build GFRave. ${RAVE_LDFLAGS}") - SET(RAVE True) - ENDIF() - ENDIF() -ELSE() - MESSAGE("You did not define the environment variable RAVEPATH which is needed to find rave. GFRave will not be built.") -ENDIF() - -IF(DEFINED RAVE) - # turn comma separated lists into space separated strings - string (REPLACE ";" " " RAVE_LDFLAGS_STR "${RAVE_LDFLAGS}") - string (REPLACE ";" " " RAVE_INCLUDE_DIRS_STR "${RAVE_INCLUDE_DIRS}") - string (REPLACE ";" " " RAVE_CFLAGS_STR "${RAVE_CFLAGS}") - - SET (CMAKE_CXX_FLAGS ${RAVE_CFLAGS_STR}) - - SET(GF_INC_DIRS - ./GFRave/include/ - ) - - AUX_SOURCE_DIRECTORY( ./GFRave/src library_sources ) -ENDIF() - -# Set GENFIT include directories -SET(GF_INC_DIRS - ./core/include/ - ./eventDisplay/include/ - ./fields/include/ - ./finitePlanes/include/ - ./fitters/include/ - ./GBL/include/ - ./measurements/include/ - ./trackReps/include/ - ./utilities/include/ - ${GF_INC_DIRS} -) - -IF (Boost_Avail) - INSTALL( DIRECTORY ${GF_INC_DIRS} - DESTINATION ${INCLUDE_OUTPUT_DIRECTORY} - ) -ENDIF() - -IF(NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." - FORCE) -ENDIF(NOT CMAKE_BUILD_TYPE) - -# Uncomment for coverage analysis. -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") -#SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") -#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") - -include(CheckCXXCompilerFlag) -# ROOT 6 requires c++11 support, enforced via headers -If (ROOT_FOUND_VERSION LESS 59999 OR NOT ROOT_FOUND_VERSION) - check_cxx_compiler_flag(-std=c++03 HAS_STD_FLAG) - check_cxx_compiler_flag(--std=c++03 HAS_STD_FLAG_ALTERNATIVE) - if (HAS_STD_FLAG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03") - elseif (HAS_STD_FLAG_ALTERNATIVE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++03") - else() - message("Neither --std=c++03 nor -std=c++03 seem to work. Moving on.") - endif() -else() - message("setup for ROOT6 ${ROOT_FOUND_VERSION}") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -EndIf() - -# require proper c++, standard is C++03, flag reads: c++98 -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wno-long-long -Wshadow -Werror=overloaded-virtual" ) -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g3") -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3") -SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -O3 -g3") - -# include directories -INCLUDE_DIRECTORIES( - BEFORE - ${GF_INC_DIRS} - ${ROOT_INCLUDE_DIR}) - -# add a target to generate API documentation with Doxygen -FIND_PACKAGE(Doxygen) - -if(DOXYGEN_FOUND) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY) - - ADD_CUSTOM_TARGET(doc - ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc - COMMENT "Generating API documentation with Doxygen" VERBATIM) -ELSE() - MESSAGE( STATUS "Doxygen not installed or found -- API documentation can't be generated!" ) -ENDIF(DOXYGEN_FOUND) - -# declare the ROOT library path -LINK_DIRECTORIES(${ROOT_LIBRARY_DIR}) - -# add the list of source code files -- careful, when a new file is added! -AUX_SOURCE_DIRECTORY( ./core/src library_sources ) -AUX_SOURCE_DIRECTORY( ./eventDisplay/src library_sources ) -AUX_SOURCE_DIRECTORY( ./fields/src library_sources ) -AUX_SOURCE_DIRECTORY( ./finitePlanes/src library_sources ) -AUX_SOURCE_DIRECTORY( ./fitters/src library_sources ) -AUX_SOURCE_DIRECTORY( ./GBL/src library_sources ) -AUX_SOURCE_DIRECTORY( ./measurements/src library_sources ) -AUX_SOURCE_DIRECTORY( ./trackReps/src library_sources ) -AUX_SOURCE_DIRECTORY( ./utilities/src library_sources ) - -SET(CORE_DICTIONARY_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/AbsFinitePlane.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/AbsFitterInfo.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/AbsHMatrix.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/AbsTrackRep.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/DetPlane.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/FitStatus.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/MaterialProperties.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/MeasuredStateOnPlane.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/MeasurementFactory.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/MeasurementOnPlane.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/MeasurementProducer.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/StateOnPlane.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/AbsMeasurement.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/ThinScatterer.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/Track.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/TrackCand.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/TrackCandHit.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/TrackPoint.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/FieldManager.h - ${CMAKE_CURRENT_SOURCE_DIR}/finitePlanes/include/RectangularFinitePlane.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/AbsFitter.h - ${CMAKE_CURRENT_SOURCE_DIR}/core/include/AbsBField.h -) -ROOT_GENERATE_DICTIONARY("${CORE_DICTIONARY_SOURCES}" - "${CMAKE_CURRENT_SOURCE_DIR}/core/src/coreLinkDef.h" - "${CMAKE_CURRENT_BINARY_DIR}/coreRootDict.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/core/include;${Boost_INCLUDE_DIR}" - ) -SET(library_sources "${CMAKE_CURRENT_BINARY_DIR}/coreRootDict.cc" "${library_sources}") - -SET(EVENTDISPLAY_DICTIONARY_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/eventDisplay/include/EventDisplay.h -) -ROOT_GENERATE_DICTIONARY("${EVENTDISPLAY_DICTIONARY_SOURCES}" - "${CMAKE_CURRENT_SOURCE_DIR}/eventDisplay/src/eventDisplayLinkDef.h" - "${CMAKE_CURRENT_BINARY_DIR}/eventDisplayRootDict.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/core/include;${CMAKE_CURRENT_SOURCE_DIR}/fitters/include;${CMAKE_CURRENT_SOURCE_DIR}/eventDisplay/include;${Boost_INCLUDE_DIR}" - ) -SET(library_sources "${CMAKE_CURRENT_BINARY_DIR}/eventDisplayRootDict.cc" "${library_sources}") - -SET(FITTERS_DICTIONARY_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/fitters/include/AbsKalmanFitter.h - ${CMAKE_CURRENT_SOURCE_DIR}/fitters/include/KalmanFittedStateOnPlane.h - ${CMAKE_CURRENT_SOURCE_DIR}/fitters/include/KalmanFitStatus.h - ${CMAKE_CURRENT_SOURCE_DIR}/fitters/include/ReferenceStateOnPlane.h - ${CMAKE_CURRENT_SOURCE_DIR}/fitters/include/KalmanFitterRefTrack.h - - ${CMAKE_CURRENT_SOURCE_DIR}/fitters/include/KalmanFitter.h - ${CMAKE_CURRENT_SOURCE_DIR}/fitters/include/KalmanFitterInfo.h - ${CMAKE_CURRENT_SOURCE_DIR}/fitters/include/DAF.h -) -ROOT_GENERATE_DICTIONARY("${FITTERS_DICTIONARY_SOURCES}" - "${CMAKE_CURRENT_SOURCE_DIR}/fitters/src/fittersLinkDef.h" - "${CMAKE_CURRENT_BINARY_DIR}/fittersRootDict.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/core/include;${CMAKE_CURRENT_SOURCE_DIR}/fitters/include;${Boost_INCLUDE_DIR}" - ) -SET(library_sources "${CMAKE_CURRENT_BINARY_DIR}/fittersRootDict.cc" "${library_sources}") - -SET(GBL_DICTIONARY_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/GBL/include/GFGbl.h -) -ROOT_GENERATE_DICTIONARY("${GBL_DICTIONARY_SOURCES}" - "${CMAKE_CURRENT_SOURCE_DIR}/GBL/src/GBLLinkDef.h" - "${CMAKE_CURRENT_BINARY_DIR}/GBLRootDict.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/core/include;${CMAKE_CURRENT_SOURCE_DIR}/GBL/include" - ) -SET(library_sources "${CMAKE_CURRENT_BINARY_DIR}/GBLRootDict.cc" "${library_sources}") - -SET(MEASUREMENTS_DICTIONARY_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/HMatrixPhi.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/HMatrixU.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/HMatrixUnit.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/HMatrixV.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/HMatrixUV.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/FullMeasurement.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/PlanarMeasurement.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/ProlateSpacepointMeasurement.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/SpacepointMeasurement.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/WireMeasurement.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/WirePointMeasurement.h - ${CMAKE_CURRENT_SOURCE_DIR}/measurements/include/WireTrackCandHit.h -) -ROOT_GENERATE_DICTIONARY("${MEASUREMENTS_DICTIONARY_SOURCES}" - "${CMAKE_CURRENT_SOURCE_DIR}/measurements/src/measurementsLinkDef.h" - "${CMAKE_CURRENT_BINARY_DIR}/measurementsRootDict.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/core/include;${CMAKE_CURRENT_SOURCE_DIR}/measurements/include;${Boost_INCLUDE_DIR}" - ) -SET(library_sources "${CMAKE_CURRENT_BINARY_DIR}/measurementsRootDict.cc" "${library_sources}") - -SET(TRACKREPS_DICTIONARY_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/trackReps/include/RKTools.h - ${CMAKE_CURRENT_SOURCE_DIR}/trackReps/include/RKTrackRep.h - ${CMAKE_CURRENT_SOURCE_DIR}/trackReps/include/TGeoMaterialInterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/trackReps/include/MaterialEffects.h -) -ROOT_GENERATE_DICTIONARY("${TRACKREPS_DICTIONARY_SOURCES}" - "${CMAKE_CURRENT_SOURCE_DIR}/trackReps/src/trackRepsLinkDef.h" - "${CMAKE_CURRENT_BINARY_DIR}/trackRepsRootDict.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/core/include;${CMAKE_CURRENT_SOURCE_DIR}/trackReps/include;${Boost_INCLUDE_DIR}" - ) -SET(library_sources "${CMAKE_CURRENT_BINARY_DIR}/trackRepsRootDict.cc" "${library_sources}") - -SET(FIELD_DICTIONARY_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/fields/include/ConstField.h - ${CMAKE_CURRENT_SOURCE_DIR}/fields/include/BellField.h -) -ROOT_GENERATE_DICTIONARY("${FIELD_DICTIONARY_SOURCES}" - "${CMAKE_CURRENT_SOURCE_DIR}/fields/src/fieldsLinkDef.h" - "${CMAKE_CURRENT_BINARY_DIR}/fieldsRootDict.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/core/include;${CMAKE_CURRENT_SOURCE_DIR}/fields/include" - ) -SET(library_sources "${CMAKE_CURRENT_BINARY_DIR}/fieldsRootDict.cc" "${library_sources}") - -SET(UTILITIES_DICTIONARY_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/utilities/include/HelixTrackModel.h - ${CMAKE_CURRENT_SOURCE_DIR}/utilities/include/MeasurementCreator.h - ${CMAKE_CURRENT_SOURCE_DIR}/utilities/include/mySpacepointDetectorHit.h - ${CMAKE_CURRENT_SOURCE_DIR}/utilities/include/mySpacepointMeasurement.h -) -ROOT_GENERATE_DICTIONARY("${UTILITIES_DICTIONARY_SOURCES}" - "${CMAKE_CURRENT_SOURCE_DIR}/utilities/src/utilitiesLinkDef.h" - "${CMAKE_CURRENT_BINARY_DIR}/utilitiesRootDict.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/core/include;${CMAKE_CURRENT_SOURCE_DIR}/utilities/include;${CMAKE_CURRENT_SOURCE_DIR}/measurements/include;${Boost_INCLUDE_DIR}" - ) -SET(library_sources "${CMAKE_CURRENT_BINARY_DIR}/utilitiesRootDict.cc" "${library_sources}") - -if(DEFINED RAVE) - SET(GFRAVE_DICTIONARY_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/GFRave/include/GFRaveTrackParameters.h - ${CMAKE_CURRENT_SOURCE_DIR}/GFRave/include/GFRaveVertex.h - ) - ROOT_GENERATE_DICTIONARY("${GFRAVE_DICTIONARY_SOURCES}" - "${CMAKE_CURRENT_SOURCE_DIR}/GFRave/src/GFRaveLinkDef.h" - "${CMAKE_CURRENT_BINARY_DIR}/GFRaveRootDict.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/core/include;${CMAKE_CURRENT_SOURCE_DIR}/GFRave/include" - ) - SET(library_sources "${CMAKE_CURRENT_BINARY_DIR}/GFRaveRootDict.cc" "${library_sources}") -endif() - -# link ROOT libraries -if(DEFINED RAVE) - set(LINK_DIRECTORIES ${ROOT_LIBRARY_DIR} - # add what is needed for RAVE - ) -else() - set(LINK_DIRECTORIES ${ROOT_LIBRARY_DIR}) -endif() - -link_directories( ${LINK_DIRECTORIES}) - -Set(SRCS ${library_sources}) -Set(HEADERS) -Set(LIBRARY_NAME genfit) -Set(DEPENDENCIES Core Geom Matrix Eve Gui Physics MathCore EG) - -Set(LINKDEF -${CMAKE_CURRENT_SOURCE_DIR}/core/src/coreLinkDef.h -${CMAKE_CURRENT_SOURCE_DIR}/eventDisplay/src/eventDisplayLinkDef.h -${CMAKE_CURRENT_SOURCE_DIR}/fitters/src/fittersLinkDef.h -${CMAKE_CURRENT_SOURCE_DIR}/GBL/src/GBLLinkDef.h -${CMAKE_CURRENT_SOURCE_DIR}/measurements/src/measurementsLinkDef.h -${CMAKE_CURRENT_SOURCE_DIR}/trackReps/src/trackRepsLinkDef.h -${CMAKE_CURRENT_SOURCE_DIR}/fields/src/fieldsLinkDef.h -${CMAKE_CURRENT_SOURCE_DIR}/utilities/src/utilitiesLinkDef.h -) -if(DEFINED RAVE) - Set(LINKDEF ${LINKDEF} ${CMAKE_CURRENT_SOURCE_DIR}/GFRave/src/GFRaveLinkDef.h) -endif() -If (ROOT_FOUND_VERSION LESS 59999) - ROOT_GENERATE_ROOTMAP() -EndIf() - -# to not call again ROOT_GENERATE_ROOTMAP -Set(LINKDEF) - -GENERATE_LIBRARY() - -# the examples, build with "make tests" -ADD_CUSTOM_TARGET( tests ) -MACRO( ADD_GENFIT_TEST _testname ) - ADD_EXECUTABLE( ${_testname} EXCLUDE_FROM_ALL ${ARGN} ) - ADD_DEPENDENCIES( tests ${_testname} ) - TARGET_LINK_LIBRARIES( ${_testname} ${PROJECT_NAME} ${ROOT_LIBS} -lGeom ) - #INSTALL( TARGETS ${_testname} DESTINATION ${EXECUTABLE_INSTALL_DIR}) -ENDMACRO( ADD_GENFIT_TEST ) - -ADD_GENFIT_TEST( fitterTests test/fitterTests/main.cc) -ADD_GENFIT_TEST( minimalFittingExample test/minimalFittingExample/main.cc) -ADD_GENFIT_TEST( measurementFactoryExample test/measurementFactoryExample/main.cc) -ADD_GENFIT_TEST( streamerTest test/streamerTest/main.cc) -ADD_GENFIT_TEST( unitTests test/unitTests/main.cc) -if(DEFINED RAVE) - ADD_GENFIT_TEST( vertexingTest test/vertexingTest/main.cc) - ADD_GENFIT_TEST( vertexingTestRead test/vertexingTest/read.cc) -endif() - -If (ROOT_FOUND_VERSION GREATER 59999) - file(GLOB GENFIT_DICTS - "genfit/*.pcm" - ) - file(COPY ${GENFIT_DICTS} DESTINATION lib) -EndIf() - -# generate and install following configuration files -#GENERATE_PACKAGE_CONFIGURATION_FILES( genfitConfig.cmake genfitConfigVersion.cmake ) diff --git a/genfit/CMakeLists.txt b/genfit/CMakeLists.txt deleted file mode 100644 index a97a480cfe..0000000000 --- a/genfit/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -# Create a library called "libgenfit" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. -If (Boost_Avail) - INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR}) - MESSAGE("-- Boost is found at: ${Boost_INCLUDE_DIR}") -Else (Boost_Avail) - MESSAGE("-- Boost is not found at... ERROR") -EndIf (Boost_Avail) - -# Set the build type. Possibilities are None, Debug, Release, -# RelWithDebInfo and MinSizeRel -SET(CMAKE_BUILD_TYPE Release) - -set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/genfit/core/include - ${CMAKE_SOURCE_DIR}/genfit/eventDisplay/include - ${CMAKE_SOURCE_DIR}/genfit/fields/include - ${CMAKE_SOURCE_DIR}/genfit/finitePlanes/include - ${CMAKE_SOURCE_DIR}/genfit/fitters/include - ${CMAKE_SOURCE_DIR}/genfit/GBL/include - ${CMAKE_SOURCE_DIR}/genfit/measurements/include - ${CMAKE_SOURCE_DIR}/genfit/trackReps/include - ${CMAKE_SOURCE_DIR}/genfit/utilities/include - ${CMAKE_SOURCE_DIR}/field - ${VMC_INCLUDE_DIRS} -) - -include_directories( ${INCLUDE_DIRECTORIES}) -include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -set(LINK_DIRECTORIES -${ROOT_LIBRARY_DIR} -${FAIRROOT_LIBRARY_DIR} -) - -link_directories( ${LINK_DIRECTORIES}) - -# add the list of source code files -- careful, when a new file is added! -AUX_SOURCE_DIRECTORY( ${CMAKE_SOURCE_DIR}/genfit/core/src library_sources ) -AUX_SOURCE_DIRECTORY( ${CMAKE_SOURCE_DIR}/genfit/eventDisplay/src library_sources ) -AUX_SOURCE_DIRECTORY( ${CMAKE_SOURCE_DIR}/genfit/fields/src library_sources ) -AUX_SOURCE_DIRECTORY( ${CMAKE_SOURCE_DIR}/genfit/finitePlanes/src library_sources ) -AUX_SOURCE_DIRECTORY( ${CMAKE_SOURCE_DIR}/genfit/fitters/src library_sources ) -AUX_SOURCE_DIRECTORY( ${CMAKE_SOURCE_DIR}/genfit/GBL/src library_sources ) -AUX_SOURCE_DIRECTORY( ${CMAKE_SOURCE_DIR}/genfit/measurements/src library_sources ) -AUX_SOURCE_DIRECTORY( ${CMAKE_SOURCE_DIR}/genfit/trackReps/src library_sources ) -AUX_SOURCE_DIRECTORY( ${CMAKE_SOURCE_DIR}/genfit/utilities/src library_sources ) - -string(REPLACE "/src/" "/include/" HEADERS "${library_sources}") -string(REPLACE ".cc" ".h" HEADERS "${HEADERS}") -set(HEADERS "${HEADERS}" - ${CMAKE_SOURCE_DIR}/genfit/utilities/include/mySpacepointDetectorHit.h - ${CMAKE_SOURCE_DIR}/genfit/utilities/include/mySpacepointMeasurement.h - ${CMAKE_SOURCE_DIR}/genfit/core/include/SharedPlanePtr.h - ${CMAKE_SOURCE_DIR}/genfit/core/include/AbsHMatrix.h -) -Set(SRCS ${library_sources}) -Set(LINKDEF ${CMAKE_SOURCE_DIR}/genfit/genfitLinkDef.h) -Set(LIBRARY_NAME genfit) -Set(DEPENDENCIES Core Geom Matrix Eve Gui Physics MathCore EG) - -GENERATE_LIBRARY() - diff --git a/genfit/GBL/include/BorderedBandMatrix.h b/genfit/GBL/include/BorderedBandMatrix.h deleted file mode 100644 index 339ee5580c..0000000000 --- a/genfit/GBL/include/BorderedBandMatrix.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * BorderedBandMatrix.h - * - * Created on: Aug 14, 2011 - * Author: kleinwrt - */ - -#ifndef BORDEREDBANDMATRIX_H_ -#define BORDEREDBANDMATRIX_H_ - -#include "VMatrix.h" - -#include -#include -#include -#include -#include -#include -#include - - -//! Namespace for the general broken lines package -namespace gbl { - -/// (Symmetric) Bordered Band Matrix. -/** - * Separate storage of border, mixed and band parts (as vector). - * - *\verbatim - * Example for matrix size=8 with border size and band width of two - * - * +- -+ - * | B11 B12 M13 M14 M15 M16 M17 M18 | - * | B12 B22 M23 M24 M25 M26 M27 M28 | - * | M13 M23 C33 C34 C35 0. 0. 0. | - * | M14 M24 C34 C44 C45 C46 0. 0. | - * | M15 M25 C35 C45 C55 C56 C57 0. | - * | M16 M26 0. C46 C56 C66 C67 C68 | - * | M17 M27 0. 0. C57 C67 C77 C78 | - * | M18 M28 0. 0. 0. C68 C78 C88 | - * +- -+ - * - * Is stored as:: - * - * +- -+ +- -+ - * | B11 B12 | | M13 M14 M15 M16 M17 M18 | - * | B12 B22 | | M23 M24 M25 M26 M27 M28 | - * +- -+ +- -+ - * - * +- -+ - * | C33 C44 C55 C66 C77 C88 | - * | C34 C45 C56 C67 C78 0. | - * | C35 C46 C57 C68 0. 0. | - * +- -+ - *\endverbatim - */ - -class BorderedBandMatrix { -public: - BorderedBandMatrix(); - virtual ~BorderedBandMatrix(); - void resize(unsigned int nSize, unsigned int nBorder = 1, - unsigned int nBand = 5); - void solveAndInvertBorderedBand(const VVector &aRightHandSide, - VVector &aSolution); - void addBlockMatrix(double aWeight, - const std::vector* anIndex, - const std::vector* aVector); - TMatrixDSym getBlockMatrix(const std::vector anIndex) const; - void printMatrix() const; - -private: - unsigned int numSize; ///< Matrix size - unsigned int numBorder; ///< Border size - unsigned int numBand; ///< Band width - unsigned int numCol; ///< Band matrix size - VSymMatrix theBorder; ///< Border part - VMatrix theMixed; ///< Mixed part - VMatrix theBand; ///< Band part - - void decomposeBand(); - VVector solveBand(const VVector &aRightHandSide) const; - VMatrix solveBand(const VMatrix &aRightHandSide) const; - VMatrix invertBand(); - VMatrix bandOfAVAT(const VMatrix &anArray, - const VSymMatrix &aSymArray) const; -}; -} -#endif /* BORDEREDBANDMATRIX_H_ */ diff --git a/genfit/GBL/include/GFGbl.h b/genfit/GBL/include/GFGbl.h deleted file mode 100644 index d2df9e4319..0000000000 --- a/genfit/GBL/include/GFGbl.h +++ /dev/null @@ -1,133 +0,0 @@ -/* Copyright 2013 - * Authors: Sergey Yashchenko and Tadeas Bilka - * - * This file is part of GENFIT. - * - * GENFIT is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GENFIT is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GENFIT. If not, see . - */ -/** @addtogroup genfit - * @{ - */ - -#ifndef GFGBL_H -#define GFGBL_H - -#include "GblTrajectory.h" -#include "AbsFitter.h" - -#include -#include - -#include -#include -#include - -#include -#include - - -namespace genfit { - - - /** @brief Generic GBL implementation - * - * The interface class to GBL track fit - * - */ - class GFGbl : public AbsFitter { - - private: - GFGbl(const GFGbl&); - GFGbl& operator=(GFGbl const&); - - std::string m_milleFileName; - std::string m_gblInternalIterations; - double m_pValueCut; - int m_minNdf; - double m_chi2Cut; - bool m_enableScatterers; - bool m_enableIntermediateScatterer; - - - public: - - /** - * Constructor - */ - GFGbl(); - - /** - * Destructor - */ - virtual ~GFGbl() {;} - - /** - * Creates the mille binary file for output of - * data for Millepede II alignment, can be set by setMP2Options - */ - void beginRun(); - - /** - * Required to write and close ROOT file - * with debug output. Destructor cannot be used. - * To be called from endRun function of a module - */ - void endRun(); - - - /** - * @brief Sets internal GBL down-weighting - * @param internalIterations GBL internal down-weighting settings, see GBL doc - * @return void - */ - void setGBLOptions(std::string internalIterations = "THC", bool enableScatterers = true, bool enableIntermediateScatterer = true) { - m_gblInternalIterations = internalIterations; - if (!enableScatterers) - enableIntermediateScatterer = false; - m_enableScatterers = enableScatterers; - m_enableIntermediateScatterer = enableIntermediateScatterer; - } - - /** - * @brief Sets GBL & Millepede settings - * @param pValueCut minimum track p-value for MP2 output - * @param minNdf minimum track NDF for MP2 output - * @param mille_file_name name of MP2 binary file for output - * @return void - */ - void setMP2Options(double pValueCut = 0., unsigned int minNdf = 1, std::string mille_file_name = "millefile.dat", double chi2Cut = 0.) { - m_pValueCut = pValueCut; - m_minNdf = minNdf; - m_milleFileName = mille_file_name; - m_chi2Cut = chi2Cut; - } - - /** - * Performs fit on a Track. - * Hit resorting currently NOT supported. - */ - void processTrackWithRep(Track* trk, const AbsTrackRep* rep, bool resortHits = false); - - - public: - - ClassDef(GFGbl, 1) - - }; - -} /* End of namespace genfit */ -/** @} */ - -#endif // GFGBL_H - diff --git a/genfit/GBL/include/GblData.h b/genfit/GBL/include/GblData.h deleted file mode 100644 index f833f729fa..0000000000 --- a/genfit/GBL/include/GblData.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * GblData.h - * - * Created on: Aug 18, 2011 - * Author: kleinwrt - */ - -#ifndef GBLDATA_H_ -#define GBLDATA_H_ - -#include -#include -#include -#include "VMatrix.h" -#include "TVectorD.h" -#include "TMatrixD.h" -#include "TMatrixDSym.h" - -#include "Math/SMatrix.h" -#include "Math/SVector.h" -typedef ROOT::Math::SMatrix SMatrix25; -typedef ROOT::Math::SMatrix SMatrix27; -typedef ROOT::Math::SMatrix SMatrix55; - -//! Namespace for the general broken lines package -namespace gbl { - -/// Data (block) for independent scalar measurement -/** - * Data (block) containing value, precision and derivatives for measurements and kinks. - * Created from attributes of GblPoints, used to construct linear equation system for track fit. - */ -class GblData { -public: - GblData(unsigned int aLabel, double aMeas, double aPrec); - virtual ~GblData(); - void addDerivatives(unsigned int iRow, - const std::vector &labDer, const SMatrix55 &matDer, - unsigned int iOff, const TMatrixD &derLocal, - const std::vector &labGlobal, const TMatrixD &derGlobal, - unsigned int nLocal, const TMatrixD &derTrans); - void addDerivatives(unsigned int iRow, - const std::vector &labDer, const SMatrix27 &matDer, - unsigned int nLocal, const TMatrixD &derTrans); - void addDerivatives(const std::vector &index, - const std::vector &derivatives); - - void setPrediction(const VVector &aVector); - double setDownWeighting(unsigned int aMethod); - double getChi2() const; - void printData() const; - void getLocalData(double &aValue, double &aWeight, - std::vector* &indLocal, - std::vector* &derLocal); - void getAllData(double &aValue, double &aErr, - std::vector* &indLocal, - std::vector* &derLocal, std::vector* &labGlobal, - std::vector* &derGlobal); - void getResidual(double &aResidual, double &aVariance, double &aDownWeight, - std::vector* &indLocal, - std::vector* &derLocal); - -private: - unsigned int theLabel; ///< Label (of measurements point) - double theValue; ///< Value (residual) - double thePrecision; ///< Precision (1/sigma**2) - double theDownWeight; ///< Down-weighting factor (0-1) - double thePrediction; ///< Prediction from fit - std::vector theParameters; ///< List of fit parameters (with non zero derivatives) - std::vector theDerivatives; ///< List of derivatives for fit - std::vector globalLabels; ///< Labels for global derivatives - std::vector globalDerivatives; ///< Global derivatives -}; -} -#endif /* GBLDATA_H_ */ diff --git a/genfit/GBL/include/GblPoint.h b/genfit/GBL/include/GblPoint.h deleted file mode 100644 index 81e9363481..0000000000 --- a/genfit/GBL/include/GblPoint.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * GblPoint.h - * - * Created on: Aug 18, 2011 - * Author: kleinwrt - */ - -#ifndef GBLPOINT_H_ -#define GBLPOINT_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -typedef ROOT::Math::SMatrix SMatrix22; -typedef ROOT::Math::SMatrix SMatrix23; -typedef ROOT::Math::SMatrix SMatrix25; -typedef ROOT::Math::SMatrix SMatrix27; -typedef ROOT::Math::SMatrix SMatrix32; -typedef ROOT::Math::SMatrix SMatrix33; -typedef ROOT::Math::SMatrix SMatrix55; -typedef ROOT::Math::SVector SVector2; -typedef ROOT::Math::SVector SVector5; - - -namespace gbl { - -/// Point on trajectory -/** - * User supplied point on (initial) trajectory. - * - * Must have jacobian for propagation from previous point. May have: - * - * -# Measurement (1D - 5D) - * -# Scatterer (thin, 2D kinks) - * -# Additional local parameters (with derivatives). Fitted together with track parameters. - * -# Additional global parameters (with labels and derivatives). Not fitted, only passed - * on to (binary) file for fitting with Millepede-II. - */ -class GblPoint { -public: - GblPoint(const TMatrixD &aJacobian); - GblPoint(const SMatrix55 &aJacobian); - virtual ~GblPoint(); - void addMeasurement(const TMatrixD &aProjection, const TVectorD &aResiduals, - const TVectorD &aPrecision, double minPrecision = 0.); - void addMeasurement(const TMatrixD &aProjection, const TVectorD &aResiduals, - const TMatrixDSym &aPrecision, double minPrecision = 0.); - void addMeasurement(const TVectorD &aResiduals, const TVectorD &aPrecision, - double minPrecision = 0.); - void addMeasurement(const TVectorD &aResiduals, - const TMatrixDSym &aPrecision, double minPrecision = 0.); - unsigned int hasMeasurement() const; - void getMeasurement(SMatrix55 &aProjection, SVector5 &aResiduals, - SVector5 &aPrecision) const; - void getMeasTransformation(TMatrixD &aTransformation) const; - void addScatterer(const TVectorD &aResiduals, const TVectorD &aPrecision); - void addScatterer(const TVectorD &aResiduals, - const TMatrixDSym &aPrecision); - bool hasScatterer() const; - void getScatterer(SMatrix22 &aTransformation, SVector2 &aResiduals, - SVector2 &aPrecision) const; - void getScatTransformation(TMatrixD &aTransformation) const; - void addLocals(const TMatrixD &aDerivatives); - unsigned int getNumLocals() const; - const TMatrixD& getLocalDerivatives() const; - void addGlobals(const std::vector &aLabels, - const TMatrixD &aDerivatives); - unsigned int getNumGlobals() const; - std::vector getGlobalLabels() const; - const TMatrixD& getGlobalDerivatives() const; - void setLabel(unsigned int aLabel); - unsigned int getLabel() const; - void setOffset(int anOffset); - int getOffset() const; - const SMatrix55& getP2pJacobian() const; - void addPrevJacobian(const SMatrix55 &aJac); - void addNextJacobian(const SMatrix55 &aJac); - void getDerivatives(int aDirection, SMatrix22 &matW, SMatrix22 &matWJ, - SVector2 &vecWd) const; - void printPoint(unsigned int level = 0) const; - -private: - unsigned int theLabel; ///< Label identifying point - int theOffset; ///< Offset number at point if not negative (else interpolation needed) - SMatrix55 p2pJacobian; ///< Point-to-point jacobian from previous point - SMatrix55 prevJacobian; ///< Jacobian to previous scatterer (or first measurement) - SMatrix55 nextJacobian; ///< Jacobian to next scatterer (or last measurement) - unsigned int measDim; ///< Dimension of measurement (1-5), 0 indicates absence of measurement - SMatrix55 measProjection; ///< Projection from measurement to local system - SVector5 measResiduals; ///< Measurement residuals - SVector5 measPrecision; ///< Measurement precision (diagonal of inverse covariance matrix) - bool transFlag; ///< Transformation exists? - TMatrixD measTransformation; ///< Transformation of diagonalization (of meas. precision matrix) - bool scatFlag; ///< Scatterer present? - SMatrix22 scatTransformation; ///< Transformation of diagonalization (of scat. precision matrix) - SVector2 scatResiduals; ///< Scattering residuals (initial kinks if iterating) - SVector2 scatPrecision; ///< Scattering precision (diagonal of inverse covariance matrix) - TMatrixD localDerivatives; ///< Derivatives of measurement vs additional local (fit) parameters - std::vector globalLabels; ///< Labels of global (MP-II) derivatives - TMatrixD globalDerivatives; ///< Derivatives of measurement vs additional global (MP-II) parameters -}; -} -#endif /* GBLPOINT_H_ */ diff --git a/genfit/GBL/include/GblTrajectory.h b/genfit/GBL/include/GblTrajectory.h deleted file mode 100644 index 704786157b..0000000000 --- a/genfit/GBL/include/GblTrajectory.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * GblTrajectory.h - * - * Created on: Aug 18, 2011 - * Author: kleinwrt - */ - -#ifndef GBLTRAJECTORY_H_ -#define GBLTRAJECTORY_H_ - -#include "GblPoint.h" -#include "GblData.h" -#include "GblPoint.h" -#include "BorderedBandMatrix.h" -#include "MilleBinary.h" -#include "TMatrixDSymEigen.h" - -//! Namespace for the general broken lines package -namespace gbl { - -/// GBL trajectory. -/** - * List of GblPoints ordered by arc length. - * Can be fitted and optionally written to MP-II binary file. - */ -class GblTrajectory { -public: - GblTrajectory(const std::vector &aPointList, bool flagCurv = true, - bool flagU1dir = true, bool flagU2dir = true); - GblTrajectory(const std::vector &aPointList, unsigned int aLabel, - const TMatrixDSym &aSeed, bool flagCurv = true, bool flagU1dir = - true, bool flagU2dir = true); - GblTrajectory( - const std::vector, TMatrixD> > &aPointaAndTransList); - GblTrajectory( - const std::vector, TMatrixD> > &aPointaAndTransList, - const TMatrixD &extDerivatives, const TVectorD &extMeasurements, - const TVectorD &extPrecisions); - virtual ~GblTrajectory(); - bool isValid() const; - unsigned int getNumPoints() const; - unsigned int getResults(int aSignedLabel, TVectorD &localPar, - TMatrixDSym &localCov) const; - unsigned int getMeasResults(unsigned int aLabel, unsigned int &numRes, - TVectorD &aResiduals, TVectorD &aMeasErrors, TVectorD &aResErrors, - TVectorD &aDownWeights); - unsigned int getScatResults(unsigned int aLabel, unsigned int &numRes, - TVectorD &aResiduals, TVectorD &aMeasErrors, TVectorD &aResErrors, - TVectorD &aDownWeights); - void getLabels(std::vector &aLabelList); - void getLabels(std::vector > &aLabelList); - unsigned int fit(double &Chi2, int &Ndf, double &lostWeight, - std::string optionList = ""); - void milleOut(MilleBinary &aMille); - void printTrajectory(unsigned int level = 0); - void printPoints(unsigned int level = 0); - void printData(); - -private: - unsigned int numAllPoints; ///< Number of all points on trajectory - std::vector numPoints; ///< Number of points on (sub)trajectory - unsigned int numTrajectories; ///< Number of trajectories (in composed trajectory) - unsigned int numOffsets; ///< Number of (points with) offsets on trajectory - unsigned int numInnerTrans; ///< Number of inner transformations to external parameters - unsigned int numCurvature; ///< Number of curvature parameters (0 or 1) or external parameters - unsigned int numParameters; ///< Number of fit parameters - unsigned int numLocals; ///< Total number of (additional) local parameters - unsigned int numMeasurements; ///< Total number of measurements - unsigned int externalPoint; ///< Label of external point (or 0) - bool constructOK; ///< Trajectory has been successfully constructed (ready for fit/output) - bool fitOK; ///< Trajectory has been successfully fitted (results are valid) - std::vector theDimension; ///< List of active dimensions (0=u1, 1=u2) in fit - std::vector > thePoints; ///< (list of) List of points on trajectory - std::vector theData; ///< List of data blocks - std::vector measDataIndex; ///< mapping points to data blocks from measurements - std::vector scatDataIndex; ///< mapping points to data blocks from scatterers - TMatrixDSym externalSeed; ///< Precision (inverse covariance matrix) of external seed - std::vector innerTransformations; ///< Transformations at innermost points of - // composed trajectory (from common external parameters) - TMatrixD externalDerivatives; // Derivatives for external measurements of composed trajectory - TVectorD externalMeasurements; // Residuals for external measurements of composed trajectory - TVectorD externalPrecisions; // Precisions for external measurements of composed trajectory - VVector theVector; ///< Vector of linear equation system - BorderedBandMatrix theMatrix; ///< (Bordered band) matrix of linear equation system - - std::pair, TMatrixD> getJacobian( - int aSignedLabel) const; - void getFitToLocalJacobian(std::vector &anIndex, - SMatrix55 &aJacobian, const GblPoint &aPoint, unsigned int measDim, - unsigned int nJacobian = 1) const; - void getFitToKinkJacobian(std::vector &anIndex, - SMatrix27 &aJacobian, const GblPoint &aPoint) const; - void construct(); - void defineOffsets(); - void calcJacobians(); - void prepare(); - void buildLinearEquationSystem(); - void predict(); - double downWeight(unsigned int aMethod); - void getResAndErr(unsigned int aData, double &aResidual, - double &aMeadsError, double &aResError, double &aDownWeight); -}; -} -#endif /* GBLTRAJECTORY_H_ */ diff --git a/genfit/GBL/include/MilleBinary.h b/genfit/GBL/include/MilleBinary.h deleted file mode 100644 index e26126a62c..0000000000 --- a/genfit/GBL/include/MilleBinary.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * MilleBinary.h - * - * Created on: Aug 31, 2011 - * Author: kleinwrt - */ - -#ifndef MILLEBINARY_H_ -#define MILLEBINARY_H_ - -#include -#include - -//! Namespace for the general broken lines package -namespace gbl { - -/// Millepede-II (binary) record. -/** - * Containing information for local (track) and global fit. - * - * The data blocks are collected in two arrays, a real array - * (containing float or double values) and integer array, of same length. - * A positive record length indicate _float_ and a negative one _double_ values. - * The content of the record is: - *\verbatim - * real array integer array - * 0 0.0 error count (this record) - * 1 RMEAS, measured value 0 -+ - * 2 local derivative index of local derivative | - * 3 local derivative index of local derivative | - * 4 ... | block - * SIGMA, error (>0) 0 | - * global derivative label of global derivative | - * global derivative label of global derivative -+ - * RMEAS, measured value 0 - * local derivative index of local derivative - * local derivative index of local derivative - * ... - * SIGMA, error 0 - * global derivative label of global derivative - * global derivative label of global derivative - * ... - * global derivative label of global derivative - *\endverbatim - */ -class MilleBinary { -public: - MilleBinary(const std::string fileName = "milleBinaryISN.dat", - bool doublePrec = false, unsigned int aSize = 2000); - virtual ~MilleBinary(); - void addData(double aMeas, double aPrec, - const std::vector &indLocal, - const std::vector &derLocal, - const std::vector &labGlobal, - const std::vector &derGlobal); - void writeRecord(); - -private: - std::ofstream binaryFile; ///< Binary File - std::vector intBuffer; ///< Integer buffer - std::vector floatBuffer; ///< Float buffer - std::vector doubleBuffer; ///< Double buffer - bool doublePrecision; ///< Flag for storage in as *double* values -}; -} -#endif /* MILLEBINARY_H_ */ diff --git a/genfit/GBL/include/MyDebugTools.h b/genfit/GBL/include/MyDebugTools.h deleted file mode 100644 index 4112461cfb..0000000000 --- a/genfit/GBL/include/MyDebugTools.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef MYDEBUGTOOLS_H -#define MYDEBUGTOOLS_H - - -#include -#include -#include -#include -#include -#include -#include -#include - -/* -using namespace std; - -ofstream file("debug.txt"); - - - -void outputMatrix(TMatrixDSym matrix, std::string caption = "") -{ - if (caption != "") file << caption << endl; - for (int i=0; i -#include -#include -#include -#include - - -//! Namespace for the general broken lines package -namespace gbl { - -/// Simple Vector based on std::vector -class VVector { -public: - VVector(const unsigned int nRows = 0); - VVector(const VVector &aVector); - virtual ~VVector(); - void resize(const unsigned int nRows); - VVector getVec(unsigned int len, unsigned int start = 0) const; - void putVec(const VVector &aVector, unsigned int start = 0); - inline double &operator()(unsigned int i); - inline double operator()(unsigned int i) const; - unsigned int getNumRows() const; - void print() const; - VVector operator-(const VVector &aVector) const; - VVector &operator=(const VVector &aVector); -private: - unsigned int numRows; ///< Number of rows - std::vector theVec; ///< Data -}; - -/// Simple Matrix based on std::vector -class VMatrix { -public: - VMatrix(const unsigned int nRows = 0, const unsigned int nCols = 0); - VMatrix(const VMatrix &aMatrix); - virtual ~VMatrix(); - void resize(const unsigned int nRows, const unsigned int nCols); - VMatrix transpose() const; - inline double &operator()(unsigned int i, unsigned int j); - inline double operator()(unsigned int i, unsigned int j) const; - unsigned int getNumRows() const; - unsigned int getNumCols() const; - void print() const; - VVector operator*(const VVector &aVector) const; - VMatrix operator*(const VMatrix &aMatrix) const; - VMatrix operator+(const VMatrix &aMatrix) const; - VMatrix &operator=(const VMatrix &aMatrix); -private: - unsigned int numRows; ///< Number of rows - unsigned int numCols; ///< Number of columns - std::vector theVec; ///< Data -}; - -/// Simple symmetric Matrix based on std::vector -class VSymMatrix { -public: - VSymMatrix(const unsigned int nRows = 0); - virtual ~VSymMatrix(); - void resize(const unsigned int nRows); - unsigned int invert(); - inline double &operator()(unsigned int i, unsigned int j); - inline double operator()(unsigned int i, unsigned int j) const; - unsigned int getNumRows() const; - void print() const; - VSymMatrix operator-(const VMatrix &aMatrix) const; - VVector operator*(const VVector &aVector) const; - VMatrix operator*(const VMatrix &aMatrix) const; -private: - unsigned int numRows; ///< Number of rows - std::vector theVec; ///< Data (symmetric storage) -}; - -/// access element (i,j) -inline double &VMatrix::operator()(unsigned int iRow, unsigned int iCol) { - return theVec[numCols * iRow + iCol]; -} - -/// access element (i,j) -inline double VMatrix::operator()(unsigned int iRow, unsigned int iCol) const { - return theVec[numCols * iRow + iCol]; -} - -/// access element (i) -inline double &VVector::operator()(unsigned int iRow) { - return theVec[iRow]; -} - -/// access element (i) -inline double VVector::operator()(unsigned int iRow) const { - return theVec[iRow]; -} - -/// access element (i,j) assuming i>=j -inline double &VSymMatrix::operator()(unsigned int iRow, unsigned int iCol) { - return theVec[(iRow * iRow + iRow) / 2 + iCol]; // assuming iCol <= iRow -} - -/// access element (i,j) assuming i>=j -inline double VSymMatrix::operator()(unsigned int iRow, - unsigned int iCol) const { - return theVec[(iRow * iRow + iRow) / 2 + iCol]; // assuming iCol <= iRow -} -} -#endif /* VMATRIX_H_ */ diff --git a/genfit/GBL/src/BorderedBandMatrix.cc b/genfit/GBL/src/BorderedBandMatrix.cc deleted file mode 100644 index df644ee74d..0000000000 --- a/genfit/GBL/src/BorderedBandMatrix.cc +++ /dev/null @@ -1,317 +0,0 @@ -/* - * BorderedBandMatrix.cpp - * - * Created on: Aug 14, 2011 - * Author: kleinwrt - */ - -#include "BorderedBandMatrix.h" - -//! Namespace for the general broken lines package -namespace gbl { - -/// Create bordered band matrix. -BorderedBandMatrix::BorderedBandMatrix() : numSize(0), numBorder(0), numBand(0), numCol(0) { -} - -BorderedBandMatrix::~BorderedBandMatrix() { -} - -/// Resize bordered band matrix. -/** - * \param nSize [in] Size of matrix - * \param nBorder [in] Size of border (=1 for q/p + additional local parameters) - * \param nBand [in] Band width (usually = 5, for simplified jacobians = 4) - */ -void BorderedBandMatrix::resize(unsigned int nSize, unsigned int nBorder, - unsigned int nBand) { - numSize = nSize; - numBorder = nBorder; - numCol = nSize - nBorder; - numBand = 0; - theBorder.resize(numBorder); - theMixed.resize(numBorder, numCol); - theBand.resize((nBand + 1), numCol); -} - -/// Add symmetric block matrix. -/** - * Add (extended) block matrix defined by 'aVector * aWeight * aVector.T' - * to bordered band matrix: - * BBmatrix(anIndex(i),anIndex(j)) += aVector(i) * aWeight * aVector(j). - * \param aWeight [in] Weight - * \param anIndex [in] List of rows/colums to be used - * \param aVector [in] Vector - */ -void BorderedBandMatrix::addBlockMatrix(double aWeight, - const std::vector* anIndex, - const std::vector* aVector) { - int nBorder = numBorder; - for (unsigned int i = 0; i < anIndex->size(); ++i) { - int iIndex = (*anIndex)[i] - 1; // anIndex has to be sorted - for (unsigned int j = 0; j <= i; ++j) { - int jIndex = (*anIndex)[j] - 1; - if (iIndex < nBorder) { - theBorder(iIndex, jIndex) += (*aVector)[i] * aWeight - * (*aVector)[j]; - } else if (jIndex < nBorder) { - theMixed(jIndex, iIndex - nBorder) += (*aVector)[i] * aWeight - * (*aVector)[j]; - } else { - unsigned int nBand = iIndex - jIndex; - theBand(nBand, jIndex - nBorder) += (*aVector)[i] * aWeight - * (*aVector)[j]; - numBand = std::max(numBand, nBand); // update band width - } - } - } -} - -/// Retrieve symmetric block matrix. -/** - * Get (compressed) block from bordered band matrix: aMatrix(i,j) = BBmatrix(anIndex(i),anIndex(j)). - * \param anIndex [in] List of rows/colums to be used - */ -TMatrixDSym BorderedBandMatrix::getBlockMatrix( - const std::vector anIndex) const { - - TMatrixDSym aMatrix(anIndex.size()); - int nBorder = numBorder; - for (unsigned int i = 0; i < anIndex.size(); ++i) { - int iIndex = anIndex[i] - 1; // anIndex has to be sorted - for (unsigned int j = 0; j <= i; ++j) { - int jIndex = anIndex[j] - 1; - if (iIndex < nBorder) { - aMatrix(i, j) = theBorder(iIndex, jIndex); // border part of inverse - } else if (jIndex < nBorder) { - aMatrix(i, j) = -theMixed(jIndex, iIndex - nBorder); // mixed part of inverse - } else { - unsigned int nBand = iIndex - jIndex; - aMatrix(i, j) = theBand(nBand, jIndex - nBorder); // band part of inverse - } - aMatrix(j, i) = aMatrix(i, j); - } - } - return aMatrix; -} - -/// Solve linear equation system, partially calculate inverse. -/** - * Solve linear equation A*x=b system with bordered band matrix A, - * calculate bordered band part of inverse of A. Use decomposition - * in border and band part for block matrix algebra: - * - * | A Ct | | x1 | | b1 | , A is the border part - * | | * | | = | | , Ct is the mixed part - * | C D | | x2 | | b2 | , D is the band part - * - * Explicit inversion of D is avoided by using solution X of D*X=C (X=D^-1*C, - * obtained from Cholesky decomposition and forward/backward substitution) - * - * | x1 | | E*b1 - E*Xt*b2 | , E^-1 = A-Ct*D^-1*C = A-Ct*X - * | | = | | - * | x2 | | x - X*x1 | , x is solution of D*x=b2 (x=D^-1*b2) - * - * Inverse matrix is: - * - * | E -E*Xt | - * | | , only band part of (D^-1 + X*E*Xt) - * | -X*E D^-1 + X*E*Xt | is calculated - * - * - * \param [in] aRightHandSide Right hand side (vector) 'b' of A*x=b - * \param [out] aSolution Solution (vector) x of A*x=b - */ -void BorderedBandMatrix::solveAndInvertBorderedBand( - const VVector &aRightHandSide, VVector &aSolution) { - - // decompose band - decomposeBand(); - // invert band - VMatrix inverseBand = invertBand(); - if (numBorder > 0) { // need to use block matrix decomposition to solve - // solve for mixed part - const VMatrix auxMat = solveBand(theMixed); // = Xt - const VMatrix auxMatT = auxMat.transpose(); // = X - // solve for border part - const VVector auxVec = aRightHandSide.getVec(numBorder) - - auxMat * aRightHandSide.getVec(numCol, numBorder); // = b1 - Xt*b2 - VSymMatrix inverseBorder = theBorder - theMixed * auxMatT; - inverseBorder.invert(); // = E - const VVector borderSolution = inverseBorder * auxVec; // = x1 - // solve for band part - const VVector bandSolution = solveBand( - aRightHandSide.getVec(numCol, numBorder)); // = x - aSolution.putVec(borderSolution); - aSolution.putVec(bandSolution - auxMatT * borderSolution, numBorder); // = x2 - // parts of inverse - theBorder = inverseBorder; // E - theMixed = inverseBorder * auxMat; // E*Xt (-mixed part of inverse) !!! - theBand = inverseBand + bandOfAVAT(auxMatT, inverseBorder); // band(D^-1 + X*E*Xt) - } else { - aSolution.putVec(solveBand(aRightHandSide)); - theBand = inverseBand; - } -} - -/// Print bordered band matrix. -void BorderedBandMatrix::printMatrix() const { - std::cout << "Border part " << std::endl; - theBorder.print(); - std::cout << "Mixed part " << std::endl; - theMixed.print(); - std::cout << "Band part " << std::endl; - theBand.print(); -} - -/*============================================================================ - from Dbandmatrix.F (MillePede-II by V. Blobel, Univ. Hamburg) - ============================================================================*/ -/// (root free) Cholesky decomposition of band part: C=LDL^T -/** - * Decompose band matrix into diagonal matrix D and lower triangular band matrix - * L (diagonal=1). Overwrite band matrix with D and off-diagonal part of L. - * \exception 2 : matrix is singular. - * \exception 3 : matrix is not positive definite. - */ -void BorderedBandMatrix::decomposeBand() { - - int nRow = numBand + 1; - int nCol = numCol; - VVector auxVec(nCol); - for (int i = 0; i < nCol; ++i) { - auxVec(i) = theBand(0, i) * 16.0; // save diagonal elements - } - for (int i = 0; i < nCol; ++i) { - if ((theBand(0, i) + auxVec(i)) != theBand(0, i)) { - theBand(0, i) = 1.0 / theBand(0, i); - if (theBand(0, i) < 0.) { - throw 3; // not positive definite - } - } else { - theBand(0, i) = 0.0; - throw 2; // singular - } - for (int j = 1; j < std::min(nRow, nCol - i); ++j) { - double rxw = theBand(j, i) * theBand(0, i); - for (int k = 0; k < std::min(nRow, nCol - i) - j; ++k) { - theBand(k, i + j) -= theBand(k + j, i) * rxw; - } - theBand(j, i) = rxw; - } - } -} - -/// Solve for band part. -/** - * Solve C*x=b for band part using decomposition C=LDL^T - * and forward (L*z=b) and backward substitution (L^T*x=D^-1*z). - * \param [in] aRightHandSide Right hand side (vector) 'b' of C*x=b - * \return Solution (vector) 'x' of C*x=b - */ -VVector BorderedBandMatrix::solveBand(const VVector &aRightHandSide) const { - - int nRow = theBand.getNumRows(); - int nCol = theBand.getNumCols(); - VVector aSolution(aRightHandSide); - for (int i = 0; i < nCol; ++i) // forward substitution - { - for (int j = 1; j < std::min(nRow, nCol - i); ++j) { - aSolution(j + i) -= theBand(j, i) * aSolution(i); - } - } - for (int i = nCol - 1; i >= 0; i--) // backward substitution - { - double rxw = theBand(0, i) * aSolution(i); - for (int j = 1; j < std::min(nRow, nCol - i); ++j) { - rxw -= theBand(j, i) * aSolution(j + i); - } - aSolution(i) = rxw; - } - return aSolution; -} - -/// solve band part for mixed part (border rows). -/** - * Solve C*X=B for mixed part using decomposition C=LDL^T - * and forward and backward substitution. - * \param [in] aRightHandSide Right hand side (matrix) 'B' of C*X=B - * \return Solution (matrix) 'X' of C*X=B - */ -VMatrix BorderedBandMatrix::solveBand(const VMatrix &aRightHandSide) const { - - int nRow = theBand.getNumRows(); - int nCol = theBand.getNumCols(); - VMatrix aSolution(aRightHandSide); - for (unsigned int iBorder = 0; iBorder < numBorder; iBorder++) { - for (int i = 0; i < nCol; ++i) // forward substitution - { - for (int j = 1; j < std::min(nRow, nCol - i); ++j) { - aSolution(iBorder, j + i) -= theBand(j, i) - * aSolution(iBorder, i); - } - } - for (int i = nCol - 1; i >= 0; i--) // backward substitution - { - double rxw = theBand(0, i) * aSolution(iBorder, i); - for (int j = 1; j < std::min(nRow, nCol - i); ++j) { - rxw -= theBand(j, i) * aSolution(iBorder, j + i); - } - aSolution(iBorder, i) = rxw; - } - } - return aSolution; -} - -/// Invert band part. -/** - * \return Inverted band - */ -VMatrix BorderedBandMatrix::invertBand() { - - int nRow = numBand + 1; - int nCol = numCol; - VMatrix inverseBand(nRow, nCol); - - for (int i = nCol - 1; i >= 0; i--) { - double rxw = theBand(0, i); - for (int j = i; j >= std::max(0, i - nRow + 1); j--) { - for (int k = j + 1; k < std::min(nCol, j + nRow); ++k) { - rxw -= inverseBand(abs(i - k), std::min(i, k)) - * theBand(k - j, j); - } - inverseBand(i - j, j) = rxw; - rxw = 0.; - } - } - return inverseBand; -} - -/// Calculate band part of: 'anArray * aSymArray * anArray.T'. -/** - * \return Band part of product - */ -VMatrix BorderedBandMatrix::bandOfAVAT(const VMatrix &anArray, - const VSymMatrix &aSymArray) const { - int nBand = numBand; - int nCol = numCol; - int nBorder = numBorder; - double sum; - VMatrix aBand((nBand + 1), nCol); - for (int i = 0; i < nCol; ++i) { - for (int j = std::max(0, i - nBand); j <= i; ++j) { - sum = 0.; - for (int l = 0; l < nBorder; ++l) { // diagonal - sum += anArray(i, l) * aSymArray(l, l) * anArray(j, l); - for (int k = 0; k < l; ++k) { // off diagonal - sum += anArray(i, l) * aSymArray(l, k) * anArray(j, k) - + anArray(i, k) * aSymArray(l, k) * anArray(j, l); - } - } - aBand(i - j, j) = sum; - } - } - return aBand; -} - -} diff --git a/genfit/GBL/src/GBLLinkDef.h b/genfit/GBL/src/GBLLinkDef.h deleted file mode 100644 index 71d6054a5d..0000000000 --- a/genfit/GBL/src/GBLLinkDef.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class genfit::GFGbl+; - -#endif diff --git a/genfit/GBL/src/GFGbl.cc b/genfit/GBL/src/GFGbl.cc deleted file mode 100644 index 7a7ae33999..0000000000 --- a/genfit/GBL/src/GFGbl.cc +++ /dev/null @@ -1,1073 +0,0 @@ -//-*-mode: C++; c-basic-offset: 2; -*- -/* Copyright 2013 - * Authors: Sergey Yashchenko and Tadeas Bilka - * - * This is an interface to General Broken Lines - * - * Version: 5 (Tadeas) - * - several bug-fixes: - * - Scatterers at bad points - * - Jacobians at a point before they should be (code reorganized) - * - Change of sign of residuals - * Version: 4 (Tadeas) - * Fixed calculation of equvivalent scatterers (solution by C. Kleinwort) - * Now a scatterer is inserted at each measurement (except last) and between each two measurements. - * TrueHits/Clusters. Ghost (1D) hits ignored. With or without magnetic field. - * Version: 3 (Tadeas) - * This version now supports both TrueHits and Clusters for VXD. - * It can be used for arbitrary material distribution between - * measurements. Moments of scattering distribution are computed - * and translated into two equivalent thin GBL scatterers placed - * at computed positions between measurement points. - * Version: 2 ... never published (Tadeas) - * Scatterer at each boundary (tooo many scatterers). TrueHits/Clusters. Without global der.&MP2 output. - * Version: 1 (Sergey & Tadeas) - * Scatterers at measurement planes. TrueHits - * Version 0: (Sergey) - * Without scatterers. Genfit 1. - * - * This file is part of GENFIT. - * - * GENFIT is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GENFIT is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with GENFIT. If not, see . - */ - -#include "GFGbl.h" -#include "GblTrajectory.h" -#include "GblPoint.h" -#include "MyDebugTools.h" - -#include "AbsMeasurement.h" -#include "PlanarMeasurement.h" -#include "KalmanFitterInfo.h" - -#include "Track.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -//#define DEBUG -//#define OUTPUT - - -#ifdef DEBUG -//ofstream debug("gbl.debug"); -#endif - -#ifdef OUTPUT - -std::string rootFileName = "gbl.root"; - - -TFile* diag; -TH1F* resHistosU[12]; -TH1F* resHistosV[12]; -TH1F* mhistosU[12]; -TH1F* mhistosV[12]; -TH1F* ghistosU[12]; -TH1F* ghistosV[12]; -TH1F* downWeightsHistosU[12]; -TH1F* downWeightsHistosV[12]; -TH1F* localPar1[12]; -TH1F* localPar2[12]; -TH1F* localPar3[12]; -TH1F* localPar4[12]; -TH1F* localPar5[12]; -TH1F* localCov1[12]; -TH1F* localCov2[12]; -TH1F* localCov3[12]; -TH1F* localCov4[12]; -TH1F* localCov5[12]; -TH1F* localCov12[12]; -TH1F* localCov13[12]; -TH1F* localCov14[12]; -TH1F* localCov15[12]; -TH1F* localCov23[12]; -TH1F* localCov24[12]; -TH1F* localCov25[12]; -TH1F* localCov34[12]; -TH1F* localCov35[12]; -TH1F* localCov45[12]; -TH1I* fitResHisto; -TH1I* ndfHisto; -TH1F* chi2OndfHisto; -TH1F* pValueHisto; -TH1I* stats; - - - -bool writeHistoDataForLabel(double label, TVectorD res, TVectorD measErr, TVectorD resErr, TVectorD downWeights, TVectorD localPar, TMatrixDSym localCov) -{ - if (label < 1.) return false; - - unsigned int id = floor(label); - // skip segment (5 bits) - id = id >> 5; - unsigned int sensor = id & 7; - id = id >> 3; - unsigned int ladder = id & 31; - id = id >> 5; - unsigned int layer = id & 7; - if (layer == 7 && ladder == 2) { - label = sensor; - } else if (layer == 7 && ladder == 3) { - label = sensor + 9 - 3; - } else { - label = layer + 3; - } - - if (label > 12.) return false; - - int i = int(label); - - #ifdef OUTPUT - resHistosU[i - 1]->Fill(res[0]); - resHistosV[i - 1]->Fill(res[1]); - mhistosU[i - 1]->Fill(res[0] / measErr[0]); - mhistosV[i - 1]->Fill(res[1] / measErr[1]); - ghistosU[i - 1]->Fill(res[0] / resErr[0]); - ghistosV[i - 1]->Fill(res[1] / resErr[1]); - downWeightsHistosU[i - 1]->Fill(downWeights[0]); - downWeightsHistosV[i - 1]->Fill(downWeights[1]); - localPar1[i - 1]->Fill(localPar(0)); - localPar2[i - 1]->Fill(localPar(1)); - localPar3[i - 1]->Fill(localPar(2)); - localPar4[i - 1]->Fill(localPar(3)); - localPar5[i - 1]->Fill(localPar(4)); - #endif - - - return true; -} -#endif - -// Millepede Binary File for output of GBL trajectories for alignment -gbl::MilleBinary* milleFile; -// Minimum scattering sigma (will be squared and inverted...) -const double scatEpsilon = 1.e-8; - - -using namespace gbl; -using namespace std; -using namespace genfit; - -GFGbl::GFGbl() : -AbsFitter(), m_milleFileName("millefile.dat"), m_gblInternalIterations("THC"), m_pValueCut(0.), m_minNdf(1), -m_chi2Cut(0.), -m_enableScatterers(true), -m_enableIntermediateScatterer(true) -{ - -} - -void GFGbl::beginRun() -{ - milleFile = new MilleBinary(m_milleFileName); - - #ifdef OUTPUT - diag = new TFile(rootFileName.c_str(), "RECREATE"); - char name[20]; - - for (int i = 0; i < 12; i++) { - sprintf(name, "res_u_%i", i + 1); - resHistosU[i] = new TH1F(name, "Residual (U)", 1000, -0.1, 0.1); - sprintf(name, "res_v_%i", i + 1); - resHistosV[i] = new TH1F(name, "Residual (V)", 1000, -0.1, 0.1); - sprintf(name, "meas_pull_u_%i", i + 1); - mhistosU[i] = new TH1F(name, "Res/Meas.Err. (U)", 1000, -20., 20.); - sprintf(name, "meas_pull_v_%i", i + 1); - mhistosV[i] = new TH1F(name, "Res/Meas.Err. (V)", 1000, -20., 20.); - sprintf(name, "pull_u_%i", i + 1); - ghistosU[i] = new TH1F(name, "Res/Res.Err. (U)", 1000, -20., 20.); - sprintf(name, "pull_v_%i", i + 1); - ghistosV[i] = new TH1F(name, "Res/Res.Err. (V)", 1000, -20., 20.); - sprintf(name, "downWeights_u_%i", i + 1); - downWeightsHistosU[i] = new TH1F(name, "Down-weights (U)", 1000, 0., 1.); - sprintf(name, "downWeights_v_%i", i + 1); - downWeightsHistosV[i] = new TH1F(name, "Down-weights (V)", 1000, 0., 1.); - sprintf(name, "localPar1_%i", i + 1); - - localPar1[i] = new TH1F(name, "Residual (U)", 1000, -0.1, 0.1); - sprintf(name, "localPar2_%i", i + 1); - localPar2[i] = new TH1F(name, "Residual (U)", 1000, -0.1, 0.1); - sprintf(name, "localPar3_%i", i + 1); - localPar3[i] = new TH1F(name, "Residual (U)", 1000, -0.1, 0.1); - sprintf(name, "localPar4_%i", i + 1); - localPar4[i] = new TH1F(name, "Residual (U)", 1000, -0.1, 0.1); - sprintf(name, "localPar5_%i", i + 1); - localPar5[i] = new TH1F(name, "Residual (U)", 1000, -0.1, 0.1); - } - fitResHisto = new TH1I("fit_result", "GBL Fit Result", 21, -1, 20); - ndfHisto = new TH1I("ndf", "GBL Track NDF", 41, -1, 40); - chi2OndfHisto = new TH1F("chi2_ndf", "Track Chi2/NDF", 100, 0., 10.); - pValueHisto = new TH1F("p_value", "Track P-value", 100, 0., 1.); - - stats = new TH1I("stats", "0: NDF>0 | 1: fTel&VXD | 2: all | 3: VXD | 4: SVD | 5: all - PXD | 6: fTel&SVD | 7: bTel", 10, 0, 10); - - #endif -} - -void GFGbl::endRun() -{ - #ifdef OUTPUT - diag->cd(); - diag->Write(); - diag->Close(); - #endif - // This is needed to close the file before alignment starts - delete milleFile; -} - -/** - * @brief Evaluates moments of radiation length distribution from list of - * material steps and computes parameters describing a corresponding thick scatterer. - * - * Based on input from Claus Kleinwort (DESY), - * adapted for continuous material distribution represented by - * a sum of step functions. Returned thick scatterer can be represented by two GBL scattering points - * at (s - ds) and (s + ds) with variance of theta equal to theta/sqrt(2) for both points. - * Calculates variance of theta from total sum of radiation lengths - * instead of summimg squares of individual deflection angle variances. - * - * @param length returned: Length of the track - * @param theta returned: Variation of distribution of deflection angle - * @param s returned: First moment of material scattering distribution - * @param ds returned: Second moment (variance) of material scattering distribution - * @param p Particle momentum magnitude (GeV/c) - * @param mass Mass of particle (GeV/c/c) - * @param steps Vector of material steps from (RKTrackRep) extrapolation - * @return void - */ -void getScattererFromMatList(double& length, double& theta, double& s, double& ds, const double p, const double mass, const double charge, const std::vector& steps) -{ - theta = 0.; s = 0.; ds = 0.; - if (steps.empty()) return; - - // sum of step lengths - double len = 0.; - // normalization - double sumxx = 0.; - // first moment (non-normalized) - double sumx2x2 = 0.; - // (part of) second moment / variance (non-normalized) - double sumx3x3 = 0.; - - double xmin = 0.; - double xmax = 0.; - - for (unsigned int i = 0; i < steps.size(); i++) { - const MatStep step = steps.at(i); - // inverse of material radiation length ... (in 1/cm) ... "density of scattering" - double rho = 1. / step.materialProperties_.getRadLen(); - len += fabs(step.stepSize_); - xmin = xmax; - xmax = xmin + fabs(step.stepSize_); - // Compute integrals - - // integral of rho(x) - sumxx += rho * (xmax - xmin); - // integral of x*rho(x) - sumx2x2 += rho * (xmax * xmax - xmin * xmin) / 2.; - // integral of x*x*rho(x) - sumx3x3 += rho * (xmax * xmax * xmax - xmin * xmin * xmin) / 3.; - } - // This ensures PDG formula still gives positive results (but sumxx should be > 1e-4 for it to hold) - if (sumxx < 1.0e-10) return; - // Calculate theta from total sum of radiation length - // instead of summimg squares of individual deflection angle variances - // PDG formula: - double beta = p / sqrt(p * p + mass * mass); - theta = (0.0136 / p / beta) * fabs(charge) * sqrt(sumxx) * (1. + 0.038 * log(sumxx)); - //theta = (0.015 / p / beta) * fabs(charge) * sqrt(sumxx); - - // track length - length = len; - // Normalization factor - double N = 1. / sumxx; - // First moment - s = N * sumx2x2; - // Square of second moment (variance) - // integral of (x - s)*(x - s)*rho(x) - double ds_2 = N * (sumx3x3 - 2. * sumx2x2 * s + sumxx * s * s); - ds = sqrt(ds_2); - - #ifdef DEBUG - //cout << "Thick scatterer parameters:" << endl; - //cout << "Variance of theta: " << theta << endl; - //cout << "Mean s : " << s << endl; - //cout << "Variance of s : " << ds << endl; - - #endif -} - - -void GFGbl::processTrackWithRep(Track* trk, const AbsTrackRep* rep, bool resortHits) -{ - // Flag used to mark error in raw measurement combination - // measurement won't be considered, but scattering yes - bool skipMeasurement = false; - // Chi2 of Reference Track - double trkChi2 = 0.; - // This flag enables/disables fitting of q/p parameter in GBL - // It is switched off automatically if no B-field at (0,0,0) is detected. - bool fitQoverP = true; - //TODO: Use clever way to determine zero B-field - double Bfield = genfit::FieldManager::getInstance()->getFieldVal(TVector3(0., 0., 0.)).Mag(); - if (!(Bfield > 0.)) - fitQoverP = false; - - // Dimesion of repository/state - int dim = rep->getDim(); - // current measurement point - TrackPoint* point_meas; - // current raw measurement - AbsMeasurement* raw_meas; - - // We assume no initial kinks, this will be reused several times - TVectorD scatResidual(2); - scatResidual.Zero(); - - // All measurement points in ref. track - int npoints_meas = trk->getNumPointsWithMeasurement(); - - #ifdef DEBUG - int npoints_all = trk->getNumPoints(); - - if (resortHits) - cout << "WARNING: Hits resorting in GBL interface not supported." << endl; - - cout << "-------------------------------------------------------" << endl; - cout << " GBL processing genfit::Track " << endl; - cout << "-------------------------------------------------------" << endl; - cout << " # Ref. Track Points : " << npoints_all << endl; - cout << " # Meas. Points : " << npoints_meas << endl; - - #endif - // List of prepared GBL points for GBL trajectory construction - std::vector listOfPoints; - - std::vector listOfLayers; - //TODO: Add internal/external seed (from CDC) option in the future - // index of point with seed information (0 for none) - unsigned int seedLabel = 0; - // Seed covariance - // TMatrixDSym clCov(dim); - // Seed state - TMatrixDSym clSeed(dim); - - // propagation Jacobian to next point from current measurement point - TMatrixD jacPointToPoint(dim, dim); - jacPointToPoint.UnitMatrix(); - - int n_gbl_points = 0; - int n_gbl_meas_points = 0; - int Ndf = 0; - double Chi2 = 0.; - double lostWeight = 0.; - - // Momentum of track at current plane - double trackMomMag = 0.; - // Charge of particle at current plane :-) - double particleCharge = 1.; - - for (int ipoint_meas = 0; ipoint_meas < npoints_meas; ipoint_meas++) { - point_meas = trk->getPointWithMeasurement(ipoint_meas); - - if (!point_meas->hasFitterInfo(rep)) { - cout << " ERROR: Measurement point does not have a fitter info. Track will be skipped." << endl; - return; - } - // Fitter info which contains Reference state and plane - KalmanFitterInfo* fi = dynamic_cast(point_meas->getFitterInfo(rep)); - if (!fi) { - cout << " ERROR: KalmanFitterInfo (with reference state) for measurement does not exist. Track will be skipped." << endl; - return; - } - // Current detector plane - SharedPlanePtr plane = fi->getPlane(); - if (!fi->hasReferenceState()) { - cout << " ERROR: Fitter info does not contain reference state. Track will be skipped." << endl; - return; - } - // Reference StateOnPlane for extrapolation - ReferenceStateOnPlane* reference = new ReferenceStateOnPlane(*fi->getReferenceState());//(dynamic_cast(*fi->getReferenceState())); - // Representation state at plane - TVectorD state = reference->getState(); - // track direction at plane (in global coords) - TVector3 trackDir = rep->getDir(*reference); - // track momentum vector at plane (in global coords) - trackMomMag = rep->getMomMag(*reference); - // charge of particle - particleCharge = rep->getCharge(*reference); - // mass of particle - double particleMass = rep->getMass(*reference); - - // Parameters of a thick scatterer between measurements - double trackLen = 0.; - double scatTheta = 0.; - double scatSMean = 0.; - double scatDeltaS = 0.; - // Parameters of two equivalent thin scatterers - double theta1 = 0.; - double theta2 = 0.; - double s1 = 0.; - double s2 = 0.; - - TMatrixDSym noise; - TVectorD deltaState; - // jacobian from s2 to M2 - TMatrixD jacMeas2Scat(dim, dim); - jacMeas2Scat.UnitMatrix(); - - - // Now get measurement. First have a look if we need to combine SVD clusters... - // Load Jacobian from previous extrapolation - // rep->getForwardJacobianAndNoise(jacPointToPoint, noise, deltaState); - // Try to get VxdId of current plane - int sensorId = 0; - PlanarMeasurement* measPlanar = dynamic_cast(point_meas->getRawMeasurement(0)); - if (measPlanar) sensorId = measPlanar->getPlaneId(); - - //WARNING: Now we only support 2D measurements. If 2 raw measurements are stored at the track - // point, these are checked if they correspond to "u" and "v" measurement (for SVD clusters) and these - // measurements are combined. SLANTED SENSORS NOT YET SUPPORTED!!! - if (point_meas->getRawMeasurement(0)->getDim() != 2 - && trk->getPointWithMeasurement(ipoint_meas)->getNumRawMeasurements() == 2 - && point_meas->getRawMeasurement(0)->getDim() == 1 - && point_meas->getRawMeasurement(1)->getDim() == 1) { - AbsMeasurement* raw_measU = 0; - AbsMeasurement* raw_measV = 0; - - // cout << " Two 1D Measurements encountered. " << endl; - - int sensorId2 = -1; - PlanarMeasurement* measPlanar2 = dynamic_cast(point_meas->getRawMeasurement(0)); - if (measPlanar2) sensorId2 = measPlanar->getPlaneId(); - - // We only try to combine if at same sensor id (should be always, but who knows) - // otherwise ignore this point - if (sensorId != sensorId2) { - skipMeasurement = true; - cout << " ERROR: Incompatible sensorIDs at measurement point " << ipoint_meas << ". Measurement will be skipped." << endl; - } - - // We have to combine two SVD 1D Clusters at the same plane into one 2D recohit - AbsMeasurement* raw_meas1 = point_meas->getRawMeasurement(0); - AbsMeasurement* raw_meas2 = point_meas->getRawMeasurement(1); - // Decide which cluster is u and which v based on H-matrix - if (raw_meas1->constructHMatrix(rep)->isEqual(genfit::HMatrixU()) - && raw_meas2->constructHMatrix(rep)->isEqual(genfit::HMatrixV())) { - // right order U, V - raw_measU = raw_meas1; - raw_measV = raw_meas2; - } else if (raw_meas2->constructHMatrix(rep)->isEqual(genfit::HMatrixU()) - && raw_meas1->constructHMatrix(rep)->isEqual(genfit::HMatrixV())) { - // inversed order V, U - raw_measU = raw_meas2; - raw_measV = raw_meas1; - } else { - // Incompatible measurements ... skip track ... I saw this once and just before a segfault ... - cout << " ERROR: Incompatible 1D measurements at meas. point " << ipoint_meas << ". Track will be skipped." << endl; - return; - } - // Combine raw measurements - TVectorD _raw_coor(2); - _raw_coor(0) = raw_measU->getRawHitCoords()(0); - _raw_coor(1) = raw_measV->getRawHitCoords()(0); - // Combine covariance matrix - TMatrixDSym _raw_cov(2); - _raw_cov.Zero(); - _raw_cov(0, 0) = raw_measU->getRawHitCov()(0, 0); - _raw_cov(1, 1) = raw_measV->getRawHitCov()(0, 0); - // Create new combined measurement - raw_meas = new PlanarMeasurement(_raw_coor, _raw_cov, raw_measU->getDetId(), raw_measU->getHitId(), point_meas); - } else { - // Default behavior - raw_meas = point_meas->getRawMeasurement(0); - } - //TODO: We only support 2D measurements in GBL (ot two 1D combined above) - if (raw_meas->getRawHitCoords().GetNoElements() != 2) { - skipMeasurement = true; - #ifdef DEBUG - cout << " WARNING: Measurement " << (ipoint_meas + 1) << " is not 2D. Measurement Will be skipped. " << endl; - #endif - } - - // Now we have all necessary information, so lets insert current measurement point - // if we don't want to skip it (e.g. ghost SVD hit ... just 1D information) - if (!skipMeasurement) { - // 2D hit coordinates - TVectorD raw_coor = raw_meas->getRawHitCoords(); - // Covariance matrix of measurement - TMatrixDSym raw_cov = raw_meas->getRawHitCov(); - // Projection matrix from repository state to measurement coords - boost::scoped_ptr HitHMatrix(raw_meas->constructHMatrix(rep)); - // Residual between measured position and reference track position - TVectorD residual = -1. * (raw_coor - HitHMatrix->Hv(state)); - - trkChi2 += residual(0) * residual(0) / raw_cov(0, 0) + residual(1) * residual(1) / raw_cov(1, 1); - - // Measurement point - GblPoint measPoint(jacPointToPoint); - // Projection from local (state) coordinates to measurement coordinates (inverted) - // 2x2 matrix ... last block of H matrix (2 rows x 5 columns) - //TMatrixD proL2m = HitHMatrix->getMatrix().GetSub(0, 1, 3, 4); - TMatrixD proL2m(2, 2); - proL2m.Zero(); - proL2m(0, 0) = HitHMatrix->getMatrix()(0, 3); - proL2m(0, 1) = HitHMatrix->getMatrix()(0, 4); - proL2m(1, 1) = HitHMatrix->getMatrix()(1, 4); - proL2m(1, 0) = HitHMatrix->getMatrix()(1, 3); - proL2m.Invert(); - //raw_cov *= 100.; - //proL2m.Print(); - measPoint.addMeasurement(proL2m, residual, raw_cov.Invert()); - - //Add global derivatives to the point - - // sensor label = sensorID * 10, then last digit is label for global derivative for the sensor - int label = sensorId * 10; - // values for global derivatives - //TMatrixD derGlobal(2, 6); - TMatrixD derGlobal(2, 12); - - // labels for global derivatives - std::vector labGlobal; - - // track direction in global coords - TVector3 tDir = trackDir; - // sensor u direction in global coords - TVector3 uDir = plane->getU(); - // sensor v direction in global coords - TVector3 vDir = plane->getV(); - // sensor normal direction in global coords - TVector3 nDir = plane->getNormal(); - //file << sensorId << endl; - //outputVector(uDir, "U"); - //outputVector(vDir, "V"); - //outputVector(nDir, "Normal"); - // track direction in local sensor system - TVector3 tLoc = TVector3(uDir.Dot(tDir), vDir.Dot(tDir), nDir.Dot(tDir)); - - // track u-slope in local sensor system - double uSlope = tLoc[0] / tLoc[2]; - // track v-slope in local sensor system - double vSlope = tLoc[1] / tLoc[2]; - - // Measured track u-position in local sensor system - double uPos = raw_coor[0]; - // Measured track v-position in local sensor system - double vPos = raw_coor[1]; - - //Global derivatives for alignment in sensor local coordinates - derGlobal(0, 0) = 1.0; - derGlobal(0, 1) = 0.0; - derGlobal(0, 2) = - uSlope; - derGlobal(0, 3) = vPos * uSlope; - derGlobal(0, 4) = -uPos * uSlope; - derGlobal(0, 5) = vPos; - - derGlobal(1, 0) = 0.0; - derGlobal(1, 1) = 1.0; - derGlobal(1, 2) = - vSlope; - derGlobal(1, 3) = vPos * vSlope; - derGlobal(1, 4) = -uPos * vSlope; - derGlobal(1, 5) = -uPos; - - labGlobal.push_back(label + 1); // u - labGlobal.push_back(label + 2); // v - labGlobal.push_back(label + 3); // w - labGlobal.push_back(label + 4); // alpha - labGlobal.push_back(label + 5); // beta - labGlobal.push_back(label + 6); // gamma - - - // Global derivatives for movement of whole detector system in global coordinates - //TODO: Usage of this requires Hierarchy Constraints to be provided to MP2 - - // sensor centre position in global system - TVector3 detPos = plane->getO(); - //cout << "detPos" << endl; - //detPos.Print(); - - // global prediction from raw measurement - TVector3 pred = detPos + uPos * uDir + vPos * vDir; - //cout << "pred" << endl; - //pred.Print(); - - double xPred = pred[0]; - double yPred = pred[1]; - double zPred = pred[2]; - - // scalar product of sensor normal and track direction - double tn = tDir.Dot(nDir); - //cout << "tn" << endl; - //cout << tn << endl; - - // derivatives of local residuals versus measurements - TMatrixD drdm(3, 3); - drdm.UnitMatrix(); - for (int row = 0; row < 3; row++) - for (int col = 0; col < 3; col++) - drdm(row, col) -= tDir[row] * nDir[col] / tn; - - //cout << "drdm" << endl; - //drdm.Print(); - - // derivatives of measurements versus global alignment parameters - TMatrixD dmdg(3, 6); - dmdg.Zero(); - dmdg(0, 0) = 1.; dmdg(0, 4) = -zPred; dmdg(0, 5) = yPred; - dmdg(1, 1) = 1.; dmdg(1, 3) = zPred; dmdg(1, 5) = -xPred; - dmdg(2, 2) = 1.; dmdg(2, 3) = -yPred; dmdg(2, 4) = xPred; - - //cout << "dmdg" << endl; - //dmdg.Print(); - - // derivatives of local residuals versus global alignment parameters - TMatrixD drldrg(3, 3); - drldrg.Zero(); - drldrg(0, 0) = uDir[0]; drldrg(0, 1) = uDir[1]; drldrg(0, 2) = uDir[2]; - drldrg(1, 0) = vDir[0]; drldrg(1, 1) = vDir[1]; drldrg(1, 2) = vDir[2]; - - //cout << "drldrg" << endl; - //drldrg.Print(); - - //cout << "drdm * dmdg" << endl; - //(drdm * dmdg).Print(); - - // derivatives of local residuals versus rigid body parameters - TMatrixD drldg(3, 6); - drldg = drldrg * (drdm * dmdg); - - //cout << "drldg" << endl; - //drldg.Print(); - - // offset to determine labels for sensor sets or individual layers - // 0: PXD, TODO 1: SVD, or individual layers - // offset 0 is for alignment of whole setup - int offset = 0; - //if (sensorId > 16704) offset = 20; // svd, but needs to introduce new 6 constraints: sum rot&shifts of pxd&svd = 0 - - derGlobal(0, 6) = drldg(0, 0); labGlobal.push_back(offset + 1); - derGlobal(0, 7) = drldg(0, 1); labGlobal.push_back(offset + 2); - derGlobal(0, 8) = drldg(0, 2); labGlobal.push_back(offset + 3); - derGlobal(0, 9) = drldg(0, 3); labGlobal.push_back(offset + 4); - derGlobal(0, 10) = drldg(0, 4); labGlobal.push_back(offset + 5); - derGlobal(0, 11) = drldg(0, 5); labGlobal.push_back(offset + 6); - - derGlobal(1, 6) = drldg(1, 0); - derGlobal(1, 7) = drldg(1, 1); - derGlobal(1, 8) = drldg(1, 2); - derGlobal(1, 9) = drldg(1, 3); - derGlobal(1, 10) = drldg(1, 4); - derGlobal(1, 11) = drldg(1, 5); - - - - measPoint.addGlobals(labGlobal, derGlobal); - listOfPoints.push_back(measPoint); - listOfLayers.push_back((unsigned int) sensorId); - n_gbl_points++; - n_gbl_meas_points++; - } else { - // Incompatible measurement, store point without measurement - GblPoint dummyPoint(jacPointToPoint); - listOfPoints.push_back(dummyPoint); - listOfLayers.push_back((unsigned int) sensorId); - n_gbl_points++; - skipMeasurement = false; - #ifdef DEBUG - cout << " Dummy point inserted. " << endl; - #endif - } - - - //cout << " Starting extrapolation..." << endl; - try { - - // Extrapolate to next measurement to get material distribution - if (ipoint_meas < npoints_meas - 1) { - // Check if fitter info is in place - if (!trk->getPoint(ipoint_meas + 1)->hasFitterInfo(rep)) { - cout << " ERROR: Measurement point does not have a fitter info. Track will be skipped." << endl; - return; - } - // Fitter of next point info which is only used now to get the plane - KalmanFitterInfo* fi_i_plus_1 = dynamic_cast(trk->getPoint(ipoint_meas + 1)->getFitterInfo(rep)); - if (!fi_i_plus_1) { - cout << " ERROR: KalmanFitterInfo (with reference state) for measurement does not exist. Track will be skipped." << endl; - return; - } - StateOnPlane refCopy(*reference); - // Extrap to point + 1, do NOT stop at boundary - rep->extrapolateToPlane(refCopy, trk->getPoint(ipoint_meas + 1)->getFitterInfo(rep)->getPlane(), false, false); - getScattererFromMatList(trackLen, - scatTheta, - scatSMean, - scatDeltaS, - trackMomMag, - particleMass, - particleCharge, - rep->getSteps()); - // Now calculate positions and scattering variance for equivalent scatterers - // (Solution from Claus Kleinwort (DESY)) - s1 = 0.; - s2 = scatSMean + scatDeltaS * scatDeltaS / (scatSMean - s1); - theta1 = sqrt(scatTheta * scatTheta * scatDeltaS * scatDeltaS / (scatDeltaS * scatDeltaS + (scatSMean - s1) * (scatSMean - s1))); - theta2 = sqrt(scatTheta * scatTheta * (scatSMean - s1) * (scatSMean - s1) / (scatDeltaS * scatDeltaS + (scatSMean - s1) * (scatSMean - s1))); - - if (m_enableScatterers && !m_enableIntermediateScatterer) { - theta1 = scatTheta; - theta2 = 0; - } else if (!m_enableScatterers) { - theta1 = 0.; - theta2 = 0.; - } - - if (s2 < 1.e-4 || s2 >= trackLen - 1.e-4 || s2 <= 1.e-4) { - cout << " WARNING: GBL points will be too close. GBLTrajectory construction might fail. Let's try it..." << endl; - } - - } - // Return back to state on current plane - delete reference; - reference = new ReferenceStateOnPlane(*fi->getReferenceState()); - - // If not last measurement, extrapolate and get jacobians for scattering points between this and next measurement - if (ipoint_meas < npoints_meas - 1) { - if (theta2 > scatEpsilon) { - // First scatterer will be placed at current measurement point (see bellow) - - // theta2 > 0 ... we want second scatterer: - // Extrapolate to s2 (remember we have s1 = 0) - rep->extrapolateBy(*reference, s2, false, true); - rep->getForwardJacobianAndNoise(jacMeas2Scat, noise, deltaState); - // Finish extrapolation to next measurement - double nextStep = rep->extrapolateToPlane(*reference, trk->getPoint(ipoint_meas + 1)->getFitterInfo(rep)->getPlane(), false, true); - if (0. > nextStep) { - cout << " ERROR: The extrapolation to measurement point " << (ipoint_meas + 2) << " stepped back by " << nextStep << "cm !!! Track will be skipped." << endl; - return; - } - rep->getForwardJacobianAndNoise(jacPointToPoint, noise, deltaState); - - } else { - // No scattering: extrapolate whole distance between measurements - rep->extrapolateToPlane(*reference, trk->getPoint(ipoint_meas + 1)->getFitterInfo(rep)->getPlane(), false, true); - //NOTE: we will load the jacobian from this extrapolation in next loop into measurement point - //jacPointToPoint.Print(); - rep->getForwardJacobianAndNoise(jacPointToPoint, noise, deltaState); - //jacPointToPoint.Print(); - } - } - } catch (...) { - cout << " ERROR: Extrapolation failed. Track will be skipped." << endl; - return; - } - //cout << " Extrapolation finished." << endl; - - - // Now store scatterers if not last measurement and if we decided - // there should be scatteres, otherwise the jacobian in measurement - // stored above is already correct - if (ipoint_meas < npoints_meas - 1) { - - if (theta1 > scatEpsilon) { - // We have to insert first scatterer at measurement point - // Therefore (because state is perpendicular to plane, NOT track) - // we have non-diaonal matrix of multiple scattering covariance - // We have to project scattering into plane coordinates - double c1 = trackDir.Dot(plane->getU()); - double c2 = trackDir.Dot(plane->getV()); - TMatrixDSym scatCov(2); - scatCov(0, 0) = 1. - c2 * c2; - scatCov(1, 1) = 1. - c1 * c1; - scatCov(0, 1) = c1 * c2; - scatCov(1, 0) = c1 * c2; - scatCov *= theta1 * theta1 / (1. - c1 * c1 - c2 * c2) / (1. - c1 * c1 - c2 * c2) ; - - // last point is the just inserted measurement (or dummy point) - GblPoint& lastPoint = listOfPoints.at(n_gbl_points - 1); - lastPoint.addScatterer(scatResidual, scatCov.Invert()); - - } - - if (theta2 > scatEpsilon) { - // second scatterer is somewhere between measurements - // TrackRep state is perpendicular to track direction if using extrapolateBy (I asked Johannes Rauch), - // therefore scattering covariance is diagonal (and both elements are equal) - TMatrixDSym scatCov(2); - scatCov.Zero(); - scatCov(0, 0) = theta2 * theta2; - scatCov(1, 1) = theta2 * theta2; - - GblPoint scatPoint(jacMeas2Scat); - scatPoint.addScatterer(scatResidual, scatCov.Invert()); - listOfPoints.push_back(scatPoint); - listOfLayers.push_back(((unsigned int) sensorId) + 0.5); - n_gbl_points++; - } - - - } - // Free memory on the heap - delete reference; - } - // We should have at least two measurement points to fit anything - if (n_gbl_meas_points > 1) { - int fitRes = -1; - double pvalue = 0.; - GblTrajectory* traj = 0; - try { - // Construct the GBL trajectory, seed not used - traj = new GblTrajectory(listOfPoints, seedLabel, clSeed, fitQoverP); - // Fit the trajectory - fitRes = traj->fit(Chi2, Ndf, lostWeight, m_gblInternalIterations); - if (fitRes != 0) { - //#ifdef DEBUG - //traj->printTrajectory(100); - //traj->printData(); - //traj->printPoints(100); - //#endif - } - } catch (...) { - // Gbl failed critically (usually GblPoint::getDerivatives ... singular matrix inversion) - return; - } - - pvalue = TMath::Prob(Chi2, Ndf); - - //traj->printTrajectory(100); - //traj->printData(); - //traj->printPoints(100); - - #ifdef OUTPUT - // Fill histogram with fit result - fitResHisto->Fill(fitRes); - ndfHisto->Fill(Ndf); - #endif - - #ifdef DEBUG - cout << " Ref. Track Chi2 : " << trkChi2 << endl; - cout << " Ref. end momentum : " << trackMomMag << " GeV/c "; - if (abs(trk->getCardinalRep()->getPDG()) == 11) { - if (particleCharge < 0.) - cout << "(electron)"; - else - cout << "(positron)"; - } - cout << endl; - cout << "------------------ GBL Fit Results --------------------" << endl; - cout << " Fit q/p parameter : " << ((fitQoverP) ? ("True") : ("False")) << endl; - cout << " Valid trajectory : " << ((traj->isValid()) ? ("True") : ("False")) << endl; - cout << " Fit result : " << fitRes << " (0 for success)" << endl; - cout << " # GBL meas. points : " << n_gbl_meas_points << endl; - cout << " # GBL all points : " << n_gbl_points << endl; - cout << " GBL track NDF : " << Ndf << " (-1 for failure)" << endl; - cout << " GBL track Chi2 : " << Chi2 << endl; - cout << " GBL track P-value : " << pvalue; - if (pvalue < m_pValueCut) - cout << " < p-value cut " << m_pValueCut; - cout << endl; - cout << "-------------------------------------------------------" << endl; - #endif - - #ifdef OUTPUT - bool hittedLayers[12]; - for (int hl = 0; hl < 12; hl++) { - hittedLayers[hl] = false; - } - #endif - - // GBL fit succeded if Ndf >= 0, but Ndf = 0 is useless - //TODO: Here should be some track quality check - // if (Ndf > 0 && fitRes == 0) { - if (traj->isValid() && pvalue >= m_pValueCut && Ndf >= m_minNdf) { - - // In case someone forgot to use beginRun and dind't reset mille file name to "" - if (!milleFile && m_milleFileName != "") - milleFile = new MilleBinary(m_milleFileName); - - // Loop over all GBL points - for (unsigned int p = 0; p < listOfPoints.size(); p++) { - unsigned int label = p + 1; - unsigned int numRes; - TVectorD residuals(2); - TVectorD measErrors(2); - TVectorD resErrors(2); - TVectorD downWeights(2); - //TODO: now we only provide info about measurements, not kinks - if (!listOfPoints.at(p).hasMeasurement()) - continue; - - #ifdef OUTPUT - // Decode VxdId and get layer in TB setup - unsigned int l = 0; - unsigned int id = listOfLayers.at(p); - // skip segment (5 bits) - id = id >> 5; - unsigned int sensor = id & 7; - id = id >> 3; - unsigned int ladder = id & 31; - id = id >> 5; - unsigned int layer = id & 7; - - if (layer == 7 && ladder == 2) { - l = sensor; - } else if (layer == 7 && ladder == 3) { - l = sensor + 9 - 3; - } else { - l = layer + 3; - } - - hittedLayers[l - 1] = true; - #endif - TVectorD localPar(5); - TMatrixDSym localCov(5); - traj->getResults(label, localPar, localCov); - // Get GBL fit results - traj->getMeasResults(label, numRes, residuals, measErrors, resErrors, downWeights); - if (m_chi2Cut && (fabs(residuals[0] / resErrors[0]) > m_chi2Cut || fabs(residuals[1] / resErrors[1]) > m_chi2Cut)) - return; - // Write layer-wise data - #ifdef OUTPUT - if (!writeHistoDataForLabel(listOfLayers.at(p), residuals, measErrors, resErrors, downWeights, localPar, localCov)) - return; - #endif - - } // end for points - - // Write binary data to mille binary - if (milleFile && m_milleFileName != "" && pvalue >= m_pValueCut && Ndf >= m_minNdf) { - traj->milleOut(*milleFile); - #ifdef DEBUG - cout << " GBL Track written to Millepede II binary file." << endl; - cout << "-------------------------------------------------------" << endl; - #endif - } - - #ifdef OUTPUT - // Fill histograms - chi2OndfHisto->Fill(Chi2 / Ndf); - pValueHisto->Fill(TMath::Prob(Chi2, Ndf)); - // track counting - stats->Fill(0); - // hitted sensors statistics - if ( - hittedLayers[0] && - hittedLayers[1] && - hittedLayers[2] && - hittedLayers[3] && - hittedLayers[4] && - hittedLayers[5] && - hittedLayers[6] && - hittedLayers[7] && - hittedLayers[8] - ) { - // front tel + pxd + svd - stats->Fill(1); - } - - if ( - hittedLayers[0] && - hittedLayers[1] && - hittedLayers[2] && - hittedLayers[3] && - hittedLayers[4] && - hittedLayers[5] && - hittedLayers[6] && - hittedLayers[7] && - hittedLayers[8] && - hittedLayers[9] && - hittedLayers[10] && - hittedLayers[11] - ) { - // all layers - stats->Fill(2); - } - if ( - hittedLayers[3] && - hittedLayers[4] && - hittedLayers[5] && - hittedLayers[6] && - hittedLayers[7] && - hittedLayers[8] - ) { - // vxd - stats->Fill(3); - } - if ( - hittedLayers[5] && - hittedLayers[6] && - hittedLayers[7] && - hittedLayers[8] - ) { - // svd - stats->Fill(4); - } - if ( - hittedLayers[0] && - hittedLayers[1] && - hittedLayers[2] && - - hittedLayers[5] && - hittedLayers[6] && - hittedLayers[7] && - hittedLayers[8] && - hittedLayers[9] && - hittedLayers[10] && - hittedLayers[11] - ) { - // all except pxd - stats->Fill(5); - } - if ( - hittedLayers[0] && - hittedLayers[1] && - hittedLayers[2] && - - hittedLayers[5] && - hittedLayers[6] && - hittedLayers[7] && - hittedLayers[8] - ) { - // front tel + svd - stats->Fill(6); - } - if ( - hittedLayers[9] && - hittedLayers[10] && - hittedLayers[11] - ) { - // backward tel - stats->Fill(7); - } - #endif - } - - // Free memory - delete traj; - } -} - diff --git a/genfit/GBL/src/GblData.cc b/genfit/GBL/src/GblData.cc deleted file mode 100644 index 38e48c8167..0000000000 --- a/genfit/GBL/src/GblData.cc +++ /dev/null @@ -1,248 +0,0 @@ -/* - * GblData.cpp - * - * Created on: Aug 18, 2011 - * Author: kleinwrt - */ - -#include "GblData.h" - -//! Namespace for the general broken lines package -namespace gbl { - -/// Create data block. -/** - * \param [in] aLabel Label of corresponding point - * \param [in] aValue Value of (scalar) measurement - * \param [in] aPrec Precision of (scalar) measurement - */ -GblData::GblData(unsigned int aLabel, double aValue, double aPrec) : - theLabel(aLabel), theValue(aValue), thePrecision(aPrec), theDownWeight( - 1.), thePrediction(0.), theParameters(), theDerivatives(), globalLabels(), globalDerivatives() { - -} - -GblData::~GblData() { -} - -/// Add derivatives from measurement. -/** - * Add (non-zero) derivatives to data block. Fill list of labels of used fit parameters. - * \param [in] iRow Row index (0-4) in up to 5D measurement - * \param [in] labDer Labels for derivatives - * \param [in] matDer Derivatives (matrix) 'measurement vs track fit parameters' - * \param [in] iOff Offset for row index for additional parameters - * \param [in] derLocal Derivatives (matrix) for additional local parameters - * \param [in] labGlobal Labels for additional global (MP-II) parameters - * \param [in] derGlobal Derivatives (matrix) for additional global (MP-II) parameters - * \param [in] extOff Offset for external parameters - * \param [in] extDer Derivatives for external Parameters - */ -void GblData::addDerivatives(unsigned int iRow, - const std::vector &labDer, const SMatrix55 &matDer, - unsigned int iOff, const TMatrixD &derLocal, - const std::vector &labGlobal, const TMatrixD &derGlobal, - unsigned int extOff, const TMatrixD &extDer) { - - unsigned int nParMax = 5 + derLocal.GetNcols() + extDer.GetNcols(); - theParameters.reserve(nParMax); // have to be sorted - theDerivatives.reserve(nParMax); - - for (int i = 0; i < derLocal.GetNcols(); ++i) // local derivatives - { - if (derLocal(iRow - iOff, i)) { - theParameters.push_back(i + 1); - theDerivatives.push_back(derLocal(iRow - iOff, i)); - } - } - - for (int i = 0; i < extDer.GetNcols(); ++i) // external derivatives - { - if (extDer(iRow - iOff, i)) { - theParameters.push_back(extOff + i + 1); - theDerivatives.push_back(extDer(iRow - iOff, i)); - } - } - - for (unsigned int i = 0; i < 5; ++i) // curvature, offset derivatives - { - if (labDer[i] and matDer(iRow, i)) { - theParameters.push_back(labDer[i]); - theDerivatives.push_back(matDer(iRow, i)); - } - } - - globalLabels = labGlobal; - for (int i = 0; i < derGlobal.GetNcols(); ++i) // global derivatives - globalDerivatives.push_back(derGlobal(iRow - iOff, i)); -} - -/// Add derivatives from kink. -/** - * Add (non-zero) derivatives to data block. Fill list of labels of used fit parameters. - * \param [in] iRow Row index (0-1) in 2D kink - * \param [in] labDer Labels for derivatives - * \param [in] matDer Derivatives (matrix) 'kink vs track fit parameters' - * \param [in] extOff Offset for external parameters - * \param [in] extDer Derivatives for external Parameters - */ -void GblData::addDerivatives(unsigned int iRow, - const std::vector &labDer, const SMatrix27 &matDer, - unsigned int extOff, const TMatrixD &extDer) { - - unsigned int nParMax = 7 + extDer.GetNcols(); - theParameters.reserve(nParMax); // have to be sorted - theDerivatives.reserve(nParMax); - - for (int i = 0; i < extDer.GetNcols(); ++i) // external derivatives - { - if (extDer(iRow, i)) { - theParameters.push_back(extOff + i + 1); - theDerivatives.push_back(extDer(iRow, i)); - } - } - - for (unsigned int i = 0; i < 7; ++i) // curvature, offset derivatives - { - if (labDer[i] and matDer(iRow, i)) { - theParameters.push_back(labDer[i]); - theDerivatives.push_back(matDer(iRow, i)); - } - } -} - -/// Add derivatives from external seed. -/** - * Add (non-zero) derivatives to data block. Fill list of labels of used fit parameters. - * \param [in] index Labels for derivatives - * \param [in] derivatives Derivatives (vector) - */ -void GblData::addDerivatives(const std::vector &index, - const std::vector &derivatives) { - for (unsigned int i = 0; i < derivatives.size(); ++i) // any derivatives - { - if (derivatives[i]) { - theParameters.push_back(index[i]); - theDerivatives.push_back(derivatives[i]); - } - } -} - -/// Calculate prediction for data from fit (by GblTrajectory::fit). -void GblData::setPrediction(const VVector &aVector) { - - thePrediction = 0.; - for (unsigned int i = 0; i < theDerivatives.size(); ++i) { - thePrediction += theDerivatives[i] * aVector(theParameters[i] - 1); - } -} - -/// Outlier down weighting with M-estimators (by GblTrajectory::fit). -/** - * \param [in] aMethod M-estimator (1: Tukey, 2:Huber, 3:Cauchy) - */ -double GblData::setDownWeighting(unsigned int aMethod) { - - double aWeight = 1.; - double scaledResidual = fabs(theValue - thePrediction) * sqrt(thePrecision); - if (aMethod == 1) // Tukey - { - if (scaledResidual < 4.6851) { - aWeight = (1.0 - 0.045558 * scaledResidual * scaledResidual); - aWeight *= aWeight; - } else { - aWeight = 0.; - } - } else if (aMethod == 2) //Huber - { - if (scaledResidual >= 1.345) { - aWeight = 1.345 / scaledResidual; - } - } else if (aMethod == 3) //Cauchy - { - aWeight = 1.0 / (1.0 + (scaledResidual * scaledResidual / 5.6877)); - } - theDownWeight = aWeight; - return aWeight; -} - -/// Calculate Chi2 contribution. -/** - * \return (down-weighted) Chi2 - */ -double GblData::getChi2() const { - double aDiff = theValue - thePrediction; - return aDiff * aDiff * thePrecision * theDownWeight; -} - -/// Print data block. -void GblData::printData() const { - - std::cout << " measurement at label " << theLabel << ": " << theValue - << ", " << thePrecision << std::endl; - std::cout << " param " << theParameters.size() << ":"; - for (unsigned int i = 0; i < theParameters.size(); ++i) { - std::cout << " " << theParameters[i]; - } - std::cout << std::endl; - std::cout << " deriv " << theDerivatives.size() << ":"; - for (unsigned int i = 0; i < theDerivatives.size(); ++i) { - std::cout << " " << theDerivatives[i]; - } - std::cout << std::endl; -} - -/// Get Data for local fit. -/** - * \param [out] aValue Value - * \param [out] aWeight Weight - * \param [out] indLocal List of labels of used (local) fit parameters - * \param [out] derLocal List of derivatives for used (local) fit parameters - */ -void GblData::getLocalData(double &aValue, double &aWeight, - std::vector* &indLocal, std::vector* &derLocal) { - - aValue = theValue; - aWeight = thePrecision * theDownWeight; - indLocal = &theParameters; - derLocal = &theDerivatives; -} - -/// Get all Data for MP-II binary record. -/** - * \param [out] aValue Value - * \param [out] aErr Error - * \param [out] indLocal List of labels of local parameters - * \param [out] derLocal List of derivatives for local parameters - * \param [out] labGlobal List of labels of global parameters - * \param [out] derGlobal List of derivatives for global parameters - */ -void GblData::getAllData(double &aValue, double &aErr, - std::vector* &indLocal, std::vector* &derLocal, - std::vector* &labGlobal, std::vector* &derGlobal) { - aValue = theValue; - aErr = 1.0 / sqrt(thePrecision); - indLocal = &theParameters; - derLocal = &theDerivatives; - labGlobal = &globalLabels; - derGlobal = &globalDerivatives; -} - -/// Get data for residual (and errors). -/** - * \param [out] aResidual Measurement-Prediction - * \param [out] aVariance Variance (of measurement) - * \param [out] aDownWeight Down-weighting factor - * \param [out] indLocal List of labels of used (local) fit parameters - * \param [out] derLocal List of derivatives for used (local) fit parameters - */ -void GblData::getResidual(double &aResidual, double &aVariance, - double &aDownWeight, std::vector* &indLocal, - std::vector* &derLocal) { - aResidual = theValue - thePrediction; - aVariance = 1.0 / thePrecision; - aDownWeight = theDownWeight; - indLocal = &theParameters; - derLocal = &theDerivatives; -} -} diff --git a/genfit/GBL/src/GblPoint.cc b/genfit/GBL/src/GblPoint.cc deleted file mode 100644 index 17aab04028..0000000000 --- a/genfit/GBL/src/GblPoint.cc +++ /dev/null @@ -1,489 +0,0 @@ -/* - * GblPoint.cpp - * - * Created on: Aug 18, 2011 - * Author: kleinwrt - */ - -#include "GblPoint.h" - -//! Namespace for the general broken lines package -namespace gbl { - -/// Create a point. -/** - * Create point on (initial) trajectory. Needs transformation jacobian from previous point. - * \param [in] aJacobian Transformation jacobian from previous point - */ -GblPoint::GblPoint(const TMatrixD &aJacobian) : - theLabel(0), theOffset(0), measDim(0), transFlag(false), measTransformation(), scatFlag( - false), localDerivatives(), globalLabels(), globalDerivatives() { - - for (unsigned int i = 0; i < 5; ++i) { - for (unsigned int j = 0; j < 5; ++j) { - p2pJacobian(i, j) = aJacobian(i, j); - } - } -} - -GblPoint::GblPoint(const SMatrix55 &aJacobian) : - theLabel(0), theOffset(0), p2pJacobian(aJacobian), measDim(0), transFlag( - false), measTransformation(), scatFlag(false), localDerivatives(), globalLabels(), globalDerivatives() { - -} - -GblPoint::~GblPoint() { -} - -/// Add a measurement to a point. -/** - * Add measurement (in meas. system) with diagonal precision (inverse covariance) matrix. - * ((up to) 2D: position, 4D: slope+position, 5D: curvature+slope+position) - * \param [in] aProjection Projection from local to measurement system - * \param [in] aResiduals Measurement residuals - * \param [in] aPrecision Measurement precision (diagonal) - * \param [in] minPrecision Minimal precision to accept measurement - */ -void GblPoint::addMeasurement(const TMatrixD &aProjection, - const TVectorD &aResiduals, const TVectorD &aPrecision, - double minPrecision) { - measDim = aResiduals.GetNrows(); - unsigned int iOff = 5 - measDim; - for (unsigned int i = 0; i < measDim; ++i) { - measResiduals(iOff + i) = aResiduals[i]; - measPrecision(iOff + i) = ( - aPrecision[i] >= minPrecision ? aPrecision[i] : 0.); - for (unsigned int j = 0; j < measDim; ++j) { - measProjection(iOff + i, iOff + j) = aProjection(i, j); - } - } -} - -/// Add a measurement to a point. -/** - * Add measurement (in meas. system) with arbitrary precision (inverse covariance) matrix. - * Will be diagonalized. - * ((up to) 2D: position, 4D: slope+position, 5D: curvature+slope+position) - * \param [in] aProjection Projection from local to measurement system - * \param [in] aResiduals Measurement residuals - * \param [in] aPrecision Measurement precision (matrix) - * \param [in] minPrecision Minimal precision to accept measurement - */ -void GblPoint::addMeasurement(const TMatrixD &aProjection, - const TVectorD &aResiduals, const TMatrixDSym &aPrecision, - double minPrecision) { - measDim = aResiduals.GetNrows(); - TMatrixDSymEigen measEigen(aPrecision); - measTransformation.ResizeTo(measDim, measDim); - measTransformation = measEigen.GetEigenVectors(); - measTransformation.T(); - transFlag = true; - TVectorD transResiduals = measTransformation * aResiduals; - TVectorD transPrecision = measEigen.GetEigenValues(); - TMatrixD transProjection = measTransformation * aProjection; - unsigned int iOff = 5 - measDim; - for (unsigned int i = 0; i < measDim; ++i) { - measResiduals(iOff + i) = transResiduals[i]; - measPrecision(iOff + i) = ( - transPrecision[i] >= minPrecision ? transPrecision[i] : 0.); - for (unsigned int j = 0; j < measDim; ++j) { - measProjection(iOff + i, iOff + j) = transProjection(i, j); - } - } -} - -/// Add a measurement to a point. -/** - * Add measurement in local system with diagonal precision (inverse covariance) matrix. - * ((up to) 2D: position, 4D: slope+position, 5D: curvature+slope+position) - * \param [in] aResiduals Measurement residuals - * \param [in] aPrecision Measurement precision (diagonal) - * \param [in] minPrecision Minimal precision to accept measurement - */ -void GblPoint::addMeasurement(const TVectorD &aResiduals, - const TVectorD &aPrecision, double minPrecision) { - measDim = aResiduals.GetNrows(); - unsigned int iOff = 5 - measDim; - for (unsigned int i = 0; i < measDim; ++i) { - measResiduals(iOff + i) = aResiduals[i]; - measPrecision(iOff + i) = ( - aPrecision[i] >= minPrecision ? aPrecision[i] : 0.); - } - measProjection = ROOT::Math::SMatrixIdentity(); -} - -/// Add a measurement to a point. -/** - * Add measurement in local system with arbitrary precision (inverse covariance) matrix. - * Will be diagonalized. - * ((up to) 2D: position, 4D: slope+position, 5D: curvature+slope+position) - * \param [in] aResiduals Measurement residuals - * \param [in] aPrecision Measurement precision (matrix) - * \param [in] minPrecision Minimal precision to accept measurement - */ -void GblPoint::addMeasurement(const TVectorD &aResiduals, - const TMatrixDSym &aPrecision, double minPrecision) { - measDim = aResiduals.GetNrows(); - TMatrixDSymEigen measEigen(aPrecision); - measTransformation.ResizeTo(measDim, measDim); - measTransformation = measEigen.GetEigenVectors(); - measTransformation.T(); - transFlag = true; - TVectorD transResiduals = measTransformation * aResiduals; - TVectorD transPrecision = measEigen.GetEigenValues(); - unsigned int iOff = 5 - measDim; - for (unsigned int i = 0; i < measDim; ++i) { - measResiduals(iOff + i) = transResiduals[i]; - measPrecision(iOff + i) = ( - transPrecision[i] >= minPrecision ? transPrecision[i] : 0.); - for (unsigned int j = 0; j < measDim; ++j) { - measProjection(iOff + i, iOff + j) = measTransformation(i, j); - } - } -} - -/// Check for measurement at a point. -/** - * Get dimension of measurement (0 = none). - * \return measurement dimension - */ -unsigned int GblPoint::hasMeasurement() const { - return measDim; -} - -/// Retrieve measurement of a point. -/** - * \param [out] aProjection Projection from (diagonalized) measurement to local system - * \param [out] aResiduals Measurement residuals - * \param [out] aPrecision Measurement precision (diagonal) - */ -void GblPoint::getMeasurement(SMatrix55 &aProjection, SVector5 &aResiduals, - SVector5 &aPrecision) const { - aProjection = measProjection; - aResiduals = measResiduals; - aPrecision = measPrecision; -} - -/// Get measurement transformation (from diagonalization). -/** - * \param [out] aTransformation Transformation matrix - */ -void GblPoint::getMeasTransformation(TMatrixD &aTransformation) const { - aTransformation.ResizeTo(measDim, measDim); - if (transFlag) { - aTransformation = measTransformation; - } else { - aTransformation.UnitMatrix(); - } -} - -/// Add a (thin) scatterer to a point. -/** - * Add scatterer with diagonal precision (inverse covariance) matrix. - * Changes local track direction. - * - * \param [in] aResiduals Scatterer residuals - * \param [in] aPrecision Scatterer precision (diagonal of inverse covariance matrix) - */ -void GblPoint::addScatterer(const TVectorD &aResiduals, - const TVectorD &aPrecision) { - scatFlag = true; - scatResiduals(0) = aResiduals[0]; - scatResiduals(1) = aResiduals[1]; - scatPrecision(0) = aPrecision[0]; - scatPrecision(1) = aPrecision[1]; - scatTransformation = ROOT::Math::SMatrixIdentity(); -} - -/// Add a (thin) scatterer to a point. -/** - * Add scatterer with arbitrary precision (inverse covariance) matrix. - * Will be diagonalized. Changes local track direction. - * - * The precision matrix for the local slopes is defined by the - * angular scattering error theta_0 and the scalar products c_1, c_2 of the - * offset directions in the local frame with the track direction: - * - * (1 - c_1*c_1 - c_2*c_2) | 1 - c_1*c_1 - c_1*c_2 | - * P = ~~~~~~~~~~~~~~~~~~~~~~~ * | | - * theta_0*theta_0 | - c_1*c_2 1 - c_2*c_2 | - * - * \param [in] aResiduals Scatterer residuals - * \param [in] aPrecision Scatterer precision (matrix) - */ -void GblPoint::addScatterer(const TVectorD &aResiduals, - const TMatrixDSym &aPrecision) { - scatFlag = true; - TMatrixDSymEigen scatEigen(aPrecision); - TMatrixD aTransformation = scatEigen.GetEigenVectors(); - aTransformation.T(); - TVectorD transResiduals = aTransformation * aResiduals; - TVectorD transPrecision = scatEigen.GetEigenValues(); - for (unsigned int i = 0; i < 2; ++i) { - scatResiduals(i) = transResiduals[i]; - scatPrecision(i) = transPrecision[i]; - for (unsigned int j = 0; j < 2; ++j) { - scatTransformation(i, j) = aTransformation(i, j); - } - } -} - -/// Check for scatterer at a point. -bool GblPoint::hasScatterer() const { - return scatFlag; -} - -/// Retrieve scatterer of a point. -/** - * \param [out] aTransformation Scatterer transformation from diagonalization - * \param [out] aResiduals Scatterer residuals - * \param [out] aPrecision Scatterer precision (diagonal) - */ -void GblPoint::getScatterer(SMatrix22 &aTransformation, SVector2 &aResiduals, - SVector2 &aPrecision) const { - aTransformation = scatTransformation; - aResiduals = scatResiduals; - aPrecision = scatPrecision; -} - -/// Get scatterer transformation (from diagonalization). -/** - * \param [out] aTransformation Transformation matrix - */ -void GblPoint::getScatTransformation(TMatrixD &aTransformation) const { - aTransformation.ResizeTo(2, 2); - if (scatFlag) { - for (unsigned int i = 0; i < 2; ++i) { - for (unsigned int j = 0; j < 2; ++j) { - aTransformation(i, j) = scatTransformation(i, j); - } - } - } else { - aTransformation.UnitMatrix(); - } -} - -/// Add local derivatives to a point. -/** - * Point needs to have a measurement. - * \param [in] aDerivatives Local derivatives (matrix) - */ -void GblPoint::addLocals(const TMatrixD &aDerivatives) { - if (measDim) { - localDerivatives.ResizeTo(aDerivatives); - if (transFlag) { - localDerivatives = measTransformation * aDerivatives; - } else { - localDerivatives = aDerivatives; - } - } -} - -/// Retrieve number of local derivatives from a point. -unsigned int GblPoint::getNumLocals() const { - return localDerivatives.GetNcols(); -} - -/// Retrieve local derivatives from a point. -const TMatrixD& GblPoint::getLocalDerivatives() const { - return localDerivatives; -} - -/// Add global derivatives to a point. -/** - * Point needs to have a measurement. - * \param [in] aLabels Global derivatives labels - * \param [in] aDerivatives Global derivatives (matrix) - */ -void GblPoint::addGlobals(const std::vector &aLabels, - const TMatrixD &aDerivatives) { - if (measDim) { - globalLabels = aLabels; - globalDerivatives.ResizeTo(aDerivatives); - if (transFlag) { - globalDerivatives = measTransformation * aDerivatives; - } else { - globalDerivatives = aDerivatives; - } - - } -} - -/// Retrieve number of global derivatives from a point. -unsigned int GblPoint::getNumGlobals() const { - return globalDerivatives.GetNcols(); -} - -/// Retrieve global derivatives labels from a point. -std::vector GblPoint::getGlobalLabels() const { - return globalLabels; -} - -/// Retrieve global derivatives from a point. -const TMatrixD& GblPoint::getGlobalDerivatives() const { - return globalDerivatives; -} - -/// Define label of point (by GBLTrajectory constructor) -/** - * \param [in] aLabel Label identifying point - */ -void GblPoint::setLabel(unsigned int aLabel) { - theLabel = aLabel; -} - -/// Retrieve label of point -unsigned int GblPoint::getLabel() const { - return theLabel; -} - -/// Define offset for point (by GBLTrajectory constructor) -/** - * \param [in] anOffset Offset number - */ -void GblPoint::setOffset(int anOffset) { - theOffset = anOffset; -} - -/// Retrieve offset for point -int GblPoint::getOffset() const { - return theOffset; -} - -/// Retrieve point-to-(previous)point jacobian -const SMatrix55& GblPoint::getP2pJacobian() const { - return p2pJacobian; -} - -/// Define jacobian to previous scatterer (by GBLTrajectory constructor) -/** - * \param [in] aJac Jacobian - */ -void GblPoint::addPrevJacobian(const SMatrix55 &aJac) { - int ifail = 0; -// to optimize: need only two last rows of inverse -// prevJacobian = aJac.InverseFast(ifail); -// block matrix algebra - SMatrix23 CA = aJac.Sub(3, 0) - * aJac.Sub(0, 0).InverseFast(ifail); // C*A^-1 - SMatrix22 DCAB = aJac.Sub(3, 3) - CA * aJac.Sub(0, 3); // D - C*A^-1 *B - DCAB.InvertFast(); - prevJacobian.Place_at(DCAB, 3, 3); - prevJacobian.Place_at(-DCAB * CA, 3, 0); -} - -/// Define jacobian to next scatterer (by GBLTrajectory constructor) -/** - * \param [in] aJac Jacobian - */ -void GblPoint::addNextJacobian(const SMatrix55 &aJac) { - nextJacobian = aJac; -} - -/// Retrieve derivatives of local track model -/** - * Linearized track model: F_u(q/p,u',u) = J*u + S*u' + d*q/p, - * W is inverse of S, negated for backward propagation. - * \param [in] aDirection Propagation direction (>0 forward, else backward) - * \param [out] matW W - * \param [out] matWJ W*J - * \param [out] vecWd W*d - * \exception std::overflow_error : matrix S is singular. - */ -void GblPoint::getDerivatives(int aDirection, SMatrix22 &matW, SMatrix22 &matWJ, - SVector2 &vecWd) const { - - SMatrix22 matJ; - SVector2 vecd; - if (aDirection < 1) { - matJ = prevJacobian.Sub(3, 3); - matW = -prevJacobian.Sub(3, 1); - vecd = prevJacobian.SubCol(0, 3); - } else { - matJ = nextJacobian.Sub(3, 3); - matW = nextJacobian.Sub(3, 1); - vecd = nextJacobian.SubCol(0, 3); - } - - if (!matW.InvertFast()) { - std::cout << " GblPoint::getDerivatives failed to invert matrix: " - << matW << std::endl; - std::cout - << " Possible reason for singular matrix: multiple GblPoints at same arc-length" - << std::endl; - throw std::overflow_error("Singular matrix inversion exception"); - } - matWJ = matW * matJ; - vecWd = matW * vecd; - -} - -/// Print GblPoint -/** - * \param [in] level print level (0: minimum, >0: more) - */ -void GblPoint::printPoint(unsigned int level) const { - std::cout << " GblPoint"; - if (theLabel) { - std::cout << ", label " << theLabel; - if (theOffset >= 0) { - std::cout << ", offset " << theOffset; - } - } - if (measDim) { - std::cout << ", " << measDim << " measurements"; - } - if (scatFlag) { - std::cout << ", scatterer"; - } - if (transFlag) { - std::cout << ", diagonalized"; - } - if (localDerivatives.GetNcols()) { - std::cout << ", " << localDerivatives.GetNcols() - << " local derivatives"; - } - if (globalDerivatives.GetNcols()) { - std::cout << ", " << globalDerivatives.GetNcols() - << " global derivatives"; - } - std::cout << std::endl; - if (level > 0) { - if (measDim) { - std::cout << " Measurement" << std::endl; - std::cout << " Projection: " << std::endl << measProjection - << std::endl; - std::cout << " Residuals: " << measResiduals << std::endl; - std::cout << " Precision: " << measPrecision << std::endl; - } - if (scatFlag) { - std::cout << " Scatterer" << std::endl; - std::cout << " Residuals: " << scatResiduals << std::endl; - std::cout << " Precision: " << scatPrecision << std::endl; - } - if (localDerivatives.GetNcols()) { - std::cout << " Local Derivatives:" << std::endl; - localDerivatives.Print(); - } - if (globalDerivatives.GetNcols()) { - std::cout << " Global Labels:"; - for (unsigned int i = 0; i < globalLabels.size(); ++i) { - std::cout << " " << globalLabels[i]; - } - std::cout << std::endl; - std::cout << " Global Derivatives:" << std::endl; - globalDerivatives.Print(); - } - std::cout << " Jacobian " << std::endl; - std::cout << " Point-to-point " << std::endl << p2pJacobian - << std::endl; - if (theLabel) { - std::cout << " To previous offset " << std::endl << prevJacobian - << std::endl; - std::cout << " To next offset " << std::endl << nextJacobian - << std::endl; - } - } -} - -} diff --git a/genfit/GBL/src/GblTrajectory.cc b/genfit/GBL/src/GblTrajectory.cc deleted file mode 100644 index 83188cbb6a..0000000000 --- a/genfit/GBL/src/GblTrajectory.cc +++ /dev/null @@ -1,1115 +0,0 @@ -/* - * GblTrajectory.cpp - * - * Created on: Aug 18, 2011 - * Author: kleinwrt - */ - -/** General information - * - * Introduction - * - * For a track with an initial trajectory from a prefit of the - * measurements (internal seed) or an external prediction - * (external seed) the description of multiple scattering is - * added by offsets in a local system. Along the initial - * trajectory points are defined with can describe a measurement - * or a (thin) scatterer or both. Measurements are arbitrary - * functions of the local track parameters at a point (e.g. 2D: - * position, 4D: direction+position). The refit provides corrections - * to the local track parameters (in the local system) and the - * corresponding covariance matrix at any of those points. - * Non-diagonal covariance matrices will be diagonalized internally. - * Outliers can be down-weighted by use of M-estimators. - * - * The broken lines trajectory is defined by (2D) offsets at the - * first and last point and all points with a scatterer. The - * prediction for a measurement is obtained by interpolation of - * the enclosing offsets and for triplets of adjacent offsets - * kink angles are determined. This requires for all points the - * jacobians for propagation to the previous and next offset. - * These are calculated from the point-to-point jacobians along - * the initial trajectory. The sequence of points has to be - * strictly monotonic in arc-length. - * - * Additional local or global parameters can be added and the - * trajectories can be written to special binary files for - * calibration and alignment with Millepede-II. - * (V. Blobel, NIM A, 566 (2006), pp. 5-13). - * - * Besides simple trajectories describing the path of a single - * particle composed trajectories are supported. These are - * constructed from the trajectories of multiple particles and - * some external parameters (like those describing a decay) - * and transformations at the first points from the external - * to the local track parameters. - * - * The conventions for the coordinate systems follow: - * Derivation of Jacobians for the propagation of covariance - * matrices of track parameters in homogeneous magnetic fields - * A. Strandlie, W. Wittek, NIM A, 566 (2006) 687-698. - * - * Calling sequence - * - * -# Create list of points on initial trajectory:\n - * std::vector list - * -# For all points on initial trajectory: - * - Create points and add appropriate attributes:\n - * - point = gbl::GblPoint(..) - * - point.addMeasurement(..) - * - Add additional local or global parameters to measurement:\n - * - point.addLocals(..) - * - point.addGlobals(..) - * - point.addScatterer(..) - * - Add point (ordered by arc length) to list:\n - * list.push_back(point) - * -# Create (simple) trajectory from list of points:\n - * traj = gbl::GblTrajectory (list) - * -# Optionally with external seed:\n - * traj = gbl::GblTrajectory (list,seed) - * -# Optionally check validity of trajectory:\n - * if (not traj.isValid()) .. //abort - * -# Fit trajectory, return error code, - * get Chi2, Ndf (and weight lost by M-estimators):\n - * ierr = traj.fit(..) - * -# For any point on initial trajectory: - * - Get corrections and covariance matrix for track parameters:\n - * [..] = traj.getResults(label) - * -# Optionally write trajectory to MP binary file (doesn't needs to be fitted):\n - * traj.milleOut(..) - * - * Local system and local parameters - * At each point on the trajectory a local coordinate system with local track - * parameters has to be defined. The first of the five parameters describes - * the bending, the next two the direction and the last two the position (offsets). - * The curvilinear system (T,U,V) with parameters (q/p, lambda, phi, x_t, y_t) - * is well suited. - * - * Implementation - * - * Matrices are implemented with ROOT (root.cern.ch). User input or output is in the - * form of TMatrices. Internally SMatrices are used for fixes sized and simple matrices - * based on std::vector<> for variable sized matrices. - * - * References - * - V. Blobel, C. Kleinwort, F. Meier, - * Fast alignment of a complex tracking detector using advanced track models, - * Computer Phys. Communications (2011), doi:10.1016/j.cpc.2011.03.017 - * - C. Kleinwort, General Broken Lines as advanced track fitting method, - * NIM A, 673 (2012), 107-110, doi:10.1016/j.nima.2012.01.024 - */ - -#include "GblTrajectory.h" - -//! Namespace for the general broken lines package -namespace gbl { - -/// Create new (simple) trajectory from list of points. -/** - * Curved trajectory in space (default) or without curvature (q/p) or in one - * plane (u-direction) only. - * \param [in] aPointList List of points - * \param [in] flagCurv Use q/p - * \param [in] flagU1dir Use in u1 direction - * \param [in] flagU2dir Use in u2 direction - */ -GblTrajectory::GblTrajectory(const std::vector &aPointList, - bool flagCurv, bool flagU1dir, bool flagU2dir) : - numAllPoints(aPointList.size()), numPoints(), numOffsets(0), numInnerTrans( - 0), numCurvature(flagCurv ? 1 : 0), numParameters(0), numLocals( - 0), numMeasurements(0), externalPoint(0), theDimension(0), thePoints(), theData(), measDataIndex(), scatDataIndex(), externalSeed(), innerTransformations(), externalDerivatives(), externalMeasurements(), externalPrecisions() { - - if (flagU1dir) - theDimension.push_back(0); - if (flagU2dir) - theDimension.push_back(1); - // simple (single) trajectory - thePoints.push_back(aPointList); - numPoints.push_back(numAllPoints); - construct(); // construct trajectory -} - -/// Create new (simple) trajectory from list of points with external seed. -/** - * Curved trajectory in space (default) or without curvature (q/p) or in one - * plane (u-direction) only. - * \param [in] aPointList List of points - * \param [in] aLabel (Signed) label of point for external seed - * (<0: in front, >0: after point, slope changes at scatterer!) - * \param [in] aSeed Precision matrix of external seed - * \param [in] flagCurv Use q/p - * \param [in] flagU1dir Use in u1 direction - * \param [in] flagU2dir Use in u2 direction - */ -GblTrajectory::GblTrajectory(const std::vector &aPointList, - unsigned int aLabel, const TMatrixDSym &aSeed, bool flagCurv, - bool flagU1dir, bool flagU2dir) : - numAllPoints(aPointList.size()), numPoints(), numOffsets(0), numInnerTrans( - 0), numCurvature(flagCurv ? 1 : 0), numParameters(0), numLocals( - 0), numMeasurements(0), externalPoint(aLabel), theDimension(0), thePoints(), theData(), measDataIndex(), scatDataIndex(), externalSeed( - aSeed), innerTransformations(), externalDerivatives(), externalMeasurements(), externalPrecisions() { - - if (flagU1dir) - theDimension.push_back(0); - if (flagU2dir) - theDimension.push_back(1); - // simple (single) trajectory - thePoints.push_back(aPointList); - numPoints.push_back(numAllPoints); - construct(); // construct trajectory -} - -/// Create new composed trajectory from list of points and transformations. -/** - * Composed of curved trajectory in space. - * \param [in] aPointsAndTransList List containing pairs with list of points and transformation (at inner (first) point) - */ -GblTrajectory::GblTrajectory( - const std::vector, TMatrixD> > &aPointsAndTransList) : - numAllPoints(), numPoints(), numOffsets(0), numInnerTrans( - aPointsAndTransList.size()), numParameters(0), numLocals(0), numMeasurements( - 0), externalPoint(0), theDimension(0), thePoints(), theData(), measDataIndex(), scatDataIndex(), externalSeed(), innerTransformations(), externalDerivatives(), externalMeasurements(), externalPrecisions() { - - for (unsigned int iTraj = 0; iTraj < aPointsAndTransList.size(); ++iTraj) { - thePoints.push_back(aPointsAndTransList[iTraj].first); - numPoints.push_back(thePoints.back().size()); - numAllPoints += numPoints.back(); - innerTransformations.push_back(aPointsAndTransList[iTraj].second); - } - theDimension.push_back(0); - theDimension.push_back(1); - numCurvature = innerTransformations[0].GetNcols(); - construct(); // construct (composed) trajectory -} - -/// Create new composed trajectory from list of points and transformations with (independent) external measurements. -/** - * Composed of curved trajectory in space. - * \param [in] aPointsAndTransList List containing pairs with list of points and transformation (at inner (first) point) - * \param [in] extDerivatives Derivatives of external measurements vs external parameters - * \param [in] extMeasurements External measurements (residuals) - * \param [in] extPrecisions Precision of external measurements - */ -GblTrajectory::GblTrajectory( - const std::vector, TMatrixD> > &aPointsAndTransList, - const TMatrixD &extDerivatives, const TVectorD &extMeasurements, - const TVectorD &extPrecisions) : - numAllPoints(), numPoints(), numOffsets(0), numInnerTrans( - aPointsAndTransList.size()), numParameters(0), numLocals(0), numMeasurements( - 0), externalPoint(0), theDimension(0), thePoints(), theData(), measDataIndex(), scatDataIndex(), externalSeed(), innerTransformations(), externalDerivatives( - extDerivatives), externalMeasurements(extMeasurements), externalPrecisions( - extPrecisions) { - - for (unsigned int iTraj = 0; iTraj < aPointsAndTransList.size(); ++iTraj) { - thePoints.push_back(aPointsAndTransList[iTraj].first); - numPoints.push_back(thePoints.back().size()); - numAllPoints += numPoints.back(); - innerTransformations.push_back(aPointsAndTransList[iTraj].second); - } - theDimension.push_back(0); - theDimension.push_back(1); - numCurvature = innerTransformations[0].GetNcols(); - construct(); // construct (composed) trajectory -} - -GblTrajectory::~GblTrajectory() { -} - -/// Retrieve validity of trajectory -bool GblTrajectory::isValid() const { - return constructOK; -} - -/// Retrieve number of point from trajectory -unsigned int GblTrajectory::getNumPoints() const { - return numAllPoints; -} - -/// Construct trajectory from list of points. -/** - * Trajectory is prepared for fit or output to binary file, may consists of sub-trajectories. - */ -void GblTrajectory::construct() { - - constructOK = false; - fitOK = false; - unsigned int aLabel = 0; - if (numAllPoints < 2) { - std::cout << " GblTrajectory construction failed: too few GblPoints " - << std::endl; - return; - } - // loop over trajectories - numTrajectories = thePoints.size(); - //std::cout << " numTrajectories: " << numTrajectories << ", " << innerTransformations.size() << std::endl; - for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) { - std::vector::iterator itPoint; - for (itPoint = thePoints[iTraj].begin(); - itPoint < thePoints[iTraj].end(); ++itPoint) { - numLocals = std::max(numLocals, itPoint->getNumLocals()); - numMeasurements += itPoint->hasMeasurement(); - itPoint->setLabel(++aLabel); - } - } - defineOffsets(); - calcJacobians(); - try { - prepare(); - } catch (std::overflow_error &e) { - std::cout << " GblTrajectory construction failed: " << e.what() - << std::endl; - return; - } - constructOK = true; - // number of fit parameters - numParameters = (numOffsets - 2 * numInnerTrans) * theDimension.size() - + numCurvature + numLocals; -} - -/// Define offsets from list of points. -/** - * Define offsets at points with scatterers and first and last point. - * All other points need interpolation from adjacent points with offsets. - */ -void GblTrajectory::defineOffsets() { - - // loop over trajectories - for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) { - // first point is offset - thePoints[iTraj].front().setOffset(numOffsets++); - // intermediate scatterers are offsets - std::vector::iterator itPoint; - for (itPoint = thePoints[iTraj].begin() + 1; - itPoint < thePoints[iTraj].end() - 1; ++itPoint) { - if (itPoint->hasScatterer()) { - itPoint->setOffset(numOffsets++); - } else { - itPoint->setOffset(-numOffsets); - } - } - // last point is offset - thePoints[iTraj].back().setOffset(numOffsets++); - } -} - -/// Calculate Jacobians to previous/next scatterer from point to point ones. -void GblTrajectory::calcJacobians() { - - SMatrix55 scatJacobian; - // loop over trajectories - for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) { - // forward propagation (all) - GblPoint* previousPoint = &thePoints[iTraj].front(); - unsigned int numStep = 0; - std::vector::iterator itPoint; - for (itPoint = thePoints[iTraj].begin() + 1; - itPoint < thePoints[iTraj].end(); ++itPoint) { - if (numStep == 0) { - scatJacobian = itPoint->getP2pJacobian(); - } else { - scatJacobian = itPoint->getP2pJacobian() * scatJacobian; - } - numStep++; - itPoint->addPrevJacobian(scatJacobian); // iPoint -> previous scatterer - if (itPoint->getOffset() >= 0) { - previousPoint->addNextJacobian(scatJacobian); // lastPoint -> next scatterer - numStep = 0; - previousPoint = &(*itPoint); - } - } - // backward propagation (without scatterers) - for (itPoint = thePoints[iTraj].end() - 1; - itPoint > thePoints[iTraj].begin(); --itPoint) { - if (itPoint->getOffset() >= 0) { - scatJacobian = itPoint->getP2pJacobian(); - continue; // skip offsets - } - itPoint->addNextJacobian(scatJacobian); // iPoint -> next scatterer - scatJacobian = scatJacobian * itPoint->getP2pJacobian(); - } - } -} - -/// Get jacobian for transformation from fit to track parameters at point. -/** - * Jacobian broken lines (q/p,..,u_i,u_i+1..) to track (q/p,u',u) parameters - * including additional local parameters. - * \param [in] aSignedLabel (Signed) label of point for external seed - * (<0: in front, >0: after point, slope changes at scatterer!) - * \return List of fit parameters with non zero derivatives and - * corresponding transformation matrix - */ -std::pair, TMatrixD> GblTrajectory::getJacobian( - int aSignedLabel) const { - - unsigned int nDim = theDimension.size(); - unsigned int nCurv = numCurvature; - unsigned int nLocals = numLocals; - unsigned int nBorder = nCurv + nLocals; - unsigned int nParBRL = nBorder + 2 * nDim; - unsigned int nParLoc = nLocals + 5; - std::vector anIndex; - anIndex.reserve(nParBRL); - TMatrixD aJacobian(nParLoc, nParBRL); - aJacobian.Zero(); - - unsigned int aLabel = abs(aSignedLabel); - unsigned int firstLabel = 1; - unsigned int lastLabel = 0; - unsigned int aTrajectory = 0; - // loop over trajectories - for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) { - aTrajectory = iTraj; - lastLabel += numPoints[iTraj]; - if (aLabel <= lastLabel) - break; - if (iTraj < numTrajectories - 1) - firstLabel += numPoints[iTraj]; - } - int nJacobian; // 0: prev, 1: next - // check consistency of (index, direction) - if (aSignedLabel > 0) { - nJacobian = 1; - if (aLabel >= lastLabel) { - aLabel = lastLabel; - nJacobian = 0; - } - } else { - nJacobian = 0; - if (aLabel <= firstLabel) { - aLabel = firstLabel; - nJacobian = 1; - } - } - const GblPoint aPoint = thePoints[aTrajectory][aLabel - firstLabel]; - std::vector labDer(5); - SMatrix55 matDer; - getFitToLocalJacobian(labDer, matDer, aPoint, 5, nJacobian); - - // from local parameters - for (unsigned int i = 0; i < nLocals; ++i) { - aJacobian(i + 5, i) = 1.0; - anIndex.push_back(i + 1); - } - // from trajectory parameters - unsigned int iCol = nLocals; - for (unsigned int i = 0; i < 5; ++i) { - if (labDer[i] > 0) { - anIndex.push_back(labDer[i]); - for (unsigned int j = 0; j < 5; ++j) { - aJacobian(j, iCol) = matDer(j, i); - } - ++iCol; - } - } - return std::make_pair(anIndex, aJacobian); -} - -/// Get (part of) jacobian for transformation from (trajectory) fit to track parameters at point. -/** - * Jacobian broken lines (q/p,..,u_i,u_i+1..) to local (q/p,u',u) parameters. - * \param [out] anIndex List of fit parameters with non zero derivatives - * \param [out] aJacobian Corresponding transformation matrix - * \param [in] aPoint Point to use - * \param [in] measDim Dimension of 'measurement' - * (<=2: calculate only offset part, >2: complete matrix) - * \param [in] nJacobian Direction (0: to previous offset, 1: to next offset) - */ -void GblTrajectory::getFitToLocalJacobian(std::vector &anIndex, - SMatrix55 &aJacobian, const GblPoint &aPoint, unsigned int measDim, - unsigned int nJacobian) const { - - unsigned int nDim = theDimension.size(); - unsigned int nCurv = numCurvature; - unsigned int nLocals = numLocals; - - int nOffset = aPoint.getOffset(); - - if (nOffset < 0) // need interpolation - { - SMatrix22 prevW, prevWJ, nextW, nextWJ, matN; - SVector2 prevWd, nextWd; - int ierr; - aPoint.getDerivatives(0, prevW, prevWJ, prevWd); // W-, W- * J-, W- * d- - aPoint.getDerivatives(1, nextW, nextWJ, nextWd); // W-, W- * J-, W- * d- - const SMatrix22 sumWJ(prevWJ + nextWJ); - matN = sumWJ.Inverse(ierr); // N = (W- * J- + W+ * J+)^-1 - // derivatives for u_int - const SMatrix22 prevNW(matN * prevW); // N * W- - const SMatrix22 nextNW(matN * nextW); // N * W+ - const SVector2 prevNd(matN * prevWd); // N * W- * d- - const SVector2 nextNd(matN * nextWd); // N * W+ * d+ - - unsigned int iOff = nDim * (-nOffset - 1) + nLocals + nCurv + 1; // first offset ('i' in u_i) - - // local offset - if (nCurv > 0) { - aJacobian.Place_in_col(-prevNd - nextNd, 3, 0); // from curvature - anIndex[0] = nLocals + 1; - } - aJacobian.Place_at(prevNW, 3, 1); // from 1st Offset - aJacobian.Place_at(nextNW, 3, 3); // from 2nd Offset - for (unsigned int i = 0; i < nDim; ++i) { - anIndex[1 + theDimension[i]] = iOff + i; - anIndex[3 + theDimension[i]] = iOff + nDim + i; - } - - // local slope and curvature - if (measDim > 2) { - // derivatives for u'_int - const SMatrix22 prevWPN(nextWJ * prevNW); // W+ * J+ * N * W- - const SMatrix22 nextWPN(prevWJ * nextNW); // W- * J- * N * W+ - const SVector2 prevWNd(nextWJ * prevNd); // W+ * J+ * N * W- * d- - const SVector2 nextWNd(prevWJ * nextNd); // W- * J- * N * W+ * d+ - if (nCurv > 0) { - aJacobian(0, 0) = 1.0; - aJacobian.Place_in_col(prevWNd - nextWNd, 1, 0); // from curvature - } - aJacobian.Place_at(-prevWPN, 1, 1); // from 1st Offset - aJacobian.Place_at(nextWPN, 1, 3); // from 2nd Offset - } - } else { // at point - // anIndex must be sorted - // forward : iOff2 = iOff1 + nDim, index1 = 1, index2 = 3 - // backward: iOff2 = iOff1 - nDim, index1 = 3, index2 = 1 - unsigned int iOff1 = nDim * nOffset + nCurv + nLocals + 1; // first offset ('i' in u_i) - unsigned int index1 = 3 - 2 * nJacobian; // index of first offset - unsigned int iOff2 = iOff1 + nDim * (nJacobian * 2 - 1); // second offset ('i' in u_i) - unsigned int index2 = 1 + 2 * nJacobian; // index of second offset - // local offset - aJacobian(3, index1) = 1.0; // from 1st Offset - aJacobian(4, index1 + 1) = 1.0; - for (unsigned int i = 0; i < nDim; ++i) { - anIndex[index1 + theDimension[i]] = iOff1 + i; - } - - // local slope and curvature - if (measDim > 2) { - SMatrix22 matW, matWJ; - SVector2 vecWd; - aPoint.getDerivatives(nJacobian, matW, matWJ, vecWd); // W, W * J, W * d - double sign = (nJacobian > 0) ? 1. : -1.; - if (nCurv > 0) { - aJacobian(0, 0) = 1.0; - aJacobian.Place_in_col(-sign * vecWd, 1, 0); // from curvature - anIndex[0] = nLocals + 1; - } - aJacobian.Place_at(-sign * matWJ, 1, index1); // from 1st Offset - aJacobian.Place_at(sign * matW, 1, index2); // from 2nd Offset - for (unsigned int i = 0; i < nDim; ++i) { - anIndex[index2 + theDimension[i]] = iOff2 + i; - } - } - } -} - -/// Get jacobian for transformation from (trajectory) fit to kink parameters at point. -/** - * Jacobian broken lines (q/p,..,u_i-1,u_i,u_i+1..) to kink (du') parameters. - * \param [out] anIndex List of fit parameters with non zero derivatives - * \param [out] aJacobian Corresponding transformation matrix - * \param [in] aPoint Point to use - */ -void GblTrajectory::getFitToKinkJacobian(std::vector &anIndex, - SMatrix27 &aJacobian, const GblPoint &aPoint) const { - - unsigned int nDim = theDimension.size(); - unsigned int nCurv = numCurvature; - unsigned int nLocals = numLocals; - - int nOffset = aPoint.getOffset(); - - SMatrix22 prevW, prevWJ, nextW, nextWJ; - SVector2 prevWd, nextWd; - aPoint.getDerivatives(0, prevW, prevWJ, prevWd); // W-, W- * J-, W- * d- - aPoint.getDerivatives(1, nextW, nextWJ, nextWd); // W-, W- * J-, W- * d- - const SMatrix22 sumWJ(prevWJ + nextWJ); // W- * J- + W+ * J+ - const SVector2 sumWd(prevWd + nextWd); // W+ * d+ + W- * d- - - unsigned int iOff = (nOffset - 1) * nDim + nCurv + nLocals + 1; // first offset ('i' in u_i) - - // local offset - if (nCurv > 0) { - aJacobian.Place_in_col(-sumWd, 0, 0); // from curvature - anIndex[0] = nLocals + 1; - } - aJacobian.Place_at(prevW, 0, 1); // from 1st Offset - aJacobian.Place_at(-sumWJ, 0, 3); // from 2nd Offset - aJacobian.Place_at(nextW, 0, 5); // from 1st Offset - for (unsigned int i = 0; i < nDim; ++i) { - anIndex[1 + theDimension[i]] = iOff + i; - anIndex[3 + theDimension[i]] = iOff + nDim + i; - anIndex[5 + theDimension[i]] = iOff + nDim * 2 + i; - } -} - -/// Get fit results at point. -/** - * Get corrections and covariance matrix for local track and additional parameters - * in forward or backward direction. - * \param [in] aSignedLabel (Signed) label of point on trajectory - * (<0: in front, >0: after point, slope changes at scatterer!) - * \param [out] localPar Corrections for local parameters - * \param [out] localCov Covariance for local parameters - * \return error code (non-zero if trajectory not fitted successfully) - */ -unsigned int GblTrajectory::getResults(int aSignedLabel, TVectorD &localPar, - TMatrixDSym &localCov) const { - if (not fitOK) - return 1; - std::pair, TMatrixD> indexAndJacobian = - getJacobian(aSignedLabel); - unsigned int nParBrl = indexAndJacobian.first.size(); - TVectorD aVec(nParBrl); // compressed vector - for (unsigned int i = 0; i < nParBrl; ++i) { - aVec[i] = theVector(indexAndJacobian.first[i] - 1); - } - TMatrixDSym aMat = theMatrix.getBlockMatrix(indexAndJacobian.first); // compressed matrix - localPar = indexAndJacobian.second * aVec; - localCov = aMat.Similarity(indexAndJacobian.second); - return 0; -} - -/// Get residuals at point from measurement. -/** - * Get (diagonalized) residual, error of measurement and residual and down-weighting - * factor for measurement at point - * - * \param [in] aLabel Label of point on trajectory - * \param [out] numData Number of data blocks from measurement at point - * \param [out] aResiduals Measurements-Predictions - * \param [out] aMeasErrors Errors of Measurements - * \param [out] aResErrors Errors of Residuals (including correlations from track fit) - * \param [out] aDownWeights Down-Weighting factors - * \return error code (non-zero if trajectory not fitted successfully) - */ -unsigned int GblTrajectory::getMeasResults(unsigned int aLabel, - unsigned int &numData, TVectorD &aResiduals, TVectorD &aMeasErrors, - TVectorD &aResErrors, TVectorD &aDownWeights) { - numData = 0; - if (not fitOK) - return 1; - - unsigned int firstData = measDataIndex[aLabel - 1]; // first data block with measurement - numData = measDataIndex[aLabel] - firstData; // number of data blocks - for (unsigned int i = 0; i < numData; ++i) { - getResAndErr(firstData + i, aResiduals[i], aMeasErrors[i], - aResErrors[i], aDownWeights[i]); - } - return 0; -} - -/// Get (kink) residuals at point from scatterer. -/** - * Get (diagonalized) residual, error of measurement and residual and down-weighting - * factor for scatterering kinks at point - * - * \param [in] aLabel Label of point on trajectory - * \param [out] numData Number of data blocks from scatterer at point - * \param [out] aResiduals (kink)Measurements-(kink)Predictions - * \param [out] aMeasErrors Errors of (kink)Measurements - * \param [out] aResErrors Errors of Residuals (including correlations from track fit) - * \param [out] aDownWeights Down-Weighting factors - * \return error code (non-zero if trajectory not fitted successfully) - */ -unsigned int GblTrajectory::getScatResults(unsigned int aLabel, - unsigned int &numData, TVectorD &aResiduals, TVectorD &aMeasErrors, - TVectorD &aResErrors, TVectorD &aDownWeights) { - numData = 0; - if (not fitOK) - return 1; - - unsigned int firstData = scatDataIndex[aLabel - 1]; // first data block with scatterer - numData = scatDataIndex[aLabel] - firstData; // number of data blocks - for (unsigned int i = 0; i < numData; ++i) { - getResAndErr(firstData + i, aResiduals[i], aMeasErrors[i], - aResErrors[i], aDownWeights[i]); - } - return 0; -} - -/// Get (list of) labels of points on (simple) trajectory -/** - * \param [out] aLabelList List of labels (aLabelList[i] = i+1) - */ -void GblTrajectory::getLabels(std::vector &aLabelList) { - unsigned int aLabel = 0; - unsigned int nPoint = thePoints[0].size(); - aLabelList.resize(nPoint); - for (unsigned i = 0; i < nPoint; ++i) { - aLabelList[i] = ++aLabel; - } -} - -/// Get (list of lists of) labels of points on (composed) trajectory -/** - * \param [out] aLabelList List of of lists of labels - */ -void GblTrajectory::getLabels( - std::vector > &aLabelList) { - unsigned int aLabel = 0; - aLabelList.resize(numTrajectories); - for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) { - unsigned int nPoint = thePoints[iTraj].size(); - aLabelList[iTraj].resize(nPoint); - for (unsigned i = 0; i < nPoint; ++i) { - aLabelList[iTraj][i] = ++aLabel; - } - } -} - -/// Get residual and errors from data block. -/** - * Get residual, error of measurement and residual and down-weighting - * factor for (single) data block - * \param [in] aData Label of data block - * \param [out] aResidual Measurement-Prediction - * \param [out] aMeasError Error of Measurement - * \param [out] aResError Error of Residual (including correlations from track fit) - * \param [out] aDownWeight Down-Weighting factor - */ -void GblTrajectory::getResAndErr(unsigned int aData, double &aResidual, - double &aMeasError, double &aResError, double &aDownWeight) { - - double aMeasVar; - std::vector* indLocal; - std::vector* derLocal; - theData[aData].getResidual(aResidual, aMeasVar, aDownWeight, indLocal, - derLocal); - unsigned int nParBrl = (*indLocal).size(); - TVectorD aVec(nParBrl); // compressed vector of derivatives - for (unsigned int j = 0; j < nParBrl; ++j) { - aVec[j] = (*derLocal)[j]; - } - TMatrixDSym aMat = theMatrix.getBlockMatrix(*indLocal); // compressed (covariance) matrix - double aFitVar = aMat.Similarity(aVec); // variance from track fit - aMeasError = sqrt(aMeasVar); // error of measurement - aResError = (aFitVar < aMeasVar ? sqrt(aMeasVar - aFitVar) : 0.); // error of residual -} - -/// Build linear equation system from data (blocks). -void GblTrajectory::buildLinearEquationSystem() { - unsigned int nBorder = numCurvature + numLocals; - theVector.resize(numParameters); - theMatrix.resize(numParameters, nBorder); - double aValue, aWeight; - std::vector* indLocal; - std::vector* derLocal; - std::vector::iterator itData; - for (itData = theData.begin(); itData < theData.end(); ++itData) { - itData->getLocalData(aValue, aWeight, indLocal, derLocal); - for (unsigned int j = 0; j < indLocal->size(); ++j) { - theVector((*indLocal)[j] - 1) += (*derLocal)[j] * aWeight * aValue; - } - theMatrix.addBlockMatrix(aWeight, indLocal, derLocal); - } -} - -/// Prepare fit for simple or composed trajectory -/** - * Generate data (blocks) from measurements, kinks, external seed and measurements. - */ -void GblTrajectory::prepare() { - unsigned int nDim = theDimension.size(); - // upper limit - unsigned int maxData = numMeasurements + nDim * (numOffsets - 2) - + externalSeed.GetNrows(); - theData.reserve(maxData); - measDataIndex.resize(numAllPoints + 3); // include external seed and measurements - scatDataIndex.resize(numAllPoints + 1); - unsigned int nData = 0; - std::vector innerTransDer; - std::vector > innerTransLab; - // composed trajectory ? - if (numInnerTrans > 0) { - //std::cout << "composed trajectory" << std::endl; - for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) { - // innermost point - GblPoint* innerPoint = &thePoints[iTraj].front(); - // transformation fit to local track parameters - std::vector firstLabels(5); - SMatrix55 matFitToLocal, matLocalToFit; - getFitToLocalJacobian(firstLabels, matFitToLocal, *innerPoint, 5); - // transformation local track to fit parameters - int ierr; - matLocalToFit = matFitToLocal.Inverse(ierr); - TMatrixD localToFit(5, 5); - for (unsigned int i = 0; i < 5; ++i) { - for (unsigned int j = 0; j < 5; ++j) { - localToFit(i, j) = matLocalToFit(i, j); - } - } - // transformation external to fit parameters at inner (first) point - innerTransDer.push_back(localToFit * innerTransformations[iTraj]); - innerTransLab.push_back(firstLabels); - } - } - // measurements - SMatrix55 matP; - // loop over trajectories - std::vector::iterator itPoint; - for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) { - for (itPoint = thePoints[iTraj].begin(); - itPoint < thePoints[iTraj].end(); ++itPoint) { - SVector5 aMeas, aPrec; - unsigned int nLabel = itPoint->getLabel(); - unsigned int measDim = itPoint->hasMeasurement(); - if (measDim) { - const TMatrixD localDer = itPoint->getLocalDerivatives(); - const std::vector globalLab = itPoint->getGlobalLabels(); - const TMatrixD globalDer = itPoint->getGlobalDerivatives(); - TMatrixD transDer; - itPoint->getMeasurement(matP, aMeas, aPrec); - unsigned int iOff = 5 - measDim; // first active component - std::vector labDer(5); - SMatrix55 matDer, matPDer; - unsigned int nJacobian = - (itPoint < thePoints[iTraj].end() - 1) ? 1 : 0; // last point needs backward propagation - getFitToLocalJacobian(labDer, matDer, *itPoint, measDim, - nJacobian); - if (measDim > 2) { - matPDer = matP * matDer; - } else { // 'shortcut' for position measurements - matPDer.Place_at( - matP.Sub(3, 3) - * matDer.Sub(3, 0), 3, 0); - } - - if (numInnerTrans > 0) { - // transform for external parameters - TMatrixD proDer(measDim, 5); - // match parameters - unsigned int ifirst = 0; - unsigned int ilabel = 0; - while (ilabel < 5) { - if (labDer[ilabel] > 0) { - while (innerTransLab[iTraj][ifirst] - != labDer[ilabel] and ifirst < 5) { - ++ifirst; - } - if (ifirst >= 5) { - labDer[ilabel] -= 2 * nDim * (iTraj + 1); // adjust label - } else { - // match - labDer[ilabel] = 0; // mark as related to external parameters - for (unsigned int k = iOff; k < 5; ++k) { - proDer(k - iOff, ifirst) = matPDer(k, - ilabel); - } - } - } - ++ilabel; - } - transDer.ResizeTo(measDim, numCurvature); - transDer = proDer * innerTransDer[iTraj]; - } - for (unsigned int i = iOff; i < 5; ++i) { - if (aPrec(i) > 0.) { - GblData aData(nLabel, aMeas(i), aPrec(i)); - aData.addDerivatives(i, labDer, matPDer, iOff, localDer, - globalLab, globalDer, numLocals, transDer); - theData.push_back(aData); - nData++; - } - } - - } - measDataIndex[nLabel] = nData; - } - } - - // pseudo measurements from kinks - SMatrix22 matT; - scatDataIndex[0] = nData; - scatDataIndex[1] = nData; - // loop over trajectories - for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) { - for (itPoint = thePoints[iTraj].begin() + 1; - itPoint < thePoints[iTraj].end() - 1; ++itPoint) { - SVector2 aMeas, aPrec; - unsigned int nLabel = itPoint->getLabel(); - if (itPoint->hasScatterer()) { - itPoint->getScatterer(matT, aMeas, aPrec); - TMatrixD transDer; - std::vector labDer(7); - SMatrix27 matDer, matTDer; - getFitToKinkJacobian(labDer, matDer, *itPoint); - matTDer = matT * matDer; - if (numInnerTrans > 0) { - // transform for external parameters - TMatrixD proDer(nDim, 5); - // match parameters - unsigned int ifirst = 0; - unsigned int ilabel = 0; - while (ilabel < 7) { - if (labDer[ilabel] > 0) { - while (innerTransLab[iTraj][ifirst] - != labDer[ilabel] and ifirst < 5) { - ++ifirst; - } - if (ifirst >= 5) { - labDer[ilabel] -= 2 * nDim * (iTraj + 1); // adjust label - } else { - // match - labDer[ilabel] = 0; // mark as related to external parameters - for (unsigned int k = 0; k < nDim; ++k) { - proDer(k, ifirst) = matTDer(k, ilabel); - } - } - } - ++ilabel; - } - transDer.ResizeTo(nDim, numCurvature); - transDer = proDer * innerTransDer[iTraj]; - } - for (unsigned int i = 0; i < nDim; ++i) { - unsigned int iDim = theDimension[i]; - if (aPrec(iDim) > 0.) { - GblData aData(nLabel, aMeas(iDim), aPrec(iDim)); - aData.addDerivatives(iDim, labDer, matTDer, numLocals, - transDer); - theData.push_back(aData); - nData++; - } - } - } - scatDataIndex[nLabel] = nData; - } - scatDataIndex[thePoints[iTraj].back().getLabel()] = nData; - } - - // external seed - if (externalPoint > 0) { - std::pair, TMatrixD> indexAndJacobian = - getJacobian(externalPoint); - std::vector externalSeedIndex = indexAndJacobian.first; - std::vector externalSeedDerivatives(externalSeedIndex.size()); - const TMatrixDSymEigen externalSeedEigen(externalSeed); - const TVectorD valEigen = externalSeedEigen.GetEigenValues(); - TMatrixD vecEigen = externalSeedEigen.GetEigenVectors(); - vecEigen = vecEigen.T() * indexAndJacobian.second; - for (int i = 0; i < externalSeed.GetNrows(); ++i) { - if (valEigen(i) > 0.) { - for (int j = 0; j < externalSeed.GetNcols(); ++j) { - externalSeedDerivatives[j] = vecEigen(i, j); - } - GblData aData(externalPoint, 0., valEigen(i)); - aData.addDerivatives(externalSeedIndex, externalSeedDerivatives); - theData.push_back(aData); - nData++; - } - } - } - measDataIndex[numAllPoints + 1] = nData; - // external measurements - unsigned int nExt = externalMeasurements.GetNrows(); - if (nExt > 0) { - std::vector index(numCurvature); - std::vector derivatives(numCurvature); - for (unsigned int iExt = 0; iExt < nExt; ++iExt) { - for (unsigned int iCol = 0; iCol < numCurvature; ++iCol) { - index[iCol] = iCol + 1; - derivatives[iCol] = externalDerivatives(iExt, iCol); - } - GblData aData(1U, externalMeasurements(iExt), - externalPrecisions(iExt)); - aData.addDerivatives(index, derivatives); - theData.push_back(aData); - nData++; - } - } - measDataIndex[numAllPoints + 2] = nData; -} - -/// Calculate predictions for all points. -void GblTrajectory::predict() { - std::vector::iterator itData; - for (itData = theData.begin(); itData < theData.end(); ++itData) { - itData->setPrediction(theVector); - } -} - -/// Down-weight all points. -/** - * \param [in] aMethod M-estimator (1: Tukey, 2:Huber, 3:Cauchy) - */ -double GblTrajectory::downWeight(unsigned int aMethod) { - double aLoss = 0.; - std::vector::iterator itData; - for (itData = theData.begin(); itData < theData.end(); ++itData) { - aLoss += (1. - itData->setDownWeighting(aMethod)); - } - return aLoss; -} - -/// Perform fit of trajectory. -/** - * Optionally iterate for outlier down-weighting. - * \param [out] Chi2 Chi2 sum (corrected for down-weighting) - * \param [out] Ndf Number of degrees of freedom - * \param [out] lostWeight Sum of weights lost due to down-weighting - * \param [in] optionList Iterations for down-weighting - * (One character per iteration: t,h,c (or T,H,C) for Tukey, Huber or Cauchy function) - * \return Error code (non zero value indicates failure of fit) - */ -unsigned int GblTrajectory::fit(double &Chi2, int &Ndf, double &lostWeight, - std::string optionList) { - const double normChi2[4] = { 1.0, 0.8737, 0.9326, 0.8228 }; - const std::string methodList = "TtHhCc"; - - Chi2 = 0.; - Ndf = -1; - lostWeight = 0.; - if (not constructOK) - return 10; - - unsigned int aMethod = 0; - - buildLinearEquationSystem(); - lostWeight = 0.; - unsigned int ierr = 0; - try { - - theMatrix.solveAndInvertBorderedBand(theVector, theVector); - predict(); - - for (unsigned int i = 0; i < optionList.size(); ++i) // down weighting iterations - { - size_t aPosition = methodList.find(optionList[i]); - if (aPosition != std::string::npos) { - aMethod = aPosition / 2 + 1; - lostWeight = downWeight(aMethod); - buildLinearEquationSystem(); - theMatrix.solveAndInvertBorderedBand(theVector, theVector); - predict(); - } - } - Ndf = theData.size() - numParameters; - Chi2 = 0.; - for (unsigned int i = 0; i < theData.size(); ++i) { - Chi2 += theData[i].getChi2(); - } - Chi2 /= normChi2[aMethod]; - fitOK = true; - - } catch (int e) { - std::cout << " GblTrajectory::fit exception " << e << std::endl; - ierr = e; - } - return ierr; -} - -/// Write valid trajectory to Millepede-II binary file. -void GblTrajectory::milleOut(MilleBinary &aMille) { - double aValue; - double aErr; - std::vector* indLocal; - std::vector* derLocal; - std::vector* labGlobal; - std::vector* derGlobal; - - if (not constructOK) - return; - -// data: measurements, kinks and external seed - std::vector::iterator itData; - for (itData = theData.begin(); itData != theData.end(); ++itData) { - itData->getAllData(aValue, aErr, indLocal, derLocal, labGlobal, - derGlobal); - aMille.addData(aValue, aErr, *indLocal, *derLocal, *labGlobal, - *derGlobal); - } - aMille.writeRecord(); -} - -/// Print GblTrajectory -/** - * \param [in] level print level (0: minimum, >0: more) - */ -void GblTrajectory::printTrajectory(unsigned int level) { - if (numInnerTrans) { - std::cout << "Composed GblTrajectory, " << numInnerTrans - << " subtrajectories" << std::endl; - } else { - std::cout << "Simple GblTrajectory" << std::endl; - } - if (theDimension.size() < 2) { - std::cout << " 2D-trajectory" << std::endl; - } - std::cout << " Number of GblPoints : " << numAllPoints - << std::endl; - std::cout << " Number of points with offsets: " << numOffsets << std::endl; - std::cout << " Number of fit parameters : " << numParameters - << std::endl; - std::cout << " Number of measurements : " << numMeasurements - << std::endl; - if (externalMeasurements.GetNrows()) { - std::cout << " Number of ext. measurements : " - << externalMeasurements.GetNrows() << std::endl; - } - if (externalPoint) { - std::cout << " Label of point with ext. seed: " << externalPoint - << std::endl; - } - if (constructOK) { - std::cout << " Constructed OK " << std::endl; - } - if (fitOK) { - std::cout << " Fitted OK " << std::endl; - } - if (level > 0) { - if (numInnerTrans) { - std::cout << " Inner transformations" << std::endl; - for (unsigned int i = 0; i < numInnerTrans; ++i) { - innerTransformations[i].Print(); - } - } - if (externalMeasurements.GetNrows()) { - std::cout << " External measurements" << std::endl; - std::cout << " Measurements:" << std::endl; - externalMeasurements.Print(); - std::cout << " Precisions:" << std::endl; - externalPrecisions.Print(); - std::cout << " Derivatives:" << std::endl; - externalDerivatives.Print(); - } - if (externalPoint) { - std::cout << " External seed:" << std::endl; - externalSeed.Print(); - } - if (fitOK) { - std::cout << " Fit results" << std::endl; - std::cout << " Parameters:" << std::endl; - theVector.print(); - std::cout << " Covariance matrix (bordered band part):" - << std::endl; - theMatrix.printMatrix(); - } - } -} - -/// Print \link GblPoint GblPoints \endlink on trajectory -/** - * \param [in] level print level (0: minimum, >0: more) - */ -void GblTrajectory::printPoints(unsigned int level) { - std::cout << "GblPoints " << std::endl; - for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) { - std::vector::iterator itPoint; - for (itPoint = thePoints[iTraj].begin(); - itPoint < thePoints[iTraj].end(); ++itPoint) { - itPoint->printPoint(level); - } - } -} - -/// Print GblData blocks for trajectory -void GblTrajectory::printData() { - std::cout << "GblData blocks " << std::endl; - std::vector::iterator itData; - for (itData = theData.begin(); itData < theData.end(); ++itData) { - itData->printData(); - } -} - -} diff --git a/genfit/GBL/src/MilleBinary.cc b/genfit/GBL/src/MilleBinary.cc deleted file mode 100644 index 2c736e7f93..0000000000 --- a/genfit/GBL/src/MilleBinary.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* - * MilleBinary.cpp - * - * Created on: Aug 31, 2011 - * Author: kleinwrt - */ - -#include "MilleBinary.h" - -//! Namespace for the general broken lines package -namespace gbl { - -/// Create binary file. -/** - * \param [in] fileName File name - * \param [in] doublePrec Flag for storage as double values - * \param [in] aSize Buffer size - */ -MilleBinary::MilleBinary(const std::string fileName, bool doublePrec, - unsigned int aSize) : - binaryFile(fileName.c_str(), std::ios::binary | std::ios::out), intBuffer(), floatBuffer(), doubleBuffer(), doublePrecision( - doublePrec) { - intBuffer.reserve(aSize); - intBuffer.push_back(0); // first word is error counter - if (doublePrecision) { - doubleBuffer.reserve(aSize); - doubleBuffer.push_back(0.); - - } else { - floatBuffer.reserve(aSize); - floatBuffer.push_back(0.); - } -} - -MilleBinary::~MilleBinary() { - binaryFile.close(); -} - -/// Add data block to (end of) record. -/** - * \param [in] aMeas Value - * \param [in] aErr Error - * \param [in] indLocal List of labels of local parameters - * \param [in] derLocal List of derivatives for local parameters - * \param [in] labGlobal List of labels of global parameters - * \param [in] derGlobal List of derivatives for global parameters - */ -void MilleBinary::addData(double aMeas, double aErr, - const std::vector &indLocal, - const std::vector &derLocal, const std::vector &labGlobal, - const std::vector &derGlobal) { - - if (doublePrecision) { - // double values - intBuffer.push_back(0); - doubleBuffer.push_back(aMeas); - for (unsigned int i = 0; i < indLocal.size(); ++i) { - intBuffer.push_back(indLocal[i]); - doubleBuffer.push_back(derLocal[i]); - } - intBuffer.push_back(0); - doubleBuffer.push_back(aErr); - for (unsigned int i = 0; i < labGlobal.size(); ++i) { - if (derGlobal[i]) { - intBuffer.push_back(labGlobal[i]); - doubleBuffer.push_back(derGlobal[i]); - } - } - } else { - // float values - intBuffer.push_back(0); - floatBuffer.push_back(aMeas); - for (unsigned int i = 0; i < indLocal.size(); ++i) { - intBuffer.push_back(indLocal[i]); - floatBuffer.push_back(derLocal[i]); - } - intBuffer.push_back(0); - floatBuffer.push_back(aErr); - for (unsigned int i = 0; i < labGlobal.size(); ++i) { - if (derGlobal[i]) { - intBuffer.push_back(labGlobal[i]); - floatBuffer.push_back(derGlobal[i]); - } - } - } -} - -/// Write record to file. -void MilleBinary::writeRecord() { - - const int recordLength = - (doublePrecision) ? -intBuffer.size() * 2 : intBuffer.size() * 2; - binaryFile.write(reinterpret_cast(&recordLength), - sizeof(recordLength)); - if (doublePrecision) - binaryFile.write(reinterpret_cast(&doubleBuffer[0]), - doubleBuffer.size() * sizeof(doubleBuffer[0])); - else - binaryFile.write(reinterpret_cast(&floatBuffer[0]), - floatBuffer.size() * sizeof(floatBuffer[0])); - binaryFile.write(reinterpret_cast(&intBuffer[0]), - intBuffer.size() * sizeof(intBuffer[0])); -// start with new record - intBuffer.resize(1); - if (doublePrecision) - doubleBuffer.resize(1); - else - floatBuffer.resize(1); -} -} diff --git a/genfit/GBL/src/VMatrix.cc b/genfit/GBL/src/VMatrix.cc deleted file mode 100644 index 8f435095ac..0000000000 --- a/genfit/GBL/src/VMatrix.cc +++ /dev/null @@ -1,430 +0,0 @@ -/* - * VMatrix.cpp - * - * Created on: Feb 15, 2012 - * Author: kleinwrt - */ - -#include "VMatrix.h" - -//! Namespace for the general broken lines package -namespace gbl { - -/*********** simple Matrix based on std::vector **********/ - -VMatrix::VMatrix(const unsigned int nRows, const unsigned int nCols) : - numRows(nRows), numCols(nCols), theVec(nRows * nCols) { -} - -VMatrix::VMatrix(const VMatrix &aMatrix) : - numRows(aMatrix.numRows), numCols(aMatrix.numCols), theVec( - aMatrix.theVec) { - -} - -VMatrix::~VMatrix() { -} - -/// Resize Matrix. -/** - * \param [in] nRows Number of rows. - * \param [in] nCols Number of columns. - */ -void VMatrix::resize(const unsigned int nRows, const unsigned int nCols) { - numRows = nRows; - numCols = nCols; - theVec.resize(nRows * nCols); -} - -/// Get transposed matrix. -/** - * \return Transposed matrix. - */ -VMatrix VMatrix::transpose() const { - VMatrix aResult(numCols, numRows); - for (unsigned int i = 0; i < numRows; ++i) { - for (unsigned int j = 0; j < numCols; ++j) { - aResult(j, i) = theVec[numCols * i + j]; - } - } - return aResult; -} - -/// Get number of rows. -/** - * \return Number of rows. - */ -unsigned int VMatrix::getNumRows() const { - return numRows; -} - -/// Get number of columns. -/** - * \return Number of columns. - */ -unsigned int VMatrix::getNumCols() const { - return numCols; -} - -/// Print matrix. -void VMatrix::print() const { - std::cout << " VMatrix: " << numRows << "*" << numCols << std::endl; - for (unsigned int i = 0; i < numRows; ++i) { - for (unsigned int j = 0; j < numCols; ++j) { - if (j % 5 == 0) { - std::cout << std::endl << std::setw(4) << i << "," - << std::setw(4) << j << "-" << std::setw(4) - << std::min(j + 4, numCols) << ":"; - } - std::cout << std::setw(13) << theVec[numCols * i + j]; - } - } - std::cout << std::endl << std::endl; -} - -/// Multiplication Matrix*Vector. -VVector VMatrix::operator*(const VVector &aVector) const { - VVector aResult(numRows); - for (unsigned int i = 0; i < this->numRows; ++i) { - double sum = 0.0; - for (unsigned int j = 0; j < this->numCols; ++j) { - sum += theVec[numCols * i + j] * aVector(j); - } - aResult(i) = sum; - } - return aResult; -} - -/// Multiplication Matrix*Matrix. -VMatrix VMatrix::operator*(const VMatrix &aMatrix) const { - - VMatrix aResult(numRows, aMatrix.numCols); - for (unsigned int i = 0; i < numRows; ++i) { - for (unsigned int j = 0; j < aMatrix.numCols; ++j) { - double sum = 0.0; - for (unsigned int k = 0; k < numCols; ++k) { - sum += theVec[numCols * i + k] * aMatrix(k, j); - } - aResult(i, j) = sum; - } - } - return aResult; -} - -/// Addition Matrix+Matrix. -VMatrix VMatrix::operator+(const VMatrix &aMatrix) const { - VMatrix aResult(numRows, numCols); - for (unsigned int i = 0; i < numRows; ++i) { - for (unsigned int j = 0; j < numCols; ++j) { - aResult(i, j) = theVec[numCols * i + j] + aMatrix(i, j); - } - } - return aResult; -} - -/// Assignment Matrix=Matrix. -VMatrix &VMatrix::operator=(const VMatrix &aMatrix) { - if (this != &aMatrix) { // Gracefully handle self assignment - numRows = aMatrix.getNumRows(); - numCols = aMatrix.getNumCols(); - theVec.resize(numRows * numCols); - for (unsigned int i = 0; i < numRows; ++i) { - for (unsigned int j = 0; j < numCols; ++j) { - theVec[numCols * i + j] = aMatrix(i, j); - } - } - } - return *this; -} - -/*********** simple symmetric Matrix based on std::vector **********/ - -VSymMatrix::VSymMatrix(const unsigned int nRows) : - numRows(nRows), theVec((nRows * nRows + nRows) / 2) { -} - -VSymMatrix::~VSymMatrix() { -} - -/// Resize symmetric matrix. -/** - * \param [in] nRows Number of rows. - */ -void VSymMatrix::resize(const unsigned int nRows) { - numRows = nRows; - theVec.resize((nRows * nRows + nRows) / 2); -} - -/// Get number of rows (= number of colums). -/** - * \return Number of rows. - */ -unsigned int VSymMatrix::getNumRows() const { - return numRows; -} - -/// Print matrix. -void VSymMatrix::print() const { - std::cout << " VSymMatrix: " << numRows << "*" << numRows << std::endl; - for (unsigned int i = 0; i < numRows; ++i) { - for (unsigned int j = 0; j <= i; ++j) { - if (j % 5 == 0) { - std::cout << std::endl << std::setw(4) << i << "," - << std::setw(4) << j << "-" << std::setw(4) - << std::min(j + 4, i) << ":"; - } - std::cout << std::setw(13) << theVec[(i * i + i) / 2 + j]; - } - } - std::cout << std::endl << std::endl; -} - -/// Subtraction SymMatrix-(sym)Matrix. -VSymMatrix VSymMatrix::operator-(const VMatrix &aMatrix) const { - VSymMatrix aResult(numRows); - for (unsigned int i = 0; i < numRows; ++i) { - for (unsigned int j = 0; j <= i; ++j) { - aResult(i, j) = theVec[(i * i + i) / 2 + j] - aMatrix(i, j); - } - } - return aResult; -} - -/// Multiplication SymMatrix*Vector. -VVector VSymMatrix::operator*(const VVector &aVector) const { - VVector aResult(numRows); - for (unsigned int i = 0; i < numRows; ++i) { - aResult(i) = theVec[(i * i + i) / 2 + i] * aVector(i); - for (unsigned int j = 0; j < i; ++j) { - aResult(j) += theVec[(i * i + i) / 2 + j] * aVector(i); - aResult(i) += theVec[(i * i + i) / 2 + j] * aVector(j); - } - } - return aResult; -} - -/// Multiplication SymMatrix*Matrix. -VMatrix VSymMatrix::operator*(const VMatrix &aMatrix) const { - unsigned int nCol = aMatrix.getNumCols(); - VMatrix aResult(numRows, nCol); - for (unsigned int l = 0; l < nCol; ++l) { - for (unsigned int i = 0; i < numRows; ++i) { - aResult(i, l) = theVec[(i * i + i) / 2 + i] * aMatrix(i, l); - for (unsigned int j = 0; j < i; ++j) { - aResult(j, l) += theVec[(i * i + i) / 2 + j] * aMatrix(i, l); - aResult(i, l) += theVec[(i * i + i) / 2 + j] * aMatrix(j, l); - } - } - } - return aResult; -} - -/*********** simple Vector based on std::vector **********/ - -VVector::VVector(const unsigned int nRows) : - numRows(nRows), theVec(nRows) { -} - -VVector::VVector(const VVector &aVector) : - numRows(aVector.numRows), theVec(aVector.theVec) { - -} - -VVector::~VVector() { -} - -/// Resize vector. -/** - * \param [in] nRows Number of rows. - */ -void VVector::resize(const unsigned int nRows) { - numRows = nRows; - theVec.resize(nRows); -} - -/// Get part of vector. -/** - * \param [in] len Length of part. - * \param [in] start Offset of part. - * \return Part of vector. - */ -VVector VVector::getVec(unsigned int len, unsigned int start) const { - VVector aResult(len); - std::memcpy(&aResult.theVec[0], &theVec[start], sizeof(double) * len); - return aResult; -} - -/// Put part of vector. -/** - * \param [in] aVector Vector with part. - * \param [in] start Offset of part. - */ -void VVector::putVec(const VVector &aVector, unsigned int start) { - std::memcpy(&theVec[start], &aVector.theVec[0], - sizeof(double) * aVector.numRows); -} - -/// Get number of rows. -/** - * \return Number of rows. - */ -unsigned int VVector::getNumRows() const { - return numRows; -} - -/// Print vector. -void VVector::print() const { - std::cout << " VVector: " << numRows << std::endl; - for (unsigned int i = 0; i < numRows; ++i) { - - if (i % 5 == 0) { - std::cout << std::endl << std::setw(4) << i << "-" << std::setw(4) - << std::min(i + 4, numRows) << ":"; - } - std::cout << std::setw(13) << theVec[i]; - } - std::cout << std::endl << std::endl; -} - -/// Subtraction Vector-Vector. -VVector VVector::operator-(const VVector &aVector) const { - VVector aResult(numRows); - for (unsigned int i = 0; i < numRows; ++i) { - aResult(i) = theVec[i] - aVector(i); - } - return aResult; -} - -/// Assignment Vector=Vector. -VVector &VVector::operator=(const VVector &aVector) { - if (this != &aVector) { // Gracefully handle self assignment - numRows = aVector.getNumRows(); - theVec.resize(numRows); - for (unsigned int i = 0; i < numRows; ++i) { - theVec[i] = aVector(i); - } - } - return *this; -} - -/*============================================================================ - from mpnum.F (MillePede-II by V. Blobel, Univ. Hamburg) - ============================================================================*/ -/// Matrix inversion. -/** - * Invert symmetric N-by-N matrix V in symmetric storage mode - * V(1) = V11, V(2) = V12, V(3) = V22, V(4) = V13, . . . - * replaced by inverse matrix - * - * Method of solution is by elimination selecting the pivot on the - * diagonal each stage. The rank of the matrix is returned in NRANK. - * For NRANK ne N, all remaining rows and cols of the resulting - * matrix V are set to zero. - * \exception 1 : matrix is singular. - * \return Rank of matrix. - */ -unsigned int VSymMatrix::invert() { - - const double eps = 1.0E-10; - unsigned int aSize = numRows; - std::vector next(aSize); - std::vector diag(aSize); - int nSize = aSize; - - int first = 1; - for (int i = 1; i <= nSize; ++i) { - next[i - 1] = i + 1; // set "next" pointer - diag[i - 1] = fabs(theVec[(i * i + i) / 2 - 1]); // save abs of diagonal elements - } - next[aSize - 1] = -1; // end flag - - unsigned int nrank = 0; - for (int i = 1; i <= nSize; ++i) { // start of loop - int k = 0; - double vkk = 0.0; - - int jCandidate = first; - int previous = 0; - int last = previous; - // look for pivot - while (jCandidate > 0) { - int jj = (jCandidate * jCandidate + jCandidate) / 2 - 1; - if (fabs(theVec[jj]) > std::max(fabs(vkk), eps * diag[jCandidate - 1])) { - vkk = theVec[jj]; - k = jCandidate; - last = previous; - } - previous = jCandidate; - jCandidate = next[jCandidate - 1]; - } - // pivot found - if (k > 0) { - int kk = (k * k + k) / 2 - 1; - if (last <= 0) { - first = next[k - 1]; - } else { - next[last - 1] = next[k - 1]; - } - next[k - 1] = 0; // index is used, reset - nrank++; // increase rank and ... - - vkk = 1.0 / vkk; - theVec[kk] = -vkk; - int jk = kk - k; - int jl = -1; - for (int j = 1; j <= nSize; ++j) { // elimination - if (j == k) { - jk = kk; - jl += j; - } else { - if (j < k) { - ++jk; - } else { - jk += j - 1; - } - - double vjk = theVec[jk]; - theVec[jk] = vkk * vjk; - int lk = kk - k; - if (j >= k) { - for (int l = 1; l <= k - 1; ++l) { - ++jl; - ++lk; - theVec[jl] -= theVec[lk] * vjk; - } - ++jl; - lk = kk; - for (int l = k + 1; l <= j; ++l) { - ++jl; - lk += l - 1; - theVec[jl] -= theVec[lk] * vjk; - } - } else { - for (int l = 1; l <= j; ++l) { - ++jl; - ++lk; - theVec[jl] -= theVec[lk] * vjk; - } - } - } - } - } else { - for (int n = 1; n <= nSize; ++n) { - if (next[n - 1] >= 0) { - int nn = (n * n - n) / 2 - 1; - for (int j = 1; j <= nSize; ++j) { - if (next[j - 1] >= 0) { - theVec[nn + j] = 0.0; // clear matrix row/col - } - } - } - } - throw 1; // singular - } - } - for (int ij = 0; ij < (nSize * nSize + nSize) / 2; ++ij) { - theVec[ij] = -theVec[ij]; // finally reverse sign of all matrix elements - } - return nrank; -} -} diff --git a/genfit/GFRave/include/GFRaveConverters.h b/genfit/GFRave/include/GFRaveConverters.h deleted file mode 100644 index 9c6dc58a21..0000000000 --- a/genfit/GFRave/include/GFRaveConverters.h +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright 2008-2009, Technische Universitaet Muenchen, - Authors: Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** - * @author Johannes Rauch (Technische Universität München, original author) - * - */ - -/** @addtogroup GFRave - * @{ - */ - - -#ifndef GFRAVECONVERTERS_H -#define GFRAVECONVERTERS_H - -#include "AbsTrackRep.h" -#include "DetPlane.h" -#include "Track.h" -#include "GFRaveVertex.h" -#include "GFRaveVertexFactory.h" - -#include -#include -#include - -#include -#include -#include - -#include - - -/** - * @brief Collection of converter functions - **/ -namespace genfit { - - // GENFIT to RAVE - - /** Convert a vector of genfit::Tracks to rave::Tracks - * also builds a map of unique ids to genfit::Tracks; These ids are stored in the rave::tracks. They are counted from startID. - * The map has to be passed to the GFRavePropagator, so that it can access the trackreps of the genfit::Tracks corresponding to the - * rave::tracks. - * If a vector of MeasuredStateOnPlane is provided, they will be used (instead of the tracks fitted states) to calculate the rave::Track parameters. - * Ownership over MeasuredStateOnPlane will be taken. - */ - std::vector < rave::Track > GFTracksToTracks(const std::vector < genfit::Track* > & GFTracks, - std::vector < genfit::MeasuredStateOnPlane* > * GFStates, // = NULL - std::map& IdGFTrackStateMap, - int startID = 0); - - rave::Track GFTrackToTrack(trackAndState, int id = -1, std::string tag=""); - //rave::Track MeasuredStateOnPlaneToTrack(const MeasuredStateOnPlane* state, const rave::Track& orig); - //rave::Track MeasuredStateOnPlaneToTrack(const MeasuredStateOnPlane* state, int id = -1, Track* originaltrack = NULL, std::string tag=""); - - // RAVE to GENFIT - /** set state and cov of a MeasuredStateOnPlane according to rave track - */ - void setData(const rave::Track & orig, MeasuredStateOnPlane* state); - - GFRaveVertex* RaveToGFVertex(const rave::Vertex &, const std::map& IdGFTrackStateMap); - void RaveToGFVertices(std::vector *, const std::vector &, const std::map& IdGFTrackStateMap); - - SharedPlanePtr PlaneToGFDetPlane(const ravesurf::Plane& rplane); - - // RAVE to ROOT - TVector3 Point3DToTVector3(const rave::Point3D&); - TVector3 Vector3DToTVector3(const rave::Vector3D&); - - TMatrixDSym Covariance3DToTMatrixDSym(const rave::Covariance3D&); - TVectorD Vector6DToTVectorD(const rave::Vector6D&); - TMatrixDSym Covariance6DToTMatrixDSym(const rave::Covariance6D&); - - // ROOT to RAVE - rave::Point3D TVector3ToPoint3D(const TVector3 &); - rave::Covariance3D TMatrixDSymToCovariance3D(const TMatrixDSym&); - - -} /* End of namespace genfit */ -/** @} */ - -#endif // GFRAVECONVERTERS_H - diff --git a/genfit/GFRave/include/GFRaveMagneticField.h b/genfit/GFRave/include/GFRaveMagneticField.h deleted file mode 100644 index 400b28d3b1..0000000000 --- a/genfit/GFRave/include/GFRaveMagneticField.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** - * @author Johannes Rauch (Technische Universität München, original author) - */ - -/** @addtogroup GFRave - * @{ - */ - -#ifndef GFRAVEMAGNETICFIELD_H -#define GFRAVEMAGNETICFIELD_H - -#include - - -namespace genfit { - -/** - * @brief GFRaveMagneticField class - * Uses the FieldManager to provide a magnetic field to rave. - */ -class GFRaveMagneticField : public rave::MagneticField { - public: - GFRaveMagneticField(){}; - virtual GFRaveMagneticField * copy() const; - virtual ~GFRaveMagneticField(){}; - - virtual rave::Vector3D inTesla ( const rave::Point3D & ) const; - - private: - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // GFRAVEMAGNETICFIELD_H diff --git a/genfit/GFRave/include/GFRavePropagator.h b/genfit/GFRave/include/GFRavePropagator.h deleted file mode 100644 index 35d2d964e2..0000000000 --- a/genfit/GFRave/include/GFRavePropagator.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** - * @author Johannes Rauch (Technische Universität München, original author) - * - */ - -/** @addtogroup GFRave - * @{ - */ - -#ifndef GFRAVEPROPAGATOR_H -#define GFRAVEPROPAGATOR_H - -#include "GFRaveVertexFactory.h" -#include "AbsTrackRep.h" - -#include -#include -#include -#include - -#include - - -namespace genfit { - -/** - * @brief GFRavePropagator class - * - * Inherits from rave::Propagator. A map has to be provided, - * containing pointers the genfit::Tracks, as well as pointers to clones of fitted states. - * The GFRavePropagator uses the information of the rave::track to set - * the state and covariance of the corresponding MeasuredStateOnPlane, - * extrapolates and then returns a new rave::track with the - * extrapolated state and covariance. - */ -class GFRavePropagator : public rave::Propagator -{ - public: - GFRavePropagator(); - virtual GFRavePropagator* copy() const; - virtual rave::Track closestTo ( const rave::Track &, - const rave::Point3D &, bool transverse ) const; - virtual std::pair < rave::Track, double > to ( const rave::Track & orig, - const ravesurf::Plane & ) const; - virtual std::pair < rave::Track, double > to ( const rave::Track & orig, - const ravesurf::Cylinder & ) const; - - virtual ~GFRavePropagator(); - - void setIdGFTrackStateMap(std::map < int, genfit::trackAndState > * map); - - private: - - // data members - std::map < int, genfit::trackAndState > * IdGFTrackStateMap_; // pointers to genfit::tracks and measuredStateOnPlanes via rave track ID -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // GFRAVEPROPAGATOR_H diff --git a/genfit/GFRave/include/GFRaveTrackParameters.h b/genfit/GFRave/include/GFRaveTrackParameters.h deleted file mode 100644 index ee8426d4c0..0000000000 --- a/genfit/GFRave/include/GFRaveTrackParameters.h +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** - * @author Johannes Rauch (Technische Universität München, original author) - * - */ - -/** @addtogroup GFRave - * @{ - */ - -#ifndef GFRAVETRACKPARAMETERS_H -#define GFRAVETRACKPARAMETERS_H - -#include "Track.h" -#include "AbsTrackRep.h" - -#include -#include -#include -#include -#include - -#include - - -namespace genfit { - -/** - * @brief GFRaveTrackParameters class - * Contains a pointer to the original genfit::Track, the weight of the track in the vertex, - * and smoothed (with the vertex information) state and covariance of the track. - */ -class GFRaveTrackParameters : public TObject -{ - public: - // constructors, destructors - GFRaveTrackParameters(); - GFRaveTrackParameters(const Track* track, MeasuredStateOnPlane* originalState, double weight, const TVectorD & state6, const TMatrixDSym & cov6x6, bool isSmoothed); - GFRaveTrackParameters(const Track* track, MeasuredStateOnPlane* originalState, double weight); - - // Accessors - double getWeight() const {return weight_;} - - bool hasTrack() const {return originalTrack_.GetObject() != NULL;} - const Track* getTrack() const {return static_cast(originalTrack_.GetObject());} - - UInt_t GetUniqueID() const {return originalTrack_.GetUniqueID();} - - bool hasSmoothedData() const {return hasSmoothedData_;} - TVectorD getState() const {return state_;} - TVector3 getPos() const; - TVector3 getMom() const; - const TMatrixDSym & getCov() const {return cov_;} - - double getCharge() const; - double getPdg() const; - - void Print(const Option_t* = "") const; - - private: - - const TRef originalTrack_; // NO ownership. We use TRef, since the Tracks could be stored in another file or tree. - - double weight_; // weight of the track in the vertex - TVectorD state_; // x, y, z, px, py, pz - TMatrixDSym cov_; // 6x6 covariance matrix - bool hasSmoothedData_; // true if state_ is forced to go through the vertex - - private: - ClassDef(GFRaveTrackParameters, 1) -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // GFRAVETRACKPARAMETERS_H diff --git a/genfit/GFRave/include/GFRaveVertex.h b/genfit/GFRave/include/GFRaveVertex.h deleted file mode 100644 index dceee52397..0000000000 --- a/genfit/GFRave/include/GFRaveVertex.h +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** - * @author Johannes Rauch (Technische Universität München, original author) - * - */ - -/** @addtogroup GFRave - * @{ - */ - -#ifndef GFRAVEVERTEX_H -#define GFRAVEVERTEX_H - -#include "AbsTrackRep.h" -#include "Track.h" -#include "GFRaveTrackParameters.h" - - -namespace genfit { - -/** - * @brief GFRaveVertex class - * - * A Vertex contains information about its position and covariance. - * The tracks the vertex is consisting of are stored in smoothedTracks_. - * These GFRaveTrackParameters contain the weight of the corresponding track - * in the vertex, smoothed track parameters and a pointer to the original - * unaltered genfit::Track. - */ -class GFRaveVertex : public TObject { - - public: - // constructors, destructors - GFRaveVertex(); - GFRaveVertex(const TVector3 & pos, const TMatrixDSym & cov, - const std::vector < genfit::GFRaveTrackParameters* > & smoothedTracks, - double ndf, double chi2, int id = -1); - - GFRaveVertex(const GFRaveVertex &); - - GFRaveVertex& operator=(GFRaveVertex); - void swap(GFRaveVertex&); - - ~GFRaveVertex(); - - - // Accessors - //! get Position - TVector3 getPos() const {return pos_;} - - //!get 3x3 covariance (error) of position. - TMatrixDSym getCov() const {return cov_;} - - double getNdf() const {return ndf_;} - double getChi2() const {return chi2_;} - - //! Number of tracks the vertex is made of - unsigned int getNTracks() const {return smoothedTracks_.size();} - GFRaveTrackParameters* getParameters(unsigned int i) const {return smoothedTracks_[i];} - - int getId() const {return id_;} - - void Print(const Option_t* = "") const; - - - private: - - TVector3 pos_; // position of the vertex - TMatrixDSym cov_; // error of the vertex position - double ndf_; - double chi2_; - int id_; // id of the rave::vertex the GFVertex is created from - - std::vector < genfit::GFRaveTrackParameters* > smoothedTracks_; //-> track parameters of smoothed (with the vertex information) tracks, weights and original tracks; Vertex has ownership! - - public: - ClassDef(GFRaveVertex, 1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // GFRAVEVERTEX_H diff --git a/genfit/GFRave/include/GFRaveVertexFactory.h b/genfit/GFRave/include/GFRaveVertexFactory.h deleted file mode 100644 index 59a05d61cd..0000000000 --- a/genfit/GFRave/include/GFRaveVertexFactory.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** - * @author Johannes Rauch (Technische Universität München, original author) - * - */ - -/** @addtogroup GFRave - * @{ - */ - - -#ifndef GFRAVEVERTEXFACTORY_H -#define GFRAVEVERTEXFACTORY_H - -#include "GFRaveVertex.h" -#include "Track.h" -#include "MeasuredStateOnPlane.h" - -#include - - -namespace rave { - class VertexFactory; - class MagneticField; - class Propagator; -} - -namespace genfit { - -/** - * @brief Simple struct containing a Track pointer and a MeasuredStateOnPlane. Used in GFRave. - */ -struct trackAndState { - const Track* track_; // pointer to original track - MeasuredStateOnPlane* state_; // pointer to copy of fitted state; can be altered (extrapolated) during vertexing -}; - - -/** - * @brief Vertex factory for producing GFRaveVertex objects from Track objects. - * - * The GFRaveVertexFactory is basically a wrapper around the rave::VertexFactory. - * It takes care of initializing the rave::VertexFactory, building the necessary maps, - * convert GENFIT to rave objects and vice versa. - **/ -class GFRaveVertexFactory { - public: - // constructors, destructors - GFRaveVertexFactory(int verbosity = 0, bool useVacuumPropagator = false); - ~GFRaveVertexFactory(); - - // functions - void findVertices ( std::vector < genfit::GFRaveVertex* > *, const std::vector < genfit::Track* > &, bool use_beamspot=false ); - //! MeasuredStateOnPlanes will be used (instead of the tracks fitted states) to calculate the rave::Track parameters. takes ownership of MeasuredStateOnPlanes. - void findVertices ( std::vector < genfit::GFRaveVertex* > *, const std::vector < genfit::Track* > &, std::vector < genfit::MeasuredStateOnPlane* > &, bool use_beamspot=false ); - - void setBeamspot(const TVector3 & pos, const TMatrixDSym & cov); - - /** - * Set the reconstruction method. See http://projects.hepforge.org/rave/trac/wiki/RaveMethods - * Smoothing has to be turned on! e.g. kalman-smoothing:1 - */ - void setMethod(const std::string & method); - - private: - - void clearMap(); - - // data members - std::map IdGFTrackStateMap_; // map of copies of the cardinal MeasuredStateOnPlanes for the GFRavePropagator; ownership of MeasuredStateOnPlanes is HERE!!! - rave::VertexFactory* factory_; // Ownership - rave::MagneticField* magneticField_; // Ownership - rave::Propagator* propagator_; // Ownership - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // GFRAVEVERTEXFACTORY_H diff --git a/genfit/GFRave/src/GFRaveConverters.cc b/genfit/GFRave/src/GFRaveConverters.cc deleted file mode 100644 index ab0996c3af..0000000000 --- a/genfit/GFRave/src/GFRaveConverters.cc +++ /dev/null @@ -1,348 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - - -#include "GFRaveConverters.h" - -#include "Exception.h" - -#include "rave/Plane.h" - -#include "GFRaveTrackParameters.h" - -#include - - -namespace genfit { - - -std::vector < rave::Track > -GFTracksToTracks(const std::vector < genfit::Track* > & GFTracks, - std::vector < genfit::MeasuredStateOnPlane* > * GFStates, - std::map& IdGFTrackStateMap, - int startID){ - - unsigned int ntracks(GFTracks.size()); - - if (GFStates != NULL) - if (GFTracks.size() != GFStates->size()) { - Exception exc("GFTracksToTracks ==> GFStates has not the same size as GFTracks!",__LINE__,__FILE__); - throw exc; - } - - std::vector < rave::Track > ravetracks; - ravetracks.reserve(ntracks); - - for (unsigned int i=0; i genfit::Track is NULL",__LINE__,__FILE__); - throw exc; - } - - // only convert successfully fitted tracks! - if (!GFTracks[i]->getFitStatus(GFTracks[i]->getCardinalRep())->isFitConverged()) continue; - - if (IdGFTrackStateMap.count(startID) > 0){ - Exception exc("GFTracksToTracks ==> IdGFTrackStateMap has already an entry for this id",__LINE__,__FILE__); - throw exc; - } - IdGFTrackStateMap[startID].track_ = GFTracks[i]; - if (GFStates == NULL) - IdGFTrackStateMap[startID].state_ = new MeasuredStateOnPlane(GFTracks[i]->getFittedState()); // here clones are made so that the state of the original GFTracks and their TrackReps will not be altered by the vertexing process - else - IdGFTrackStateMap[startID].state_ = (*GFStates)[i]; - - ravetracks.push_back(GFTrackToTrack(IdGFTrackStateMap[startID], startID) ); - - ++startID; - } - - //std::cout << "IdGFTrackStateMap size " << IdGFTrackStateMap.size() << std::endl; - return ravetracks; -} - - -rave::Track -GFTrackToTrack(trackAndState trackAndState, int id, std::string tag){ - - if (trackAndState.track_ == NULL) { - Exception exc("GFTrackToTrack ==> originaltrack is NULL",__LINE__,__FILE__); - throw exc; - } - - if (! trackAndState.track_->getFitStatus()->isFitConverged()) { - Exception exc("GFTrackToTrack ==> Trackfit is not converged",__LINE__,__FILE__); - throw exc; - } - - TVector3 pos, mom; - TMatrixDSym cov; - - trackAndState.track_->getFittedState().getPosMomCov(pos, mom, cov); - - // state - rave::Vector6D ravestate(pos.X(), pos.Y(), pos.Z(), - mom.X(), mom.Y(), mom.Z()); - - // covariance - rave::Covariance6D ravecov(cov(0,0), cov(1,0), cov(2,0), - cov(1,1), cov(2,1), cov(2,2), - cov(3,0), cov(4,0), cov(5,0), - cov(3,1), cov(4,1), cov(5,1), - cov(3,2), cov(4,2), cov(5,2), - cov(3,3), cov(4,3), cov(5,3), - cov(4,4), cov(5,4), cov(5,5)); - - //std::cerr<<"create rave track with id " << id << std::endl; - //std::cerr<<" pos: "; Point3DToTVector3(ravestate.position()).Print(); - //std::cerr<<" mom: "; Vector3DToTVector3(ravestate.momentum()).Print(); - - rave::Track ret(id, ravestate, ravecov, - trackAndState.track_->getFitStatus()->getCharge(), - trackAndState.track_->getFitStatus()->getChi2(), - trackAndState.track_->getFitStatus()->getNdf(), - static_cast(const_cast(trackAndState.track_)), tag); - - //std::cout << "ret.originalObject() " << ret.originalObject() << "\n"; - //std::cout << "ret.id() " << ret.id() << "\n"; - - return ret; -} - - -void -setData(const rave::Track& orig, MeasuredStateOnPlane* state){ - - state->setPosMomCov(TVector3(orig.state().x(), orig.state().y(), orig.state().z()), - TVector3(orig.state().px(), orig.state().py(), orig.state().pz()), - Covariance6DToTMatrixDSym(orig.error())); - -} - - -GFRaveVertex* -RaveToGFVertex(const rave::Vertex & raveVertex, - const std::map& IdGFTrackStateMap){ - - if (!(raveVertex.isValid())) { - Exception exc("RaveToGFVertex ==> rave Vertex is not valid!",__LINE__,__FILE__); - throw exc; - } - - std::vector < std::pair < float, rave::Track > > raveWeightedTracks(raveVertex.weightedTracks()); - std::vector < std::pair < float, rave::Track > > raveSmoothedTracks(raveVertex.weightedRefittedTracks()); - - int id; - unsigned int nTrks(raveWeightedTracks.size()); - - // check if rave vertex has refitted tracks - bool smoothing(true); - if (! (raveVertex.hasRefittedTracks()) ) { - smoothing = false; - } - - // check numbers of tracks and smoothed tracks - if (smoothing && nTrks != raveSmoothedTracks.size()){ - Exception exc("RaveToGFVertex ==> number of smoothed tracks != number of tracks",__LINE__,__FILE__); - throw exc; - } - - // (smoothed) track parameters - std::vector < GFRaveTrackParameters* > trackParameters; - trackParameters.reserve(nTrks); - - // convert tracks - for (unsigned int i=0; i rave track id is not present in IdGFTrackStateMap",__LINE__,__FILE__); - throw exc; - } - - GFRaveTrackParameters* trackparams; - - if(smoothing) { - // convert smoothed track parameters - trackparams = new GFRaveTrackParameters(IdGFTrackStateMap.at(id).track_, //track - IdGFTrackStateMap.at(id).state_, //state - raveWeightedTracks[i].first, //weight - Vector6DToTVectorD(raveSmoothedTracks[i].second.state()), //smoothed state - Covariance6DToTMatrixDSym(raveSmoothedTracks[i].second.error()), //smoothed cov - true); - } - else { - // convert track parameters, no smoothed tracks available - trackparams = new GFRaveTrackParameters(IdGFTrackStateMap.at(id).track_, //track - IdGFTrackStateMap.at(id).state_, //state - raveWeightedTracks[i].first, //weight - Vector6DToTVectorD(raveWeightedTracks[i].second.state()), //state - Covariance6DToTMatrixDSym(raveWeightedTracks[i].second.error()), //cov - false); - } - trackParameters.push_back(trackparams); - } - - return new GFRaveVertex(Point3DToTVector3(raveVertex.position()), - Covariance3DToTMatrixDSym(raveVertex.error()), - trackParameters, - raveVertex.ndf(), raveVertex.chiSquared(), raveVertex.id()); -} - -void -RaveToGFVertices(std::vector * GFVertices, - const std::vector & raveVertices, - const std::map& IdGFTrackStateMap){ - - unsigned int nVert(raveVertices.size()); - - GFVertices->reserve(nVert); - - for (unsigned int i=0; ipush_back(RaveToGFVertex(raveVertices[i], IdGFTrackStateMap)); - } -} - - -SharedPlanePtr -PlaneToGFDetPlane(const ravesurf::Plane& rplane) { - return SharedPlanePtr(new DetPlane(Point3DToTVector3(rplane.position()), - Vector3DToTVector3(rplane.normalVector()) )); -} - - -TVector3 -Point3DToTVector3(const rave::Point3D& v) { - return TVector3(v.x(), v.y(), v.z()); -} - -TVector3 -Vector3DToTVector3(const rave::Vector3D& v) { - return TVector3(v.x(), v.y(), v.z()); -} - - -TMatrixDSym -Covariance3DToTMatrixDSym(const rave::Covariance3D& ravecov){ - TMatrixDSym cov(3); - - cov(0,0) = ravecov.dxx(); - cov(0,1) = ravecov.dxy(); - cov(0,2) = ravecov.dxz(); - - cov(1,0) = ravecov.dxy(); - cov(1,1) = ravecov.dyy(); - cov(1,2) = ravecov.dyz(); - - cov(2,0) = ravecov.dxz(); - cov(2,1) = ravecov.dyz(); - cov(2,2) = ravecov.dzz(); - - return cov; -} - - -TVectorD -Vector6DToTVectorD(const rave::Vector6D& ravevec){ - TVectorD vec(6); - - vec[0] = ravevec.x(); - vec[1] = ravevec.y(); - vec[2] = ravevec.z(); - - vec[3] = ravevec.px(); - vec[4] = ravevec.py(); - vec[5] = ravevec.pz(); - - return vec; -} - - -TMatrixDSym -Covariance6DToTMatrixDSym(const rave::Covariance6D& ravecov){ - TMatrixDSym cov(6); - - cov(0,0) = ravecov.dxx(); - cov(0,1) = ravecov.dxy(); - cov(0,2) = ravecov.dxz(); - cov(0,3) = ravecov.dxpx(); - cov(0,4) = ravecov.dxpy(); - cov(0,5) = ravecov.dxpz(); - - cov(1,0) = ravecov.dxy(); - cov(1,1) = ravecov.dyy(); - cov(1,2) = ravecov.dyz(); - cov(1,3) = ravecov.dypx(); - cov(1,4) = ravecov.dypy(); - cov(1,5) = ravecov.dypz(); - - cov(2,0) = ravecov.dxz(); - cov(2,1) = ravecov.dyz(); - cov(2,2) = ravecov.dzz(); - cov(2,3) = ravecov.dzpx(); - cov(2,4) = ravecov.dzpy(); - cov(2,5) = ravecov.dzpz(); - - cov(3,0) = ravecov.dxpx(); - cov(3,1) = ravecov.dypx(); - cov(3,2) = ravecov.dzpx(); - cov(3,3) = ravecov.dpxpx(); - cov(3,4) = ravecov.dpxpy(); - cov(3,5) = ravecov.dpxpz(); - - cov(4,0) = ravecov.dxpy(); - cov(4,1) = ravecov.dypy(); - cov(4,2) = ravecov.dzpy(); - cov(4,3) = ravecov.dpxpy(); - cov(4,4) = ravecov.dpypy(); - cov(4,5) = ravecov.dpypz(); - - cov(5,0) = ravecov.dxpz(); - cov(5,1) = ravecov.dypz(); - cov(5,2) = ravecov.dzpz(); - cov(5,3) = ravecov.dpxpz(); - cov(5,4) = ravecov.dpypz(); - cov(5,5) = ravecov.dpzpz(); - - return cov; -} - - -rave::Point3D -TVector3ToPoint3D(const TVector3 & vec){ - return rave::Point3D(vec.X(), vec.Y(), vec.Z()); -} - - -rave::Covariance3D -TMatrixDSymToCovariance3D(const TMatrixDSym & matrix){ - if (matrix.GetNrows()!=3) { - Exception exc("TMatrixDSymToCovariance3D ==> TMatrixDSym is not 3x3!",__LINE__,__FILE__); - throw exc; - } - - return rave::Covariance3D(matrix(0,0), matrix(0,1), matrix(0,2), - matrix(1,1), matrix(1,2), matrix(2,2)); - -} - - -} // end of namespace genfit - diff --git a/genfit/GFRave/src/GFRaveLinkDef.h b/genfit/GFRave/src/GFRaveLinkDef.h deleted file mode 100644 index aa79ec764b..0000000000 --- a/genfit/GFRave/src/GFRaveLinkDef.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - - -#pragma link C++ class genfit::GFRaveVertex+; -#pragma link C++ class genfit::GFRaveTrackParameters+; - -#endif - diff --git a/genfit/GFRave/src/GFRaveMagneticField.cc b/genfit/GFRave/src/GFRaveMagneticField.cc deleted file mode 100644 index e30581e886..0000000000 --- a/genfit/GFRave/src/GFRaveMagneticField.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - - -#include "GFRaveMagneticField.h" -#include - -#include - - -namespace genfit { - -GFRaveMagneticField * -GFRaveMagneticField::copy() const{ - return new GFRaveMagneticField(*this); -} - - -rave::Vector3D -GFRaveMagneticField::inTesla ( const rave::Point3D & position) const -{ - TVector3 pos(position.x(), position.y(), position.z()); - - TVector3 B = FieldManager::getInstance()->getFieldVal(pos); // magnetic field in kGauss - B *= 1.E-1; - - return rave::Vector3D (B.X(), B.Y(), B.Z()); -} - - -} /* End of namespace genfit */ diff --git a/genfit/GFRave/src/GFRavePropagator.cc b/genfit/GFRave/src/GFRavePropagator.cc deleted file mode 100644 index 0bbbd35ede..0000000000 --- a/genfit/GFRave/src/GFRavePropagator.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - - -#include "GFRavePropagator.h" -#include "GFRaveConverters.h" -#include "Exception.h" - -#include - - -namespace genfit { - -GFRavePropagator::GFRavePropagator() : - IdGFTrackStateMap_(NULL) -{ - //std::cout << "GFRavePropagator::GFRavePropagator() \n"; -} - -GFRavePropagator* -GFRavePropagator::copy() const -{ - //std::cout << "GFRavePropagator::copy() \n"; - return new GFRavePropagator(*this); -} - - -GFRavePropagator::~GFRavePropagator() -{ - //std::cout << "GFRavePropagator::~GFRavePropagator() \n"; -} - - -std::pair < rave::Track, double > -GFRavePropagator::to ( const rave::Track & orig, - const ravesurf::Cylinder & rcyl ) const -{ - // todo to be implemented!! - Exception exc("GFRavePropagator::to (cylinder) ==> not yet implemented!",__LINE__,__FILE__); - throw exc; -} - - -std::pair < rave::Track, double > -GFRavePropagator::to ( const rave::Track & orig, - const ravesurf::Plane & rplane ) const -{ - // will throw Exception if extrapolation does not work - double path = IdGFTrackStateMap_->at(orig.id()).state_->extrapolateToPlane(PlaneToGFDetPlane(rplane)); - - std::pair < rave::Track, double > ret(GFTrackToTrack(IdGFTrackStateMap_->at(orig.id()), orig.id(), orig.tag()), path); - return ret; -} - - -rave::Track -GFRavePropagator::closestTo ( const rave::Track & orig, - const rave::Point3D & pt, bool transverse ) const -{ - - if (transverse){ - Exception exc("GFRavePropagator::closestTo ==> transverse is true, not implemented!",__LINE__,__FILE__); - throw exc; - } - - TVector3 point(Point3DToTVector3(pt)); - IdGFTrackStateMap_->at(orig.id()).state_->extrapolateToPoint(point); - - return GFTrackToTrack(IdGFTrackStateMap_->at(orig.id()), orig.id(), orig.tag()); -} - - -void -GFRavePropagator::setIdGFTrackStateMap(std::map < int, genfit::trackAndState > * map){ - std::cout << "GFRavePropagator::setIdGFMeasuredStateOnPlaneMap() \n"; - - IdGFTrackStateMap_ = map; - - if (IdGFTrackStateMap_==NULL) { - Exception exc("GFRavePropagator::setIdGFMeasuredStateOnPlaneMap ==> map is NULL!",__LINE__,__FILE__); - throw exc; - } - //std::cout<<"IdGFTrackStateMap_: " << (int)IdGFTrackStateMap_ << std::endl; -} - -} /* End of namespace genfit */ diff --git a/genfit/GFRave/src/GFRaveTrackParameters.cc b/genfit/GFRave/src/GFRaveTrackParameters.cc deleted file mode 100644 index fe152b7aed..0000000000 --- a/genfit/GFRave/src/GFRaveTrackParameters.cc +++ /dev/null @@ -1,112 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - - -#include "GFRaveTrackParameters.h" -#include "GFRaveConverters.h" -#include "Exception.h" - -#include - - -namespace genfit { - - -GFRaveTrackParameters::GFRaveTrackParameters() : - originalTrack_(NULL), - weight_(0), - state_(6), - cov_(6,6), - hasSmoothedData_(false) -{ - ; -} - - -GFRaveTrackParameters::GFRaveTrackParameters(const Track* track, MeasuredStateOnPlane* originalState, double weight, const TVectorD & state6, const TMatrixDSym & cov6x6, bool isSmoothed) : - originalTrack_(const_cast(track)), - weight_(weight), - state_(state6), - cov_(cov6x6), - hasSmoothedData_(isSmoothed) -{ - if (state_.GetNrows() != 6) { - Exception exc("GFRaveTrackParameters ==> State is not 6D!",__LINE__,__FILE__); - throw exc; - } - if (cov_.GetNrows()!=6) { - Exception exc("GFRaveTrackParameters ==> Covariance is not 6D!",__LINE__,__FILE__); - throw exc; - } - -} - - -GFRaveTrackParameters::GFRaveTrackParameters(const Track* track, MeasuredStateOnPlane* originalState, double weight) : - originalTrack_(const_cast(track)), - weight_(weight), - state_(1,6), - cov_(6,6), - hasSmoothedData_(false) -{ - ; -} - - -TVector3 -GFRaveTrackParameters::getPos() const { - return TVector3(state_[0], state_[1], state_[2]); -} - - -TVector3 -GFRaveTrackParameters::getMom() const { - return TVector3(state_[3], state_[4], state_[5]); -} - - -double -GFRaveTrackParameters::getCharge() const { - return getTrack()->getFitStatus()->getCharge(); -} - - -double -GFRaveTrackParameters::getPdg() const{ - if (hasTrack()) - return getTrack()->getCardinalRep()->getPDG(); - else { - Exception exc("GFRaveTrackParameters::getPdg() ==> no genfit::Track available!",__LINE__,__FILE__); - throw exc; - } -} - - -void -GFRaveTrackParameters::Print(const Option_t*) const { - std::cout << "weight: " << getWeight() << "\n"; - if (!hasSmoothedData_) std::cout << "state and cov are NOT smoothed! \n"; - std::cout << "state: "; getState().Print(); - std::cout << "cov: "; getCov().Print(); - if (hasTrack()) {std::cout << "genfit::Track: "; getTrack()->Print();} - else std::cout << "NO genfit::Track pointer \n"; -} - - -} /* End of namespace genfit */ diff --git a/genfit/GFRave/src/GFRaveVertex.cc b/genfit/GFRave/src/GFRaveVertex.cc deleted file mode 100644 index 8a59b10344..0000000000 --- a/genfit/GFRave/src/GFRaveVertex.cc +++ /dev/null @@ -1,130 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - - -#include "GFRaveVertex.h" -#include "GFRaveConverters.h" -#include - -#include - -namespace genfit { - -//#define COUNT - -#ifdef COUNT -static int instCount(0); -#endif - -GFRaveVertex::GFRaveVertex() : - cov_(3,3), - ndf_(0), - chi2_(0), - id_(-1) -{ -#ifdef COUNT - std::cerr << "GFRaveVertex::GFRaveVertex() - Number of objects: " << ++instCount << std::endl; -#endif -} - - -GFRaveVertex::GFRaveVertex(const TVector3 & pos, const TMatrixDSym& cov, - const std::vector < GFRaveTrackParameters* > & smoothedTracks, - double ndf, double chi2, int id) : - pos_(pos), - cov_(cov), - ndf_(ndf), - chi2_(chi2), - id_(id), - smoothedTracks_(smoothedTracks) -{ - if (cov_.GetNrows()!=3 || cov_.GetNcols()!=3) { - Exception exc("GFRaveVertex ==> Covariance is not 3x3!",__LINE__,__FILE__); - throw exc; - } - -#ifdef COUNT - std::cerr << "GFRaveVertex::GFRaveVertex(...) - Number of objects: " << ++instCount << std::endl; -#endif -} - - -GFRaveVertex::GFRaveVertex(const GFRaveVertex & vertex) : - TObject(vertex), - pos_(vertex.pos_), - cov_(vertex.cov_), - ndf_(vertex.ndf_), - chi2_(vertex.chi2_), - id_(vertex.id_) -{ - unsigned int nPar = vertex.smoothedTracks_.size(); - smoothedTracks_.reserve(nPar); - for (unsigned int i=0; ipos_, other.pos_); - this->cov_.ResizeTo(other.cov_); - std::swap(this->cov_, other.cov_); - std::swap(this->ndf_, other.ndf_); - std::swap(this->chi2_, other.chi2_); - std::swap(this->id_, other.id_); - std::swap(this->smoothedTracks_, other.smoothedTracks_); -} - - -GFRaveVertex::~GFRaveVertex(){ - unsigned int nPar = smoothedTracks_.size(); - for (unsigned int i=0; iPrint(); - } -} - -} /* End of namespace genfit */ - diff --git a/genfit/GFRave/src/GFRaveVertexFactory.cc b/genfit/GFRave/src/GFRaveVertexFactory.cc deleted file mode 100644 index bcf5f6e7db..0000000000 --- a/genfit/GFRave/src/GFRaveVertexFactory.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include - -#include "GFRaveVertexFactory.h" -#include "GFRaveConverters.h" -#include "GFRaveVertex.h" - -#include "GFRaveMagneticField.h" -#include "GFRavePropagator.h" - -#include "Exception.h" - -#include "rave/Propagator.h" -#include "rave/MagneticField.h" -#include "rave/VertexFactory.h" -#include "rave/Vertex.h" -#include "rave/Ellipsoid3D.h" - - -namespace genfit { - -GFRaveVertexFactory::GFRaveVertexFactory(int verbosity, bool useVacuumPropagator) { - - if (useVacuumPropagator) { - propagator_ = new rave::VacuumPropagator(); - } - else { - propagator_ = new GFRavePropagator(); - (static_cast(propagator_))->setIdGFTrackStateMap(&IdGFTrackStateMap_); - } - - magneticField_ = new GFRaveMagneticField(); - - if (verbosity > 0) ++verbosity; // verbosity has to be >1 for rave - - factory_ = new rave::VertexFactory(*magneticField_, *propagator_, "kalman-smoothing:1", verbosity); // here copies of magneticField_ and propagator_ are made! -} - - -GFRaveVertexFactory::~GFRaveVertexFactory(){ - delete magneticField_; - delete propagator_; - delete factory_; -} - - -void -GFRaveVertexFactory::findVertices ( std::vector < genfit::GFRaveVertex* > * GFvertices, - const std::vector < genfit::Track* > & GFTracks, - bool use_beamspot ){ - - clearMap(); - - try{ - RaveToGFVertices(GFvertices, - factory_->create(GFTracksToTracks(GFTracks, NULL, IdGFTrackStateMap_, 0), - use_beamspot), - IdGFTrackStateMap_); - } - catch(Exception & e){ - std::cerr << e.what(); - } - -} - - -void -GFRaveVertexFactory::findVertices ( std::vector < genfit::GFRaveVertex* > * GFvertices, - const std::vector < genfit::Track* > & GFTracks, - std::vector < genfit::MeasuredStateOnPlane* > & GFStates, - bool use_beamspot ){ - - clearMap(); - - try{ - RaveToGFVertices(GFvertices, - factory_->create(GFTracksToTracks(GFTracks, &GFStates, IdGFTrackStateMap_, 0), - use_beamspot), - IdGFTrackStateMap_); - } - catch(Exception & e){ - std::cerr << e.what(); - } - -} - - -void -GFRaveVertexFactory::setBeamspot(const TVector3 & pos, const TMatrixDSym & cov){ - factory_->setBeamSpot(rave::Ellipsoid3D(TVector3ToPoint3D(pos), - TMatrixDSymToCovariance3D(cov))); -} - - -void -GFRaveVertexFactory::setMethod(const std::string & method){ - size_t found = method.find("smoothing:1"); - if (found==std::string::npos){ - std::cerr << "GFRaveVertexFactory::setMethod(" << method << ") ==> smoothing not turned on! GFRaveTrackParameters will be unsmoothed!" << std::endl; - } - factory_->setDefaultMethod(method); - std::cout << "GFRaveVertexFactory::setMethod ==> set method to " << factory_->method() << std::endl; -} - - -void -GFRaveVertexFactory::clearMap() { - - for (unsigned int i=0; i diff --git a/genfit/UML/ClassDiagram.png b/genfit/UML/ClassDiagram.png deleted file mode 100644 index 5ae5027869..0000000000 Binary files a/genfit/UML/ClassDiagram.png and /dev/null differ diff --git a/genfit/UML/Genfit.zargo b/genfit/UML/Genfit.zargo deleted file mode 100644 index 6bcef1b027..0000000000 Binary files a/genfit/UML/Genfit.zargo and /dev/null differ diff --git a/genfit/core/include/AbsBField.h b/genfit/core/include/AbsBField.h deleted file mode 100644 index 8f7c4f7170..0000000000 --- a/genfit/core/include/AbsBField.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_AbsBField_h -#define genfit_AbsBField_h - -#include - - -namespace genfit { - -/** @brief Abstract Interface to magnetic fields in GENFIT - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - */ -class AbsBField { -public: - - AbsBField(){;} - virtual ~AbsBField(){;} - - /** - * @brief Get the magneticField [kGauss] at position. - * - * Override this in your concrete implementation. - * Provided for compatibility with old genfit. Use the other interface to avoid - * unnecessary TVector3 instantiations. - */ - virtual TVector3 get(const TVector3& position) const = 0; - - /** - * @brief Get the magneticField [kGauss] at position. - * - * Override this in your concrete implementation. - */ - virtual void get(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz) const { const TVector3& B(this->get(TVector3(posX, posY, posZ))); Bx = B.X(); By = B.Y(); Bz = B.Z(); } - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_AbsBField_h diff --git a/genfit/core/include/AbsFinitePlane.h b/genfit/core/include/AbsFinitePlane.h deleted file mode 100644 index 5c6e2e6ce0..0000000000 --- a/genfit/core/include/AbsFinitePlane.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** - * @author Christian Höppner (Technische Universität München, original author) - * - */ - - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_AbsFinitePlane_h -#define genfit_AbsFinitePlane_h - -#include // for Option_t - - -namespace genfit { - -/** - * @brief Abstract base class for finite detector planes. - * - * This is most important for avoiding fake intersection points in fitting of curlers. - * This should be implemented for silicon detectors most importantly. - */ -class AbsFinitePlane { - - public: - - AbsFinitePlane() {}; - virtual ~AbsFinitePlane() {}; - - //! Returns whether a u,v point is in the active plane or not. Needs to be implemented - //! in child class. - virtual bool isInActive(double u, double v) const = 0; - - //! Deep copy ctor for polymorphic class. - virtual AbsFinitePlane* clone() const = 0; - - virtual void Print(const Option_t* = "") const = 0; - - - protected: - - // protect from calling copy c'tor or assignment operator from outside the class. Use #clone() if you want a copy! - AbsFinitePlane(const AbsFinitePlane&) {;} - AbsFinitePlane& operator=(const AbsFinitePlane&); - - ClassDef(AbsFinitePlane, 1); -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_AbsFinitePlane_h diff --git a/genfit/core/include/AbsFitter.h b/genfit/core/include/AbsFitter.h deleted file mode 100644 index b857e19636..0000000000 --- a/genfit/core/include/AbsFitter.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2013, Ludwig-Maximilians Universität München, - Authors: Tobias Schlüter & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_AbsFitter_h -#define genfit_AbsFitter_h - - -namespace genfit { - -class Track; -class AbsTrackRep; - -/** - * @brief Abstract base class for fitters. - */ -class AbsFitter { - public: - AbsFitter() : debugLvl_(0) {} - virtual ~AbsFitter() {} - - /** - * Process Track with one AbsTrackRep of the Track. Optionally resort the hits if necessary (and supported by the fitter) - */ - virtual void processTrackWithRep(Track*, const AbsTrackRep*, bool resortHits = false) = 0; - - /** - * Process all reps. Start with the cardinalRep and resort the hits if necessary (and supported by the fitter) - */ - void processTrack(Track*, bool resortHits = true); - - virtual void setDebugLvl(unsigned int lvl = 1) {debugLvl_ = lvl;} - - - protected: - - unsigned int debugLvl_; - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif //genfit_AbsFitter_h diff --git a/genfit/core/include/AbsFitterInfo.h b/genfit/core/include/AbsFitterInfo.h deleted file mode 100644 index 077f76e2d5..0000000000 --- a/genfit/core/include/AbsFitterInfo.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_AbsFitterInfo_h -#define genfit_AbsFitterInfo_h - -#include "MeasurementOnPlane.h" - -#include -#include - - -namespace genfit { - -class AbsTrackRep; -class TrackPoint; - -/** - * @brief This class collects all information needed and produced by a specific AbsFitter and is specific to one AbsTrackRep of the Track. - */ -class AbsFitterInfo : public TObject { - - public: - - AbsFitterInfo(); - AbsFitterInfo(const TrackPoint* trackPoint, const AbsTrackRep* rep); - - virtual ~AbsFitterInfo() {}; - - //! Deep copy ctor for polymorphic class. - virtual AbsFitterInfo* clone() const = 0; - - const TrackPoint* getTrackPoint() const {return trackPoint_;} - const AbsTrackRep* getRep() const {return rep_;} - - void setTrackPoint(const TrackPoint *tp) {trackPoint_ = tp;} - virtual void setRep(const AbsTrackRep* rep) {rep_ = rep;} - - virtual bool hasMeasurements() const = 0; - virtual bool hasReferenceState() const = 0; - virtual bool hasForwardPrediction() const = 0; - virtual bool hasBackwardPrediction() const = 0; - virtual bool hasPrediction(int direction) const {if (direction >=0) return hasForwardPrediction(); return hasBackwardPrediction();} - virtual bool hasForwardUpdate() const = 0; - virtual bool hasBackwardUpdate() const = 0; - virtual bool hasUpdate(int direction) const {if (direction >=0) return hasForwardUpdate(); return hasBackwardUpdate();} - - virtual void deleteForwardInfo() = 0; - virtual void deleteBackwardInfo() = 0; - virtual void deleteReferenceInfo() = 0; - virtual void deleteMeasurementInfo() = 0; - - const SharedPlanePtr& getPlane() const {return sharedPlane_;} - virtual const MeasuredStateOnPlane& getFittedState(bool biased = true) const = 0; - virtual MeasurementOnPlane getResidual(unsigned int iMeasurement = 0, bool biased = true, bool onlyMeasurementErrors = false) const = 0; - - void setPlane(const SharedPlanePtr& plane) {sharedPlane_ = plane;} - - virtual void Print(const Option_t* = "") const {;} - - virtual bool checkConsistency() const = 0; - - protected: - - /** Pointer to TrackPoint where the FitterInfo belongs to - */ - const TrackPoint* trackPoint_; //! No ownership - - /** Pointer to AbsTrackRep with respect to which the FitterInfo is defined - */ - const AbsTrackRep* rep_; //! No ownership - - SharedPlanePtr sharedPlane_; //! Shared ownership. '!' shuts up ROOT. - - - private: - AbsFitterInfo(const AbsFitterInfo&); // copy constructor - AbsFitterInfo& operator=(const AbsFitterInfo&); // assignment operator - - - public: - ClassDef(AbsFitterInfo,1) - -}; - -//! Needed for boost cloneability: -inline AbsFitterInfo* new_clone( const AbsFitterInfo & a) -{ - return a.clone(); -} - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_AbsFitterInfo_h diff --git a/genfit/core/include/AbsHMatrix.h b/genfit/core/include/AbsHMatrix.h deleted file mode 100644 index 5fba46852e..0000000000 --- a/genfit/core/include/AbsHMatrix.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_AbsHMatrix_h -#define genfit_AbsHMatrix_h - -#include -#include -#include - - -namespace genfit { - -/** - * @brief HMatrix for projecting from AbsTrackRep parameters to measured parameters in a DetPlane. - * - */ -class AbsHMatrix : public TObject { - - public: - - AbsHMatrix() {;} - - virtual ~AbsHMatrix() {;} - - //! Get the actual matrix representation - virtual const TMatrixD& getMatrix() const = 0; - - //! H*v - virtual TVectorD Hv(const TVectorD& v) const {return getMatrix()*v;} - - //! M*H^t - virtual TMatrixD MHt(const TMatrixDSym& M) const {return TMatrixD(M, TMatrixD::kMultTranspose, getMatrix());} - virtual TMatrixD MHt(const TMatrixD& M) const {return TMatrixD(M, TMatrixD::kMultTranspose, getMatrix());} - - //! similarity: H*M*H^t - virtual void HMHt(TMatrixDSym& M) const {M.Similarity(getMatrix());} - - virtual AbsHMatrix* clone() const = 0; - - bool operator==(const AbsHMatrix& other) const {return this->isEqual(other);} - bool operator!=(const AbsHMatrix& other) const {return !(this->isEqual(other));} - virtual bool isEqual(const AbsHMatrix& other) const = 0; - - virtual void Print(const Option_t* = "") const {;} - - protected: - // protect from calling copy c'tor or assignment operator from outside the class. Use #clone() if you want a copy! - AbsHMatrix(const AbsHMatrix& o) : TObject(o) {;} - AbsHMatrix& operator=(const AbsHMatrix&); - - public: - ClassDef(AbsHMatrix,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_AbsHMatrix_h diff --git a/genfit/core/include/AbsMeasurement.h b/genfit/core/include/AbsMeasurement.h deleted file mode 100644 index 17fb8b536f..0000000000 --- a/genfit/core/include/AbsMeasurement.h +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_AbsMeasurement_h -#define genfit_AbsMeasurement_h - -#include "MeasurementOnPlane.h" -#include "AbsHMatrix.h" - -#include - - -namespace genfit { - -class AbsTrackRep; -class TrackPoint; - -/** - * @brief Contains the measurement and covariance in raw detector coordinates. - * - * Detector and hit ids can be used to point back to the original detector hits (clusters etc.). - */ -class AbsMeasurement : public TObject { - - public: - - AbsMeasurement() : rawHitCoords_(), rawHitCov_(), detId_(-1), hitId_(-1) {;} - AbsMeasurement(int nDims) : rawHitCoords_(nDims), rawHitCov_(nDims), detId_(-1), hitId_(-1) {;} - AbsMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint); - - virtual ~AbsMeasurement(); - - //! Deep copy ctor for polymorphic class. - virtual AbsMeasurement* clone() const = 0; - - TrackPoint* getTrackPoint() const {return trackPoint_;} - void setTrackPoint(TrackPoint* tp) {trackPoint_ = tp;} - - const TVectorD& getRawHitCoords() const {return rawHitCoords_;} - const TMatrixDSym& getRawHitCov() const {return rawHitCov_;} - int getDetId() const {return detId_;} - int getHitId() const {return hitId_;} - - unsigned int getDim() const {return rawHitCoords_.GetNrows();} - - void setDetId(int detId) {detId_ = detId;} - void setHitId(int hitId) {hitId_ = hitId;} - - - /** - * Construct (virtual) detector plane (use state's AbsTrackRep). - * It's possible to make corrections to the plane here. - * The state should be defined somewhere near the measurement. - * For virtual planes, the state will be extrapolated to the POCA to point (SpacepointMeasurement) - * or line (WireMeasurement), and from this info the plane will be constructed. - */ - virtual SharedPlanePtr constructPlane(const StateOnPlane& state) const = 0; - - /** - * Construct MeasurementOnPlane on plane of the state - * and wrt the states TrackRep. - * The state will usually be the prediction or reference state, - * and has to be defined AT the measurement. - * The AbsMeasurement will be projected onto the plane. - * It's possible to make corrections to the coordinates here (e.g. by using the state coordinates). - * Usually the vector will contain only one element. But in the case of e.g. a WireMeasurement, it will be 2 (left and right). - */ - virtual std::vector constructMeasurementsOnPlane(const StateOnPlane& state) const = 0; - - /** - * Returns a new AbsHMatrix object. Caller must take ownership. - */ - virtual const AbsHMatrix* constructHMatrix(const AbsTrackRep*) const = 0; - - virtual void Print(const Option_t* = "") const; - - - private: - //! protect from calling assignment operator from outside the class. Use #clone() if you want a copy! - AbsMeasurement& operator=(const AbsMeasurement&); // default cannot work because TVector and TMatrix = operators don't do resizing - - protected: - //! protect from calling copy c'tor from outside the class. Use #clone() if you want a copy! - AbsMeasurement(const AbsMeasurement&); - - TVectorD rawHitCoords_; - TMatrixDSym rawHitCov_; - int detId_; // detId id is -1 per default - int hitId_; // hitId id is -1 per default - - //! Pointer to TrackPoint where the measurement belongs to - TrackPoint* trackPoint_; //! No ownership - - public: - ClassDef(AbsMeasurement, 1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_AbsMeasurement_h diff --git a/genfit/core/include/AbsTrackRep.h b/genfit/core/include/AbsTrackRep.h deleted file mode 100644 index 4d537f7758..0000000000 --- a/genfit/core/include/AbsTrackRep.h +++ /dev/null @@ -1,359 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_AbsTrackRep_h -#define genfit_AbsTrackRep_h - -#include "SharedPlanePtr.h" -//#include "MaterialInfo.h" -#include "MaterialProperties.h" - -#include -#include -#include -#include -#include - - -namespace genfit { - -/** - * @brief Simple struct containing MaterialProperties and stepsize in the material. - */ -struct MatStep { - MaterialProperties materialProperties_; - double stepSize_; - - MatStep() { - stepSize_ = 0; - } - -}; - -class StateOnPlane; -class MeasuredStateOnPlane; -class AbsMeasurement; - -/** - * @brief Abstract base class for a track representation - * - * Provides functionality to extrapolate a StateOnPlane to another DetPlane, - * to the POCA to a line or a point, or a cylinder or sphere. - * Defines a set of parameters describing the track. - * StateOnPlane objects are always defined with a track parameterization of a specific AbsTrackRep. - * The AbsTrackRep provides functionality to translate from the internal representation of a state - * into cartesian position and momentum (and covariance) and vice versa. - */ -class AbsTrackRep : public TObject { - - public: - - AbsTrackRep(); - AbsTrackRep(int pdgCode, char propDir = 0); - - virtual ~AbsTrackRep() {;} - - //! Clone the trackRep. - virtual AbsTrackRep* clone() const = 0; - - /** - * @brief Extrapolates the state to plane, and returns the extrapolation length - * and, via reference, the extrapolated state. - * - * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. - * - * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. - * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. - */ - virtual double extrapolateToPlane( - StateOnPlane& state, - const genfit::SharedPlanePtr& plane, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const = 0; - - /** - * @brief Extrapolates the state to the POCA to a line, and returns the extrapolation length - * and, via reference, the extrapolated state. - * - * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. - * - * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. - * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. - */ - virtual double extrapolateToLine(StateOnPlane& state, - const TVector3& linePoint, - const TVector3& lineDirection, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const = 0; - - /** - * @brief Resembles the interface of GFAbsTrackRep in old versions of genfit - * - * This interface to extrapolateToLine is intended to resemble the - * interface of GFAbsTrackRep in old versions of genfit and is - * implemented by default via the preceding function. - * - * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. - * - * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. - * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. - */ - virtual double extrapolateToLine(StateOnPlane& state, - const TVector3& point1, - const TVector3& point2, - TVector3& poca, - TVector3& dirInPoca, - TVector3& poca_onwire, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const { - TVector3 wireDir(point2 - point1); - wireDir.Unit(); - double retval = this->extrapolateToLine(state, point1, wireDir, stopAtBoundary, calcJacobianNoise); - poca = this->getPos(state); - dirInPoca = this->getMom(state); - dirInPoca.Unit(); - - poca_onwire = point1 + wireDir*((poca - point1)*wireDir); - - return retval; - } - - /** - * @brief Extrapolates the state to the POCA to a point, and returns the extrapolation length - * and, via reference, the extrapolated state. - * - * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. - * - * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. - * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. - */ - virtual double extrapolateToPoint(StateOnPlane& state, - const TVector3& point, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const = 0; - - /** - * @brief Extrapolates the state to the POCA to a point in the metric of G, and returns the extrapolation length - * and, via reference, the extrapolated state. - * - * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. - * - * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. - * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. - */ - virtual double extrapolateToPoint(StateOnPlane& state, - const TVector3& point, - const TMatrixDSym& G, // weight matrix (metric) - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const = 0; - - /** - * @brief Extrapolates the state to the cylinder surface, and returns the extrapolation length - * and, via reference, the extrapolated state. - * - * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. - * - * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. - * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. - */ - virtual double extrapolateToCylinder(StateOnPlane& state, - double radius, - const TVector3& linePoint = TVector3(0.,0.,0.), - const TVector3& lineDirection = TVector3(0.,0.,1.), - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const = 0; - - /** - * @brief Extrapolates the state to the sphere surface, and returns the extrapolation length - * and, via reference, the extrapolated state. - * - * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. - * - * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. - * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. - */ - virtual double extrapolateToSphere(StateOnPlane& state, - double radius, - const TVector3& point = TVector3(0.,0.,0.), - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const = 0; - - /** - * @brief Extrapolates the state by step (cm) and returns the extrapolation length - * and, via reference, the extrapolated state. - * - * If stopAtBoundary is true, the extrapolation stops as soon as a material boundary is encountered. - * - * If state has a covariance, jacobian and noise matrices will be calculated and the covariance will be propagated. - * If state has no covariance, jacobian and noise will only be calculated if calcJacobianNoise == true. - */ - virtual double extrapolateBy(StateOnPlane& state, - double step, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const = 0; - - //! extrapolate to an AbsMeasurement - double extrapolateToMeasurement(StateOnPlane& state, - const AbsMeasurement* measurement, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - //! Get the dimension of the state vector used by the track representation. - virtual unsigned int getDim() const = 0; - - //! Get the cartesian position of a state. - virtual TVector3 getPos(const StateOnPlane& state) const = 0; - - //! Get the cartesian momentum vector of a state. - virtual TVector3 getMom(const StateOnPlane& state) const = 0; - - //! Get the direction vector of a state. - TVector3 getDir(const StateOnPlane& state) const {return getMom(state).Unit();} - - //! Get cartesian position and momentum vector of a state. - virtual void getPosMom(const StateOnPlane& state, TVector3& pos, TVector3& mom) const = 0; - - //! Get cartesian position and direction vector of a state. - void getPosDir(const StateOnPlane& state, TVector3& pos, TVector3& dir) const {getPosMom(state, pos, dir); dir.SetMag(1.);} - - //! Get the 6D state vector (x, y, z, p_x, p_y, p_z). - virtual TVectorD get6DState(const StateOnPlane& state) const; - - //! Get the 6D covariance. - virtual TMatrixDSym get6DCov(const MeasuredStateOnPlane& state) const = 0; - - //! Translates MeasuredStateOnPlane into 3D position, momentum and 6x6 covariance. - virtual void getPosMomCov(const MeasuredStateOnPlane& state, TVector3& pos, TVector3& mom, TMatrixDSym& cov) const = 0; - - //! Translates MeasuredStateOnPlane into 6D state vector (x, y, z, p_x, p_y, p_z) and 6x6 covariance. - virtual void get6DStateCov(const MeasuredStateOnPlane& state, TVectorD& stateVec, TMatrixDSym& cov) const; - - //! get the magnitude of the momentum in GeV. - virtual double getMomMag(const StateOnPlane& state) const = 0; - //! get the variance of the absolute value of the momentum . - virtual double getMomVar(const MeasuredStateOnPlane& state) const = 0; - - //! Get the pdg code. - int getPDG() const {return pdgCode_;} - - //! Get the charge of the particle of the pdg code - double getPDGCharge() const; - - /** - * @brief Get the (fitted) charge of a state. - * This is not always equal the pdg charge (e.g. if the charge sign was flipped during the fit). - */ - virtual double getCharge(const StateOnPlane& state) const = 0; - //! Get charge over momentum. - virtual double getQop(const StateOnPlane& state) const = 0; - //! Get tha particle mass in GeV/c^2 - double getMass(const StateOnPlane& state) const; - - //! Get propagation direction. (-1, 0, 1) -> (backward, auto, forward). - char getPropDir() const {return propDir_;} - - //! Get the jacobian and noise matrix of the last extrapolation. - virtual void getForwardJacobianAndNoise(TMatrixD& jacobian, TMatrixDSym& noise, TVectorD& deltaState) const = 0; - - //! Get the jacobian and noise matrix of the last extrapolation if it would have been done in opposite direction. - virtual void getBackwardJacobianAndNoise(TMatrixD& jacobian, TMatrixDSym& noise, TVectorD& deltaState) const = 0; - - //! Get stepsizes and material properties of crossed materials of the last extrapolation. - virtual std::vector getSteps() const = 0; - - //! Get the accumulated X/X0 (path / radiation length) of the material crossed in the last extrapolation. - virtual double getRadiationLenght() const = 0; - - //! Get the time of flight [ns] of the last extrapolation - virtual double getTOF() const = 0; - - /** - * @brief Calculate Jacobian of transportation numerically. - * Slow but accurate. Can be used to validate (semi)analytic calculations. - */ - void calcJacobianNumerically(const genfit::StateOnPlane& origState, - const genfit::SharedPlanePtr destPlane, - TMatrixD& jacobian) const; - - //! try to multiply pdg code with -1. (Switch from particle to anti-particle and vice versa). - bool switchPDGSign(); - - //! Set position and momentum of state. - virtual void setPosMom(StateOnPlane& state, const TVector3& pos, const TVector3& mom) const = 0; - //! Set position and momentum of state. - virtual void setPosMom(StateOnPlane& state, const TVectorD& state6) const = 0; - //! Set position and momentum and error of state. - virtual void setPosMomErr(MeasuredStateOnPlane& state, const TVector3& pos, const TVector3& mom, const TVector3& posErr, const TVector3& momErr) const = 0; - //! Set position, momentum and covariance of state. - virtual void setPosMomCov(MeasuredStateOnPlane& state, const TVector3& pos, const TVector3& mom, const TMatrixDSym& cov6x6) const = 0; - //! Set position, momentum and covariance of state. - virtual void setPosMomCov(MeasuredStateOnPlane& state, const TVectorD& state6, const TMatrixDSym& cov6x6) const = 0; - - //! Set the sign of the charge according to charge. - virtual void setChargeSign(StateOnPlane& state, double charge) const = 0; - //! Set charge/momentum. - virtual void setQop(StateOnPlane& state, double qop) const = 0; - - //! Set propagation direction. (-1, 0, 1) -> (backward, auto, forward). - void setPropDir(int dir) { - if (dir>0) propDir_ = 1; - else if (dir<0) propDir_ = -1; - else propDir_ = 0; - }; - - //! Switch propagation direction. Has no effect if propDir_ is set to 0. - void switchPropDir(){propDir_ = -1*propDir_;} - - //! check if other is of same type (e.g. RKTrackRep). - virtual bool isSameType(const AbsTrackRep* other) = 0; - - //! check if other is of same type (e.g. RKTrackRep) and has same pdg code. - virtual bool isSame(const AbsTrackRep* other) = 0; - - virtual void setDebugLvl(unsigned int lvl = 1) {debugLvl_ = lvl;} - - virtual void Print(const Option_t* = "") const; - - protected: - - //! protect from calling copy c'tor from outside the class. Use #clone() if you want a copy! - AbsTrackRep(const AbsTrackRep&); - //! protect from calling assignment operator from outside the class. Use #clone() instead! - AbsTrackRep& operator=(const AbsTrackRep&); - - - //! Particle code - int pdgCode_; - //! propagation direction (-1, 0, 1) -> (backward, auto, forward) - char propDir_; - - unsigned int debugLvl_; - - public: - ClassDef(AbsTrackRep,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_AbsTrackRep_h diff --git a/genfit/core/include/DetPlane.h b/genfit/core/include/DetPlane.h deleted file mode 100644 index 8d750d5651..0000000000 --- a/genfit/core/include/DetPlane.h +++ /dev/null @@ -1,205 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -// Description: -// Detector plane - a geometric object -/** - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * - */ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_DetPlane_h -#define genfit_DetPlane_h - -#include "AbsFinitePlane.h" - -#include -#include - -#ifndef __CINT__ -#include -#endif - - -namespace genfit { - -/** @brief Detector plane. - * - * A detector plane is the principle object to define coordinate systems for - * track fitting in genfit. Since a particle trajectory is a - * one-dimensional object (regardless of any specific parameterization) - * positions with respect to the track are always measured in a plane. - * - * Which plane is chosen depends on the type of detector. Fixed plane - * detectors have their detector plane defined by their mechanical setup. While - * wire chambers or time projection chambers might want to define a detector - * plane more flexibly. - * - * This class parameterizes a plane in terms of an origin vector o - * and two plane-spanning directions u and v. - */ -class DetPlane : public TObject { - - public: - - - // Constructors/Destructors --------- - DetPlane(AbsFinitePlane* finite = NULL); - - DetPlane(const TVector3& o, - const TVector3& u, - const TVector3& v, - AbsFinitePlane* finite = NULL); - - DetPlane(const TVector3& o, - const TVector3& n, - AbsFinitePlane* finite = NULL); - - virtual ~DetPlane(); - - DetPlane(const DetPlane&); - DetPlane& operator=(DetPlane); - void swap(DetPlane& other); // nothrow - - // Accessors ----------------------- - const TVector3& getO() const {return o_;} - const TVector3& getU() const {return u_;} - const TVector3& getV() const {return v_;} - - // Modifiers ----------------------- - void set(const TVector3& o, - const TVector3& u, - const TVector3& v); - void setO(const TVector3& o); - void setO(double, double, double); - void setU(const TVector3& u); - void setU(double, double, double); - void setV(const TVector3& v); - void setV(double, double, double); - void setUV(const TVector3& u, const TVector3& v); - void setON(const TVector3& o, const TVector3& n); - - //! Optionally, set the finite plane definition. This is most important for - //! avoiding fake intersection points in fitting of curlers. This should - //! be implemented for silicon detectors most importantly. - void setFinitePlane(AbsFinitePlane* finite){finitePlane_.reset(finite);} - - // Operations ---------------------- - TVector3 getNormal() const; - void setNormal(const TVector3& n); - void setNormal(double, double, double); - void setNormal(const double& theta, const double& phi); - - //! projecting a direction onto the plane: - TVector2 project(const TVector3& x) const; - - //! transform from Lab system into plane - TVector2 LabToPlane(const TVector3& x) const; - - //! transform from plane coordinates to lab system - TVector3 toLab(const TVector2& x) const; - - // get vector from point to plane (normal) - TVector3 dist(const TVector3& point) const; - - //! gives u,v coordinates of the intersection point of a straight line with plane - TVector2 straightLineToPlane(const TVector3& point, const TVector3& dir) const; - - //! gives u,v coordinates of the intersection point of a straight line with plane - void straightLineToPlane(const double& posX, const double& posY, const double& posZ, - const double& dirX, const double& dirY, const double& dirZ, - double& u, double& v) const; - - void Print(const Option_t* = "") const; - - //! Checks equality of planes by comparing the 9 double values that define them. - friend bool operator== (const DetPlane& lhs, const DetPlane& rhs); - //! returns NOT == - friend bool operator!= (const DetPlane& lhs, const DetPlane& rhs); - - //! absolute distance from a point to the plane - double distance(const TVector3& point) const; - double distance(double, double, double) const; - - - //! intersect in the active area? C.f. AbsFinitePlane - bool isInActive(const TVector3& point, const TVector3& dir) const { - if(finitePlane_.get() == NULL) return true; - return this->isInActive( this->straightLineToPlane(point,dir)); - } - - //! intersect in the active area? C.f. AbsFinitePlane - bool isInActive(const double& posX, const double& posY, const double& posZ, - const double& dirX, const double& dirY, const double& dirZ) const { - if(finitePlane_.get() == NULL) return true; - double u, v; - this->straightLineToPlane(posX, posY, posZ, dirX, dirY, dirZ, u, v); - return this->isInActive(u, v); - } - - //! isInActive methods refer to finite plane. C.f. AbsFinitePlane - bool isInActive(double u, double v) const{ - if(finitePlane_.get() == NULL) return true; - return finitePlane_->isInActive(u,v); - } - - //! isInActive methods refer to finite plane. C.f. AbsFinitePlane - bool isInActive(const TVector2& v) const{ - return isInActive(v.X(),v.Y()); - } - - bool isFinite() const { - return (finitePlane_.get() != NULL); - } - - //! rotate u and v around normal. Angle is in rad. More for debugging than for actual use. - void rotate(double angle); - - //! delete finitePlane_ and set O, U, V to default values - void reset(); - - private: - // Private Methods ----------------- - //! ensures orthonormal coordinates - void sane(); - - TVector3 o_; - TVector3 u_; - TVector3 v_; - -#ifndef __CINT__ - boost::scoped_ptr finitePlane_; // Ownership -#else - class AbsFinitePlane* finitePlane_; //! Shut ROOT up, this class has a custom streamer. -#endif - - - public: - ClassDef(DetPlane,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_DetPlane_h diff --git a/genfit/core/include/Exception.h b/genfit/core/include/Exception.h deleted file mode 100644 index d2fada3981..0000000000 --- a/genfit/core/include/Exception.h +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_Exception_h -#define genfit_Exception_h - -#include -#include -#include -#include -#include - -#include - - -namespace genfit { - -/** @brief Exception class for error handling in GENFIT (provides storage for diagnostic information) - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * - * This is the class that is used for all error handling in GENFIT. - * It is a utility class that allows to store numbers and matrices together - * with an error string. The exception class can then be thrown when an error - * is detected and the C++ exception handling facilities can be used to - * catch and process the exception. - */ -class Exception : public TObject { - - public: - /** @brief Initializing constructor - * - * @param excString error message. - * @param line line at which the exception is created. Can be set through __LINE__ macro. - * @param file sourcefile in which the exception is created. Can be set through __FILE__ macro. - */ - Exception(std::string excString, int line, std::string file); - virtual ~Exception() throw(); - - //! Set fatal flag. - void setFatal (bool b=true){fatal_=b;} - //! Get fatal flag. - bool isFatal (){return fatal_;} - //! Set list of numbers with description. - void setNumbers (std::string, const std::vector&); - //! Set list of matrices with description. - void setMatrices(std::string, const std::vector&); - - //! Print information in the exception object. - void info(); - - //! Standard error message handling for exceptions. use like "std::cerr << e.what();" - virtual const char* what() const throw(); - - std::string getExcString(){return excString_;} - - //! "std::cerr << e.what();" will not write anything. - static void quiet(bool b=true){quiet_=b;} - - private: - - static bool quiet_; - - std::string excString_; - int line_; - std::string file_; - - std::string errorMessage_; - - std::string numbersLabel_; - std::string matricesLabel_; - std::vector numbers_; - std::vector matrices_; - - bool fatal_; - - //ClassDef(Exception,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_Exception_h diff --git a/genfit/core/include/FieldManager.h b/genfit/core/include/FieldManager.h deleted file mode 100644 index b75961233d..0000000000 --- a/genfit/core/include/FieldManager.h +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - - -#ifndef genfit_FieldManager_h -#define genfit_FieldManager_h - -#include "AbsBField.h" - -#include -#include -#include - -#define CACHE - -namespace genfit { - -#ifdef CACHE -/** - * @brief Cache B field at a position. Used by FieldManager. - */ -struct fieldCache { - double posX; double posY; double posZ; - double Bx; double By; double Bz; -}; -#endif - - -/** @brief Singleton which provides access to magnetic field maps. - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - */ -class FieldManager { - - public: - - AbsBField* getField(){ - checkInitialized(); - return field_; - } - - //! This does NOT use the cache! - TVector3 getFieldVal(const TVector3& position){ - checkInitialized(); - return field_->get(position); - } - -#ifdef CACHE - void getFieldVal(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz); -#else - inline void getFieldVal(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz) { - checkInitialized(); - return field_->get(posX, posY, posZ, Bx, By, Bz); - } -#endif - - //! set the magnetic field here. Magnetic field classes must be derived from AbsBField. - void init(AbsBField* b) { - field_=b; - } - - bool isInitialized() { return field_ != NULL; } - - void checkInitialized() { - if(! isInitialized()){ - std::cerr << "FieldManager hasn't been initialized with a correct AbsBField pointer!" << std::endl; - std::string msg("FieldManager hasn't been initialized with a correct AbsBField pointer!"); - std::runtime_error err(msg); - throw err; - } - } - - static void checkInstanciated() { - if(instance_==NULL){ - std::cerr << "FieldManager hasn't been instantiated yet, call getInstance() and init() before getFieldVal()!" << std::endl; - std::string msg("FieldManager hasn't been instantiated yet, call getInstance() and init() before getFieldVal()!"); - std::runtime_error err(msg); - throw err; - } - } - -#ifdef CACHE - //! Cache last lookup positions, and use stored field values if a lookup at (almost) the same position is done. - void useCache(bool opt = true, unsigned int nBuckets = 8); -#else - void useCache(bool opt = true, unsigned int nBuckets = 8) { - std::cerr << "genfit::FieldManager::useCache() - FieldManager is compiled w/o CACHE, no caching will be done!" << std::endl; - } -#endif - - //! Get singleton instance. - static FieldManager* getInstance(){ - if(instance_ == NULL) { - instance_ = new FieldManager(); - } - return instance_; - } - - - private: - - FieldManager() {} -#ifdef CACHE - ~FieldManager() { delete cache_; } -#else - ~FieldManager() { } -#endif - static FieldManager* instance_; - static AbsBField* field_; - -#ifdef CACHE - static bool useCache_; - static unsigned int n_buckets_; - static fieldCache* cache_; -#endif - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_FieldManager_h diff --git a/genfit/core/include/FitStatus.h b/genfit/core/include/FitStatus.h deleted file mode 100644 index fa5ab635e8..0000000000 --- a/genfit/core/include/FitStatus.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_FitStatus_h -#define genfit_FitStatus_h - -#include -#include - - -namespace genfit { - -/** @brief Class where important numbers and properties of a fit can be stored. - * - * @author Johannes Rauch (Technische Universität München, original author) - */ -class FitStatus { - - public: - - FitStatus() : - isFitted_(false), isFitConvergedFully_(false), isFitConvergedPartially_(false), nFailedPoints_(0), - trackHasChanged_(false), trackIsPruned_(false), charge_(0), chi2_(-1e99), ndf_(-1e99) - {;} - - virtual ~FitStatus() {}; - - virtual FitStatus* clone() const {return new FitStatus(*this);} - - //! Has the track been fitted? - bool isFitted() const {return isFitted_;} - //! Did the fit converge (in all Points or only partially)? - /** - * Per default, this function will only be true, if all TrackPoints - * (with measurements) have been used in the fit, and the fit has converged. - * - * If one or more TrackPoints have been skipped - * (e.g. plane could not be constructed or extrapolation to plane failed), - * but the fit otherwise met the convergence criteria, isFitConverged(false) - * will return true. - */ - bool isFitConverged(bool inAllPoints = true) const { - if (inAllPoints) return isFitConvergedFully_; return isFitConvergedPartially_; - } - bool isFitConvergedFully() const {return isFitConvergedFully_;} - bool isFitConvergedPartially() const {return isFitConvergedPartially_;} - int getNFailedPoints() const {return nFailedPoints_;} - //! Has anything in the Track been changed since the fit? - bool hasTrackChanged() const {return trackHasChanged_;} - //! Has the track been pruned after the fit? - bool isTrackPruned() const {return trackIsPruned_;} - //! Get the fitted charge. - double getCharge() const {return charge_;} - //! Get chi^2 of the fit. - double getChi2() const {return chi2_;} - //! Get the degrees of freedom of the fit. - double getNdf() const {return ndf_;} - /** - * @brief Get the p value of the fit. - * - * Virtual, because the fitter may use a different probability distribution. - */ - virtual double getPVal() const {return ROOT::Math::chisquared_cdf_c(chi2_, ndf_);} - - void setIsFitted(bool fitted = true) {isFitted_ = fitted;} - void setIsFitConvergedFully(bool fitConverged = true) {isFitConvergedFully_ = fitConverged;} - void setIsFitConvergedPartially(bool fitConverged = true) {isFitConvergedPartially_ = fitConverged;} - void setNFailedPoints(int nFailedPoints) {nFailedPoints_ = nFailedPoints;} - void setHasTrackChanged(bool trackChanged = true) {trackHasChanged_ = trackChanged;} - void setIsTrackPruned(bool pruned = true) {trackIsPruned_ = pruned;} - void setCharge(double charge) {charge_ = charge;} - - void setChi2(const double& chi2) {chi2_ = chi2;} - void setNdf(const double& ndf) {ndf_ = ndf;} - - virtual void Print(const Option_t* = "") const; - - protected: - - //! has the track been fitted? - bool isFitted_; - //! did the fit converge with all TrackPoints? - bool isFitConvergedFully_; - //! did the fit converge with a subset of all TrackPoints? - bool isFitConvergedPartially_; - //! Number of failed TrackPoints - int nFailedPoints_; - //! has anything in the Track been changed since the fit? -> fit isn't valid anymore - bool trackHasChanged_; - //! Information has been stripped off, no refitting possible! - bool trackIsPruned_; - //! fitted charge - double charge_; - - //! These are provided for the sake of the fitter, and their interpretation may vary. - //! For the Kalman-derived fitters in particular, this corresponds to the backwards fit. - double chi2_; - double ndf_; - - ClassDef(FitStatus, 1); -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_FitStatus_h diff --git a/genfit/core/include/MaterialProperties.h b/genfit/core/include/MaterialProperties.h deleted file mode 100644 index 08877f1e82..0000000000 --- a/genfit/core/include/MaterialProperties.h +++ /dev/null @@ -1,119 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_MaterialProperties_h -#define genfit_MaterialProperties_h - -#include - - -namespace genfit { - - -/** - * @brief Material properties needed e.g. for material effects calculation. - */ -class MaterialProperties : public TObject { - - public: - - //! Compare material parameters - friend bool operator== (const MaterialProperties& lhs, const MaterialProperties& rhs); - friend bool operator!= (const MaterialProperties& lhs, const MaterialProperties& rhs); - - MaterialProperties(); - MaterialProperties(const double& density, - const double& Z, - const double& A, - const double& radiationLength, - const double& mEE); - - double getDensity() const {return density_;} - double getZ() const {return Z_;} - double getA() const {return A_;} - double getRadLen() const {return radiationLength_;} - double getMEE() const {return mEE_;} - - void getMaterialProperties(double& density, - double& Z, - double& A, - double& radiationLength, - double& mEE) const; - - void setMaterialProperties(const double& density, - const double& Z, - const double& A, - const double& radiationLength, - const double& mEE); - - void Print(const Option_t* = "") const; - - private: - - // material variables - //! density of material - double density_; - //! Atomic number Z of material - double Z_; - //! Mass number A of material - double A_; - //! radiation length X0 - double radiationLength_; - //! mean excitation energy [eV] - double mEE_; - - - public: - ClassDef(MaterialProperties, 1) - -}; - - -inline MaterialProperties::MaterialProperties() : - density_(0), - Z_(0), - A_(0), - radiationLength_(0), - mEE_(0) -{ - ; -} - -inline MaterialProperties::MaterialProperties(const double& density, - const double& Z, - const double& A, - const double& radiationLength, - const double& mEE) : - density_(density), - Z_(Z), - A_(A), - radiationLength_(radiationLength), - mEE_(mEE) -{ - ; -} - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_MaterialProperties_h diff --git a/genfit/core/include/MeasuredStateOnPlane.h b/genfit/core/include/MeasuredStateOnPlane.h deleted file mode 100644 index 73cbe3d682..0000000000 --- a/genfit/core/include/MeasuredStateOnPlane.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_MeasuredStateOnPlane_h -#define genfit_MeasuredStateOnPlane_h - -#include "StateOnPlane.h" -#include "AbsTrackRep.h" - -#include - - -namespace genfit { - -/** - * @brief #StateOnPlane with additional covariance matrix. - */ -class MeasuredStateOnPlane : public StateOnPlane { - - public: - - MeasuredStateOnPlane(const AbsTrackRep* rep = NULL); - MeasuredStateOnPlane(const TVectorD& state, const TMatrixDSym& cov, const genfit::SharedPlanePtr& plane, const AbsTrackRep* rep); - MeasuredStateOnPlane(const TVectorD& state, const TMatrixDSym& cov, const genfit::SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo); - MeasuredStateOnPlane(const MeasuredStateOnPlane& o); - MeasuredStateOnPlane(const StateOnPlane& state, const TMatrixDSym& cov); - - MeasuredStateOnPlane& operator=(MeasuredStateOnPlane other); - void swap(MeasuredStateOnPlane& other); // nothrow - - virtual ~MeasuredStateOnPlane() {} - - const TMatrixDSym& getCov() const {return cov_;} - TMatrixDSym& getCov() {return cov_;} - - void blowUpCov(double blowUpFac, bool resetOffDiagonals = true); - - void setStateCov(const TVectorD& state, const TMatrixDSym& cov) {setState(state); setCov(cov);} - void setStateCovPlane(const TVectorD& state, const TMatrixDSym& cov, const SharedPlanePtr& plane) {setStatePlane(state, plane); setCov(cov);} - void setCov(const TMatrixDSym& cov) {if(cov_.GetNrows() == 0) cov_.ResizeTo(cov); cov_ = cov;} - - // Shortcuts to TrackRep functions - TMatrixDSym get6DCov() const {return getRep()->get6DCov(*this);}; - void getPosMomCov(TVector3& pos, TVector3& mom, TMatrixDSym& cov) const {getRep()->getPosMomCov(*this, pos, mom, cov);} - void get6DStateCov(TVectorD& stateVec, TMatrixDSym& cov) const {getRep()->get6DStateCov(*this, stateVec, cov);} - double getMomVar() const {return getRep()->getMomVar(*this);} - - void setPosMomErr(const TVector3& pos, const TVector3& mom, const TVector3& posErr, const TVector3& momErr) {getRep()->setPosMomErr(*this, pos, mom, posErr, momErr);} - void setPosMomCov(const TVector3& pos, const TVector3& mom, const TMatrixDSym& cov6x6) {getRep()->setPosMomCov(*this, pos, mom, cov6x6);} - void setPosMomCov(const TVectorD& state6, const TMatrixDSym& cov6x6) {getRep()->setPosMomCov(*this, state6, cov6x6);} - - - virtual void Print(Option_t* option = "") const; - - protected: - - TMatrixDSym cov_; - - public: - ClassDef(MeasuredStateOnPlane,1) - -}; - - -/** - * @brief Calculate weighted average between two MeasuredStateOnPlanes - */ -MeasuredStateOnPlane calcAverageState(const MeasuredStateOnPlane& forwardState, const MeasuredStateOnPlane& backwardState); - - -inline void MeasuredStateOnPlane::swap(MeasuredStateOnPlane& other) { - StateOnPlane::swap(other); - this->cov_.ResizeTo(other.cov_); - std::swap(this->cov_, other.cov_); -} - -inline MeasuredStateOnPlane::MeasuredStateOnPlane(const AbsTrackRep* rep) : - StateOnPlane(rep), cov_(0,0) -{ - if (rep != NULL) { - cov_.ResizeTo(rep->getDim(), rep->getDim()); - } -} - -inline MeasuredStateOnPlane::MeasuredStateOnPlane(const TVectorD& state, const TMatrixDSym& cov, const SharedPlanePtr& plane, const AbsTrackRep* rep) : - StateOnPlane(state, plane, rep), cov_(cov) -{ - assert(rep != NULL); - //assert(cov_.GetNcols() == (signed)rep->getDim()); -} - -inline MeasuredStateOnPlane::MeasuredStateOnPlane(const TVectorD& state, const TMatrixDSym& cov, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo) : - StateOnPlane(state, plane, rep, auxInfo), cov_(cov) -{ - assert(rep != NULL); - //assert(cov_.GetNcols() == (signed)rep->getDim()); -} - -inline MeasuredStateOnPlane::MeasuredStateOnPlane(const MeasuredStateOnPlane& o) : - StateOnPlane(o), cov_(o.cov_) -{ -} - -inline MeasuredStateOnPlane::MeasuredStateOnPlane(const StateOnPlane& state, const TMatrixDSym& cov) : - StateOnPlane(state), cov_(cov) -{ - //assert(cov_.GetNcols() == (signed)getRep()->getDim()); -} - -inline MeasuredStateOnPlane& MeasuredStateOnPlane::operator=(MeasuredStateOnPlane other) { - swap(other); - return *this; -} - - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_MeasuredStateOnPlane_h diff --git a/genfit/core/include/MeasurementFactory.h b/genfit/core/include/MeasurementFactory.h deleted file mode 100644 index aa75de5cde..0000000000 --- a/genfit/core/include/MeasurementFactory.h +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - - -#ifndef genfit_MeasurementFactory_h -#define genfit_MeasurementFactory_h - -#include "MeasurementProducer.h" -#include "TrackCand.h" - -#include -#include - - -namespace genfit { - -class AbsMeasurement; - -/** @brief Factory object to create AbsMeasurement objects from digitized and clustered data - * - * The MeasurementFactory is used to automatically fill Track objects with - * hit data. For each detector type that is used, one AbsMeasurementProducer - * has to be registered in the factory. The factory can the use the index - * information from a TrackCand object to load the indexed hits into - * the Track. - * - * @sa AbsMeasurementProducer - * @sa TrackCand - */ -template -class MeasurementFactory { - private: - std::map*> hitProdMap_; - - - public: - MeasurementFactory() {}; - virtual ~MeasurementFactory() { clear(); } - - /** @brief Register a producer module to the factory - * - * For each type of hit a separate producer is needed. The type of hit - * is identified by the detector ID (detID). This index corresponds to the - * detector ID that is stored in the TrackCand. - */ - void addProducer(int detID, AbsMeasurementProducer* hitProd); - - /** @brief Clear all hit producers - */ - void clear(); - - /** @brief Create a Measurement - * - * Measurements have to implement a Constructor which takes the cluster object - * from which the Measurement is build as the only parameter. - * @sa AbsMeasurementProducer - */ - measurement_T* createOne (int detID, int index, const TrackCandHit* hit) const; - - /** @brief Create a collection of Measurements - * - * This is the standard way to prepare the hit collection for a Track. The - * resulting collection can contain hits from several detectors. The order - * of the hits is the same as in the TrackCand. It is assumed that this order - * is already along the Track. - * - * Measurements have to implement a constructor which takes the cluster object - * from which the Measurement is build as the only parameter. - * @sa AbsMeasurementProducer - */ - std::vector createMany(const TrackCand& cand) const; - -}; - - -template -void MeasurementFactory::addProducer(int detID, AbsMeasurementProducer* hitProd) { - typename std::map*>::iterator it = hitProdMap_.find(detID); - if(it == hitProdMap_.end()) { - hitProdMap_[detID] = hitProd; - } else { - Exception exc("MeasurementFactory: detID already in use",__LINE__,__FILE__); - exc.setFatal(); - std::vector numbers; - numbers.push_back(detID); - exc.setNumbers("detID",numbers); - throw exc; - } -} - -template -void MeasurementFactory::clear(){ - typename std::map*>::iterator it=hitProdMap_.begin(); - while(it!=hitProdMap_.end()){ - delete it->second; - ++it; - } - hitProdMap_.clear(); -} - -template -measurement_T* MeasurementFactory::createOne(int detID, int index, const TrackCandHit* hit) const { - typename std::map*>::const_iterator it = hitProdMap_.find(detID); - - if(it != hitProdMap_.end()) { - return it->second->produce(index, hit); - } else { - Exception exc("MeasurementFactory: no hitProducer for this detID available",__LINE__,__FILE__); - exc.setFatal(); - std::vector numbers; - numbers.push_back(detID); - exc.setNumbers("detID", numbers); - throw exc; - } -} - -template -typename std::vector MeasurementFactory::createMany(const TrackCand& cand) const { - typename std::vector hitVec; - unsigned int nHits=cand.getNHits(); - for(unsigned int i=0;i::createOne(hit->getDetId(), hit->getHitId(), hit) ); - } - return hitVec; -} - - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_MeasurementFactory_h diff --git a/genfit/core/include/MeasurementOnPlane.h b/genfit/core/include/MeasurementOnPlane.h deleted file mode 100644 index ce4ebba877..0000000000 --- a/genfit/core/include/MeasurementOnPlane.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_MeasurementOnPlane_h -#define genfit_MeasurementOnPlane_h - -#include "MeasuredStateOnPlane.h" -#include "AbsHMatrix.h" - -#include - -#include - - -namespace genfit { - -/** - * @brief Measured coordinates on a plane. - * - * The dimensionality will usually be 1 or 2. - * The HMatrix is a projetion matrix, which is used to project the track parameters - * with the originalt dimesionality down to the measured dimensionality. - */ -class MeasurementOnPlane : public MeasuredStateOnPlane { - - public: - - MeasurementOnPlane(const AbsTrackRep* rep = NULL) : - MeasuredStateOnPlane(rep), hMatrix_(NULL), weight_(0) {} - MeasurementOnPlane(const TVectorD& state, const TMatrixDSym& cov, SharedPlanePtr plane, const AbsTrackRep* rep, const AbsHMatrix* hMatrix, double weight = 1.) : - MeasuredStateOnPlane(state, cov, plane, rep), hMatrix_(hMatrix), weight_(weight) {} - - //! copy constructor - MeasurementOnPlane(const MeasurementOnPlane& other); - //! assignment operator - MeasurementOnPlane& operator=(MeasurementOnPlane other); - void swap(MeasurementOnPlane& other); - - virtual ~MeasurementOnPlane() {} - - const AbsHMatrix* getHMatrix() const {return hMatrix_.get();} - double getWeight() const {return weight_;} - - TMatrixDSym getWeightedCov() {return weight_*cov_;} - - void setHMatrix(const AbsHMatrix* hMatrix) {hMatrix_.reset(hMatrix);} - void setWeight(double weight) {weight_ = fmax(weight, 1.E-10);} - - void Print(Option_t* option = "") const ; - - protected: - -#ifndef __CINT__ - boost::scoped_ptr hMatrix_; // Ownership -#else - const AbsHMatrix* hMatrix_; //! Ownership. Projection matrix -#endif - double weight_; - - public: - ClassDef(MeasurementOnPlane,1) - -}; - -} /* End of namespace */ -/** @} */ - -#endif // _MeasurementOnPlane_h diff --git a/genfit/core/include/MeasurementProducer.h b/genfit/core/include/MeasurementProducer.h deleted file mode 100644 index fe959f723f..0000000000 --- a/genfit/core/include/MeasurementProducer.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_MeasurementProducer_h -#define genfit_MeasurementProducer_h - -#include "Exception.h" -#include "TrackCand.h" - -#include -#include - - -namespace genfit { - -class AbsMeasurement; - -/** @brief Abstract interface class for MeasurementProducer - * - * Defines the very basic interface of a producer. - */ -template -class AbsMeasurementProducer { -public: - /** @brief Virtual abstract method to produce a Measurement. - * Implemented in MeasurementProducer - */ - virtual measurement_T* produce(int index, const TrackCandHit* hit) = 0; - virtual ~AbsMeasurementProducer() {}; -}; - - -/** @brief Template class for a measurement producer module - * - * A MeasurementProducer module is used by MeasurementFactory to create Measurements for - * one specific detector type. - * - * It is assumed that each detector has as output of its digitization / - * clustering some sort of hit or cluster class which stores all information that - * corresponds to a measured hit in that detector. The MeasurementProducer - * converts this information into a class that can be handled by genfit. - * This class is realized as a Measurement (a class inheriting from AbsMeasurement). - * - * In order to use the MeasurementProducer facility, a - * Measurement has to implement a constructor which takes as an argument - * a pointer to the cluster class and a TrackCandHit. This constructor serves as the initializing - * constructor for the Measurement. - * - * The MeasurementProducer will fetch the cluster objects from a TClonesArray and - * use the initializing constructor to build the corresponding Measurement. - * - * @param hit_t template parameter specifying hit/cluster class - * @param measurement_T template parameter specifying Measurement - */ -template -class MeasurementProducer : public AbsMeasurementProducer { - private: - /** @brief pointer to array with cluster data */ - TClonesArray* hitArrayTClones_; - - public: - /** @brief Constructor takes pointer to the hit array */ - MeasurementProducer(TClonesArray*); - virtual ~MeasurementProducer(); - - /** @brief Create a Measurement from the cluster at position index - * in TClonesArray - */ - virtual AbsMeasurement* produce(int index, const TrackCandHit* hit); -}; - - -template - MeasurementProducer::MeasurementProducer(TClonesArray* theArr) { - hitArrayTClones_ = theArr; - //std::cout << "hit array with " << hitArrayTClones_->GetEntries() << " entries." << std::endl; -} - -template -MeasurementProducer::~MeasurementProducer() { - // we don't assume ownership over the hit arrays -} - -template -AbsMeasurement* MeasurementProducer::produce(int index, const TrackCandHit* hit) { - assert(hitArrayTClones_ != NULL); - //std::cout << "hit array with " << hitArrayTClones_->GetEntries() << " entries, looking for entry " << index << "." << std::endl; - if(hitArrayTClones_->At(index) == 0) { - Exception e("In MeasurementProducer: index for hit in TClonesArray out of bounds",__LINE__,__FILE__); - e.setFatal(); - throw e; - } - return ( new measurement_T( (hit_T*) hitArrayTClones_->At(index), hit ) ); -} - - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_MeasurementProducer_h diff --git a/genfit/core/include/SharedMaterialPropertiesPtr.h b/genfit/core/include/SharedMaterialPropertiesPtr.h deleted file mode 100644 index 629c8af68d..0000000000 --- a/genfit/core/include/SharedMaterialPropertiesPtr.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_SharedMaterialPropertiesPtr_h -#define genfit_SharedMaterialPropertiesPtr_h - -#include "MaterialProperties.h" - -#ifndef __CINT__ -#include -#endif - - - -namespace genfit { - -#ifndef __CINT__ -typedef boost::shared_ptr< const genfit::MaterialProperties > SharedMaterialPropertiesPtr; -#else -class SharedMaterialPropertiesPrt; -#endif - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_SharedMaterialPropertiesPtr_h diff --git a/genfit/core/include/SharedPlanePtr.h b/genfit/core/include/SharedPlanePtr.h deleted file mode 100644 index dabffaa60b..0000000000 --- a/genfit/core/include/SharedPlanePtr.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_SharedPlanePtr_h -#define genfit_SharedPlanePtr_h - -#include "DetPlane.h" - -#ifndef __CINT__ -#include -#endif - - -namespace genfit { - -/** - * @brief Shared Pointer to a DetPlane. - * - * Ownership can be shared, e.g between multiple StateOnPlane objects. - * The DetPlane will automatically be deleted, if no owner remains. - */ -#ifndef __CINT__ -typedef boost::shared_ptr< genfit::DetPlane > SharedPlanePtr; -#else -class SharedPlanePtr; -#endif - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_SharedPlanePtr_h diff --git a/genfit/core/include/StateOnPlane.h b/genfit/core/include/StateOnPlane.h deleted file mode 100644 index d5f23156a6..0000000000 --- a/genfit/core/include/StateOnPlane.h +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_StateOnPlane_h -#define genfit_StateOnPlane_h - -#include "SharedPlanePtr.h" -#include "AbsTrackRep.h" - -#include -#include - - -namespace genfit { - -/** - * @brief A state with arbitrary dimension defined in a DetPlane. - * - * The dimension and meaning of the #state_ vector are defined by the track parameterization of the #rep_. - * #sharedPlane_ is a shared_pointer, the ownership over that plane is shared between all StateOnPlane objects defined in that plane. - * The definition of the state is bound to the TrackRep #rep_. Therefore, the StateOnPlane contains a pointer to a AbsTrackRep. - * It will provide functionality to extrapolate it and translate the state it into cartesian coordinates. - * Shortcuts to all functions of the AbsTrackRep which use this StateOnPlane are also provided here. - */ -class StateOnPlane : public TObject { - - public: - - - StateOnPlane(const AbsTrackRep* rep = NULL); - StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep); - StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo); - - StateOnPlane& operator=(StateOnPlane other); - void swap(StateOnPlane& other); // nothrow - - virtual ~StateOnPlane() {} - - const TVectorD& getState() const {return state_;} - TVectorD& getState() {return state_;} - const TVectorD& getAuxInfo() const {return auxInfo_;} - TVectorD& getAuxInfo() {return auxInfo_;} - const SharedPlanePtr& getPlane() const {return sharedPlane_;} - const AbsTrackRep* getRep() const {return rep_;} - - void setState(const TVectorD& state) {if(state_.GetNrows() == 0) state_.ResizeTo(state); state_ = state;} - void setPlane(const SharedPlanePtr& plane) {sharedPlane_ = plane;} - void setStatePlane(const TVectorD& state, const SharedPlanePtr& plane) {state_ = state; sharedPlane_ = plane;} - void setAuxInfo(const TVectorD& auxInfo) {if(auxInfo_.GetNrows() == 0) auxInfo_.ResizeTo(auxInfo); auxInfo_ = auxInfo;} - void setRep(const AbsTrackRep* rep) {rep_ = rep;} - - // Shortcuts to TrackRep functions - double extrapolateToPlane(const SharedPlanePtr& plane, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) {return rep_->extrapolateToPlane(*this, plane, stopAtBoundary, calcJacobianNoise);} - double extrapolateToLine(const TVector3& linePoint, - const TVector3& lineDirection, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) {return rep_->extrapolateToLine(*this, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);} - double extrapolateToPoint(const TVector3& point, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) {return rep_->extrapolateToPoint(*this, point, stopAtBoundary, calcJacobianNoise);} - double extrapolateToPoint(const TVector3& point, - const TMatrixDSym& G, // weight matrix (metric) - bool stopAtBoundary = false, - bool calcJacobianNoise = false) {return rep_->extrapolateToPoint(*this, point, G, stopAtBoundary, calcJacobianNoise);} - double extrapolateToCylinder(double radius, - const TVector3& linePoint = TVector3(0.,0.,0.), - const TVector3& lineDirection = TVector3(0.,0.,1.), - bool stopAtBoundary = false, - bool calcJacobianNoise = false) {return rep_->extrapolateToCylinder(*this, radius, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);} - double extrapolateToSphere(double radius, - const TVector3& point = TVector3(0.,0.,0.), - bool stopAtBoundary = false, - bool calcJacobianNoise = false) {return rep_->extrapolateToSphere(*this, radius, point, stopAtBoundary, calcJacobianNoise);} - double extrapolateBy(double step, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) {return rep_->extrapolateBy(*this, step, stopAtBoundary, calcJacobianNoise);} - double extrapolateToMeasurement(const AbsMeasurement* measurement, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) {return rep_->extrapolateToMeasurement(*this, measurement, stopAtBoundary, calcJacobianNoise);} - - - TVector3 getPos() const {return rep_->getPos(*this);} - TVector3 getMom() const {return rep_->getMom(*this);} - TVector3 getDir() const {return rep_->getDir(*this);} - void getPosMom(TVector3& pos, TVector3& mom) const {rep_->getPosMom(*this, pos, mom);} - void getPosDir(TVector3& pos, TVector3& dir) const {rep_->getPosDir(*this, pos, dir);} - TVectorD get6DState() const {return rep_->get6DState(*this);} - double getMomMag() const {return rep_->getMomMag(*this);} - int getPDG() const {return rep_->getPDG();} - double getCharge() const {return rep_->getCharge(*this);} - double getQop() const {return rep_->getQop(*this);} - double getMass() const {return rep_->getMass(*this);} - - void setPosMom(const TVector3& pos, const TVector3& mom) {rep_->setPosMom(*this, pos, mom);} - void setPosMom(const TVectorD& state6) {rep_->setPosMom(*this, state6);} - void setChargeSign(double charge) {rep_->setChargeSign(*this, charge);} - void setQop(double qop) {rep_->setQop(*this, qop);} - - - virtual void Print(Option_t* option = "") const; - - protected: - - TVectorD state_; // state vector - TVectorD auxInfo_; // auxiliary information (e.g. charge, flight direction etc.) - SharedPlanePtr sharedPlane_; //! Shared ownership. '!' in order to silence ROOT, custom streamer writes and reads this. - - private: - - /** Pointer to TrackRep with respect to which StateOnPlane is defined - */ - const AbsTrackRep* rep_; //! No ownership - - public: - ClassDef(StateOnPlane,1) - -}; - - -inline StateOnPlane::StateOnPlane(const AbsTrackRep* rep) : - state_(0), auxInfo_(0), sharedPlane_(), rep_(rep) -{ - if (rep != NULL) { - state_.ResizeTo(rep->getDim()); - } -} - -inline StateOnPlane::StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep) : - state_(state), auxInfo_(0), sharedPlane_(plane), rep_(rep) -{ - assert(rep != NULL); - assert(sharedPlane_.get() != NULL); -} - -inline StateOnPlane::StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo) : - state_(state), auxInfo_(auxInfo), sharedPlane_(plane), rep_(rep) -{ - assert(rep != NULL); - assert(sharedPlane_.get() != NULL); -} - -inline StateOnPlane& StateOnPlane::operator=(StateOnPlane other) { - swap(other); - return *this; -} - -inline void StateOnPlane::swap(StateOnPlane& other) { - this->state_.ResizeTo(other.state_); - std::swap(this->state_, other.state_); - this->auxInfo_.ResizeTo(other.auxInfo_); - std::swap(this->auxInfo_, other.auxInfo_); - this->sharedPlane_.swap(other.sharedPlane_); - std::swap(this->rep_, other.rep_); -} - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_StateOnPlane_h diff --git a/genfit/core/include/ThinScatterer.h b/genfit/core/include/ThinScatterer.h deleted file mode 100644 index d4cfd25622..0000000000 --- a/genfit/core/include/ThinScatterer.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_ThinScatterer_h -#define genfit_ThinScatterer_h - -#include "SharedPlanePtr.h" -#include "MaterialProperties.h" - -#include - - -namespace genfit { - -/** - * @brief Thin or thick scatterer - */ -class ThinScatterer : public TObject { - - public: - - ThinScatterer() : - TObject(), sharedPlane_(), material_() {;} - ThinScatterer(const SharedPlanePtr& sharedPlane, const MaterialProperties& material) : - TObject(), sharedPlane_(sharedPlane), material_(material) {;} - - SharedPlanePtr getPlane() const {return sharedPlane_;} - const MaterialProperties& getMaterial() const {return material_;} - - void Print(const Option_t* = "") const; - - private: - - SharedPlanePtr sharedPlane_; //! Material boundary. '!' shuts up ROOT. - MaterialProperties material_; // Material properties - - - public: - ClassDef(ThinScatterer, 1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_ThinScatterer_h diff --git a/genfit/core/include/Tools.h b/genfit/core/include/Tools.h deleted file mode 100644 index a33a3d30ac..0000000000 --- a/genfit/core/include/Tools.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_Tools_h -#define genfit_Tools_h - -#include -#include -#include - -/** - * @brief Matrix inversion tools. - */ -namespace genfit { -namespace tools { - - /** @brief Invert a matrix, throwing an Exception when inversion fails. - * Optional calculation of determinant. - */ - void invertMatrix(const TMatrixDSym& mat, TMatrixDSym& inv, double* determinant = NULL); - /** @brief Same, replacing its argument. - */ - void invertMatrix(TMatrixDSym& mat, double* determinant = NULL); - - /** @brief Solves R^t x = b, replacing b with the solution for x. R is - * assumed to be upper diagonal. - */ - bool transposedForwardSubstitution(const TMatrixD& R, TVectorD& b); - /** @brief Same, for a column of the matrix b. */ - bool transposedForwardSubstitution(const TMatrixD& R, TMatrixD& b, int nCol); - /** @brief Inverts the transpose of the upper right matrix R into inv. */ - bool transposedInvert(const TMatrixD& R, TMatrixD& inv); - - /** @brief Replaces A with an upper right matrix connected to A by - * an orthongonal transformation. I.e., it computes R from a QR - * decomposition of A = QR, replacing A. - */ -void QR(TMatrixD& A); - - /** @brief This averages the covariance matrices C1, C2 in a - * numerically stable way by using matrix square roots. This code - * is in no way optimized so use with care if speed is a concern. - */ -void safeAverage(const TMatrixDSym& C1, const TMatrixDSym& C2, - TMatrixDSym& result); - -} /* End of namespace tools */ -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_Tools_h diff --git a/genfit/core/include/Track.h b/genfit/core/include/Track.h deleted file mode 100644 index 31b225ed01..0000000000 --- a/genfit/core/include/Track.h +++ /dev/null @@ -1,313 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_Track_h -#define genfit_Track_h - -#include "AbsTrackRep.h" -#include "FitStatus.h" -#include "MeasurementFactory.h" -#include "TrackCand.h" -#include "TrackPoint.h" - -#include -#include -#include - - -namespace genfit { - -class KalmanFitStatus; - -/** - * @brief Helper class for TrackPoint sorting, used in Track::sort(). - */ -class TrackPointComparator { - public: - /** - * Comparison operator used in Track::sort(). Compares sorting parameter. - */ - bool operator() (const TrackPoint* lhs, const TrackPoint* rhs) const { - return lhs->getSortingParameter() < rhs->getSortingParameter(); - } -}; - - -/** - * @brief Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects - * - * Holds a number of AbsTrackRep objects, which correspond to the - * different particle hypotheses or track models which should be fitted. - * A 6D seed #stateSeed_ (x,y,z,p_x,p_y,p_z) and 6x6 #covSeed_ should be provided as start values for fitting. - * When fitting the Track with a AbsFitter, - * a FitStatus object will be created, containing information about the fit. - * The fitted states will be stored in AbsFitterInfo objects in every TrackPoints. - * - * The fit will be performed for every AbsTrackRep, - * so after the fit there will be one AbsFitterInfo for each AbsTrackRep - * in every TrackPoint, as well as one FitStatus for every AbsTrackRep. - * - */ -class Track : public TObject { - - public: - - Track(); - - /** - * @ brief Construct Track from TrackCand, using a MeasurementFactory - * - * The MeasurementFactory will be used to create AbsMeasuremen objects. - * TrackPoints will be created. - * If two or more consecutive PlanarMeasurement objects with the same detector- and planeId - * are created by the factory, they will be put into the same TrackPoint. - * - * Optionally, a AbsTrackRep can be provided. - * - * The stateSeed_ of the Track will be filled with the seed of the TrackCand. - * A guess for covSeed_ will be made using the largest entry of the cov of the first measurement - * and the number of measurements (For the covSeed_, it is just important that it will be - * big enough not to bias the fit too much, but not too big in order to avoid - * numerical problems). - */ - Track(const TrackCand& trackCand, const MeasurementFactory& factory, AbsTrackRep* rep = NULL); - - Track(AbsTrackRep* trackRep, const TVectorD& stateSeed); - Track(AbsTrackRep* trackRep, const TVector3& posSeed, const TVector3& momSeed); - Track(AbsTrackRep* trackRep, const TVectorD& stateSeed, const TMatrixDSym& covSeed); - - Track(const Track&); // copy constructor - Track& operator=(Track); // assignment operator - void swap(Track& other); // nothrow - - virtual ~Track(); - virtual void Clear(Option_t* = ""); - - TrackPoint* getPoint(int id) const; - const std::vector< genfit::TrackPoint* > & getPoints() const {return trackPoints_;} - unsigned int getNumPoints() const {return trackPoints_.size();} - - TrackPoint* getPointWithMeasurement(int id) const; - const std::vector< genfit::TrackPoint* > & getPointsWithMeasurement() const {return trackPointsWithMeasurement_;} - unsigned int getNumPointsWithMeasurement() const {return trackPointsWithMeasurement_.size();} - - TrackPoint* getPointWithMeasurementAndFitterInfo(int id, const AbsTrackRep* rep) const; - - /** - * @brief Shortcut to get FittedStates. - * - * Uses getPointWithMeasurementAndFitterInfo(id, rep). - * Gets the fitted state at trackpoint id for the track representation rep. - * Per default, the fitted state of the fitterInfo of the first TrackPoint - * with one or more AbsMeasurement and AbsFitterInfo objects - * is returned. If no AbsTrackRep is specified, the AbsFitterInfo of the cardinal rep will be used. - */ - const MeasuredStateOnPlane& getFittedState(int id = 0, const AbsTrackRep* rep = NULL, bool biased = true) const; - - AbsTrackRep* getTrackRep(int id) const {return trackReps_.at(id);} - unsigned int getNumReps() const {return trackReps_.size();} - - //! This is used when streaming TrackPoints. - int getIdForRep(const AbsTrackRep* rep) const; - - /** @brief Get cardinal track representation - * - * The user has to choose which AbsTrackRep should be considered the - * best one after the fit. E.g. the track representation giving the - * smallest chi2 could be chosen. By default the first in the list is returned. - * @sa #determineCardinalRep() - */ - AbsTrackRep* getCardinalRep() const {return trackReps_.at(cardinalRep_);} - unsigned int getCardinalRepId() const {return cardinalRep_;} - - //! Get the MCT track id, for MC simulations - default value = -1 - int getMcTrackId() const {return mcTrackId_;} - - //! Check if track has a FitStatus for given AbsTrackRep. Per default, check for cardinal rep. - bool hasFitStatus(const AbsTrackRep* rep = NULL) const; - //! Get FitStatus for a AbsTrackRep. Per default, return FitStatus for cardinalRep. - FitStatus* getFitStatus(const AbsTrackRep* rep = NULL) const {if (rep == NULL) rep = getCardinalRep(); return fitStatuses_.at(rep);} - - //! Check if track has a KalmanFitStatus for given AbsTrackRep. Per default, check for cardinal rep. - bool hasKalmanFitStatus(const AbsTrackRep* rep = NULL) const; - //! If FitStatus is a KalmanFitStatus, return it. Otherwise return NULL - KalmanFitStatus* getKalmanFitStatus(const AbsTrackRep* rep = NULL) const; - - void setFitStatus(FitStatus* fitStatus, const AbsTrackRep* rep); - - const TVectorD& getStateSeed() const {return stateSeed_;} - void setStateSeed(const TVectorD& s) {stateSeed_.ResizeTo(s); stateSeed_ = s;} - void setStateSeed(const TVector3& pos, const TVector3& mom); - - const TMatrixDSym& getCovSeed() const {return covSeed_;} - void setCovSeed(const TMatrixDSym& c) {covSeed_.ResizeTo(c); covSeed_ = c;} - - //! Set the MCT track id, for MC simulations - void setMcTrackId(int i) {mcTrackId_ = i;} - - /** - * @brief Insert TrackPoint BEFORE TrackPoint with position id, if id >= 0. - * - * Id -1 means after last TrackPoint. Id -2 means before last TrackPoint. ... - * Also deletes backwardInfos before new point and forwardInfos after new point. - * Also sets Track backpointer of point accordingly. - */ - void insertPoint(TrackPoint* point, int id = -1); - - /** - * @brief Insert TrackPoints BEFORE TrackPoint with position id, if id >= 0. - * - * Id -1 means after last TrackPoint. Id -2 means before last TrackPoint. ... - * Also deletes backwardInfos before and for new points and forwardInfos after and for new points. - * Also sets Track backpointers of points accordingly. - */ - void insertPoints(std::vector points, int id = -1); - - void deletePoint(int id); - - //! Creates a new TrackPoint containing the measurement, and adds it to the track - void insertMeasurement(AbsMeasurement* measurement, int id = -1); - - /** - * @brief Merge two tracks. - * - * The TrackPoint objects of other will be cloned and inserted - * after id (per default, they will be appended at the end). - * The other Track will not be altered, the TrackPoint objects will be (deep) copied. - * Only copies the TrackPoint objects, NOT the AbsTrackRep, FitStatus, seed state and other objects of the other track. - */ - void mergeTrack(const Track* other, int id = -1); - - void addTrackRep(AbsTrackRep* trackRep); - - //! Delete a AbsTrackRep and all corresponding AbsFitterInfo objects in every TrackPoint. - void deleteTrackRep(int id); - - void setCardinalRep(int id); - //! See with which AbsTrackRep the track was fitted best (converged fit w/ smallest chi2) and set the cardinal rep accordingly. - void determineCardinalRep(); - - /** - * @brief Sort TrackPoint and according to their sorting parameters. - * - * Returns if the order of the TrackPoint has actually changed. - */ - bool sort(); - - //! Try to set the fitted state as seed. Return if it was successfull. - //! Adapt the sign of all TrackReps' pdg to the actual fitted charge. - bool udpateSeed(int id = 0, AbsTrackRep* rep = NULL, bool biased = true); - - //! Flip the ordering of the TrackPoints - void reverseTrackPoints(); - - //! Flip direction of momentum seed - void reverseMomSeed() { - stateSeed_(3) *= -1; stateSeed_(4) *= -1; stateSeed_(5) *= -1; - } - - //! Switch the pdg signs of specified rep (of all reps if rep == NULL). - void switchPDGSigns(AbsTrackRep* rep = NULL); - - //! Make track ready to be fitted in reverse direction - /** - * Flip the order of TrackPoints and the momentum direction of the seed state. - * If possible, take the smoothed state of the last hit as new seed state. - * Flip charge of the TrackReps. - */ - void reverseTrack(); - - - void deleteForwardInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = NULL); // delete in range [startId, endId]. If rep == NULL, delete for ALL reps, otherwise only for rep. - void deleteBackwardInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = NULL); // delete in range [startId, endId]. If rep == NULL, delete for ALL reps, otherwise only for rep. - void deleteReferenceInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = NULL); // delete in range [startId, endId]. If rep == NULL, delete for ALL reps, otherwise only for rep. - void deleteMeasurementInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = NULL); // delete in range [startId, endId]. If rep == NULL, delete for ALL reps, otherwise only for rep. - void deleteFitterInfo(int startId = 0, int endId = -1, const AbsTrackRep* rep = NULL); // delete in range [startId, endId]. If rep == NULL, delete for ALL reps, otherwise only for rep. - - //! get TrackLength between to trackPoints (if NULL, for cardinal rep) - double getTrackLen(AbsTrackRep* rep = NULL, int startId = 0, int endId = -1) const; - //! get time of flight in ns between to trackPoints (if NULL, for cardinal rep) - double getTOF(AbsTrackRep* rep = NULL, int startId = 0, int endId = -1) const; - - //! Construct a new TrackCand containing the hit IDs of the measurements - /** - * The idea is hat you can get a TrackCand for storing the hit IDs after a track has been fitted. - * His could have been reordered, added or removed, so that the original TackCand no longer - * represents the Track correctly. - * You might want to call determineCardinalRep() and/or udpateSeed() before. - */ - //TrackCand* constructTrackCand() const; - TrackCand* constructTrackCand() const { return 0; /* implementation missing FIXME RDM */ } - - //! Helper function: For all KalmanFitterInfos belonging to rep (if NULL, for all reps), - //! call the fixWeights() function, so that e.g. the DAF will not alter weights anymore. - void fixWeights(AbsTrackRep* rep = NULL, int startId = 0, int endId = -1); - - /** - * @brief Delete unneeded information from the Track. - * - * Possible options: - * C: prune all reps except cardinalRep - * F: prune all points except first point - * L: prune all points except last point - * FL: prune all points except first and last point - * W: prune rawMeasurements from TrackPoints - * R: prune referenceInfo from fitterInfos - * M: prune measurementInfo from fitterInfos - * I: if F, L, or FL is set, prune forward (backward) info of first (last) point - * U: if fitterInfo is a KalmanFitterInfo, prune predictions and keep updates - */ - void prune(const Option_t* = "CFLWRMIU"); - - void Print(const Option_t* = "") const; - - bool checkConsistency() const; - - private: - - void trackHasChanged(); - - void fillPointsWithMeasurement(); - - std::vector trackReps_; // Ownership - unsigned int cardinalRep_; // THE selected rep, default = 0; - - std::vector trackPoints_; // Ownership - std::vector trackPointsWithMeasurement_; //! helper - - std::map< const AbsTrackRep*, FitStatus* > fitStatuses_; // Ownership over FitStatus* - - int mcTrackId_; /**< if MC simulation, store the mc track id here */ - TVectorD stateSeed_; // 6D: position, momentum - TMatrixDSym covSeed_; // 6D - - - public: - ClassDef(Track,2) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_Track_h diff --git a/genfit/core/include/TrackCand.h b/genfit/core/include/TrackCand.h deleted file mode 100644 index 6456778085..0000000000 --- a/genfit/core/include/TrackCand.h +++ /dev/null @@ -1,212 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . - */ -/** @addtogroup genfit - * @{ */ - -#ifndef genfit_TrackCand_h -#define genfit_TrackCand_h - -#include "TrackCandHit.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - - -namespace genfit { - -/** @brief Track candidate -- seed values and indices - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * @author Moritz Nadler (maintainer during 2012) - * - * The main task of the TrackCand object is to store a list of indices to - * cluster objects. Each cluster in the Track is identified by it's - * detector ID and it's index in the corresponding TClonesArray. - * Also there is a ordering parameter to order hits. - * Optionally, plane indices for the hits can be stored (most importantly - * for fitting with the Daf). - * This information is used by the RecoHitFactory to automatically load - * RecoHits into a Track. Through this it is possible to define Tracks over - * an arbitrary number of different detectors. - * - * In addition TrackCand offers members to store starting values for the fit. - * The starting values (seeds) for the fit are stored as a 6D state (x,y,z,px,py,pz) and its - * corresponding 6x6 covariance matrix. All seed getter and setter manipulate these two members - * but the user can chose using TVector3 or TMatrixD to get/set the seed state. - * However this information is not automatically used in genfit. - * But a pointer to a TrackCand can be passed to the a RKTrackRep constructor - * to make use of this information without manually extracting it from the TrackCand object. - * - * @sa RecoHitFactory - */ -class TrackCand : public TObject { - - - public: - - - // Constructors/Destructors --------- - TrackCand(); - ~TrackCand(); - - //! copy constructor - TrackCand( const TrackCand& other ); - //! assignment operator - TrackCand& operator=(TrackCand other); - void swap(TrackCand& other); // nothrow - - //! == operator checks equality of TrackCandHits. Does not check for sorting parameters. - friend bool operator== (const TrackCand& lhs, const TrackCand& rhs); - friend bool operator!= (const TrackCand& lhs, const TrackCand& rhs) {return !(lhs == rhs);} - - static bool compareTrackCandHits(const TrackCandHit* lhs, const TrackCandHit* rhs) {return (*lhs < *rhs);} // operator< defined in TrackCandHit.h - - // Accessors ----------------------- - TrackCandHit* getHit(int i) const; - - //!Get detector Id and hit Id for hit number i - void getHit(int i, int& detId, int& hitId) const; - - //! Get detector Id, hit Id and sorting parameter for hit number i - void getHit(int i, int& detId, int& hitId, double& sortingParameter) const; - - //! Get detector Id, hit Id and plane id for hit number i - void getHitWithPlane(int i, int& detId, int& hitId, int& planeId) const; - - unsigned int getNHits() const {return hits_.size();} - - /** - * @brief Get hit ids of from a specific detector. - * - * DetId -1 gives hitIds of hits with default detId -1. The default argument -2 gives hit Ids of all hits. - */ - std::vector getHitIDs(int detId = -2) const; - - //! Get detector IDs of all hits - std::vector getDetIDs() const; - //! Get sorting parameterts of all hits - std::vector getSortingParameters() const; - std::set getUniqueDetIDs() const; - - //! Get the MCT track id, for MC simulations - default value = -1 - int getMcTrackId() const {return mcTrackId_;} - - /** @brief get the seed value for track: pos. Identical to the first 3 components of getStateSeed*/ - TVector3 getPosSeed() const {return TVector3(state6D_(0), state6D_(1), state6D_(2));} - - /** @brief get the seed value for track: mom. Identical to the last 3 components of getStateSeed*/ - TVector3 getMomSeed() const {return TVector3(state6D_(3), state6D_(4), state6D_(5));} - - /** @brief set the covariance matrix seed (6D). */ - void setCovSeed(const TMatrixDSym& cov6D) {cov6D_ = cov6D; /* always 6D, no need to resize */} - - /** @brief get the covariance matrix seed (6D). */ - const TMatrixDSym& getCovSeed() const {return cov6D_;} - - //! Returns the 6D seed state; should be in global coordinates. - const TVectorD& getStateSeed() const {return state6D_;} - - double getChargeSeed() const {return q_;} - - //! Get the PDG code - int getPdgCode() const {return pdg_;} - - //! Is there a hit with detId and hitId in the TrackCand? - bool hitInTrack(int detId, int hitId) const; - - // Modifiers ----------------------- - - void addHit(int detId, int hitId, int planeId = -1, double sortingParameter = 0); - - void addHit(TrackCandHit* hit) {hits_.push_back(hit);} - - //! Set the MCT track id, for MC simulations - void setMcTrackId(int i) {mcTrackId_ = i;} - - //! Set a particle hypothesis in form of a PDG code. This will also set the charge attribute - void setPdgCode(int pdgCode); - - //! Clone the TrackCandHit objects from the other TrackCand and append them to this TrackCand - void append(const TrackCand&); - - //! Sort the hits that were already added to the trackCand using the sorting parameters. - void sortHits(); - - void sortHits(const std::vector& indices); - - // Operations ---------------------- - //! Delete and clear the TrackCandHits - void reset(); - - //! Write the content of all private attributes to the terminal - void Print(const Option_t* = "") const ; - - /** @brief sets the state to seed the track fitting. State has to be a TVectorD(6). First 3 elements are the staring postion second 3 elements the starting momentum. Everything in global coordinates - * charge is the charge hypotheses of the particle charge - */ - void set6DSeed(const TVectorD& state6D, const double charge); - - /** @brief This function works the same as set6DSeed but instead of a charge hypothesis you can set a pdg code which will set the charge automatically - */ - void set6DSeedAndPdgCode(const TVectorD& state6D, const int pdgCode); - - /** @brief sets the state to seed the track fitting. State has to be a TVector3 for position and a TVector3 for momentum. Everything in global coordinates - * charge is the charge hypotheses of the particle charge - */ - void setPosMomSeed(const TVector3& pos, const TVector3& mom, const double charge); - - /** @brief This function works the same as setPosMomSeed but instead of a charge hypothesis you can set a pdg code which will set the charge automatically - */ - void setPosMomSeedAndPdgCode(const TVector3& pos, const TVector3& mom, const int pdgCode); - - - private: - - // Private Data Members ------------ - std::vector hits_; //-> - - int mcTrackId_; /**< if MC simulation, store the mc track id here */ - int pdg_; /**< particle data groupe's id for a particle*/ - - TVectorD state6D_; /**< global 6D position plus momentum state */ - TMatrixDSym cov6D_; /**< global 6D position plus momentum state */ - double q_; /**< the charge of the particle in units of elementary charge */ - - - public: - - ClassDef(TrackCand,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_TrackCand_h diff --git a/genfit/core/include/TrackCandHit.h b/genfit/core/include/TrackCandHit.h deleted file mode 100644 index 2183be8286..0000000000 --- a/genfit/core/include/TrackCandHit.h +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . - */ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_TrackCandHit_h -#define genfit_TrackCandHit_h - -#include - - -namespace genfit { - -/** - * @brief Hit object for use in TrackCand. Provides IDs and sorting parameters. - */ -class TrackCandHit : public TObject { - public: - - // Constructors/Destructors --------- - TrackCandHit(int detId = -1, - int hitId = -1, - int planeId = -1, - double sortingParameter = 0.); - - virtual ~TrackCandHit() {;} - - virtual TrackCandHit* clone() const {return new TrackCandHit(*this);} - - // Accessors - int getDetId() const {return detId_;} - int getHitId() const {return hitId_;} - int getPlaneId() const {return planeId_;} - double getSortingParameter() const {return sortingParameter_;} - - // Modifiers - void setSortingParameter(double sortingParameter) {sortingParameter_ = sortingParameter;} - - virtual void Print(Option_t* option = "") const; - - - /** @brief Equality operator. Does not check sortingParameter. - */ - friend bool operator== (const TrackCandHit& lhs, const TrackCandHit& rhs); - friend bool operator!= (const TrackCandHit& lhs, const TrackCandHit& rhs) { - return !(lhs == rhs); - } - - /** @brief Compare sortingParameter, needed for sorting - */ - friend bool operator< (const TrackCandHit& lhs, const TrackCandHit& rhs) { - return (lhs.sortingParameter_ < rhs.sortingParameter_); - } - - protected: - - //! protect from calling copy c'tor from outside the class. Use #clone() if you want a copy! - TrackCandHit(const TrackCandHit& other) : - TObject(other), detId_(other.detId_), hitId_(other.hitId_), planeId_(other.planeId_), sortingParameter_(other.sortingParameter_) {;} - //! protect from calling assignment operator from outside the class. Use #clone() instead! - TrackCandHit& operator=(const TrackCandHit&); - - - // Data Members ------------ - int detId_; // detId id is -1 per default - int hitId_; // hitId id is -1 per default - int planeId_; // planeId id is -1 per default - double sortingParameter_; // sorting parameter - - - public: - - ClassDef(TrackCandHit,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_TrackCandHit_h diff --git a/genfit/core/include/TrackPoint.h b/genfit/core/include/TrackPoint.h deleted file mode 100644 index 6f1e3e643c..0000000000 --- a/genfit/core/include/TrackPoint.h +++ /dev/null @@ -1,166 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_TrackPoint_h -#define genfit_TrackPoint_h - -#include "AbsMeasurement.h" -#include "AbsFitterInfo.h" -#include "ThinScatterer.h" - -#include - -#include -#include -#include - -#ifndef __CINT__ -#include -#endif - - -namespace genfit { - -class Track; -class KalmanFitterInfo; - -/** - * @brief Object containing AbsMeasurement and AbsFitterInfo objects. - * - */ -class TrackPoint : public TObject { - - public: - - TrackPoint(); - TrackPoint(Track* track); - - /** - * @brief Contructor taking list of measurements. - * - * AbsMeasurement::setTrackPoint() of each measurement will be called. - * TrackPoint takes ownership over rawMeasurements. - */ - TrackPoint(const std::vector< genfit::AbsMeasurement* >& rawMeasurements, Track* track); - - /** - * @brief Contructor taking one measurement. - * - * AbsMeasurement::setTrackPoint() of the measurement will be called. - * TrackPoint takes ownership over the rawMeasurement. - */ - TrackPoint(genfit::AbsMeasurement* rawMeasurement, Track* track); - - TrackPoint(const TrackPoint&); // copy constructor - TrackPoint& operator=(TrackPoint); // assignment operator - void swap(TrackPoint& other); - - /** - * custom copy constructor where all TrackRep pointers are exchanged according to the map. - * FitterInfos with a rep in repsToIgnore will NOT be copied. - */ - TrackPoint(const TrackPoint& rhs, - const std::map& map, - const std::vector * repsToIgnore = NULL); - - virtual ~TrackPoint(); - - - double getSortingParameter() const {return sortingParameter_;} - - Track* getTrack() const {return track_;} - void setTrack(Track* track) {track_ = track;} - - const std::vector< genfit::AbsMeasurement* >& getRawMeasurements() const {return rawMeasurements_;} - AbsMeasurement* getRawMeasurement(int i = 0) const; - unsigned int getNumRawMeasurements() const {return rawMeasurements_.size();} - bool hasRawMeasurements() const {return (rawMeasurements_.size() != 0);} - //! Get list of all fitterInfos - std::vector< genfit::AbsFitterInfo* > getFitterInfos() const; - //! Get fitterInfo for rep. Per default, use cardinal rep - AbsFitterInfo* getFitterInfo(const AbsTrackRep* rep = NULL) const; - //! Helper to avoid casting - KalmanFitterInfo* getKalmanFitterInfo(const AbsTrackRep* rep = NULL) const; - bool hasFitterInfo(const AbsTrackRep* rep) const { - return (fitterInfos_.find(rep) != fitterInfos_.end()); - } - - ThinScatterer* getMaterialInfo() {return thinScatterer_.get();} - bool hasThinScatterer() {return thinScatterer_.get() != NULL;} - - - void setSortingParameter(double sortingParameter) {sortingParameter_ = sortingParameter;} - //! Takes ownership and sets this as measurement's trackPoint - void addRawMeasurement(genfit::AbsMeasurement* rawMeasurement) {assert(rawMeasurement!=NULL); rawMeasurement->setTrackPoint(this); rawMeasurements_.push_back(rawMeasurement);} - void deleteRawMeasurements(); - //! Takes Ownership - void setFitterInfo(genfit::AbsFitterInfo* fitterInfo); - void deleteFitterInfo(const AbsTrackRep* rep) {delete fitterInfos_[rep]; fitterInfos_.erase(rep);} - - void setScatterer(ThinScatterer* scatterer) {thinScatterer_.reset(scatterer);} - - void Print(const Option_t* = "") const; - - /** - * This function is used when reading the TrackPoint and is called - * by the owner in order to build fitterInfos_ from vFitterInfos_. - * This requires that the track_ be set. It also empties - * vFitterInfos_ which has served its purpose after this function is - * called. - */ - void fixupRepsForReading(); - - private: - double sortingParameter_; - - //! Pointer to Track where TrackPoint belongs to - Track* track_; //! No ownership - - //! Can be more than one, e.g. multiple measurements in the same Si detector, left and right measurements of a wire detector etc. - std::vector rawMeasurements_; // Ownership - - std::map< const AbsTrackRep*, AbsFitterInfo* > fitterInfos_; //! Ownership over FitterInfos - - /** - * The following vector is read while streaming. After reading the - * TrackPoint, the Track's streamer will call fixupRepsForReading, - * and this vector will be translated into the map fitterInfos. The - * vector is indexed by the ids of the corresponding TrackReps. - */ - std::vector< AbsFitterInfo* > vFitterInfos_; //! - -#ifndef __CINT__ - boost::scoped_ptr thinScatterer_; // Ownership -#else - class ThinScatterer* thinScatterer_; -#endif - - public: - - ClassDef(TrackPoint,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_TrackPoint_h diff --git a/genfit/core/src/AbsFinitePlane.cc b/genfit/core/src/AbsFinitePlane.cc deleted file mode 100644 index 51faca1352..0000000000 --- a/genfit/core/src/AbsFinitePlane.cc +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "AbsFinitePlane.h" - -namespace genfit { - -} /* End of namespace genfit */ diff --git a/genfit/core/src/AbsFitter.cc b/genfit/core/src/AbsFitter.cc deleted file mode 100644 index 84e1bbbe48..0000000000 --- a/genfit/core/src/AbsFitter.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "AbsFitter.h" -#include "Track.h" - -namespace genfit { - -void AbsFitter::processTrack(Track* tr, bool resortHits) { - AbsTrackRep* cardRep = tr->getCardinalRep(); - // process cardinal rep first - processTrackWithRep(tr, cardRep, resortHits); - - // now process rest of reps, but don't change sorting anymore! - for (unsigned int i=0; igetNumReps(); ++i) { - if (tr->getTrackRep(i) != cardRep) - processTrackWithRep(tr, tr->getTrackRep(i), false); - } - - // self check - assert(tr->checkConsistency()); -} - -} /* End of namespace genfit */ diff --git a/genfit/core/src/AbsFitterInfo.cc b/genfit/core/src/AbsFitterInfo.cc deleted file mode 100644 index 965510b6c3..0000000000 --- a/genfit/core/src/AbsFitterInfo.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "AbsFitterInfo.h" - -#include -#include - -namespace genfit { - -AbsFitterInfo::AbsFitterInfo() : - trackPoint_(NULL), - rep_(NULL) -{ - ; -} - -AbsFitterInfo::AbsFitterInfo(const TrackPoint* trackPoint, const AbsTrackRep* rep) : - trackPoint_(trackPoint), - rep_(rep) -{ - ; -} - -void AbsFitterInfo::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::AbsFitterInfo. - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::AbsFitterInfo thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - //TObject::Streamer(R__b); - // See the long comment in AbsFinitePlane::Streamer. This - // creates a duplicate of the DetPlane. - TClass* cl = TClass::Load(R__b); - DetPlane *p = (DetPlane*)(cl->New()); - cl->Streamer(p, R__b); - sharedPlane_.reset(p); - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - //TObject::Streamer(R__b); - // See the long comment in AbsFinitePlane::Streamer. This - // stores a duplicate of the DetPlane, allowing for typesafe - // reading. - sharedPlane_->IsA()->Store(R__b); - sharedPlane_->Streamer(R__b); - R__b.SetByteCount(R__c, kTRUE); - } -} - -} /* End of namespace genfit */ diff --git a/genfit/core/src/AbsMeasurement.cc b/genfit/core/src/AbsMeasurement.cc deleted file mode 100644 index c09eb25ded..0000000000 --- a/genfit/core/src/AbsMeasurement.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "AbsMeasurement.h" - -#include -#include - - -namespace genfit { - -AbsMeasurement::AbsMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint) - : rawHitCoords_(rawHitCoords), rawHitCov_(rawHitCov), detId_(detId), hitId_(hitId), trackPoint_(trackPoint) -{ - assert(rawHitCov_.GetNrows() == rawHitCoords_.GetNrows()); -} - - -AbsMeasurement::AbsMeasurement(const AbsMeasurement& o) - : TObject(o), - rawHitCoords_(o.rawHitCoords_), - rawHitCov_(o.rawHitCov_), - detId_(o.detId_), - hitId_(o.hitId_), - trackPoint_(o.trackPoint_) -{ - ; -} - - -AbsMeasurement::~AbsMeasurement() -{ - ; -} - - -AbsMeasurement& AbsMeasurement::operator=(const AbsMeasurement&) { - fputs ("must not call AbsMeasurement::operator=\n",stderr); - abort(); - return *this; -} - - -void AbsMeasurement::Print(const Option_t*) const { - std::cout << "genfit::AbsMeasurement, detId = " << detId_ << ". hitId = " << hitId_ << "\n"; - std::cout << "Raw hit coordinates: "; rawHitCoords_.Print(); - std::cout << "Raw hit covariance: "; rawHitCov_.Print(); -} - - -} /* End of namespace genfit */ diff --git a/genfit/core/src/AbsTrackRep.cc b/genfit/core/src/AbsTrackRep.cc deleted file mode 100644 index 46de43ea2c..0000000000 --- a/genfit/core/src/AbsTrackRep.cc +++ /dev/null @@ -1,199 +0,0 @@ -/* Copyright 2008-2009, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "AbsTrackRep.h" -#include "StateOnPlane.h" -#include "AbsMeasurement.h" - -#include - -#include - - -namespace genfit { - -AbsTrackRep::AbsTrackRep() : - pdgCode_(0), propDir_(0), debugLvl_(0) -{ - ; -} - -AbsTrackRep::AbsTrackRep(int pdgCode, char propDir) : - pdgCode_(pdgCode), propDir_(propDir), debugLvl_(0) -{ - ; -} - -AbsTrackRep::AbsTrackRep(const AbsTrackRep& rep) : - TObject(rep), pdgCode_(rep.pdgCode_), propDir_(rep.propDir_), debugLvl_(rep.debugLvl_) -{ - ; -} - - -double AbsTrackRep::extrapolateToMeasurement(StateOnPlane& state, - const AbsMeasurement* measurement, - bool stopAtBoundary, - bool calcJacobianNoise) const { - - return this->extrapolateToPlane(state, measurement->constructPlane(state), stopAtBoundary, calcJacobianNoise); -} - - -TVectorD AbsTrackRep::get6DState(const StateOnPlane& state) const { - TVector3 pos, mom; - getPosMom(state, pos, mom); - - TVectorD stateVec(6); - - stateVec(0) = pos.X(); - stateVec(1) = pos.Y(); - stateVec(2) = pos.Z(); - - stateVec(3) = mom.X(); - stateVec(4) = mom.Y(); - stateVec(5) = mom.Z(); - - return stateVec; -} - - -void AbsTrackRep::get6DStateCov(const MeasuredStateOnPlane& state, TVectorD& stateVec, TMatrixDSym& cov) const { - TVector3 pos, mom; - getPosMomCov(state, pos, mom, cov); - - stateVec.ResizeTo(6); - - stateVec(0) = pos.X(); - stateVec(1) = pos.Y(); - stateVec(2) = pos.Z(); - - stateVec(3) = mom.X(); - stateVec(4) = mom.Y(); - stateVec(5) = mom.Z(); -} - - -double AbsTrackRep::getPDGCharge() const { - TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(pdgCode_); - assert(particle != NULL); - return particle->Charge()/(3.); -} - - -double AbsTrackRep::getMass(const StateOnPlane& /*state*/) const { - return TDatabasePDG::Instance()->GetParticle(pdgCode_)->Mass(); -} - - -void AbsTrackRep::calcJacobianNumerically(const genfit::StateOnPlane& origState, - const genfit::SharedPlanePtr destPlane, - TMatrixD& jacobian) const { - - // Find the transport matrix for track propagation from origState to destPlane - // I.e. this finds - // d stateDestPlane / d origState |_origState - - jacobian.ResizeTo(getDim(), getDim()); - - // no science behind these values, I verified that forward and - // backward propagation yield inverse matrices to good - // approximation. In order to avoid bad roundoff errors, the actual - // step taken is determined below, separately for each direction. - const double defaultStepX = 1.E-5; - double stepX; - - // Calculate derivative for all three dimensions successively. - // The algorithm follows the one in TF1::Derivative() : - // df(x) = (4 D(h/2) - D(h)) / 3 - // with D(h) = (f(x + h) - f(x - h)) / (2 h). - // - // Could perhaps do better by also using f(x) which would be stB. - TVectorD rightShort(getDim()), rightFull(getDim()); - TVectorD leftShort(getDim()), leftFull(getDim()); - for (size_t i = 0; i < getDim(); ++i) { - { - genfit::StateOnPlane stateCopy(origState); - double temp = stateCopy.getState()(i) + defaultStepX / 2; - // Find the actual size of the step, which will differ from - // defaultStepX due to roundoff. This is the step-size we will - // use for this direction. Idea taken from Numerical Recipes, - // 3rd ed., section 5.7. - // - // Note that if a number is exactly representable, it's double - // will also be exact. Outside denormals, this also holds for - // halving. Unless the exponent changes (which it only will in - // the vicinity of zero) adding or subtracing doesn't make a - // difference. - // - // We determine the roundoff error for the half-step. If this - // is exactly representable, the full step will also be. - stepX = 2 * (temp - stateCopy.getState()(i)); - (stateCopy.getState())(i) = temp; - extrapolateToPlane(stateCopy, destPlane); - rightShort = stateCopy.getState(); - } - { - genfit::StateOnPlane stateCopy(origState); - (stateCopy.getState())(i) -= stepX / 2; - extrapolateToPlane(stateCopy, destPlane); - leftShort = stateCopy.getState(); - } - { - genfit::StateOnPlane stateCopy(origState); - (stateCopy.getState())(i) += stepX; - extrapolateToPlane(stateCopy, destPlane); - rightFull = stateCopy.getState(); - } - { - genfit::StateOnPlane stateCopy(origState); - (stateCopy.getState())(i) -= stepX; - extrapolateToPlane(stateCopy, destPlane); - leftFull = stateCopy.getState(); - } - - // Calculate the derivatives for the individual components of - // the track parameters. - for (size_t j = 0; j < getDim(); ++j) { - double derivFull = (rightFull(j) - leftFull(j)) / 2 / stepX; - double derivShort = (rightShort(j) - leftShort(j)) / stepX; - - jacobian(j, i) = 1./3.*(4*derivShort - derivFull); - } - } -} - - -bool AbsTrackRep::switchPDGSign() { - TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(-pdgCode_); - if(particle != NULL) { - pdgCode_ *= -1; - return true; - } - return false; -} - - - -void AbsTrackRep::Print(const Option_t*) const { - std::cout << "genfit::AbsTrackRep, pdgCode = " << pdgCode_ << ". PropDir = " << (int)propDir_ << "\n"; -} - - -} /* End of namespace genfit */ diff --git a/genfit/core/src/DetPlane.cc b/genfit/core/src/DetPlane.cc deleted file mode 100644 index 1d86878309..0000000000 --- a/genfit/core/src/DetPlane.cc +++ /dev/null @@ -1,408 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "DetPlane.h" - -#include -#include -#include -#include -#include -#include - - -namespace genfit { - - -DetPlane::DetPlane(AbsFinitePlane* finite) - :finitePlane_(finite) -{ - // default constructor - o_.SetXYZ(0.,0.,0.); - u_.SetXYZ(1.,0.,0.); - v_.SetXYZ(0.,1.,0.); - // sane() not needed here -} - - -DetPlane::DetPlane(const TVector3& o, - const TVector3& u, - const TVector3& v, - AbsFinitePlane* finite) - :o_(o), u_(u), v_(v), finitePlane_(finite) -{ - sane(); -} - -DetPlane::DetPlane(const TVector3& o, - const TVector3& n, - AbsFinitePlane* finite) - :o_(o), finitePlane_(finite) -{ - setNormal(n); -} - - -DetPlane::~DetPlane(){ - ; -} - - -DetPlane::DetPlane(const DetPlane& rhs) : - TObject(rhs), - o_(rhs.o_), - u_(rhs.u_), - v_(rhs.v_) -{ - if(rhs.finitePlane_) - finitePlane_.reset(rhs.finitePlane_->clone()); - else finitePlane_.reset(); -} - - -DetPlane& DetPlane::operator=(DetPlane other) { - swap(other); - return *this; -} - - -void DetPlane::swap(DetPlane& other) { - // by swapping the members of two classes, - // the two classes are effectively swapped - std::swap(this->o_, other.o_); - std::swap(this->u_, other.u_); - std::swap(this->v_, other.v_); - this->finitePlane_.swap(other.finitePlane_); -} - - -void DetPlane::set(const TVector3& o, - const TVector3& u, - const TVector3& v) -{ - o_ = o; - u_ = u; - v_ = v; - sane(); -} - - -void DetPlane::setO(const TVector3& o) -{ - o_ = o; -} - -void DetPlane::setO(double X,double Y,double Z) -{ - o_.SetXYZ(X,Y,Z); -} - -void DetPlane::setU(const TVector3& u) -{ - u_ = u; - sane(); // sets v_ perpendicular to u_ -} - -void DetPlane::setU(double X,double Y,double Z) -{ - u_.SetXYZ(X,Y,Z); - sane(); // sets v_ perpendicular to u_ -} - -void DetPlane::setV(const TVector3& v) -{ - v_ = v; - u_ = getNormal().Cross(v_); - u_ *= -1.; - sane(); -} - -void DetPlane::setV(double X,double Y,double Z) -{ - v_.SetXYZ(X,Y,Z); - u_ = getNormal().Cross(v_); - u_ *= -1.; - sane(); -} - -void DetPlane::setUV(const TVector3& u,const TVector3& v) -{ - u_ = u; - v_ = v; - sane(); -} - -void DetPlane::setON(const TVector3& o,const TVector3& n){ - o_ = o; - setNormal(n); -} - - -TVector3 DetPlane::getNormal() const -{ - return u_.Cross(v_); -} - -void DetPlane::setNormal(double X,double Y,double Z){ - setNormal( TVector3(X,Y,Z) ); -} - -void DetPlane::setNormal(const TVector3& n){ - u_ = n.Orthogonal(); - v_ = n.Cross(u_); - u_.SetMag(1.); - v_.SetMag(1.); -} - -void DetPlane::setNormal(const double& theta, const double& phi){ - setNormal( TVector3(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ); -} - - -TVector2 DetPlane::project(const TVector3& x)const -{ - return TVector2(u_*x, v_*x); -} - - -TVector2 DetPlane::LabToPlane(const TVector3& x)const -{ - return project(x-o_); -} - - -TVector3 DetPlane::toLab(const TVector2& x)const -{ - TVector3 d(o_); - d += x.X()*u_; - d += x.Y()*v_; - return d; -} - - -TVector3 DetPlane::dist(const TVector3& x)const -{ - return toLab(LabToPlane(x)) - x; -} - - -void DetPlane::sane(){ - assert(u_!=v_); - - // ensure unit vectors - u_.SetMag(1.); - v_.SetMag(1.); - - // check if already orthogonal - if (u_.Dot(v_) < 1.E-5) return; - - // ensure orthogonal system - v_ = getNormal().Cross(u_); -} - - -void DetPlane::Print(const Option_t* option) const -{ - std::cout<<"DetPlane: " - <<"O("<Print(option); - } - -} - - -/* - I could write pages of comments about correct equality checking for - floating point numbers, but: When two planes are as close as 10E-5 cm - in all nine numbers that define the plane, this will be enough for all - practical purposes - */ -bool operator== (const DetPlane& lhs, const DetPlane& rhs){ - if (&lhs == &rhs) - return true; - static const double detplaneEpsilon = 1.E-5; - if( - fabs( (lhs.o_.X()-rhs.o_.X()) ) > detplaneEpsilon || - fabs( (lhs.o_.Y()-rhs.o_.Y()) ) > detplaneEpsilon || - fabs( (lhs.o_.Z()-rhs.o_.Z()) ) > detplaneEpsilon - ) return false; - else if( - fabs( (lhs.u_.X()-rhs.u_.X()) ) > detplaneEpsilon || - fabs( (lhs.u_.Y()-rhs.u_.Y()) ) > detplaneEpsilon || - fabs( (lhs.u_.Z()-rhs.u_.Z()) ) > detplaneEpsilon - ) return false; - else if( - fabs( (lhs.v_.X()-rhs.v_.X()) ) > detplaneEpsilon || - fabs( (lhs.v_.Y()-rhs.v_.Y()) ) > detplaneEpsilon || - fabs( (lhs.v_.Z()-rhs.v_.Z()) ) > detplaneEpsilon - ) return false; - return true; -} - -bool operator!= (const DetPlane& lhs, const DetPlane& rhs){ - return !(lhs==rhs); -} - - -double DetPlane::distance(const TVector3& point) const { - // |(point - o_)*(u_ x v_)| - return fabs( (point.X()-o_.X()) * (u_.Y()*v_.Z() - u_.Z()*v_.Y()) + - (point.Y()-o_.Y()) * (u_.Z()*v_.X() - u_.X()*v_.Z()) + - (point.Z()-o_.Z()) * (u_.X()*v_.Y() - u_.Y()*v_.X())); -} - -double DetPlane::distance(double x, double y, double z) const { - // |(point - o_)*(u_ x v_)| - return fabs( (x-o_.X()) * (u_.Y()*v_.Z() - u_.Z()*v_.Y()) + - (y-o_.Y()) * (u_.Z()*v_.X() - u_.X()*v_.Z()) + - (z-o_.Z()) * (u_.X()*v_.Y() - u_.Y()*v_.X())); -} - - -TVector2 DetPlane::straightLineToPlane (const TVector3& point, const TVector3& dir) const { - TVector3 dirNorm(dir.Unit()); - TVector3 normal = getNormal(); - double dirTimesN = dirNorm*normal; - if(fabs(dirTimesN)<1.E-6){//straight line is parallel to plane, so return infinity - return TVector2(1.E100,1.E100); - } - double t = 1./dirTimesN * ((o_-point)*normal); - return project(point - o_ + t * dirNorm); -} - - -//! gives u,v coordinates of the intersection point of a straight line with plane -void DetPlane::straightLineToPlane(const double& posX, const double& posY, const double& posZ, - const double& dirX, const double& dirY, const double& dirZ, - double& u, double& v) const { - - TVector3 W = getNormal(); - double dirTimesN = dirX*W.X() + dirY*W.Y() + dirZ*W.Z(); - if(fabs(dirTimesN)<1.E-6){//straight line is parallel to plane, so return infinity - u = 1.E100; - v = 1.E100; - return; - } - double t = 1./dirTimesN * ((o_.X()-posX)*W.X() + - (o_.Y()-posY)*W.Y() + - (o_.Z()-posZ)*W.Z()); - - double posOnPlaneX = posX-o_.X() + t*dirX; - double posOnPlaneY = posY-o_.Y() + t*dirY; - double posOnPlaneZ = posZ-o_.Z() + t*dirZ; - - u = u_.X()*posOnPlaneX + u_.Y()*posOnPlaneY + u_.Z()*posOnPlaneZ; - v = v_.X()*posOnPlaneX + v_.Y()*posOnPlaneY + v_.Z()*posOnPlaneZ; -} - - -void DetPlane::rotate(double angle) { - TVector3 normal = getNormal(); - u_.Rotate(angle, normal); - v_.Rotate(angle, normal); - - sane(); -} - - -void DetPlane::reset() { - o_.SetXYZ(0.,0.,0.); - u_.SetXYZ(1.,0.,0.); - v_.SetXYZ(0.,1.,0.); - finitePlane_.reset(); -} - - -void DetPlane::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::DetPlane. - // This is modified from the streamer generated by ROOT in order to - // account for the scoped_ptr. - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::DetPlane thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - //TObject::Streamer(R__b); - o_.Streamer(R__b); - u_.Streamer(R__b); - v_.Streamer(R__b); - finitePlane_.reset(); - char flag; - R__b >> flag; - if (flag) { - // Read AbsFinitePlane with correct overload ... see comment - // in writing code. - TClass* cl = TClass::Load(R__b); - AbsFinitePlane *p = (AbsFinitePlane*)(cl->New()); - cl->Streamer(p, R__b); - finitePlane_.reset(p); - } - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - //TObject::Streamer(R__b); - o_.Streamer(R__b); - u_.Streamer(R__b); - v_.Streamer(R__b); - if (finitePlane_) { - R__b << (char)1; - - // finitPlane_ is a scoped_ptr, but a shared plane may be - // written several times in different places (e.g. it may also - // be stored in the measurement class). Since we have no way - // of knowing in which other places the same plane is written - // (it may even be in another track!), we cannot synchronize - // these writes and have to duplicate the SharedPlanePtr's - // instead. ROOT caches which pointers were written and read - // if one uses 'R__b << p' or equivalent. This can lead to - // trouble have no way of synchronizing two reads to - // shared_ptr's pointing to the same memory location. But - // even if we break the link between the two shared_ptr's, - // ROOT will still try to outsmart us, and it will notice that - // the finitePlane_ was the same during writing. This will - // lead to the same address being attached to two different - // scoped_ptrs in reading. Highly undesirable. Since we - // cannot know whether other parts of code implicitly or - // explicitly rely on TBuffer's caching, we cannot just - // disable this caching via R__b.ResetMap() (it's not - // documented in any elucidating manner anyway). - // - // Therefore, we have to write and read the AbsFinitePlane* - // manually, bypassing ROOT's caching. In order to do this, - // we need the information on the actual type, because - // otherwise we couldn't read it back reliably. Finally, the - // _working_ means of reading and writing class information - // are TClass::Store and TClass::Load, again barely - // documented, but if one tries any of the other ways that - // suggest themselves, weird breakage will occur. - finitePlane_->IsA()->Store(R__b); - finitePlane_->Streamer(R__b); - } else { - R__b << (char)0; - } - R__b.SetByteCount(R__c, kTRUE); - } -} -} /* End of namespace genfit */ diff --git a/genfit/core/src/Exception.cc b/genfit/core/src/Exception.cc deleted file mode 100644 index 29e874c217..0000000000 --- a/genfit/core/src/Exception.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "Exception.h" - -namespace genfit { - -bool Exception::quiet_ = true; // TR, to stop this annoying messages, false; - -Exception::Exception(std::string excString, int line, std::string file) : - excString_(excString), line_(line), file_(file), fatal_(false) { - std::ostringstream ErrMsgStream; - ErrMsgStream << "genfit::Exception thrown with excString:" - << std::endl << excString_ << std::endl - << "in line: " << line_ << " in file: " << file_ << std::endl - << "with fatal flag " << fatal_ << std::endl; - errorMessage_ = ErrMsgStream.str(); -} - -Exception::~Exception() throw() { -} - -void Exception::setNumbers(std::string _numbersLabel, - const std::vector& _numbers) { - numbersLabel_ = _numbersLabel; - numbers_ = _numbers; -} - -void Exception::setMatrices(std::string _matricesLabel, - const std::vector& _matrices) { - matricesLabel_ = _matricesLabel; - matrices_ = _matrices; -} - -const char* Exception::what() const throw(){ - //std::cerr << errorMessage_.c_str() << std::endl; // FIXME just for debugging purposes - if(quiet_) { - return ""; - } - return errorMessage_.c_str(); -} - -void Exception::info() { - if(quiet_) return; - if(numbers_.empty() && matrices_.empty()) return; //do nothing - std::cout << "genfit::Exception Info Output" << std::endl; - std::cout << "===========================" << std::endl; - if(numbersLabel_ != "") { - std::cout << "Numbers Label String:" << std::endl; - std::cout << numbersLabel_ << std::endl; - } - if(!numbers_.empty()) { - std::cout << "---------------------------" << std::endl; - std::cout << "Numbers:" << std::endl; - for(unsigned int i=0;i. -*/ -#include "FieldManager.h" - -#include -#include - -namespace genfit { - -FieldManager* FieldManager::instance_ = NULL; -AbsBField* FieldManager::field_ = NULL; - -#ifdef CACHE -bool FieldManager::useCache_ = false; -unsigned int FieldManager::n_buckets_ = 8; -fieldCache* FieldManager::cache_ = NULL; -#endif - -//#define DEBUG - -#ifdef CACHE -void FieldManager::getFieldVal(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz){ - checkInitialized(); - - if (useCache_) { - - // cache code copied from http://en.wikibooks.org/wiki/Optimizing_C%2B%2B/General_optimization_techniques/Memoization - static int last_read_i = 0; - static int last_written_i = 0; - int i = last_read_i; - - static const double epsilon = 0.001; - - #ifdef DEBUG - static int used = 0; - static int notUsed = 0; - #endif - - do { - if (fabs(cache_[i].posX - posX) < epsilon && - fabs(cache_[i].posY - posY) < epsilon && - fabs(cache_[i].posZ - posZ) < epsilon) { - Bx = cache_[i].Bx; - By = cache_[i].By; - Bz = cache_[i].Bz; - #ifdef DEBUG - ++used; - std::cout<<"used the cache! " << double(used)/(used + notUsed) << "\n"; - #endif - return; - } - i = (i + 1) % n_buckets_; - } while (i != last_read_i); - - last_read_i = last_written_i = (last_written_i + 1) % n_buckets_; - - cache_[last_written_i].posX = posX; - cache_[last_written_i].posY = posY; - cache_[last_written_i].posZ = posZ; - - field_->get(posX, posY, posZ, cache_[last_written_i].Bx, cache_[last_written_i].By, cache_[last_written_i].Bz); - - Bx = cache_[last_written_i].Bx; - By = cache_[last_written_i].By; - Bz = cache_[last_written_i].Bz; - #ifdef DEBUG - ++notUsed; - std::cout<<"did NOT use the cache! \n"; - #endif - return; - - } - else - return field_->get(posX, posY, posZ, Bx, By, Bz); - -} - - -void FieldManager::useCache(bool opt, unsigned int nBuckets) { - useCache_ = opt; - n_buckets_ = nBuckets; - - if (useCache_) { - cache_ = new fieldCache[n_buckets_]; - for (size_t i = 0; i < n_buckets_; ++i) { - // Should be safe to initialize with values in Andromeda - cache_[i].posX = cache_[i].posY = cache_[i].posZ = 2.4e24 / sqrt(3); - cache_[i].Bx = cache_[i].By = cache_[i].Bz = 1e30; - } - } -} -#endif - -} /* End of namespace genfit */ diff --git a/genfit/core/src/FitStatus.cc b/genfit/core/src/FitStatus.cc deleted file mode 100644 index b46a2a793f..0000000000 --- a/genfit/core/src/FitStatus.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2013, Technische Universitaet Muenchen, Ludwig-Maximilians-Universität München - Authors: Johannes Rauch & Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - - -#include "FitStatus.h" - -#include - -namespace genfit { - -void FitStatus::Print(const Option_t*) const -{ - std::cout << "fitStatus \n"; - if (isFitted_) { - std::cout << " track has been fitted,"; - if (isFitConvergedFully_) - std::cout << " fit has converged fully,"; - else if (isFitConvergedPartially_) - std::cout << " fit has converged partially,"; - else - std::cout << " fit has NOT converged,"; - std::cout << " " << nFailedPoints_ << " TrackPoints could not be processed,"; - if (trackHasChanged_) std::cout << " track has changed since the fit,"; - if (trackIsPruned_) std::cout << " track is pruned,"; - std::cout << " fitted charge = " << charge_ << " \n"; - } - else - std::cout << " track has NOT been fitted,"; -} - -} /* End of namespace genfit */ diff --git a/genfit/core/src/MaterialProperties.cc b/genfit/core/src/MaterialProperties.cc deleted file mode 100644 index ce97a1d51f..0000000000 --- a/genfit/core/src/MaterialProperties.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2008-2009, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "MaterialProperties.h" - -#include - -namespace genfit { - -bool operator== (const MaterialProperties& lhs, const MaterialProperties& rhs){ - if (&lhs == &rhs) - return true; - if (lhs.density_ != rhs.density_ || - lhs.Z_ != rhs.Z_ || - lhs.A_ != rhs.A_ || - lhs.radiationLength_ != rhs.radiationLength_ || - lhs.mEE_ != rhs.mEE_) - return false; - - return true; -} - -bool operator!= (const MaterialProperties& lhs, const MaterialProperties& rhs) { - return !(lhs==rhs); -} - - -void MaterialProperties::getMaterialProperties(double& density, - double& Z, - double& A, - double& radiationLength, - double& mEE) const { - density = density_; - Z = Z_; - A = A_; - radiationLength = radiationLength_; - mEE = mEE_; -} - - -void MaterialProperties::setMaterialProperties(const double& density, - const double& Z, - const double& A, - const double& radiationLength, - const double& mEE) { - density_ = density; - Z_ = Z; - A_ = A; - radiationLength_ = radiationLength; - mEE_ = mEE; -} - - -void MaterialProperties::Print(const Option_t*) const { - std::cout << "Density = " << density_ << ", \t" << - "Z = " << Z_ << ", \t" << - "A = " << A_ << ", \t" << - "radiationLength = " << radiationLength_ << ", \t" << - "mEE = " << mEE_ << "\n"; -} - - -} /* End of namespace genfit */ diff --git a/genfit/core/src/MeasuredStateOnPlane.cc b/genfit/core/src/MeasuredStateOnPlane.cc deleted file mode 100644 index 59d9e8fcd3..0000000000 --- a/genfit/core/src/MeasuredStateOnPlane.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "MeasuredStateOnPlane.h" -#include "AbsTrackRep.h" -#include "Exception.h" -#include "Tools.h" - -#include -#include - -namespace genfit { - -void MeasuredStateOnPlane::Print(Option_t*) const { - std::cout << "genfit::MeasuredStateOnPlane "; - std::cout << "my address " << this << " my plane's address " << this->sharedPlane_.get() << "; use count: " << sharedPlane_.use_count() << std::endl; - std::cout << " state vector: "; state_.Print(); - std::cout << " covariance matrix: "; cov_.Print(); - if (sharedPlane_ != NULL) { - std::cout << " defined in plane "; sharedPlane_->Print(); - TVector3 pos, mom; - TMatrixDSym cov(6,6); - getRep()->getPosMomCov(*this, pos, mom, cov); - std::cout << " 3D position: "; pos.Print(); - std::cout << " 3D momentum: "; mom.Print(); - //std::cout << " 6D covariance: "; cov.Print(); - } -} - -void MeasuredStateOnPlane::blowUpCov(double blowUpFac, bool resetOffDiagonals) { - - if (resetOffDiagonals) { - unsigned int dim = cov_.GetNcols(); - for (unsigned int i=0; i. -*/ - -#include -#include -#include - -#include "MeasurementOnPlane.h" - -namespace genfit { - -MeasurementOnPlane::MeasurementOnPlane(const MeasurementOnPlane& other) : - MeasuredStateOnPlane(other), - weight_(other.weight_) -{ - hMatrix_.reset(other.hMatrix_->clone()); -} - - -MeasurementOnPlane& MeasurementOnPlane::operator=(MeasurementOnPlane other) { - swap(other); - return *this; -} - - -void MeasurementOnPlane::swap(MeasurementOnPlane& other) { - MeasuredStateOnPlane::swap(other); - this->hMatrix_.swap(other.hMatrix_); - std::swap(this->weight_, other.weight_); -} - - -void MeasurementOnPlane::Print(Option_t*) const -{ - std::cout << "genfit::MeasurementOnPlane, weight = " << weight_ << "\n"; - std::cout << " state vector: "; state_.Print(); - std::cout << " covariance matrix: "; cov_.Print(); - if (sharedPlane_ != NULL) - std::cout << " defined in plane "; sharedPlane_->Print(); - std::cout << " hMatrix: "; hMatrix_->Print(); - -} - - -void MeasurementOnPlane::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::MeasurementOnPlane. - - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::MeasurementOnPlane thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - MeasuredStateOnPlane::Streamer(R__b); - hMatrix_.reset(); - char flag; - R__b.ReadChar(flag); - if (flag) { - AbsHMatrix *h = 0; - R__b >> h; - hMatrix_.reset(h); - } - R__b >> weight_; - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - MeasuredStateOnPlane::Streamer(R__b); - if (hMatrix_) { - R__b.WriteChar(1); - R__b << hMatrix_.get(); - } else { - R__b.WriteChar(0); - } - R__b << weight_; - R__b.SetByteCount(R__c, kTRUE); - } -} - -} /* End of namespace genfit */ diff --git a/genfit/core/src/StateOnPlane.cc b/genfit/core/src/StateOnPlane.cc deleted file mode 100644 index 848b29c6ac..0000000000 --- a/genfit/core/src/StateOnPlane.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "StateOnPlane.h" -#include "AbsTrackRep.h" - -#include -#include -#include - -namespace genfit { - - -void StateOnPlane::Print(Option_t*) const { - std::cout << "genfit::StateOnPlane "; - std::cout << " state vector: "; state_.Print(); - if (sharedPlane_ != NULL) { - std::cout << " defined in plane "; sharedPlane_->Print(); - TVector3 pos, mom; - getRep()->getPosMom(*this, pos, mom); - std::cout << " 3D position: "; pos.Print(); - std::cout << " 3D momentum: "; mom.Print(); - } -} - - -// Modified from auto-generated Streamer to account for sharedPlane_ -// also ignore rep_, this has to be set when loading the object owning -// this state. -void StateOnPlane::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::StateOnPlane. - - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::StateOnPlane thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - //TObject::Streamer(R__b); - state_.Streamer(R__b); - auxInfo_.Streamer(R__b); - sharedPlane_.reset(); // needs to be set by owner; - rep_ = NULL; // needs to be set by owner - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - //TObject::Streamer(R__b); - state_.Streamer(R__b); - auxInfo_.Streamer(R__b); - R__b.SetByteCount(R__c, kTRUE); - } -} - - -} /* End of namespace genfit */ diff --git a/genfit/core/src/ThinScatterer.cc b/genfit/core/src/ThinScatterer.cc deleted file mode 100644 index 0102f2ebab..0000000000 --- a/genfit/core/src/ThinScatterer.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright 2008-2009, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "ThinScatterer.h" - -#include -#include - - -namespace genfit { - - -void ThinScatterer::Print(const Option_t*) const { - std::cout << "ThinScatterer, defined in plane: "; - sharedPlane_->Print(); - std::cout << "Material properties: "; - material_.Print(); -} - - -void ThinScatterer::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::ThinScatterer. - - // TODO: test - - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::ThinScatterer thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - //TObject::Streamer(R__b); - sharedPlane_.reset(new DetPlane()); - sharedPlane_->Streamer(R__b); - material_.Streamer(R__b); - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - //TObject::Streamer(R__b); - sharedPlane_->Streamer(R__b); - material_.Streamer(R__b); - R__b.SetByteCount(R__c, kTRUE); - } -} - - - -} /* End of namespace genfit */ diff --git a/genfit/core/src/Tools.cc b/genfit/core/src/Tools.cc deleted file mode 100644 index ee10147d3d..0000000000 --- a/genfit/core/src/Tools.cc +++ /dev/null @@ -1,353 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "Tools.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include "Exception.h" - -// Use Cramer inversion for small matrices? -static const bool useCramer = false; - -namespace genfit { - -void tools::invertMatrix(const TMatrixDSym& mat, TMatrixDSym& inv, double* determinant){ - inv.ResizeTo(mat); - - // check if numerical limits are reached (i.e at least one entry < 1E-100 and/or at least one entry > 1E100) - if (!(mat<1.E100) || !(mat>-1.E100)){ - Exception e("Tools::invertMatrix() - cannot invert matrix, entries too big (>1e100)", - __LINE__,__FILE__); - e.setFatal(); - throw e; - } - // do the trivial inversions for 1x1 and 2x2 matrices manually - if (mat.GetNrows() == 1){ - if (determinant != NULL) *determinant = mat(0,0); - inv(0,0) = 1./mat(0,0); - return; - } - - if (mat.GetNrows() == 2){ - double det = mat(0,0)*mat(1,1) - mat(1,0)*mat(1,0); - if (determinant != NULL) *determinant = det; - if(fabs(det) < 1E-50){ - Exception e("Tools::invertMatrix() - cannot invert matrix , determinant = 0", - __LINE__,__FILE__); - e.setFatal(); - throw e; - } - det = 1./det; - inv(0,0) = det * mat(1,1); - inv(0,1) = inv(1,0) = -det * mat(1,0); - inv(1,1) = det * mat(0,0); - return; - } - - - if (useCramer && mat.GetNrows() <= 6){ - Bool_t (*inversion)(TMatrixDSym&, Double_t*) = 0; - inv.ResizeTo(mat); - inv = mat; - switch (mat.GetNrows()) { - case 3: - inversion = TMatrixTSymCramerInv::Inv3x3; break; - case 4: - inversion = TMatrixTSymCramerInv::Inv4x4; break; - case 5: - inversion = TMatrixTSymCramerInv::Inv5x5; break; - case 6: - inversion = TMatrixTSymCramerInv::Inv6x6; break; - } - - Bool_t success = inversion(inv, determinant); - if (!success){ - Exception e("Tools::invertMatrix() - cannot invert matrix, determinant = 0", - __LINE__,__FILE__); - e.setFatal(); - throw e; - } - return; - } - - // else use TDecompChol - bool status = 0; - TDecompChol invertAlgo(mat, 1E-50); - - status = invertAlgo.Invert(inv); - if(status == 0){ - Exception e("Tools::invertMatrix() - cannot invert matrix, status = 0", - __LINE__,__FILE__); - e.setFatal(); - throw e; - } - - if (determinant != NULL) { - double d1, d2; - invertAlgo.Det(d1, d2); - *determinant = ldexp(d1, d2); - } -} - -void tools::invertMatrix(TMatrixDSym& mat, double* determinant){ - // check if numerical limits are reached (i.e at least one entry < 1E-100 and/or at least one entry > 1E100) - if (!(mat<1.E100) || !(mat>-1.E100)){ - Exception e("Tools::invertMatrix() - cannot invert matrix, entries too big (>1e100)", - __LINE__,__FILE__); - e.setFatal(); - throw e; - } - // do the trivial inversions for 1x1 and 2x2 matrices manually - if (mat.GetNrows() == 1){ - if (determinant != NULL) *determinant = mat(0,0); - mat(0,0) = 1./mat(0,0); - return; - } - - if (mat.GetNrows() == 2){ - double *arr = mat.GetMatrixArray(); - double det = arr[0]*arr[3] - arr[1]*arr[1]; - if (determinant != NULL) *determinant = det; - if(fabs(det) < 1E-50){ - Exception e("Tools::invertMatrix() - cannot invert matrix, determinant = 0", - __LINE__,__FILE__); - e.setFatal(); - throw e; - } - det = 1./det; - double temp[3]; - temp[0] = det * arr[3]; - temp[1] = -det * arr[1]; - temp[2] = det * arr[0]; - //double *arr = mat.GetMatrixArray(); - arr[0] = temp[0]; - arr[1] = arr[2] = temp[1]; - arr[3] = temp[2]; - return; - } - - if (useCramer && mat.GetNrows() <= 6){ - Bool_t (*inversion)(TMatrixDSym&, Double_t*) = 0; - switch (mat.GetNrows()) { - case 3: - inversion = TMatrixTSymCramerInv::Inv3x3; break; - case 4: - inversion = TMatrixTSymCramerInv::Inv4x4; break; - case 5: - inversion = TMatrixTSymCramerInv::Inv5x5; break; - case 6: - inversion = TMatrixTSymCramerInv::Inv6x6; break; - } - - Bool_t success = inversion(mat, determinant); - if (!success){ - Exception e("Tools::invertMatrix() - cannot invert matrix, determinant = 0", - __LINE__,__FILE__); - e.setFatal(); - throw e; - } - return; - } - - // else use TDecompChol - bool status = 0; - TDecompChol invertAlgo(mat, 1E-50); - - status = invertAlgo.Invert(mat); - if(status == 0){ - Exception e("Tools::invertMatrix() - cannot invert matrix, status = 0", - __LINE__,__FILE__); - e.setFatal(); - throw e; - } - - if (determinant != NULL) { - double d1, d2; - invertAlgo.Det(d1, d2); - *determinant = ldexp(d1, d2); - } -} - - -// Solves R^T x = b, replaces b with the result x. R is assumed -// to be upper-diagonal. This is forward substitution, but with -// indices flipped. -bool tools::transposedForwardSubstitution(const TMatrixD& R, TVectorD& b) -{ - size_t n = R.GetNrows(); - for (unsigned int i = 0; i < n; ++i) { - double sum = b(i); - for (unsigned int j = 0; j < i; ++j) { - sum -= b(j)*R(j,i); // already replaced previous elements in b. - } - if (R(i,i) == 0) - return false; - b(i) = sum / R(i,i); - } - return true; -} - -// Same, but for one column of the matrix b. Used by transposedInvert below -bool tools::transposedForwardSubstitution(const TMatrixD& R, TMatrixD& b, int nCol) -{ - size_t n = R.GetNrows(); - for (unsigned int i = 0; i < n; ++i) { - double sum = b(i, nCol); - for (unsigned int j = 0; j < i; ++j) { - sum -= b(j, nCol)*R(j,i); // already replaced previous elements in b. - } - if (R(i,i) == 0) - return false; - b(i, nCol) = sum / R(i,i); - } - return true; -} - -// inv will be the inverse of the transposed of the upper-right matrix R -bool tools::transposedInvert(const TMatrixD& R, TMatrixD& inv) -{ - bool result = true; - - inv.ResizeTo(R); - for (int i = 0; i < inv.GetNrows(); ++i) - for (int j = 0; j < inv.GetNcols(); ++j) - inv(i, j) = (i == j); - - for (int i = 0; i < inv.GetNcols(); ++i) - result = result && transposedForwardSubstitution(R, inv, i); - - return result; -} - -// This replaces A with an upper right matrix connected to A by a -// orthogonal transformation. I.e., it computes the R from a QR -// decomposition of A replacing A. -void tools::QR(TMatrixD& A) -{ - int nCols = A.GetNcols(); - int nRows = A.GetNrows(); - assert(nRows >= nCols); - // This uses Businger and Golub's algorithm from Handbook for - // Automatical Computation, Vol. 2, Chapter 8, but without - // pivoting. I.e., we stop at the middle of page 112. We don't - // explicitly calculate the orthogonal matrix. - - double *const ak = A.GetMatrixArray(); - // No variable-length arrays in C++, alloca does the exact same thing ... - double *const u = (double *)alloca(sizeof(double)*nRows); - - // Main loop over matrix columns. - for (int k = 0; k < nCols; ++k) { - double akk = ak[k*nCols + k]; - - double sum = akk*akk; - // Put together a housholder transformation. - for (int i = k + 1; i < nRows; ++i) { - sum += ak[i*nCols + k]*ak[i*nCols + k]; - u[i] = ak[i*nCols + k]; - } - double sigma = sqrt(sum); - double beta = 1/(sum + sigma*fabs(akk)); - // The algorithm uses only the uk[i] for i >= k. - u[k] = copysign(sigma + fabs(akk), akk); - - // Calculate y (again taking into account zero entries). This - // encodes how the (sub)matrix changes by the householder transformation. - for (int i = k; i < nCols; ++i) { - double y = 0; - for (int j = k; j < nRows; ++j) - y += u[j]*ak[j*nCols + i]; - y *= beta; - // ... and apply the changes. - for (int j = k; j < nRows; ++j) - ak[j*nCols + i] -= u[j]*y; //y[j]; - } - } - - // Zero below diagonal - for (int i = 1; i < nCols; ++i) - for (int j = 0; j < i; ++j) - ak[i*nCols + j] = 0.; - for (int i = nCols; i < nRows; ++i) - for (int j = 0; j < nCols; ++j) - ak[i*nCols + j] = 0.; -} - -// This averages the covariance matrices C1, C2 in a numerically -// stable way by using matrix square roots. No optimizations -// performed, so use with care. -void tools::safeAverage(const TMatrixDSym& C1, const TMatrixDSym& C2, - TMatrixDSym& result) -{ - /* - The algorithm proceeds as follows: - write C1 = S1 S1' (prime for transpose), - C2 = S2 S2' - Then the inverse of the average can be written as ("." for matrix - multiplication) - C^-1 = ((S1'^-1, S2'^-1) . (S1'^-1) ) - ( (S2'^-1) ) - Inserting an orthogonal matrix T in the middle: - C^-1 = ((S1'^-1, S2'^-1) . T . T' . (S1'^-1) ) - ( (S2'^-1) ) - doesn't change this because T.T' = 1. - Now choose T s.t. T'.(S1'^-1, S2'^-1)' is an upper right matrix. We - use Tools::QR for the purpose, as we don't actually need T. - - Then the inverse needed to obtain the covariance matrix can be - obtained by inverting the upper right matrix, which is squared to - obtained the new covariance matrix. */ - TDecompChol dec1(C1); - dec1.Decompose(); - TDecompChol dec2(C2); - dec2.Decompose(); - - const TMatrixD& S1 = dec1.GetU(); - const TMatrixD& S2 = dec2.GetU(); - - TMatrixD S1inv, S2inv; - transposedInvert(S1, S1inv); - transposedInvert(S2, S2inv); - - TMatrixD A(2 * S1.GetNrows(), S1.GetNcols()); - for (int i = 0; i < S1.GetNrows(); ++i) { - for (int j = 0; j < S2.GetNcols(); ++j) { - A(i, j) = S1inv(i, j); - A(i + S1.GetNrows(), j) = S2inv(i, j); - } - } - - QR(A); - A.ResizeTo(S1.GetNrows(), S1.GetNrows()); - - TMatrixD inv; - transposedInvert(A, inv); - - result.ResizeTo(inv.GetNcols(), inv.GetNcols()); - result = TMatrixDSym(TMatrixDSym::kAtA, inv); -} -} /* End of namespace genfit */ diff --git a/genfit/core/src/Track.cc b/genfit/core/src/Track.cc deleted file mode 100644 index b9ff2baa65..0000000000 --- a/genfit/core/src/Track.cc +++ /dev/null @@ -1,1513 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "Track.h" - -#include "Exception.h" -#include "KalmanFitterInfo.h" -#include "KalmanFitStatus.h" -#include "PlanarMeasurement.h" - -#include -#include -#include - -#include -#include -#include - -//#include - -//#define DEBUG - - -namespace genfit { - -Track::Track() : - cardinalRep_(0), fitStatuses_(), stateSeed_(6), covSeed_(6) -{ - ; -} - - -Track::Track(const TrackCand& trackCand, const MeasurementFactory& factory, AbsTrackRep* rep) : - cardinalRep_(0), fitStatuses_(), stateSeed_(6), covSeed_(6) -{ - - if (rep != NULL) - addTrackRep(rep); - - // create the measurements using the factory. - std::vector factoryHits = factory.createMany(trackCand); - - // create TrackPoints - PlanarMeasurement* lastPlanarMeas(NULL); - PlanarMeasurement* planarMeas(NULL); - for (unsigned int i=0; i(factoryHits[i]); - - if (lastPlanarMeas != NULL && planarMeas != NULL && - lastPlanarMeas->getDetId() == planarMeas->getDetId() && - planarMeas->getPlaneId() != -1 && // -1 is default plane id - lastPlanarMeas->getPlaneId() == planarMeas->getPlaneId() ) { - trackPoints_.back()->addRawMeasurement(factoryHits[i]); - } - else - insertPoint(new genfit::TrackPoint(factoryHits[i], this)); - - lastPlanarMeas = dynamic_cast(factoryHits[i]); - } - - // fill seed state - stateSeed_ = trackCand.getStateSeed(); - - // initial guess for cov - covSeed_ = trackCand.getCovSeed(); - - // fill cache - fillPointsWithMeasurement(); - - // self test - assert(checkConsistency()); -} - - -Track::Track(AbsTrackRep* trackRep, const TVectorD& stateSeed) : - cardinalRep_(0), fitStatuses_(), stateSeed_(stateSeed), - covSeed_(TMatrixDSym::kUnit, TMatrixDSym(6)) -{ - addTrackRep(trackRep); -} - - -Track::Track(AbsTrackRep* trackRep, const TVector3& posSeed, const TVector3& momSeed) : - cardinalRep_(0), fitStatuses_(), stateSeed_(6), - covSeed_(TMatrixDSym::kUnit, TMatrixDSym(6)) -{ - addTrackRep(trackRep); - setStateSeed(posSeed, momSeed); -} - - -Track::Track(AbsTrackRep* trackRep, const TVectorD& stateSeed, const TMatrixDSym& covSeed) : - cardinalRep_(0), fitStatuses_(), stateSeed_(stateSeed), covSeed_(covSeed) -{ - addTrackRep(trackRep); -} - - -Track::Track(const Track& rhs) : - TObject(rhs), - cardinalRep_(rhs.cardinalRep_), stateSeed_(rhs.stateSeed_), covSeed_(rhs.covSeed_) -{ - assert(rhs.checkConsistency()); - - std::map oldRepNewRep; - - for (std::vector::const_iterator it=rhs.trackReps_.begin(); it!=rhs.trackReps_.end(); ++it) { - AbsTrackRep* newRep = (*it)->clone(); - addTrackRep(newRep); - oldRepNewRep[(*it)] = newRep; - } - - trackPoints_.reserve(rhs.trackPoints_.size()); - for (std::vector::const_iterator it=rhs.trackPoints_.begin(); it!=rhs.trackPoints_.end(); ++it) { - trackPoints_.push_back(new TrackPoint(**it, oldRepNewRep)); - trackPoints_.back()->setTrack(this); - } - - for (std::map< const AbsTrackRep*, FitStatus* >::const_iterator it=rhs.fitStatuses_.begin(); it!=rhs.fitStatuses_.end(); ++it) { - setFitStatus(it->second->clone(), oldRepNewRep[it->first]); - } - - fillPointsWithMeasurement(); - - // self test - assert(checkConsistency()); -} - -Track& Track::operator=(Track other) { - swap(other); - - for (std::vector::const_iterator it=trackPoints_.begin(); it!=trackPoints_.end(); ++it) { - trackPoints_.back()->setTrack(this); - } - - fillPointsWithMeasurement(); - - // self test - assert(checkConsistency()); - - return *this; -} - -void Track::swap(Track& other) { - std::swap(this->trackReps_, other.trackReps_); - std::swap(this->cardinalRep_, other.cardinalRep_); - std::swap(this->trackPoints_, other.trackPoints_); - std::swap(this->trackPointsWithMeasurement_, other.trackPointsWithMeasurement_); - std::swap(this->fitStatuses_, other.fitStatuses_); - std::swap(this->stateSeed_, other.stateSeed_); - std::swap(this->covSeed_, other.covSeed_); - -} - -Track::~Track() { - // causes problem for python, is it needed ? TR 2014 this->Clear(); - this->Clear(); -} - -void Track::Clear(Option_t*) -{ - // This function is needed for TClonesArray embedding. - // FIXME: smarter containers or pointers needed ... - for (size_t i = 0; i < trackPoints_.size(); ++i) - delete trackPoints_[i]; - - trackPoints_.clear(); - trackPointsWithMeasurement_.clear(); - - for (std::map< const AbsTrackRep*, FitStatus* >::iterator it = fitStatuses_.begin(); it!= fitStatuses_.end(); ++it) - delete it->second; - fitStatuses_.clear(); - - for (size_t i = 0; i < trackReps_.size(); ++i) - delete trackReps_[i]; - trackReps_.clear(); - - cardinalRep_ = 0; - - stateSeed_ *= 0; - covSeed_ *= 0; -} - - -TrackPoint* Track::getPoint(int id) const { - if (id < 0) - id += trackPoints_.size(); - - return trackPoints_.at(id); -} - - -TrackPoint* Track::getPointWithMeasurement(int id) const { - if (id < 0) - id += trackPointsWithMeasurement_.size(); - - return trackPointsWithMeasurement_.at(id); -} - - -TrackPoint* Track::getPointWithMeasurementAndFitterInfo(int id, const AbsTrackRep* rep) const { - int i(0); - for (std::vector::const_iterator it = trackPointsWithMeasurement_.begin(); it != trackPointsWithMeasurement_.end(); ++it) { - if ((*it)->hasFitterInfo(rep)) { - if (id == i) - return (*it); - ++i; - } - } - - return NULL; -} - - -const MeasuredStateOnPlane& Track::getFittedState(int id, const AbsTrackRep* rep, bool biased) const { - if (rep == NULL) - rep = getCardinalRep(); - - TrackPoint* point = getPointWithMeasurementAndFitterInfo(id, rep); - if (point == NULL) { - Exception exc("Track::getFittedState ==> no trackPoint with fitterInfo for rep",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - return point->getFitterInfo(rep)->getFittedState(biased); -} - - -int Track::getIdForRep(const AbsTrackRep* rep) const -{ - for (size_t i = 0; i < trackReps_.size(); ++i) - if (trackReps_[i] == rep) - return i; - - // std::cout << "track debug " << trackReps_.size() <<" "<< trackReps_[0] << " " << rep <<"\n"; - - //assert(0 == 1); // Cannot happen. - return 0; //RDM -} - - -bool Track::hasFitStatus(const AbsTrackRep* rep) const { - if (rep == NULL) - rep = getCardinalRep(); - - if (fitStatuses_.find(rep) == fitStatuses_.end()) - return false; - - return (fitStatuses_.at(rep) != NULL); -} - - -bool Track::hasKalmanFitStatus(const AbsTrackRep* rep) const { - if (rep == NULL) - rep = getCardinalRep(); - - if (fitStatuses_.find(rep) == fitStatuses_.end()) - return false; - - return (dynamic_cast(fitStatuses_.at(rep)) != NULL); -} - - -KalmanFitStatus* Track::getKalmanFitStatus(const AbsTrackRep* rep) const { - return dynamic_cast(getFitStatus(rep)); -} - - -void Track::setFitStatus(FitStatus* fitStatus, const AbsTrackRep* rep) { - if (fitStatuses_.find(rep) != fitStatuses_.end()) - delete fitStatuses_.at(rep); - - fitStatuses_[rep] = fitStatus; -} - - -void Track::setStateSeed(const TVector3& pos, const TVector3& mom) { - stateSeed_.ResizeTo(6); - - stateSeed_(0) = pos.X(); - stateSeed_(1) = pos.Y(); - stateSeed_(2) = pos.Z(); - - stateSeed_(3) = mom.X(); - stateSeed_(4) = mom.Y(); - stateSeed_(5) = mom.Z(); -} - - - -void Track::insertPoint(TrackPoint* point, int id) { - - point->setTrack(this); - - #ifdef DEBUG - std::cout << "Track::insertPoint at position " << id << "\n"; - #endif - assert(point!=NULL); - trackHasChanged(); - - point->setTrack(this); - - if (trackPoints_.size() == 0) { - trackPoints_.push_back(point); - - if (point->hasRawMeasurements()) - trackPointsWithMeasurement_.push_back(point); - - return; - } - - if (id == -1 || id == (int)trackPoints_.size()) { - trackPoints_.push_back(point); - - if (point->hasRawMeasurements()) - trackPointsWithMeasurement_.push_back(point); - - deleteReferenceInfo(std::max(0, (int)trackPoints_.size()-2), (int)trackPoints_.size()-1); - - // delete fitter infos if inserted point has a measurement - if (point->hasRawMeasurements()) { - deleteForwardInfo(-1, -1); - deleteBackwardInfo(0, -2); - } - - return; - } - - // [-size, size-1] is the allowed range - assert(id < (ssize_t)trackPoints_.size() || -id-1 <= (ssize_t)trackPoints_.size()); - - if (id < 0) - id += trackPoints_.size() + 1; - - // insert - trackPoints_.insert(trackPoints_.begin() + id, point); // insert inserts BEFORE - - // delete fitter infos if inserted point has a measurement - if (point->hasRawMeasurements()) { - deleteForwardInfo(id, -1); - deleteBackwardInfo(0, id); - } - - // delete reference info of neighbouring points - deleteReferenceInfo(std::max(0, id-1), std::min((int)trackPoints_.size()-1, id+1)); - - fillPointsWithMeasurement(); -} - - -void Track::insertPoints(std::vector points, int id) { - - int nBefore = getNumPoints(); - int n = points.size(); - - if (n == 0) - return; - if (n == 1) { - insertPoint(points[0], id); - return; - } - - for (std::vector::iterator p = points.begin(); p != points.end(); ++p) - (*p)->setTrack(this); - - if (id == -1 || id == (int)trackPoints_.size()) { - trackPoints_.insert(trackPoints_.end(), points.begin(), points.end()); - - deleteReferenceInfo(std::max(0, nBefore-1), nBefore); - - deleteForwardInfo(nBefore, -1); - deleteBackwardInfo(0, std::max(0, nBefore-1)); - - fillPointsWithMeasurement(); - - return; - } - - - assert(id < (ssize_t)trackPoints_.size() || -id-1 <= (ssize_t)trackPoints_.size()); - - if (id < 0) - id += trackPoints_.size() + 1; - - - // insert - trackPoints_.insert(trackPoints_.begin() + id, points.begin(), points.end()); // insert inserts BEFORE - - // delete fitter infos if inserted point has a measurement - deleteForwardInfo(id, -1); - deleteBackwardInfo(0, id+n); - - // delete reference info of neighbouring points - deleteReferenceInfo(std::max(0, id-1), std::min((int)trackPoints_.size()-1, id)); - deleteReferenceInfo(std::max(0, id+n-1), std::min((int)trackPoints_.size()-1, id+n)); - - fillPointsWithMeasurement(); -} - - -void Track::deletePoint(int id) { - - #ifdef DEBUG - std::cout << "Track::deletePoint at position " << id << "\n"; - #endif - - trackHasChanged(); - - if (id < 0) - id += trackPoints_.size(); - assert(id>0); - - - // delete forwardInfo after point (backwardInfo before point) if deleted point has a measurement - if (trackPoints_[id]->hasRawMeasurements()) { - deleteForwardInfo(id, -1); - deleteBackwardInfo(0, id-1); - } - - // delete reference info of neighbouring points - deleteReferenceInfo(std::max(0, id-1), std::min((int)trackPoints_.size()-1, id+1)); - - // delete point - std::vector::iterator it = std::find(trackPointsWithMeasurement_.begin(), trackPointsWithMeasurement_.end(), trackPoints_[id]); - if (it != trackPointsWithMeasurement_.end()) - trackPointsWithMeasurement_.erase(it); - - delete trackPoints_[id]; - trackPoints_.erase(trackPoints_.begin()+id); - - fillPointsWithMeasurement(); - -} - - -void Track::insertMeasurement(AbsMeasurement* measurement, int id) { - insertPoint(new TrackPoint(measurement, this), id); -} - - -void Track::mergeTrack(const Track* other, int id) { - - #ifdef DEBUG - std::cout << "Track::mergeTrack\n"; - #endif - - if (other->getNumPoints() == 0) - return; - - std::map otherRepThisRep; - std::vector otherRepsToRemove; - - for (std::vector::const_iterator otherRep=other->trackReps_.begin(); otherRep!=other->trackReps_.end(); ++otherRep) { - bool found(false); - for (std::vector::const_iterator thisRep=trackReps_.begin(); thisRep!=trackReps_.end(); ++thisRep) { - if ((*thisRep)->isSame(*otherRep)) { - otherRepThisRep[*otherRep] = *thisRep; - #ifdef DEBUG - std::cout << " map other rep " << *otherRep << " to " << (*thisRep) << "\n"; - #endif - if (found) { - Exception exc("Track::mergeTrack ==> more than one matching rep.",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - found = true; - break; - } - } - if (!found) { - otherRepsToRemove.push_back(*otherRep); - #ifdef DEBUG - std::cout << " remove other rep " << *otherRep << "\n"; - #endif - } - } - - - std::vector points; - points.reserve(other->getNumPoints()); - - for (std::vector::const_iterator otherTp=other->trackPoints_.begin(); otherTp!=other->trackPoints_.end(); ++otherTp) { - points.push_back(new TrackPoint(**otherTp, otherRepThisRep, &otherRepsToRemove)); - } - - insertPoints(points, id); -} - - -void Track::addTrackRep(AbsTrackRep* trackRep) { - trackReps_.push_back(trackRep); - fitStatuses_[trackRep] = new FitStatus(); -} - - -void Track::deleteTrackRep(int id) { - if (id < 0) - id += trackReps_.size(); - - AbsTrackRep* rep = trackReps_.at(id); - - // update cardinalRep_ - if (int(cardinalRep_) == id) - cardinalRep_ = 0; // reset - else if (int(cardinalRep_) > id) - --cardinalRep_; // make cardinalRep_ point to the same TrackRep before and after deletion - - // delete FitterInfos related to the deleted TrackRep - for (std::vector::const_iterator pointIt = trackPoints_.begin(); pointIt != trackPoints_.end(); ++pointIt) { - (*pointIt)->deleteFitterInfo(rep); - } - - // delete fitStatus - delete fitStatuses_.at(rep); - fitStatuses_.erase(rep); - - // delete rep - delete rep; - trackReps_.erase(trackReps_.begin()+id); -} - - -void Track::setCardinalRep(int id) { - - if (id < 0) - id += trackReps_.size(); - - if (id >= 0 && (unsigned int)id < trackReps_.size()) - cardinalRep_ = id; - else { - cardinalRep_ = 0; - std::cerr << "Track::setCardinalRep: Attempted to set cardinalRep_ to a value out of bounds. Resetting cardinalRep_ to 0." << std::endl; - } -} - - -void Track::determineCardinalRep() { - - // Todo: test - - if (trackReps_.size() <= 1) - return; - - double minChi2(9.E99); - const AbsTrackRep* bestRep(NULL); - - for (std::map< const AbsTrackRep*, FitStatus* >::const_iterator it = fitStatuses_.begin(); it != fitStatuses_.end(); ++it) { - if (it->second->isFitConverged()) { - if (it->second->getChi2() < minChi2) { - minChi2 = it->second->getChi2(); - bestRep = it->first; - } - } - } - - if (bestRep != NULL) { - setCardinalRep(getIdForRep(bestRep)); - } -} - - -bool Track::sort() { - #ifdef DEBUG - std::cout << "Track::sort \n"; - #endif - - int nPoints(trackPoints_.size()); - // original order - std::vector pointsBefore(trackPoints_); - - // sort - std::stable_sort(trackPoints_.begin(), trackPoints_.end(), TrackPointComparator()); - - // see where order changed - int equalUntil(-1), equalFrom(nPoints); - for (int i = 0; iequalUntil; --i) { - if (pointsBefore[i] == trackPoints_[i]) - equalFrom = i; - else - break; - } - - #ifdef DEBUG - std::cout << "Track::sort. Equal up to (including) hit " << equalUntil << " and from (including) hit " << equalFrom << " \n"; - #endif - - deleteForwardInfo(equalUntil+1, -1); - deleteBackwardInfo(0, equalFrom-1); - - deleteReferenceInfo(std::max(0, equalUntil+1), std::min((int)trackPoints_.size()-1, equalFrom-1)); - - fillPointsWithMeasurement(); - - return true; -} - - -bool Track::udpateSeed(int id, AbsTrackRep* rep, bool biased) { - try { - const MeasuredStateOnPlane& fittedState = getFittedState(id, rep, biased); - setStateSeed(fittedState.get6DState()); - setCovSeed(fittedState.get6DCov()); - - double fittedCharge = fittedState.getCharge(); - - for (unsigned int i = 0; igetPDGCharge() * fittedCharge < 0) { - trackReps_[i]->switchPDGSign(); - } - } - } - catch (Exception& e) { - // in this case the original track seed will be used - return false; - } - return true; -} - - -void Track::reverseTrackPoints() { - - std::reverse(trackPoints_.begin(),trackPoints_.end()); - - deleteForwardInfo(0, -1); - deleteBackwardInfo(0, -1); - deleteReferenceInfo(0, -1); - - fillPointsWithMeasurement(); -} - - -void Track::switchPDGSigns(AbsTrackRep* rep) { - if (rep != NULL) { - rep->switchPDGSign(); - return; - } - - for (unsigned int i = 0; iswitchPDGSign(); - } -} - - -void Track::reverseTrack() { - udpateSeed(-1); // set fitted state of last hit as new seed - reverseMomSeed(); // flip momentum direction - switchPDGSigns(); - reverseTrackPoints(); // also deletes all fitterInfos -} - - -void Track::deleteForwardInfo(int startId, int endId, const AbsTrackRep* rep) { - #ifdef DEBUG - std::cout << "Track::deleteForwardInfo from position " << startId << " to " << endId << "\n"; - #endif - - trackHasChanged(); - - if (startId < 0) - startId += trackPoints_.size(); - if (endId < 0) - endId += trackPoints_.size(); - endId += 1; - - assert (endId >= startId); - - for (std::vector::const_iterator pointIt = trackPoints_.begin() + startId; pointIt != trackPoints_.begin() + endId; ++pointIt) { - if (rep != NULL) { - if ((*pointIt)->hasFitterInfo(rep)) - (*pointIt)->getFitterInfo(rep)->deleteForwardInfo(); - } - else { - const std::vector fitterInfos = (*pointIt)->getFitterInfos(); - for (std::vector::const_iterator fitterInfoIt = fitterInfos.begin(); fitterInfoIt != fitterInfos.end(); ++fitterInfoIt) { - (*fitterInfoIt)->deleteForwardInfo(); - } - } - } -} - -void Track::deleteBackwardInfo(int startId, int endId, const AbsTrackRep* rep) { - - #ifdef DEBUG - std::cout << "Track::deleteBackwardInfo from position " << startId << " to " << endId << "\n"; - #endif - - trackHasChanged(); - - if (startId < 0) - startId += trackPoints_.size(); - if (endId < 0) - endId += trackPoints_.size(); - endId += 1; - - assert (endId >= startId); - - - for (std::vector::const_iterator pointIt = trackPoints_.begin() + startId; pointIt != trackPoints_.begin() + endId; ++pointIt) { - if (rep != NULL) { - if ((*pointIt)->hasFitterInfo(rep)) - (*pointIt)->getFitterInfo(rep)->deleteBackwardInfo(); - } - else { - const std::vector fitterInfos = (*pointIt)->getFitterInfos(); - for (std::vector::const_iterator fitterInfoIt = fitterInfos.begin(); fitterInfoIt != fitterInfos.end(); ++fitterInfoIt) { - (*fitterInfoIt)->deleteBackwardInfo(); - } - } - } -} - -void Track::deleteReferenceInfo(int startId, int endId, const AbsTrackRep* rep) { - - #ifdef DEBUG - std::cout << "Track::deleteReferenceInfo from position " << startId << " to " << endId << "\n"; - #endif - - trackHasChanged(); - - if (startId < 0) - startId += trackPoints_.size(); - if (endId < 0) - endId += trackPoints_.size(); - endId += 1; - - assert (endId >= startId); - - for (std::vector::const_iterator pointIt = trackPoints_.begin() + startId; pointIt != trackPoints_.begin() + endId; ++pointIt) { - if (rep != NULL) { - if ((*pointIt)->hasFitterInfo(rep)) - (*pointIt)->getFitterInfo(rep)->deleteReferenceInfo(); - } - else { - std::vector fitterInfos = (*pointIt)->getFitterInfos(); - for (std::vector::const_iterator fitterInfoIt = fitterInfos.begin(); fitterInfoIt != fitterInfos.end(); ++fitterInfoIt) { - (*fitterInfoIt)->deleteReferenceInfo(); - } - } - } -} - -void Track::deleteMeasurementInfo(int startId, int endId, const AbsTrackRep* rep) { - - #ifdef DEBUG - std::cout << "Track::deleteMeasurementInfo from position " << startId << " to " << endId << "\n"; - #endif - - trackHasChanged(); - - if (startId < 0) - startId += trackPoints_.size(); - if (endId < 0) - endId += trackPoints_.size(); - endId += 1; - - assert (endId >= startId); - - for (std::vector::const_iterator pointIt = trackPoints_.begin() + startId; pointIt != trackPoints_.begin() + endId; ++pointIt) { - if (rep != NULL) { - if ((*pointIt)->hasFitterInfo(rep)) - (*pointIt)->getFitterInfo(rep)->deleteMeasurementInfo(); - } - else { - std::vector fitterInfos = (*pointIt)->getFitterInfos(); - for (std::vector::const_iterator fitterInfoIt = fitterInfos.begin(); fitterInfoIt != fitterInfos.end(); ++fitterInfoIt) { - (*fitterInfoIt)->deleteMeasurementInfo(); - } - } - } -} - -void Track::deleteFitterInfo(int startId, int endId, const AbsTrackRep* rep) { - - #ifdef DEBUG - std::cout << "Track::deleteFitterInfo from position " << startId << " to " << endId << "\n"; - #endif - - trackHasChanged(); - - if (startId < 0) - startId += trackPoints_.size(); - if (endId < 0) - endId += trackPoints_.size(); - endId += 1; - - assert (endId >= startId); - - for (std::vector::const_iterator pointIt = trackPoints_.begin() + startId; pointIt != trackPoints_.begin() + endId; ++pointIt) { - if (rep != NULL) { - if ((*pointIt)->hasFitterInfo(rep)) - (*pointIt)->deleteFitterInfo(rep); - } - else { - for (std::vector::const_iterator repIt = trackReps_.begin(); repIt != trackReps_.end(); ++repIt) { - if ((*pointIt)->hasFitterInfo(*repIt)) - (*pointIt)->deleteFitterInfo(*repIt); - } - } - } -} - - -double Track::getTrackLen(AbsTrackRep* rep, int startId, int endId) const { - - if (startId < 0) - startId += trackPoints_.size(); - if (endId < 0) - endId += trackPoints_.size(); - - bool backwards(false); - if (startId > endId) { - double temp = startId; - startId = endId; - endId = temp; - backwards = true; - } - - endId += 1; - - if (rep == NULL) - rep = getCardinalRep(); - - double trackLen(0); - StateOnPlane state; - - for (std::vector::const_iterator pointIt = trackPoints_.begin() + startId; pointIt != trackPoints_.begin() + endId; ++pointIt) { - if (! (*pointIt)->hasFitterInfo(rep)) { - Exception e("Track::getTracklength: trackPoint has no fitterInfo", __LINE__,__FILE__); - throw e; - } - - if (pointIt != trackPoints_.begin() + startId) { - trackLen += rep->extrapolateToPlane(state, (*pointIt)->getFitterInfo(rep)->getPlane()); - } - - state = (*pointIt)->getFitterInfo(rep)->getFittedState(); - } - - if (backwards) - trackLen *= -1.; - - return trackLen; -} - - -double Track::getTOF(AbsTrackRep* rep, int startId, int endId) const { - - if (startId < 0) - startId += trackPoints_.size(); - if (endId < 0) - endId += trackPoints_.size(); - - bool backwards(false); - if (startId > endId) { - double temp = startId; - startId = endId; - endId = temp; - backwards = true; - } - - endId += 1; - - if (rep == NULL) - rep = getCardinalRep(); - - double tof(0); - StateOnPlane state; - - for (std::vector::const_iterator pointIt = trackPoints_.begin() + startId; pointIt != trackPoints_.begin() + endId; ++pointIt) { - if (! (*pointIt)->hasFitterInfo(rep)) { - Exception e("Track::getTOF: trackPoint has no fitterInfo", __LINE__,__FILE__); - throw e; - } - - if (pointIt != trackPoints_.begin() + startId) { - rep->extrapolateToPlane(state, (*pointIt)->getFitterInfo(rep)->getPlane()); - tof += rep->getTOF(); - } - - state = (*pointIt)->getFitterInfo(rep)->getFittedState(); - } - - if (backwards) - tof *= -1.; - - return tof; -} - - -void Track::fixWeights(AbsTrackRep* rep, int startId, int endId) { - - if (startId < 0) - startId += trackPoints_.size(); - if (endId < 0) - endId += trackPoints_.size(); - - assert(startId >= 0); - assert(startId <= endId); - assert(endId <= (int)trackPoints_.size()); - - std::vector< genfit::AbsFitterInfo* > fis; - - for (std::vector::iterator tp = trackPoints_.begin() + startId; tp != trackPoints_.begin() + endId; ++tp) { - fis.clear(); - if (rep == NULL) { - fis = (*tp)->getFitterInfos(); - } - else if ((*tp)->hasFitterInfo(rep)) { - fis.push_back((*tp)->getFitterInfo(rep)); - } - - for (std::vector< genfit::AbsFitterInfo* >::iterator fi = fis.begin(); fi != fis.end(); ++fi) { - KalmanFitterInfo* kfi = dynamic_cast(*fi); - if (kfi == NULL) - continue; - - kfi->fixWeights(); - } - } -} - - -void Track::prune(const Option_t* option) { - - TString opt = option; - opt.ToUpper(); - - for (std::map< const AbsTrackRep*, FitStatus* >::const_iterator it=fitStatuses_.begin(); it!=fitStatuses_.end(); ++it) { - it->second->setIsTrackPruned(); - } - - // prune trackPoints - if (opt.Contains("F") || opt.Contains("L")) { - TrackPoint* firstPoint = getPointWithMeasurement(0); - TrackPoint* lastPoint = getPointWithMeasurement(-1); - for (unsigned int i = 0; ideleteRawMeasurements(); - - std::vector< genfit::AbsFitterInfo* > fis = trackPoints_[i]->getFitterInfos(); - for (unsigned int j = 0; jdeleteForwardInfo(); - else if (i == trackPoints_.size()-1 && opt.Contains("I") && opt.Contains("F") && opt.Contains("L")) - fis[j]->deleteBackwardInfo(); - else if (opt.Contains("I") && opt.Contains("F")) - fis[j]->deleteForwardInfo(); - else if (opt.Contains("I") && opt.Contains("L")) - fis[j]->deleteBackwardInfo(); - - if (opt.Contains("U") && dynamic_cast(fis[j]) != NULL) { - static_cast(fis[j])->deletePredictions(); - } - - if (opt.Contains("R")) - fis[j]->deleteReferenceInfo(); - if (opt.Contains("M")) - fis[j]->deleteMeasurementInfo(); - } - } - - fillPointsWithMeasurement(); - - #ifdef DEBUG - std::cout << "pruned Track: "; Print(); - #endif - -} - - -void Track::Print(const Option_t* option) const { - TString opt = option; - opt.ToUpper(); - if (opt.Contains("C")) { // compact - - std::cout << "\n "; - for (unsigned int i=0; igetSortingParameter()); - } - - for (std::vector::const_iterator rep = trackReps_.begin(); rep != trackReps_.end(); ++rep) { - std::cout << "\n" << getIdForRep(*rep) << " "; - for (unsigned int i=0; ihasFitterInfo(*rep)) { - std::cout << " "; - continue; - } - AbsFitterInfo* fi = trackPoints_[i]->getFitterInfo(*rep); - if (fi->hasMeasurements()) - std::cout << "M"; - else - std::cout << " "; - - if (fi->hasReferenceState()) - std::cout << "R"; - else - std::cout << " "; - - std::cout << " "; - } - std::cout << "\n"; - - std::cout << " -> "; - for (unsigned int i=0; ihasFitterInfo(*rep)) { - std::cout << " "; - continue; - } - AbsFitterInfo* fi = trackPoints_[i]->getFitterInfo(*rep); - if (fi->hasForwardPrediction()) - std::cout << "P"; - else - std::cout << " "; - - if (fi->hasForwardUpdate()) - std::cout << "U"; - else - std::cout << " "; - - std::cout << " "; - } - std::cout << "\n"; - - std::cout << " <- "; - for (unsigned int i=0; ihasFitterInfo(*rep)) { - std::cout << " "; - continue; - } - AbsFitterInfo* fi = trackPoints_[i]->getFitterInfo(*rep); - if (fi->hasBackwardPrediction()) - std::cout << "P"; - else - std::cout << " "; - - if (fi->hasBackwardUpdate()) - std::cout << "U"; - else - std::cout << " "; - - std::cout << " "; - } - - std::cout << "\n"; - - } //end loop over reps - - std::cout << "\n"; - return; - } - - - - std::cout << "=======================================================================================\n"; - std::cout << "genfit::Track, containing " << trackPoints_.size() << " TrackPoints and " << trackReps_.size() << " TrackReps.\n"; - std::cout << " Seed state: "; stateSeed_.Print(); - - for (unsigned int i=0; iPrint(); - } - - std::cout << "---------------------------------------------------------------------------------------\n"; - - for (unsigned int i=0; iPrint(); - std::cout << "..........................................................................\n"; - } - - for (std::map< const AbsTrackRep*, FitStatus* >::const_iterator it=fitStatuses_.begin(); it!=fitStatuses_.end(); ++it) { - it->second->Print(); - } - - std::cout << "=======================================================================================\n"; - -} - - -bool Track::checkConsistency() const { - - bool retVal(true); - - std::map prevFis; - - // check if seed is 6D - if (stateSeed_.GetNrows() != 6) { - std::cerr << "Track::checkConsistency(): stateSeed_ dimension != 6" << std::endl; - retVal = false; - } - - if (covSeed_.GetNrows() != 6) { - std::cerr << "Track::checkConsistency(): covSeed_ dimension != 6" << std::endl; - retVal = false; - } - - if (covSeed_.Max() == 0.) { - std::cerr << "Track::checkConsistency(): Warning: covSeed_ is zero" << std::endl; - //retVal = false; - } - - // check if cardinalRep_ is in range of trackReps_ - if (trackReps_.size() && cardinalRep_ >= trackReps_.size()) { - std::cerr << "Track::checkConsistency(): cardinalRep id " << cardinalRep_ << " out of bounds" << std::endl; - retVal = false; - } - - for (std::vector::const_iterator rep = trackReps_.begin(); rep != trackReps_.end(); ++rep) { - // check for NULL - if ((*rep) == NULL) { - std::cerr << "Track::checkConsistency(): TrackRep is NULL" << std::endl; - retVal = false; - } - - // check for valid pdg code - TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle((*rep)->getPDG()); - if (particle == NULL) { - std::cerr << "Track::checkConsistency(): TrackRep pdg ID " << (*rep)->getPDG() << " is not valid" << std::endl; - retVal = false; - } - - } - - // check TrackPoints - for (std::vector::const_iterator tp = trackPoints_.begin(); tp != trackPoints_.end(); ++tp) { - // check for NULL - if ((*tp) == NULL) { - std::cerr << "Track::checkConsistency(): TrackPoint is NULL" << std::endl; - retVal = false; - } - // check if trackPoint points back to this track - if ((*tp)->getTrack() != this) { - std::cerr << "Track::checkConsistency(): TrackPoint does not point back to this track" << std::endl; - retVal = false; - } - - // check rawMeasurements - const std::vector& rawMeasurements = (*tp)->getRawMeasurements(); - for (std::vector::const_iterator m = rawMeasurements.begin(); m != rawMeasurements.end(); ++m) { - // check for NULL - if ((*m) == NULL) { - std::cerr << "Track::checkConsistency(): Measurement is NULL" << std::endl; - retVal = false; - } - // check if measurement points back to TrackPoint - if ((*m)->getTrackPoint() != *tp) { - std::cerr << "Track::checkConsistency(): Measurement does not point back to correct TrackPoint" << std::endl; - retVal = false; - } - } - - // check fitterInfos - std::vector fitterInfos = (*tp)->getFitterInfos(); - for (std::vector::const_iterator fi = fitterInfos.begin(); fi != fitterInfos.end(); ++fi) { - // check for NULL - if ((*fi) == NULL) { - std::cerr << "Track::checkConsistency(): FitterInfo is NULL. TrackPoint: " << *tp << std::endl; - retVal = false; - } - - if (!( (*fi)->checkConsistency() ) ) { - std::cerr << "Track::checkConsistency(): FitterInfo not consistent. TrackPoint: " << *tp << std::endl; - retVal = false; - } - - // check if fitterInfos point to valid TrackReps in trackReps_ - int mycount (0); - for (std::vector::const_iterator rep = trackReps_.begin(); rep != trackReps_.end(); ++rep) { - if ( (*rep) == (*fi)->getRep() ) { - ++mycount; - } - } - if (mycount == 0) { - std::cerr << "Track::checkConsistency(): fitterInfo points to TrackRep which is not in Track" << std::endl; - retVal = false; - } - - if (dynamic_cast(*fi) != NULL) { - if (prevFis[(*fi)->getRep()] != NULL && - static_cast(*fi)->hasReferenceState() && - prevFis[(*fi)->getRep()]->hasReferenceState() ) { - double len = static_cast(*fi)->getReferenceState()->getForwardSegmentLength(); - double prevLen = prevFis[(*fi)->getRep()]->getReferenceState()->getBackwardSegmentLength(); - if (fabs(prevLen + len) > 1E-10 ) { - std::cerr << "Track::checkConsistency(): segment lengths of reference states for rep " << (*fi)->getRep() << " (id " << getIdForRep((*fi)->getRep()) << ") at TrackPoint " << (*tp) << " don't match" << std::endl; - std::cerr << prevLen << " + " << len << " = " << prevLen + len << std::endl; - std::cerr << "TrackPoint " << *tp << ", FitterInfo " << *fi << ", rep " << getIdForRep((*fi)->getRep()) << std::endl; - retVal = false; - } - } - - prevFis[(*fi)->getRep()] = static_cast(*fi); - } - else - prevFis[(*fi)->getRep()] = NULL; - - } // end loop over FitterInfos - - } // end loop over TrackPoints - - - // check trackPointsWithMeasurement_ - std::vector trackPointsWithMeasurement; - - for (std::vector::const_iterator it = trackPoints_.begin(); it != trackPoints_.end(); ++it) { - if ((*it)->hasRawMeasurements()) { - trackPointsWithMeasurement.push_back(*it); - } - } - - if (trackPointsWithMeasurement.size() != trackPointsWithMeasurement_.size()) { - std::cerr << "Track::checkConsistency(): trackPointsWithMeasurement_ has incorrect size" << std::endl; - retVal = false; - } - - for (unsigned int i = 0; i < trackPointsWithMeasurement.size(); ++i) { - if (trackPointsWithMeasurement[i] != trackPointsWithMeasurement_[i]) { - std::cerr << "Track::checkConsistency(): trackPointsWithMeasurement_ is not correct" << std::endl; - std::cerr << "has id " << i << ", adress " << trackPointsWithMeasurement_[i] << std::endl; - std::cerr << "should have id " << i << ", adress " << trackPointsWithMeasurement[i] << std::endl; - retVal = false; - } - } - - return retVal; -} - - -void Track::trackHasChanged() { - - #ifdef DEBUG - std::cout << "Track::trackHasChanged \n"; - #endif - - if (fitStatuses_.empty()) - return; - - for (std::map< const AbsTrackRep*, FitStatus* >::const_iterator it=fitStatuses_.begin(); it!=fitStatuses_.end(); ++it) { - it->second->setHasTrackChanged(); - } -} - - -void Track::fillPointsWithMeasurement() { - trackPointsWithMeasurement_.clear(); - trackPointsWithMeasurement_.reserve(trackPoints_.size()); - - for (std::vector::const_iterator it = trackPoints_.begin(); it != trackPoints_.end(); ++it) { - if ((*it)->hasRawMeasurements()) { - trackPointsWithMeasurement_.push_back(*it); - } - } -} - - -void Track::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::Track. - const bool streamTrackPoints = true; // debugging option - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::Track thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - this->Clear(); - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - TObject::Streamer(R__b); - { - std::vector &R__stl = trackReps_; - R__stl.clear(); - TClass *R__tcl1 = TBuffer::GetClass(typeid(genfit::AbsTrackRep)); - if (R__tcl1==0) { - Error("trackReps_ streamer","Missing the TClass object for genfit::AbsTrackRep!"); - return; - } - int R__i, R__n; - R__b >> R__n; - R__stl.reserve(R__n); - for (R__i = 0; R__i < R__n; R__i++) { - genfit::AbsTrackRep* R__t; - R__b >> R__t; - R__stl.push_back(R__t); - } - } - R__b >> cardinalRep_; - if (streamTrackPoints) - { - std::vector &R__stl = trackPoints_; - R__stl.clear(); - TClass *R__tcl1 = TBuffer::GetClass(typeid(genfit::TrackPoint)); - if (R__tcl1==0) { - Error("trackPoints_ streamer","Missing the TClass object for genfit::TrackPoint!"); - return; - } - int R__i, R__n; - R__b >> R__n; - R__stl.reserve(R__n); - for (R__i = 0; R__i < R__n; R__i++) { - genfit::TrackPoint* R__t; - R__t = (genfit::TrackPoint*)R__b.ReadObjectAny(R__tcl1); - R__t->setTrack(this); - R__t->fixupRepsForReading(); - R__stl.push_back(R__t); - } - } - { - std::map &R__stl = fitStatuses_; - R__stl.clear(); - TClass *R__tcl2 = TBuffer::GetClass(typeid(genfit::FitStatus)); - if (R__tcl2==0) { - Error("fitStatuses_ streamer","Missing the TClass object for genfit::FitStatus!"); - return; - } - int R__i, R__n; - R__b >> R__n; - for (R__i = 0; R__i < R__n; R__i++) { - int id; - R__b >> id; - genfit::FitStatus* R__t2; - R__t2 = (genfit::FitStatus*)R__b.ReadObjectAny(R__tcl2); - - R__stl[this->getTrackRep(id)] = R__t2; - } - } - stateSeed_.Streamer(R__b); - covSeed_.Streamer(R__b); - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - - fillPointsWithMeasurement(); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - TObject::Streamer(R__b); - { - std::vector &R__stl = trackReps_; - int R__n=int(R__stl.size()); - R__b << R__n; - if(R__n) { - TClass *R__tcl1 = TBuffer::GetClass(typeid(genfit::AbsTrackRep)); - if (R__tcl1==0) { - Error("trackReps_ streamer","Missing the TClass object for genfit::AbsTrackRep!"); - return; - } - std::vector::iterator R__k; - for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) { - R__b << *R__k; - } - } - } - R__b << cardinalRep_; - if (streamTrackPoints) - { - std::vector &R__stl = trackPoints_; - int R__n=int(R__stl.size()); - R__b << R__n; - if(R__n) { - std::vector::iterator R__k; - for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) { - R__b << (*R__k); - } - } - } - { - std::map &R__stl = fitStatuses_; - int R__n=int(R__stl.size()); - R__b << R__n; - if(R__n) { - TClass *R__tcl1 = TBuffer::GetClass(typeid(genfit::AbsTrackRep)); - if (R__tcl1==0) { - Error("fitStatuses_ streamer","Missing the TClass object for genfit::AbsTrackRep!"); - return; - } - std::map::iterator R__k; -/* this piece does not work for me TR July 2014 - for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) { - int id = this->getIdForRep((*R__k).first); - R__b << id; - R__b << ((*R__k).second); - } - use instead */ - int n=0; - for (R__k = R__stl.begin(); n < 1; ++R__k){ - #ifdef DEBUG - std::cout << "i am here " << (*R__k).first << " "<getIdForRep((*R__k).first); - R__b << id; - R__b << ((*R__k).second); - } - } - } - } - stateSeed_.Streamer(R__b); - covSeed_.Streamer(R__b); - R__b.SetByteCount(R__c, kTRUE); - } -} - - - -} /* End of namespace genfit */ diff --git a/genfit/core/src/TrackCand.cc b/genfit/core/src/TrackCand.cc deleted file mode 100644 index c6c605d8ef..0000000000 --- a/genfit/core/src/TrackCand.cc +++ /dev/null @@ -1,268 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . - */ - -#include "TrackCand.h" -#include "Exception.h" -#include "TDatabasePDG.h" - -#include -#include -#include - -namespace genfit { - - -TrackCand::TrackCand() : - mcTrackId_(-1), - pdg_(0), - state6D_(6), - cov6D_(6), - q_(0) -{ - ; -} - -TrackCand::~TrackCand() { - for (unsigned int i=0; iclone() ); - } - - if (other.pdg_ != 0) - setPdgCode(other.pdg_); -} - -TrackCand& TrackCand::operator=(TrackCand other) { - swap(other); - return *this; -} - - -void TrackCand::swap(TrackCand& other) { - // by swapping the members of two classes, - // the two classes are effectively swapped - std::swap(this->hits_, other.hits_); - std::swap(this->mcTrackId_, other.mcTrackId_); - std::swap(this->pdg_, other.pdg_); - std::swap(this->state6D_, other.state6D_); - std::swap(this->cov6D_, other.cov6D_); - std::swap(this->q_, other.q_); -} - - -TrackCandHit* TrackCand::getHit(int i) const { - if (i < 0) - i += hits_.size(); - - return hits_.at(i); -} - - -void TrackCand::getHit(int i, int& detId, int& hitId) const { - if (i < 0) - i += hits_.size(); - - detId = hits_.at(i)->getDetId(); - hitId = hits_[i]->getHitId(); -} - - -void TrackCand::getHit(int i, int& detId, int& hitId, double& sortingParameter) const { - if (i < 0) - i += hits_.size(); - - detId = hits_.at(i)->getDetId(); - hitId = hits_[i]->getHitId(); - sortingParameter = hits_[i]->getSortingParameter(); -} - - -void TrackCand::getHitWithPlane(int i, int& detId, int& hitId, int& planeId) const { - if (i < 0) - i += hits_.size(); - - detId = hits_.at(i)->getDetId(); - hitId = hits_[i]->getHitId(); - planeId = hits_[i]->getPlaneId(); -} - - -void TrackCand::addHit(int detId, int hitId, int planeId, double sortingParameter) -{ - hits_.push_back(new TrackCandHit(detId, hitId, planeId, sortingParameter)); -} - -std::vector TrackCand::getHitIDs(int detId) const { - std::vector result; - for(unsigned int i=0; igetDetId() == detId) { - result.push_back(hits_[i]->getHitId()); - } - } - return result; -} - -std::vector TrackCand::getDetIDs() const { - std::vector result; - for(unsigned int i=0; igetDetId()); - } - return result; -} - -std::vector TrackCand::getSortingParameters() const { - std::vector result; - for(unsigned int i=0; igetSortingParameter()); - } - return result; -} - -std::set TrackCand::getUniqueDetIDs() const { - std::set retVal; - for (unsigned int i = 0; i < hits_.size(); ++i) { - retVal.insert(hits_[i]->getDetId()); - } - return retVal; -} - - -void TrackCand::setPdgCode(int pdgCode) { - pdg_ = pdgCode; - TParticlePDG* part = TDatabasePDG::Instance()->GetParticle(pdg_); - q_ = part->Charge() / (3.); -} - - -void TrackCand::reset() -{ - for (unsigned int i=0; igetDetId() && hitId == hits_[i]->getHitId()) - return true; - } - return false; -} - - -bool operator== (const TrackCand& lhs, const TrackCand& rhs){ - if(lhs.getNHits() != rhs.getNHits()) return false; - for (unsigned int i = 0; i < lhs.getNHits(); ++i){ - if (lhs.getHit(i) != rhs.getHit(i)) return false; - } - return true; -} - - -void TrackCand::Print(const Option_t* option) const { - std::cout << "======== TrackCand::print ========\n"; - std::cout << "mcTrackId=" << mcTrackId_ << "\n"; - std::cout << "seed values for 6D state: \n"; - state6D_.Print(option); - std::cout << "q" << q_ << "\n"; - std::cout << "PDG code= " << pdg_ << "\n"; - for(unsigned int i=0; iPrint(); - } -} - - -void TrackCand::append(const TrackCand& rhs){ - for(unsigned int i=0; iclone()); - } -} - - -void TrackCand::sortHits(){ - std::stable_sort(hits_.begin(), hits_.end(), compareTrackCandHits); -} - - -void TrackCand::sortHits(const std::vector& indices){ - - const unsigned int nHits(getNHits()); - if (indices.size() != nHits){ - abort(); - Exception exc("TrackCand::sortHits ==> Size of indices != number of hits!",__LINE__,__FILE__); - throw exc; - } - - //these containers will hold the sorted results. They are created to avoid probably slower in-place sorting - std::vector sortedHits(nHits); - for (unsigned int i=0; i. - */ - -#include "TrackCandHit.h" - -#include - -namespace genfit { - -TrackCandHit::TrackCandHit(int detId, - int hitId, - int planeId, - double sortingParameter) - : detId_(detId), - hitId_(hitId), - planeId_(planeId), - sortingParameter_(sortingParameter) -{ - ; -} - - -void TrackCandHit::Print(Option_t*) const { - std::cout << " TrackCandHit. DetId = " << detId_ - << " \t HitId = " << hitId_ - << " \t PlaneId = " << planeId_ - << " \t SortingParameter = " << sortingParameter_ << "\n"; -} - - -bool operator== (const TrackCandHit& lhs, const TrackCandHit& rhs){ - if(lhs.detId_ == rhs.detId_ && - lhs.hitId_ == rhs.hitId_ && - lhs.planeId_ == rhs.planeId_) - return true; - return false; -} - -} /* End of namespace genfit */ diff --git a/genfit/core/src/TrackPoint.cc b/genfit/core/src/TrackPoint.cc deleted file mode 100644 index 0f30b67690..0000000000 --- a/genfit/core/src/TrackPoint.cc +++ /dev/null @@ -1,334 +0,0 @@ -/* Copyright 2008-2009, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "Track.h" - -#include "TrackPoint.h" -#include "Exception.h" -#include "KalmanFitterInfo.h" - -#include -#include - - -namespace genfit { - -TrackPoint::TrackPoint() : - sortingParameter_(0), track_(NULL), thinScatterer_(NULL) -{ - ; -} - -TrackPoint::TrackPoint(Track* track) : - sortingParameter_(0), track_(track), thinScatterer_(NULL) -{ - ; -} - -TrackPoint::TrackPoint(const std::vector< genfit::AbsMeasurement* >& rawMeasurements, Track* track) : - sortingParameter_(0), track_(track), thinScatterer_(NULL) -{ - rawMeasurements_.reserve(rawMeasurements.size()); - - for (std::vector::const_iterator m = rawMeasurements.begin(); m != rawMeasurements.end(); ++m) { - addRawMeasurement(*m); - } -} - -TrackPoint::TrackPoint(AbsMeasurement* rawMeasurement, Track* track) : - sortingParameter_(0), track_(track), thinScatterer_(NULL) -{ - addRawMeasurement(rawMeasurement); -} - - -TrackPoint::TrackPoint(const TrackPoint& rhs) : - TObject(rhs), - sortingParameter_(rhs.sortingParameter_), track_(rhs.track_), thinScatterer_(NULL) -{ - // clone rawMeasurements - for (std::vector::const_iterator it = rhs.rawMeasurements_.begin(); it != rhs.rawMeasurements_.end(); ++it) { - AbsMeasurement* tp = (*it)->clone(); - addRawMeasurement(tp); - } - - // copy fitterInfos - for (std::map::const_iterator it = rhs.fitterInfos_.begin(); it != rhs.fitterInfos_.end(); ++it ) { - AbsFitterInfo* fi = it->second->clone(); - fi->setTrackPoint(this); - setFitterInfo(fi); - } - - if (rhs.thinScatterer_ != NULL) - thinScatterer_.reset(new ThinScatterer(*(rhs.thinScatterer_))); -} - -TrackPoint::TrackPoint(const TrackPoint& rhs, - const std::map& map, - const std::vector * repsToIgnore) : - sortingParameter_(rhs.sortingParameter_), track_(rhs.track_), thinScatterer_(NULL) -{ - // clone rawMeasurements - for (std::vector::const_iterator it = rhs.rawMeasurements_.begin(); it!=rhs.rawMeasurements_.end(); ++it) { - AbsMeasurement* m = (*it)->clone(); - addRawMeasurement(m); - } - - // copy fitterInfos - for (std::map::const_iterator it = rhs.fitterInfos_.begin(); it != rhs.fitterInfos_.end(); ++it ) { - if (repsToIgnore != NULL) { - if (std::find(repsToIgnore->begin(), repsToIgnore->end(), it->first) != repsToIgnore->end()) - continue; - } - AbsFitterInfo* fi = it->second->clone(); - fi->setRep(map.at(it->first)); - fi->setTrackPoint(this); - setFitterInfo(fi); - } - - if (rhs.thinScatterer_ != NULL) - thinScatterer_.reset(new ThinScatterer(*(rhs.thinScatterer_))); -} - - -TrackPoint& TrackPoint::operator=(TrackPoint rhs) { - swap(rhs); - - for (std::vector::const_iterator it = rawMeasurements_.begin(); it!=rawMeasurements_.end(); ++it) { - (*it)->setTrackPoint(this); - } - - for (std::map::const_iterator it = fitterInfos_.begin(); it != fitterInfos_.end(); ++it ) { - it->second->setTrackPoint(this); - } - - return *this; -} - - -void TrackPoint::swap(TrackPoint& other) { - std::swap(this->sortingParameter_, other.sortingParameter_); - std::swap(this->track_, other.track_); - std::swap(this->rawMeasurements_, other.rawMeasurements_); - std::swap(this->fitterInfos_, other.fitterInfos_); - this->thinScatterer_.swap(other.thinScatterer_); -} - - -TrackPoint::~TrackPoint() { - // FIXME: We definitely need some smart containers or smart pointers that - // take care of this, but so far we haven't found a convincing - // option (2013-07-05). - - for (size_t i = 0; i < rawMeasurements_.size(); ++i) - delete rawMeasurements_[i]; - - std::map< const AbsTrackRep*, AbsFitterInfo* >::iterator it; - for (it = fitterInfos_.begin(); it != fitterInfos_.end(); ++it) - delete it->second; -} - - -AbsMeasurement* TrackPoint::getRawMeasurement(int i) const { - if (i < 0) - i += rawMeasurements_.size(); - - return rawMeasurements_.at(i); -} - - -std::vector< AbsFitterInfo* > TrackPoint::getFitterInfos() const { - std::vector< AbsFitterInfo* > retVal; - - if (fitterInfos_.empty()) - return retVal; - - for (std::map::const_iterator it = fitterInfos_.begin(); it != fitterInfos_.end(); ++it ) { - retVal.push_back(it->second); - } - - return retVal; -} - - -AbsFitterInfo* TrackPoint::getFitterInfo(const AbsTrackRep* rep) const { - if (!rep) - rep = track_->getCardinalRep(); - std::map::const_iterator it = fitterInfos_.find(rep); - if (it == fitterInfos_.end()) - return NULL; - return fitterInfos_.at(rep); -} - - -KalmanFitterInfo* TrackPoint::getKalmanFitterInfo(const AbsTrackRep* rep) const { - return dynamic_cast(getFitterInfo(rep)); -} - - - -void TrackPoint::deleteRawMeasurements() { - for (size_t i = 0; i < rawMeasurements_.size(); ++i) - delete rawMeasurements_[i]; - - rawMeasurements_.clear(); -} - - -void TrackPoint::setFitterInfo(genfit::AbsFitterInfo* fitterInfo) { - assert (fitterInfo != NULL); - if (hasFitterInfo(fitterInfo->getRep())) - delete fitterInfos_[fitterInfo->getRep()]; - - fitterInfos_[fitterInfo->getRep()] = fitterInfo; -} - - -void TrackPoint::Print(const Option_t*) const { - std::cout << "genfit::TrackPoint, belonging to Track " << track_ << "; sorting parameter = " << sortingParameter_ << "\n"; - std::cout << "contains " << rawMeasurements_.size() << " rawMeasurements and " << getFitterInfos().size() << " fitterInfos for " << fitterInfos_.size() << " TrackReps.\n"; - - for (unsigned int i=0; iPrint(); - std::cout << "............\n"; - } - - for (std::map< const AbsTrackRep*, AbsFitterInfo* >::const_iterator it = fitterInfos_.begin(); it != fitterInfos_.end(); ++it ) { - std::cout << "FitterInfo for TrackRep " << it->first << "\n"; - it->second->Print(); - std::cout << "............\n"; - } - - if (thinScatterer_) - thinScatterer_->Print(); - -} - - -// -// This is modified from the auto-generated Streamer. -// -void TrackPoint::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::TrackPoint. - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::TrackPoint thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - //TObject::Streamer(R__b); - R__b >> sortingParameter_; - { - std::vector > &R__stl = rawMeasurements_; - R__stl.clear(); - TClass *R__tcl1 = TBuffer::GetClass(typeid(genfit::AbsMeasurement)); - if (R__tcl1==0) { - Error("rawMeasurements_ streamer","Missing the TClass object for genfit::AbsMeasurement!"); - return; - } - int R__i, R__n; - R__b >> R__n; - R__stl.reserve(R__n); - for (R__i = 0; R__i < R__n; R__i++) { - genfit::AbsMeasurement* R__t = 0; - R__b >> R__t; - R__stl.push_back(R__t); - } - } - track_ = NULL; - size_t nTrackReps; - R__b >> nTrackReps; - vFitterInfos_.resize(nTrackReps); - for (size_t i = 0; i < nTrackReps; ++i) { - int id; - R__b >> id; - AbsFitterInfo* p = 0; - R__b >> p; - vFitterInfos_[id] = p; - } - thinScatterer_.reset(); - char flag; - R__b >> flag; - if (flag) { - genfit::ThinScatterer *scatterer = 0; - R__b >> scatterer; - thinScatterer_.reset(new ThinScatterer(*scatterer)); - } - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - - - // Fixup ownerships. - for (size_t i = 0; i < rawMeasurements_.size(); ++i) { - rawMeasurements_[i]->setTrackPoint(this); - } - for (size_t i = 0; i < vFitterInfos_.size(); ++i) { - // May not have FitterInfos for all reps. - if (vFitterInfos_[i]) - vFitterInfos_[i]->setTrackPoint(this); - } - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - //TObject::Streamer(R__b); - R__b << sortingParameter_; - { - std::vector > &R__stl = rawMeasurements_; - int R__n=int(R__stl.size()); - R__b << R__n; - if(R__n) { - std::vector >::iterator R__k; - for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) { - R__b << (*R__k); - } - } - } - R__b << fitterInfos_.size(); - for (std::map::const_iterator it = fitterInfos_.begin(); - it != fitterInfos_.end(); ++it) - { - int id = track_->getIdForRep(it->first); - R__b << id; - R__b << it->second; - } - if (thinScatterer_) { - R__b << (char)1; - R__b << thinScatterer_.get(); - } else { - R__b << (char)0; - } - R__b.SetByteCount(R__c, kTRUE); - } -} - - -void TrackPoint::fixupRepsForReading() -{ - for (size_t i = 0; i < vFitterInfos_.size(); ++i) { - // The vector is filled such that i corresponds to the id of the TrackRep. - - // May not have FitterInfos for all reps. - if (!vFitterInfos_[i]) - continue; - fitterInfos_[track_->getTrackRep(i)] = vFitterInfos_[i]; - fitterInfos_[track_->getTrackRep(i)]->setRep(track_->getTrackRep(i)); - } - vFitterInfos_.clear(); -} - -} /* End of namespace genfit */ diff --git a/genfit/core/src/coreLinkDef.h b/genfit/core/src/coreLinkDef.h deleted file mode 100644 index 5caccc767b..0000000000 --- a/genfit/core/src/coreLinkDef.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -// These need no special treatment. -#pragma link C++ class genfit::AbsFinitePlane+; -#pragma link C++ class genfit::AbsHMatrix+; -#pragma link C++ class genfit::RectangularFinitePlane+; -#pragma link C++ class genfit::FitStatus+; -#pragma link C++ class genfit::MaterialProperties+; -#pragma link C++ class genfit::TrackCand+; -#pragma link C++ class genfit::TrackCandHit+; -#pragma link C++ class genfit::FieldManager+; -#pragma link C++ class genfit::AbsFitter+; -#pragma link C++ class genfit::AbsBField+; - -// These inherit from classes with custom streamers, or reference shared_ptrs in their interfaces. -#pragma link C++ class genfit::AbsTrackRep+; -#pragma link C++ class genfit::MeasuredStateOnPlane+; - -// These need their owners fixed up after reading. -#pragma link C++ class genfit::AbsMeasurement+; // trackPoint_ - -// These cannot be dealt with by default streamers because of -// shared_ptrs<> or scoped_ptrs<>. Additionally, they may need their -// owners fixed up. -#pragma link C++ class genfit::AbsFitterInfo-; // trackPoint_, rep_, sharedPlanePtr -#pragma link C++ class genfit::DetPlane-; // scoped_ptr<> finitePlane_ -#pragma link C++ class genfit::MeasurementOnPlane-; // scoped_ptr<> hMatrix_ -#pragma link C++ class genfit::StateOnPlane-; // rep_, sharedPlanePtr -#pragma link C++ class genfit::ThinScatterer-; // sharedPlanePtr -#pragma link C++ class genfit::Track-; -#pragma link C++ class genfit::TrackPoint-; // track_, fixup the map -#pragma link C++ class std::vector-; -#pragma link C++ class std::vector-; - -#endif diff --git a/genfit/doc/Doxyfile.in b/genfit/doc/Doxyfile.in deleted file mode 100644 index f0451b3a15..0000000000 --- a/genfit/doc/Doxyfile.in +++ /dev/null @@ -1,1804 +0,0 @@ -# Doxyfile 1.7.6.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. - -PROJECT_NAME = GENFIT - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = Rev: @GLOBAL_SVN_REVISION@ - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST = YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = @CMAKE_CURRENT_SOURCE_DIR@/core/src -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/core/include -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/eventDisplay/include -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/eventDisplay/src -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/fields/src -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/fields/include -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/finitePlanes/src -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/finitePlanes/include -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/fitters/src -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/fitters/include -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/GBL/src -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/GBL/include -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/GFRave/src -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/GFRave/include -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/measurements/src -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/measurements/include -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/trackReps/include -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/trackReps/src -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/utilities/src -INPUT += @CMAKE_CURRENT_SOURCE_DIR@/utilities/include -#INPUT += @CMAKE_CURRENT_SOURCE_DIR@//src -#INPUT += @CMAKE_CURRENT_SOURCE_DIR@//include - - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# style sheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the -# mathjax.org site, so you can quickly see the result without installing -# MathJax, but it is strongly recommended to install a local copy of MathJax -# before deployment. - -MATHJAX_RELPATH = http://www.mathjax.org/mathjax - -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. - -MATHJAX_EXTENSIONS = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the -# directory containing the font. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to -# set the path where dot can find it. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = YES - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible in IE 9+ (other browsers do not have this requirement). - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible. Older versions of IE do not have SVG support. - -INTERACTIVE_SVG = NO - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/genfit/eventDisplay/include/EventDisplay.h b/genfit/eventDisplay/include/EventDisplay.h deleted file mode 100644 index 767d67f88d..0000000000 --- a/genfit/eventDisplay/include/EventDisplay.h +++ /dev/null @@ -1,252 +0,0 @@ -/* Copyright 2011, Technische Universitaet Muenchen, - Author: Karl Bicker - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup EventDisplay -* @{ -*/ - -#ifndef genfit_EventDisplay_h -#define genfit_EventDisplay_h - -#include "Track.h" -#include "AbsKalmanFitter.h" - -#include -#include -#include -#include - -#include -#include -#include - - -namespace genfit { - -enum eFitterType { - SimpleKalman, - RefKalman, - DafSimple, - DafRef -}; - -/** @brief Event display designed to run with Genfit. - * - * @author Karl Bicker (Technische Universität München, original author) - * - * The EventDisplay class is a singelton used to visualize the events processed with Genfit. The - * event display uses the EVE event visualization package to visualize Tracks which are bundled - * in a vector and which form one event. The information about the tracks is supplied in Track - * objects. To use the event display, the geometry (TGeoManager)and magnetic field (FieldManager) - * have to be initialized and gApplication and gEve have to exist. - * - */ -class EventDisplay : public TNamed { - private: - EventDisplay(); - - public: - ~EventDisplay(); - static EventDisplay* getInstance(); - - /** @brief Drop all events.*/ - void reset(); - - /** @brief Add new event - * - * Add a new event. An event is a collection of Tracks which are displayed at the - * the same time. - * The tracks are copied. - * - */ - void addEvent(std::vector& tracks); - void addEvent(std::vector& tracks); - - /** @brief Add new event - * - * Add a new event consisting of one track. - * - */ - void addEvent(const Track* tr); - - /** @brief Go to the next event or step a certain number of events ahead.*/ - void next(unsigned int stp = 1); - - /** @brief Go to the previous event or step a certain number of events back.*/ - void prev(unsigned int stp = 1); - - /** @brief Go to event with index id.*/ - void gotoEvent(unsigned int id); - - /** @brief Get the total number of events stored.*/ - int getNEvents(); - - /** @brief Set the display options. - * - * The option string lets you steer the way the events are displayed. The following - * options are available:\n - * \n - * 'A': Autoscale errors. The representation of hits are scaled with the error found - * their covariance matrix. This can lead to hits not being displayed beause the - * errors are too small. Autoscaling ensures that the errors are scaled up - * sufficiently to ensure all hits are displayed. However, this can lead to unwanted - * results if there are only a few hits with very small errors, as all hits are scaled - * by the same factor to ensure consistency.\n\n - * 'B': Draw Backward Fit (track segments start at updates and end at predictions)\n\n - * 'D': Draw detectors. This causes a simple representation for all detectors to be drawn. For - * planar detectors, this is a plane with the same position and orientation of the real - * detector plane, but with different size. For wires, this is a tube whose diameter - * is equal to the value measured by the wire. Spacepoint hits are not affected by this - * option.\n\n - * 'E': Draw Error cones (position and direction uncertainties) around the track.\n\n - * 'F': Draw Forward Fit (track segments start at updates and end at predictions) - * 'H': Draw hits. This causes the hits to be visualized. Normally, the size of the hit - * representation is connected to the covariance matrix of the hit, scaled by the value - * set in setErrScale which is normally 1. See also option 'A' and 'S'. Normally used in - * connection with 'D'.\n\n - * 'G': Draw geometry. Draw also the geometry in the gGeoManager. This feature is experimental - * and may lead to strang things being drawn.\n\n - * 'M': Draw track markers. Draw the intersection points between the track and the virtual - * (and/or real) detector planes. Can only be used in connection with 'T'.\n\n - * 'P': Draw detector planes. Draws the virtual (and/or real) detector planes.\n\n - * 'S': Scale manually. This leads to the spacepoint hits (and only them up to now!) being drawn - * as spheres with radius 0.5 scaled with the error scale factor. Can be used if the scaling - * with errors leads to problems.\n\n - * 'T': Draw Track. Draw the track as lines between the virtual (and/or real) detector - * planes.\n\n - * 'X': Draw silent. Does not run the TApplication. - * - */ - void setOptions(std::string opts); - - /** @brief Set the scaling factor for the visualization of the errors.*/ - void setErrScale(double errScale = 1.); - - /** @brief Get the error scaling factor.*/ - double getErrScale(); - - /** @brief Open the event display.*/ - void open(); - - void guiGoto(); - void guiGoto2(); - void guiSetDrawParams(); - void guiSelectFitterId(int val); - void guiSelectMmHandling(int val); - - private: - /** @brief Build the buttons for event navigation.*/ - void makeGui(); - - /** @brief Draw an event.*/ - void drawEvent(unsigned int id, bool resetCam = true); - - /** @brief Create a box around o, oriented along u and v with widths ud, vd and depth and - * return a pointer to the box object. - */ - TEveBox* boxCreator(TVector3 o, TVector3 u, TVector3 v, float ud, float vd, float depth); - - void makeLines(const StateOnPlane* prevState, const StateOnPlane* state, const AbsTrackRep* rep, - const Color_t& color, const Style_t& style, bool drawMarkers, bool drawErrors, double lineWidth = 2, int markerPos = 1); - - - static EventDisplay* eventDisplay_; //! - unsigned int eventId_; //! - double errorScale_; //! - std::vector< std::vector* > events_; //! - - - TGNumberEntry* guiEvent; - TGNumberEntry* guiEvent2; - - TGCheckButton* guiDrawGeometry_; - bool drawGeometry_; - TGCheckButton* guiDrawDetectors_; - bool drawDetectors_; - TGCheckButton* guiDrawHits_; - bool drawHits_; - TGCheckButton* guiDrawErrors_; - bool drawErrors_; - - TGCheckButton* guiDrawPlanes_; - bool drawPlanes_; - TGCheckButton* guiDrawTrackMarkers_; - bool drawTrackMarkers_; - - TGCheckButton* guiDrawTrack_; - bool drawTrack_; - TGCheckButton* guiDrawRefTrack_; - bool drawRefTrack_; - TGCheckButton* guiDrawForward_; - bool drawForward_; - TGCheckButton* guiDrawBackward_; - bool drawBackward_; - - TGCheckButton* guiDrawAutoScale_; - bool drawAutoScale_; - TGCheckButton* guiDrawScaleMan_; - bool drawScaleMan_; - TGNumberEntry* guiErrorScale_; - - bool drawSilent_; - - TGCheckButton* guiDrawCardinalRep_; - bool drawCardinalRep_; - TGNumberEntry* guiRepId_; - unsigned int repId_; - - TGCheckButton* guiDrawAllTracks_; - bool drawAllTracks_; - TGNumberEntry* guiTrackId_; - unsigned int trackId_; - - TGCheckButton* guiRefit_; - bool refit_; - TGNumberEntry* guiDebugLvl_; - unsigned int debugLvl_; - TGButtonGroup* guiFitterId_; - eFitterType fitterId_; - TGButtonGroup* guiMmHandling_; - eMultipleMeasurementHandling mmHandling_; - - TGCheckButton* guiSquareRootFormalism_; - bool squareRootFormalism_; - TGNumberEntry* guiDPVal_; - double dPVal_; - TGNumberEntry* guiRelChi2_; - double dRelChi2_; - TGNumberEntry* guiNMinIter_; - unsigned int nMinIter_; - TGNumberEntry* guiNMaxIter_; - unsigned int nMaxIter_; - TGNumberEntry* guiNMaxFailed_; - int nMaxFailed_; - TGCheckButton* guiResort_; - bool resort_; - - - public: - ClassDef(EventDisplay,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_EventDisplay_h - diff --git a/genfit/eventDisplay/src/EventDisplay.cc b/genfit/eventDisplay/src/EventDisplay.cc deleted file mode 100644 index d35af099f4..0000000000 --- a/genfit/eventDisplay/src/EventDisplay.cc +++ /dev/null @@ -1,1628 +0,0 @@ - -#include "EventDisplay.h" - -#include -#include -#include -#include -#include -#include - -#include "AbsMeasurement.h" -#include "FullMeasurement.h" -#include "PlanarMeasurement.h" -#include "ProlateSpacepointMeasurement.h" -#include "SpacepointMeasurement.h" -#include "WireMeasurement.h" -#include "WirePointMeasurement.h" -#include "AbsTrackRep.h" -#include "ConstField.h" -#include "DetPlane.h" -#include "Exception.h" -#include "FieldManager.h" -#include "Tools.h" -#include "KalmanFitterInfo.h" -#include "KalmanFitter.h" -#include "DAF.h" -#include "KalmanFitterRefTrack.h" -#include "RKTrackRep.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "boost/scoped_ptr.hpp" - - - -namespace genfit { - - -EventDisplay* EventDisplay::eventDisplay_ = NULL; - -EventDisplay::EventDisplay() : - errorScale_(1.), - drawGeometry_(false), - drawDetectors_(true), - drawHits_(true), - drawErrors_(true), - drawPlanes_(true), - drawTrackMarkers_(true), - drawTrack_(true), - drawRefTrack_(true), - drawForward_(true), - drawBackward_(true), - drawAutoScale_(true), - drawScaleMan_(false), - drawSilent_(false), - drawCardinalRep_(true), - repId_(0), - drawAllTracks_(true), - trackId_(0), - refit_(false), - debugLvl_(0), - fitterId_(SimpleKalman), - mmHandling_(weightedAverage), - squareRootFormalism_(false), - dPVal_(1.E-3), - dRelChi2_(0.2), - nMinIter_(2), - nMaxIter_(4), - nMaxFailed_(-1), - resort_(false) -{ - - if((!gApplication) || (gApplication && gApplication->TestBit(TApplication::kDefaultApplication))) { - std::cout << "In EventDisplay ctor: gApplication not found, creating..." << std::flush; - new TApplication("ROOT_application", 0, 0); - std::cout << "done!" << std::endl; - } - if(!gEve) { - std::cout << "In EventDisplay ctor: gEve not found, creating..." << std::flush; - TEveManager::Create(); - std::cout << "done!" << std::endl; - } - - eventId_ = 0; - -} - -void EventDisplay::setOptions(std::string opts) { - - if(opts != "") { - for(size_t i = 0; i < opts.length(); ++i) { - if(opts[i] == 'A') drawAutoScale_ = true; - if(opts[i] == 'B') drawBackward_ = true; - if(opts[i] == 'D') drawDetectors_ = true; - if(opts[i] == 'E') drawErrors_ = true; - if(opts[i] == 'F') drawForward_ = true; - if(opts[i] == 'H') drawHits_ = true; - if(opts[i] == 'M') drawTrackMarkers_ = true; - if(opts[i] == 'P') drawPlanes_ = true; - if(opts[i] == 'S') drawScaleMan_ = true; - if(opts[i] == 'T') drawTrack_ = true; - if(opts[i] == 'X') drawSilent_ = true; - if(opts[i] == 'G') drawGeometry_ = true; - } - } - -} - -void EventDisplay::setErrScale(double errScale) { errorScale_ = errScale; } - -double EventDisplay::getErrScale() { return errorScale_; } - -EventDisplay* EventDisplay::getInstance() { - - if(eventDisplay_ == NULL) { - eventDisplay_ = new EventDisplay(); - } - return eventDisplay_; - -} - -EventDisplay::~EventDisplay() { reset(); } - -void EventDisplay::reset() { - - for(unsigned int i = 0; i < events_.size(); i++) { - - for(unsigned int j = 0; j < events_[i]->size(); j++) { - - delete events_[i]->at(j); - - } - delete events_[i]; - } - - events_.clear(); -} - - -void EventDisplay::addEvent(std::vector& tracks) { - - std::vector* vec = new std::vector; - - for(unsigned int i = 0; i < tracks.size(); i++) { - vec->push_back(new Track(*(tracks[i]))); - } - - events_.push_back(vec); -} - - -void EventDisplay::addEvent(std::vector& tracks) { - - std::vector* vec = new std::vector; - - for(unsigned int i = 0; i < tracks.size(); i++) { - vec->push_back(new Track(*(tracks[i]))); - } - - events_.push_back(vec); -} - - -void EventDisplay::addEvent(const Track* tr) { - - std::vector* vec = new std::vector; - vec->push_back(new Track(*tr)); - events_.push_back(vec); -} - - -void EventDisplay::next(unsigned int stp) { - - gotoEvent(eventId_ + stp); - -} - -void EventDisplay::prev(unsigned int stp) { - - if(events_.size() == 0) return; - if(eventId_ < stp) { - gotoEvent(0); - } else { - gotoEvent(eventId_ - stp); - } - -} - -int EventDisplay::getNEvents() { return events_.size(); } - - -void EventDisplay::gotoEvent(unsigned int id) { - - if (events_.size() == 0) - return; - else if(id >= events_.size()) - id = events_.size() - 1; - - bool resetCam = true; - - if (id == eventId_) - resetCam = false; - - eventId_ = id; - - std::cout << "At event " << id << std::endl; - if (gEve->GetCurrentEvent()) { - gEve->GetCurrentEvent()->DestroyElements(); - } - double old_error_scale = errorScale_; - drawEvent(eventId_, resetCam); - if(old_error_scale != errorScale_) { - if (gEve->GetCurrentEvent()) { - gEve->GetCurrentEvent()->DestroyElements(); - } - drawEvent(eventId_, resetCam); // if autoscaling changed the error, draw again. - } - errorScale_ = old_error_scale; - -} - -void EventDisplay::open() { - - std::cout << "EventDisplay::open(); " << getNEvents() << " events loaded" << std::endl; - - if(getNEvents() > 0) { - double old_error_scale = errorScale_; - drawEvent(0); - if(old_error_scale != errorScale_) { - std::cout << "autoscaling changed the error, draw again." << std::endl; - gotoEvent(0); // if autoscaling changed the error, draw again. - } - errorScale_ = old_error_scale; - } - - - if(!drawSilent_) { - makeGui(); - gApplication->Run(kTRUE); - } - - std::cout << "opened" << std::endl; - -} - - -void EventDisplay::drawEvent(unsigned int id, bool resetCam) { - - std::cout << "EventDisplay::drawEvent(" << id << ")" << std::endl; - - - // draw the geometry, does not really work yet. If it's fixed, the docu in the header file should be changed. - if(drawGeometry_) { - TGeoNode* top_node = gGeoManager->GetTopNode(); - assert(top_node != NULL); - - //Set transparency & color of geometry - TObjArray* volumes = gGeoManager->GetListOfVolumes(); - for(int i = 0; i < volumes->GetEntriesFast(); i++) { - TGeoVolume* volume = dynamic_cast(volumes->At(i)); - assert(volume != NULL); - volume->SetLineColor(12); - volume->SetTransparency(50); - } - - TEveGeoTopNode* eve_top_node = new TEveGeoTopNode(gGeoManager, top_node); - eve_top_node->IncDenyDestroy(); - gEve->AddElement(eve_top_node); - } - - - for(unsigned int i = 0; i < events_.at(id)->size(); i++) { // loop over all tracks in an event - - if (!drawAllTracks_ && trackId_ != i) - continue; - - Track* track = events_[id]->at(i); - if (! track->checkConsistency()){ - std::cerr<<"track is not consistent"< refittedTrack(NULL); - if (refit_) { - - std::cout << "Refit track:" << std::endl; - - boost::scoped_ptr fitter; - switch (fitterId_) { - case SimpleKalman: - fitter.reset(new KalmanFitter(nMaxIter_, dPVal_)); - fitter->setMultipleMeasurementHandling(mmHandling_); - (static_cast(fitter.get()))->useSquareRootFormalism(squareRootFormalism_); - break; - - case RefKalman: - fitter.reset(new KalmanFitterRefTrack(nMaxIter_, dPVal_)); - fitter->setMultipleMeasurementHandling(mmHandling_); - break; - - case DafSimple: - fitter.reset(new DAF(false)); - ( static_cast( (static_cast(fitter.get()))->getKalman() ) )->useSquareRootFormalism(squareRootFormalism_); - break; - case DafRef: - fitter.reset(new DAF()); - break; - - } - fitter->setDebugLvl(std::max(0, (int)debugLvl_-1)); - fitter->setMinIterations(nMinIter_); - fitter->setMaxIterations(nMaxIter_); - fitter->setRelChi2Change(dRelChi2_); - fitter->setMaxFailedHits(nMaxFailed_); - - - refittedTrack.reset(new Track(*track)); - refittedTrack->deleteFitterInfo(); - - if (debugLvl_>0) - refittedTrack->Print("C"); - - timeval startcputime, endcputime; - - try{ - gettimeofday(&startcputime, NULL); - fitter->processTrack(refittedTrack.get(), resort_); - gettimeofday(&endcputime, NULL); - } - catch(genfit::Exception& e){ - std::cerr << e.what(); - std::cerr << "Exception, could not refit track" << std::endl; - continue; - } - - int microseconds = 1000000*(endcputime.tv_sec - startcputime.tv_sec) + (endcputime.tv_usec - startcputime.tv_usec); - std::cout << "it took " << double(microseconds) / 1000 << " ms of CPU to fit the track\n"; - - if (! refittedTrack->checkConsistency()){ - std::cerr<<"refittedTrack is not consistent"<getCardinalRep(); - std::cout << "Draw cardinal rep" << std::endl; - } - else { - if (repId_ >= track->getNumReps()) - repId_ = track->getNumReps() - 1; - rep = track->getTrackRep(repId_); - std::cout << "Draw rep" << repId_ << std::endl; - } - - if (debugLvl_>0) { - //track->Print(); - track->Print("C"); - track->getFitStatus(rep)->Print(); - - if (track->getFitStatus(rep)->isFitted()) { - try { - std::cout << "fitted state: \n"; - track->getFittedState().Print(); - } - catch (Exception& e) { - std::cerr << e.what(); - } - } - } - - - - rep->setPropDir(0); - - unsigned int numhits = track->getNumPointsWithMeasurement(); - - KalmanFitterInfo* fi; - KalmanFitterInfo* prevFi = 0; - const MeasuredStateOnPlane* fittedState(NULL); - const MeasuredStateOnPlane* prevFittedState(NULL); - - for(unsigned int j = 0; j < numhits; j++) { // loop over all hits in the track - - fittedState = NULL; - - TrackPoint* tp = track->getPointWithMeasurement(j); - if (! tp->hasRawMeasurements()) { - std::cerr<<"trackPoint has no raw measurements"<getRawMeasurement(); - int hit_coords_dim = m->getDim(); - - // check if multiple AbsMeasurements are of same type - if (tp->getNumRawMeasurements() > 1) { - bool sameTypes(true); - for (unsigned int iM=1; iMgetNumRawMeasurements(); ++iM) { - AbsMeasurement* tmp = tp->getRawMeasurement(iM); - if (typeid(*tmp) != typeid(*m)) - sameTypes = false; - } - if (!sameTypes) { - std::cerr<<"cannot draw trackpoint containing multiple Measurements of differend types"<hasFitterInfo(rep)) { - std::cerr<<"trackPoint has no fitterInfo for rep"<getFitterInfo(rep); - - fi = dynamic_cast(fitterInfo); - if(fi == NULL) { - std::cerr<<"can only display KalmanFitterInfo"<hasPredictionsAndUpdates()) { - std::cerr<<"KalmanFitterInfo does not have all predictions and updates"<getFittedState(true)); - } - catch (Exception& e) { - std::cerr << e.what(); - std::cerr<<"can not get fitted state"<hasForwardUpdate()) { - fittedState = fi->getForwardUpdate(); - } - else if (fi->hasBackwardUpdate()) { - fittedState = fi->getBackwardUpdate(); - } - else if (fi->hasForwardPrediction()) { - fittedState = fi->getForwardPrediction(); - } - else if (fi->hasBackwardPrediction()) { - fittedState = fi->getBackwardPrediction(); - } - } - - if (fittedState == NULL) { - std::cout << "canot get any state from fitterInfo, continue.\n"; - prevFi = fi; - prevFittedState = fittedState; - continue; - } - - TVector3 track_pos = fittedState->getPos(); - double charge = fittedState->getCharge(); - - //std::cout << "trackPos: "; track_pos.Print(); - - - // determine measurement type - bool full_hit = false; - bool planar_hit = false; - bool planar_pixel_hit = false; - bool space_hit = false; - bool wire_hit = false; - bool wirepoint_hit = false; - if (dynamic_cast(m) != NULL) { - full_hit = true; - } - else if(dynamic_cast(m) != NULL) { - planar_hit = true; - if(hit_coords_dim == 2) { - planar_pixel_hit = true; - } - } else if (dynamic_cast(m) != NULL) { - space_hit = true; - } else if (dynamic_cast(m) != NULL) { - wire_hit = true; - if (dynamic_cast(m) != NULL) { - wirepoint_hit = true; - } - } else { - std::cout << "Track " << i << ", Hit " << j << ": Unknown measurement type: skipping hit!" << std::endl; - continue; - } - - - // loop over MeasurementOnPlanes - for (unsigned int iMeas = 0; iMeas < fi->getNumMeasurements(); ++iMeas) { - - if (iMeas > 0 && wire_hit) - break; - - const MeasurementOnPlane* mop = fi->getMeasurementOnPlane(iMeas); - const TVectorT& hit_coords = mop->getState(); - const TMatrixTSym& hit_cov = mop->getCov(); - - // finished getting the hit infos ----------------------------------------------------- - - // sort hit infos into variables ------------------------------------------------------ - TVector3 o = fittedState->getPlane()->getO(); - TVector3 u = fittedState->getPlane()->getU(); - TVector3 v = fittedState->getPlane()->getV(); - - double_t hit_u = 0; - double_t hit_v = 0; - double_t plane_size = 4; - TVector2 stripDir(1,0); - - if(planar_hit) { - if(!planar_pixel_hit) { - if (dynamic_cast(rep) != NULL) { - const TMatrixD& H = mop->getHMatrix()->getMatrix(); - stripDir.Set(H(0,3), H(0,4)); - } - hit_u = hit_coords(0); - } else { - hit_u = hit_coords(0); - hit_v = hit_coords(1); - } - } else if (wire_hit) { - hit_u = fabs(hit_coords(0)); - hit_v = v*(track_pos-o); // move the covariance tube so that the track goes through it - if (wirepoint_hit) { - hit_v = hit_coords(1); - } - } - - if(plane_size < 4) plane_size = 4; - // finished setting variables --------------------------------------------------------- - - // draw planes if corresponding option is set ----------------------------------------- - if(iMeas == 0 && - (drawPlanes_ || (drawDetectors_ && planar_hit))) { - TVector3 move(0,0,0); - if (planar_hit) move = track_pos-o; - if (wire_hit) move = v*(v*(track_pos-o)); // move the plane along the wire until the track goes through it - TEveBox* box = boxCreator(o + move, u, v, plane_size, plane_size, 0.01); - if (drawDetectors_ && planar_hit) { - box->SetMainColor(kCyan); - } else { - box->SetMainColor(kGray); - } - box->SetMainTransparency(50); - gEve->AddElement(box); - } - // finished drawing planes ------------------------------------------------------------ - - // draw track if corresponding option is set ------------------------------------------ - if (j > 0 && prevFi != NULL) { - if(drawTrack_) { - makeLines(prevFittedState, fittedState, rep, charge > 0 ? kRed : kBlue, 1, drawTrackMarkers_, drawErrors_, 3); - if (drawErrors_) { // make sure to draw errors in both directions - makeLines(prevFittedState, fittedState, rep, charge > 0 ? kRed : kBlue, 1, false, drawErrors_, 0, 0); - } - } - if (drawForward_) - makeLines(prevFi->getForwardUpdate(), fi->getForwardPrediction(), rep, kCyan, 1, drawTrackMarkers_, drawErrors_, 1, 0); - if (drawBackward_) - makeLines(prevFi->getBackwardPrediction(), fi->getBackwardUpdate(), rep, kMagenta, 1, drawTrackMarkers_, drawErrors_, 1); - // draw reference track if corresponding option is set ------------------------------------------ - if(drawRefTrack_ && fi->hasReferenceState() && prevFi->hasReferenceState()) - makeLines(prevFi->getReferenceState(), fi->getReferenceState(), rep, charge > 0 ? kRed + 2 : kBlue + 2, 2, drawTrackMarkers_, false, 3); - } - else if (j > 0 && prevFi == NULL) { - std::cout << "previous FitterInfo == NULL \n"; - } - - // draw detectors if option is set, only important for wire hits ---------------------- - if(drawDetectors_) { - - if(wire_hit) { - TEveGeoShape* det_shape = new TEveGeoShape("det_shape"); - det_shape->IncDenyDestroy(); - det_shape->SetShape(new TGeoTube(std::max(0., (double)(hit_u-0.0105/2.)), hit_u+0.0105/2., plane_size)); - - TVector3 norm = u.Cross(v); - TGeoRotation det_rot("det_rot", (u.Theta()*180)/TMath::Pi(), (u.Phi()*180)/TMath::Pi(), - (norm.Theta()*180)/TMath::Pi(), (norm.Phi()*180)/TMath::Pi(), - (v.Theta()*180)/TMath::Pi(), (v.Phi()*180)/TMath::Pi()); // move the tube to the right place and rotate it correctly - TVector3 move = v*(v*(track_pos-o)); // move the tube along the wire until the track goes through it - TGeoCombiTrans det_trans(o(0) + move.X(), - o(1) + move.Y(), - o(2) + move.Z(), - &det_rot); - det_shape->SetTransMatrix(det_trans); - det_shape->SetMainColor(kCyan); - det_shape->SetMainTransparency(25); - if((drawHits_ && (hit_u+0.0105/2 > 0)) || !drawHits_) { - gEve->AddElement(det_shape); - } - } - - } - // finished drawing detectors --------------------------------------------------------- - - if(drawHits_) { - - // draw planar hits, with distinction between strip and pixel hits ---------------- - if (full_hit) { - - StateOnPlane dummy(rep); - StateOnPlane dummy2(TVectorD(rep->getDim()), static_cast(m)->constructPlane(dummy), rep); - MeasuredStateOnPlane sop = *(static_cast(m)->constructMeasurementsOnPlane(dummy2)[0]); - sop.getCov()*=errorScale_; - - MeasuredStateOnPlane prevSop(sop); - prevSop.extrapolateBy(-3); - makeLines(&sop, &prevSop, rep, kYellow, 1, false, true, 0, 0); - - prevSop = sop; - prevSop.extrapolateBy(3); - makeLines(&sop, &prevSop, rep, kYellow, 1, false, true, 0, 0); - } - - if(planar_hit) { - if(!planar_pixel_hit) { - TEveBox* hit_box; - TVector3 stripDir3 = stripDir.X()*u + stripDir.Y()*v; - TVector3 stripDir3perp = stripDir.Y()*u - stripDir.X()*v; - TVector3 move = stripDir3perp*(stripDir3perp*(track_pos-o)); - hit_box = boxCreator((o + move + hit_u*stripDir3), stripDir3, stripDir3perp, errorScale_*std::sqrt(hit_cov(0,0)), plane_size, 0.0105); - hit_box->SetMainColor(kYellow); - hit_box->SetMainTransparency(0); - gEve->AddElement(hit_box); - } else { - // calculate eigenvalues to draw error-ellipse ---------------------------- - TMatrixDEigen eigen_values(hit_cov); - TEveGeoShape* cov_shape = new TEveGeoShape("cov_shape"); - cov_shape->IncDenyDestroy(); - TMatrixT ev = eigen_values.GetEigenValues(); - TMatrixT eVec = eigen_values.GetEigenVectors(); - double pseudo_res_0 = errorScale_*std::sqrt(ev(0,0)); - double pseudo_res_1 = errorScale_*std::sqrt(ev(1,1)); - // finished calcluating, got the values ----------------------------------- - - // do autoscaling if necessary -------------------------------------------- - if(drawAutoScale_) { - double min_cov = std::min(pseudo_res_0,pseudo_res_1); - if(min_cov < 1e-5) { - std::cout << "Track " << i << ", Hit " << j << ": Invalid covariance matrix (Eigenvalue < 1e-5), autoscaling not possible!" << std::endl; - } else { - if(min_cov < 0.049) { - double cor = 0.05 / min_cov; - std::cout << "Track " << i << ", Hit " << j << ": Pixel covariance too small, rescaling by " << cor; - errorScale_ *= cor; - pseudo_res_0 *= cor; - pseudo_res_1 *= cor; - std::cout << " to " << errorScale_ << std::endl; - } - } - } - // finished autoscaling --------------------------------------------------- - - // calculate the semiaxis of the error ellipse ---------------------------- - cov_shape->SetShape(new TGeoEltu(pseudo_res_0, pseudo_res_1, 0.0105)); - TVector3 pix_pos = o + hit_u*u + hit_v*v; - TVector3 u_semiaxis = (pix_pos + eVec(0,0)*u + eVec(1,0)*v)-pix_pos; - TVector3 v_semiaxis = (pix_pos + eVec(0,1)*u + eVec(1,1)*v)-pix_pos; - TVector3 norm = u.Cross(v); - // finished calculating --------------------------------------------------- - - // rotate and translate everything correctly ------------------------------ - TGeoRotation det_rot("det_rot", (u_semiaxis.Theta()*180)/TMath::Pi(), (u_semiaxis.Phi()*180)/TMath::Pi(), - (v_semiaxis.Theta()*180)/TMath::Pi(), (v_semiaxis.Phi()*180)/TMath::Pi(), - (norm.Theta()*180)/TMath::Pi(), (norm.Phi()*180)/TMath::Pi()); - TGeoCombiTrans det_trans(pix_pos(0),pix_pos(1),pix_pos(2), &det_rot); - cov_shape->SetTransMatrix(det_trans); - // finished rotating and translating -------------------------------------- - - cov_shape->SetMainColor(kYellow); - cov_shape->SetMainTransparency(0); - gEve->AddElement(cov_shape); - } - } - // finished drawing planar hits --------------------------------------------------- - - // draw spacepoint hits ----------------------------------------------------------- - if(space_hit) { - { - // get eigenvalues of covariance to know how to draw the ellipsoid ------------ - TMatrixDEigen eigen_values(m->getRawHitCov()); - TEveGeoShape* cov_shape = new TEveGeoShape("cov_shape"); - cov_shape->IncDenyDestroy(); - cov_shape->SetShape(new TGeoSphere(0.,1.)); - TMatrixT ev = eigen_values.GetEigenValues(); - TMatrixT eVec = eigen_values.GetEigenVectors(); - TVector3 eVec1(eVec(0,0),eVec(1,0),eVec(2,0)); - TVector3 eVec2(eVec(0,1),eVec(1,1),eVec(2,1)); - TVector3 eVec3(eVec(0,2),eVec(1,2),eVec(2,2)); - const TVector3 norm = u.Cross(v); - // got everything we need ----------------------------------------------------- - - static const double radDeg(180./TMath::Pi()); - TGeoRotation det_rot("det_rot", eVec1.Theta()*radDeg, eVec1.Phi()*radDeg, - eVec2.Theta()*radDeg, eVec2.Phi()*radDeg, - eVec3.Theta()*radDeg, eVec3.Phi()*radDeg); - - if (! det_rot.IsValid()){ - // hackish fix if eigenvectors are not orthonogonal - if (fabs(eVec2*eVec3) > 1.e-10) - eVec3 = eVec1.Cross(eVec2); - - det_rot.SetAngles(eVec1.Theta()*radDeg, eVec1.Phi()*radDeg, - eVec2.Theta()*radDeg, eVec2.Phi()*radDeg, - eVec3.Theta()*radDeg, eVec3.Phi()*radDeg); - } - - // set the scaled eigenvalues ------------------------------------------------- - double pseudo_res_0 = errorScale_*std::sqrt(ev(0,0)); - double pseudo_res_1 = errorScale_*std::sqrt(ev(1,1)); - double pseudo_res_2 = errorScale_*std::sqrt(ev(2,2)); - if(drawScaleMan_) { // override again if necessary - pseudo_res_0 = errorScale_*0.5; - pseudo_res_1 = errorScale_*0.5; - pseudo_res_2 = errorScale_*0.5; - } - // finished scaling ----------------------------------------------------------- - - // autoscale if necessary ----------------------------------------------------- - if(drawAutoScale_) { - double min_cov = std::min(pseudo_res_0,std::min(pseudo_res_1,pseudo_res_2)); - if(min_cov < 1e-5) { - std::cout << "Track " << i << ", Hit " << j << ": Invalid covariance matrix (Eigenvalue < 1e-5), autoscaling not possible!" << std::endl; - } else { - if(min_cov <= 0.149) { - double cor = 0.15 / min_cov; - std::cout << "Track " << i << ", Hit " << j << ": Space hit covariance too small, rescaling by " << cor; - errorScale_ *= cor; - pseudo_res_0 *= cor; - pseudo_res_1 *= cor; - pseudo_res_2 *= cor; - std::cout << " to " << errorScale_ << std::endl; - - } - } - } - // finished autoscaling ------------------------------------------------------- - - // rotate and translate ------------------------------------------------------- - TGeoGenTrans det_trans(o(0),o(1),o(2), - //std::sqrt(pseudo_res_0/pseudo_res_1/pseudo_res_2), std::sqrt(pseudo_res_1/pseudo_res_0/pseudo_res_2), std::sqrt(pseudo_res_2/pseudo_res_0/pseudo_res_1), // this workaround is necessary due to the "normalization" performed in TGeoGenTrans::SetScale - //1/(pseudo_res_0),1/(pseudo_res_1),1/(pseudo_res_2), - pseudo_res_0, pseudo_res_1, pseudo_res_2, - &det_rot); - cov_shape->SetTransMatrix(det_trans); - // finished rotating and translating ------------------------------------------ - - cov_shape->SetMainColor(kYellow); - cov_shape->SetMainTransparency(10); - gEve->AddElement(cov_shape); - } - - - { - // calculate eigenvalues to draw error-ellipse ---------------------------- - TMatrixDEigen eigen_values(hit_cov); - TEveGeoShape* cov_shape = new TEveGeoShape("cov_shape"); - cov_shape->IncDenyDestroy(); - TMatrixT ev = eigen_values.GetEigenValues(); - TMatrixT eVec = eigen_values.GetEigenVectors(); - double pseudo_res_0 = errorScale_*std::sqrt(ev(0,0)); - double pseudo_res_1 = errorScale_*std::sqrt(ev(1,1)); - // finished calcluating, got the values ----------------------------------- - - // do autoscaling if necessary -------------------------------------------- - if(drawAutoScale_) { - double min_cov = std::min(pseudo_res_0,pseudo_res_1); - if(min_cov < 1e-5) { - std::cout << "Track " << i << ", Hit " << j << ": Invalid covariance matrix (Eigenvalue < 1e-5), autoscaling not possible!" << std::endl; - } else { - if(min_cov < 0.049) { - double cor = 0.05 / min_cov; - std::cout << "Track " << i << ", Hit " << j << ": Pixel covariance too small, rescaling by " << cor; - errorScale_ *= cor; - pseudo_res_0 *= cor; - pseudo_res_1 *= cor; - std::cout << " to " << errorScale_ << std::endl; - } - } - } - // finished autoscaling --------------------------------------------------- - - // calculate the semiaxis of the error ellipse ---------------------------- - cov_shape->SetShape(new TGeoEltu(pseudo_res_0, pseudo_res_1, 0.0105)); - TVector3 pix_pos = o + hit_u*u + hit_v*v; - TVector3 u_semiaxis = (pix_pos + eVec(0,0)*u + eVec(1,0)*v)-pix_pos; - TVector3 v_semiaxis = (pix_pos + eVec(0,1)*u + eVec(1,1)*v)-pix_pos; - TVector3 norm = u.Cross(v); - // finished calculating --------------------------------------------------- - - // rotate and translate everything correctly ------------------------------ - static const double radDeg(180./TMath::Pi()); - TGeoRotation det_rot("det_rot", u_semiaxis.Theta()*radDeg, u_semiaxis.Phi()*radDeg, - v_semiaxis.Theta()*radDeg, v_semiaxis.Phi()*radDeg, - norm.Theta()*radDeg, norm.Phi()*radDeg); - /*if (! det_rot.IsValid()){ - u_semiaxis.Print(); - v_semiaxis.Print(); - norm.Print(); - }*/ - TGeoCombiTrans det_trans(pix_pos(0),pix_pos(1),pix_pos(2), &det_rot); - cov_shape->SetTransMatrix(det_trans); - // finished rotating and translating -------------------------------------- - - cov_shape->SetMainColor(kYellow); - cov_shape->SetMainTransparency(0); - gEve->AddElement(cov_shape); - } - } - // finished drawing spacepoint hits ----------------------------------------------- - - // draw wire hits ----------------------------------------------------------------- - if(wire_hit) { - TEveGeoShape* cov_shape = new TEveGeoShape("cov_shape"); - cov_shape->IncDenyDestroy(); - double pseudo_res_0 = errorScale_*std::sqrt(hit_cov(0,0)); - double pseudo_res_1 = plane_size; - if (wirepoint_hit) pseudo_res_1 = errorScale_*std::sqrt(hit_cov(1,1)); - - // autoscale if necessary ----------------------------------------------------- - if(drawAutoScale_) { - if(pseudo_res_0 < 1e-5) { - std::cout << "Track " << i << ", Hit " << j << ": Invalid wire resolution (< 1e-5), autoscaling not possible!" << std::endl; - } else { - if(pseudo_res_0 < 0.0049) { - double cor = 0.005 / pseudo_res_0; - std::cout << "Track " << i << ", Hit " << j << ": Wire covariance too small, rescaling by " << cor; - errorScale_ *= cor; - pseudo_res_0 *= cor; - std::cout << " to " << errorScale_ << std::endl; - } - } - - if(wirepoint_hit && pseudo_res_1 < 1e-5) { - std::cout << "Track " << i << ", Hit " << j << ": Invalid wire resolution (< 1e-5), autoscaling not possible!" << std::endl; - } else { - if(pseudo_res_1 < 0.0049) { - double cor = 0.005 / pseudo_res_1; - std::cout << "Track " << i << ", Hit " << j << ": Wire covariance too small, rescaling by " << cor; - errorScale_ *= cor; - pseudo_res_1 *= cor; - std::cout << " to " << errorScale_ << std::endl; - } - } - } - // finished autoscaling ------------------------------------------------------- - - TEveBox* hit_box; - TVector3 move = v*(v*(track_pos-o)); - hit_box = boxCreator((o + move + hit_u*u), u, v, errorScale_*std::sqrt(hit_cov(0,0)), pseudo_res_1, 0.0105); - hit_box->SetMainColor(kYellow); - hit_box->SetMainTransparency(0); - gEve->AddElement(hit_box); - - hit_box = boxCreator((o + move - hit_u*u), u, v, errorScale_*std::sqrt(hit_cov(0,0)), pseudo_res_1, 0.0105); - hit_box->SetMainColor(kYellow); - hit_box->SetMainTransparency(0); - gEve->AddElement(hit_box); - } - // finished drawing wire hits ----------------------------------------------------- - - } // finished drawing hits - - } // finished looping over MeasurmentOnPlanes - - - prevFi = fi; - prevFittedState = fittedState; - - } - - } - - gEve->Redraw3D(resetCam); - -} - - - - -TEveBox* EventDisplay::boxCreator(TVector3 o, TVector3 u, TVector3 v, float ud, float vd, float depth) { - - TEveBox* box = new TEveBox("detPlane_shape"); - float vertices[24]; - - TVector3 norm = u.Cross(v); - u *= (0.5*ud); - v *= (0.5*vd); - norm *= (0.5*depth); - - vertices[0] = o(0) - u(0) - v(0) - norm(0); - vertices[1] = o(1) - u(1) - v(1) - norm(1); - vertices[2] = o(2) - u(2) - v(2) - norm(2); - - vertices[3] = o(0) + u(0) - v(0) - norm(0); - vertices[4] = o(1) + u(1) - v(1) - norm(1); - vertices[5] = o(2) + u(2) - v(2) - norm(2); - - vertices[6] = o(0) + u(0) - v(0) + norm(0); - vertices[7] = o(1) + u(1) - v(1) + norm(1); - vertices[8] = o(2) + u(2) - v(2) + norm(2); - - vertices[9] = o(0) - u(0) - v(0) + norm(0); - vertices[10] = o(1) - u(1) - v(1) + norm(1); - vertices[11] = o(2) - u(2) - v(2) + norm(2); - - vertices[12] = o(0) - u(0) + v(0) - norm(0); - vertices[13] = o(1) - u(1) + v(1) - norm(1); - vertices[14] = o(2) - u(2) + v(2) - norm(2); - - vertices[15] = o(0) + u(0) + v(0) - norm(0); - vertices[16] = o(1) + u(1) + v(1) - norm(1); - vertices[17] = o(2) + u(2) + v(2) - norm(2); - - vertices[18] = o(0) + u(0) + v(0) + norm(0); - vertices[19] = o(1) + u(1) + v(1) + norm(1); - vertices[20] = o(2) + u(2) + v(2) + norm(2); - - vertices[21] = o(0) - u(0) + v(0) + norm(0); - vertices[22] = o(1) - u(1) + v(1) + norm(1); - vertices[23] = o(2) - u(2) + v(2) + norm(2); - - - for(int k = 0; k < 24; k += 3) box->SetVertex((k/3), vertices[k], vertices[k+1], vertices[k+2]); - - return box; - -} - - -void EventDisplay::makeLines(const StateOnPlane* prevState, const StateOnPlane* state, const AbsTrackRep* rep, - const Color_t& color, const Style_t& style, bool drawMarkers, bool drawErrors, double lineWidth, int markerPos) -{ - if (prevState == NULL || state == NULL) { - std::cerr << "prevState == NULL || state == NULL\n"; - return; - } - - TVector3 pos, dir, oldPos, oldDir; - rep->getPosDir(*state, pos, dir); - rep->getPosDir(*prevState, oldPos, oldDir); - - double distA = (pos-oldPos).Mag(); - double distB = distA; - if ((pos-oldPos)*oldDir < 0) - distA *= -1.; - if ((pos-oldPos)*dir < 0) - distB *= -1.; - TVector3 intermediate1 = oldPos + 0.3 * distA * oldDir; - TVector3 intermediate2 = pos - 0.3 * distB * dir; - TEveStraightLineSet* lineSet = new TEveStraightLineSet; - lineSet->AddLine(oldPos(0), oldPos(1), oldPos(2), intermediate1(0), intermediate1(1), intermediate1(2)); - lineSet->AddLine(intermediate1(0), intermediate1(1), intermediate1(2), intermediate2(0), intermediate2(1), intermediate2(2)); - lineSet->AddLine(intermediate2(0), intermediate2(1), intermediate2(2), pos(0), pos(1), pos(2)); - lineSet->SetLineColor(color); - lineSet->SetLineStyle(style); - lineSet->SetLineWidth(lineWidth); - if (drawMarkers) { - if (markerPos == 0) - lineSet->AddMarker(oldPos(0), oldPos(1), oldPos(2)); - else - lineSet->AddMarker(pos(0), pos(1), pos(2)); - } - - if (lineWidth > 0) - gEve->AddElement(lineSet); - - - if (drawErrors) { - const MeasuredStateOnPlane* measuredState; - if (markerPos == 0) - measuredState = dynamic_cast(prevState); - else - measuredState = dynamic_cast(state); - - if (measuredState != NULL) { - - // step for evaluate at a distance from the original plane - TVector3 eval; - if (markerPos == 0) { - if (fabs(distA) < 1.) { - distA < 0 ? distA = -1 : distA = 1; - } - eval = 0.2 * distA * oldDir; - } - else { - if (fabs(distB) < 1.) { - distB < 0 ? distB = -1 : distB = 1; - } - eval = -0.2 * distB * dir; - } - - - // get cov at first plane - TMatrixDSym cov; - TVector3 position, direction; - rep->getPosMomCov(*measuredState, position, direction, cov); - - // get eigenvalues & -vectors - TMatrixDEigen eigen_values(cov.GetSub(0,2, 0,2)); - TMatrixT ev = eigen_values.GetEigenValues(); - TMatrixT eVec = eigen_values.GetEigenVectors(); - TVector3 eVec1, eVec2; - // limit - static const double maxErr = 1000.; - double ev0 = std::min(ev(0,0), maxErr); - double ev1 = std::min(ev(1,1), maxErr); - double ev2 = std::min(ev(2,2), maxErr); - - // get two largest eigenvalues/-vectors - if (ev0 < ev1 && ev0 < ev2) { - eVec1.SetXYZ(eVec(0,1),eVec(1,1),eVec(2,1)); - eVec1 *= sqrt(ev1); - eVec2.SetXYZ(eVec(0,2),eVec(1,2),eVec(2,2)); - eVec2 *= sqrt(ev2); - } - else if (ev1 < ev0 && ev1 < ev2) { - eVec1.SetXYZ(eVec(0,0),eVec(1,0),eVec(2,0)); - eVec1 *= sqrt(ev0); - eVec2.SetXYZ(eVec(0,2),eVec(1,2),eVec(2,2)); - eVec2 *= sqrt(ev2); - } - else { - eVec1.SetXYZ(eVec(0,0),eVec(1,0),eVec(2,0)); - eVec1 *= sqrt(ev0); - eVec2.SetXYZ(eVec(0,1),eVec(1,1),eVec(2,1)); - eVec2 *= sqrt(ev1); - } - - if (eVec1.Cross(eVec2)*eval < 0) - eVec2 *= -1; - //assert(eVec1.Cross(eVec2)*eval > 0); - - const TVector3 oldEVec1(eVec1); - const TVector3 oldEVec2(eVec2); - - const int nEdges = 24; - std::vector vertices; - - vertices.push_back(position); - - // vertices at plane - for (int i=0; igetPlane())); - newPlane->setO(position + eval); - - MeasuredStateOnPlane stateCopy(*measuredState); - try{ - rep->extrapolateToPlane(stateCopy, SharedPlanePtr(newPlane)); - } - catch(Exception& e){ - std::cerr<getPosMomCov(stateCopy, position, direction, cov); - - // get eigenvalues & -vectors - TMatrixDEigen eigen_values2(cov.GetSub(0,2, 0,2)); - ev = eigen_values2.GetEigenValues(); - eVec = eigen_values2.GetEigenVectors(); - // limit - ev0 = std::min(ev(0,0), maxErr); - ev1 = std::min(ev(1,1), maxErr); - ev2 = std::min(ev(2,2), maxErr); - - // get two largest eigenvalues/-vectors - if (ev0 < ev1 && ev0 < ev2) { - eVec1.SetXYZ(eVec(0,1),eVec(1,1),eVec(2,1)); - eVec1 *= sqrt(ev1); - eVec2.SetXYZ(eVec(0,2),eVec(1,2),eVec(2,2)); - eVec2 *= sqrt(ev2); - } - else if (ev1 < ev0 && ev1 < ev2) { - eVec1.SetXYZ(eVec(0,0),eVec(1,0),eVec(2,0)); - eVec1 *= sqrt(ev0); - eVec2.SetXYZ(eVec(0,2),eVec(1,2),eVec(2,2)); - eVec2 *= sqrt(ev2); - } - else { - eVec1.SetXYZ(eVec(0,0),eVec(1,0),eVec(2,0)); - eVec1 *= sqrt(ev0); - eVec2.SetXYZ(eVec(0,1),eVec(1,1),eVec(2,1)); - eVec2 *= sqrt(ev1); - } - - if (eVec1.Cross(eVec2)*eval < 0) - eVec2 *= -1; - //assert(eVec1.Cross(eVec2)*eval > 0); - - if (oldEVec1*eVec1 < 0) { - eVec1 *= -1; - eVec2 *= -1; - } - - // vertices at 2nd plane - double angle0 = eVec1.Angle(oldEVec1); - if (eVec1*(eval.Cross(oldEVec1)) < 0) - angle0 *= -1; - for (int i=0; iSetVertex(k, vertices[k].X(), vertices[k].Y(), vertices[k].Z()); - } - - assert(vertices.size() == 2*nEdges+2); - - int iTri(0); - for (int i=0; iSetTriangle(iTri++, 0, i+1, (i+1)%nEdges+1); - error_shape->SetTriangle(iTri++, i+1, i+1+nEdges, (i+1)%nEdges+1); - error_shape->SetTriangle(iTri++, (i+1)%nEdges+1, i+1+nEdges, (i+1)%nEdges+1+nEdges); - //error_shape->SetTriangle(iTri++, 2*nEdges+1, i+1+nEdges, (i+1)%nEdges+1+nEdges); - } - - //assert(iTri == nEdges*4); - - error_shape->SetMainColor(color); - error_shape->SetMainTransparency(25); - gEve->AddElement(error_shape); - } - } -} - - -void EventDisplay::makeGui() { - - TEveBrowser* browser = gEve->GetBrowser(); - browser->StartEmbedding(TRootBrowser::kLeft); - - TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600); - frmMain->SetWindowName("XX GUI"); - frmMain->SetCleanup(kDeepCleanup); - - TGLabel* lbl = 0; - TGTextButton* tb = 0; - EventDisplay* fh = EventDisplay::getInstance(); - - TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain); { - // evt number entry - lbl = new TGLabel(hf, "Go to event: "); - hf->AddFrame(lbl); - guiEvent = new TGNumberEntry(hf, 0, 9,999, TGNumberFormat::kNESInteger, - TGNumberFormat::kNEANonNegative, - TGNumberFormat::kNELLimitMinMax, - 0, 99999); - hf->AddFrame(guiEvent); - guiEvent->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiGoto()"); - - // redraw button - tb = new TGTextButton(hf, "Redraw Event"); - hf->AddFrame(tb); - tb->Connect("Clicked()", "genfit::EventDisplay", fh, "guiGoto()"); - } - frmMain->AddFrame(hf); - - // draw options - hf = new TGHorizontalFrame(frmMain); { - lbl = new TGLabel(hf, "\n Draw Options"); - hf->AddFrame(lbl); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawGeometry_ = new TGCheckButton(hf, "Draw geometry"); - if(drawGeometry_) guiDrawGeometry_->Toggle(); - hf->AddFrame(guiDrawGeometry_); - guiDrawGeometry_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawDetectors_ = new TGCheckButton(hf, "Draw detectors"); - if(drawDetectors_) guiDrawDetectors_->Toggle(); - hf->AddFrame(guiDrawDetectors_); - guiDrawDetectors_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawHits_ = new TGCheckButton(hf, "Draw hits"); - if(drawHits_) guiDrawHits_->Toggle(); - hf->AddFrame(guiDrawHits_); - guiDrawHits_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - - - hf = new TGHorizontalFrame(frmMain); { - guiDrawPlanes_ = new TGCheckButton(hf, "Draw planes"); - if(drawPlanes_) guiDrawPlanes_->Toggle(); - hf->AddFrame(guiDrawPlanes_); - guiDrawPlanes_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawTrackMarkers_ = new TGCheckButton(hf, "Draw track markers"); - if(drawTrackMarkers_) guiDrawTrackMarkers_->Toggle(); - hf->AddFrame(guiDrawTrackMarkers_); - guiDrawTrackMarkers_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - - hf = new TGHorizontalFrame(frmMain); { - guiDrawTrack_ = new TGCheckButton(hf, "Draw track"); - if(drawTrack_) guiDrawTrack_->Toggle(); - hf->AddFrame(guiDrawTrack_); - guiDrawTrack_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawRefTrack_ = new TGCheckButton(hf, "Draw reference track"); - if(drawRefTrack_) guiDrawRefTrack_->Toggle(); - hf->AddFrame(guiDrawRefTrack_); - guiDrawRefTrack_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawErrors_ = new TGCheckButton(hf, "Draw track errors"); - if(drawErrors_) guiDrawErrors_->Toggle(); - hf->AddFrame(guiDrawErrors_); - guiDrawErrors_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawForward_ = new TGCheckButton(hf, "Draw forward fit"); - if(drawForward_) guiDrawForward_->Toggle(); - hf->AddFrame(guiDrawForward_); - guiDrawForward_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawBackward_ = new TGCheckButton(hf, "Draw backward fit"); - if(drawBackward_) guiDrawBackward_->Toggle(); - hf->AddFrame(guiDrawBackward_); - guiDrawBackward_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - - hf = new TGHorizontalFrame(frmMain); { - guiDrawAutoScale_ = new TGCheckButton(hf, "Auto-scale errors"); - if(drawAutoScale_) guiDrawAutoScale_->Toggle(); - hf->AddFrame(guiDrawAutoScale_); - guiDrawAutoScale_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawScaleMan_ = new TGCheckButton(hf, "Manually scale errors"); - if(drawScaleMan_) guiDrawScaleMan_->Toggle(); - hf->AddFrame(guiDrawScaleMan_); - guiDrawScaleMan_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiErrorScale_ = new TGNumberEntry(hf, errorScale_, 6,999, TGNumberFormat::kNESReal, - TGNumberFormat::kNEANonNegative, - TGNumberFormat::kNELLimitMinMax, - 1.E-4, 1.E5); - hf->AddFrame(guiErrorScale_); - guiErrorScale_->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - lbl = new TGLabel(hf, "Error scale"); - hf->AddFrame(lbl); - } - frmMain->AddFrame(hf); - - - - hf = new TGHorizontalFrame(frmMain); { - lbl = new TGLabel(hf, "\n TrackRep options"); - hf->AddFrame(lbl); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawCardinalRep_ = new TGCheckButton(hf, "Draw cardinal rep"); - if(drawCardinalRep_) guiDrawCardinalRep_->Toggle(); - hf->AddFrame(guiDrawCardinalRep_); - guiDrawCardinalRep_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiRepId_ = new TGNumberEntry(hf, repId_, 6,999, TGNumberFormat::kNESInteger, - TGNumberFormat::kNEANonNegative, - TGNumberFormat::kNELLimitMinMax, - 0, 99); - hf->AddFrame(guiRepId_); - guiRepId_->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - lbl = new TGLabel(hf, "Else draw rep with id"); - hf->AddFrame(lbl); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiDrawAllTracks_ = new TGCheckButton(hf, "Draw all tracks"); - if(drawAllTracks_) guiDrawAllTracks_->Toggle(); - hf->AddFrame(guiDrawAllTracks_); - guiDrawAllTracks_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain); { - guiTrackId_ = new TGNumberEntry(hf, trackId_, 6,999, TGNumberFormat::kNESInteger, - TGNumberFormat::kNEANonNegative, - TGNumberFormat::kNELLimitMinMax, - 0, 99); - hf->AddFrame(guiTrackId_); - guiTrackId_->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - lbl = new TGLabel(hf, "Else draw track nr. "); - hf->AddFrame(lbl); - } - frmMain->AddFrame(hf); - - - - frmMain->MapSubwindows(); - frmMain->Resize(); - frmMain->MapWindow(); - - browser->StopEmbedding(); - browser->SetTabTitle("Draw Control", 0); - - - browser->StartEmbedding(TRootBrowser::kLeft); - TGMainFrame* frmMain2 = new TGMainFrame(gClient->GetRoot(), 1000, 600); - frmMain2->SetWindowName("XX GUI"); - frmMain2->SetCleanup(kDeepCleanup); - - hf = new TGHorizontalFrame(frmMain2); { - // evt number entry - lbl = new TGLabel(hf, "Go to event: "); - hf->AddFrame(lbl); - guiEvent2 = new TGNumberEntry(hf, 0, 9,999, TGNumberFormat::kNESInteger, - TGNumberFormat::kNEANonNegative, - TGNumberFormat::kNELLimitMinMax, - 0, 99999); - hf->AddFrame(guiEvent2); - guiEvent2->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiGoto2()"); - - // redraw button - tb = new TGTextButton(hf, "Redraw Event"); - hf->AddFrame(tb); - tb->Connect("Clicked()", "genfit::EventDisplay", fh, "guiGoto()"); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - lbl = new TGLabel(hf, "\n Fitting options"); - hf->AddFrame(lbl); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - guiRefit_ = new TGCheckButton(hf, "Refit"); - if(refit_) guiRefit_->Toggle(); - hf->AddFrame(guiRefit_); - guiRefit_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - guiDebugLvl_ = new TGNumberEntry(hf, debugLvl_, 6,999, TGNumberFormat::kNESInteger, - TGNumberFormat::kNEANonNegative, - TGNumberFormat::kNELLimitMinMax, - 0, 999); - hf->AddFrame(guiDebugLvl_); - guiDebugLvl_->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - lbl = new TGLabel(hf, "debug level"); - hf->AddFrame(lbl); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - guiFitterId_ = new TGButtonGroup(hf,"Fitter type:"); - guiFitterId_->Connect("Clicked(Int_t)","genfit::EventDisplay", fh, "guiSelectFitterId(int)"); - hf->AddFrame(guiFitterId_, new TGLayoutHints(kLHintsTop)); - TGRadioButton* fitterId_button = new TGRadioButton(guiFitterId_, "Simple Kalman"); - new TGRadioButton(guiFitterId_, "Reference Kalman"); - new TGRadioButton(guiFitterId_, "DAF w/ simple Kalman"); - new TGRadioButton(guiFitterId_, "DAF w/ reference Kalman"); - fitterId_button->SetDown(true, false); - guiFitterId_->Show(); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - guiMmHandling_ = new TGButtonGroup(hf,"Multiple measurement handling in Kalman:"); - guiMmHandling_->Connect("Clicked(Int_t)","genfit::EventDisplay", fh, "guiSelectMmHandling(int)"); - hf->AddFrame(guiMmHandling_, new TGLayoutHints(kLHintsTop)); - TGRadioButton* mmHandling_button = new TGRadioButton(guiMmHandling_, "weighted average"); - new TGRadioButton(guiMmHandling_, "unweighted average"); - new TGRadioButton(guiMmHandling_, "weighted, closest to reference"); - new TGRadioButton(guiMmHandling_, "unweighted, closest to reference"); - new TGRadioButton(guiMmHandling_, "weighted, closest to prediction"); - new TGRadioButton(guiMmHandling_, "unweighted, closest to prediction"); - new TGRadioButton(guiMmHandling_, "weighted, closest to reference for WireMeasurements, weighted average else"); - new TGRadioButton(guiMmHandling_, "unweighted, closest to reference for WireMeasurements, unweighted average else"); - new TGRadioButton(guiMmHandling_, "weighted, closest to prediction for WireMeasurements, weighted average else"); - new TGRadioButton(guiMmHandling_, "unweighted, closest to prediction for WireMeasurements, unweighted average else"); - mmHandling_button->SetDown(true, false); - guiMmHandling_->Show(); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - guiSquareRootFormalism_ = new TGCheckButton(hf, "Use square root formalism (simple Kalman/simple DAF)"); - if(squareRootFormalism_) guiSquareRootFormalism_->Toggle(); - hf->AddFrame(guiSquareRootFormalism_); - guiSquareRootFormalism_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - guiDPVal_ = new TGNumberEntry(hf, dPVal_, 6,9999, TGNumberFormat::kNESReal, - TGNumberFormat::kNEANonNegative, - TGNumberFormat::kNELLimitMinMax, - 0, 999); - hf->AddFrame(guiDPVal_); - guiDPVal_->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - lbl = new TGLabel(hf, "delta pVal (convergence criterium)"); - hf->AddFrame(lbl); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - guiRelChi2_ = new TGNumberEntry(hf, dRelChi2_, 6,9999, TGNumberFormat::kNESReal, - TGNumberFormat::kNEANonNegative, - TGNumberFormat::kNELLimitMinMax, - 0, 999); - hf->AddFrame(guiRelChi2_); - guiRelChi2_->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - lbl = new TGLabel(hf, "rel chi^2 change (non-convergence criterium)"); - hf->AddFrame(lbl); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - guiNMinIter_ = new TGNumberEntry(hf, nMinIter_, 6,999, TGNumberFormat::kNESInteger, - TGNumberFormat::kNEANonNegative, - TGNumberFormat::kNELLimitMinMax, - 1, 100); - hf->AddFrame(guiNMinIter_); - guiNMinIter_->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - lbl = new TGLabel(hf, "Minimum nr of iterations"); - hf->AddFrame(lbl); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - guiNMaxIter_ = new TGNumberEntry(hf, nMaxIter_, 6,999, TGNumberFormat::kNESInteger, - TGNumberFormat::kNEANonNegative, - TGNumberFormat::kNELLimitMinMax, - 1, 100); - hf->AddFrame(guiNMaxIter_); - guiNMaxIter_->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - lbl = new TGLabel(hf, "Maximum nr of iterations"); - hf->AddFrame(lbl); - } - frmMain2->AddFrame(hf); - - hf = new TGHorizontalFrame(frmMain2); { - guiNMaxFailed_ = new TGNumberEntry(hf, nMaxFailed_, 6,999, TGNumberFormat::kNESInteger, - TGNumberFormat::kNEAAnyNumber, - TGNumberFormat::kNELLimitMinMax, - -1, 1000); - hf->AddFrame(guiNMaxFailed_); - guiNMaxFailed_->Connect("ValueSet(Long_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - lbl = new TGLabel(hf, "Maximum nr of failed hits"); - hf->AddFrame(lbl); - } - frmMain2->AddFrame(hf); - - - hf = new TGHorizontalFrame(frmMain2); { - guiResort_ = new TGCheckButton(hf, "Resort track"); - if(resort_) guiResort_->Toggle(); - hf->AddFrame(guiResort_); - guiResort_->Connect("Toggled(Bool_t)", "genfit::EventDisplay", fh, "guiSetDrawParams()"); - } - frmMain2->AddFrame(hf); - - - - - frmMain2->MapSubwindows(); - frmMain2->Resize(); - frmMain2->MapWindow(); - - browser->StopEmbedding(); - browser->SetTabTitle("Refit Control", 0); -} - - -void EventDisplay::guiGoto(){ - Long_t n = guiEvent->GetNumberEntry()->GetIntNumber(); - guiEvent2->SetIntNumber(n); - gotoEvent(n); -} - -void EventDisplay::guiGoto2(){ - Long_t n = guiEvent2->GetNumberEntry()->GetIntNumber(); - guiEvent->SetIntNumber(n); - gotoEvent(n); -} - - -void EventDisplay::guiSetDrawParams(){ - - drawGeometry_ = guiDrawGeometry_->IsOn(); - drawDetectors_ = guiDrawDetectors_->IsOn(); - drawHits_ = guiDrawHits_->IsOn(); - drawErrors_ = guiDrawErrors_->IsOn(); - - drawPlanes_ = guiDrawPlanes_->IsOn(); - drawTrackMarkers_ = guiDrawTrackMarkers_->IsOn(); - drawTrack_ = guiDrawTrack_->IsOn(); - drawRefTrack_ = guiDrawRefTrack_->IsOn(); - drawForward_ = guiDrawForward_->IsOn(); - drawBackward_ = guiDrawBackward_->IsOn(); - - drawAutoScale_ = guiDrawAutoScale_->IsOn(); - drawScaleMan_ = guiDrawScaleMan_->IsOn(); - - errorScale_ = guiErrorScale_->GetNumberEntry()->GetNumber(); - - drawCardinalRep_ = guiDrawCardinalRep_->IsOn(); - repId_ = guiRepId_->GetNumberEntry()->GetNumber(); - - drawAllTracks_ = guiDrawAllTracks_->IsOn(); - trackId_ = guiTrackId_->GetNumberEntry()->GetNumber(); - - - refit_ = guiRefit_->IsOn(); - debugLvl_ = guiDebugLvl_->GetNumberEntry()->GetNumber(); - - squareRootFormalism_ = guiSquareRootFormalism_->IsOn(); - dPVal_ = guiDPVal_->GetNumberEntry()->GetNumber(); - dRelChi2_ = guiRelChi2_->GetNumberEntry()->GetNumber(); - nMinIter_ = guiNMinIter_->GetNumberEntry()->GetNumber(); - nMaxIter_ = guiNMaxIter_->GetNumberEntry()->GetNumber(); - nMaxFailed_ = guiNMaxFailed_->GetNumberEntry()->GetNumber(); - resort_ = guiResort_->IsOn(); - - gotoEvent(eventId_); -} - - -void EventDisplay::guiSelectFitterId(int val){ - fitterId_ = eFitterType(val-1); - gotoEvent(eventId_); -} - -void EventDisplay::guiSelectMmHandling(int val){ - mmHandling_ = eMultipleMeasurementHandling(val-1); - gotoEvent(eventId_); -} - - -} // end of namespace genfit diff --git a/genfit/eventDisplay/src/eventDisplayLinkDef.h b/genfit/eventDisplay/src/eventDisplayLinkDef.h deleted file mode 100644 index 6204f3e828..0000000000 --- a/genfit/eventDisplay/src/eventDisplayLinkDef.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -// These need no special treatment. -#pragma link C++ class genfit::EventDisplay+; - -#endif diff --git a/genfit/fields/include/BellField.h b/genfit/fields/include/BellField.h deleted file mode 100644 index 5dd5bedb54..0000000000 --- a/genfit/fields/include/BellField.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_BellField_h -#define genfit_BellField_h - -#include "AbsBField.h" - - -namespace genfit { - -/** @brief Bell Field for SHiP - * - * @author Thomas Ruf CERN - */ -class BellField : public AbsBField { - public: - - /** Default constructor **/ - BellField(); - - /** Standard constructor **/ - BellField(double Peak, double Middle,int orientation, double Btube); - - - //! return value at position - TVector3 get(const TVector3& pos) const; - void get(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz) const; - - private: - double fMiddle; - double fPeak; - int fOrient; - double fBtube; - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_BellField_h diff --git a/genfit/fields/include/ConstField.h b/genfit/fields/include/ConstField.h deleted file mode 100644 index b06918d964..0000000000 --- a/genfit/fields/include/ConstField.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_ConstField_h -#define genfit_ConstField_h - -#include "AbsBField.h" - - -namespace genfit { - -/** @brief Constant Magnetic field - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * - */ -class ConstField : public AbsBField { - public: - //! define the constant field in this ctor - ConstField(double b1, double b2, double b3) - : field_(b1, b2, b3) - { ; } - - ConstField(const TVector3& field) - : field_(field) - { ; } - - //! return value at position - TVector3 get(const TVector3& pos) const; - void get(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz) const; - - private: - TVector3 field_; -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_ConstField_h diff --git a/genfit/fields/include/GoliathField.h b/genfit/fields/include/GoliathField.h deleted file mode 100644 index d80f74efdc..0000000000 --- a/genfit/fields/include/GoliathField.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_GoliathField_h -#define genfit_GoliathField_h - -#include "AbsBField.h" - - -namespace genfit { - -/** @brief Constant Magnetic field - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * - */ -class GoliathField : public AbsBField { - public: - //! define the constant field in this ctor - GoliathField(double b1, double b2, double b3) - : field_(b1, b2, b3) - { ; } - - GoliathField(const TVector3& field) - : field_(field) - { ; } - Float_t coords[13][6]; - - - //! return value at position - TVector3 get(const TVector3& pos) const; - void get(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz) const; - void getpos(TString vol, TVector3 &bot, TVector3 &top) const; - void setup(); - - private: - TVector3 field_; -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_GoliathField_h diff --git a/genfit/fields/src/BellField.cc b/genfit/fields/src/BellField.cc deleted file mode 100644 index 33553452e7..0000000000 --- a/genfit/fields/src/BellField.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -#include "BellField.h" -#include "math.h" -#include -using std::cout; -using std::endl; -Double_t kilogauss = 1.; -Double_t tesla = 10*kilogauss; -Double_t cm = 1; // cm -Double_t meter = 100*cm; // m -Double_t mm = 0.1*cm; // mm - -// implementation of Bellshape field for Ship -namespace genfit { - - BellField::BellField() - : AbsBField(), - fMiddle(0),fPeak(0) - { ; } - BellField::BellField(double Peak, double Middle,int orientation, double Btube ) - : AbsBField(), - fMiddle(Middle),fPeak(Peak),fOrient(orientation),fBtube(Btube) - { ; } - -TVector3 BellField::get(const TVector3& pos) const { - Double_t bx,by,bz; - get(pos.X(),pos.Y(),pos.Z(),bx,by,bz); - TVector3 field_(bx,by,bz); - return field_; -} - -void BellField::get(const double& x, const double& y, const double& z, double& Bx, double& By, double& Bz) const { - Double_t zlocal=fabs((z-fMiddle)/100.); - Bz = 0.; - By = 0.; - Bx = 0.; - if (fOrient==1){ By = fPeak/(1.+pow(fabs(zlocal)/2.1,6.));} - if (fOrient==2){ - //new field based on simulation of Davide Tommasini (22/1/2015) - - //field in box 20 cm larger than inner tube. - if ( (fabs(x)<2.7*meter) && (fabs(y). - - This file should stay in sync with charmdet/MuonfluxSpectrometer.cxx and charmdet/Spectrometer.cxx. - It is used for fitting reconstructed tracks. After instantiating in shipDigiReco.py call setup(): - - self.bfield = ROOT.genfit.GoliathField(0 ,1.*u.tesla,0) - self.bfield.setup() - - Contact EvH for help if necessary. -*/ -#include "GoliathField.h" -#include "TGeoNavigator.h" -#include "TGeoNode.h" -#include "TGeoManager.h" -#include "TGeoBBox.h" -#include "TVector3.h" - -#include // for NULL -#include // for operator<<, basic_ostream, etc - -using std::cout; -using std::endl; -using std::vector; - -namespace genfit { - -TVector3 GoliathField::get(const TVector3&) const { - return field_; -} - -void GoliathField::get(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz) const { - Bx=0.;By=0.;Bz=0.; - if ((posX < coords[0][0]) && (posX > coords[0][3]) && (posY < coords[0][1]) && (posY > coords[0][4]) && (posZ < coords[0][2]+5.) && (posZ>coords[0][5]+5.) ) { - Bx = field_.X(); - By = field_.Y(); - Bz = field_.Z(); - } - else { - for (Int_t i=1;i<13;i++){ - if ((posX < coords[i][0]) && (posX > coords[i][3]) && (posY < coords[i][1]) && (posY > coords[i][4]) && (posZ < coords[i][2]) && (posZ>coords[i][5])) { - Bx = 0.; - By = -10.; - Bz = 0.; - break; - } - } - } -} - - -void GoliathField::getpos(TString volname, TVector3 &vbot, TVector3 &vtop) const { - TGeoNavigator* nav = gGeoManager->GetCurrentNavigator(); - Bool_t rc = nav->cd(volname); - if (not rc){ - cout << "Goliathfield::getpos, TGeoNavigator failed "<GetCurrentNode(); - TGeoBBox* S = dynamic_cast(W->GetVolume()->GetShape()); - Double_t top[3] = {S->GetDX(),S->GetDY(),S->GetDZ()}; - Double_t bot[3] = {-S->GetDX(),-S->GetDY(),-S->GetDZ()}; - Double_t Gtop[3],Gbot[3]; - nav->LocalToMaster(top, Gtop); - nav->LocalToMaster(bot, Gbot); - vtop.SetXYZ(Gtop[0],Gtop[1],Gtop[2]); - vbot.SetXYZ(Gbot[0],Gbot[1],Gbot[2]); -} - -void GoliathField::setup(){ - TVector3 bot,top; - std::vector volume={"/volGoliath_1/VolVacuum_1","/volGoliath_1/volLateralS1_1","/volGoliath_1/volLateralS2_1","/volGoliath_1/volLateralSurface1low_1", - "/volGoliath_1/volLateralSurface2low_1","/volGoliath_1/volLateralS1_b_1","/volGoliath_1/volLateralS2_b_1","/volGoliath_1/volLateralSurface1blow_1", - "/volGoliath_1/volLateralSurface2blow_1","/volGoliath_1/volLateralS1_d_1","/volGoliath_1/volLateralS2_d_1","/volGoliath_1/volLateralS1_c_1", - "/volGoliath_1/volLateralS2_c_1"}; - for (Int_t i=0;i<13;i++){ - getpos(volume[i],bot,top); - for (Int_t j=0;j<3;j++) { - coords[i][j]=top[j]; - coords[i][j+3]=bot[j]; - } - //std::cout<. -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_RectangularFinitePlane_h -#define genfit_RectangularFinitePlane_h - -#include "AbsFinitePlane.h" - - -namespace genfit { - -/** - * @brief Rectangular finite plane. - */ -class RectangularFinitePlane : public AbsFinitePlane { - - public: - - //! give dimensions of finite rectangle: u1,u2, v1,v2 - RectangularFinitePlane(const double&, const double&, const double&, const double&); - RectangularFinitePlane(); - virtual ~RectangularFinitePlane(); - - //override inActive & Print methods - bool isInActive(double u, double v) const; - void Print(const Option_t* = "") const; - - RectangularFinitePlane* clone() const { - return new RectangularFinitePlane(*this); - } - - private: - - double uMin_, uMax_, vMin_, vMax_; - - public: - - ClassDef(RectangularFinitePlane,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_RectangularFinitePlane_h diff --git a/genfit/finitePlanes/src/RectangularFinitePlane.cc b/genfit/finitePlanes/src/RectangularFinitePlane.cc deleted file mode 100644 index 659c7cd3b8..0000000000 --- a/genfit/finitePlanes/src/RectangularFinitePlane.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include -#include - -#include "RectangularFinitePlane.h" - -namespace genfit { - -RectangularFinitePlane::RectangularFinitePlane(const double& umin,const double& umax, - const double& vmin,const double& vmax) - : uMin_(umin),uMax_(umax),vMin_(vmin),vMax_(vmax) -{ - assert(umin=uMin_ && u<=uMax_ && v>=vMin_ && v<=vMax_); -} - -void RectangularFinitePlane::Print(const Option_t*) const{ - std::cout << "Rectangular Finite Plane Umin=" << uMin_ << ", Umax=" - << uMax_ << ", Vmin=" << vMin_ << ", Vmax=" << vMax_ << std::endl; -} - -} /* End of namespace genfit */ diff --git a/genfit/fitters/include/AbsKalmanFitter.h b/genfit/fitters/include/AbsKalmanFitter.h deleted file mode 100644 index 026b3e3ddb..0000000000 --- a/genfit/fitters/include/AbsKalmanFitter.h +++ /dev/null @@ -1,155 +0,0 @@ -/* Copyright 2013, Ludwig-Maximilians Universität München, - Authors: Tobias Schlüter & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_AbsKalmanFitter_h -#define genfit_AbsKalmanFitter_h - -#include "AbsFitter.h" -#include "MeasurementOnPlane.h" -#include "TrackPoint.h" - - -namespace genfit { - -class KalmanFitterInfo; - -enum eMultipleMeasurementHandling { - weightedAverage, /**< weighted average between measurements; used by DAF */ - unweightedAverage, /**< average between measurements, all weighted with 1 */ - weightedClosestToReference, /**< closest to reference, weighted with its weight_ */ - unweightedClosestToReference, /**< closest to reference, weighted with 1 */ - weightedClosestToPrediction, /**< closest to prediction, weighted with its weight_ */ - unweightedClosestToPrediction, /**< closest to prediction, weighted with 1 */ - weightedClosestToReferenceWire, /**< if corresponding TrackPoint has one WireMeasurement, select closest to reference, weighted with its weight_. Otherwise use weightedAverage. */ - unweightedClosestToReferenceWire, /**< if corresponding TrackPoint has one WireMeasurement, select closest to reference, weighted with 1. Otherwise use unweightedAverage. */ - weightedClosestToPredictionWire, /**< if corresponding TrackPoint has one WireMeasurement, select closest to prediction, weighted with its weight_. Otherwise use weightedAverage. */ - unweightedClosestToPredictionWire /**< if corresponding TrackPoint has one WireMeasurement, select closest to prediction, weighted with 1. Otherwise use unweightedAverage. Recommended for KalmanFitter to 'resolve' l/r ambiguities */ -}; - -/** - * @brief Abstract base class for Kalman fitter and derived fitting algorithms - */ -class AbsKalmanFitter : public AbsFitter { - - public: - - AbsKalmanFitter(unsigned int maxIterations = 4, double deltaPval = 1e-3, double blowUpFactor = 1e3) - : AbsFitter(), minIterations_(2), maxIterations_(maxIterations), deltaPval_(deltaPval), relChi2Change_(0.2), - blowUpFactor_(blowUpFactor), multipleMeasurementHandling_(unweightedClosestToPredictionWire), - maxFailedHits_(-1) { - if (minIterations_ > maxIterations_) - minIterations_ = maxIterations_; - } - - virtual ~AbsKalmanFitter() {;} - - //virtual void fitTrack(Track* tr, const AbsTrackRep* rep, double& chi2, double& ndf, int direction) = 0; - - void getChiSquNdf(const Track* tr, const AbsTrackRep* rep, double& bChi2, double& fChi2, double& bNdf, double& fNdf) const; - double getChiSqu(const Track* tr, const AbsTrackRep* rep, int direction = -1) const; - double getNdf(const Track* tr, const AbsTrackRep* rep, int direction = -1) const; - double getRedChiSqu(const Track* tr, const AbsTrackRep* rep, int direction = -1) const; - double getPVal(const Track* tr, const AbsTrackRep* rep, int direction = -1) const; - eMultipleMeasurementHandling getMultipleMeasurementHandling() const {return multipleMeasurementHandling_;} - - //! Set the minimum number of iterations - virtual void setMinIterations(unsigned int n) {minIterations_ = std::max((unsigned int)1,n); if (maxIterations_ < minIterations_) maxIterations_ = minIterations_;} - //! Set the maximum number of iterations - virtual void setMaxIterations(unsigned int n) {maxIterations_ = n; if (minIterations_ > maxIterations_) minIterations_ = maxIterations_;} - - /** - * @brief Set Convergence criterion - * - * if track total P-value changes less than this between consecutive iterations, consider the track converged. - * chi² from the backwards fit is used. - */ - void setDeltaPval(double deltaPval) {deltaPval_ = deltaPval;} - - /** - * @ brief Set Non-convergence criterion - * - * if the relative chi^2 between two iterations is larger than relChi2Change_, the fit is NOT converged and - * further iterations will be done, even if the deltaPval_ convergence criterium is met. - * This is especially useful for fits which have a p-value of almost 0 (possibly due to bad start values), - * where the p-value from one iteration to the next might not change much. However, a significant change in - * chi^2 tells us, that the fit might not yet be converged. - */ - void setRelChi2Change(double relChi2Change) {relChi2Change_ = relChi2Change;} - - //! How should multiple measurements be handled? - void setMultipleMeasurementHandling(eMultipleMeasurementHandling mmh) {multipleMeasurementHandling_ = mmh;} - - virtual void setMaxFailedHits(int val) {maxFailedHits_ = val;} - - bool isTrackPrepared(const Track* tr, const AbsTrackRep* rep) const; - bool isTrackFitted(const Track* tr, const AbsTrackRep* rep) const; - - //! returns if the fitter can ignore the weights and handle the MeasurementOnPlanes as if they had weight 1. - bool canIgnoreWeights() const; - - protected: - - //! get the measurementsOnPlane taking the multipleMeasurementHandling_ into account - const std::vector getMeasurements(const KalmanFitterInfo* fi, const TrackPoint* tp, int direction) const; - - //! Minimum number of iterations to attempt. Forward and backward are counted as one iteration. - unsigned int minIterations_; - - //! Maximum number of iterations to attempt. Forward and backward are counted as one iteration. - unsigned int maxIterations_; - /** - * @brief Convergence criterion - * - * if track total P-value changes less than this between consecutive iterations, consider the track converged. - * chi² from the backwards fit is used. - */ - double deltaPval_; - /** - * @ brief Non-convergence criterion - * - * if the relative chi^2 between two iterations is larger than relChi2Change_, the fit is NOT converged and - * further iterations will be done, even if the deltaPval_ convergence criterium is met. - * This is especially useful for fits which have a p-value of almost 0 (possibly due to bad start values), - * where the p-value from one iteration to the next might not change much. However, a significant change in - * chi^2 tells us, that the fit might not yet be converged. - */ - double relChi2Change_; - //! Blow up the covariance of the forward (backward) fit by this factor before seeding the backward (forward) fit. - double blowUpFactor_; - - //! How to handle if there are multiple MeasurementsOnPlane - eMultipleMeasurementHandling multipleMeasurementHandling_; - - //! after how many failed hits (exception during construction of plane, extrapolation etc.) should the fit be cancelled. - //! -1 means don't cancel - int maxFailedHits_; - - public: - - ClassDef(AbsKalmanFitter, 1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif //genfit_AbsKalmanFitter_h diff --git a/genfit/fitters/include/DAF.h b/genfit/fitters/include/DAF.h deleted file mode 100644 index fd13d450ff..0000000000 --- a/genfit/fitters/include/DAF.h +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright 2013, Ludwig-Maximilians Universität München, - Authors: Tobias Schlüter & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_DAF_h -#define genfit_DAF_h - -#include "AbsKalmanFitter.h" - -#include -#include - - -namespace genfit { - -/** @brief Determinstic Annealing Filter (DAF) implementation. - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Karl Bicker (Technische Universität München) - * - * The DAF is an iterative Kalman filter with annealing. It is capable of - * fitting tracks which are contaminated with noise hits. The algorithm is - * taken from the references R. Fruehwirth & A. Strandlie, Computer Physics - * Communications 120 (1999) 197-214 and CERN thesis: Dissertation by Matthias - * Winkler. - * - * The weights which were assigned to the hits by the DAF are accessible in the MeasurementOnPlane objects - * in the KalmanFitterInfo objects. - */ -class DAF : public AbsKalmanFitter { - - private: - - DAF(const DAF&); - DAF& operator=(genfit::DAF const&); - - public: - - /** - * @brief Create DAF. Per default, use KalmanFitterRefTrack as fitter. - * - * @param useRefKalman If false, use KalmanFitter as fitter. - */ - DAF(bool useRefKalman = true, double deltaWeight = 1e-3, double deltaPval = 1e-3); - /** - * @brief Create DAF. Use the provided AbsKalmanFitter as fitter. - */ - DAF(AbsKalmanFitter* kalman, double deltaWeight = 1e-3, double deltaPval = 1e-3); - ~DAF() {}; - - //! Process a track using the DAF. - void processTrackWithRep(Track* tr, const AbsTrackRep* rep, bool resortHits = false); - - /** @brief Set the probability cut for the weight calculation for the hits. - * - * By default the cut values for measurements of dimensionality from 1 to 5 are calculated. - * If you what to have cut values for an arbitrary measurement dimensionality use - * addProbCut(double prob_cut, int maxDim); - */ - void setProbCut(const double prob_cut); - - //! Set the probability cut for the weight calculation for the hits for a specific measurement dimensionality. - void addProbCut(const double prob_cut, const int measDim); - - /** @brief Configure the annealing scheme. - * - * In the current implementation you need to provide at least one temperature - * and not more then ten temperatures. - * Also sets #minIterations_ and #maxIterations_. - */ - void setBetas(double b1,double b2=-1, double b3=-1., double b4=-1., double b5=-1., double b6=-1., double b7=-1., double b8=-1., double b9=-1., double b10=-1.); - - /** @brief Configure the annealing scheme. - * - * Set a start and end temperature and the number of steps. A logarithmic sequence of temperatures will be calculated. - * Also sets #minIterations_ and #maxIterations_. - */ - void setAnnealingScheme(double bStart, double bFinal, unsigned int nSteps); - - void setMaxIterations(unsigned int n) {maxIterations_ = n; betas_.resize(maxIterations_,betas_.back());} - - //! If all weights change less than delta between two iterations, the fit is regarded as converged. - void setConvergenceDeltaWeight(double delta) {deltaWeight_ = delta;} - - AbsKalmanFitter* getKalman() const {return kalman_.get();} - - virtual void setMaxFailedHits(int val) {getKalman()->setMaxFailedHits(val);} - - virtual void setDebugLvl(unsigned int lvl = 1) {AbsFitter::setDebugLvl(lvl); if (lvl > 1) getKalman()->setDebugLvl(lvl-1);} - - private: - - /** @brief Calculate and set the weights for the next fitting pass. - * Return if convergence is met. - * The convergence criterium is the largest absolute change of all weights. - */ - bool calcWeights(Track* trk, const AbsTrackRep* rep, double beta); - - - double deltaWeight_; // convergence criterium - std::vector betas_; - std::map chi2Cuts_; -#ifndef __CINT__ - boost::scoped_ptr kalman_; -#else - AbsKalmanFitter* kalman_; -#endif - - public: - - ClassDef(DAF,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif //genfit_DAF_h diff --git a/genfit/fitters/include/KalmanFitStatus.h b/genfit/fitters/include/KalmanFitStatus.h deleted file mode 100644 index 8c56497ee3..0000000000 --- a/genfit/fitters/include/KalmanFitStatus.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_KalmanFitStatus_h -#define genfit_KalmanFitStatus_h - -#include "FitStatus.h" - -#include - - -namespace genfit { - -/** - * @brief FitStatus for use with AbsKalmanFitter implementations - */ -class KalmanFitStatus : public FitStatus { - - public: - - KalmanFitStatus() : - FitStatus(), numIterations_(0), fittedWithDaf_(false), fittedWithReferenceTrack_(false), - trackLen_(0), fChi2_(-1e99), fNdf_(-1e99) {;} - - virtual ~KalmanFitStatus() {}; - - virtual FitStatus* clone() const {return new KalmanFitStatus(*this);} - - unsigned int getNumIterations() const {return numIterations_;} - bool isFittedWithDaf() const {return fittedWithDaf_;} - bool isFittedWithReferenceTrack() const {return fittedWithReferenceTrack_;} - double getTrackLen() const {return trackLen_;} - double getForwardChi2() const {return fChi2_;} - double getBackwardChi2() const {return FitStatus::getChi2();} - double getForwardNdf() const {return fNdf_;} - double getBackwardNdf() const {return FitStatus::getNdf();} - // virtual double getPVal() : not overridden, as it does the right thing. - double getForwardPVal() const {return ROOT::Math::chisquared_cdf_c(fChi2_, fNdf_);} - double getBackwardPVal() const {return FitStatus::getPVal(); } - - void setNumIterations(unsigned int numIterations) {numIterations_ = numIterations;} - void setIsFittedWithDaf(bool fittedWithDaf = true) {fittedWithDaf_ = fittedWithDaf;} - void setIsFittedWithReferenceTrack(bool fittedWithReferenceTrack = true) {fittedWithReferenceTrack_ = fittedWithReferenceTrack;} - void setTrackLen(double trackLen) {trackLen_ = trackLen;} - void setForwardChi2(double fChi2) {fChi2_ = fChi2;} - void setBackwardChi2(double bChi2) {FitStatus::setChi2(bChi2);} - void setForwardNdf(double fNdf) {fNdf_ = fNdf;} - void setBackwardNdf(double bNdf) {FitStatus::setNdf(bNdf);} - - virtual void Print(const Option_t* = "") const; - - protected: - - unsigned int numIterations_; // number of iterations that have been performed - bool fittedWithDaf_; - bool fittedWithReferenceTrack_; - - double trackLen_; - - double fChi2_; // chi^2 of the forward fit - double fNdf_; // degrees of freedom of the forward fit - double fPval_; // p-value of the forward fit, set whenever either of chi2 or ndf changes - - public: - - ClassDef(KalmanFitStatus, 1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_KalmanFitStatus_h diff --git a/genfit/fitters/include/KalmanFittedStateOnPlane.h b/genfit/fitters/include/KalmanFittedStateOnPlane.h deleted file mode 100644 index 8de84ea4cc..0000000000 --- a/genfit/fitters/include/KalmanFittedStateOnPlane.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_KalmanFittedStateOnPlane_h -#define genfit_KalmanFittedStateOnPlane_h - -#include "MeasuredStateOnPlane.h" - - -namespace genfit { - - -/** - * @brief #MeasuredStateOnPlane with additional info produced by a Kalman filter or DAF. - */ -class KalmanFittedStateOnPlane : public MeasuredStateOnPlane { - - public: - - KalmanFittedStateOnPlane(); - KalmanFittedStateOnPlane(const TVectorD& state, const TMatrixDSym& cov, const SharedPlanePtr& plane, const AbsTrackRep* rep, double chiSquareIncrement, double ndf); - KalmanFittedStateOnPlane(const TVectorD& state, const TMatrixDSym& cov, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo, double chiSquareIncrement, double ndf); - KalmanFittedStateOnPlane(const MeasuredStateOnPlane& state, double chiSquareIncrement, double ndf); - - KalmanFittedStateOnPlane& operator=(KalmanFittedStateOnPlane other); - void swap(KalmanFittedStateOnPlane& other); // nothrow - - virtual ~KalmanFittedStateOnPlane() {} - - double getChiSquareIncrement() const {return chiSquareIncrement_;} - double getNdf() const {return ndf_;} - - void setChiSquareIncrement(double chiSquareIncrement) {chiSquareIncrement_ = chiSquareIncrement;} - void setNdf(double ndf) {ndf_ = ndf;} - - - protected: - - double chiSquareIncrement_; - - //! Degrees of freedom. Needs to be a double because of DAF. - double ndf_; - - - public: - - ClassDef(KalmanFittedStateOnPlane,1) - -}; - - -inline KalmanFittedStateOnPlane::KalmanFittedStateOnPlane() : - MeasuredStateOnPlane(), chiSquareIncrement_(0), ndf_(0) -{ - ; -} - -inline KalmanFittedStateOnPlane::KalmanFittedStateOnPlane(const TVectorD& state, const TMatrixDSym& cov, const SharedPlanePtr& plane, const AbsTrackRep* rep, double chiSquareIncrement, double ndf) : - MeasuredStateOnPlane(state, cov, plane, rep), chiSquareIncrement_(chiSquareIncrement), ndf_(ndf) -{ - ; -} - -inline KalmanFittedStateOnPlane::KalmanFittedStateOnPlane(const TVectorD& state, const TMatrixDSym& cov, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo, double chiSquareIncrement, double ndf) : - MeasuredStateOnPlane(state, cov, plane, rep, auxInfo), chiSquareIncrement_(chiSquareIncrement), ndf_(ndf) -{ - ; -} - -inline KalmanFittedStateOnPlane::KalmanFittedStateOnPlane(const MeasuredStateOnPlane& state, double chiSquareIncrement, double ndf) : - MeasuredStateOnPlane(state), chiSquareIncrement_(chiSquareIncrement), ndf_(ndf) -{ - ; -} - -inline KalmanFittedStateOnPlane& KalmanFittedStateOnPlane::operator=(KalmanFittedStateOnPlane other) { - swap(other); - return *this; -} - -inline void KalmanFittedStateOnPlane::swap(KalmanFittedStateOnPlane& other) { - MeasuredStateOnPlane::swap(other); - std::swap(this->chiSquareIncrement_, other.chiSquareIncrement_); - std::swap(this->ndf_, other.ndf_); -} - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_KalmanFittedStateOnPlane_h diff --git a/genfit/fitters/include/KalmanFitter.h b/genfit/fitters/include/KalmanFitter.h deleted file mode 100644 index 21d8947dd4..0000000000 --- a/genfit/fitters/include/KalmanFitter.h +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright 2013, Ludwig-Maximilians Universität München, - Authors: Tobias Schlüter & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_KalmanFitter_h -#define genfit_KalmanFitter_h - -#include "AbsKalmanFitter.h" - -#ifndef __CINT__ -#include -#endif - - -namespace genfit { - -class KalmanFitterInfo; -class MeasuredStateOnPlane; -class TrackPoint; - -/** - * @brief Simple Kalman filter implementation. - */ -class KalmanFitter : public AbsKalmanFitter { - - private: - - // These private functions are needed, otherwise strange things happen, no idea why! - KalmanFitter(const KalmanFitter&); - KalmanFitter& operator=(KalmanFitter const&); - - public: - - KalmanFitter(unsigned int maxIterations = 4, double deltaPval = 1e-3, double blowUpFactor = 1e3, bool squareRootFormalism = false) - : AbsKalmanFitter(maxIterations, deltaPval, blowUpFactor), currentState_(NULL), - squareRootFormalism_(squareRootFormalism) - {} - - ~KalmanFitter() {} - - //! Hit resorting currently NOT supported. - void processTrackWithRep(Track* tr, const AbsTrackRep* rep, bool resortHits = false); - - //! process only a part of the track. Can also be used to process the track only in backward direction. - //! Does not alter the FitStatus and does not do multiple iterations. - void processTrackPartially(Track* tr, const AbsTrackRep* rep, int startId = 0, int endId = -1); - - void useSquareRootFormalism(bool squareRootFormalism = true) {squareRootFormalism_ = squareRootFormalism;} - - private: - bool fitTrack(Track* tr, const AbsTrackRep* rep, double& chi2, double& ndf, int startId, int endId, int& nFailedHits); - void processTrackPoint(TrackPoint* tp, - const AbsTrackRep* rep, double& chi2, double& ndf, int direction); - -#ifndef __CINT__ - boost::scoped_ptr currentState_; -#else - MeasuredStateOnPlane* currentState_; -#endif - - bool squareRootFormalism_; - - public: - ClassDef(KalmanFitter,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif //genfit_KalmanFitter_h diff --git a/genfit/fitters/include/KalmanFitterInfo.h b/genfit/fitters/include/KalmanFitterInfo.h deleted file mode 100644 index 2bcbc1bcb9..0000000000 --- a/genfit/fitters/include/KalmanFitterInfo.h +++ /dev/null @@ -1,162 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_KalmanFitterInfo_h -#define genfit_KalmanFitterInfo_h - -#include "AbsFitterInfo.h" -#include "KalmanFittedStateOnPlane.h" -#include "MeasuredStateOnPlane.h" -#include "MeasurementOnPlane.h" -#include "ReferenceStateOnPlane.h" -#include "StateOnPlane.h" - -#include - -#ifndef __CINT__ -#include -#endif - - -namespace genfit { - - -/** - * @brief Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one AbsTrackRep of the Track. - */ -class KalmanFitterInfo : public AbsFitterInfo { - - public: - - KalmanFitterInfo(); - KalmanFitterInfo(const TrackPoint* trackPoint, const AbsTrackRep* rep); - virtual ~KalmanFitterInfo(); - - virtual KalmanFitterInfo* clone() const; - - ReferenceStateOnPlane* getReferenceState() const {return referenceState_.get();} - MeasuredStateOnPlane* getForwardPrediction() const {return forwardPrediction_.get();} - MeasuredStateOnPlane* getBackwardPrediction() const {return backwardPrediction_.get();} - MeasuredStateOnPlane* getPrediction(int direction) const {if (direction >=0) return forwardPrediction_.get(); return backwardPrediction_.get();} - KalmanFittedStateOnPlane* getForwardUpdate() const {return forwardUpdate_.get();} - KalmanFittedStateOnPlane* getBackwardUpdate() const {return backwardUpdate_.get();} - KalmanFittedStateOnPlane* getUpdate(int direction) const {if (direction >=0) return forwardUpdate_.get(); return backwardUpdate_.get();} - const std::vector< genfit::MeasurementOnPlane* >& getMeasurementsOnPlane() const {return measurementsOnPlane_;} - MeasurementOnPlane* getMeasurementOnPlane(int i = 0) const {if (i<0) i += measurementsOnPlane_.size(); return measurementsOnPlane_.at(i);} - //! Get weighted mean of all measurements. - //! @param ignoreWeights If set, the weights of the individual measurements will be ignored (they will be treated as if they all had weight 1) - MeasurementOnPlane getAvgWeightedMeasurementOnPlane(bool ignoreWeights = false) const; - //! Get measurements which is closest to state. - MeasurementOnPlane* getClosestMeasurementOnPlane(const StateOnPlane*) const; - unsigned int getNumMeasurements() const {return measurementsOnPlane_.size();} - //! Get weights of measurements. - std::vector getWeights() const; - //! Are the weights fixed? - bool areWeightsFixed() const {return fixWeights_;} - //! Get unbiased or biased (default) smoothed state. - const MeasuredStateOnPlane& getFittedState(bool biased = true) const; - //! Get unbiased (default) or biased residual from ith measurement. - MeasurementOnPlane getResidual(unsigned int iMeasurement = 0, bool biased = false, bool onlyMeasurementErrors = true) const; // calculate residual, track and measurement errors are added if onlyMeasurementErrors is false - - bool hasMeasurements() const {return getNumMeasurements() > 0;} - bool hasReferenceState() const {return (referenceState_.get() != NULL);} - bool hasForwardPrediction() const {return (forwardPrediction_.get() != NULL);} - bool hasBackwardPrediction() const {return (backwardPrediction_.get() != NULL);} - bool hasForwardUpdate() const {return (forwardUpdate_.get() != NULL);} - bool hasBackwardUpdate() const {return (backwardUpdate_.get() != NULL);} - bool hasUpdate(int direction) const {if (direction < 0) return hasBackwardUpdate(); return hasForwardUpdate();} - bool hasPredictionsAndUpdates() const {return (hasForwardPrediction() && hasBackwardPrediction() && hasForwardUpdate() && hasBackwardUpdate());} - - void setReferenceState(ReferenceStateOnPlane* referenceState); - void setForwardPrediction(MeasuredStateOnPlane* forwardPrediction); - void setBackwardPrediction(MeasuredStateOnPlane* backwardPrediction); - void setPrediction(MeasuredStateOnPlane* prediction, int direction) {if (direction >=0) setForwardPrediction(prediction); else setBackwardPrediction(prediction);} - void setForwardUpdate(KalmanFittedStateOnPlane* forwardUpdate); - void setBackwardUpdate(KalmanFittedStateOnPlane* backwardUpdate); - void setUpdate(KalmanFittedStateOnPlane* update, int direction) {if (direction >=0) setForwardUpdate(update); else setBackwardUpdate(update);} - void setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane); - void addMeasurementOnPlane(MeasurementOnPlane* measurementOnPlane); - void addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane); - //! Set weights of measurements. - void setWeights(const std::vector&); - void fixWeights(bool arg = true) {fixWeights_ = arg;} - void setRep(const AbsTrackRep* rep); - - void deleteForwardInfo(); - void deleteBackwardInfo(); - void deletePredictions(); - void deleteReferenceInfo() {setReferenceState(NULL);} - void deleteMeasurementInfo(); - - virtual void Print(const Option_t* = "") const; - - virtual bool checkConsistency() const; - - private: - - -#ifndef __CINT__ - //! Reference state. Used by KalmanFitterRefTrack. - boost::scoped_ptr referenceState_; // Ownership - boost::scoped_ptr forwardPrediction_; // Ownership - boost::scoped_ptr forwardUpdate_; // Ownership - boost::scoped_ptr backwardPrediction_; // Ownership - boost::scoped_ptr backwardUpdate_; // Ownership - mutable boost::scoped_ptr fittedStateUnbiased_; //! cache - mutable boost::scoped_ptr fittedStateBiased_; //! cache -#else - class ReferenceStateOnPlane* referenceState_; - class MeasuredStateOnPlane* forwardPrediction_; - class KalmanFittedStateOnPlane* forwardUpdate_; - class MeasuredStateOnPlane* backwardPrediction_; - class KalmanFittedStateOnPlane* backwardUpdate_; - class MeasuredStateOnPlane* fittedStateUnbiased_; //! cache - class MeasuredStateOnPlane* fittedStateBiased_; //! cache -#endif - - - //> TODO ! ptr implement: to the special ownership version - /* class owned_pointer_vector : private std::vector { - public: - ~owned_pointer_vector() { for (size_t i = 0; i < this->size(); ++i) - delete this[i]; } - size_t size() const { return this->size(); }; - void push_back(MeasuredStateOnPlane* measuredState) { this->push_back(measuredState); }; - const MeasuredStateOnPlane* at(size_t i) const { return this->at(i); }; - //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator position) ; - //owned_pointer_vector::iterator erase(owned_pointer_vector::iterator first, owned_pointer_vector::iterator last); -}; - */ - - std::vector measurementsOnPlane_; // Ownership - bool fixWeights_; // weights should not be altered by fitters anymore - - public: - - ClassDef(KalmanFitterInfo,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_KalmanFitterInfo_h diff --git a/genfit/fitters/include/KalmanFitterRefTrack.h b/genfit/fitters/include/KalmanFitterRefTrack.h deleted file mode 100644 index 750e6a9978..0000000000 --- a/genfit/fitters/include/KalmanFitterRefTrack.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright 2013, Ludwig-Maximilians Universität München, - Authors: Tobias Schlüter & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_KalmanFitterRefTrack_h -#define genfit_KalmanFitterRefTrack_h - -#include "AbsKalmanFitter.h" - - -namespace genfit { - -class KalmanFitterInfo; -class TrackPoint; - -/** - * @brief Kalman filter implementation with linearization around a reference track - */ -class KalmanFitterRefTrack : public AbsKalmanFitter { - public: - KalmanFitterRefTrack(unsigned int maxIterations = 4, double deltaPval = 1e-3, double blowUpFactor = 1e3) - : AbsKalmanFitter(maxIterations, deltaPval, blowUpFactor), refitAll_(false), deltaChi2Ref_(1) {} - - virtual ~KalmanFitterRefTrack() {} - - /** @brief Fit the track. - * - * Needs a prepared track! Return last TrackPoint that has been processed. - */ - TrackPoint* fitTrack(Track* tr, const AbsTrackRep* rep, double& chi2, double& ndf, int direction); - - void processTrackWithRep(Track* tr, const AbsTrackRep* rep, bool resortHits = false); - - /** @brief Prepare the track - * - * Calc all reference states. - * If setSortingParams is true, the extrapolation lengths will be set as sorting parameters - * of the TrackPoints. - * Returns if the track has been changed. - */ - bool prepareTrack(Track* tr, const AbsTrackRep* rep, bool setSortingParams, int& nFailedHits); - - //! If true always refit all points, otherwise fit points only if reference states have changed - void setRefitAll(bool refit = true) {refitAll_ = refit;} - - /** - * When will the reference track be updated? - * If (smoothedState - referenceState) * smoothedCov^(-1) * (smoothedState - referenceState)^T >= deltaChi2Ref_. - */ - void setDeltaChi2Ref(double dChi2) {deltaChi2Ref_ = dChi2;} - - private: - void processTrackPoint(KalmanFitterInfo* fi, const KalmanFitterInfo* prevFi, const TrackPoint* tp, double& chi2, double& ndf, int direction); - - /** - * @brief Remove referenceStates if they are too far from smoothed states. - * - * Does NOT remove forward and backward info, but returns from/to where they have to be removed later - * Return if anything has changed. - */ - bool removeOutdated(Track* tr, const AbsTrackRep* rep, int& notChangedUntil, int& notChangedFrom); - - //! If refitAll_, remove all information. - void removeForwardBackwardInfo(Track* tr, const AbsTrackRep* rep, int notChangedUntil, int notChangedFrom) const; - - bool refitAll_; // always refit all points or only if reference states have changed - double deltaChi2Ref_; // reference track update cut - - // aux variables for prepareTrack - TMatrixD FTransportMatrix_; //! - TMatrixD BTransportMatrix_; //! - TMatrixDSym FNoiseMatrix_; //! - TMatrixDSym BNoiseMatrix_; //! - TVectorD forwardDeltaState_; //! - TVectorD backwardDeltaState_; //! - - // aux variables for processTrackPoint - TVectorD p_; //! - TMatrixDSym C_; //! - TMatrixDSym covSumInv_; //! - TMatrixDSym Rinv_; //! - TVectorD res_; //! - - // aux variables for removeOutdated - TVectorD resM_; //! - - public: - ClassDef(KalmanFitterRefTrack, 1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif //genfit_KalmanFitterRefTrack_h diff --git a/genfit/fitters/include/ReferenceStateOnPlane.h b/genfit/fitters/include/ReferenceStateOnPlane.h deleted file mode 100644 index 433f31fbba..0000000000 --- a/genfit/fitters/include/ReferenceStateOnPlane.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_ReferenceStateOnPlane_h -#define genfit_ReferenceStateOnPlane_h - -#include "StateOnPlane.h" - - -namespace genfit { - -/** - * @brief #StateOnPlane with linearized transport to that #ReferenceStateOnPlane from previous and next #ReferenceStateOnPlane - * - * Transport matrices describe transport TO that plane. - * We have transport matrix F, noise matrix N and delta state c. - * Now, state p and covariance C follow this mathematics: - * - * p = F * p_old + c - * C = F * C_old * F^T + N - * - */ -class ReferenceStateOnPlane : public StateOnPlane { - - public: - - ReferenceStateOnPlane(); - ReferenceStateOnPlane(const TVectorD& state, - const SharedPlanePtr& plane, - const AbsTrackRep* rep); - ReferenceStateOnPlane(const TVectorD& state, - const SharedPlanePtr& plane, - const AbsTrackRep* rep, - const TVectorD& auxInfo); - ReferenceStateOnPlane(const StateOnPlane& state); - - StateOnPlane& operator=(ReferenceStateOnPlane other); - void swap(ReferenceStateOnPlane& other); // nothrow - - virtual ~ReferenceStateOnPlane() {} - - void setForwardSegmentLength(double len) {forwardSegmentLength_ = len;} - void setBackwardSegmentLength(double len) {backwardSegmentLength_ = len;} - void setForwardTransportMatrix(const TMatrixD& mat) {forwardTransportMatrix_.ResizeTo(mat); forwardTransportMatrix_=mat;} - void setBackwardTransportMatrix(const TMatrixD& mat) {backwardTransportMatrix_.ResizeTo(mat); backwardTransportMatrix_=mat;} - void setTransportMatrix(const TMatrixD& mat, int direction) {if (direction >= 0) setForwardTransportMatrix(mat); else setBackwardTransportMatrix(mat);} - void setForwardNoiseMatrix(const TMatrixDSym& mat) {forwardNoiseMatrix_.ResizeTo(mat); forwardNoiseMatrix_=mat;} - void setBackwardNoiseMatrix(const TMatrixDSym& mat) {backwardNoiseMatrix_.ResizeTo(mat); backwardNoiseMatrix_=mat;} - void setNoiseMatrix(const TMatrixDSym& mat, int direction) {if (direction >= 0) setForwardNoiseMatrix(mat); else setBackwardNoiseMatrix(mat);} - void setForwardDeltaState(const TVectorD& mat) {forwardDeltaState_.ResizeTo(mat); forwardDeltaState_=mat;} - void setBackwardDeltaState(const TVectorD& mat) {backwardDeltaState_.ResizeTo(mat); backwardDeltaState_=mat;} - void setDeltaState(const TVectorD& mat, int direction) {if (direction >= 0) setForwardDeltaState(mat); else setBackwardDeltaState(mat);} - - - double getForwardSegmentLength() const {return forwardSegmentLength_;} - double getBackwardSegmentLength() const {return backwardSegmentLength_;} - const TMatrixD& getForwardTransportMatrix() const {return forwardTransportMatrix_;} - const TMatrixD& getBackwardTransportMatrix() const {return backwardTransportMatrix_;} - const TMatrixD& getTransportMatrix(int direction) const {if (direction >= 0) return forwardTransportMatrix_; return backwardTransportMatrix_;} - const TMatrixDSym& getForwardNoiseMatrix() const {return forwardNoiseMatrix_;} - const TMatrixDSym& getBackwardNoiseMatrix() const {return backwardNoiseMatrix_;} - const TMatrixDSym& getNoiseMatrix(int direction) const {if (direction >= 0) return forwardNoiseMatrix_; return backwardNoiseMatrix_;} - const TVectorD& getForwardDeltaState() const {return forwardDeltaState_;} - const TVectorD& getBackwardDeltaState() const {return backwardDeltaState_;} - const TVectorD& getDeltaState(int direction) const {if (direction >= 0) return forwardDeltaState_; return backwardDeltaState_;} - - void resetForward(); - void resetBackward(); - - virtual void Print(Option_t* option = "") const; - - protected: - - double forwardSegmentLength_; /**< Segment length from previous referenceState */ - double backwardSegmentLength_; /**< Segment length from next referenceState */ - TMatrixD forwardTransportMatrix_; /**< transport matrix F from previous referenceState */ - TMatrixD backwardTransportMatrix_; /**< transport matrix F from next referenceState */ - TMatrixDSym forwardNoiseMatrix_; /**< noise matrix N for transport from previous referenceState */ - TMatrixDSym backwardNoiseMatrix_; /**< noise matrix N for transport from next referenceState */ - TVectorD forwardDeltaState_; /**< c */ - TVectorD backwardDeltaState_; /**< c */ - - - public: - - ClassDef(ReferenceStateOnPlane,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_ReferenceStateOnPlane_h diff --git a/genfit/fitters/src/AbsKalmanFitter.cc b/genfit/fitters/src/AbsKalmanFitter.cc deleted file mode 100644 index 2a9bfc65c5..0000000000 --- a/genfit/fitters/src/AbsKalmanFitter.cc +++ /dev/null @@ -1,279 +0,0 @@ -/* Copyright 2013, Ludwig-Maximilians Universität München, - Authors: Tobias Schlüter & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/* This implements the simple Kalman fitter with no reference track - that uses the stateSeed only until it forgets about it after the - first few hits. */ - -#include "Track.h" -#include "TrackPoint.h" -#include "Exception.h" -#include "KalmanFitterInfo.h" -#include "WireMeasurement.h" - -#include "AbsKalmanFitter.h" -#include - - -//#define DEBUG - -using namespace genfit; - - - -void AbsKalmanFitter::getChiSquNdf(const Track* tr, const AbsTrackRep* rep, - double& bChi2, double& fChi2, - double& bNdf, double& fNdf) const { - - bChi2 = 0; - fChi2 = 0; - bNdf = -1. * rep->getDim(); - fNdf = -1. * rep->getDim(); - - const std::vector& pointsWM = tr->getPointsWithMeasurement(); - for (std::vector::const_iterator tpIter = pointsWM.begin(), endIter = pointsWM.end(); tpIter != endIter; ++tpIter) { - if (! (*tpIter)->hasFitterInfo(rep)) - continue; - - AbsFitterInfo* afi = (*tpIter)->getFitterInfo(rep); - KalmanFitterInfo* fi = dynamic_cast(afi); - if (!fi) { - Exception exc("AbsKalmanFitter::getChiSqu(): fitterInfo is not a KalmanFitterInfo", __LINE__,__FILE__); - throw exc; - } - - KalmanFittedStateOnPlane* fup = fi->getForwardUpdate(); - KalmanFittedStateOnPlane* bup = fi->getBackwardUpdate(); - - if (fup == NULL || bup == NULL) { - Exception exc("AbsKalmanFitter::getChiSqu(): fup == NULL || bup == NULL", __LINE__,__FILE__); - throw exc; - } - - bChi2 += bup->getChiSquareIncrement(); - fChi2 += fup->getChiSquareIncrement(); - - bNdf += bup->getNdf(); - fNdf += fup->getNdf(); - } - - if (bNdf < 0) - bNdf = 0; - - if (fNdf < 0) - fNdf = 0; -} - - -double AbsKalmanFitter::getChiSqu(const Track* tr, const AbsTrackRep* rep, int direction) const { - double bChi2(0), fChi2(0), bNdf(0), fNdf(0); - - getChiSquNdf(tr, rep, bChi2, fChi2, bNdf, fNdf); - - if (direction < 0) - return bChi2; - return fChi2; -} - -double AbsKalmanFitter::getNdf(const Track* tr, const AbsTrackRep* rep, int direction) const { - double bChi2(0), fChi2(0), bNdf(0), fNdf(0); - - getChiSquNdf(tr, rep, bChi2, fChi2, bNdf, fNdf); - - if (direction < 0) - return bNdf; - return fNdf; -} - -double AbsKalmanFitter::getRedChiSqu(const Track* tr, const AbsTrackRep* rep, int direction) const { - double bChi2(0), fChi2(0), bNdf(0), fNdf(0); - - getChiSquNdf(tr, rep, bChi2, fChi2, bNdf, fNdf); - - if (direction < 0) - return bChi2/bNdf; - return fChi2/fNdf; -} - -double AbsKalmanFitter::getPVal(const Track* tr, const AbsTrackRep* rep, int direction) const { - double bChi2(0), fChi2(0), bNdf(0), fNdf(0); - - getChiSquNdf(tr, rep, bChi2, fChi2, bNdf, fNdf); - - if (direction < 0) - return ROOT::Math::chisquared_cdf_c(bChi2, bNdf); - return ROOT::Math::chisquared_cdf_c(fChi2, fNdf); -} - - -bool AbsKalmanFitter::isTrackPrepared(const Track* tr, const AbsTrackRep* rep) const { - const std::vector& points = tr->getPointsWithMeasurement(); - - if (points.size() == 0) - return true; - - for (std::vector::const_iterator pIt = points.begin(), pEnd = points.end(); pIt != pEnd; ++pIt) { - KalmanFitterInfo* fi = dynamic_cast((*pIt)->getFitterInfo(rep)); - - if (!fi) - continue; - - if (!(fi->checkConsistency())) - return false; - - if (!(fi->hasReferenceState())) - return false; - } - - return true; -} - -bool AbsKalmanFitter::isTrackFitted(const Track* tr, const AbsTrackRep* rep) const { - if (! tr->getFitStatus(rep)->isFitted()) - return false; - - // in depth check - - const std::vector< TrackPoint* >& points = tr->getPointsWithMeasurement(); - - if (points.size() == 0) - return true; - - for (std::vector::const_iterator pIt = points.begin(), pEnd = points.end(); pIt != pEnd; ++pIt) { - KalmanFitterInfo* fi = dynamic_cast((*pIt)->getFitterInfo(rep)); - if (!fi) - return false; - - if (!(fi->checkConsistency())) - return false; - - if (!(fi->hasForwardUpdate())) - return false; - - if (!(fi->hasBackwardUpdate())) - return false; - } - - return true; -} - - -const std::vector AbsKalmanFitter::getMeasurements(const KalmanFitterInfo* fi, const TrackPoint* tp, int direction) const { - - switch (multipleMeasurementHandling_) { - case weightedAverage : - case unweightedAverage : - return fi->getMeasurementsOnPlane(); - - case weightedClosestToReference : - case unweightedClosestToReference : - { - if (!fi->hasReferenceState()) { - Exception e("AbsKalmanFitter::getMeasurement: no ReferenceState.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - std::vector retVal; - retVal.push_back(fi->getClosestMeasurementOnPlane(fi->getReferenceState())); - return retVal; - } - - case weightedClosestToPrediction : - case unweightedClosestToPrediction : - { - if (!fi->hasPrediction(direction)) { - Exception e("AbsKalmanFitter::getMeasurement: no prediction.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - std::vector retVal; - retVal.push_back(fi->getClosestMeasurementOnPlane(fi->getPrediction(direction))); - return retVal; - } - - - case weightedClosestToReferenceWire : - case unweightedClosestToReferenceWire : - { - if (tp->getNumRawMeasurements() == 1 && dynamic_cast(tp->getRawMeasurement()) != NULL) { - if (!fi->hasReferenceState()) { - Exception e("AbsKalmanFitter::getMeasurement: no ReferenceState.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - std::vector retVal; - retVal.push_back(fi->getClosestMeasurementOnPlane(fi->getReferenceState())); - return retVal; - } - else - return fi->getMeasurementsOnPlane(); - } - - case weightedClosestToPredictionWire : - case unweightedClosestToPredictionWire : - { - if (tp->getNumRawMeasurements() == 1 && dynamic_cast(tp->getRawMeasurement()) != NULL) { - if (!fi->hasPrediction(direction)) { - Exception e("AbsKalmanFitter::getMeasurement: no prediction.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - std::vector retVal; - retVal.push_back(fi->getClosestMeasurementOnPlane(fi->getPrediction(direction))); - return retVal; - } - else - return fi->getMeasurementsOnPlane(); - } - - - default: - { - Exception e("AbsKalmanFitter::getMeasurement: choice not valid.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - } -} - - -bool AbsKalmanFitter::canIgnoreWeights() const { - switch (multipleMeasurementHandling_) { - case unweightedAverage : - case unweightedClosestToReference : - case unweightedClosestToPrediction : - case unweightedClosestToReferenceWire : - case unweightedClosestToPredictionWire : - return true; - - case weightedAverage : - case weightedClosestToReference : - case weightedClosestToPrediction : - case weightedClosestToReferenceWire : - case weightedClosestToPredictionWire : - return false; - - default: - { - Exception e("AbsKalmanFitter::canIgnoreWeights: choice not valid.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - } -} diff --git a/genfit/fitters/src/DAF.cc b/genfit/fitters/src/DAF.cc deleted file mode 100644 index b71a77d9c8..0000000000 --- a/genfit/fitters/src/DAF.cc +++ /dev/null @@ -1,437 +0,0 @@ -/* Copyright 2008-2013, Technische Universitaet Muenchen, Ludwig-Maximilians-Universität München - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "DAF.h" -#include "Exception.h" -#include "KalmanFitterInfo.h" -#include "KalmanFitter.h" -#include "KalmanFitterRefTrack.h" -#include "KalmanFitStatus.h" -#include "Tools.h" -#include "Track.h" -#include "TrackPoint.h" - -#include -#include - -//root stuff -#include -#include -#include - - - -namespace genfit { - -DAF::DAF(bool useRefKalman, double deltaPval, double deltaWeight) - : AbsKalmanFitter(10, deltaPval), deltaWeight_(deltaWeight) -{ - if (useRefKalman) { - kalman_.reset(new KalmanFitterRefTrack()); - static_cast(kalman_.get())->setRefitAll(); - } - else - kalman_.reset(new KalmanFitter()); - - kalman_->setMultipleMeasurementHandling(weightedAverage); - kalman_->setMaxIterations(1); - - setAnnealingScheme(100, 0.1, 5); // also sets maxIterations_ - setProbCut(0.01); -} - -DAF::DAF(AbsKalmanFitter* kalman, double deltaPval, double deltaWeight) - : AbsKalmanFitter(10, deltaPval), deltaWeight_(deltaWeight) -{ - kalman_.reset(kalman); - kalman_->setMultipleMeasurementHandling(weightedAverage); // DAF makes no sense otherwise - kalman_->setMaxIterations(1); - - if (dynamic_cast(kalman_.get()) != NULL) { - static_cast(kalman_.get())->setRefitAll(); - } - - setAnnealingScheme(100, 0.1, 5); // also sets maxIterations_ - setProbCut(0.01); -} - - -void DAF::processTrackWithRep(Track* tr, const AbsTrackRep* rep, bool resortHits) { - - if (debugLvl_ > 0) { - std::cout<<"DAF::processTrack //////////////////////////////////////////////////////////////// \n"; - } - - KalmanFitStatus* status = 0; - bool oneLastIter = false; - - double lastPval = -1; - - for(unsigned int iBeta = 0;; ++iBeta) { - - if (debugLvl_ > 0) { - std::cout<<"DAF::processTrack, trackRep " << rep << ", iteration " << iBeta+1 << ", beta = " << betas_.at(iBeta) << "\n"; - } - - kalman_->processTrackWithRep(tr, rep, resortHits); - - status = static_cast(tr->getFitStatus(rep)); - status->setIsFittedWithDaf(); - status->setNumIterations(iBeta+1); - - - // check break conditions - - if (! status->isFitted()){ - if (debugLvl_ > 0) { - std::cout << "DAF::Kalman could not fit!\n"; - } - status->setIsFitted(false); - break; - } - - if( oneLastIter == true){ - if (debugLvl_ > 0) { - std::cout << "DAF::break after one last iteration\n"; - } - status->setIsFitConvergedFully(status->getNFailedPoints() == 0); - status->setIsFitConvergedPartially(); - break; - } - - if(iBeta >= maxIterations_-1){ - status->setIsFitConvergedFully(false); - status->setIsFitConvergedPartially(false); - if (debugLvl_ > 0) { - std::cout << "DAF::number of max iterations reached!\n"; - } - break; - } - - - // get and update weights - bool converged(false); - try{ - converged = calcWeights(tr, rep, betas_.at(iBeta)); - if (!converged && iBeta >= minIterations_-1 && - status->getBackwardPVal() != 0 && fabs(lastPval - status->getBackwardPVal()) < this->deltaPval_) { - if (debugLvl_ > 0) { - std::cout << "converged by Pval = " << status->getBackwardPVal() << " even though weights changed at iBeta = " << iBeta << std::endl; - } - converged = true; - } - lastPval = status->getBackwardPVal(); - } catch(Exception& e) { - std::cerr<getTrackRep(0)->setStatusFlag(1); - status->setIsFitted(false); - status->setIsFitConvergedFully(false); - status->setIsFitConvergedPartially(false); - break; - } - - // check if converged - if (iBeta >= minIterations_-1 && converged) { - if (debugLvl_ > 0) { - std::cout << "DAF::convergence reached in iteration " << iBeta+1 << " -> Do one last iteration with updated weights.\n"; - } - oneLastIter = true; - status->setIsFitConvergedFully(status->getNFailedPoints() == 0); - status->setIsFitConvergedPartially(); - } - - } // end loop over betas - - - if (status->getForwardPVal() == 0. && - status->getBackwardPVal() == 0.) { - status->setIsFitConvergedFully(false); - status->setIsFitConvergedPartially(false); - } - -} - - -void DAF::setProbCut(const double prob_cut){ - for ( int i = 1; i != 6; ++i){ - addProbCut(prob_cut, i); - } -} - -void DAF::addProbCut(const double prob_cut, const int measDim){ - if ( prob_cut > 1.0 || prob_cut < 0.0){ - Exception exc("DAF::addProbCut prob_cut is not between 0 and 1",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - if ( measDim < 1){ - Exception exc("DAF::addProbCut measDim must be > 0",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - chi2Cuts_[measDim] = ROOT::Math::chisquared_quantile_c( prob_cut, measDim); -} - - -void DAF::setBetas(double b1,double b2,double b3,double b4,double b5,double b6,double b7,double b8,double b9,double b10){ - betas_.clear(); - assert(b1>0);betas_.push_back(b1); - if(b2>0){ - assert(b2<=b1);betas_.push_back(b2); - if(b3>=0.) { - assert(b3<=b2);betas_.push_back(b3); - if(b4>=0.) { - assert(b4<=b3);betas_.push_back(b4); - if(b5>=0.) { - assert(b5<=b4);betas_.push_back(b5); - if(b6>=0.) { - assert(b6<=b5);betas_.push_back(b6); - if(b7>=0.) { - assert(b7<=b6);betas_.push_back(b7); - if(b8>=0.) { - assert(b8<=b7);betas_.push_back(b8); - if(b9>=0.) { - assert(b9<=b8);betas_.push_back(b9); - if(b10>=0.) { - assert(b10<=b9);betas_.push_back(b10); - } - } - } - } - } - } - } - } - } - minIterations_ = betas_.size(); - maxIterations_ = betas_.size() + 4; - betas_.resize(maxIterations_,betas_.back()); //make sure main loop has a maximum of maxIterations_ and also make sure the last beta value is used for if more iterations are needed then the ones set by the user. -} - - -void DAF::setAnnealingScheme(double bStart, double bFinal, unsigned int nSteps) { - // The betas are calculated as a geometric series that takes nSteps - // steps to go from bStart to bFinal. - assert(bStart > bFinal); - assert(bFinal > 1.E-10); - assert(nSteps > 1); - - minIterations_ = nSteps; - maxIterations_ = nSteps + 4; - - betas_.clear(); - - for (unsigned int i=0; i 0) { - std::cout<<"DAF::calcWeights \n"; - } - - bool converged(true); - double maxAbsChange(0); - - const std::vector< TrackPoint* >& trackPoints = tr->getPointsWithMeasurement(); - for (std::vector< TrackPoint* >::const_iterator tp = trackPoints.begin(); tp != trackPoints.end(); ++tp) { - if (! (*tp)->hasFitterInfo(rep)) { - continue; - } - AbsFitterInfo* fi = (*tp)->getFitterInfo(rep); - if (dynamic_cast(fi) == NULL){ - Exception exc("DAF::getWeights ==> can only use KalmanFitterInfos",__LINE__,__FILE__); - throw exc; - } - KalmanFitterInfo* kfi = static_cast(fi); - - if (kfi->areWeightsFixed()) { - if (debugLvl_ > 0) { - std::cout<<"weights are fixed, continue \n"; - } - continue; - } - - unsigned int nMeas = kfi->getNumMeasurements(); - - std::vector phi(nMeas, 0.); - double phi_sum = 0; - double phi_cut = 0; - for(unsigned int j=0; jgetResidual(j, true, true); - const TVectorD& resid(residual.getState()); - TMatrixDSym Vinv(residual.getCov()); - double detV; - tools::invertMatrix(Vinv, &detV); // can throw an Exception - int hitDim = resid.GetNrows(); - // Needed for normalization, special cases for the two common cases, - // shouldn't matter, but the original code made some efforts to make - // this calculation faster, and it's not complex ... - double twoPiN = 2.*M_PI; - if (hitDim == 2) - twoPiN *= twoPiN; - else if (hitDim > 2) - twoPiN = pow(twoPiN, hitDim); - - double chi2 = Vinv.Similarity(resid); - if (debugLvl_ > 1) { - std::cout<<"chi2 = " << chi2 << "\n"; - } - - double norm = 1./sqrt(twoPiN * detV); - - phi[j] = norm*exp(-0.5*chi2/beta); - phi_sum += phi[j]; - //std::cerr << "hitDim " << hitDim << " fchi2Cuts[hitDim] " << fchi2Cuts[hitDim] << std::endl; - double cutVal = chi2Cuts_[hitDim]; - assert(cutVal>1.E-6); - //the following assumes that in the competing hits could have different V otherwise calculation could be simplified - phi_cut += norm*exp(-0.5*cutVal/beta); - } - catch(Exception& e) { - std::cerr << e.what(); - e.info(); - } - } - - for(unsigned int j=0; jgetMeasurementOnPlane(j)->getWeight())); - if (converged && absChange > deltaWeight_) { - converged = false; - if (absChange > maxAbsChange) - maxAbsChange = absChange; - } - - if (debugLvl_ > 0) { - if (debugLvl_ > 1 || absChange > deltaWeight_) { - std::cout<<"\t old weight: " << kfi->getMeasurementOnPlane(j)->getWeight(); - std::cout<<"\t new weight: " << weight; - } - } - - kfi->getMeasurementOnPlane(j)->setWeight(weight); - } - } - - if (debugLvl_ > 0) { - std::cout << "\t "; - std::cout << "max abs weight change = " << maxAbsChange << "\n"; - } - - return converged; -} - - -// Customized from generated Streamer. -void DAF::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::DAF. - - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::DAF thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - //This works around a msvc bug and should be harmless on other platforms - typedef genfit::AbsKalmanFitter baseClass0; - baseClass0::Streamer(R__b); - R__b >> deltaWeight_; - // weights_ are only of intermediate use -> not saved - { - std::vector &R__stl = betas_; - R__stl.clear(); - int R__i, R__n; - R__b >> R__n; - R__stl.reserve(R__n); - for (R__i = 0; R__i < R__n; R__i++) { - double R__t; - R__b >> R__t; - R__stl.push_back(R__t); - } - } - { - std::map &R__stl = chi2Cuts_; - R__stl.clear(); - int R__i, R__n; - R__b >> R__n; - for (R__i = 0; R__i < R__n; R__i++) { - int R__t; - R__b >> R__t; - double R__t2; - R__b >> R__t2; - typedef int Value_t; - std::pair R__t3(R__t,R__t2); - R__stl.insert(R__t3); - } - } - AbsKalmanFitter *p; - R__b >> p; - kalman_.reset(p); - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - //This works around a msvc bug and should be harmless on other platforms - typedef genfit::AbsKalmanFitter baseClass0; - baseClass0::Streamer(R__b); - R__b << deltaWeight_; - { - std::vector &R__stl = betas_; - int R__n=int(R__stl.size()); - R__b << R__n; - if(R__n) { - std::vector::iterator R__k; - for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) { - R__b << (*R__k); - } - } - } - { - std::map &R__stl = chi2Cuts_; - int R__n=int(R__stl.size()); - R__b << R__n; - if(R__n) { - std::map::iterator R__k; - for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) { - R__b << ((*R__k).first ); - R__b << ((*R__k).second); - } - } - } - R__b << kalman_.get(); - R__b.SetByteCount(R__c, kTRUE); - } -} - -} /* End of namespace genfit */ diff --git a/genfit/fitters/src/KalmanFitStatus.cc b/genfit/fitters/src/KalmanFitStatus.cc deleted file mode 100644 index 95fe9a483e..0000000000 --- a/genfit/fitters/src/KalmanFitStatus.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright 2013, Technische Universitaet Muenchen, Ludwig-Maximilians-Universität München - Authors: Johannes Rauch & Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - - -#include "KalmanFitStatus.h" - -#include - -namespace genfit { - -void KalmanFitStatus::Print(const Option_t*) const -{ - FitStatus::Print(); - if (fittedWithDaf_) std::cout << " track has been fitted with DAF,"; - if (fittedWithReferenceTrack_) std::cout << " track has been fitted with reference track,"; - if (isFitted_) { - std::cout << " numIterations = " << numIterations_ << ", "; - std::cout << "track length = " << trackLen_ << ", "; - std::cout << "fChi2 = " << fChi2_ << ", "; - std::cout << "bChi2 = " << FitStatus::getChi2() << ", "; - std::cout << "fNdf = " << fNdf_ << ", "; - std::cout << "bNdf = " << FitStatus::getNdf() << ", "; - std::cout << "fPVal = " << getForwardPVal() << ", "; - std::cout << "bPVal = " << getBackwardPVal() << "\n"; - } - std::cout << "\n"; -} - -} /* End of namespace genfit */ diff --git a/genfit/fitters/src/KalmanFittedStateOnPlane.cc b/genfit/fitters/src/KalmanFittedStateOnPlane.cc deleted file mode 100644 index 96b22e34f2..0000000000 --- a/genfit/fitters/src/KalmanFittedStateOnPlane.cc +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "KalmanFittedStateOnPlane.h" - -namespace genfit { - - -} /* End of namespace genfit */ - diff --git a/genfit/fitters/src/KalmanFitter.cc b/genfit/fitters/src/KalmanFitter.cc deleted file mode 100644 index 7c2e635a23..0000000000 --- a/genfit/fitters/src/KalmanFitter.cc +++ /dev/null @@ -1,700 +0,0 @@ -/* Copyright 2013, Ludwig-Maximilians Universität München, - Authors: Tobias Schlüter & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/* This implements the simple Kalman fitter with no reference track - that uses the stateSeed only until it forgets about it after the - first few hits. */ - -#include "KalmanFitter.h" - -#include "Exception.h" -#include "KalmanFitterInfo.h" -#include "KalmanFitStatus.h" -#include "Track.h" -#include "TrackPoint.h" -#include "Tools.h" - -#include -#include -#include -#include -#include - -using namespace genfit; - - -bool KalmanFitter::fitTrack(Track* tr, const AbsTrackRep* rep, - double& chi2, double& ndf, - int startId, int endId, int& nFailedHits) -{ - - if (multipleMeasurementHandling_ == unweightedClosestToReference || - multipleMeasurementHandling_ == weightedClosestToReference || - multipleMeasurementHandling_ == unweightedClosestToReferenceWire || - multipleMeasurementHandling_ == weightedClosestToReferenceWire) { - Exception exc("KalmanFitter::fitTrack ==> cannot use (un)weightedClosestToReference(Wire) as multiple measurement handling.",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - if (startId < 0) - startId += tr->getNumPointsWithMeasurement(); - if (endId < 0) - endId += tr->getNumPointsWithMeasurement(); - - int direction(1); - if (endId < startId) - direction = -1; - - chi2 = 0; - ndf = -1. * rep->getDim(); - - nFailedHits = 0; - - if (debugLvl_ > 0) { - std::cout << tr->getNumPointsWithMeasurement() << " TrackPoints w/ measurement in this track." << std::endl; - } - for (int i = startId; ; i+=direction) { - TrackPoint *tp = tr->getPointWithMeasurement(i); - assert(direction == +1 || direction == -1); - - if (debugLvl_ > 0) { - std::cout << " process TrackPoint nr. " << i << " (" << tp << ")\n"; - } - - try { - processTrackPoint(tp, rep, chi2, ndf, direction); - } - catch (Exception& e) { - std::cerr << e.what(); - - ++nFailedHits; - if (maxFailedHits_<0 || nFailedHits <= maxFailedHits_) { - tr->getPoint(i)->deleteFitterInfo(rep); - - if (i == endId) - break; - - if (debugLvl_ > 0) - std::cout << "There was an exception, try to continue with next TrackPoint " << i+direction << " \n"; - - continue; - } - - return false; - } - - if (i == endId) - break; - } - - return true; -} - - -void KalmanFitter::processTrackWithRep(Track* tr, const AbsTrackRep* rep, bool) -{ - - if (tr->getFitStatus(rep) != NULL && tr->getFitStatus(rep)->isTrackPruned()) { - Exception exc("KalmanFitter::processTrack: Cannot process pruned track!", __LINE__,__FILE__); - throw exc; - } - - TrackPoint* trackPoint = tr->getPointWithMeasurement(0); - - if (trackPoint->hasFitterInfo(rep) && - dynamic_cast(trackPoint->getFitterInfo(rep)) != NULL && - static_cast(trackPoint->getFitterInfo(rep))->hasUpdate(-1)) { - MeasuredStateOnPlane* update = static_cast(trackPoint->getFitterInfo(rep))->getUpdate(-1); - currentState_.reset(new MeasuredStateOnPlane(*update)); - if (debugLvl_ > 0) - std::cout << "take backward update of previous iteration as seed \n"; - } - if (rep != tr->getCardinalRep() && - trackPoint->hasFitterInfo(tr->getCardinalRep()) && - dynamic_cast(trackPoint->getFitterInfo(tr->getCardinalRep())) != NULL && - static_cast(trackPoint->getFitterInfo(tr->getCardinalRep()))->hasPredictionsAndUpdates() ) { - if (debugLvl_ > 0) - std::cout << "take smoothed state of cardinal rep fit as seed \n"; - TVector3 pos, mom; - TMatrixDSym cov; - const MeasuredStateOnPlane& fittedState = static_cast(trackPoint->getFitterInfo(tr->getCardinalRep()))->getFittedState(true); - tr->getCardinalRep()->getPosMomCov(fittedState, pos, mom, cov); - currentState_.reset(new MeasuredStateOnPlane(rep)); - rep->setPosMomCov(*currentState_, pos, mom, cov); - rep->setQop(*currentState_, tr->getCardinalRep()->getQop(fittedState)); - } - else { - currentState_.reset(new MeasuredStateOnPlane(rep)); - rep->setPosMomCov(*currentState_, tr->getStateSeed(), tr->getCovSeed()); - if (debugLvl_ > 0) - std::cout << "take seed state of track as seed \n"; - } - - // Only after we have linearly propagated the error into the TrackRep can we - // blow up the error in good faith. - currentState_->blowUpCov(blowUpFactor_); - - double oldChi2FW(1.e6); - double oldChi2BW(1.e6); - double oldPvalFW(0.); - - double oldPvalBW = 0.; - double chi2FW(0), ndfFW(0); - double chi2BW(0), ndfBW(0); - - int nFailedHitsForward(0), nFailedHitsBackward(0); - - - KalmanFitStatus* status = new KalmanFitStatus(); - tr->setFitStatus(status, rep); - - unsigned int nIt = 0; - for(;;) { - try { - if (debugLvl_ > 0) { - std::cout << "\033[1;21mstate pre" << std::endl; - currentState_->Print(); - std::cout << "\033[0mfitting" << std::endl; - } - - if (!fitTrack(tr, rep, chi2FW, ndfFW, 0, -1, nFailedHitsForward)) { - status->setIsFitted(false); - status->setIsFitConvergedFully(false); - status->setIsFitConvergedPartially(false); - status->setNFailedPoints(nFailedHitsForward); - return; - } - - if (debugLvl_ > 0) { - std::cout << "\033[1;21mstate post forward" << std::endl; - currentState_->Print(); - std::cout << "\033[0m"; - } - - // Backwards iteration: - currentState_->blowUpCov(blowUpFactor_); // blow up cov - - if (!fitTrack(tr, rep, chi2BW, ndfBW, -1, 0, nFailedHitsBackward)) { - status->setIsFitted(false); - status->setIsFitConvergedFully(false); - status->setIsFitConvergedPartially(false); - status->setNFailedPoints(nFailedHitsBackward); - return; - } - - if (debugLvl_ > 0) { - std::cout << "\033[1;21mstate post backward" << std::endl; - currentState_->Print(); - std::cout << "\033[0m"; - - std::cout << "old chi2s: " << oldChi2BW << ", " << oldChi2FW - << " new chi2s: " << chi2BW << ", " << chi2FW - << " oldPvals " << oldPvalFW << ", " << oldPvalBW << std::endl; - } - ++nIt; - - double PvalBW = ROOT::Math::chisquared_cdf_c(chi2BW, ndfBW); - double PvalFW = (debugLvl_ > 0) ? ROOT::Math::chisquared_cdf_c(chi2FW, ndfFW) : 0; // Don't calculate if not debugging as this function potentially takes a lot of time. - // See if p-value only changed little. If the initial - // parameters are very far off, initial chi^2 and the chi^2 - // after the first iteration will be both very close to zero, so - // we need to force at least two iterations here. Convergence - // doesn't make much sense before running twice anyway. - bool converged(false); - bool finished(false); - if (nIt >= minIterations_ && fabs(oldPvalBW - PvalBW) < deltaPval_) { - // if pVal ~ 0, check if chi2 has changed significantly - if (chi2BW == 0) { - finished = false; - } - else if (fabs(1 - fabs(oldChi2BW / chi2BW)) > relChi2Change_) { - finished = false; - } - else { - finished = true; - converged = true; - } - - if (PvalBW == 0.) - converged = false; - } - - if (finished) { - if (debugLvl_ > 0) { - std::cout << "Fit is finished! "; - if(converged) - std::cout << "Fit is converged! "; - std::cout << "\n"; - } - - if (nFailedHitsForward == 0 && nFailedHitsBackward == 0) - status->setIsFitConvergedFully(converged); - else - status->setIsFitConvergedFully(false); - - status->setIsFitConvergedPartially(converged); - - status->setNFailedPoints(std::max(nFailedHitsForward, nFailedHitsBackward)); - - break; - } - else { - oldPvalBW = PvalBW; - oldChi2BW = chi2BW; - if (debugLvl_ > 0) { - oldPvalFW = PvalFW; - oldChi2FW = chi2FW; - } - currentState_->blowUpCov(blowUpFactor_); // blow up cov - } - - if (nIt >= maxIterations_) { - if (debugLvl_ > 0) - std::cout << "KalmanFitter::number of max iterations reached!\n"; - break; - } - } - catch(Exception& e) { // should not happen, but I leave it in for safety - std::cerr << e.what(); - status->setIsFitted(false); - status->setIsFitConvergedFully(false); - status->setIsFitConvergedPartially(false); - status->setNFailedPoints(std::max(nFailedHitsForward, nFailedHitsBackward)); - return; - } - } - - status->setIsFitted(); - double charge(0); - TrackPoint* tp = tr->getPointWithMeasurementAndFitterInfo(0, rep); - if (tp != NULL) { - if (static_cast(tp->getFitterInfo(rep))->hasBackwardUpdate()) - charge = static_cast(tp->getFitterInfo(rep))->getBackwardUpdate()->getCharge(); - } - status->setNFailedPoints(std::max(nFailedHitsForward, nFailedHitsBackward)); - status->setCharge(charge); - status->setNumIterations(nIt); - status->setForwardChi2(chi2FW); - status->setBackwardChi2(chi2BW); - status->setForwardNdf(std::max(0., ndfFW)); - status->setBackwardNdf(std::max(0., ndfBW)); -} - - -void -KalmanFitter::processTrackPartially(Track* tr, const AbsTrackRep* rep, int startId, int endId) { - - if (tr->getFitStatus(rep) != NULL && tr->getFitStatus(rep)->isTrackPruned()) { - Exception exc("KalmanFitter::processTrack: Cannot process pruned track!", __LINE__,__FILE__); - throw exc; - } - - if (startId < 0) - startId += tr->getNumPointsWithMeasurement(); - if (endId < 0) - endId += tr->getNumPointsWithMeasurement(); - - int direction(1); - if (endId < startId) - direction = -1; - - - TrackPoint* trackPoint = tr->getPointWithMeasurement(startId); - TrackPoint* prevTrackPoint(NULL); - - - if (direction == 1 && startId > 0) - prevTrackPoint = tr->getPointWithMeasurement(startId - 1); - else if (direction == -1 && startId < (int)tr->getNumPointsWithMeasurement() - 1) - prevTrackPoint = tr->getPointWithMeasurement(startId + 1); - - - if (prevTrackPoint != NULL && - prevTrackPoint->hasFitterInfo(rep) && - dynamic_cast(prevTrackPoint->getFitterInfo(rep)) != NULL && - static_cast(prevTrackPoint->getFitterInfo(rep))->hasUpdate(direction)) { - currentState_.reset(new MeasuredStateOnPlane(*(static_cast(prevTrackPoint->getFitterInfo(rep))->getUpdate(direction)))); - if (debugLvl_ > 0) - std::cout << "take update of previous fitter info as seed \n"; - } - else if (rep != tr->getCardinalRep() && - trackPoint->hasFitterInfo(tr->getCardinalRep()) && - dynamic_cast(trackPoint->getFitterInfo(tr->getCardinalRep())) != NULL && - static_cast(trackPoint->getFitterInfo(tr->getCardinalRep()))->hasPredictionsAndUpdates() ) { - if (debugLvl_ > 0) - std::cout << "take smoothed state of cardinal rep fit as seed \n"; - TVector3 pos, mom; - TMatrixDSym cov; - const MeasuredStateOnPlane& fittedState = static_cast(trackPoint->getFitterInfo(tr->getCardinalRep()))->getFittedState(true); - tr->getCardinalRep()->getPosMomCov(fittedState, pos, mom, cov); - currentState_.reset(new MeasuredStateOnPlane(rep)); - rep->setPosMomCov(*currentState_, pos, mom, cov); - rep->setQop(*currentState_, tr->getCardinalRep()->getQop(fittedState)); - } - else { - currentState_.reset(new MeasuredStateOnPlane(rep)); - rep->setPosMomCov(*currentState_, tr->getStateSeed(), tr->getCovSeed()); - if (debugLvl_ > 0) - std::cout << "take seed of track as seed \n"; - } - - // if at first or last hit, blow up - if (startId == 0 || startId == (int)tr->getNumPointsWithMeasurement() - 1) { - currentState_->blowUpCov(blowUpFactor_); - if (debugLvl_ > 0) - std::cout << "blow up seed \n"; - } - - if (debugLvl_ > 0) { - std::cout << "\033[1;21mstate pre" << std::endl; - currentState_->Print(); - std::cout << "\033[0mfitting" << std::endl; - } - - double chi2, ndf; - int nFailedHits; - fitTrack(tr, rep, chi2, ndf, startId, endId, nFailedHits); // return value has no consequences here - -} - - -void -KalmanFitter::processTrackPoint(TrackPoint* tp, - const AbsTrackRep* rep, double& chi2, double& ndf, int direction) -{ - assert(direction == -1 || direction == +1); - - if (!tp->hasRawMeasurements()) - return; - - bool newFi(false); - - KalmanFitterInfo* fi; - if (! tp->hasFitterInfo(rep)) { - fi = new KalmanFitterInfo(tp, rep); - tp->setFitterInfo(fi); - newFi = true; - } - else - fi = static_cast(tp->getFitterInfo(rep)); - - SharedPlanePtr plane; - bool oldWeightsFixed(false); - std::vector oldWeights; - - // construct measurementsOnPlane if forward fit - if (newFi) { - // remember old weights - oldWeights = fi->getWeights(); - oldWeightsFixed = fi->areWeightsFixed(); - - // delete outdated stuff - fi->deleteForwardInfo(); - fi->deleteBackwardInfo(); - fi->deleteMeasurementInfo(); - - // construct plane with first measurement - const std::vector< genfit::AbsMeasurement* >& rawMeasurements = tp->getRawMeasurements(); - plane = rawMeasurements[0]->constructPlane(*currentState_); - } - else - plane = fi->getPlane(); - - - - // Extrapolate - MeasuredStateOnPlane* state = new MeasuredStateOnPlane(*currentState_); - double extLen = rep->extrapolateToPlane(*state, plane); - - if (debugLvl_ > 0) { - std::cout << "extrapolated by " << extLen << std::endl; - } - //std::cout << "after extrap: " << std::endl; - //state.Print(); - - // unique_ptr takes care of disposing of the old prediction, takes ownership of state. - fi->setPrediction(state, direction); - - - // construct new MeasurementsOnPlane - if (newFi) { - const std::vector< genfit::AbsMeasurement* >& rawMeasurements = tp->getRawMeasurements(); - for (std::vector< genfit::AbsMeasurement* >::const_iterator it = rawMeasurements.begin(); it != rawMeasurements.end(); ++it) { - fi->addMeasurementsOnPlane((*it)->constructMeasurementsOnPlane(*state)); - } - if (oldWeights.size() == fi->getNumMeasurements()) { - fi->setWeights(oldWeights); - fi->fixWeights(oldWeightsFixed); - if (debugLvl_ > 0) { - std::cout << "set old weights \n"; - } - } - assert(fi->getPlane() == plane); - assert(fi->checkConsistency()); - } - - if (debugLvl_ > 0) { - std::cout << "its plane is at R = " << plane->getO().Perp() - << " with normal pointing along (" << plane->getNormal().X() << ", " << plane->getNormal().Y() << ", " << plane->getNormal().Z() << ")" << std::endl; - } - - - // update(s) - TVectorD stateVector(state->getState()); - TMatrixDSym cov(state->getCov()); - - double chi2inc = 0; - double ndfInc = 0; - const std::vector measurements = getMeasurements(fi, tp, direction); - for (std::vector::const_iterator it = measurements.begin(); it != measurements.end(); ++it) { - const MeasurementOnPlane& mOnPlane = **it; - const double weight = mOnPlane.getWeight(); - - if (debugLvl_ > 0) { - std::cout << "Weight of measurement: " << weight << "\n"; - } - - if (!canIgnoreWeights() && weight <= 1.01E-10) { - if (debugLvl_ > 0) { - std::cout << "Weight of measurement is almost 0, continue ... \n"; - } - continue; - } - - const TVectorD& measurement(mOnPlane.getState()); - const AbsHMatrix* H(mOnPlane.getHMatrix()); - // (weighted) cov - const TMatrixDSym& V((!canIgnoreWeights() && weight < 0.99999) ? - 1./weight * mOnPlane.getCov() : - mOnPlane.getCov()); - if (debugLvl_ > 1) { - std::cout << "\033[31m"; - std::cout << "State prediction: "; stateVector.Print(); - std::cout << "Cov prediction: "; state->getCov().Print(); - std::cout << "\033[0m"; - std::cout << "\033[34m"; - std::cout << "measurement: "; measurement.Print(); - std::cout << "measurement covariance V: "; V.Print(); - //cov.Print(); - //measurement.Print(); - } - - TVectorD res(measurement - H->Hv(stateVector)); - if (debugLvl_ > 1) { - std::cout << "Residual = (" << res(0); - if (res.GetNrows() > 1) - std::cout << ", " << res(1); - std::cout << ")" << std::endl; - std::cout << "\033[0m"; - } - // If hit, do Kalman algebra. - - if (squareRootFormalism_) - { - // Square Root formalism, Anderson & Moore, 6.5.12 gives the - // formalism for combined update and prediction in that - // sequence. We need the opposite sequence. Therefore, this - // is my own invention. This is not optimized for speed - // outside the QR decomposition code (which would be faster if - // it were to work on the transposed matrix). First step - // would be replacing the use of TMatrixDSymEigen with an LDLt - // transformation. - TMatrixD F; - TMatrixDSym noise; - TVectorD deltaState; - rep->getForwardJacobianAndNoise(F, noise, deltaState); - const TMatrixDSym& oldCov(currentState_->getCov()); - - // Square Roots: - // - // The noise matrix is only positive semi-definite, for instance - // no noise on q/p. A Cholesky decomposition is therefore not - // possible. Hence we pull out the eigenvalues, viz noise = z d - // z^T (with z orthogonal, d diagonal) and then construct the - // square root according to Q^T = sqrt(d) z where sqrt is - // applied element-wise and negative eigenvalues are forced to - // zero. We then reduce the matrix such that the zero - // eigenvalues don't appear in the remainder of the calculation. - TMatrixDSymEigen eig(noise); - TMatrixD Q(eig.GetEigenVectors()); - const TVectorD& evs(eig.GetEigenValues()); - // Multiplication with a diagonal matrix ... eigenvalues are - // sorted in descending order. - int iCol = 0; - for (; iCol < Q.GetNcols(); ++iCol) { - double ev = evs(iCol) > 0 ? sqrt(evs(iCol)) : 0; - if (ev == 0) - break; - for (int j = 0; j < Q.GetNrows(); ++j) - Q(j,iCol) *= ev; - } - if (iCol < Q.GetNrows()) { - // Hit zero eigenvalue, resize matrix ... - Q.ResizeTo(iCol, Q.GetNcols()); - } - // This gives the original matrix: - // TMatrixDSym(TMatrixDSym::kAtA,TMatrixD(TMatrixD::kTransposed,Q)).Print(); - // i.e., we now have the transposed we need. - - TDecompChol oldCovDecomp(oldCov); - oldCovDecomp.Decompose(); - const TMatrixD& S(oldCovDecomp.GetU()); // this actually the transposed we want. - - TDecompChol decompR(V); - decompR.Decompose(); - - TMatrixD pre(S.GetNrows() + Q.GetNrows() + V.GetNrows(), - S.GetNcols() + V.GetNcols()); - TMatrixD SFt(S, TMatrixD::kMultTranspose, F); - pre.SetSub( 0, 0,decompR.GetU());/* upper right block is zero */ - pre.SetSub( V.GetNrows(), 0,H->MHt(SFt)); pre.SetSub(V.GetNrows(), V.GetNcols(),SFt); - if (Q.GetNrows() > 0) { // needed to suppress warnings when inserting an empty Q - pre.SetSub(S.GetNrows()+V.GetNrows(),0,H->MHt(Q)); pre.SetSub(S.GetNrows()+V.GetNrows(),V.GetNcols(), Q); - } - - tools::QR(pre); - const TMatrixD& r = pre; - - TMatrixD R(r.GetSub(0, V.GetNrows()-1, 0, V.GetNcols()-1)); - //R.Print(); - TMatrixD K(TMatrixD::kTransposed, r.GetSub(0, V.GetNrows()-1, V.GetNcols(), pre.GetNcols()-1)); - //K.Print(); - //(K*R).Print(); - TMatrixD Snew(r.GetSub(V.GetNrows(), V.GetNrows() + S.GetNrows() - 1, - V.GetNcols(), pre.GetNcols()-1)); - //Snew.Print(); - // No need for matrix inversion. - TVectorD update(res); - tools::transposedForwardSubstitution(R, update); - update *= K; - stateVector += update; - cov = TMatrixDSym(TMatrixDSym::kAtA, Snew); // Note that this is transposed in just the right way. - } - else - { - // calculate kalman gain ------------------------------ - // calculate covsum (V + HCH^T) and invert - TMatrixDSym covSumInv(cov); - H->HMHt(covSumInv); - covSumInv += V; - tools::invertMatrix(covSumInv); - - TMatrixD CHt(H->MHt(cov)); - TVectorD update(TMatrixD(CHt, TMatrixD::kMult, covSumInv) * res); - //TMatrixD(CHt, TMatrixD::kMult, covSumInv).Print(); - - if (debugLvl_ > 1) { - //std::cout << "STATUS:" << std::endl; - //stateVector.Print(); - std::cout << "\033[32m"; - std::cout << "Update: "; update.Print(); - std::cout << "\033[0m"; - //cov.Print(); - } - - stateVector += update; - covSumInv.Similarity(CHt); // with (C H^T)^T = H C^T = H C (C is symmetric) - cov -= covSumInv; - } - - if (debugLvl_ > 1) { - std::cout << "\033[32m"; - std::cout << "updated state: "; stateVector.Print(); - std::cout << "updated cov: "; cov.Print(); - } - - TVectorD resNew(measurement - H->Hv(stateVector)); - if (debugLvl_ > 1) { - std::cout << "Residual New = (" << resNew(0); - - if (resNew.GetNrows() > 1) - std::cout << ", " << resNew(1); - std::cout << ")" << std::endl; - std::cout << "\033[0m"; - } - - /*TDecompChol dec(cov); - TMatrixDSym mist(cov); - bool status = dec.Invert(mist); - if (!status) { - if (debugLvl_ > 0) { - std::cout << "new cov not pos. def." << std::endl; - } - }*/ - - // Calculate chi² - TMatrixDSym HCHt(cov); - H->HMHt(HCHt); - HCHt -= V; - HCHt *= -1; - - tools::invertMatrix(HCHt); - - chi2inc += HCHt.Similarity(resNew); - - if (!canIgnoreWeights()) { - ndfInc += weight * measurement.GetNrows(); - } - else - ndfInc += measurement.GetNrows(); - - if (debugLvl_ > 0) { - std::cout << "chi² increment = " << chi2inc << std::endl; - } - } // end loop over measurements - - currentState_->setStateCovPlane(stateVector, cov, plane); - currentState_->setAuxInfo(state->getAuxInfo()); - - chi2 += chi2inc; - ndf += ndfInc; - - // set update - KalmanFittedStateOnPlane* updatedSOP = new KalmanFittedStateOnPlane(*currentState_, chi2inc, ndfInc); - fi->setUpdate(updatedSOP, direction); -} - - -// Modified from auto-generated streamer to deal with scoped_ptr correctly. -void KalmanFitter::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::KalmanFitter. - - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::KalmanFitter thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - //This works around a msvc bug and should be harmless on other platforms - typedef genfit::AbsKalmanFitter baseClass0; - baseClass0::Streamer(R__b); - MeasuredStateOnPlane *p = 0; - R__b >> p; - currentState_.reset(p); - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - //This works around a msvc bug and should be harmless on other platforms - typedef genfit::AbsKalmanFitter baseClass0; - baseClass0::Streamer(R__b); - R__b << currentState_.get(); - R__b.SetByteCount(R__c, kTRUE); - } -} diff --git a/genfit/fitters/src/KalmanFitterInfo.cc b/genfit/fitters/src/KalmanFitterInfo.cc deleted file mode 100644 index 8a53cf9144..0000000000 --- a/genfit/fitters/src/KalmanFitterInfo.cc +++ /dev/null @@ -1,746 +0,0 @@ -/* Copyright 2008-2013, Technische Universitaet Muenchen, Ludwig-Maximilians-Universität München - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch & Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "KalmanFitterInfo.h" - -#include -#include -#include - -#include "Exception.h" -#include "Tools.h" -#include "Track.h" -#include "TrackPoint.h" - -//#define DEBUG - - -namespace genfit { - -KalmanFitterInfo::KalmanFitterInfo() : - AbsFitterInfo(), fixWeights_(false) -{ - ; -} - -KalmanFitterInfo::KalmanFitterInfo(const TrackPoint* trackPoint, const AbsTrackRep* rep) : - AbsFitterInfo(trackPoint, rep), fixWeights_(false) -{ - ; -} - -KalmanFitterInfo::~KalmanFitterInfo() { - deleteMeasurementInfo(); -} - - -KalmanFitterInfo* KalmanFitterInfo::clone() const { - KalmanFitterInfo* retVal = new KalmanFitterInfo(this->getTrackPoint(), this->getRep()); - if (hasReferenceState()) - retVal->setReferenceState(new ReferenceStateOnPlane(*getReferenceState())); - if (hasForwardPrediction()) - retVal->setForwardPrediction(new MeasuredStateOnPlane(*getForwardPrediction())); - if (hasForwardUpdate()) - retVal->setForwardUpdate(new KalmanFittedStateOnPlane(*getForwardUpdate())); - if (hasBackwardPrediction()) - retVal->setBackwardPrediction(new MeasuredStateOnPlane(*getBackwardPrediction())); - if (hasBackwardUpdate()) - retVal->setBackwardUpdate(new KalmanFittedStateOnPlane(*getBackwardUpdate())); - - retVal->measurementsOnPlane_.reserve(getNumMeasurements()); - for (std::vector::const_iterator it = this->measurementsOnPlane_.begin(); it != this->measurementsOnPlane_.end(); ++it) { - retVal->addMeasurementOnPlane(new MeasurementOnPlane(**it)); - } - - retVal->fixWeights_ = this->fixWeights_; - - return retVal; -} - - -MeasurementOnPlane KalmanFitterInfo::getAvgWeightedMeasurementOnPlane(bool ignoreWeights) const { - - MeasurementOnPlane retVal(*(measurementsOnPlane_[0])); - - if(measurementsOnPlane_.size() == 1) { - if (ignoreWeights) { - retVal.setWeight(1.); - } - else { - double weight = (measurementsOnPlane_[0])->getWeight(); - if (weight != 1.) { - retVal.getCov() *= 1. / weight; - } - retVal.setWeight(weight); - } - return retVal; - } - - // more than one hit - - double sumOfWeights(0), weight(0); - - retVal.getState().Zero(); - retVal.getCov().Zero(); - - TMatrixDSym covInv; - - for(unsigned int i=0; i0) { - // make sure we have compatible measurement types - // TODO: replace with Exceptions! - assert(measurementsOnPlane_[i]->getPlane() == measurementsOnPlane_[0]->getPlane()); - assert(*(measurementsOnPlane_[i]->getHMatrix()) == *(measurementsOnPlane_[0]->getHMatrix())); - } - - tools::invertMatrix(measurementsOnPlane_[i]->getCov(), covInv); // invert cov - if (ignoreWeights) { - sumOfWeights += 1.; - } - else { - weight = measurementsOnPlane_[i]->getWeight(); - sumOfWeights += weight; - covInv *= weight; // weigh cov - } - retVal.getCov() += covInv; // covInv is already inverted and weighted - - retVal.getState() += covInv * measurementsOnPlane_[i]->getState(); - } - - // invert Cov - tools::invertMatrix(retVal.getCov()); - - retVal.getState() *= retVal.getCov(); - - retVal.setWeight(sumOfWeights); - - return retVal; -} - - -MeasurementOnPlane* KalmanFitterInfo::getClosestMeasurementOnPlane(const StateOnPlane* sop) const { - if(measurementsOnPlane_.size() == 0) - return NULL; - - if(measurementsOnPlane_.size() == 1) - return getMeasurementOnPlane(0); - - double normMin(9.99E99); - unsigned int iMin(0); - const AbsHMatrix* H = measurementsOnPlane_[0]->getHMatrix(); - for (unsigned int i=0; igetHMatrix()) != *H){ - Exception e("KalmanFitterInfo::getClosestMeasurementOnPlane: Cannot compare measurements with different H-Matrices. Maybe you have to select a different multipleMeasurementHandling.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - - TVectorD res = measurementsOnPlane_[i]->getState() - H->Hv(sop->getState()); - double norm = sqrt(res.Norm2Sqr()); - if (norm < normMin) { - normMin = norm; - iMin = i; - } - } - - return getMeasurementOnPlane(iMin); -} - - -std::vector KalmanFitterInfo::getWeights() const { - std::vector retVal(getNumMeasurements()); - - for (unsigned int i=0; igetWeight(); - } - - return retVal; -} - - -const MeasuredStateOnPlane& KalmanFitterInfo::getFittedState(bool biased) const { - if (biased) { - if (fittedStateBiased_.get() != NULL) - return *fittedStateBiased_; - - if (this->getTrackPoint()->getTrack()->getPointWithMeasurementAndFitterInfo(-1, this->getRep()) - == this->getTrackPoint()) {// last measurement - if(forwardUpdate_.get() == NULL) { - Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - #ifdef DEBUG - std::cout << "KalmanFitterInfo::getFittedState - biased at last measurement = forwardUpdate_ \n"; - #endif - return *forwardUpdate_; - } - else if (this->getTrackPoint()->getTrack()->getPointWithMeasurementAndFitterInfo(0, this->getRep()) - == this->getTrackPoint()) { // first measurement - if(backwardUpdate_.get() == NULL) { - Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - #ifdef DEBUG - std::cout << "KalmanFitterInfo::getFittedState - biased at first measurement = backwardUpdate_ \n"; - backwardUpdate_->Print(); - #endif - return *backwardUpdate_; - } - - if(forwardUpdate_.get() == NULL || backwardPrediction_.get() == NULL) { - Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - #ifdef DEBUG - std::cout << "KalmanFitterInfo::getFittedState - biased = mean(forwardUpdate_, backwardPrediction_) \n"; - #endif - fittedStateBiased_.reset(new MeasuredStateOnPlane(calcAverageState(*forwardUpdate_, *backwardPrediction_))); - return *fittedStateBiased_; - } - else { // unbiased - if (fittedStateUnbiased_.get() != NULL) - return *fittedStateUnbiased_; - - if (this->getTrackPoint()->getTrack()->getPointWithMeasurementAndFitterInfo(-1, this->getRep()) - == this->getTrackPoint()) { // last measurement - if(forwardPrediction_.get() == NULL) { - Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - #ifdef DEBUG - std::cout << "KalmanFitterInfo::getFittedState - unbiased at last measurement = forwardPrediction_ \n"; - #endif - return *forwardPrediction_; - } - else if (this->getTrackPoint()->getTrack()->getPointWithMeasurementAndFitterInfo(0, this->getRep()) - == this->getTrackPoint()) { // first measurement - if(backwardPrediction_.get() == NULL) { - Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - #ifdef DEBUG - std::cout << "KalmanFitterInfo::getFittedState - unbiased at first measurement = backwardPrediction_ \n"; - #endif - return *backwardPrediction_; - } - - if(forwardPrediction_.get() == NULL || backwardPrediction_.get() == NULL) { - Exception e("KalmanFitterInfo::getFittedState: Needed updates/redictions not available in this FitterInfo.", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - #ifdef DEBUG - std::cout << "KalmanFitterInfo::getFittedState - unbiased = mean(forwardPrediction_, backwardPrediction_) \n"; - #endif - fittedStateUnbiased_.reset(new MeasuredStateOnPlane(calcAverageState(*forwardPrediction_, *backwardPrediction_))); - return *fittedStateUnbiased_; - } - -} - - -MeasurementOnPlane KalmanFitterInfo::getResidual(unsigned int iMeasurement, bool biased, bool onlyMeasurementErrors) const { - - const MeasuredStateOnPlane& smoothedState = getFittedState(biased); - const MeasurementOnPlane* measurement = measurementsOnPlane_.at(iMeasurement); - const SharedPlanePtr& plane = measurement->getPlane(); - - // check equality of planes and reps - if(*(smoothedState.getPlane()) != *plane) { - Exception e("KalmanFitterInfo::getResidual: smoothedState and measurement are not defined in the same plane.", __LINE__,__FILE__); - throw e; - } - if(smoothedState.getRep() != measurement->getRep()) { - Exception e("KalmanFitterInfo::getResidual: smoothedState and measurement are not defined wrt the same TrackRep.", __LINE__,__FILE__); - throw e; - } - - const AbsHMatrix* H = measurement->getHMatrix(); - - //TODO: shouldn't the definition be (smoothed - measured) ? - // res = -(H*smoothedState - measuredState) - TVectorD res(H->Hv(smoothedState.getState())); - res -= measurement->getState(); - res *= -1; - - if (onlyMeasurementErrors) { - return MeasurementOnPlane(res, measurement->getCov(), plane, smoothedState.getRep(), H->clone(), measurement->getWeight()); - } - - TMatrixDSym cov(smoothedState.getCov()); - H->HMHt(cov); - cov += measurement->getCov(); - - return MeasurementOnPlane(res, cov, plane, smoothedState.getRep(), H->clone(), measurement->getWeight()); -} - - -void KalmanFitterInfo::setReferenceState(ReferenceStateOnPlane* referenceState) { - referenceState_.reset(referenceState); - if (referenceState_) - setPlane(referenceState_->getPlane()); - - // if plane has changed, delete outdated info - /*if (forwardPrediction_ && forwardPrediction_->getPlane() != getPlane()) - setForwardPrediction(0); - - if (forwardUpdate_ && forwardUpdate_->getPlane() != getPlane()) - setForwardUpdate(0); - - if (backwardPrediction_ && backwardPrediction_->getPlane() != getPlane()) - setBackwardPrediction(0); - - if (backwardUpdate_ && backwardUpdate_->getPlane() != getPlane()) - setBackwardUpdate(0); - - if (measurementsOnPlane_.size() > 0 && measurementsOnPlane_[0]->getPlane() != getPlane()) - deleteMeasurementInfo(); - */ -} - - -void KalmanFitterInfo::setForwardPrediction(MeasuredStateOnPlane* forwardPrediction) { - forwardPrediction_.reset(forwardPrediction); - fittedStateUnbiased_.reset(); - fittedStateBiased_.reset(); - if (forwardPrediction_) - setPlane(forwardPrediction_->getPlane()); -} - -void KalmanFitterInfo::setBackwardPrediction(MeasuredStateOnPlane* backwardPrediction) { - backwardPrediction_.reset(backwardPrediction); - fittedStateUnbiased_.reset(); - fittedStateBiased_.reset(); - if (backwardPrediction_) - setPlane(backwardPrediction_->getPlane()); -} - -void KalmanFitterInfo::setForwardUpdate(KalmanFittedStateOnPlane* forwardUpdate) { - forwardUpdate_.reset(forwardUpdate); - fittedStateUnbiased_.reset(); - fittedStateBiased_.reset(); - if (forwardUpdate_) - setPlane(forwardUpdate_->getPlane()); -} - -void KalmanFitterInfo::setBackwardUpdate(KalmanFittedStateOnPlane* backwardUpdate) { - backwardUpdate_.reset(backwardUpdate); - fittedStateUnbiased_.reset(); - fittedStateBiased_.reset(); - if (backwardUpdate_) - setPlane(backwardUpdate_->getPlane()); -} - - -void KalmanFitterInfo::setMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane) { - deleteMeasurementInfo(); - - for (std::vector::const_iterator m = measurementsOnPlane.begin(), mend = measurementsOnPlane.end(); m < mend; ++m) { - addMeasurementOnPlane(*m); - } -} - - -void KalmanFitterInfo::addMeasurementOnPlane(MeasurementOnPlane* measurementOnPlane) { - if (measurementsOnPlane_.size() == 0) - setPlane(measurementOnPlane->getPlane()); - - measurementsOnPlane_.push_back(measurementOnPlane); -} - -void KalmanFitterInfo::addMeasurementsOnPlane(const std::vector< genfit::MeasurementOnPlane* >& measurementsOnPlane) { - for (std::vector::const_iterator m = measurementsOnPlane.begin(), mend = measurementsOnPlane.end(); m < mend; ++m) { - addMeasurementOnPlane(*m); - } -} - - -void KalmanFitterInfo::setRep(const AbsTrackRep* rep) { - rep_ = rep; - - if (referenceState_) - referenceState_->setRep(rep); - - if (forwardPrediction_) - forwardPrediction_->setRep(rep); - - if (forwardUpdate_) - forwardUpdate_->setRep(rep); - - if (backwardPrediction_) - backwardPrediction_->setRep(rep); - - if (backwardUpdate_) - backwardUpdate_->setRep(rep); - - for (std::vector::iterator it = measurementsOnPlane_.begin(); it != measurementsOnPlane_.end(); ++it) { - (*it)->setRep(rep); - } -} - - -void KalmanFitterInfo::setWeights(const std::vector& weights) { - - if (weights.size() != getNumMeasurements()) { - Exception e("KalmanFitterInfo::setWeights: weights do not have the same size as measurementsOnPlane", __LINE__,__FILE__); - throw e; - } - - if (fixWeights_) { - std::cerr << "KalmanFitterInfo::setWeights - WARNING: setting weights even though weights are fixed!" << std::endl; - } - - for (unsigned int i=0; isetWeight(weights[i]); - } -} - - -void KalmanFitterInfo::deleteForwardInfo() { - setForwardPrediction(NULL); - setForwardUpdate(NULL); - fittedStateUnbiased_.reset(); - fittedStateBiased_.reset(); -} - -void KalmanFitterInfo::deleteBackwardInfo() { - setBackwardPrediction(NULL); - setBackwardUpdate(NULL); - fittedStateUnbiased_.reset(); - fittedStateBiased_.reset(); -} - -void KalmanFitterInfo::deletePredictions() { - setForwardPrediction(NULL); - setBackwardPrediction(NULL); - fittedStateUnbiased_.reset(); - fittedStateBiased_.reset(); -} - -void KalmanFitterInfo::deleteMeasurementInfo() { - // FIXME: need smart pointers / smart containers here - for (size_t i = 0; i < measurementsOnPlane_.size(); ++i) - delete measurementsOnPlane_[i]; - - measurementsOnPlane_.clear(); -} - - -void KalmanFitterInfo::Print(const Option_t*) const { - std::cout << "genfit::KalmanFitterInfo. Belongs to TrackPoint " << trackPoint_ << "; TrackRep " << rep_ << "\n"; - - if (fixWeights_) - std::cout << "Weights are fixed.\n"; - - for (unsigned int i=0; iPrint(); - } - - if (referenceState_) { - std::cout << "Reference state: "; referenceState_->Print(); - } - if (forwardPrediction_) { - std::cout << "Forward prediction_: "; forwardPrediction_->Print(); - } - if (forwardUpdate_) { - std::cout << "Forward update: "; forwardUpdate_->Print(); - } - if (backwardPrediction_) { - std::cout << "Backward prediction_: "; backwardPrediction_->Print(); - } - if (backwardUpdate_) { - std::cout << "Backward update: "; backwardUpdate_->Print(); - } - -} - - -bool KalmanFitterInfo::checkConsistency() const { - - bool retVal(true); - - // check if in a TrackPoint - if (!trackPoint_) { - std::cerr << "KalmanFitterInfo::checkConsistency(): trackPoint_ is NULL" << std::endl; - retVal = false; - } - - // check if there is a reference state - /*if (!referenceState_) { - std::cerr << "KalmanFitterInfo::checkConsistency(): referenceState_ is NULL" << std::endl; - retVal = false; - }*/ - - SharedPlanePtr plane = getPlane(); - - if (plane.get() == NULL) { - if (!(referenceState_ || forwardPrediction_ || forwardUpdate_ || backwardPrediction_ || backwardUpdate_ || measurementsOnPlane_.size() > 0)) - return true; - std::cerr << "KalmanFitterInfo::checkConsistency(): plane is NULL" << std::endl; - retVal = false; - } - - TVector3 oTest = plane->getO(); // see if the plane object is there - oTest *= 47.11; - - // if more than one measurement, check if they have the same dimensionality - if (measurementsOnPlane_.size() > 1) { - int dim = measurementsOnPlane_[0]->getState().GetNrows(); - for (unsigned int i = 1; igetState().GetNrows() != dim) { - std::cerr << "KalmanFitterInfo::checkConsistency(): measurementsOnPlane_ do not all have the same dimensionality" << std::endl; - retVal = false; - } - } - if (dim == 0) { - std::cerr << "KalmanFitterInfo::checkConsistency(): measurementsOnPlane_ have dimension 0" << std::endl; - retVal = false; - } - } - - // see if everything else is defined wrt this plane and rep_ - int dim = rep_->getDim(); // check dim - if (referenceState_) { - if(referenceState_->getPlane() != plane) { - std::cerr << "KalmanFitterInfo::checkConsistency(): referenceState_ is not defined with the correct plane " << referenceState_->getPlane().get() << " vs. " << plane.get() << std::endl; - retVal = false; - } - if (referenceState_->getRep() != rep_) { - std::cerr << "KalmanFitterInfo::checkConsistency(): referenceState_ is not defined with the correct TrackRep" << std::endl; - retVal = false; - } - if (referenceState_->getState().GetNrows() != dim) { - std::cerr << "KalmanFitterInfo::checkConsistency(): referenceState_ does not have the right dimension!" << std::endl; - retVal = false; - } - } - - if (forwardPrediction_) { - if(forwardPrediction_->getPlane() != plane) { - std::cerr << "KalmanFitterInfo::checkConsistency(): forwardPrediction_ is not defined with the correct plane" << std::endl; - retVal = false; - } - if(forwardPrediction_->getRep() != rep_) { - std::cerr << "KalmanFitterInfo::checkConsistency(): forwardPrediction_ is not defined with the correct TrackRep" << std::endl; - retVal = false; - } - if (forwardPrediction_->getState().GetNrows() != dim || forwardPrediction_->getCov().GetNrows() != dim) { - std::cerr << "KalmanFitterInfo::checkConsistency(): forwardPrediction_ does not have the right dimension!" << std::endl; - retVal = false; - } - } - if (forwardUpdate_) { - if(forwardUpdate_->getPlane() != plane) { - std::cerr << "KalmanFitterInfo::checkConsistency(): forwardUpdate_ is not defined with the correct plane" << std::endl; - retVal = false; - } - if(forwardUpdate_->getRep() != rep_) { - std::cerr << "KalmanFitterInfo::checkConsistency(): forwardUpdate_ is not defined with the correct TrackRep" << std::endl; - retVal = false; - } - if (forwardUpdate_->getState().GetNrows() != dim || forwardUpdate_->getCov().GetNrows() != dim) { - std::cerr << "KalmanFitterInfo::checkConsistency(): forwardUpdate_ does not have the right dimension!" << std::endl; - retVal = false; - } - } - - if (backwardPrediction_) { - if(backwardPrediction_->getPlane() != plane) { - std::cerr << "KalmanFitterInfo::checkConsistency(): backwardPrediction_ is not defined with the correct plane" << std::endl; - retVal = false; - } - if(backwardPrediction_->getRep() != rep_) { - std::cerr << "KalmanFitterInfo::checkConsistency(): backwardPrediction_ is not defined with the correct TrackRep" << std::endl; - retVal = false; - } - if (backwardPrediction_->getState().GetNrows() != dim || backwardPrediction_->getCov().GetNrows() != dim) { - std::cerr << "KalmanFitterInfo::checkConsistency(): backwardPrediction_ does not have the right dimension!" << std::endl; - retVal = false; - } - } - if (backwardUpdate_) { - if(backwardUpdate_->getPlane() != plane) { - std::cerr << "KalmanFitterInfo::checkConsistency(): backwardUpdate_ is not defined with the correct plane" << std::endl; - retVal = false; - } - if(backwardUpdate_->getRep() != rep_) { - std::cerr << "KalmanFitterInfo::checkConsistency(): backwardUpdate_ is not defined with the correct TrackRep" << std::endl; - retVal = false; - } - if (backwardUpdate_->getState().GetNrows() != dim || backwardUpdate_->getCov().GetNrows() != dim) { - std::cerr << "KalmanFitterInfo::checkConsistency(): backwardUpdate_ does not have the right dimension!" << std::endl; - retVal = false; - } - } - - for (std::vector::const_iterator it = measurementsOnPlane_.begin(); it != measurementsOnPlane_.end(); ++it) { - if((*it)->getPlane() != plane) { - std::cerr << "KalmanFitterInfo::checkConsistency(): measurement is not defined with the correct plane" << std::endl; - retVal = false; - } - if((*it)->getRep() != rep_) { - std::cerr << "KalmanFitterInfo::checkConsistency(): measurement is not defined with the correct TrackRep" << std::endl; - retVal = false; - } - if ((*it)->getState().GetNrows() == 0) { - std::cerr << "KalmanFitterInfo::checkConsistency(): measurement has dimension 0!" << std::endl; - retVal = false; - } - } - - // see if there is an update w/o prediction or measurement - if (forwardUpdate_ && !forwardPrediction_) { - std::cerr << "KalmanFitterInfo::checkConsistency(): forwardUpdate_ w/o forwardPrediction_" << std::endl; - retVal = false; - } - - if (forwardUpdate_ && measurementsOnPlane_.size() == 0) { - std::cerr << "KalmanFitterInfo::checkConsistency(): forwardUpdate_ w/o measurement" << std::endl; - retVal = false; - } - - - if (backwardUpdate_ && !backwardPrediction_) { - std::cerr << "KalmanFitterInfo::checkConsistency(): backwardUpdate_ w/o backwardPrediction_" << std::endl; - retVal = false; - } - - if (backwardUpdate_ && measurementsOnPlane_.size() == 0) { - std::cerr << "KalmanFitterInfo::checkConsistency(): backwardUpdate_ w/o measurement" << std::endl; - retVal = false; - } - - - return retVal; -} - - -// Modified from auto-generated Streamer to correctly deal with smart pointers. -void KalmanFitterInfo::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::KalmanFitterInfo. - - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::KalmanFitterInfo thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - //This works around a msvc bug and should be harmless on other platforms - typedef genfit::AbsFitterInfo baseClass0; - baseClass0::Streamer(R__b); - int flag; - R__b >> flag; - deleteForwardInfo(); - deleteBackwardInfo(); - deleteReferenceInfo(); - deleteMeasurementInfo(); - if (flag & 1) { - referenceState_.reset(new ReferenceStateOnPlane()); - referenceState_->Streamer(R__b); - referenceState_->setPlane(getPlane()); - // rep needs to be fixed up - } - if (flag & (1 << 1)) { - forwardPrediction_.reset(new MeasuredStateOnPlane()); - forwardPrediction_->Streamer(R__b); - forwardPrediction_->setPlane(getPlane()); - // rep needs to be fixed up - } - if (flag & (1 << 2)) { - forwardUpdate_.reset(new KalmanFittedStateOnPlane()); - forwardUpdate_->Streamer(R__b); - forwardUpdate_->setPlane(getPlane()); - // rep needs to be fixed up - } - if (flag & (1 << 3)) { - backwardPrediction_.reset(new MeasuredStateOnPlane()); - backwardPrediction_->Streamer(R__b); - backwardPrediction_->setPlane(getPlane()); - // rep needs to be fixed up - } - if (flag & (1 << 4)) { - backwardUpdate_.reset(new KalmanFittedStateOnPlane()); - backwardUpdate_->Streamer(R__b); - backwardUpdate_->setPlane(getPlane()); - // rep needs to be fixed up - } - { - std::vector > &R__stl = measurementsOnPlane_; - TClass *R__tcl1 = TBuffer::GetClass(typeid(genfit::MeasurementOnPlane)); - if (R__tcl1==0) { - Error("measurementsOnPlane_ streamer","Missing the TClass object for genfit::MeasurementOnPlane!"); - return; - } - int R__i, R__n; - R__b >> R__n; - R__stl.reserve(R__n); - for (R__i = 0; R__i < R__n; R__i++) { - genfit::MeasurementOnPlane* R__t = new MeasurementOnPlane(); - R__t->Streamer(R__b); - R__t->setPlane(getPlane()); - R__stl.push_back(R__t); - } - } - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - //This works around a msvc bug and should be harmless on other platforms - typedef genfit::AbsFitterInfo baseClass0; - baseClass0::Streamer(R__b); - // "!!" forces the value to 1 or 0 (pointer != 0 or pointer == 0), - // this value is then written as a bitfield. - int flag = (!!referenceState_ - | (!!forwardPrediction_ << 1) - | (!!forwardUpdate_ << 2) - | (!!backwardPrediction_ << 3) - | (!!backwardUpdate_ << 4)); - R__b << flag; - if (flag & 1) - referenceState_->Streamer(R__b); - if (flag & (1 << 1)) - forwardPrediction_->Streamer(R__b); - if (flag & (1 << 2)) - forwardUpdate_->Streamer(R__b); - if (flag & (1 << 3)) - backwardPrediction_->Streamer(R__b); - if (flag & (1 << 4)) - backwardUpdate_->Streamer(R__b); - { - std::vector > &R__stl = measurementsOnPlane_; - int R__n=int(R__stl.size()); - R__b << R__n; - if(R__n) { - std::vector >::iterator R__k; - for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) { - (*R__k)->Streamer(R__b); - } - } - } - R__b.SetByteCount(R__c, kTRUE); - } -} - - -} /* End of namespace genfit */ diff --git a/genfit/fitters/src/KalmanFitterRefTrack.cc b/genfit/fitters/src/KalmanFitterRefTrack.cc deleted file mode 100644 index 89478c7bbb..0000000000 --- a/genfit/fitters/src/KalmanFitterRefTrack.cc +++ /dev/null @@ -1,1116 +0,0 @@ -/* Copyright 2013, Ludwig-Maximilians Universität München, Technische Universität München - Authors: Tobias Schlüter & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/* This implements the Kalman fitter with reference track. */ - -#include "Tools.h" -#include "Track.h" -#include "TrackPoint.h" -#include "Exception.h" - -#include "KalmanFitterRefTrack.h" -#include "KalmanFitterInfo.h" -#include "KalmanFitStatus.h" - -#include "boost/scoped_ptr.hpp" - -#include - - -using namespace genfit; - - -TrackPoint* KalmanFitterRefTrack::fitTrack(Track* tr, const AbsTrackRep* rep, double& chi2, double& ndf, int direction) -{ - - //if (!isTrackPrepared(tr, rep)) { - // Exception exc("KalmanFitterRefTrack::fitTrack ==> track is not properly prepared.",__LINE__,__FILE__); - // throw exc; - //} - - unsigned int dim = rep->getDim(); - - chi2 = 0; - ndf = -1. * dim; - KalmanFitterInfo* prevFi(NULL); - - TrackPoint* retVal(NULL); - - if (debugLvl_ > 0) { - std::cout << tr->getNumPoints() << " TrackPoints with measurements in this track." << std::endl; - } - - bool alreadyFitted(!refitAll_); - - p_.ResizeTo(dim); - C_.ResizeTo(dim, dim); - - for (size_t i = 0; i < tr->getNumPointsWithMeasurement(); ++i) { - TrackPoint *tp = 0; - assert(direction == +1 || direction == -1); - if (direction == +1) - tp = tr->getPointWithMeasurement(i); - else if (direction == -1) - tp = tr->getPointWithMeasurement(-i-1); - - if (! tp->hasFitterInfo(rep)) { - if (debugLvl_ > 0) { - std::cout << "TrackPoint " << i << " has no fitterInfo -> continue. \n"; - } - continue; - } - - KalmanFitterInfo* fi = static_cast(tp->getFitterInfo(rep)); - - if (alreadyFitted && fi->hasUpdate(direction)) { - if (debugLvl_ > 0) { - std::cout << "TrackPoint " << i << " is already fitted -> continue. \n"; - } - prevFi = fi; - chi2 += fi->getUpdate(direction)->getChiSquareIncrement(); - ndf += fi->getUpdate(direction)->getNdf(); - continue; - } - - alreadyFitted = false; - - if (debugLvl_ > 0) { - std::cout << " process TrackPoint nr. " << i << "\n"; - } - processTrackPoint(fi, prevFi, tp, chi2, ndf, direction); - retVal = tp; - - prevFi = fi; - } - - return retVal; -} - - -void KalmanFitterRefTrack::processTrackWithRep(Track* tr, const AbsTrackRep* rep, bool resortHits) -{ - - if (tr->getFitStatus(rep) != NULL && tr->getFitStatus(rep)->isTrackPruned()) { - Exception exc("KalmanFitterRefTrack::processTrack: Cannot process pruned track!", __LINE__,__FILE__); - throw exc; - } - - double oldChi2FW = 1e6; - double oldPvalFW = 0.; - double oldChi2BW = 1e6; - double oldPvalBW = 0.; - double chi2FW(0), ndfFW(0); - double chi2BW(0), ndfBW(0); - int nFailedHits(0); - - KalmanFitStatus* status = new KalmanFitStatus(); - tr->setFitStatus(status, rep); - - status->setIsFittedWithReferenceTrack(true); - - unsigned int nIt=0; - for (;;) { - - try { - if (debugLvl_ > 0) { - std::cout << " KalmanFitterRefTrack::processTrack with rep " << rep - << " (id == " << tr->getIdForRep(rep) << ")"<< ", iteration nr. " << nIt << "\n"; - } - - // prepare - if (!prepareTrack(tr, rep, resortHits, nFailedHits) && !refitAll_) { - if (debugLvl_ > 0) { - std::cout << "KalmanFitterRefTrack::processTrack. Track preparation did not change anything!\n"; - } - - status->setIsFitted(); - - status->setIsFitConvergedPartially(); - if (nFailedHits == 0) - status->setIsFitConvergedFully(); - else - status->setIsFitConvergedFully(false); - - status->setNFailedPoints(nFailedHits); - - status->setHasTrackChanged(false); - status->setCharge(rep->getCharge(*static_cast(tr->getPointWithMeasurement(0)->getFitterInfo(rep))->getBackwardUpdate())); - status->setNumIterations(nIt); - status->setForwardChi2(chi2FW); - status->setBackwardChi2(chi2BW); - status->setForwardNdf(std::max(0., ndfFW)); - status->setBackwardNdf(std::max(0., ndfBW)); - if (debugLvl_ > 0) { - status->Print(); - } - return; - } - - if (debugLvl_ > 0) { - std::cout << "KalmanFitterRefTrack::processTrack. Prepared Track:"; - tr->Print("C"); - //tr->Print(); - } - - // resort - if (resortHits) { - if (tr->sort()) { - if (debugLvl_ > 0) { - std::cout << "KalmanFitterRefTrack::processTrack. Resorted Track:"; - tr->Print("C"); - } - prepareTrack(tr, rep, resortHits, nFailedHits);// re-prepare if order of hits has changed! - status->setNFailedPoints(nFailedHits); - if (debugLvl_ > 0) { - std::cout << "KalmanFitterRefTrack::processTrack. Prepared resorted Track:"; - tr->Print("C"); - } - } - } - - - // fit forward - if (debugLvl_ > 0) - std::cout << "KalmanFitterRefTrack::forward fit\n"; - TrackPoint* lastProcessedPoint = fitTrack(tr, rep, chi2FW, ndfFW, +1); - - // fit backward - if (debugLvl_ > 0) { - std::cout << "KalmanFitterRefTrack::backward fit\n"; - } - - // backward fit must not necessarily start at last hit, set prediction = forward update and blow up cov - if (lastProcessedPoint != NULL) { - KalmanFitterInfo* lastInfo = static_cast(lastProcessedPoint->getFitterInfo(rep)); - if (! lastInfo->hasBackwardPrediction()) { - lastInfo->setBackwardPrediction(new MeasuredStateOnPlane(*(lastInfo->getForwardUpdate()))); - lastInfo->getBackwardPrediction()->blowUpCov(blowUpFactor_); // blow up cov - if (debugLvl_ > 0) { - std::cout << "blow up cov for backward fit at TrackPoint " << lastProcessedPoint << "\n"; - } - } - } - - fitTrack(tr, rep, chi2BW, ndfBW, -1); - - ++nIt; - - - double PvalBW = ROOT::Math::chisquared_cdf_c(chi2BW, ndfBW); - double PvalFW = (debugLvl_ > 0) ? ROOT::Math::chisquared_cdf_c(chi2FW, ndfFW) : 0; // Don't calculate if not debugging as this function potentially takes a lot of time. - - if (debugLvl_ > 0) { - std::cout << "KalmanFitterRefTrack::Track after fit:"; tr->Print("C"); - - std::cout << "old chi2s: " << oldChi2BW << ", " << oldChi2FW - << " new chi2s: " << chi2BW << ", " << chi2FW << std::endl; - std::cout << "old pVals: " << oldPvalBW << ", " << oldPvalFW - << " new pVals: " << PvalBW << ", " << PvalFW << std::endl; - } - - // See if p-value only changed little. If the initial - // parameters are very far off, initial chi^2 and the chi^2 - // after the first iteration will be both very close to zero, so - // we need to have at least two iterations here. Convergence - // doesn't make much sense before running twice anyway. - bool converged(false); - bool finished(false); - if (nIt >= minIterations_ && fabs(oldPvalBW - PvalBW) < deltaPval_) { - // if pVal ~ 0, check if chi2 has changed significantly - if (fabs(1 - fabs(oldChi2BW / chi2BW)) > relChi2Change_) { - finished = false; - } - else { - finished = true; - converged = true; - } - - if (PvalBW == 0.) - converged = false; - } - - if (finished) { - if (debugLvl_ > 0) { - std::cout << "Fit is finished! "; - if(converged) - std::cout << "Fit is converged! "; - std::cout << "\n"; - } - - if (nFailedHits == 0) - status->setIsFitConvergedFully(converged); - else - status->setIsFitConvergedFully(false); - - status->setIsFitConvergedPartially(converged); - status->setNFailedPoints(nFailedHits); - - break; - } - else { - oldPvalBW = PvalBW; - oldChi2BW = chi2BW; - if (debugLvl_ > 0) { - oldPvalFW = PvalFW; - oldChi2FW = chi2FW; - } - } - - if (nIt >= maxIterations_) { - if (debugLvl_ > 0) { - std::cout << "KalmanFitterRefTrack::number of max iterations reached!\n"; - } - break; - } - } - catch(Exception& e) { - std::cerr << e.what(); - status->setIsFitted(false); - status->setIsFitConvergedFully(false); - status->setIsFitConvergedPartially(false); - status->setNFailedPoints(nFailedHits); - if (debugLvl_ > 0) { - status->Print(); - } - return; - } - - } - - - TrackPoint* tp = tr->getPointWithMeasurementAndFitterInfo(0, rep); - - double charge(0); - if (tp != NULL) { - if (static_cast(tp->getFitterInfo(rep))->hasBackwardUpdate()) - charge = static_cast(tp->getFitterInfo(rep))->getBackwardUpdate()->getCharge(); - } - status->setCharge(charge); - - if (tp != NULL) { - status->setIsFitted(); - } - else { // none of the trackPoints has a fitterInfo - status->setIsFitted(false); - status->setIsFitConvergedFully(false); - status->setIsFitConvergedPartially(false); - status->setNFailedPoints(nFailedHits); - } - - status->setHasTrackChanged(false); - status->setNumIterations(nIt); - status->setForwardChi2(chi2FW); - status->setBackwardChi2(chi2BW); - status->setForwardNdf(ndfFW); - status->setBackwardNdf(ndfBW); - - if (debugLvl_ > 0) { - status->Print(); - } -} - - -bool KalmanFitterRefTrack::prepareTrack(Track* tr, const AbsTrackRep* rep, bool setSortingParams, int& nFailedHits) { - - if (debugLvl_ > 0) { - std::cout << "KalmanFitterRefTrack::prepareTrack \n"; - } - - int notChangedUntil, notChangedFrom; - - // remove outdated reference states - bool changedSmthg = removeOutdated(tr, rep, notChangedUntil, notChangedFrom); - - - // declare matrices - FTransportMatrix_.ResizeTo(rep->getDim(), rep->getDim()); - FTransportMatrix_.UnitMatrix(); - BTransportMatrix_.ResizeTo(rep->getDim(), rep->getDim()); - - FNoiseMatrix_.ResizeTo(rep->getDim(), rep->getDim()); - BNoiseMatrix_.ResizeTo(rep->getDim(), rep->getDim()); - - forwardDeltaState_.ResizeTo(rep->getDim()); - backwardDeltaState_.ResizeTo(rep->getDim()); - - // declare stuff - KalmanFitterInfo* prevFitterInfo(NULL); - boost::scoped_ptr firstBackwardUpdate; - - ReferenceStateOnPlane* referenceState(NULL); - ReferenceStateOnPlane* prevReferenceState(NULL); - - const MeasuredStateOnPlane* smoothedState(NULL); - const MeasuredStateOnPlane* prevSmoothedState(NULL); - - double trackLen(0); - - bool newRefState(false); // has the current Point a new reference state? - bool prevNewRefState(false); // has the last successfull point a new reference state? - - unsigned int nPoints = tr->getNumPoints(); - - - unsigned int i=0; - nFailedHits = 0; - - - // loop over TrackPoints - for (; i 0) { - std::cout << "Prepare TrackPoint " << i << "\n"; - } - - TrackPoint* trackPoint = tr->getPoint(i); - - // check if we have a measurement - if (!trackPoint->hasRawMeasurements()) { - if (debugLvl_ > 0) { - std::cout << "TrackPoint has no rawMeasurements -> continue \n"; - } - continue; - } - - newRefState = false; - - - // get fitterInfo - KalmanFitterInfo* fitterInfo(NULL); - if (trackPoint->hasFitterInfo(rep)) - fitterInfo = dynamic_cast(trackPoint->getFitterInfo(rep)); - - // create new fitter info if none available - if (fitterInfo == NULL) { - if (debugLvl_ > 0) { - std::cout << "create new KalmanFitterInfo \n"; - } - changedSmthg = true; - fitterInfo = new KalmanFitterInfo(trackPoint, rep); - trackPoint->setFitterInfo(fitterInfo); - } - else { - if (debugLvl_ > 0) { - std::cout << "TrackPoint " << i << " (" << trackPoint << ") already has KalmanFitterInfo \n"; - } - - if (prevFitterInfo == NULL) { - if (fitterInfo->hasBackwardUpdate()) - firstBackwardUpdate.reset(new MeasuredStateOnPlane(*(fitterInfo->getBackwardUpdate()))); - } - } - - // get smoothedState if available - if (fitterInfo->hasPredictionsAndUpdates()) { - smoothedState = &(fitterInfo->getFittedState(true)); - if (debugLvl_ > 0) { - std::cout << "got smoothed state \n"; - //smoothedState->Print(); - } - } - else { - smoothedState = NULL; - } - - - if (fitterInfo->hasReferenceState()) { - - referenceState = fitterInfo->getReferenceState(); - - - if (!prevNewRefState) { - if (debugLvl_ > 0) { - std::cout << "TrackPoint already has referenceState and previous referenceState has not been altered -> continue \n"; - } - trackLen += referenceState->getForwardSegmentLength(); - if (setSortingParams) - trackPoint->setSortingParameter(trackLen); - - prevNewRefState = newRefState; - prevReferenceState = referenceState; - prevFitterInfo = fitterInfo; - prevSmoothedState = smoothedState; - - continue; - } - - - if (prevReferenceState == NULL) { - if (debugLvl_ > 0) { - std::cout << "TrackPoint already has referenceState but previous referenceState is NULL -> reset forward info of current reference state and continue \n"; - } - - referenceState->resetForward(); - - if (setSortingParams) - trackPoint->setSortingParameter(trackLen); - - prevNewRefState = newRefState; - prevReferenceState = referenceState; - prevFitterInfo = fitterInfo; - prevSmoothedState = smoothedState; - - continue; - } - - // previous refState has been altered ->need to update transport matrices - if (debugLvl_ > 0) { - std::cout << "TrackPoint already has referenceState but previous referenceState has been altered -> update transport matrices and continue \n"; - } - StateOnPlane stateToExtrapolate(*prevReferenceState); - - // make sure track is consistent if extrapolation fails - prevReferenceState->resetBackward(); - referenceState->resetForward(); - - double segmentLen = rep->extrapolateToPlane(stateToExtrapolate, fitterInfo->getReferenceState()->getPlane(), false, true); - if (debugLvl_ > 0) { - std::cout << "extrapolated stateToExtrapolate (prevReferenceState) by " << segmentLen << " cm.\n"; - } - trackLen += segmentLen; - - if (segmentLen == 0) { - FTransportMatrix_.UnitMatrix(); - FNoiseMatrix_.Zero(); - forwardDeltaState_.Zero(); - BTransportMatrix_.UnitMatrix(); - BNoiseMatrix_.Zero(); - backwardDeltaState_.Zero(); - } - else { - rep->getForwardJacobianAndNoise(FTransportMatrix_, FNoiseMatrix_, forwardDeltaState_); - rep->getBackwardJacobianAndNoise(BTransportMatrix_, BNoiseMatrix_, backwardDeltaState_); - } - - prevReferenceState->setBackwardSegmentLength(-segmentLen); - prevReferenceState->setBackwardTransportMatrix(BTransportMatrix_); - prevReferenceState->setBackwardNoiseMatrix(BNoiseMatrix_); - prevReferenceState->setBackwardDeltaState(backwardDeltaState_); - - referenceState->setForwardSegmentLength(segmentLen); - referenceState->setForwardTransportMatrix(FTransportMatrix_); - referenceState->setForwardNoiseMatrix(FNoiseMatrix_); - referenceState->setForwardDeltaState(forwardDeltaState_); - - newRefState = true; - - if (setSortingParams) - trackPoint->setSortingParameter(trackLen); - - prevNewRefState = newRefState; - prevReferenceState = referenceState; - prevFitterInfo = fitterInfo; - prevSmoothedState = smoothedState; - - continue; - } - - - // Construct plane - SharedPlanePtr plane; - if (smoothedState != NULL) { - if (debugLvl_ > 0) - std::cout << "construct plane with smoothedState \n"; - plane = trackPoint->getRawMeasurement(0)->constructPlane(*smoothedState); - } - else if (prevSmoothedState != NULL) { - if (debugLvl_ > 0) { - std::cout << "construct plane with prevSmoothedState \n"; - //prevSmoothedState->Print(); - } - plane = trackPoint->getRawMeasurement(0)->constructPlane(*prevSmoothedState); - } - else if (prevReferenceState != NULL) { - if (debugLvl_ > 0) { - std::cout << "construct plane with prevReferenceState \n"; - } - plane = trackPoint->getRawMeasurement(0)->constructPlane(*prevReferenceState); - } - else if (rep != tr->getCardinalRep() && - trackPoint->hasFitterInfo(tr->getCardinalRep()) && - dynamic_cast(trackPoint->getFitterInfo(tr->getCardinalRep())) != NULL && - static_cast(trackPoint->getFitterInfo(tr->getCardinalRep()))->hasPredictionsAndUpdates() ) { - if (debugLvl_ > 0) { - std::cout << "construct plane with smoothed state of cardinal rep fit \n"; - } - TVector3 pos, mom; - const MeasuredStateOnPlane& fittedState = static_cast(trackPoint->getFitterInfo(tr->getCardinalRep()))->getFittedState(true); - tr->getCardinalRep()->getPosMom(fittedState, pos, mom); - StateOnPlane cardinalState(rep); - rep->setPosMom(cardinalState, pos, mom); - rep->setQop(cardinalState, tr->getCardinalRep()->getQop(fittedState)); - plane = trackPoint->getRawMeasurement(0)->constructPlane(cardinalState); - } - else { - if (debugLvl_ > 0) { - std::cout << "construct plane with state from track \n"; - } - StateOnPlane seedFromTrack(rep); - rep->setPosMom(seedFromTrack, tr->getStateSeed()); // also fills auxInfo - plane = trackPoint->getRawMeasurement(0)->constructPlane(seedFromTrack); - } - - if (plane.get() == NULL) { - Exception exc("KalmanFitterRefTrack::prepareTrack ==> construced plane is NULL!",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - - - // do extrapolation and set reference state infos - boost::scoped_ptr stateToExtrapolate(NULL); - if (prevFitterInfo == NULL) { // first measurement - if (debugLvl_ > 0) { - std::cout << "prevFitterInfo == NULL \n"; - } - if (smoothedState != NULL) { - if (debugLvl_ > 0) { - std::cout << "extrapolate smoothedState to plane\n"; - } - stateToExtrapolate.reset(new StateOnPlane(*smoothedState)); - } - else if (referenceState != NULL) { - if (debugLvl_ > 0) { - std::cout << "extrapolate referenceState to plane\n"; - } - stateToExtrapolate.reset(new StateOnPlane(*referenceState)); - } - else if (rep != tr->getCardinalRep() && - trackPoint->hasFitterInfo(tr->getCardinalRep()) && - dynamic_cast(trackPoint->getFitterInfo(tr->getCardinalRep())) != NULL && - static_cast(trackPoint->getFitterInfo(tr->getCardinalRep()))->hasPredictionsAndUpdates() ) { - if (debugLvl_ > 0) { - std::cout << "extrapolate smoothed state of cardinal rep fit to plane\n"; - } - TVector3 pos, mom; - const MeasuredStateOnPlane& fittedState = static_cast(trackPoint->getFitterInfo(tr->getCardinalRep()))->getFittedState(true); - tr->getCardinalRep()->getPosMom(fittedState, pos, mom); - stateToExtrapolate.reset(new StateOnPlane(rep)); - rep->setPosMom(*stateToExtrapolate, pos, mom); - rep->setQop(*stateToExtrapolate, tr->getCardinalRep()->getQop(fittedState)); - } - else { - if (debugLvl_ > 0) { - std::cout << "extrapolate seed from track to plane\n"; - } - stateToExtrapolate.reset(new StateOnPlane(rep)); - rep->setPosMom(*stateToExtrapolate, tr->getStateSeed()); - } - } // end if (prevFitterInfo == NULL) - else { - if (prevSmoothedState != NULL) { - if (debugLvl_ > 0) { - std::cout << "extrapolate prevSmoothedState to plane \n"; - } - stateToExtrapolate.reset(new StateOnPlane(*prevSmoothedState)); - } - else { - assert (prevReferenceState != NULL); - if (debugLvl_ > 0) { - std::cout << "extrapolate prevReferenceState to plane \n"; - } - stateToExtrapolate.reset(new StateOnPlane(*prevReferenceState)); - } - } - - // make sure track is consistent if extrapolation fails - if (prevReferenceState != NULL) - prevReferenceState->resetBackward(); - fitterInfo->deleteReferenceInfo(); - - if (prevFitterInfo != NULL) { - rep->extrapolateToPlane(*stateToExtrapolate, prevFitterInfo->getPlane()); - if (debugLvl_ > 0) { - std::cout << "extrapolated stateToExtrapolate to plane of prevFitterInfo (plane could have changed!) \n"; - } - } - - double segmentLen = rep->extrapolateToPlane(*stateToExtrapolate, plane, false, true); - trackLen += segmentLen; - if (debugLvl_ > 0) { - std::cout << "extrapolated stateToExtrapolate by " << segmentLen << " cm.\t"; - std::cout << "charge of stateToExtrapolate: " << rep->getCharge(*stateToExtrapolate) << " \n"; - } - - // get jacobians and noise matrices - if (segmentLen == 0) { - FTransportMatrix_.UnitMatrix(); - FNoiseMatrix_.Zero(); - forwardDeltaState_.Zero(); - BTransportMatrix_.UnitMatrix(); - BNoiseMatrix_.Zero(); - backwardDeltaState_.Zero(); - } - else { - if (i>0) - rep->getForwardJacobianAndNoise(FTransportMatrix_, FNoiseMatrix_, forwardDeltaState_); - rep->getBackwardJacobianAndNoise(BTransportMatrix_, BNoiseMatrix_, backwardDeltaState_); - } - - - if (i==0) { - // if we are at first measurement and seed state is defined somewhere else - segmentLen = 0; - trackLen = 0; - } - if (setSortingParams) - trackPoint->setSortingParameter(trackLen); - - - // set backward matrices for previous reference state - if (prevReferenceState != NULL) { - prevReferenceState->setBackwardSegmentLength(-segmentLen); - prevReferenceState->setBackwardTransportMatrix(BTransportMatrix_); - prevReferenceState->setBackwardNoiseMatrix(BNoiseMatrix_); - prevReferenceState->setBackwardDeltaState(backwardDeltaState_); - } - - - // create new reference state - newRefState = true; - changedSmthg = true; - referenceState = new ReferenceStateOnPlane(stateToExtrapolate->getState(), - stateToExtrapolate->getPlane(), - stateToExtrapolate->getRep(), - stateToExtrapolate->getAuxInfo()); - referenceState->setForwardSegmentLength(segmentLen); - referenceState->setForwardTransportMatrix(FTransportMatrix_); - referenceState->setForwardNoiseMatrix(FNoiseMatrix_); - referenceState->setForwardDeltaState(forwardDeltaState_); - - referenceState->resetBackward(); - - fitterInfo->setReferenceState(referenceState); - - - // get MeasurementsOnPlane - std::vector oldWeights = fitterInfo->getWeights(); - bool oldWeightsFixed = fitterInfo->areWeightsFixed(); - fitterInfo->deleteMeasurementInfo(); - const std::vector& rawMeasurements = trackPoint->getRawMeasurements(); - for ( std::vector< genfit::AbsMeasurement* >::const_iterator measurement = rawMeasurements.begin(), lastMeasurement = rawMeasurements.end(); measurement != lastMeasurement; ++measurement) { - assert((*measurement) != NULL); - fitterInfo->addMeasurementsOnPlane((*measurement)->constructMeasurementsOnPlane(*referenceState)); - } - if (oldWeights.size() == fitterInfo->getNumMeasurements()) { - fitterInfo->setWeights(oldWeights); - fitterInfo->fixWeights(oldWeightsFixed); - } - - - // if we made it here, no Exceptions were thrown and the TrackPoint could successfully be processed - prevNewRefState = newRefState; - prevReferenceState = referenceState; - prevFitterInfo = fitterInfo; - prevSmoothedState = smoothedState; - - } - catch (Exception& e) { - - if (debugLvl_ > 0) { - std::cout << "exception at hit " << i << "\n"; - std::cerr << e.what(); - } - - - ++nFailedHits; - if (maxFailedHits_<0 || nFailedHits <= maxFailedHits_) { - prevNewRefState = true; - referenceState = NULL; - smoothedState = NULL; - tr->getPoint(i)->deleteFitterInfo(rep); - - if (setSortingParams) - tr->getPoint(i)->setSortingParameter(trackLen); - - if (debugLvl_ > 0) { - std::cout << "There was an exception, try to continue with next TrackPoint " << i+1 << " \n"; - } - - continue; - } - - - // clean up - removeForwardBackwardInfo(tr, rep, notChangedUntil, notChangedFrom); - - // set sorting parameters of rest of TrackPoints and remove FitterInfos - for (; igetPoint(i); - - if (setSortingParams) - trackPoint->setSortingParameter(trackLen); - - trackPoint->deleteFitterInfo(rep); - } - return true; - - } - - } // end loop over TrackPoints - - - - - removeForwardBackwardInfo(tr, rep, notChangedUntil, notChangedFrom); - - if (firstBackwardUpdate && tr->getPointWithMeasurementAndFitterInfo(0, rep)) { - KalmanFitterInfo* fi = static_cast(tr->getPointWithMeasurementAndFitterInfo(0, rep)->getFitterInfo(rep)); - if (fi && ! fi->hasForwardPrediction()) { - if (debugLvl_ > 0) { - std::cout << "set backwards update of first point as forward prediction (with blown up cov) \n"; - } - if (fi->getPlane() != firstBackwardUpdate->getPlane()) { - rep->extrapolateToPlane(*firstBackwardUpdate, fi->getPlane()); - } - firstBackwardUpdate->blowUpCov(blowUpFactor_); - fi->setForwardPrediction(new MeasuredStateOnPlane(*firstBackwardUpdate)); - } - } - - KalmanFitStatus* fitStatus = dynamic_cast(tr->getFitStatus(rep)); - if (fitStatus != NULL) - fitStatus->setTrackLen(trackLen); - - if (debugLvl_ > 0) { - std::cout << "trackLen of reference track = " << trackLen << "\n"; - } - - // self check - //assert(tr->checkConsistency()); - assert(isTrackPrepared(tr, rep)); - - return changedSmthg; -} - - -bool -KalmanFitterRefTrack::removeOutdated(Track* tr, const AbsTrackRep* rep, int& notChangedUntil, int& notChangedFrom) { - - if (debugLvl_ > 0) { - std::cout << "KalmanFitterRefTrack::removeOutdated \n"; - } - - bool changedSmthg(false); - - unsigned int nPoints = tr->getNumPoints(); - notChangedUntil = nPoints-1; - notChangedFrom = 0; - - // loop over TrackPoints - for (unsigned int i=0; igetPoint(i); - - // check if we have a measurement - if (!trackPoint->hasRawMeasurements()) { - if (debugLvl_ > 0) { - std::cout << "TrackPoint has no rawMeasurements -> continue \n"; - } - continue; - } - - // get fitterInfo - KalmanFitterInfo* fitterInfo(NULL); - if (trackPoint->hasFitterInfo(rep)) - fitterInfo = dynamic_cast(trackPoint->getFitterInfo(rep)); - - if (fitterInfo == NULL) - continue; - - - // check if we need to calculate or update reference state - if (fitterInfo->hasReferenceState()) { - - if (! fitterInfo->hasPredictionsAndUpdates()) { - if (debugLvl_ > 0) { - std::cout << "reference state but not all predictions & updates -> do not touch reference state. \n"; - } - continue; - } - - - const MeasuredStateOnPlane& smoothedState = fitterInfo->getFittedState(true); - resM_.ResizeTo(smoothedState.getState()); - resM_ = smoothedState.getState(); - resM_ -= fitterInfo->getReferenceState()->getState(); - double chi2(0); - - // calculate chi2, ignore off diagonals - double* resArray = resM_.GetMatrixArray(); - for (int j=0; j do not update reference state - if (debugLvl_ > 0) { - std::cout << "reference state is near smoothed state -> do not update reference state, chi2 = " << chi2 << "\n"; - } - continue; - } else { - if (debugLvl_ > 0) { - std::cout << "reference state is not close to smoothed state, chi2 = " << chi2 << "\n"; - } - } - } - - if (debugLvl_ > 0) { - std::cout << "remove reference info \n"; - } - - fitterInfo->deleteReferenceInfo(); - changedSmthg = true; - - // decided to update reference state -> set notChangedUntil (only once) - if (notChangedUntil == (int)nPoints-1) - notChangedUntil = i-1; - - notChangedFrom = i+1; - - } // end loop over TrackPoints - - - if (debugLvl_ > 0) { - tr->Print("C"); - } - - return changedSmthg; -} - - -void -KalmanFitterRefTrack::removeForwardBackwardInfo(Track* tr, const AbsTrackRep* rep, int notChangedUntil, int notChangedFrom) const { - - unsigned int nPoints = tr->getNumPoints(); - - if (refitAll_) { - tr->deleteForwardInfo(0, -1, rep); - tr->deleteBackwardInfo(0, -1, rep); - return; - } - - // delete forward/backward info from/to points where reference states have changed - if (notChangedUntil != (int)nPoints-1) { - tr->deleteForwardInfo(notChangedUntil+1, -1, rep); - } - if (notChangedFrom != 0) - tr->deleteBackwardInfo(0, notChangedFrom-1, rep); - -} - - -void -KalmanFitterRefTrack::processTrackPoint(KalmanFitterInfo* fi, const KalmanFitterInfo* prevFi, const TrackPoint* tp, double& chi2, double& ndf, int direction) -{ - if (debugLvl_ > 0) { - std::cout << " KalmanFitterRefTrack::processTrackPoint " << fi->getTrackPoint() << "\n"; - } - - unsigned int dim = fi->getRep()->getDim(); - - p_.Zero(); // p_{k|k-1} - C_.Zero(); // C_{k|k-1} - - // predict - if (prevFi != NULL) { - const TMatrixD& F = fi->getReferenceState()->getTransportMatrix(direction); // Transport matrix - assert(F.GetNcols() == (int)dim); - const TMatrixDSym& N = fi->getReferenceState()->getNoiseMatrix(direction); // Noise matrix - //p_ = ( F * prevFi->getUpdate(direction)->getState() ) + fi->getReferenceState()->getDeltaState(direction); - p_ = prevFi->getUpdate(direction)->getState(); - p_ *= F; - p_ += fi->getReferenceState()->getDeltaState(direction); - - C_ = prevFi->getUpdate(direction)->getCov(); - C_.Similarity(F); - C_ += N; - fi->setPrediction(new MeasuredStateOnPlane(p_, C_, fi->getReferenceState()->getPlane(), fi->getReferenceState()->getRep(), fi->getReferenceState()->getAuxInfo()), direction); - if (debugLvl_ > 1) { - std::cout << "\033[31m"; - std::cout << "F (Transport Matrix) "; F.Print(); - std::cout << "p_{k,r} (reference state) "; fi->getReferenceState()->getState().Print(); - std::cout << "c (delta state) "; fi->getReferenceState()->getDeltaState(direction).Print(); - std::cout << "F*p_{k-1,r} + c "; (F *prevFi->getReferenceState()->getState() + fi->getReferenceState()->getDeltaState(direction)).Print(); - } - } - else { - if (fi->hasPrediction(direction)) { - if (debugLvl_ > 0) { - std::cout << " Use prediction as start \n"; - } - p_ = fi->getPrediction(direction)->getState(); - C_ = fi->getPrediction(direction)->getCov(); - } - else { - if (debugLvl_ > 0) { - std::cout << " Use reference state and seed cov as start \n"; - } - const AbsTrackRep *rep = fi->getReferenceState()->getRep(); - p_ = fi->getReferenceState()->getState(); - - // Convert from 6D covariance of the seed to whatever the trackRep wants. - TMatrixDSym dummy(p_.GetNrows()); - MeasuredStateOnPlane mop(p_, dummy, fi->getReferenceState()->getPlane(), rep, fi->getReferenceState()->getAuxInfo()); - TVector3 pos, mom; - rep->getPosMom(mop, pos, mom); - rep->setPosMomCov(mop, pos, mom, fi->getTrackPoint()->getTrack()->getCovSeed()); - // Blow up, set. - mop.blowUpCov(blowUpFactor_); - fi->setPrediction(new MeasuredStateOnPlane(mop), direction); - C_ = mop.getCov(); - } - if (debugLvl_ > 1) { - std::cout << "\033[31m"; - std::cout << "p_{k,r} (reference state)"; fi->getReferenceState()->getState().Print(); - } - } - - if (debugLvl_ > 1) { - std::cout << " p_{k|k-1} (state prediction)"; p_.Print(); - std::cout << " C_{k|k-1} (covariance prediction)"; C_.Print(); - std::cout << "\033[0m"; - } - - // update(s) - double chi2inc = 0; - double ndfInc = 0; - const std::vector measurements = getMeasurements(fi, tp, direction); - for (std::vector::const_iterator it = measurements.begin(); it != measurements.end(); ++it) { - const MeasurementOnPlane& m = **it; - - if (!canIgnoreWeights() && m.getWeight() <= 1.01E-10) { - if (debugLvl_ > 1) { - std::cout << "Weight of measurement is almost 0, continue ... /n"; - } - continue; - } - - const AbsHMatrix* H(m.getHMatrix()); - // (weighted) cov - const TMatrixDSym& V((!canIgnoreWeights() && m.getWeight() < 0.99999) ? - 1./m.getWeight() * m.getCov() : - m.getCov()); - - covSumInv_.ResizeTo(C_); - covSumInv_ = C_; // (V_k + H_k C_{k|k-1} H_k^T)^(-1) - H->HMHt(covSumInv_); - covSumInv_ += V; - - tools::invertMatrix(covSumInv_); - - const TMatrixD& CHt(H->MHt(C_)); - - res_.ResizeTo(m.getState()); - res_ = m.getState(); - res_ -= H->Hv(p_); // residual - if (debugLvl_ > 1) { - std::cout << "\033[34m"; - std::cout << "m (measurement) "; m.getState().Print(); - std::cout << "V ((weighted) measurement covariance) "; (1./m.getWeight() * m.getCov()).Print(); - std::cout << "residual "; res_.Print(); - std::cout << "\033[0m"; - } - p_ += TMatrixD(CHt, TMatrixD::kMult, covSumInv_) * res_; // updated state - if (debugLvl_ > 1) { - std::cout << "\033[32m"; - std::cout << " update"; (TMatrixD(CHt, TMatrixD::kMult, covSumInv_) * res_).Print(); - std::cout << "\033[0m"; - } - - covSumInv_.Similarity(CHt); // with (C H^T)^T = H C^T = H C (C is symmetric) - C_ -= covSumInv_; // updated Cov - - if (debugLvl_ > 1) { - //std::cout << " C update "; covSumInv_.Print(); - std::cout << "\033[32m"; - std::cout << " p_{k|k} (updated state)"; p_.Print(); - std::cout << " C_{k|k} (updated covariance)"; C_.Print(); - std::cout << "\033[0m"; - } - - // Calculate chi² increment. At the first point chi2inc == 0 and - // the matrix will not be invertible. - res_ = m.getState(); - res_ -= H->Hv(p_); // new residual - if (debugLvl_ > 1) { - std::cout << " resNew "; - res_.Print(); - } - - // only calculate chi2inc if res != NULL. - // If matrix inversion fails, chi2inc = 0 - if (res_ != 0) { - Rinv_.ResizeTo(C_); - Rinv_ = C_; - H->HMHt(Rinv_); - Rinv_ -= V; - Rinv_ *= -1; - - bool couldInvert(true); - try { - tools::invertMatrix(Rinv_); - } - catch (Exception& e) { - if (debugLvl_ > 1) { - std::cerr << e.what(); - } - couldInvert = false; - } - - if (couldInvert) { - if (debugLvl_ > 1) { - std::cout << " Rinv "; - Rinv_.Print(); - } - chi2inc += Rinv_.Similarity(res_); - } - } - - - if (!canIgnoreWeights()) { - ndfInc += m.getWeight() * m.getState().GetNrows(); - } - else - ndfInc += m.getState().GetNrows(); - - - } // end loop over measurements - - chi2 += chi2inc; - ndf += ndfInc; - - - KalmanFittedStateOnPlane* upState = new KalmanFittedStateOnPlane(p_, C_, fi->getReferenceState()->getPlane(), fi->getReferenceState()->getRep(), fi->getReferenceState()->getAuxInfo(), chi2inc, ndfInc); - upState->setAuxInfo(fi->getReferenceState()->getAuxInfo()); - fi->setUpdate(upState, direction); - - - if (debugLvl_ > 0) { - std::cout << " chi² inc " << chi2inc << "\t"; - std::cout << " ndf inc " << ndfInc << "\t"; - std::cout << " charge of update " << fi->getRep()->getCharge(*upState) << "\n"; - } - - // check - assert(fi->checkConsistency()); - -} diff --git a/genfit/fitters/src/ReferenceStateOnPlane.cc b/genfit/fitters/src/ReferenceStateOnPlane.cc deleted file mode 100644 index 0309157356..0000000000 --- a/genfit/fitters/src/ReferenceStateOnPlane.cc +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "ReferenceStateOnPlane.h" - -#include - - -namespace genfit { - -ReferenceStateOnPlane::ReferenceStateOnPlane() : - StateOnPlane(), - forwardSegmentLength_(0), - backwardSegmentLength_(0), - forwardTransportMatrix_(), - backwardTransportMatrix_(), - forwardNoiseMatrix_(), - backwardNoiseMatrix_(), - forwardDeltaState_(), - backwardDeltaState_() -{ - ; -} - -ReferenceStateOnPlane::ReferenceStateOnPlane(const TVectorD& state, - const SharedPlanePtr& plane, - const AbsTrackRep* rep) : - StateOnPlane(state, plane, rep), - forwardSegmentLength_(0), - backwardSegmentLength_(0), - forwardTransportMatrix_(rep->getDim(), rep->getDim()), - backwardTransportMatrix_(rep->getDim(), rep->getDim()), - forwardNoiseMatrix_(rep->getDim()), - backwardNoiseMatrix_(rep->getDim()), - forwardDeltaState_(rep->getDim()), - backwardDeltaState_(rep->getDim()) -{ - ; -} - -ReferenceStateOnPlane::ReferenceStateOnPlane(const TVectorD& state, - const SharedPlanePtr& plane, - const AbsTrackRep* rep, - const TVectorD& auxInfo) : - StateOnPlane(state, plane, rep, auxInfo), - forwardSegmentLength_(0), - backwardSegmentLength_(0), - forwardTransportMatrix_(rep->getDim(), rep->getDim()), - backwardTransportMatrix_(rep->getDim(), rep->getDim()), - forwardNoiseMatrix_(rep->getDim()), - backwardNoiseMatrix_(rep->getDim()), - forwardDeltaState_(rep->getDim()), - backwardDeltaState_(rep->getDim()) -{ - ; -} - - -ReferenceStateOnPlane::ReferenceStateOnPlane(const StateOnPlane& state) : - StateOnPlane(state), - forwardSegmentLength_(0), - backwardSegmentLength_(0), - forwardTransportMatrix_(state.getRep()->getDim(), state.getRep()->getDim()), - backwardTransportMatrix_(state.getRep()->getDim(), state.getRep()->getDim()), - forwardNoiseMatrix_(state.getRep()->getDim()), - backwardNoiseMatrix_(state.getRep()->getDim()), - forwardDeltaState_(state.getRep()->getDim()), - backwardDeltaState_(state.getRep()->getDim()) -{ - std::cout << "should never come here" << std::endl; - exit(0); -} - - -StateOnPlane& ReferenceStateOnPlane::operator=(ReferenceStateOnPlane other) { - swap(other); - return *this; -} - -void ReferenceStateOnPlane::swap(ReferenceStateOnPlane& other) { - StateOnPlane::swap(other); - std::swap(this->forwardSegmentLength_, other.forwardSegmentLength_); - std::swap(this->backwardSegmentLength_, other.backwardSegmentLength_); - this->forwardTransportMatrix_.ResizeTo(other.forwardTransportMatrix_); - std::swap(this->forwardTransportMatrix_, other.forwardTransportMatrix_); - this->backwardTransportMatrix_.ResizeTo(other.backwardTransportMatrix_); - std::swap(this->backwardTransportMatrix_, other.backwardTransportMatrix_); - this->forwardNoiseMatrix_.ResizeTo(other.forwardNoiseMatrix_); - std::swap(this->forwardNoiseMatrix_, other.forwardNoiseMatrix_); - this->backwardNoiseMatrix_.ResizeTo(other.backwardNoiseMatrix_); - std::swap(this->backwardNoiseMatrix_, other.backwardNoiseMatrix_); - this->forwardDeltaState_.ResizeTo(other.forwardDeltaState_); - std::swap(this->forwardDeltaState_, other.forwardDeltaState_); - this->backwardDeltaState_.ResizeTo(other.backwardDeltaState_); - std::swap(this->backwardDeltaState_, other.backwardDeltaState_); -} - - -void ReferenceStateOnPlane::resetForward() { - forwardSegmentLength_ = 0; - forwardTransportMatrix_.UnitMatrix(); - forwardNoiseMatrix_.Zero(); - forwardDeltaState_.Zero(); -} - -void ReferenceStateOnPlane::resetBackward() { - backwardSegmentLength_ = 0; - backwardTransportMatrix_.UnitMatrix(); - backwardNoiseMatrix_.Zero(); - backwardDeltaState_.Zero(); -} - - -void ReferenceStateOnPlane::Print(Option_t*) const { - StateOnPlane::Print(); - - std::cout << " forwardSegmentLength: " << forwardSegmentLength_ << "\n"; - std::cout << " forwardTransportMatrix: "; forwardTransportMatrix_.Print(); - std::cout << " forwardNoiseMatrix: "; forwardNoiseMatrix_.Print(); - std::cout << " forwardDeltaState: "; forwardDeltaState_.Print(); - - std::cout << " backwardSegmentLength_: " << backwardSegmentLength_ << "\n"; - std::cout << " backwardTransportMatrix: "; backwardTransportMatrix_.Print(); - std::cout << " backwardNoiseMatrix: "; backwardNoiseMatrix_.Print(); - std::cout << " backwardDeltaState: "; backwardDeltaState_.Print(); - -} - - -} /* End of namespace genfit */ diff --git a/genfit/fitters/src/fittersLinkDef.h b/genfit/fitters/src/fittersLinkDef.h deleted file mode 100644 index 92eecc4556..0000000000 --- a/genfit/fitters/src/fittersLinkDef.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -// these need no special tratment -#pragma link C++ class genfit::AbsKalmanFitter+; -#pragma link C++ class genfit::KalmanFitStatus; -#pragma link C++ class genfit::KalmanFitterRefTrack+; - -// these inherit from classes that need custom streamers -#pragma link C++ class genfit::KalmanFittedStateOnPlane+; -#pragma link C++ class genfit::ReferenceStateOnPlane+; - -// Classes that needed manually written streamers: -#pragma link C++ class genfit::KalmanFitter-; -#pragma link C++ class genfit::KalmanFitterInfo-; -#pragma link C++ class genfit::DAF-; - -#endif diff --git a/genfit/genfitLinkDef.h b/genfit/genfitLinkDef.h deleted file mode 100644 index b450ffc93e..0000000000 --- a/genfit/genfitLinkDef.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -// These need no special treatment. -#pragma link C++ class genfit::AbsFinitePlane+; -#pragma link C++ class genfit::AbsHMatrix+; -#pragma link C++ class genfit::RectangularFinitePlane+; -#pragma link C++ class genfit::FitStatus+; -#pragma link C++ class genfit::MaterialProperties+; -#pragma link C++ class genfit::TrackCand+; -#pragma link C++ class genfit::TrackCandHit+; -#pragma link C++ class genfit::FieldManager+; -#pragma link C++ class genfit::AbsFitter+; -#pragma link C++ class genfit::AbsBField+; -#pragma link C++ class genfit::AbsKalmanFitter+; -#pragma link C++ class genfit::KalmanFitStatus; -#pragma link C++ class genfit::KalmanFitterRefTrack+; -#pragma link C++ class genfit::GFGbl+; -#pragma link C++ class genfit::HMatrixU+; -#pragma link C++ class genfit::HMatrixUnit+; -#pragma link C++ class genfit::HMatrixV+; -#pragma link C++ class genfit::HMatrixUV+; -#pragma link C++ class genfit::ProlateSpacepointMeasurement+; -#pragma link C++ class genfit::WireMeasurement+; -#pragma link C++ class genfit::WirePointMeasurement+; - -#pragma link C++ class genfit::HMatrixPhi-; -#pragma link C++ class genfit::FullMeasurement-; -#pragma link C++ class genfit::PlanarMeasurement-; -#pragma link C++ class genfit::SpacepointMeasurement-; - -#pragma link C++ class genfit::WireTrackCandHit+; - -#pragma link C++ class genfit::RKTrackRep-; -#pragma link C++ class genfit::RKTools+; -#pragma link C++ class genfit::TGeoMaterialInterface+; -#pragma link C++ class genfit::MaterialEffects+; - -#pragma link C++ class genfit::HelixTrackModel+; -#pragma link C++ class genfit::MeasurementCreator+; -#pragma link C++ enum genfit::eMeasurementType; - -// These inherit from classes with custom streamers, or reference shared_ptrs in their interfaces. -#pragma link C++ class genfit::AbsTrackRep+; -#pragma link C++ class genfit::MeasuredStateOnPlane+; -#pragma link C++ class genfit::EventDisplay+; -#pragma link C++ class genfit::ConstField+; -#pragma link C++ class genfit::GoliathField+; -#pragma link C++ class genfit::BellField+; -#pragma link C++ class genfit::FairShipFields+; -#pragma link C++ class genfit::KalmanFittedStateOnPlane+; -#pragma link C++ class genfit::ReferenceStateOnPlane+; - -// These need their owners fixed up after reading. -#pragma link C++ class genfit::AbsMeasurement+; // trackPoint_ - -// These cannot be dealt with by default streamers because of -// shared_ptrs<> or scoped_ptrs<>. Additionally, they may need their -// owners fixed up. -#pragma link C++ class genfit::AbsFitterInfo-; // trackPoint_, rep_, sharedPlanePtr -#pragma link C++ class genfit::DetPlane-; // scoped_ptr<> finitePlane_ -#pragma link C++ class genfit::MeasurementOnPlane-; // scoped_ptr<> hMatrix_ -#pragma link C++ class genfit::StateOnPlane-; // rep_, sharedPlanePtr -#pragma link C++ class genfit::ThinScatterer-; // sharedPlanePtr -#pragma link C++ class genfit::Track-; -#pragma link C++ class genfit::TrackPoint-; // track_, fixup the map -#pragma link C++ class std::vector-; -#pragma link C++ class std::vector-; -// Classes that needed manually written streamers: -#pragma link C++ class genfit::KalmanFitter-; -#pragma link C++ class genfit::KalmanFitterInfo-; -#pragma link C++ class genfit::DAF-; - -#pragma link C++ class genfit::mySpacepointDetectorHit+; -#pragma link C++ class genfit::mySpacepointMeasurement+; - - -#endif - diff --git a/genfit/include/genfit/AbsMaterialInterface.h b/genfit/include/genfit/AbsMaterialInterface.h deleted file mode 100644 index fc9b279045..0000000000 --- a/genfit/include/genfit/AbsMaterialInterface.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright 2008-2009, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup RKTrackRep - * @{ - */ - -#ifndef genfit_AbsMaterialInterface_h -#define genfit_AbsMaterialInterface_h - -#include "RKTrackRep.h" -#include "MaterialProperties.h" - -#include -#include - - -namespace genfit { - -/** - * @brief Abstract base class for geometry interfacing - */ -class AbsMaterialInterface : public TObject { - - public: - - AbsMaterialInterface(){;}; - virtual ~AbsMaterialInterface(){;}; - - /** @brief Initialize the navigator at given position and with given direction. Return true if volume changed. - */ - virtual bool initTrack(double posX, double posY, double posZ, - double dirX, double dirY, double dirZ) = 0; - - /** @brief Get material parameters in current material - */ - virtual void getMaterialParameters(double& density, - double& Z, - double& A, - double& radiationLength, - double& mEE) = 0; - - virtual void getMaterialParameters(MaterialProperties& parameters) = 0; - - /** @brief Make a step until maxStep or the next boundary is reached. - * - * After making a step to a boundary, the position has to be beyond the boundary, - * i.e. in the current material has to be that beyond the boundary. - * The actual step made is returned. - */ - virtual double findNextBoundary(const RKTrackRep* rep, - const M1x7& state7, - double sMax, - bool varField = true) = 0; - - virtual double findNextBoundaryAndStepStraight(double sMax) = 0; - - - //ClassDef(AbsMaterialInterface, 1); - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_AbsMaterialInterface_h diff --git a/genfit/include/genfit/BellField.h b/genfit/include/genfit/BellField.h deleted file mode 100644 index bf5c16670d..0000000000 --- a/genfit/include/genfit/BellField.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_BellField_h -#define genfit_BellField_h - -#include "AbsBField.h" - - -namespace genfit { - -/** @brief Bell Field for SHiP - * - * @author Thomas Ruf CERN - */ -class BellField : public AbsBField { - public: - - /** Default constructor **/ - BellField(); - - /** Standard constructor **/ - BellField(double Peak, double Middle); - - - //! return value at position - TVector3 get(const TVector3& pos) const; - void get(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz) const; - - private: - double fMiddle; - double fPeak; -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_BellField_h diff --git a/genfit/include/genfit/FieldManager.h b/genfit/include/genfit/FieldManager.h deleted file mode 100644 index b75961233d..0000000000 --- a/genfit/include/genfit/FieldManager.h +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - - -#ifndef genfit_FieldManager_h -#define genfit_FieldManager_h - -#include "AbsBField.h" - -#include -#include -#include - -#define CACHE - -namespace genfit { - -#ifdef CACHE -/** - * @brief Cache B field at a position. Used by FieldManager. - */ -struct fieldCache { - double posX; double posY; double posZ; - double Bx; double By; double Bz; -}; -#endif - - -/** @brief Singleton which provides access to magnetic field maps. - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - */ -class FieldManager { - - public: - - AbsBField* getField(){ - checkInitialized(); - return field_; - } - - //! This does NOT use the cache! - TVector3 getFieldVal(const TVector3& position){ - checkInitialized(); - return field_->get(position); - } - -#ifdef CACHE - void getFieldVal(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz); -#else - inline void getFieldVal(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz) { - checkInitialized(); - return field_->get(posX, posY, posZ, Bx, By, Bz); - } -#endif - - //! set the magnetic field here. Magnetic field classes must be derived from AbsBField. - void init(AbsBField* b) { - field_=b; - } - - bool isInitialized() { return field_ != NULL; } - - void checkInitialized() { - if(! isInitialized()){ - std::cerr << "FieldManager hasn't been initialized with a correct AbsBField pointer!" << std::endl; - std::string msg("FieldManager hasn't been initialized with a correct AbsBField pointer!"); - std::runtime_error err(msg); - throw err; - } - } - - static void checkInstanciated() { - if(instance_==NULL){ - std::cerr << "FieldManager hasn't been instantiated yet, call getInstance() and init() before getFieldVal()!" << std::endl; - std::string msg("FieldManager hasn't been instantiated yet, call getInstance() and init() before getFieldVal()!"); - std::runtime_error err(msg); - throw err; - } - } - -#ifdef CACHE - //! Cache last lookup positions, and use stored field values if a lookup at (almost) the same position is done. - void useCache(bool opt = true, unsigned int nBuckets = 8); -#else - void useCache(bool opt = true, unsigned int nBuckets = 8) { - std::cerr << "genfit::FieldManager::useCache() - FieldManager is compiled w/o CACHE, no caching will be done!" << std::endl; - } -#endif - - //! Get singleton instance. - static FieldManager* getInstance(){ - if(instance_ == NULL) { - instance_ = new FieldManager(); - } - return instance_; - } - - - private: - - FieldManager() {} -#ifdef CACHE - ~FieldManager() { delete cache_; } -#else - ~FieldManager() { } -#endif - static FieldManager* instance_; - static AbsBField* field_; - -#ifdef CACHE - static bool useCache_; - static unsigned int n_buckets_; - static fieldCache* cache_; -#endif - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_FieldManager_h diff --git a/genfit/include/genfit/MaterialEffects.h b/genfit/include/genfit/MaterialEffects.h deleted file mode 100644 index ce531c76ac..0000000000 --- a/genfit/include/genfit/MaterialEffects.h +++ /dev/null @@ -1,202 +0,0 @@ -/* Copyright 2008-2014, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup RKTrackRep - * @{ - */ - -#ifndef genfit_MaterialEffects_h -#define genfit_MaterialEffects_h - -#include "RKTools.h" -#include "AbsMaterialInterface.h" - -#include -#include - -#include -#include - - -namespace genfit { - -/** @brief Stepper and energy loss/noise matrix calculation - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * @author Johannes Rauch (Technische Universität München, author) - * - * It provides functionality to limit the stepsize of an extrapolation in order not to - * exceed a specified maximum momentum loss. After propagation, the energy loss - * for the given length and (optionally) the noise matrix can be calculated. - * You have to set which energy-loss and noise mechanisms you want to use. - * At the moment, per default all energy loss and noise options are ON. - */ -class MaterialEffects { - - private: - - MaterialEffects(); - virtual ~MaterialEffects(); - - static MaterialEffects* instance_; - - -public: - - static MaterialEffects* getInstance(); - static void destruct(); - - //! set the material interface here. Material interface classes must be derived from AbsMaterialInterface. - void init(AbsMaterialInterface* matIfc); - bool isInitialized() { return materialInterface_ != nullptr; } - - void setNoEffects(bool opt = true) {noEffects_ = opt;} - - void setEnergyLossBetheBloch(bool opt = true) {energyLossBetheBloch_ = opt; noEffects_ = false;} - void setNoiseBetheBloch(bool opt = true) {noiseBetheBloch_ = opt; noEffects_ = false;} - void setNoiseCoulomb(bool opt = true) {noiseCoulomb_ = opt; noEffects_ = false;} - void setEnergyLossBrems(bool opt = true) {energyLossBrems_ = opt; noEffects_ = false;} - void setNoiseBrems(bool opt = true) {noiseBrems_ = opt; noEffects_ = false;} - void ignoreBoundariesBetweenEqualMaterials(bool opt = true) {ignoreBoundariesBetweenEqualMaterials_ = opt;} - - /** @brief Select the multiple scattering model that will be used during track fit. - * - * At the moment two model are available GEANE and Highland. GEANE is the model was was present in Genfit first. - * Note that using this function has no effect if setNoiseCoulomb(false) is set. - */ - void setMscModel(const std::string& modelName); - - - //! Calculates energy loss in the traveled path, optional calculation of noise matrix - double effects(const std::vector& steps, - int materialsFXStart, - int materialsFXStop, - const double& mom, - const int& pdg, - M7x7* noise = nullptr); - - /** @brief Returns maximum length so that a specified momentum loss will not be exceeded. - * - * The stepper returns the maximum length that the particle may travel, so that a specified relative momentum loss will not be exceeded, - * or the next material boundary is reached. The material crossed are stored together with their stepsizes. - */ - void stepper(const RKTrackRep* rep, - M1x7& state7, - const double& mom, // momentum - double& relMomLoss, // relative momloss for the step will be added - const int& pdg, - MaterialProperties& currentMaterial, - StepLimits& limits, - bool varField = true); - - - private: - - //! sets charge_, mass_ and calculates beta_, gamma_, fgammasquare; - void getParticleParameters(double mom); - - //! Returns energy loss - /** Uses Bethe Bloch formula to calculate energy loss. - * Calcuates and sets dEdx_ which needed also for noiseBetheBloch. - * Therefore it is not a const function! - * - */ - double energyLossBetheBloch(); - - //! calculation of energy loss straggeling - /** For the energy loss straggeling, different formulas are used for different regions: - * - Vavilov-Gaussian regime - * - Urban/Landau approximation - * - truncated Landau distribution - * - Urban model - * - * Needs dEdx_, which is calculated in energyLossBetheBloch, so it has to be called afterwards! - */ - void noiseBetheBloch(M7x7& noise) const; - - //! calculation of multiple scattering - /** This function first calcuates a MSC variance based on the current material and step length - * 2 different formulas for the MSC variance are implemeted. One can select the formula via "setMscModel". - * With the MSC variance and the current direction of the track a full 7D noise matrix is calculated. - * This noise matrix is the additional noise at the end of fStep in the 7D globa cooridnate system - * taking even the (co)variances of the position coordinates into account. - * - */ - void noiseCoulomb(M7x7& noise, - const M1x3& direction) const; - - //! Returns energy loss - /** Can be called with any pdg, but only calculates energy loss for electrons and positrons (otherwise returns 0). - * Uses a gaussian approximation (Bethe-Heitler formula with Migdal corrections). - * For positrons the energy loss is weighed with a correction factor. - */ - double energyLossBrems() const; - - //! calculation of energy loss straggeling - /** Can be called with any pdg, but only calculates straggeling for electrons and positrons. - * - */ - void noiseBrems(M7x7& noise) const; - - - bool noEffects_; - - bool energyLossBetheBloch_; - bool noiseBetheBloch_; - bool noiseCoulomb_; - bool energyLossBrems_; - bool noiseBrems_; - - bool ignoreBoundariesBetweenEqualMaterials_; - - const double me_; // electron mass (GeV) - - double stepSize_; // stepsize - - // cached values for energy loss and noise calculations - double mom_; - double beta_; - double dEdx_; - double gamma_; - double gammaSquare_; - - double matDensity_; - double matZ_; - double matA_; - double radiationLength_; - double mEE_; // mean excitation energy - - int pdg_; - int charge_; - double mass_; - - int mscModelCode_; /// depending on this number a specific msc model is chosen in the noiseCoulomb function. - - AbsMaterialInterface* materialInterface_; - - - //ClassDef(MaterialEffects, 1); - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_MaterialEffects_h diff --git a/genfit/include/genfit/RKTrackRep.h b/genfit/include/genfit/RKTrackRep.h deleted file mode 100644 index e07b3dc473..0000000000 --- a/genfit/include/genfit/RKTrackRep.h +++ /dev/null @@ -1,306 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup RKTrackRep - * @{ - */ - -#ifndef genfit_RKTrackRep_h -#define genfit_RKTrackRep_h - -#include "AbsTrackRep.h" -#include "StateOnPlane.h" -#include "RKTools.h" -#include "StepLimits.h" - - -namespace genfit { - -/** - * @brief Helper for RKTrackRep - */ -struct RKStep { - MatStep matStep_; // material properties and stepsize - M1x7 state7_; // 7D state vector - StepLimits limits_; - - RKStep() { - memset(state7_, 0x00, 7*sizeof(double)); - } -}; - - -/** - * @brief Helper for RKTrackRep - */ -struct ExtrapStep { - M7x7 jac7_; // 5D jacobian of transport - M7x7 noise7_; // 5D noise matrix - - ExtrapStep() { - memset(jac7_, 0, sizeof(M7x7)); - memset(noise7_, 0, sizeof(M7x7)); - } -}; - - -/** - * @brief AbsTrackRep with 5D track parameterization in plane coordinates: (q/p, u', v', u, v) - * - * q/p is charge over momentum. - * u' and v' are direction tangents. - * u and v are positions on a DetPlane. - */ -class RKTrackRep : public AbsTrackRep { - - - public: - - RKTrackRep(); - RKTrackRep(int pdgCode, char propDir = 0); - - virtual ~RKTrackRep(); - - virtual AbsTrackRep* clone() const {return new RKTrackRep(*this);} - - virtual double extrapolateToPlane(StateOnPlane& state, - const SharedPlanePtr& plane, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - using AbsTrackRep::extrapolateToLine; - - virtual double extrapolateToLine(StateOnPlane& state, - const TVector3& linePoint, - const TVector3& lineDirection, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - virtual double extrapolateToPoint(StateOnPlane& state, - const TVector3& point, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const { - return extrapToPoint(state, point, NULL, stopAtBoundary, calcJacobianNoise); - } - - virtual double extrapolateToPoint(StateOnPlane& state, - const TVector3& point, - const TMatrixDSym& G, // weight matrix (metric) - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const { - return extrapToPoint(state, point, &G, stopAtBoundary, calcJacobianNoise); - } - - virtual double extrapolateToCylinder(StateOnPlane& state, - double radius, - const TVector3& linePoint = TVector3(0.,0.,0.), - const TVector3& lineDirection = TVector3(0.,0.,1.), - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - virtual double extrapolateToSphere(StateOnPlane& state, - double radius, - const TVector3& point = TVector3(0.,0.,0.), - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - virtual double extrapolateBy(StateOnPlane& state, - double step, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - - unsigned int getDim() const {return 5;} - - virtual TVector3 getPos(const StateOnPlane& state) const; - - virtual TVector3 getMom(const StateOnPlane& state) const; - virtual void getPosMom(const StateOnPlane& state, TVector3& pos, TVector3& mom) const; - - virtual double getMomMag(const StateOnPlane& state) const; - virtual double getMomVar(const MeasuredStateOnPlane& state) const; - - virtual TMatrixDSym get6DCov(const MeasuredStateOnPlane& state) const; - virtual void getPosMomCov(const MeasuredStateOnPlane& state, TVector3& pos, TVector3& mom, TMatrixDSym& cov) const; - virtual double getCharge(const StateOnPlane& state) const; - virtual double getQop(const StateOnPlane& state) const {return state.getState()(0);} - double getSpu(const StateOnPlane& state) const; - - virtual void getForwardJacobianAndNoise(TMatrixD& jacobian, TMatrixDSym& noise, TVectorD& deltaState) const; - - virtual void getBackwardJacobianAndNoise(TMatrixD& jacobian, TMatrixDSym& noise, TVectorD& deltaState) const; - - std::vector getSteps() const; - - virtual double getRadiationLenght() const; - - virtual double getTOF() const; - - - virtual void setPosMom(StateOnPlane& state, const TVector3& pos, const TVector3& mom) const; - virtual void setPosMom(StateOnPlane& state, const TVectorD& state6) const; - virtual void setPosMomErr(MeasuredStateOnPlane& state, const TVector3& pos, const TVector3& mom, const TVector3& posErr, const TVector3& momErr) const; - virtual void setPosMomCov(MeasuredStateOnPlane& state, const TVector3& pos, const TVector3& mom, const TMatrixDSym& cov6x6) const; - virtual void setPosMomCov(MeasuredStateOnPlane& state, const TVectorD& state6, const TMatrixDSym& cov6x6) const; - - virtual void setChargeSign(StateOnPlane& state, double charge) const; - virtual void setQop(StateOnPlane& state, double qop) const {state.getState()(0) = qop;} - - void setSpu(StateOnPlane& state, double spu) const; - - //! The actual Runge Kutta propagation - /** propagate state7 with step S. Fills SA (Start directions derivatives dA/S). - * If jacobian is NULL, only the state is propagated, - * otherwise also the 7x7 jacobian is calculated. - * If varField is false, the magnetic field will only be evaluated at the starting position. - * The return value is an estimation on how good the extrapolation is, and it is usually fine if it is > 1. - * It gives a suggestion how you must scale S so that the quality will be sufficient. - */ - double RKPropagate(M1x7& state7, - M7x7* jacobian, - M1x3& SA, - double S, - bool varField = true, - bool calcOnlyLastRowOfJ = false) const; - - virtual bool isSameType(const AbsTrackRep* other); - virtual bool isSame(const AbsTrackRep* other); - - private: - - void initArrays() const; - - virtual double extrapToPoint(StateOnPlane& state, - const TVector3& point, - const TMatrixDSym* G = NULL, // weight matrix (metric) - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - void getState7(const StateOnPlane& state, M1x7& state7) const; - void getState5(StateOnPlane& state, const M1x7& state7) const; // state7 must already lie on plane of state! - - void transformPM7(const MeasuredStateOnPlane& state, - M7x7& out7x7) const; - - void calcJ_pM_5x7(M5x7& J_pM, const TVector3& U, const TVector3& V, const M1x3& pTilde, double spu) const; - - void transformPM6(const MeasuredStateOnPlane& state, - M6x6& out6x6) const; - - void transformM7P(const M7x7& in7x7, - const M1x7& state7, - MeasuredStateOnPlane& state) const; // plane must already be set! - - void calcJ_Mp_7x5(M7x5& J_Mp, const TVector3& U, const TVector3& V, const TVector3& W, const M1x3& A) const; - - void calcForwardJacobianAndNoise(const M1x7& startState7, const DetPlane& startPlane, - const M1x7& destState7, const DetPlane& destPlane) const; - - void transformM6P(const M6x6& in6x6, - const M1x7& state7, - MeasuredStateOnPlane& state) const; // plane and charge must already be set! - - //! Propagates the particle through the magnetic field. - /** If the propagation is successful and the plane is reached, the function returns true. - * Propagated state and the jacobian of the extrapolation are written to state7 and jacobianT. - * The jacobian is only calculated if jacobianT != NULL. - * In the main loop of the Runge Kutta algorithm, the estimateStep() is called - * and may reduce the estimated stepsize so that a maximum momentum loss will not be exceeded, - * and stop at material boundaries. - * If this is the case, RKutta() will only propagate the reduced distance and then return. This is to ensure that - * material effects, which are calculated after the propagation, are taken into account properly. - */ - bool RKutta(const M1x4& SU, - const DetPlane& plane, - double charge, - M1x7& state7, - M7x7* jacobianT, - double& coveredDistance, // signed - bool& checkJacProj, - M7x7& noiseProjection, - StepLimits& limits, - bool onlyOneStep = false, - bool calcOnlyLastRowOfJ = false) const; - - double estimateStep(const M1x7& state7, - const M1x4& SU, - const DetPlane& plane, - const double& charge, - double& relMomLoss, - StepLimits& limits) const; - - TVector3 pocaOnLine(const TVector3& linePoint, - const TVector3& lineDirection, - const TVector3& point) const; - - //! Handles propagation and material effects - /** #extrapolateToPlane(), #extrapolateToPoint() and #extrapolateToLine() etc. call this function. - * #Extrap() needs a plane as an argument, hence #extrapolateToPoint() and #extrapolateToLine() create virtual detector planes. - * In this function, #RKutta() is called and the resulting points and point paths are filtered - * so that the direction doesn't change and tiny steps are filtered out. - * After the propagation the material effects are called via the MaterialEffects singleton. - * #Extrap() will loop until the plane is reached, unless the propagation fails or the maximum number of - * iterations is exceeded. - */ - double Extrap(const DetPlane& startPlane, // plane where Extrap starts - const DetPlane& destPlane, // plane where Extrap has to extrapolate to - double charge, - bool& isAtBoundary, - M1x7& state7, - bool fillExtrapSteps, - TMatrixDSym* cov = nullptr, - bool onlyOneStep = false, - bool stopAtBoundary = false, - double maxStep = 1.E99) const; - - void checkCache(const StateOnPlane& state, const SharedPlanePtr* plane) const; - - double momMag(const M1x7& state7) const; - - - mutable StateOnPlane lastStartState_; //! state where the last extrapolation has started - mutable StateOnPlane lastEndState_; //! state where the last extrapolation has ended - mutable std::vector RKSteps_; //! RungeKutta steps made in the last extrapolation - mutable int RKStepsFXStart_; //! - mutable int RKStepsFXStop_; //! - mutable std::vector ExtrapSteps_; //! steps made in Extrap during last extrapolation - - mutable TMatrixD fJacobian_; //! - mutable TMatrixDSym fNoise_; //! - - mutable bool useCache_; //! use cached RKSteps_ for extrapolation - mutable unsigned int cachePos_; //! - - // auxiliary variables and arrays - // needed in Extrap() - mutable StepLimits limits_; //! - mutable M7x7 noiseArray_; //! noise matrix of the last extrapolation - mutable M7x7 noiseProjection_; //! - mutable M7x7 J_MMT_; //! - - public: - - ClassDef(RKTrackRep, 1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_RKTrackRep_h diff --git a/genfit/include/genfit/TGeoMaterialInterface.h b/genfit/include/genfit/TGeoMaterialInterface.h deleted file mode 100644 index e6d77c0418..0000000000 --- a/genfit/include/genfit/TGeoMaterialInterface.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2008-2014, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup RKTrackRep - * @{ - */ - -#ifndef genfit_TGeoMaterialInterface_h -#define genfit_TGeoMaterialInterface_h - -#include "AbsMaterialInterface.h" - - -namespace genfit { - -/** - * @brief AbsMaterialInterface implementation for use with ROOT's TGeoManager. - */ -class TGeoMaterialInterface : public AbsMaterialInterface { - - public: - - TGeoMaterialInterface() {}; - virtual ~TGeoMaterialInterface(){;}; - - /** @brief Initialize the navigator at given position and with given - direction. Returns true if the volume changed. - */ - bool initTrack(double posX, double posY, double posZ, - double dirX, double dirY, double dirZ); - - /** @brief Get material parameters in current material - */ - void getMaterialParameters(double& density, - double& Z, - double& A, - double& radiationLength, - double& mEE); - - void getMaterialParameters(MaterialProperties& parameters); - - /** @brief Make a step (following the curvature) until step length - * sMax or the next boundary is reached. After making a step to a - * boundary, the position has to be beyond the boundary, i.e. the - * current material has to be that beyond the boundary. The actual - * step made is returned. - */ - double findNextBoundary(const RKTrackRep* rep, - const M1x7& state7, - double sMax, - bool varField = true); - - double findNextBoundaryAndStepStraight(double sMax); - - ClassDef(TGeoMaterialInterface, 1); - - private: -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_TGeoMaterialInterface_h diff --git a/genfit/lgpl.txt b/genfit/lgpl.txt deleted file mode 100644 index cca7fc278f..0000000000 --- a/genfit/lgpl.txt +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/genfit/makeEnv.sh b/genfit/makeEnv.sh deleted file mode 100755 index 56f78ecf77..0000000000 --- a/genfit/makeEnv.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -ENVFILE=env.sh -if [ -z $GENFIT ]; then - echo "define the GENFIT env variable before executing this script" -else - echo "if [ -z \$ROOTSYS ]; then" > $ENVFILE - echo "echo \"ROOTSYS is not set. Check your ROOT installation.\"" >> $ENVFILE - echo "else" >> $ENVFILE - echo "export GENFIT=$GENFIT" >> $ENVFILE - echo "if [ \`root-config --arch\` = macosx ]; then" >>$ENVFILE - echo "export DYLD_LIBRARY_PATH=\$DYLD_LIBRARY_PATH:\$GENFIT/lib" >>$ENVFILE - echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$GENFIT/lib" >>$ENVFILE - echo "else" >>$ENVFILE - echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$GENFIT/lib" >>$ENVFILE - echo "fi" >>$ENVFILE - echo "fi" >> $ENVFILE - - if [ $RAVEPATH ]; then - echo "export RAVEPATH=$RAVEPATH" >> $ENVFILE - fi -fi - diff --git a/genfit/measurements/include/FullMeasurement.h b/genfit/measurements/include/FullMeasurement.h deleted file mode 100644 index c87ee59b1b..0000000000 --- a/genfit/measurements/include/FullMeasurement.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_FullMeasurement_h -#define genfit_FullMeasurement_h - -#include "AbsMeasurement.h" -#include "AbsHMatrix.h" -#include "MeasurementOnPlane.h" - - -namespace genfit { - -class AbsTrackRep; - -/** @brief Measurement class implementing a measurement of all track parameters. - * - * @author Johannes Rauch (Technische Universität München, original author) - * - * This class can e.g. be used, if the fitted track parameters measured in one subdetector should be - * put into one "measurement". - */ -class FullMeasurement : public AbsMeasurement { - - public: - FullMeasurement(int nDim = 5); - FullMeasurement(const MeasuredStateOnPlane&, int detId = -1, int hitId = -1, TrackPoint* trackPoint = NULL); - - virtual ~FullMeasurement() {;} - - virtual AbsMeasurement* clone() const {return new FullMeasurement(*this);} - - virtual SharedPlanePtr constructPlane(const StateOnPlane& state) const; - - virtual std::vector constructMeasurementsOnPlane(const StateOnPlane& state) const; - - virtual const AbsHMatrix* constructHMatrix(const AbsTrackRep*) const; - - protected: - SharedPlanePtr plane_; //! This is persistent, but '!' makes ROOT shut up. - - public: - - ClassDef(FullMeasurement,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_FullMeasurement_h diff --git a/genfit/measurements/include/HMatrixPhi.h b/genfit/measurements/include/HMatrixPhi.h deleted file mode 100644 index f9a9c153ab..0000000000 --- a/genfit/measurements/include/HMatrixPhi.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_HMatrixPhi_h -#define genfit_HMatrixPhi_h - -#include "AbsHMatrix.h" - - -namespace genfit { - -/** - * @brief AbsHMatrix implementation for one-dimensional MeasurementOnPlane and RKTrackRep parameterization. - * - * For one dimensional measurements which are rotated by phi against U of the DetPlane - * H = (0, 0, 0, cos(phi), sin(phi)) - */ -class HMatrixPhi : public AbsHMatrix { - - public: - - HMatrixPhi(double phi = 0); - - const TMatrixD& getMatrix() const; - - TVectorD Hv(const TVectorD& v) const; - - TMatrixD MHt(const TMatrixDSym& M) const; - TMatrixD MHt(const TMatrixD& M) const; - - void HMHt(TMatrixDSym& M) const; - - virtual AbsHMatrix* clone() const {return new HMatrixPhi(*this);} - - virtual bool isEqual(const AbsHMatrix& other) const; - - ClassDef(HMatrixPhi,1) - - private: - - double phi_; - double cosPhi_; //! - double sinPhi_; //! - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_HMatrixPhi_h diff --git a/genfit/measurements/include/HMatrixU.h b/genfit/measurements/include/HMatrixU.h deleted file mode 100644 index 51d34509f7..0000000000 --- a/genfit/measurements/include/HMatrixU.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_HMatrixU_h -#define genfit_HMatrixU_h - -#include "AbsHMatrix.h" - - -namespace genfit { - -/** - * @brief AbsHMatrix implementation for one-dimensional MeasurementOnPlane and RKTrackRep parameterization. - * - * This projects out u. - * H = (0, 0, 0, 1, 0) - */ -class HMatrixU : public AbsHMatrix { - - public: - - HMatrixU() {;} - - const TMatrixD& getMatrix() const; - - TVectorD Hv(const TVectorD& v) const; - - TMatrixD MHt(const TMatrixDSym& M) const; - TMatrixD MHt(const TMatrixD& M) const; - - void HMHt(TMatrixDSym& M) const; - - virtual AbsHMatrix* clone() const {return new HMatrixU(*this);} - - virtual bool isEqual(const AbsHMatrix& other) const {return (dynamic_cast(&other) != NULL);} - - ClassDef(HMatrixU,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_HMatrixU_h diff --git a/genfit/measurements/include/HMatrixUV.h b/genfit/measurements/include/HMatrixUV.h deleted file mode 100644 index 95d4cb3b75..0000000000 --- a/genfit/measurements/include/HMatrixUV.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_HMatrixUV_h -#define genfit_HMatrixUV_h - -#include "AbsHMatrix.h" - - -namespace genfit { - -/** - * @brief AbsHMatrix implementation for two-dimensional MeasurementOnPlane and RKTrackRep parameterization. - * - * This projects out u and v. - * H = (0, 0, 0, 1, 0) - * (0, 0, 0, 0, 1) - * - */ -class HMatrixUV : public AbsHMatrix { - - - public: - - HMatrixUV() {;} - - const TMatrixD& getMatrix() const; - - TVectorD Hv(const TVectorD& v) const; - - TMatrixD MHt(const TMatrixDSym& M) const; - TMatrixD MHt(const TMatrixD& M) const; - - void HMHt(TMatrixDSym& M) const; - - virtual AbsHMatrix* clone() const {return new HMatrixUV(*this);} - - virtual bool isEqual(const AbsHMatrix& other) const {return (dynamic_cast(&other) != NULL);} - - ClassDef(HMatrixUV,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - - -#endif // genfit_HMatrixUV_h diff --git a/genfit/measurements/include/HMatrixUnit.h b/genfit/measurements/include/HMatrixUnit.h deleted file mode 100644 index c0118137ec..0000000000 --- a/genfit/measurements/include/HMatrixUnit.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_HMatrixUnit_h -#define genfit_HMatrixUnit_h - -#include "AbsHMatrix.h" - - -namespace genfit { - -/** - * @brief AbsHMatrix implementation for 5-dimensional MeasurementOnPlane and RKTrackRep parameterization. - * - * H = (1, 0, 0, 0, 0) - * (0, 1, 0, 0, 0) - * (0, 0, 1, 0, 0) - * (0, 0, 0, 1, 0) - * (0, 0, 0, 0, 1) - */ -class HMatrixUnit : public AbsHMatrix { - - public: - - HMatrixUnit() {;} - - const TMatrixD& getMatrix() const; - - TVectorD Hv(const TVectorD& v) const {return v;} - - TMatrixD MHt(const TMatrixDSym& M) const {return TMatrixD(M);} - TMatrixD MHt(const TMatrixD& M) const {return M;} - - void HMHt(TMatrixDSym&) const {return;} - - virtual AbsHMatrix* clone() const {return new HMatrixUnit(*this);} - - virtual bool isEqual(const AbsHMatrix& other) const {return (dynamic_cast(&other) != NULL);} - - ClassDef(HMatrixUnit,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_HMatrixUnit_h diff --git a/genfit/measurements/include/HMatrixV.h b/genfit/measurements/include/HMatrixV.h deleted file mode 100644 index 7e42786d12..0000000000 --- a/genfit/measurements/include/HMatrixV.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_HMatrixV_h -#define genfit_HMatrixV_h - -#include "AbsHMatrix.h" - - -namespace genfit { - -/** - * @brief AbsHMatrix implementation for one-dimensional MeasurementOnPlane and RKTrackRep parameterization. - * - * This projects out v. - * H = (0, 0, 0, 0, 1) - */ -class HMatrixV : public AbsHMatrix { - - public: - - HMatrixV() {;} - - const TMatrixD& getMatrix() const; - - TVectorD Hv(const TVectorD& v) const; - - TMatrixD MHt(const TMatrixDSym& M) const; - TMatrixD MHt(const TMatrixD& M) const; - - void HMHt(TMatrixDSym& M) const; - - virtual AbsHMatrix* clone() const {return new HMatrixV(*this);} - - virtual bool isEqual(const AbsHMatrix& other) const {return (dynamic_cast(&other) != NULL);} - - ClassDef(HMatrixV,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_HMatrixV_h diff --git a/genfit/measurements/include/PlanarMeasurement.h b/genfit/measurements/include/PlanarMeasurement.h deleted file mode 100644 index dcd44c59dd..0000000000 --- a/genfit/measurements/include/PlanarMeasurement.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_PlanarMeasurement_h -#define genfit_PlanarMeasurement_h - -#include "AbsMeasurement.h" -#include "AbsHMatrix.h" -#include "MeasurementOnPlane.h" - - -namespace genfit { - -class AbsTrackRep; - -/** @brief Measurement class implementing a planar hit geometry (1 or 2D). - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * @author Johannes Rauch (Technische Universität München, original author) - * - * The main feature of this type of hit is, that the detector plane - * is defined by the detector hardware. - */ -class PlanarMeasurement : public AbsMeasurement { - - public: - PlanarMeasurement(int nDim = 1); - PlanarMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint); - - virtual ~PlanarMeasurement() {;} - - virtual AbsMeasurement* clone() const {return new PlanarMeasurement(*this);} - - int getPlaneId() const {return planeId_;} - - virtual SharedPlanePtr constructPlane(const StateOnPlane& state) const; - - virtual std::vector constructMeasurementsOnPlane(const StateOnPlane& state) const; - - virtual const AbsHMatrix* constructHMatrix(const AbsTrackRep*) const; - - virtual void setPlane(const SharedPlanePtr& physicalPlane, int planeId = -1) {physicalPlane_ = physicalPlane; planeId_ = planeId;} - - /** @brief Use if the coordinate for 1D hits measured in V direction. - * - * Per default for 1D planar hits, the coordinate is measured in U direction. - * With this function you can set it to be measured in V direction. - * This affects the outcoe of constructHMatrix(). - */ - void setStripV(bool v = true) {stripV_ = v;} - - protected: - SharedPlanePtr physicalPlane_; //! This is persistent, but '!' makes ROOT shut up. - int planeId_; // planeId id is -1 per default - bool stripV_; - - public: - - ClassDef(PlanarMeasurement,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_PlanarMeasurement_h diff --git a/genfit/measurements/include/ProlateSpacepointMeasurement.h b/genfit/measurements/include/ProlateSpacepointMeasurement.h deleted file mode 100644 index 40232c4638..0000000000 --- a/genfit/measurements/include/ProlateSpacepointMeasurement.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_ProlateSpacepointMeasurement_h -#define genfit_ProlateSpacepointMeasurement_h - -#include "SpacepointMeasurement.h" - - -namespace genfit { - -/** @brief Class for measurements implementing a space point hit geometry with a very prolate - * form of the covariance matrix. - * - * @author Johannes Rauch (Technische Universität München, original author) - * - * Measurements from detectors measuring 3D space points with errors in one direction - * much larger than the errors perpendicular should use this class. - * - * For these hits, a virtual detector plane lying in the POCA and - * perpendicular to the track yields wrong results. Instead, the plane should contain the - * direction of the largest error. - * - * The largest error direction can be set. Standard is in z. - * - */ -class ProlateSpacepointMeasurement : public SpacepointMeasurement { - - public: - ProlateSpacepointMeasurement(int nDim = 3); - ProlateSpacepointMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint); - - virtual ~ProlateSpacepointMeasurement() {;} - - virtual AbsMeasurement* clone() const {return new ProlateSpacepointMeasurement(*this);} - - virtual SharedPlanePtr constructPlane(const StateOnPlane& state) const; - - - const TVector3& getLargestErrorDirection(){return largestErrorDirection_;} - void setLargestErrorDirection(const TVector3& dir){largestErrorDirection_ = dir.Unit();} - - protected: - TVector3 largestErrorDirection_; // direction of largest error - - public: - - ClassDef(ProlateSpacepointMeasurement,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_ProlateSpacepointMeasurement_h diff --git a/genfit/measurements/include/SpacepointMeasurement.h b/genfit/measurements/include/SpacepointMeasurement.h deleted file mode 100644 index 632b36af6a..0000000000 --- a/genfit/measurements/include/SpacepointMeasurement.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_SpacepointMeasurement_h -#define genfit_SpacepointMeasurement_h - -#include "AbsMeasurement.h" -#include "AbsHMatrix.h" - - -namespace genfit { - -/** @brief Class for measurements implementing a space point hit geometry. - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * @author Johannes Rauch (Technische Universität München, original author) - * - * For a space point the detector plane has to be defined with respect to - * a track representation. SpacepointMeasurement implements a scheme where the - * detectorplane is chosen perpendicular to the track. - * In a track fit, only two of the three coordinates of a space point are - * independent (the track is a one-dimensional object). Therefore the 3D - * data of the hit is used to define a proper detector plane into which the - * hit coordinates are then projected. - */ -class SpacepointMeasurement : public AbsMeasurement { - - public: - SpacepointMeasurement(int nDim = 3); - SpacepointMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint, - bool weightedPlaneContruction = true, bool cutCov = true); - - virtual ~SpacepointMeasurement() {;} - - virtual AbsMeasurement* clone() const {return new SpacepointMeasurement(*this);} - - /** - * @brief Contruct the virtual detector plane - * - * Per default, the plane will be constructed such that it contains the measurement and POCA to the measurement in cartesian space. - * The plane is perpendicular to the track (at the POCA). - * - * If weightedPlaneContruction_ is set, the POCA will be calculated in a space weighted with the inverse of the 3D covariance. - * E.g. if the covariance is very oblate, the plane will be almost defined by the covariance shape. - * If the covariance is very prolate, the behaviour will be very similar to the ProlateSpacepointHit. - */ - virtual SharedPlanePtr constructPlane(const StateOnPlane& state) const; - - virtual std::vector constructMeasurementsOnPlane(const StateOnPlane& state) const; - - virtual const AbsHMatrix* constructHMatrix(const AbsTrackRep*) const; - - private: - - void initG(); - - bool weightedPlaneContruction_; // false: use POCA to construct DetPlane. true: Use metric G to construct POCA (default) - TMatrixDSym G_; //! inverse of 3x3 cov - bool cutCov_; // false: project 3D cov onto DetPlane. true: cut 3D cov with DetPlane (default) - - ClassDef(SpacepointMeasurement,3) -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_SpacepointMeasurement_h diff --git a/genfit/measurements/include/WireMeasurement.h b/genfit/measurements/include/WireMeasurement.h deleted file mode 100644 index 38ee15dbf5..0000000000 --- a/genfit/measurements/include/WireMeasurement.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_WireMeasurement_h -#define genfit_WireMeasurement_h - -#include "AbsMeasurement.h" -#include "AbsHMatrix.h" -#include "MeasurementOnPlane.h" - - -namespace genfit { - -/** @brief Class for measurements in wire detectors (Straw tubes and drift chambers) - * which do not measure the coordinate along the wire. - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Lia Lavezzi (INFN Pavia, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * @author Johannes Rauch (Technische Universität München, original author) - * - * This hit class is not valid for any kind of plane orientation - * choice: to use it you MUST choose a plane described by u - * and v axes with v coincident with the wire (and u orthogonal - * to it, obviously). - * The hit will be described by 7 coordinates: - * w_x1, w_y1, w_z1, w_x2, w_y2, w_z2, rdrift - * where w_ji (with j = x, y, z and i = 1, 2) are the wire - * extremities coordinates; rdrift = distance from the wire (u - * coordinate in the plane) - * - */ -class WireMeasurement : public AbsMeasurement { - - public: - WireMeasurement(int nDim = 7); - WireMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint); - - virtual ~WireMeasurement() {;} - - virtual AbsMeasurement* clone() const {return new WireMeasurement(*this);} - - virtual SharedPlanePtr constructPlane(const StateOnPlane& state) const; - - /** Hits with a small drift distance get a higher weight, whereas hits with - * big drift distances become weighted down. - * When these initial weights are used by the DAF, the smoothed track will be closer to the real - * trajectory than if both sides are weighted with 0.5 regardless of the drift distance. - * This helps a lot when resolving l/r ambiguities with the DAF. - * The idea is that for the first iteration of the DAF, the wire positions are taken. - * For small drift radii, the wire position does not bend the fit away from the - * trajectory, whereas the wire position for hits with large drift radii is further away - * from the trajectory and will therefore bias the fit if not weighted down. - */ - virtual std::vector constructMeasurementsOnPlane(const StateOnPlane& state) const; - - virtual const AbsHMatrix* constructHMatrix(const AbsTrackRep*) const; - - /** Set maximum drift distance. This is used to calculate the start weights of the two - * measurementsOnPlane. - */ - void setMaxDistance(double d){maxDistance_ = d;} - /** - * select how to resolve the left/right ambiguity: - * -1: negative (left) side on vector (track direction) x (wire direction) - * 0: auto select (take side with smallest distance to track) - * 1: positive (right) side on vector (track direction) x (wire direction) - */ - void setLeftRightResolution(int lr); - - double getMaxDistance(){return maxDistance_;} - int getLeftRightResolution() const {return leftRight_;} - - protected: - - double maxDistance_; - double leftRight_; - - public: - - ClassDef(WireMeasurement, 1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_WireMeasurement_h diff --git a/genfit/measurements/include/WirePointMeasurement.h b/genfit/measurements/include/WirePointMeasurement.h deleted file mode 100644 index fd7a7ca31c..0000000000 --- a/genfit/measurements/include/WirePointMeasurement.h +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_WirePointMeasurement_h -#define genfit_WirePointMeasurement_h - -#include "WireMeasurement.h" - - -namespace genfit { - -/** @brief Class for measurements in wire detectors (Straw tubes and drift chambers) - * which can measure the coordinate along the wire - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Lia Lavezzi (INFN Pavia, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * @author Johannes Rauch (Technische Universität München, original author) - * - * This is not valid for any kind of plane orientation - * choice: to use it you MUST choose a plane described by u - * and v axes with v coincident with the wire (and u orthogonal - * to it, obviously). - * The hit will be described by 8 coordinates: - * w_x1, w_y1, w_z1, w_x2, w_y2, w_z2, rdrift, zreco - * where w_ji (with j = x, y, z and i = 1, 2) are the wire - * extremities coordinates; rdrift = distance from the wire (u - * coordinate in the plane) and zreco = coordinate along the - * wire (w2 -w1) (in the plane reference frame, v coordinate). - * - */ -class WirePointMeasurement : public WireMeasurement { - - public: - WirePointMeasurement(int nDim = 8); - WirePointMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint); - - virtual ~WirePointMeasurement() {;} - - virtual AbsMeasurement* clone() const {return new WirePointMeasurement(*this);} - - virtual SharedPlanePtr constructPlane(const StateOnPlane& state) const; - - virtual std::vector constructMeasurementsOnPlane(const StateOnPlane& state) const; - - virtual const AbsHMatrix* constructHMatrix(const AbsTrackRep*) const; - - - public: - - ClassDef(WirePointMeasurement,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_WirePointMeasurement_h diff --git a/genfit/measurements/include/WireTrackCandHit.h b/genfit/measurements/include/WireTrackCandHit.h deleted file mode 100644 index 63e9963ba9..0000000000 --- a/genfit/measurements/include/WireTrackCandHit.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . - */ -/** @addtogroup genfit - * @{ - */ - -#ifndef genfit_WireTrackCandHit_h -#define genfit_WireTrackCandHit_h - -#include "TrackCandHit.h" - - -namespace genfit { - -/** - * @brief Hit object for use in TrackCand. Provides additional left/right parameter. - */ -class WireTrackCandHit : public TrackCandHit { - public: - - // Constructors/Destructors --------- - WireTrackCandHit(int detId = -1, - int hitId = -1, - int planeId = -1, - double sortingParameter = 0., - char leftRight = 0); - - virtual ~WireTrackCandHit() {;} - - virtual TrackCandHit* clone() const {return new WireTrackCandHit(*this);} - - // Accessors - double getLeftRightResolution() const {return leftRight_;} - - // Modifiers - void setLeftRightResolution(double leftRight) {leftRight_ = leftRight;} - - virtual void Print(Option_t* option = "") const; - - - protected: - - //! protect from calling copy c'tor from outside the class. Use #clone() if you want a copy! - WireTrackCandHit(const WireTrackCandHit& other) : - TrackCandHit(other), leftRight_(other.leftRight_) {;} - //! protect from calling assignment operator from outside the class. Use #clone() instead! - WireTrackCandHit& operator=(const WireTrackCandHit&); - - - // Data Members ------------ - char leftRight_; // sorting parameter - - - public: - - ClassDef(WireTrackCandHit,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_TrackCandHit_h diff --git a/genfit/measurements/src/FullMeasurement.cc b/genfit/measurements/src/FullMeasurement.cc deleted file mode 100644 index 6c82017802..0000000000 --- a/genfit/measurements/src/FullMeasurement.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "FullMeasurement.h" - -#include -#include -#include - -#include -#include - - -namespace genfit { - -FullMeasurement::FullMeasurement(int nDim) - : AbsMeasurement(nDim), plane_() -{ - assert(nDim >= 1); -} - - -FullMeasurement::FullMeasurement(const MeasuredStateOnPlane& state, int detId, int hitId, TrackPoint* trackPoint) - : AbsMeasurement(state.getState(), state.getCov(), detId, hitId, trackPoint), plane_(state.getPlane()) -{ - assert(rawHitCoords_.GetNrows() == (int)state.getRep()->getDim()); -} - - -SharedPlanePtr FullMeasurement::constructPlane(const StateOnPlane&) const { - if (!plane_) { - Exception exc("FullMeasurement::constructPlane(): No plane has been set!", __LINE__,__FILE__); - throw exc; - } - return plane_; -} - - -std::vector FullMeasurement::constructMeasurementsOnPlane(const StateOnPlane& state) const { - - MeasurementOnPlane* mop = new MeasurementOnPlane(rawHitCoords_, - rawHitCov_, - state.getPlane(), state.getRep(), constructHMatrix(state.getRep())); - - std::vector retVal; - retVal.push_back(mop); - return retVal; -} - - -const AbsHMatrix* FullMeasurement::constructHMatrix(const AbsTrackRep* rep) const { - - if (dynamic_cast(rep) == NULL) { - Exception exc("SpacepointMeasurement default implementation can only handle state vectors of type RKTrackRep!", __LINE__,__FILE__); - throw exc; - } - - return new HMatrixUnit(); -} - - -void FullMeasurement::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::FullMeasurement. - - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::FullMeasurement thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - //This works around a msvc bug and should be harmless on other platforms - typedef genfit::AbsMeasurement baseClass0; - baseClass0::Streamer(R__b); - char flag; - R__b >> flag; - plane_.reset(); - if (flag) { - plane_.reset(new DetPlane()); - plane_->Streamer(R__b); - } - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - //This works around a msvc bug and should be harmless on other platforms - typedef genfit::AbsMeasurement baseClass0; - baseClass0::Streamer(R__b); - if (plane_) { - R__b << (char)1; - plane_->Streamer(R__b); - } else { - R__b << (char)0; - } - R__b.SetByteCount(R__c, kTRUE); - } -} - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/HMatrixPhi.cc b/genfit/measurements/src/HMatrixPhi.cc deleted file mode 100644 index 5ecb94d61c..0000000000 --- a/genfit/measurements/src/HMatrixPhi.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright 2013, Technische Universitaet Muenchen, - Authors: Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "HMatrixPhi.h" -#include -#include -#include -#include - - -namespace genfit { - - -// 0, 0, 0, cos(phi), sin(phi) - - -HMatrixPhi::HMatrixPhi(double phi) : - phi_(phi), - cosPhi_(cos(phi)), - sinPhi_(sin(phi)) -{ - ; -} - -const TMatrixD& HMatrixPhi::getMatrix() const { - static const double HMatrixContent[5] = {0, 0, 0, cosPhi_, sinPhi_}; - - static const TMatrixD HMatrix(1,5, HMatrixContent); - - return HMatrix; -} - - -TVectorD HMatrixPhi::Hv(const TVectorD& v) const { - assert (v.GetNrows() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * 1); - - retValArray[0] = cosPhi_*v(3) + sinPhi_*v(4); - - return TVectorD(1, retValArray); -} - - -TMatrixD HMatrixPhi::MHt(const TMatrixDSym& M) const { - assert (M.GetNcols() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * 5); - const double* MatArray = M.GetMatrixArray(); - - for (unsigned int i=0; i<5; ++i) { - retValArray[i] = cosPhi_*MatArray[i*5 + 3] + sinPhi_*MatArray[i*5 + 4]; - } - - return TMatrixD(5,1, retValArray); -} - - -TMatrixD HMatrixPhi::MHt(const TMatrixD& M) const { - assert (M.GetNcols() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * M.GetNrows()); - const double* MatArray = M.GetMatrixArray(); - - for (int i = 0; i < M.GetNrows(); ++i) { - retValArray[i] = cosPhi_*MatArray[i*5 + 3] + sinPhi_*MatArray[i*5 + 4]; - } - - return TMatrixD(M.GetNrows(),1, retValArray); -} - - -void HMatrixPhi::HMHt(TMatrixDSym& M) const { - assert (M.GetNrows() == 5); - - M(0,0) = cosPhi_ * (cosPhi_*M(3,3) + sinPhi_*M(3,4)) - + sinPhi_ * (cosPhi_*M(4,3) + sinPhi_*M(4,4)); - - M.ResizeTo(1,1); -} - - -bool HMatrixPhi::isEqual(const AbsHMatrix& other) const { - if (dynamic_cast(&other) == NULL) - return false; - - return (phi_ == static_cast(&other)->phi_); -} - - -void HMatrixPhi::Streamer(TBuffer &R__b) { - // Stream an object of class genfit::HMatrixPhi. - - // Modified from auto-generated streamer to set non-persistent members after reading - - if (R__b.IsReading()) { - R__b.ReadClassBuffer(genfit::HMatrixPhi::Class(),this); - cosPhi_ = cos(phi_); - sinPhi_ = sin(phi_); - } else { - R__b.WriteClassBuffer(genfit::HMatrixPhi::Class(),this); - } -} - - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/HMatrixU.cc b/genfit/measurements/src/HMatrixU.cc deleted file mode 100644 index 2b5d8305c4..0000000000 --- a/genfit/measurements/src/HMatrixU.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright 2013, Technische Universitaet Muenchen, - Authors: Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "HMatrixU.h" -#include -#include - - -namespace genfit { - - -// 0, 0, 0, 1, 0 - -const TMatrixD& HMatrixU::getMatrix() const { - static const double HMatrixContent[5] = {0, 0, 0, 1, 0}; - - static const TMatrixD HMatrix(1,5, HMatrixContent); - - return HMatrix; -} - - -TVectorD HMatrixU::Hv(const TVectorD& v) const { - assert (v.GetNrows() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * 1); - - retValArray[0] = v(3); // u - - return TVectorD(1, retValArray); -} - - -TMatrixD HMatrixU::MHt(const TMatrixDSym& M) const { - assert (M.GetNcols() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * 5); - const double* MatArray = M.GetMatrixArray(); - - for (unsigned int i=0; i<5; ++i) { - retValArray[i] = MatArray[i*5 + 3]; - } - - return TMatrixD(5,1, retValArray); -} - - -TMatrixD HMatrixU::MHt(const TMatrixD& M) const { - assert (M.GetNcols() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * M.GetNrows()); - const double* MatArray = M.GetMatrixArray(); - - for (int i = 0; i < M.GetNrows(); ++i) { - retValArray[i] = MatArray[i*5 + 3]; - } - - return TMatrixD(M.GetNrows(),1, retValArray); -} - - -void HMatrixU::HMHt(TMatrixDSym& M) const { - assert (M.GetNrows() == 5); - - M(0,0) = M(3,3); - - M.ResizeTo(1,1); -} - - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/HMatrixUV.cc b/genfit/measurements/src/HMatrixUV.cc deleted file mode 100644 index e908de8820..0000000000 --- a/genfit/measurements/src/HMatrixUV.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright 2013, Technische Universitaet Muenchen, Ludwig-Maximilians-Universität München - Authors: Johannes Rauch, Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "HMatrixUV.h" -#include -#include - -namespace genfit { - - -// 0, 0, 0, 1, 0 -// 0, 0, 0, 0, 1 - -const TMatrixD& HMatrixUV::getMatrix() const { - static const double HMatrixContent[2*5] = {0, 0, 0, 1, 0, - 0, 0, 0, 0, 1}; - - static const TMatrixD HMatrix(2,5, HMatrixContent); - - return HMatrix; -} - - -TVectorD HMatrixUV::Hv(const TVectorD& v) const { - assert (v.GetNrows() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * 2); - const double* VecArray = v.GetMatrixArray(); - - retValArray[0] = VecArray[3]; // u - retValArray[1] = VecArray[4]; // v - - return TVectorD(2, retValArray); -} - - -TMatrixD HMatrixUV::MHt(const TMatrixDSym& M) const { - assert (M.GetNcols() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * 5*2); - const double* MatArray = M.GetMatrixArray(); - - for (unsigned int i=0; i<5; ++i) { - retValArray[i*2] = MatArray[i*5 + 3]; - retValArray[i*2 + 1] = MatArray[i*5 + 4]; - } - - return TMatrixD(5,2, retValArray); -} - - -TMatrixD HMatrixUV::MHt(const TMatrixD& M) const { - assert (M.GetNcols() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * M.GetNrows()*2); - const double* MatArray = M.GetMatrixArray(); - - for (int i = 0; i < M.GetNrows(); ++i) { - retValArray[i*2] = MatArray[i*5 + 3]; - retValArray[i*2 + 1] = MatArray[i*5 + 4]; - } - - return TMatrixD(M.GetNrows(),2, retValArray); -} - - -void HMatrixUV::HMHt(TMatrixDSym& M) const { - assert (M.GetNrows() == 5); - double* MatArray = M.GetMatrixArray(); - - // - // HMH^t = ( M_33 M_34 ) where M_34 == M_43 - // ( M_43 M_44 ) - // - double uu = MatArray[3*5 + 3]; - double uv = MatArray[3*5 + 4]; - double vv = MatArray[4*5 + 4]; - - M.ResizeTo(2,2); - MatArray = M.GetMatrixArray(); - MatArray[0] = uu; MatArray[1] = uv; - MatArray[2] = uv; MatArray[3] = vv; -} - - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/HMatrixUnit.cc b/genfit/measurements/src/HMatrixUnit.cc deleted file mode 100644 index e41af2052a..0000000000 --- a/genfit/measurements/src/HMatrixUnit.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2013, Technische Universitaet Muenchen, Ludwig-Maximilians-Universität München - Authors: Johannes Rauch, Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "HMatrixUnit.h" -#include -#include - - -namespace genfit { - - -// 1, 0, 0, 0, 0, -// 0, 1, 0, 0, 0, -// 0, 0, 1, 0, 0, -// 0, 0, 0, 1, 0, -// 0, 0, 0, 0, 1 - -const TMatrixD& HMatrixUnit::getMatrix() const { - static const double HMatrixContent[5*5] = {1, 0, 0, 0, 0, - 0, 1, 0, 0, 0, - 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0, - 0, 0, 0, 0, 1}; - - static const TMatrixD HMatrix(5,5, HMatrixContent); - - return HMatrix; -} - - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/HMatrixV.cc b/genfit/measurements/src/HMatrixV.cc deleted file mode 100644 index 2e0c919474..0000000000 --- a/genfit/measurements/src/HMatrixV.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright 2013, Technische Universitaet Muenchen, Ludwig-Maximilians-Universität München - Authors: Johannes Rauch, Tobias Schlüter - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "HMatrixV.h" -#include -#include - - -namespace genfit { - - -// 0, 0, 0, 0, 1 - -const TMatrixD& HMatrixV::getMatrix() const { - static const double HMatrixContent[5] = {0, 0, 0, 0, 1}; - - static const TMatrixD HMatrix(1,5, HMatrixContent); - - return HMatrix; -} - - -TVectorD HMatrixV::Hv(const TVectorD& v) const { - assert (v.GetNrows() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * 1); - - retValArray[0] = v(4); // u - - return TVectorD(1, retValArray); -} - - -TMatrixD HMatrixV::MHt(const TMatrixDSym& M) const { - assert (M.GetNcols() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * 5); - const double* MatArray = M.GetMatrixArray(); - - for (unsigned int i=0; i<5; ++i) { - retValArray[i] = MatArray[i*5 + 4]; - } - - return TMatrixD(5,1, retValArray); -} - - -TMatrixD HMatrixV::MHt(const TMatrixD& M) const { - assert (M.GetNcols() == 5); - - double* retValArray =(double *)alloca(sizeof(double) * M.GetNrows()); - const double* MatArray = M.GetMatrixArray(); - - for (int i = 0; i < M.GetNrows(); ++i) { - retValArray[i] = MatArray[i*5 + 4]; - } - - return TMatrixD(M.GetNrows(),1, retValArray); -} - - -void HMatrixV::HMHt(TMatrixDSym& M) const { - assert (M.GetNrows() == 5); - - M(0,0) = M(4,4); - - M.ResizeTo(1,1); -} - - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/PlanarMeasurement.cc b/genfit/measurements/src/PlanarMeasurement.cc deleted file mode 100644 index 8f24619c39..0000000000 --- a/genfit/measurements/src/PlanarMeasurement.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "PlanarMeasurement.h" - -#include -#include -#include -#include -#include - -#include -#include - - -namespace genfit { - -PlanarMeasurement::PlanarMeasurement(int nDim) - : AbsMeasurement(nDim), physicalPlane_(), planeId_(-1), stripV_(false) -{ - assert(nDim >= 1); -} - -PlanarMeasurement::PlanarMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint) - : AbsMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint), physicalPlane_(), planeId_(-1), stripV_(false) -{ - assert(rawHitCoords_.GetNrows() >= 1); -} - - -SharedPlanePtr PlanarMeasurement::constructPlane(const StateOnPlane&) const { - if (!physicalPlane_) { - Exception exc("PlanarMeasurement::constructPlane(): No plane has been set!", __LINE__,__FILE__); - throw exc; - } - return physicalPlane_; -} - - -std::vector PlanarMeasurement::constructMeasurementsOnPlane(const StateOnPlane& state) const { - - MeasurementOnPlane* mop = new MeasurementOnPlane(rawHitCoords_, - rawHitCov_, - state.getPlane(), state.getRep(), constructHMatrix(state.getRep())); - - std::vector retVal; - retVal.push_back(mop); - return retVal; -} - - -const AbsHMatrix* PlanarMeasurement::constructHMatrix(const AbsTrackRep* rep) const { - - if (dynamic_cast(rep) == NULL) { - Exception exc("SpacepointMeasurement default implementation can only handle state vectors of type RKTrackRep!", __LINE__,__FILE__); - throw exc; - } - - switch(rawHitCoords_.GetNrows()) { - case 1: - if (stripV_) - return new HMatrixV(); - return new HMatrixU(); - - case 2: - return new HMatrixUV(); - - default: - Exception exc("PlanarMeasurement default implementation can only handle 1D (strip) or 2D (pixel) measurements!", __LINE__,__FILE__); - throw exc; - } - -} - -void PlanarMeasurement::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::PlanarMeasurement. - - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::PlanarMeasurement thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - //This works around a msvc bug and should be harmless on other platforms - typedef genfit::AbsMeasurement baseClass0; - baseClass0::Streamer(R__b); - char flag; - R__b >> flag; - physicalPlane_.reset(); - if (flag) { - physicalPlane_.reset(new DetPlane()); - physicalPlane_->Streamer(R__b); - } - R__b >> planeId_; - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - } else { - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - //This works around a msvc bug and should be harmless on other platforms - typedef genfit::AbsMeasurement baseClass0; - baseClass0::Streamer(R__b); - if (physicalPlane_) { - R__b << (char)1; - physicalPlane_->Streamer(R__b); - } else { - R__b << (char)0; - } - R__b << planeId_; - R__b.SetByteCount(R__c, kTRUE); - } -} - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/ProlateSpacepointMeasurement.cc b/genfit/measurements/src/ProlateSpacepointMeasurement.cc deleted file mode 100644 index a6d23131fb..0000000000 --- a/genfit/measurements/src/ProlateSpacepointMeasurement.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "ProlateSpacepointMeasurement.h" - -#include - -#include "Exception.h" -#include "RKTrackRep.h" - - -namespace genfit { - -ProlateSpacepointMeasurement::ProlateSpacepointMeasurement(int nDim) - : SpacepointMeasurement(nDim), largestErrorDirection_(0,0,1) -{ - ; -} - -ProlateSpacepointMeasurement::ProlateSpacepointMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint) - : SpacepointMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint), largestErrorDirection_(0,0,1) -{ - ; -} - - -SharedPlanePtr ProlateSpacepointMeasurement::constructPlane(const StateOnPlane& state) const { - - // copy state. Neglect covariance. - StateOnPlane st(state); - - - const TVector3 wire1(rawHitCoords_(0), rawHitCoords_(1), rawHitCoords_(2)); - - const AbsTrackRep* rep = state.getRep(); - rep->extrapolateToLine(st, wire1, largestErrorDirection_); - - TVector3 dirInPoca = rep->getMom(st); - dirInPoca.SetMag(1.); - - // check if direction is parallel to wire - if (fabs(largestErrorDirection_.Angle(dirInPoca)) < 0.01){ - Exception exc("ProlateSpacepointMeasurement::constructPlane(): Cannot construct detector plane, track direction is parallel to largest error direction", __LINE__,__FILE__); - throw exc; - } - - // construct orthogonal vector - TVector3 U = largestErrorDirection_.Cross(dirInPoca); - - return SharedPlanePtr(new DetPlane(wire1, U, largestErrorDirection_)); -} - - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/SpacepointMeasurement.cc b/genfit/measurements/src/SpacepointMeasurement.cc deleted file mode 100644 index ea507f8e1a..0000000000 --- a/genfit/measurements/src/SpacepointMeasurement.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "SpacepointMeasurement.h" - -#include -#include -#include -#include - -#include -#include - - -namespace genfit { - -SpacepointMeasurement::SpacepointMeasurement(int nDim) - : AbsMeasurement(nDim), weightedPlaneContruction_(true), G_(3), cutCov_(true) -{ - assert(nDim >= 3); - - //this->initG(); -} - -SpacepointMeasurement::SpacepointMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint, - bool weightedPlaneContruction, bool cutCov) - : AbsMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint), - weightedPlaneContruction_(weightedPlaneContruction), cutCov_(cutCov) -{ - assert(rawHitCoords_.GetNrows() >= 3); - - if (weightedPlaneContruction_) - this->initG(); -} - - -SharedPlanePtr SpacepointMeasurement::constructPlane(const StateOnPlane& state) const { - - // copy state. Neglect covariance. - StateOnPlane st(state); - - const TVector3 point(rawHitCoords_(0), rawHitCoords_(1), rawHitCoords_(2)); - - if (weightedPlaneContruction_) - st.extrapolateToPoint(point, G_); - else - st.extrapolateToPoint(point); - - return st.getPlane(); -} - - -std::vector SpacepointMeasurement::constructMeasurementsOnPlane(const StateOnPlane& state) const -{ - MeasurementOnPlane* mop = new MeasurementOnPlane(TVectorD(2), - TMatrixDSym(3), // will be resized to 2x2 by Similarity later - state.getPlane(), state.getRep(), constructHMatrix(state.getRep())); - - TVectorD& m = mop->getState(); - TMatrixDSym& V = mop->getCov(); - - const TVector3& o(state.getPlane()->getO()); - const TVector3& u(state.getPlane()->getU()); - const TVector3& v(state.getPlane()->getV()); - - // m - m(0) = (rawHitCoords_(0)-o.X()) * u.X() + - (rawHitCoords_(1)-o.Y()) * u.Y() + - (rawHitCoords_(2)-o.Z()) * u.Z(); - - m(1) = (rawHitCoords_(0)-o.X()) * v.X() + - (rawHitCoords_(1)-o.Y()) * v.Y() + - (rawHitCoords_(2)-o.Z()) * v.Z(); - - // - // V - // - V = rawHitCov_; - - // jac = dF_i/dx_j = s_unitvec * t_untivec, with s=u,v and t=x,y,z - TMatrixD jac(3,2); - jac(0,0) = u.X(); - jac(1,0) = u.Y(); - jac(2,0) = u.Z(); - jac(0,1) = v.X(); - jac(1,1) = v.Y(); - jac(2,1) = v.Z(); - - if (cutCov_) { // cut (default) - tools::invertMatrix(V); - V.SimilarityT(jac); - tools::invertMatrix(V); - } - else { // projection - V.SimilarityT(jac); - } - - std::vector retVal; - retVal.push_back(mop); - return retVal; -} - - -const AbsHMatrix* SpacepointMeasurement::constructHMatrix(const AbsTrackRep* rep) const { - if (dynamic_cast(rep) == NULL) { - Exception exc("SpacepointMeasurement default implementation can only handle state vectors of type RKTrackRep!", __LINE__,__FILE__); - throw exc; - } - - return new HMatrixUV(); -} - - -void SpacepointMeasurement::initG() { - rawHitCov_.GetSub(0, 2, G_); - tools::invertMatrix(G_); -} - - -// Modified from auto-generated Streamer to account for non-persistent G_ -void SpacepointMeasurement::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::SpacepointMeasurement. - - if (R__b.IsReading()) { - R__b.ReadClassBuffer(genfit::SpacepointMeasurement::Class(),this); - - if (weightedPlaneContruction_) - this->initG(); - } else { - R__b.WriteClassBuffer(genfit::SpacepointMeasurement::Class(),this); - } -} - - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/WireMeasurement.cc b/genfit/measurements/src/WireMeasurement.cc deleted file mode 100644 index 3a567f6350..0000000000 --- a/genfit/measurements/src/WireMeasurement.cc +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** @addtogroup genfit - * @{ - */ - -#include "WireMeasurement.h" - -#include -#include - -#include -#include -#include - -#include - - -namespace genfit { - - -WireMeasurement::WireMeasurement(int nDim) - : AbsMeasurement(nDim), maxDistance_(2), leftRight_(0) -{ - assert(nDim >= 7); -} - -WireMeasurement::WireMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint) - : AbsMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint), maxDistance_(2), leftRight_(0) -{ - assert(rawHitCoords_.GetNrows() >= 7); -} - -SharedPlanePtr WireMeasurement::constructPlane(const StateOnPlane& state) const { - - // copy state. Neglect covariance. - StateOnPlane st(state); - - TVector3 wire1(rawHitCoords_(0), rawHitCoords_(1), rawHitCoords_(2)); - TVector3 wire2(rawHitCoords_(3), rawHitCoords_(4), rawHitCoords_(5)); - - //std::cout << " wire1(" << rawHitCoords_(0) << ", " << rawHitCoords_(1) << ", " << rawHitCoords_(2) << ")" << std::endl; - //std::cout << " wire2(" << rawHitCoords_(3) << ", " << rawHitCoords_(4) << ", " << rawHitCoords_(5) << ")" << std::endl; - - // unit vector along the wire (V) - TVector3 wireDirection = wire2 - wire1; - wireDirection.SetMag(1.); - - //std::cout << " wireDirection(" << wireDirection.X() << ", " << wireDirection.Y() << ", " << wireDirection.Z() << ")" << std::endl; - - // point of closest approach - const AbsTrackRep* rep = state.getRep(); - rep->extrapolateToLine(st, wire1, wireDirection); - const TVector3& poca = rep->getPos(st); - TVector3 dirInPoca = rep->getMom(st); - dirInPoca.SetMag(1.); - const TVector3& pocaOnWire = wire1 + wireDirection.Dot(poca - wire1)*wireDirection; - - // check if direction is parallel to wire - if (fabs(wireDirection.Angle(dirInPoca)) < 0.01){ - Exception exc("WireMeasurement::detPlane(): Cannot construct detector plane, direction is parallel to wire", __LINE__,__FILE__); - throw exc; - } - - // construct orthogonal vector - TVector3 U = dirInPoca.Cross(wireDirection); - // U.SetMag(1.); automatically assured - - return SharedPlanePtr(new DetPlane(pocaOnWire, U, wireDirection)); -} - - -std::vector WireMeasurement::constructMeasurementsOnPlane(const StateOnPlane& state) const -{ - double mR = rawHitCoords_(6); - double mL = -mR; - double V = rawHitCov_(6,6); - - MeasurementOnPlane* mopL = new MeasurementOnPlane(TVectorD(1, &mL), - TMatrixDSym(1, &V), - state.getPlane(), state.getRep(), constructHMatrix(state.getRep())); - - MeasurementOnPlane* mopR = new MeasurementOnPlane(TVectorD(1, &mR), - TMatrixDSym(1, &V), - state.getPlane(), state.getRep(), constructHMatrix(state.getRep())); - - // set left/right weights - if (leftRight_ < 0) { - mopL->setWeight(1); - mopR->setWeight(0); - } - else if (leftRight_ > 0) { - mopL->setWeight(0); - mopR->setWeight(1); - } - else { - double val = 0.5 * pow(std::max(0., 1 - mR/maxDistance_), 2.); - mopL->setWeight(val); - mopR->setWeight(val); - } - - std::vector retVal; - retVal.push_back(mopL); - retVal.push_back(mopR); - return retVal; -} - -const AbsHMatrix* WireMeasurement::constructHMatrix(const AbsTrackRep* rep) const { - if (dynamic_cast(rep) == NULL) { - Exception exc("WireMeasurement default implementation can only handle state vectors of type RKTrackRep!", __LINE__,__FILE__); - throw exc; - } - - return new HMatrixU(); -} - -void WireMeasurement::setLeftRightResolution(int lr){ - if (lr==0) leftRight_ = 0; - else if (lr<0) leftRight_ = -1; - else leftRight_ = 1; -} - - -} /* End of namespace genfit */ -/** @} */ diff --git a/genfit/measurements/src/WirePointMeasurement.cc b/genfit/measurements/src/WirePointMeasurement.cc deleted file mode 100644 index 12969744b1..0000000000 --- a/genfit/measurements/src/WirePointMeasurement.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "WirePointMeasurement.h" - -#include -#include -#include - -#include -#include - - -namespace genfit { - -WirePointMeasurement::WirePointMeasurement(int nDim) - : WireMeasurement(nDim) -{ - assert(nDim >= 8); -} - -WirePointMeasurement::WirePointMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint) - : WireMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint) -{ - assert(rawHitCoords_.GetNrows() >= 8); -} - - -SharedPlanePtr WirePointMeasurement::constructPlane(const StateOnPlane& state) const { - - // copy state. Neglect covariance. - StateOnPlane st(state); - - TVector3 wire1(rawHitCoords_(0), rawHitCoords_(1), rawHitCoords_(2)); - TVector3 wire2(rawHitCoords_(3), rawHitCoords_(4), rawHitCoords_(5)); - - //std::cout << " wire1(" << rawHitCoords_(0) << ", " << rawHitCoords_(1) << ", " << rawHitCoords_(2) << ")" << std::endl; - //std::cout << " wire2(" << rawHitCoords_(3) << ", " << rawHitCoords_(4) << ", " << rawHitCoords_(5) << ")" << std::endl; - - // unit vector along the wire (V) - TVector3 wireDirection = wire2 - wire1; - wireDirection.SetMag(1.); - - //std::cout << " wireDirection(" << wireDirection.X() << ", " << wireDirection.Y() << ", " << wireDirection.Z() << ")" << std::endl; - - // point of closest approach - const AbsTrackRep* rep = state.getRep(); - rep->extrapolateToLine(st, wire1, wireDirection); - //const TVector3& poca = rep->getPos(st); - TVector3 dirInPoca = rep->getMom(st); - dirInPoca.SetMag(1.); - //const TVector3& pocaOnWire = wire1 + wireDirection.Dot(poca - wire1)*wireDirection; - - // check if direction is parallel to wire - if (fabs(wireDirection.Angle(dirInPoca)) < 0.01){ - Exception exc("WireMeasurement::detPlane(): Cannot construct detector plane, direction is parallel to wire", __LINE__,__FILE__); - throw exc; - } - - // construct orthogonal vector - TVector3 U = dirInPoca.Cross(wireDirection); - // U.SetMag(1.); automatically assured - - return SharedPlanePtr(new DetPlane(wire1, U, wireDirection)); -} - - -std::vector WirePointMeasurement::constructMeasurementsOnPlane(const StateOnPlane& state) const -{ - MeasurementOnPlane* mopR = new MeasurementOnPlane(TVectorD(2), - TMatrixDSym(2), - state.getPlane(), state.getRep(), constructHMatrix(state.getRep())); - - mopR->getState()(0) = rawHitCoords_(6); - mopR->getState()(1) = rawHitCoords_(7); - - mopR->getCov()(0,0) = rawHitCov_(6,6); - mopR->getCov()(1,0) = rawHitCov_(7,6); - mopR->getCov()(0,1) = rawHitCov_(6,7); - mopR->getCov()(1,1) = rawHitCov_(7,7); - - - MeasurementOnPlane* mopL = new MeasurementOnPlane(*mopR); - mopL->getState()(0) *= -1; - - // set left/right weights - if (leftRight_ < 0) { - mopL->setWeight(1); - mopR->setWeight(0); - } - else if (leftRight_ > 0) { - mopL->setWeight(0); - mopR->setWeight(1); - } - else { - double val = 0.5 * pow(std::max(0., 1 - rawHitCoords_(6)/maxDistance_), 2.); - mopL->setWeight(val); - mopR->setWeight(val); - } - - std::vector retVal; - retVal.push_back(mopL); - retVal.push_back(mopR); - return retVal; -} - -const AbsHMatrix* WirePointMeasurement::constructHMatrix(const AbsTrackRep* rep) const { - if (dynamic_cast(rep) == NULL) { - Exception exc("WirePointMeasurement default implementation can only handle state vectors of type RKTrackRep!", __LINE__,__FILE__); - throw exc; - } - - return new HMatrixUV(); -} - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/WireTrackCandHit.cc b/genfit/measurements/src/WireTrackCandHit.cc deleted file mode 100644 index 8e68db4aa0..0000000000 --- a/genfit/measurements/src/WireTrackCandHit.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . - */ - -#include "WireTrackCandHit.h" - -#include - -namespace genfit { - -WireTrackCandHit::WireTrackCandHit(int detId, - int hitId, - int planeId, - double sortingParameter, - char leftRight) - : TrackCandHit(detId, hitId, planeId, sortingParameter), - leftRight_(leftRight) -{ - ; -} - - -void WireTrackCandHit::Print(Option_t*) const { - std::cout << " WireTrackCandHit. DetId = " << detId_ - << " \t HitId = " << hitId_ - << " \t PlaneId = " << planeId_ - << " \t SortingParameter = " << sortingParameter_ - << " \t leftRight = " << (int)leftRight_ << "\n"; -} - -} /* End of namespace genfit */ diff --git a/genfit/measurements/src/measurementsLinkDef.h b/genfit/measurements/src/measurementsLinkDef.h deleted file mode 100644 index 9bbe376547..0000000000 --- a/genfit/measurements/src/measurementsLinkDef.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class genfit::HMatrixU+; -#pragma link C++ class genfit::HMatrixUnit+; -#pragma link C++ class genfit::HMatrixV+; -#pragma link C++ class genfit::HMatrixUV+; -#pragma link C++ class genfit::ProlateSpacepointMeasurement+; -#pragma link C++ class genfit::WireMeasurement+; -#pragma link C++ class genfit::WirePointMeasurement+; - -#pragma link C++ class genfit::HMatrixPhi-; -#pragma link C++ class genfit::FullMeasurement-; -#pragma link C++ class genfit::PlanarMeasurement-; -#pragma link C++ class genfit::SpacepointMeasurement-; - -#pragma link C++ class genfit::WireTrackCandHit+; - -#endif diff --git a/genfit/test/README b/genfit/test/README deleted file mode 100644 index 756e115b4e..0000000000 --- a/genfit/test/README +++ /dev/null @@ -1,9 +0,0 @@ -to build the examples, first build genfit. -with 'make tests', you can build the examples. -The binaries will be in *youBuildDir*/bin/ - -Most of the examples need a geometry. -It can be built via -'root makeGeom.C' - -The output ('genfitGeom.root') has to be put into the *youBuildDir*/bin/ directory. diff --git a/genfit/test/fitterTests/main.cc b/genfit/test/fitterTests/main.cc deleted file mode 100644 index 9fb48c2704..0000000000 --- a/genfit/test/fitterTests/main.cc +++ /dev/null @@ -1,827 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "TDatabasePDG.h" -#include -#include - -#include - - -void handler(int sig) { - void *array[10]; - size_t size; - - // get void*'s for all entries on the stack - size = backtrace(array, 10); - - // print out all the frames to stderr - fprintf(stderr, "Error: signal %d:\n", sig); - backtrace_symbols_fd(array, size, 2); - exit(1); -} - -int randomPdg() { - int pdg; - - switch(int(gRandom->Uniform(8))) { - case 1: - pdg = -11; break; - case 2: - pdg = 11; break; - case 3: - pdg = 13; break; - case 4: - pdg = -13; break; - case 5: - pdg = 211; break; - case 6: - pdg = -211; break; - case 7: - pdg = 2212; break; - default: - pdg = 211; - } - - return pdg; -} - - -int randomSign() { - if (gRandom->Uniform(1) > 0.5) - return 1; - return -1; -} - -//--------------------------------------------------------------------------------------------------------- -//--------------------------------------------------------------------------------------------------------- -//--------------------------------------------------------------------------------------------------------- -//--------------------------------------------------------------------------------------------------------- -//--------------------------------------------------------------------------------------------------------- - -//#define VALGRIND - -#ifdef VALGRIND - #include -#else -#define CALLGRIND_START_INSTRUMENTATION -#define CALLGRIND_STOP_INSTRUMENTATION -#define CALLGRIND_DUMP_STATS -#endif - -int main() { - std::cout<<"main"<SetSeed(14); - - - const unsigned int nEvents = 100; - const unsigned int nMeasurements = 56; - const double BField = 15.; // kGauss - const double momentum = 0.4; // GeV - const double theta = 120; // degree - const double thetaDetPlane = 90; // degree - const double phiDetPlane = 0; // degree - const double pointDist = 5; // cm; approx. distance between measurements - const double resolution = 0.02; // cm; resolution of generated measurements - - const double resolutionWire = 5*resolution; // cm; resolution of generated measurements - const TVector3 wireDir(0,0,1); - const double skewAngle(5); - const bool useSkew = true; - const int nSuperLayer = 10; - const double minDrift = 0.; - const double maxDrift = 2; - const bool idealLRResolution = false; // resolve the l/r ambiguities of the wire measurements - - const double outlierProb = -0.1; - const double outlierRange = 2; - - const double hitSwitchProb = -0.1; // probability to give hits to fit in wrong order (flip two hits) - - const int splitTrack = -5; // for track merging testing. - const bool fullMeasurement = false; // put fit result of first tracklet as FullMeasurement into second tracklet, don't merge - - const genfit::eFitterType fitterId = genfit::SimpleKalman; - //const genfit::eFitterType fitterId = genfit::RefKalman; - //const genfit::eFitterType fitterId = genfit::DafRef; - //const genfit::eFitterType fitterId = genfit::DafSimple; - //const genfit::eMultipleMeasurementHandling mmHandling = genfit::weightedAverage; - //const genfit::eMultipleMeasurementHandling mmHandling = genfit::unweightedClosestToReference; - //const genfit::eMultipleMeasurementHandling mmHandling = genfit::unweightedClosestToPrediction; - //const genfit::eMultipleMeasurementHandling mmHandling = genfit::weightedClosestToReference; - //const genfit::eMultipleMeasurementHandling mmHandling = genfit::weightedClosestToPrediction; - //const genfit::eMultipleMeasurementHandling mmHandling = genfit::unweightedClosestToReferenceWire; - const genfit::eMultipleMeasurementHandling mmHandling = genfit::unweightedClosestToPredictionWire; - //const genfit::eMultipleMeasurementHandling mmHandling = genfit::weightedClosestToReferenceWire; - //const genfit::eMultipleMeasurementHandling mmHandling = genfit::weightedClosestToPredictionWire; - const int nIter = 20; // max number of iterations - const double dPVal = 1.E-3; // convergence criterion - - const bool resort = true; - const bool prefit = false; // make a simple Kalman iteration before the actual fit - const bool refit = false; // if fit did not converge, try to fit again - - const bool twoReps = false; // test if everything works with more than one rep in the tracks - - const int pdg = 13; // particle pdg code - - const bool smearPosMom = true; // init the Reps with smeared pos and mom - const double chargeSwitchProb = -0.1; // probability to seed with wrong charge sign - const double posSmear = 10*resolution; // cm - const double momSmear = 5. /180.*TMath::Pi(); // rad - const double momMagSmear = 0.2; // relative - const double zSmearFac = 2; - - - const bool matFX = false; // include material effects; can only be disabled for RKTrackRep! - - const bool debug = false; - const bool onlyDisplayFailed = true; // only load non-converged tracks into the display - - std::vector measurementTypes; - measurementTypes.push_back(genfit::Pixel); - measurementTypes.push_back(genfit::Pixel); - measurementTypes.push_back(genfit::StripUV); - measurementTypes.push_back(genfit::StripUV); - measurementTypes.push_back(genfit::StripUV); - measurementTypes.push_back(genfit::StripUV); - for (unsigned int i = 0; i<50; ++i) - measurementTypes.push_back(genfit::Wire); - - - signal(SIGSEGV, handler); // install our handler - - // init fitter - genfit::AbsKalmanFitter* fitter = 0; - switch (fitterId) { - case genfit::SimpleKalman: - fitter = new genfit::KalmanFitter(nIter, dPVal); - fitter->setMultipleMeasurementHandling(mmHandling); - break; - - case genfit::RefKalman: - fitter = new genfit::KalmanFitterRefTrack(nIter, dPVal); - fitter->setMultipleMeasurementHandling(mmHandling); - break; - - case genfit::DafSimple: - fitter = new genfit::DAF(false); - break; - case genfit::DafRef: - fitter = new genfit::DAF(); - break; - } - fitter->setMaxIterations(nIter); - if (debug) - fitter->setDebugLvl(10); - - /*if (dynamic_cast(fitter) != NULL) { - //static_cast(fitter)->setBetas(100, 50, 25, 12, 6, 3, 1, 0.5, 0.1); - //static_cast(fitter)->setBetas(81, 8, 4, 0.5, 0.1); - static_cast(fitter)->setAnnealingScheme(100, 0.1, 5); - //static_cast(fitter)->setConvergenceDeltaWeight(0.0001); - //fitter->setMaxIterations(nIter); - }*/ - - - // init MeasurementCreator - genfit::MeasurementCreator measurementCreator; - measurementCreator.setResolution(resolution); - measurementCreator.setResolutionWire(resolutionWire); - measurementCreator.setOutlierProb(outlierProb); - measurementCreator.setOutlierRange(outlierRange); - measurementCreator.setThetaDetPlane(thetaDetPlane); - measurementCreator.setPhiDetPlane(phiDetPlane); - measurementCreator.setWireDir(wireDir); - measurementCreator.setMinDrift(minDrift); - measurementCreator.setMaxDrift(maxDrift); - measurementCreator.setIdealLRResolution(idealLRResolution); - measurementCreator.setUseSkew(useSkew); - measurementCreator.setSkewAngle(skewAngle); - measurementCreator.setNSuperLayer(nSuperLayer); - measurementCreator.setDebug(debug); - - - // init geometry and mag. field - new TGeoManager("Geometry", "Geane geometry"); - TGeoManager::Import("genfitGeom.root"); - genfit::FieldManager::getInstance()->init(new genfit::ConstField(0.,0.,BField)); - genfit::FieldManager::getInstance()->useCache(true, 8); - genfit::MaterialEffects::getInstance()->init(new genfit::TGeoMaterialInterface()); - - const double charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge()/(3.); - - // init event display -#ifndef VALGRIND - genfit::EventDisplay* display = genfit::EventDisplay::getInstance(); - display->reset(); -#endif - - -#ifndef VALGRIND - // create histograms - gROOT->SetStyle("Plain"); - gStyle->SetPalette(1); - gStyle->SetOptFit(1111); - - TH1D *hmomRes = new TH1D("hmomRes","mom res",500,-10*resolution*momentum/nMeasurements,10*resolution*momentum/nMeasurements); - TH1D *hupRes = new TH1D("hupRes","u' res",500,-5*resolution/nMeasurements, 5*resolution/nMeasurements); - TH1D *hvpRes = new TH1D("hvpRes","v' res",500,-5*resolution/nMeasurements, 5*resolution/nMeasurements); - TH1D *huRes = new TH1D("huRes","u res",500,-5*resolution, 5*resolution); - TH1D *hvRes = new TH1D("hvRes","v res",500,-5*resolution, 5*resolution); - - TH1D *hqopPu = new TH1D("hqopPu","q/p pull",200,-6.,6.); - TH1D *pVal = new TH1D("pVal","p-value",100,0.,1.00000001); - pVal->SetMinimum(0); - TH1D *hupPu = new TH1D("hupPu","u' pull",200,-6.,6.); - TH1D *hvpPu = new TH1D("hvpPu","v' pull",200,-6.,6.); - TH1D *huPu = new TH1D("huPu","u pull",200,-6.,6.); - TH1D *hvPu = new TH1D("hvPu","v pull",200,-6.,6.); - - TH1D *weights = new TH1D("weights","Daf vs true weights",500,-1.01,1.01); - - TH1D *trackLenRes = new TH1D("trackLenRes","(trueLen - FittedLen) / trueLen",500,-0.01,0.01); -#endif - - double maxWeight(0); - unsigned int nTotalIterConverged(0); - unsigned int nTotalIterNotConverged(0); - unsigned int nTotalIterSecondConverged(0); - unsigned int nTotalIterSecondNotConverged(0); - unsigned int nConvergedFits(0); - unsigned int nUNConvergedFits(0); - unsigned int nConvergedFitsSecond(0); - unsigned int nUNConvergedFitsSecond(0); - - - CALLGRIND_START_INSTRUMENTATION; - - genfit::Track* fitTrack(NULL); - genfit::Track* secondTrack(NULL); - - // main loop - for (unsigned int iEvent=0; iEventUniform(8)));*/ - - - if (debug || (iEvent)%10==0) - std::cout << "Event Nr. " << iEvent << " "; - else std::cout << ". "; - if (debug || (iEvent+1)%10==0) - std::cout << "\n"; - - - // clean up - delete fitTrack; - fitTrack = NULL; - delete secondTrack; - secondTrack = NULL; - - - // true start values - TVector3 pos(0, 0, 0); - TVector3 mom(1.,0,0); - mom.SetPhi(gRandom->Uniform(0.,2*TMath::Pi())); - //mom.SetTheta(gRandom->Uniform(0.4*TMath::Pi(),0.6*TMath::Pi())); - mom.SetTheta(theta*TMath::Pi()/180); - mom.SetMag(momentum); - TMatrixDSym covM(6); - for (int i = 0; i < 3; ++i) - covM(i,i) = resolution*resolution; - for (int i = 3; i < 6; ++i) - covM(i,i) = pow(resolution / nMeasurements / sqrt(3), 2); - - if (debug) { - std::cout << "start values \n"; - pos.Print(); - mom.Print(); - } - - // calc helix parameters - genfit::HelixTrackModel* helix = new genfit::HelixTrackModel(pos, mom, charge); - measurementCreator.setTrackModel(helix); - - // smeared start values - TVector3 posM(pos); - TVector3 momM(mom); - if (smearPosMom) { - posM.SetX(gRandom->Gaus(posM.X(),posSmear)); - posM.SetY(gRandom->Gaus(posM.Y(),posSmear)); - posM.SetZ(gRandom->Gaus(posM.Z(),zSmearFac*posSmear)); - - momM.SetPhi(gRandom->Gaus(mom.Phi(),momSmear)); - momM.SetTheta(gRandom->Gaus(mom.Theta(),momSmear)); - momM.SetMag(gRandom->Gaus(mom.Mag(), momMagSmear*mom.Mag())); - } - - - // trackrep for creating measurements - double sign(1.); - if (chargeSwitchProb > gRandom->Uniform(1.)) - sign = -1.; - genfit::AbsTrackRep* rep = new genfit::RKTrackRep(sign*pdg); - sign = 1.; - if (chargeSwitchProb > gRandom->Uniform(1.)) - sign = -1.; - genfit::AbsTrackRep* secondRep = new genfit::RKTrackRep(sign*-211); - genfit::MeasuredStateOnPlane stateRef(rep); - rep->setPosMomCov(stateRef, pos, mom, covM); - - // smeared start state - genfit::MeasuredStateOnPlane stateSmeared(rep); - rep->setPosMomCov(stateSmeared, posM, momM, covM); - - //rep->setPropDir(1); - - if (!matFX) genfit::MaterialEffects::getInstance()->setNoEffects(); - - // remember original initial state - const genfit::StateOnPlane stateRefOrig(stateRef); - - // create smeared measurements - std::vector< std::vector > measurements; - - std::vector outlierTrue; - bool outlier; - // true values for left right. 0 for non wire measurements - std::vector leftRightTrue; - int lr; - - double trueLen; - - try{ - for (unsigned int i=0; iget6DStateCov(stateSmeared, seedState, seedCov); - fitTrack = new genfit::Track(rep, seedState, seedCov); //initialized with smeared rep - secondTrack = new genfit::Track(rep->clone(), seedState, seedCov); //initialized with smeared rep - if (twoReps) { - fitTrack->addTrackRep(secondRep); - secondTrack->addTrackRep(secondRep->clone()); - } - else - delete secondRep; - //if (debug) fitTrack->Print("C"); - - assert(fitTrack->checkConsistency()); - //fitTrack->addTrackRep(rep->clone()); // check if everything works fine with more than one rep - - // add measurements - for(unsigned int i=0; i 0 && (int)i >= splitTrack) - break; - if (i>0 && hitSwitchProb > gRandom->Uniform(1.)) - fitTrack->insertPoint(new genfit::TrackPoint(measurements[i], fitTrack), -2); - else - fitTrack->insertPoint(new genfit::TrackPoint(measurements[i], fitTrack)); - - assert(fitTrack->checkConsistency()); - //if (debug) fitTrack->Print("C"); - } - - if (splitTrack > 0) { - for(unsigned int i=splitTrack; i0 && hitSwitchProb > gRandom->Uniform(1.)) - secondTrack->insertPoint(new genfit::TrackPoint(measurements[i], secondTrack), -2); - else - secondTrack->insertPoint(new genfit::TrackPoint(measurements[i], secondTrack)); - - //if (debug) fitTrack->Print("C"); - } - } - - assert(fitTrack->checkConsistency()); - assert(secondTrack->checkConsistency()); - - //if (debug) fitTrack->Print(); - - // do the fit - try{ - if (debug) std::cout<<"Starting the fitter"<getCardinalRep()); - } - - fitter->processTrack(fitTrack, resort); - if (splitTrack > 0) - fitter->processTrack(secondTrack, resort); - - if (debug) std::cout<<"fitter is finished!"< 0) { - if (debug) fitTrack->Print("C"); - if (debug) secondTrack->Print("C"); - - if (fullMeasurement) { - genfit::FullMeasurement* fullM = new genfit::FullMeasurement(secondTrack->getFittedState()); - fitTrack->insertPoint(new genfit::TrackPoint(fullM, fitTrack)); - } - else - fitTrack->mergeTrack(secondTrack); - - if (debug) fitTrack->Print("C"); - - try{ - if (debug) std::cout<<"Starting the fitter"<processTrack(fitTrack, resort); - if (debug) std::cout<<"fitter is finished!"<getFitStatus(rep)->isFitConverged()) { - std::cout<<"Trying to fit again "<processTrack(fitTrack, resort); - } - - - - if (debug) { - fitTrack->Print("C"); - fitTrack->getFitStatus(rep)->Print(); - } - - assert(fitTrack->checkConsistency()); - assert(secondTrack->checkConsistency()); - -#ifndef VALGRIND - if (!onlyDisplayFailed && iEvent < 1000) - display->addEvent(fitTrack); - else if (onlyDisplayFailed && - (!fitTrack->getFitStatus(rep)->isFitConverged() || - fitTrack->getFitStatus(rep)->getPVal() < 0.01)) { - // add track to event display - display->addEvent(fitTrack); - } -#endif - - - if (fitTrack->getFitStatus(rep)->isFitConverged()) { - nTotalIterConverged += static_cast(fitTrack->getFitStatus(rep))->getNumIterations(); - nConvergedFits += 1; - } - else { - nTotalIterNotConverged += static_cast(fitTrack->getFitStatus(rep))->getNumIterations(); - nUNConvergedFits += 1; - } - - if (twoReps) { - if (fitTrack->getFitStatus(secondRep)->isFitConverged()) { - nTotalIterSecondConverged += static_cast(fitTrack->getFitStatus(secondRep))->getNumIterations(); - nConvergedFitsSecond += 1; - } - else { - nTotalIterSecondNotConverged += static_cast(fitTrack->getFitStatus(secondRep))->getNumIterations(); - nUNConvergedFitsSecond += 1; - } - } - - - // check if fit was successful - if (! fitTrack->getFitStatus(rep)->isFitConverged()) { - std::cout << "Track could not be fitted successfully! Fit is not converged! \n"; - continue; - } - - - genfit::TrackPoint* tp = fitTrack->getPointWithMeasurementAndFitterInfo(0, rep); - if (tp == NULL) { - std::cout << "Track has no TrackPoint with fitterInfo! \n"; - continue; - } - genfit::KalmanFittedStateOnPlane kfsop(*(static_cast(tp->getFitterInfo(rep))->getBackwardUpdate())); - if (debug) { - std::cout << "state before extrapolating back to reference plane \n"; - kfsop.Print(); - } - - // extrapolate back to reference plane. - try{ - rep->extrapolateToPlane(kfsop, stateRefOrig.getPlane());; - } - catch(genfit::Exception& e){ - std::cerr<<"Exception, next track"<getPVal(fitTrack, rep); - assert( fabs(pval - static_cast(fitTrack->getFitStatus(rep))->getBackwardPVal()) < 1E-10 ); - - hmomRes->Fill( (charge/state[0]-momentum)); - hupRes->Fill( (state[1]-referenceState[1])); - hvpRes->Fill( (state[2]-referenceState[2])); - huRes->Fill( (state[3]-referenceState[3])); - hvRes->Fill( (state[4]-referenceState[4])); - - hqopPu->Fill( (state[0]-referenceState[0]) / sqrt(cov[0][0]) ); - pVal->Fill( pval); - hupPu->Fill( (state[1]-referenceState[1]) / sqrt(cov[1][1]) ); - hvpPu->Fill( (state[2]-referenceState[2]) / sqrt(cov[2][2]) ); - huPu->Fill( (state[3]-referenceState[3]) / sqrt(cov[3][3]) ); - hvPu->Fill( (state[4]-referenceState[4]) / sqrt(cov[4][4]) ); - - - try { - trackLenRes->Fill( (trueLen - fitTrack->getTrackLen(rep)) / trueLen ); - - if (debug) { - std::cout << "true track length = " << trueLen << "; fitted length = " << fitTrack->getTrackLen(rep) << "\n"; - std::cout << "fitted tof = " << fitTrack->getTOF(rep) << " ns\n"; - } - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - std::cout << "could not get TrackLen or TOF! \n"; - } - - - // check l/r resolution and outlier rejection - if (dynamic_cast(fitter) != NULL) { - for (unsigned int i=0; igetNumPointsWithMeasurement(); ++i){ - - if (! fitTrack->getPointWithMeasurement(i)->hasFitterInfo(rep)) - continue; - - if (debug) { - std::vector dafWeights = dynamic_cast(fitTrack->getPointWithMeasurement(i)->getFitterInfo(rep))->getWeights(); - std::cout << "hit " << i; - if (outlierTrue[i]) std::cout << " is an OUTLIER"; - std::cout << " weights: "; - for (unsigned int j=0; j dafWeightLR = dynamic_cast(fitTrack->getPointWithMeasurement(i)->getFitterInfo(rep))->getWeights(); - if(dafWeightLR.size() != 2) - continue; - - double weightCorrectSide, weightWrongSide; - - if (trueSide < 0) { - weightCorrectSide = dafWeightLR[0]; - weightWrongSide = dafWeightLR[1]; - } - else { - weightCorrectSide = dafWeightLR[1]; - weightWrongSide = dafWeightLR[0]; - } - weightWrongSide -= 1.; - - weights->Fill(weightCorrectSide); - weights->Fill(weightWrongSide); - - if (weightCorrectSide>maxWeight) maxWeight = weightCorrectSide; - } - - for (unsigned int i=0; igetNumPointsWithMeasurement(); ++i){ - if (! fitTrack->getPointWithMeasurement(i)->hasFitterInfo(rep)) - continue; - - std::vector dafWeights = dynamic_cast(fitTrack->getPointWithMeasurement(i)->getFitterInfo(rep))->getWeights(); - - if (outlierTrue[i]) { // an outlier - for (unsigned int j=0; jFill(dafWeights[j]-1); - } - } - else if (leftRightTrue[i] == 0) { // only for non wire hits - for (unsigned int j=0; jFill(dafWeights[j]); - } - } - } - - } - - - fitTrack->prune(); - if (debug) { - std::cout<<" pruned track: "; - fitTrack->Print(); - } - -#endif - - - }// end loop over events - - delete fitTrack; - delete secondTrack; - delete fitter; - - CALLGRIND_STOP_INSTRUMENTATION; - CALLGRIND_DUMP_STATS; - - std::cout<<"maxWeight = " << maxWeight << std::endl; - std::cout<<"avg nr iterations = " << (double)(nTotalIterConverged + nTotalIterNotConverged)/(double)(nConvergedFits + nUNConvergedFits) << std::endl; - std::cout<<"avg nr iterations of converged fits = " << (double)(nTotalIterConverged)/(double)(nConvergedFits) << std::endl; - std::cout<<"avg nr iterations of UNconverged fits = " << (double)(nTotalIterNotConverged)/(double)(nUNConvergedFits) << std::endl; - std::cout<<"fit efficiency = " << (double)nConvergedFits/nEvents << std::endl; - - if (twoReps) { - std::cout<<"second rep: \navg nr iterations = " << (double)(nTotalIterSecondConverged + nTotalIterSecondNotConverged)/(double)(nConvergedFitsSecond + nUNConvergedFitsSecond) << std::endl; - std::cout<<"avg nr iterations of converged fits = " << (double)(nTotalIterSecondConverged)/(double)(nConvergedFitsSecond) << std::endl; - std::cout<<"avg nr iterations of UNconverged fits = " << (double)(nTotalIterSecondNotConverged)/(double)(nUNConvergedFitsSecond) << std::endl; - std::cout<<"fit efficiency = " << (double)nConvergedFitsSecond/nEvents << std::endl; - } - - - //std::cout<<"avg nr iterations (2nd rep) = " << (double)nTotalIterSecond/nSuccessfullFitsSecond << std::endl; - //std::cout<<"fit efficiency (2nd rep) = " << (double)nConvergedFitsSecond/nEvents << std::endl; - - -#ifndef VALGRIND - - if (debug) std::cout<<"Draw histograms ..."; - // fit and draw histograms - TCanvas* c1 = new TCanvas(); - c1->Divide(2,3); - - c1->cd(1); - hmomRes->Fit("gaus"); - hmomRes->Draw(); - - c1->cd(2); - weights->Draw(); - - c1->cd(3); - hupRes->Fit("gaus"); - hupRes->Draw(); - - c1->cd(4); - hvpRes->Fit("gaus"); - hvpRes->Draw(); - - c1->cd(5); - huRes->Fit("gaus"); - huRes->Draw(); - - c1->cd(6); - hvRes->Fit("gaus"); - hvRes->Draw(); - - c1->Write(); - - TCanvas* c2 = new TCanvas(); - c2->Divide(2,3); - - c2->cd(1); - hqopPu->Fit("gaus"); - hqopPu->Draw(); - - c2->cd(2); - pVal->Fit("pol1"); - pVal->Draw(); - c2->cd(3); - hupPu->Fit("gaus"); - hupPu->Draw(); - - c2->cd(4); - hvpPu->Fit("gaus"); - hvpPu->Draw(); - - c2->cd(5); - huPu->Fit("gaus"); - huPu->Draw(); - - c2->cd(6); - hvPu->Fit("gaus"); - hvPu->Draw(); - - c2->Write(); - - - - TCanvas* c3 = new TCanvas(); - //c3->Divide(2,3); - - c3->cd(1); - trackLenRes->Fit("gaus"); - trackLenRes->Draw(); - - c3->Write(); - - if (debug) std::cout<<"... done"<setOptions("ABDEFHMPT"); // G show geometry - if (matFX) display->setOptions("ABDEFGHMPT"); // G show geometry - display->open(); - - -#endif - - -} diff --git a/genfit/test/makeGeom.C b/genfit/test/makeGeom.C deleted file mode 100644 index cc7deaa5b7..0000000000 --- a/genfit/test/makeGeom.C +++ /dev/null @@ -1,72 +0,0 @@ -void makeGeom() -{ - //--- Definition of a simple geometry - // gSystem->Load("libGeom"); - new TGeoManager("genfitGeom", "GENFIT geometry"); - - - unsigned int medInd(0); - Double_t mPar[10]; - //TAG sollte wieder 0 werden sens flag - mPar[0]=0.;//sensitive volume flag - mPar[1]=1.;//magnetic field flag - mPar[2]=30.;//max fiel in kGauss - mPar[3]=0.1;//maximal angular dev. due to field - mPar[4]=0.01;//max step allowed (in cm) - mPar[5]=1.e-5;//max fractional energy loss - mPar[6]=1.e-3;//boundary crossing accuracy - mPar[7]=1.e-5;//minimum step - mPar[8]=0.;//not defined - mPar[9]=0.;//not defined - - TGeoMaterial *_siliconMat = new TGeoMaterial("siliconMat",28.0855,14.,2.329); - _siliconMat->SetRadLen(1.);//calc automatically, need this for elemental mats. - TGeoMedium *_silicon = new TGeoMedium("silicon",medInd++,_siliconMat,mPar); - - TGeoMixture *_airMat = new TGeoMixture("airMat",3); - _airMat->AddElement(14.01,7.,.78); - _airMat->AddElement(16.00,8.,.21); - _airMat->AddElement(39.95,18.,.01); - _airMat->SetDensity(1.2e-3); - TGeoMedium *_air = new TGeoMedium("air",medInd++,_airMat,mPar); - - TGeoMixture *_vacuumMat = new TGeoMixture("vacuumMat",3); - _vacuumMat->AddElement(14.01,7.,.78); - _vacuumMat->AddElement(16.00,8.,.21); - _vacuumMat->AddElement(39.95,18.,.01); - _vacuumMat->SetDensity(1.2e-15); - TGeoMedium *_vacuum = new TGeoMedium("vacuum",medInd++,_vacuumMat,mPar); - - - - - TGeoMedium *vacuum = gGeoManager->GetMedium("vacuum"); - assert(vacuum!=NULL); - TGeoMedium *air = gGeoManager->GetMedium("air"); - assert(air!=NULL); - TGeoMedium *sil = gGeoManager->GetMedium("silicon"); - assert(sil!=NULL); - - TGeoVolume *top = gGeoManager->MakeBox("TOPPER", air, 1000., 1000., 1000.); - gGeoManager->SetTopVolume(top); // mandatory ! - - double thickness(0.05); - double distance = 1; - - for (unsigned int i=1; i<5; ++i){ - TGeoVolume *redBullCan = gGeoManager->MakeTube("redBullCan", sil, i*distance, i*distance+thickness, 20.);//, 90., 270.); - redBullCan->SetLineColor(kRed); - top->AddNode(redBullCan, 1, gGeoIdentity); - } - - - //--- close the geometry - gGeoManager->CloseGeometry(); - - //--- draw the ROOT box - gGeoManager->SetVisLevel(10); - //top->Draw("ogl"); - TFile *outfile = TFile::Open("genfitGeom.root","RECREATE"); - gGeoManager->Write(); - outfile->Close(); -} diff --git a/genfit/test/measurementFactoryExample/main.cc b/genfit/test/measurementFactoryExample/main.cc deleted file mode 100644 index 70bddd3c56..0000000000 --- a/genfit/test/measurementFactoryExample/main.cc +++ /dev/null @@ -1,180 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "mySpacepointDetectorHit.h" -#include "mySpacepointMeasurement.h" - -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "TDatabasePDG.h" -#include - - - - -int main() { - - gRandom->SetSeed(14); - - // init MeasurementCreator - genfit::MeasurementCreator measurementCreator; - - - // init geometry and mag. field - new TGeoManager("Geometry", "Geane geometry"); - TGeoManager::Import("genfitGeom.root"); - genfit::FieldManager::getInstance()->init(new genfit::ConstField(0.,0., 15.)); // 15 kGauss - genfit::MaterialEffects::getInstance()->init(new genfit::TGeoMaterialInterface()); - - - // init event display - genfit::EventDisplay* display = genfit::EventDisplay::getInstance(); - - - // init fitter - genfit::AbsKalmanFitter* fitter = new genfit::KalmanFitterRefTrack(); - - - TClonesArray myDetectorHitArray("genfit::mySpacepointDetectorHit"); - - // init the factory - int myDetId(1); - genfit::MeasurementFactory factory; - genfit::MeasurementProducer myProducer(&myDetectorHitArray); - factory.addProducer(myDetId, &myProducer); - - - // main loop - for (unsigned int iEvent=0; iEvent<100; ++iEvent){ - - myDetectorHitArray.Clear(); - - //TrackCand - genfit::TrackCand myCand; - - // true start values - TVector3 pos(0, 0, 0); - TVector3 mom(1.,0,0); - mom.SetPhi(gRandom->Uniform(0.,2*TMath::Pi())); - mom.SetTheta(gRandom->Uniform(0.4*TMath::Pi(),0.6*TMath::Pi())); - mom.SetMag(gRandom->Uniform(0.2, 1.)); - - - // helix track model - const int pdg = 13; // particle pdg code - const double charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge()/(3.); - genfit::HelixTrackModel* helix = new genfit::HelixTrackModel(pos, mom, charge); - measurementCreator.setTrackModel(helix); - - - unsigned int nMeasurements = gRandom->Uniform(5, 15); - - // covariance - double resolution = 0.01; - TMatrixDSym cov(3); - for (int i = 0; i < 3; ++i) - cov(i,i) = resolution*resolution; - - for (unsigned int i=0; igetPos(i*2.); - currentPos.SetX(gRandom->Gaus(currentPos.X(), resolution)); - currentPos.SetY(gRandom->Gaus(currentPos.Y(), resolution)); - currentPos.SetZ(gRandom->Gaus(currentPos.Z(), resolution)); - - // Fill the TClonesArray and the TrackCand - // In a real experiment, you detector code would deliver mySpacepointDetectorHits and fill the TClonesArray. - // The patternRecognition would create the TrackCand. - new(myDetectorHitArray[i]) genfit::mySpacepointDetectorHit(currentPos, cov); - myCand.addHit(myDetId, i); - } - - - // smeared start values (would come from the pattern recognition) - const bool smearPosMom = true; // init the Reps with smeared pos and mom - const double posSmear = 0.1; // cm - const double momSmear = 3. /180.*TMath::Pi(); // rad - const double momMagSmear = 0.1; // relative - - TVector3 posM(pos); - TVector3 momM(mom); - if (smearPosMom) { - posM.SetX(gRandom->Gaus(posM.X(),posSmear)); - posM.SetY(gRandom->Gaus(posM.Y(),posSmear)); - posM.SetZ(gRandom->Gaus(posM.Z(),posSmear)); - - momM.SetPhi(gRandom->Gaus(mom.Phi(),momSmear)); - momM.SetTheta(gRandom->Gaus(mom.Theta(),momSmear)); - momM.SetMag(gRandom->Gaus(mom.Mag(), momMagSmear*mom.Mag())); - } - - // initial guess for cov - TMatrixDSym covSeed(6); - for (int i = 0; i < 3; ++i) - covSeed(i,i) = resolution*resolution; - for (int i = 3; i < 6; ++i) - covSeed(i,i) = pow(resolution / nMeasurements / sqrt(3), 2); - - - // set start values and pdg to cand - myCand.setPosMomSeedAndPdgCode(posM, momM, pdg); - myCand.setCovSeed(covSeed); - - - // create track - genfit::Track fitTrack(myCand, factory, new genfit::RKTrackRep(pdg)); - - - // do the fit - try{ - fitter->processTrack(&fitTrack); - } - catch(genfit::Exception& e){ - std::cerr << e.what(); - std::cerr << "Exception, next track" << std::endl; - continue; - } - - //check - assert(fitTrack.checkConsistency()); - - - if (iEvent < 1000) { - // add track to event display - display->addEvent(&fitTrack); - } - - - }// end loop over events - - delete fitter; - - // open event display - display->open(); - -} - - diff --git a/genfit/test/minimalFittingExample/main.cc b/genfit/test/minimalFittingExample/main.cc deleted file mode 100644 index 7692ee8dee..0000000000 --- a/genfit/test/minimalFittingExample/main.cc +++ /dev/null @@ -1,160 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "TDatabasePDG.h" -#include - - - - -int main() { - - gRandom->SetSeed(14); - - // init MeasurementCreator - genfit::MeasurementCreator measurementCreator; - - - // init geometry and mag. field - new TGeoManager("Geometry", "Geane geometry"); - TGeoManager::Import("genfitGeom.root"); - genfit::FieldManager::getInstance()->init(new genfit::ConstField(0.,0., 15.)); // 15 kGauss - genfit::MaterialEffects::getInstance()->init(new genfit::TGeoMaterialInterface()); - - - // init event display - genfit::EventDisplay* display = genfit::EventDisplay::getInstance(); - - - // init fitter - genfit::AbsKalmanFitter* fitter = new genfit::KalmanFitterRefTrack(); - - // main loop - for (unsigned int iEvent=0; iEvent<100; ++iEvent){ - - // true start values - TVector3 pos(0, 0, 0); - TVector3 mom(1.,0,0); - mom.SetPhi(gRandom->Uniform(0.,2*TMath::Pi())); - mom.SetTheta(gRandom->Uniform(0.4*TMath::Pi(),0.6*TMath::Pi())); - mom.SetMag(gRandom->Uniform(0.2, 1.)); - - - // helix track model - const int pdg = 13; // particle pdg code - const double charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge()/(3.); - genfit::HelixTrackModel* helix = new genfit::HelixTrackModel(pos, mom, charge); - measurementCreator.setTrackModel(helix); - - - unsigned int nMeasurements = gRandom->Uniform(5, 15); - - - // smeared start values - const bool smearPosMom = true; // init the Reps with smeared pos and mom - const double posSmear = 0.1; // cm - const double momSmear = 3. /180.*TMath::Pi(); // rad - const double momMagSmear = 0.1; // relative - - TVector3 posM(pos); - TVector3 momM(mom); - if (smearPosMom) { - posM.SetX(gRandom->Gaus(posM.X(),posSmear)); - posM.SetY(gRandom->Gaus(posM.Y(),posSmear)); - posM.SetZ(gRandom->Gaus(posM.Z(),posSmear)); - - momM.SetPhi(gRandom->Gaus(mom.Phi(),momSmear)); - momM.SetTheta(gRandom->Gaus(mom.Theta(),momSmear)); - momM.SetMag(gRandom->Gaus(mom.Mag(), momMagSmear*mom.Mag())); - } - // approximate covariance - TMatrixDSym covM(6); - double resolution = 0.01; - for (int i = 0; i < 3; ++i) - covM(i,i) = resolution*resolution; - for (int i = 3; i < 6; ++i) - covM(i,i) = pow(resolution / nMeasurements / sqrt(3), 2); - - - // trackrep - genfit::AbsTrackRep* rep = new genfit::RKTrackRep(pdg); - - // smeared start state - genfit::MeasuredStateOnPlane stateSmeared(rep); - rep->setPosMomCov(stateSmeared, posM, momM, covM); - - - // create track - TVectorD seedState(6); - TMatrixDSym seedCov(6); - rep->get6DStateCov(stateSmeared, seedState, seedCov); - genfit::Track fitTrack(rep, seedState, seedCov); - - - // create random measurement types - std::vector measurementTypes; - for (unsigned int i = 0; i < nMeasurements; ++i) - measurementTypes.push_back(genfit::eMeasurementType(gRandom->Uniform(8))); - - - // create smeared measurements and add to track - try{ - for (unsigned int i=0; i measurements = measurementCreator.create(measurementTypes[i], i*5.); - fitTrack.insertPoint(new genfit::TrackPoint(measurements, &fitTrack)); - } - } - catch(genfit::Exception& e){ - std::cerr<<"Exception, next track"<processTrack(&fitTrack); - - //check - assert(fitTrack.checkConsistency()); - - - if (iEvent < 1000) { - // add track to event display - display->addEvent(&fitTrack); - } - - - - }// end loop over events - - delete fitter; - - // open event display - display->open(); - -} - - diff --git a/genfit/test/streamerTest/main.cc b/genfit/test/streamerTest/main.cc deleted file mode 100644 index 6d34c2b528..0000000000 --- a/genfit/test/streamerTest/main.cc +++ /dev/null @@ -1,263 +0,0 @@ -// -// Write fit results to tree, read again, compare. -// - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "TDatabasePDG.h" -#include -#include -#include - - -#define FILENAME "/tmp/streamerTest.root" - - -bool emptyTrackTest() -{ - TFile *f = TFile::Open(FILENAME, "RECREATE"); - f->cd(); - genfit::Track *t = new genfit::Track(); - if (!t->checkConsistency()) - return false; - t->Write("direct"); - f->Close(); - delete t; - delete f; - - f = TFile::Open(FILENAME, "READ"); - t = (genfit::Track*)f->Get("direct"); - bool result = t->checkConsistency(); - delete t; - delete f; - return result; -} - - -int main() { - if (!emptyTrackTest()) { - std::cout << "emptyTrackTest failed." << std::endl; - return 1; - } - - - // prepare output tree for Tracks - // std::unique_ptr fitTrack(new genfit::Track()); - genfit::Track* fitTrack = new genfit::Track(); - TVectorD stateFinal; - TMatrixDSym covFinal; - genfit::DetPlane planeFinal; - - TFile* fOut = new TFile(FILENAME, "RECREATE"); - fOut->cd(); - TTree* tResults = new TTree("tResults", "results from track fit"); - tResults->Branch("gfTrack", "genfit::Track", &fitTrack, 32000, -1); - tResults->Branch("stateFinal", &stateFinal); - tResults->Branch("covFinal", &covFinal, 32000, -1); - tResults->Branch("planeFinal", &planeFinal, 32000, -1); - - - - - - gRandom->SetSeed(14); - - // init MeasurementCreator - genfit::MeasurementCreator measurementCreator; - - - // init geometry and mag. field - new TGeoManager("Geometry", "Geane geometry"); - TGeoManager::Import("genfitGeom.root"); - genfit::FieldManager::getInstance()->init(new genfit::ConstField(0.,0., 15.)); // 15 kGauss - genfit::MaterialEffects::getInstance()->init(new genfit::TGeoMaterialInterface()); - - - // init fitter - genfit::AbsKalmanFitter* fitter = new genfit::KalmanFitterRefTrack(); - - // main loop - for (unsigned int iEvent=0; iEvent<100; ++iEvent){ - - // true start values - TVector3 pos(0, 0, 0); - TVector3 mom(1.,0,0); - mom.SetPhi(gRandom->Uniform(0.,2*TMath::Pi())); - mom.SetTheta(gRandom->Uniform(0.4*TMath::Pi(),0.6*TMath::Pi())); - mom.SetMag(gRandom->Uniform(0.2, 1.)); - - - // helix track model - const int pdg = 13; // particle pdg code - const double charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge()/(3.); - genfit::HelixTrackModel* helix = new genfit::HelixTrackModel(pos, mom, charge); - measurementCreator.setTrackModel(helix); - - - unsigned int nMeasurements = gRandom->Uniform(5, 15); - - - // smeared start values - const bool smearPosMom = true; // init the Reps with smeared pos and mom - const double posSmear = 0.1; // cm - const double momSmear = 3. /180.*TMath::Pi(); // rad - const double momMagSmear = 0.1; // relative - - TVector3 posM(pos); - TVector3 momM(mom); - if (smearPosMom) { - posM.SetX(gRandom->Gaus(posM.X(),posSmear)); - posM.SetY(gRandom->Gaus(posM.Y(),posSmear)); - posM.SetZ(gRandom->Gaus(posM.Z(),posSmear)); - - momM.SetPhi(gRandom->Gaus(mom.Phi(),momSmear)); - momM.SetTheta(gRandom->Gaus(mom.Theta(),momSmear)); - momM.SetMag(gRandom->Gaus(mom.Mag(), momMagSmear*mom.Mag())); - } - // approximate covariance - TMatrixDSym covM(6); - double resolution = 0.01; - for (int i = 0; i < 3; ++i) - covM(i,i) = resolution*resolution; - for (int i = 3; i < 6; ++i) - covM(i,i) = pow(resolution / nMeasurements / sqrt(3), 2); - - - // trackrep - genfit::AbsTrackRep* rep = new genfit::RKTrackRep(pdg); - - // smeared start state - genfit::MeasuredStateOnPlane stateSmeared(rep); - rep->setPosMomCov(stateSmeared, posM, momM, covM); - - - // create track - TVectorD seedState(6); - TMatrixDSym seedCov(6); - rep->get6DStateCov(stateSmeared, seedState, seedCov); - fitTrack = new genfit::Track(rep, seedState, seedCov); - - - // create random measurement types - std::vector measurementTypes; - for (unsigned int i = 0; i < nMeasurements; ++i) - measurementTypes.push_back(genfit::eMeasurementType(gRandom->Uniform(8))); - - - // create smeared measurements and add to track - try{ - for (unsigned int i=0; i measurements = measurementCreator.create(measurementTypes[i], i*5.); - genfit::TrackPoint* tp = new genfit::TrackPoint(measurements, fitTrack); - // test scatterers - genfit::ThinScatterer* sc = new genfit::ThinScatterer(genfit::SharedPlanePtr(new genfit::DetPlane(TVector3(1,1,1), TVector3(1,1,1))), - genfit::MaterialProperties(1,2,3,4,5)); - tp->setScatterer(sc); - - fitTrack->insertPoint(tp); - } - } - catch(genfit::Exception& e){ - std::cerr<<"Exception, next track"<checkConsistency()); - - // do the fit - fitter->processTrack(fitTrack); - - //check - assert(fitTrack->checkConsistency()); - - - stateFinal.ResizeTo(fitTrack->getFittedState().getState()); - stateFinal = fitTrack->getFittedState().getState(); - covFinal.ResizeTo(fitTrack->getFittedState().getCov()); - covFinal = fitTrack->getFittedState().getCov(); - planeFinal = *(fitTrack->getFittedState().getPlane()); - - tResults->Fill(); - - //fitTrack->Print(); - - delete fitTrack; - fitTrack = 0; - - }// end loop over events - - delete fitter; - - - - - fOut->Write(); - delete fOut; - - fOut = TFile::Open(FILENAME, "READ"); - fOut->GetObject("tResults", tResults); - TVectorD* pState = 0; - tResults->SetBranchAddress("stateFinal", &pState); - TMatrixDSym* pMatrix = 0; - tResults->SetBranchAddress("covFinal", &pMatrix); - genfit::DetPlane* plane = 0; - tResults->SetBranchAddress("planeFinal", &plane); - tResults->SetBranchAddress("gfTrack", &fitTrack); - - for (Long_t nEntry = 0; nEntry < tResults->GetEntries(); ++nEntry) { - tResults->GetEntry(nEntry); - //fitTrack->Print(); - if (!fitTrack->checkConsistency()) { - std::cout << "stored track inconsistent" << std::endl; - return 1; - } - - if (*pState == fitTrack->getFittedState().getState() && - *pMatrix == fitTrack->getFittedState().getCov() && - *plane == *(fitTrack->getFittedState().getPlane())) { - // track ok - } - else { - std::cout << "stored track not equal" << std::endl; - pState->Print(); - fitTrack->getFittedState().getState().Print(); - pMatrix->Print(); - fitTrack->getFittedState().getCov().Print(); - plane->Print(); - fitTrack->getFittedState().getPlane()->Print(); - - return 1; - } - } - std::cout << "stored tracks are identical to fitted tracks, as far as tested." << std::endl; - delete fitTrack; - std::cout << "deleteing didn't segfault" << std::endl; - - return 0; -} diff --git a/genfit/test/unitTests/main.cc b/genfit/test/unitTests/main.cc deleted file mode 100644 index e7bf7e8179..0000000000 --- a/genfit/test/unitTests/main.cc +++ /dev/null @@ -1,999 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "TDatabasePDG.h" -#include -#include - - -void handler(int sig) { - void *array[10]; - size_t size; - - // get void*'s for all entries on the stack - size = backtrace(array, 10); - - // print out all the frames to stderr - fprintf(stderr, "Error: signal %d:\n", sig); - backtrace_symbols_fd(array, size, 2); - exit(1); -} - -int randomPdg() { - int pdg; - - switch(int(gRandom->Uniform(8))) { - case 1: - pdg = -11; break; - case 2: - pdg = 11; break; - case 3: - pdg = 13; break; - case 4: - pdg = -13; break; - case 5: - pdg = 211; break; - case 6: - pdg = -211; break; - case 7: - pdg = 2212; break; - default: - pdg = 211; - } - - return pdg; -} - - -int randomSign() { - if (gRandom->Uniform(1) > 0.5) - return 1; - return -1; -} - - -bool compareMatrices(const TMatrixTBase& A, const TMatrixTBase& B, double maxRelErr) { - bool retVal = true; - - // search max abs value - double max(0); - for (int i=0; i max) - max = fabs(A(i,j)); - } - } - - double maxAbsErr = maxRelErr*max; - - for (int i=0; i maxAbsErr ) { - double relErr = A(i,j)/B(i,j) - 1; - if ( fabs(relErr) > maxRelErr ) { - std::cout << "compareMatrices: A("<& cov) { - - if (!(cov.IsSymmetric())) { - std::cout << "isCovMatrix: not symmetric\n"; - return false; - } - - for (int i=0; iGaus(0,0.1),gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1)); - TVector3 mom(0,0.5,gRandom->Gaus(0,0.3)); - mom.SetMag(0.5); - mom *= randomSign(); - - - genfit::StateOnPlane state(rep); - rep->setPosMom(state, pos, mom); - - // check if we can set another position in the same plane - if (randomSign() == 1) { - genfit::SharedPlanePtr plane = state.getPlane(); - const TVector3& u = plane->getU(); - const TVector3& v = plane->getV(); - - // random position on plane - pos += gRandom->Gaus() * u; - pos += gRandom->Gaus() * v; - - // new random momentum - mom.SetXYZ(0,0.5,gRandom->Gaus(0,0.3)); - mom.SetMag(0.5); - mom *= randomSign(); - - rep->setPosMom(state, pos, mom); - - // check if plane has changed - if (state.getPlane() != plane) { - std::cout << "plane has changed unexpectedly! \n"; - delete rep; - return false; - } - } - - - // compare - if ((pos - rep->getPos(state)).Mag() > epsilonLen || - (mom - rep->getMom(state)).Mag() > epsilonMom) { - - state.Print(); - - std::cout << "pos difference = " << (pos - rep->getPos(state)).Mag() << "\n"; - std::cout << "mom difference = " << (mom - rep->getMom(state)).Mag() << "\n"; - - std::cout << std::endl; - - delete rep; - return false; - } - - delete rep; - return true; - -} - - -bool compareForthBackExtrapolation() { - - double epsilonLen = 5.E-5; // 0.5 mu - double epsilonMom = 1.E-4; // 100 keV - - int pdg = randomPdg(); - genfit::AbsTrackRep* rep; - rep = new genfit::RKTrackRep(pdg); - - //TVector3 pos(0,0,0); - TVector3 pos(gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1)); - TVector3 mom(0,0.5,gRandom->Gaus(0,0.3)); - mom.SetMag(0.5); - mom *= randomSign(); - - - genfit::StateOnPlane state(rep); - rep->setPosMom(state, pos, mom); - - genfit::SharedPlanePtr origPlane = state.getPlane(); - genfit::SharedPlanePtr plane(new genfit::DetPlane(TVector3(0,randomSign()*10,0), TVector3(0,randomSign()*1,0))); - - genfit::StateOnPlane origState(state); - - // forth - double extrapLen(0); - try { - extrapLen = rep->extrapolateToPlane(state, plane); - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - - delete rep; - return false; - } - - // back - double backExtrapLen(0); - try { - backExtrapLen = rep->extrapolateToPlane(state, origPlane); - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - - delete rep; - return false; - } - - // compare - if ((rep->getPos(origState) - rep->getPos(state)).Mag() > epsilonLen || - (rep->getMom(origState) - rep->getMom(state)).Mag() > epsilonMom || - fabs(extrapLen + backExtrapLen) > epsilonLen) { - - origState.Print(); - state.Print(); - - std::cout << "pos difference = " << (rep->getPos(origState) - rep->getPos(state)).Mag() << "\n"; - std::cout << "mom difference = " << (rep->getMom(origState) - rep->getMom(state)).Mag() << "\n"; - std::cout << "len difference = " << extrapLen + backExtrapLen << "\n"; - - std::cout << std::endl; - - delete rep; - return false; - } - - delete rep; - return true; - -} - - -bool compareForthBackJacNoise() { - - bool retVal(true); - - bool fx( randomSign() > 0); - genfit::MaterialEffects::getInstance()->setNoEffects(!fx); - - double deltaJac = 0.005; // relative - double deltaNoise = 0.00001; - double deltaState = 3.E-6; // absolute - - if (fx) { - deltaJac = 0.1; // relative - deltaNoise = 0.1; - deltaState = 5.E-4; // absolute - } - - int pdg = randomPdg(); - genfit::AbsTrackRep* rep; - rep = new genfit::RKTrackRep(pdg); - - //TVector3 pos(0,0,0); - //TVector3 mom(0,1,2); - TVector3 pos(gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1)); - TVector3 mom(0, 0.5, gRandom->Gaus(0, 1)); - mom *= randomSign(); - mom.SetMag(gRandom->Uniform(2)+0.3); - //mom.SetMag(3); - - TMatrixD jac_f, jac_fi, jac_b, jac_bi; - TMatrixDSym noise_f, noise_fi, noise_b, noise_bi; - TVectorD c_f, c_fi, c_b, c_bi; - TVectorD state_man, stateOrig_man; - - // original state and plane - genfit::MeasuredStateOnPlane state(rep); - rep->setPosMom(state, pos, mom); - - static const double smear = 0.2; - TVector3 normal(mom); - normal.SetMag(1); - normal.SetXYZ(gRandom->Gaus(normal.X(), smear), - gRandom->Gaus(normal.Y(), smear), - gRandom->Gaus(normal.Z(), smear)); - genfit::DetPlane* origPlanePtr = new genfit::DetPlane (pos, normal); - //genfit::DetPlane* origPlanePtr = new genfit::DetPlane (pos, TVector3(1,0,0), TVector3(0,0,1)); - double rotAngleOrig = gRandom->Uniform(2.*TMath::Pi()); - origPlanePtr->rotate(rotAngleOrig); - genfit::SharedPlanePtr origPlane(origPlanePtr); - //genfit::SharedPlanePtr origPlane = state.getPlane(); - rep->extrapolateToPlane(state, origPlane); - - const genfit::StateOnPlane origState(state); - - - // dest plane - normal = mom; - normal.SetMag(1); - normal.SetXYZ(gRandom->Gaus(normal.X(), smear), - gRandom->Gaus(normal.Y(), smear), - gRandom->Gaus(normal.Z(), smear)); - TVector3 dest(mom); - dest.SetMag(10); - genfit::DetPlane* planePtr = new genfit::DetPlane (dest, normal); - //genfit::DetPlane* planePtr = new genfit::DetPlane (dest, TVector3(1,0,0), TVector3(0,0,1)); - double rotAngle = gRandom->Uniform(2.*TMath::Pi()); - planePtr->rotate(rotAngle); - genfit::SharedPlanePtr plane(planePtr); - - /* genfit::DetPlane* planePtr = new genfit::DetPlane (*origPlane); - planePtr->setO(TVector3(0,randomSign()*10,0)); - //planePtr->rotate(rotAngle); - genfit::SharedPlanePtr plane(planePtr); -*/ - - // numerical calculation - TMatrixD jac_f_num; - rep->calcJacobianNumerically(origState, plane, jac_f_num); - - - // forth - genfit::StateOnPlane extrapolatedState; - try { - //std::cout << "DO FORTH EXTRAPOLATION \n"; - rep->extrapolateToPlane(state, plane); - //std::cout << "GET INFO FOR FORTH EXTRAPOLATION \n"; - extrapolatedState = state; - rep->getForwardJacobianAndNoise(jac_f, noise_f, c_f); - rep->getBackwardJacobianAndNoise(jac_fi, noise_fi, c_fi); - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - - delete rep; - genfit::MaterialEffects::getInstance()->setNoEffects(false); - return false; - } - - // back - try { - //std::cout << "DO BACK EXTRAPOLATION \n"; - rep->extrapolateToPlane(state, origPlane); - //std::cout << "GET INFO FOR BACK EXTRAPOLATION \n"; - rep->getForwardJacobianAndNoise(jac_b, noise_b, c_b); - rep->getBackwardJacobianAndNoise(jac_bi, noise_bi, c_bi); - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - - delete rep; - genfit::MaterialEffects::getInstance()->setNoEffects(false); - return false; - } - - - // compare - if (!((origState.getState() - state.getState()).Abs() < deltaState) ) { - std::cout << "(origState.getState() - state.getState()) "; - (origState.getState() - state.getState()).Print(); - - retVal = false; - } - - // check c - if (!((jac_f * origState.getState() + c_f - extrapolatedState.getState()).Abs() < deltaState) || - !((jac_bi * origState.getState() + c_bi - extrapolatedState.getState()).Abs() < deltaState) || - !((jac_b * extrapolatedState.getState() + c_b - origState.getState()).Abs() < deltaState) || - !((jac_fi * extrapolatedState.getState() + c_fi - origState.getState()).Abs() < deltaState) ) { - - std::cout << "(jac_f * origState.getState() + c_f - extrapolatedState.getState()) "; - (jac_f * origState.getState() + c_f - extrapolatedState.getState()).Print(); - std::cout << "(jac_bi * origState.getState() + c_bi - extrapolatedState.getState()) "; - (jac_bi * origState.getState() + c_bi - extrapolatedState.getState()).Print(); - std::cout << "(jac_b * extrapolatedState.getState() + c_b - origState.getState()) "; - (jac_b * extrapolatedState.getState() + c_b - origState.getState()).Print(); - std::cout << "(jac_fi * extrapolatedState.getState() + c_fi - origState.getState()) "; - (jac_fi * extrapolatedState.getState() + c_fi - origState.getState()).Print(); - - retVal = false; - } - - if (!isCovMatrix(state.getCov())) { - retVal = false; - } - - - // compare - if (!compareMatrices(jac_f, jac_bi, deltaJac)) { - std::cout << "jac_f = "; jac_f.Print(); - std::cout << "jac_bi = "; jac_bi.Print(); - std::cout << std::endl; - - retVal = false; - } - - // compare - if (!compareMatrices(jac_b, jac_fi, deltaJac)) { - std::cout << "jac_b = "; jac_b.Print(); - std::cout << "jac_fi = "; jac_fi.Print(); - std::cout << std::endl; - - retVal = false; - } - - // compare - if (!compareMatrices(noise_f, noise_bi, deltaNoise)) { - std::cout << "noise_f = "; noise_f.Print(); - std::cout << "noise_bi = "; noise_bi.Print(); - std::cout << std::endl; - - retVal = false; - } - - // compare - if (!compareMatrices(noise_b, noise_fi, deltaNoise)) { - std::cout << "noise_b = "; noise_b.Print(); - std::cout << "noise_fi = "; noise_fi.Print(); - std::cout << std::endl; - - retVal = false; - } - - - if (!fx) { - // compare - if (!compareMatrices(jac_f, jac_f_num, deltaJac)) { - std::cout << "jac_f = "; jac_f.Print(); - std::cout << "jac_f_num = "; jac_f_num.Print(); - std::cout << std::endl; - - retVal = false; - } - } - - delete rep; - genfit::MaterialEffects::getInstance()->setNoEffects(false); - - return retVal; -} - - -bool checkStopAtBoundary() { - - double epsilonLen = 1.E-4; // 1 mu - //double epsilonMom = 1.E-5; // 10 keV - - double matRadius(1.); - - int pdg = randomPdg(); - genfit::AbsTrackRep* rep; - rep = new genfit::RKTrackRep(pdg); - - //TVector3 pos(0,0,0); - TVector3 pos(gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1)); - TVector3 mom(0,0.5,gRandom->Gaus(0,0.1)); - mom *= randomSign(); - - - genfit::StateOnPlane state(rep); - rep->setPosMom(state, pos, mom); - - genfit::SharedPlanePtr origPlane = state.getPlane(); - genfit::SharedPlanePtr plane(new genfit::DetPlane(TVector3(0,randomSign()*10,0), TVector3(0,randomSign()*1,0))); - - genfit::StateOnPlane origState(state); - - // forth - try { - rep->extrapolateToPlane(state, plane, true); - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - - delete rep; - return false; - } - - - // compare - if (fabs(rep->getPos(state).Perp() - matRadius) > epsilonLen) { - - origState.Print(); - state.Print(); - - std::cerr << "radius difference = " << rep->getPos(state).Perp() - matRadius << "\n"; - - std::cerr << std::endl; - - delete rep; - return false; - } - - delete rep; - return true; - -} - - -bool checkErrorPropagation() { - - //double epsilonLen = 1.E-4; // 1 mu - //double epsilonMom = 1.E-5; // 10 keV - - int pdg = randomPdg(); - genfit::AbsTrackRep* rep; - rep = new genfit::RKTrackRep(pdg); - - //TVector3 pos(0,0,0); - TVector3 pos(gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1)); - TVector3 mom(0,0.5,gRandom->Gaus(0,0.1)); - mom *= randomSign(); - - - genfit::MeasuredStateOnPlane state(rep); - rep->setPosMom(state, pos, mom); - - genfit::SharedPlanePtr origPlane = state.getPlane(); - genfit::SharedPlanePtr plane(new genfit::DetPlane(TVector3(0,randomSign()*50,0), TVector3(0,randomSign()*1,0))); - - genfit::MeasuredStateOnPlane origState(state); - - // forth - try { - rep->extrapolateToPlane(state, plane); - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - - delete rep; - return false; - } - - - // check - if (!isCovMatrix(state.getCov())) { - - origState.Print(); - state.Print(); - - delete rep; - return false; - } - - delete rep; - return true; - -} - - -bool checkExtrapolateToLine() { - - double epsilonLen = 1.E-4; // 1 mu - double epsilonMom = 1.E-5; // 10 keV - - int pdg = randomPdg(); - genfit::AbsTrackRep* rep; - rep = new genfit::RKTrackRep(pdg); - - //TVector3 pos(0,0,0); - TVector3 pos(0+gRandom->Gaus(0,0.1),0+gRandom->Gaus(0,0.1),0+gRandom->Gaus(0,0.1)); - TVector3 mom(0,0.5,0.); - mom *= randomSign(); - - - genfit::StateOnPlane state(rep); - rep->setPosMom(state, pos, mom); - - genfit::SharedPlanePtr origPlane = state.getPlane(); - genfit::StateOnPlane origState(state); - - TVector3 linePoint(gRandom->Gaus(),randomSign()*10+gRandom->Gaus(),gRandom->Gaus()); - TVector3 lineDirection(gRandom->Gaus(),gRandom->Gaus(),randomSign()*10+gRandom->Gaus()); - - // forth - try { - rep->extrapolateToLine(state, linePoint, lineDirection, false); - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - - delete rep; - return false; - } - - - // compare - if (fabs(state.getPlane()->distance(linePoint)) > epsilonLen || - fabs(state.getPlane()->distance(linePoint+lineDirection)) > epsilonLen || - (rep->getMom(state).Unit() * state.getPlane()->getNormal()) > epsilonMom) { - - origState.Print(); - state.Print(); - - std::cout << "distance of linePoint to plane = " << state.getPlane()->distance(linePoint) << "\n"; - std::cout << "distance of linePoint+lineDirection to plane = " << state.getPlane()->distance(linePoint+lineDirection) << "\n"; - std::cout << "direction * plane normal = " << rep->getMom(state).Unit() * state.getPlane()->getNormal() << "\n"; - - delete rep; - return false; - } - - delete rep; - return true; - -} - - -bool checkExtrapolateToPoint() { - - double epsilonLen = 1.E-4; // 1 mu - double epsilonMom = 1.E-5; // 10 keV - - int pdg = randomPdg(); - genfit::AbsTrackRep* rep; - rep = new genfit::RKTrackRep(pdg); - - //TVector3 pos(0,0,0); - TVector3 pos(gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1)); - TVector3 mom(0,0.5,gRandom->Gaus(0,0.1)); - mom *= randomSign(); - - - genfit::StateOnPlane state(rep); - rep->setPosMom(state, pos, mom); - - genfit::SharedPlanePtr origPlane = state.getPlane(); - genfit::StateOnPlane origState(state); - - TVector3 point(gRandom->Gaus(),randomSign()*10+gRandom->Gaus(),gRandom->Gaus()); - - // forth - try { - rep->extrapolateToPoint(state, point, false); - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - - delete rep; - return false; - } - - - // compare - if (fabs(state.getPlane()->distance(point)) > epsilonLen || - fabs((rep->getMom(state).Unit() * state.getPlane()->getNormal())) - 1 > epsilonMom) { - - origState.Print(); - state.Print(); - - std::cout << "distance of point to plane = " << state.getPlane()->distance(point) << "\n"; - std::cout << "direction * plane normal = " << rep->getMom(state).Unit() * state.getPlane()->getNormal() << "\n"; - - delete rep; - return false; - } - - delete rep; - return true; - -} - - -bool checkExtrapolateToCylinder() { - - double epsilonLen = 1.E-4; // 1 mu - //double epsilonMom = 1.E-5; // 10 keV - - int pdg = randomPdg(); - genfit::AbsTrackRep* rep; - rep = new genfit::RKTrackRep(pdg); - - //TVector3 pos(0,0,0); - TVector3 pos(0+gRandom->Gaus(0,0.1),0+gRandom->Gaus(0,0.1),0+gRandom->Gaus(0,0.1)); - TVector3 mom(0,0.5,0.); - mom *= randomSign(); - - - genfit::StateOnPlane state(rep); - rep->setPosMom(state, pos, mom); - - genfit::SharedPlanePtr origPlane = state.getPlane(); - genfit::StateOnPlane origState(state); - - const TVector3 linePoint(gRandom->Gaus(0,5), gRandom->Gaus(0,5), gRandom->Gaus(0,5)); - const TVector3 lineDirection(gRandom->Gaus(),gRandom->Gaus(),2+gRandom->Gaus()); - const double radius = gRandom->Uniform(10); - - // forth - try { - rep->extrapolateToCylinder(state, radius, linePoint, lineDirection, false); - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - - delete rep; - - static const char* bla = "cannot solve"; - const char* what = e.what(); - if (strstr(what, bla)) - return true; - return false; - } - - TVector3 pocaOnLine(lineDirection); - double t = 1./(pocaOnLine.Mag2()) * ((rep->getPos(state)*pocaOnLine) - (linePoint*pocaOnLine)); - pocaOnLine *= t; - pocaOnLine += linePoint; - - TVector3 radiusVec = rep->getPos(state) - pocaOnLine; - - // compare - if (fabs(state.getPlane()->getNormal()*radiusVec.Unit())-1 > epsilonLen || - fabs(lineDirection*radiusVec) > epsilonLen || - fabs(radiusVec.Mag()-radius) > epsilonLen) { - - origState.Print(); - state.Print(); - - std::cout << "lineDirection*radiusVec = " << lineDirection*radiusVec << "\n"; - std::cout << "radiusVec.Mag()-radius = " << radiusVec.Mag()-radius << "\n"; - - delete rep; - return false; - } - - delete rep; - return true; - -} - - -bool checkExtrapolateToSphere() { - - double epsilonLen = 1.E-4; // 1 mu - //double epsilonMom = 1.E-5; // 10 keV - - int pdg = randomPdg(); - genfit::AbsTrackRep* rep; - rep = new genfit::RKTrackRep(pdg); - - //TVector3 pos(0,0,0); - TVector3 pos(0+gRandom->Gaus(0,0.1),0+gRandom->Gaus(0,0.1),0+gRandom->Gaus(0,0.1)); - TVector3 mom(0,0.5,0.); - mom *= randomSign(); - - - genfit::StateOnPlane state(rep); - rep->setPosMom(state, pos, mom); - - genfit::SharedPlanePtr origPlane = state.getPlane(); - genfit::StateOnPlane origState(state); - - const TVector3 centerPoint(gRandom->Gaus(0,10), gRandom->Gaus(0,10), gRandom->Gaus(0,10)); - const double radius = gRandom->Uniform(10); - - // forth - try { - rep->extrapolateToSphere(state, radius, centerPoint, false); - } - catch (genfit::Exception& e) { - std::cerr << e.what(); - - delete rep; - - static const char* bla = "cannot solve"; - const char* what = e.what(); - if (strstr(what, bla)) - return true; - return false; - } - - - TVector3 radiusVec = rep->getPos(state) - centerPoint; - - // compare - if (fabs(state.getPlane()->getNormal()*radiusVec.Unit())-1 > epsilonLen || - fabs(radiusVec.Mag()-radius) > epsilonLen) { - - origState.Print(); - state.Print(); - - std::cout << "state.getPlane()->getNormal()*radiusVec = " << state.getPlane()->getNormal()*radiusVec << "\n"; - std::cout << "radiusVec.Mag()-radius = " << radiusVec.Mag()-radius << "\n"; - - delete rep; - return false; - } - - delete rep; - return true; - -} - - -bool checkExtrapolateBy() { - - double epsilonLen = 1.E-3; // 10 mu - - int pdg = randomPdg(); - genfit::AbsTrackRep* rep; - rep = new genfit::RKTrackRep(pdg); - - //TVector3 pos(0,0,0); - TVector3 pos(0+gRandom->Gaus(0,0.1),0+gRandom->Gaus(0,0.1),0+gRandom->Gaus(0,0.1)); - TVector3 mom(0,0.5,0.); - mom *= randomSign(); - - - genfit::StateOnPlane state(rep); - rep->setPosMom(state, pos, mom); - - TVector3 posOrig(state.getPos()); - - genfit::SharedPlanePtr origPlane = state.getPlane(); - genfit::StateOnPlane origState(state); - - double step = gRandom->Uniform(-15.,15.); - double extrapolatedLen(0); - - // forth - try { - extrapolatedLen = rep->extrapolateBy(state, step, false); - } - catch (genfit::Exception& e) { - return false; - } - - TVector3 posExt(state.getPos()); - - - - - // compare - if (fabs(extrapolatedLen-step) > epsilonLen || - (posOrig - posExt).Mag() > fabs(step)) { - - origState.Print(); - state.Print(); - - std::cout << "extrapolatedLen-step = " << extrapolatedLen-step << "\n"; - std::cout << "started extrapolation from: "; posOrig.Print(); - std::cout << "extrapolated to "; posExt.Print(); - std::cout << "difference = " << (posOrig - posExt).Mag() << "; step = " << step << "\n"; - - delete rep; - return false; - } - - delete rep; - return true; - -} -//===================================================================================================================== -//===================================================================================================================== -//===================================================================================================================== -//===================================================================================================================== - - -int main() { - - const double BField = 15.; // kGauss - //const bool debug = true; - - gRandom->SetSeed(10); - signal(SIGSEGV, handler); // install our handler - - // init geometry and mag. field - new TGeoManager("Geometry", "Geane geometry"); - TGeoManager::Import("genfitGeom.root"); - genfit::FieldManager::getInstance()->init(new genfit::ConstField(0.,0.,BField)); - genfit::MaterialEffects::getInstance()->init(new genfit::TGeoMaterialInterface()); - - TDatabasePDG::Instance()->GetParticle(211); - - - unsigned int nFailed(0); - const unsigned int nTests(100); - - for (unsigned int i=0; i -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - - - - -int main() { - - gRandom->SetSeed(14); - - // init MeasurementCreator - genfit::MeasurementCreator measurementCreator; - - - // init geometry and mag. field - new TGeoManager("Geometry", "Geane geometry"); - TGeoManager::Import("genfitGeom.root"); - genfit::FieldManager::getInstance()->init(new genfit::ConstField(0.,0., 15.)); // 15 kGauss - genfit::MaterialEffects::getInstance()->init(new genfit::TGeoMaterialInterface()); - - - // init event display - genfit::EventDisplay* display = genfit::EventDisplay::getInstance(); - - - // init fitter - genfit::AbsKalmanFitter* fitter = new genfit::KalmanFitterRefTrack(); - - // init vertex factory - genfit::GFRaveVertexFactory vertexFactory(2); - vertexFactory.setMethod("kalman-smoothing:1"); - - - // init root file - // tracks and vertices are written to two different branches - TFile* trackFile = new TFile("tracks.root", "RECREATE"); - trackFile->cd(); - TTree* tree = new TTree("tree", "fitted tracks"); - TClonesArray trackArray("genfit::Track"); - tree->Branch("trackBranch", &trackArray, 32000, -1); - - TClonesArray vertexArray("genfit::GFRaveVertex"); - tree->Branch("vertexBranch", &vertexArray, 32000, -1); - - std::vector tracks; - std::vector vertices; - - // main loop - for (unsigned int iEvent=0; iEvent<10; ++iEvent){ - - // clean up - trackArray.Delete(); - vertexArray.Delete(); - tracks.clear(); - vertices.clear(); - - - unsigned int nTracks = gRandom->Uniform(2, 10); - - for (unsigned int iTrack=0; iTrackUniform(0.,2*TMath::Pi())); - mom.SetTheta(gRandom->Uniform(0.4*TMath::Pi(),0.6*TMath::Pi())); - mom.SetMag(gRandom->Uniform(0.2, 1.)); - - - // helix track model - const int pdg = 13; // particle pdg code - const double charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge()/(3.); - genfit::HelixTrackModel* helix = new genfit::HelixTrackModel(pos, mom, charge); - measurementCreator.setTrackModel(helix); - - - unsigned int nMeasurements = gRandom->Uniform(5, 15); - - - // smeared start values - const bool smearPosMom = true; // init the Reps with smeared pos and mom - const double posSmear = 0.1; // cm - const double momSmear = 3. /180.*TMath::Pi(); // rad - const double momMagSmear = 0.1; // relative - - TVector3 posM(pos); - TVector3 momM(mom); - if (smearPosMom) { - posM.SetX(gRandom->Gaus(posM.X(),posSmear)); - posM.SetY(gRandom->Gaus(posM.Y(),posSmear)); - posM.SetZ(gRandom->Gaus(posM.Z(),posSmear)); - - momM.SetPhi(gRandom->Gaus(mom.Phi(),momSmear)); - momM.SetTheta(gRandom->Gaus(mom.Theta(),momSmear)); - momM.SetMag(gRandom->Gaus(mom.Mag(), momMagSmear*mom.Mag())); - } - // approximate covariance - TMatrixDSym covM(6); - double resolution = 0.01; - for (int i = 0; i < 3; ++i) - covM(i,i) = resolution*resolution; - for (int i = 3; i < 6; ++i) - covM(i,i) = pow(resolution / nMeasurements / sqrt(3), 2); - - - // trackrep - genfit::AbsTrackRep* rep = new genfit::RKTrackRep(pdg); - - // smeared start state - genfit::MeasuredStateOnPlane stateSmeared(rep); - rep->setPosMomCov(stateSmeared, posM, momM, covM); - - - // create track - TVectorD seedState(6); - TMatrixDSym seedCov(6); - rep->get6DStateCov(stateSmeared, seedState, seedCov); - - new(trackArray[iTrack]) genfit::Track(rep, seedState, seedCov); - genfit::Track* trackPtr(static_cast(trackArray.At(iTrack))); - tracks.push_back(trackPtr); - - // create random measurement types - std::vector measurementTypes; - for (unsigned int i = 0; i < nMeasurements; ++i) - measurementTypes.push_back(genfit::eMeasurementType(gRandom->Uniform(8))); - - - // create smeared measurements and add to track - try{ - for (unsigned int i=1; i measurements = measurementCreator.create(measurementTypes[i], i*5.); - trackPtr->insertPoint(new genfit::TrackPoint(measurements, trackPtr)); - } - } - catch(genfit::Exception& e){ - std::cerr<<"Exception, next track"<checkConsistency()); - - // do the fit - try{ - fitter->processTrack(trackPtr); - } - catch(genfit::Exception& e){ - std::cerr << e.what(); - std::cerr << "Exception, next track" << std::endl; - continue; - } - - //check - assert(trackPtr->checkConsistency()); - - } // end loop over tracks - - - - // vertexing - vertexFactory.findVertices(&vertices, tracks); - - for (unsigned int i=0; i(vertices[i]); - for (unsigned int j=0; jgetNTracks(); ++j) { - std::cout << "track parameters uniqueID: " << vtx->getParameters(j)->GetUniqueID() << "\n"; - } - } - - - for (unsigned int i=0; i(tracks[i]); - std::cout << "track uniqueID: " << trk->GetUniqueID() << "\n"; - } - - - // fill - std::cout << "trackArray nr of entries: " << trackArray.GetEntries() << "\n"; - tree->Fill(); - - - if (iEvent < 1000) { - // add tracks to event display - display->addEvent(tracks); - } - - } // end loop over events - - delete fitter; - - // write and close files - trackFile->Write(); - trackFile->Close(); - /*vertexFile->Write(); - vertexFile->Close();*/ - - // open event display - //display->open(); - -} - - diff --git a/genfit/test/vertexingTest/read.cc b/genfit/test/vertexingTest/read.cc deleted file mode 100644 index 6a2174d380..0000000000 --- a/genfit/test/vertexingTest/read.cc +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - - -int main() { - - genfit::Track tr; // pull in genfit libraries - - //genfit::Track* aTrackPtr(NULL); - genfit::GFRaveVertex* aVertexPtr(NULL); - - TFile* trackFile = TFile::Open("tracks.root", "READ"); - if (!trackFile) { - std::cerr << "Couldn't open 'tracks.root'." << std::endl; - return -1; - } - TTree* tree = (TTree*)trackFile->Get("tree"); - if (!tree) { - std::cerr << "Couldn't find tree 'tree' in file 'tracks.root'." << std::endl; - return -1; - } - TClonesArray* trackArray = new TClonesArray("genfit::Track"); - tree->SetBranchAddress("trackBranch", &trackArray); - - tree->Print(); - - TClonesArray* vertexArray = new TClonesArray("genfit::GFRaveVertex"); - tree->SetBranchAddress("vertexBranch", &vertexArray); - - - for (Long_t i = 0; i < tree->GetEntries(); ++i) { - tree->GetEntry(i); - - std::cout << "trackArray nr of entries: " << trackArray->GetEntries() << "\n"; - - for (Long_t j = 0; j < trackArray->GetEntriesFast(); ++j) { - std::cout << "track uniqueID: " << static_cast(trackArray->At(j))->GetUniqueID() << - " (" << static_cast(trackArray->At(j))->GetUniqueID() - 16777216 << ")\n"; - } - - for (Long_t j = 0; j < vertexArray->GetEntriesFast(); ++j) { - - aVertexPtr = (genfit::GFRaveVertex*)(vertexArray->At(j)); - //aVertexPtr->Print(); - - for (unsigned int k=0; kgetNTracks(); ++k) { - std::cout << "track parameters uniqueID: " << aVertexPtr->getParameters(k)->GetUniqueID() << "\n"; - } - - // when the track branch from the tracks.root file is loaded, the TRefs to the tracks - // in the GFRaveTrackParameters are again pointing to them. - for (unsigned int k = 0; kgetNTracks(); ++k) { - if (aVertexPtr->getParameters(k)->hasTrack()) { - std::cout << "track parameters have track \n"; - } - else { - std::cout << "track parameters have NO track <--------------------------------- \n"; - } - } - - } - - } - - -} - - diff --git a/genfit/trackReps/include/AbsMaterialInterface.h b/genfit/trackReps/include/AbsMaterialInterface.h deleted file mode 100644 index fc9b279045..0000000000 --- a/genfit/trackReps/include/AbsMaterialInterface.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright 2008-2009, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup RKTrackRep - * @{ - */ - -#ifndef genfit_AbsMaterialInterface_h -#define genfit_AbsMaterialInterface_h - -#include "RKTrackRep.h" -#include "MaterialProperties.h" - -#include -#include - - -namespace genfit { - -/** - * @brief Abstract base class for geometry interfacing - */ -class AbsMaterialInterface : public TObject { - - public: - - AbsMaterialInterface(){;}; - virtual ~AbsMaterialInterface(){;}; - - /** @brief Initialize the navigator at given position and with given direction. Return true if volume changed. - */ - virtual bool initTrack(double posX, double posY, double posZ, - double dirX, double dirY, double dirZ) = 0; - - /** @brief Get material parameters in current material - */ - virtual void getMaterialParameters(double& density, - double& Z, - double& A, - double& radiationLength, - double& mEE) = 0; - - virtual void getMaterialParameters(MaterialProperties& parameters) = 0; - - /** @brief Make a step until maxStep or the next boundary is reached. - * - * After making a step to a boundary, the position has to be beyond the boundary, - * i.e. in the current material has to be that beyond the boundary. - * The actual step made is returned. - */ - virtual double findNextBoundary(const RKTrackRep* rep, - const M1x7& state7, - double sMax, - bool varField = true) = 0; - - virtual double findNextBoundaryAndStepStraight(double sMax) = 0; - - - //ClassDef(AbsMaterialInterface, 1); - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_AbsMaterialInterface_h diff --git a/genfit/trackReps/include/MaterialEffects.h b/genfit/trackReps/include/MaterialEffects.h deleted file mode 100644 index ce531c76ac..0000000000 --- a/genfit/trackReps/include/MaterialEffects.h +++ /dev/null @@ -1,202 +0,0 @@ -/* Copyright 2008-2014, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup RKTrackRep - * @{ - */ - -#ifndef genfit_MaterialEffects_h -#define genfit_MaterialEffects_h - -#include "RKTools.h" -#include "AbsMaterialInterface.h" - -#include -#include - -#include -#include - - -namespace genfit { - -/** @brief Stepper and energy loss/noise matrix calculation - * - * @author Christian Höppner (Technische Universität München, original author) - * @author Sebastian Neubert (Technische Universität München, original author) - * @author Johannes Rauch (Technische Universität München, author) - * - * It provides functionality to limit the stepsize of an extrapolation in order not to - * exceed a specified maximum momentum loss. After propagation, the energy loss - * for the given length and (optionally) the noise matrix can be calculated. - * You have to set which energy-loss and noise mechanisms you want to use. - * At the moment, per default all energy loss and noise options are ON. - */ -class MaterialEffects { - - private: - - MaterialEffects(); - virtual ~MaterialEffects(); - - static MaterialEffects* instance_; - - -public: - - static MaterialEffects* getInstance(); - static void destruct(); - - //! set the material interface here. Material interface classes must be derived from AbsMaterialInterface. - void init(AbsMaterialInterface* matIfc); - bool isInitialized() { return materialInterface_ != nullptr; } - - void setNoEffects(bool opt = true) {noEffects_ = opt;} - - void setEnergyLossBetheBloch(bool opt = true) {energyLossBetheBloch_ = opt; noEffects_ = false;} - void setNoiseBetheBloch(bool opt = true) {noiseBetheBloch_ = opt; noEffects_ = false;} - void setNoiseCoulomb(bool opt = true) {noiseCoulomb_ = opt; noEffects_ = false;} - void setEnergyLossBrems(bool opt = true) {energyLossBrems_ = opt; noEffects_ = false;} - void setNoiseBrems(bool opt = true) {noiseBrems_ = opt; noEffects_ = false;} - void ignoreBoundariesBetweenEqualMaterials(bool opt = true) {ignoreBoundariesBetweenEqualMaterials_ = opt;} - - /** @brief Select the multiple scattering model that will be used during track fit. - * - * At the moment two model are available GEANE and Highland. GEANE is the model was was present in Genfit first. - * Note that using this function has no effect if setNoiseCoulomb(false) is set. - */ - void setMscModel(const std::string& modelName); - - - //! Calculates energy loss in the traveled path, optional calculation of noise matrix - double effects(const std::vector& steps, - int materialsFXStart, - int materialsFXStop, - const double& mom, - const int& pdg, - M7x7* noise = nullptr); - - /** @brief Returns maximum length so that a specified momentum loss will not be exceeded. - * - * The stepper returns the maximum length that the particle may travel, so that a specified relative momentum loss will not be exceeded, - * or the next material boundary is reached. The material crossed are stored together with their stepsizes. - */ - void stepper(const RKTrackRep* rep, - M1x7& state7, - const double& mom, // momentum - double& relMomLoss, // relative momloss for the step will be added - const int& pdg, - MaterialProperties& currentMaterial, - StepLimits& limits, - bool varField = true); - - - private: - - //! sets charge_, mass_ and calculates beta_, gamma_, fgammasquare; - void getParticleParameters(double mom); - - //! Returns energy loss - /** Uses Bethe Bloch formula to calculate energy loss. - * Calcuates and sets dEdx_ which needed also for noiseBetheBloch. - * Therefore it is not a const function! - * - */ - double energyLossBetheBloch(); - - //! calculation of energy loss straggeling - /** For the energy loss straggeling, different formulas are used for different regions: - * - Vavilov-Gaussian regime - * - Urban/Landau approximation - * - truncated Landau distribution - * - Urban model - * - * Needs dEdx_, which is calculated in energyLossBetheBloch, so it has to be called afterwards! - */ - void noiseBetheBloch(M7x7& noise) const; - - //! calculation of multiple scattering - /** This function first calcuates a MSC variance based on the current material and step length - * 2 different formulas for the MSC variance are implemeted. One can select the formula via "setMscModel". - * With the MSC variance and the current direction of the track a full 7D noise matrix is calculated. - * This noise matrix is the additional noise at the end of fStep in the 7D globa cooridnate system - * taking even the (co)variances of the position coordinates into account. - * - */ - void noiseCoulomb(M7x7& noise, - const M1x3& direction) const; - - //! Returns energy loss - /** Can be called with any pdg, but only calculates energy loss for electrons and positrons (otherwise returns 0). - * Uses a gaussian approximation (Bethe-Heitler formula with Migdal corrections). - * For positrons the energy loss is weighed with a correction factor. - */ - double energyLossBrems() const; - - //! calculation of energy loss straggeling - /** Can be called with any pdg, but only calculates straggeling for electrons and positrons. - * - */ - void noiseBrems(M7x7& noise) const; - - - bool noEffects_; - - bool energyLossBetheBloch_; - bool noiseBetheBloch_; - bool noiseCoulomb_; - bool energyLossBrems_; - bool noiseBrems_; - - bool ignoreBoundariesBetweenEqualMaterials_; - - const double me_; // electron mass (GeV) - - double stepSize_; // stepsize - - // cached values for energy loss and noise calculations - double mom_; - double beta_; - double dEdx_; - double gamma_; - double gammaSquare_; - - double matDensity_; - double matZ_; - double matA_; - double radiationLength_; - double mEE_; // mean excitation energy - - int pdg_; - int charge_; - double mass_; - - int mscModelCode_; /// depending on this number a specific msc model is chosen in the noiseCoulomb function. - - AbsMaterialInterface* materialInterface_; - - - //ClassDef(MaterialEffects, 1); - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_MaterialEffects_h diff --git a/genfit/trackReps/include/RKTools.h b/genfit/trackReps/include/RKTools.h deleted file mode 100644 index d083f448d9..0000000000 --- a/genfit/trackReps/include/RKTools.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright 2008-2009, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup RKTrackRep - * @{ - */ - -#ifndef genfit_RKTools_h -#define genfit_RKTools_h - -namespace genfit { - -/** - * Array Matrix typedefs. They are needed for SSE optimization: - * gcc can vectorize loops only if the array sizes are known. - */ -typedef double M1x3[1*3]; -typedef double M1x4[1*4]; -typedef double M1x6[1*6]; -typedef double M1x7[1*7]; -typedef double M5x5[5*5]; -typedef double M6x6[6*6]; -typedef double M7x7[7*7]; -typedef double M8x7[8*7]; -typedef double M6x5[6*5]; -typedef double M7x5[7*5]; -typedef double M5x6[5*6]; -typedef double M5x7[5*7]; - -/** - * @brief Array matrix multiplications used in RKTrackRep - */ -namespace RKTools { - - void J_pMTxcov5xJ_pM(const M5x7& J_pM, const M5x5& cov5, M7x7& out7); - void J_pMTxcov5xJ_pM(const M5x6& J_pM, const M5x5& cov5, M6x6& out6); - - void J_MpTxcov7xJ_Mp(const M7x5& J_Mp, const M7x7& cov7, M5x5& out5); - void J_MpTxcov6xJ_Mp(const M6x5& J_Mp, const M6x6& cov6, M5x5& out5); - - void J_MMTxcov7xJ_MM(const M7x7& J_MM, M7x7& cov7); - - void J_MMxJ_MM(M7x7& J_MM, const M7x7& J_MM_old); - - void J_pMTTxJ_MMTTxJ_MpTT(const M7x5& J_pMT, const M7x7& J_MMT, const M5x7& J_MpT, M5x5& J_pp); - - void Np_N_NpT(const M7x7& Np, M7x7& N); - - void printDim(const double* mat, unsigned int dimX, unsigned int dimY); - -} - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_RKTools_h - diff --git a/genfit/trackReps/include/RKTrackRep.h b/genfit/trackReps/include/RKTrackRep.h deleted file mode 100644 index 3ef902836e..0000000000 --- a/genfit/trackReps/include/RKTrackRep.h +++ /dev/null @@ -1,311 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup RKTrackRep - * @{ - */ - -#ifndef genfit_RKTrackRep_h -#define genfit_RKTrackRep_h - -#include "AbsTrackRep.h" -#include "StateOnPlane.h" -#include "RKTools.h" -#include "StepLimits.h" - - -namespace genfit { - -/** - * @brief Helper for RKTrackRep - */ -struct RKStep { - MatStep matStep_; // material properties and stepsize - M1x7 state7_; // 7D state vector - StepLimits limits_; - - RKStep() { - memset(state7_, 0x00, 7*sizeof(double)); - } -}; - - -/** - * @brief Helper for RKTrackRep - */ -struct ExtrapStep { - M7x7 jac7_; // 5D jacobian of transport - M7x7 noise7_; // 5D noise matrix - - ExtrapStep() { - memset(jac7_, 0, sizeof(M7x7)); - memset(noise7_, 0, sizeof(M7x7)); - } -}; - - -/** - * @brief AbsTrackRep with 5D track parameterization in plane coordinates: (q/p, u', v', u, v) - * - * q/p is charge over momentum. - * u' and v' are direction tangents. - * u and v are positions on a DetPlane. - */ -class RKTrackRep : public AbsTrackRep { - - - public: - - RKTrackRep(); - RKTrackRep(int pdgCode, char propDir = 0); - - virtual ~RKTrackRep(); - - virtual AbsTrackRep* clone() const {return new RKTrackRep(*this);} - - SharedPlanePtr makePlane(const TVector3& o,const TVector3& u,const TVector3& v); - virtual double extrapolateToPlane(StateOnPlane& state, - const SharedPlanePtr& plane, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - virtual double extrapolateToPlane(StateOnPlane& state, - const TVector3 & point,const TVector3 & dir, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - using AbsTrackRep::extrapolateToLine; - - virtual double extrapolateToLine(StateOnPlane& state, - const TVector3& linePoint, - const TVector3& lineDirection, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - virtual double extrapolateToPoint(StateOnPlane& state, - const TVector3& point, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const { - return extrapToPoint(state, point, NULL, stopAtBoundary, calcJacobianNoise); - } - - virtual double extrapolateToPoint(StateOnPlane& state, - const TVector3& point, - const TMatrixDSym& G, // weight matrix (metric) - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const { - return extrapToPoint(state, point, &G, stopAtBoundary, calcJacobianNoise); - } - - virtual double extrapolateToCylinder(StateOnPlane& state, - double radius, - const TVector3& linePoint = TVector3(0.,0.,0.), - const TVector3& lineDirection = TVector3(0.,0.,1.), - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - virtual double extrapolateToSphere(StateOnPlane& state, - double radius, - const TVector3& point = TVector3(0.,0.,0.), - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - virtual double extrapolateBy(StateOnPlane& state, - double step, - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - - unsigned int getDim() const {return 5;} - - virtual TVector3 getPos(const StateOnPlane& state) const; - - virtual TVector3 getMom(const StateOnPlane& state) const; - virtual void getPosMom(const StateOnPlane& state, TVector3& pos, TVector3& mom) const; - - virtual double getMomMag(const StateOnPlane& state) const; - virtual double getMomVar(const MeasuredStateOnPlane& state) const; - - virtual TMatrixDSym get6DCov(const MeasuredStateOnPlane& state) const; - virtual void getPosMomCov(const MeasuredStateOnPlane& state, TVector3& pos, TVector3& mom, TMatrixDSym& cov) const; - virtual double getCharge(const StateOnPlane& state) const; - virtual double getQop(const StateOnPlane& state) const {return state.getState()(0);} - double getSpu(const StateOnPlane& state) const; - - virtual void getForwardJacobianAndNoise(TMatrixD& jacobian, TMatrixDSym& noise, TVectorD& deltaState) const; - - virtual void getBackwardJacobianAndNoise(TMatrixD& jacobian, TMatrixDSym& noise, TVectorD& deltaState) const; - - std::vector getSteps() const; - - virtual double getRadiationLenght() const; - - virtual double getTOF() const; - - - virtual void setPosMom(StateOnPlane& state, const TVector3& pos, const TVector3& mom) const; - virtual void setPosMom(StateOnPlane& state, const TVectorD& state6) const; - virtual void setPosMomErr(MeasuredStateOnPlane& state, const TVector3& pos, const TVector3& mom, const TVector3& posErr, const TVector3& momErr) const; - virtual void setPosMomCov(MeasuredStateOnPlane& state, const TVector3& pos, const TVector3& mom, const TMatrixDSym& cov6x6) const; - virtual void setPosMomCov(MeasuredStateOnPlane& state, const TVectorD& state6, const TMatrixDSym& cov6x6) const; - - virtual void setChargeSign(StateOnPlane& state, double charge) const; - virtual void setQop(StateOnPlane& state, double qop) const {state.getState()(0) = qop;} - - void setSpu(StateOnPlane& state, double spu) const; - - //! The actual Runge Kutta propagation - /** propagate state7 with step S. Fills SA (Start directions derivatives dA/S). - * If jacobian is NULL, only the state is propagated, - * otherwise also the 7x7 jacobian is calculated. - * If varField is false, the magnetic field will only be evaluated at the starting position. - * The return value is an estimation on how good the extrapolation is, and it is usually fine if it is > 1. - * It gives a suggestion how you must scale S so that the quality will be sufficient. - */ - double RKPropagate(M1x7& state7, - M7x7* jacobian, - M1x3& SA, - double S, - bool varField = true, - bool calcOnlyLastRowOfJ = false) const; - - virtual bool isSameType(const AbsTrackRep* other); - virtual bool isSame(const AbsTrackRep* other); - - private: - - void initArrays() const; - - virtual double extrapToPoint(StateOnPlane& state, - const TVector3& point, - const TMatrixDSym* G = NULL, // weight matrix (metric) - bool stopAtBoundary = false, - bool calcJacobianNoise = false) const; - - void getState7(const StateOnPlane& state, M1x7& state7) const; - void getState5(StateOnPlane& state, const M1x7& state7) const; // state7 must already lie on plane of state! - - void transformPM7(const MeasuredStateOnPlane& state, - M7x7& out7x7) const; - - void calcJ_pM_5x7(M5x7& J_pM, const TVector3& U, const TVector3& V, const M1x3& pTilde, double spu) const; - - void transformPM6(const MeasuredStateOnPlane& state, - M6x6& out6x6) const; - - void transformM7P(const M7x7& in7x7, - const M1x7& state7, - MeasuredStateOnPlane& state) const; // plane must already be set! - - void calcJ_Mp_7x5(M7x5& J_Mp, const TVector3& U, const TVector3& V, const TVector3& W, const M1x3& A) const; - - void calcForwardJacobianAndNoise(const M1x7& startState7, const DetPlane& startPlane, - const M1x7& destState7, const DetPlane& destPlane) const; - - void transformM6P(const M6x6& in6x6, - const M1x7& state7, - MeasuredStateOnPlane& state) const; // plane and charge must already be set! - - //! Propagates the particle through the magnetic field. - /** If the propagation is successful and the plane is reached, the function returns true. - * Propagated state and the jacobian of the extrapolation are written to state7 and jacobianT. - * The jacobian is only calculated if jacobianT != NULL. - * In the main loop of the Runge Kutta algorithm, the estimateStep() is called - * and may reduce the estimated stepsize so that a maximum momentum loss will not be exceeded, - * and stop at material boundaries. - * If this is the case, RKutta() will only propagate the reduced distance and then return. This is to ensure that - * material effects, which are calculated after the propagation, are taken into account properly. - */ - bool RKutta(const M1x4& SU, - const DetPlane& plane, - double charge, - M1x7& state7, - M7x7* jacobianT, - double& coveredDistance, // signed - bool& checkJacProj, - M7x7& noiseProjection, - StepLimits& limits, - bool onlyOneStep = false, - bool calcOnlyLastRowOfJ = false) const; - - double estimateStep(const M1x7& state7, - const M1x4& SU, - const DetPlane& plane, - const double& charge, - double& relMomLoss, - StepLimits& limits) const; - - TVector3 pocaOnLine(const TVector3& linePoint, - const TVector3& lineDirection, - const TVector3& point) const; - - //! Handles propagation and material effects - /** #extrapolateToPlane(), #extrapolateToPoint() and #extrapolateToLine() etc. call this function. - * #Extrap() needs a plane as an argument, hence #extrapolateToPoint() and #extrapolateToLine() create virtual detector planes. - * In this function, #RKutta() is called and the resulting points and point paths are filtered - * so that the direction doesn't change and tiny steps are filtered out. - * After the propagation the material effects are called via the MaterialEffects singleton. - * #Extrap() will loop until the plane is reached, unless the propagation fails or the maximum number of - * iterations is exceeded. - */ - double Extrap(const DetPlane& startPlane, // plane where Extrap starts - const DetPlane& destPlane, // plane where Extrap has to extrapolate to - double charge, - bool& isAtBoundary, - M1x7& state7, - bool fillExtrapSteps, - TMatrixDSym* cov = nullptr, - bool onlyOneStep = false, - bool stopAtBoundary = false, - double maxStep = 1.E99) const; - - void checkCache(const StateOnPlane& state, const SharedPlanePtr* plane) const; - - double momMag(const M1x7& state7) const; - - - mutable StateOnPlane lastStartState_; //! state where the last extrapolation has started - mutable StateOnPlane lastEndState_; //! state where the last extrapolation has ended - mutable std::vector RKSteps_; //! RungeKutta steps made in the last extrapolation - mutable int RKStepsFXStart_; //! - mutable int RKStepsFXStop_; //! - mutable std::vector ExtrapSteps_; //! steps made in Extrap during last extrapolation - - mutable TMatrixD fJacobian_; //! - mutable TMatrixDSym fNoise_; //! - - mutable bool useCache_; //! use cached RKSteps_ for extrapolation - mutable unsigned int cachePos_; //! - - // auxiliary variables and arrays - // needed in Extrap() - mutable StepLimits limits_; //! - mutable M7x7 noiseArray_; //! noise matrix of the last extrapolation - mutable M7x7 noiseProjection_; //! - mutable M7x7 J_MMT_; //! - - public: - - ClassDef(RKTrackRep, 1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_RKTrackRep_h diff --git a/genfit/trackReps/include/StepLimits.h b/genfit/trackReps/include/StepLimits.h deleted file mode 100644 index d3098ffa8d..0000000000 --- a/genfit/trackReps/include/StepLimits.h +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright 2008-2014, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup RKTrackRep - * @{ - */ - -#ifndef genfit_StepLimits_h -#define genfit_StepLimits_h - -#include -#include - - -namespace genfit { - -enum StepLimitType { - // soft limits (only rough estimation, can go beyond safely) - stp_noLimit = 0, // only for internal use - - // medium limits (can go a bit further if e.g. plane or boundary will be reached) - stp_fieldCurv, // stepsize limited by curvature and magnetic field inhomogenities - stp_momLoss, // stepsize limited by stepper because maximum momLoss is reached - stp_sMax, // stepsize limited by SMax defined in #estimateStep() - - // hard limits (must stop there at any case!) - stp_sMaxArg, // stepsize limited by argument maxStepArg passed to #estimateStep() - stp_boundary, // stepsize limited by stepper because material boundary is encountered - stp_plane, // stepsize limited because destination plane is reached - - ENUM_NR_ITEMS // only for internal use -}; - - -/** - * @brief Helper to store different limits on the stepsize for the RKTRackRep. - */ -class StepLimits { - - public: - StepLimits() - : limits_(ENUM_NR_ITEMS, maxLimit_), stepSign_(1) {;} - - StepLimits& operator=(const StepLimits& other); - - //! Get limit of type. If that limit has not yet been set, return max double value. - double getLimit(StepLimitType type) const {return limits_[type];} - double getLimitSigned(StepLimitType type) const { - return stepSign_*getLimit(type); - } - - /** - * @brief Get the lowest limit. - * - * If hard limits are there, medium limits can be exceeded by up to margin - * (default margin is 0.1, i.e. medium limits can be exceeded by up to 10%). - * If no limit has been set yet, return std::pair::max>. - */ - std::pair getLowestLimit(double margin = 1.E-3) const; - - //! Get the unsigned numerical value of the lowest limit. - double getLowestLimitVal(double margin = 1.E-3) const; - //! Get the numerical value of the lowest limit, signed with #stepSign_. - double getLowestLimitSignedVal(double margin = 1.E-3) const { - return getLowestLimitVal(margin) * stepSign_; - } - - char getStepSign() const {return stepSign_;} // +- 1 - - //! absolute of value will be taken! If limit is already lower, it will stay. - void reduceLimit(StepLimitType type, double value); - //! absolute of value will be taken! If limit is already lower, it will be set to value anyway. - void setLimit(StepLimitType type, double value) {limits_[type] = fabs(value);} - //! sets #stepSign_ to sign of signedVal - void setStepSign(char signedVal); - //! sets #stepSign_ to sign of signedVal - void setStepSign(double signedVal); - - void removeLimit(StepLimitType type) {limits_[type] = maxLimit_;} - - void reset(); - void Print(); - - private: - std::vector limits_; // limits are unsigned (i.e. non-negative) - signed char stepSign_; - static const double maxLimit_; - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_StepLimits_h diff --git a/genfit/trackReps/include/TGeoMaterialInterface.h b/genfit/trackReps/include/TGeoMaterialInterface.h deleted file mode 100644 index e6d77c0418..0000000000 --- a/genfit/trackReps/include/TGeoMaterialInterface.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2008-2014, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -/** @addtogroup RKTrackRep - * @{ - */ - -#ifndef genfit_TGeoMaterialInterface_h -#define genfit_TGeoMaterialInterface_h - -#include "AbsMaterialInterface.h" - - -namespace genfit { - -/** - * @brief AbsMaterialInterface implementation for use with ROOT's TGeoManager. - */ -class TGeoMaterialInterface : public AbsMaterialInterface { - - public: - - TGeoMaterialInterface() {}; - virtual ~TGeoMaterialInterface(){;}; - - /** @brief Initialize the navigator at given position and with given - direction. Returns true if the volume changed. - */ - bool initTrack(double posX, double posY, double posZ, - double dirX, double dirY, double dirZ); - - /** @brief Get material parameters in current material - */ - void getMaterialParameters(double& density, - double& Z, - double& A, - double& radiationLength, - double& mEE); - - void getMaterialParameters(MaterialProperties& parameters); - - /** @brief Make a step (following the curvature) until step length - * sMax or the next boundary is reached. After making a step to a - * boundary, the position has to be beyond the boundary, i.e. the - * current material has to be that beyond the boundary. The actual - * step made is returned. - */ - double findNextBoundary(const RKTrackRep* rep, - const M1x7& state7, - double sMax, - bool varField = true); - - double findNextBoundaryAndStepStraight(double sMax); - - ClassDef(TGeoMaterialInterface, 1); - - private: -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_TGeoMaterialInterface_h diff --git a/genfit/trackReps/src/MaterialEffects.cc b/genfit/trackReps/src/MaterialEffects.cc deleted file mode 100644 index e3bad3a8ff..0000000000 --- a/genfit/trackReps/src/MaterialEffects.cc +++ /dev/null @@ -1,681 +0,0 @@ -/* Copyright 2008-2014, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "MaterialEffects.h" -#include "Exception.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - - -//#define DEBUG - -namespace genfit { - -MaterialEffects* MaterialEffects::instance_ = nullptr; - - -MaterialEffects::MaterialEffects(): - noEffects_(false), - energyLossBetheBloch_(true), noiseBetheBloch_(true), - noiseCoulomb_(true), - energyLossBrems_(true), noiseBrems_(true), - ignoreBoundariesBetweenEqualMaterials_(true), - me_(0.510998910E-3), - stepSize_(0), - mom_(0), - beta_(0), - dEdx_(0), - gamma_(0), - gammaSquare_(0), - matDensity_(0), - matZ_(0), - matA_(0), - radiationLength_(0), - mEE_(0), - pdg_(0), - charge_(0), - mass_(0), - mscModelCode_(0), - materialInterface_(nullptr) -{ -} - -MaterialEffects::~MaterialEffects() -{ - if (materialInterface_ != nullptr) delete materialInterface_; -} - -MaterialEffects* MaterialEffects::getInstance() -{ - if (instance_ == nullptr) instance_ = new MaterialEffects(); - return instance_; -} - -void MaterialEffects::destruct() -{ - if (instance_ != nullptr) { - delete instance_; - instance_ = nullptr; - } -} - -void MaterialEffects::init(AbsMaterialInterface* matIfc) -{ - if (materialInterface_ != nullptr) { - std::string msg("MaterialEffects::initMaterialInterface(): Already initialized! "); - std::runtime_error err(msg); - } - materialInterface_ = matIfc; -} - - - -void MaterialEffects::setMscModel(const std::string& modelName) -{ - if (modelName == std::string("GEANE")) { - mscModelCode_ = 0; - } else if (modelName == std::string("Highland")) { - mscModelCode_ = 1; - } else {// throw exception - std::string errorMsg = std::string("There is no MSC model called \"") + modelName + "\". Maybe it is not implemented or you misspelled the model name"; - Exception exc(errorMsg, __LINE__, __FILE__); - exc.setFatal(); - std::cerr << exc.what(); - throw exc; - } -} - - -double MaterialEffects::effects(const std::vector& steps, - int materialsFXStart, - int materialsFXStop, - const double& mom, - const int& pdg, - M7x7* noise) -{ - -#ifdef DEBUG - std::cout << " MaterialEffects::effects \n"; -#endif - - /*std::cout << "noEffects_ " << noEffects_ << "\n"; - std::cout << "energyLossBetheBloch_ " << energyLossBetheBloch_ << "\n"; - std::cout << "noiseBetheBloch_ " << noiseBetheBloch_ << "\n"; - std::cout << "noiseCoulomb_ " << noiseCoulomb_ << "\n"; - std::cout << "energyLossBrems_ " << energyLossBrems_ << "\n"; - std::cout << "noiseBrems_ " << noiseBrems_ << "\n";*/ - - - if (noEffects_) return 0.; - - if (materialInterface_ == nullptr) { - std::string msg("MaterialEffects hasn't been initialized with a correct AbsMaterialInterface pointer!"); - std::runtime_error err(msg); - throw err; - } - - bool doNoise(noise != nullptr); - - pdg_ = pdg; - getParticleParameters(mom); - - double momLoss = 0.; - - for ( std::vector::const_iterator it = steps.begin() + materialsFXStart; it != steps.begin() + materialsFXStop; ++it) { // loop over steps - - double realPath = it->matStep_.stepSize_; - if (fabs(realPath) < 1.E-8) { - // do material effects only if distance is not too small - continue; - } - - #ifdef DEBUG - std::cout << " calculate matFX "; - if (doNoise) - std::cout << " and noise"; - std::cout << " for "; - std::cout << "stepSize = " << it->stepSize_ << "\t"; - it->materialProperties_.Print(); - #endif - - double stepSign(1.); - if (realPath < 0) - stepSign = -1.; - realPath = fabs(realPath); - stepSize_ = realPath; - - it->matStep_.materialProperties_.getMaterialProperties(matDensity_, matZ_, matA_, radiationLength_, mEE_); - - if (matZ_ > 1.E-3) { // don't calculate energy loss for vacuum - - if (energyLossBetheBloch_) - momLoss += stepSign * this->energyLossBetheBloch(); - if (doNoise && energyLossBetheBloch_ && noiseBetheBloch_) - this->noiseBetheBloch(*noise); - - if (doNoise && noiseCoulomb_) - this->noiseCoulomb(*noise, *((M1x3*) &it->state7_[3]) ); - - if (energyLossBrems_) - momLoss += stepSign * this->energyLossBrems(); - if (doNoise && energyLossBrems_ && noiseBrems_) - this->noiseBrems(*noise); - - } - - } // end loop over steps - - return momLoss; -} - - -void MaterialEffects::stepper(const RKTrackRep* rep, - M1x7& state7, - const double& mom, // momentum - double& relMomLoss, // relative momloss for the step will be added - const int& pdg, - MaterialProperties& currentMaterial, - StepLimits& limits, - bool varField) -{ - - static const double maxRelMomLoss = .005; // maximum relative momentum loss allowed - static const double minStep = 1.E-4; // 1 µm - - // Trivial cases - - if (noEffects_) - return; - - if (materialInterface_ == nullptr) { - std::string msg("MaterialEffects hasn't been initialized with a correct AbsMaterialInterface pointer!"); - std::runtime_error err(msg); - throw err; - } - - if (relMomLoss > maxRelMomLoss) { - limits.setLimit(stp_momLoss, 0); - return; - } - - - double sMax = limits.getLowestLimitSignedVal(); // signed - - if (fabs(sMax) < minStep) - return; - - - - pdg_ = pdg; - getParticleParameters(mom); - - - // make minStep - state7[0] += limits.getStepSign() * minStep * state7[3]; - state7[1] += limits.getStepSign() * minStep * state7[4]; - state7[2] += limits.getStepSign() * minStep * state7[5]; - - materialInterface_->initTrack(state7[0], state7[1], state7[2], - limits.getStepSign() * state7[3], limits.getStepSign() * state7[4], limits.getStepSign() * state7[5]); - - materialInterface_->getMaterialParameters(matDensity_, matZ_, matA_, radiationLength_, mEE_); - currentMaterial.setMaterialProperties(matDensity_, matZ_, matA_, radiationLength_, mEE_); - - - #ifdef DEBUG - std::cout << " currentMaterial "; currentMaterial.Print(); - #endif - - // limit due to momloss - double relMomLossPer_cm(0); - stepSize_ = 1; // set stepsize for momLoss calculation - - if (matZ_ > 1.E-3) { // don't calculate energy loss for vacuum - if (energyLossBetheBloch_) relMomLossPer_cm += this->energyLossBetheBloch() / mom; - if (energyLossBrems_) relMomLossPer_cm += this->energyLossBrems() / mom; - } - - double maxStepMomLoss = (maxRelMomLoss - relMomLoss) / relMomLossPer_cm; - limits.setLimit(stp_momLoss, maxStepMomLoss); - - #ifdef DEBUG - std::cout << " momLoss exceeded after a step of " << maxStepMomLoss << "\n"; - #endif - - - // now look for boundaries - sMax = limits.getLowestLimitSignedVal(); - - stepSize_ = limits.getStepSign() * minStep; - MaterialProperties materialAfter; - M1x3 SA; - double boundaryStep(sMax); - - for (unsigned int i=0; i<100; ++i) { - #ifdef DEBUG - std::cout << " find next boundary\n"; - #endif - double step = materialInterface_->findNextBoundary(rep, state7, boundaryStep, varField); - stepSize_ += step; - boundaryStep -= step; - - #ifdef DEBUG - std::cout << " made a step of " << step << "\n"; - #endif - - if (! ignoreBoundariesBetweenEqualMaterials_) - break; - - if (fabs(stepSize_) >= fabs(sMax)) - break; - - // propagate with found step to boundary - rep->RKPropagate(state7, NULL, SA, step, varField); - - // make minStep to cross boundary - state7[0] += limits.getStepSign() * minStep * state7[3]; - state7[1] += limits.getStepSign() * minStep * state7[4]; - state7[2] += limits.getStepSign() * minStep * state7[5]; - - materialInterface_->initTrack(state7[0], state7[1], state7[2], - limits.getStepSign() * state7[3], limits.getStepSign() * state7[4], limits.getStepSign() * state7[5]); - - materialInterface_->getMaterialParameters(materialAfter); - - #ifdef DEBUG - std::cout << " material after step "; materialAfter.Print(); - #endif - - if (materialAfter != currentMaterial) - break; - } - - limits.setLimit(stp_boundary, stepSize_); - - - relMomLoss += relMomLossPer_cm * limits.getLowestLimitVal(); -} - - -void MaterialEffects::getParticleParameters(double mom) -{ - TParticlePDG* part = TDatabasePDG::Instance()->GetParticle(pdg_); - mom_ = mom; - charge_ = int(part->Charge() / 3.); // We only ever use the square - mass_ = part->Mass(); // GeV - - beta_ = 1 / hypot(mass_ / mom, 1); - gammaSquare_ = 1 + mom*mom / mass_ / mass_; - gamma_ = hypot(mom / mass_, 1); -} - - - -//---- Energy-loss and Noise calculations ----------------------------------------- - -double MaterialEffects::energyLossBetheBloch() -{ - - // calc dEdx_, also needed in noiseBetheBloch! - dEdx_ = 0.307075 * matZ_ / matA_ * matDensity_ / (beta_ * beta_) * charge_ * charge_; - double massRatio = me_ / mass_; - double argument = gammaSquare_ * beta_ * beta_ * me_ * 1.E3 * 2. / ((1.E-6 * mEE_) * sqrt(1 + 2 * gamma_ * massRatio + massRatio * massRatio)); - dEdx_ *= log(argument) - beta_ * beta_; // Bethe-Bloch [MeV/cm] - dEdx_ *= 1.E-3; // in GeV/cm, hence 1.e-3 - if (dEdx_ < 0.) dEdx_ = 0; - - double dE = fabs(stepSize_) * dEdx_; //always positive - double momLoss = sqrt(mom_ * mom_ + 2.*sqrt(mom_ * mom_ + mass_ * mass_) * dE + dE * dE) - mom_; //always positive - - //in vacuum it can numerically happen that momLoss becomes a small negative number. - if (momLoss < 0.) return 0.; - return momLoss; -} - - -void MaterialEffects::noiseBetheBloch(M7x7& noise) const -{ - - // Code ported from GEANT 3 - - // ENERGY LOSS FLUCTUATIONS; calculate sigma^2(E); - double sigma2E = 0.; - double zeta = 153.4E3 * charge_ * charge_ / (beta_ * beta_) * matZ_ / matA_ * matDensity_ * fabs(stepSize_); // eV - double Emax = 2.E9 * me_ * beta_ * beta_ * gammaSquare_ / (1. + 2.*gamma_ * me_ / mass_ + (me_ / mass_) * (me_ / mass_)); // eV - double kappa = zeta / Emax; - - if (kappa > 0.01) { // Vavilov-Gaussian regime - sigma2E += zeta * Emax * (1. - beta_ * beta_ / 2.); // eV^2 - } else { // Urban/Landau approximation - // calculate number of collisions Nc - double I = 16. * pow(matZ_, 0.9); // eV - double f2 = 0.; - if (matZ_ > 2.) f2 = 2. / matZ_; - double f1 = 1. - f2; - double e2 = 10.*matZ_ * matZ_; // eV - double e1 = pow((I / pow(e2, f2)), 1. / f1); // eV - - double mbbgg2 = 2.E9 * mass_ * beta_ * beta_ * gammaSquare_; // eV - double Sigma1 = dEdx_ * 1.0E9 * f1 / e1 * (log(mbbgg2 / e1) - beta_ * beta_) / (log(mbbgg2 / I) - beta_ * beta_) * 0.6; // 1/cm - double Sigma2 = dEdx_ * 1.0E9 * f2 / e2 * (log(mbbgg2 / e2) - beta_ * beta_) / (log(mbbgg2 / I) - beta_ * beta_) * 0.6; // 1/cm - double Sigma3 = dEdx_ * 1.0E9 * Emax / (I * (Emax + I) * log((Emax + I) / I)) * 0.4; // 1/cm - - double Nc = (Sigma1 + Sigma2 + Sigma3) * fabs(stepSize_); - - if (Nc > 50.) { // truncated Landau distribution - double sigmaalpha = 15.76; - // calculate sigmaalpha (see GEANT3 manual W5013) - double RLAMED = -0.422784 - beta_ * beta_ - log(zeta / Emax); - double RLAMAX = 0.60715 + 1.1934 * RLAMED + (0.67794 + 0.052382 * RLAMED) * exp(0.94753 + 0.74442 * RLAMED); - // from lambda max to sigmaalpha=sigma (empirical polynomial) - if (RLAMAX <= 1010.) { - sigmaalpha = 1.975560 - + 9.898841e-02 * RLAMAX - - 2.828670e-04 * RLAMAX * RLAMAX - + 5.345406e-07 * pow(RLAMAX, 3.) - - 4.942035e-10 * pow(RLAMAX, 4.) - + 1.729807e-13 * pow(RLAMAX, 5.); - } else { sigmaalpha = 1.871887E+01 + 1.296254E-02 * RLAMAX; } - // alpha=54.6 corresponds to a 0.9996 maximum cut - if (sigmaalpha > 54.6) sigmaalpha = 54.6; - sigma2E += sigmaalpha * sigmaalpha * zeta * zeta; // eV^2 - } else { // Urban model - static const double alpha = 0.996; - double Ealpha = I / (1. - (alpha * Emax / (Emax + I))); // eV - double meanE32 = I * (Emax + I) / Emax * (Ealpha - I); // eV^2 - sigma2E += fabs(stepSize_) * (Sigma1 * e1 * e1 + Sigma2 * e2 * e2 + Sigma3 * meanE32); // eV^2 - } - } - - sigma2E *= 1.E-18; // eV -> GeV - - // update noise matrix, using linear error propagation from E to q/p - noise[6 * 7 + 6] += charge_*charge_/beta_/beta_ / pow(mom_, 4) * sigma2E; -} - - -void MaterialEffects::noiseCoulomb(M7x7& noise, - const M1x3& direction) const -{ - - // MULTIPLE SCATTERING; calculate sigma^2 - double sigma2 = 0; - assert(mscModelCode_ == 0 || mscModelCode_ == 1); - const double step = fabs(stepSize_); - const double step2 = step * step; - if (mscModelCode_ == 0) {// PANDA report PV/01-07 eq(43); linear in step length - sigma2 = 225.E-6 * charge_ * charge_ / (beta_ * beta_ * mom_ * mom_) * step / radiationLength_ * matZ_ / (matZ_ + 1) * log(159.*pow(matZ_, -1. / 3.)) / log(287.*pow(matZ_, -0.5)); // sigma^2 = 225E-6*z^2/mom^2 * XX0/beta_^2 * Z/(Z+1) * ln(159*Z^(-1/3))/ln(287*Z^(-1/2) - - } else if (mscModelCode_ == 1) { //Highland not linear in step length formula taken from PDG book 2011 edition - double stepOverRadLength = step / radiationLength_; - double logCor = (1 + 0.038 * log(stepOverRadLength)); - sigma2 = 0.0136 * 0.0136 * charge_ * charge_ / (beta_ * beta_ * mom_ * mom_) * stepOverRadLength * logCor * logCor; - } - //assert(sigma2 >= 0.0); - sigma2 = (sigma2 > 0.0 ? sigma2 : 0.0); - //XXX std::cout << "MaterialEffects::noiseCoulomb the MSC variance is " << sigma2 << std::endl; - - double noiseAfter[7 * 7]; // will hold the new MSC noise to cause by the current stepSize_ length - memset(noiseAfter, 0x00, 7 * 7 * sizeof(double)); - - const double *a = direction; - // This calculates the MSC angular spread in the 7D global - // coordinate system. See PDG 2010, Sec. 27.3 for formulae. - noiseAfter[0 * 7 + 0] = sigma2 * step2 / 3.0 * (1 - a[0]*a[0]); - noiseAfter[1 * 7 + 0] = -sigma2 * step2 / 3.0 * a[0]*a[1]; - noiseAfter[2 * 7 + 0] = -sigma2 * step2 / 3.0 * a[0]*a[2]; - noiseAfter[3 * 7 + 0] = sigma2 * step * 0.5 * (1 - a[0]*a[0]); - noiseAfter[4 * 7 + 0] = -sigma2 * step * 0.5 * a[0]*a[1]; - noiseAfter[5 * 7 + 0] = -sigma2 * step * 0.5 * a[0]*a[1]; - noiseAfter[0 * 7 + 1] = noiseAfter[1 * 7 + 0]; - noiseAfter[1 * 7 + 1] = sigma2 * step2 / 3.0 * (1 - a[1]*a[1]); - noiseAfter[2 * 7 + 1] = -sigma2 * step2 / 3.0 * a[1]*a[2]; - noiseAfter[3 * 7 + 1] = noiseAfter[4 * 7 + 0]; // Cov(x,a_y) = Cov(y,a_x) - noiseAfter[4 * 7 + 1] = sigma2 * step * 0.5 * (1 - a[1] * a[1]); - noiseAfter[5 * 7 + 1] = -sigma2 * step * 0.5 * a[1]*a[2]; - noiseAfter[0 * 7 + 2] = noiseAfter[2 * 7 + 0]; - noiseAfter[1 * 7 + 2] = noiseAfter[2 * 7 + 1]; - noiseAfter[2 * 7 + 2] = sigma2 * step2 / 3.0 * (1 - a[2]*a[2]); - noiseAfter[3 * 7 + 2] = noiseAfter[5 * 7 + 0]; // Cov(z,a_x) = Cov(x,a_z) - noiseAfter[4 * 7 + 2] = noiseAfter[5 * 7 + 1]; // Cov(y,a_z) = Cov(z,a_y) - noiseAfter[5 * 7 + 2] = sigma2 * step * 0.5 * (1 - a[2]*a[2]); - noiseAfter[0 * 7 + 3] = noiseAfter[3 * 7 + 0]; - noiseAfter[1 * 7 + 3] = noiseAfter[3 * 7 + 1]; - noiseAfter[2 * 7 + 3] = noiseAfter[3 * 7 + 2]; - noiseAfter[3 * 7 + 3] = sigma2 * (1 - a[0]*a[0]); - noiseAfter[4 * 7 + 3] = -sigma2 * a[0]*a[1]; - noiseAfter[5 * 7 + 3] = -sigma2 * a[0]*a[2]; - noiseAfter[0 * 7 + 4] = noiseAfter[4 * 7 + 0]; - noiseAfter[1 * 7 + 4] = noiseAfter[4 * 7 + 1]; - noiseAfter[2 * 7 + 4] = noiseAfter[4 * 7 + 2]; - noiseAfter[3 * 7 + 4] = noiseAfter[4 * 7 + 3]; - noiseAfter[4 * 7 + 4] = sigma2 * (1 - a[1]*a[1]); - noiseAfter[5 * 7 + 4] = -sigma2 * a[1]*a[2]; - noiseAfter[0 * 7 + 5] = noiseAfter[5 * 7 + 0]; - noiseAfter[1 * 7 + 5] = noiseAfter[5 * 7 + 1]; - noiseAfter[2 * 7 + 5] = noiseAfter[5 * 7 + 2]; - noiseAfter[3 * 7 + 5] = noiseAfter[5 * 7 + 3]; - noiseAfter[4 * 7 + 5] = noiseAfter[5 * 7 + 4]; - noiseAfter[5 * 7 + 5] = sigma2 * (1 - a[2]*a[2]); -// std::cout << "new noise\n"; -// RKTools::printDim(noiseAfter, 7,7); - for (unsigned int i = 0; i < 7 * 7; ++i) { - noise[i] += noiseAfter[i]; - } -} - - -double MaterialEffects::energyLossBrems() const -{ - - // Code ported from GEANT 3 - - if (abs(pdg_) != 11) return 0; // only for electrons and positrons - -#if !defined(BETHE) - static const double C[101] = { 0.0, -0.960613E-01, 0.631029E-01, -0.142819E-01, 0.150437E-02, -0.733286E-04, 0.131404E-05, 0.859343E-01, -0.529023E-01, 0.131899E-01, -0.159201E-02, 0.926958E-04, -0.208439E-05, -0.684096E+01, 0.370364E+01, -0.786752E+00, 0.822670E-01, -0.424710E-02, 0.867980E-04, -0.200856E+01, 0.129573E+01, -0.306533E+00, 0.343682E-01, -0.185931E-02, 0.392432E-04, 0.127538E+01, -0.515705E+00, 0.820644E-01, -0.641997E-02, 0.245913E-03, -0.365789E-05, 0.115792E+00, -0.463143E-01, 0.725442E-02, -0.556266E-03, 0.208049E-04, -0.300895E-06, -0.271082E-01, 0.173949E-01, -0.452531E-02, 0.569405E-03, -0.344856E-04, 0.803964E-06, 0.419855E-02, -0.277188E-02, 0.737658E-03, -0.939463E-04, 0.569748E-05, -0.131737E-06, -0.318752E-03, 0.215144E-03, -0.579787E-04, 0.737972E-05, -0.441485E-06, 0.994726E-08, 0.938233E-05, -0.651642E-05, 0.177303E-05, -0.224680E-06, 0.132080E-07, -0.288593E-09, -0.245667E-03, 0.833406E-04, -0.129217E-04, 0.915099E-06, -0.247179E-07, 0.147696E-03, -0.498793E-04, 0.402375E-05, 0.989281E-07, -0.133378E-07, -0.737702E-02, 0.333057E-02, -0.553141E-03, 0.402464E-04, -0.107977E-05, -0.641533E-02, 0.290113E-02, -0.477641E-03, 0.342008E-04, -0.900582E-06, 0.574303E-05, 0.908521E-04, -0.256900E-04, 0.239921E-05, -0.741271E-07, -0.341260E-04, 0.971711E-05, -0.172031E-06, -0.119455E-06, 0.704166E-08, 0.341740E-05, -0.775867E-06, -0.653231E-07, 0.225605E-07, -0.114860E-08, -0.119391E-06, 0.194885E-07, 0.588959E-08, -0.127589E-08, 0.608247E-10}; - static const double xi = 2.51, beta = 0.99, vl = 0.00004; -#endif -#if defined(BETHE) // no MIGDAL corrections - static const double C[101] = { 0.0, 0.834459E-02, 0.443979E-02, -0.101420E-02, 0.963240E-04, -0.409769E-05, 0.642589E-07, 0.464473E-02, -0.290378E-02, 0.547457E-03, -0.426949E-04, 0.137760E-05, -0.131050E-07, -0.547866E-02, 0.156218E-02, -0.167352E-03, 0.101026E-04, -0.427518E-06, 0.949555E-08, -0.406862E-02, 0.208317E-02, -0.374766E-03, 0.317610E-04, -0.130533E-05, 0.211051E-07, 0.158941E-02, -0.385362E-03, 0.315564E-04, -0.734968E-06, -0.230387E-07, 0.971174E-09, 0.467219E-03, -0.154047E-03, 0.202400E-04, -0.132438E-05, 0.431474E-07, -0.559750E-09, -0.220958E-02, 0.100698E-02, -0.596464E-04, -0.124653E-04, 0.142999E-05, -0.394378E-07, 0.477447E-03, -0.184952E-03, -0.152614E-04, 0.848418E-05, -0.736136E-06, 0.190192E-07, -0.552930E-04, 0.209858E-04, 0.290001E-05, -0.133254E-05, 0.116971E-06, -0.309716E-08, 0.212117E-05, -0.103884E-05, -0.110912E-06, 0.655143E-07, -0.613013E-08, 0.169207E-09, 0.301125E-04, -0.461920E-04, 0.871485E-05, -0.622331E-06, 0.151800E-07, -0.478023E-04, 0.247530E-04, -0.381763E-05, 0.232819E-06, -0.494487E-08, -0.336230E-04, 0.223822E-04, -0.384583E-05, 0.252867E-06, -0.572599E-08, 0.105335E-04, -0.567074E-06, -0.216564E-06, 0.237268E-07, -0.658131E-09, 0.282025E-05, -0.671965E-06, 0.565858E-07, -0.193843E-08, 0.211839E-10, 0.157544E-04, -0.304104E-05, -0.624410E-06, 0.120124E-06, -0.457445E-08, -0.188222E-05, -0.407118E-06, 0.375106E-06, -0.466881E-07, 0.158312E-08, 0.945037E-07, 0.564718E-07, -0.319231E-07, 0.371926E-08, -0.123111E-09}; - static const double xi = 2.10, beta = 1.00, vl = 0.001; -#endif - - double BCUT = 10000.; // energy up to which soft bremsstrahlung energy loss is calculated - - static const double THIGH = 100., CHIGH = 50.; - double dedxBrems = 0.; - - if (BCUT > 0.) { - double T, kc; - - if (BCUT >= mom_) BCUT = mom_; // confine BCUT to mom_ - - // T=mom_, confined to THIGH - // kc=BCUT, confined to CHIGH ?? - if (mom_ >= THIGH) { - T = THIGH; - if (BCUT >= THIGH) kc = CHIGH; - else kc = BCUT; - } else { - T = mom_; - kc = BCUT; - } - - double E = T + me_; // total electron energy - if (BCUT > T) kc = T; - - double X = log(T / me_); - double Y = log(kc / (E * vl)); - - double XX; - int K; - double S = 0., YY = 1.; - - for (unsigned int I = 1; I <= 2; ++I) { - XX = 1.; - for (unsigned int J = 1; J <= 6; ++J) { - K = 6 * I + J - 6; - S = S + C[K] * XX * YY; - XX = XX * X; - } - YY = YY * Y; - } - - for (unsigned int I = 3; I <= 6; ++I) { - XX = 1.; - for (unsigned int J = 1; J <= 6; ++J) { - K = 6 * I + J - 6; - if (Y <= 0.) S = S + C[K] * XX * YY; - else S = S + C[K + 24] * XX * YY; - XX = XX * X; - } - YY = YY * Y; - } - - double SS = 0.; - YY = 1.; - - for (unsigned int I = 1; I <= 2; ++I) { - XX = 1.; - for (unsigned int J = 1; J <= 5; ++J) { - K = 5 * I + J + 55; - SS = SS + C[K] * XX * YY; - XX = XX * X; - } - YY = YY * Y; - } - - for (unsigned int I = 3; I <= 5; ++I) { - XX = 1.; - for (unsigned int J = 1; J <= 5; ++J) { - K = 5 * I + J + 55; - if (Y <= 0.) SS = SS + C[K] * XX * YY; - else SS = SS + C[K + 15] * XX * YY; - XX = XX * X; - } - YY = YY * Y; - } - - S = S + matZ_ * SS; - - if (S > 0.) { - double CORR = 1.; -#if !defined(BETHE) - CORR = 1. / (1. + 0.805485E-10 * matDensity_ * matZ_ * E * E / (matA_ * kc * kc)); // MIGDAL correction factor -#endif - - // We use exp(beta * log(...) here because pow(..., beta) is - // REALLY slow and we don't need ultimate numerical precision - // for this approximation. - double FAC = matZ_ * (matZ_ + xi) * E * E / (E + me_); - if (beta == 1.) { // That is the #ifdef BETHE case - FAC *= kc * CORR / T; - } else { - FAC *= exp(beta * log(kc * CORR / T)); - } - if (FAC <= 0.) return 0.; - dedxBrems = FAC * S; - - - if (mom_ > THIGH) { - double RAT; - if (BCUT < THIGH) { - RAT = BCUT / mom_; - S = (1. - 0.5 * RAT + 2.*RAT * RAT / 9.); - RAT = BCUT / T; - S = S / (1. - 0.5 * RAT + 2.*RAT * RAT / 9.); - } else { - RAT = BCUT / mom_; - S = BCUT * (1. - 0.5 * RAT + 2.*RAT * RAT / 9.); - RAT = kc / T; - S = S / (kc * (1. - 0.5 * RAT + 2.*RAT * RAT / 9.)); - } - dedxBrems = dedxBrems * S; // GeV barn - } - - dedxBrems = 0.60221367 * matDensity_ * dedxBrems / matA_; // energy loss dE/dx [GeV/cm] - } - } - - if (dedxBrems < 0.) dedxBrems = 0; - - double factor = 1.; // positron correction factor - - if (pdg_ == -11) { - static const double AA = 7522100., A1 = 0.415, A3 = 0.0021, A5 = 0.00054; - - double ETA = 0.; - if (matZ_ > 0.) { - double X = log(AA * mom_ / (matZ_ * matZ_)); - if (X > -8.) { - if (X >= +9.) ETA = 1.; - else { - double W = A1 * X + A3 * pow(X, 3.) + A5 * pow(X, 5.); - ETA = 0.5 + atan(W) / M_PI; - } - } - } - - if (ETA < 0.0001) factor = 1.E-10; - else if (ETA > 0.9999) factor = 1.; - else { - double E0 = BCUT / mom_; - if (E0 > 1.) E0 = 1.; - if (E0 < 1.E-8) factor = 1.; - else factor = ETA * (1. - pow(1. - E0, 1. / ETA)) / E0; - } - } - - double dE = fabs(stepSize_) * factor * dedxBrems; //always positive - double momLoss = sqrt(mom_ * mom_ + 2.*sqrt(mom_ * mom_ + mass_ * mass_) * dE + dE * dE) - mom_; //always positive - - return momLoss; -} - - -void MaterialEffects::noiseBrems(M7x7& noise) const -{ - - // Code ported from GEANT 3 and simplified - // this formula assumes p >> m and therefore p^2 + m^2 = p^2 - // the factor 1.44 is not in the original Behta Heitler model. It seems to be some empirical correction copied over from some other project - - if (abs(pdg_) != 11) return; // only for electrons and positrons - - double minusXOverLn2 = -1.442695 * fabs(stepSize_) / radiationLength_; - double sigma2 = 1.44*(pow(3., minusXOverLn2) - pow(4., minusXOverLn2)) / (mom_*mom_); - //XXX std::cout << "breams sigma: " << sigma2E << std::endl; - //assert(sigma2 >= 0.0); - sigma2 = (sigma2 > 0.0 ? sigma2 : 0.0); - noise[6 * 7 + 6] += charge_*charge_/beta_/beta_ / pow(mom_, 4) * sigma2; - -} - -} /* End of namespace genfit */ - - diff --git a/genfit/trackReps/src/RKTools.cc b/genfit/trackReps/src/RKTools.cc deleted file mode 100644 index 031a833ac6..0000000000 --- a/genfit/trackReps/src/RKTools.cc +++ /dev/null @@ -1,706 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include - -#include -#include - -#include -#include -#include -#include - -static const int flagSlowMatrix = 1 << 10; // Replace custom matrix multiplications with general equivalents -static const int debugFlags = 0; // | flagSlowMatrix; - -namespace genfit { - - -void RKTools::J_pMTxcov5xJ_pM(const M5x7& J_pM, const M5x5& cov5, M7x7& out7){ - - // 5D -> 7D - - // J_pM - // 0 0 0 0 0 0 1 - // 0 0 0 x x x 0 - // 0 0 0 x x x 0 - // x x x 0 0 0 0 - // x x x 0 0 0 0 - - // it is assumed that J_pM is only non-zero here: - // [6] = 1 - - // [1*7+3] - // [1*7+4] - // [1*7+5] - - // [2*7+3] - // [2*7+4] - // [2*7+5] - - // [3*7+0] - // [3*7+1] - // [3*7+2] - - // [4*7+0] - // [4*7+1] - // [4*7+2] - - double JTC0 = J_pM[21] * cov5[18] + J_pM[28] * cov5[23]; - double JTC1 = J_pM[21] * cov5[23] + J_pM[28] * cov5[24]; - double JTC2 = J_pM[21] * cov5[16] + J_pM[28] * cov5[21]; - double JTC3 = J_pM[21] * cov5[17] + J_pM[28] * cov5[22]; - double JTC4 = J_pM[22] * cov5[18] + J_pM[29] * cov5[23]; - double JTC5 = J_pM[22] * cov5[23] + J_pM[29] * cov5[24]; - double JTC6 = J_pM[22] * cov5[16] + J_pM[29] * cov5[21]; - double JTC7 = J_pM[22] * cov5[17] + J_pM[29] * cov5[22]; - double JTC8 = J_pM[23] * cov5[18] + J_pM[30] * cov5[23]; - double JTC9 = J_pM[23] * cov5[23] + J_pM[30] * cov5[24]; - double JTC10 = J_pM[23] * cov5[16] + J_pM[30] * cov5[21]; - double JTC11 = J_pM[23] * cov5[17] + J_pM[30] * cov5[22]; - double JTC12 = J_pM[10] * cov5[6] + J_pM[17] * cov5[11]; - double JTC13 = J_pM[10] * cov5[11] + J_pM[17] * cov5[12]; - double JTC14 = J_pM[11] * cov5[6] + J_pM[18] * cov5[11]; - double JTC15 = J_pM[11] * cov5[11] + J_pM[18] * cov5[12]; - - // loops are vectorizable by the compiler! - for (int i=0; i<3; ++i) out7[i] = JTC0 * J_pM[21+i] + JTC1 * J_pM[28+i]; - for (int i=0; i<3; ++i) out7[3+i] = JTC2 * J_pM[10+i] + JTC3 * J_pM[17+i]; - out7[6] = J_pM[21] * cov5[15] + J_pM[28] * cov5[20]; - - for (int i=0; i<2; ++i) out7[8+i] = JTC4 * J_pM[22+i] + JTC5 * J_pM[29+i]; - for (int i=0; i<3; ++i) out7[10+i] = JTC6 * J_pM[10+i] + JTC7 * J_pM[17+i]; - out7[13] = J_pM[22] * cov5[15] + J_pM[29] * cov5[20]; - - out7[16] = JTC8 * J_pM[23] + JTC9 * J_pM[30]; - for (int i=0; i<3; ++i) out7[17+i] = JTC10 * J_pM[10+i] + JTC11 * J_pM[17+i]; - out7[20] = J_pM[23] * cov5[15] + J_pM[30] * cov5[20]; - - for (int i=0; i<3; ++i) out7[24+i] = JTC12 * J_pM[10+i] + JTC13 * J_pM[17+i]; - out7[27] = J_pM[10] * cov5[5] + J_pM[17] * cov5[10]; - - for (int i=0; i<2; ++i) out7[32+i] = JTC14 * J_pM[11+i] + JTC15 * J_pM[18+i]; - out7[34] = J_pM[11] * cov5[5] + J_pM[18] * cov5[10]; - - out7[40] = (J_pM[12] * cov5[6] + J_pM[19] * cov5[11]) * J_pM[12] + (J_pM[12] * cov5[11] + J_pM[19] * cov5[12]) * J_pM[19]; - out7[41] = J_pM[12] * cov5[5] + J_pM[19] * cov5[10]; - - out7[48] = cov5[0]; - - // symmetric part - out7[7] = out7[1]; - out7[14] = out7[2]; out7[15] = out7[9]; - out7[21] = out7[3]; out7[22] = out7[10]; out7[23] = out7[17]; - out7[28] = out7[4]; out7[29] = out7[11]; out7[30] = out7[18]; out7[31] = out7[25]; - out7[35] = out7[5]; out7[36] = out7[12]; out7[37] = out7[19]; out7[38] = out7[26]; out7[39] = out7[33]; - out7[42] = out7[6]; out7[43] = out7[13]; out7[44] = out7[20]; out7[45] = out7[27]; out7[46] = out7[34]; out7[47] = out7[41]; - -} - - -void RKTools::J_pMTxcov5xJ_pM(const M5x6& J_pM, const M5x5& cov5, M6x6& out6){ - - // 5D -> 6D - - // J_pM - // 0 0 0 x x x - // 0 0 0 x x x - // 0 0 0 x x x - // x x x 0 0 0 - // x x x 0 0 0 - - // it is assumed that J_pM is only non-zero here: - // [3] - // [4] - // [5] - - // [1*6+3] - // [1*6+4] - // [1*6+5] - - // [2*6+3] - // [2*6+4] - // [2*6+5] - - // [3*6+0] - // [3*6+1] - // [3*6+2] - - // [4*6+0] - // [4*6+1] - // [4*6+2] - - double JTC0 = J_pM[18] * cov5[15+3] + J_pM[24] * cov5[20+3]; - double JTC1 = J_pM[18] * cov5[20+3] + J_pM[24] * cov5[20+4]; - double JTC2 = J_pM[18] * cov5[15] + J_pM[24] * cov5[20]; - double JTC3 = J_pM[18] * cov5[15+1] + J_pM[24] * cov5[20+1]; - double JTC4 = J_pM[18] * cov5[15+2] + J_pM[24] * cov5[20+2]; - double JTC5 = J_pM[18+1] * cov5[15+3] + J_pM[24+1] * cov5[20+3]; - double JTC6 = J_pM[18+1] * cov5[20+3] + J_pM[24+1] * cov5[20+4]; - double JTC7 = J_pM[18+1] * cov5[15] + J_pM[24+1] * cov5[20]; - double JTC8 = J_pM[18+1] * cov5[15+1] + J_pM[24+1] * cov5[20+1]; - double JTC9 = J_pM[18+1] * cov5[15+2] + J_pM[24+1] * cov5[20+2]; - double JTC10 = J_pM[18+2] * cov5[15] + J_pM[24+2] * cov5[20]; - double JTC11 = J_pM[18+2] * cov5[15+1] + J_pM[24+2] * cov5[20+1]; - double JTC12 = J_pM[18+2] * cov5[15+2] + J_pM[24+2] * cov5[20+2]; - double JTC13 = J_pM[3] * cov5[0*5] + J_pM[6+3] * cov5[5] + J_pM[12+3] * cov5[10]; - double JTC14 = J_pM[3] * cov5[5] + J_pM[6+3] * cov5[5+1] + J_pM[12+3] * cov5[10+1]; - double JTC15 = J_pM[3] * cov5[10] + J_pM[6+3] * cov5[10+1] + J_pM[12+3] * cov5[10+2]; - double JTC16 = J_pM[4] * cov5[0*5] + J_pM[6+4] * cov5[5] + J_pM[12+4] * cov5[10]; - double JTC17 = J_pM[4] * cov5[5] + J_pM[6+4] * cov5[5+1] + J_pM[12+4] * cov5[10+1]; - double JTC18 = J_pM[4] * cov5[10] + J_pM[6+4] * cov5[10+1] + J_pM[12+4] * cov5[10+2]; - - // loops are vectorizable by the compiler! - for (int i=0; i<3; ++i) out6[i] = JTC0 * J_pM[18+i] + JTC1 * J_pM[24+i]; - for (int i=0; i<3; ++i) out6[3+i] = JTC2 * J_pM[3+i] + JTC3 * J_pM[9+i] + JTC4 * J_pM[15+i]; - - for (int i=0; i<2; ++i) out6[7+i] = JTC5 * J_pM[19+i] + JTC6 * J_pM[25+i]; - for (int i=0; i<3; ++i) out6[9+i] = JTC7 * J_pM[3+i] + JTC8 * J_pM[9+i] + JTC9 * J_pM[15+i]; - - out6[12+2] = (J_pM[18+2] * cov5[15+3] + J_pM[24+2] * cov5[20+3]) * J_pM[18+2] + (J_pM[18+2] * cov5[20+3] + J_pM[24+2] * cov5[20+4]) * J_pM[24+2]; - for (int i=0; i<3; ++i) out6[15+i] = JTC10 * J_pM[3+i] + JTC11 * J_pM[9+i] + JTC12 * J_pM[15+i]; - - for (int i=0; i<3; ++i) out6[21+i] = JTC13 * J_pM[3+i] + JTC14 * J_pM[9+i] + JTC15 * J_pM[15+i]; - - for (int i=0; i<3; ++i) out6[28+i] = JTC16 * J_pM[4+i] + JTC17 * J_pM[10+i] + JTC18 * J_pM[16+i]; - - out6[30+5] = (J_pM[5] * cov5[0*5] + J_pM[6+5] * cov5[5] + J_pM[12+5] * cov5[10]) * J_pM[5] + (J_pM[5] * cov5[5] + J_pM[6+5] * cov5[5+1] + J_pM[12+5] * cov5[10+1]) * J_pM[6+5] + (J_pM[5] * cov5[10] + J_pM[6+5] * cov5[10+1] + J_pM[12+5] * cov5[10+2]) * J_pM[12+5]; - - // symmetric part - out6[6] = out6[1]; - out6[12] = out6[2]; out6[12+1] = out6[6+2]; - out6[18] = out6[3]; out6[18+1] = out6[6+3]; out6[18+2] = out6[12+3]; - out6[24] = out6[4]; out6[24+1] = out6[6+4]; out6[24+2] = out6[12+4]; out6[24+3] = out6[18+4]; - out6[30] = out6[5]; out6[30+1] = out6[6+5]; out6[30+2] = out6[12+5]; out6[30+3] = out6[18+5]; out6[30+4] = out6[24+5]; - -} - - -void RKTools::J_MpTxcov7xJ_Mp(const M7x5& J_Mp, const M7x7& cov7, M5x5& out5) -{ - if (debugFlags & flagSlowMatrix) { - TMatrixD JMp(7, 5, (const double*)&J_Mp); - TMatrixD J7(7, 7, (const double*)&cov7); - TMatrixD result(JMp, TMatrixD::kTransposeMult, - TMatrixD(J7, TMatrixD::kMult, JMp)); - memcpy(out5, result.GetMatrixArray(), 5*5*sizeof(double)); - return; - } - - // 7D -> 5D - - // J_Mp - // 0 0 0 x x - // 0 0 0 x x - // 0 0 0 x x - // 0 x x 0 0 - // 0 x x 0 0 - // 0 x x 0 0 - // 1 0 0 0 0 - - // it is assumed that J_Mp is only non-zero here: - // [3] - // [1*7+3] - // [2*7+3] - - // [4] - // [1*7+4] - // [2*7+4] - - // [3*7+1] - // [4*7+1] - // [5*7+1] - - // [3*7+2] - // [4*7+2] - // [5*7+2] - - // [6*7+0] = 1 - - - double JTC0 = (J_Mp[16] * cov7[24] + J_Mp[21] * cov7[31] + J_Mp[26] * cov7[38]); - double JTC1 = (J_Mp[16] * cov7[31] + J_Mp[21] * cov7[32] + J_Mp[26] * cov7[39]); - double JTC2 = (J_Mp[16] * cov7[38] + J_Mp[21] * cov7[39] + J_Mp[26] * cov7[40]); - double JTC3 = (J_Mp[16] * cov7[21] + J_Mp[21] * cov7[28] + J_Mp[26] * cov7[35]); - double JTC4 = (J_Mp[16] * cov7[22] + J_Mp[21] * cov7[29] + J_Mp[26] * cov7[36]); - double JTC5 = (J_Mp[16] * cov7[23] + J_Mp[21] * cov7[30] + J_Mp[26] * cov7[37]); - double JTC6 = (J_Mp[17] * cov7[21] + J_Mp[22] * cov7[28] + J_Mp[27] * cov7[35]); - double JTC7 = (J_Mp[17] * cov7[22] + J_Mp[22] * cov7[29] + J_Mp[27] * cov7[36]); - double JTC8 = (J_Mp[17] * cov7[23] + J_Mp[22] * cov7[30] + J_Mp[27] * cov7[37]); - double JTC9 = (J_Mp[3] * cov7[0] + J_Mp[8] * cov7[7] + J_Mp[13] * cov7[14]); - double JTC10 = (J_Mp[3] * cov7[7] + J_Mp[8] * cov7[8] + J_Mp[13] * cov7[15]); - double JTC11 = (J_Mp[3] * cov7[14] + J_Mp[8] * cov7[15] + J_Mp[13] * cov7[16]); - - out5[0] = cov7[48]; - out5[1] = J_Mp[16] * cov7[45] + J_Mp[21] * cov7[46] + J_Mp[26] * cov7[47]; - out5[2] = J_Mp[17] * cov7[45] + J_Mp[22] * cov7[46] + J_Mp[27] * cov7[47]; - out5[3] = J_Mp[3] * cov7[42] + J_Mp[8] * cov7[43] + J_Mp[13] * cov7[44]; - out5[4] = J_Mp[4] * cov7[42] + J_Mp[9] * cov7[43] + J_Mp[14] * cov7[44]; - - // loops are vectorizable by the compiler! - for (int i=0; i<2; ++i) out5[6+i] = JTC0 * J_Mp[16+i] + JTC1 * J_Mp[21+i] + JTC2 * J_Mp[26+i]; - for (int i=0; i<2; ++i) out5[8+i] = JTC3 * J_Mp[3+i] + JTC4 * J_Mp[8+i] + JTC5 * J_Mp[13+i]; - - out5[12] = (J_Mp[17] * cov7[24] + J_Mp[22] * cov7[31] + J_Mp[27] * cov7[38]) * J_Mp[17] + (J_Mp[17] * cov7[31] + J_Mp[22] * cov7[32] + J_Mp[27] * cov7[39]) * J_Mp[22] + (J_Mp[17] * cov7[38] + J_Mp[22] * cov7[39] + J_Mp[27] * cov7[40]) * J_Mp[27]; - for (int i=0; i<2; ++i) out5[13+i] = JTC6 * J_Mp[3+i] + JTC7 * J_Mp[8+i] + JTC8 * J_Mp[13+i]; - - for (int i=0; i<2; ++i) out5[18+i] = JTC9 * J_Mp[3+i] + JTC10 * J_Mp[8+i] + JTC11 * J_Mp[13+i]; - - out5[24] = (J_Mp[4] * cov7[0] + J_Mp[9] * cov7[7] + J_Mp[14] * cov7[14]) * J_Mp[4] + (J_Mp[4] * cov7[7] + J_Mp[9] * cov7[8] + J_Mp[14] * cov7[15]) * J_Mp[9] + (J_Mp[4] * cov7[14] + J_Mp[9] * cov7[15] + J_Mp[14] * cov7[16]) * J_Mp[14]; - - // symmetric part - out5[5] = out5[1]; - out5[10] = out5[2]; out5[11] = out5[7]; - out5[15] = out5[3]; out5[16] = out5[8]; out5[17] = out5[13]; - out5[20] = out5[4]; out5[21] = out5[9]; out5[22] = out5[14]; out5[23] = out5[19]; - -} - - -void RKTools::J_MpTxcov6xJ_Mp(const M6x5& J_Mp, const M6x6& cov6, M5x5& out5) -{ - if (debugFlags & flagSlowMatrix) { - TMatrixD JMp(6, 5, (const double*)&J_Mp); - TMatrixD J7(6, 6, (const double*)&cov6); - TMatrixD result(JMp, TMatrixD::kTransposeMult, - TMatrixD(J7, TMatrixD::kMult, JMp)); - memcpy(out5, result.GetMatrixArray(), 5*5*sizeof(double)); - return; - } - - // 6D -> 5D - - // J_Mp - // 0 0 0 x x - // 0 0 0 x x - // 0 0 0 x x - // x x x 0 0 - // x x x 0 0 - // x x x 0 0 - - // it is assumed that J_Mp is only non-zero here: - // [3] - // [1*6+3] - // [2*6+3] - - // [4] - // [1*6+4] - // [2*6+4] - - // [3*6+0] - // [4*6+0] - // [5*6+0] - - // [3*6+1] - // [4*6+1] - // [5*6+1] - - // [3*6+2] - // [4*6+2] - // [5*6+2] - - double JTC0 = (J_Mp[15] * cov6[18+3] + J_Mp[20] * cov6[24+3] + J_Mp[25] * cov6[30+3]); - double JTC1 = (J_Mp[15] * cov6[24+3] + J_Mp[20] * cov6[24+4] + J_Mp[25] * cov6[30+4]); - double JTC2 = (J_Mp[15] * cov6[30+3] + J_Mp[20] * cov6[30+4] + J_Mp[25] * cov6[30+5]); - double JTC3 = (J_Mp[15] * cov6[18] + J_Mp[20] * cov6[24] + J_Mp[25] * cov6[30]); - double JTC4 = (J_Mp[15] * cov6[18+1] + J_Mp[20] * cov6[24+1] + J_Mp[25] * cov6[30+1]); - double JTC5 = (J_Mp[15] * cov6[18+2] + J_Mp[20] * cov6[24+2] + J_Mp[25] * cov6[30+2]); - double JTC6 = (J_Mp[15+1] * cov6[18+3] + J_Mp[20+1] * cov6[24+3] + J_Mp[25+1] * cov6[30+3]); - double JTC7 = (J_Mp[15+1] * cov6[24+3] + J_Mp[20+1] * cov6[24+4] + J_Mp[25+1] * cov6[30+4]); - double JTC8 = (J_Mp[15+1] * cov6[30+3] + J_Mp[20+1] * cov6[30+4] + J_Mp[25+1] * cov6[30+5]); - double JTC9 = (J_Mp[15+1] * cov6[18] + J_Mp[20+1] * cov6[24] + J_Mp[25+1] * cov6[30]); - double JTC10 = (J_Mp[15+1] * cov6[18+1] + J_Mp[20+1] * cov6[24+1] + J_Mp[25+1] * cov6[30+1]); - double JTC11 = (J_Mp[15+1] * cov6[18+2] + J_Mp[20+1] * cov6[24+2] + J_Mp[25+1] * cov6[30+2]); - double JTC12 = (J_Mp[15+2] * cov6[18] + J_Mp[20+2] * cov6[24] + J_Mp[25+2] * cov6[30]); - double JTC13 = (J_Mp[15+2] * cov6[18+1] + J_Mp[20+2] * cov6[24+1] + J_Mp[25+2] * cov6[30+1]); - double JTC14 = (J_Mp[15+2] * cov6[18+2] + J_Mp[20+2] * cov6[24+2] + J_Mp[25+2] * cov6[30+2]); - double JTC15 = (J_Mp[3] * cov6[0] + J_Mp[5+3] * cov6[6] + J_Mp[10+3] * cov6[12]); - double JTC16 = (J_Mp[3] * cov6[6] + J_Mp[5+3] * cov6[6+1] + J_Mp[10+3] * cov6[12+1]); - double JTC17 = (J_Mp[3] * cov6[12] + J_Mp[5+3] * cov6[12+1] + J_Mp[10+3] * cov6[12+2]); - - // loops are vectorizable by the compiler! - for (int i=0; i<3; ++i) out5[i] = JTC0 * J_Mp[15+i] + JTC1 * J_Mp[20+i] + JTC2 * J_Mp[25+i]; - for (int i=0; i<2; ++i) out5[3+i] = JTC3 * J_Mp[3+i] + JTC4 * J_Mp[8+i] + JTC5 * J_Mp[13+i]; - - for (int i=0; i<2; ++i) out5[6+i] = JTC6 * J_Mp[16+i] + JTC7 * J_Mp[21+i] + JTC8 * J_Mp[26+i]; - for (int i=0; i<2; ++i) out5[8+i] = JTC9 * J_Mp[3+i] + JTC10 * J_Mp[8+i] + JTC11 * J_Mp[13+i]; - - out5[10+2] = (J_Mp[15+2] * cov6[18+3] + J_Mp[20+2] * cov6[24+3] + J_Mp[25+2] * cov6[30+3]) * J_Mp[15+2] + (J_Mp[15+2] * cov6[24+3] + J_Mp[20+2] * cov6[24+4] + J_Mp[25+2] * cov6[30+4]) * J_Mp[20+2] + (J_Mp[15+2] * cov6[30+3] + J_Mp[20+2] * cov6[30+4] + J_Mp[25+2] * cov6[30+5]) * J_Mp[25+2]; - for (int i=0; i<2; ++i) out5[13+i] = JTC12 * J_Mp[3+i] + JTC13 * J_Mp[8+i] + JTC14 * J_Mp[13+i]; - - for (int i=0; i<2; ++i) out5[18+i] = JTC15 * J_Mp[3+i] + JTC16 * J_Mp[8+i] + JTC17 * J_Mp[13+i]; - - out5[20+4] = (J_Mp[4] * cov6[0] + J_Mp[5+4] * cov6[6] + J_Mp[10+4] * cov6[12]) * J_Mp[4] + (J_Mp[4] * cov6[6] + J_Mp[5+4] * cov6[6+1] + J_Mp[10+4] * cov6[12+1]) * J_Mp[5+4] + (J_Mp[4] * cov6[12] + J_Mp[5+4] * cov6[12+1] + J_Mp[10+4] * cov6[12+2]) * J_Mp[10+4]; - - // symmetric part - out5[5] = out5[1]; - out5[10] = out5[2]; out5[10+1] = out5[5+2]; - out5[15] = out5[3]; out5[15+1] = out5[5+3]; out5[15+2] = out5[10+3]; - out5[20] = out5[4]; out5[20+1] = out5[5+4]; out5[20+2] = out5[10+4]; out5[20+3] = out5[15+4]; - -} - - -void RKTools::J_MMTxcov7xJ_MM(const M7x7& J_MM, M7x7& cov7){ - - // it is assumed that the last column of J_MM is [0,0,0,0,0,0,1] - - double JTC0 = J_MM[0] * cov7[0] + J_MM[7] * cov7[7] + J_MM[14] * cov7[14] + J_MM[21] * cov7[21] + J_MM[28] * cov7[28] + J_MM[35] * cov7[35] + J_MM[42] * cov7[42]; - double JTC1 = J_MM[0] * cov7[7] + J_MM[7] * cov7[7+1] + J_MM[14] * cov7[14+1] + J_MM[21] * cov7[21+1] + J_MM[28] * cov7[28+1] + J_MM[35] * cov7[35+1] + J_MM[42] * cov7[42+1]; - double JTC2 = J_MM[0] * cov7[14] + J_MM[7] * cov7[14+1] + J_MM[14] * cov7[14+2] + J_MM[21] * cov7[21+2] + J_MM[28] * cov7[28+2] + J_MM[35] * cov7[35+2] + J_MM[42] * cov7[42+2]; - double JTC3 = J_MM[0] * cov7[21] + J_MM[7] * cov7[21+1] + J_MM[14] * cov7[21+2] + J_MM[21] * cov7[21+3] + J_MM[28] * cov7[28+3] + J_MM[35] * cov7[35+3] + J_MM[42] * cov7[42+3]; - double JTC4 = J_MM[0] * cov7[28] + J_MM[7] * cov7[28+1] + J_MM[14] * cov7[28+2] + J_MM[21] * cov7[28+3] + J_MM[28] * cov7[28+4] + J_MM[35] * cov7[35+4] + J_MM[42] * cov7[42+4]; - double JTC5 = J_MM[0] * cov7[35] + J_MM[7] * cov7[35+1] + J_MM[14] * cov7[35+2] + J_MM[21] * cov7[35+3] + J_MM[28] * cov7[35+4] + J_MM[35] * cov7[35+5] + J_MM[42] * cov7[42+5]; - double JTC6 = J_MM[0] * cov7[42] + J_MM[7] * cov7[42+1] + J_MM[14] * cov7[42+2] + J_MM[21] * cov7[42+3] + J_MM[28] * cov7[42+4] + J_MM[35] * cov7[42+5] + J_MM[42] * cov7[42+6]; - - double JTC7 = J_MM[1] * cov7[0] + J_MM[7+1] * cov7[7] + J_MM[14+1] * cov7[14] + J_MM[21+1] * cov7[21] + J_MM[28+1] * cov7[28] + J_MM[35+1] * cov7[35] + J_MM[42+1] * cov7[42]; - double JTC8 = J_MM[1] * cov7[7] + J_MM[7+1] * cov7[7+1] + J_MM[14+1] * cov7[14+1] + J_MM[21+1] * cov7[21+1] + J_MM[28+1] * cov7[28+1] + J_MM[35+1] * cov7[35+1] + J_MM[42+1] * cov7[42+1]; - double JTC9 = J_MM[1] * cov7[14] + J_MM[7+1] * cov7[14+1] + J_MM[14+1] * cov7[14+2] + J_MM[21+1] * cov7[21+2] + J_MM[28+1] * cov7[28+2] + J_MM[35+1] * cov7[35+2] + J_MM[42+1] * cov7[42+2]; - double JTC10 = J_MM[1] * cov7[21] + J_MM[7+1] * cov7[21+1] + J_MM[14+1] * cov7[21+2] + J_MM[21+1] * cov7[21+3] + J_MM[28+1] * cov7[28+3] + J_MM[35+1] * cov7[35+3] + J_MM[42+1] * cov7[42+3]; - double JTC11 = J_MM[1] * cov7[28] + J_MM[7+1] * cov7[28+1] + J_MM[14+1] * cov7[28+2] + J_MM[21+1] * cov7[28+3] + J_MM[28+1] * cov7[28+4] + J_MM[35+1] * cov7[35+4] + J_MM[42+1] * cov7[42+4]; - double JTC12 = J_MM[1] * cov7[35] + J_MM[7+1] * cov7[35+1] + J_MM[14+1] * cov7[35+2] + J_MM[21+1] * cov7[35+3] + J_MM[28+1] * cov7[35+4] + J_MM[35+1] * cov7[35+5] + J_MM[42+1] * cov7[42+5]; - double JTC13 = J_MM[1] * cov7[42] + J_MM[7+1] * cov7[42+1] + J_MM[14+1] * cov7[42+2] + J_MM[21+1] * cov7[42+3] + J_MM[28+1] * cov7[42+4] + J_MM[35+1] * cov7[42+5] + J_MM[42+1] * cov7[42+6]; - - double JTC14 = J_MM[2] * cov7[0] + J_MM[7+2] * cov7[7] + J_MM[14+2] * cov7[14] + J_MM[21+2] * cov7[21] + J_MM[28+2] * cov7[28] + J_MM[35+2] * cov7[35] + J_MM[42+2] * cov7[42]; - double JTC15 = J_MM[2] * cov7[7] + J_MM[7+2] * cov7[7+1] + J_MM[14+2] * cov7[14+1] + J_MM[21+2] * cov7[21+1] + J_MM[28+2] * cov7[28+1] + J_MM[35+2] * cov7[35+1] + J_MM[42+2] * cov7[42+1]; - double JTC16 = J_MM[2] * cov7[14] + J_MM[7+2] * cov7[14+1] + J_MM[14+2] * cov7[14+2] + J_MM[21+2] * cov7[21+2] + J_MM[28+2] * cov7[28+2] + J_MM[35+2] * cov7[35+2] + J_MM[42+2] * cov7[42+2]; - double JTC17 = J_MM[2] * cov7[21] + J_MM[7+2] * cov7[21+1] + J_MM[14+2] * cov7[21+2] + J_MM[21+2] * cov7[21+3] + J_MM[28+2] * cov7[28+3] + J_MM[35+2] * cov7[35+3] + J_MM[42+2] * cov7[42+3]; - double JTC18 = J_MM[2] * cov7[28] + J_MM[7+2] * cov7[28+1] + J_MM[14+2] * cov7[28+2] + J_MM[21+2] * cov7[28+3] + J_MM[28+2] * cov7[28+4] + J_MM[35+2] * cov7[35+4] + J_MM[42+2] * cov7[42+4]; - double JTC19 = J_MM[2] * cov7[35] + J_MM[7+2] * cov7[35+1] + J_MM[14+2] * cov7[35+2] + J_MM[21+2] * cov7[35+3] + J_MM[28+2] * cov7[35+4] + J_MM[35+2] * cov7[35+5] + J_MM[42+2] * cov7[42+5]; - double JTC20 = J_MM[2] * cov7[42] + J_MM[7+2] * cov7[42+1] + J_MM[14+2] * cov7[42+2] + J_MM[21+2] * cov7[42+3] + J_MM[28+2] * cov7[42+4] + J_MM[35+2] * cov7[42+5] + J_MM[42+2] * cov7[42+6]; - - double JTC21 = J_MM[3] * cov7[0] + J_MM[7+3] * cov7[7] + J_MM[14+3] * cov7[14] + J_MM[21+3] * cov7[21] + J_MM[28+3] * cov7[28] + J_MM[35+3] * cov7[35] + J_MM[42+3] * cov7[42]; - double JTC22 = J_MM[3] * cov7[7] + J_MM[7+3] * cov7[7+1] + J_MM[14+3] * cov7[14+1] + J_MM[21+3] * cov7[21+1] + J_MM[28+3] * cov7[28+1] + J_MM[35+3] * cov7[35+1] + J_MM[42+3] * cov7[42+1]; - double JTC23 = J_MM[3] * cov7[14] + J_MM[7+3] * cov7[14+1] + J_MM[14+3] * cov7[14+2] + J_MM[21+3] * cov7[21+2] + J_MM[28+3] * cov7[28+2] + J_MM[35+3] * cov7[35+2] + J_MM[42+3] * cov7[42+2]; - double JTC24 = J_MM[3] * cov7[21] + J_MM[7+3] * cov7[21+1] + J_MM[14+3] * cov7[21+2] + J_MM[21+3] * cov7[21+3] + J_MM[28+3] * cov7[28+3] + J_MM[35+3] * cov7[35+3] + J_MM[42+3] * cov7[42+3]; - double JTC25 = J_MM[3] * cov7[28] + J_MM[7+3] * cov7[28+1] + J_MM[14+3] * cov7[28+2] + J_MM[21+3] * cov7[28+3] + J_MM[28+3] * cov7[28+4] + J_MM[35+3] * cov7[35+4] + J_MM[42+3] * cov7[42+4]; - double JTC26 = J_MM[3] * cov7[35] + J_MM[7+3] * cov7[35+1] + J_MM[14+3] * cov7[35+2] + J_MM[21+3] * cov7[35+3] + J_MM[28+3] * cov7[35+4] + J_MM[35+3] * cov7[35+5] + J_MM[42+3] * cov7[42+5]; - double JTC27 = J_MM[3] * cov7[42] + J_MM[7+3] * cov7[42+1] + J_MM[14+3] * cov7[42+2] + J_MM[21+3] * cov7[42+3] + J_MM[28+3] * cov7[42+4] + J_MM[35+3] * cov7[42+5] + J_MM[42+3] * cov7[42+6]; - - double JTC28 = J_MM[4] * cov7[0] + J_MM[7+4] * cov7[7] + J_MM[14+4] * cov7[14] + J_MM[21+4] * cov7[21] + J_MM[28+4] * cov7[28] + J_MM[35+4] * cov7[35] + J_MM[42+4] * cov7[42]; - double JTC29 = J_MM[4] * cov7[7] + J_MM[7+4] * cov7[7+1] + J_MM[14+4] * cov7[14+1] + J_MM[21+4] * cov7[21+1] + J_MM[28+4] * cov7[28+1] + J_MM[35+4] * cov7[35+1] + J_MM[42+4] * cov7[42+1]; - double JTC30 = J_MM[4] * cov7[14] + J_MM[7+4] * cov7[14+1] + J_MM[14+4] * cov7[14+2] + J_MM[21+4] * cov7[21+2] + J_MM[28+4] * cov7[28+2] + J_MM[35+4] * cov7[35+2] + J_MM[42+4] * cov7[42+2]; - double JTC31 = J_MM[4] * cov7[21] + J_MM[7+4] * cov7[21+1] + J_MM[14+4] * cov7[21+2] + J_MM[21+4] * cov7[21+3] + J_MM[28+4] * cov7[28+3] + J_MM[35+4] * cov7[35+3] + J_MM[42+4] * cov7[42+3]; - double JTC32 = J_MM[4] * cov7[28] + J_MM[7+4] * cov7[28+1] + J_MM[14+4] * cov7[28+2] + J_MM[21+4] * cov7[28+3] + J_MM[28+4] * cov7[28+4] + J_MM[35+4] * cov7[35+4] + J_MM[42+4] * cov7[42+4]; - double JTC33 = J_MM[4] * cov7[35] + J_MM[7+4] * cov7[35+1] + J_MM[14+4] * cov7[35+2] + J_MM[21+4] * cov7[35+3] + J_MM[28+4] * cov7[35+4] + J_MM[35+4] * cov7[35+5] + J_MM[42+4] * cov7[42+5]; - double JTC34 = J_MM[4] * cov7[42] + J_MM[7+4] * cov7[42+1] + J_MM[14+4] * cov7[42+2] + J_MM[21+4] * cov7[42+3] + J_MM[28+4] * cov7[42+4] + J_MM[35+4] * cov7[42+5] + J_MM[42+4] * cov7[42+6]; - - double out7_40 = (J_MM[5] * cov7[0] + J_MM[7+5] * cov7[7] + J_MM[14+5] * cov7[14] + J_MM[21+5] * cov7[21] + J_MM[28+5] * cov7[28] + J_MM[35+5] * cov7[35] + J_MM[42+5] * cov7[42]) * J_MM[5] + (J_MM[5] * cov7[7] + J_MM[7+5] * cov7[7+1] + J_MM[14+5] * cov7[14+1] + J_MM[21+5] * cov7[21+1] + J_MM[28+5] * cov7[28+1] + J_MM[35+5] * cov7[35+1] + J_MM[42+5] * cov7[42+1]) * J_MM[7+5] + (J_MM[5] * cov7[14] + J_MM[7+5] * cov7[14+1] + J_MM[14+5] * cov7[14+2] + J_MM[21+5] * cov7[21+2] + J_MM[28+5] * cov7[28+2] + J_MM[35+5] * cov7[35+2] + J_MM[42+5] * cov7[42+2]) * J_MM[14+5] + (J_MM[5] * cov7[21] + J_MM[7+5] * cov7[21+1] + J_MM[14+5] * cov7[21+2] + J_MM[21+5] * cov7[21+3] + J_MM[28+5] * cov7[28+3] + J_MM[35+5] * cov7[35+3] + J_MM[42+5] * cov7[42+3]) * J_MM[21+5] + (J_MM[5] * cov7[28] + J_MM[7+5] * cov7[28+1] + J_MM[14+5] * cov7[28+2] + J_MM[21+5] * cov7[28+3] + J_MM[28+5] * cov7[28+4] + J_MM[35+5] * cov7[35+4] + J_MM[42+5] * cov7[42+4]) * J_MM[28+5] + (J_MM[5] * cov7[35] + J_MM[7+5] * cov7[35+1] + J_MM[14+5] * cov7[35+2] + J_MM[21+5] * cov7[35+3] + J_MM[28+5] * cov7[35+4] + J_MM[35+5] * cov7[35+5] + J_MM[42+5] * cov7[42+5]) * J_MM[35+5] + (J_MM[5] * cov7[42] + J_MM[7+5] * cov7[42+1] + J_MM[14+5] * cov7[42+2] + J_MM[21+5] * cov7[42+3] + J_MM[28+5] * cov7[42+4] + J_MM[35+5] * cov7[42+5] + J_MM[42+5] * cov7[42+6]) * J_MM[42+5]; - - // last row - cov7[6] = JTC6; - cov7[7+6] = JTC13; - cov7[14+6] = JTC20; - cov7[21+6] = JTC27; - cov7[28+6] = JTC34; - cov7[35+6] = J_MM[5] * cov7[42] + J_MM[7+5] * cov7[42+1] + J_MM[14+5] * cov7[42+2] + J_MM[21+5] * cov7[42+3] + J_MM[28+5] * cov7[42+4] + J_MM[35+5] * cov7[42+5] + J_MM[42+5] * cov7[42+6]; - //cov7[42+6] = cov7[42+6]; - - // loops are vectorizable by the compiler! - for (int i=0; i<6; ++i) cov7[i] = JTC0 * J_MM[i] + JTC1 * J_MM[7+i] + JTC2 * J_MM[14+i] + JTC3 * J_MM[21+i] + JTC4 * J_MM[28+i] + JTC5 * J_MM[35+i] + JTC6 * J_MM[42+i]; - for (int i=1; i<6; ++i) cov7[7+i] = JTC7 * J_MM[i] + JTC8 * J_MM[7+i] + JTC9 * J_MM[14+i] + JTC10 * J_MM[21+i] + JTC11 * J_MM[28+i] + JTC12 * J_MM[35+i] + JTC13 * J_MM[42+i]; - for (int i=2; i<6; ++i) cov7[14+i] = JTC14 * J_MM[i] + JTC15 * J_MM[7+i] + JTC16 * J_MM[14+i] + JTC17 * J_MM[21+i] + JTC18 * J_MM[28+i] + JTC19 * J_MM[35+i] + JTC20 * J_MM[42+i]; - for (int i=3; i<6; ++i) cov7[21+i] = JTC21 * J_MM[i] + JTC22 * J_MM[7+i] + JTC23 * J_MM[14+i] + JTC24 * J_MM[21+i] + JTC25 * J_MM[28+i] + JTC26 * J_MM[35+i] + JTC27 * J_MM[42+i]; - for (int i=4; i<6; ++i) cov7[28+i] = JTC28 * J_MM[i] + JTC29 * J_MM[7+i] + JTC30 * J_MM[14+i] + JTC31 * J_MM[21+i] + JTC32 * J_MM[28+i] + JTC33 * J_MM[35+i] + JTC34 * J_MM[42+i]; - cov7[35+5] = out7_40; - - // symmetric part - cov7[7] = cov7[1]; - cov7[14] = cov7[2]; cov7[14+1] = cov7[9]; - cov7[21] = cov7[3]; cov7[21+1] = cov7[10]; cov7[21+2] = cov7[17]; - cov7[28] = cov7[4]; cov7[28+1] = cov7[11]; cov7[28+2] = cov7[18]; cov7[28+3] = cov7[25]; - cov7[35] = cov7[5]; cov7[35+1] = cov7[12]; cov7[35+2] = cov7[19]; cov7[35+3] = cov7[26]; cov7[35+4] = cov7[33]; - cov7[42] = cov7[6]; cov7[42+1] = cov7[13]; cov7[42+2] = cov7[20]; cov7[42+3] = cov7[27]; cov7[42+4] = cov7[34]; cov7[42+5] = cov7[41]; - -} - - -void RKTools::J_MMxJ_MM(M7x7& J_MM, const M7x7& J_MM_old){ - - // J and J_old are - // 1 0 0 0 0 0 0 - // 0 1 0 0 0 0 0 - // 0 0 1 0 0 0 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x x - - M7x7 J_MM_temp; - memcpy(J_MM_temp, J_MM, 7*7*sizeof(double)); - - /*J_MM[0] = 1; - J_MM[1] = 0; - J_MM[2] = 0; - J_MM[3] = 0; - J_MM[4] = 0; - J_MM[5] = 0; - J_MM[6] = 0; - - J_MM[1*7+0] = 0; - J_MM[1*7+1] = 1; - J_MM[1*7+2] = 0; - J_MM[1*7+3] = 0; - J_MM[1*7+4] = 0; - J_MM[1*7+5] = 0; - J_MM[1*7+6] = 0; - - J_MM[2*7+0] = 0; - J_MM[2*7+1] = 0; - J_MM[2*7+2] = 1; - J_MM[2*7+3] = 0; - J_MM[2*7+4] = 0; - J_MM[2*7+5] = 0; - J_MM[2*7+6] = 0;*/ - - J_MM[21] = J_MM_old[21] + J_MM_old[21+3] * J_MM_temp[21] + J_MM_old[21+4] * J_MM_temp[28] + J_MM_old[21+5] * J_MM_temp[35]; - J_MM[21+1] = J_MM_old[21+1] + J_MM_old[21+3] * J_MM_temp[21+1] + J_MM_old[21+4] * J_MM_temp[28+1] + J_MM_old[21+5] * J_MM_temp[35+1]; - J_MM[21+2] = J_MM_old[21+2] + J_MM_old[21+3] * J_MM_temp[21+2] + J_MM_old[21+4] * J_MM_temp[28+2] + J_MM_old[21+5] * J_MM_temp[35+2]; - J_MM[21+3] = J_MM_old[21+3] * J_MM_temp[21+3] + J_MM_old[21+4] * J_MM_temp[28+3] + J_MM_old[21+5] * J_MM_temp[35+3]; - J_MM[21+4] = J_MM_old[21+3] * J_MM_temp[21+4] + J_MM_old[21+4] * J_MM_temp[28+4] + J_MM_old[21+5] * J_MM_temp[35+4]; - J_MM[21+5] = J_MM_old[21+3] * J_MM_temp[21+5] + J_MM_old[21+4] * J_MM_temp[28+5] + J_MM_old[21+5] * J_MM_temp[35+5]; - //J_MM[21+6] = 0; - - J_MM[28] = J_MM_old[28] + J_MM_old[28+3] * J_MM_temp[21] + J_MM_old[28+4] * J_MM_temp[28] + J_MM_old[28+5] * J_MM_temp[35]; - J_MM[28+1] = J_MM_old[28+1] + J_MM_old[28+3] * J_MM_temp[21+1] + J_MM_old[28+4] * J_MM_temp[28+1] + J_MM_old[28+5] * J_MM_temp[35+1]; - J_MM[28+2] = J_MM_old[28+2] + J_MM_old[28+3] * J_MM_temp[21+2] + J_MM_old[28+4] * J_MM_temp[28+2] + J_MM_old[28+5] * J_MM_temp[35+2]; - J_MM[28+3] = J_MM_old[28+3] * J_MM_temp[21+3] + J_MM_old[28+4] * J_MM_temp[28+3] + J_MM_old[28+5] * J_MM_temp[35+3]; - J_MM[28+4] = J_MM_old[28+3] * J_MM_temp[21+4] + J_MM_old[28+4] * J_MM_temp[28+4] + J_MM_old[28+5] * J_MM_temp[35+4]; - J_MM[28+5] = J_MM_old[28+3] * J_MM_temp[21+5] + J_MM_old[28+4] * J_MM_temp[28+5] + J_MM_old[28+5] * J_MM_temp[35+5]; - //J_MM[28+6] = 0; - - J_MM[35] = J_MM_old[35] + J_MM_old[35+3] * J_MM_temp[21] + J_MM_old[35+4] * J_MM_temp[28] + J_MM_old[35+5] * J_MM_temp[35] ; - J_MM[35+1] = J_MM_old[35+1] + J_MM_old[35+3] * J_MM_temp[21+1] + J_MM_old[35+4] * J_MM_temp[28+1] + J_MM_old[35+5] * J_MM_temp[35+1]; - J_MM[35+2] = J_MM_old[35+2] + J_MM_old[35+3] * J_MM_temp[21+2] + J_MM_old[35+4] * J_MM_temp[28+2] + J_MM_old[35+5] * J_MM_temp[35+2]; - J_MM[35+3] = J_MM_old[35+3] * J_MM_temp[21+3] + J_MM_old[35+4] * J_MM_temp[28+3] + J_MM_old[35+5] * J_MM_temp[35+3]; - J_MM[35+4] = J_MM_old[35+3] * J_MM_temp[21+4] + J_MM_old[35+4] * J_MM_temp[28+4] + J_MM_old[35+5] * J_MM_temp[35+4]; - J_MM[35+5] = J_MM_old[35+3] * J_MM_temp[21+5] + J_MM_old[35+4] * J_MM_temp[28+5] + J_MM_old[35+5] * J_MM_temp[35+5]; - //J_MM[35+6] = 0; - - J_MM[42] = J_MM_old[42] + J_MM_old[42+3] * J_MM_temp[21] + J_MM_old[42+4] * J_MM_temp[28] + J_MM_old[42+5] * J_MM_temp[35] + J_MM_old[42+6] * J_MM_temp[42]; - J_MM[42+1] = J_MM_old[42+1] + J_MM_old[42+3] * J_MM_temp[21+1] + J_MM_old[42+4] * J_MM_temp[28+1] + J_MM_old[42+5] * J_MM_temp[35+1] + J_MM_old[42+6] * J_MM_temp[42+1]; - J_MM[42+2] = J_MM_old[42+2] + J_MM_old[42+3] * J_MM_temp[21+2] + J_MM_old[42+4] * J_MM_temp[28+2] + J_MM_old[42+5] * J_MM_temp[35+2] + J_MM_old[42+6] * J_MM_temp[42+2]; - J_MM[42+3] = J_MM_old[42+3] * J_MM_temp[21+3] + J_MM_old[42+4] * J_MM_temp[28+3] + J_MM_old[42+5] * J_MM_temp[35+3] + J_MM_old[42+6] * J_MM_temp[42+3]; - J_MM[42+4] = J_MM_old[42+3] * J_MM_temp[21+4] + J_MM_old[42+4] * J_MM_temp[28+4] + J_MM_old[42+5] * J_MM_temp[35+4] + J_MM_old[42+6] * J_MM_temp[42+4]; - J_MM[42+5] = J_MM_old[42+3] * J_MM_temp[21+5] + J_MM_old[42+4] * J_MM_temp[28+5] + J_MM_old[42+5] * J_MM_temp[35+5] + J_MM_old[42+6] * J_MM_temp[42+5]; - J_MM[42+6] = J_MM_old[42+6] * J_MM_temp[42+6]; - -} - - -void RKTools::J_pMTTxJ_MMTTxJ_MpTT(const M7x5& J_pMT, const M7x7& J_MMT, const M5x7& J_MpT, M5x5& J_pp) -{ - // calculates J_pp = J_pM * J_MM * J_Mp - // input J_MMT is transposed version of actual jacobian J_MM - // input J_pMT is transposed version of actual jacobian J_pM (Master to plane) - // input J_MpT is transposed version of actual jacobian J_Mp (plane to Master) - - if (debugFlags & flagSlowMatrix) { - TMatrixD JpMT(7, 5, (const double*)&J_pMT); - TMatrixD J7(7, 7, (const double*)&J_MMT); - TMatrixD JMpT(5, 7, (const double*)&J_MpT); - TMatrixD result(TMatrixD::kTransposed, - TMatrixD(JMpT, TMatrixD::kMult, - TMatrixD(J7, TMatrixD::kMult, JpMT))); - - memcpy(J_pp, result.GetMatrixArray(), 5*5*sizeof(double)); - return; - } - - - // J_pMT - // 0 0 0 x x - // 0 0 0 x x - // 0 0 0 x x - // 0 x x 0 0 - // 0 x x 0 0 - // 0 x x 0 0 - // 1 0 0 0 0 - - // J_MMT if MMproj == true - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x x - - // J_MpT - // 0 0 0 0 0 0 1 - // 0 0 0 x x x 0 - // 0 0 0 x x x 0 - // x x x 0 0 0 0 - // x x x 0 0 0 0 - - - J_pp[0*5+0] = J_MMT[6*7+6]; - J_pp[0*5+1] = 0; - J_pp[0*5+2] = 0; - J_pp[0*5+3] = 0; - J_pp[0*5+4] = 0; - - J_pp[1*5+0] = J_pMT[3*5+1] * J_MMT[6*7+3] + J_pMT[4*5+1] * J_MMT[6*7+4] + J_pMT[5*5+1] * J_MMT[6*7+5]; - J_pp[1*5+1] = ( (J_pMT[3*5+1] * J_MMT[3*7+3] + J_pMT[4*5+1] * J_MMT[3*7+4] + J_pMT[5*5+1] * J_MMT[3*7+5]) * J_MpT[1*7+3] - + (J_pMT[3*5+1] * J_MMT[4*7+3] + J_pMT[4*5+1] * J_MMT[4*7+4] + J_pMT[5*5+1] * J_MMT[4*7+5]) * J_MpT[1*7+4] - + (J_pMT[3*5+1] * J_MMT[5*7+3] + J_pMT[4*5+1] * J_MMT[5*7+4] + J_pMT[5*5+1] * J_MMT[5*7+5]) * J_MpT[1*7+5]); - J_pp[1*5+2] = ( (J_pMT[3*5+1] * J_MMT[3*7+3] + J_pMT[4*5+1] * J_MMT[3*7+4] + J_pMT[5*5+1] * J_MMT[3*7+5]) * J_MpT[2*7+3] - + (J_pMT[3*5+1] * J_MMT[4*7+3] + J_pMT[4*5+1] * J_MMT[4*7+4] + J_pMT[5*5+1] * J_MMT[4*7+5]) * J_MpT[2*7+4] - + (J_pMT[3*5+1] * J_MMT[5*7+3] + J_pMT[4*5+1] * J_MMT[5*7+4] + J_pMT[5*5+1] * J_MMT[5*7+5]) * J_MpT[2*7+5]); - J_pp[1*5+3] = ( (J_pMT[3*5+1] * J_MMT[0*7+3] + J_pMT[4*5+1] * J_MMT[0*7+4] + J_pMT[5*5+1] * J_MMT[0*7+5]) * J_MpT[3*7+0] - + (J_pMT[3*5+1] * J_MMT[1*7+3] + J_pMT[4*5+1] * J_MMT[1*7+4] + J_pMT[5*5+1] * J_MMT[1*7+5]) * J_MpT[3*7+1] - + (J_pMT[3*5+1] * J_MMT[2*7+3] + J_pMT[4*5+1] * J_MMT[2*7+4] + J_pMT[5*5+1] * J_MMT[2*7+5]) * J_MpT[3*7+2]); - J_pp[1*5+4] = ( (J_pMT[3*5+1] * J_MMT[0*7+3] + J_pMT[4*5+1] * J_MMT[0*7+4] + J_pMT[5*5+1] * J_MMT[0*7+5]) * J_MpT[4*7+0] - + (J_pMT[3*5+1] * J_MMT[1*7+3] + J_pMT[4*5+1] * J_MMT[1*7+4] + J_pMT[5*5+1] * J_MMT[1*7+5]) * J_MpT[4*7+1] - + (J_pMT[3*5+1] * J_MMT[2*7+3] + J_pMT[4*5+1] * J_MMT[2*7+4] + J_pMT[5*5+1] * J_MMT[2*7+5]) * J_MpT[4*7+2]); - - J_pp[2*5+0] = J_pMT[3*5+2] * J_MMT[6*7+3] + J_pMT[4*5+2] * J_MMT[6*7+4] + J_pMT[5*5+2] * J_MMT[6*7+5]; - J_pp[2*5+1] = ( (J_pMT[3*5+2] * J_MMT[3*7+3] + J_pMT[4*5+2] * J_MMT[3*7+4] + J_pMT[5*5+2] * J_MMT[3*7+5]) * J_MpT[1*7+3] - + (J_pMT[3*5+2] * J_MMT[4*7+3] + J_pMT[4*5+2] * J_MMT[4*7+4] + J_pMT[5*5+2] * J_MMT[4*7+5]) * J_MpT[1*7+4] - + (J_pMT[3*5+2] * J_MMT[5*7+3] + J_pMT[4*5+2] * J_MMT[5*7+4] + J_pMT[5*5+2] * J_MMT[5*7+5]) * J_MpT[1*7+5]); - J_pp[2*5+2] = ( (J_pMT[3*5+2] * J_MMT[3*7+3] + J_pMT[4*5+2] * J_MMT[3*7+4] + J_pMT[5*5+2] * J_MMT[3*7+5]) * J_MpT[2*7+3] - + (J_pMT[3*5+2] * J_MMT[4*7+3] + J_pMT[4*5+2] * J_MMT[4*7+4] + J_pMT[5*5+2] * J_MMT[4*7+5]) * J_MpT[2*7+4] - + (J_pMT[3*5+2] * J_MMT[5*7+3] + J_pMT[4*5+2] * J_MMT[5*7+4] + J_pMT[5*5+2] * J_MMT[5*7+5]) * J_MpT[2*7+5]); - J_pp[2*5+3] = ( (J_pMT[3*5+2] * J_MMT[0*7+3] + J_pMT[4*5+2] * J_MMT[0*7+4] + J_pMT[5*5+2] * J_MMT[0*7+5]) * J_MpT[3*7+0] - + (J_pMT[3*5+2] * J_MMT[1*7+3] + J_pMT[4*5+2] * J_MMT[1*7+4] + J_pMT[5*5+2] * J_MMT[1*7+5]) * J_MpT[3*7+1] - + (J_pMT[3*5+2] * J_MMT[2*7+3] + J_pMT[4*5+2] * J_MMT[2*7+4] + J_pMT[5*5+2] * J_MMT[2*7+5]) * J_MpT[3*7+2]); - J_pp[2*5+4] = ( (J_pMT[3*5+2] * J_MMT[0*7+3] + J_pMT[4*5+2] * J_MMT[0*7+4] + J_pMT[5*5+2] * J_MMT[0*7+5]) * J_MpT[4*7+0] - + (J_pMT[3*5+2] * J_MMT[1*7+3] + J_pMT[4*5+2] * J_MMT[1*7+4] + J_pMT[5*5+2] * J_MMT[1*7+5]) * J_MpT[4*7+1] - + (J_pMT[3*5+2] * J_MMT[2*7+3] + J_pMT[4*5+2] * J_MMT[2*7+4] + J_pMT[5*5+2] * J_MMT[2*7+5]) * J_MpT[4*7+2]); - - J_pp[3*5+0] = J_pMT[0*5+3] * J_MMT[6*7+0] + J_pMT[1*5+3] * J_MMT[6*7+1] + J_pMT[2*5+3] * J_MMT[6*7+2]; - J_pp[3*5+1] = ( (J_pMT[0*5+3] * J_MMT[3*7+0] + J_pMT[1*5+3] * J_MMT[3*7+1] + J_pMT[2*5+3] * J_MMT[3*7+2]) * J_MpT[1*7+3] - + (J_pMT[0*5+3] * J_MMT[4*7+0] + J_pMT[1*5+3] * J_MMT[4*7+1] + J_pMT[2*5+3] * J_MMT[4*7+2]) * J_MpT[1*7+4] - + (J_pMT[0*5+3] * J_MMT[5*7+0] + J_pMT[1*5+3] * J_MMT[5*7+1] + J_pMT[2*5+3] * J_MMT[5*7+2]) * J_MpT[1*7+5]); - J_pp[3*5+2] = ( (J_pMT[0*5+3] * J_MMT[3*7+0] + J_pMT[1*5+3] * J_MMT[3*7+1] + J_pMT[2*5+3] * J_MMT[3*7+2]) * J_MpT[2*7+3] - + (J_pMT[0*5+3] * J_MMT[4*7+0] + J_pMT[1*5+3] * J_MMT[4*7+1] + J_pMT[2*5+3] * J_MMT[4*7+2]) * J_MpT[2*7+4] - + (J_pMT[0*5+3] * J_MMT[5*7+0] + J_pMT[1*5+3] * J_MMT[5*7+1] + J_pMT[2*5+3] * J_MMT[5*7+2]) * J_MpT[2*7+5]); - J_pp[3*5+3] = ( (J_pMT[0*5+3] * J_MMT[0*7+0] + J_pMT[1*5+3] * J_MMT[0*7+1] + J_pMT[2*5+3] * J_MMT[0*7+2]) * J_MpT[3*7+0] - + (J_pMT[0*5+3] * J_MMT[1*7+0] + J_pMT[1*5+3] * J_MMT[1*7+1] + J_pMT[2*5+3] * J_MMT[1*7+2]) * J_MpT[3*7+1] - + (J_pMT[0*5+3] * J_MMT[2*7+0] + J_pMT[1*5+3] * J_MMT[2*7+1] + J_pMT[2*5+3] * J_MMT[2*7+2]) * J_MpT[3*7+2]); - J_pp[3*5+4] = ( (J_pMT[0*5+3] * J_MMT[0*7+0] + J_pMT[1*5+3] * J_MMT[0*7+1] + J_pMT[2*5+3] * J_MMT[0*7+2]) * J_MpT[4*7+0] - + (J_pMT[0*5+3] * J_MMT[1*7+0] + J_pMT[1*5+3] * J_MMT[1*7+1] + J_pMT[2*5+3] * J_MMT[1*7+2]) * J_MpT[4*7+1] - + (J_pMT[0*5+3] * J_MMT[2*7+0] + J_pMT[1*5+3] * J_MMT[2*7+1] + J_pMT[2*5+3] * J_MMT[2*7+2]) * J_MpT[4*7+2]); - - J_pp[4*5+0] = J_pMT[0*5+4] * J_MMT[6*7+0] + J_pMT[1*5+4] * J_MMT[6*7+1] + J_pMT[2*5+4] * J_MMT[6*7+2]; - J_pp[4*5+1] = ( (J_pMT[0*5+4] * J_MMT[3*7+0] + J_pMT[1*5+4] * J_MMT[3*7+1] + J_pMT[2*5+4] * J_MMT[3*7+2]) * J_MpT[1*7+3] - + (J_pMT[0*5+4] * J_MMT[4*7+0] + J_pMT[1*5+4] * J_MMT[4*7+1] + J_pMT[2*5+4] * J_MMT[4*7+2]) * J_MpT[1*7+4] - + (J_pMT[0*5+4] * J_MMT[5*7+0] + J_pMT[1*5+4] * J_MMT[5*7+1] + J_pMT[2*5+4] * J_MMT[5*7+2]) * J_MpT[1*7+5]); - J_pp[4*5+2] = ( (J_pMT[0*5+4] * J_MMT[3*7+0] + J_pMT[1*5+4] * J_MMT[3*7+1] + J_pMT[2*5+4] * J_MMT[3*7+2]) * J_MpT[2*7+3] - + (J_pMT[0*5+4] * J_MMT[4*7+0] + J_pMT[1*5+4] * J_MMT[4*7+1] + J_pMT[2*5+4] * J_MMT[4*7+2]) * J_MpT[2*7+4] - + (J_pMT[0*5+4] * J_MMT[5*7+0] + J_pMT[1*5+4] * J_MMT[5*7+1] + J_pMT[2*5+4] * J_MMT[5*7+2]) * J_MpT[2*7+5]); - J_pp[4*5+3] = ( (J_pMT[0*5+4] * J_MMT[0*7+0] + J_pMT[1*5+4] * J_MMT[0*7+1] + J_pMT[2*5+4] * J_MMT[0*7+2]) * J_MpT[3*7+0] - + (J_pMT[0*5+4] * J_MMT[1*7+0] + J_pMT[1*5+4] * J_MMT[1*7+1] + J_pMT[2*5+4] * J_MMT[1*7+2]) * J_MpT[3*7+1] - + (J_pMT[0*5+4] * J_MMT[2*7+0] + J_pMT[1*5+4] * J_MMT[2*7+1] + J_pMT[2*5+4] * J_MMT[2*7+2]) * J_MpT[3*7+2]); - J_pp[4*5+4] = ( (J_pMT[0*5+4] * J_MMT[0*7+0] + J_pMT[1*5+4] * J_MMT[0*7+1] + J_pMT[2*5+4] * J_MMT[0*7+2]) * J_MpT[4*7+0] - + (J_pMT[0*5+4] * J_MMT[1*7+0] + J_pMT[1*5+4] * J_MMT[1*7+1] + J_pMT[2*5+4] * J_MMT[1*7+2]) * J_MpT[4*7+1] - + (J_pMT[0*5+4] * J_MMT[2*7+0] + J_pMT[1*5+4] * J_MMT[2*7+1] + J_pMT[2*5+4] * J_MMT[2*7+2]) * J_MpT[4*7+2]); -} - - -void RKTools::Np_N_NpT(const M7x7& Np, M7x7& N) { - - // N is symmetric - - // Np - // x x x 0 0 0 0 - // x x x 0 0 0 0 - // x x x 0 0 0 0 - // x x x 1 0 0 0 - // x x x 0 1 0 0 - // x x x 0 0 1 0 - // 0 0 0 0 0 0 1 - - // calculate: - // Np * N * Np^T - - if (debugFlags & flagSlowMatrix) { - TMatrixDSym n(7,N); - TMatrixD np(7,7,Np); - n.Similarity(np); - memcpy(N, np.GetMatrixArray(), sizeof(M7x7)); - return; - } - - double N00(N[0*7+0]), N11(N[1*7+1]), N22(N[2*7+2]), N33(N[3*7+3]), N44(N[4*7+4]), N55(N[5*7+5]); - - // replace lower left triangle using the original values from upper right triangle plus the cached diagonal values - N[0*7+0] = (Np[0*7+0] * N00 + Np[0*7+1] * N[0*7+1] + Np[0*7+2] * N[0*7+2]) * Np[0*7+0] + (Np[0*7+0] * N[0*7+1] + Np[0*7+1] * N11 + Np[0*7+2] * N[1*7+2]) * Np[0*7+1] + (Np[0*7+0] * N[0*7+2] + Np[0*7+1] * N[1*7+2] + Np[0*7+2] * N22) * Np[0*7+2]; - - N[1*7+0] = (Np[1*7+0] * N00 + Np[1*7+1] * N[0*7+1] + Np[1*7+2] * N[0*7+2]) * Np[0*7+0] + (Np[1*7+0] * N[0*7+1] + Np[1*7+1] * N11 + Np[1*7+2] * N[1*7+2]) * Np[0*7+1] + (Np[1*7+0] * N[0*7+2] + Np[1*7+1] * N[1*7+2] + Np[1*7+2] * N22) * Np[0*7+2]; - N[1*7+1] = (Np[1*7+0] * N00 + Np[1*7+1] * N[0*7+1] + Np[1*7+2] * N[0*7+2]) * Np[1*7+0] + (Np[1*7+0] * N[0*7+1] + Np[1*7+1] * N11 + Np[1*7+2] * N[1*7+2]) * Np[1*7+1] + (Np[1*7+0] * N[0*7+2] + Np[1*7+1] * N[1*7+2] + Np[1*7+2] * N22) * Np[1*7+2]; - - N[2*7+0] = (Np[2*7+0] * N00 + Np[2*7+1] * N[0*7+1] + Np[2*7+2] * N[0*7+2]) * Np[0*7+0] + (Np[2*7+0] * N[0*7+1] + Np[2*7+1] * N11 + Np[2*7+2] * N[1*7+2]) * Np[0*7+1] + (Np[2*7+0] * N[0*7+2] + Np[2*7+1] * N[1*7+2] + Np[2*7+2] * N22) * Np[0*7+2]; - N[2*7+1] = (Np[2*7+0] * N00 + Np[2*7+1] * N[0*7+1] + Np[2*7+2] * N[0*7+2]) * Np[1*7+0] + (Np[2*7+0] * N[0*7+1] + Np[2*7+1] * N11 + Np[2*7+2] * N[1*7+2]) * Np[1*7+1] + (Np[2*7+0] * N[0*7+2] + Np[2*7+1] * N[1*7+2] + Np[2*7+2] * N22) * Np[1*7+2]; - N[2*7+2] = (Np[2*7+0] * N00 + Np[2*7+1] * N[0*7+1] + Np[2*7+2] * N[0*7+2]) * Np[2*7+0] + (Np[2*7+0] * N[0*7+1] + Np[2*7+1] * N11 + Np[2*7+2] * N[1*7+2]) * Np[2*7+1] + (Np[2*7+0] * N[0*7+2] + Np[2*7+1] * N[1*7+2] + Np[2*7+2] * N22) * Np[2*7+2]; - - N[3*7+0] = (Np[3*7+0] * N00 + Np[3*7+1] * N[0*7+1] + Np[3*7+2] * N[0*7+2] + N[0*7+3]) * Np[0*7+0] + (Np[3*7+0] * N[0*7+1] + Np[3*7+1] * N11 + Np[3*7+2] * N[1*7+2] + N[1*7+3]) * Np[0*7+1] + (Np[3*7+0] * N[0*7+2] + Np[3*7+1] * N[1*7+2] + Np[3*7+2] * N22 + N[2*7+3]) * Np[0*7+2]; - N[3*7+1] = (Np[3*7+0] * N00 + Np[3*7+1] * N[0*7+1] + Np[3*7+2] * N[0*7+2] + N[0*7+3]) * Np[1*7+0] + (Np[3*7+0] * N[0*7+1] + Np[3*7+1] * N11 + Np[3*7+2] * N[1*7+2] + N[1*7+3]) * Np[1*7+1] + (Np[3*7+0] * N[0*7+2] + Np[3*7+1] * N[1*7+2] + Np[3*7+2] * N22 + N[2*7+3]) * Np[1*7+2]; - N[3*7+2] = (Np[3*7+0] * N00 + Np[3*7+1] * N[0*7+1] + Np[3*7+2] * N[0*7+2] + N[0*7+3]) * Np[2*7+0] + (Np[3*7+0] * N[0*7+1] + Np[3*7+1] * N11 + Np[3*7+2] * N[1*7+2] + N[1*7+3]) * Np[2*7+1] + (Np[3*7+0] * N[0*7+2] + Np[3*7+1] * N[1*7+2] + Np[3*7+2] * N22 + N[2*7+3]) * Np[2*7+2]; - N[3*7+3] = (Np[3*7+0] * N00 + Np[3*7+1] * N[0*7+1] + Np[3*7+2] * N[0*7+2] + N[0*7+3]) * Np[3*7+0] + (Np[3*7+0] * N[0*7+1] + Np[3*7+1] * N11 + Np[3*7+2] * N[1*7+2] + N[1*7+3]) * Np[3*7+1] + (Np[3*7+0] * N[0*7+2] + Np[3*7+1] * N[1*7+2] + Np[3*7+2] * N22 + N[2*7+3]) * Np[3*7+2] + Np[3*7+0] * N[0*7+3] + Np[3*7+1] * N[1*7+3] + Np[3*7+2] * N[2*7+3] + N33; - - N[4*7+0] = (Np[4*7+0] * N00 + Np[4*7+1] * N[0*7+1] + Np[4*7+2] * N[0*7+2] + N[0*7+4]) * Np[0*7+0] + (Np[4*7+0] * N[0*7+1] + Np[4*7+1] * N11 + Np[4*7+2] * N[1*7+2] + N[1*7+4]) * Np[0*7+1] + (Np[4*7+0] * N[0*7+2] + Np[4*7+1] * N[1*7+2] + Np[4*7+2] * N22 + N[2*7+4]) * Np[0*7+2]; - N[4*7+1] = (Np[4*7+0] * N00 + Np[4*7+1] * N[0*7+1] + Np[4*7+2] * N[0*7+2] + N[0*7+4]) * Np[1*7+0] + (Np[4*7+0] * N[0*7+1] + Np[4*7+1] * N11 + Np[4*7+2] * N[1*7+2] + N[1*7+4]) * Np[1*7+1] + (Np[4*7+0] * N[0*7+2] + Np[4*7+1] * N[1*7+2] + Np[4*7+2] * N22 + N[2*7+4]) * Np[1*7+2]; - N[4*7+2] = (Np[4*7+0] * N00 + Np[4*7+1] * N[0*7+1] + Np[4*7+2] * N[0*7+2] + N[0*7+4]) * Np[2*7+0] + (Np[4*7+0] * N[0*7+1] + Np[4*7+1] * N11 + Np[4*7+2] * N[1*7+2] + N[1*7+4]) * Np[2*7+1] + (Np[4*7+0] * N[0*7+2] + Np[4*7+1] * N[1*7+2] + Np[4*7+2] * N22 + N[2*7+4]) * Np[2*7+2]; - N[4*7+3] = (Np[4*7+0] * N00 + Np[4*7+1] * N[0*7+1] + Np[4*7+2] * N[0*7+2] + N[0*7+4]) * Np[3*7+0] + (Np[4*7+0] * N[0*7+1] + Np[4*7+1] * N11 + Np[4*7+2] * N[1*7+2] + N[1*7+4]) * Np[3*7+1] + (Np[4*7+0] * N[0*7+2] + Np[4*7+1] * N[1*7+2] + Np[4*7+2] * N22 + N[2*7+4]) * Np[3*7+2] + Np[4*7+0] * N[0*7+3] + Np[4*7+1] * N[1*7+3] + Np[4*7+2] * N[2*7+3] + N[3*7+4]; - N[4*7+4] = (Np[4*7+0] * N00 + Np[4*7+1] * N[0*7+1] + Np[4*7+2] * N[0*7+2] + N[0*7+4]) * Np[4*7+0] + (Np[4*7+0] * N[0*7+1] + Np[4*7+1] * N11 + Np[4*7+2] * N[1*7+2] + N[1*7+4]) * Np[4*7+1] + (Np[4*7+0] * N[0*7+2] + Np[4*7+1] * N[1*7+2] + Np[4*7+2] * N22 + N[2*7+4]) * Np[4*7+2] + Np[4*7+0] * N[0*7+4] + Np[4*7+1] * N[1*7+4] + Np[4*7+2] * N[2*7+4] + N44; - - N[5*7+0] = (Np[5*7+0] * N00 + Np[5*7+1] * N[0*7+1] + Np[5*7+2] * N[0*7+2] + N[0*7+5]) * Np[0*7+0] + (Np[5*7+0] * N[0*7+1] + Np[5*7+1] * N11 + Np[5*7+2] * N[1*7+2] + N[1*7+5]) * Np[0*7+1] + (Np[5*7+0] * N[0*7+2] + Np[5*7+1] * N[1*7+2] + Np[5*7+2] * N22 + N[2*7+5]) * Np[0*7+2]; - N[5*7+1] = (Np[5*7+0] * N00 + Np[5*7+1] * N[0*7+1] + Np[5*7+2] * N[0*7+2] + N[0*7+5]) * Np[1*7+0] + (Np[5*7+0] * N[0*7+1] + Np[5*7+1] * N11 + Np[5*7+2] * N[1*7+2] + N[1*7+5]) * Np[1*7+1] + (Np[5*7+0] * N[0*7+2] + Np[5*7+1] * N[1*7+2] + Np[5*7+2] * N22 + N[2*7+5]) * Np[1*7+2]; - N[5*7+2] = (Np[5*7+0] * N00 + Np[5*7+1] * N[0*7+1] + Np[5*7+2] * N[0*7+2] + N[0*7+5]) * Np[2*7+0] + (Np[5*7+0] * N[0*7+1] + Np[5*7+1] * N11 + Np[5*7+2] * N[1*7+2] + N[1*7+5]) * Np[2*7+1] + (Np[5*7+0] * N[0*7+2] + Np[5*7+1] * N[1*7+2] + Np[5*7+2] * N22 + N[2*7+5]) * Np[2*7+2]; - N[5*7+3] = (Np[5*7+0] * N00 + Np[5*7+1] * N[0*7+1] + Np[5*7+2] * N[0*7+2] + N[0*7+5]) * Np[3*7+0] + (Np[5*7+0] * N[0*7+1] + Np[5*7+1] * N11 + Np[5*7+2] * N[1*7+2] + N[1*7+5]) * Np[3*7+1] + (Np[5*7+0] * N[0*7+2] + Np[5*7+1] * N[1*7+2] + Np[5*7+2] * N22 + N[2*7+5]) * Np[3*7+2] + Np[5*7+0] * N[0*7+3] + Np[5*7+1] * N[1*7+3] + Np[5*7+2] * N[2*7+3] + N[3*7+5]; - N[5*7+4] = (Np[5*7+0] * N00 + Np[5*7+1] * N[0*7+1] + Np[5*7+2] * N[0*7+2] + N[0*7+5]) * Np[4*7+0] + (Np[5*7+0] * N[0*7+1] + Np[5*7+1] * N11 + Np[5*7+2] * N[1*7+2] + N[1*7+5]) * Np[4*7+1] + (Np[5*7+0] * N[0*7+2] + Np[5*7+1] * N[1*7+2] + Np[5*7+2] * N22 + N[2*7+5]) * Np[4*7+2] + Np[5*7+0] * N[0*7+4] + Np[5*7+1] * N[1*7+4] + Np[5*7+2] * N[2*7+4] + N[4*7+5]; - N[5*7+5] = (Np[5*7+0] * N00 + Np[5*7+1] * N[0*7+1] + Np[5*7+2] * N[0*7+2] + N[0*7+5]) * Np[5*7+0] + (Np[5*7+0] * N[0*7+1] + Np[5*7+1] * N11 + Np[5*7+2] * N[1*7+2] + N[1*7+5]) * Np[5*7+1] + (Np[5*7+0] * N[0*7+2] + Np[5*7+1] * N[1*7+2] + Np[5*7+2] * N22 + N[2*7+5]) * Np[5*7+2] + Np[5*7+0] * N[0*7+5] + Np[5*7+1] * N[1*7+5] + Np[5*7+2] * N[2*7+5] + N55; - - N[6*7+0] = Np[0*7+0] * N[0*7+6] + Np[0*7+1] * N[1*7+6] + Np[0*7+2] * N[2*7+6]; - N[6*7+1] = Np[1*7+0] * N[0*7+6] + Np[1*7+1] * N[1*7+6] + Np[1*7+2] * N[2*7+6]; - N[6*7+2] = Np[2*7+0] * N[0*7+6] + Np[2*7+1] * N[1*7+6] + Np[2*7+2] * N[2*7+6]; - N[6*7+3] = Np[3*7+0] * N[0*7+6] + Np[3*7+1] * N[1*7+6] + Np[3*7+2] * N[2*7+6] + N[3*7+6]; - N[6*7+4] = Np[4*7+0] * N[0*7+6] + Np[4*7+1] * N[1*7+6] + Np[4*7+2] * N[2*7+6] + N[4*7+6]; - N[6*7+5] = Np[5*7+0] * N[0*7+6] + Np[5*7+1] * N[1*7+6] + Np[5*7+2] * N[2*7+6] + N[5*7+6]; - //N[6*7+6] = N[6*7+6]; remains unchanged - - - // copy the results from the lower left triangle to the upper right triangle as well - N[5*7+6] = N[6*7+5]; - N[4*7+5] = N[5*7+4]; N[4*7+6] = N[6*7+4]; - N[3*7+4] = N[4*7+3]; N[3*7+5] = N[5*7+3]; N[3*7+6] = N[6*7+3]; - N[2*7+3] = N[3*7+2]; N[2*7+4] = N[4*7+2]; N[2*7+5] = N[5*7+2]; N[2*7+6] = N[6*7+2]; - N[1*7+2] = N[2*7+1]; N[1*7+3] = N[3*7+1]; N[1*7+4] = N[4*7+1]; N[1*7+5] = N[5*7+1]; N[1*7+6] = N[6*7+1]; - N[0*7+1] = N[1*7+0]; N[0*7+2] = N[2*7+0]; N[0*7+3] = N[3*7+0]; N[0*7+4] = N[4*7+0]; N[0*7+5] = N[5*7+0]; N[0*7+6] = N[6*7+0]; -} - - -void RKTools::printDim(const double* mat, unsigned int dimX, unsigned int dimY){ - - std::cout << dimX << " x " << dimY << " matrix as follows: \n"; - for (unsigned int i=0; i< dimX; ++i){ - for (unsigned int j=0; j< dimY; ++j){ - printf(" %11.5g", mat[i*dimY+j]); - } - std::cout<<"\n"; - } - std::cout<. -*/ - -#include "RKTrackRep.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#define MINSTEP 0.001 // minimum step [cm] for Runge Kutta and iteration to POCA -//#define DEBUG - -namespace { - // Use fast inversion instead of LU decomposition? - const bool useInvertFast = false; -} - -namespace genfit { - - -RKTrackRep::RKTrackRep() : - AbsTrackRep(), - lastStartState_(this), - lastEndState_(this), - RKStepsFXStart_(0), - RKStepsFXStop_(0), - fJacobian_(5,5), - fNoise_(5), - useCache_(false), - cachePos_(0) -{ - initArrays(); -} - - -RKTrackRep::RKTrackRep(int pdgCode, char propDir) : - AbsTrackRep(pdgCode, propDir), - lastStartState_(this), - lastEndState_(this), - RKStepsFXStart_(0), - RKStepsFXStop_(0), - fJacobian_(5,5), - fNoise_(5), - useCache_(false), - cachePos_(0) -{ - initArrays(); -} - - -RKTrackRep::~RKTrackRep() { - ; -} - -SharedPlanePtr RKTrackRep::makePlane(const TVector3& o,const TVector3& u,const TVector3& v){ - SharedPlanePtr plane = SharedPlanePtr(new DetPlane(o,u,v)); - return plane; -} - -double RKTrackRep::extrapolateToPlane(StateOnPlane& state, - const TVector3 & point,const TVector3 & dir, - bool stopAtBoundary, - bool calcJacobianNoise) const { - // std::cout << "test "< 0) { - std::cout << "RKTrackRep::extrapolateToPlane()\n"; - } - - - if (state.getPlane() == plane) { - if (debugLvl_ > 0) { - std::cout << "state is already defined at plane. Do nothing! \n"; - } - return 0; - } - - checkCache(state, &plane); - - // to 7D - M1x7 state7; - getState7(state, state7); - - TMatrixDSym* covPtr(NULL); - bool fillExtrapSteps(false); - if (dynamic_cast(&state) != NULL) { - covPtr = &(static_cast(&state)->getCov()); - fillExtrapSteps = true; - } - else if (calcJacobianNoise) - fillExtrapSteps = true; - - // actual extrapolation - bool isAtBoundary(false); - double coveredDistance = Extrap(*(state.getPlane()), *plane, getCharge(state), isAtBoundary, state7, fillExtrapSteps, covPtr, false, stopAtBoundary); - - if (stopAtBoundary && isAtBoundary) { - state.setPlane(SharedPlanePtr(new DetPlane(TVector3(state7[0], state7[1], state7[2]), - TVector3(state7[3], state7[4], state7[5])))); - } - else { - state.setPlane(plane); - } - - // back to 5D - getState5(state, state7); - - lastEndState_ = state; - - return coveredDistance; -} - - -double RKTrackRep::extrapolateToLine(StateOnPlane& state, - const TVector3& linePoint, - const TVector3& lineDirection, - bool stopAtBoundary, - bool calcJacobianNoise) const { - - if (debugLvl_ > 0) { - std::cout << "RKTrackRep::extrapolateToLine()\n"; - } - - checkCache(state, NULL); - - static const unsigned int maxIt(1000); - - // to 7D - M1x7 state7; - getState7(state, state7); - - bool fillExtrapSteps(false); - if (dynamic_cast(&state) != NULL) { - fillExtrapSteps = true; - } - else if (calcJacobianNoise) - fillExtrapSteps = true; - - double step(0.), lastStep(0.), maxStep(1.E99), angle(0), distToPoca(0), tracklength(0); - double charge = getCharge(state); - TVector3 dir(state7[3], state7[4], state7[5]); - TVector3 lastDir(0,0,0); - TVector3 poca, poca_onwire; - bool isAtBoundary(false); - - DetPlane startPlane(*(state.getPlane())); - SharedPlanePtr plane(new DetPlane(linePoint, dir.Cross(lineDirection), lineDirection)); - unsigned int iterations(0); - - while(true){ - if(++iterations == maxIt) { - Exception exc("RKTrackRep::extrapolateToLine ==> extrapolation to line failed, maximum number of iterations reached",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - lastStep = step; - lastDir = dir; - - step = this->Extrap(startPlane, *plane, charge, isAtBoundary, state7, false, NULL, true, stopAtBoundary, maxStep); - tracklength += step; - - dir.SetXYZ(state7[3], state7[4], state7[5]); - poca.SetXYZ(state7[0], state7[1], state7[2]); - poca_onwire = pocaOnLine(linePoint, lineDirection, poca); - - // check break conditions - if (stopAtBoundary && isAtBoundary) { - plane->setON(dir, poca); - break; - } - - angle = fabs(dir.Angle((poca_onwire-poca))-TMath::PiOver2()); // angle between direction and connection to point - 90 deg - distToPoca = (poca_onwire-poca).Mag(); - if (angle*distToPoca < 0.1*MINSTEP) break; - - // if lastStep and step have opposite sign, the real normal vector lies somewhere between the last two normal vectors (i.e. the directions) - // -> try mean value of the two (normalization not needed) - if (lastStep*step < 0){ - dir += lastDir; - maxStep = 0.5*fabs(lastStep); // make it converge! - } - - startPlane = *plane; - plane->setU(dir.Cross(lineDirection)); - } - - if (fillExtrapSteps) { // now do the full extrapolation with covariance matrix - // make use of the cache - lastEndState_.setPlane(plane); - getState5(lastEndState_, state7); - - tracklength = extrapolateToPlane(state, plane, false, true); - } - else { - state.setPlane(plane); - getState5(state, state7); - } - - if (debugLvl_ > 0) { - std::cout << "RKTrackRep::extrapolateToLine(): Reached POCA after " << iterations+1 << " iterations. Distance: " << (poca_onwire-poca).Mag() << " cm. Angle deviation: " << dir.Angle((poca_onwire-poca))-TMath::PiOver2() << " rad \n"; - } - - lastEndState_ = state; - - return tracklength; -} - - -double RKTrackRep::extrapToPoint(StateOnPlane& state, - const TVector3& point, - const TMatrixDSym* G, - bool stopAtBoundary, - bool calcJacobianNoise) const { - - if (debugLvl_ > 0) { - std::cout << "RKTrackRep::extrapolateToPoint()\n"; - } - - checkCache(state, NULL); - - static const unsigned int maxIt(1000); - - // to 7D - M1x7 state7; - getState7(state, state7); - - bool fillExtrapSteps(false); - if (dynamic_cast(&state) != NULL) { - fillExtrapSteps = true; - } - else if (calcJacobianNoise) - fillExtrapSteps = true; - - double step(0.), lastStep(0.), maxStep(1.E99), angle(0), distToPoca(0), tracklength(0); - TVector3 dir(state7[3], state7[4], state7[5]); - if (G != NULL) { - if(G->GetNrows() != 3) { - Exception exc("RKTrackRep::extrapolateToLine ==> G is not 3x3",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - dir = TMatrix(*G) * dir; - } - TVector3 lastDir(0,0,0); - - TVector3 poca; - bool isAtBoundary(false); - - DetPlane startPlane(*(state.getPlane())); - SharedPlanePtr plane(new DetPlane(point, dir)); - unsigned int iterations(0); - - while(true){ - if(++iterations == maxIt) { - Exception exc("RKTrackRep::extrapolateToPoint ==> extrapolation to point failed, maximum number of iterations reached",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - lastStep = step; - lastDir = dir; - - step = this->Extrap(startPlane, *plane, getCharge(state), isAtBoundary, state7, false, NULL, true, stopAtBoundary, maxStep); - tracklength += step; - - dir.SetXYZ(state7[3], state7[4], state7[5]); - if (G != NULL) { - dir = TMatrix(*G) * dir; - } - poca.SetXYZ(state7[0], state7[1], state7[2]); - - // check break conditions - if (stopAtBoundary && isAtBoundary) { - plane->setON(dir, poca); - break; - } - - angle = fabs(dir.Angle((point-poca))-TMath::PiOver2()); // angle between direction and connection to point - 90 deg - distToPoca = (point-poca).Mag(); - if (angle*distToPoca < 0.1*MINSTEP) break; - - // if lastStep and step have opposite sign, the real normal vector lies somewhere between the last two normal vectors (i.e. the directions) - // -> try mean value of the two (normalization not needed) - if (lastStep*step < 0){ - dir += lastDir; - maxStep = 0.5*fabs(lastStep); // make it converge! - } - - startPlane = *plane; - plane->setNormal(dir); - } - - if (fillExtrapSteps) { // now do the full extrapolation with covariance matrix - // make use of the cache - lastEndState_.setPlane(plane); - getState5(lastEndState_, state7); - - tracklength = extrapolateToPlane(state, plane, false, true); - } - else { - state.setPlane(plane); - getState5(state, state7); - } - - - if (debugLvl_ > 0) { - std::cout << "RKTrackRep::extrapolateToPoint(): Reached POCA after " << iterations+1 << " iterations. Distance: " << (point-poca).Mag() << " cm. Angle deviation: " << dir.Angle((point-poca))-TMath::PiOver2() << " rad \n"; - } - - lastEndState_ = state; - - return tracklength; -} - - -double RKTrackRep::extrapolateToCylinder(StateOnPlane& state, - double radius, - const TVector3& linePoint, - const TVector3& lineDirection, - bool stopAtBoundary, - bool calcJacobianNoise) const { - - if (debugLvl_ > 0) { - std::cout << "RKTrackRep::extrapolateToCylinder()\n"; - } - - checkCache(state, NULL); - - static const unsigned int maxIt(1000); - - // to 7D - M1x7 state7; - getState7(state, state7); - - bool fillExtrapSteps(false); - if (dynamic_cast(&state) != NULL) { - fillExtrapSteps = true; - } - else if (calcJacobianNoise) - fillExtrapSteps = true; - - double tracklength(0.), maxStep(1.E99); - - TVector3 dest, pos, dir; - - bool isAtBoundary(false); - - DetPlane startPlane(*(state.getPlane())); - SharedPlanePtr plane(new DetPlane()); - unsigned int iterations(0); - - while(true){ - if(++iterations == maxIt) { - Exception exc("RKTrackRep::extrapolateToCylinder ==> maximum number of iterations reached",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - pos.SetXYZ(state7[0], state7[1], state7[2]); - dir.SetXYZ(state7[3], state7[4], state7[5]); - - // solve quadratic equation - TVector3 AO = (pos - linePoint); - TVector3 AOxAB = (AO.Cross(lineDirection)); - TVector3 VxAB = (dir.Cross(lineDirection)); - float ab2 = (lineDirection * lineDirection); - float a = (VxAB * VxAB); - float b = 2 * (VxAB * AOxAB); - float c = (AOxAB * AOxAB) - (radius*radius * ab2); - double arg = b*b - 4.*a*c; - if(arg < 0) { - Exception exc("RKTrackRep::extrapolateToCylinder ==> cannot solve",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - double term = sqrt(arg); - double k1, k2; - if (b<0) { - k1 = (-b + term)/(2.*a); - k2 = 2.*c/(-b + term); - } - else { - k1 = 2.*c/(-b - term); - k2 = (-b - term)/(2.*a); - } - - // select smallest absolute solution -> closest cylinder surface - double k = k1; - if (fabs(k2) 0) { - std::cout << "RKTrackRep::extrapolateToCylinder(); k = " << k << "\n"; - } - - dest = pos + k * dir; - - plane->setO(dest); - plane->setUV((dest-linePoint).Cross(lineDirection), lineDirection); - - tracklength += this->Extrap(startPlane, *plane, getCharge(state), isAtBoundary, state7, false, NULL, true, stopAtBoundary, maxStep); - - // check break conditions - if (stopAtBoundary && isAtBoundary) { - pos.SetXYZ(state7[0], state7[1], state7[2]); - dir.SetXYZ(state7[3], state7[4], state7[5]); - plane->setO(pos); - plane->setUV((pos-linePoint).Cross(lineDirection), lineDirection); - break; - } - - if(fabs(k) 0) { - std::cout << "RKTrackRep::extrapolateToSphere()\n"; - } - - checkCache(state, NULL); - - static const unsigned int maxIt(1000); - - // to 7D - M1x7 state7; - getState7(state, state7); - - bool fillExtrapSteps(false); - if (dynamic_cast(&state) != NULL) { - fillExtrapSteps = true; - } - else if (calcJacobianNoise) - fillExtrapSteps = true; - - double tracklength(0.), maxStep(1.E99); - - TVector3 dest, pos, dir; - - bool isAtBoundary(false); - - DetPlane startPlane(*(state.getPlane())); - SharedPlanePtr plane(new DetPlane()); - unsigned int iterations(0); - - while(true){ - if(++iterations == maxIt) { - Exception exc("RKTrackRep::extrapolateToSphere ==> maximum number of iterations reached",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - pos.SetXYZ(state7[0], state7[1], state7[2]); - dir.SetXYZ(state7[3], state7[4], state7[5]); - - // solve quadratic equation - TVector3 AO = (pos - point); - double dirAO = dir * AO; - double arg = dirAO*dirAO - AO*AO + radius*radius; - if(arg < 0) { - Exception exc("RKTrackRep::extrapolateToSphere ==> cannot solve",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - double term = sqrt(arg); - double k1, k2; - k1 = -dirAO + term; - k2 = -dirAO - term; - - // select smallest absolute solution -> closest cylinder surface - double k = k1; - if (fabs(k2) 0) { - std::cout << "RKTrackRep::extrapolateToSphere(); k = " << k << "\n"; - } - - dest = pos + k * dir; - - plane->setON(dest, dest-point); - - tracklength += this->Extrap(startPlane, *plane, getCharge(state), isAtBoundary, state7, false, NULL, true, stopAtBoundary, maxStep); - - // check break conditions - if (stopAtBoundary && isAtBoundary) { - pos.SetXYZ(state7[0], state7[1], state7[2]); - dir.SetXYZ(state7[3], state7[4], state7[5]); - plane->setON(pos, pos-point); - break; - } - - if(fabs(k) 0) { - std::cout << "RKTrackRep::extrapolateBy()\n"; - } - - checkCache(state, NULL); - - static const unsigned int maxIt(1000); - - // to 7D - M1x7 state7; - getState7(state, state7); - - bool fillExtrapSteps(false); - if (dynamic_cast(&state) != NULL) { - fillExtrapSteps = true; - } - else if (calcJacobianNoise) - fillExtrapSteps = true; - - double tracklength(0.); - - TVector3 dest, pos, dir; - - bool isAtBoundary(false); - - DetPlane startPlane(*(state.getPlane())); - SharedPlanePtr plane(new DetPlane()); - unsigned int iterations(0); - - while(true){ - if(++iterations == maxIt) { - Exception exc("RKTrackRep::extrapolateBy ==> maximum number of iterations reached",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - pos.SetXYZ(state7[0], state7[1], state7[2]); - dir.SetXYZ(state7[3], state7[4], state7[5]); - - dest = pos + 1.5*(step-tracklength) * dir; - - plane->setON(dest, dir); - - tracklength += this->Extrap(startPlane, *plane, getCharge(state), isAtBoundary, state7, false, NULL, true, stopAtBoundary, (step-tracklength)); - - // check break conditions - if (stopAtBoundary && isAtBoundary) { - pos.SetXYZ(state7[0], state7[1], state7[2]); - dir.SetXYZ(state7[3], state7[4], state7[5]); - plane->setON(pos, dir); - break; - } - - if (fabs(tracklength-step) < MINSTEP) { - if (debugLvl_ > 0) { - std::cout << "RKTrackRep::extrapolateBy(): reached after " << iterations << " iterations. \n"; - } - pos.SetXYZ(state7[0], state7[1], state7[2]); - dir.SetXYZ(state7[3], state7[4], state7[5]); - plane->setON(pos, dir); - break; - } - - startPlane = *plane; - - } - - if (fillExtrapSteps) { // now do the full extrapolation with covariance matrix - // make use of the cache - lastEndState_.setPlane(plane); - getState5(lastEndState_, state7); - - tracklength = extrapolateToPlane(state, plane, false, true); - } - else { - state.setPlane(plane); - getState5(state, state7); - } - - lastEndState_ = state; - - return tracklength; -} - - -TVector3 RKTrackRep::getPos(const StateOnPlane& state) const { - M1x7 state7; - getState7(state, state7); - - return TVector3(state7[0], state7[1], state7[2]); -} - - -TVector3 RKTrackRep::getMom(const StateOnPlane& state) const { - M1x7 state7; - getState7(state, state7); - - TVector3 mom(state7[3], state7[4], state7[5]); - mom.SetMag(getCharge(state)/state7[6]); - return mom; -} - - -void RKTrackRep::getPosMom(const StateOnPlane& state, TVector3& pos, TVector3& mom) const { - M1x7 state7; - getState7(state, state7); - - pos.SetXYZ(state7[0], state7[1], state7[2]); - mom.SetXYZ(state7[3], state7[4], state7[5]); - mom.SetMag(getCharge(state)/state7[6]); -} - - -void RKTrackRep::getPosMomCov(const MeasuredStateOnPlane& state, TVector3& pos, TVector3& mom, TMatrixDSym& cov) const { - getPosMom(state, pos, mom); - cov.ResizeTo(6,6); - transformPM6(state, *((M6x6*) cov.GetMatrixArray())); -} - - -TMatrixDSym RKTrackRep::get6DCov(const MeasuredStateOnPlane& state) const { - TMatrixDSym cov(6); - transformPM6(state, *((M6x6*) cov.GetMatrixArray())); - - return cov; -} - - -double RKTrackRep::getCharge(const StateOnPlane& state) const { - - if (dynamic_cast(&state) != NULL) { - Exception exc("RKTrackRep::getCharge - cannot get charge from MeasurementOnPlane",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - double pdgCharge = getPDGCharge(); - - // return pdgCharge with sign of q/p - if (state.getState()(0) * pdgCharge < 0) - return -pdgCharge; - else - return pdgCharge; -} - - -double RKTrackRep::getMomMag(const StateOnPlane& state) const { - // p = q / qop - double p = getCharge(state)/state.getState()(0); - assert (p>=0); - return p; -} - - -double RKTrackRep::getMomVar(const MeasuredStateOnPlane& state) const { - - if (dynamic_cast(&state) != NULL) { - Exception exc("RKTrackRep::getMomVar - cannot get momVar from MeasurementOnPlane",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - // p(qop) = q/qop - // dp/d(qop) = - q / (qop^2) - // (delta p) = (delta qop) * |dp/d(qop)| = delta qop * |q / (qop^2)| - // (var p) = (var qop) * q^2 / (qop^4) - - // delta means sigma - // cov(0,0) is sigma^2 - - return state.getCov()(0,0) * pow(getCharge(state), 2) / pow(state.getState()(0), 4); -} - - -double RKTrackRep::getSpu(const StateOnPlane& state) const { - - if (dynamic_cast(&state) != NULL) { - Exception exc("RKTrackRep::getSpu - cannot get spu from MeasurementOnPlane",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - const TVectorD& auxInfo = state.getAuxInfo(); - if (auxInfo.GetNrows() == 1) - return state.getAuxInfo()(0); - else - return 1.; -} - - -void RKTrackRep::calcForwardJacobianAndNoise(const M1x7& startState7, const DetPlane& startPlane, - const M1x7& destState7, const DetPlane& destPlane) const { - - if (debugLvl_ > 0) { - std::cout << "RKTrackRep::calcForwardJacobianAndNoise " << std::endl; - } - - if (ExtrapSteps_.size() == 0) { - Exception exc("RKTrackRep::calcForwardJacobianAndNoise ==> cache is empty. Extrapolation must run with a MeasuredStateOnPlane.",__LINE__,__FILE__); - throw exc; - } - - // The Jacobians returned from RKutta are transposed. - TMatrixD jac(TMatrixD::kTransposed, TMatrixD(7, 7, ExtrapSteps_.back().jac7_)); - TMatrixDSym noise(7, ExtrapSteps_.back().noise7_); - for (int i = ExtrapSteps_.size() - 2; i >= 0; --i) { - noise += TMatrixDSym(7, ExtrapSteps_[i].noise7_).Similarity(jac); - jac *= TMatrixD(TMatrixD::kTransposed, TMatrixD(7, 7, ExtrapSteps_[i].jac7_)); - } - - // Project into 5x5 space. - M1x3 pTilde = {startState7[3], startState7[4], startState7[5]}; - const TVector3& normal = startPlane.getNormal(); - double pTildeW = pTilde[0] * normal.X() + pTilde[1] * normal.Y() + pTilde[2] * normal.Z(); - double spu = pTildeW > 0 ? 1 : -1; - for (unsigned int i=0; i<3; ++i) { - pTilde[i] *= spu/pTildeW; // | pTilde * W | has to be 1 (definition of pTilde) - } - M5x7 J_pM; - calcJ_pM_5x7(J_pM, startPlane.getU(), startPlane.getV(), pTilde, spu); - M7x5 J_Mp; - calcJ_Mp_7x5(J_Mp, destPlane.getU(), destPlane.getV(), destPlane.getNormal(), *((M1x3*) &destState7[3])); - jac.Transpose(jac); // Because the helper function wants transposed input. - RKTools::J_pMTTxJ_MMTTxJ_MpTT(J_Mp, *(M7x7 *)jac.GetMatrixArray(), - J_pM, *(M5x5 *)fJacobian_.GetMatrixArray()); - RKTools::J_MpTxcov7xJ_Mp(J_Mp, *(M7x7 *)noise.GetMatrixArray(), - *(M5x5 *)fNoise_.GetMatrixArray()); - - if (debugLvl_ > 0) { - std::cout << "total jacobian : "; fJacobian_.Print(); - std::cout << "total noise : "; fNoise_.Print(); - } - -} - - -void RKTrackRep::getForwardJacobianAndNoise(TMatrixD& jacobian, TMatrixDSym& noise, TVectorD& deltaState) const { - - jacobian.ResizeTo(5,5); - jacobian = fJacobian_; - - noise.ResizeTo(5,5); - noise = fNoise_; - - // lastEndState_ = jacobian * lastStartState_ + deltaState - deltaState.ResizeTo(5); - // Calculate this without temporaries: - //deltaState = lastEndState_.getState() - jacobian * lastStartState_.getState() - deltaState = lastStartState_.getState(); - deltaState *= jacobian; - deltaState -= lastEndState_.getState(); - deltaState *= -1; - - - if (debugLvl_ > 0) { - std::cout << "delta state : "; deltaState.Print(); - } -} - - -void RKTrackRep::getBackwardJacobianAndNoise(TMatrixD& jacobian, TMatrixDSym& noise, TVectorD& deltaState) const { - - if (debugLvl_ > 0) { - std::cout << "RKTrackRep::getBackwardJacobianAndNoise " << std::endl; - } - - if (ExtrapSteps_.size() == 0) { - Exception exc("RKTrackRep::getBackwardJacobianAndNoise ==> cache is empty. Extrapolation must run with a MeasuredStateOnPlane.",__LINE__,__FILE__); - throw exc; - } - - jacobian.ResizeTo(5,5); - jacobian = fJacobian_; - if (!useInvertFast) { - TDecompLU invertAlgo(jacobian); - bool status = invertAlgo.Invert(jacobian); - if(status == 0){ - Exception e("cannot invert matrix, status = 0", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - } else { - double det; - jacobian.InvertFast(&det); - if(det < 1e-80){ - Exception e("cannot invert matrix, status = 0", __LINE__,__FILE__); - e.setFatal(); - throw e; - } - } - - noise.ResizeTo(5,5); - noise = fNoise_; - noise.Similarity(jacobian); - - // lastStartState_ = jacobian * lastEndState_ + deltaState - deltaState.ResizeTo(5); - deltaState = lastStartState_.getState() - jacobian * lastEndState_.getState(); -} - - -std::vector RKTrackRep::getSteps() const { - - // Todo: test - - if (RKSteps_.size() == 0) { - Exception exc("RKTrackRep::getSteps ==> cache is empty.",__LINE__,__FILE__); - throw exc; - } - - std::vector retVal; - retVal.reserve(RKSteps_.size()); - - for (unsigned int i = 0; i cache is empty.",__LINE__,__FILE__); - throw exc; - } - - double radLen(0); - - for (unsigned int i = 0; i cache is empty.",__LINE__,__FILE__); - throw exc; - } - - double m = getMass(lastStartState_); // GeV - double m2 = m*m; - static const double c = TMath::Ccgs(); // cm/s - double p1(0), p2(0), trackLen(0), beta(0); - - double tof(0); - - p1 = lastStartState_.getMomMag(); - - for (unsigned int i = 0; i state is defined wrt. another TrackRep",__LINE__,__FILE__); - throw exc; - } - - if (dynamic_cast(&state) != NULL) { - Exception exc("RKTrackRep::setPosMom - cannot set pos/mom of a MeasurementOnPlane",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - // init auxInfo if that has not yet happened - TVectorD& auxInfo = state.getAuxInfo(); - if (auxInfo.GetNrows() != 1) { - auxInfo.ResizeTo(1); - setSpu(state, 1.); - } - - if (state.getPlane() != NULL && state.getPlane()->distance(pos) < MINSTEP) { // pos is on plane -> do not change plane! - - M1x7 state7; - - state7[0] = pos.X(); - state7[1] = pos.Y(); - state7[2] = pos.Z(); - - state7[3] = mom.X(); - state7[4] = mom.Y(); - state7[5] = mom.Z(); - - // normalize dir - double norm = 1. / sqrt(state7[3]*state7[3] + state7[4]*state7[4] + state7[5]*state7[5]); - for (unsigned int i=3; i<6; ++i) - state7[i] *= norm; - - state7[6] = getCharge(state) * norm; - - getState5(state, state7); - - } - else { // pos is not on plane -> create new plane! - - // TODO: Raise Warning that a new plane has been created! - SharedPlanePtr plane(new DetPlane(pos, mom)); - state.setPlane(plane); - - TVectorD& state5(state.getState()); - - state5(0) = getCharge(state)/mom.Mag(); // q/p - state5(1) = 0.; // u' - state5(2) = 0.; // v' - state5(3) = 0.; // u - state5(4) = 0.; // v - - setSpu(state, 1.); - } - -} - - -void RKTrackRep::setPosMom(StateOnPlane& state, const TVectorD& state6) const { - if (state6.GetNrows()!=6){ - Exception exc("RKTrackRep::setPosMom ==> state has to be 6d (x, y, z, px, py, pz)",__LINE__,__FILE__); - throw exc; - } - setPosMom(state, TVector3(state6(0), state6(1), state6(2)), TVector3(state6(3), state6(4), state6(5))); -} - - -void RKTrackRep::setPosMomErr(MeasuredStateOnPlane& state, const TVector3& pos, const TVector3& mom, const TVector3& posErr, const TVector3& momErr) const { - - // TODO: test! - - setPosMom(state, pos, mom); - - const TVector3& U(state.getPlane()->getU()); - const TVector3& V(state.getPlane()->getV()); - TVector3 W(state.getPlane()->getNormal()); - - double pw = mom * W; - double pu = mom * U; - double pv = mom * V; - - TMatrixDSym& cov(state.getCov()); - - cov(0,0) = pow(getCharge(state), 2) / pow(mom.Mag(), 6) * - (mom.X()*mom.X() * momErr.X()*momErr.X()+ - mom.Y()*mom.Y() * momErr.Y()*momErr.Y()+ - mom.Z()*mom.Z() * momErr.Z()*momErr.Z()); - - cov(1,1) = pow((U.X()/pw - W.X()*pu/(pw*pw)),2.) * momErr.X()*momErr.X() + - pow((U.Y()/pw - W.Y()*pu/(pw*pw)),2.) * momErr.Y()*momErr.Y() + - pow((U.Z()/pw - W.Z()*pu/(pw*pw)),2.) * momErr.Z()*momErr.Z(); - - cov(2,2) = pow((V.X()/pw - W.X()*pv/(pw*pw)),2.) * momErr.X()*momErr.X() + - pow((V.Y()/pw - W.Y()*pv/(pw*pw)),2.) * momErr.Y()*momErr.Y() + - pow((V.Z()/pw - W.Z()*pv/(pw*pw)),2.) * momErr.Z()*momErr.Z(); - - cov(3,3) = posErr.X()*posErr.X() * U.X()*U.X() + - posErr.Y()*posErr.Y() * U.Y()*U.Y() + - posErr.Z()*posErr.Z() * U.Z()*U.Z(); - - cov(4,4) = posErr.X()*posErr.X() * V.X()*V.X() + - posErr.Y()*posErr.Y() * V.Y()*V.Y() + - posErr.Z()*posErr.Z() * V.Z()*V.Z(); - -} - - - - -void RKTrackRep::setPosMomCov(MeasuredStateOnPlane& state, const TVector3& pos, const TVector3& mom, const TMatrixDSym& cov6x6) const { - - if (cov6x6.GetNcols()!=6 || cov6x6.GetNrows()!=6){ - Exception exc("RKTrackRep::setPosMomCov ==> cov has to be 6x6 (x, y, z, px, py, pz)",__LINE__,__FILE__); - throw exc; - } - - setPosMom(state, pos, mom); // charge does not change! - - M1x7 state7; - getState7(state, state7); - - const M6x6& cov6x6_( *((M6x6*) cov6x6.GetMatrixArray()) ); - - transformM6P(cov6x6_, state7, state); - -} - -void RKTrackRep::setPosMomCov(MeasuredStateOnPlane& state, const TVectorD& state6, const TMatrixDSym& cov6x6) const { - - if (state6.GetNrows()!=6){ - Exception exc("RKTrackRep::setPosMomCov ==> state has to be 6d (x, y, z, px, py, pz)",__LINE__,__FILE__); - throw exc; - } - - if (cov6x6.GetNcols()!=6 || cov6x6.GetNrows()!=6){ - Exception exc("RKTrackRep::setPosMomCov ==> cov has to be 6x6 (x, y, z, px, py, pz)",__LINE__,__FILE__); - throw exc; - } - - TVector3 pos(state6(0), state6(1), state6(2)); - TVector3 mom(state6(3), state6(4), state6(5)); - setPosMom(state, pos, mom); // charge does not change! - - M1x7 state7; - getState7(state, state7); - - const M6x6& cov6x6_( *((M6x6*) cov6x6.GetMatrixArray()) ); - - transformM6P(cov6x6_, state7, state); - -} - - -void RKTrackRep::setChargeSign(StateOnPlane& state, double charge) const { - - if (dynamic_cast(&state) != NULL) { - Exception exc("RKTrackRep::setChargeSign - cannot set charge of a MeasurementOnPlane",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - if (state.getState()(0) * charge < 0) { - state.getState()(0) *= -1.; - } -} - - -void RKTrackRep::setSpu(StateOnPlane& state, double spu) const { - state.getAuxInfo().ResizeTo(1); - (state.getAuxInfo())(0) = spu; -} - - - -double RKTrackRep::RKPropagate(M1x7& state7, - M7x7* jacobianT, - M1x3& SA, - double S, - bool varField, - bool calcOnlyLastRowOfJ) const { - - // important fixed numbers - static const double EC = 0.000149896229; // c/(2*10^12) resp. c/2Tera - static const double P3 = 1./3.; // 1/3 - static const double DLT = .0002; // max. deviation for approximation-quality test - static const double par = 1./3.081615; - // Aux parameters - M1x3& R = *((M1x3*) &state7[0]); // Start coordinates [cm] (x, y, z) - M1x3& A = *((M1x3*) &state7[3]); // Start directions (ax, ay, az); ax^2+ay^2+az^2=1 - double S3(0), S4(0), PS2(0); - M1x3 H0 = {0.,0.,0.}, H1 = {0.,0.,0.}, H2 = {0.,0.,0.}; - M1x3 r = {0.,0.,0.}; - // Variables for Runge Kutta solver - double A0(0), A1(0), A2(0), A3(0), A4(0), A5(0), A6(0); - double B0(0), B1(0), B2(0), B3(0), B4(0), B5(0), B6(0); - double C0(0), C1(0), C2(0), C3(0), C4(0), C5(0), C6(0); - - // - // Runge Kutta Extrapolation - // - S3 = P3*S; - S4 = 0.25*S; - PS2 = state7[6]*EC * S; - - // First point - r[0] = R[0]; r[1] = R[1]; r[2]=R[2]; - FieldManager::getInstance()->getFieldVal(r[0], r[1], r[2], H0[0], H0[1], H0[2]); // magnetic field in 10^-1 T = kGauss - H0[0] *= PS2; H0[1] *= PS2; H0[2] *= PS2; // H0 is PS2*(Hx, Hy, Hz) @ R0 - A0 = A[1]*H0[2]-A[2]*H0[1]; B0 = A[2]*H0[0]-A[0]*H0[2]; C0 = A[0]*H0[1]-A[1]*H0[0]; // (ax, ay, az) x H0 - A2 = A[0]+A0 ; B2 = A[1]+B0 ; C2 = A[2]+C0 ; // (A0, B0, C0) + (ax, ay, az) - A1 = A2+A[0] ; B1 = B2+A[1] ; C1 = C2+A[2] ; // (A0, B0, C0) + 2*(ax, ay, az) - - // Second point - if (varField) { - r[0] += A1*S4; r[1] += B1*S4; r[2] += C1*S4; - FieldManager::getInstance()->getFieldVal(r[0], r[1], r[2], H1[0], H1[1], H1[2]); - H1[0] *= PS2; H1[1] *= PS2; H1[2] *= PS2; // H1 is PS2*(Hx, Hy, Hz) @ (x, y, z) + 0.25*S * [(A0, B0, C0) + 2*(ax, ay, az)] - } - else { H1[0] = H0[0]; H1[1] = H0[1]; H1[2] = H0[2]; }; // invalid: H1 = H0; !! - A3 = B2*H1[2]-C2*H1[1]+A[0]; B3 = C2*H1[0]-A2*H1[2]+A[1]; C3 = A2*H1[1]-B2*H1[0]+A[2]; // (A2, B2, C2) x H1 + (ax, ay, az) - A4 = B3*H1[2]-C3*H1[1]+A[0]; B4 = C3*H1[0]-A3*H1[2]+A[1]; C4 = A3*H1[1]-B3*H1[0]+A[2]; // (A3, B3, C3) x H1 + (ax, ay, az) - A5 = A4-A[0]+A4 ; B5 = B4-A[1]+B4 ; C5 = C4-A[2]+C4 ; // 2*(A4, B4, C4) - (ax, ay, az) - - // Last point - if (varField) { - r[0]=R[0]+S*A4; r[1]=R[1]+S*B4; r[2]=R[2]+S*C4; //setup.Field(r,H2); - FieldManager::getInstance()->getFieldVal(r[0], r[1], r[2], H2[0], H2[1], H2[2]); - H2[0] *= PS2; H2[1] *= PS2; H2[2] *= PS2; // H2 is PS2*(Hx, Hy, Hz) @ (x, y, z) + 0.25*S * (A4, B4, C4) - } - else { H2[0] = H0[0]; H2[1] = H0[1]; H2[2] = H0[2]; }; // invalid: H2 = H0; !! - A6 = B5*H2[2]-C5*H2[1]; B6 = C5*H2[0]-A5*H2[2]; C6 = A5*H2[1]-B5*H2[0]; // (A5, B5, C5) x H2 - - - // - // Derivatives of track parameters - // - if(jacobianT != NULL){ - - // jacobianT - // 1 0 0 0 0 0 0 - // 0 1 0 0 0 0 0 - // 0 0 1 0 0 0 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 1 - - double dA0(0), dA2(0), dA3(0), dA4(0), dA5(0), dA6(0); - double dB0(0), dB2(0), dB3(0), dB4(0), dB5(0), dB6(0); - double dC0(0), dC2(0), dC3(0), dC4(0), dC5(0), dC6(0); - - int start(0); - - if (!calcOnlyLastRowOfJ) { - - if (!varField) { - // d(x, y, z)/d(x, y, z) submatrix is unit matrix - (*jacobianT)[0] = 1; (*jacobianT)[8] = 1; (*jacobianT)[16] = 1; - // d(ax, ay, az)/d(ax, ay, az) submatrix is 0 - // start with d(x, y, z)/d(ax, ay, az) - start = 3; - } - - for(int i=start*7; i<42; i+=7) { - - //first point - dA0 = H0[2]*(*jacobianT)[i+4]-H0[1]*(*jacobianT)[i+5]; // dA0/dp } - dB0 = H0[0]*(*jacobianT)[i+5]-H0[2]*(*jacobianT)[i+3]; // dB0/dp } = dA x H0 - dC0 = H0[1]*(*jacobianT)[i+3]-H0[0]*(*jacobianT)[i+4]; // dC0/dp } - - dA2 = dA0+(*jacobianT)[i+3]; // } - dB2 = dB0+(*jacobianT)[i+4]; // } = (dA0, dB0, dC0) + dA - dC2 = dC0+(*jacobianT)[i+5]; // } - - //second point - dA3 = (*jacobianT)[i+3]+dB2*H1[2]-dC2*H1[1]; // dA3/dp } - dB3 = (*jacobianT)[i+4]+dC2*H1[0]-dA2*H1[2]; // dB3/dp } = dA + (dA2, dB2, dC2) x H1 - dC3 = (*jacobianT)[i+5]+dA2*H1[1]-dB2*H1[0]; // dC3/dp } - - dA4 = (*jacobianT)[i+3]+dB3*H1[2]-dC3*H1[1]; // dA4/dp } - dB4 = (*jacobianT)[i+4]+dC3*H1[0]-dA3*H1[2]; // dB4/dp } = dA + (dA3, dB3, dC3) x H1 - dC4 = (*jacobianT)[i+5]+dA3*H1[1]-dB3*H1[0]; // dC4/dp } - - //last point - dA5 = dA4+dA4-(*jacobianT)[i+3]; // } - dB5 = dB4+dB4-(*jacobianT)[i+4]; // } = 2*(dA4, dB4, dC4) - dA - dC5 = dC4+dC4-(*jacobianT)[i+5]; // } - - dA6 = dB5*H2[2]-dC5*H2[1]; // dA6/dp } - dB6 = dC5*H2[0]-dA5*H2[2]; // dB6/dp } = (dA5, dB5, dC5) x H2 - dC6 = dA5*H2[1]-dB5*H2[0]; // dC6/dp } - - // this gives the same results as multiplying the old with the new Jacobian - (*jacobianT)[i] += (dA2+dA3+dA4)*S3; (*jacobianT)[i+3] = ((dA0+2.*dA3)+(dA5+dA6))*P3; // dR := dR + S3*[(dA2, dB2, dC2) + (dA3, dB3, dC3) + (dA4, dB4, dC4)] - (*jacobianT)[i+1] += (dB2+dB3+dB4)*S3; (*jacobianT)[i+4] = ((dB0+2.*dB3)+(dB5+dB6))*P3; // dA := 1/3*[(dA0, dB0, dC0) + 2*(dA3, dB3, dC3) + (dA5, dB5, dC5) + (dA6, dB6, dC6)] - (*jacobianT)[i+2] += (dC2+dC3+dC4)*S3; (*jacobianT)[i+5] = ((dC0+2.*dC3)+(dC5+dC6))*P3; - } - - } // end if (!calcOnlyLastRowOfJ) - - unsigned int i = 42; - - (*jacobianT)[i+3] *= state7[6]; (*jacobianT)[i+4] *= state7[6]; (*jacobianT)[i+5] *= state7[6]; - - //first point - dA0 = H0[2]*(*jacobianT)[i+4]-H0[1]*(*jacobianT)[i+5] + A0; // dA0/dp } - dB0 = H0[0]*(*jacobianT)[i+5]-H0[2]*(*jacobianT)[i+3] + B0; // dB0/dp } = dA x H0 + (A0, B0, C0) - dC0 = H0[1]*(*jacobianT)[i+3]-H0[0]*(*jacobianT)[i+4] + C0; // dC0/dp } - - dA2 = dA0+(*jacobianT)[i+3]; // } - dB2 = dB0+(*jacobianT)[i+4]; // } = (dA0, dB0, dC0) + dA - dC2 = dC0+(*jacobianT)[i+5]; // } - - //second point - dA3 = (*jacobianT)[i+3]+dB2*H1[2]-dC2*H1[1] + (A3-A[0]); // dA3/dp } - dB3 = (*jacobianT)[i+4]+dC2*H1[0]-dA2*H1[2] + (B3-A[1]); // dB3/dp } = dA + (dA2, dB2, dC2) x H1 - dC3 = (*jacobianT)[i+5]+dA2*H1[1]-dB2*H1[0] + (C3-A[2]); // dC3/dp } - - dA4 = (*jacobianT)[i+3]+dB3*H1[2]-dC3*H1[1] + (A4-A[0]); // dA4/dp } - dB4 = (*jacobianT)[i+4]+dC3*H1[0]-dA3*H1[2] + (B4-A[1]); // dB4/dp } = dA + (dA3, dB3, dC3) x H1 - dC4 = (*jacobianT)[i+5]+dA3*H1[1]-dB3*H1[0] + (C4-A[2]); // dC4/dp } - - //last point - dA5 = dA4+dA4-(*jacobianT)[i+3]; // } - dB5 = dB4+dB4-(*jacobianT)[i+4]; // } = 2*(dA4, dB4, dC4) - dA - dC5 = dC4+dC4-(*jacobianT)[i+5]; // } - - dA6 = dB5*H2[2]-dC5*H2[1] + A6; // dA6/dp } - dB6 = dC5*H2[0]-dA5*H2[2] + B6; // dB6/dp } = (dA5, dB5, dC5) x H2 + (A6, B6, C6) - dC6 = dA5*H2[1]-dB5*H2[0] + C6; // dC6/dp } - - // this gives the same results as multiplying the old with the new Jacobian - (*jacobianT)[i] += (dA2+dA3+dA4)*S3/state7[6]; (*jacobianT)[i+3] = ((dA0+2.*dA3)+(dA5+dA6))*P3/state7[6]; // dR := dR + S3*[(dA2, dB2, dC2) + (dA3, dB3, dC3) + (dA4, dB4, dC4)] - (*jacobianT)[i+1] += (dB2+dB3+dB4)*S3/state7[6]; (*jacobianT)[i+4] = ((dB0+2.*dB3)+(dB5+dB6))*P3/state7[6]; // dA := 1/3*[(dA0, dB0, dC0) + 2*(dA3, dB3, dC3) + (dA5, dB5, dC5) + (dA6, dB6, dC6)] - (*jacobianT)[i+2] += (dC2+dC3+dC4)*S3/state7[6]; (*jacobianT)[i+5] = ((dC0+2.*dC3)+(dC5+dC6))*P3/state7[6]; - - } - - // - // Track parameters in last point - // - R[0] += (A2+A3+A4)*S3; A[0] += (SA[0]=((A0+2.*A3)+(A5+A6))*P3-A[0]); // R = R0 + S3*[(A2, B2, C2) + (A3, B3, C3) + (A4, B4, C4)] - R[1] += (B2+B3+B4)*S3; A[1] += (SA[1]=((B0+2.*B3)+(B5+B6))*P3-A[1]); // A = 1/3*[(A0, B0, C0) + 2*(A3, B3, C3) + (A5, B5, C5) + (A6, B6, C6)] - R[2] += (C2+C3+C4)*S3; A[2] += (SA[2]=((C0+2.*C3)+(C5+C6))*P3-A[2]); // SA = A_new - A_old - - // normalize A - double CBA = 1./sqrt(A[0]*A[0]+A[1]*A[1]+A[2]*A[2]); // 1/|A| - A[0] *= CBA; A[1] *= CBA; A[2] *= CBA; - - - // Test approximation quality on given step - double EST = fabs((A1+A6)-(A3+A4)) + - fabs((B1+B6)-(B3+B4)) + - fabs((C1+C6)-(C3+C4)); // EST = ||(ABC1+ABC6)-(ABC3+ABC4)||_1 = ||(axzy x H0 + ABC5 x H2) - (ABC2 x H1 + ABC3 x H1)||_1 - if (EST < 1.E-7) EST = 1.E-7; // prevent q from getting too large - if (debugLvl_ > 0) { - std::cout << " RKTrackRep::RKPropagate. Step = "<< S << "; quality EST = " << EST << " \n"; - } - return pow(DLT/EST, par); -} - - - -void RKTrackRep::initArrays() const { - memset(noiseArray_, 0x00, 7*7*sizeof(double)); - memset(noiseProjection_, 0x00, 7*7*sizeof(double)); - for (unsigned int i=0; i<7; ++i) // initialize as diagonal matrix - noiseProjection_[i*8] = 1; - memset(J_MMT_, 0x00, 7*7*sizeof(double)); - - fJacobian_.UnitMatrix(); - fNoise_.Zero(); - limits_.reset(); - - RKSteps_.reserve(100); - ExtrapSteps_.reserve(100); - - lastStartState_.getAuxInfo().ResizeTo(1); - lastEndState_.getAuxInfo().ResizeTo(1); -} - - -void RKTrackRep::getState7(const StateOnPlane& state, M1x7& state7) const { - - if (dynamic_cast(&state) != NULL) { - Exception exc("RKTrackRep::getState7 - cannot get pos or mom from a MeasurementOnPlane",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - const TVector3& U(state.getPlane()->getU()); - const TVector3& V(state.getPlane()->getV()); - const TVector3& O(state.getPlane()->getO()); - const TVector3& W(state.getPlane()->getNormal()); - - assert(state.getState().GetNrows() == 5); - const double* state5 = state.getState().GetMatrixArray(); - - double spu = getSpu(state); - - state7[0] = O.X() + state5[3]*U.X() + state5[4]*V.X(); // x - state7[1] = O.Y() + state5[3]*U.Y() + state5[4]*V.Y(); // y - state7[2] = O.Z() + state5[3]*U.Z() + state5[4]*V.Z(); // z - - state7[3] = spu * (W.X() + state5[1]*U.X() + state5[2]*V.X()); // a_x - state7[4] = spu * (W.Y() + state5[1]*U.Y() + state5[2]*V.Y()); // a_y - state7[5] = spu * (W.Z() + state5[1]*U.Z() + state5[2]*V.Z()); // a_z - - // normalize dir - double norm = 1. / sqrt(state7[3]*state7[3] + state7[4]*state7[4] + state7[5]*state7[5]); - for (unsigned int i=3; i<6; ++i) state7[i] *= norm; - - state7[6] = state5[0]; // q/p -} - - -void RKTrackRep::getState5(StateOnPlane& state, const M1x7& state7) const { - - // state5: (q/p, u', v'. u, v) - - double spu(1.); - - const TVector3& O(state.getPlane()->getO()); - const TVector3& U(state.getPlane()->getU()); - const TVector3& V(state.getPlane()->getV()); - const TVector3& W(state.getPlane()->getNormal()); - - TVector3 posShift(state7[0], state7[1], state7[2]); - posShift -= state.getPlane()->getO(); - - // force A to be in normal direction and set spu accordingly - double AtW = state7[3]*W.X() + state7[4]*W.Y() + state7[5]*W.Z(); - if (AtW < 0) { - //fDir *= -1.; - //AtW *= -1.; - spu = -1.; - } - - TVectorD& state5 = state.getState(); - - state5(0) = state7[6]; // q/p - state5(1) = (state7[3]*U.X() + state7[4]*U.Y() + state7[5]*U.Z()) / AtW; // u' = (A * U) / (A * W) - state5(2) = (state7[3]*V.X() + state7[4]*V.Y() + state7[5]*V.Z()) / AtW; // v' = (A * V) / (A * W) - state5(3) = ((state7[0]-O.X())*U.X() + - (state7[1]-O.Y())*U.Y() + - (state7[2]-O.Z())*U.Z()); // u = (pos - O) * U - state5(4) = ((state7[0]-O.X())*V.X() + - (state7[1]-O.Y())*V.Y() + - (state7[2]-O.Z())*V.Z()); // v = (pos - O) * V - - setSpu(state, spu); - -} - - - -void RKTrackRep::transformPM7(const MeasuredStateOnPlane& state, - M7x7& out7x7) const { - - // get vectors and aux variables - const TVector3& U(state.getPlane()->getU()); - const TVector3& V(state.getPlane()->getV()); - const TVector3& W(state.getPlane()->getNormal()); - - const TVectorD& state5(state.getState()); - double spu(getSpu(state)); - - M1x3 pTilde; - pTilde[0] = spu * (W.X() + state5(1)*U.X() + state5(2)*V.X()); // a_x - pTilde[1] = spu * (W.Y() + state5(1)*U.Y() + state5(2)*V.Y()); // a_y - pTilde[2] = spu * (W.Z() + state5(1)*U.Z() + state5(2)*V.Z()); // a_z - - M5x7 J_pM; - calcJ_pM_5x7(J_pM, U, V, pTilde, spu); - - // since the Jacobian contains a lot of zeros, and the resulting cov has to be symmetric, - // the multiplication can be done much faster directly on array level - // out = J_pM^T * in5x5 * J_pM - const M5x5& in5x5_ = *((M5x5*) state.getCov().GetMatrixArray()); - RKTools::J_pMTxcov5xJ_pM(J_pM, in5x5_, out7x7); -} - - -void RKTrackRep::calcJ_pM_5x7(M5x7& J_pM, const TVector3& U, const TVector3& V, const M1x3& pTilde, double spu) const { - /*if (debugLvl_ > 1) { - std::cout << "RKTrackRep::calcJ_pM_5x7 \n"; - std::cout << " U = "; U.Print(); - std::cout << " V = "; V.Print(); - std::cout << " pTilde = "; RKTools::printDim(pTilde, 3,1); - std::cout << " spu = " << spu << "\n"; - }*/ - - memset(J_pM, 0, sizeof(M5x7)); - - const double pTildeMag = sqrt(pTilde[0]*pTilde[0] + pTilde[1]*pTilde[1] + pTilde[2]*pTilde[2]); - const double pTildeMag2 = pTildeMag*pTildeMag; - - const double utpTildeOverpTildeMag2 = (U.X()*pTilde[0] + U.Y()*pTilde[1] + U.Z()*pTilde[2]) / pTildeMag2; - const double vtpTildeOverpTildeMag2 = (V.X()*pTilde[0] + V.Y()*pTilde[1] + V.Z()*pTilde[2]) / pTildeMag2; - - //J_pM matrix is d(x,y,z,ax,ay,az,q/p) / d(q/p,u',v',u,v) (out is 7x7) - - // d(x,y,z)/d(u) - J_pM[21] = U.X(); // [3][0] - J_pM[22] = U.Y(); // [3][1] - J_pM[23] = U.Z(); // [3][2] - // d(x,y,z)/d(v) - J_pM[28] = V.X(); // [4][0] - J_pM[29] = V.Y(); // [4][1] - J_pM[30] = V.Z(); // [4][2] - // d(q/p)/d(q/p) - J_pM[6] = 1.; // not needed for array matrix multiplication - // d(ax,ay,az)/d(u') - double fact = spu / pTildeMag; - J_pM[10] = fact * ( U.X() - pTilde[0]*utpTildeOverpTildeMag2 ); // [1][3] - J_pM[11] = fact * ( U.Y() - pTilde[1]*utpTildeOverpTildeMag2 ); // [1][4] - J_pM[12] = fact * ( U.Z() - pTilde[2]*utpTildeOverpTildeMag2 ); // [1][5] - // d(ax,ay,az)/d(v') - J_pM[17] = fact * ( V.X() - pTilde[0]*vtpTildeOverpTildeMag2 ); // [2][3] - J_pM[18] = fact * ( V.Y() - pTilde[1]*vtpTildeOverpTildeMag2 ); // [2][4] - J_pM[19] = fact * ( V.Z() - pTilde[2]*vtpTildeOverpTildeMag2 ); // [2][5] - - /*if (debugLvl_ > 1) { - std::cout << " J_pM_5x7_ = "; RKTools::printDim(J_pM_5x7_, 5,7); - }*/ -} - - -void RKTrackRep::transformPM6(const MeasuredStateOnPlane& state, - M6x6& out6x6) const { - - // get vectors and aux variables - const TVector3& U(state.getPlane()->getU()); - const TVector3& V(state.getPlane()->getV()); - const TVector3& W(state.getPlane()->getNormal()); - - const TVectorD& state5(state.getState()); - double spu(getSpu(state)); - - M1x3 pTilde; - pTilde[0] = spu * (W.X() + state5(1)*U.X() + state5(2)*V.X()); // a_x - pTilde[1] = spu * (W.Y() + state5(1)*U.Y() + state5(2)*V.Y()); // a_y - pTilde[2] = spu * (W.Z() + state5(1)*U.Z() + state5(2)*V.Z()); // a_z - - const double pTildeMag = sqrt(pTilde[0]*pTilde[0] + pTilde[1]*pTilde[1] + pTilde[2]*pTilde[2]); - const double pTildeMag2 = pTildeMag*pTildeMag; - - const double utpTildeOverpTildeMag2 = (U.X()*pTilde[0] + U.Y()*pTilde[1] + U.Z()*pTilde[2]) / pTildeMag2; - const double vtpTildeOverpTildeMag2 = (V.X()*pTilde[0] + V.Y()*pTilde[1] + V.Z()*pTilde[2]) / pTildeMag2; - - //J_pM matrix is d(x,y,z,px,py,pz) / d(q/p,u',v',u,v) (out is 6x6) - - const double qop = state5(0); - const double p = getCharge(state)/qop; // momentum - - M5x6 J_pM_5x6; - memset(J_pM_5x6, 0, sizeof(M5x6)); - - // d(px,py,pz)/d(q/p) - double fact = -1. * p / (pTildeMag * qop); - J_pM_5x6[3] = fact * pTilde[0]; // [0][3] - J_pM_5x6[4] = fact * pTilde[1]; // [0][4] - J_pM_5x6[5] = fact * pTilde[2]; // [0][5] - // d(px,py,pz)/d(u') - fact = p * spu / pTildeMag; - J_pM_5x6[9] = fact * ( U.X() - pTilde[0]*utpTildeOverpTildeMag2 ); // [1][3] - J_pM_5x6[10] = fact * ( U.Y() - pTilde[1]*utpTildeOverpTildeMag2 ); // [1][4] - J_pM_5x6[11] = fact * ( U.Z() - pTilde[2]*utpTildeOverpTildeMag2 ); // [1][5] - // d(px,py,pz)/d(v') - J_pM_5x6[15] = fact * ( V.X() - pTilde[0]*vtpTildeOverpTildeMag2 ); // [2][3] - J_pM_5x6[16] = fact * ( V.Y() - pTilde[1]*vtpTildeOverpTildeMag2 ); // [2][4] - J_pM_5x6[17] = fact * ( V.Z() - pTilde[2]*vtpTildeOverpTildeMag2 ); // [2][5] - // d(x,y,z)/d(u) - J_pM_5x6[18] = U.X(); // [3][0] - J_pM_5x6[19] = U.Y(); // [3][1] - J_pM_5x6[20] = U.Z(); // [3][2] - // d(x,y,z)/d(v) - J_pM_5x6[24] = V.X(); // [4][0] - J_pM_5x6[25] = V.Y(); // [4][1] - J_pM_5x6[26] = V.Z(); // [4][2] - - - // do the transformation - // out = J_pM^T * in5x5 * J_pM - const M5x5& in5x5_ = *((M5x5*) state.getCov().GetMatrixArray()); - RKTools::J_pMTxcov5xJ_pM(J_pM_5x6, in5x5_, out6x6); - -} - - -void RKTrackRep::transformM7P(const M7x7& in7x7, - const M1x7& state7, - MeasuredStateOnPlane& state) const { // plane must already be set! - - // get vectors and aux variables - const TVector3& U(state.getPlane()->getU()); - const TVector3& V(state.getPlane()->getV()); - const TVector3& W(state.getPlane()->getNormal()); - - M1x3& A = *((M1x3*) &state7[3]); - - M5x7 J_Mp; - calcJ_Mp_7x5(J_Mp, U, V, W, A); - - // since the Jacobian contains a lot of zeros, and the resulting cov has to be symmetric, - // the multiplication can be done much faster directly on array level - // out5x5 = J_Mp^T * in * J_Mp - M5x5& out5x5_ = *((M5x5*) state.getCov().GetMatrixArray()); - RKTools::J_MpTxcov7xJ_Mp(J_Mp, in7x7, out5x5_); - -} - - -void RKTrackRep::calcJ_Mp_7x5(M7x5& J_Mp, const TVector3& U, const TVector3& V, const TVector3& W, const M1x3& A) const { - - /*if (debugLvl_ > 1) { - std::cout << "RKTrackRep::calcJ_Mp_7x5 \n"; - std::cout << " U = "; U.Print(); - std::cout << " V = "; V.Print(); - std::cout << " W = "; W.Print(); - std::cout << " A = "; RKTools::printDim(A, 3,1); - }*/ - - memset(J_Mp, 0, sizeof(M7x5)); - - const double AtU = A[0]*U.X() + A[1]*U.Y() + A[2]*U.Z(); - const double AtV = A[0]*V.X() + A[1]*V.Y() + A[2]*V.Z(); - const double AtW = A[0]*W.X() + A[1]*W.Y() + A[2]*W.Z(); - - // J_Mp matrix is d(q/p,u',v',u,v) / d(x,y,z,ax,ay,az,q/p) (in is 7x7) - - // d(u')/d(ax,ay,az) - double fact = 1./(AtW*AtW); - J_Mp[16] = fact * (U.X()*AtW - W.X()*AtU); // [3][1] - J_Mp[21] = fact * (U.Y()*AtW - W.Y()*AtU); // [4][1] - J_Mp[26] = fact * (U.Z()*AtW - W.Z()*AtU); // [5][1] - // d(v')/d(ax,ay,az) - J_Mp[17] = fact * (V.X()*AtW - W.X()*AtV); // [3][2] - J_Mp[22] = fact * (V.Y()*AtW - W.Y()*AtV); // [4][2] - J_Mp[27] = fact * (V.Z()*AtW - W.Z()*AtV); // [5][2] - // d(q/p)/d(q/p) - J_Mp[30] = 1.; // [6][0] - not needed for array matrix multiplication - //d(u)/d(x,y,z) - J_Mp[3] = U.X(); // [0][3] - J_Mp[8] = U.Y(); // [1][3] - J_Mp[13] = U.Z(); // [2][3] - //d(v)/d(x,y,z) - J_Mp[4] = V.X(); // [0][4] - J_Mp[9] = V.Y(); // [1][4] - J_Mp[14] = V.Z(); // [2][4] - - /*if (debugLvl_ > 1) { - std::cout << " J_Mp_7x5_ = "; RKTools::printDim(J_Mp, 7,5); - }*/ - -} - - -void RKTrackRep::transformM6P(const M6x6& in6x6, - const M1x7& state7, - MeasuredStateOnPlane& state) const { // plane and charge must already be set! - - // get vectors and aux variables - const TVector3& U(state.getPlane()->getU()); - const TVector3& V(state.getPlane()->getV()); - const TVector3& W(state.getPlane()->getNormal()); - - const double AtU = state7[3]*U.X() + state7[4]*U.Y() + state7[5]*U.Z(); - const double AtV = state7[3]*V.X() + state7[4]*V.Y() + state7[5]*V.Z(); - const double AtW = state7[3]*W.X() + state7[4]*W.Y() + state7[5]*W.Z(); - - // J_Mp matrix is d(q/p,u',v',u,v) / d(x,y,z,px,py,pz) (in is 6x6) - - const double qop = state7[6]; - const double p = getCharge(state)/qop; // momentum - - M6x5 J_Mp_6x5; - memset(J_Mp_6x5, 0, sizeof(M6x5)); - - //d(u)/d(x,y,z) - J_Mp_6x5[3] = U.X(); // [0][3] - J_Mp_6x5[8] = U.Y(); // [1][3] - J_Mp_6x5[13] = U.Z(); // [2][3] - //d(v)/d(x,y,z) - J_Mp_6x5[4] = V.X(); // [0][4] - J_Mp_6x5[9] = V.Y(); // [1][4] - J_Mp_6x5[14] = V.Z(); // [2][4] - // d(q/p)/d(px,py,pz) - double fact = (-1.) * qop / p; - J_Mp_6x5[15] = fact * state7[3]; // [3][0] - J_Mp_6x5[20] = fact * state7[4]; // [4][0] - J_Mp_6x5[25] = fact * state7[5]; // [5][0] - // d(u')/d(px,py,pz) - fact = 1./(p*AtW*AtW); - J_Mp_6x5[16] = fact * (U.X()*AtW - W.X()*AtU); // [3][1] - J_Mp_6x5[21] = fact * (U.Y()*AtW - W.Y()*AtU); // [4][1] - J_Mp_6x5[26] = fact * (U.Z()*AtW - W.Z()*AtU); // [5][1] - // d(v')/d(px,py,pz) - J_Mp_6x5[17] = fact * (V.X()*AtW - W.X()*AtV); // [3][2] - J_Mp_6x5[22] = fact * (V.Y()*AtW - W.Y()*AtV); // [4][2] - J_Mp_6x5[27] = fact * (V.Z()*AtW - W.Z()*AtV); // [5][2] - - // do the transformation - // out5x5 = J_Mp^T * in * J_Mp - M5x5& out5x5_ = *((M5x5*) state.getCov().GetMatrixArray()); - RKTools::J_MpTxcov6xJ_Mp(J_Mp_6x5, in6x6, out5x5_); - -} - - -// -// Runge-Kutta method for tracking a particles through a magnetic field. -// Uses Nystroem algorithm (See Handbook Nat. Bur. of Standards, procedure 25.5.20) -// -// Input parameters: -// SU - plane parameters -// SU[0] - direction cosines normal to surface Ex -// SU[1] - ------- Ey -// SU[2] - ------- Ez; Ex*Ex+Ey*Ey+Ez*Ez=1 -// SU[3] - distance to surface from (0,0,0) > 0 cm -// -// state7 - initial parameters (coordinates(cm), direction, -// charge/momentum (Gev-1) -// cov and derivatives this parameters (7x7) -// -// X Y Z Ax Ay Az q/P -// state7[0] state7[1] state7[2] state7[3] state7[4] state7[5] state7[6] -// -// dX/dp dY/dp dZ/dp dAx/dp dAy/dp dAz/dp d(q/P)/dp -// cov[ 0] cov[ 1] cov[ 2] cov[ 3] cov[ 4] cov[ 5] cov[ 6] d()/dp1 -// -// cov[ 7] cov[ 8] cov[ 9] cov[10] cov[11] cov[12] cov[13] d()/dp2 -// ............................................................................ d()/dpND -// -// Authors: R.Brun, M.Hansroul, V.Perevoztchikov (Geant3) -// -bool RKTrackRep::RKutta(const M1x4& SU, - const DetPlane& plane, - double charge, - M1x7& state7, - M7x7* jacobianT, - double& coveredDistance, - bool& checkJacProj, - M7x7& noiseProjection, - StepLimits& limits, - bool onlyOneStep, - bool calcOnlyLastRowOfJ) const { - - // limits, check-values, etc. Can be tuned! - static const double Wmax = 6000.; // max. way allowed [cm] TR 1/12/2014 3000->6000 - static const double AngleMax = 6.3; // max. total angle change of momentum. Prevents extrapolating a curler round and round if no active plane is found. - static const double Pmin = 4.E-3; // minimum momentum for propagation [GeV] - static const unsigned int maxNumIt = 1000; // maximum number of iterations in main loop - // Aux parameters - M1x3& R = *((M1x3*) &state7[0]); // Start coordinates [cm] (x, y, z) - M1x3& A = *((M1x3*) &state7[3]); // Start directions (ax, ay, az); ax^2+ay^2+az^2=1 - M1x3 SA = {0.,0.,0.}; // Start directions derivatives dA/S - double Way = 0.; // Sum of absolute values of all extrapolation steps [cm] - double momentum = fabs(charge/state7[6]);// momentum [GeV] - double relMomLoss = 0; // relative momentum loss in RKutta - double deltaAngle = 0.; // total angle by which the momentum has changed during extrapolation - double An(0), S(0), Sl(0), CBA(0); - - - if (debugLvl_ > 0) { - std::cout << "RKTrackRep::RKutta \n"; - std::cout << "position: "; TVector3(R[0], R[1], R[2]).Print(); - std::cout << "direction: "; TVector3(A[0], A[1], A[2]).Print(); - std::cout << "momentum: " << momentum << " GeV\n"; - std::cout << "destination: "; plane.Print(); - } - - checkJacProj = false; - - // check momentum - if(momentum < Pmin){ - std::ostringstream sstream; - sstream << "RKTrackRep::RKutta ==> momentum too low: " << momentum*1000. << " MeV"; - Exception exc(sstream.str(),__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - unsigned int counter(0); - - // Step estimation (signed) - S = estimateStep(state7, SU, plane, charge, relMomLoss, limits); - - // - // Main loop of Runge-Kutta method - // - while (fabs(S) >= MINSTEP || counter == 0) { - - if(++counter > maxNumIt){ - Exception exc("RKTrackRep::RKutta ==> maximum number of iterations exceeded",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - if (debugLvl_ > 0) { - std::cout << "------ RKutta main loop nr. " << counter-1 << " ------\n"; - } - - M1x3 ABefore = { A[0], A[1], A[2] }; // M1x3 ABefore(A); - RKPropagate(state7, jacobianT, SA, S, true, calcOnlyLastRowOfJ); // the actual Runge Kutta propagation - - // update paths - coveredDistance += S; // add stepsize to way (signed) - Way += fabs(S); - - // check way limit - if(Way > Wmax){ - std::ostringstream sstream; - sstream << "RKTrackRep::RKutta ==> Total extrapolation length is longer than length limit : " << Way << " cm !"; - Exception exc(sstream.str(),__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - if (onlyOneStep) return(true); - - // if stepsize has been limited by material, break the loop and return. No linear extrapolation! - if (limits.getLowestLimit().first == stp_momLoss) { - if (debugLvl_ > 0) { - std::cout<<" momLossExceeded -> return(true); \n"; - } - return(true); - } - - // if stepsize has been limited by material boundary, break the loop and return. No linear extrapolation! - if (limits.getLowestLimit().first == stp_boundary) { - if (debugLvl_ > 0) { - std::cout<<" at boundary -> return(true); \n"; - } - return(true); - } - - - // estimate Step for next loop or linear extrapolation - Sl = S; // last S used - limits.removeLimit(stp_fieldCurv); - limits.removeLimit(stp_momLoss); - limits.removeLimit(stp_boundary); - limits.removeLimit(stp_plane); - S = estimateStep(state7, SU, plane, charge, relMomLoss, limits); - - if (limits.getLowestLimit().first == stp_plane && - fabs(S) < MINSTEP) { - if (debugLvl_ > 0) { - std::cout<<" (at Plane && fabs(S) < MINSTEP) -> break and do linear extrapolation \n"; - } - break; - } - if (limits.getLowestLimit().first == stp_momLoss && - fabs(S) < MINSTEP) { - if (debugLvl_ > 0) { - std::cout<<" (momLossExceeded && fabs(S) < MINSTEP) -> return(true), no linear extrapolation; \n"; - } - RKSteps_.erase(RKSteps_.end()-1); - --RKStepsFXStop_; - return(true); // no linear extrapolation! - } - - // check if total angle is bigger than AngleMax. Can happen if a curler should be fitted and it does not hit the active area of the next plane. - deltaAngle += acos(ABefore[0]*A[0] + ABefore[1]*A[1] + ABefore[2]*A[2]); - if (fabs(deltaAngle) > AngleMax){ - std::ostringstream sstream; - sstream << "RKTrackRep::RKutta ==> Do not get to an active plane! Already extrapolated " << deltaAngle * 180 / TMath::Pi() << "°."; - Exception exc(sstream.str(),__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - // check if we went back and forth multiple times -> we don't come closer to the plane! - if (counter > 3){ - if (S *RKSteps_.at(counter-1).matStep_.stepSize_ < 0 && - RKSteps_.at(counter-1).matStep_.stepSize_*RKSteps_.at(counter-2).matStep_.stepSize_ < 0 && - RKSteps_.at(counter-2).matStep_.stepSize_*RKSteps_.at(counter-3).matStep_.stepSize_ < 0){ - Exception exc("RKTrackRep::RKutta ==> Do not get closer to plane!",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - } - - } //end of main loop - - - // - // linear extrapolation to plane - // - if (limits.getLowestLimit().first == stp_plane) { - - if (fabs(Sl) > 0.001*MINSTEP){ - if (debugLvl_ > 0) { - std::cout << " RKutta - linear extrapolation to surface\n"; - } - Sl = 1./Sl; // Sl = inverted last Stepsize Sl - - // normalize SA - SA[0]*=Sl; SA[1]*=Sl; SA[2]*=Sl; // SA/Sl = delta A / delta way; local derivative of A with respect to the length of the way - - // calculate A - A[0] += SA[0]*S; // S = distance to surface - A[1] += SA[1]*S; // A = A + S * SA*Sl - A[2] += SA[2]*S; - - // normalize A - CBA = 1./sqrt(A[0]*A[0]+A[1]*A[1]+A[2]*A[2]); // 1/|A| - A[0] *= CBA; A[1] *= CBA; A[2] *= CBA; - - R[0] += S*(A[0]-0.5*S*SA[0]); // R = R + S*(A - 0.5*S*SA); approximation for final point on surface - R[1] += S*(A[1]-0.5*S*SA[1]); - R[2] += S*(A[2]-0.5*S*SA[2]); - - - coveredDistance += S; - Way += fabs(S); - } - else if (debugLvl_ > 0) { - std::cout << " RKutta - last stepsize too small -> can't do linear extrapolation! \n"; - } - - // - // Project Jacobian of extrapolation onto destination plane - // - if (jacobianT != NULL) { - - // projected jacobianT - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 0 - // x x x x x x 1 - - if (checkJacProj && RKSteps_.size()>0){ - Exception exc("RKTrackRep::Extrap ==> covariance is projected onto destination plane again",__LINE__,__FILE__); - throw exc; - } - - if (debugLvl_ > 0) { - //std::cout << " Jacobian^T of extrapolation before Projection:\n"; - //RKTools::printDim(*jacobianT, 7,7); - std::cout << " Project Jacobian of extrapolation onto destination plane\n"; - } - An = A[0]*SU[0] + A[1]*SU[1] + A[2]*SU[2]; - An = (fabs(An) > 1.E-7 ? 1./An : 0); // 1/A_normal - double norm; - int i=0; - if (calcOnlyLastRowOfJ) - i = 42; - - for(; i<49; i+=7) { - double* jacPtr = *jacobianT; - norm = (jacPtr[i]*SU[0] + jacPtr[i+1]*SU[1] + jacPtr[i+2]*SU[2]) * An; // dR_normal / A_normal - jacPtr[i] -= norm*A [0]; jacPtr[i+1] -= norm*A [1]; jacPtr[i+2] -= norm*A [2]; - jacPtr[i+3] -= norm*SA[0]; jacPtr[i+4] -= norm*SA[1]; jacPtr[i+5] -= norm*SA[2]; - } - checkJacProj = true; - - - if (debugLvl_ > 0) { - //std::cout << " Jacobian^T of extrapolation after Projection:\n"; - //RKTools::printDim(*jacobianT, 7,7); - } - - if (!calcOnlyLastRowOfJ) { - for (int iRow = 0; iRow < 3; ++iRow) { - for (int iCol = 0; iCol < 3; ++iCol) { - noiseProjection[iRow*7 + iCol] = (iRow == iCol) - An * SU[iCol] * A[iRow]; - noiseProjection[(iRow + 3)*7 + iCol] = - An * SU[iCol] * SA[iRow]; - - } - } - - // noiseProjection will look like this: - // x x x 0 0 0 0 - // x x x 0 0 0 0 - // x x x 0 0 0 0 - // x x x 1 0 0 0 - // x x x 0 1 0 0 - // x x x 0 0 1 0 - // 0 0 0 0 0 0 1 - } - - } - } // end of linear extrapolation to surface - - return(true); - -} - - -double RKTrackRep::estimateStep(const M1x7& state7, - const M1x4& SU, - const DetPlane& plane, - const double& charge, - double& relMomLoss, - StepLimits& limits) const { - - if (useCache_) { - if (cachePos_ >= RKSteps_.size()) { - useCache_ = false; - } - else { - if (RKSteps_.at(cachePos_).limits_.getLowestLimit().first == stp_plane) { - // we need to step exactly to the plane, so don't use the cache! - useCache_ = false; - RKSteps_.erase(RKSteps_.begin() + cachePos_, RKSteps_.end()); - } - else { - if (debugLvl_ > 0) { - std::cout << " RKTrackRep::estimateStep: use stepSize " << cachePos_ << " from cache: " << RKSteps_.at(cachePos_).matStep_.stepSize_ << "\n"; - } - //for(int n = 0; n < 1*7; ++n) RKSteps_[cachePos_].state7_[n] = state7[n]; - ++RKStepsFXStop_; - limits = RKSteps_.at(cachePos_).limits_; - return RKSteps_.at(cachePos_++).matStep_.stepSize_; - } - } - } - - limits.setLimit(stp_sMax, 25.); // max. step allowed [cm] - - if (debugLvl_ > 0) { - std::cout << " RKTrackRep::estimateStep \n"; - std::cout << " position: "; TVector3(state7[0], state7[1], state7[2]).Print(); - std::cout << " direction: "; TVector3(state7[3], state7[4], state7[5]).Print(); - } - - // calculate SL distance to surface - double Dist = SU[3] - (state7[0]*SU[0] + - state7[1]*SU[1] + - state7[2]*SU[2]); // Distance between start coordinates and surface - double An = state7[3]*SU[0] + - state7[4]*SU[1] + - state7[5]*SU[2]; // An = dir * N; component of dir normal to surface - - double SLDist; // signed - if (fabs(An) > 1.E-10) - SLDist = Dist/An; - else { - SLDist = Dist*1.E10; - if (An<0) SLDist *= -1.; - } - - limits.setLimit(stp_plane, SLDist); - limits.setStepSign(SLDist); - - if (debugLvl_ > 0) { - std::cout << " Distance to plane: " << Dist << "\n"; - std::cout << " SL distance to plane: " << SLDist << "\n"; - if (limits.getStepSign()>0) - std::cout << " Direction is pointing towards surface.\n"; - else - std::cout << " Direction is pointing away from surface.\n"; - } - // DONE calculate SL distance to surface - - // - // Limit according to curvature and magnetic field inhomogenities - // and improve stepsize estimation to reach plane - // - double fieldCurvLimit(limits.getLowestLimitSignedVal()); // signed - std::pair distVsStep (9.E99, 9.E99); // first: smallest straight line distances to plane; second: RK steps - - static const unsigned int maxNumIt = 10; - unsigned int counter(0); - - while (fabs(fieldCurvLimit) > MINSTEP) { - - if(++counter > maxNumIt){ - // if max iterations are reached, take a safe value - // (in previous iteration, fieldCurvLimit has been not more than doubled) - // and break. - fieldCurvLimit *= 0.5; - break; - } - - M1x7 state7_temp = { state7[0], state7[1], state7[2], state7[3], state7[4], state7[5], state7[6] }; // invalid: M1x7 state7_temp(state7); - M1x3 SA; - - double q = RKPropagate(state7_temp, NULL, SA, fieldCurvLimit, true); - if (debugLvl_ > 0) { - std::cout << " maxStepArg = " << fieldCurvLimit << "; q = " << q << " \n"; - } - - // remember steps and resulting SL distances to plane for stepsize improvement - // calculate distance to surface - Dist = SU[3] - (state7_temp[0] * SU[0] + - state7_temp[1] * SU[1] + - state7_temp[2] * SU[2]); // Distance between position and surface - - An = state7_temp[3] * SU[0] + - state7_temp[4] * SU[1] + - state7_temp[5] * SU[2]; // An = dir * N; component of dir normal to surface - - if (fabs(Dist/An) < fabs(distVsStep.first)) { - distVsStep.first = Dist/An; - distVsStep.second = fieldCurvLimit; - } - - // resize limit according to q never grow step size more than - // two-fold to avoid infinite grow-shrink loops with strongly - // inhomogeneous fields. - if (q>2) { - fieldCurvLimit *= 2; - break; - } - - fieldCurvLimit *= q * 0.95; - - if (fabs(q-1) < 0.25 || // good enough! - fabs(fieldCurvLimit) > limits.getLowestLimitVal()) // other limits are lower! - break; - } - if (fabs(fieldCurvLimit) < MINSTEP) - limits.setLimit(stp_fieldCurv, MINSTEP); - else - limits.setLimit(stp_fieldCurv, fieldCurvLimit); - - double stepToPlane(limits.getLimitSigned(stp_plane)); - if (fabs(distVsStep.first) < 8.E99) { - stepToPlane = distVsStep.first + distVsStep.second; - } - limits.setLimit(stp_plane, stepToPlane); - - - // - // Select direction - // - // auto select - if (propDir_ == 0 || !plane.isFinite()){ - if (debugLvl_ > 0) { - std::cout << " auto select direction"; - if (!plane.isFinite()) std::cout << ", plane is not finite"; - std::cout << ".\n"; - } - } - // see if straight line approximation is ok - else if ( limits.getLimit(stp_plane) < 0.2*limits.getLimit(stp_fieldCurv) ){ - if (debugLvl_ > 0) { - std::cout << " straight line approximation is fine.\n"; - } - - // if direction is pointing to active part of surface - if( plane.isInActive(state7[0], state7[1], state7[2], state7[3], state7[4], state7[5]) ) { - if (debugLvl_ > 0) { - std::cout << " direction is pointing to active part of surface. \n"; - } - } - // if we are near the plane, but not pointing to the active area, make a big step! - else { - limits.removeLimit(stp_plane); - limits.setStepSign(propDir_); - if (debugLvl_ > 0) { - std::cout << " we are near the plane, but not pointing to the active area. make a big step! \n"; - } - } - } - // propDir_ is set and we are not pointing to an active part of a plane -> propDir_ decides! - else { - if (limits.getStepSign() * propDir_ < 0){ - limits.removeLimit(stp_plane); - limits.setStepSign(propDir_); - if (debugLvl_ > 0) { - std::cout << " invert Step according to propDir_ and make a big step. \n"; - } - } - } - - - // call stepper and reduce stepsize if step not too small - static const RKStep defaultRKStep; - RKSteps_.push_back( defaultRKStep ); - std::vector::iterator lastStep = RKSteps_.end() - 1; - //!invalid: RKSteps_.back().state7_ = { state7[0], state7[1], state7[2], state7[3], state7[4], state7[5], state7[6] }; - for(int n = 0; n < 1*7; ++n) lastStep->state7_[n] = state7[n]; - ++RKStepsFXStop_; - if (/*!fNoMaterial*/ true){ - - if(limits.getLowestLimitVal() > MINSTEP){ // only call stepper if step estimation big enough - M1x7 state7_temp = { state7[0], state7[1], state7[2], state7[3], state7[4], state7[5], state7[6] }; // invalid: ... = (state7); - - MaterialEffects::getInstance()->stepper(this, - state7_temp, - charge/state7[6], // |p| - relMomLoss, - pdgCode_, - lastStep->matStep_.materialProperties_, - limits, - true); - } - else { //assume material has not changed - if (RKSteps_.size()>1) { - lastStep->matStep_.materialProperties_ = (lastStep - 1)->matStep_.materialProperties_; - } - } - } - - if (debugLvl_ > 0) { - std::cout << " final limits:\n"; - limits.Print(); - } - - double finalStep = limits.getLowestLimitSignedVal(); - - lastStep->matStep_.stepSize_ = finalStep; - lastStep->limits_ = limits; - - if (debugLvl_ > 0) { - std::cout << " --> Step to be used: " << finalStep << "\n"; - } - - return finalStep; - -} - - -TVector3 RKTrackRep::pocaOnLine(const TVector3& linePoint, const TVector3& lineDirection, const TVector3& point) const { - - TVector3 retVal(lineDirection); - - double t = 1./(retVal.Mag2()) * ((point*retVal) - (linePoint*retVal)); - retVal *= t; - retVal += linePoint; - return retVal; // = linePoint + t*lineDirection - -} - - -double RKTrackRep::Extrap(const DetPlane& startPlane, - const DetPlane& destPlane, - double charge, - bool& isAtBoundary, - M1x7& state7, - bool fillExtrapSteps, - TMatrixDSym* cov, // 5D - bool onlyOneStep, - bool stopAtBoundary, - double maxStep) const { - - static const unsigned int maxNumIt(500); - unsigned int numIt(0); - - double coveredDistance(0.); - double dqop(0.); - - const TVector3 W(destPlane.getNormal()); - M1x4 SU = {W.X(), W.Y(), W.Z(), destPlane.distance(0., 0., 0.)}; - - // make SU vector point away from origin - if (W*destPlane.getO() < 0) { - SU[0] *= -1; - SU[1] *= -1; - SU[2] *= -1; - } - - - M1x7 startState7; - memcpy(startState7, state7, sizeof(M1x7)); - - while(true){ - - if (debugLvl_ > 0) { - std::cout << "\n============ RKTrackRep::Extrap loop nr. " << numIt << " ============\n"; - std::cout << "Start plane: "; startPlane.Print(); - std::cout << "fillExtrapSteps " << fillExtrapSteps << "\n"; - } - - if(++numIt > maxNumIt){ - Exception exc("RKTrackRep::Extrap ==> maximum number of iterations exceeded",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - // initialize jacobianT with unit matrix - for(int i = 0; i < 7*7; ++i) J_MMT_[i] = 0; // invalid: J_MMT_.fill(0); - for(int i=0; i<7; ++i) J_MMT_[8*i] = 1.; - - M7x7* noise = NULL; - isAtBoundary = false; - - // Remember previous state - M1x7 oldState7; - memcpy(oldState7, state7, sizeof(M1x7)); - - // propagation - bool checkJacProj = false; - limits_.reset(); - limits_.setLimit(stp_sMaxArg, maxStep-fabs(coveredDistance)); - - if( ! RKutta(SU, destPlane, charge, state7, &J_MMT_, - coveredDistance, checkJacProj, noiseProjection_, - limits_, onlyOneStep, !fillExtrapSteps) ) { - Exception exc("RKTrackRep::Extrap ==> Runge Kutta propagation failed",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - bool atPlane(limits_.getLowestLimit().first == stp_plane); - if (limits_.getLowestLimit().first == stp_boundary) - isAtBoundary = true; - - - if (debugLvl_ > 0) { - std::cout<<"RKSteps \n"; - for (std::vector::iterator it = RKSteps_.begin(); it != RKSteps_.end(); ++it){ - std::cout << "stepSize = " << it->matStep_.stepSize_ << "\t"; - it->matStep_.materialProperties_.Print(); - } - std::cout<<"\n"; - } - - - - // call MatFX - if(fillExtrapSteps) { - noise = &noiseArray_; - for(int i = 0; i < 7*7; ++i) noiseArray_[i] = 0; // set noiseArray_ to 0 - } - - unsigned int nPoints(RKStepsFXStop_ - RKStepsFXStart_); - if (/*!fNoMaterial &&*/ nPoints>0){ - // momLoss has a sign - negative loss means momentum gain - double momLoss = MaterialEffects::getInstance()->effects(RKSteps_, - RKStepsFXStart_, - RKStepsFXStop_, - fabs(charge/state7[6]), // momentum - pdgCode_, - noise); - - RKStepsFXStart_ = RKStepsFXStop_; - - if (debugLvl_ > 0) { - std::cout << "momLoss: " << momLoss << " GeV; relative: " << momLoss/fabs(charge/state7[6]) << "\n"; - if (debugLvl_ > 1 && noise != NULL) { - std::cout << "7D noise: \n"; - RKTools::printDim(*noise, 7, 7); - } - } - - // do momLoss only for defined 1/momentum .ne.0 - if(fabs(state7[6])>1.E-10) { - double qop = charge/(fabs(charge/state7[6])-momLoss); - dqop = qop - state7[6]; - state7[6] = qop; - - // correct state7 with dx/dqop, dy/dqop ... Greatly improves extrapolation accuracy! - if (debugLvl_ > 0) { - std::cout << "correct state7 with dx/dqop, dy/dqop ...\n"; - } - for (unsigned int i=0; i<6; ++i) { - state7[i] += 0.5 * dqop * J_MMT_[6*7 + i]; - } - } - } // finished MatFX - - - // fill ExtrapSteps_ - if (fillExtrapSteps) { - static const ExtrapStep defaultExtrapStep; - ExtrapSteps_.push_back(defaultExtrapStep); - std::vector::iterator lastStep = ExtrapSteps_.end() - 1; - - // Store Jacobian of this step for final calculation. - memcpy(lastStep->jac7_, J_MMT_, sizeof(M7x7)); - - if( checkJacProj == true ){ - //project the noise onto the destPlane - RKTools::Np_N_NpT(noiseProjection_, noiseArray_); - - if (debugLvl_ > 1) { - std::cout << "7D noise projected onto plane: \n"; - RKTools::printDim(noiseArray_, 7, 7); - } - } - - // Store this step's noise for final calculation. - memcpy(lastStep->noise7_, noiseArray_, sizeof(M7x7)); - - if (debugLvl_ > 2) { - std::cout<<"ExtrapSteps \n"; - for (std::vector::iterator it = ExtrapSteps_.begin(); it != ExtrapSteps_.end(); ++it){ - std::cout << "7D Jacobian: "; RKTools::printDim((it->jac7_), 5,5); - std::cout << "7D noise: "; RKTools::printDim((it->noise7_), 5,5); - } - std::cout<<"\n"; - } - } - - - - // check if at boundary - if (stopAtBoundary) { - if (debugLvl_ > 0) { - std::cout << "stopAtBoundary -> break; \n "; - } - break; - } - - if (onlyOneStep) { - if (debugLvl_ > 0) { - std::cout << "onlyOneStep -> break; \n "; - } - break; - } - - //break if we arrived at destPlane - if(atPlane) { - if (debugLvl_ > 0) { - std::cout << "arrived at destPlane with a distance of " << destPlane.distance(state7[0], state7[1], state7[2]) << " cm left. "; - if (destPlane.isInActive(state7[0], state7[1], state7[2], state7[3], state7[4], state7[5])) - std::cout << "In active area of destPlane. \n"; - else - std::cout << "NOT in active area of plane. \n"; - } - break; - } - - } - - if (fillExtrapSteps) { - // propagate cov and add noise - calcForwardJacobianAndNoise(startState7, startPlane, state7, destPlane); - - if (cov != NULL) { - cov->Similarity(fJacobian_); - *cov += fNoise_; - } - - if (debugLvl_ > 0) { - if (cov != NULL) { - std::cout << "final covariance matrix after Extrap: "; cov->Print(); - } - } - } - - return coveredDistance; -} - - -void RKTrackRep::checkCache(const StateOnPlane& state, const SharedPlanePtr* plane) const { - - if (state.getRep() != this){ - Exception exc("RKTrackRep::checkCache ==> state is defined wrt. another TrackRep",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - if (dynamic_cast(&state) != NULL) { - Exception exc("RKTrackRep::checkCache - cannot extrapolate MeasurementOnPlane",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - cachePos_ = 0; - RKStepsFXStart_ = 0; - RKStepsFXStop_ = 0; - ExtrapSteps_.clear(); - initArrays(); - - - if (plane != NULL && - lastStartState_.getPlane().get() != NULL && - lastEndState_.getPlane().get() != NULL && - state.getPlane() == lastStartState_.getPlane() && - state.getState() == lastStartState_.getState() && - (*plane)->distance(getPos(lastEndState_)) <= MINSTEP) { - useCache_ = true; - - // clean up cache. Only use steps with same sign. - double firstStep(0); - for (unsigned int i=0; i 0) { - std::cout << "RKTrackRep::checkCache: use cached material and step values.\n"; - } - } - else { - - if (debugLvl_ > 0) { - std::cout << "RKTrackRep::checkCache: can NOT use cached material and step values.\n"; - - if (plane != NULL) { - if (state.getPlane() != lastStartState_.getPlane()) { - std::cout << "state.getPlane() != lastStartState_.getPlane()\n"; - } - else { - if (! (state.getState() == lastStartState_.getState())) { - std::cout << "state.getState() != lastStartState_.getState()\n"; - } - else if (lastEndState_.getPlane().get() != NULL) { - std::cout << "distance " << (*plane)->distance(getPos(lastEndState_)) << "\n"; - } - } - } - } - - useCache_ = false; - RKSteps_.clear(); - - lastStartState_.setStatePlane(state.getState(), state.getPlane()); - } -} - - -double RKTrackRep::momMag(const M1x7& state7) const { - double momMag2 = state7[3]*state7[3] + state7[4]*state7[4] + state7[5]*state7[5]; - return sqrt(momMag2); -} - - -bool RKTrackRep::isSameType(const AbsTrackRep* other) { - if (dynamic_cast(other) == NULL) - return false; - - return true; -} - - -bool RKTrackRep::isSame(const AbsTrackRep* other) { - if (getPDG() != other->getPDG()) - return false; - - return isSameType(other); -} - - -void RKTrackRep::Streamer(TBuffer &R__b) -{ - // Stream an object of class genfit::RKTrackRep. - - //This works around a msvc bug and should be harmless on other platforms - typedef ::genfit::RKTrackRep thisClass; - UInt_t R__s, R__c; - if (R__b.IsReading()) { - ::genfit::AbsTrackRep::Streamer(R__b); - Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } - R__b.CheckByteCount(R__s, R__c, thisClass::IsA()); - lastStartState_.setRep(this); - lastEndState_.setRep(this); - } else { - ::genfit::AbsTrackRep::Streamer(R__b); - R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE); - R__b.SetByteCount(R__c, kTRUE); - } -} - -} /* End of namespace genfit */ diff --git a/genfit/trackReps/src/StepLimits.cc b/genfit/trackReps/src/StepLimits.cc deleted file mode 100644 index 32f449f699..0000000000 --- a/genfit/trackReps/src/StepLimits.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "StepLimits.h" - -#include -#include -#include -#include - - -namespace genfit { - -const double StepLimits::maxLimit_ = 99.E99; - - -StepLimits& StepLimits::operator=(const StepLimits& other) { - for (unsigned int i=1; i StepLimits::getLowestLimit(double margin) const { - - double lowest(maxLimit_); - unsigned int iLowest(0); - - for (unsigned int i=1; i(static_cast(iLowest), lowest); -} - - -double StepLimits::getLowestLimitVal(double margin) const { - - double lowest(maxLimit_); - - for (unsigned int i=1; i value) - limits_[type] = value; -} - - -void StepLimits::setStepSign(char signedVal) { - if (signedVal < 0) - stepSign_ = -1; - else - stepSign_ = 1; -} - -void StepLimits::setStepSign(double signedVal) { - if (signedVal < 0.) - stepSign_ = -1; - else - stepSign_ = 1; -} - - -void StepLimits::reset() { - for (unsigned int i=1; i= maxLimit_) - continue; - - std::cout << " | " << limits_[i] << " cm due to "; - switch (static_cast(i)) { - case stp_noLimit: - break; - case stp_fieldCurv: - std::cout << "stp_fieldCurv (medium limit): stepsize limited by curvature and magnetic field inhomogenities"; - break; - case stp_momLoss: - std::cout << "stp_momLoss (medium limit): stepsize limited by stepper because maximum momLoss is reached"; - break; - case stp_sMax: - std::cout << "stp_sMax (medium limit): stepsize limited by SMax defined in #estimateStep()"; - break; - case stp_sMaxArg: - std::cout << "stp_sMaxArg (hard limit): stepsize limited by argument maxStepArg passed to #estimateStep()"; - break; - case stp_boundary: - std::cout << "stp_boundary (hard limit): stepsize limited by stepper because material boundary is encountered"; - break; - case stp_plane: - std::cout << "stp_plane (hard limit): stepsize limited because destination plane is reached"; - break; - case ENUM_NR_ITEMS: - break; - } - std::cout << "\n"; - } - std::cout << "\n"; -} - -} /* End of namespace genfit */ diff --git a/genfit/trackReps/src/TGeoMaterialInterface.cc b/genfit/trackReps/src/TGeoMaterialInterface.cc deleted file mode 100644 index 2f5fe723f2..0000000000 --- a/genfit/trackReps/src/TGeoMaterialInterface.cc +++ /dev/null @@ -1,249 +0,0 @@ -/* Copyright 2008-2014, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include -#include - -#include -#include -#include -#include -#include - -static const bool debug = false; -//static const bool debug = true; - -namespace genfit { - -double MeanExcEnergy_get(int Z); -double MeanExcEnergy_get(TGeoMaterial*); - - -bool -TGeoMaterialInterface::initTrack(double posX, double posY, double posZ, - double dirX, double dirY, double dirZ){ - #ifdef DEBUG - std::cout << "TGeoMaterialInterface::initTrack. \n"; - std::cout << "Pos "; TVector3(posX, posY, posZ).Print(); - std::cout << "Dir "; TVector3(dirX, dirY, dirZ).Print(); - #endif - - // Move to the new point. - bool result = !gGeoManager->IsSameLocation(posX, posY, posZ, kTRUE); - // Set the intended direction. - gGeoManager->SetCurrentDirection(dirX, dirY, dirZ); - return result; -} - - -void -TGeoMaterialInterface::getMaterialParameters(double& density, - double& Z, - double& A, - double& radiationLength, - double& mEE){ - - TGeoMaterial* mat = gGeoManager->GetCurrentVolume()->GetMedium()->GetMaterial(); - - density = mat->GetDensity(); - Z = mat->GetZ(); - A = mat->GetA(); - radiationLength = mat->GetRadLen(); - mEE = MeanExcEnergy_get(mat); - -} - - -void -TGeoMaterialInterface::getMaterialParameters(MaterialProperties& parameters) { - - TGeoMaterial* mat = gGeoManager->GetCurrentVolume()->GetMedium()->GetMaterial(); - - parameters.setMaterialProperties(mat->GetDensity(), - mat->GetZ(), - mat->GetA(), - mat->GetRadLen(), - MeanExcEnergy_get(mat)); - -} - - -double -TGeoMaterialInterface::findNextBoundary(const RKTrackRep* rep, - const M1x7& stateOrig, - double sMax, // signed - bool varField) -{ - const double delta(1.E-2); // cm, distance limit beneath which straight-line steps are taken. - const double epsilon(1.E-1); // cm, allowed upper bound on arch - // deviation from straight line - - M1x3 SA; - M1x7 state7, oldState7; - memcpy(oldState7, stateOrig, sizeof(state7)); - - int stepSign(sMax < 0 ? -1 : 1); - - double s = 0; // trajectory length to boundary - - const unsigned maxIt = 300; - unsigned it = 0; - - // Initialize the geometry to the current location (set by caller). - gGeoManager->FindNextBoundary(fabs(sMax) - s); - double safety = gGeoManager->GetSafeDistance(); - double slDist = gGeoManager->GetStep(); - double step = slDist; - - while (1) { - if (++it > maxIt){ - Exception exc("TGeoMaterialInterface::findNextBoundary ==> maximum number of iterations exceeded",__LINE__,__FILE__); - exc.setFatal(); - throw exc; - } - - // No boundary in sight? - if (s + safety > fabs(sMax)) { - if (debug) - std::cout << " next boundary is further away than sMax \n"; - return stepSign*(s + safety); //sMax; - } - - // Are we at the boundary? - if (slDist < delta) { - if (debug) - std::cout << " very close to the boundary -> return" - << " stepSign*(s + slDist) = " - << stepSign << "*(" << s + slDist << ")\n"; - return stepSign*(s + slDist); - } - - // We have to find whether there's any boundary on our path. - - // Follow curved arch, then see if we may have missed a boundary. - // Always propagate complete way from original start to avoid - // inconsistent extrapolations. - memcpy(state7, stateOrig, sizeof(state7)); - rep->RKPropagate(state7, NULL, SA, stepSign*(s + step), varField); - - // Straight line distance² between extrapolation finish and - // the end of the previously determined safe segment. - double dist2 = (pow(state7[0] - oldState7[0], 2) - + pow(state7[1] - oldState7[1], 2) - + pow(state7[2] - oldState7[2], 2)); - // Maximal lateral deviation². - double maxDeviation2 = 0.25*(step*step - dist2); - - if (step > safety - && maxDeviation2 > epsilon*epsilon) { - // Need to take a shorter step to reliably estimate material, - // but only if we didn't move by safety. In order to avoid - // issues with roundoff we check 'step > safety' instead of - // 'step != safety'. If we moved by safety, there couldn't have - // been a boundary that we missed along the path, but we could - // be on the boundary. - - // Take a shorter step, but never shorter than safety. - step = std::max(step / 2, safety); - } else { - gGeoManager->PushPoint(); - bool volChanged = initTrack(state7[0], state7[1], state7[2], - stepSign*state7[3], stepSign*state7[4], - stepSign*state7[5]); - - if (volChanged) { - // Move back to start. - gGeoManager->PopPoint(); - - // Extrapolation may not take the exact step length we asked - // for, so it can happen that a requested step < safety takes - // us across the boundary. This is then the best estimate we - // can get of the distance to the boundary with the stepper. - if (step <= safety) - return stepSign*(s + step); - - // Volume changed during the extrapolation. Take a shorter - // step, but never shorter than safety. - step = std::max(step / 2, safety); - } else { - // we're in the new place, the step was safe, advance - s += step; - - memcpy(oldState7, state7, sizeof(state7)); - gGeoManager->PopDummy(); // Pop stack, but stay in place. - - gGeoManager->FindNextBoundary(fabs(sMax) - s); - safety = gGeoManager->GetSafeDistance(); - step = slDist = gGeoManager->GetStep(); - } - } - } -} - - -double -TGeoMaterialInterface::findNextBoundaryAndStepStraight(double sMax) { - - gGeoManager->FindNextBoundaryAndStep(sMax); - return gGeoManager->GetStep(); - -} - - - - -/* -Reference for elemental mean excitation energies at: -http://physics.nist.gov/PhysRefData/XrayMassCoef/tab1.html - -Code ported from GEANT 3 -*/ - -const int MeanExcEnergy_NELEMENTS = 93; // 0 = vacuum, 1 = hydrogen, 92 = uranium -const double MeanExcEnergy_vals[] = {1.e15, 19.2, 41.8, 40.0, 63.7, 76.0, 78., 82.0, 95.0, 115.0, 137.0, 149.0, 156.0, 166.0, 173.0, 173.0, 180.0, 174.0, 188.0, 190.0, 191.0, 216.0, 233.0, 245.0, 257.0, 272.0, 286.0, 297.0, 311.0, 322.0, 330.0, 334.0, 350.0, 347.0, 348.0, 343.0, 352.0, 363.0, 366.0, 379.0, 393.0, 417.0, 424.0, 428.0, 441.0, 449.0, 470.0, 470.0, 469.0, 488.0, 488.0, 487.0, 485.0, 491.0, 482.0, 488.0, 491.0, 501.0, 523.0, 535.0, 546.0, 560.0, 574.0, 580.0, 591.0, 614.0, 628.0, 650.0, 658.0, 674.0, 684.0, 694.0, 705.0, 718.0, 727.0, 736.0, 746.0, 757.0, 790.0, 790.0, 800.0, 810.0, 823.0, 823.0, 830.0, 825.0, 794.0, 827.0, 826.0, 841.0, 847.0, 878.0, 890.0}; - - -double -MeanExcEnergy_get(int Z) { - assert(Z >= 0 && Z < MeanExcEnergy_NELEMENTS); - return MeanExcEnergy_vals[Z]; -} - - -double -MeanExcEnergy_get(TGeoMaterial* mat) { - if (mat->IsMixture()) { - double logMEE = 0.; - double denom = 0.; - TGeoMixture* mix = (TGeoMixture*)mat; - for (int i = 0; i < mix->GetNelements(); ++i) { - int index = int(floor((mix->GetZmixt())[i])); - logMEE += 1. / (mix->GetAmixt())[i] * (mix->GetWmixt())[i] * (mix->GetZmixt())[i] * log(MeanExcEnergy_get(index)); - denom += (mix->GetWmixt())[i] * (mix->GetZmixt())[i] * 1. / (mix->GetAmixt())[i]; - } - logMEE /= denom; - return exp(logMEE); - } else { // not a mixture - int index = int(floor(mat->GetZ())); - return MeanExcEnergy_get(index); - } -} - - -} /* End of namespace genfit */ diff --git a/genfit/trackReps/src/trackRepsLinkDef.h b/genfit/trackReps/src/trackRepsLinkDef.h deleted file mode 100644 index 1f338d662b..0000000000 --- a/genfit/trackReps/src/trackRepsLinkDef.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class genfit::RKTrackRep-; -#pragma link C++ class genfit::RKTools+; -#pragma link C++ class genfit::TGeoMaterialInterface+; -#pragma link C++ class genfit::MaterialEffects+; - -#endif diff --git a/genfit/utilities/include/HelixTrackModel.h b/genfit/utilities/include/HelixTrackModel.h deleted file mode 100644 index 884c71fa7c..0000000000 --- a/genfit/utilities/include/HelixTrackModel.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2013, Technische Universitaet Muenchen, - Authors: Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** - * @author Johannes Rauch (Technische Universität München, original author) - * - */ - - -/** @addtogroup utilities - * @{ - */ - -#ifndef genfit_HelixTrackModel_h -#define genfit_HelixTrackModel_h - -#include -#include - - -namespace genfit { - -/** - * @brief Helix track model for testing purposes - */ -class HelixTrackModel : public TObject { - - public: - - // Constructors/Destructors --------- - HelixTrackModel(const TVector3& pos, const TVector3& mom, double charge); - - TVector3 getPos(double tracklength) const; - void getPosMom(double tracklength, TVector3& pos, TVector3& mom) const; - void getPosDir(double tracklength, TVector3& pos, TVector3& dir) const { - getPosMom(tracklength, pos, dir); - dir.SetMag(1); - } - - - private: - - double sgn_; - double mom_; - double R_; // radius - TVector3 center_; - double alpha0_; - double theta_; - - - public: - ClassDef(HelixTrackModel,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_HelixTrackModel_h diff --git a/genfit/utilities/include/MeasurementCreator.h b/genfit/utilities/include/MeasurementCreator.h deleted file mode 100644 index 1a74758302..0000000000 --- a/genfit/utilities/include/MeasurementCreator.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ -/** - * @author Johannes Rauch (Technische Universität München, original author) - * - */ - - -/** @addtogroup utilities - * @{ - */ - -#ifndef genfit_MeasurementOnPlaneCreator_h -#define genfit_MeasurementOnPlaneCreator_h - -#include "AbsMeasurement.h" -#include "HelixTrackModel.h" - -#include -#include - - -namespace genfit { - - -enum eMeasurementType { Pixel = 0, - Spacepoint, - ProlateSpacepoint, - StripU, - StripV, - StripUV, - Wire, - WirePoint }; - - -/** - * @brief Create different measurement types along a HelixTrackModel for testing purposes. - */ -class MeasurementCreator : public TObject { - - - public: - - // Constructors/Destructors --------- - MeasurementCreator(); - - ~MeasurementCreator() {delete trackModel_;} - - //! Takes ownership! - void setTrackModel(const HelixTrackModel* model) {delete trackModel_; trackModel_ = model;} - void setResolution(double resolution) {resolution_ = resolution;} - void setResolutionWire(double resolutionWire) {resolutionWire_ = resolutionWire;} - void setOutlierProb(double outlierProb) {outlierProb_ = outlierProb;} - void setOutlierRange(double outlierRange) {outlierRange_ = outlierRange;} - void setThetaDetPlane(double thetaDetPlane) {thetaDetPlane_ = thetaDetPlane;} - void setPhiDetPlane(double phiDetPlane) {phiDetPlane_ = phiDetPlane;} - void setWireDir(const TVector3 wireDir) {wireDir_ = wireDir; wireDir_.SetMag(1.);} - void setMinDrift(double minDrift) {minDrift_ = minDrift;} - void setMaxDrift(double maxDrift) {maxDrift_ = maxDrift;} - void setIdealLRResolution(bool idealLRResolution) {idealLRResolution_ = idealLRResolution;} - void setUseSkew(bool useSkew) {useSkew_ = useSkew;} - void setSkewAngle(double skewAngle) {skewAngle_ = skewAngle;} - void setNSuperLayer(int nSuperLayer) {nSuperLayer_ = nSuperLayer;} - void setDebug(bool debug) {debug_ = debug;} - - - std::vector create(eMeasurementType, double tracklength, bool& outlier, int& lr); - std::vector create(eMeasurementType type, double tracklength) { - bool dummy1; - int dummy2; - return create(type, tracklength, dummy1, dummy2); - } - - void reset(); - - private: - - const HelixTrackModel* trackModel_; // ownership - - double resolution_; // cm; resolution of generated measurements - double resolutionWire_; // cm; resolution in wire direction of generated measurements (wire and prolate sp measurements) - - double outlierProb_; - double outlierRange_; - - // planarMeasurement specific - double thetaDetPlane_; // degree - double phiDetPlane_; // degree - - // WireMeasurement specific - int wireCounter_; - TVector3 wireDir_; - double minDrift_; - double maxDrift_; - bool idealLRResolution_; // resolve the l/r ambiguities of the wire measurements - bool useSkew_; - double skewAngle_; - int nSuperLayer_; - - // misc - int measurementCounter_; - bool debug_; - - - public: - ClassDef(MeasurementCreator,1) - -}; - -} /* End of namespace genfit */ -/** @} */ - -#endif // genfit_MeasurementOnPlaneCreator_h diff --git a/genfit/utilities/include/mySpacepointDetectorHit.h b/genfit/utilities/include/mySpacepointDetectorHit.h deleted file mode 100644 index 18c3753922..0000000000 --- a/genfit/utilities/include/mySpacepointDetectorHit.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#ifndef genfit_mySpacepointDetectorHit_h -#define genfit_mySpacepointDetectorHit_h - -#include - - -namespace genfit { - -/** @brief Example class for a spacepoint detector hit. - * - * @author Johannes Rauch (Technische Universität München, original author) - * - */ -class mySpacepointDetectorHit : public TObject { - - public: - mySpacepointDetectorHit() {;} - - mySpacepointDetectorHit(const TVector3& pos, const TMatrixDSym cov) - : pos_(pos), cov_(cov) {;} - - const TVector3 getPos() const {return pos_;} - const TMatrixDSym getCov() const {return cov_;} - - private: - - TVector3 pos_; - TMatrixDSym cov_; - - ClassDef(mySpacepointDetectorHit,1) -}; -/** @} */ - -} /* End of namespace genfit */ - -#endif // genfit_mySpacepointDetectorHit_h diff --git a/genfit/utilities/include/mySpacepointMeasurement.h b/genfit/utilities/include/mySpacepointMeasurement.h deleted file mode 100644 index 439eb98cf0..0000000000 --- a/genfit/utilities/include/mySpacepointMeasurement.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#ifndef genfit_mySpacepointMeasurement_h -#define genfit_mySpacepointMeasurement_h - -#include "SpacepointMeasurement.h" -#include "TrackCandHit.h" -#include "mySpacepointDetectorHit.h" - - -namespace genfit { - -/** @brief Example class for a spacepoint measurement which can be created - * from mySpacepointDetectorHit via the MeasurementFactory. - * - * @author Johannes Rauch (Technische Universität München, original author) - * - */ -class mySpacepointMeasurement : public SpacepointMeasurement { - - public: - - /** Default constructor for ROOT IO. */ - mySpacepointMeasurement() : - SpacepointMeasurement() {;} - - mySpacepointMeasurement(const mySpacepointDetectorHit* detHit, const TrackCandHit* hit) : - SpacepointMeasurement() - { - rawHitCoords_(0) = detHit->getPos()(0); - rawHitCoords_(1) = detHit->getPos()(1); - rawHitCoords_(2) = detHit->getPos()(2); - rawHitCov_ = detHit->getCov(); - detId_ = hit->getDetId(); - hitId_ = hit->getHitId(); - } - - virtual AbsMeasurement* clone() const {return new mySpacepointMeasurement(*this);} - - ClassDef(mySpacepointMeasurement,1) -}; -/** @} */ - -} /* End of namespace genfit */ - -#endif // genfit_mySpacepointMeasurement_h diff --git a/genfit/utilities/src/HelixTrackModel.cc b/genfit/utilities/src/HelixTrackModel.cc deleted file mode 100644 index 12bdabbfd5..0000000000 --- a/genfit/utilities/src/HelixTrackModel.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "HelixTrackModel.h" -#include - -#include -#include - -namespace genfit { - -HelixTrackModel::HelixTrackModel(const TVector3& pos, const TVector3& mom, double charge) { - - mom_ = mom.Mag(); - - TVector3 B = genfit::FieldManager::getInstance()->getFieldVal(pos); - std::cout<<"check " << B.Y() << "\n"; - // B must point in Z direction - // assert(B.X() == 0); - // assert(B.Y() == 0); - - double Bz = B.Z(); - - // calc helix parameters - TVector3 dir2D(mom); - dir2D.SetZ(0); - dir2D.SetMag(1.); - R_ = 100.*mom.Perp()/(0.0299792458*Bz) / fabs(charge); - sgn_ = 1; - if (charge<0) sgn_=-1.; - center_ = pos + sgn_ * R_ * dir2D.Orthogonal(); - alpha0_ = (pos-center_).Phi(); - - theta_ = mom.Theta(); - - //std::cout<<"radius " << R_ << " center "; - //center_.Print(); - -} - - -TVector3 HelixTrackModel::getPos(double tracklength) const { - - TVector3 pos; - - double angle = alpha0_ - sgn_ * tracklength / R_ * sin(theta_); - - TVector3 radius(R_,0,0); - radius.SetPhi(angle); - pos = center_ + radius; - pos.SetZ(center_.Z() - sgn_ * ((alpha0_-angle)*R_ * tan(theta_-M_PI/2.)) ); - - return pos; -} - -void HelixTrackModel::getPosMom(double tracklength, TVector3& pos, TVector3& mom) const { - - double angle = alpha0_ - sgn_ * tracklength / R_ * sin(theta_); - - TVector3 radius(R_,0,0); - radius.SetPhi(angle); - pos = center_ + radius; - pos.SetZ(center_.Z() - sgn_ * ((alpha0_-angle)*R_ * tan(theta_-M_PI/2.)) ); - - mom.SetXYZ(1,1,1); - mom.SetTheta(theta_); - mom.SetPhi(angle - sgn_*M_PI/2.); - mom.SetMag(mom_); - - /*std::cout<<"tracklength " << tracklength << "\n"; - std::cout<<"angle " << angle << "\n"; - std::cout<<"radius vector "; radius.Print(); - std::cout<<"pos "; pos.Print(); - std::cout<<"mom "; mom.Print();*/ - -} - - -} /* End of namespace genfit */ diff --git a/genfit/utilities/src/MeasurementCreator.cc b/genfit/utilities/src/MeasurementCreator.cc deleted file mode 100644 index e91135c2ad..0000000000 --- a/genfit/utilities/src/MeasurementCreator.cc +++ /dev/null @@ -1,344 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#include "MeasurementCreator.h" - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -namespace genfit { - -MeasurementCreator::MeasurementCreator() : - trackModel_(NULL), - resolution_(0.01), - resolutionWire_(0.1), - outlierProb_(0), - outlierRange_(2), - thetaDetPlane_(90), - phiDetPlane_(0), - wireCounter_(0), - wireDir_(0.,0.,1.), - minDrift_(0), - maxDrift_(2), - idealLRResolution_(true), - useSkew_(false), - skewAngle_(5), - nSuperLayer_(5), - measurementCounter_(0), - debug_(false) -{ - ; -} - - -std::vector MeasurementCreator::create(eMeasurementType type, double tracklength, bool& outlier, int& lr) { - - outlier = false; - lr = 0; - std::vector retVal; - genfit::AbsMeasurement* measurement; - - TVector3 point, dir; - trackModel_->getPosDir(tracklength, point, dir); - - - TVector3 planeNorm(dir); - planeNorm.SetTheta(thetaDetPlane_*TMath::Pi()/180); - planeNorm.SetPhi(planeNorm.Phi()+phiDetPlane_); - static const TVector3 z(0,0,1); - static const TVector3 x(1,0,0); - - - TVector3 currentWireDir(wireDir_); - TVector3 wirePerp; - - if (type == Wire || - type == WirePoint){ - - // skew layers - if (useSkew_ && (int)((double)wireCounter_/(double)nSuperLayer_)%2 == 1) { - TVector3 perp(wireDir_.Cross(dir)); - if ((int)((double)wireCounter_/(double)nSuperLayer_)%4 == 1){ - currentWireDir.Rotate(skewAngle_*TMath::Pi()/180, wireDir_.Cross(perp)); - } - else currentWireDir.Rotate(-skewAngle_*TMath::Pi()/180, wireDir_.Cross(perp)); - } - currentWireDir.SetMag(1.); - - // left/right - lr = 1; - wirePerp = dir.Cross(currentWireDir); - if (gRandom->Uniform(-1,1) >= 0) { - wirePerp *= -1.; - lr = -1; - } - wirePerp.SetMag(gRandom->Uniform(minDrift_, maxDrift_)); - } - - if (outlierProb_ > gRandom->Uniform(1.)) { - outlier = true; - if(debug_) std::cerr << "create outlier" << std::endl; - } - - - switch(type){ - case Pixel: { - if (debug_) std::cerr << "create PixHit" << std::endl; - - genfit::SharedPlanePtr plane(new genfit::DetPlane(point, planeNorm.Cross(z), (planeNorm.Cross(z)).Cross(planeNorm))); - - TVectorD hitCoords(2); - if (outlier) { - hitCoords(0) = gRandom->Uniform(-outlierRange_, outlierRange_); - hitCoords(1) = gRandom->Uniform(-outlierRange_, outlierRange_); - } - else { - hitCoords(0) = gRandom->Gaus(0,resolution_); - hitCoords(1) = gRandom->Gaus(0,resolution_); - } - - TMatrixDSym hitCov(2); - hitCov(0,0) = resolution_*resolution_; - hitCov(1,1) = resolution_*resolution_; - - measurement = new genfit::PlanarMeasurement(hitCoords, hitCov, int(type), measurementCounter_, nullptr); - static_cast(measurement)->setPlane(plane, measurementCounter_); - retVal.push_back(measurement); - } - break; - - case Spacepoint: { - if (debug_) std::cerr << "create SpacepointHit" << std::endl; - - TVectorD hitCoords(3); - if (outlier) { - hitCoords(0) = gRandom->Uniform(point.X()-outlierRange_, point.X()+outlierRange_); - hitCoords(1) = gRandom->Uniform(point.Y()-outlierRange_, point.Y()+outlierRange_); - hitCoords(2) = gRandom->Uniform(point.Z()-outlierRange_, point.Z()+outlierRange_); - } - else { - hitCoords(0) = gRandom->Gaus(point.X(),resolution_); - hitCoords(1) = gRandom->Gaus(point.Y(),resolution_); - hitCoords(2) = gRandom->Gaus(point.Z(),resolution_); - } - - TMatrixDSym hitCov(3); - hitCov(0,0) = resolution_*resolution_; - hitCov(1,1) = resolution_*resolution_; - hitCov(2,2) = resolution_*resolution_; - - measurement = new genfit::SpacepointMeasurement(hitCoords, hitCov, int(type), measurementCounter_, nullptr); - retVal.push_back(measurement); - } - break; - - case ProlateSpacepoint: { - if (debug_) std::cerr << "create ProlateSpacepointHit" << std::endl; - - TVectorD hitCoords(3); - if (outlier) { - hitCoords(0) = gRandom->Uniform(point.X()-outlierRange_, point.X()+outlierRange_); - hitCoords(1) = gRandom->Uniform(point.Y()-outlierRange_, point.Y()+outlierRange_); - hitCoords(2) = gRandom->Uniform(point.Z()-outlierRange_, point.Z()+outlierRange_); - } - else { - hitCoords(0) = point.X(); - hitCoords(1) = point.Y(); - hitCoords(2) = point.Z(); - } - - TMatrixDSym hitCov(3); - hitCov(0,0) = resolution_*resolution_; - hitCov(1,1) = resolution_*resolution_; - hitCov(2,2) = resolutionWire_*resolutionWire_; - - // rotation matrix - TVector3 xp = currentWireDir.Orthogonal(); - xp.SetMag(1); - TVector3 yp = currentWireDir.Cross(xp); - yp.SetMag(1); - - TMatrixD rot(3,3); - - rot(0,0) = xp.X(); rot(0,1) = yp.X(); rot(0,2) = currentWireDir.X(); - rot(1,0) = xp.Y(); rot(1,1) = yp.Y(); rot(1,2) = currentWireDir.Y(); - rot(2,0) = xp.Z(); rot(2,1) = yp.Z(); rot(2,2) = currentWireDir.Z(); - - // smear - TVectorD smearVec(3); - smearVec(0) = resolution_; - smearVec(1) = resolution_; - smearVec(2) = resolutionWire_; - smearVec *= rot; - if (!outlier) { - hitCoords(0) += gRandom->Gaus(0, smearVec(0)); - hitCoords(1) += gRandom->Gaus(0, smearVec(1)); - hitCoords(2) += gRandom->Gaus(0, smearVec(2)); - } - - - // rotate cov - hitCov.Similarity(rot); - - measurement = new genfit::ProlateSpacepointMeasurement(hitCoords, hitCov, int(type), measurementCounter_, nullptr); - static_cast(measurement)->setLargestErrorDirection(currentWireDir); - retVal.push_back(measurement); - } - break; - - case StripU: case StripV: case StripUV : { - if (debug_) std::cerr << "create StripHit" << std::endl; - - TVector3 vU, vV; - vU = planeNorm.Cross(z); - vV = (planeNorm.Cross(z)).Cross(planeNorm); - genfit::SharedPlanePtr plane(new genfit::DetPlane(point, vU, vV)); - - TVectorD hitCoords(1); - if (outlier) - hitCoords(0) = gRandom->Uniform(-outlierRange_, outlierRange_); - else - hitCoords(0) = gRandom->Gaus(0,resolution_); - - TMatrixDSym hitCov(1); - hitCov(0,0) = resolution_*resolution_; - - measurement = new genfit::PlanarMeasurement(hitCoords, hitCov, int(type), measurementCounter_, nullptr); - static_cast(measurement)->setPlane(plane, measurementCounter_); - if (type == StripV) - static_cast(measurement)->setStripV(); - retVal.push_back(measurement); - - - if (type == StripUV) { - if (outlier) - hitCoords(0) = gRandom->Uniform(-outlierRange_, outlierRange_); - else - hitCoords(0) = gRandom->Gaus(0,resolution_); - - hitCov(0,0) = resolution_*resolution_; - - measurement = new genfit::PlanarMeasurement(hitCoords, hitCov, int(type), measurementCounter_, nullptr); - static_cast(measurement)->setPlane(plane, measurementCounter_); - static_cast(measurement)->setStripV(); - retVal.push_back(measurement); - } - } - break; - - case Wire: { - if (debug_) std::cerr << "create WireHit" << std::endl; - - if (outlier) { - wirePerp.SetMag(gRandom->Uniform(outlierRange_)); - } - - TVectorD hitCoords(7); - hitCoords(0) = (point-wirePerp-currentWireDir).X(); - hitCoords(1) = (point-wirePerp-currentWireDir).Y(); - hitCoords(2) = (point-wirePerp-currentWireDir).Z(); - - hitCoords(3) = (point-wirePerp+currentWireDir).X(); - hitCoords(4) = (point-wirePerp+currentWireDir).Y(); - hitCoords(5) = (point-wirePerp+currentWireDir).Z(); - - if (outlier) - hitCoords(6) = gRandom->Uniform(outlierRange_); - else - hitCoords(6) = gRandom->Gaus(wirePerp.Mag(), resolution_); - - TMatrixDSym hitCov(7); - hitCov(6,6) = resolution_*resolution_; - - - measurement = new genfit::WireMeasurement(hitCoords, hitCov, int(type), measurementCounter_, nullptr); - if (idealLRResolution_){ - static_cast(measurement)->setLeftRightResolution(lr); - } - ++wireCounter_; - retVal.push_back(measurement); - } - break; - - case WirePoint: { - if (debug_) std::cerr << "create WirePointHit" << std::endl; - - if (outlier) { - wirePerp.SetMag(gRandom->Uniform(outlierRange_)); - } - - TVectorD hitCoords(8); - hitCoords(0) = (point-wirePerp-currentWireDir).X(); - hitCoords(1) = (point-wirePerp-currentWireDir).Y(); - hitCoords(2) = (point-wirePerp-currentWireDir).Z(); - - hitCoords(3) = (point-wirePerp+currentWireDir).X(); - hitCoords(4) = (point-wirePerp+currentWireDir).Y(); - hitCoords(5) = (point-wirePerp+currentWireDir).Z(); - - if (outlier) { - hitCoords(6) = gRandom->Uniform(outlierRange_); - hitCoords(7) = gRandom->Uniform(currentWireDir.Mag()-outlierRange_, currentWireDir.Mag()+outlierRange_); - } - else { - hitCoords(6) = gRandom->Gaus(wirePerp.Mag(), resolution_); - hitCoords(7) = gRandom->Gaus(currentWireDir.Mag(), resolutionWire_); - } - - - TMatrixDSym hitCov(8); - hitCov(6,6) = resolution_*resolution_; - hitCov(7,7) = resolutionWire_*resolutionWire_; - - measurement = new genfit::WirePointMeasurement(hitCoords, hitCov, int(type), measurementCounter_, nullptr); - if (idealLRResolution_){ - static_cast(measurement)->setLeftRightResolution(lr); - } - ++wireCounter_; - retVal.push_back(measurement); - } - break; - - default: - std::cerr << "measurement type not defined!" << std::endl; - exit(0); - } - - return retVal; - -} - - -void MeasurementCreator::reset() { - wireCounter_ = 0; - measurementCounter_ = 0; -} - -} /* End of namespace genfit */ diff --git a/genfit/utilities/src/utilitiesLinkDef.h b/genfit/utilities/src/utilitiesLinkDef.h deleted file mode 100644 index 36a5d06672..0000000000 --- a/genfit/utilities/src/utilitiesLinkDef.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2008-2010, Technische Universitaet Muenchen, - Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch - - This file is part of GENFIT. - - GENFIT is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GENFIT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with GENFIT. If not, see . -*/ - -#ifdef __CINT__ - - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - - -#pragma link C++ class genfit::HelixTrackModel+; -#pragma link C++ class genfit::MeasurementCreator+; -#pragma link C++ class genfit::mySpacepointDetectorHit+; -#pragma link C++ class genfit::mySpacepointMeasurement+; -#pragma link C++ enum genfit::eMeasurementType; - -#endif -