Scripting LHE files in WHIZARD

Asked by Shafakat Arifeen

Dear experts,

I am trying to script a process while changing the mass every run, and all outputs should give separate LHE files. The script that I'm currently using does generate separate .phs, .vg, and .log files, but it overwrites the LHE file. I am also trying to rename the files but I am having a hard time dealing with it.

Here is the script (.sin file):

##########################################
model = pidmtest1 (ufo)
process pff = a, a => dpip, dpim, dpi0
?rebuild_library = true
sqrts = 14 TeV
beams = p,p => lhapdf, lhapdf
$lhapdf_file = "LUXqed17_plus_PDF4LHC15_nnlo_100"
$phs_method = "wood"
n_events = 10000

scan Mdpim=(0.1 GeV => 10 GeV /+ 0.1 GeV){
    scan Mdpi0=(0.1 GeV => 10 GeV /+ 0.1 GeV){
        $run_id = sprintf "%e" (Mdpim*Mdpi0)
        compile
        simulate(pff){ sample_format = lhef }
        show(results)
    }
}

#################################################
I'm trying to change the mass of both dpim and dpi0, since the process leaves dpi0, dpim, and dpip (antiparticle of dpim) in the final state. This leads to massive output of .vg, .log, and .phs files, but as mentioned before, the LHE file keeps being overwritten (which is the main file I want to extract).

Is there any way to script this? Doing this manually would be extremely tedious.

Thank you.

Question information

Language:
English Edit question
Status:
Solved
For:
WHIZARD Edit question
Assignee:
Aleksander Filip Zarnecki Edit question
Solved by:
Shafakat Arifeen
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Aleksander Filip Zarnecki (alfizar) said :
#1

Dear Shafakat,

You can try to modify the $sample variable (defining the output event file name root) inside the loop.
I would use something like:
$sample = sprintf "my_output_file_%d" (file_id)
where you need to define 'file_id' counter before entering the scan loop:
int file_id = 0
and increase it inside the loop...

I am not really an expert, but I do hope it will work...

Regards
  Filip

Revision history for this message
Shafakat Arifeen (arifeen) said :
#2

Dear Filip,

Thank you for your suggestion, I applied it, as well as checked the manual, and here is the .sin script:

########################
model = pidmtest1 (ufo)
process pff = a, a => dpip, dpim, dpi0
?rebuild_library = true
sqrts = 14 TeV
beams = p,p => lhapdf, lhapdf
$lhapdf_file = "LUXqed17_plus_PDF4LHC15_nnlo_100"
$phs_method = "wood"
n_events = 10000
int file_id = 0
scan Mdpim=(0.1 GeV => 10 GeV /+ 0.1 GeV){
    scan Mdpi0=(0.1 GeV => 10 GeV /+ 0.1 GeV){
        compile
        simulate(pff){
            $sample = sprintf "my_output_file_%d" (file_id)
            sample_format = lhef
            }
        show(results)
        file_id = file_id + 1
    }
}
#########################################

However, the LHE files are still being named as pff.lhe and so keep being replaced.
Also this error shows up after the first iteration:

IDENTIFIER <variable> = file_id
******************************************************************************
*** ERROR: This variable is undefined at this point
******************************************************************************

I'm inclined to believe I'm just messing up a syntax, but I cannot figure out where.

Thanks
Shafakat

Revision history for this message
Shafakat Arifeen (arifeen) said :
#3

Oops, I've mistakenly clicked Solved, so I'm posting this message.

Revision history for this message
Aleksander Filip Zarnecki (alfizar) said :
#4

The error is very strange, do you get any message in the output file on the $sample variable being set?
Could you try to move the $sample delcaration to the main code of the loop:

int file_id = 0
scan Mdpim=(0.1 GeV => 10 GeV /+ 0.1 GeV){
    scan Mdpi0=(0.1 GeV => 10 GeV /+ 0.1 GeV){
        compile
        $sample = sprintf "my_output_file_%d" (file_id)
        sample_format = lhef
        simulate(pff)
        show(results)
        file_id = file_id + 1
    }
}

Maybe this will help...

Regards
 Filip

Revision history for this message
Juergen Reuter (j.r.reuter) said :
#5

Just a quick comment from mine:
it is benefecial to add
?write_raw = false
to suppress Whizard internal bytecode event format, outside of the scan loop,
to add
?rebuild_events = true
outside of the event loop, and to
connect the sample name on the scan variables, e.g.
           $sample = sprintf "my_foo_%1.3f_%1.3f" (Mdipm,Mdpi0)

inside the scan body.

Revision history for this message
Shafakat Arifeen (arifeen) said :
#6

Hello,

I've tried implementing the suggestion made by Juergen, but I still get the following:

| Events: writing to LHEF file 'pff.lhe'
| Events: generating 10000 unweighted, unpolarized events ...
| Events: event normalization mode '1'

For reference this is the .sin file:
############################
model = pidmtest1 (ufo)
process pff = a, a => dpip, dpim, dpi0
?rebuild_library = true
sqrts = 14 TeV
beams = p,p => lhapdf, lhapdf
$lhapdf_file = "LUXqed17_plus_PDF4LHC15_nnlo_100"
$phs_method = "wood"
n_events = 10000
?write_raw = false
?rebuild_events = true
scan Mdpim=(0.1 GeV => 10 GeV /+ 0.1 GeV){
    scan Mdpi0=(0.1 GeV => 10 GeV /+ 0.1 GeV){
        compile
        $sample = sprintf "my_foo_%1.3f_%1.3f" (Mdipm,Mdpi0)
        sample_format = lhef
        simulate(pff)
        show(results)
    }
}
#########################################

For the suggestion made by Filip, this is the error I get:

+ IDENTIFIER <variable> = file_id
******************************************************************************
*** ERROR: This variable is undefined at this point
******************************************************************************

Do note that I also received the same thing here:

| Events: writing to LHEF file 'pff.lhe'
| Events: generating 10000 unweighted, unpolarized events ...
| Events: event normalization mode '1'

Here's the .sin file:

###########################
model = pidmtest1 (ufo)
process pff = a, a => dpip, dpim, dpi0
?rebuild_library = true
sqrts = 14 TeV
beams = p,p => lhapdf, lhapdf
$lhapdf_file = "LUXqed17_plus_PDF4LHC15_nnlo_100"
$phs_method = "wood"
n_events = 10000
?write_raw = false
?rebuild_events = true
int file_id = 0
scan Mdpim=(0.1 GeV => 10 GeV /+ 0.1 GeV){
    scan Mdpi0=(0.1 GeV => 10 GeV /+ 0.1 GeV){
        compile
        $sample = sprintf "my_output_file_%d" (file_id)
        sample_format = lhef
        simulate(pff)
        show(results)
        file_id = file_id + 1
    }
}
############################

The main goal is to get different .lhe files, WHIZARD keeps overwriting them.

Sincerely
Shafakat

Revision history for this message
Shafakat Arifeen (arifeen) said :
#7

......It seems that there was a typo in Mdpim in:

$sample = sprintf "my_foo_%1.3f_%1.3f" (Mdpim,Mdpi0)

It now works, I get different lhe files. Thank you Filip and Juergen!

Sincerely
Shafakat