rivet is hosted by Hepforge, IPPP Durham

Rivet analyses reference

ATLAS_2016_I1426523

Measurement of the $WZ$ production cross section at 8 TeV
Experiment: ATLAS (LHC)
Inspire ID: 1426523
Status: VALIDATED
Authors:
  • Elena Yatsenko
References: Beams: p+ p+
Beam energies: (4000.0, 4000.0) GeV
Run details:
  • pp -> WZ + X, diboson decays to electrons and muons

This paper presents measurements of $W^\pm Z$ production in pp collisions at a center-of-mass energy of 8 TeV. The gauge bosons are reconstructed using their leptonic decay modes into electrons and muons. The data were collected in 2012 by the ATLAS experiment at the Large Hadron Collider and correspond to an integrated luminosity of 20.3fb${}^{-1}$. The measured inclusive cross section in the detector fiducial region is $\sigma(W^\pm Z\to \ell^\prime\nu\ell\ell) = 35.1\pm 0.9$(stat)$\pm 0.8$(sys)$\pm 0.8$(lumi)fb, for one leptonic decay channel. In comparison, the next-to-leading-order Standard Model expectation is $30.0\pm 2.1$fb. Cross sections for $W^+ Z$ and $W^- Z$ production and their ratio are presented as well as differential cross sections for several kinematic observables. Limits on anomalous triple gauge boson couplings are derived from the transverse mass spectrum of the $W^\pm Z$ system. From the analysis of events with a $W$ and a $Z$ boson associated with two or more forward jets an upper limit at 95% confidence level on the $W^\pm Z$ scattering cross section of 0.63 fb, for each leptonic decay channel, is established, while the Standard Model prediction at next-to-leading order is $0.13\pm 0.01$fb. Limits on anomalous quartic gauge boson couplings are also extracted. For distributions that include the infinity symbol ($\infty$) on the horizontal axis, the last bin will include the events from the overflow bin. Users should note that explicit matching of lepton flavour between individual SM neutrinos and charged leptons is used in this analysis routine, to match the MC-based correction to the fiducial region applied in the paper. The data are therefore only valid under the assumption of the Standard Model and cannot be used for BSM reinterpretation.

Source code: ATLAS_2016_I1426523.cc
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
// -*- C++ -*-
#include "Rivet/Analysis.hh"
#include "Rivet/Projections/FinalState.hh"
#include "Rivet/Projections/FastJets.hh"
#include "Rivet/Projections/IdentifiedFinalState.hh"
#include "Rivet/Projections/PromptFinalState.hh"
#include "Rivet/Projections/DressedLeptons.hh"
#include "Rivet/Projections/VetoedFinalState.hh"

namespace Rivet {


  /// @brief Measurement of the WZ production cross section at 8 TeV
  class ATLAS_2016_I1426523 : public Analysis {
  public:

    /// Constructor
    DEFAULT_RIVET_ANALYSIS_CTOR(ATLAS_2016_I1426523);


    /// @name Analysis methods
    //@{

