PotentialBug in FCCAnalysisRun.py

Dear experts,
I have a feeling there’s a bug in FCCAnalysisRun when tracking the events processed. If I look to line 796 here:

I think it should be:
processEvents[pr]+=events

I am also not sure what the following line is doing?
Either way, at the moment the code keeps telling me there are more events in the tree than those I have processed :slightly_smiling_face:
If you agree that this is a bug I’ll put a fix in…

Sarah

Hello @williams,

The line

processEvents[pr]=events

loads original number of entries from the supplied input file created in previous step.

This number and number of entries in the tree might be different if there were any filters applied.

Best,
Juraj

Hi @jsmiesko ,
Thanks for this- this does make sense, however I would expect that the number of processedEvents must exceed the total number of events in the tree, which is inconsistent with what I was seeing before…
I realised I was pointing you to the wrong bit of code before (that one is fine and actually refers to the case of a single file). I am instead interested in L808-822, which describe the case that you have a directory of batch files.
I think the offending lines are actually these:

                for key in tfin.GetListOfKeys():
                    if 'eventsProcessed' == key.GetName():
                        events = tfin.eventsProcessed.GetVal()
                        processEvents[pr]+=events
                        found=True
                if not found:
                    processEvents[pr]=1

Where actually it should be

                if not found:
                    processEvents[pr]+=0

?

If I run it without the fix I get…

processed events  {'p8_ee_Zee_ecm91': 100000000, 'p8_ee_Ztautau_ecm91': 2000001, 'p8_ee_Zbb_ecm91': 22700001}
events in ttree   {'p8_ee_Zee_ecm91': 28230, 'p8_ee_Ztautau_ecm91': 158, 'p8_ee_Zbb_ecm91': 95}

But with the fix I get…

processed events  {'p8_ee_Zee_ecm91': 100000000, 'p8_ee_Ztautau_ecm91': 78000000, 'p8_ee_Zbb_ecm91': 280039718}
events in ttree   {'p8_ee_Zee_ecm91': 28230, 'p8_ee_Ztautau_ecm91': 158, 'p8_ee_Zbb_ecm91': 95}

Which seems more sensible to me, but maybe I am missing something?
Can you clarify that this makes sense? And sorry for the confusing message earlier…
Sarah

Just to clarify that I have since gone through and checked the individual “chunk” files and added up all the eventsProcessed counts and I think we do need to change to something like this:

            for key in tfin.GetListOfKeys():
                if 'eventsProcessed' == key.GetName():
                    events = tfin.eventsProcessed.GetVal()
                    print ('events processed=  ',events)
                    processEvents[pr]+=events
                    found=True
            if not found:
                print ('events processed=  ',0)
                processEvents[pr]+=0

(Ignore the print messages).
Please let me know if this makes sense to you,

Sarah

Hello @williams,

yap, it seems the additional 1 in case the processEvents is not found in the file seems to be there as a protection against dividing by zero in the later parts. I will prepare the PR with the fix for you to test.

In case: 'p8_ee_Zbb_ecm91': 280039718 the number looks suspicious, I would expect something round.

Best,
Juraj

Hello @williams,

I prepared the PR#275 with the changes, can you try to run it?

I expect that at least one of your files is missing eventsProcessed and the FCCAnalyses should crash gracefully.

Best,
Juraj

Hi @jsmiesko
thanks a lot for this- I’ll try to run it…
I’ve been continuing to do some digging as to why I don’t seem to get the full Zbb samples when I run…
If I divide the total event sample for Winter2023 (438,738,637 events total) I get that some jobs fail…
If I test for example this one:

source /afs/cern.ch/work/w/williams/public/FCC-LLP-tutorial-Spring2023/FCCAnalyses/BatchOutputs/2023-04-18_16-39-12/p8_ee_Zbb_ecm91/jobp8_ee_Zbb_ecm91_chunk91.sh

It fails like this:

[williams@lxplus781>/afs/cern.ch/work/w/williams/public/FCC-LLP-tutorial-Spring2023/FCCAnalyses>]$ source BatchOutputs/2023-04-18_16-39-12/p8_ee_Zbb_ecm91/jobp8_ee_Zbb_ecm91_chunk91.sh 
INFO: Key4hep stack already set up.
----> Info: Loading analyzers from libFCCAnalyses... 
----> Info: Loading analysis file:
      /afs/cern.ch/work/w/williams/public/FCC-LLP-tutorial-Spring2023/FCCAnalyses/examples/FCCee/bsm/LLPs/DisplacedHNL/analysis_stage1.py
The variable <outputDirEos> is optional in your analysis.py file, return default empty string
----> Running with user defined list of files (either locally or from batch)
----> Create dataframe object from files: 
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_060425524.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_125783611.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_100822432.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_146667278.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_155502704.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_126249930.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_069262305.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_005591936.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_152452924.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_000985204.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_091797610.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_165765128.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_174798950.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_106260564.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_014945929.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_112899660.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_088852080.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_192792903.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_110608169.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_015747757.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_085312044.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_051890609.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_010384131.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_184654584.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_012476409.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_178826353.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_101914793.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_043713283.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_145619837.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_032104916.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_113006261.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_066665166.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_153645562.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_120150652.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_156689327.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_107434473.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_103308179.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_114649318.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_180369465.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_109072526.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_035229539.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_131137885.root
    root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/IDEA/p8_ee_Zbb_ecm91/events_095699210.root
----> nevents original=0  local=4300000
The variable <geometryFile> is optional in your analysis.py file, return default value empty string
The variable <readoutName> is optional in your analysis.py file, return default value empty string
----> Init done, about to run 4300000 events on 4 CPUs
----> Error: During the execution of the stage file:
      /afs/cern.ch/work/w/williams/public/FCC-LLP-tutorial-Spring2023/FCCAnalyses/examples/FCCee/bsm/LLPs/DisplacedHNL/analysis_stage1.py
      exception occurred:
'TObject' object has no attribute 'GetEntries'

But then others work fine.
Do you have any idea what could be causing this?
Sarah

Hello @williams,

It seems to me, that after the analysis is run over one or few of the files from the set above, non of the events are left — they are all eliminated.

But, in order to keep track of the original number of events the output file needs to exist.

Few more checks on the file(s) need to be added.

Best,
Juraj

Hi @jsmiesko ,
Thanks so much for this. Can you point me to the part of the FCC analysis code where I can add more checks here?
Is it in FCCAnalysisRun.py…?

Sarah

Hello @williams,

The PR with the changes/checks is ready here:

Can you try to run FCCAnalyses from this branch:

?

Best,
Juraj

Hi @jsmiesko,
Thanks a lot for this.
It seems as though the above branch might be along the lines of what I implemented locally- I’ll try to investigate and check this week.
Sarah