Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Overlay when not preserving truth particles #2

Merged
merged 5 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SET( ${PROJECT_NAME}_VERSION_PATCH 0 )
FIND_PACKAGE( ILCUTIL REQUIRED COMPONENTS ILCSOFT_CMAKE_MODULES )

# load default settings from ILCSOFT_CMAKE_MODULES
INCLUDE( ilcsoft_default_settings )
#INCLUDE( ilcsoft_default_settings )
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question for whoever has time. I always have to comment this out when compiling this locally with other packages due to an otherwise multiply defined unistall make target, although I seem to see a protection against this in the main make files included, but apparently it's not working well. Anyone else having these problems?
I can of course revert this change for the PR, since this should not be changed in the main mc branch.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pandreetto is looking into this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean when you write "compiling with other packages"?
Are you trying to merge the compilation of multiple components somehow?
If I remove the instruction above, cmake reports an error (Unknown CMake command "ADD_SHARED_LIBRARY")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pandreetto , I've posted here the instructions to reproduce the problem:
MuonColliderSoft/LCTuple#4
(it happens for all packages)



FIND_PACKAGE( Marlin 1.0 REQUIRED ) # minimum required Marlin version
Expand Down
24 changes: 22 additions & 2 deletions src/OverlayTiming.cc
Original file line number Diff line number Diff line change
Expand Up @@ -712,11 +712,30 @@ namespace overlay {
source_collection->removeElementAt(i);
}
}
else if ((source_collection->getTypeName() == LCIO::SIMTRACKERHIT) && ((std::fabs(time_offset) < std::numeric_limits<float>::epsilon()) || !TPC_hits))
else if (source_collection->getTypeName() == LCIO::SIMTRACKERHIT) {
//If truth is removed in the overlay, we need to remove the pointer since it will become invalid
if (not _mergeMCParticles) {
for (int k = 0; k < number_of_elements; ++k)
{
SimTrackerHitImpl *TrackerHit = static_cast<SimTrackerHitImpl*>(source_collection->getElementAt(k));
EVENT::MCParticle *mcParticle = TrackerHit->getMCParticle();
//if a valida pointer exists, keep momentum information
if (mcParticle) {
const double *preserveMomentum = mcParticle->getMomentum();
TrackerHit->setMomentum(preserveMomentum[0], preserveMomentum[1], preserveMomentum[2]);
}
TrackerHit->setMCParticle(nullptr);
}
}
//Adjust timing information on hits depending on BX and set overlay flag
if ((std::fabs(time_offset) < std::numeric_limits<float>::epsilon()) || !TPC_hits)
{
for (int k = number_of_elements - 1; k >= 0; --k)
{
SimTrackerHitImpl *TrackerHit = static_cast<SimTrackerHitImpl*>(source_collection->getElementAt(k));

TrackerHit->setOverlay(true);

const float _time_of_flight = time_of_flight(TrackerHit->getPosition()[0], TrackerHit->getPosition()[1], TrackerHit->getPosition()[2]);

if (((TrackerHit->getTime() + time_offset) > (this_start + _time_of_flight)) && ((TrackerHit->getTime() + time_offset) < (this_stop + _time_of_flight)))
Expand All @@ -727,7 +746,7 @@ namespace overlay {
}
}
}
else if ((source_collection->getTypeName() == LCIO::SIMTRACKERHIT) && TPC_hits)
else if (TPC_hits)
{
for (int k = number_of_elements - 1; k >= 0; --k)
{
Expand All @@ -752,6 +771,7 @@ namespace overlay {
}
}
}
}
else if (source_collection->getTypeName() == LCIO::SIMCALORIMETERHIT)
{
// create a map of dest Collection
Expand Down