    /// Book histograms and initialise projections before the run
    void init() {

      // Lepton cuts
      Cut FS_Zlept = Cuts::abseta < 2.5 && Cuts::pT > 15*GeV;

      const FinalState fs;
      Cut fs_z = Cuts::abseta < 2.5 && Cuts::pT > 15*GeV;
      Cut fs_j = Cuts::abseta < 4.5 && Cuts::pT > 25*GeV;

      // Get photons to dress leptons
      PromptFinalState photons(Cuts::abspid == PID::PHOTON);

      // Electrons and muons in Fiducial PS
      PromptFinalState leptons(fs_z && (Cuts::abspid == PID::ELECTRON || Cuts::abspid == PID::MUON));
      leptons.acceptTauDecays(false);
      DressedLeptons dressedleptons(photons, leptons, 0.1, FS_Zlept, true);
      addProjection(dressedleptons, "DressedLeptons");

      // Electrons and muons in Total PS
      PromptFinalState leptons_total(Cuts::abspid == PID::ELECTRON || Cuts::abspid == PID::MUON);
      leptons_total.acceptTauDecays(false);
      DressedLeptons dressedleptonsTotal(photons, leptons_total, 0.1, Cuts::open(), true);
      addProjection(dressedleptonsTotal, "DressedLeptonsTotal");

      // Neutrinos
      IdentifiedFinalState nu_id;
      nu_id.acceptNeutrinos();
      PromptFinalState neutrinos(nu_id);
      neutrinos.acceptTauDecays(false);
      declare(neutrinos, "Neutrinos");
      MSG_WARNING("\033[91;1mLIMITED VALIDITY - check info file for details!\033[m");

      // Jets
      VetoedFinalState veto;
      veto.addVetoOnThisFinalState(dressedleptons);
      FastJets jets(veto, FastJets::ANTIKT, 0.4);
      declare(jets, "Jets");

      // Book histograms
      _h["eee"]        = bookHisto1D(1, 1, 1);
      _h["mee"]        = bookHisto1D(1, 1, 2);
      _h["emm"]        = bookHisto1D(1, 1, 3);
      _h["mmm"]        = bookHisto1D(1, 1, 4);
      _h["fid"]        = bookHisto1D(1, 1, 5);
      _h["eee_Plus"]   = bookHisto1D(2, 1, 1);
      _h["mee_Plus"]   = bookHisto1D(2, 1, 2);
      _h["emm_Plus"]   = bookHisto1D(2, 1, 3);
      _h["mmm_Plus"]   = bookHisto1D(2, 1, 4);
      _h["fid_Plus"]   = bookHisto1D(2, 1, 5);
      _h["eee_Minus"]  = bookHisto1D(3, 1, 1);
      _h["mee_Minus"]  = bookHisto1D(3, 1, 2);
      _h["emm_Minus"]  = bookHisto1D(3, 1, 3);
      _h["mmm_Minus"]  = bookHisto1D(3, 1, 4);
      _h["fid_Minus"]  = bookHisto1D(3, 1, 5);
      _h["total"]      = bookHisto1D(5, 1, 1);
      _h["Njets"]      = bookHisto1D(27, 1, 1);
      _h["Njets_norm"] = bookHisto1D(41, 1, 1);

      bookHandler("ZpT",	             12);
      bookHandler("ZpT_Plus",          13);
      bookHandler("ZpT_Minus",         14);
      bookHandler("WpT",	             15);
      bookHandler("WpT_Plus",          16);
      bookHandler("WpT_Minus",         17);
      bookHandler("mTWZ",              18);
      bookHandler("mTWZ_Plus",         19);
      bookHandler("mTWZ_Minus",        20);
      bookHandler("pTv",               21);
      bookHandler("pTv_Plus",          22);
      bookHandler("pTv_Minus",         23);
      bookHandler("Deltay",	           24);
      bookHandler("Deltay_Plus",       25);
      bookHandler("Deltay_Minus",      26);
      bookHandler("mjj",               28);
      bookHandler("Deltayjj",          29);
      bookHandler("ZpT_norm",          30);
      bookHandler("ZpT_Plus_norm",     31);
      bookHandler("ZpT_Minus_norm",    32);
      bookHandler("WpT_norm",          33);
      bookHandler("mTWZ_norm",         34);
      bookHandler("pTv_norm", 	       35);
      bookHandler("pTv_Plus_norm",	   36);
      bookHandler("pTv_Minus_norm",	   37);
      bookHandler("Deltay_norm",	     38);
      bookHandler("Deltay_Minus_norm", 39);
      bookHandler("Deltay_Plus_norm",  40);
      bookHandler("mjj_norm",          42);
      bookHandler("Deltayjj_norm",     43);
    }

    void bookHandler(const string& tag, size_t ID) {
      _s[tag] = bookScatter2D(ID, 1, 1);
      const string code1 = makeAxisCode(ID, 1, 1);
      const string code2 = makeAxisCode(ID, 1, 2);
      _h[tag] = bookHisto1D(code2, refData(code1));
    }


