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

Add support for TVirtualMCSensitiveDetector. #889

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

kresan
Copy link
Contributor

@kresan kresan commented Apr 25, 2019

Inherit FairModule from TVirtualMCSensitiveDetector, which allows to use VMC stepping.
Tested with Tutorial1.
Requires changes in detector interface.

@sawenzel
Copy link
Contributor

Could you please summarize shortly what is the idea behind this change? Will it be backward compatible/optional or will it lead to deep changes?

@kresan
Copy link
Contributor Author

kresan commented May 6, 2019

It is still work in progress. Idea is to simplify handling of sensitive detectors in FairRoot. Currently foreseen as a default solution. Would require changes in FairDetector interface, which are not backward compatible. Changes are in ProcessHits method.

@dennisklein dennisklein added this to the v18.4 milestone Jul 4, 2019
@dennisklein dennisklein removed this from the v18.4 milestone Apr 6, 2020
@dennisklein dennisklein added this to the V18.6 milestone Apr 29, 2020
@kresan kresan removed the in progress label Feb 9, 2021
@kresan
Copy link
Contributor Author

kresan commented Feb 9, 2021

@MohammadAlTurany , Looking into it again, I have realised that the experiments will need to change ProcessHits method in every detector class

@karabowi
Copy link
Collaborator

karabowi commented Feb 9, 2021

can you shortly describe, what the changes would have to be?

@kresan
Copy link
Contributor Author

kresan commented Feb 9, 2021

The declaration:

virtual Bool_t ProcessHits(FairVolume* v = 0) = 0;

will be changed to:

virtual void ProcessHits()=0;

@karabowi
Copy link
Collaborator

karabowi commented Feb 9, 2021

Looking at the code, you've also moved the function from FairDetector to FairModule.
What is the reason to remove its argument and return value?
Can't it stay it used to be?

@MohammadAlTurany
Copy link
Contributor

MohammadAlTurany commented Feb 9, 2021

This change is needed only if you went to use the sensitive detector or did I miss something here?

@fuhlig1
Copy link
Member

fuhlig1 commented Feb 9, 2021

I thought there was a wrapper in FairRoot which calls the old function if the new one isn't available.

@kresan
Copy link
Contributor Author

kresan commented Feb 9, 2021

@karabowi We used to take care about bookkeeping of sensitive volumes in FairRoot. Idea of this PR is to let VMC do it. The new function is VMC requirement.
@MohammadAlTurany I thought we want to get read of the parts where we have to handle sensitive volumes on our own completely. Does it make sense to keep both options?
I agree to Florian that a wrapper can help here.
But, we have to be aware, that FairVolume parameter of the overloaded methods might have been used in the experiment code. How do we handle this with the wrapper?

@MohammadAlTurany
Copy link
Contributor

One could get the current volume and the corresponding FairVolume and call the old method, at least for some time to allow the experiments to move smoothly to the new one!

@karabowi
Copy link
Collaborator

karabowi commented Feb 9, 2021

With the current state of this branch, there seems to be no any MC points stored in the output files.

@kresan
Copy link
Contributor Author

kresan commented Feb 10, 2021

@karabowi thanks for testing. Probably something went wrong while rebasing. The whole thing will be revisited completely. I will open another PR soon.

@dennisklein dennisklein modified the milestones: v19.0, v19.2 Mar 8, 2021
@dennisklein dennisklein marked this pull request as draft March 8, 2021 16:17
@karabowi karabowi force-pushed the feature_sensitive_volumes branch 2 times, most recently from 51bffcc to 011da54 Compare May 6, 2022 11:52
@fuhlig1
Copy link
Member

fuhlig1 commented Jun 1, 2022

I started testing the Pull Request for CbmRoot and had several problems which are spread over the whole application stack. For my tests I used FairSoft apr21p2 and FairRoot v18.6.7 as baseline since these are the default versions used by CbmRoot. To compare to the PR I cherry-picked the changes from the PR into v18.6.7.

Compilation of the patches FairRoot as well as CbmRoot worked but when running out transport tests all of them failed with an assertion in the Initialize() function of one of our detector classes. The assertion checked that the function was only called once but obviously it was called twice.
When deriving FairModule from TVirtualMCSensitiveDetector the Initialize() function of Detectors/Modules is called from VMC and we need to remove calling the function from out FairMCApplication.
After the change in FairRoot and several fixes in CbmRoot I was able to run the tests without errors. When comparing the results produced with the patched and unpatched versions they were identical for most of our detector systems but for two of them only part of the MCPoints were produced.
After two days of debugging I probably found the problem in TGeant3. If I am correct the issue is already fixed with v4-0 which is the default for FairSoft apr22. I am currently compiling the new FairSoft version to confirm that with this new version the problem is fixed.

