# Bias Re-weighting in DY+Jets

Dear experts,

I have a question regarding the bias re-weighting. I want to produce a DY sample with a smooth mass tail up to masses of a few TeV for the excited lepton analysis in CMS. In order to avoid producing several mass-binned tail samples I want to use the bias re-weighting technique.

In the end I want to select events in the 2l2j final state and I need the NLO shape as the LO shape does not fit the observed spectrum well. For testing purposes I also tried the production at LO and I found issues even though different to the ones in NLO.

For LO I wrote a bias re-weighting module as explained in the wiki (https:/

C parameters = {'bias_

C 'bias_exponent': 4.29171,

C 'bias_switch': 1.73642d3,

C 'bias_exponential': 1.41843d-3,

C 'bias_cutoff': 1d4}

C

C -------

C BEGIN IMPLEMENTATION

C -------

do i=1,nexternal

if (is_a_l(i)) then

endif

enddo

mass = sqrt(sump(0)**2 - sump(1)**2 - sump(2)**2 - sump(3)**2)

if (mass.gt.

& exp((mass-

endif

return

If I generate p p > e- e+ I get a really nice mass spectrum which is smooth up to masses of ~10TeV. I can also add jets (p p > e- e+ j) and it still works fine. However, combining both processes into one job does not succeed:

generate p p > e+ e- j / h @0

add process p p > e+ e- j / h @1

I only get events containing zero jet and no events containing one jet. What am I doing wrong here? If I do not use my bias module everything works fine (i.e. I get a fraction of 0.175 containing one jet).

For NLO I use the same code in the cuts.f with the change of is_a_l(i) -> abs(ipdg(i)).eq.11 .or. abs(ipdg(i)).eq.13 .or. abs(ipdg(i)).eq.15.

Here, the production without jets works fine (generate p p > e+ e- [QCD]) and I get again a nice smooth spectrum. If I add a jet (generate p p > e+ e- j [QCD]) the generation fails "during the collection of results". It gives me two log files to check and in both log files I get the message:

Error 3 in kinematics_driver: negtive sqrt

It seems that after receiving this error 100 times the generation stops.

Concluding, it seems that my bias re-weighting code works fine for Drell-Yan without jets but have some issues when adding jets. Can you point me to the mistakes I am making and how a possible solution could look like. If needed I am happy to provide more code/files/

best and thank you,

Jonas

## Question information

- Language:
- English Edit question

- Status:
- Answered

- Assignee:
- Paolo Torrielli Edit question

- Last query:
- 2017-11-23

- Last reply:
- 2017-11-27

Hi,

Are you using the latest version of the code?

This reminds me an old bug which was occuring only in presence of matching/merging.

For NLO, are you sure that your bias is infrared save? This might be the problem.

Cheers,

Olivier

Jonas Roemer (jonasroemer) said : | #2 |

Hi,

Oh sorry, forgot to mention it. I am using madgraph in the version 2.6.0. I guess that is the latest version, right?

For NLO: I hoped that taking the invariant mass of the two leptons would be infrared safe. But I am sadly far from being a generator or theory expert so I am not entirely sure about it.

best,

Jonas

Jonas Roemer (jonasroemer) said : | #3 |

Hi,

I tested some things like adding a constant term in the sqrt of the mass calculation to see if that sqrt gets negative but it did not solve the problem add all.

Do you have an idea why it does not work?

best,

Jonas

when I print the bias_weight value from the function that you wrote, I have the following value:

4.4691152697

4.7975613598

5.1501265095

5.5285804658

5.9348227290

Note: The following floating-point exceptions are signalling: IEEE_OVERFLOW_FLAG

STOP 1

6.3708920579

6.8389766715

7.3414251970

7.8807584192

8.4596818903

9.0810994619

9.7481278074

1.0464112007

1.1232642276

1.2057571911

1.2943036553

One weird stuff is that such number are always increasing and so large.

Did you try to reset sump to 0 at the beginning of each call?

Cheers,

Olivier

> On Nov 6, 2017, at 12:44, Jonas Roemer <email address hidden> wrote:

>

> Question #660025 on MadGraph5_aMC@NLO changed:

> https:/

>

> Jonas Roemer posted a new comment:

> Hi,

>

> I tested some things like adding a constant term in the sqrt of the mass

> calculation to see if that sqrt gets negative but it did not solve the

> problem add all.

>

> Do you have an idea why it does not work?

>

> best,

> Jonas

>

> --

> You received this question notification because you are an answer

> contact for MadGraph5_aMC@NLO.

Jonas Roemer (jonasroemer) said : | #5 |

Hi Olivier,

Are these numbers from LO or NLO calculations. In fact, for LO, I did not set sump to 0 at the start, for NLO I fixed that in the meantime and set them to 0. I also added some debug output and found out a few things.

For LO: If I generate 0 jets and 1 jets (generate p p > e+ e- j / h @0, add process p p > e+ e- j / h @1) I find 2 leptons in the loop over all particles (do i=1,nexternal) for the process 0 (so the pp>ee) but 0 leptons for the process 1 (pp>eej). Also nexternals is 4 for the process 1 while it should be 5 (if i generate only pp>eej it is 5). Checking the SubProcesses/

For NLO: I print the weight and the mass every time the bias_weight_

I also calculated the expected range of weights. For 50GeV I would get 5.4e-07 and for 10TeV 5.0e8. At least after the addition of sump=0 this is also what I see in the debug output.

Thank You,

Jonas

Hi,

I did not test this for LO, since my understanding is that you had it working in that case.

But indeed have different multiplicity would be problematic.

I thought that the nexternal.inc in Source was suppose to be set to the maximal value to avoid such kind of issue.

I need to check this, but this is likely to fix the problem.

So do I understand correctly that your NLO bias is working now?

If not do you know which sqrt is not working? is it the one that you define in your bias function or another one?

Cheers,

Olivier

Jonas Roemer (jonasroemer) said : | #7 |

Hi,

It sadly failed again (every run takes several hours). I do not know which sqrt fails but it is definitely not the one in the bias weight function. So I guess it is some internal sqrt. I also see no clear correlation between the bias_weight/mass and the failure of a sqrt. It also happens rarely - most events are generated without error. If it helps I can send you the log file for one job that failed. I append the exact bias code I am using now:

subroutine bias_weight_

implicit none

include 'nexternal.inc'

double precision bias_wgt,

integer ipdg(nexternal),i

double precision sump(0:3)

double precision mass

double precision bias_normalization

double precision bias_exponent

double precision bias_switch

double precision bias_exponential

double precision bias_cutoff

logical do_mass

bias_

bias_

bias_

bias_

bias_

sump(0)=0d0

sump(1)=0d0

sump(2)=0d0

sump(3)=0d0

do_

do i=1,nexternal

if (abs(ipdg(i)).eq.11 .or. abs(ipdg(i)).eq.13 .or.

& abs(ipdg(i)).eq.15) then

endif

enddo

if (.not.do_mass) then

write(*,*) bias_wgt

return

endif

mass = sump(0)

if (mass.gt.0d0) then

else

mass=0d0

endif

bias_

if (mass.gt.

endif

write(*,*) bias_wgt, mass

return

end

Neither is do_mass false nor is mass=0d0 so both cases never seem to happen.

The commands to execute are:

generate p p > e+ e- j [QCD]

output DY_EE_1jhet_

launch

6 (madanalysis)

done

set event_norm bias

set mll_sf 50 (did not work without this as well)

set nevents 10000

done

Thank You,

Jonas

Looks like that the sqrt which goes negative is the one in mountecarlocoun

I will assign Paolo to this thread since he is the expert in counterterm.

Cheers,

Olivier

Jonas Roemer (jonasroemer) said : | #9 |

Hi,

I also looked in the last days into this issue again and I think I found a "fix" (run just completed yesterday evening). I now use pythia8 for showering (it was herwig before I guess since I did not change anything) and it went through without crashing. However, I was not able to check the distributions since madanalysis refuses to analyze the resulting lhe file.

I see the issue in the same file in the if(shower_

Thank You,

Jonas

Hi,

Depend actually of what the problem in that block is.

Paolo should be able to comment more (I hope)

Olivier

> On Nov 23, 2017, at 12:53, Jonas Roemer <email address hidden> wrote:

>

> Question #660025 on MadGraph5_aMC@NLO changed:

> https:/

>

> Jonas Roemer gave more information on the question:

> Hi,

>

> I also looked in the last days into this issue again and I think I found

> a "fix" (run just completed yesterday evening). I now use pythia8 for

> showering (it was herwig before I guess since I did not change anything)

> and it went through without crashing. However, I was not able to check

> the distributions since madanalysis refuses to analyze the resulting lhe

> file.

>

> I see the issue in the same file in the

> if(shower_

> switching to Pythia "fixed" the issue as the code is not called anymore.

> But I doubt that this is the desired solution for the problem.

>

> Thank You,

> Jonas

>

> --

> You received this question notification because you are an answer

> contact for MadGraph5_aMC@NLO.

Dear all,

as Olivier correctly pointed out, the error is caused by line 1469 in montecarlocount

Thanks.

Cheers.

Paolo

## Can you help with this problem?

Provide an answer of your own, or ask Jonas Roemer for more information if necessary.