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 nested tube array geometry (optical fibers) #139

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

WilfS
Copy link

@WilfS WilfS commented Jun 17, 2024

Optical fibers (such as wavelength shifting fibers) are not explicitly defined in ratpac, despite their prevalence in physics experiments. One could create such a fiber in ratpac by constructing several concentric tubes with relevant materials, but when simulating experiments with thousands of fibers this can lead to undesirably large geometry files.

To address this issue, this update will add the nested tube array geometry, that allows construction of an array of three concentric tubes (a core, an inner tube and an outer tube). The length, position, and direction of each nested tube can be set individually. Materials and radii are set for the whole array.

Validation has been performed to ensure the nested tube arrays are correctly placed in the geometry and have the same optical properties as concentric tubes manually placed in the geometry. A validation macro and geometry file have been added that demonstrate how the nested tube arrays are placed.

The rat DS has been updated to include nested tube array info such as direction, length and material. This is similar to the PMTInfo class.

No extra materials have been added that would be useful when using nested tube arrays as optical fibers. We hope to add this later when we have more accurate properties.

The documentation has been updated to include the nested tube array geometry.

Wilf Shorrock added 3 commits June 6, 2024 09:04
This will allow us to pass on fiber info like angle and length to processors.
Also added a validation macro and geometry for the nested tubes.
Copy link
Contributor

@JamesJieranShen JamesJieranShen left a comment

Choose a reason for hiding this comment

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

This looks mostly ok with me on the geom construction perspective. I will wait on comments from others before merging.

doc/users_guide/processes.rst Outdated Show resolved Hide resolved
@JamesJieranShen
Copy link
Contributor

Argh.. please fix the formatting as well.

Wilf Shorrock added 2 commits June 24, 2024 11:24
Changed "optical photon" back to "opticalphoton" to reflect the name of the G4 class it is referring to.
@WilfS
Copy link
Author

WilfS commented Jun 24, 2024

Just pushed changes that are clang-formatted. Sorry, I missed that requirement.

Wilf Shorrock added 6 commits June 24, 2024 15:09
Formatting was flagged, despite using clang-format on all edited files (I made sure the .clang-format file was being used). I've changed the flagged files to have the same format as similar existing files.
One can now set the cores of nested tubes as sensitive detectors. Useful if using as optical fibres.
@WilfS
Copy link
Author

WilfS commented Jul 5, 2024

I've just added some commits relating to adding the ability to make the core of the nested tubes a sensitive detector. This is particularly useful when using the nested tubes as optical fibers. The hit information from the sensitive detector gets saved to the rat DS every event and can be accessed by processors.

Wilf Shorrock and others added 4 commits July 11, 2024 09:03
Previously, the nested tube array code would save the information for
all nested tubes in the array to the rat DS. This could potentially
consume a lot of memory. The behaviour has now been changed so that
information is only stored for nested tubes with sensitive detector
hits.
@MarcFBergevin MarcFBergevin self-requested a review September 6, 2024 17:18
@MarcFBergevin
Copy link

I have successfully compiled the PR with no issues. However when I run the following macro:

rat --vis macros/vis_nestedTubeArrays.mac -o ~/nested -l ~/nested.l

I obtain the following error:

GeoNestedTubeArrayFactory: Constructing volume fibers DB: Field GEO[fibers].outer_material lookup failure. Does not exist or has wrong type.

@MarcFBergevin
Copy link

I have switched values from material_outer to outer_material in the geo file and I was able to get an output (also for inner and core). I am not too certain I understand the following output:

Screenshot 2024-09-13 at 8 58 34 AM

Is this the same output on your end?

@WilfS
Copy link
Author

WilfS commented Sep 13, 2024

Apologies i forgot to update the macro.

Yes that output is expected. It's demonstrating the construction of fibres. The different colors are for the different construction methods. One with the old method of defining individual tubes and the other with the new array method.

@MarcFBergevin
Copy link

Thank you, that makes sense!

I did a quick test to test out the features with for four fibers. The visual output looks very nice. However, I am having difficulties accessing time and hit location in the outroot file (The error might be on my side). Have you cross-checked that hits are recorded for a test case scenario?

@WilfS
Copy link
Author

WilfS commented Sep 14, 2024

The fibers are sensitive detectors. Any hits that occur in them are saved as a hit collection in the ratds. I haven't added them to the outroot file, but they're easily accessed in processors so could be added

@MarcFBergevin
Copy link

Apologies, I should have made a clearer statement. I did notice that the ntuple root files were not filled out and I was going to propose to you to add that in (potentially as an optional output to the ntuple root files). I was referring to the /rat/proc outroot (instead of /rat/proc outntuple files) which records the ratds in a root format.

By modifying the MC you essentially have already filled out the outroot root files (or ds files). However when I query via the TBrowser I get empty values:
TBrowser

~71000 photon bombs event where generated in the scintillator material with 4 fibers for my test. I can forward the macro to you. The setup looked like this.

fiberSetup

I expected to see some hits, but could not confirm any hits in the ratdb root files.

@MarcFBergevin
Copy link

I have tried to add the sensitive detector option:

{ name: "GEO", index: "fibers", enable: 1, valid_begin: [0, 0], valid_end: [0, 0], mother: "outer_tank", type: "nestedtubearray", core_r: 0.47, inner_r: 0.485, outer_r: 0.5, pos_table: "cable_pos", orientation: "manual", outer_material: "aluminum", inner_material: "glass", core_material: "mirror", sensitive_detector: "/mydet/fibers", #drawstyle: "solid", color: [0.8,0.0,0.0,0.8] }

However, I am still not seeing any registered hits at this point.

@WilfS
Copy link
Author

WilfS commented Sep 20, 2024

Hmm. I've never looked at the outroot output, but I'm able to extract the fibre hits from the ratds when I use a custom processor, so it should be added to the outroot output... Looking into this now

@MarcFBergevin
Copy link

It would be nice to add an option so that the output could be save optionally to the outntuple files `src/io.

Maybe something like /rat/procset include_fibers 1 which by default would be 0. And then the macro could look like:

#/rat/proc outroot
/rat/proc outntuple
/rat/procset include_tracking 0
/rat/procset include_mcparticles 1
/rat/procset include_pmthits 0
/rat/procset include_fibers 1
/rat/procset include_untriggered_events 1

Wilf Shorrock added 4 commits December 10, 2024 10:35
The position of the logical volume for each nested tube was set to the
position of detected photons in the sensitive detector, which looked
strange in the visualiser. Fixed the issue by adding a new hit_position
variable to the hit collection and using that instead of the logical
volume position.
Forgot to update the header during last bugfix
@WilfS
Copy link
Author

WilfS commented Dec 13, 2024

We've changed the example macro to use some example WLS materials that we've added to ratdb. With these materials photons will actually get absorbed in the core of the nested tubes and be recorded by the sensitive detectors.

Looking at the outroot file, I see entries for the GetMCNestedTubeHitCount() method, so the hits are getting saved to the ratpac DS. Yet, if I look at the hit information using GetHitTime, I get errors saying

Error in <TTreeFormula::DefinedVariable>: Unknown method:photon.GetHitTime() in vector<RAT::DS::MCNestedTubeHit> 
Error in <TTreeFormula::Compile>:  Bad numerical expression : "ds.mc.nt.photon.GetHitTime()"

and if I try using the hitTime variable it says

Error in <TTreeFormula::DefinedVariable>: hitTime is not a datamember of vector<RAT::DS::MCNestedTubeHit>
Error in <TTreeFormula::Compile>:  Bad numerical expression : "ds.mc.nt.photon.hitTime"

I may just have things setup wrong, as I get the same errors when I try to retrieve hit information from the MCPMT class.

@JamesJieranShen
Copy link
Contributor

We've changed the example macro to use some example WLS materials that we've added to ratdb. With these materials photons will actually get absorbed in the core of the nested tubes and be recorded by the sensitive detectors.

Looking at the outroot file, I see entries for the GetMCNestedTubeHitCount() method, so the hits are getting saved to the ratpac DS. Yet, if I look at the hit information using GetHitTime, I get errors saying

Error in <TTreeFormula::DefinedVariable>: Unknown method:photon.GetHitTime() in vector<RAT::DS::MCNestedTubeHit> 
Error in <TTreeFormula::Compile>:  Bad numerical expression : "ds.mc.nt.photon.GetHitTime()"

and if I try using the hitTime variable it says

Error in <TTreeFormula::DefinedVariable>: hitTime is not a datamember of vector<RAT::DS::MCNestedTubeHit>
Error in <TTreeFormula::Compile>:  Bad numerical expression : "ds.mc.nt.photon.hitTime"

I may just have things setup wrong, as I get the same errors when I try to retrieve hit information from the MCPMT class.

Hey Wilf, you might need vectored versions of your data structures added to LinkDef.hh. Something like #pragma link C++ class vector < RAT::DS::MCNestedTubeHit>;. I think this will let cint (therefore ROOT) know about how to deal with vectors of the new DS objects.

@WilfS
Copy link
Author

WilfS commented Dec 13, 2024

Hi James. I believe I'm already doing that. And if I had forgotten to do it it wouldn't explain why the same thing is happening for the MCPhoton info. I must be doing something wrong with my root setup such that cint isn't getting the info from linkdef.

If someone else could test to confirm this is a "Wilf problem" rather than a general problem, that would help.

@WilfS
Copy link
Author

WilfS commented Dec 13, 2024

I've just added the requested feature from Marc where the nested tube hits are written to the ntuple output if requested.

If /rat/procset include_nestedtubehits is included in the macro, then nested tube info will be saved to the meta TTree and nested tube hit info will be saved in the output TTree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants