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

Modified the LYSO target design #1498

Open
wants to merge 7 commits into
base: trunk
Choose a base branch
from
Open

Conversation

zwl0331
Copy link

@zwl0331 zwl0331 commented Nov 25, 2024

I am updating ldmx-sw, here are the details.

What are the issues that this addresses?

This resolves #1370 and implements the new design for the LYSO target. It consiste of two layers. The first layer has 32 bar, while the second has 33 bars.

Check List

  • I successfully compiled ldmx-sw with my developments
  • I ran my developments and the following shows that they are successful.

@zwl0331 zwl0331 self-assigned this Nov 25, 2024
@bryngemark
Copy link
Contributor

Hi Sam,
if your PR is ready for review (necessary before it gets merged), you need to pick at least two reviewers who will take a look and approve when satisfied. @tvami, @tomeichlersmith or myself would all be qualified.

To help us understand how you know that your changes are good, please upload some plots in this discussion thread, explain what you ran to get them, and what they show. (This is the purpose of the second box, that you already checked when you made the PR. I unchecked it until you have shared some more material.)

@zwl0331
Copy link
Author

zwl0331 commented Nov 26, 2024

I implemented the following geometry:
Picture1
In Geant4 this looks like this:

  • Side view:
Screenshot 2024-11-25 at 5 26 02 PM
  • Front view:
Screenshot 2024-11-25 at 5 26 36 PM

@zwl0331 zwl0331 requested review from tvami and bryngemark November 26, 2024 01:28
Copy link
Member

@tomeichlersmith tomeichlersmith left a comment

Choose a reason for hiding this comment

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

Thank you for the images! Those look great :)

I just want to confirm that this runs and the geometry doesn't have any sneaky issues (e.g. overlaps that are not visible because they are small but could cause issues during the simulation). Can you share a configuration you've used to confirm that this geometry successfully runs a simulation?

We can then run the same configuration with

# sim is the simulator configuration object already created
sim.validate_detector = True
sim.verbosity = 5

so that ldmx-sw takes extra time to make sure the geometry is valid.

@zwl0331
Copy link
Author

zwl0331 commented Dec 4, 2024

I have talked to Dr. James Oyang, @joyang8caltech, and he agreed to run some simulations using this geometry. Dr. Oyang, I forked a version of ldmx-sw into my github account and made the geometry modifications. It is at https://github.com/zwl0331/ldmx-sw You can clone it to run simulations with it.

Copy link
Member

@tvami tvami left a comment

Choose a reason for hiding this comment

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

Sorry it took me some time to look at this (DR writing...), I made some suggestions / questions in below.

Generarly I'd really like to see some tests that use this geometry, furthermore I'd suggest to either copy or rename the whole directory to r2, i.e. ldmx-lyso-r2-v14-8gev the r was for the revision, so it was exactly meant for this purposes. If you chose to rename, please add the info in the README that v4.1.4 is the last one to have ldmx-lyso-r1-v14-8gev

@bryngemark
Copy link
Contributor

I have talked to Dr. James Oyang, @joyang8caltech, and he agreed to run some simulations using this geometry. Dr. Oyang, I forked a version of ldmx-sw into my github account and made the geometry modifications. It is at https://github.com/zwl0331/ldmx-sw You can clone it to run simulations with it.

How is this going? Please see the specific geometry validation instructions posted here by @tomeichlersmith.

I also wonder, @tomeichlersmith and @tvami, if we should have a validation workflow for geometry changes? (This is not the last time we'll make an update.) We do expect a whole lot of changes to distributions, so it's not clear what tests are meaningful, apart from that things run, and the overlap check tom mentioned.

@bryngemark
Copy link
Contributor

By the way @zwl0331, @joyang8caltech, the plastic geometry doesn't look right. We expect to have 24 bars in each plastics array, so they are equal height but staggered in y.

@joyang8caltech
Copy link

joyang8caltech commented Dec 16, 2024 via email

@tvami
Copy link
Member

tvami commented Jan 24, 2025

if we should have a validation workflow for geometry changes?

I agree we need this, but I think we should have this after the sensitive volumes are defined, then we can do a PN sample with LYSO in the CI

The validate_detector doesnt work, see #1533

So we need to do this semi-blind...

@zwl0331 can you please update the code with the comments from me and Tom?

@zwl0331
Copy link
Author

zwl0331 commented Feb 3, 2025

I have successfully built ldmx-sw with the new geometry ran a simple simulation with it. Here is the simulation configuration:

from LDMX.Framework import ldmxcfg
p = ldmxcfg.Process( "sim" )
import sys
p.maxEvents = 10 #Note: use small number as you really are just checking the geom
if len(sys.argv) > 1 :
    p.maxEvents = int(sys.argv[1])

# we want to see every event
p.logFrequency = 1 if p.maxEvents <= 10 else 100
p.termLogLevel = 1

# Set a run number
p.run = 9001

p.outputFiles = [ "elecGun_8GeV.root" ]

from LDMX.SimCore import simulator as sim
import LDMX.Ecal.EcalGeometry
import LDMX.Hcal.HcalGeometry
mySim = sim.simulator( "mySim" )
mySim.setDetector( 'ldmx-det-v14-8gev' , True )
#sim.beamSpotSmear = [20., 80., 0.]

# Get a pre-written generator
from LDMX.SimCore import generators as gen

myGun = gen.gun('myGun')
myGun.particle = "e-" #'neutron','mu-','pi-','e-','gamma'
myGun.position = [ 0., 0., 0. ]
myGun.direction = [ 0., 0., 1.]
myGun.energy = 8.0 #GeV
mySim.generators.append( myGun )

# sim is the simulator configuration object already created--> From Tom
sim.validate_detector = True
sim.verbosity = 5

# add your configured simulation to the sequence
p.sequence.append( mySim )

# #Note: reco stuff --> use what you need, probably you dont care too much about this stuff
import LDMX.Ecal.EcalGeometry
import LDMX.Ecal.ecal_hardcoded_conditions
import LDMX.Hcal.HcalGeometry
import LDMX.Hcal.hcal_hardcoded_conditions
import LDMX.Ecal.digi as ecal_digi
import LDMX.Ecal.vetos as ecal_vetos
import LDMX.Hcal.digi as hcal_digi

from LDMX.Hcal import hcal_trig_digi
from LDMX.Ecal import ecal_trig_digi
from LDMX.Hcal import hcal
p.sequence.extend([
        ecal_digi.EcalDigiProducer(),
        ecal_digi.EcalRecProducer(),
        hcal_digi.HcalDigiProducer(),
        hcal_digi.HcalRecProducer()
        ])

The simulation ran successfully, giving the following output:

zwl0331@Samoffice:~/Documents/Research/LDMX/software/ldmx-sw$ sudo env "PATH=$PATH" denv fire elecGun.py
[sudo] password for zwl0331:
---- LDMXSW: Loading configuration --------
---- LDMXSW: Configuration load complete  --------
---- LDMXSW: Starting event processing --------
[ RunManager ]: Parallel worlds physics list has been registered.
[ RunManager ]: Parallel worlds have been enabled.
[ Process ] 1  info: Processing 1 Run 9001 Event 1  (2025-02-03 20:28:04.616878000+0000)
[ Process ] 2  info: Processing 2 Run 9001 Event 2  (2025-02-03 20:28:05.031306001+0000)
[ Process ] 3  info: Processing 3 Run 9001 Event 3  (2025-02-03 20:28:05.328579000+0000)
[ Process ] 4  info: Processing 4 Run 9001 Event 4  (2025-02-03 20:28:05.613524001+0000)
[ Process ] 5  info: Processing 5 Run 9001 Event 5  (2025-02-03 20:28:05.908598000+0000)
[ Process ] 6  info: Processing 6 Run 9001 Event 6  (2025-02-03 20:28:06.211264000+0000)
[ Process ] 7  info: Processing 7 Run 9001 Event 7  (2025-02-03 20:28:06.502809000+0000)
[ Process ] 8  info: Processing 8 Run 9001 Event 8  (2025-02-03 20:28:06.796944000+0000)
[ Process ] 9  info: Processing 9 Run 9001 Event 9  (2025-02-03 20:28:07.090554000+0000)
[ Process ] 10  info: Processing 10 Run 9001 Event 10  (2025-02-03 20:28:07.383509000+0000)
[ Process ] 10  info: RunHeader { run: 9001, numTries: 10, detectorName: ldmx-det-v14-8gev, description:
  intParameters:
    Included Scoring Planes = 1
    RandomNumberMasterSeed[sim] = 9001
    Use Random Seed from Event Header = 0
  floatParameters:
    Gen0 Direction X = 0
    Gen0 Direction Y = 0
    Gen0 Direction Z = 1
    Gen0 Energy [GeV] = 8
    Gen0 Time [ns] = 0
    Gen0 X [mm] = 0
    Gen0 Y [mm] = 0
    Gen0 Z [mm] = 0
  stringParameters:
    Geant4 revision =
    Gen0 Class = simcore::generators::ParticleGun
    Gen0 Particle = e-
    ldmx-sw revision = 2d449dc907f3b131b1c3c48c575695d0eae795f0
    ldmx-sw version = 4.2.8
}
[ Simulator ] : Started 10 events to produce 10 events.
---- LDMXSW: Event processing complete  --------

@zwl0331
Copy link
Author

zwl0331 commented Feb 3, 2025

By the way @zwl0331, @joyang8caltech, the plastic geometry doesn't look right. We expect to have 24 bars in each plastics array, so they are equal height but staggered in y.

Sorry about this. I put up the wrong figures. The correct ones are these. As you can see, they are 24 bars on both TS layers and they are staggered in y.
Screenshot 2025-02-03 at 12 37 17 PM
Screenshot 2025-02-03 at 12 37 35 PM

@tomeichlersmith
Copy link
Member

There are two points of confusion with your configuration.

sim.validate_detector = True
sim.verbosity = 5

As written, this won't work. sim is the simulator module and not the object your created mySim. It is just being silently ignored right now, but don't worry about that. This check won't work anyways because Geant4 can't seem to download the schema necessary to do the check itself. #1533

mySim.setDetector( 'ldmx-det-v14-8gev' , True )

This is saying to run the simulation with the ldmx-det-v14-8gev detector. You are adding the ldmx-lyso-r2-v14-8gev detector, so the simulation you have run is not using the detector you have been editing.

@tomeichlersmith
Copy link
Member

Unrelated, you can avoid having to use sudo and type your password in if you give your user access to manage the docker group on your computer.

https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user

@bryngemark
Copy link
Contributor

thanks @zwl0331 for sharing your config file! as you can see this was a great way to catch some issues with your validation procedure.
in addition to what @tomeichlersmith has spotted, i also notice that you are manually setting up an electron gun to start at the origin (myGun.position = [ 0., 0., 0. ]) , which ought to be in the middle of the LYSO target. I suggest using the predefined generator single_8gev_e_upstream_tagger() (double check the exact name) for this instead.

@zwl0331
Copy link
Author

zwl0331 commented Feb 6, 2025

thanks @zwl0331 for sharing your config file! as you can see this was a great way to catch some issues with your validation procedure. in addition to what @tomeichlersmith has spotted, i also notice that you are manually setting up an electron gun to start at the origin (myGun.position = [ 0., 0., 0. ]) , which ought to be in the middle of the LYSO target. I suggest using the predefined generator single_8gev_e_upstream_tagger() (double check the exact name) for this instead.

Thanks for the comments! This is the new simulation configuration I ran:

from LDMX.Framework import ldmxcfg
p = ldmxcfg.Process( "sim" )
import sys
p.maxEvents = 10 #Note: use small number as you really are just checking the geom
if len(sys.argv) > 1 :
    p.maxEvents = int(sys.argv[1])

# we want to see every event
p.logFrequency = 1 if p.maxEvents <= 10 else 100
p.termLogLevel = 1

# Set a run number
p.run = 9001

p.outputFiles = [ "elecGun_8GeV.root" ]

from LDMX.SimCore import simulator as sim
import LDMX.Ecal.EcalGeometry
import LDMX.Hcal.HcalGeometry
mySim = sim.simulator( "mySim" )
mySim.setDetector( 'ldmx-lyso-r2-v14-8gev' , True )
#sim.beamSpotSmear = [20., 80., 0.]

# Get a pre-written generator
from LDMX.SimCore import generators as gen

myGun = gen.single_8gev_e_upstream_tagger()
mySim.generators.append( myGun )

# sim is the simulator configuration object already created--> From Tom
sim.validate_detector = True
sim.verbosity = 5

# add your configured simulation to the sequence
p.sequence.append( mySim )

# #Note: reco stuff --> use what you need, probably you dont care too much about this stuff
import LDMX.Ecal.EcalGeometry
import LDMX.Ecal.ecal_hardcoded_conditions
import LDMX.Hcal.HcalGeometry
import LDMX.Hcal.hcal_hardcoded_conditions
import LDMX.Ecal.digi as ecal_digi
import LDMX.Ecal.vetos as ecal_vetos
import LDMX.Hcal.digi as hcal_digi

from LDMX.Hcal import hcal_trig_digi
from LDMX.Ecal import ecal_trig_digi
from LDMX.Hcal import hcal
p.sequence.extend([
        ecal_digi.EcalDigiProducer(),
        ecal_digi.EcalRecProducer(),
        hcal_digi.HcalDigiProducer(),
        hcal_digi.HcalRecProducer()
        ])

And it ran successfully:

zwl0331@Samoffice:~/Documents/Research/LDMX/software/ldmx-sw$ denv fire elecGun.py
---- LDMXSW: Loading configuration --------
---- LDMXSW: Configuration load complete  --------
---- LDMXSW: Starting event processing --------
[ RunManager ]: Parallel worlds physics list has been registered.
[ RunManager ]: Parallel worlds have been enabled.
[ Process ] 1  info: Processing 1 Run 9001 Event 1  (2025-02-06 00:42:07.534521000+0000)
[ Process ] 2  info: Processing 2 Run 9001 Event 2  (2025-02-06 00:42:07.919035000+0000)
[ Process ] 3  info: Processing 3 Run 9001 Event 3  (2025-02-06 00:42:08.215431001+0000)
[ Process ] 4  info: Processing 4 Run 9001 Event 4  (2025-02-06 00:42:08.511326000+0000)
[ Process ] 5  info: Processing 5 Run 9001 Event 5  (2025-02-06 00:42:08.815088000+0000)
[ Process ] 6  info: Processing 6 Run 9001 Event 6  (2025-02-06 00:42:09.110338000+0000)
[ Process ] 7  info: Processing 7 Run 9001 Event 7  (2025-02-06 00:42:09.396317000+0000)
[ Process ] 8  info: Processing 8 Run 9001 Event 8  (2025-02-06 00:42:09.690388000+0000)
[ Process ] 9  info: Processing 9 Run 9001 Event 9  (2025-02-06 00:42:09.979721000+0000)
[ Process ] 10  info: Processing 10 Run 9001 Event 10  (2025-02-06 00:42:10.281946000+0000)
[ Process ] 10  info: RunHeader { run: 9001, numTries: 10, detectorName: ldmx-lyso-r2-v14, description:
  intParameters:
    Included Scoring Planes = 1
    RandomNumberMasterSeed[sim] = 9001
    Use Random Seed from Event Header = 0
  floatParameters:
    Gen0 Direction X = 0.0485658
    Gen0 Direction Y = 0
    Gen0 Direction Z = 0.99882
    Gen0 Energy [GeV] = 8
    Gen0 Time [ns] = 0
    Gen0 X [mm] = -21.7459
    Gen0 Y [mm] = 0
    Gen0 Z [mm] = -883
  stringParameters:
    Geant4 revision =
    Gen0 Class = simcore::generators::ParticleGun
    Gen0 Particle = e-
    ldmx-sw revision = 8c1b6fcdf39f0055ee138d14d26efe25e65d80f9
    ldmx-sw version = v4.2.9
}
[ Simulator ] : Started 10 events to produce 10 ev

@tvami
Copy link
Member

tvami commented Feb 6, 2025

I'd like to point out that

  1. This doesnt validate the geometry (we cant until The validate_detector is broken #1533 is resolved)
  2. This does check that passive element part, but then how different are the results from running it thru a W target?
  3. For the r1 version of this we used signal to compare, maybe that's the best way to do this now too
  4. Or we should implement the sensitive volume and then have a pn interaction on it (and this is what I think we should have in the CI when we have it)

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

Successfully merging this pull request may close these issues.

LYSO active target for ldmx-lyso-r2-v14-8gev
5 participants