Preliminary comparison of execution times of the patched and unpatched FairRoot versions don't show any observable difference.

@ChristianTackeGSI
Copy link
Member

ChristianTackeGSI commented Jun 2, 2022

@fuhlig1
Could you add this double-calling-prevention assert to some of the FairRoot tests/examples please? Maybe open it in a new PR, so that we get this test before we merge the TVirtualMCSensitiveDetector PR?

@fuhlig1
Copy link
Member

fuhlig1 commented Jun 7, 2022

@ChristianTackeGSI,

the requested test case is described in #1195 and implemented with #1196.

@fuhlig1
Copy link
Member

fuhlig1 commented Jun 7, 2022

@kresan,

sorry but I think I messed up the PR a minute ago. There was a conflict which I tried to solve using the web editor but it seems to me that instead off doing a rebase the webpage did a merge. Could you please have a look.

@kresan kresan force-pushed the feature_sensitive_volumes branch from ad6983f to 011da54 Compare June 8, 2022 07:09
@kresan
Copy link
Contributor Author

kresan commented Jun 8, 2022

@fuhlig1, I reverted back your merge action. Now we need to resolve conflicts properly.

@fuhlig1
Copy link
Member

fuhlig1 commented Jun 8, 2022

@kresan,

thanks. Could you solve the conflicts. I fear if I do it from the web frontend we run into the same problem.

@karabowi karabowi force-pushed the feature_sensitive_volumes branch 2 times, most recently from a96f67f to 2259768 Compare June 8, 2022 08:02
@ChristianTackeGSI
Copy link
Member

We noticed in this morning's meeting, that we should consider raising the minimum required geant3 version to the one containing some fixes relevant to this pull request.

If we do so, it should be done in the CMakeLists.txt.

@ChristianTackeGSI
Copy link
Member

Also before we merge this one, we probably should do a rebase/cleanup of the commits.

And before we merge it, we should get clear on our release planning (this currently targets 19.2, not 19.0).

kresan and others added 6 commits January 26, 2023 12:23
Remove the double function definition.
Define the void FairDetector::ProcessHits() function, which calls the
depracated Bool_t ProcessHits(FairVolume*) of derived classes.

Update the FairMCApplication to match the update of the VMC:
introduction of EndOfEvent function called before
the TVirtualMCSensitiveDetectors->EndOfEvent().

Implement the temporary FairMCApplication::GetFairVolume()
function to keep the backward compability.

Cleanup of FairModule, FairMCApplication double code.
FairRoot allows for construction of clones volumes
using the volume_name#{clone_number} scheme.
Changing FairMCApplication::ConstructSensitiveDetectors()
to support this.
Since VMC is initializing TVirtualMCSensitiveDetector,
removed detector->Initialize() from FairMCApplication.

Removed the GetFairVolume function used by FairDetector::ProcessHits().
It now calls the deprecated function with NULL argument.

Changed the propagator example to use the new ProcessHits().
Comment on lines 1302 to 1303
std::map<std::string, FairModule*>::iterator it;
it = cloneVolumeMap.find(volName);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
std::map<std::string, FairModule*>::iterator it;
it = cloneVolumeMap.find(volName);
auto it = cloneVolumeMap.find(volName);

Comment on lines 552 to 553
Int_t id = fMC->CurrentVolID(copyNo);
id = fMC->CurrentVolID(copyNo);
Copy link
Member

Choose a reason for hiding this comment

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

You're assigning twice the same?

Suggested change
Int_t id = fMC->CurrentVolID(copyNo);
id = fMC->CurrentVolID(copyNo);
Int_t id = fMC->CurrentVolID(copyNo);

Copy link
Member

@ChristianTackeGSI ChristianTackeGSI left a comment

Choose a reason for hiding this comment

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

I have added a few minor comments.

In reality, I would like to discuss the whole design with people interested. Because I think, it's making things more and more complex and unmaintainable in the long run. It took me a few iterations to start to understand why things are done this way. And I have some ideas / questions about this.

base/sim/FairMCApplication.cxx Show resolved Hide resolved
base/sim/FairMCApplication.cxx Show resolved Hide resolved
base/sim/FairMCApplication.h Outdated Show resolved Hide resolved
base/sim/FairModule.h Outdated Show resolved Hide resolved
examples/advanced/propagator/src/FairTutPropDet.cxx Outdated Show resolved Hide resolved
Removed FairDetector::DefineSensitiveVolumes() function,
the functionality moved to FairMCApplication private special copy constructor.

Removed detector initialization from FairMCApplication::RegisterOutput(),
the detectors are initialized in the VMC.

Added few overrides for ProcessHits.
Removed the IsSensitive() function.
Increase the number of events to run in the MT mode to 20.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants