ldmx-sw icon indicating copy to clipboard operation
ldmx-sw copied to clipboard

Modified the LYSO target design

Open zwl0331 opened this issue 1 year ago • 16 comments

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

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

zwl0331 avatar Nov 25 '24 05:11 zwl0331

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.)

bryngemark avatar Nov 25 '24 15:11 bryngemark

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 avatar Nov 26 '24 01:11 zwl0331

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.

zwl0331 avatar Dec 04 '24 20:12 zwl0331

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 avatar Dec 16 '24 14:12 bryngemark

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.

bryngemark avatar Dec 16 '24 14:12 bryngemark

We need to have thirty two 3mm height and 40mm long LYSO bars so that the active LYSO target will have the same coverage as tungsten target.

On Dec 16, 2024, at 6:17 AM, bryngemark @.***> wrote:

By the way @zwl0331https://github.com/zwl0331, @joyang8caltechhttps://github.com/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.

— Reply to this email directly, view it on GitHubhttps://github.com/LDMX-Software/ldmx-sw/pull/1498#issuecomment-2545747983, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A24FEATKUB4RTRRVJDB5Q4T2F3OI5AVCNFSM6AAAAABSNDXYUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBVG42DOOJYGM. You are receiving this because you were mentioned.Message ID: @.***>

joyang8caltech avatar Dec 16 '24 18:12 joyang8caltech

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 https://github.com/LDMX-Software/ldmx-sw/issues/1533

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

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

tvami avatar Jan 24 '25 18:01 tvami

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 avatar Feb 03 '25 20:02 zwl0331

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

zwl0331 avatar Feb 03 '25 20:02 zwl0331

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 avatar Feb 03 '25 20:02 tomeichlersmith

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

tomeichlersmith avatar Feb 03 '25 20:02 tomeichlersmith

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.

bryngemark avatar Feb 04 '25 23:02 bryngemark

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

zwl0331 avatar Feb 06 '25 00:02 zwl0331

I'd like to point out that

  1. This doesnt validate the geometry (we cant until https://github.com/LDMX-Software/ldmx-sw/issues/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)

tvami avatar Feb 06 '25 01:02 tvami

thanks @tvami, those are some good points. @zwl0331 how is this coming along?

bryngemark avatar Apr 01 '25 10:04 bryngemark

thanks @tvami, those are some good points. @zwl0331 how is this coming along?

I cannot validate the geometry until #1533 is resolved. As for the rest, @joyang8caltech has agreed to take on the tasks, because I am mainly working on a different experiment.

zwl0331 avatar Apr 22 '25 21:04 zwl0331

This PR is from Sam's trunk to ldmx-sw's trunk, which is not the recommended way of doing it: insted it should be a branch in ldmx-sw to trunk in ldmx-sw. So now I modified the target of this PR to go into LDMX-Software:iss1370-lyso-new-geom. I'll merge this and then immediately open a PR, which should be totally equivalent to this, but it will allow us to rebase and do some other changes collaboratively

tvami avatar Jul 02 '25 04:07 tvami