LDMX-Software / ldmx-sw

The Light Dark Matter eXperiment simulation and reconstruction framework.
https://ldmx-software.github.io
GNU General Public License v3.0
22 stars 21 forks source link

Multiple printouts when using logFrequency #1455

Closed tvami closed 2 months ago

tvami commented 2 months ago

Describe the bug

With the settings of

p.logFrequency = 100
p.termLogLevel = 1

I'd expect a single msg every 100 event to show up, instead, every 100 event the following

[ Process ] 1 : Processing 100 Run 2 Event 100  (2024-09-13 17:11:04.004336000-0700)
[ Process ] 1 : Processing 100 Run 2 Event 100  (2024-09-13 17:11:04.005039001-0700)

this comes up >5000 times!

To Reproduce I was running this

from LDMX.Framework import ldmxcfg
p=ldmxcfg.Process("v14_nonfid")

from LDMX.Ecal import EcalGeometry
from LDMX.Hcal import HcalGeometry
import LDMX.Ecal.ecal_hardcoded_conditions as ecal_conditions
import LDMX.Hcal.hcal_hardcoded_conditions as hcal_conditions
from LDMX.Biasing import ecal
from LDMX.SimCore import generators

mysim = ecal.nonfiducial_photo_nuclear('ldmx-det-v14-8gev', generators.single_8gev_e_upstream_tagger())
mysim.description = "ECal Non-Fiducial Test Simulation"

#from LDMX.Biasing import util
#mysim.actions.append( util.StepPrinter(1) )

import LDMX.Ecal.digi as ecal_digi
import LDMX.Ecal.vetos as ecal_vetos

p.outputFiles = [f'events_nonfiducial_test_production.root']
p.histogramFile = f'hist_nonfiducial_test_production.root'

p.maxTriesPerEvent = 10000
p.maxEvents = 100
p.totalEvents = 1000
p.run = 2
p.logFrequency = 100
p.termLogLevel = 1

p.sequence=[ mysim,
        ecal_digi.EcalDigiProducer(),
        ecal_digi.EcalRecProducer(),
        ecal_vetos.EcalVetoProcessor()
        ]

from LDMX.DQM import dqm
p.sequence.extend(dqm.ecal_dqm)

Desired behavior

Just have that print out once after ever N event

Environment:

denv_workspace="/home/vamitamas/NonFiducialSimu/v4.1.2"
denv_name="v4.1.2"
denv_image="ldmx/pro:v4.1.2"
denv_mounts="/home/vamitamas/NonFiducialSimu/v4.1.2 "
denv_shell="/bin/bash -i"
denv_network="true"
apptainer version 1.2.5
tomeichlersmith commented 2 months ago

This is expected since the outer loop over number of events is separate from the inner loop on the number of trials. We printout conditioned on the event index (decided by the outer loop) which means if there are multiple trials for an event matching the frequency, multiple printouts will be made.

Multiple printouts is confusing, but I'm curious what an improvement would be. Would just add a check that skips printouts if we are on later trials?

tvami commented 2 months ago

Would just add a check that skips printouts if we are on later trials?

Yes, I think that would be sufficient and satisfactory