Merge lp:~maddevelopers/mg5amcnlo/bias_function into lp:~mg5core1/mg5amcnlo/2.5.6
- bias_function
- Merge into 2.5.6
Status: | Merged |
---|---|
Merge reported by: | Rikkert Frederix |
Merged at revision: | not available |
Proposed branch: | lp:~maddevelopers/mg5amcnlo/bias_function |
Merge into: | lp:~mg5core1/mg5amcnlo/2.5.6 |
Diff against target: |
1381 lines (+456/-195) (has conflicts) 26 files modified
Template/NLO/Cards/run_card.dat (+1/-1) Template/NLO/MCatNLO/srcHerwig/madfks_hwdriver.f (+1/-1) Template/NLO/MCatNLO/srcPythia/madfks_pydriver.f (+1/-1) Template/NLO/MCatNLO/srcPythia8/Pythia8.cc (+2/-2) Template/NLO/MCatNLO/srcPythia8/Pythia82.cc (+2/-2) Template/NLO/MCatNLO/srcPythia8/Pythia82_hep.cc (+1/-1) Template/NLO/MCatNLO/srcPythia8/Pythia8_hep.cc (+1/-1) Template/NLO/Source/setrun.f (+6/-4) Template/NLO/SubProcesses/collect_events.f (+0/-7) Template/NLO/SubProcesses/cuts.f (+39/-24) Template/NLO/SubProcesses/driver_mintMC.f (+20/-4) Template/NLO/SubProcesses/fks_singular.f (+150/-25) Template/NLO/SubProcesses/reweight_xsec_events.f (+1/-1) Template/NLO/SubProcesses/symmetry_fks_v3.f (+4/-3) Template/NLO/SubProcesses/weight_lines.f (+7/-1) Template/NLO/SubProcesses/write_event.f (+1/-9) Template/NLO/Utilities/check_events.f (+164/-92) Template/NLO/Utilities/makefile (+3/-2) UpdateNotes.txt (+4/-0) madgraph/interface/amcatnlo_run_interface.py (+11/-2) madgraph/interface/common_run_interface.py (+2/-2) madgraph/interface/reweight_interface.py (+1/-1) madgraph/madevent/gen_crossxhtml.py (+8/-2) madgraph/madevent/sum_html.py (+1/-1) madgraph/various/lhe_parser.py (+14/-2) madgraph/various/systematics.py (+11/-4) Text conflict in UpdateNotes.txt |
To merge this branch: | bzr merge lp:~maddevelopers/mg5amcnlo/bias_function |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Olivier Mattelaer | Needs Fixing | ||
Stefano Frixione | Pending | ||
Review via email: mp+328265@code.launchpad.net |
Commit message
Description of the change
Including the bias_weight_
Rikkert Frederix (frederix) wrote : | # |
Valentin Hirschi (valentin-hirschi) wrote : | # |
Hi Rik,
Great to see this functionality, thanks!
It would be nice to amend the bias wiki page:
https:/
with this new NLO functionality.
Also, how does it work exactly? Can you easily use user-defined biasing weight formulae?
A very quick look reveals that you intend to steer it via the 'event_norm' run_card entry.
Wouldn't it be handy to adopt the already existing structure at LO with:
None = bias_module ! Bias type of bias, [None, ptj_bias, -custom_folder-]
{} = bias_parameters ! Specifies the parameters of the module.
Where the user can create his own bias module and parameters (according to the conventions laid down on the wiki page) which will be moved automatically to the Source/BIAS directory and be compiled/link against the code?
Rikkert Frederix (frederix) wrote : | # |
Hi Valentin,
Stefano and I discussed this last week with Olivier, and decided not to use the LO syntax. CMS has been asking this for some time and we want to get it out asap (essentially the coming week).
At NLO, the bias function is not as easy as at LO, e.g. the function needs to be IR safe, and therefore, at least for the moment, keep it somewhat hidden for normal users. So, we don't want that users have a function that works at LO, and then simply try to use that at NLO without thinking it over. Hence, we should not use the same syntax. Anyway, also the current way of doing it, was already available at fNLO, so, if there were some users already using that, they can effectively use exactly the same as before.
Cheers,
Rik
Valentin Hirschi (valentin-hirschi) wrote : | # |
Ok, as you might suspect I have a different take on such matters, but I
understand your concerns and resulting choice.
In any case, amending the bias wiki page with the details of how to setup
bias at NLO and what the pitfalls/
On Sat, Jul 29, 2017 at 12:44 Rikkert Frederix <email address hidden>
wrote:
> Hi Valentin,
>
> Stefano and I discussed this last week with Olivier, and decided not to
> use the LO syntax. CMS has been asking this for some time and we want to
> get it out asap (essentially the coming week).
> At NLO, the bias function is not as easy as at LO, e.g. the function needs
> to be IR safe, and therefore, at least for the moment, keep it somewhat
> hidden for normal users. So, we don't want that users have a function that
> works at LO, and then simply try to use that at NLO without thinking it
> over. Hence, we should not use the same syntax. Anyway, also the current
> way of doing it, was already available at fNLO, so, if there were some
> users already using that, they can effectively use exactly the same as
> before.
>
> Cheers,
> Rik
>
> --
>
> https:/
> Your team mg5core1 is subscribed to branch lp:~mg5core1/mg5amcnlo/2.5.6.
>
--
Valentin
Stefano Frixione (stefano-frixione) wrote : | # |
Hi Valentin,
to add to what Rikkert said.
I've taken a look at the LO bias wiki page (which, I agree, should be
amended to include information on the NLO stuff).
It is all very beautiful, but also fairly discouraging for the
average user. It is *way* too complicated for someone who simply
doesn't want to bother (which is the majority of the users and,
maybe, myself).
Notably (which is the truly important thing here) the average
ATLAS user fall into the latter category: he/she is not even able
to reproduce some very basic behaviour (as many "bug" reports can
testify).
If one wants to take a positive outlook on this, such an attitude
is not unjustified: the code should simplify life for those who want
to extract physics from it: if the technical infrastucture becomes too
heavy, its flexibility and power will simply become irrelevant: users
are put off -- trust me on that, since I talk to a very large number
of experimentalists.
Finally, in this specific case: NLO gives one many more possibilities
than LO to screw things up big time. Furthermore, the NLO and LO
structures are already different, which is why a difference in this
context is perfectly acceptable.
Cheers, Stefano.
On Sat, 29 Jul 2017, Valentin Hirschi wrote:
> Hi Rik,
>
> Great to see this functionality, thanks!
>
> It would be nice to amend the bias wiki page:
>
> https:/
>
> with this new NLO functionality.
>
> Also, how does it work exactly? Can you easily use user-defined biasing weight formulae?
>
> A very quick look reveals that you intend to steer it via the 'event_norm' run_card entry.
> Wouldn't it be handy to adopt the already existing structure at LO with:
>
> None = bias_module ! Bias type of bias, [None, ptj_bias, -custom_folder-]
> {} = bias_parameters ! Specifies the parameters of the module.
>
> Where the user can create his own bias module and parameters (according to the conventions laid down on the wiki page) which will be moved automatically to the Source/BIAS directory and be compiled/link against the code?
> --
> https:/
> You are requested to review the proposed merge of lp:~maddevelopers/mg5amcnlo/bias_function into lp:~mg5core1/mg5amcnlo/2.5.6.
>
- 308. By Rikkert Frederix
-
fixed the definition of H_T in the bias-function
Olivier Mattelaer (olivier-mattelaer) wrote : | # |
Hi rikkert,
I have taken a look at the code and this is my comment
1) I do not like very much to use "event_norm" to trigger the bias. The main reason is that this flag is used to control how the weight of the event should be written. How would I set the normalization of the event to "Sum" in presence of bias?
Do we really need a flag in the run_card? Can't we have the default bias function to be "1"?
Like this, this will creates problem with the re-weighting/
2) the HTML/printout results, only display the un-physical number (with a very nice warning).
Should not we automatically display the correct result? I guess that this is fine like this since we want to have this only for very advanced user.
3) So For the moment, the only way to get the physical cross-section is trough the systematics printout. However for the "example" bias [pt_t**3]. This returns a wrong number (for p p > t t~):
It returns:
----
Scale variation (computed from LHE events):
instead of
----
Scale variation (computed from LHE events):
It seems to be a numerical precision issue, since if I change the bias to pt_top:
----
Scale variation (computed from LHE events):
----
However already using pt_top^2 seems bad:
----
Scale variation (computed from LHE events):
----
If for this bias pt_top^2, I increase the statistic to 250k, then I have:
----
Scale variation (computed from LHE events):
----
So maybe we should a comment about this "problem" in cuts.f (looks like we are much more sensitive than at LO)
4) After fixing systematics.py in order to assume that bias normalisation is equivalent to average.
Then I have the following results
4.1)from the online version:
----
Summary:
Process p p > t t~ [QCD]
Run at p-p collider (6500.0 + 6500.0 GeV)
Number of events generated: 10000
Total cross section, incl. bias (DO NOT USE): 8.236e+04 +- 5.0e+02 pb
----
Scale variation (computed from LHE events):
...
Stefano Frixione (stefano-frixione) wrote : | # |
Hi Olivier,
some comments on your comments.
> 1) I do not like very much to use "event_norm" to trigger the bias. The
> main reason is that this flag is used to control how the weight of
> the event should be written. How would I set the normalization of the
> event to "Sum" in presence of bias?
well, tastes aside (I personally like "bias") this option has a rather
direct bearing on the nature of the weights written in the LHEF, and
this includes their "norm". Furthermore, "bias" (or equivalent)
conveys immediately the message that these, at variance with the
other weights produced out of the integration, are not unweighted.
> Do we really need a flag in the run_card? Can't we have the default bias
> function to be "1"?
I strongly oppose this. The current choice may indeed be redundant,
but it is the only safe one. The possibility of screwing with this
stuff is significant, so we do need an extra layer of protection.
What can be done (no strong feelings here) is to have a check that,
if the bias function is identically equal to one, the warning printouts
are removed from the output.
> Like this, this will creates problem with the re-weighting/
> module (but trivial to fix) since they are all using that variable to
> know how to handle the weights.
I think we shouldn't do reverse engineering here: it's a new option,
so the systematics module must cope with it.
> 2) the HTML/printout results, only display the un-physical number (with
> a very nice warning). Should not we automatically display the
> correct result? I guess that this is fine like this since we want to
> have this only for very advanced user.
Well, I thought that the number printed out resulted from the integration,
not from the sum of event weights (since the former is more precise).
That being the case, the currect choice has no alternative, I'm afraid
(which is OK with me).
> 3) So For the moment, the only way to get the physical cross-section is
> trough the systematics printout. However for the "example" bias
......
> It seems to be a numerical precision issue, since if I change the bias
......
> So maybe we should a comment about this "problem" in cuts.f (looks like
> we are much more sensitive than at LO)
Well, this is expected, isn't it? By biasing, one shouldn't obtain
a particularly reliable number for inclusive rates, but smoother
high-pt tails. A comment, if any, should stress only this fact.
> 4) After fixing systematics.py in order to assume that bias
>
> So this indicates a problem in the way the weight is written in the file.
....
Note: in my tests, I've only looked at distributions. Although I've
mostly concentrated on the central weights, a quick looks at results
for non central scale values didn't show anything strange.
I'm using standard analyses as provided in ./MCatNLO subdirectories.
Cheers, Stefano.
> Did you change that format? did you add one entry?
> This is important since this will also forbid the re-weighting actually.
> (We can skype about this if you want to).
>
>
>
>
>
>
> --
> https:/
> You are requested to review the propo...
- 309. By Rikkert Frederix
-
Added a comment in the bias-function header saying the the statistical
uncertainty from computing the cross section by averaging the event
weights can be greatly enlarged when including a non-zero
bias-function
Rikkert Frederix (frederix) wrote : | # |
Hi Olivier,
1. I agree with Stefano here. Also, the python code has to do things slightly differently when including this bias function: it might be slightly more efficient in the original way as compared to including the bias. Hence, I would prefer to have an access at the level of the python code (which means some sort of flag in the run_card).
2. See Stefano.
3. I've added a comment in the header of the bias-weight-
4. I'll look for you on Skype asap.
Cheers,
Rik
Rikkert Frederix (frederix) wrote : | # |
Hi Olivier,
One more thing that I just realise only now. I see that the systematics also includes reweighting with muR=muF=sqrt(shat). This cannot be done at NLO, since shat is not an IR-safe quantity. (Think about collinear initial state radiation).
Hence, we should never include this option for NLO.
Cheers,
Rik
Olivier Mattelaer (olivier-mattelaer) wrote : | # |
Hi,
Well this is more tricky since you have case where it does make sense.
Like e+ e- > b b~ [QCD]
Cheers,
Olivier
Stefano Frixione (stefano-frixione) wrote : | # |
Hi Olivier,
not quite: the scale in that case is MZ. Which is almost the same
as sqrt(s), but only if you're talking about QCD. Given that we're
about to release the EW stuff, let's try and keep things as
general as possible, in order to be able to apply them to a
broader spectrum of possibilities.
Cheers, Stefano
On Mon, 7 Aug 2017, Olivier Mattelaer wrote:
> Hi,
>
> Well this is more tricky since you have case where it does make sense.
> Like e+ e- > b b~ [QCD]
>
> Cheers,
>
> Olivier
> --
> https:/
> You are requested to review the proposed merge of lp:~maddevelopers/mg5amcnlo/bias_function into lp:~mg5core1/mg5amcnlo/2.5.6.
>
- 310. By olivier-mattelaer
-
fixing the normalisation issue related to the systematics
Olivier Mattelaer (olivier-mattelaer) wrote : | # |
Hi,
I have implemented a switch to remove it automatically as soon as we have some proton in the initial state.
I have also fix the systematics computation. I do not have test the re-weighting (but I have switch all the part depending of event_norm). For that one, I will merge this branch into reweight_mass branch to be able to do the test in that branch (since I need to do some change to that branch due to this one anyway).
Rikkert, did you check the potential side effect on the parton-shower?
I see the following line in the function banner_to_mcatnlo:
content += 'EVENT_NORM=%s\n' % self.banner.
so the shower might have some side effect as well related to the new event_normalisa
Those in turn are (I guess) related to those:
./NLO/MCatNLO/
./NLO/MCatNLO/
./NLO/MCatNLO/
./NLO/MCatNLO/
I check one of those:
cat <<EOF >> ./$ifile
$EVENT_NORM ! Event weights are normalized to sun or average to the cross section
EOF
But after that I loose track on the potential impact of your change.
Cheers,
Olivier
Rikkert Frederix (frederix) wrote : | # |
Hi Olivier,
The event normalisation after shower has been taken care of. In the drivers that start the shower, instead of the checking for 'event_
Cheers,
Rik
Olivier Mattelaer (olivier-mattelaer) wrote : | # |
Perfect then.
I approve the merge.
Cheers,
Olivier
Olivier Mattelaer (olivier-mattelaer) wrote : | # |
Hi Rik,
I actually just found a bug when testing the re-weighting in the other branch.
If I use the nevt_jobs options with the 'bias' module then the results are crap.
I should have notice it above but in that case it was so close to a factor 10 that I miss it.
If I ask 250k events with nevt_jobs at 7500 then I have (for tt~):
----
Summary:
Process p p > t t~ [QCD]
Run at p-p collider (6500.0 + 6500.0 GeV)
Number of events generated: 250000
Total cross section, incl. bias (DO NOT USE): 1.427e+07 +- 3.6e+04 pb
----
Scale variation (computed from LHE events):
----
and you can see that the central value for the scale variation is everything but reliable.
at 250k events, I do not think that this is an effect of the statistical uncertainty.
I guess that this is a side effect of the "bias" flag.
Cheers,
Olivier
Rikkert Frederix (frederix) wrote : | # |
Hi Olivier,
I've fixed it directly in 2.5.6, since this branch was already merged. It was only a problem with the cross section printed to the screen; the weights of the actual events were okay.
Cheers,
Rik
Olivier Mattelaer (olivier-mattelaer) wrote : | # |
Thanks,
> I've fixed it directly in 2.5.6, since this branch was already merged. It was only a problem with the cross section printed to the screen; the weights of the actual events were okay.
Make sense since the (top mass) re-weighting was actually returning the correct value.
Thanks,
Olivier
> On 8 Aug 2017, at 14:42, Rikkert Frederix <email address hidden> wrote:
>
> Hi Olivier,
>
> I've fixed it directly in 2.5.6, since this branch was already merged. It was only a problem with the cross section printed to the screen; the weights of the actual events were okay.
>
> Cheers,
> Rik
> --
> https:/
> You are reviewing the proposed merge of lp:~maddevelopers/mg5amcnlo/bias_function into lp:~mg5core1/mg5amcnlo/2.5.6.
Preview Diff
1 | === modified file 'Template/NLO/Cards/run_card.dat' |
2 | --- Template/NLO/Cards/run_card.dat 2016-09-08 23:15:34 +0000 |
3 | +++ Template/NLO/Cards/run_card.dat 2017-08-07 21:43:30 +0000 |
4 | @@ -36,7 +36,7 @@ |
5 | # Normalize the weights of LHE events such that they sum or average to * |
6 | # the total cross section * |
7 | #*********************************************************************** |
8 | - %(event_norm)s = event_norm ! average or sum |
9 | + %(event_norm)s = event_norm ! valid settings: average, sum, bias |
10 | #*********************************************************************** |
11 | # Number of points per itegration channel (ignored for aMC@NLO runs) * |
12 | #*********************************************************************** |
13 | |
14 | === modified file 'Template/NLO/MCatNLO/srcHerwig/madfks_hwdriver.f' |
15 | --- Template/NLO/MCatNLO/srcHerwig/madfks_hwdriver.f 2017-07-25 08:06:10 +0000 |
16 | +++ Template/NLO/MCatNLO/srcHerwig/madfks_hwdriver.f 2017-08-07 21:43:30 +0000 |
17 | @@ -323,7 +323,7 @@ |
18 | C---EVENTS ARE NORMALIZED TO SUM OR AVERAGE TO THE TOTAL CROSS SECTION |
19 | WRITE(*,*)'How are the events normalized ("average" or "sum")?' |
20 | READ(*,*)NORM_EVENT |
21 | - if (NORM_EVENT.eq.'average')MQQ=1 |
22 | + if (NORM_EVENT(1:3).ne.'sum')MQQ=1 |
23 | |
24 | MSFLAG=0 |
25 | IF (LHSOFT) THEN |
26 | |
27 | === modified file 'Template/NLO/MCatNLO/srcPythia/madfks_pydriver.f' |
28 | --- Template/NLO/MCatNLO/srcPythia/madfks_pydriver.f 2014-11-27 15:36:48 +0000 |
29 | +++ Template/NLO/MCatNLO/srcPythia/madfks_pydriver.f 2017-08-07 21:43:30 +0000 |
30 | @@ -318,7 +318,7 @@ |
31 | C---EVENTS ARE NORMALIZED TO SUM OR AVERAGE TO THE TOTAL CROSS SECTION |
32 | WRITE(*,*)'How are the events normalized ("average" or "sum")?' |
33 | READ(*,*)NORM_EVENT |
34 | - if (NORM_EVENT.eq.'average')MQQ=1 |
35 | + if (NORM_EVENT(1:3).ne.'sum')MQQ=1 |
36 | |
37 | C---USER'S INITIAL CALCULATIONS |
38 | CALL PYABEG |
39 | |
40 | === modified file 'Template/NLO/MCatNLO/srcPythia8/Pythia8.cc' |
41 | --- Template/NLO/MCatNLO/srcPythia8/Pythia8.cc 2016-02-23 11:25:37 +0000 |
42 | +++ Template/NLO/MCatNLO/srcPythia8/Pythia8.cc 2017-08-07 21:43:30 +0000 |
43 | @@ -58,7 +58,7 @@ |
44 | int iEventshower=pythia.mode("Main:spareMode1"); |
45 | string evt_norm=pythia.word("Main:spareWord1"); |
46 | int iEventtot_norm=iEventtot; |
47 | - if (evt_norm == "average"){ |
48 | + if (evt_norm != "sum"){ |
49 | iEventtot_norm=1; |
50 | } |
51 | |
52 | @@ -112,7 +112,7 @@ |
53 | double normhepmc; |
54 | // Add the weight of the current event to the cross section. |
55 | normhepmc = 1. / double(iEventshower); |
56 | - if (evt_norm == "average") { |
57 | + if (evt_norm != "sum") { |
58 | sigmaTotal += evtweight*normhepmc; |
59 | } else { |
60 | sigmaTotal += evtweight*normhepmc*iEventtot; |
61 | |
62 | === modified file 'Template/NLO/MCatNLO/srcPythia8/Pythia82.cc' |
63 | --- Template/NLO/MCatNLO/srcPythia8/Pythia82.cc 2016-02-23 11:25:37 +0000 |
64 | +++ Template/NLO/MCatNLO/srcPythia8/Pythia82.cc 2017-08-07 21:43:30 +0000 |
65 | @@ -57,7 +57,7 @@ |
66 | int iEventshower=pythia.mode("Main:spareMode1"); |
67 | string evt_norm=pythia.word("Main:spareWord1"); |
68 | int iEventtot_norm=iEventtot; |
69 | - if (evt_norm == "average"){ |
70 | + if (evt_norm != "sum"){ |
71 | iEventtot_norm=1; |
72 | } |
73 | |
74 | @@ -118,7 +118,7 @@ |
75 | double normhepmc; |
76 | // Add the weight of the current event to the cross section. |
77 | normhepmc = 1. / double(iEventshower); |
78 | - if (evt_norm == "average") { |
79 | + if (evt_norm != "sum") { |
80 | sigmaTotal += evtweight*normhepmc; |
81 | } else { |
82 | sigmaTotal += evtweight*normhepmc*iEventtot; |
83 | |
84 | === modified file 'Template/NLO/MCatNLO/srcPythia8/Pythia82_hep.cc' |
85 | --- Template/NLO/MCatNLO/srcPythia8/Pythia82_hep.cc 2017-07-27 05:51:14 +0000 |
86 | +++ Template/NLO/MCatNLO/srcPythia8/Pythia82_hep.cc 2017-08-07 21:43:30 +0000 |
87 | @@ -83,7 +83,7 @@ |
88 | double evtweight = pythia.info.weight(); |
89 | double normhepmc; |
90 | // ALWAYS NORMALISE HEPMC WEIGHTS TO SUM TO THE CROSS SECTION |
91 | - if (evt_norm == "average") { |
92 | + if (evt_norm != "sum") { |
93 | normhepmc = 1. / double(iEventshower); |
94 | } else { |
95 | normhepmc = double(iEventtot) / double(iEventshower); |
96 | |
97 | === modified file 'Template/NLO/MCatNLO/srcPythia8/Pythia8_hep.cc' |
98 | --- Template/NLO/MCatNLO/srcPythia8/Pythia8_hep.cc 2017-07-27 05:51:14 +0000 |
99 | +++ Template/NLO/MCatNLO/srcPythia8/Pythia8_hep.cc 2017-08-07 21:43:30 +0000 |
100 | @@ -77,7 +77,7 @@ |
101 | double evtweight = pythia.info.weight(); |
102 | double normhepmc; |
103 | // ALWAYS NORMALISE HEPMC WEIGHTS TO SUM TO THE CROSS SECTION |
104 | - if (evt_norm == "average") { |
105 | + if (evt_norm != "sum") { |
106 | normhepmc = 1. / double(iEventshower); |
107 | } else { |
108 | normhepmc = double(iEventtot) / double(iEventshower); |
109 | |
110 | === modified file 'Template/NLO/Source/setrun.f' |
111 | --- Template/NLO/Source/setrun.f 2017-06-16 06:55:44 +0000 |
112 | +++ Template/NLO/Source/setrun.f 2017-08-07 21:43:30 +0000 |
113 | @@ -67,12 +67,14 @@ |
114 | buff = event_norm |
115 | call case_trap2(buff) ! requires a string of length 20 at least |
116 | event_norm=buff |
117 | - if (event_norm(1:7).ne.'average' .and. event_norm(1:3).ne.'sum' |
118 | - $ .and. event_norm(1:5).ne.'unity')then |
119 | + if ( event_norm(1:7).ne.'average' .and. |
120 | + $ event_norm(1:3).ne.'sum' .and. |
121 | + $ event_norm(1:5).ne.'unity'.and. |
122 | + $ event_norm(1:4).ne.'bias')then |
123 | write (*,*) 'Do not understand the event_norm parameter'/ |
124 | & /' in the run_card.dat. Possible options are'/ |
125 | - & /' "average", "sum" or "unity". Current input is: ', |
126 | - & event_norm |
127 | + & /' "average", "sum", "unity" or "bias". '/ |
128 | + & /'Current input is: ', event_norm |
129 | stop 1 |
130 | endif |
131 | c Check parameters for FxFx/UNLOPS/NNLL-veto |
132 | |
133 | === modified file 'Template/NLO/SubProcesses/collect_events.f' |
134 | --- Template/NLO/SubProcesses/collect_events.f 2017-07-29 08:02:08 +0000 |
135 | +++ Template/NLO/SubProcesses/collect_events.f 2017-08-07 21:43:30 +0000 |
136 | @@ -238,8 +238,6 @@ |
137 | data iseed/1/ |
138 | double precision rnd,fk88random |
139 | external fk88random |
140 | - logical debug |
141 | - parameter (debug=.false.) |
142 | integer nevents_file(80),proc_id(80) |
143 | common /to_nevents_file/nevents_file,proc_id |
144 | double precision xsecfrac_all(80) |
145 | @@ -256,11 +254,6 @@ |
146 | logical get_xsec_from_res1 |
147 | common/total_xsec/xsec,xerr,xsecABS,proc_id_tot,get_xsec_from_res1 |
148 | c |
149 | - if(debug) then |
150 | - write (*,*) ioutput,numoffiles,(junit(ii),ii=1,numoffiles) |
151 | - write(ioutput,*)'test test test' |
152 | - return |
153 | - endif |
154 | maxevt=0 |
155 | if (.not. get_xsec_from_res1) then |
156 | do i=1,100 |
157 | |
158 | === modified file 'Template/NLO/SubProcesses/cuts.f' |
159 | --- Template/NLO/SubProcesses/cuts.f 2017-05-09 12:37:07 +0000 |
160 | +++ Template/NLO/SubProcesses/cuts.f 2017-08-07 21:43:30 +0000 |
161 | @@ -898,32 +898,47 @@ |
162 | end |
163 | |
164 | |
165 | - subroutine unweight_function(p_born,unwgtfun) |
166 | -c This is a user-defined function to which to unweight the events |
167 | -c A non-flat distribution will generate events with a certain |
168 | -c weight. This is particularly useful to generate more events |
169 | -c (with smaller weight) in tails of distributions. |
170 | -c It computes the unwgt factor from the momenta and multiplies |
171 | -c the weight that goes into MINT (or vegas) with this factor. |
172 | -c Before writing out the events (or making the plots), this factor |
173 | -c is again divided out. |
174 | -c This function should be called with the Born momenta to be sure |
175 | -c that it stays the same for the events, counter-events, etc. |
176 | -c A value different from 1 makes that MINT (or vegas) does not list |
177 | -c the correct cross section. |
178 | + subroutine bias_weight_function(p,ipdg,bias_wgt) |
179 | +c This is a user-defined function to which to bias the event generation. |
180 | +c A non-flat distribution will generate events with a certain weight |
181 | +c inversely proportinal to the bias_wgt. This is particularly useful to |
182 | +c generate more events (with smaller weight) in tails of distributions. |
183 | +c It computes the bias_wgt factor from the momenta and multiplies the |
184 | +c weight that goes into MINT (or vegas) with this factor. Before |
185 | +c writing out the events (or making the plots), this factor is again |
186 | +c divided out. A value different from 1 makes that MINT (or vegas) does |
187 | +c not list the correct cross section, but the cross section can still be |
188 | +c computed from summing all the weights of the events (and dividing by |
189 | +c the number of events). Since the weights of the events are no longer |
190 | +c identical for all events, the statistical uncertainty on this total |
191 | +c cross section can be much larger than without including the bias. |
192 | +c |
193 | +c The 'bias_wgt' should be a IR-safe function of the momenta. |
194 | +c |
195 | +c For this to be used, the 'event_norm' option in the run_card should be |
196 | +c set to |
197 | +c 'bias' = event_norm |
198 | +c |
199 | implicit none |
200 | include 'nexternal.inc' |
201 | - double precision unwgtfun,p_born(0:3,nexternal-1),shat,sumdot |
202 | - external sumdot |
203 | - |
204 | - unwgtfun=1d0 |
205 | - |
206 | -c How to enhance the tails is very process dependent. But, it is |
207 | -c probably easiest to enhance the tails using shat, e.g.: |
208 | -c shat=sumdot(p_born(0,1),p_born(0,2),1d0) |
209 | -c unwgtfun=max(100d0**2,shat)/100d0**2 |
210 | -c unwgtfun=unwgtfun**2 |
211 | - |
212 | + double precision bias_wgt,p(0:3,nexternal),H_T |
213 | + integer ipdg(nexternal),i |
214 | + |
215 | + bias_wgt=1d0 |
216 | + |
217 | +c How to enhance the tails is very process dependent. For example for |
218 | +c top quark production one could use: |
219 | +c do i=1,nexternal |
220 | +c if (ipdg(i).eq.6) then |
221 | +c bias_wgt=sqrt(p(1,i)**2+p(2,i)**2)**3 |
222 | +c endif |
223 | +c enddo |
224 | +c Or to use H_T^2 one does |
225 | +c H_T=0d0 |
226 | +c do i=1,nexternal |
227 | +c H_T=H_T+sqrt(max(0d0,(pp(0,i)+pp(3,i))*(pp(0,i)-pp(3,i)))) |
228 | +c enddo |
229 | +c bias_wgt=H_T**2 |
230 | return |
231 | end |
232 | |
233 | |
234 | === modified file 'Template/NLO/SubProcesses/driver_mintMC.f' |
235 | --- Template/NLO/SubProcesses/driver_mintMC.f 2017-07-29 08:02:08 +0000 |
236 | +++ Template/NLO/SubProcesses/driver_mintMC.f 2017-08-07 21:43:30 +0000 |
237 | @@ -50,7 +50,9 @@ |
238 | double precision average_virtual(maxchannels),virtual_fraction(maxchannels) |
239 | common/c_avg_virt/average_virtual,virtual_fraction |
240 | |
241 | - double precision weight |
242 | + double precision weight,event_weight,inv_bias |
243 | + character*7 event_norm |
244 | + common /event_normalisation/event_norm |
245 | c For MINT: |
246 | real* 8 xgrid(0:nintervals,ndimmax,maxchannels),ymax(nintervals |
247 | $ ,ndimmax,maxchannels),ymax_virt(maxchannels),ans(nintegrals |
248 | @@ -311,7 +313,11 @@ |
249 | if (ickkw.eq.-1) putonshell=.false. |
250 | unwgt=.true. |
251 | open (unit=99,file='nevts',status='old',err=999) |
252 | - read (99,*) nevts |
253 | + if (event_norm(1:4).ne.'bias') then |
254 | + read (99,*) nevts |
255 | + else |
256 | + read (99,*) nevts,event_weight |
257 | + endif |
258 | close(99) |
259 | write(*,*) 'Generating ', nevts, ' events' |
260 | if(nevts.eq.0) then |
261 | @@ -354,7 +360,11 @@ |
262 | absint=ans(1,1)+ans(5,1) |
263 | uncer=unc(2,1) |
264 | |
265 | - weight=(ans(1,1)+ans(5,1))/ncall |
266 | + if (event_norm(1:4).ne.'bias') then |
267 | + weight=(ans(1,1)+ans(5,1))/ncall |
268 | + else |
269 | + weight=event_weight |
270 | + endif |
271 | |
272 | if (abrv(1:3).ne.'all' .and. abrv(1:4).ne.'born' .and. |
273 | $ abrv(1:4).ne.'virt') then |
274 | @@ -389,6 +399,10 @@ |
275 | call pick_unweight_contr(iFKS_picked) |
276 | call update_fks_dir(iFKS_picked) |
277 | call fill_rwgt_lines |
278 | + if (event_norm(1:4).eq.'bias') then |
279 | + call include_inverse_bias_wgt(inv_bias) |
280 | + weight=event_weight*inv_bias |
281 | + endif |
282 | call finalize_event(x,weight,lunlhe,putonshell) |
283 | enddo |
284 | call deallocate_weight_lines |
285 | @@ -945,9 +959,11 @@ |
286 | call include_shape_in_shower_scale(p,iFKS) |
287 | enddo |
288 | 12 continue |
289 | - |
290 | + |
291 | c Include PDFs and alpha_S and reweight to include the uncertainties |
292 | call include_PDF_and_alphas |
293 | +c Include the weight from the bias_function |
294 | + call include_bias_wgt |
295 | c Sum the contributions that can be summed before taking the ABS value |
296 | call sum_identical_contributions |
297 | c Update the shower starting scale for the S-events after we have |
298 | |
299 | === modified file 'Template/NLO/SubProcesses/fks_singular.f' |
300 | --- Template/NLO/SubProcesses/fks_singular.f 2017-06-19 06:49:26 +0000 |
301 | +++ Template/NLO/SubProcesses/fks_singular.f 2017-08-07 21:43:30 +0000 |
302 | @@ -619,7 +619,7 @@ |
303 | include 'run.inc' |
304 | include 'genps.inc' |
305 | include 'timing_variables.inc' |
306 | - double precision pi,unwgtfun,vegas_wgt,enhance,xnoborn_cnt,xtot |
307 | + double precision pi,vegas_wgt,enhance,xnoborn_cnt,xtot |
308 | $ ,bpower,cpower,tiny |
309 | data xnoborn_cnt /0d0/ |
310 | integer inoborn_cnt,i |
311 | @@ -732,11 +732,10 @@ |
312 | enhance=0d0 |
313 | endif |
314 | endif |
315 | - call unweight_function(p_born,unwgtfun) |
316 | call set_cms_stuff(0) |
317 | c f_* multiplication factors for Born and nbody |
318 | f_b=jac_cnt(0)*xinorm_ev/(min(xiimax_ev,xiBSVcut_used)*shat/(16 |
319 | - $ *pi**2))*enhance*unwgtfun *fkssymmetryfactorBorn*vegas_wgt |
320 | + $ *pi**2))*enhance*fkssymmetryfactorBorn*vegas_wgt |
321 | f_nb=f_b |
322 | call cpu_time(tAfter) |
323 | tf_nb=tf_nb+(tAfter-tBefore) |
324 | @@ -753,7 +752,7 @@ |
325 | include 'fks_powers.inc' |
326 | include 'coupl.inc' |
327 | include 'timing_variables.inc' |
328 | - double precision unwgtfun,vegas_wgt,enhance,xnoborn_cnt,xtot |
329 | + double precision vegas_wgt,enhance,xnoborn_cnt,xtot |
330 | & ,prefact,prefact_cnt_ssc,prefact_deg,prefact_c,prefact_coll |
331 | & ,jac_ev,pi,prefact_cnt_ssc_c,prefact_coll_c,prefact_deg_slxi |
332 | & ,prefact_deg_sxi,zero |
333 | @@ -845,11 +844,10 @@ |
334 | enhance=0d0 |
335 | endif |
336 | endif |
337 | - call unweight_function(p_born,unwgtfun) |
338 | prefact=xinorm_ev/xi_i_fks_ev/(1-y_ij_fks_ev) |
339 | |
340 | c f_* multiplication factors for real-emission, soft counter, ... etc. |
341 | - f_r=prefact*jac_ev*enhance*unwgtfun*fkssymmetryfactor*vegas_wgt |
342 | + f_r=prefact*jac_ev*enhance*fkssymmetryfactor*vegas_wgt |
343 | f_MC_S=f_r |
344 | f_MC_H=f_r |
345 | if (.not.nocntevents) then |
346 | @@ -857,9 +855,9 @@ |
347 | & log(xicut_used/min(xiimax_ev,xiScut_used))/(1 |
348 | & -y_ij_fks_ev) |
349 | f_s=(prefact+prefact_cnt_ssc)*jac_cnt(0)*enhance |
350 | - $ *unwgtfun*fkssymmetryfactor*vegas_wgt |
351 | + $ *fkssymmetryfactor*vegas_wgt |
352 | f_s_MC_S=prefact*jac_cnt(0)*enhance |
353 | - $ *unwgtfun*fkssymmetryfactor*vegas_wgt |
354 | + $ *fkssymmetryfactor*vegas_wgt |
355 | f_s_MC_H=f_s_MC_S |
356 | |
357 | if (pmass(j_fks).eq.0d0) then |
358 | @@ -867,9 +865,9 @@ |
359 | prefact_coll=xinorm_cnt(1)/xi_i_fks_cnt(1)*log(delta_used |
360 | $ /deltaS)/deltaS |
361 | f_c=(prefact_c+prefact_coll)*jac_cnt(1) |
362 | - $ *enhance*unwgtfun*fkssymmetryfactor*vegas_wgt |
363 | + $ *enhance*fkssymmetryfactor*vegas_wgt |
364 | f_c_MC_S=prefact_c*jac_cnt(1) |
365 | - $ *enhance*unwgtfun*fkssymmetryfactor*vegas_wgt |
366 | + $ *enhance*fkssymmetryfactor*vegas_wgt |
367 | f_c_MC_H=f_c_MC_S |
368 | |
369 | call set_cms_stuff(1) |
370 | @@ -881,12 +879,12 @@ |
371 | $ *log(xicut_used/min(xiimax_cnt(1),xiScut_used)) |
372 | $ *log(delta_used/deltaS)/deltaS |
373 | f_dc=jac_cnt(1)*prefact_deg/(shat/(32*pi**2))*enhance |
374 | - $ *unwgtfun*fkssymmetryfactorDeg*vegas_wgt |
375 | + $ *fkssymmetryfactorDeg*vegas_wgt |
376 | f_sc=(prefact_c+prefact_coll+prefact_cnt_ssc_c |
377 | - & +prefact_coll_c)*jac_cnt(2)*enhance*unwgtfun |
378 | + & +prefact_coll_c)*jac_cnt(2)*enhance |
379 | & *fkssymmetryfactorDeg*vegas_wgt |
380 | f_sc_MC_S=prefact_c*jac_cnt(2) |
381 | - $ *enhance*unwgtfun*fkssymmetryfactor*vegas_wgt |
382 | + $ *enhance*fkssymmetryfactor*vegas_wgt |
383 | f_sc_MC_H=f_sc_MC_S |
384 | |
385 | call set_cms_stuff(2) |
386 | @@ -898,13 +896,13 @@ |
387 | & -log(min(xiimax_cnt(1),xiScut_used))**2 )*1/(2.d0 |
388 | & *deltaS) |
389 | f_dsc(1)=prefact_deg*jac_cnt(2)/(shat/(32*pi**2))*enhance |
390 | - & *unwgtfun*fkssymmetryfactorDeg*vegas_wgt |
391 | + & *fkssymmetryfactorDeg*vegas_wgt |
392 | f_dsc(2)=prefact_deg_sxi*jac_cnt(2)/(shat/(32*pi**2)) |
393 | - & *enhance*unwgtfun*fkssymmetryfactorDeg*vegas_wgt |
394 | + & *enhance*fkssymmetryfactorDeg*vegas_wgt |
395 | f_dsc(3)=prefact_deg_slxi*jac_cnt(2)/(shat/(32*pi**2)) |
396 | - & *enhance*unwgtfun*fkssymmetryfactorDeg*vegas_wgt |
397 | + & *enhance*fkssymmetryfactorDeg*vegas_wgt |
398 | f_dsc(4)=( prefact_deg+prefact_deg_sxi )*jac_cnt(2)/(shat |
399 | - & /(32*pi**2))*enhance*unwgtfun*fkssymmetryfactorDeg |
400 | + & /(32*pi**2))*enhance*fkssymmetryfactorDeg |
401 | & *vegas_wgt |
402 | else |
403 | f_c=0d0 |
404 | @@ -1214,6 +1212,117 @@ |
405 | return |
406 | end |
407 | |
408 | + subroutine include_bias_wgt |
409 | +c Include the weight from the bias_wgt_function to all the contributions |
410 | +c in icontr. This only changes the weight of the central value (after |
411 | +c inclusion of alphaS and parton luminosity). Both for 'wgts(1,icontr)' |
412 | +c as well as the the 'parton_iproc(1:niproc(icontr),icontr)', since |
413 | +c these are the ones used in MINT as well as for unweighting. Also the |
414 | +c 'virt_wgt_mint' and 'born_wgt_mint' are updated. Furthermore, to |
415 | +c include the weight also in the 'wgt' array that contain the |
416 | +c coefficients for PDF and scale computations. |
417 | + use weight_lines |
418 | + implicit none |
419 | + integer i,j |
420 | + double precision bias |
421 | + character*7 event_norm |
422 | + common /event_normalisation/event_norm |
423 | + double precision virt_wgt_mint,born_wgt_mint |
424 | + common /virt_born_wgt_mint/virt_wgt_mint,born_wgt_mint |
425 | +c Set the bias_wgt to 1 in case we do not have to do any biassing |
426 | + if (event_norm(1:4).ne.'bias') then |
427 | + do i=1,icontr |
428 | + bias_wgt(i)=1d0 |
429 | + enddo |
430 | + return |
431 | + endif |
432 | +c loop over all contributions |
433 | + do i=1,icontr |
434 | + if (itype(i).eq.1) then |
435 | + ! use (n+1)-body momenta for the real emission. Pick the |
436 | + ! first IPROC for parton PDGs. |
437 | + call bias_weight_function(momenta_m(0,1,2,i),parton_pdg(1,1 |
438 | + $ ,i),bias) |
439 | + else |
440 | + ! use n-body momenta for all the other contributions. Pick |
441 | + ! the first IPROC for parton PDGs. |
442 | + call bias_weight_function(momenta_m(0,1,1,i),parton_pdg(1,1 |
443 | + $ ,i),bias) |
444 | + endif |
445 | + bias_wgt(i)=bias |
446 | +c Update the weights: |
447 | + wgts(1,i)=wgts(1,i)*bias_wgt(i) |
448 | + do j=1,niproc(i) |
449 | + parton_iproc(j,i)=parton_iproc(j,i)*bias_wgt(i) |
450 | + enddo |
451 | + do j=1,3 |
452 | + wgt(j,i)=wgt(j,i)*bias_wgt(i) |
453 | + enddo |
454 | + if (itype(i).eq.14) then |
455 | + virt_wgt_mint=virt_wgt_mint*bias_wgt(i) |
456 | + born_wgt_mint=born_wgt_mint*bias_wgt(i) |
457 | + endif |
458 | + enddo |
459 | + return |
460 | + end |
461 | + |
462 | + subroutine include_inverse_bias_wgt(inv_bias) |
463 | +c Update the inverse of the bias in the event weight. All information in |
464 | +c the rwgt_lines is NOT updated. |
465 | + use weight_lines |
466 | + use extra_weights |
467 | + implicit none |
468 | + include 'genps.inc' |
469 | + include 'nFKSconfigs.inc' |
470 | + integer i,ict,ipr,ii |
471 | + double precision wgt_num,wgt_denom,inv_bias |
472 | + character*7 event_norm |
473 | + common /event_normalisation/event_norm |
474 | + integer iproc_save(fks_configs),eto(maxproc,fks_configs) |
475 | + $ ,etoi(maxproc,fks_configs),maxproc_found |
476 | + common/cproc_combination/iproc_save,eto,etoi,maxproc_found |
477 | + logical Hevents |
478 | + common/SHevents/Hevents |
479 | + if (event_norm(1:4).ne.'bias') then |
480 | + inv_bias=1d0 |
481 | + return |
482 | + endif |
483 | + wgt_num=0d0 |
484 | + wgt_denom=0d0 |
485 | + do i=1,icontr_sum(0,icontr_picked) |
486 | + ict=icontr_sum(i,icontr_picked) |
487 | + if (bias_wgt(ict).eq.0d0) then |
488 | + write (*,*) "ERROR in include_inverse_bias_wgt: "/ |
489 | + $ /"bias_wgt is equal to zero",ict,bias_wgt |
490 | + stop 1 |
491 | + endif |
492 | +c for all the rwgt_lines, remove the bias-wgt contribution from the |
493 | +c weights there. Note that the wgtref (also written in the event file) |
494 | +c keeps its contribution from the bias_wgt. |
495 | + if (.not. Hevents) then |
496 | + ipr=eto(etoi(iproc_picked,nFKS(ict)),nFKS(ict)) |
497 | + do ii=1,iproc_save(nFKS(ict)) |
498 | + if (eto(ii,nFKS(ict)).ne.ipr) cycle |
499 | + wgt_denom=wgt_denom+parton_iproc(ii,ict) |
500 | + wgt_num=wgt_num+parton_iproc(ii,ict)/bias_wgt(ict) |
501 | + enddo |
502 | + else |
503 | + ipr=iproc_picked |
504 | + wgt_denom=wgt_denom+parton_iproc(ipr,ict) |
505 | + wgt_num=wgt_num+parton_iproc(ipr,ict)/bias_wgt(ict) |
506 | + endif |
507 | + enddo |
508 | + if (abs((wgtref-wgt_denom)/(wgtref+wgt_denom)).gt.1d-10) then |
509 | + write (*,*) "ERROR in include_inverse_bias_wgt: "/ |
510 | + $ /"reference weight not equal to recomputed weight",wgtref |
511 | + $ ,wgt_denom |
512 | + stop 1 |
513 | + endif |
514 | +c update the event weight to be written in the file |
515 | + inv_bias=wgt_num/wgt_denom |
516 | + return |
517 | + end |
518 | + |
519 | |
520 | subroutine set_pdg_codes(iproc,pd,iFKS,ict) |
521 | use weight_lines |
522 | @@ -1748,14 +1857,27 @@ |
523 | include 'nexternal.inc' |
524 | include 'mint.inc' |
525 | integer i |
526 | - double precision f(nintegrals),sigint |
527 | + double precision f(nintegrals),sigint,bias |
528 | double precision virt_wgt_mint,born_wgt_mint |
529 | common /virt_born_wgt_mint/virt_wgt_mint,born_wgt_mint |
530 | double precision virtual_over_born |
531 | common /c_vob/ virtual_over_born |
532 | + character*7 event_norm |
533 | + common /event_normalisation/event_norm |
534 | sigint=0d0 |
535 | do i=1,icontr |
536 | - sigint=sigint+wgts(1,i) |
537 | + if (event_norm(1:4).ne.'bias') then |
538 | + sigint=sigint+wgts(1,i) |
539 | + else |
540 | + if (itype(i).eq.1) then |
541 | + call bias_weight_function(momenta_m(0,1,2,i),parton_pdg(1 |
542 | + $ ,1,i),bias) |
543 | + else |
544 | + call bias_weight_function(momenta_m(0,1,1,i),parton_pdg(1 |
545 | + $ ,1,i),bias) |
546 | + endif |
547 | + sigint=sigint+wgts(1,i)*bias |
548 | + endif |
549 | enddo |
550 | f(1)=abs(sigint) |
551 | f(2)=sigint |
552 | @@ -2193,7 +2315,7 @@ |
553 | n_ctr_found=0 |
554 | n_mom_conf=0 |
555 | c Loop over all the contributions in the picked contribution (the latter |
556 | -c is chosen in the pick_unweight_cont() subroutine) |
557 | +c is chosen in the pick_unweight_contr() subroutine) |
558 | do i=1,icontr_sum(0,icontr_picked) |
559 | ict=icontr_sum(i,icontr_picked) |
560 | c Check if the current set of momenta are already available in the |
561 | @@ -2270,8 +2392,7 @@ |
562 | & trim(adjustl(n_ctr_str(n_ctr_found)))//' ' |
563 | & //trim(adjustl(procid)) |
564 | |
565 | - write (str_temp, |
566 | - & '(i2,6(1x,d14.8),6(1x,i2),1x,i8,1x,d18.12)') |
567 | + write (str_temp,30) |
568 | & QCDpower(ict), |
569 | & (bjx(j,ict),j=1,2), |
570 | & (scales2(j,ict),j=1,3), |
571 | @@ -2282,7 +2403,8 @@ |
572 | & fks_i_d(nFKS(ict)), |
573 | & fks_j_d(nFKS(ict)), |
574 | & parton_pdg_uborn(fks_j_d(nFKS(ict)),ii,ict), |
575 | - & parton_iproc(ii,ict) |
576 | + & parton_iproc(ii,ict), |
577 | + & bias_wgt(ict) |
578 | n_ctr_str(n_ctr_found) = |
579 | & trim(adjustl(n_ctr_str(n_ctr_found)))//' ' |
580 | & //trim(adjustl(str_temp)) |
581 | @@ -2321,7 +2443,7 @@ |
582 | & trim(adjustl(n_ctr_str(n_ctr_found)))//' ' |
583 | & //trim(adjustl(procid)) |
584 | |
585 | - write (str_temp,'(i2,6(1x,d14.8),6(1x,i2),1x,i8,1x,d18.12)') |
586 | + write (str_temp,30) |
587 | & QCDpower(ict), |
588 | & (bjx(j,ict),j=1,2), |
589 | & (scales2(j,ict),j=1,3), |
590 | @@ -2332,7 +2454,8 @@ |
591 | & fks_i_d(nFKS(ict)), |
592 | & fks_j_d(nFKS(ict)), |
593 | & parton_pdg_uborn(fks_j_d(nFKS(ict)),ipr,ict), |
594 | - & parton_iproc(ipr,ict) |
595 | + & parton_iproc(ipr,ict), |
596 | + & bias_wgt(ict) |
597 | n_ctr_str(n_ctr_found) = |
598 | & trim(adjustl(n_ctr_str(n_ctr_found)))//' ' |
599 | & //trim(adjustl(str_temp)) |
600 | @@ -2340,6 +2463,8 @@ |
601 | |
602 | endif |
603 | enddo |
604 | + return |
605 | + 30 format(i2,6(1x,d14.8),6(1x,i2),1x,i8,1x,d18.12,1x,d18.12) |
606 | end |
607 | |
608 | |
609 | |
610 | === modified file 'Template/NLO/SubProcesses/reweight_xsec_events.f' |
611 | --- Template/NLO/SubProcesses/reweight_xsec_events.f 2017-06-15 16:22:23 +0000 |
612 | +++ Template/NLO/SubProcesses/reweight_xsec_events.f 2017-08-07 21:43:30 +0000 |
613 | @@ -394,7 +394,7 @@ |
614 | read(n_ctr_str(i),*)(wgt(j,i),j=1,3),(wgt_ME_tree(j,i),j=1,2) |
615 | & ,idum,(pdg(j,i),j=1,nexternal),QCDpower(i),(bjx(j,i),j=1 |
616 | & ,2),(scales2(j,i),j=1,3),g_strong(i),(momenta_conf(j),j=1 |
617 | - & ,2),itype(i),nFKS(i),idum,idum,idum,wgts(1,i) |
618 | + & ,2),itype(i),nFKS(i),idum,idum,idum,wgts(1,i),bias_wgt(i) |
619 | do ii=1,2 |
620 | do j=1,nexternal |
621 | do k=0,3 |
622 | |
623 | === modified file 'Template/NLO/SubProcesses/symmetry_fks_v3.f' |
624 | --- Template/NLO/SubProcesses/symmetry_fks_v3.f 2017-06-16 14:41:09 +0000 |
625 | +++ Template/NLO/SubProcesses/symmetry_fks_v3.f 2017-08-07 21:43:30 +0000 |
626 | @@ -313,12 +313,13 @@ |
627 | RETURN |
628 | END |
629 | |
630 | - subroutine unweight_function(p_born,unwgtfun) |
631 | + subroutine bias_weight_function(p,ipdg,bias_wgt) |
632 | c Dummy function. Should always retrun 1. |
633 | implicit none |
634 | include 'nexternal.inc' |
635 | - double precision unwgtfun,p_born(0:3,nexternal-1) |
636 | - unwgtfun=1d0 |
637 | + integer ipdg(nexternal) |
638 | + double precision bias_wgt,p(0:3,nexternal) |
639 | + bias_wgt=1d0 |
640 | return |
641 | end |
642 | |
643 | |
644 | === modified file 'Template/NLO/SubProcesses/weight_lines.f' |
645 | --- Template/NLO/SubProcesses/weight_lines.f 2017-06-13 17:00:25 +0000 |
646 | +++ Template/NLO/SubProcesses/weight_lines.f 2017-08-07 21:43:30 +0000 |
647 | @@ -11,7 +11,7 @@ |
648 | double precision, allocatable :: momenta(:,:,:),momenta_m(:,:,: |
649 | $ ,:),wgt(:,:),wgt_ME_tree(:,:),bjx(:,:),scales2(:,:) |
650 | $ ,g_strong(:),wgts(:,:),parton_iproc(:,:),y_bst(:) |
651 | - $ ,plot_wgts(:,:),shower_scale(:),unwgt(:,:) |
652 | + $ ,plot_wgts(:,:),shower_scale(:),unwgt(:,:),bias_wgt(:) |
653 | save |
654 | end module weight_lines |
655 | |
656 | @@ -157,6 +157,10 @@ |
657 | allocate(temp1(n_contr)) |
658 | temp1(1:max_contr)=y_bst |
659 | call move_alloc(temp1,y_bst) |
660 | +c bias_wgt |
661 | + allocate(temp1(n_contr)) |
662 | + temp1(1:max_contr)=bias_wgt |
663 | + call move_alloc(temp1,bias_wgt) |
664 | c plot_wgts |
665 | allocate(temp2(max_wgt,n_contr)) |
666 | temp2(1:max_wgt,1:max_contr)=plot_wgts |
667 | @@ -201,6 +205,7 @@ |
668 | allocate(wgts(1,1)) |
669 | allocate(parton_iproc(1,1)) |
670 | allocate(y_bst(1)) |
671 | + allocate(bias_wgt(1)) |
672 | allocate(plot_wgts(1,1)) |
673 | allocate(shower_scale(1)) |
674 | allocate(unwgt(1,1)) |
675 | @@ -238,6 +243,7 @@ |
676 | if (allocated(wgts)) deallocate(wgts) |
677 | if (allocated(parton_iproc)) deallocate(parton_iproc) |
678 | if (allocated(y_bst)) deallocate(y_bst) |
679 | + if (allocated(bias_wgt)) deallocate(bias_wgt) |
680 | if (allocated(plot_wgts)) deallocate(plot_wgts) |
681 | if (allocated(shower_scale)) deallocate(shower_scale) |
682 | if (allocated(unwgt)) deallocate(unwgt) |
683 | |
684 | === modified file 'Template/NLO/SubProcesses/write_event.f' |
685 | --- Template/NLO/SubProcesses/write_event.f 2017-06-16 08:20:04 +0000 |
686 | +++ Template/NLO/SubProcesses/write_event.f 2017-08-07 21:43:30 +0000 |
687 | @@ -13,7 +13,7 @@ |
688 | integer i,j,lunlhe |
689 | real*8 xx(ndimmax),weight,evnt_wgt |
690 | logical putonshell |
691 | - double precision wgt,unwgtfun |
692 | + double precision wgt |
693 | double precision x(99),p(0:3,nexternal) |
694 | integer jpart(7,-nexternal+3:2*nexternal-3) |
695 | double precision pb(0:4,-nexternal+3:2*nexternal-3) |
696 | @@ -82,14 +82,6 @@ |
697 | call add_write_info(p_born,p,ybst_til_tolab,iconfig,Hevents, |
698 | & putonshell,ndim,x,jpart,npart,pb,shower_scale) |
699 | |
700 | - call unweight_function(p_born,unwgtfun) |
701 | - if (unwgtfun.ne.0d0) then |
702 | - evnt_wgt=evnt_wgt/unwgtfun |
703 | - else |
704 | - write (*,*) 'ERROR in finalize_event, unwgtfun=0',unwgtfun |
705 | - stop |
706 | - endif |
707 | - |
708 | c Write-out the events |
709 | call write_events_lhe(pb(0,1),evnt_wgt,jpart(1,1),npart,lunlhe |
710 | $ ,shower_scale,ickkw) |
711 | |
712 | === modified file 'Template/NLO/Utilities/check_events.f' |
713 | --- Template/NLO/Utilities/check_events.f 2014-02-19 09:46:05 +0000 |
714 | +++ Template/NLO/Utilities/check_events.f 2017-08-07 21:43:30 +0000 |
715 | @@ -6,10 +6,12 @@ |
716 | c With some work on finalizeprocesses(), it should work also for |
717 | c LH files created by Herwig, assuming they are identified by a |
718 | c negative number of events |
719 | + use extra_weights |
720 | implicit none |
721 | integer maxevt,ifile,efile,mfile,jfile,kfile,rfile,i,npart, |
722 | # iuseres_1,iwhmass,ilepmass,idec,itempsc,itempPDF,isavesc, |
723 | # isavePDF,itemp,ii |
724 | + integer numscales,numPDFpairs,numPDFs |
725 | double precision chtot,xint,xinterr,xinta,xintaerr,qtiny |
726 | parameter (qtiny=1.d-4) |
727 | double precision charges(-100:100),zmasses(1:100) |
728 | @@ -42,7 +44,8 @@ |
729 | double precision wgt3a,wgt3s |
730 | double precision wgt4a,wgt4s |
731 | double precision wgt5a,wgt5s |
732 | - double precision saved_weight,tmp |
733 | + double precision saved_weight,tmp,wmin,wmax,wlim |
734 | + integer ipos,ineg |
735 | character*80 event_file |
736 | character*140 buff |
737 | character*6 ch6 |
738 | @@ -59,14 +62,14 @@ |
739 | integer j,k |
740 | real*8 ecm,xmass(3*nexternal),xmom(0:3,3*nexternal),xnorm |
741 | |
742 | - include 'reweight0.inc' |
743 | - integer kr,kf,kpdf |
744 | - double precision sum_wgt_resc_scale(maxscales,maxscales), |
745 | - # sum_wgt_resc_pdf(0:maxPDFs), |
746 | - # xmax_wgt_resc_scale(maxscales,maxscales), |
747 | - # xmax_wgt_resc_pdf(0:maxPDFs), |
748 | - # xmin_wgt_resc_scale(maxscales,maxscales), |
749 | - # xmin_wgt_resc_pdf(0:maxPDFs) |
750 | + integer kk,kr,kf,kpdf |
751 | + double precision |
752 | + # sum_wgt_resc_scale(maxscales,maxscales,maxdynscales), |
753 | + # sum_wgt_resc_pdf(0:maxPDFs,maxPDFsets), |
754 | + # xmax_wgt_resc_scale(maxscales,maxscales,maxdynscales), |
755 | + # xmax_wgt_resc_pdf(0:maxPDFs,maxPDFsets), |
756 | + # xmin_wgt_resc_scale(maxscales,maxscales,maxdynscales), |
757 | + # xmin_wgt_resc_pdf(0:maxPDFs,maxPDFsets) |
758 | integer istep |
759 | double precision percentage |
760 | include 'dbook.inc' |
761 | @@ -144,6 +147,8 @@ |
762 | unweighted=.true. |
763 | keepevent=.true. |
764 | shower=.false. |
765 | + wmax=-1.d100 |
766 | + wmin=1.d100 |
767 | |
768 | call read_lhef_header_full(ifile,maxevt,itempsc,itempPDF, |
769 | # MonteCarlo) |
770 | @@ -220,7 +225,7 @@ |
771 | & XSECUP,XERRUP,XMAXUP,LPRUP) |
772 | |
773 | |
774 | - do i=1,min(10,maxevt) |
775 | + do i=1,min(100,maxevt) |
776 | call read_lhef_event_catch(ifile, |
777 | & NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP, |
778 | & IDUP,ISTUP,MOTHUP,ICOLUP,PUP,VTIMUP,SPINUP,buff) |
779 | @@ -247,10 +252,12 @@ |
780 | write(*,*)'Inconsistency #2 in event file',i,' ',buff |
781 | stop |
782 | endif |
783 | - unweighted=unweighted.and. |
784 | + unweighted=unweighted.and. |
785 | # abs(1.d0-abs(XWGTUP)/saved_weight).lt.1.d-5 |
786 | endif |
787 | endif |
788 | + wmax=max(wmax,XWGTUP) |
789 | + wmin=min(wmin,XWGTUP) |
790 | if(idec.eq.0)call findmothers(NUP,IDUP,ISTUP) |
791 | |
792 | enddo |
793 | @@ -263,6 +270,11 @@ |
794 | write(*,*)'The events appear to be unweighted' |
795 | else |
796 | write(*,*)'The events appear to be weighted' |
797 | + if(event_norm.eq.'ave'.or.event_norm.eq.'bia')then |
798 | + wmax=wmax/maxevt |
799 | + wmin=wmin/maxevt |
800 | + endif |
801 | + wlim=max(abs(wmax),abs(wmin)) |
802 | endif |
803 | |
804 | if(rwgtinfo)then |
805 | @@ -304,25 +316,40 @@ |
806 | itoterr=0 |
807 | mtoterr=0 |
808 | if(jwgtinfo.eq.8.or.jwgtinfo.eq.9)then |
809 | - do kr=1,maxscales |
810 | - do kf=1,maxscales |
811 | - sum_wgt_resc_scale(kr,kf)=0.d0 |
812 | - xmax_wgt_resc_scale(kr,kf)=-1.d100 |
813 | - xmin_wgt_resc_scale(kr,kf)=1.d100 |
814 | + do kk=1,maxdynscales |
815 | + do kr=1,maxscales |
816 | + do kf=1,maxscales |
817 | + sum_wgt_resc_scale(kr,kf,kk)=0.d0 |
818 | + xmax_wgt_resc_scale(kr,kf,kk)=-1.d100 |
819 | + xmin_wgt_resc_scale(kr,kf,kk)=1.d100 |
820 | + enddo |
821 | enddo |
822 | enddo |
823 | - do kpdf=0,maxPDFs |
824 | - sum_wgt_resc_pdf(kpdf)=0.d0 |
825 | - xmax_wgt_resc_pdf(kpdf)=-1.d100 |
826 | - xmin_wgt_resc_pdf(kpdf)=1.d100 |
827 | + do kk=1,maxPDFsets |
828 | + do kpdf=0,maxPDFs |
829 | + sum_wgt_resc_pdf(kpdf,kk)=0.d0 |
830 | + xmax_wgt_resc_pdf(kpdf,kk)=-1.d100 |
831 | + xmin_wgt_resc_pdf(kpdf,kk)=1.d100 |
832 | + enddo |
833 | enddo |
834 | endif |
835 | |
836 | i=0 |
837 | + ipos=0 |
838 | + ineg=0 |
839 | call inihist |
840 | call bookup(1,'scalup',2d0,0d0,200d0) |
841 | call bookup(2,'scalup',8d0,0d0,800d0) |
842 | call bookup(3,'log scalup',0.1d0,0d0,4d0) |
843 | + if(.not.unweighted)then |
844 | + tmp=2*wlim/100.d0 |
845 | + call bookup(4,'weight',tmp,-wlim,wlim) |
846 | + tmp=4*wlim/100.d0 |
847 | + call bookup(5,'weight',tmp,-2*wlim,2*wlim) |
848 | + tmp=8*wlim/100.d0 |
849 | + call bookup(6,'weight',tmp,-4*wlim,4*wlim) |
850 | + endif |
851 | + |
852 | dowhile(i.lt.maxevt.and.keepevent) |
853 | call read_lhef_event_catch(ifile, |
854 | & NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP, |
855 | @@ -330,6 +357,17 @@ |
856 | call mfill(1,SCALUP,XWGTUP) |
857 | call mfill(2,SCALUP,XWGTUP) |
858 | if(SCALUP.gt.0d0)call mfill(3,log10(SCALUP),XWGTUP) |
859 | + if(.not.unweighted)then |
860 | + if(event_norm.eq.'ave'.or.event_norm.eq.'bia')then |
861 | + call mfill(4,XWGTUP/maxevt,abs(XWGTUP)) |
862 | + call mfill(5,XWGTUP/maxevt,abs(XWGTUP)) |
863 | + call mfill(6,XWGTUP/maxevt,abs(XWGTUP)) |
864 | + else |
865 | + call mfill(4,XWGTUP,abs(XWGTUP)) |
866 | + call mfill(5,XWGTUP,abs(XWGTUP)) |
867 | + call mfill(6,XWGTUP,abs(XWGTUP)) |
868 | + endif |
869 | + endif |
870 | if(index(buff,'endoffile').ne.0)then |
871 | keepevent=.false. |
872 | goto 111 |
873 | @@ -338,32 +376,41 @@ |
874 | i=i+1 |
875 | sum_wgt=sum_wgt+XWGTUP |
876 | sum_abs_wgt=sum_abs_wgt+abs(XWGTUP) |
877 | + if(sign(1.d0,XWGTUP).gt.0.d0)then |
878 | + ipos=ipos+1 |
879 | + else |
880 | + ineg=ineg+1 |
881 | + endif |
882 | |
883 | c Note: with pre-beta2 convention, the reweighting cross sections were |
884 | c normalized such that one needed to compute e.g. |
885 | c XWGTUP*wgtxsecmu(kr,kf)/wgtref |
886 | if(jwgtinfo.eq.8.or.jwgtinfo.eq.9)then |
887 | - do kr=1,numscales |
888 | - do kf=1,numscales |
889 | - sum_wgt_resc_scale(kr,kf)=sum_wgt_resc_scale(kr,kf)+ |
890 | - # wgtxsecmu(kr,kf) |
891 | - xmax_wgt_resc_scale(kr,kf)= |
892 | - # max(xmax_wgt_resc_scale(kr,kf), |
893 | - # wgtxsecmu(kr,kf)) |
894 | - xmin_wgt_resc_scale(kr,kf)= |
895 | - # min(xmin_wgt_resc_scale(kr,kf), |
896 | - # wgtxsecmu(kr,kf)) |
897 | + do kk=1,dyn_scale(0) |
898 | + do kr=1,numscales |
899 | + do kf=1,numscales |
900 | + sum_wgt_resc_scale(kr,kf,kk)= |
901 | + # sum_wgt_resc_scale(kr,kf,kk)+wgtxsecmu(kr,kf,kk) |
902 | + xmax_wgt_resc_scale(kr,kf,kk)= |
903 | + # max(xmax_wgt_resc_scale(kr,kf,kk), |
904 | + # wgtxsecmu(kr,kf,kk)) |
905 | + xmin_wgt_resc_scale(kr,kf,kk)= |
906 | + # min(xmin_wgt_resc_scale(kr,kf,kk), |
907 | + # wgtxsecmu(kr,kf,kk)) |
908 | + enddo |
909 | enddo |
910 | enddo |
911 | - do kpdf=1,2*numPDFpairs |
912 | - sum_wgt_resc_pdf(kpdf)=sum_wgt_resc_pdf(kpdf)+ |
913 | - # wgtxsecPDF(kpdf) |
914 | - xmax_wgt_resc_pdf(kpdf)= |
915 | - # max(xmax_wgt_resc_pdf(kpdf), |
916 | - # wgtxsecPDF(kpdf)) |
917 | - xmin_wgt_resc_pdf(kpdf)= |
918 | - # min(xmin_wgt_resc_pdf(kpdf), |
919 | - # wgtxsecPDF(kpdf)) |
920 | + do kk=1,lhaPDFid(0) |
921 | + do kpdf=1,2*numPDFpairs |
922 | + sum_wgt_resc_pdf(kpdf,kk)=sum_wgt_resc_pdf(kpdf,kk)+ |
923 | + # wgtxsecPDF(kpdf,kk) |
924 | + xmax_wgt_resc_pdf(kpdf,kk)= |
925 | + # max(xmax_wgt_resc_pdf(kpdf,kk), |
926 | + # wgtxsecPDF(kpdf,kk)) |
927 | + xmin_wgt_resc_pdf(kpdf,kk)= |
928 | + # min(xmin_wgt_resc_pdf(kpdf,kk), |
929 | + # wgtxsecPDF(kpdf,kk)) |
930 | + enddo |
931 | enddo |
932 | endif |
933 | |
934 | @@ -476,18 +523,20 @@ |
935 | tmp=wgtcentral/XWGTUP |
936 | wgt1a=wgt1a+tmp |
937 | wgt1s=wgt1s+tmp**2 |
938 | - tmp=wgtmumin/wgtcentral |
939 | - wgt2a=wgt2a+tmp |
940 | - wgt2s=wgt2s+tmp**2 |
941 | - tmp=wgtmumax/wgtcentral |
942 | - wgt3a=wgt3a+tmp |
943 | - wgt3s=wgt3s+tmp**2 |
944 | - tmp=wgtpdfmin/wgtcentral |
945 | - wgt4a=wgt4a+tmp |
946 | - wgt4s=wgt4s+tmp**2 |
947 | - tmp=wgtpdfmax/wgtcentral |
948 | - wgt5a=wgt5a+tmp |
949 | - wgt5s=wgt5s+tmp**2 |
950 | + if(wgtcentral.ne.0.d0)then |
951 | + tmp=wgtmumin/wgtcentral |
952 | + wgt2a=wgt2a+tmp |
953 | + wgt2s=wgt2s+tmp**2 |
954 | + tmp=wgtmumax/wgtcentral |
955 | + wgt3a=wgt3a+tmp |
956 | + wgt3s=wgt3s+tmp**2 |
957 | + tmp=wgtpdfmin/wgtcentral |
958 | + wgt4a=wgt4a+tmp |
959 | + wgt4s=wgt4s+tmp**2 |
960 | + tmp=wgtpdfmax/wgtcentral |
961 | + wgt5a=wgt5a+tmp |
962 | + wgt5s=wgt5s+tmp**2 |
963 | + endif |
964 | endif |
965 | endif |
966 | |
967 | @@ -505,6 +554,11 @@ |
968 | 111 continue |
969 | enddo |
970 | |
971 | + if(maxevt.ne.(ipos+ineg))then |
972 | + write(*,*)'Something wrong with counting events:', |
973 | + # maxevt,ipos,ineg |
974 | + endif |
975 | + |
976 | open(unit=99,file='SCALUP.top',status='unknown') |
977 | call mclear |
978 | xnorm=1d0 |
979 | @@ -515,13 +569,19 @@ |
980 | call multitop(1,3,2,'scalup ',' ','LOG') |
981 | call multitop(2,3,2,'scalup ',' ','LOG') |
982 | call multitop(3,3,2,'log scalup',' ','LOG') |
983 | + call multitop(4,3,2,'weight ',' ','LOG') |
984 | + call multitop(5,3,2,'weight ',' ','LOG') |
985 | + call multitop(6,3,2,'weight ',' ','LOG') |
986 | close(99) |
987 | |
988 | - if(event_norm.eq.'ave')sum_wgt=sum_wgt/maxevt |
989 | - if(event_norm.eq.'ave')sum_abs_wgt=sum_abs_wgt/maxevt |
990 | + if(event_norm.eq.'ave'.or.event_norm.eq.'bia') |
991 | + # sum_wgt=sum_wgt/maxevt |
992 | + if(event_norm.eq.'ave'.or.event_norm.eq.'bia') |
993 | + # sum_abs_wgt=sum_abs_wgt/maxevt |
994 | err_wgt=sum_abs_wgt/sqrt(dfloat(maxevt)) |
995 | write(*,*)' ' |
996 | write (*,*) 'The total number of events is:',i |
997 | + write (*,*) ' of which:',ipos,' w>0',ineg,' w<0' |
998 | write (*,*) 'Sum of weights is :',sum_wgt,' +-',err_wgt |
999 | write (*,*) 'Sum of abs weights is:',sum_abs_wgt,' +-',err_wgt |
1000 | |
1001 | @@ -586,56 +646,68 @@ |
1002 | if(jwgtinfo.eq.8.or.jwgtinfo.eq.9)then |
1003 | write(64,*)' ' |
1004 | write(64,*)'Sums of rescaled weights' |
1005 | - do kr=1,numscales |
1006 | - do kf=1,numscales |
1007 | - if(event_norm.eq.'ave')then |
1008 | - write(64,300)'scales',kr,kf,' ->', |
1009 | - # sum_wgt_resc_scale(kr,kf)/maxevt |
1010 | - else |
1011 | - write(64,300)'scales',kr,kf,' ->', |
1012 | - # sum_wgt_resc_scale(kr,kf) |
1013 | - endif |
1014 | + do kk=1,dyn_scale(0) |
1015 | + do kr=1,numscales |
1016 | + do kf=1,numscales |
1017 | + if(event_norm.eq.'ave'.or.event_norm.eq.'bia')then |
1018 | + write(64,300)'scales',kk,kr,kf,' ->', |
1019 | + # sum_wgt_resc_scale(kr,kf,kk)/maxevt |
1020 | + else |
1021 | + write(64,300)'scales',kk,kr,kf,' ->', |
1022 | + # sum_wgt_resc_scale(kr,kf,kk) |
1023 | + endif |
1024 | + enddo |
1025 | enddo |
1026 | enddo |
1027 | - if(event_norm.eq.'ave')then |
1028 | - do kpdf=1,2*numPDFpairs |
1029 | - write(64,301)'PDF',kpdf,' ->', |
1030 | - # sum_wgt_resc_pdf(kpdf)/maxevt |
1031 | + if(event_norm.eq.'ave'.or.event_norm.eq.'bia')then |
1032 | + do kk=1,lhaPDFid(0) |
1033 | + do kpdf=1,2*numPDFpairs |
1034 | + write(64,301)'PDF',kk,kpdf,' ->', |
1035 | + # sum_wgt_resc_pdf(kpdf,kk)/maxevt |
1036 | + enddo |
1037 | enddo |
1038 | else |
1039 | - do kpdf=1,2*numPDFpairs |
1040 | - write(64,301)'PDF',kpdf,' ->', |
1041 | - # sum_wgt_resc_pdf(kpdf) |
1042 | + do kk=1,lhaPDFid(0) |
1043 | + do kpdf=1,2*numPDFpairs |
1044 | + write(64,301)'PDF',kk,kpdf,' ->', |
1045 | + # sum_wgt_resc_pdf(kpdf,kk) |
1046 | + enddo |
1047 | enddo |
1048 | endif |
1049 | endif |
1050 | if(jwgtinfo.eq.8.or.jwgtinfo.eq.9)then |
1051 | write(64,*)' ' |
1052 | write(64,*)'Max and min of rescaled weights' |
1053 | - do kr=1,numscales |
1054 | - do kf=1,numscales |
1055 | - if(event_norm.eq.'ave')then |
1056 | - write(64,400)'scales',kr,kf,' ->', |
1057 | - # xmax_wgt_resc_scale(kr,kf), |
1058 | - # xmin_wgt_resc_scale(kr,kf) |
1059 | - else |
1060 | - write(64,400)'scales',kr,kf,' ->', |
1061 | - # xmax_wgt_resc_scale(kr,kf), |
1062 | - # xmin_wgt_resc_scale(kr,kf) |
1063 | - endif |
1064 | + do kk=1,dyn_scale(0) |
1065 | + do kr=1,numscales |
1066 | + do kf=1,numscales |
1067 | + if(event_norm.eq.'ave'.or.event_norm.eq.'bia')then |
1068 | + write(64,400)'scales',kk,kr,kf,' ->', |
1069 | + # xmax_wgt_resc_scale(kr,kf,kk)/maxevt, |
1070 | + # xmin_wgt_resc_scale(kr,kf,kk)/maxevt |
1071 | + else |
1072 | + write(64,400)'scales',kk,kr,kf,' ->', |
1073 | + # xmax_wgt_resc_scale(kr,kf,kk), |
1074 | + # xmin_wgt_resc_scale(kr,kf,kk) |
1075 | + endif |
1076 | + enddo |
1077 | enddo |
1078 | enddo |
1079 | - if(event_norm.eq.'ave')then |
1080 | - do kpdf=1,2*numPDFpairs |
1081 | - write(64,401)'PDF',kpdf,' ->', |
1082 | - # xmax_wgt_resc_pdf(kpdf), |
1083 | - # xmin_wgt_resc_pdf(kpdf) |
1084 | + if(event_norm.eq.'ave'.or.event_norm.eq.'bia')then |
1085 | + do kk=1,lhaPDFid(0) |
1086 | + do kpdf=1,2*numPDFpairs |
1087 | + write(64,401)'PDF',kk,kpdf,' ->', |
1088 | + # xmax_wgt_resc_pdf(kpdf,kk)/maxevt, |
1089 | + # xmin_wgt_resc_pdf(kpdf,kk)/maxevt |
1090 | + enddo |
1091 | enddo |
1092 | else |
1093 | + do kk=1,lhaPDFid(0) |
1094 | do kpdf=1,2*numPDFpairs |
1095 | - write(64,401)'PDF',kpdf,' ->', |
1096 | - # xmax_wgt_resc_pdf(kpdf), |
1097 | - # xmin_wgt_resc_pdf(kpdf) |
1098 | + write(64,401)'PDF',kk,kpdf,' ->', |
1099 | + # xmax_wgt_resc_pdf(kpdf,kk), |
1100 | + # xmin_wgt_resc_pdf(kpdf,kk) |
1101 | + enddo |
1102 | enddo |
1103 | endif |
1104 | endif |
1105 | @@ -655,10 +727,10 @@ |
1106 | |
1107 | if(idec.eq.0)call finalizedecays() |
1108 | |
1109 | - 300 format(a,2(1x,i2),a,(1x,f16.6)) |
1110 | - 301 format(a,6x,i3,a,(1x,f16.6)) |
1111 | - 400 format(a,2(1x,i2),a,2(1x,f16.6)) |
1112 | - 401 format(a,6x,i3,a,2(1x,f16.6)) |
1113 | + 300 format(a,3(1x,i2),a,(1x,f16.6)) |
1114 | + 301 format(a,6x,i2,i3,a,(1x,f16.6)) |
1115 | + 400 format(a,3(1x,i2),a,2(1x,f16.6)) |
1116 | + 401 format(a,6x,i2,i3,a,2(1x,f16.6)) |
1117 | |
1118 | end |
1119 | |
1120 | |
1121 | === added symlink 'Template/NLO/Utilities/extra_weights.f' |
1122 | === target is u'../Source/extra_weights.f' |
1123 | === modified file 'Template/NLO/Utilities/makefile' |
1124 | --- Template/NLO/Utilities/makefile 2014-10-31 10:50:31 +0000 |
1125 | +++ Template/NLO/Utilities/makefile 2017-08-07 21:43:30 +0000 |
1126 | @@ -2,8 +2,9 @@ |
1127 | P01=$(shell echo $(P0) | cut -d'/' -f3) |
1128 | |
1129 | INCLUDE=-I../SubProcesses/$(P01) |
1130 | -FF=gfortran -g -fno-automatic -ffixed-line-length-132 $(INCLUDE) |
1131 | -FILES=handling_lhe_events.o fill_MC_mshell.o |
1132 | +EXTRAW=-I../Source |
1133 | +FF=gfortran -g -fno-automatic -ffixed-line-length-132 $(INCLUDE) $(EXTRAW) |
1134 | +FILES=handling_lhe_events.o fill_MC_mshell.o extra_weights.o |
1135 | FILES2=madfks_plot.o dbook.o setcuts.o analysis_td_template.o \ |
1136 | open_output_files.o open_output_files_dummy.o appl_interface_dummy.o |
1137 | |
1138 | |
1139 | === modified file 'UpdateNotes.txt' |
1140 | --- UpdateNotes.txt 2017-08-04 23:05:05 +0000 |
1141 | +++ UpdateNotes.txt 2017-08-07 21:43:30 +0000 |
1142 | @@ -16,7 +16,11 @@ |
1143 | RF: Fixed bug #1706072 related to wrong path with NLO gridpack mode |
1144 | diagrams with 1->3 decays. |
1145 | RF: Refactor of the (NLO) code related to extra weights (for PDF/scale uncertainties). |
1146 | +<<<<<<< TREE |
1147 | RF: Fixed a bug (found by SF) that gave a seriously biased resonance mass when using MadSpin for decaying a 2->1 process. |
1148 | +======= |
1149 | + RF+OM: Added the possibility to also have a bias-function for event generation at (f)NLO(+PS) |
1150 | +>>>>>>> MERGE-SOURCE |
1151 | |
1152 | 2.5.5(26/05/17) |
1153 | OM: Fixing bug in the creation of the LO gridpack introduced in 2.4.3. Since 2.4.3 the generated |
1154 | |
1155 | === modified file 'madgraph/interface/amcatnlo_run_interface.py' |
1156 | --- madgraph/interface/amcatnlo_run_interface.py 2017-08-05 18:44:21 +0000 |
1157 | +++ madgraph/interface/amcatnlo_run_interface.py 2017-08-07 21:43:30 +0000 |
1158 | @@ -1755,7 +1755,10 @@ |
1159 | """write the nevts files in the SubProcesses/P*/G*/ directories""" |
1160 | for job in jobs: |
1161 | with open(pjoin(job['dirname'],'nevts'),'w') as f: |
1162 | - f.write('%i\n' % job['nevents']) |
1163 | + if self.run_card['event_norm'].lower()=='bias': |
1164 | + f.write('%i %f\n' % (job['nevents'],self.cross_sect_dict['xseca'])) |
1165 | + else: |
1166 | + f.write('%i\n' % job['nevents']) |
1167 | |
1168 | def combine_split_order_run(self,jobs_to_run): |
1169 | """Combines jobs and grids from split jobs that have been run""" |
1170 | @@ -2579,6 +2582,8 @@ |
1171 | self.cross_sect_dict['unit']='pb' |
1172 | self.cross_sect_dict['xsec_string']='Total cross section' |
1173 | self.cross_sect_dict['axsec_string']='Total abs(cross section)' |
1174 | + if self.run_card['event_norm'].lower()=='bias': |
1175 | + self.cross_sect_dict['xsec_string']+=', incl. bias (DO NOT USE)' |
1176 | |
1177 | if mode in ['aMC@NLO', 'aMC@LO', 'noshower', 'noshowerLO']: |
1178 | status = ['Determining the number of unweighted events per channel', |
1179 | @@ -3165,6 +3170,8 @@ |
1180 | p.communicate(input = '1\n') |
1181 | elif event_norm.lower() == 'unity': |
1182 | p.communicate(input = '3\n') |
1183 | + elif event_norm.lower() == 'bias': |
1184 | + p.communicate(input = '0\n') |
1185 | else: |
1186 | p.communicate(input = '2\n') |
1187 | |
1188 | @@ -3576,7 +3583,7 @@ |
1189 | |
1190 | if self.banner.get('run_card', 'event_norm').lower() == 'sum': |
1191 | norm = 1. |
1192 | - elif self.banner.get('run_card', 'event_norm').lower() == 'average': |
1193 | + else: |
1194 | norm = 1./float(self.shower_card['nsplit_jobs']) |
1195 | |
1196 | plotfiles2 = [] |
1197 | @@ -3981,6 +3988,8 @@ |
1198 | # number of events is not 0 |
1199 | evt_files = [line.split()[0] for line in lines[:-1] if line.split()[1] != '0'] |
1200 | evt_wghts = [float(line.split()[3]) for line in lines[:-1] if line.split()[1] != '0'] |
1201 | + if self.run_card['event_norm'].lower()=='bias' and self.run_card['nevents'] != 0: |
1202 | + evt_wghts[:]=[wgt/float(self.run_card['nevents']) for wgt in evt_wghts] |
1203 | #prepare the job_dict |
1204 | job_dict = {} |
1205 | exe = 'reweight_xsec_events.local' |
1206 | |
1207 | === modified file 'madgraph/interface/common_run_interface.py' |
1208 | --- madgraph/interface/common_run_interface.py 2017-08-04 23:05:05 +0000 |
1209 | +++ madgraph/interface/common_run_interface.py 2017-08-07 21:43:30 +0000 |
1210 | @@ -1733,7 +1733,7 @@ |
1211 | key = tuple(float(x) for x in split[:-1]) |
1212 | cross= float(split[-1]) |
1213 | if 'event_norm' in self.run_card and \ |
1214 | - self.run_card['event_norm'] in ['average', 'unity']: |
1215 | + self.run_card['event_norm'] in ['average', 'unity', 'bias']: |
1216 | cross *= (event_per_job+1 if i <nb_job_with_plus_one else event_per_job) |
1217 | if len(all_cross) > pos: |
1218 | all_cross[pos] += cross |
1219 | @@ -1955,7 +1955,7 @@ |
1220 | raise Exception, "Some of the run failed: Please read %s_%s_debug.log" % (f, self.run_tag) |
1221 | |
1222 | |
1223 | - if 'event_norm' in self.run_card and self.run_card['event_norm'] == 'average': |
1224 | + if 'event_norm' in self.run_card and self.run_card['event_norm'] in ['average','bias']: |
1225 | for key, value in cross_sections.items(): |
1226 | cross_sections[key] = value / (nb_event+1) |
1227 | lhe.remove() |
1228 | |
1229 | === modified file 'madgraph/interface/reweight_interface.py' |
1230 | --- madgraph/interface/reweight_interface.py 2017-04-12 15:03:26 +0000 |
1231 | +++ madgraph/interface/reweight_interface.py 2017-08-07 21:43:30 +0000 |
1232 | @@ -717,7 +717,7 @@ |
1233 | |
1234 | # check normalisation of the events: |
1235 | if 'event_norm' in self.run_card: |
1236 | - if self.run_card['event_norm'] == 'average': |
1237 | + if self.run_card['event_norm'] in ['average','bias']: |
1238 | for key, value in cross.items(): |
1239 | cross[key] = value / (event_nb+1) |
1240 | |
1241 | |
1242 | === modified file 'madgraph/madevent/gen_crossxhtml.py' |
1243 | --- madgraph/madevent/gen_crossxhtml.py 2016-09-05 10:10:45 +0000 |
1244 | +++ madgraph/madevent/gen_crossxhtml.py 2017-08-07 21:43:30 +0000 |
1245 | @@ -750,6 +750,7 @@ |
1246 | # define at run_result |
1247 | self['run_name'] = run_name |
1248 | self['tag'] = run_card['run_tag'] |
1249 | + self['event_norm'] = run_card['event_norm'] |
1250 | self.event_path = pjoin(path,'Events') |
1251 | self.me_dir = path |
1252 | self.debug = None |
1253 | @@ -1336,7 +1337,7 @@ |
1254 | # Compute the text for eachsubpart |
1255 | |
1256 | sub_part_template_parton = """ |
1257 | - <td rowspan=%(cross_span)s><center><a href="./HTML/%(run)s/results.html"> %(cross).4g <font face=symbol>±</font> %(err).2g</a> %(syst)s </center></td> |
1258 | + <td rowspan=%(cross_span)s><center><a href="./HTML/%(run)s/results.html"> %(cross).4g <font face=symbol>±</font> %(err).2g %(bias)s</a> %(syst)s </center></td> |
1259 | <td rowspan=%(cross_span)s><center> %(nb_event)s<center></td><td> %(type)s </td> |
1260 | <td> %(links)s</td> |
1261 | <td> %(action)s</td> |
1262 | @@ -1411,6 +1412,10 @@ |
1263 | continue |
1264 | local_dico = {'type': ttype, 'run': self['run_name'], 'syst': '', |
1265 | 'tag': self['tag']} |
1266 | + if self['event_norm'].lower()=='bias': |
1267 | + local_dico['bias']='(biased, do not use)' |
1268 | + else: |
1269 | + local_dico['bias']='' |
1270 | |
1271 | if 'run_mode' in self.keys(): |
1272 | local_dico['run_mode'] = self['run_mode'] |
1273 | @@ -1545,7 +1550,8 @@ |
1274 | 'links': 'banner only', |
1275 | 'action': action, |
1276 | 'run_mode': '', |
1277 | - 'syst':'' |
1278 | + 'syst':'', |
1279 | + 'bias':'' |
1280 | } |
1281 | |
1282 | if self.debug is KeyboardInterrupt: |
1283 | |
1284 | === modified file 'madgraph/madevent/sum_html.py' |
1285 | --- madgraph/madevent/sum_html.py 2017-07-07 10:47:20 +0000 |
1286 | +++ madgraph/madevent/sum_html.py 2017-08-07 21:43:30 +0000 |
1287 | @@ -337,7 +337,7 @@ |
1288 | # this is for amcatnlo: the number of events has to be read from another file |
1289 | if self.nevents == 0 and self.nunwgt == 0 and isinstance(filepath, str) and \ |
1290 | os.path.exists(pjoin(os.path.split(filepath)[0], 'nevts')): |
1291 | - nevts = int(open(pjoin(os.path.split(filepath)[0], 'nevts')).read()) |
1292 | + nevts = int((open(pjoin(os.path.split(filepath)[0], 'nevts')).read()).split()[0]) |
1293 | self.nevents = nevts |
1294 | self.nunwgt = nevts |
1295 | |
1296 | |
1297 | === modified file 'madgraph/various/lhe_parser.py' |
1298 | --- madgraph/various/lhe_parser.py 2017-08-03 07:23:07 +0000 |
1299 | +++ madgraph/various/lhe_parser.py 2017-08-07 21:43:30 +0000 |
1300 | @@ -2236,8 +2236,9 @@ |
1301 | return out |
1302 | |
1303 | |
1304 | - def parse(self, text): |
1305 | - """parse the line and create the related object""" |
1306 | + def parse(self, text, keep_bias=False): |
1307 | + """parse the line and create the related object. |
1308 | + keep bias allow to not systematically correct for the bias in the written information""" |
1309 | #0.546601845792D+00 0.000000000000D+00 0.000000000000D+00 0.119210435309D+02 0.000000000000D+00 5 -1 2 -11 12 21 0 0.24546101D-01 0.15706890D-02 0.12586055D+04 0.12586055D+04 0.12586055D+04 1 2 2 2 5 2 2 0.539995789976D+04 |
1310 | #0.274922677249D+01 0.000000000000D+00 0.000000000000D+00 0.770516514633D+01 0.113763730192D+00 5 21 2 -11 12 1 2 0.52500539D-02 0.30205908D+00 0.45444066D+04 0.45444066D+04 0.45444066D+04 0.12520062D+01 1 2 1 3 5 1 -1 0.110944218997D+05 |
1311 | # below comment are from Rik description email |
1312 | @@ -2341,6 +2342,17 @@ |
1313 | # (and is passed to the integrator). It contains everything. |
1314 | # from example: 0.110944218997D+05 |
1315 | self.ref_wgt = float(data[flag+14]) |
1316 | + # 15. The bias weight. This weight is included in the self.ref_wgt, as well as in |
1317 | + # the self.pwgt. However, it is already removed from the XWGTUP (and |
1318 | + # scale/pdf weights). That means that in practice this weight is not used. |
1319 | + try: |
1320 | + self.bias_wgt = float(data[flag+15]) |
1321 | + except KeyError: |
1322 | + self.bias_wgt = 1.0 |
1323 | + |
1324 | + if not keep_bias: |
1325 | + self.ref_wgt /= self.bias_wgt |
1326 | + self.pwgt = [p/self.bias_wgt for p in self.pwgt] |
1327 | |
1328 | #check the momenta configuration linked to the event |
1329 | if self.type in self.real_type: |
1330 | |
1331 | === modified file 'madgraph/various/systematics.py' |
1332 | --- madgraph/various/systematics.py 2017-08-03 07:23:07 +0000 |
1333 | +++ madgraph/various/systematics.py 2017-08-07 21:43:30 +0000 |
1334 | @@ -81,7 +81,8 @@ |
1335 | self.force_write_banner = bool(write_banner) |
1336 | self.orig_dyn = self.banner.get('run_card', 'dynamical_scale_choice') |
1337 | self.orig_pdf = self.banner.run_card.get_lhapdf_id() |
1338 | - |
1339 | + matching_mode = self.banner.get('run_card', 'ickkw') |
1340 | + |
1341 | #check for beam |
1342 | beam1, beam2 = self.banner.get_pdg_beam() |
1343 | if abs(beam1) != 2212 and abs(beam2) != 2212: |
1344 | @@ -124,7 +125,13 @@ |
1345 | if isinstance(dyn, str): |
1346 | dyn = dyn.split(',') |
1347 | self.dyn=[int(i) for i in dyn] |
1348 | - |
1349 | + # For FxFx only mode -1 makes sense |
1350 | + if matching_mode == 3: |
1351 | + self.dyn = [-1] |
1352 | + # avoid sqrts at NLO if ISR is possible |
1353 | + if 4 in self.dyn and self.b1 and self.b2 and not self.is_lo: |
1354 | + self.dyn.remove(4) |
1355 | + |
1356 | if isinstance(together, str): |
1357 | self.together = together.split(',') |
1358 | else: |
1359 | @@ -375,7 +382,7 @@ |
1360 | |
1361 | if norm == 'sum': |
1362 | norm = 1 |
1363 | - elif norm == 'average': |
1364 | + elif norm in ['average', 'bias']: |
1365 | norm = 1./nb_event |
1366 | elif norm == 'unity': |
1367 | norm = 1 |
1368 | @@ -838,6 +845,7 @@ |
1369 | tmp *= wgtpdf |
1370 | wgt += tmp |
1371 | |
1372 | + |
1373 | if __debug__ and dyn== -1 and Dmur==1 and Dmuf==1 and pdf==self.orig_pdf: |
1374 | if not misc.equal(tmp, onewgt.ref_wgt, sig_fig=2): |
1375 | misc.sprint(tmp, onewgt.ref_wgt, (tmp-onewgt.ref_wgt)/tmp) |
1376 | @@ -846,7 +854,6 @@ |
1377 | misc.sprint(mur2,muf2) |
1378 | raise Exception, 'not enough agreement between stored value and computed one' |
1379 | |
1380 | - |
1381 | return wgt |
1382 | |
1383 |
Stefano already performed some tests, showing that it works as expected with 'normal' running. Things that need to be tested are including external modules, like MadSpin, or the REWEIGHT. Also, if you have a good suggestion for a unit/acceptance test, please consider implementing it.