    /// Perform the per-event analysis
    void analyze(const Event& event) {

      /// @todo Do the event by event analysis here
      const double weight = event.weight();

      const vector<DressedLepton>& dressedleptons = apply<DressedLeptons>(event, "DressedLeptons").dressedLeptons();
      const vector<DressedLepton>& dressedleptonsTotal = apply<DressedLeptons>(event, "DressedLeptonsTotal").dressedLeptons();
      const Particles& neutrinos = apply<PromptFinalState>(event, "Neutrinos").particlesByPt();
      Jets jets = apply<JetAlg>(event, "Jets").jetsByPt( (Cuts::abseta < 4.5) && (Cuts::pT > 25*GeV) );

      if ((dressedleptonsTotal.size()<3) || (neutrinos.size()<1)) vetoEvent;

      //---Total PS: assign leptons to W and Z bosons using Resonant shape algorithm
      // NB: This resonant shape algorithm assumes the Standard Model and can therefore
      // NOT be used for reinterpretation in terms of new-physics models.

      int i, j, k;
      double MassZ01 = 0., MassZ02 = 0., MassZ12 = 0.;
      double MassW0 = 0., MassW1 = 0., MassW2 = 0.;
      double WeightZ1, WeightZ2, WeightZ3;
      double WeightW1, WeightW2, WeightW3;
      double M1, M2, M3;
      double WeightTotal1, WeightTotal2, WeightTotal3;

      //try Z pair of leptons 01
      if ( (dressedleptonsTotal[0].pid()==-(dressedleptonsTotal[1].pid())) && (dressedleptonsTotal[2].abspid()==neutrinos[0].abspid()-1)){
        MassZ01 = (dressedleptonsTotal[0].momentum()+dressedleptonsTotal[1].momentum()).mass();
        MassW2 = (dressedleptonsTotal[2].momentum()+neutrinos[0].momentum()).mass();
      }
      //try Z pair of leptons 02
      if ( (dressedleptonsTotal[0].pid()==-(dressedleptonsTotal[2].pid())) && (dressedleptonsTotal[1].abspid()==neutrinos[0].abspid()-1)){
        MassZ02 = (dressedleptonsTotal[0].momentum()+dressedleptonsTotal[2].momentum()).mass();
        MassW1 = (dressedleptonsTotal[1].momentum()+neutrinos[0].momentum()).mass();
      }
      //try Z pair of leptons 12
      if ( (dressedleptonsTotal[1].pid()==-(dressedleptonsTotal[2].pid())) && (dressedleptonsTotal[0].abspid()==neutrinos[0].abspid()-1)){
        MassZ12 = (dressedleptonsTotal[1].momentum()+dressedleptonsTotal[2].momentum()).mass();
        MassW0 = (dressedleptonsTotal[0].momentum()+neutrinos[0].momentum()).mass();
      }
      WeightZ1 = 1/(pow(MassZ01*MassZ01 - MZ_PDG*MZ_PDG,2) + pow(MZ_PDG*GammaZ_PDG,2));
      WeightW1 = 1/(pow(MassW2*MassW2 - MW_PDG*MW_PDG,2) + pow(MW_PDG*GammaW_PDG,2));
      WeightTotal1 = WeightZ1*WeightW1;
      M1 = -1*WeightTotal1;

      WeightZ2 = 1/(pow(MassZ02*MassZ02- MZ_PDG*MZ_PDG,2) + pow(MZ_PDG*GammaZ_PDG,2));
      WeightW2 = 1/(pow(MassW1*MassW1- MW_PDG*MW_PDG,2) + pow(MW_PDG*GammaW_PDG,2));
      WeightTotal2 = WeightZ2*WeightW2;
      M2 = -1*WeightTotal2;

      WeightZ3 = 1/(pow(MassZ12*MassZ12 - MZ_PDG*MZ_PDG,2) + pow(MZ_PDG*GammaZ_PDG,2));
      WeightW3 = 1/(pow(MassW0*MassW0 - MW_PDG*MW_PDG,2) + pow(MW_PDG*GammaW_PDG,2));
      WeightTotal3 = WeightZ3*WeightW3;
      M3 = -1*WeightTotal3;

      if( (M1 < M2 && M1 < M3) || (MassZ01 != 0 && MassW2 != 0 && MassZ02 == 0 && MassZ12 == 0) ){
        i = 0; j = 1; k = 2;
      }
      if( (M2 < M1 && M2 < M3) || (MassZ02 != 0 && MassW1 != 0 && MassZ01 == 0 && MassZ12 == 0) ){
        i = 0; j = 2; k = 1;
      }
      if( (M3 < M1 && M3 < M2) || (MassZ12 != 0 && MassW0 != 0 && MassZ01 == 0 && MassZ02 == 0) ){
        i = 1; j = 2; k = 0;
      }

      FourMomentum ZbosonTotal   = dressedleptonsTotal[i].momentum()+dressedleptonsTotal[j].momentum();

      if ( (ZbosonTotal.mass() >= 66*GeV) && (ZbosonTotal.mass() <= 116*GeV) ) _h["total"]->fill(8000, weight);

      //---end Total PS


      //---Fiducial PS: assign leptons to W and Z bosons using Resonant shape algorithm
      if (dressedleptons.size() < 3 || neutrinos.size() < 1)  vetoEvent;

      int EventType = -1;
      int Nel = 0, Nmu = 0;

      for (const DressedLepton& l : dressedleptons) {
        if (l.abspid() == 11)  ++Nel;
        if (l.abspid() == 13)  ++Nmu;
      }

      if ( Nel == 3  && Nmu==0 )  EventType = 3;
      if ( Nel == 2  && Nmu==1 )  EventType = 2;
      if ( Nel == 1  && Nmu==2 )  EventType = 1;
      if ( Nel == 0  && Nmu==3 )  EventType = 0;

      int EventCharge = -dressedleptons[0].charge()*dressedleptons[1].charge()*dressedleptons[2].charge();

      MassZ01 = 0; MassZ02 = 0; MassZ12 = 0;
      MassW0 = 0;  MassW1 = 0;  MassW2 = 0;

      //try Z pair of leptons 01
      if ( (dressedleptons[0].pid()==-(dressedleptons[1].pid())) && (dressedleptons[2].abspid()==neutrinos[0].abspid()-1)){
        MassZ01 = (dressedleptons[0].momentum()+dressedleptons[1].momentum()).mass();
        MassW2 = (dressedleptons[2].momentum()+neutrinos[0].momentum()).mass();
      }
      //try Z pair of leptons 02
      if ( (dressedleptons[0].pid()==-(dressedleptons[2].pid())) && (dressedleptons[1].abspid()==neutrinos[0].abspid()-1)){
        MassZ02 = (dressedleptons[0].momentum()+dressedleptons[2].momentum()).mass();
        MassW1 = (dressedleptons[1].momentum()+neutrinos[0].momentum()).mass();
      }
      //try Z pair of leptons 12
      if ( (dressedleptons[1].pid()==-(dressedleptons[2].pid())) && (dressedleptons[0].abspid()==neutrinos[0].abspid()-1)){
        MassZ12 = (dressedleptons[1].momentum()+dressedleptons[2].momentum()).mass();
        MassW0 = (dressedleptons[0].momentum()+neutrinos[0].momentum()).mass();
      }
      WeightZ1 = 1/(pow(MassZ01*MassZ01 - MZ_PDG*MZ_PDG,2) + pow(MZ_PDG*GammaZ_PDG,2));
      WeightW1 = 1/(pow(MassW2*MassW2 - MW_PDG*MW_PDG,2) + pow(MW_PDG*GammaW_PDG,2));
      WeightTotal1 = WeightZ1*WeightW1;
      M1 = -1*WeightTotal1;

      WeightZ2 = 1/(pow(MassZ02*MassZ02- MZ_PDG*MZ_PDG,2) + pow(MZ_PDG*GammaZ_PDG,2));
      WeightW2 = 1/(pow(MassW1*MassW1- MW_PDG*MW_PDG,2) + pow(MW_PDG*GammaW_PDG,2));
      WeightTotal2 = WeightZ2*WeightW2;
      M2 = -1*WeightTotal2;

      WeightZ3 = 1/(pow(MassZ12*MassZ12 - MZ_PDG*MZ_PDG,2) + pow(MZ_PDG*GammaZ_PDG,2));
      WeightW3 = 1/(pow(MassW0*MassW0 - MW_PDG*MW_PDG,2) + pow(MW_PDG*GammaW_PDG,2));
      WeightTotal3 = WeightZ3*WeightW3;
      M3 = -1*WeightTotal3;

      if( (M1 < M2 && M1 < M3) || (MassZ01 != 0 && MassW2 != 0 && MassZ02 == 0 && MassZ12 == 0) ){
        i = 0; j = 1; k = 2;
      }
      if( (M2 < M1 && M2 < M3) || (MassZ02 != 0 && MassW1 != 0 && MassZ01 == 0 && MassZ12 == 0) ){
        i = 0; j = 2; k = 1;
      }
      if( (M3 < M1 && M3 < M2) || (MassZ12 != 0 && MassW0 != 0 && MassZ01 == 0 && MassZ02 == 0) ){
        i = 1; j = 2; k = 0;
      }

      FourMomentum Zlepton1 = dressedleptons[i].momentum();
      FourMomentum Zlepton2 = dressedleptons[j].momentum();
      FourMomentum Wlepton  = dressedleptons[k].momentum();
      FourMomentum Zboson   = dressedleptons[i].momentum()+dressedleptons[j].momentum();
      FourMomentum Wboson   = dressedleptons[k].momentum()+neutrinos[0].momentum();

      double Wboson_mT = sqrt( 2 * Wlepton.pT() * neutrinos[0].pt() * (1 - cos(deltaPhi(Wlepton, neutrinos[0]))) )/GeV;

      if (fabs(Zboson.mass()-MZ_PDG)>=10.)  vetoEvent;
      if (Wboson_mT<=30.)                   vetoEvent;
      if (Wlepton.pT()<=20.)                vetoEvent;
      if (deltaR(Zlepton1,Zlepton2) < 0.2)  vetoEvent;
      if (deltaR(Zlepton1,Wlepton)  < 0.3)  vetoEvent;
      if (deltaR(Zlepton2,Wlepton)  < 0.3)  vetoEvent;

      double WZ_pt = Zlepton1.pt() + Zlepton2.pt() + Wlepton.pt() + neutrinos[0].pt();
      double WZ_px = Zlepton1.px() + Zlepton2.px() + Wlepton.px() + neutrinos[0].px();
      double WZ_py = Zlepton1.py() + Zlepton2.py() + Wlepton.py() + neutrinos[0].py();
      double mTWZ = sqrt( pow(WZ_pt, 2) - ( pow(WZ_px, 2) + pow(WZ_py,2) ) )/GeV;

      double AbsDeltay = fabs(Zboson.rapidity()-Wlepton.rapidity());

      if (EventType == 3) _h["eee"]->fill(8000., weight);
      if (EventType == 2) _h["mee"]->fill(8000., weight);
      if (EventType == 1) _h["emm"]->fill(8000., weight);
      if (EventType == 0) _h["mmm"]->fill(8000., weight);
      _h["fid"]->fill(8000., weight);

      if (EventCharge == 1) {

        if (EventType == 3) _h["eee_Plus"]->fill(8000., weight);
        if (EventType == 2) _h["mee_Plus"]->fill(8000., weight);
        if (EventType == 1) _h["emm_Plus"]->fill(8000., weight);
        if (EventType == 0) _h["mmm_Plus"]->fill(8000., weight);
        _h["fid_Plus"]->fill(8000., weight);

        _h["Deltay_Plus"]->fill(AbsDeltay, weight);
        _h["Deltay_Plus_norm"]->fill(AbsDeltay, weight);
        fillWithOverflow("ZpT_Plus", Zboson.pT()/GeV, 220, weight);
        fillWithOverflow("WpT_Plus", Wboson.pT()/GeV, 220, weight);
        fillWithOverflow("mTWZ_Plus", mTWZ, 600, weight);
        fillWithOverflow("pTv_Plus", neutrinos[0].pt(), 90, weight);
        fillWithOverflow("ZpT_Plus_norm", Zboson.pT()/GeV, 220, weight);
        fillWithOverflow("pTv_Plus_norm", neutrinos[0].pt()/GeV, 90, weight);

      } else {

        if (EventType == 3) _h["eee_Minus"]->fill(8000., weight);
        if (EventType == 2) _h["mee_Minus"]->fill(8000., weight);
        if (EventType == 1) _h["emm_Minus"]->fill(8000., weight);
        if (EventType == 0) _h["mmm_Minus"]->fill(8000., weight);
        _h["fid_Minus"]->fill(8000., weight);

        _h["Deltay_Minus"]->fill(AbsDeltay, weight);
        _h["Deltay_Minus_norm"]->fill(AbsDeltay, weight);
        fillWithOverflow("ZpT_Minus", Zboson.pT()/GeV, 220, weight);
        fillWithOverflow("WpT_Minus", Wboson.pT()/GeV, 220, weight);
        fillWithOverflow("mTWZ_Minus", mTWZ, 600, weight);
        fillWithOverflow("pTv_Minus", neutrinos[0].pt()/GeV, 90, weight);
        fillWithOverflow("ZpT_Minus_norm", Zboson.pT()/GeV, 220, weight);
        fillWithOverflow("pTv_Minus_norm", neutrinos[0].pt()/GeV, 90, weight);

      }

      fillWithOverflow("ZpT", Zboson.pT()/GeV, 220, weight);
      fillWithOverflow("WpT", Wboson.pT()/GeV, 220, weight);
      fillWithOverflow("mTWZ", mTWZ, 600, weight);
      fillWithOverflow("pTv", neutrinos[0].pt()/GeV, 90, weight);

      _h["Deltay"]->fill(AbsDeltay, weight);

      fillWithOverflow("Njets", jets.size(), 5, weight);
      fillWithOverflow("Njets_norm", jets.size(), 5, weight);
      fillWithOverflow("ZpT_norm", Zboson.pT()/GeV, 220, weight);
      fillWithOverflow("WpT_norm", Wboson.pT()/GeV, 220, weight);
      fillWithOverflow("mTWZ_norm", mTWZ, 600, weight);
      fillWithOverflow("pTv_norm", neutrinos[0].pt()/GeV, 90, weight);

      _h["Deltay_norm"]->fill(AbsDeltay, weight);

      if (jets.size()>1) {
        double mjj = (jets[0].momentum()+jets[1].momentum()).mass()/GeV;
        fillWithOverflow("mjj",      mjj, 800, weight);
        fillWithOverflow("mjj_norm", mjj, 800, weight);
        double DeltaYjj = fabs(jets[0].rapidity()-jets[1].rapidity());
        fillWithOverflow("Deltayjj",      DeltaYjj, 5, weight);
        fillWithOverflow("Deltayjj_norm", DeltaYjj, 5, weight);
      }

    }


    void fillWithOverflow(const string& tag, const double value, const double overflow, const double weight){
      if (value < overflow) _h[tag]->fill(value,   weight);
      else _h[tag]->fill(overflow - 0.45,   weight);
    }


    /// Normalise histograms etc., after the run
    void finalize() {

      const double xs_pb(crossSection() / picobarn);
      const double xs_fb(crossSection() / femtobarn);
      const double sumw(sumOfWeights());
      MSG_INFO("Cross-Section/pb: " << xs_pb      );
      MSG_INFO("Cross-Section/fb: " << xs_fb      );
      MSG_INFO("Sum of weights  : " << sumw       );
      MSG_INFO("nEvents         : " << numEvents());

      const double sf_pb(xs_pb / sumw);
      const double sf_fb(xs_fb / sumw);

      MSG_INFO("sf_pb         : " << sf_pb);
      MSG_INFO("sf_fb         : " << sf_fb);

      float totalBR= 4*0.1086*0.033658; // W and Z leptonic branching fractions

      for (map<string, Histo1DPtr>::iterator it = _h.begin(); it != _h.end(); ++it) {
        if (it->first.find("total") != string::npos)        scale(it->second, sf_pb/totalBR);
        else if (it->first.find("norm") != string::npos)    normalize(it->second);
        else if (it->first.find("fid") != string::npos)     scale(it->second, sf_fb/4.);
        else if (it->first.find("Njets") != string::npos)   scale(it->second, sf_fb/4.);
        else if (it->first.find("ZpT") != string::npos)     scale(it->second, sf_fb/4.);
        else if (it->first.find("WpT") != string::npos)     scale(it->second, sf_fb/4.);
        else if (it->first.find("mTWZ") != string::npos)    scale(it->second, sf_fb/4.);
        else if (it->first.find("pTv") != string::npos)     scale(it->second, sf_fb/4.);
        else if (it->first.find("Deltay") != string::npos)  scale(it->second, sf_fb/4.);
        else if (it->first.find("mjj") != string::npos)     scale(it->second, sf_fb/4.);
        else                                                scale(it->second, sf_fb);
      }
      for (map<string, Scatter2DPtr>::iterator it = _s.begin(); it != _s.end(); ++it) {
        makeScatterWithoutDividingByBinwidth(it->first);
        removeAnalysisObject(_h[it->first]);
      }
    }

    void makeScatterWithoutDividingByBinwidth(const string& tag) {
      vector<Point2D> points;
      //size_t nBins = _dummy->numBins();
      for (const HistoBin1D &bin : _h[tag]->bins()) {
        double  x = bin.midpoint();
        double  y = bin.sumW();
        double ex = bin.xWidth()/2;
        double ey = sqrt(bin.sumW2());
        points.push_back(Point2D(x, y, ex, ey));
      }
      _s[tag]->addPoints(points);
    }


    //@}


  private:

    /// @name Histograms
    //@{

     map<string, Histo1DPtr> _h;
     map<string, Scatter2DPtr> _s;

     //@}

     double MZ_PDG = 91.1876;
     double MW_PDG = 83.385;
     double GammaZ_PDG = 2.4952;
     double GammaW_PDG = 2.085;

  };

  // The hook for the plugin system
  DECLARE_RIVET_PLUGIN(ATLAS_2016_I1426523);

}