Skip to content

Commit

Permalink
Merge pull request #7 from brownd1978/libfix
Browse files Browse the repository at this point in the history
Remove explicit lib loading: now dictionary comes from KinKal
  • Loading branch information
brownd1978 authored Dec 1, 2021
2 parents 2592a12 + 831ff73 commit 558907b
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 133 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ add_subdirectory(Spectra)
add_subdirectory(General)
add_subdirectory(Tests)

install(TARGETS Spectra Detector General Tests
install(TARGETS Spectra Detector General
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

Expand Down
20 changes: 3 additions & 17 deletions Detector/IPA.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "KinKal/MatEnv/MatDBInfo.hh"
#include "KinKal/MatEnv/DetMaterial.hh"
#include "KinKal/General/TimeRange.hh"
#include "TrackToy/General/Moyal.hh"
#include "TrackToy/General/TrajUtilities.hh"
#include "TrackToy/Detector/CylindricalShell.hh"
namespace TrackToy {
Expand All @@ -17,8 +16,6 @@ namespace TrackToy {
auto const& cylinder() const { return cyl_; }
auto const& material() const { return *mat_; }
auto type() const { return type_; }
// find the Moyal distribution describing the eloss function for a given intersection of a trajectory with this cylinder.
template<class PKTRAJ> Moyal energyLoss(PKTRAJ const& pktraj, KinKal::TimeRange const& trange) const;
// extend a trajectory through the IPA. Return value specifies if the particle continues downsream (true) or stops in the target or exits the field upstream (false)
template<class PKTRAJ> bool extendTrajectory(KinKal::BFieldMap const& bfield, PKTRAJ& pktraj,TimeRanges& intersections) const;
void print(std::ostream& os) const;
Expand All @@ -28,16 +25,6 @@ namespace TrackToy {
const MatEnv::DetMaterial* mat_;
};

template<class PKTRAJ> Moyal IPA::energyLoss(PKTRAJ const& pktraj, KinKal::TimeRange const& trange) const {
// sample the trajectory at the middle of the range
auto const& ktraj = pktraj.nearestPiece(trange.mid());
double beta = ktraj.beta();
double mom = ktraj.momentum();
double plen = ktraj.speed(trange.mid())*trange.range();
double xi = mat_->eloss_xi(beta,plen);
double dp = mat_->energyLossMPV(mom,plen,ktraj.mass());
return Moyal(dp,xi);
}

template<class PKTRAJ> bool IPA::extendTrajectory(KinKal::BFieldMap const& bfield, PKTRAJ& pktraj, TimeRanges& intersections) const {
bool retval(false);
Expand All @@ -58,13 +45,12 @@ namespace TrackToy {
cyl_.intersect(pktraj,intersections,tstart,tstep);
if(intersections.size() > 0){
for (auto const& ipainter : intersections) {
auto eloss = energyLoss(pktraj,ipainter);
double de = eloss.mean(); // should sample the distribution FIXME
// double de = eloss.sample(tr_.Uniform(0.0,1.0)); // currently broken, FIXME
double mom = pktraj.momentum(ipainter.mid());
double plen = pktraj.speed(ipainter.mid())*ipainter.range();
double de = mat_->energyLossMPV(mom,plen,pktraj.mass()); // should sample TODO
energy += de;
}
retval = updateEnergy(pktraj,intersections.back().end(),energy);
// std::cout << "IPA update " << retval << std::endl;
}
}
return retval;
Expand Down
2 changes: 1 addition & 1 deletion FindKINKAL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MESSAGE(STATUS "Adding KinKal include path $ENV{KINKAL_SOURCE_DIR}")
set(KINKAL_INCLUDE_DIR $ENV{KINKAL_SOURCE_DIR}/..)
mark_as_advanced(KINKAL_INCLUDE_DIR)
MESSAGE(STATUS "Looking for KinKal libraries in directory $ENV{KINKAL_LIBRARY_DIR}")
foreach( _cpt General MatEnv Trajectory Detector Fit)
foreach( _cpt MatEnv Trajectory Detector Fit General )
MESSAGE("Looking for Kinkal library ${_cpt}")
find_library(KINKAL_${_cpt}_LIBRARY ${_cpt} HINTS $ENV{KINKAL_LIBRARY_DIR})
if(KINKAL_${_cpt}_LIBRARY)
Expand Down
1 change: 0 additions & 1 deletion General/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

add_library(General SHARED
MuonRange.cc
Moyal.cc
)

# set top-level directory as include root
Expand Down
66 changes: 0 additions & 66 deletions General/Moyal.cc

This file was deleted.

22 changes: 0 additions & 22 deletions General/Moyal.hh

This file was deleted.

2 changes: 0 additions & 2 deletions Tests/BField_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
}
// not sure why this is necessary...
gSystem->Load("lib/libTests.dylib");
if(file.size()==0){
cout << "No input file specified: terminating" << endl;
return 1;
Expand Down
18 changes: 1 addition & 17 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# List of test test sources
# ls -1 *_test.cc

set( TEST_SOURCE_FILES
Spectrum_test.cc
Expand All @@ -10,22 +9,7 @@ set( TEST_SOURCE_FILES
CeTracks_test.cc
)

# generate root dictionary
include_directories(${PROJECT_SOURCE_DIR}/..)
ROOT_GENERATE_DICTIONARY(TestsDict
${PROJECT_SOURCE_DIR}/../KinKal/General/ParticleState.hh
LINKDEF LinkDef.h
)
# create shared library with ROOT dict
add_library(Tests SHARED TestsDict)

target_include_directories(Tests PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_include_directories(Tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
# add KinKal; this may be redundant, but...
target_include_directories(Tests PRIVATE ${KINKAL_INCLUDE_DIR})

# link ROOT libraries
target_link_libraries(Tests ${ROOT_LIBRARIES} ${KINKAL_LIBRARIES})

# Generate test targets
foreach( testsourcefile ${TEST_SOURCE_FILES} )
Expand All @@ -41,7 +25,7 @@ foreach( testsourcefile ${TEST_SOURCE_FILES} )
# add the project root as an include directory
# link all test tests to KinKal, MatEnv, and ROOT libraries.
target_include_directories(Test_${testname} PRIVATE ${PROJECT_SOURCE_DIR}/..)
target_link_libraries( Test_${testname} Spectra Detector General ${ROOT_LIBRARIES} ${KINKAL_LIBRARIES})
target_link_libraries( Test_${testname} Spectra Detector General ${KINKAL_LIBRARIES} ${ROOT_LIBRARIES} )

# ensure the test test executable filename is just its test name
set_target_properties( Test_${testname} PROPERTIES OUTPUT_NAME ${testname})
Expand Down
5 changes: 2 additions & 3 deletions Tests/MuStops_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
}
// not sure why this is necessary...
gSystem->Load("lib/libTests.dylib");
// gSystem->Load("lib/libTests.so");
if(mbfile.size()==0){
cout << "No input muon beam file specified: terminating" << endl;
return 1;
Expand All @@ -91,6 +88,8 @@ int main(int argc, char **argv) {
// find the TTree in the mbfile
TDirectory* td = (TDirectory*)mubeamfile->Get("StepPointMCDumper");
TTreeReader reader("nt",td);
ParticleState ps;
cout << "pstate " << ps.momentum3() << endl;
TTreeReaderValue<ParticleState> pstate(reader, "particle");
TTree* ptree = (TTree*)td->Get("nt");
cout << "MuonBeam particle TTree from file " << mbfile << " has " << ptree->GetEntries() << " Entries" << endl;
Expand Down
3 changes: 0 additions & 3 deletions Tests/Particle_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
}
// not sure why this is necessary...
gSystem->Load("lib/libTests.dylib");
gSystem->Load("libGeom");
if(pfile.size()==0){
cout << "No input pfile specified: terminating" << endl;
return 1;
Expand Down

0 comments on commit 558907b

Please sign in to comment.