From f7b0f771a0531c923f438f5c81106ccac7ea18b1 Mon Sep 17 00:00:00 2001 From: Whitney Armstrong <warmstrong@anl.gov> Date: Thu, 6 Feb 2020 21:27:15 -0600 Subject: [PATCH] Major build restructuring --- CMakeLists.txt | 36 +- cmake/HcanaConfig.cmake.in | 5 + src/HallC_LinkDef.h_postamble | 2 - src/HallC_LinkDef.h_preamble | 11 - src/{ => hallc}/CMakeLists.txt | 122 +- src/{ => hallc}/HallC_LinkDef.h | 0 src/{ => hallc}/THcShowerCluster.h.float | 0 .../THcDC.cxx => hallc/derp/DriftChamber.cxx} | 0 src/hallc/derp/DriftChamber.h | 258 +++ src/{ => hallc}/hc_compiledata.h.in | 0 src/{ => hallc}/include/Scaler9001.h | 0 src/{ => hallc}/include/Scaler9250.h | 0 src/{ => hallc}/include/Scandalizer.h | 0 src/{ => hallc}/include/Shower2.h | 0 src/{ => hallc}/include/THcAerogel.h | 0 src/{ => hallc}/include/THcAerogelHit.h | 0 src/{ => hallc}/include/THcAnalyzer.h | 0 src/{ => hallc}/include/THcBCMCurrent.h | 0 src/{ => hallc}/include/THcCherenkov.h | 0 src/{ => hallc}/include/THcCherenkovHit.h | 0 src/{ => hallc}/include/THcCoinTime.h | 0 src/{ => hallc}/include/THcConfigEvtHandler.h | 0 src/{ => hallc}/include/THcDC.h | 0 src/{ => hallc}/include/THcDCHit.h | 0 src/{ => hallc}/include/THcDCLookupTTDConv.h | 0 src/{ => hallc}/include/THcDCTimeToDistConv.h | 0 src/{ => hallc}/include/THcDCTrack.h | 0 src/{ => hallc}/include/THcDCWire.h | 0 src/{ => hallc}/include/THcDetectorMap.h | 0 src/{ => hallc}/include/THcDriftChamber.h | 0 .../include/THcDriftChamberPlane.h | 0 .../include/THcDummySpectrometer.h | 0 src/{ => hallc}/include/THcExtTarCor.h | 0 src/{ => hallc}/include/THcFormula.h | 0 src/{ => hallc}/include/THcGlobals.h | 0 .../include/THcHallCSpectrometer.h | 0 src/{ => hallc}/include/THcHelicity.h | 0 src/{ => hallc}/include/THcHelicityReader.h | 0 src/{ => hallc}/include/THcHelicityScaler.h | 0 src/{ => hallc}/include/THcHitList.h | 0 src/{ => hallc}/include/THcHodoEff.h | 0 src/{ => hallc}/include/THcHodoHit.h | 0 src/{ => hallc}/include/THcHodoscope.h | 0 src/{ => hallc}/include/THcInterface.h | 0 src/{ => hallc}/include/THcParmList.h | 0 src/{ => hallc}/include/THcPeriodicReport.h | 0 src/{ => hallc}/include/THcPrimaryKine.h | 0 src/{ => hallc}/include/THcRaster.h | 0 src/{ => hallc}/include/THcRasterRawHit.h | 0 src/{ => hallc}/include/THcRasteredBeam.h | 0 src/{ => hallc}/include/THcRawAdcHit.h | 0 src/{ => hallc}/include/THcRawDCHit.h | 0 src/{ => hallc}/include/THcRawHit.h | 0 src/{ => hallc}/include/THcRawHodoHit.h | 0 src/{ => hallc}/include/THcRawShowerHit.h | 0 src/{ => hallc}/include/THcRawTdcHit.h | 0 src/{ => hallc}/include/THcReactionPoint.h | 0 src/{ => hallc}/include/THcRun.h | 0 src/{ => hallc}/include/THcRunParameters.h | 0 src/{ => hallc}/include/THcScalerEvtHandler.h | 0 .../include/THcScintPlaneCluster.h | 0 .../include/THcScintillatorPlane.h | 0 src/{ => hallc}/include/THcSecondaryKine.h | 0 src/{ => hallc}/include/THcShower.h | 0 src/{ => hallc}/include/THcShowerArray.h | 0 src/{ => hallc}/include/THcShowerHit.h | 0 src/{ => hallc}/include/THcShowerPlane.h | 0 src/{ => hallc}/include/THcSignalHit.h | 0 src/{ => hallc}/include/THcSpacePoint.h | 0 .../include/THcTimeSyncEvtHandler.h | 0 src/{ => hallc}/include/THcTrigApp.h | 0 src/{ => hallc}/include/THcTrigDet.h | 0 src/{ => hallc}/include/THcTrigRawHit.h | 0 src/{ => hallc}/include/TIBlobModule.h | 0 src/hallc/include/TrackingEfficiency.hhh | 104 ++ src/{ => hallc}/include/hcana/HallC_Data.h | 0 src/{ => hallc}/include/hcana/Logger.h | 0 src/{ => hallc}/include/hcana/helpers.hxx | 0 src/{ => hallc}/nlohmann/json.hpp | 0 src/{ => hallc}/src/Scaler9001.cxx | 0 src/{ => hallc}/src/Scaler9250.cxx | 0 src/{ => hallc}/src/Scandalizer.cxx | 0 src/{ => hallc}/src/Shower2.cxx | 0 src/{ => hallc}/src/THcAerogel.cxx | 0 src/{ => hallc}/src/THcAerogelHit.cxx | 0 src/{ => hallc}/src/THcAnalyzer.cxx | 0 src/{ => hallc}/src/THcBCMCurrent.cxx | 0 src/{ => hallc}/src/THcCherenkov.cxx | 0 src/{ => hallc}/src/THcCherenkovHit.cxx | 0 src/{ => hallc}/src/THcCoinTime.cxx | 0 src/{ => hallc}/src/THcConfigEvtHandler.cxx | 0 src/hallc/src/THcDC.cxx | 1404 +++++++++++++++++ src/{ => hallc}/src/THcDCHit.cxx | 0 src/{ => hallc}/src/THcDCLookupTTDConv.cxx | 0 src/{ => hallc}/src/THcDCTimeToDistConv.cxx | 0 src/{ => hallc}/src/THcDCTrack.cxx | 0 src/{ => hallc}/src/THcDCWire.cxx | 0 src/{ => hallc}/src/THcDetectorMap.cxx | 0 src/{ => hallc}/src/THcDriftChamber.cxx | 0 src/{ => hallc}/src/THcDriftChamberPlane.cxx | 0 src/{ => hallc}/src/THcDummySpectrometer.cxx | 0 src/{ => hallc}/src/THcExtTarCor.cxx | 0 src/{ => hallc}/src/THcFormula.cxx | 0 src/{ => hallc}/src/THcHallCSpectrometer.cxx | 0 src/{ => hallc}/src/THcHelicity.cxx | 0 src/{ => hallc}/src/THcHelicityReader.cxx | 0 src/{ => hallc}/src/THcHelicityScaler.cxx | 0 src/{ => hallc}/src/THcHitList.cxx | 0 src/{ => hallc}/src/THcHodoEff.cxx | 0 src/{ => hallc}/src/THcHodoHit.cxx | 0 src/{ => hallc}/src/THcHodoscope.cxx | 0 src/{ => hallc}/src/THcInterface.cxx | 0 src/{ => hallc}/src/THcParmList.cxx | 0 src/{ => hallc}/src/THcPeriodicReport.cxx | 0 src/{ => hallc}/src/THcPrimaryKine.cxx | 0 src/{ => hallc}/src/THcRaster.cxx | 0 src/{ => hallc}/src/THcRasterRawHit.cxx | 0 src/{ => hallc}/src/THcRasteredBeam.cxx | 0 src/{ => hallc}/src/THcRawAdcHit.cxx | 0 src/{ => hallc}/src/THcRawDCHit.cxx | 0 src/{ => hallc}/src/THcRawHit.cxx | 0 src/{ => hallc}/src/THcRawHodoHit.cxx | 0 src/{ => hallc}/src/THcRawShowerHit.cxx | 0 src/{ => hallc}/src/THcRawTdcHit.cxx | 0 src/{ => hallc}/src/THcReactionPoint.cxx | 0 src/{ => hallc}/src/THcRun.cxx | 0 src/{ => hallc}/src/THcRunParameters.cxx | 0 src/{ => hallc}/src/THcScalerEvtHandler.cxx | 0 src/{ => hallc}/src/THcScintPlaneCluster.cxx | 0 src/{ => hallc}/src/THcScintillatorPlane.cxx | 0 src/{ => hallc}/src/THcSecondaryKine.cxx | 0 src/{ => hallc}/src/THcShower.cxx | 0 src/{ => hallc}/src/THcShowerArray.cxx | 0 src/{ => hallc}/src/THcShowerHit.cxx | 0 src/{ => hallc}/src/THcShowerPlane.cxx | 0 src/{ => hallc}/src/THcSignalHit.cxx | 0 src/{ => hallc}/src/THcSpacePoint.cxx | 0 src/{ => hallc}/src/THcTimeSyncEvtHandler.cxx | 0 src/{ => hallc}/src/THcTrigApp.cxx | 0 src/{ => hallc}/src/THcTrigDet.cxx | 0 src/{ => hallc}/src/THcTrigRawHit.cxx | 0 src/{ => hallc}/src/TIBlobModule.cxx | 0 src/hallc/src/TrackingEfficiency.cpppp | 451 ++++++ src/hcana/CMakeLists.txt | 29 + src/{ => hcana}/main.C | 0 145 files changed, 2338 insertions(+), 84 deletions(-) create mode 100644 cmake/HcanaConfig.cmake.in delete mode 100644 src/HallC_LinkDef.h_postamble delete mode 100644 src/HallC_LinkDef.h_preamble rename src/{ => hallc}/CMakeLists.txt (52%) rename src/{ => hallc}/HallC_LinkDef.h (100%) rename src/{ => hallc}/THcShowerCluster.h.float (100%) rename src/{src/THcDC.cxx => hallc/derp/DriftChamber.cxx} (100%) create mode 100644 src/hallc/derp/DriftChamber.h rename src/{ => hallc}/hc_compiledata.h.in (100%) rename src/{ => hallc}/include/Scaler9001.h (100%) rename src/{ => hallc}/include/Scaler9250.h (100%) rename src/{ => hallc}/include/Scandalizer.h (100%) rename src/{ => hallc}/include/Shower2.h (100%) rename src/{ => hallc}/include/THcAerogel.h (100%) rename src/{ => hallc}/include/THcAerogelHit.h (100%) rename src/{ => hallc}/include/THcAnalyzer.h (100%) rename src/{ => hallc}/include/THcBCMCurrent.h (100%) rename src/{ => hallc}/include/THcCherenkov.h (100%) rename src/{ => hallc}/include/THcCherenkovHit.h (100%) rename src/{ => hallc}/include/THcCoinTime.h (100%) rename src/{ => hallc}/include/THcConfigEvtHandler.h (100%) rename src/{ => hallc}/include/THcDC.h (100%) rename src/{ => hallc}/include/THcDCHit.h (100%) rename src/{ => hallc}/include/THcDCLookupTTDConv.h (100%) rename src/{ => hallc}/include/THcDCTimeToDistConv.h (100%) rename src/{ => hallc}/include/THcDCTrack.h (100%) rename src/{ => hallc}/include/THcDCWire.h (100%) rename src/{ => hallc}/include/THcDetectorMap.h (100%) rename src/{ => hallc}/include/THcDriftChamber.h (100%) rename src/{ => hallc}/include/THcDriftChamberPlane.h (100%) rename src/{ => hallc}/include/THcDummySpectrometer.h (100%) rename src/{ => hallc}/include/THcExtTarCor.h (100%) rename src/{ => hallc}/include/THcFormula.h (100%) rename src/{ => hallc}/include/THcGlobals.h (100%) rename src/{ => hallc}/include/THcHallCSpectrometer.h (100%) rename src/{ => hallc}/include/THcHelicity.h (100%) rename src/{ => hallc}/include/THcHelicityReader.h (100%) rename src/{ => hallc}/include/THcHelicityScaler.h (100%) rename src/{ => hallc}/include/THcHitList.h (100%) rename src/{ => hallc}/include/THcHodoEff.h (100%) rename src/{ => hallc}/include/THcHodoHit.h (100%) rename src/{ => hallc}/include/THcHodoscope.h (100%) rename src/{ => hallc}/include/THcInterface.h (100%) rename src/{ => hallc}/include/THcParmList.h (100%) rename src/{ => hallc}/include/THcPeriodicReport.h (100%) rename src/{ => hallc}/include/THcPrimaryKine.h (100%) rename src/{ => hallc}/include/THcRaster.h (100%) rename src/{ => hallc}/include/THcRasterRawHit.h (100%) rename src/{ => hallc}/include/THcRasteredBeam.h (100%) rename src/{ => hallc}/include/THcRawAdcHit.h (100%) rename src/{ => hallc}/include/THcRawDCHit.h (100%) rename src/{ => hallc}/include/THcRawHit.h (100%) rename src/{ => hallc}/include/THcRawHodoHit.h (100%) rename src/{ => hallc}/include/THcRawShowerHit.h (100%) rename src/{ => hallc}/include/THcRawTdcHit.h (100%) rename src/{ => hallc}/include/THcReactionPoint.h (100%) rename src/{ => hallc}/include/THcRun.h (100%) rename src/{ => hallc}/include/THcRunParameters.h (100%) rename src/{ => hallc}/include/THcScalerEvtHandler.h (100%) rename src/{ => hallc}/include/THcScintPlaneCluster.h (100%) rename src/{ => hallc}/include/THcScintillatorPlane.h (100%) rename src/{ => hallc}/include/THcSecondaryKine.h (100%) rename src/{ => hallc}/include/THcShower.h (100%) rename src/{ => hallc}/include/THcShowerArray.h (100%) rename src/{ => hallc}/include/THcShowerHit.h (100%) rename src/{ => hallc}/include/THcShowerPlane.h (100%) rename src/{ => hallc}/include/THcSignalHit.h (100%) rename src/{ => hallc}/include/THcSpacePoint.h (100%) rename src/{ => hallc}/include/THcTimeSyncEvtHandler.h (100%) rename src/{ => hallc}/include/THcTrigApp.h (100%) rename src/{ => hallc}/include/THcTrigDet.h (100%) rename src/{ => hallc}/include/THcTrigRawHit.h (100%) rename src/{ => hallc}/include/TIBlobModule.h (100%) create mode 100644 src/hallc/include/TrackingEfficiency.hhh rename src/{ => hallc}/include/hcana/HallC_Data.h (100%) rename src/{ => hallc}/include/hcana/Logger.h (100%) rename src/{ => hallc}/include/hcana/helpers.hxx (100%) rename src/{ => hallc}/nlohmann/json.hpp (100%) rename src/{ => hallc}/src/Scaler9001.cxx (100%) rename src/{ => hallc}/src/Scaler9250.cxx (100%) rename src/{ => hallc}/src/Scandalizer.cxx (100%) rename src/{ => hallc}/src/Shower2.cxx (100%) rename src/{ => hallc}/src/THcAerogel.cxx (100%) rename src/{ => hallc}/src/THcAerogelHit.cxx (100%) rename src/{ => hallc}/src/THcAnalyzer.cxx (100%) rename src/{ => hallc}/src/THcBCMCurrent.cxx (100%) rename src/{ => hallc}/src/THcCherenkov.cxx (100%) rename src/{ => hallc}/src/THcCherenkovHit.cxx (100%) rename src/{ => hallc}/src/THcCoinTime.cxx (100%) rename src/{ => hallc}/src/THcConfigEvtHandler.cxx (100%) create mode 100644 src/hallc/src/THcDC.cxx rename src/{ => hallc}/src/THcDCHit.cxx (100%) rename src/{ => hallc}/src/THcDCLookupTTDConv.cxx (100%) rename src/{ => hallc}/src/THcDCTimeToDistConv.cxx (100%) rename src/{ => hallc}/src/THcDCTrack.cxx (100%) rename src/{ => hallc}/src/THcDCWire.cxx (100%) rename src/{ => hallc}/src/THcDetectorMap.cxx (100%) rename src/{ => hallc}/src/THcDriftChamber.cxx (100%) rename src/{ => hallc}/src/THcDriftChamberPlane.cxx (100%) rename src/{ => hallc}/src/THcDummySpectrometer.cxx (100%) rename src/{ => hallc}/src/THcExtTarCor.cxx (100%) rename src/{ => hallc}/src/THcFormula.cxx (100%) rename src/{ => hallc}/src/THcHallCSpectrometer.cxx (100%) rename src/{ => hallc}/src/THcHelicity.cxx (100%) rename src/{ => hallc}/src/THcHelicityReader.cxx (100%) rename src/{ => hallc}/src/THcHelicityScaler.cxx (100%) rename src/{ => hallc}/src/THcHitList.cxx (100%) rename src/{ => hallc}/src/THcHodoEff.cxx (100%) rename src/{ => hallc}/src/THcHodoHit.cxx (100%) rename src/{ => hallc}/src/THcHodoscope.cxx (100%) rename src/{ => hallc}/src/THcInterface.cxx (100%) rename src/{ => hallc}/src/THcParmList.cxx (100%) rename src/{ => hallc}/src/THcPeriodicReport.cxx (100%) rename src/{ => hallc}/src/THcPrimaryKine.cxx (100%) rename src/{ => hallc}/src/THcRaster.cxx (100%) rename src/{ => hallc}/src/THcRasterRawHit.cxx (100%) rename src/{ => hallc}/src/THcRasteredBeam.cxx (100%) rename src/{ => hallc}/src/THcRawAdcHit.cxx (100%) rename src/{ => hallc}/src/THcRawDCHit.cxx (100%) rename src/{ => hallc}/src/THcRawHit.cxx (100%) rename src/{ => hallc}/src/THcRawHodoHit.cxx (100%) rename src/{ => hallc}/src/THcRawShowerHit.cxx (100%) rename src/{ => hallc}/src/THcRawTdcHit.cxx (100%) rename src/{ => hallc}/src/THcReactionPoint.cxx (100%) rename src/{ => hallc}/src/THcRun.cxx (100%) rename src/{ => hallc}/src/THcRunParameters.cxx (100%) rename src/{ => hallc}/src/THcScalerEvtHandler.cxx (100%) rename src/{ => hallc}/src/THcScintPlaneCluster.cxx (100%) rename src/{ => hallc}/src/THcScintillatorPlane.cxx (100%) rename src/{ => hallc}/src/THcSecondaryKine.cxx (100%) rename src/{ => hallc}/src/THcShower.cxx (100%) rename src/{ => hallc}/src/THcShowerArray.cxx (100%) rename src/{ => hallc}/src/THcShowerHit.cxx (100%) rename src/{ => hallc}/src/THcShowerPlane.cxx (100%) rename src/{ => hallc}/src/THcSignalHit.cxx (100%) rename src/{ => hallc}/src/THcSpacePoint.cxx (100%) rename src/{ => hallc}/src/THcTimeSyncEvtHandler.cxx (100%) rename src/{ => hallc}/src/THcTrigApp.cxx (100%) rename src/{ => hallc}/src/THcTrigDet.cxx (100%) rename src/{ => hallc}/src/THcTrigRawHit.cxx (100%) rename src/{ => hallc}/src/TIBlobModule.cxx (100%) create mode 100644 src/hallc/src/TrackingEfficiency.cpppp create mode 100644 src/hcana/CMakeLists.txt rename src/{ => hcana}/main.C (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2241647..5b4f71a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.12) project(hcana - VERSION 1.2.0 + VERSION 2.0.0 LANGUAGES CXX) @@ -63,5 +63,35 @@ set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/${MAIN_PROJECT_NAME_LC}) #---------------------------------------------------------------------------- # Directories in which we build things -add_subdirectory(src) -add_subdirectory(cmake) +add_subdirectory(src/hallc) +add_subdirectory(src/hcana) + +# ------------------------- +# install library config +include(CMakePackageConfigHelpers) + +# Install and export targets +install(EXPORT HcanaTargets + FILE HcanaTargets.cmake + NAMESPACE Hcana:: + DESTINATION lib/Hcana + ) + +set(TARGETS_INSTALL_PATH Hcana/HcanaTargets.cmake) +CONFIGURE_PACKAGE_CONFIG_FILE( + cmake/HcanaConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/HcanaConfig.cmake + INSTALL_DESTINATION lib + PATH_VARS TARGETS_INSTALL_PATH + ) + +write_basic_package_version_file("HcanaConfigVersion.cmake" + VERSION ${VERSION} + COMPATIBILITY SameMajorVersion + ) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/HcanaConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/HcanaConfigVersion.cmake + DESTINATION lib/Hcana + ) diff --git a/cmake/HcanaConfig.cmake.in b/cmake/HcanaConfig.cmake.in new file mode 100644 index 0000000..9423eda --- /dev/null +++ b/cmake/HcanaConfig.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ + +include("@PACKAGE_TARGETS_INSTALL_PATH@") + +check_required_components(Hcana) diff --git a/src/HallC_LinkDef.h_postamble b/src/HallC_LinkDef.h_postamble deleted file mode 100644 index 5a3d3bc..0000000 --- a/src/HallC_LinkDef.h_postamble +++ /dev/null @@ -1,2 +0,0 @@ -// Postamble for HallC_Linkdef.h file -#endif diff --git a/src/HallC_LinkDef.h_preamble b/src/HallC_LinkDef.h_preamble deleted file mode 100644 index 88e466d..0000000 --- a/src/HallC_LinkDef.h_preamble +++ /dev/null @@ -1,11 +0,0 @@ -// Preamble to HallC_LinkDef.h file - -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ global gHcParms; -#pragma link C++ global gHcDetectorMap; - diff --git a/src/CMakeLists.txt b/src/hallc/CMakeLists.txt similarity index 52% rename from src/CMakeLists.txt rename to src/hallc/CMakeLists.txt index 2cbaa22..34b154d 100644 --- a/src/CMakeLists.txt +++ b/src/hallc/CMakeLists.txt @@ -1,60 +1,72 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) #---------------------------------------------------------------------------- -# Names of the main items we build here set(LIBNAME HallC) -set(EXENAME hcana) + include(FindThreads) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) #---------------------------------------------------------------------------- # Sources and headers -file(GLOB src "src/*.cxx") -file(GLOB allheaders RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "include/*.h") -list(REMOVE_ITEM allheaders - "${CMAKE_CURRENT_SOURCE_DIR}/${LIBNAME}_LinkDef.h" - ) -set(headers "${allheaders}") -list(REMOVE_ITEM headers - "${CMAKE_CURRENT_SOURCE_DIR}/hc_compiledata.h" +set(sources + Scaler9001.cxx Scaler9250.cxx Scandalizer.cxx + Shower2.cxx THcAerogel.cxx THcAerogelHit.cxx + THcAnalyzer.cxx THcBCMCurrent.cxx THcCherenkov.cxx + THcCherenkovHit.cxx THcCoinTime.cxx THcConfigEvtHandler.cxx + THcDC.cxx THcDCHit.cxx THcDCLookupTTDConv.cxx + THcDCTimeToDistConv.cxx THcDCTrack.cxx THcDCWire.cxx + THcDetectorMap.cxx THcDriftChamber.cxx THcDriftChamberPlane.cxx + THcDummySpectrometer.cxx THcExtTarCor.cxx THcFormula.cxx + THcHallCSpectrometer.cxx THcHelicity.cxx THcHelicityReader.cxx + THcHelicityScaler.cxx THcHitList.cxx THcHodoEff.cxx + THcHodoHit.cxx THcHodoscope.cxx THcInterface.cxx + THcParmList.cxx THcPeriodicReport.cxx THcPrimaryKine.cxx + THcRaster.cxx THcRasteredBeam.cxx THcRasterRawHit.cxx + THcRawAdcHit.cxx THcRawDCHit.cxx THcRawHit.cxx + THcRawHodoHit.cxx THcRawShowerHit.cxx THcRawTdcHit.cxx + THcReactionPoint.cxx THcRun.cxx THcRunParameters.cxx + THcScalerEvtHandler.cxx THcScintillatorPlane.cxx THcScintPlaneCluster.cxx + THcSecondaryKine.cxx THcShowerArray.cxx THcShower.cxx + THcShowerHit.cxx THcShowerPlane.cxx THcSignalHit.cxx + THcSpacePoint.cxx THcTimeSyncEvtHandler.cxx THcTrigApp.cxx + THcTrigDet.cxx THcTrigRawHit.cxx TIBlobModule.cxx ) -set(classheaders "${headers}") -list(REMOVE_ITEM classheaders - "${CMAKE_CURRENT_SOURCE_DIR}/include/THcGlobals.h" + +string(REPLACE .cxx .h headers "${sources}") +#list(APPEND headers THaGlobals.h THaBenchmark.h) +list(TRANSFORM sources PREPEND "src/") +list(TRANSFORM headers PREPEND "include/") + + +set(allheaders + ${headers} + include/THcGlobals.h ) -#---------------------------------------------------------------------------- -# Generate HallC_LinkDef.h -#set(linkdef "${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}_LinkDef.h") -#file(READ "${CMAKE_CURRENT_SOURCE_DIR}/${LIBNAME}_LinkDef.h_preamble" preamble) -#file(WRITE "${linkdef}" "${preamble}") -#unset(preamble) - -#foreach(hdr IN LISTS classheaders) -# get_filename_component(basename "${hdr}" NAME_WE) -# if("${basename}" MATCHES "^Scaler" OR "${basename}" STREQUAL "TIBlobModule") -# file(APPEND ${linkdef} "#pragma link C++ class Decoder::${basename}+;\n") -# else() -# file(APPEND ${linkdef} "#pragma link C++ class ${basename}+;\n") -# endif() -#endforeach() -#file(READ "${CMAKE_CURRENT_SOURCE_DIR}/${LIBNAME}_LinkDef.h_postamble" postamble) -#file(APPEND "${linkdef}" "${postamble}") -#unset(postamble) -#---------------------------------------------------------------------------- -# Generate hc_compiledata.h -#include(PoddCompileInfo) +#file(GLOB allheaders RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "include/*.h") +#list(REMOVE_ITEM allheaders +# "${CMAKE_CURRENT_SOURCE_DIR}/${LIBNAME}_LinkDef.h" +# ) +#set(headers "${allheaders}") +#list(REMOVE_ITEM headers +# "${CMAKE_CURRENT_SOURCE_DIR}/hc_compiledata.h" +# ) +#set(classheaders "${headers}") +#list(REMOVE_ITEM classheaders +# "${CMAKE_CURRENT_SOURCE_DIR}/include/THcGlobals.h" +# ) -# Ensure there's no old hc_compiledata.h hanging around from a non-CMake build -file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/hc_compiledata.h") -configure_file(hc_compiledata.h.in hc_compiledata.h) +#---------------------------------------------------------------------------- + +configure_file(hc_compiledata.h.in ${CMAKE_CURRENT_BINARY_DIR}/hc_compiledata.h) list(APPEND allheaders "${CMAKE_CURRENT_BINARY_DIR}/hc_compiledata.h") #---------------------------------------------------------------------------- # libHallC add_library(${LIBNAME} SHARED - ${src} + ${sources} ${allheaders} ${LIBNAME}Dict.cxx) #add_library(${PROJECT_NAME}::${LIBNAME} ALIAS ${LIBNAME}) @@ -87,11 +99,8 @@ target_include_directories(${LIBNAME} $<BUILD_INTERFACE:${FMT_INCLUDE_DIR}> ) -target_compile_options(${LIBNAME} - PUBLIC - ${${PROJECT_NAME_UC}_CXX_FLAGS_LIST} - PRIVATE - ${${PROJECT_NAME_UC}_DIAG_FLAGS_LIST} +target_compile_features(${LIBNAME} + PUBLIC cxx_std_17 ) if(WITH_DEBUG) target_compile_definitions(${LIBNAME} PUBLIC WITH_DEBUG) @@ -115,7 +124,7 @@ set_target_properties(${LIBNAME} PROPERTIES ) install(TARGETS ${LIBNAME} - EXPORT ${MAIN_PROJECT_NAME_LC}-exports + EXPORT HcanaTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} @@ -126,29 +135,6 @@ install(FILES ${allheaders} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY include/hcana DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) #install(DIRECTORY include/spdlog DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hcana) -# hcana executable -add_executable(${EXENAME} main.C) - -target_link_libraries(${EXENAME} - PRIVATE - ${LIBNAME} - ) -target_compile_options(${EXENAME} - PUBLIC - ${${PROJECT_NAME_UC}_CXX_FLAGS_LIST} - PRIVATE - ${${PROJECT_NAME_UC}_DIAG_FLAGS_LIST} - ) -if(${CMAKE_SYSTEM_NAME} MATCHES Linux) - # Linux (at least with g++) requires -fPIC even for main - target_compile_options(${EXENAME} PUBLIC -fPIC) -endif() - -install(TARGETS ${EXENAME} - DESTINATION ${CMAKE_INSTALL_BINDIR} - ) - - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}Dict_rdict.pcm DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/src/HallC_LinkDef.h b/src/hallc/HallC_LinkDef.h similarity index 100% rename from src/HallC_LinkDef.h rename to src/hallc/HallC_LinkDef.h diff --git a/src/THcShowerCluster.h.float b/src/hallc/THcShowerCluster.h.float similarity index 100% rename from src/THcShowerCluster.h.float rename to src/hallc/THcShowerCluster.h.float diff --git a/src/src/THcDC.cxx b/src/hallc/derp/DriftChamber.cxx similarity index 100% rename from src/src/THcDC.cxx rename to src/hallc/derp/DriftChamber.cxx diff --git a/src/hallc/derp/DriftChamber.h b/src/hallc/derp/DriftChamber.h new file mode 100644 index 0000000..78caec0 --- /dev/null +++ b/src/hallc/derp/DriftChamber.h @@ -0,0 +1,258 @@ +#ifndef hallc_DriftChamber_HH +#define hallc_DriftChamber_HH + +/////////////////////////////////////////////////////////////////////////////// +// // +// Drift Chamber // +// // +/////////////////////////////////////////////////////////////////////////////// + +#include "THaTrackingDetector.h" +#include "THcHitList.h" +#include "THcRawDCHit.h" +#include "THcSpacePoint.h" +#include "THcDriftChamberPlane.h" +#include "THcDriftChamber.h" +#include "TMath.h" + +#include <map> +#include "hcana/Logger.h" + +#define NUM_FPRAY 4 + +namespace hallc { + namespace data { + + /** Drift chamber data. + * Currently just for testing + */ + struct DriftChamber { + + // Plane number + std::map<int,double> _Residuals; + std::map<int,double> _ResidualsExclPlane; + std::map<int,double> _Wire_hit_did; + std::map<int,double> _Wire_hit_should; + + ClassDef(DriftChamber,1) + }; + + } // namespace data +} + +class THcDC : public THaTrackingDetector, public THcHitList { + +protected: + std::shared_ptr<spdlog::logger> _sub_logger; //! + +public: + + hallc::data::DriftChamber _basic_data; + + THcDC( const char* name, const char* description = "", + THaApparatus* a = NULL ); + virtual ~THcDC(); + + virtual Int_t Decode( const THaEvData& ); + virtual EStatus Init( const TDatime& run_time ); + virtual Int_t ManualInitTree( TTree* t ); + virtual Int_t End(THaRunBase* run=0); + virtual Int_t CoarseTrack( TClonesArray& tracks ); + virtual Int_t FineTrack( TClonesArray& tracks ); + + virtual Int_t ApplyCorrections( void ); + + // Int_t GetNHits() const { return fNhit; } + + Int_t GetNTracks() const { return fNDCTracks; } + // const TClonesArray* GetTrackHits() const { return fTrackProj; } + void SetFocalPlaneBestTrack(Int_t golden_track_index); // Called in THcHallCSpectrometer: + + Int_t GetNWires(Int_t plane) const { return fNWires[plane-1];} + Int_t GetNChamber(Int_t plane) const { return fNChamber[plane-1];} + Int_t GetWireOrder(Int_t plane) const { return fWireOrder[plane-1];} + Double_t GetPitch(Int_t plane) const { return fPitch[plane-1];} + Double_t GetCentralWire(Int_t plane) const { return fCentralWire[plane-1];} + Int_t GetTdcWinMin(Int_t plane) const { return fTdcWinMin[plane-1];} + Int_t GetTdcWinMax(Int_t plane) const { return fTdcWinMax[plane-1];} + + Double_t GetXPos(Int_t plane) const { return fXPos[plane-1];} + Double_t GetYPos(Int_t plane) const { return fYPos[plane-1];} + Double_t GetZPos(Int_t plane) const { return fZPos[plane-1];} + Double_t GetAlphaAngle(Int_t plane) const { return fAlphaAngle[plane-1];} + Double_t GetBetaAngle(Int_t plane) const { return fBetaAngle[plane-1];} + Double_t GetGammaAngle(Int_t plane) const { return fGammaAngle[plane-1];} + + Int_t GetMinHits(Int_t chamber) const { return fMinHits[chamber-1];} + Int_t GetMaxHits(Int_t chamber) const { return fMaxHits[chamber-1];} + Int_t GetMinCombos(Int_t chamber) const { return fMinCombos[chamber-1];} + Double_t GetSpacePointCriterion(Int_t chamber) const { return fSpace_Point_Criterion[chamber-1];} + Double_t GetCentralTime(Int_t plane) const { return fCentralTime[plane-1];} + Int_t GetDriftTimeSign(Int_t plane) const { return fDriftTimeSign[plane-1];} + Int_t GetReadoutLR(Int_t plane) const { return fReadoutLR[plane-1];} + Int_t GetReadoutTB(Int_t plane) const { return fReadoutTB[plane-1];} + Int_t GetVersion() const {return fVersion;} + + + + + Double_t GetPlaneTimeZero(Int_t plane) const { return fPlaneTimeZero[plane-1];} + Double_t GetSigma(Int_t plane) const { return fSigma[plane-1];} + Int_t GetFixPropagationCorrectionFlag() const {return fFixPropagationCorrection;} + + Double_t GetNSperChan() const { return fNSperChan;} + + Double_t GetCenter(Int_t plane) const { + return + //fXCenter[chamber]*sin(fAlphaAngle[plane-1]) + + //fYCenter[chamber]*cos(fAlphaAngle[plane-1]); + + fXPos[plane-1]*sin(fAlphaAngle[plane-1]) + + fYPos[plane-1]*cos(fAlphaAngle[plane-1]); + } + // friend class THaScCalib; + + THcDC(); // for ROOT I/O + +protected: + Int_t fdebuglinkstubs; + Int_t fdebugprintrawdc; + Int_t fdebugflagpr; + Int_t fdebugflagstubs; + Int_t fdebugtrackprint; + Int_t fdebugprintdecodeddc; + Int_t fHMSStyleChambers; + Int_t fTDC_RefTimeCut; + + UInt_t fNDCTracks; + TClonesArray* fDCTracks; // Tracks found from stubs (THcDCTrack obj) + // Calibration + + // Hall C Parameters + char fPrefix[2]; + Int_t fNPlanes; // Total number of DC planes + char** fPlaneNames; + UInt_t fNChambers; + Int_t fFixLR; // If 1, allow a given hit to have different LR + // for different space points + Int_t fFixPropagationCorrection; // If 1, don't reapply (and accumulate) the + // propagation along the wire correction for + // each space point a hit occurs in. Keep a + // separate correction for each space point. + Int_t fProjectToChamber; // If 1, project y position each stub back to it's own + // chamber before comparing y positions in LinkStubs + // Was used for SOS in ENGINE. + + // Per-event data + Int_t fStubTest; + Int_t fNhits; + Int_t fNthits; + Int_t fN_True_RawHits; + Int_t fNSp; // Number of space points + Int_t fNsp_best; // Number of space points for gloden track + Double_t* fResiduals; //[fNPlanes] Array of residuals + Double_t* fResidualsExclPlane; //[fNPlanes] Array of residuals with plane excluded + Double_t* fWire_hit_did; //[fNPlanes] + Double_t* fWire_hit_should; //[fNPlanes] + + Double_t fNSperChan; /* TDC bin size */ + Double_t fWireVelocity; + Int_t fSingleStub; /* If 1, single stubs make tracks */ + Int_t fNTracksMaxFP; + Double_t fXtTrCriterion; + Double_t fYtTrCriterion; + Double_t fXptTrCriterion; + Double_t fYptTrCriterion; + Int_t fVersion; + + // Each of these will be dimensioned with the number of chambers + Double_t* fXCenter; + Double_t* fYCenter; + Int_t* fMinHits; + Int_t* fMaxHits; + Int_t* fMinCombos; + Double_t* fSpace_Point_Criterion; + + // Each of these will be dimensioned with the number of planes + // A THcDCPlane class object will need to access the value for + // its plane number. Should we have a Get method for each or + Int_t* fTdcWinMin; + Int_t* fTdcWinMax; + Double_t* fCentralTime; + Int_t* fNWires; // Number of wires per plane + Int_t* fNChamber; + Int_t* fWireOrder; + Int_t* fDriftTimeSign; + Int_t* fReadoutTB; + Int_t* fReadoutLR; + + + Double_t* fXPos; + Double_t* fYPos; + Double_t* fZPos; + Double_t* fAlphaAngle; + Double_t* fBetaAngle; + Double_t* fGammaAngle; + Double_t* fPitch; + Double_t* fCentralWire; + Double_t* fPlaneTimeZero; + Double_t* fSigma; + Double_t** fPlaneCoeffs; + // + Double_t fX_fp_best; + Double_t fY_fp_best; + Double_t fXp_fp_best; + Double_t fYp_fp_best; + Double_t fChisq_best; + Int_t fSp1_ID_best; + Int_t fSp2_ID_best; + Bool_t fInSideDipoleExit_best; + // For accumulating statitics for efficiencies + Int_t fTotEvents; + Int_t* fNChamHits; + Int_t* fPlaneEvents; + + // Pointer to global var indicating whether this spectrometer is triggered + // for this event. + Bool_t* fPresentP; + + // Useful derived quantities + // double tan_angle, sin_angle, cos_angle; + + // Intermediate structure for building + static const UInt_t MAXTRACKS = 50; + +public: + THcDriftChamberPlane* GetPlane(unsigned int i_plane) { + if(static_cast<int>(i_plane) < fNPlanes) { + return fPlanes[i_plane]; + } + return nullptr; + } + +protected: + std::vector<THcDriftChamberPlane*> fPlanes; // List of plane objects + std::vector<THcDriftChamber*> fChambers; // List of chamber objects + + TClonesArray* fTrackProj; // projection of track onto scintillator plane + // and estimated match to TOF paddle + void ClearEvent(); + void DeleteArrays(); + virtual Int_t ReadDatabase( const TDatime& date ); + virtual Int_t DefineVariables( EMode mode = kDefine ); + void LinkStubs(); + void TrackFit(); + Double_t DpsiFun(Double_t ray[4], Int_t plane); + void EffInit(); + void Eff(); + + void Setup(const char* name, const char* description); + void PrintSpacePoints(); + void PrintStubs(); + void EfficiencyPerWire(Int_t golden_track_index); + ClassDef(THcDC,0) // Set of Drift Chambers detector +}; + +//////////////////////////////////////////////////////////////////////////////// + +#endif diff --git a/src/hc_compiledata.h.in b/src/hallc/hc_compiledata.h.in similarity index 100% rename from src/hc_compiledata.h.in rename to src/hallc/hc_compiledata.h.in diff --git a/src/include/Scaler9001.h b/src/hallc/include/Scaler9001.h similarity index 100% rename from src/include/Scaler9001.h rename to src/hallc/include/Scaler9001.h diff --git a/src/include/Scaler9250.h b/src/hallc/include/Scaler9250.h similarity index 100% rename from src/include/Scaler9250.h rename to src/hallc/include/Scaler9250.h diff --git a/src/include/Scandalizer.h b/src/hallc/include/Scandalizer.h similarity index 100% rename from src/include/Scandalizer.h rename to src/hallc/include/Scandalizer.h diff --git a/src/include/Shower2.h b/src/hallc/include/Shower2.h similarity index 100% rename from src/include/Shower2.h rename to src/hallc/include/Shower2.h diff --git a/src/include/THcAerogel.h b/src/hallc/include/THcAerogel.h similarity index 100% rename from src/include/THcAerogel.h rename to src/hallc/include/THcAerogel.h diff --git a/src/include/THcAerogelHit.h b/src/hallc/include/THcAerogelHit.h similarity index 100% rename from src/include/THcAerogelHit.h rename to src/hallc/include/THcAerogelHit.h diff --git a/src/include/THcAnalyzer.h b/src/hallc/include/THcAnalyzer.h similarity index 100% rename from src/include/THcAnalyzer.h rename to src/hallc/include/THcAnalyzer.h diff --git a/src/include/THcBCMCurrent.h b/src/hallc/include/THcBCMCurrent.h similarity index 100% rename from src/include/THcBCMCurrent.h rename to src/hallc/include/THcBCMCurrent.h diff --git a/src/include/THcCherenkov.h b/src/hallc/include/THcCherenkov.h similarity index 100% rename from src/include/THcCherenkov.h rename to src/hallc/include/THcCherenkov.h diff --git a/src/include/THcCherenkovHit.h b/src/hallc/include/THcCherenkovHit.h similarity index 100% rename from src/include/THcCherenkovHit.h rename to src/hallc/include/THcCherenkovHit.h diff --git a/src/include/THcCoinTime.h b/src/hallc/include/THcCoinTime.h similarity index 100% rename from src/include/THcCoinTime.h rename to src/hallc/include/THcCoinTime.h diff --git a/src/include/THcConfigEvtHandler.h b/src/hallc/include/THcConfigEvtHandler.h similarity index 100% rename from src/include/THcConfigEvtHandler.h rename to src/hallc/include/THcConfigEvtHandler.h diff --git a/src/include/THcDC.h b/src/hallc/include/THcDC.h similarity index 100% rename from src/include/THcDC.h rename to src/hallc/include/THcDC.h diff --git a/src/include/THcDCHit.h b/src/hallc/include/THcDCHit.h similarity index 100% rename from src/include/THcDCHit.h rename to src/hallc/include/THcDCHit.h diff --git a/src/include/THcDCLookupTTDConv.h b/src/hallc/include/THcDCLookupTTDConv.h similarity index 100% rename from src/include/THcDCLookupTTDConv.h rename to src/hallc/include/THcDCLookupTTDConv.h diff --git a/src/include/THcDCTimeToDistConv.h b/src/hallc/include/THcDCTimeToDistConv.h similarity index 100% rename from src/include/THcDCTimeToDistConv.h rename to src/hallc/include/THcDCTimeToDistConv.h diff --git a/src/include/THcDCTrack.h b/src/hallc/include/THcDCTrack.h similarity index 100% rename from src/include/THcDCTrack.h rename to src/hallc/include/THcDCTrack.h diff --git a/src/include/THcDCWire.h b/src/hallc/include/THcDCWire.h similarity index 100% rename from src/include/THcDCWire.h rename to src/hallc/include/THcDCWire.h diff --git a/src/include/THcDetectorMap.h b/src/hallc/include/THcDetectorMap.h similarity index 100% rename from src/include/THcDetectorMap.h rename to src/hallc/include/THcDetectorMap.h diff --git a/src/include/THcDriftChamber.h b/src/hallc/include/THcDriftChamber.h similarity index 100% rename from src/include/THcDriftChamber.h rename to src/hallc/include/THcDriftChamber.h diff --git a/src/include/THcDriftChamberPlane.h b/src/hallc/include/THcDriftChamberPlane.h similarity index 100% rename from src/include/THcDriftChamberPlane.h rename to src/hallc/include/THcDriftChamberPlane.h diff --git a/src/include/THcDummySpectrometer.h b/src/hallc/include/THcDummySpectrometer.h similarity index 100% rename from src/include/THcDummySpectrometer.h rename to src/hallc/include/THcDummySpectrometer.h diff --git a/src/include/THcExtTarCor.h b/src/hallc/include/THcExtTarCor.h similarity index 100% rename from src/include/THcExtTarCor.h rename to src/hallc/include/THcExtTarCor.h diff --git a/src/include/THcFormula.h b/src/hallc/include/THcFormula.h similarity index 100% rename from src/include/THcFormula.h rename to src/hallc/include/THcFormula.h diff --git a/src/include/THcGlobals.h b/src/hallc/include/THcGlobals.h similarity index 100% rename from src/include/THcGlobals.h rename to src/hallc/include/THcGlobals.h diff --git a/src/include/THcHallCSpectrometer.h b/src/hallc/include/THcHallCSpectrometer.h similarity index 100% rename from src/include/THcHallCSpectrometer.h rename to src/hallc/include/THcHallCSpectrometer.h diff --git a/src/include/THcHelicity.h b/src/hallc/include/THcHelicity.h similarity index 100% rename from src/include/THcHelicity.h rename to src/hallc/include/THcHelicity.h diff --git a/src/include/THcHelicityReader.h b/src/hallc/include/THcHelicityReader.h similarity index 100% rename from src/include/THcHelicityReader.h rename to src/hallc/include/THcHelicityReader.h diff --git a/src/include/THcHelicityScaler.h b/src/hallc/include/THcHelicityScaler.h similarity index 100% rename from src/include/THcHelicityScaler.h rename to src/hallc/include/THcHelicityScaler.h diff --git a/src/include/THcHitList.h b/src/hallc/include/THcHitList.h similarity index 100% rename from src/include/THcHitList.h rename to src/hallc/include/THcHitList.h diff --git a/src/include/THcHodoEff.h b/src/hallc/include/THcHodoEff.h similarity index 100% rename from src/include/THcHodoEff.h rename to src/hallc/include/THcHodoEff.h diff --git a/src/include/THcHodoHit.h b/src/hallc/include/THcHodoHit.h similarity index 100% rename from src/include/THcHodoHit.h rename to src/hallc/include/THcHodoHit.h diff --git a/src/include/THcHodoscope.h b/src/hallc/include/THcHodoscope.h similarity index 100% rename from src/include/THcHodoscope.h rename to src/hallc/include/THcHodoscope.h diff --git a/src/include/THcInterface.h b/src/hallc/include/THcInterface.h similarity index 100% rename from src/include/THcInterface.h rename to src/hallc/include/THcInterface.h diff --git a/src/include/THcParmList.h b/src/hallc/include/THcParmList.h similarity index 100% rename from src/include/THcParmList.h rename to src/hallc/include/THcParmList.h diff --git a/src/include/THcPeriodicReport.h b/src/hallc/include/THcPeriodicReport.h similarity index 100% rename from src/include/THcPeriodicReport.h rename to src/hallc/include/THcPeriodicReport.h diff --git a/src/include/THcPrimaryKine.h b/src/hallc/include/THcPrimaryKine.h similarity index 100% rename from src/include/THcPrimaryKine.h rename to src/hallc/include/THcPrimaryKine.h diff --git a/src/include/THcRaster.h b/src/hallc/include/THcRaster.h similarity index 100% rename from src/include/THcRaster.h rename to src/hallc/include/THcRaster.h diff --git a/src/include/THcRasterRawHit.h b/src/hallc/include/THcRasterRawHit.h similarity index 100% rename from src/include/THcRasterRawHit.h rename to src/hallc/include/THcRasterRawHit.h diff --git a/src/include/THcRasteredBeam.h b/src/hallc/include/THcRasteredBeam.h similarity index 100% rename from src/include/THcRasteredBeam.h rename to src/hallc/include/THcRasteredBeam.h diff --git a/src/include/THcRawAdcHit.h b/src/hallc/include/THcRawAdcHit.h similarity index 100% rename from src/include/THcRawAdcHit.h rename to src/hallc/include/THcRawAdcHit.h diff --git a/src/include/THcRawDCHit.h b/src/hallc/include/THcRawDCHit.h similarity index 100% rename from src/include/THcRawDCHit.h rename to src/hallc/include/THcRawDCHit.h diff --git a/src/include/THcRawHit.h b/src/hallc/include/THcRawHit.h similarity index 100% rename from src/include/THcRawHit.h rename to src/hallc/include/THcRawHit.h diff --git a/src/include/THcRawHodoHit.h b/src/hallc/include/THcRawHodoHit.h similarity index 100% rename from src/include/THcRawHodoHit.h rename to src/hallc/include/THcRawHodoHit.h diff --git a/src/include/THcRawShowerHit.h b/src/hallc/include/THcRawShowerHit.h similarity index 100% rename from src/include/THcRawShowerHit.h rename to src/hallc/include/THcRawShowerHit.h diff --git a/src/include/THcRawTdcHit.h b/src/hallc/include/THcRawTdcHit.h similarity index 100% rename from src/include/THcRawTdcHit.h rename to src/hallc/include/THcRawTdcHit.h diff --git a/src/include/THcReactionPoint.h b/src/hallc/include/THcReactionPoint.h similarity index 100% rename from src/include/THcReactionPoint.h rename to src/hallc/include/THcReactionPoint.h diff --git a/src/include/THcRun.h b/src/hallc/include/THcRun.h similarity index 100% rename from src/include/THcRun.h rename to src/hallc/include/THcRun.h diff --git a/src/include/THcRunParameters.h b/src/hallc/include/THcRunParameters.h similarity index 100% rename from src/include/THcRunParameters.h rename to src/hallc/include/THcRunParameters.h diff --git a/src/include/THcScalerEvtHandler.h b/src/hallc/include/THcScalerEvtHandler.h similarity index 100% rename from src/include/THcScalerEvtHandler.h rename to src/hallc/include/THcScalerEvtHandler.h diff --git a/src/include/THcScintPlaneCluster.h b/src/hallc/include/THcScintPlaneCluster.h similarity index 100% rename from src/include/THcScintPlaneCluster.h rename to src/hallc/include/THcScintPlaneCluster.h diff --git a/src/include/THcScintillatorPlane.h b/src/hallc/include/THcScintillatorPlane.h similarity index 100% rename from src/include/THcScintillatorPlane.h rename to src/hallc/include/THcScintillatorPlane.h diff --git a/src/include/THcSecondaryKine.h b/src/hallc/include/THcSecondaryKine.h similarity index 100% rename from src/include/THcSecondaryKine.h rename to src/hallc/include/THcSecondaryKine.h diff --git a/src/include/THcShower.h b/src/hallc/include/THcShower.h similarity index 100% rename from src/include/THcShower.h rename to src/hallc/include/THcShower.h diff --git a/src/include/THcShowerArray.h b/src/hallc/include/THcShowerArray.h similarity index 100% rename from src/include/THcShowerArray.h rename to src/hallc/include/THcShowerArray.h diff --git a/src/include/THcShowerHit.h b/src/hallc/include/THcShowerHit.h similarity index 100% rename from src/include/THcShowerHit.h rename to src/hallc/include/THcShowerHit.h diff --git a/src/include/THcShowerPlane.h b/src/hallc/include/THcShowerPlane.h similarity index 100% rename from src/include/THcShowerPlane.h rename to src/hallc/include/THcShowerPlane.h diff --git a/src/include/THcSignalHit.h b/src/hallc/include/THcSignalHit.h similarity index 100% rename from src/include/THcSignalHit.h rename to src/hallc/include/THcSignalHit.h diff --git a/src/include/THcSpacePoint.h b/src/hallc/include/THcSpacePoint.h similarity index 100% rename from src/include/THcSpacePoint.h rename to src/hallc/include/THcSpacePoint.h diff --git a/src/include/THcTimeSyncEvtHandler.h b/src/hallc/include/THcTimeSyncEvtHandler.h similarity index 100% rename from src/include/THcTimeSyncEvtHandler.h rename to src/hallc/include/THcTimeSyncEvtHandler.h diff --git a/src/include/THcTrigApp.h b/src/hallc/include/THcTrigApp.h similarity index 100% rename from src/include/THcTrigApp.h rename to src/hallc/include/THcTrigApp.h diff --git a/src/include/THcTrigDet.h b/src/hallc/include/THcTrigDet.h similarity index 100% rename from src/include/THcTrigDet.h rename to src/hallc/include/THcTrigDet.h diff --git a/src/include/THcTrigRawHit.h b/src/hallc/include/THcTrigRawHit.h similarity index 100% rename from src/include/THcTrigRawHit.h rename to src/hallc/include/THcTrigRawHit.h diff --git a/src/include/TIBlobModule.h b/src/hallc/include/TIBlobModule.h similarity index 100% rename from src/include/TIBlobModule.h rename to src/hallc/include/TIBlobModule.h diff --git a/src/hallc/include/TrackingEfficiency.hhh b/src/hallc/include/TrackingEfficiency.hhh new file mode 100644 index 0000000..5e2ea1b --- /dev/null +++ b/src/hallc/include/TrackingEfficiency.hhh @@ -0,0 +1,104 @@ +#ifndef ROOT_TrackingEfficiency +#define ROOT_TrackingEfficiency + +/////////////////////////////////////////////////////////////////////////////// +// // +// TrackingEfficiency // +// // +/////////////////////////////////////////////////////////////////////////////// + +#include "THaEvData.h" +#include "THaCutList.h" +#include "VarDef.h" +#include "VarType.h" +#include "TClonesArray.h" + +#include <cstring> +#include <cstdio> +#include <cstdlib> +#include <iostream> + +#include "THaPhysicsModule.h" +#include "THcHodoscope.h" +#include "THaSpectrometer.h" +#include "THaTrack.h" + +namespace hcana { + + + /** \brief TrackingEfficiency calculation. + * + * \ingroup PhysMods + */ + class TrackingEfficiency : public THaPhysicsModule { + public: + TrackingEfficiency(const char* name, const char* description, const char* hodname); + virtual ~TrackingEfficiency(); + + virtual Int_t Begin(THaRunBase* r = 0); + virtual Int_t End(THaRunBase* r = 0); + virtual EStatus Init(const TDatime& run_time); + virtual Int_t Process(const THaEvData&); + + void Reset(Option_t* opt = ""); + + protected: + virtual Int_t ReadDatabase(const TDatime& date); + virtual Int_t DefineVariables(EMode mode = kDefine); + /* Int_t GetScinIndex(Int_t nPlane, Int_t nPaddle); */ + + // Data needed for efficiency calculation for one Hodoscope paddle + + // Double_t* fZPos; // + + // TString fName; // Name of hodoscope + // THcHodoscope* fHod; // Hodscope object + // THaSpectrometer* fSpectro; // Spectrometer object + + // Long64_t fNevt; + + //// Information about the hodoscopes that we get from the + //// THcHodoscope object + + // Int_t fEffiTest; + // Int_t fNPlanes; + // THcScintillatorPlane** fPlanes; + // Double_t* fPosZ; + // Double_t* fSpacing; + // Double_t* fCenterFirst; + // Int_t* fNCounters; + //// Int_t* fHodoPlnContHit; + // Int_t* fHodoPosEffi; + // Int_t* fHodoNegEffi; + // Int_t* fHodoOrEffi; + // Int_t* fHodoAndEffi; + // Int_t* fStatTrk; + // Int_t* fStatTrkSum; + // Int_t* fStatAndSum; + // Double_t* fStatAndEff; + // Double_t fStatSlop; + // Double_t fHodoEff_CalEnergy_Cut; + // Double_t fMaxChisq; + // Double_t* fHodoSlop; + // Double_t fHodoEff_s1, fHodoEff_s2, fHodoEff_tof, fHodoEff_3_of_4, fHodoEff_4_of_4; + + //// Arrays for accumulating statistics + // vector<vector<vector<Int_t>>> fHitShould; + // vector<vector<vector<Int_t>>> fStatAndHitDel; + // vector<vector<vector<Int_t>>> fStatTrkDel; + // vector<vector<Int_t>> fStatPosHit; + // vector<vector<Int_t>> fStatNegHit; + // vector<vector<Int_t>> fStatAndHit; + // vector<vector<Int_t>> fStatOrHit; + // vector<vector<Int_t>> fBothGood; + // vector<vector<Int_t>> fNegGood; + // vector<vector<Int_t>> fPosGood; + + // Int_t* fHitPlane; + + ClassDef(TrackingEfficiency, 0) // Hodoscope efficiency module + }; + +} // namespace hcana + +#endif diff --git a/src/include/hcana/HallC_Data.h b/src/hallc/include/hcana/HallC_Data.h similarity index 100% rename from src/include/hcana/HallC_Data.h rename to src/hallc/include/hcana/HallC_Data.h diff --git a/src/include/hcana/Logger.h b/src/hallc/include/hcana/Logger.h similarity index 100% rename from src/include/hcana/Logger.h rename to src/hallc/include/hcana/Logger.h diff --git a/src/include/hcana/helpers.hxx b/src/hallc/include/hcana/helpers.hxx similarity index 100% rename from src/include/hcana/helpers.hxx rename to src/hallc/include/hcana/helpers.hxx diff --git a/src/nlohmann/json.hpp b/src/hallc/nlohmann/json.hpp similarity index 100% rename from src/nlohmann/json.hpp rename to src/hallc/nlohmann/json.hpp diff --git a/src/src/Scaler9001.cxx b/src/hallc/src/Scaler9001.cxx similarity index 100% rename from src/src/Scaler9001.cxx rename to src/hallc/src/Scaler9001.cxx diff --git a/src/src/Scaler9250.cxx b/src/hallc/src/Scaler9250.cxx similarity index 100% rename from src/src/Scaler9250.cxx rename to src/hallc/src/Scaler9250.cxx diff --git a/src/src/Scandalizer.cxx b/src/hallc/src/Scandalizer.cxx similarity index 100% rename from src/src/Scandalizer.cxx rename to src/hallc/src/Scandalizer.cxx diff --git a/src/src/Shower2.cxx b/src/hallc/src/Shower2.cxx similarity index 100% rename from src/src/Shower2.cxx rename to src/hallc/src/Shower2.cxx diff --git a/src/src/THcAerogel.cxx b/src/hallc/src/THcAerogel.cxx similarity index 100% rename from src/src/THcAerogel.cxx rename to src/hallc/src/THcAerogel.cxx diff --git a/src/src/THcAerogelHit.cxx b/src/hallc/src/THcAerogelHit.cxx similarity index 100% rename from src/src/THcAerogelHit.cxx rename to src/hallc/src/THcAerogelHit.cxx diff --git a/src/src/THcAnalyzer.cxx b/src/hallc/src/THcAnalyzer.cxx similarity index 100% rename from src/src/THcAnalyzer.cxx rename to src/hallc/src/THcAnalyzer.cxx diff --git a/src/src/THcBCMCurrent.cxx b/src/hallc/src/THcBCMCurrent.cxx similarity index 100% rename from src/src/THcBCMCurrent.cxx rename to src/hallc/src/THcBCMCurrent.cxx diff --git a/src/src/THcCherenkov.cxx b/src/hallc/src/THcCherenkov.cxx similarity index 100% rename from src/src/THcCherenkov.cxx rename to src/hallc/src/THcCherenkov.cxx diff --git a/src/src/THcCherenkovHit.cxx b/src/hallc/src/THcCherenkovHit.cxx similarity index 100% rename from src/src/THcCherenkovHit.cxx rename to src/hallc/src/THcCherenkovHit.cxx diff --git a/src/src/THcCoinTime.cxx b/src/hallc/src/THcCoinTime.cxx similarity index 100% rename from src/src/THcCoinTime.cxx rename to src/hallc/src/THcCoinTime.cxx diff --git a/src/src/THcConfigEvtHandler.cxx b/src/hallc/src/THcConfigEvtHandler.cxx similarity index 100% rename from src/src/THcConfigEvtHandler.cxx rename to src/hallc/src/THcConfigEvtHandler.cxx diff --git a/src/hallc/src/THcDC.cxx b/src/hallc/src/THcDC.cxx new file mode 100644 index 0000000..cad4ce9 --- /dev/null +++ b/src/hallc/src/THcDC.cxx @@ -0,0 +1,1404 @@ +/** \class THcDC + \ingroup Detectors + +\brief Analyze a package of horizontal drift chambers. + +Uses the +first letter of the apparatus name as a prefix to parameter names. The +paramters, read in the Setup method, determine the number of chambers and +the number of parameters per plane. + +\author S. A. Wood, based on Fortran ENGINE + +*/ + +#include "THcDC.h" +#include "TClonesArray.h" +#include "THaApparatus.h" +#include "THaCutList.h" +#include "THaDetMap.h" +#include "THaEvData.h" +#include "THaTrack.h" +#include "THcDCTrack.h" +#include "THcDetectorMap.h" +#include "THcGlobals.h" +#include "THcHallCSpectrometer.h" +#include "THcParmList.h" +#include "TMath.h" +#include "TVectorD.h" +#include "VarDef.h" +#include "VarType.h" + +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <iostream> + +#include "spdlog/sinks/basic_file_sink.h" // support for basic file logging +#include "spdlog/sinks/stdout_color_sinks.h" //support for stdout logging +#include "spdlog/spdlog.h" + +using namespace std; + +//_____________________________________________________________________________ +THcDC::THcDC(const char* name, const char* description, THaApparatus* apparatus) + : THaTrackingDetector(name, description, apparatus) { + // Constructor + + fNPlanes = 0; // No planes until we make them + _sub_logger = _det_logger->clone("THcDC"); + fXCenter = NULL; + fYCenter = NULL; + fMinHits = NULL; + fMaxHits = NULL; + fMinCombos = NULL; + fSpace_Point_Criterion = NULL; + + fTdcWinMin = NULL; + fTdcWinMax = NULL; + fCentralTime = NULL; + fNWires = NULL; + fNChamber = NULL; + fWireOrder = NULL; + fDriftTimeSign = NULL; + fReadoutTB = NULL; + fReadoutLR = NULL; + + fXPos = NULL; + fYPos = NULL; + fZPos = NULL; + fAlphaAngle = NULL; + fBetaAngle = NULL; + fGammaAngle = NULL; + fPitch = NULL; + fCentralWire = NULL; + fPlaneTimeZero = NULL; + fSigma = NULL; + + // These should be set to zero (in a parameter file) in order to + // replicate historical ENGINE behavior + fFixLR = 1; + fFixPropagationCorrection = 1; + fProjectToChamber = 0; // Use 1 for SOS chambers + + fDCTracks = new TClonesArray("THcDCTrack", 20); + + fNChamHits = 0; + fPlaneEvents = 0; + + // The version defaults to 0 (old HMS style). 1 is new HMS style and 2 is SHMS style. + fVersion = 0; + + // Create and return a shared_ptr to a multithreaded console logger. + //_logger = spdlog::get("config"); + // if(!_logger) { + // _logger = spdlog::stdout_color_mt("config"); + //} + _sub_logger->debug("THcDC constructor"); +} + +//_____________________________________________________________________________ +void THcDC::Setup(const char* name, const char* description) { + + Bool_t optional = true; + + // Create the chamber and plane objects using parameters. + static const char* const here = "Setup"; + + THaApparatus* app = GetApparatus(); + if (app) { + // cout << app->GetName() << endl; + fPrefix[0] = tolower(app->GetName()[0]); + fPrefix[1] = '\0'; + } else { + cout << "No apparatus found" << endl; + fPrefix[0] = '\0'; + } + + // For now, decide chamber style from the spectrometer name. + // Should override with a paramter + // cout<<"HMS Style??\t"<<fHMSStyleChambers<<endl; + string planenamelist; + DBRequest list[] = {{"dc_num_planes", &fNPlanes, kInt}, + {"dc_num_chambers", &fNChambers, kInt}, + {"dc_tdc_time_per_channel", &fNSperChan, kDouble}, + {"dc_wire_velocity", &fWireVelocity, kDouble}, + {"dc_plane_names", &planenamelist, kString}, + {"dc_version", &fVersion, kInt, 0, optional}, + {"dc_tdcrefcut", &fTDC_RefTimeCut, kInt, 0, 1}, + {0}}; + + fTDC_RefTimeCut = 0; // Minimum allowed reference times + gHcParms->LoadParmValues((DBRequest*)&list, fPrefix); + + if (fVersion == 0) { + fHMSStyleChambers = 1; + } else { + fHMSStyleChambers = 0; + } + + _det_logger->info("Plane Name List: {}", planenamelist); + _det_logger->info("Drift Chambers: {} planes in {} chambers", fNPlanes, fNChambers); + // cout << "Plane Name List: " << planenamelist << endl; + // cout << "Drift Chambers: " << fNPlanes << " planes in " << fNChambers << " chambers" << endl; + + vector<string> plane_names = vsplit(planenamelist); + + if (plane_names.size() != (UInt_t)fNPlanes) { + // cout << "ERROR: Number of planes " << fNPlanes << " doesn't agree with number of plane names + // " << plane_names.size() << endl; + _det_logger->error("ERROR: Number of planes {} doesn't agree with number of plane names {}", + fNPlanes, plane_names.size()); + + // Should quit. Is there an official way to quit? + } + fPlaneNames = new char*[fNPlanes]; + for (Int_t i = 0; i < fNPlanes; i++) { + fPlaneNames[i] = new char[plane_names[i].length() + 1]; + strcpy(fPlaneNames[i], plane_names[i].c_str()); + } + + char* desc = new char[strlen(description) + 100]; + char* desc1 = new char[strlen(description) + 100]; + fPlanes.clear(); + + for (Int_t i = 0; i < fNPlanes; i++) { + strcpy(desc, description); + strcat(desc, " Plane "); + strcat(desc, fPlaneNames[i]); + + THcDriftChamberPlane* newplane = new THcDriftChamberPlane(fPlaneNames[i], desc, i + 1, this); + if (!newplane or newplane->IsZombie()) { + _det_logger->error("{} Error creating Drift Chamber plane {}. Call expert.", Here(here), + name); + MakeZombie(); + delete[] desc; + delete[] desc1; + return; + } + fPlanes.push_back(newplane); + newplane->SetDebug(fDebug); + // cout << "Created Drift Chamber Plane " << fPlaneNames[i] << ", " << desc << endl; + } + + fChambers.clear(); + for (UInt_t i = 0; i < fNChambers; i++) { + sprintf(desc1, "Ch%d", i + 1); + + // Should construct a better chamber name + THcDriftChamber* newchamber = new THcDriftChamber(desc1, desc, i + 1, this); + fChambers.push_back(newchamber); + // cout << "Created Drift Chamber " << i+1 << ", " << desc1 << endl; + _det_logger->info("Created Drift Chamber {}, {}", i + 1, desc1); + newchamber->SetHMSStyleFlag(fHMSStyleChambers); // Tell the chamber its style + } + delete[] desc; + delete[] desc1; +} + +//_____________________________________________________________________________ +THcDC::THcDC() { + // Constructor +} + +//_____________________________________________________________________________ +THaAnalysisObject::EStatus THcDC::Init(const TDatime& date) { + // Register the plane objects with the appropriate chambers. + // Trigger ReadDatabase to load the remaining parameters + Setup(GetName(), GetTitle()); // Create the subdetectors here + EffInit(); + + char EngineDID[] = "xDC"; + EngineDID[0] = toupper(GetApparatus()->GetName()[0]); + if (gHcDetectorMap->FillMap(fDetMap, EngineDID) < 0) { + static const char* const here = "Init()"; + _det_logger->error("{} Error filling detectormap for {}.", Here(here), EngineDID); + return kInitError; + } + + // Should probably put this in ReadDatabase as we will know the + // maximum number of hits after setting up the detector map + _det_logger->info("DC tdc ref time cut = {} ", fTDC_RefTimeCut); + // cout << " DC tdc ref time cut = " << fTDC_RefTimeCut << endl; + InitHitList(fDetMap, "THcRawDCHit", fDetMap->GetTotNumChan() + 1, fTDC_RefTimeCut, 0); + + CreateMissReportParms(Form("%sdc", fPrefix)); + + EStatus status; + // This triggers call of ReadDatabase and DefineVariables + if ((status = THaTrackingDetector::Init(date))) + return fStatus = status; + + // Initialize planes and add them to chambers + for (Int_t ip = 0; ip < fNPlanes; ip++) { + if ((status = fPlanes[ip]->Init(date))) { + return fStatus = status; + } else { + Int_t chamber = fNChamber[ip]; + fChambers[chamber - 1]->AddPlane(fPlanes[ip]); + } + } + // Initialize chambers + for (UInt_t ic = 0; ic < fNChambers; ic++) { + if ((status = fChambers[ic]->Init(date))) { + return fStatus = status; + } + } + // Retrieve the fiting coefficients + fPlaneCoeffs = new Double_t*[fNPlanes]; + for (Int_t ip = 0; ip < fNPlanes; ip++) { + fPlaneCoeffs[ip] = fPlanes[ip]->GetPlaneCoef(); + } + + fResiduals = new Double_t[fNPlanes]; + fResidualsExclPlane = new Double_t[fNPlanes]; + fWire_hit_did = new Double_t[fNPlanes]; + fWire_hit_should = new Double_t[fNPlanes]; + + // Replace with what we need for Hall C + // const DataDest tmp[NDEST] = { + // { &fRTNhit, &fRANhit, fRT, fRT_c, fRA, fRA_p, fRA_c, fROff, fRPed, fRGain }, + // { &fLTNhit, &fLANhit, fLT, fLT_c, fLA, fLA_p, fLA_c, fLOff, fLPed, fLGain } + // }; + // memcpy( fDataDest, tmp, NDEST*sizeof(DataDest) ); + + fPresentP = 0; + THaVar* vpresent = gHaVars->Find(Form("%s.present", GetApparatus()->GetName())); + if (vpresent) { + fPresentP = (Bool_t*)vpresent->GetValuePointer(); + } + return fStatus = kOK; +} +//_____________________________________________________________________________ + +Int_t THcDC::ManualInitTree(TTree* t) { + std::string app_name = GetApparatus()->GetName(); + std::string det_name = GetName(); + std::string branch_name = (app_name + "_" + det_name + "_data"); + if (t) { + _det_logger->info("THcDC::ManualInitTree : Adding branch, {}, to output tree", branch_name); + t->Branch(branch_name.c_str(), &_basic_data, 32000, 99); + } + return 0; +} + +//_____________________________________________________________________________ +Int_t THcDC::ReadDatabase(const TDatime& date) { + /** + Read this detector's parameters from the ThcParmList + This function is called by THaDetectorBase::Init() once at the + beginning of the analysis. + + */ + // static const char* const here = "ReadDatabase()"; + + delete[] fXCenter; + fXCenter = new Double_t[fNChambers]; + delete[] fYCenter; + fYCenter = new Double_t[fNChambers]; + delete[] fMinHits; + fMinHits = new Int_t[fNChambers]; + delete[] fMaxHits; + fMaxHits = new Int_t[fNChambers]; + delete[] fMinCombos; + fMinCombos = new Int_t[fNChambers]; + delete[] fSpace_Point_Criterion; + fSpace_Point_Criterion = new Double_t[fNChambers]; + + delete[] fTdcWinMin; + fTdcWinMin = new Int_t[fNPlanes]; + delete[] fTdcWinMax; + fTdcWinMax = new Int_t[fNPlanes]; + delete[] fCentralTime; + fCentralTime = new Double_t[fNPlanes]; + delete[] fNWires; + fNWires = new Int_t[fNPlanes]; + delete[] fNChamber; + fNChamber = new Int_t[fNPlanes]; // Which chamber is this plane + delete[] fWireOrder; + fWireOrder = new Int_t[fNPlanes]; // Wire readout order + delete[] fDriftTimeSign; + fDriftTimeSign = new Int_t[fNPlanes]; + delete[] fReadoutLR; + fReadoutLR = new Int_t[fNPlanes]; + delete[] fReadoutTB; + fReadoutTB = new Int_t[fNPlanes]; + + delete[] fXPos; + fXPos = new Double_t[fNPlanes]; + delete[] fYPos; + fYPos = new Double_t[fNPlanes]; + delete[] fZPos; + fZPos = new Double_t[fNPlanes]; + delete[] fAlphaAngle; + fAlphaAngle = new Double_t[fNPlanes]; + delete[] fBetaAngle; + fBetaAngle = new Double_t[fNPlanes]; + delete[] fGammaAngle; + fGammaAngle = new Double_t[fNPlanes]; + delete[] fPitch; + fPitch = new Double_t[fNPlanes]; + delete[] fCentralWire; + fCentralWire = new Double_t[fNPlanes]; + delete[] fPlaneTimeZero; + fPlaneTimeZero = new Double_t[fNPlanes]; + delete[] fSigma; + fSigma = new Double_t[fNPlanes]; + + Bool_t optional = true; + + DBRequest list[] = {{"dc_tdc_time_per_channel", &fNSperChan, kDouble}, + {"dc_wire_velocity", &fWireVelocity, kDouble}, + + {"dc_xcenter", fXCenter, kDouble, fNChambers}, + {"dc_ycenter", fYCenter, kDouble, fNChambers}, + {"min_hit", fMinHits, kInt, fNChambers}, + {"max_pr_hits", fMaxHits, kInt, fNChambers}, + {"min_combos", fMinCombos, kInt, fNChambers}, + {"space_point_criterion", fSpace_Point_Criterion, kDouble, fNChambers}, + + {"dc_tdc_min_win", fTdcWinMin, kInt, (UInt_t)fNPlanes}, + {"dc_tdc_max_win", fTdcWinMax, kInt, (UInt_t)fNPlanes}, + {"dc_central_time", fCentralTime, kDouble, (UInt_t)fNPlanes}, + {"dc_nrwire", fNWires, kInt, (UInt_t)fNPlanes}, + {"dc_chamber_planes", fNChamber, kInt, (UInt_t)fNPlanes}, + {"dc_wire_counting", fWireOrder, kInt, (UInt_t)fNPlanes}, + {"dc_drifttime_sign", fDriftTimeSign, kInt, (UInt_t)fNPlanes}, + {"dc_readoutLR", fReadoutLR, kInt, (UInt_t)fNPlanes, optional}, + {"dc_readoutTB", fReadoutTB, kInt, (UInt_t)fNPlanes, optional}, + + {"dc_zpos", fZPos, kDouble, (UInt_t)fNPlanes}, + {"dc_alpha_angle", fAlphaAngle, kDouble, (UInt_t)fNPlanes}, + {"dc_beta_angle", fBetaAngle, kDouble, (UInt_t)fNPlanes}, + {"dc_gamma_angle", fGammaAngle, kDouble, (UInt_t)fNPlanes}, + {"dc_pitch", fPitch, kDouble, (UInt_t)fNPlanes}, + {"dc_central_wire", fCentralWire, kDouble, (UInt_t)fNPlanes}, + {"dc_plane_time_zero", fPlaneTimeZero, kDouble, (UInt_t)fNPlanes}, + {"dc_sigma", fSigma, kDouble, (UInt_t)fNPlanes}, + {"single_stub", &fSingleStub, kInt, 0, 1}, + {"ntracks_max_fp", &fNTracksMaxFP, kInt}, + {"xt_track_criterion", &fXtTrCriterion, kDouble}, + {"yt_track_criterion", &fYtTrCriterion, kDouble}, + {"xpt_track_criterion", &fXptTrCriterion, kDouble}, + {"ypt_track_criterion", &fYptTrCriterion, kDouble}, + {"dc_fix_lr", &fFixLR, kInt}, + {"dc_fix_propcorr", &fFixPropagationCorrection, kInt}, + {"debuglinkstubs", &fdebuglinkstubs, kInt}, + {"debugprintrawdc", &fdebugprintrawdc, kInt}, + {"debugprintdecodeddc", &fdebugprintdecodeddc, kInt}, + {"debugflagpr", &fdebugflagpr, kInt}, + {"debugflagstubs", &fdebugflagstubs, kInt}, + {"debugtrackprint", &fdebugtrackprint, kInt}, + {0}}; + fSingleStub = 0; + for (Int_t ip = 0; ip < fNPlanes; ip++) { + fReadoutLR[ip] = 0.0; + fReadoutTB[ip] = 0.0; + } + + gHcParms->LoadParmValues((DBRequest*)&list, fPrefix); + + // Set the default plane x,y positions to those of the chamber + for (Int_t ip = 0; ip < fNPlanes; ip++) { + fXPos[ip] = fXCenter[GetNChamber(ip + 1) - 1]; + fYPos[ip] = fYCenter[GetNChamber(ip + 1) - 1]; + } + + // Load the x,y positions of the planes if they exist (overwrites defaults) + DBRequest listOpt[] = {{"dc_xpos", fXPos, kDouble, (UInt_t)fNPlanes, optional}, + {"dc_ypos", fYPos, kDouble, (UInt_t)fNPlanes, optional}, + {0}}; + gHcParms->LoadParmValues((DBRequest*)&listOpt, fPrefix); + if (fNTracksMaxFP <= 0) + fNTracksMaxFP = 10; + // if(fNTracksMaxFP > HNRACKS_MAX) fNTracksMaxFP = NHTRACKS_MAX; + + std::string plane_counts_string; + // cout << "Plane counts:"; + for (Int_t i = 0; i < fNPlanes; i++) { + // cout << " " << fNWires[i]; + plane_counts_string += std::string(" "); + plane_counts_string += std::to_string(fNWires[i]); + } + // cout << endl; + _det_logger->info("Plane counts: {}", plane_counts_string); + + fIsInit = true; + + return kOK; +} + +//_____________________________________________________________________________ +Int_t THcDC::DefineVariables(EMode mode) { + /** + Initialize global variables for histograms and Root tree + */ + if (mode == kDefine && fIsSetup) + return kOK; + fIsSetup = (mode == kDefine); + + // Register variables in global list + + RVarDef vars[] = { + {"stubtest", "stub test", "fStubTest"}, + {"nhit", "Number of DC hits", "fNhits"}, + {"tnhit", "Number of good DC hits", "fNthits"}, + {"trawhit", "Number of true raw DC hits", "fN_True_RawHits"}, + {"ntrack", "Number of Tracks", "fNDCTracks"}, + {"nsp", "Number of Space Points", "fNSp"}, + {"track_nsp", "Number of spacepoints in track", "fDCTracks.THcDCTrack.GetNSpacePoints()"}, + {"x", "X at focal plane", "fDCTracks.THcDCTrack.GetX()"}, + {"y", "Y at focal plane", "fDCTracks.THcDCTrack.GetY()"}, + {"xp", "XP at focal plane", "fDCTracks.THcDCTrack.GetXP()"}, + {"yp", "YP at focal plane", "fDCTracks.THcDCTrack.GetYP()"}, + {"x_fp", "X at focal plane (golden track)", "fX_fp_best"}, + {"y_fp", "Y at focal plane( golden track)", "fY_fp_best"}, + {"xp_fp", "XP at focal plane (golden track)", "fXp_fp_best"}, + {"yp_fp", "YP at focal plane(golden track) ", "fYp_fp_best"}, + {"chisq", "chisq/dof (golden track) ", "fChisq_best"}, + {"sp1_id", " (golden track) ", "fSp1_ID_best"}, + {"sp2_id", " (golden track) ", "fSp2_ID_best"}, + {"InsideDipoleExit", " ", "fInSideDipoleExit_best"}, + {"gtrack_nsp", " Number of space points in golden track ", "fNsp_best"}, + {"residual", "Residuals", "fResiduals"}, + {"residualExclPlane", "Residuals", "fResidualsExclPlane"}, + {"wireHitDid", "Wire did have matched track hit", "fWire_hit_did"}, + {"wireHitShould", "Wire should have matched track hit", "fWire_hit_should"}, + {0}}; + return DefineVarsFromList(vars, mode); +} + +//_____________________________________________________________________________ +THcDC::~THcDC() { + // Destructor. Remove variables from global list. + + if (fIsSetup) + RemoveVariables(); + if (fIsInit) + DeleteArrays(); + + // Delete the plane objects + for (vector<THcDriftChamberPlane*>::iterator ip = fPlanes.begin(); ip != fPlanes.end(); ++ip) + delete *ip; + // Delete the chamber objects + for (vector<THcDriftChamber*>::iterator ip = fChambers.begin(); ip != fChambers.end(); ++ip) + delete *ip; + + delete fDCTracks; +} + +//_____________________________________________________________________________ +void THcDC::DeleteArrays() { + // Delete member arrays. Used by destructor. + + delete[] fXCenter; + fXCenter = NULL; + delete[] fYCenter; + fYCenter = NULL; + delete[] fMinHits; + fMinHits = NULL; + delete[] fMaxHits; + fMaxHits = NULL; + delete[] fMinCombos; + fMinCombos = NULL; + delete[] fSpace_Point_Criterion; + fSpace_Point_Criterion = NULL; + + delete[] fTdcWinMin; + fTdcWinMin = NULL; + delete[] fTdcWinMax; + fTdcWinMax = NULL; + delete[] fCentralTime; + fCentralTime = NULL; + delete[] fNWires; + fNWires = NULL; + delete[] fNChamber; + fNChamber = NULL; + delete[] fWireOrder; + fWireOrder = NULL; + delete[] fDriftTimeSign; + fDriftTimeSign = NULL; + delete[] fReadoutLR; + fReadoutLR = NULL; + delete[] fReadoutTB; + fReadoutTB = NULL; + + delete[] fXPos; + fXPos = NULL; + delete[] fYPos; + fYPos = NULL; + delete[] fZPos; + fZPos = NULL; + delete[] fAlphaAngle; + fAlphaAngle = NULL; + delete[] fBetaAngle; + fBetaAngle = NULL; + delete[] fGammaAngle; + fGammaAngle = NULL; + delete[] fPitch; + fPitch = NULL; + delete[] fCentralWire; + fCentralWire = NULL; + delete[] fPlaneTimeZero; + fPlaneTimeZero = NULL; + delete[] fSigma; + fSigma = NULL; + + // Efficiency arrays + delete[] fNChamHits; + fNChamHits = NULL; + delete[] fPlaneEvents; + fPlaneEvents = NULL; + + for (Int_t i = 0; i < fNPlanes; ++i) + delete[] fPlaneNames[i]; + delete[] fPlaneNames; + + delete[] fPlaneCoeffs; + fPlaneCoeffs = 0; + delete[] fResiduals; + fResiduals = 0; + delete[] fResidualsExclPlane; + fResidualsExclPlane = 0; + delete[] fWire_hit_did; + fWire_hit_did = 0; + delete[] fWire_hit_should; + fWire_hit_should = 0; +} + +//_____________________________________________________________________________ +inline void THcDC::ClearEvent() { + // Reset per-event data. + fStubTest = 0; + fNhits = 0; + fNthits = 0; + fN_True_RawHits = 0; + fX_fp_best = -10000.; + fY_fp_best = -10000.; + fXp_fp_best = -10000.; + fYp_fp_best = -10000.; + fChisq_best = kBig; + fNsp_best = 0; + fInSideDipoleExit_best = kTRUE; + for (UInt_t i = 0; i < fNChambers; i++) { + fChambers[i]->Clear(); + } + + for (Int_t i = 0; i < fNPlanes; i++) { + fResiduals[i] = 1000.0; + fResidualsExclPlane[i] = 1000.0; + fWire_hit_did[i] = 1000.0; + fWire_hit_should[i] = 1000.0; + } + + // fTrackProj->Clear(); +} + +//_____________________________________________________________________________ +Int_t THcDC::Decode(const THaEvData& evdata) { + /** + Decode event into hit list. + Pass hit list to the planes. + Load hits from planes into chamber objects + */ + ClearEvent(); + Int_t num_event = evdata.GetEvNum(); + if (fdebugprintrawdc || fdebugprintdecodeddc || fdebuglinkstubs || fdebugtrackprint) + cout << " event num = " << num_event << endl; + // Get the Hall C style hitlist (fRawHitList) for this event + + Bool_t present = kTRUE; // Suppress reference time warnings + if (fPresentP) { // if this spectrometer not part of trigger + present = *fPresentP; + } + fNhits = DecodeToHitList(evdata, !present); + + if (!gHaCuts->Result("Pedestal_event")) { + // Let each plane get its hits + Int_t nexthit = 0; + for (Int_t ip = 0; ip < fNPlanes; ip++) { + nexthit = fPlanes[ip]->ProcessHits(fRawHitList, nexthit); + fN_True_RawHits += fPlanes[ip]->GetNRawhits(); + } + + // fRawHitList is TClones array of THcRawDCHit objects + Int_t counter = 0; + if (fdebugprintrawdc) { + cout << " RAW_TOT_HITS = " << fNRawHits << endl; + cout << " Hit # " + << "Plane " + << " Wire " + << " Raw TDC " << endl; + for (UInt_t ihit = 0; ihit < fNRawHits; ihit++) { + THcRawDCHit* hit = (THcRawDCHit*)fRawHitList->At(ihit); + for (UInt_t imhit = 0; imhit < hit->GetRawTdcHit().GetNHits(); imhit++) { + counter++; + cout << counter << " " << hit->fPlane << " " << hit->fCounter << " " + << hit->GetRawTdcHit().GetTimeRaw(imhit) << endl; + } + } + cout << endl; + } + Eff(); // Accumlate statistics + } + return fNhits; +} + +//_____________________________________________________________________________ +Int_t THcDC::ApplyCorrections(void) { return (0); } + +//_____________________________________________________________________________ +Int_t THcDC::CoarseTrack(TClonesArray& tracks) { + /** + Find a set of tracks through the drift chambers and put them + into the tracks TClonesArray. + Tracks are in the detector coordinate system. + */ + + // Subtract starttimes from each plane hit + for (Int_t ip = 0; ip < fNPlanes; ip++) { + fPlanes[ip]->SubtractStartTime(); + } + // + // Let each chamber get its hits + for (UInt_t ic = 0; ic < fNChambers; ic++) { + fChambers[ic]->ProcessHits(); + fNthits += fChambers[ic]->GetNHits(); + if (fdebugprintdecodeddc) + fChambers[ic]->PrintDecode(); + } + // + for (UInt_t i = 0; i < fNChambers; i++) { + fChambers[i]->FindSpacePoints(); + fChambers[i]->CorrectHitTimes(); + fChambers[i]->LeftRight(); + } + if (fdebugflagstubs) + PrintSpacePoints(); + if (fdebugflagstubs) + PrintStubs(); + // Now link the stubs between chambers + LinkStubs(); + if (fNDCTracks > 0) { + TrackFit(); + // Copy tracks into podd tracks list + for (UInt_t itrack = 0; itrack < fNDCTracks; itrack++) { + THaTrack* theTrack = NULL; + theTrack = AddTrack(tracks, 0.0, 0.0, 0.0, 0.0); // Leaving off trackID + // Should we add stubs with AddCluster? Could we do this + // by having stubs inherit from cluster + + THcDCTrack* tr = static_cast<THcDCTrack*>(fDCTracks->At(itrack)); + theTrack->Set(tr->GetX(), tr->GetY(), tr->GetXP(), tr->GetYP()); + theTrack->SetFlag((UInt_t)0); + // Need to look at how engine does chi2 and track selection. Reduced? + theTrack->SetChi2(tr->GetChisq(), tr->GetNFree()); + // CalcFocalPlaneCoords. Aren't our tracks already in focal plane coords + // We should have some kind of track ID so that the THaTrack can be + // associate back with the DC track + // Assign the track number + theTrack->SetTrkNum(itrack + 1); + } + } + + ApplyCorrections(); + + return 0; +} + +//_____________________________________________________________________________ +Int_t THcDC::FineTrack(TClonesArray& tracks) { return 0; } +// +void THcDC::SetFocalPlaneBestTrack(Int_t golden_track_index) { + THcDCTrack* tr1 = static_cast<THcDCTrack*>(fDCTracks->At(golden_track_index)); + fX_fp_best = tr1->GetX(); + fY_fp_best = tr1->GetY(); + fXp_fp_best = tr1->GetXP(); + fYp_fp_best = tr1->GetYP(); + THcHallCSpectrometer* app = dynamic_cast<THcHallCSpectrometer*>(GetApparatus()); + fInSideDipoleExit_best = + app->InsideDipoleExitWindow(fX_fp_best, fXp_fp_best, fY_fp_best, fYp_fp_best); + fSp1_ID_best = tr1->GetSp1_ID(); + fSp2_ID_best = tr1->GetSp2_ID(); + fChisq_best = tr1->GetChisq(); + fNsp_best = tr1->GetNSpacePoints(); + for (UInt_t ihit = 0; ihit < UInt_t(tr1->GetNHits()); ihit++) { + THcDCHit* hit = tr1->GetHit(ihit); + Int_t plane = hit->GetPlaneNum() - 1; + _basic_data._Residuals[plane] = tr1->GetResidual(plane); + fResiduals[plane] = tr1->GetResidual(plane); + _basic_data._ResidualsExclPlane[plane] = tr1->GetResidualExclPlane(plane); + fResidualsExclPlane[plane] = tr1->GetResidualExclPlane(plane); + } + EfficiencyPerWire(golden_track_index); +} +// +void THcDC::EfficiencyPerWire(Int_t golden_track_index) { + THcDCTrack* tr1 = static_cast<THcDCTrack*>(fDCTracks->At(golden_track_index)); + Double_t track_pos; + for (UInt_t ihit = 0; ihit < UInt_t(tr1->GetNHits()); ihit++) { + THcDCHit* hit = tr1->GetHit(ihit); + Int_t plane = hit->GetPlaneNum() - 1; + track_pos = tr1->GetCoord(plane); + Int_t wire_num = hit->GetWireNum(); + Int_t wire_track_num = round(fPlanes[plane]->CalcWireFromPos(track_pos)); + if ((wire_num - wire_track_num) == 0) + fWire_hit_did[plane] = wire_num; + } + for (Int_t ip = 0; ip < fNPlanes; ip++) { + track_pos = tr1->GetCoord(ip); + Int_t wire_should = round(fPlanes[ip]->CalcWireFromPos(track_pos)); + fWire_hit_should[ip] = wire_should; + } +} +// +void THcDC::PrintSpacePoints() { + for (UInt_t ich = 0; ich < fNChambers; ich++) { + printf("%s %2d %s %3d %s %3d \n", " chamber = ", fChambers[ich]->GetChamberNum(), + " number of hits = ", fChambers[ich]->GetNHits(), + " number of spacepoints = ", fChambers[ich]->GetNSpacePoints()); + printf("%6s %-8s %-8s %6s %6s %10s \n", " ", " ", " ", "Number", "Number", "Plane Wire"); + printf("%6s %-8s %-8s %6s %6s %10s \n", "Point", "x", "y", " hits ", "combos", " for each hit"); + TClonesArray* spacepointarray = fChambers[ich]->GetSpacePointsP(); + for (Int_t isp = 0; isp < fChambers[ich]->GetNSpacePoints(); isp++) { + THcSpacePoint* sp = (THcSpacePoint*)(spacepointarray->At(isp)); + printf("%5d %8.5f %8.5f %5d %5d ", isp + 1, sp->GetX(), sp->GetY(), sp->GetNHits(), + sp->GetCombos()); + for (Int_t ii = 0; ii < sp->GetNHits(); ii++) { + THcDCHit* hittemp = (THcDCHit*)(sp->GetHit(ii)); + printf("%3d %3d %3d", hittemp->GetPlaneNum(), hittemp->GetWireNum(), hittemp->GetLR()); + } + printf("\n"); + } + } +} +// +// +void THcDC::PrintStubs() { + for (UInt_t ich = 0; ich < fNChambers; ich++) { + printf("%s %3d \n", " Stub fit results Chamber = ", ich + 1); + printf("%-5s %-18s %-18s %-18s %-18s\n", "point", "x_t", "y_t", "xp_t", "yp_t"); + printf("%-5s %-18s %-18s %-18s %-18s\n", " ", "[cm]", "[cm]", "[cm]", "[cm]"); + TClonesArray* spacepointarray = fChambers[ich]->GetSpacePointsP(); + for (Int_t isp = 0; isp < fChambers[ich]->GetNSpacePoints(); isp++) { + THcSpacePoint* sp = (THcSpacePoint*)(spacepointarray->At(isp)); + Double_t* spstubt = sp->GetStubP(); + printf("%-5d % 15.10e % 15.10e % 15.10e % 15.10e \n", isp + 1, spstubt[0], spstubt[1], + spstubt[2], spstubt[3]); + } + } +} +// +//_____________________________________________________________________________ +void THcDC::LinkStubs() { + /** + The logic is + 0) Put all space points in a single list + 1) loop over all space points as seeds isp1 + 2) Check if this space point is all ready in a track + 3) loop over all succeeding space pointss isp2 + 4) check if there is a track-criterion match + either add to existing track + or if there is another point in same chamber + make a copy containing isp2 rather than + other point in same chamber + 5) If hsingle_stub is set, make a track of all single + stubs. + */ + + std::vector<THcSpacePoint*> fSp; + fNSp = 0; + fSp.clear(); + fSp.reserve(100); + fNDCTracks = 0; // Number of Focal Plane tracks found + fDCTracks->Delete(); + // Make a vector of pointers to the SpacePoints + // if (fChambers[0]->GetNSpacePoints()+fChambers[1]->GetNSpacePoints()>10) return; + + for (UInt_t ich = 0; ich < fNChambers; ich++) { + Int_t nchamber = fChambers[ich]->GetChamberNum(); + TClonesArray* spacepointarray = fChambers[ich]->GetSpacePointsP(); + for (Int_t isp = 0; isp < fChambers[ich]->GetNSpacePoints(); isp++) { + fSp.push_back(static_cast<THcSpacePoint*>(spacepointarray->At(isp))); + fSp[fNSp]->fNChamber = nchamber; + fSp[fNSp]->fNChamber_spnum = isp; + fNSp++; + if (ich == 0 && fNSp > 50) + break; + if (fNSp > 100) + break; + } + } + Double_t stubminx = 999999; + Double_t stubminy = 999999; + Double_t stubminxp = 999999; + Double_t stubminyp = 999999; + Int_t stub_tracks[MAXTRACKS]; + if (fSingleStub == 0) { + for (Int_t isp1 = 0; isp1 < fNSp - 1; + isp1++) { // isp1 is index/id in total list of space points + THcSpacePoint* sp1 = fSp[isp1]; + Int_t sptracks = 0; + // Now make sure this sp is not already used in a sp. + // Could this be done by having a sp point to the track it is in? + Int_t tryflag = 1; + for (UInt_t itrack = 0; itrack < fNDCTracks; itrack++) { + THcDCTrack* theDCTrack = static_cast<THcDCTrack*>(fDCTracks->At(itrack)); + for (Int_t isp = 0; isp < theDCTrack->GetNSpacePoints(); isp++) { + // isp is index into list of space points attached to theDCTrack + if (theDCTrack->GetSpacePoint(isp) == sp1) { + tryflag = 0; + } + } + } + if (tryflag) { // SP not already part of a track + Int_t newtrack = 1; + for (Int_t isp2 = isp1 + 1; isp2 < fNSp; isp2++) { + THcSpacePoint* sp2 = fSp[isp2]; + if (sp1->fNChamber != sp2->fNChamber && sp1->GetSetStubFlag() && sp2->GetSetStubFlag()) { + Double_t* spstub1 = sp1->GetStubP(); + Double_t* spstub2 = sp2->GetStubP(); + Double_t dposx = spstub1[0] - spstub2[0]; + Double_t dposy; + if (fProjectToChamber) { // From SOS s_link_stubs + // Since single chamber resolution is ~50mr, and the maximum y` + // angle is about 30mr, use differenece between y AT CHAMBERS, rather + // than at focal plane. (Project back to chamber, to take out y' uncertainty) + // (Should this be done for SHMS and HMS too?) + Double_t y1 = spstub1[1] + fChambers[sp1->fNChamber]->GetZPos() * spstub1[3]; + Double_t y2 = spstub2[1] + fChambers[sp2->fNChamber]->GetZPos() * spstub2[3]; + dposy = y1 - y2; + } else { + dposy = spstub1[1] - spstub2[1]; + } + Double_t dposxp = spstub1[2] - spstub2[2]; + Double_t dposyp = spstub1[3] - spstub2[3]; + + // What is the point of saving these stubmin values. They + // Don't seem to be used anywhere except that they can be + // printed out if hbypass_track_eff_files is zero. + if (TMath::Abs(dposx) < TMath::Abs(stubminx)) + stubminx = dposx; + if (TMath::Abs(dposy) < TMath::Abs(stubminy)) + stubminy = dposy; + if (TMath::Abs(dposxp) < TMath::Abs(stubminxp)) + stubminxp = dposxp; + if (TMath::Abs(dposyp) < TMath::Abs(stubminyp)) + stubminyp = dposyp; + + // if hbypass_track_eff_files == 0 then + // Print out each stubminX that is less that its criterion + + if ((TMath::Abs(dposx) < fXtTrCriterion) && (TMath::Abs(dposy) < fYtTrCriterion) && + (TMath::Abs(dposxp) < fXptTrCriterion) && (TMath::Abs(dposyp) < fYptTrCriterion)) { + if (newtrack) { + assert(sptracks == 0); + fStubTest = 1; + // stubtest=1; Used in h_track_tests.f + // Make a new track if there are not to many + if (fNDCTracks < fNTracksMaxFP) { + sptracks = 0; // Number of tracks with this seed + stub_tracks[sptracks++] = fNDCTracks; + THcDCTrack* theDCTrack = new ((*fDCTracks)[fNDCTracks++]) THcDCTrack(fNPlanes); + theDCTrack->AddSpacePoint(sp1); + theDCTrack->AddSpacePoint(sp2); + if (sp1->fNChamber == 1) + theDCTrack->SetSp1_ID(sp1->fNChamber_spnum); + if (sp1->fNChamber == 2) + theDCTrack->SetSp2_ID(sp1->fNChamber_spnum); + if (sp2->fNChamber == 1) + theDCTrack->SetSp1_ID(sp2->fNChamber_spnum); + if (sp2->fNChamber == 2) + theDCTrack->SetSp2_ID(sp2->fNChamber_spnum); + newtrack = 0; // Make no more tracks in this loop + // (But could replace a SP?) + } else { + if (fHMSStyleChambers) { + fNDCTracks = 0; + return; + } + } + } else { + // Check if there is another space point in the same chamber + for (Int_t itrack = 0; itrack < sptracks; itrack++) { + Int_t track = stub_tracks[itrack]; + THcDCTrack* theDCTrack = static_cast<THcDCTrack*>(fDCTracks->At(track)); + Int_t spoint = -1; + Int_t duppoint = 0; + for (Int_t isp = 0; isp < theDCTrack->GetNSpacePoints(); isp++) { + // isp is index of space points in theDCTrack + if (sp2->fNChamber == theDCTrack->GetSpacePoint(isp)->fNChamber) { + spoint = isp; + } + if (sp2 == theDCTrack->GetSpacePoint(isp)) { + duppoint = 1; + } + } // End loop over sp in tracks with isp1 + // If there is no other space point in this chamber + // add this space point to current track(2) + if (!duppoint) { + if (spoint < 0) { + theDCTrack->AddSpacePoint(sp2); + if (sp2->fNChamber == 1) + theDCTrack->SetSp1_ID(sp2->fNChamber_spnum); + if (sp2->fNChamber == 2) + theDCTrack->SetSp2_ID(sp2->fNChamber_spnum); + } else { + // If there is another point in the same chamber + // in this track create a new track with all the + // same space points except spoint + if (fNDCTracks < MAXTRACKS) { + stub_tracks[sptracks++] = fNDCTracks; + THcDCTrack* newDCTrack = + new ((*fDCTracks)[fNDCTracks++]) THcDCTrack(fNPlanes); + for (Int_t isp = 0; isp < theDCTrack->GetNSpacePoints(); isp++) { + if (isp != spoint) { + newDCTrack->AddSpacePoint(theDCTrack->GetSpacePoint(isp)); + if (theDCTrack->GetSpacePoint(isp)->fNChamber == 1) + newDCTrack->SetSp1_ID( + theDCTrack->GetSpacePoint(isp)->fNChamber_spnum); + if (theDCTrack->GetSpacePoint(isp)->fNChamber == 2) + newDCTrack->SetSp2_ID( + theDCTrack->GetSpacePoint(isp)->fNChamber_spnum); + } else { + newDCTrack->AddSpacePoint(sp2); + if (sp2->fNChamber == 1) + newDCTrack->SetSp1_ID(sp2->fNChamber_spnum); + if (sp2->fNChamber == 2) + newDCTrack->SetSp2_ID(sp2->fNChamber_spnum); + } // End check for dup on copy + } // End copy of track + } else { + if (fHMSStyleChambers) { + if (fdebuglinkstubs) + cout << "EPIC FAIL 2: Too many tracks found in THcDC::LinkStubs " + "maxtracks = " + << MAXTRACKS << endl; + fNDCTracks = 0; + return; // Max # of allowed tracks + } + } + } // end if on same chamber + } // end if on duplicate point + } // end for over tracks with isp1 + } // else newtrack + } // criterion + } // end test on same chamber + } // end isp2 loop over new space points + } // end test on tryflag + } // end isp1 outer loop over space points + // + // + } else { // Make track out of each single space point + for (Int_t isp = 0; isp < fNSp; isp++) { + if (fNDCTracks < MAXTRACKS) { + // Need some constructed t thingy + if (fSp[isp]->GetSetStubFlag()) { + THcDCTrack* newDCTrack = new ((*fDCTracks)[fNDCTracks++]) THcDCTrack(fNPlanes); + newDCTrack->AddSpacePoint(fSp[isp]); + } + } else { + if (fdebuglinkstubs) + cout << "EPIC FAIL 3: Too many tracks found in THcDC::LinkStubs" << endl; + fNDCTracks = 0; + // Do something here to fail this event + return; // Max # of allowed tracks + } + } + } + /// + if (fdebuglinkstubs) { + cout << " Number of tracks from link stubs = " << fNDCTracks << endl; + printf("%s %s \n", "Track", "Plane Wire "); + for (UInt_t itrack = 0; itrack < fNDCTracks; itrack++) { + THcDCTrack* tempTrack = (THcDCTrack*)(fDCTracks->At(itrack)); + printf("%-5d ", itrack + 1); + for (Int_t ihit = 0; ihit < tempTrack->GetNHits(); ihit++) { + THcDCHit* hit = (THcDCHit*)(tempTrack->GetHit(ihit)); + printf("%3d %3d", hit->GetPlaneNum(), hit->GetWireNum()); + } + printf("\n"); + } + } +} + +//_____________________________________________________________________________ +void THcDC::TrackFit() { + /** + Primary track fitting routine + */ + + // Number of ray parameters in focal plane. + const Int_t raycoeffmap[] = {4, 5, 2, 3}; + + Double_t dummychi2 = 1.0E4; + for (UInt_t itrack = 0; itrack < fNDCTracks; itrack++) { + // Double_t chi2 = dummychi2; + // Int_t htrack_fit_num = itrack; + THcDCTrack* theDCTrack = static_cast<THcDCTrack*>(fDCTracks->At(itrack)); + + Double_t coords[theDCTrack->GetNHits()]; + Int_t planes[theDCTrack->GetNHits()]; + for (Int_t ihit = 0; ihit < theDCTrack->GetNHits(); ihit++) { + THcDCHit* hit = theDCTrack->GetHit(ihit); + planes[ihit] = hit->GetPlaneNum() - 1; + if (fFixLR) { + if (fFixPropagationCorrection) { + coords[ihit] = hit->GetPos() + theDCTrack->GetHitLR(ihit) * theDCTrack->GetHitDist(ihit); + } else { + coords[ihit] = hit->GetPos() + theDCTrack->GetHitLR(ihit) * hit->GetDist(); + } + + } else { + if (fFixPropagationCorrection) { + coords[ihit] = hit->GetPos() + hit->GetLR() * theDCTrack->GetHitDist(ihit); + } else { + coords[ihit] = hit->GetCoord(); + } + } + + } // end loop over hits + + theDCTrack->SetNFree(theDCTrack->GetNHits() - NUM_FPRAY); + Double_t chi2 = dummychi2; + if (theDCTrack->GetNFree() > 0) { + TVectorD TT(NUM_FPRAY); + TMatrixD AA(NUM_FPRAY, NUM_FPRAY); + for (Int_t irayp = 0; irayp < NUM_FPRAY; irayp++) { + TT[irayp] = 0.0; + for (Int_t ihit = 0; ihit < theDCTrack->GetNHits(); ihit++) { + + THcDCHit* hit = theDCTrack->GetHit(ihit); + + TT[irayp] += (coords[ihit] * fPlaneCoeffs[planes[ihit]][raycoeffmap[irayp]]) / + pow(hit->GetWireSigma(), 2); + // if (hit->GetPlaneNum()==5) + // { + // // cout << "Plane: " << hit->GetPlaneNum() << endl; + // //cout << "Wire: " <<hit->GetWireNum() << endl; + // //cout << "Sigma: " << hit->GetWireSigma() << endl; + // } + + } // end hit loop + } + for (Int_t irayp = 0; irayp < NUM_FPRAY; irayp++) { + for (Int_t jrayp = 0; jrayp < NUM_FPRAY; jrayp++) { + AA[irayp][jrayp] = 0.0; + if (jrayp < irayp) { // Symmetric + AA[irayp][jrayp] = AA[jrayp][irayp]; + } else { + for (Int_t ihit = 0; ihit < theDCTrack->GetNHits(); ihit++) { + + THcDCHit* hit = theDCTrack->GetHit(ihit); + + AA[irayp][jrayp] += fPlaneCoeffs[planes[ihit]][raycoeffmap[irayp]] * + fPlaneCoeffs[planes[ihit]][raycoeffmap[jrayp]] / + pow(hit->GetWireSigma(), 2); + + } // end ihit loop + } + } + } + + // Solve 4x4 equations + TVectorD dray(NUM_FPRAY); + // Should check that it is invertable + AA.Invert(); + dray = AA * TT; + // cout << "DRAY: " << dray[0] << " "<< dray[1] << " "<< dray[2] << " "<< dray[3] << " " + // << endl; if(bad_determinant) { + // dray[0] = dray[1] = 10000.; dray[2] = dray[3] = 2.0; + // } + // Calculate hit coordinate for each plane for chi2 and efficiency + // calculations + + // Make sure fCoords, fResiduals, and fDoubleResiduals are clear + for (Int_t iplane = 0; iplane < fNPlanes; iplane++) { + Double_t coord = 0.0; + for (Int_t ir = 0; ir < NUM_FPRAY; ir++) { + coord += fPlaneCoeffs[iplane][raycoeffmap[ir]] * dray[ir]; + // cout << "ir = " << ir << ", dray[ir] = " << dray[ir] << endl; + } + theDCTrack->SetCoord(iplane, coord); + } + // Compute Chi2 and residuals + chi2 = 0.0; + for (Int_t ihit = 0; ihit < theDCTrack->GetNHits(); ihit++) { + + THcDCHit* hit = theDCTrack->GetHit(ihit); + + Double_t residual = coords[ihit] - theDCTrack->GetCoord(planes[ihit]); + theDCTrack->SetResidual(planes[ihit], residual); + + // double track_coord = theDCTrack->GetCoord(planes[ihit]); + // cout<<planes[ihit]<<"\t"<<track_coord<<"\t"<<coords[ihit]<<"\t"<<residual<<endl; + chi2 += pow(residual / hit->GetWireSigma(), 2); + } + + theDCTrack->SetVector(dray[0], dray[1], 0.0, dray[2], dray[3]); + } + theDCTrack->SetChisq(chi2); + + // calculate ray without a plane in track + for (Int_t ipl_hit = 0; ipl_hit < theDCTrack->GetNHits(); ipl_hit++) { + + if (theDCTrack->GetNFree() > 0) { + TVectorD TT(NUM_FPRAY); + TMatrixD AA(NUM_FPRAY, NUM_FPRAY); + for (Int_t irayp = 0; irayp < NUM_FPRAY; irayp++) { + TT[irayp] = 0.0; + for (Int_t ihit = 0; ihit < theDCTrack->GetNHits(); ihit++) { + + THcDCHit* hit = theDCTrack->GetHit(ihit); + + if (ihit != ipl_hit) { + TT[irayp] += (coords[ihit] * fPlaneCoeffs[planes[ihit]][raycoeffmap[irayp]]) / + pow(hit->GetWireSigma(), 2); + } + } + } + for (Int_t irayp = 0; irayp < NUM_FPRAY; irayp++) { + for (Int_t jrayp = 0; jrayp < NUM_FPRAY; jrayp++) { + AA[irayp][jrayp] = 0.0; + if (jrayp < irayp) { // Symmetric + AA[irayp][jrayp] = AA[jrayp][irayp]; + } else { + + for (Int_t ihit = 0; ihit < theDCTrack->GetNHits(); ihit++) { + + THcDCHit* hit = theDCTrack->GetHit(ihit); + + if (ihit != ipl_hit) { + AA[irayp][jrayp] += fPlaneCoeffs[planes[ihit]][raycoeffmap[irayp]] * + fPlaneCoeffs[planes[ihit]][raycoeffmap[jrayp]] / + pow(hit->GetWireSigma(), 2); + } + } + } + } + } + // + // Solve 4x4 equations + // Should check that it is invertable + TVectorD dray(NUM_FPRAY); + AA.Invert(); + dray = AA * TT; + Double_t coord = 0.0; + for (Int_t ir = 0; ir < NUM_FPRAY; ir++) { + coord += fPlaneCoeffs[planes[ipl_hit]][raycoeffmap[ir]] * dray[ir]; + // cout << "ir = " << ir << ", dray[ir] = " << dray[ir] << endl; + } + Double_t residual = coords[ipl_hit] - coord; + theDCTrack->SetResidualExclPlane(planes[ipl_hit], residual); + } + } + } + // Calculate residual without plane + + // Calculate residuals for each chamber if in single stub mode + // and there was a track found in each chamber + // Specific for two chambers. Can/should it be generalized? + + if (fSingleStub != 0) { + if (fNDCTracks == 2) { + THcDCTrack* theDCTrack1 = static_cast<THcDCTrack*>(fDCTracks->At(0)); + THcDCTrack* theDCTrack2 = static_cast<THcDCTrack*>(fDCTracks->At(1)); + // Int_t itrack=0; + Int_t ihit = 0; + THcDCHit* hit = theDCTrack1->GetHit(ihit); + Int_t plane = hit->GetPlaneNum() - 1; + Int_t chamber = fNChamber[plane]; + if (chamber == 1) { + // itrack=1; + hit = theDCTrack2->GetHit(ihit); + plane = hit->GetPlaneNum() - 1; + chamber = fNChamber[plane]; + if (chamber == 2) { + Double_t ray1[4]; + Double_t ray2[4]; + theDCTrack1->GetRay(ray1); + theDCTrack2->GetRay(ray2); + // itrack = 1; + // Loop over hits in second chamber + for (Int_t ihit = 0; ihit < theDCTrack2->GetNHits(); ihit++) { + // Calculate residual in second chamber from first chamber track + THcDCHit* hit = theDCTrack2->GetHit(ihit); + Int_t plane = hit->GetPlaneNum() - 1; + Double_t pos = DpsiFun(ray1, plane); + Double_t coord; + if (fFixLR) { + if (fFixPropagationCorrection) { + coord = hit->GetPos() + theDCTrack2->GetHitLR(ihit) * theDCTrack2->GetHitDist(ihit); + } else { + coord = hit->GetPos() + theDCTrack2->GetHitLR(ihit) * hit->GetDist(); + } + } else { + if (fFixPropagationCorrection) { + coord = hit->GetPos() + hit->GetLR() * theDCTrack2->GetHitDist(ihit); + } else { + coord = hit->GetCoord(); + } + } + theDCTrack1->SetDoubleResidual(plane, coord - pos); + // hdc_dbl_res(pln) = hdc_double_residual(1,pln) for hists + } + // itrack=0; + // Loop over hits in first chamber + for (Int_t ihit = 0; ihit < theDCTrack1->GetNHits(); ihit++) { + // Calculate residual in first chamber from second chamber track + THcDCHit* hit = theDCTrack1->GetHit(ihit); + Int_t plane = hit->GetPlaneNum() - 1; + Double_t pos = DpsiFun(ray1, plane); + Double_t coord; + if (fFixLR) { + if (fFixPropagationCorrection) { + coord = hit->GetPos() + theDCTrack1->GetHitLR(ihit) * theDCTrack1->GetHitDist(ihit); + } else { + coord = hit->GetPos() + theDCTrack1->GetHitLR(ihit) * hit->GetDist(); + } + } else { + if (fFixPropagationCorrection) { + coord = hit->GetPos() + hit->GetLR() * theDCTrack1->GetHitDist(ihit); + } else { + coord = hit->GetCoord(); + } + } + theDCTrack2->SetDoubleResidual(plane, coord - pos); + // hdc_dbl_res(pln) = hdc_double_residual(1,pln) for hists + } + } + } + } + } + // + if (fdebugtrackprint) { + printf("%5s %-14s %-14s %-14s %-14s %-10s %-10s \n", "Track", "x_t", "y_t", "xp_t", "yp_t", + "chi2", "DOF"); + printf("%5s %-14s %-14s %-14s %-14s %-10s %-10s \n", " ", "[cm]", "[cm]", "[rad]", "[rad]", + " ", " "); + for (UInt_t itr = 0; itr < fNDCTracks; itr++) { + THcDCTrack* theDCTrack = static_cast<THcDCTrack*>(fDCTracks->At(itr)); + printf("%-5d %14.6e %14.6e %14.6e %14.6e %10.3e %3d \n", itr + 1, theDCTrack->GetX(), + theDCTrack->GetY(), theDCTrack->GetXP(), theDCTrack->GetYP(), theDCTrack->GetChisq(), + theDCTrack->GetNFree()); + } + for (UInt_t itr = 0; itr < fNDCTracks; itr++) { + printf("%s %5d \n", "Hit info for track number = ", itr + 1); + printf("%5s %-15s %-15s %-15s \n", "Plane", "WIRE_COORD", "Fit postiion", "Residual"); + THcDCTrack* theDCTrack = static_cast<THcDCTrack*>(fDCTracks->At(itr)); + for (Int_t ihit = 0; ihit < theDCTrack->GetNHits(); ihit++) { + THcDCHit* hit = theDCTrack->GetHit(ihit); + Int_t plane = hit->GetPlaneNum() - 1; + Double_t coords_temp; + if (fFixLR) { + if (fFixPropagationCorrection) { + coords_temp = hit->GetPos() + theDCTrack->GetHitLR(ihit) * theDCTrack->GetHitDist(ihit); + } else { + coords_temp = hit->GetPos() + theDCTrack->GetHitLR(ihit) * hit->GetDist(); + } + } else { + if (fFixPropagationCorrection) { + coords_temp = hit->GetPos() + hit->GetLR() * theDCTrack->GetHitDist(ihit); + } else { + coords_temp = hit->GetCoord(); + } + } + printf("%-5d %15.7e %15.7e %15.7e \n", plane + 1, coords_temp, theDCTrack->GetCoord(plane), + theDCTrack->GetResidual(plane)); + } + } + } + + // +} +// +// +Double_t THcDC::DpsiFun(Double_t ray[4], Int_t plane) { + /** + this function calculates the psi coordinate of the intersection + of a ray (defined by ray) with a hms wire chamber plane. the geometry + of the plane is contained in the coeff array calculated in the + array hplane_coeff + Note it is call by MINUIT via H_FCNCHISQ and so uses double precision + variables + + the ray is defined by + x = (z-zt)*tan(xp) + xt + y = (z-zt)*tan(yp) + yt + at some fixed value of zt* + ray(1) = xt + ray(2) = yt + ray(3) = tan(xp) + ray(4) = tan(yp) + */ + + Double_t infinity = 1.0E+20; + Double_t cinfinity = 1 / infinity; + Double_t DpsiFun = ray[2] * ray[1] * fPlaneCoeffs[plane][0] + + ray[3] * ray[0] * fPlaneCoeffs[plane][1] + ray[2] * fPlaneCoeffs[plane][2] + + ray[3] * fPlaneCoeffs[plane][3] + ray[0] * fPlaneCoeffs[plane][4] + + ray[1] * fPlaneCoeffs[plane][5]; + Double_t denom = + ray[2] * fPlaneCoeffs[plane][6] + ray[3] * fPlaneCoeffs[plane][7] + fPlaneCoeffs[plane][8]; + if (TMath::Abs(denom) < cinfinity) { + DpsiFun = infinity; + } else { + DpsiFun = DpsiFun / denom; + } + return (DpsiFun); +} + +//_____________________________________________________________________________ +Int_t THcDC::End(THaRunBase* run) { + // EffCalc(); + MissReport(Form("%s.%s", GetApparatus()->GetName(), GetName())); + return 0; +} + +//_____________________________________________________________________________ +void THcDC::EffInit() { + /** + Create, and initialize counters used to calculate + efficiencies. Register the counters in gHcParms so that the + variables can be used in end of run reports. + */ + + delete[] fNChamHits; + fNChamHits = new Int_t[fNChambers]; + delete[] fPlaneEvents; + fPlaneEvents = new Int_t[fNPlanes]; + + fTotEvents = 0; + for (UInt_t i = 0; i < fNChambers; i++) { + fNChamHits[i] = 0; + } + for (Int_t i = 0; i < fNPlanes; i++) { + fPlaneEvents[i] = 0; + } + gHcParms->Define(Form("%sdc_tot_events", fPrefix), "Total DC Events", fTotEvents); + gHcParms->Define(Form("%sdc_cham_hits[%d]", fPrefix, fNChambers), + "N events with hits per chamber", *fNChamHits); + gHcParms->Define(Form("%sdc_events[%d]", fPrefix, fNPlanes), "N events with hits per plane", + *fPlaneEvents); +} + +//_____________________________________________________________________________ +void THcDC::Eff() { + /** + Accumulate statistics for efficiency calculations + */ + + fTotEvents++; + for (UInt_t i = 0; i < fNChambers; i++) { + if (fChambers[i]->GetNHits() > 0) + fNChamHits[i]++; + } + for (Int_t i = 0; i < fNPlanes; i++) { + if (fPlanes[i]->GetNHits() > 0) + fPlaneEvents[i]++; + } + return; +} + +ClassImp(THcDC) + //////////////////////////////////////////////////////////////////////////////// diff --git a/src/src/THcDCHit.cxx b/src/hallc/src/THcDCHit.cxx similarity index 100% rename from src/src/THcDCHit.cxx rename to src/hallc/src/THcDCHit.cxx diff --git a/src/src/THcDCLookupTTDConv.cxx b/src/hallc/src/THcDCLookupTTDConv.cxx similarity index 100% rename from src/src/THcDCLookupTTDConv.cxx rename to src/hallc/src/THcDCLookupTTDConv.cxx diff --git a/src/src/THcDCTimeToDistConv.cxx b/src/hallc/src/THcDCTimeToDistConv.cxx similarity index 100% rename from src/src/THcDCTimeToDistConv.cxx rename to src/hallc/src/THcDCTimeToDistConv.cxx diff --git a/src/src/THcDCTrack.cxx b/src/hallc/src/THcDCTrack.cxx similarity index 100% rename from src/src/THcDCTrack.cxx rename to src/hallc/src/THcDCTrack.cxx diff --git a/src/src/THcDCWire.cxx b/src/hallc/src/THcDCWire.cxx similarity index 100% rename from src/src/THcDCWire.cxx rename to src/hallc/src/THcDCWire.cxx diff --git a/src/src/THcDetectorMap.cxx b/src/hallc/src/THcDetectorMap.cxx similarity index 100% rename from src/src/THcDetectorMap.cxx rename to src/hallc/src/THcDetectorMap.cxx diff --git a/src/src/THcDriftChamber.cxx b/src/hallc/src/THcDriftChamber.cxx similarity index 100% rename from src/src/THcDriftChamber.cxx rename to src/hallc/src/THcDriftChamber.cxx diff --git a/src/src/THcDriftChamberPlane.cxx b/src/hallc/src/THcDriftChamberPlane.cxx similarity index 100% rename from src/src/THcDriftChamberPlane.cxx rename to src/hallc/src/THcDriftChamberPlane.cxx diff --git a/src/src/THcDummySpectrometer.cxx b/src/hallc/src/THcDummySpectrometer.cxx similarity index 100% rename from src/src/THcDummySpectrometer.cxx rename to src/hallc/src/THcDummySpectrometer.cxx diff --git a/src/src/THcExtTarCor.cxx b/src/hallc/src/THcExtTarCor.cxx similarity index 100% rename from src/src/THcExtTarCor.cxx rename to src/hallc/src/THcExtTarCor.cxx diff --git a/src/src/THcFormula.cxx b/src/hallc/src/THcFormula.cxx similarity index 100% rename from src/src/THcFormula.cxx rename to src/hallc/src/THcFormula.cxx diff --git a/src/src/THcHallCSpectrometer.cxx b/src/hallc/src/THcHallCSpectrometer.cxx similarity index 100% rename from src/src/THcHallCSpectrometer.cxx rename to src/hallc/src/THcHallCSpectrometer.cxx diff --git a/src/src/THcHelicity.cxx b/src/hallc/src/THcHelicity.cxx similarity index 100% rename from src/src/THcHelicity.cxx rename to src/hallc/src/THcHelicity.cxx diff --git a/src/src/THcHelicityReader.cxx b/src/hallc/src/THcHelicityReader.cxx similarity index 100% rename from src/src/THcHelicityReader.cxx rename to src/hallc/src/THcHelicityReader.cxx diff --git a/src/src/THcHelicityScaler.cxx b/src/hallc/src/THcHelicityScaler.cxx similarity index 100% rename from src/src/THcHelicityScaler.cxx rename to src/hallc/src/THcHelicityScaler.cxx diff --git a/src/src/THcHitList.cxx b/src/hallc/src/THcHitList.cxx similarity index 100% rename from src/src/THcHitList.cxx rename to src/hallc/src/THcHitList.cxx diff --git a/src/src/THcHodoEff.cxx b/src/hallc/src/THcHodoEff.cxx similarity index 100% rename from src/src/THcHodoEff.cxx rename to src/hallc/src/THcHodoEff.cxx diff --git a/src/src/THcHodoHit.cxx b/src/hallc/src/THcHodoHit.cxx similarity index 100% rename from src/src/THcHodoHit.cxx rename to src/hallc/src/THcHodoHit.cxx diff --git a/src/src/THcHodoscope.cxx b/src/hallc/src/THcHodoscope.cxx similarity index 100% rename from src/src/THcHodoscope.cxx rename to src/hallc/src/THcHodoscope.cxx diff --git a/src/src/THcInterface.cxx b/src/hallc/src/THcInterface.cxx similarity index 100% rename from src/src/THcInterface.cxx rename to src/hallc/src/THcInterface.cxx diff --git a/src/src/THcParmList.cxx b/src/hallc/src/THcParmList.cxx similarity index 100% rename from src/src/THcParmList.cxx rename to src/hallc/src/THcParmList.cxx diff --git a/src/src/THcPeriodicReport.cxx b/src/hallc/src/THcPeriodicReport.cxx similarity index 100% rename from src/src/THcPeriodicReport.cxx rename to src/hallc/src/THcPeriodicReport.cxx diff --git a/src/src/THcPrimaryKine.cxx b/src/hallc/src/THcPrimaryKine.cxx similarity index 100% rename from src/src/THcPrimaryKine.cxx rename to src/hallc/src/THcPrimaryKine.cxx diff --git a/src/src/THcRaster.cxx b/src/hallc/src/THcRaster.cxx similarity index 100% rename from src/src/THcRaster.cxx rename to src/hallc/src/THcRaster.cxx diff --git a/src/src/THcRasterRawHit.cxx b/src/hallc/src/THcRasterRawHit.cxx similarity index 100% rename from src/src/THcRasterRawHit.cxx rename to src/hallc/src/THcRasterRawHit.cxx diff --git a/src/src/THcRasteredBeam.cxx b/src/hallc/src/THcRasteredBeam.cxx similarity index 100% rename from src/src/THcRasteredBeam.cxx rename to src/hallc/src/THcRasteredBeam.cxx diff --git a/src/src/THcRawAdcHit.cxx b/src/hallc/src/THcRawAdcHit.cxx similarity index 100% rename from src/src/THcRawAdcHit.cxx rename to src/hallc/src/THcRawAdcHit.cxx diff --git a/src/src/THcRawDCHit.cxx b/src/hallc/src/THcRawDCHit.cxx similarity index 100% rename from src/src/THcRawDCHit.cxx rename to src/hallc/src/THcRawDCHit.cxx diff --git a/src/src/THcRawHit.cxx b/src/hallc/src/THcRawHit.cxx similarity index 100% rename from src/src/THcRawHit.cxx rename to src/hallc/src/THcRawHit.cxx diff --git a/src/src/THcRawHodoHit.cxx b/src/hallc/src/THcRawHodoHit.cxx similarity index 100% rename from src/src/THcRawHodoHit.cxx rename to src/hallc/src/THcRawHodoHit.cxx diff --git a/src/src/THcRawShowerHit.cxx b/src/hallc/src/THcRawShowerHit.cxx similarity index 100% rename from src/src/THcRawShowerHit.cxx rename to src/hallc/src/THcRawShowerHit.cxx diff --git a/src/src/THcRawTdcHit.cxx b/src/hallc/src/THcRawTdcHit.cxx similarity index 100% rename from src/src/THcRawTdcHit.cxx rename to src/hallc/src/THcRawTdcHit.cxx diff --git a/src/src/THcReactionPoint.cxx b/src/hallc/src/THcReactionPoint.cxx similarity index 100% rename from src/src/THcReactionPoint.cxx rename to src/hallc/src/THcReactionPoint.cxx diff --git a/src/src/THcRun.cxx b/src/hallc/src/THcRun.cxx similarity index 100% rename from src/src/THcRun.cxx rename to src/hallc/src/THcRun.cxx diff --git a/src/src/THcRunParameters.cxx b/src/hallc/src/THcRunParameters.cxx similarity index 100% rename from src/src/THcRunParameters.cxx rename to src/hallc/src/THcRunParameters.cxx diff --git a/src/src/THcScalerEvtHandler.cxx b/src/hallc/src/THcScalerEvtHandler.cxx similarity index 100% rename from src/src/THcScalerEvtHandler.cxx rename to src/hallc/src/THcScalerEvtHandler.cxx diff --git a/src/src/THcScintPlaneCluster.cxx b/src/hallc/src/THcScintPlaneCluster.cxx similarity index 100% rename from src/src/THcScintPlaneCluster.cxx rename to src/hallc/src/THcScintPlaneCluster.cxx diff --git a/src/src/THcScintillatorPlane.cxx b/src/hallc/src/THcScintillatorPlane.cxx similarity index 100% rename from src/src/THcScintillatorPlane.cxx rename to src/hallc/src/THcScintillatorPlane.cxx diff --git a/src/src/THcSecondaryKine.cxx b/src/hallc/src/THcSecondaryKine.cxx similarity index 100% rename from src/src/THcSecondaryKine.cxx rename to src/hallc/src/THcSecondaryKine.cxx diff --git a/src/src/THcShower.cxx b/src/hallc/src/THcShower.cxx similarity index 100% rename from src/src/THcShower.cxx rename to src/hallc/src/THcShower.cxx diff --git a/src/src/THcShowerArray.cxx b/src/hallc/src/THcShowerArray.cxx similarity index 100% rename from src/src/THcShowerArray.cxx rename to src/hallc/src/THcShowerArray.cxx diff --git a/src/src/THcShowerHit.cxx b/src/hallc/src/THcShowerHit.cxx similarity index 100% rename from src/src/THcShowerHit.cxx rename to src/hallc/src/THcShowerHit.cxx diff --git a/src/src/THcShowerPlane.cxx b/src/hallc/src/THcShowerPlane.cxx similarity index 100% rename from src/src/THcShowerPlane.cxx rename to src/hallc/src/THcShowerPlane.cxx diff --git a/src/src/THcSignalHit.cxx b/src/hallc/src/THcSignalHit.cxx similarity index 100% rename from src/src/THcSignalHit.cxx rename to src/hallc/src/THcSignalHit.cxx diff --git a/src/src/THcSpacePoint.cxx b/src/hallc/src/THcSpacePoint.cxx similarity index 100% rename from src/src/THcSpacePoint.cxx rename to src/hallc/src/THcSpacePoint.cxx diff --git a/src/src/THcTimeSyncEvtHandler.cxx b/src/hallc/src/THcTimeSyncEvtHandler.cxx similarity index 100% rename from src/src/THcTimeSyncEvtHandler.cxx rename to src/hallc/src/THcTimeSyncEvtHandler.cxx diff --git a/src/src/THcTrigApp.cxx b/src/hallc/src/THcTrigApp.cxx similarity index 100% rename from src/src/THcTrigApp.cxx rename to src/hallc/src/THcTrigApp.cxx diff --git a/src/src/THcTrigDet.cxx b/src/hallc/src/THcTrigDet.cxx similarity index 100% rename from src/src/THcTrigDet.cxx rename to src/hallc/src/THcTrigDet.cxx diff --git a/src/src/THcTrigRawHit.cxx b/src/hallc/src/THcTrigRawHit.cxx similarity index 100% rename from src/src/THcTrigRawHit.cxx rename to src/hallc/src/THcTrigRawHit.cxx diff --git a/src/src/TIBlobModule.cxx b/src/hallc/src/TIBlobModule.cxx similarity index 100% rename from src/src/TIBlobModule.cxx rename to src/hallc/src/TIBlobModule.cxx diff --git a/src/hallc/src/TrackingEfficiency.cpppp b/src/hallc/src/TrackingEfficiency.cpppp new file mode 100644 index 0000000..53b055a --- /dev/null +++ b/src/hallc/src/TrackingEfficiency.cpppp @@ -0,0 +1,451 @@ +#include "THaEvData.h" +#include "THaCutList.h" +#include "VarDef.h" +#include "VarType.h" +#include "TClonesArray.h" + +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <iostream> + +#include "THaApparatus.h" +#include "THcGlobals.h" +#include "THcHodoHit.h" +#include "THcParmList.h" +#include "TrackingEfficiency.h" + +namespace hcana { + + using namespace std; + + TrackingEfficiency::TrackingEfficiency(const char* name, const char* description, + const char* hodname) + : THaPhysicsModule(name, description) {} + + TrackingEfficiency::~TrackingEfficiency() { + // Destructor + RemoveVariables(); + } + //_____________________________________________________________________________ + + void TrackingEfficiency::Reset(Option_t* opt) + // Clear event-by-event data + { + Clear(opt); + } + + //_____________________________________________________________________________ + Int_t TrackingEfficiency::Begin(THaRunBase*) { + // Start of analysis + + //if (!IsOK()) + // return -1; + + //// Book any special histograms here + + //fNevt = 0; + + //// Clear all the accumulators here + //for (Int_t ip = 0; ip < fNPlanes; ip++) { + // fHitPlane[ip] = 0; + // for (Int_t ic = 0; ic < fNCounters[ip]; ic++) { + // fStatPosHit[ip][ic] = 0; + // fStatNegHit[ip][ic] = 0; + // fStatAndHit[ip][ic] = 0; + // fStatOrHit[ip][ic] = 0; + // fBothGood[ip][ic] = 0; + // fPosGood[ip][ic] = 0; + // fNegGood[ip][ic] = 0; + // for (Int_t idel = 0; idel < 20; idel++) { + // fStatTrkDel[ip][ic][idel] = 0; + // fStatAndHitDel[ip][ic][idel] = 0; + // } + // } + //} + + return 0; + } + + //_____________________________________________________________________________ + Int_t TrackingEfficiency::End(THaRunBase*) { + //// End of analysis + //for (Int_t ip = 0; ip < fNPlanes; ip++) { + // fStatAndEff[ip] = 0; + // for (Int_t ic = 0; ic < fNCounters[ip]; ic++) { + // fStatTrkSum[ip] += fStatTrk[fHod->GetScinIndex(ip, ic)]; + // fStatAndSum[ip] += fHodoAndEffi[fHod->GetScinIndex(ip, ic)]; + // } + // if (fStatTrkSum[ip] != 0) + // fStatAndEff[ip] = float(fStatAndSum[ip]) / float(fStatTrkSum[ip]); + //} + //// + //Double_t p1 = fStatAndEff[0]; + //Double_t p2 = fStatAndEff[1]; + //Double_t p3 = fStatAndEff[2]; + //Double_t p4 = fStatAndEff[3]; + //// probability that ONLY the listed planes had triggers + //Double_t p1234 = p1 * p2 * p3 * p4; + //Double_t p123 = p1 * p2 * p3 * (1. - p4); + //Double_t p124 = p1 * p2 * (1. - p3) * p4; + //Double_t p134 = p1 * (1. - p2) * p3 * p4; + //Double_t p234 = (1. - p1) * p2 * p3 * p4; + //fHodoEff_s1 = 1. - ((1. - p1) * (1. - p2)); + //fHodoEff_s2 = 1. - ((1. - p3) * (1. - p4)); + //fHodoEff_tof = fHodoEff_s1 * fHodoEff_s2; + //fHodoEff_3_of_4 = p1234 + p123 + p124 + p134 + p234; + //fHodoEff_4_of_4 = p1234; + return 0; + } + + //_____________________________________________________________________________ + THaAnalysisObject::EStatus TrackingEfficiency::Init(const TDatime& run_time) { + // Initialize TrackingEfficiency physics module + + // const char* const here = "Init"; + + // Standard initialization. Calls ReadDatabase(), ReadRunDatabase(), + // and DefineVariables() (see THaAnalysisObject::Init) + + //fHod = dynamic_cast<THcHodoscope*>(FindModule(fName.Data(), "THcHodoscope")); + + //fSpectro = static_cast<THaSpectrometer*>(fHod->GetApparatus()); + + //if (THaPhysicsModule::Init(run_time) != kOK) + // return fStatus; + + //cout << "TrackingEfficiency::Init nplanes=" << fHod->GetNPlanes() << endl; + //cout << "TrackingEfficiency::Init Apparatus = " << fHod->GetName() << " " + // << (fHod->GetApparatus())->GetName() << endl; + + return fStatus = kOK; + } + + //_____________________________________________________________________________ + Int_t TrackingEfficiency::ReadDatabase(const TDatime& date) { + //// Read database. Gets variable needed for efficiency calculation + //// Get # of planes and their z positions here. + + //fNPlanes = fHod->GetNPlanes(); + //fPlanes = new THcScintillatorPlane*[fNPlanes]; + //fPosZ = new Double_t[fNPlanes]; + //fSpacing = new Double_t[fNPlanes]; + //fCenterFirst = new Double_t[fNPlanes]; + //fNCounters = new Int_t[fNPlanes]; + //fHodoSlop = new Double_t[fNPlanes]; + //fStatTrkSum = new Int_t[fNPlanes]; + //fStatAndSum = new Int_t[fNPlanes]; + //fStatAndEff = new Double_t[fNPlanes]; + + //Int_t maxcountersperplane = 0; + //for (Int_t ip = 0; ip < fNPlanes; ip++) { + // fStatTrkSum[ip] = 0.; + // fStatAndSum[ip] = 0.; + // fStatAndEff[ip] = 0.; + // fPlanes[ip] = fHod->GetPlane(ip); + // fPosZ[ip] = fPlanes[ip]->GetZpos() + 0.5 * fPlanes[ip]->GetDzpos(); + // fSpacing[ip] = fPlanes[ip]->GetSpacing(); + // fCenterFirst[ip] = fPlanes[ip]->GetPosCenter(0) + fPlanes[ip]->GetPosOffset(); + // fNCounters[ip] = fPlanes[ip]->GetNelem(); + // maxcountersperplane = TMath::Max(maxcountersperplane, fNCounters[ip]); + //} + //Int_t totalpaddles = fNPlanes * maxcountersperplane; + //fHodoPosEffi = new Int_t[totalpaddles]; + //fHodoNegEffi = new Int_t[totalpaddles]; + //fHodoOrEffi = new Int_t[totalpaddles]; + //fHodoAndEffi = new Int_t[totalpaddles]; + //fStatTrk = new Int_t[totalpaddles]; + + //char prefix[2]; + //prefix[0] = tolower((fHod->GetApparatus())->GetName()[0]); + //prefix[1] = '\0'; + + //DBRequest list[] = {{"stat_slop", &fStatSlop, kDouble}, + // {"stat_maxchisq", &fMaxChisq, kDouble}, + // {"HodoEff_CalEnergy_Cut", &fHodoEff_CalEnergy_Cut, kDouble, 0, 1}, + // {"hodo_slop", fHodoSlop, kDouble, (UInt_t)fNPlanes}, + // {0}}; + //fHodoEff_CalEnergy_Cut = 0.050; // set default value + //gHcParms->LoadParmValues((DBRequest*)&list, prefix); + //cout << "\n\nTrackingEfficiency::ReadDatabase nplanes=" << fHod->GetNPlanes() << endl; + //// Setup statistics arrays + //// Better method to put this in? + //// These all need to be cleared in Begin + //fHitPlane = new Int_t[fNPlanes]; + //fStatTrkDel.resize(fNPlanes); + //fStatAndHitDel.resize(fNPlanes); + //fStatPosHit.resize(fNPlanes); + //fStatNegHit.resize(fNPlanes); + //fStatAndHit.resize(fNPlanes); + //fStatOrHit.resize(fNPlanes); + //fBothGood.resize(fNPlanes); + //fPosGood.resize(fNPlanes); + //fNegGood.resize(fNPlanes); + + //for (Int_t ip = 0; ip < fNPlanes; ip++) { + + // cout << "Plane = " << ip + 1 << " counters = " << fNCounters[ip] << endl; + + // fStatTrkDel[ip].resize(fNCounters[ip]); + // fStatAndHitDel[ip].resize(fNCounters[ip]); + // fStatPosHit[ip].resize(fNCounters[ip]); + // fStatNegHit[ip].resize(fNCounters[ip]); + // fStatAndHit[ip].resize(fNCounters[ip]); + // fStatOrHit[ip].resize(fNCounters[ip]); + // fBothGood[ip].resize(fNCounters[ip]); + // fPosGood[ip].resize(fNCounters[ip]); + // fNegGood[ip].resize(fNCounters[ip]); + // for (Int_t ic = 0; ic < fNCounters[ip]; ic++) { + // fStatTrkDel[ip][ic].resize(20); // Max this settable + // fStatAndHitDel[ip][ic].resize(20); // Max this settable + + // fHodoPosEffi[fHod->GetScinIndex(ip, ic)] = 0; + // fHodoNegEffi[fHod->GetScinIndex(ip, ic)] = 0; + // fHodoOrEffi[fHod->GetScinIndex(ip, ic)] = 0; + // fHodoAndEffi[fHod->GetScinIndex(ip, ic)] = 0; + // fStatTrk[fHod->GetScinIndex(ip, ic)] = 0; + // } + //} + + //// Int_t fHodPaddles = fNCounters[0]; + //// gHcParms->Define(Form("%shodo_pos_hits[%d][%d]",fPrefix,fNPlanes,fHodPaddles), + //// "Golden track's pos pmt hit",*&fStatPosHit); + + //gHcParms->Define(Form("%shodo_pos_eff[%d]", prefix, totalpaddles), "Hodo positive effi", + // *fHodoPosEffi); + //gHcParms->Define(Form("%shodo_neg_eff[%d]", prefix, totalpaddles), "Hodo negative effi", + // *fHodoNegEffi); + //gHcParms->Define(Form("%shodo_or_eff[%d]", prefix, totalpaddles), "Hodo or effi", *fHodoOrEffi); + //gHcParms->Define(Form("%shodo_and_eff[%d]", prefix, totalpaddles), "Hodo and effi", + // *fHodoAndEffi); + //gHcParms->Define(Form("%shodo_plane_AND_eff[%d]", prefix, fNPlanes), "Hodo plane AND eff", + // *fStatAndEff); + //gHcParms->Define(Form("%shodo_gold_hits[%d]", prefix, totalpaddles), "Hodo golden hits", + // *fStatTrk); + //gHcParms->Define(Form("%shodo_s1XY_eff", prefix), "Efficiency for S1XY", fHodoEff_s1); + //gHcParms->Define(Form("%shodo_s2XY_eff", prefix), "Efficiency for S2XY", fHodoEff_s2); + //gHcParms->Define(Form("%shodo_stof_eff", prefix), "Efficiency for STOF", fHodoEff_tof); + //gHcParms->Define(Form("%shodo_3_of_4_eff", prefix), "Efficiency for 3 of 4", fHodoEff_3_of_4); + //gHcParms->Define(Form("%shodo_4_of_4_eff", prefix), "Efficiency for 4 of 4", fHodoEff_4_of_4); + + return kOK; + } + + //_____________________________________________________________________________ + Int_t TrackingEfficiency::DefineVariables(EMode mode) { + + //if (mode == kDefine && fIsSetup) + // return kOK; + //fIsSetup = (mode == kDefine); + + //// fEffiTest = 0; + //// gHcParms->Define(Form("hodoeffi"),"Testing effi",fEffiTest); + + //const RVarDef vars[] = {// Move these into THcHallCSpectrometer using track fTracks + // // {"effitestvar", "efficiency test var", "fEffiTest"}, + // // {"goldhodposhit", "pos pmt hit in hodo", "fStatPosHit"}, + // {0}}; + //return DefineVarsFromList(vars, mode); + return kOK; + } + + //_____________________________________________________________________________ + Int_t TrackingEfficiency::Process(const THaEvData& evdata) { + // Accumulate statistics for efficiency + + // const char* const here = "Process"; + + if (!IsOK()) + return -1; + + //// Project the golden track to each + //// plane. Need to get track at Focal Plane, not tgt. + //// + //// Assumes that planes are X, Y, X, Y + //THaTrack* theTrack = fSpectro->GetGoldenTrack(); + //// Since fSpectro knows the index of the golden track, we can + //// get other information about the track from fSpectro. + //// Need to remove the specialized stuff from fGoldenTrack + + //if (!theTrack) + // return 0; + //Int_t trackIndex = theTrack->GetTrkNum() - 1; + + //// May make these member variables + //Double_t hitPos[fNPlanes]; + //Double_t hitDistance[fNPlanes]; + //Int_t hitCounter[fNPlanes]; + //Int_t checkHit[fNPlanes]; + //// Bool_t goodTdcBothSides[fNPlanes]; + //// Bool_t goodTdcOneSide[fNPlanes]; + + //for (Int_t ip = 0; ip < fNPlanes; ip++) { + // // Should really have plane object self identify as X or Y + // if (ip % 2 == 0) { // X Plane + // hitPos[ip] = theTrack->GetX() + theTrack->GetTheta() * fPosZ[ip]; + // hitCounter[ip] = + // TMath::Max(TMath::Min(TMath::Nint((hitPos[ip] - fCenterFirst[ip]) / fSpacing[ip] + 1), + // fNCounters[ip]), + // 1); + // hitDistance[ip] = hitPos[ip] - (fSpacing[ip] * (hitCounter[ip] - 1) + fCenterFirst[ip]); + // } else { // Y Plane + // hitPos[ip] = theTrack->GetY() + theTrack->GetPhi() * fPosZ[ip]; + // hitCounter[ip] = + // TMath::Max(TMath::Min(TMath::Nint((fCenterFirst[ip] - hitPos[ip]) / fSpacing[ip] + 1), + // fNCounters[ip]), + // 1); + // hitDistance[ip] = hitPos[ip] - (fCenterFirst[ip] - fSpacing[ip] * (hitCounter[ip] - 1)); + // } + //} + + //// Fill dpos histograms and set checkHit for each plane. + //// dpos stuff not implemented + //// Why do dpos stuff here, does any other part need the dpos historgrams + //// Look to VDCEff code to see how to create and fill histograms + + //for (Int_t ip = 0; ip < fNPlanes; ip++) { + // Int_t hitcounter = hitCounter[ip]; + // // goodTdcBothSides[ip] = kFALSE; + // // goodTdcOneSide[ip] = kFALSE; + // checkHit[ip] = 2; + // Int_t nphits = fPlanes[ip]->GetNScinHits(); + // TClonesArray* hodoHits = fPlanes[ip]->GetHits(); + // for (Int_t ihit = 0; ihit < nphits; ihit++) { + // THcHodoHit* hit = (THcHodoHit*)hodoHits->At(ihit); + // Int_t counter = hit->GetPaddleNumber(); + // if (counter == hitcounter) { + // checkHit[ip] = 0; + // } else { + // if (TMath::Abs(counter - hitcounter) == 1 && checkHit[ip] != 0) { + // checkHit[ip] = 1; + // } + // } + // } + //} + + //// Record position differences between track and center of scin + //// and increment 'should have hit' counters + //for (Int_t ip = 0; ip < fNPlanes; ip++) { + // // Int_t hitcounter = hitCounter[ip]; + // Double_t dist = hitDistance[ip]; + // if (TMath::Abs(dist) <= fStatSlop && theTrack->GetChi2() / theTrack->GetNDoF() <= fMaxChisq && + // theTrack->GetEnergy() >= fHodoEff_CalEnergy_Cut) { + // fStatTrk[fHod->GetScinIndex(ip, hitCounter[ip] - 1)]++; + // // Double_t delta = theTrack->GetDp(); + // // Int_t idel = TMath::Floor(delta+10.0); + // // Should + // // if(idel >=0 && idel < 20) { + // // fStatTrkDel[ip][hitcounter][idel]++; + // // } + // // lookat[ip] = TRUE; + // } + // fHitPlane[ip] = 0; + //} + //// Is there a hit on or adjacent to paddle that track + //// passes through? + + //// May collapse this loop into last + + //// record the hits as a "didhit" if track is near center of + //// scintillator, the chisqared of the track is good and it is the + //// first "didhit" in that plane. + + //for (Int_t ip = 0; ip < fNPlanes; ip++) { + // Int_t hitcounter = hitCounter[ip]; + // if (hitcounter >= fNCounters[ip]) + // hitcounter = fNCounters[ip] - 1; + // if (hitcounter < 0) + // hitcounter = 0; + // Double_t dist = hitDistance[ip]; + // Int_t nphits = fPlanes[ip]->GetNScinHits(); + // TClonesArray* hodoHits = fPlanes[ip]->GetHits(); + // for (Int_t ihit = 0; ihit < nphits; ihit++) { + // THcHodoHit* hit = (THcHodoHit*)hodoHits->At(ihit); + // Int_t counter = hit->GetPaddleNumber(); + // // Finds first best hit + // Bool_t onTrack, goodScinTime, goodTdcNeg, goodTdcPos; + // fHod->GetFlags(trackIndex, ip, ihit, onTrack, goodScinTime, goodTdcNeg, goodTdcPos); + // if (TMath::Abs(dist) <= fStatSlop && TMath::Abs(hitcounter - counter) <= checkHit[ip] && + // fHitPlane[ip] == 0 && theTrack->GetChi2() / theTrack->GetNDoF() <= fMaxChisq && + // theTrack->GetEnergy() >= fHodoEff_CalEnergy_Cut) { + // fHitPlane[ip]++; + + // // Need to find out hgood_tdc_pos(igoldentrack,ihit) and neg + // if (goodTdcPos) { + // if (goodTdcNeg) { // Both fired + // fStatPosHit[ip][hitcounter]++; + // fStatNegHit[ip][hitcounter]++; + // fStatAndHit[ip][hitcounter]++; + // fStatOrHit[ip][hitcounter]++; + + // fHodoPosEffi[fHod->GetScinIndex(ip, hitCounter[ip] - 1)]++; + // fHodoNegEffi[fHod->GetScinIndex(ip, hitCounter[ip] - 1)]++; + // fHodoAndEffi[fHod->GetScinIndex(ip, hitCounter[ip] - 1)]++; + // fHodoOrEffi[fHod->GetScinIndex(ip, hitCounter[ip] - 1)]++; + + // // Double_t delta = theTrack->GetDp(); + // // Int_t idel = TMath::Floor(delta+10.0); + // // if(idel >=0 && idel < 20) { + // // fStatAndHitDel[ip][hitcounter][idel]++; + // // } + // } else { + // fStatPosHit[ip][hitcounter]++; + // fStatOrHit[ip][hitcounter]++; + // fHodoPosEffi[fHod->GetScinIndex(ip, hitCounter[ip] - 1)]++; + // fHodoOrEffi[fHod->GetScinIndex(ip, hitCounter[ip] - 1)]++; + // } + // } else if (goodTdcNeg) { + // fStatNegHit[ip][hitcounter]++; + // fStatOrHit[ip][hitcounter]++; + // fHodoNegEffi[fHod->GetScinIndex(ip, hitCounter[ip] - 1)]++; + // fHodoOrEffi[fHod->GetScinIndex(ip, hitCounter[ip] - 1)]++; + // } + + // // Increment pos/neg/both fired. Track independent, so + // // no chisquared cut, but note that only scintillators on the + // // track are examined. + // if (goodTdcPos) { + // if (goodTdcNeg) { + // fBothGood[ip][hitcounter]++; + // } else { + // fPosGood[ip][hitcounter]++; + // } + // } else if (goodTdcNeg) { + // fNegGood[ip][hitcounter]++; + // } + // // Determine if one or both PMTs had a good tdc + + // // if(goodTdcPos && goodTdcNeg) { + // // goodTdcBothSides[ip] = kTRUE; + // // } + // // if(goodTdcPos || goodTdcNeg) { + // // goodTdcOneSide[ip] = kTRUE; + // // } + // } + + // /* + // For each plane, see of other 3 fired. This means that they were enough + // to form a 3/4 trigger, and so the fraction of times this plane fired is + // the plane trigger efficiency. NOTE: we only require a TDC hit, not a + // TDC hit within the SCIN 3/4 trigger window, so high rates will make + // this seem better than it is. Also, make sure we're not near the edge + // of the hodoscope (at the last plane), using the same hhodo_slop param. + // as for h_tof.f + // NOTE ALSO: to make this check simpler, we are assuming that all planes + // have identical active areas. y_scin = y_cent + y_offset, so shift track + // position by offset for comparing to edges. + // */ + + // // Need to add calculation and cuts on + // // xatback and yatback in order to set the + // // htrig_hododidflag, htrig_hodoshouldflag and otherthreehit flags + // // + + // ++fNevt; + // } + //} + return 0; + } + +} // namespace hcana + diff --git a/src/hcana/CMakeLists.txt b/src/hcana/CMakeLists.txt new file mode 100644 index 0000000..a570f1e --- /dev/null +++ b/src/hcana/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.12) + +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +set(EXENAME hcana) + +# hcana executable +add_executable(${EXENAME} main.C) +target_link_libraries(${EXENAME} + PUBLIC HallC) +target_compile_features(${EXENAME} + PUBLIC cxx_std_17 + ) +#target_compile_options(${EXENAME} +# PUBLIC +# ${${PROJECT_NAME_UC}_CXX_FLAGS_LIST} +# PRIVATE +# ${${PROJECT_NAME_UC}_DIAG_FLAGS_LIST} +# ) +#if(${CMAKE_SYSTEM_NAME} MATCHES Linux) +# # Linux (at least with g++) requires -fPIC even for main +# target_compile_options(${EXENAME} -fPIC) +#endif() + +install(TARGETS ${EXENAME} + DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + + diff --git a/src/main.C b/src/hcana/main.C similarity index 100% rename from src/main.C rename to src/hcana/main.C -- GitLab