Rivet Analyses Reference

H1_1996_I422230

Charged particle multiplicities in deep inelastic scattering at HERA
Experiment: H1 (HERA)
Inspire ID: 422230
Status: VALIDATED
Authors:
  • Ariadna Leon
  • Hannes Jung
References:Beams: e+ p+, p+ e+
Beam energies: (27.5, 820.0); (820.0, 27.5) GeV
Run details:
  • validation with 3000001 events generated RAPGAP33, 26.7x820 GeV, Q2>2, 0.01 < y <0.95, IPRO=12, pt2cut=9, mixing with O(alphas) process, Nf_QCDC=4, NFLA=5

Using the H1 detector at HERA, charged particle multiplicity distributions in deep inelastic ep scattering have been measured over a large kinematical region. The evolution with W and Q2 of the multiplicity distribution and of the multiplicity moments in pseudorapidity domains of varying size is studied in the current fragmentation region of the hadronic centre-of-mass frame. Data on multiplicity as well as the various moments of the distribution are given in a variety of psuedorapidity regions. The moments are the generalised dispersions (D), the factorial moments (R), the Muller moments (K) and the C factors (C).

Source code: H1_1996_I422230.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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
// -*- C++ -*-
#include "Rivet/Analysis.hh"
#include "Rivet/Projections/FinalState.hh"
#include "Rivet/Projections/FastJets.hh"
#include "Rivet/Projections/ChargedFinalState.hh"
#include "Rivet/Projections/DISKinematics.hh"
#include "Rivet/Tools/BinnedHistogram.hh"

namespace Rivet {


  /// @brief Charged particle multiplicities in deep inelastic scattering at HERA (H1)
  class H1_1996_I422230 : public Analysis {
  public:

    const vector<double> WEdges {80., 115, 150., 185., 220.};


    /// Constructor
    RIVET_DEFAULT_ANALYSIS_CTOR(H1_1996_I422230);


    /// @name Analysis methods
    ///@{

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

      // Initialise and register projections
      const DISLepton disl;
      declare(disl, "Lepton");
      declare(DISKinematics(), "Kinematics");

      // The basic final-state projection:
      // all final-state particles within
      // the given eta acceptance
      const FinalState fs;
      declare(fs,"FS");
      const ChargedFinalState cfs(disl.remainingFinalState());
      declare(cfs,"CFS");



      //binned histograms to count for the multiplicity
      for (size_t ix = 0; ix < 4; ++ix) {
        book(_Nevt_after_cuts[ix], "TMP/Nevt_after_cuts"+ to_string(ix));
      }
      Histo1DPtr dummy;
      for (int iW = 0; iW < 4; ++iW) {
        // cout << " iW " << iW << " " << WEdges[iW+1] << " " << WEdges[iW] << endl;
        _h_mult1.add(WEdges[iW], WEdges[iW+1],book(dummy,iW+1,1,1));
        _h_mult2.add(WEdges[iW], WEdges[iW+1],book(dummy,iW+1,1,2));
        _h_mult3.add(WEdges[iW], WEdges[iW+1],book(dummy,iW+1,1,3));
        _h_mult4.add(WEdges[iW], WEdges[iW+1],book(dummy,iW+1,1,4));
        _h_mult_all.add(WEdges[iW], WEdges[iW+1],book(dummy,"TMP/dummy"+ to_string(iW),refData(4,1,4)));
        _h_mult10_all.add(WEdges[iW], WEdges[iW+1],book(dummy,"TMP/dummy1"+ to_string(iW),refData(4,1,4)));
        _h_mult11_all.add(WEdges[iW], WEdges[iW+1],book(dummy,"TMP/dummy2"+ to_string(iW),refData(4,1,4)));
        _h_mult12_all.add(WEdges[iW], WEdges[iW+1],book(dummy,"TMP/dummy3"+ to_string(iW),refData(4,1,4)));
      }
      //histograms for the statistical moments and the mean

      book(_h_mean0,5,1,1);
      book(_h_D2_0,5,1,2);
      book(_h_D3_0,5,1,3);
      book(_h_D4_0,5,1,4);
      book(_h_C2_0,5,1,5);
      book(_h_C3_0,5,1,6);
      book(_h_C4_0,5,1,7);
      book(_h_R2_0,5,1,8);
      book(_h_R3_0,5,1,9);

      book(_h_mean12,6,1,1);
      book(_h_D2_12,6,1,2);
      book(_h_D3_12,6,1,3);
      book(_h_D4_12,6,1,4);
      book(_h_C2_12,6,1,5);
      book(_h_C3_12,6,1,6);
      book(_h_C4_12,6,1,7);
      book(_h_R2_12,6,1,8);
      book(_h_R3_12,6,1,9);
      book(_h_K3_12,6,1,10);

      book(_h_mean13,7,1,1);
      book(_h_D2_13,7,1,2);
      book(_h_D3_13,7,1,3);
      book(_h_D4_13,7,1,4);
      book(_h_C2_13,7,1,5);
      book(_h_C3_13,7,1,6);
      book(_h_C4_13,7,1,7);
      book(_h_R2_13,7,1,8);
      book(_h_R3_13,7,1,9);
      book(_h_K3_13,7,1,10);

      book(_h_mean14,8,1,1);
      book(_h_D2_14,8,1,2);
      book(_h_D3_14,8,1,3);
      book(_h_D4_14,8,1,4);
      book(_h_C2_14,8,1,5);
      book(_h_C3_14,8,1,6);
      book(_h_C4_14,8,1,7);
      book(_h_R2_14,8,1,8);
      book(_h_R3_14,8,1,9);

      book(_h_mean15,9,1,1);
      book(_h_D2_15,9,1,2);
      book(_h_D3_15,9,1,3);
      book(_h_D4_15,9,1,4);
      book(_h_C2_15,9,1,5);
      book(_h_C3_15,9,1,6);
      book(_h_C4_15,9,1,7);
      book(_h_R2_15,9,1,8);
      book(_h_R3_15,9,1,9);

      book(_h_mean23,10,1,1);
      book(_h_D2_23,10,1,2);
      book(_h_D3_23,10,1,3);
      book(_h_D4_23,10,1,4);
      book(_h_C2_23,10,1,5);
      book(_h_C3_23,10,1,6);
      book(_h_C4_23,10,1,7);
      book(_h_R2_23,10,1,8);
      book(_h_R3_23,10,1,9);
      book(_h_K3_23,10,1,10);

      book(_h_mean34,11,1,1);
      book(_h_D2_34,11,1,2);
      book(_h_D3_34,11,1,3);
      book(_h_D4_34,11,1,4);
      book(_h_C2_34,11,1,5);
      book(_h_C3_34,11,1,6);
      book(_h_C4_34,11,1,7);
      book(_h_R2_34,11,1,8);
      book(_h_R3_34,11,1,9);
      book(_h_K3_34,11,1,10);

      book(_h_mean45,12,1,1);
      book(_h_D2_45,12,1,2);
      book(_h_D3_45,12,1,3);
      book(_h_D4_45,12,1,4);
      book(_h_C2_45,12,1,5);
      book(_h_C3_45,12,1,6);
      book(_h_C4_45,12,1,7);
      book(_h_R2_45,12,1,8);
      book(_h_R3_45,12,1,9);
      book(_h_K3_45,12,1,10);
    }


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

      //apply the final state of all particles and the one for only charged particles
      const FinalState& fs = apply<FinalState>(event, "FS");
      const size_t numParticles = fs.particles().size();
      const ChargedFinalState& cfs = apply<ChargedFinalState>(event,"CFS");
      const Particles& particles = cfs.particles();

      //because it does not make sense to have a collision with the numparticles is less than two,we use the vetoEvent so that if there is an event like this it does not run the analysis and goes to the next one

      if (numParticles<2) {
        MSG_DEBUG("Failed leptonic cut");
        vetoEvent;
      }

      //apply DIS kinematics in the event
      const DISKinematics& dk = apply<DISKinematics>(event,"Kinematics");
      //const DISLepton& dl = apply<DISLepton>(event,"Lepton");

      //get the DIS Kinematics but not in a loop because they are variables that descrube the type of event not the particles
      double Q2 = dk.Q2();
      double W2 = dk.W2();
      double W = std::sqrt(W2);
      bool cut1 = W<220. && W>80.;
      if (!cut1) vetoEvent;
      bool cut = Q2<1000. && Q2>10. && W>80. && W<220.;
      if (!cut) vetoEvent;

      double Efwd = 0. ;
      for (size_t ip1 = 0; ip1 < particles.size(); ++ip1) {
        const Particle& p = particles[ip1];
        double theta = p.theta()/degree ;
        if ( inRange(theta,4.4,15.) ) {
          Efwd = Efwd + p.E() ;
        }
      }

      bool cut_fwd = Efwd > 0.5 && dk.beamLepton().E() > 12. ;
      if (!cut_fwd) vetoEvent ;

      for (int iW = 0; iW < 4; ++iW) {
        if (inRange(W, WEdges[iW],WEdges[iW+1])) {
          _Nevt_after_cuts[iW] -> fill();
        }
      }


      //boost to the hadronic centre of mass frame
      const LorentzTransform hcmboost = dk.boostHCM();
      double kall = 0.;
      double k1 = 0.;
      double k2 = 0.;
      double k3 = 0.;
      double k4 = 0.;
      double k10 = 0.;
      double k11 = 0.;
      double k12 = 0.;
      for (size_t ip1 = 0; ip1 < particles.size(); ++ip1) {
        const Particle& p = particles[ip1];
        const FourMomentum hcmMom = hcmboost.transform(p.momentum());
        const double etahcm_char = hcmMom.eta();
        if (etahcm_char>0.) {
          kall = kall+1;
        }
        if (etahcm_char>1. && etahcm_char<2.) {
          k1 = k1+1;
        }
        if (etahcm_char>1. && etahcm_char<3.) {
          k2 = k2+1;
        }
        if (etahcm_char>1. && etahcm_char<4.) {
          k3 = k3+1;
        }
        if (etahcm_char>1. && etahcm_char<5.) {
          k4 = k4+1;
        }
        if (etahcm_char>2. && etahcm_char<3.) {
          k10 = k10+1;
        }
        if (etahcm_char>3. && etahcm_char<4.) {
          k11 = k11+1;
        }
        if (etahcm_char>4. && etahcm_char<5.) {
          k12 = k12+1;
        }

      }
      // cout<<k1<<endl;
      _h_mult_all.fill(W,kall);
      _h_mult10_all.fill(W,k10);
      _h_mult11_all.fill(W,k11);
      _h_mult12_all.fill(W,k12);
      _h_mult1.fill(W,k1);
      _h_mult2.fill(W,k2);
      _h_mult3.fill(W,k3);
      _h_mult4.fill(W,k4);

    }

    /// Normalise histograms etc., after the run
    void finalize() {
      // cout << _h_mult1.histo() << endl;
      int iW = 0 ;
      double iq  ;
      double mean, dispersion, cq ,R2,R3,K3 ;
      for (Histo1DPtr histo : _h_mult_all.histos()) {
        double Werr = (WEdges[iW+1] - WEdges[iW])/2. ;
        //cout << " iW " << iW << " Edges " << WEdges[iW+1] << " " << WEdges[iW] << " Werr = " << Werr << endl;
        double Wmid = (WEdges[iW+1] + WEdges[iW])/2. ;
        //cout << " new histo: W = "  << Wmid << " " << histo->name() << endl;
        iq = 2 ;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        //cout << " mean " << mean << " dispersion " << dispersion << " for iq = " << iq << endl;

        // just to have some values, needs to be corrected

        _h_mean0->addPoint(Wmid, mean, Werr, dispersion/2);
        _h_D2_0->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C2_0->addPoint(Wmid, cq, Werr, cq/mean);
        _h_R2_0->addPoint(Wmid, R2, Werr, R2/mean);
        _h_R3_0->addPoint(Wmid,R3,Werr,R3/mean);
        iq = 3 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D3_0->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C3_0->addPoint(Wmid, cq, Werr, cq/mean);
        iq = 4 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D4_0->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C4_0->addPoint(Wmid, cq, Werr, cq/mean);

        ++iW;
      }
      iW = 0 ;
      mean = 0.;
      dispersion = 0.;
      cq = 0.;
      R2 = 0;
      R3 = 0.;
      K3 = 0.;
      for (Histo1DPtr histo : _h_mult1.histos()) {
        // use scale to get Prob in %, and use counter to count events after cuts
        //cout << " Nevt " << dbl(*_Nevt_after_cuts[iW]) << endl;
        scale(histo, 100.0/ *_Nevt_after_cuts[iW]);
        //
        double Werr = (WEdges[iW+1] - WEdges[iW])/2. ;
        double Wmid = (WEdges[iW+1] + WEdges[iW])/2. ;
        iq = 2 ;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;

        _h_mean12->addPoint(Wmid, mean, Werr, dispersion/2);
        _h_D2_12->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C2_12->addPoint(Wmid, cq, Werr, cq/mean);
        _h_R2_12->addPoint(Wmid, R2, Werr, R2/mean);
        _h_R3_12->addPoint(Wmid,R3,Werr,R3/mean);
        _h_K3_12->addPoint(Wmid,K3,Werr,K3/mean);
        iq = 3 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D3_12->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C3_12->addPoint(Wmid, cq, Werr, cq/mean);
        iq = 4 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D4_12->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C4_12->addPoint(Wmid, cq, Werr, cq/mean);
        ++iW;
      }
      iW = 0 ;
      mean = 0.;
      dispersion = 0.;
      cq = 0.;
      R2 = 0;
      R3 = 0.;
      K3 = 0.;

      for (Histo1DPtr histo : _h_mult2.histos()) {
        // use scale to get Prob in %, and use counter to count events after cuts
        //cout << " Nevt " << dbl(*_Nevt_after_cuts[0]) << endl;
        scale(histo, 100.0/ *_Nevt_after_cuts[iW]);
        //
        double Werr = (WEdges[iW+1] - WEdges[iW])/2. ;
        double Wmid = (WEdges[iW+1] + WEdges[iW])/2. ;
        iq = 2 ;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;

        _h_mean13->addPoint(Wmid, mean, Werr, dispersion/2);
        _h_D2_13->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C2_13->addPoint(Wmid, cq, Werr, cq/mean);
        _h_R2_13->addPoint(Wmid, R2, Werr, R2/mean);
        _h_R3_13->addPoint(Wmid,R3,Werr,R3/mean);
        _h_K3_13->addPoint(Wmid,K3,Werr,K3/mean);
        iq = 3 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D3_13->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C3_13->addPoint(Wmid, cq, Werr, cq/mean);
        iq = 4 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D4_13->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C4_13->addPoint(Wmid, cq, Werr, cq/mean);
        ++iW;
      }
      iW = 0 ;
      mean = 0.;
      dispersion = 0.;
      cq = 0.;
      R2 = 0;
      R3 = 0.;
      K3 = 0.;

      for (Histo1DPtr histo : _h_mult3.histos()) {
        // use scale to get Prob in %, and use counter to count events after cuts
        //cout << " Nevt " << dbl(*_Nevt_after_cuts[0]) << endl;
        scale(histo, 100.0/ *_Nevt_after_cuts[iW]);
        //
        double Werr = (WEdges[iW+1] - WEdges[iW])/2. ;
        double Wmid = (WEdges[iW+1] + WEdges[iW])/2. ;
        iq = 2 ;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_mean14->addPoint(Wmid, mean, Werr, dispersion/2);
        _h_D2_14->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C2_14->addPoint(Wmid, cq, Werr, cq/mean);
        _h_R2_14->addPoint(Wmid, R2, Werr, R2/mean);
        _h_R3_14->addPoint(Wmid,R3,Werr,R3/mean);
        iq = 3 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D3_14->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C3_14->addPoint(Wmid, cq, Werr, cq/mean);
        iq = 4 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D4_14->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C4_14->addPoint(Wmid, cq, Werr, cq/mean);
        ++iW;
      }
      iW = 0 ;
      mean = 0.;
      dispersion = 0.;
      cq = 0.;
      R2 = 0;
      R3 = 0.;
      K3 = 0.;

      for (Histo1DPtr histo : _h_mult4.histos()) {
        // use scale to get Prob in %, and use counter to count events after cuts
        //cout << " Nevt " << dbl(*_Nevt_after_cuts[0]) << endl;
        scale(histo, 100.0/ *_Nevt_after_cuts[iW]);
        //
        double Werr = (WEdges[iW+1] - WEdges[iW])/2. ;
        double Wmid = (WEdges[iW+1] + WEdges[iW])/2. ;
        iq = 2 ;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_mean15->addPoint(Wmid, mean, Werr, dispersion/2);
        _h_D2_15->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C2_15->addPoint(Wmid, cq, Werr, cq/mean);
        _h_R2_15->addPoint(Wmid, R2, Werr, R2/mean);
        _h_R3_15->addPoint(Wmid,R3,Werr,R3/mean);
        iq = 3 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D3_15->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C3_15->addPoint(Wmid, cq, Werr, cq/mean);
        iq = 4 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D4_15->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C4_15->addPoint(Wmid, cq, Werr, cq/mean);
        ++iW;
      }
      iW = 0 ;
      mean = 0.;
      dispersion = 0.;
      cq = 0.;
      R2 = 0;
      R3 = 0.;
      K3 = 0.;

      for (Histo1DPtr histo : _h_mult10_all.histos()) {
        // use scale to get Prob in %, and use counter to count events after cuts
        //cout << " Nevt " << dbl(*_Nevt_after_cuts[0]) << endl;
        scale(histo, 100.0/ *_Nevt_after_cuts[iW]);
        //
        double Werr = (WEdges[iW+1] - WEdges[iW])/2. ;
        double Wmid = (WEdges[iW+1] + WEdges[iW])/2. ;
        iq = 2 ;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_mean23->addPoint(Wmid, mean, Werr, dispersion/2);
        _h_D2_23->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C2_23->addPoint(Wmid, cq, Werr, cq/mean);
        _h_R2_23->addPoint(Wmid, R2, Werr,R2/mean);
        _h_R3_23->addPoint(Wmid,R3,Werr,R3/mean);
        _h_K3_23->addPoint(Wmid,K3,Werr,K3/mean);
        iq = 3 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D3_23->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C3_23->addPoint(Wmid, cq, Werr, cq/mean);
        iq = 4 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D4_23->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C4_23->addPoint(Wmid, cq, Werr, cq/mean);
        ++iW;
      }

      iW = 0 ;
      mean = 0.;
      dispersion = 0.;
      cq = 0.;
      R2 = 0;
      R3 = 0.;
      K3 = 0.;

      for (Histo1DPtr histo : _h_mult11_all.histos()) {
        // use scale to get Prob in %, and use counter to count events after cuts
        //cout << " Nevt " << dbl(*_Nevt_after_cuts[0]) << endl;
        scale(histo, 100.0/ *_Nevt_after_cuts[iW]);
        //
        double Werr = (WEdges[iW+1] - WEdges[iW])/2. ;
        double Wmid = (WEdges[iW+1] + WEdges[iW])/2. ;
        iq = 2 ;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_mean34->addPoint(Wmid, mean, Werr, dispersion/2);
        _h_D2_34->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C2_34->addPoint(Wmid, cq, Werr, cq/mean);
        _h_R2_34->addPoint(Wmid, R2, Werr, R2/mean);
        _h_R3_34->addPoint(Wmid,R3,Werr,R3/mean);
        _h_K3_34->addPoint(Wmid,K3,Werr,K3/mean);
        iq = 3 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D3_34->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C3_34->addPoint(Wmid, cq, Werr, cq/mean);
        iq = 4 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D4_34->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C4_34->addPoint(Wmid, cq, Werr, cq/mean);
        ++iW;
      }
      iW = 0 ;
      mean = 0.;
      dispersion = 0.;
      cq = 0.;
      R2 = 0;
      R3 = 0.;
      K3 = 0.;

      for (Histo1DPtr histo : _h_mult12_all.histos()) {
        // use scale to get Prob in %, and use counter to count events after cuts
        //cout << " Nevt " << dbl(*_Nevt_after_cuts[0]) << endl;
        scale(histo, 100.0/ *_Nevt_after_cuts[iW]);
        //
        double Werr = (WEdges[iW+1] - WEdges[iW])/2. ;
        double Wmid = (WEdges[iW+1] + WEdges[iW])/2. ;
        iq = 2 ;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_mean45->addPoint(Wmid, mean, Werr, dispersion/2);
        _h_D2_45->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C2_45->addPoint(Wmid, cq, Werr, cq/mean);
        _h_R2_45->addPoint(Wmid, R2, Werr, R2/mean);
        _h_R3_45->addPoint(Wmid,R3,Werr,R3/mean);
        // cout<<"R2= "<<R2<<"R3= "<<R3<<"K3= "<<K3<<endl;
        _h_K3_45->addPoint(Wmid,K3,Werr,K3/mean);
        iq = 3 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D3_45->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C3_45->addPoint(Wmid, cq, Werr, cq/mean);
        iq = 4 ;
        dispersion = 0 ;
        cq = 0;
        _histo_to_moments(histo, iq , mean, dispersion,cq,R2,R3,K3) ;
        _h_D4_45->addPoint(Wmid, dispersion, Werr, dispersion/mean);
        _h_C4_45->addPoint(Wmid, cq, Werr, cq/mean);
        ++iW;
      }

    }


    inline void _histo_to_moments(Histo1DPtr histo_input, double iq, double & mean, double & dispersion, double & cq,double &R2,double &R3, double &K3) {

      //cout << " histo mean = " << histo_input->xMean() << " variance " << histo_input->xVariance() << endl;
      double mysumWX = 0. ;
      double mysumW2X = 0. ;
      double mysumWX2 = 0. ;
      double mysumW2 = 0. ;
      double mysumW = 0. ;

      // cout << histo_input->name() << endl;
      if (histo_input->effNumEntries() == 0 || histo_input->sumW() == 0) {
        MSG_WARNING("Requested mean of a distribution with no net fill weights");
      } else {
        // loop to calcualte mean
        for (size_t b = 0; b < histo_input->numBins(); ++b) { // loop over points
          mysumWX  += histo_input->bin(b).height()      *  histo_input->bin(b).xMid() ;
          mysumW2X += sqr(histo_input->bin(b).height()) *  histo_input->bin(b).xMid() ;
          mysumWX2 += histo_input->bin(b).height()      *  sqr(histo_input->bin(b).xMid()) ;
          mysumW2  += sqr(histo_input->bin(b).height()) ;
          mysumW   += histo_input->bin(b).height() ;
        }
        mean = mysumWX/mysumW ;


        // loop to calculate dispersion (variance)
        double var = 0.;
        for (size_t b = 0; b < histo_input->numBins(); ++b) { // loop over points
          double xval = histo_input->bin(b).xMid() ;
          double weight = histo_input->bin(b).height() ;
          var = var + weight * pow((xval - mean),iq) ;
        }

        var = var/mysumW ;

        dispersion = pow(var,1./iq) ;
        double c = 0.;
        for (size_t b = 0; b < histo_input->numBins(); ++b) { // loop over points
          double xval = histo_input->bin(b).xMid() ;
          double weight = histo_input->bin(b).height() ;
          c = c+pow(xval,iq)*weight;
        }
        cq = c/(mysumW*pow(mean,iq));
        double r2 = 0.;
        double r3 = 0.;
        for (size_t b = 0; b < histo_input->numBins(); ++b) { // loop over points
          double xval = histo_input->bin(b).xMid() ;
          double weight = histo_input->bin(b).height() ;
          r2 = r2+xval*(xval-1)*weight;
          r3 = r3+xval*(xval-1)*(xval-2)*weight;
        }
        R2 = r2/(mysumW*pow(mean,2));
        R3 = r3/(mysumW*pow(mean,3));
        K3 = R3 - 3*R2 + 2;
      }
    }

    ///@}


  private:

    /// @name Histograms
    ///@{

    BinnedHistogram _h_mult1;
    BinnedHistogram _h_mult2;
    BinnedHistogram _h_mult3;
    BinnedHistogram _h_mult4;
    BinnedHistogram _h_mult_all;
    BinnedHistogram _h_mult10_all;
    BinnedHistogram _h_mult11_all;
    BinnedHistogram _h_mult12_all;

    Histo1DPtr _h2_W5;
    Histo1DPtr _h2_W6;
    Histo1DPtr _h2_W7;
    Histo1DPtr _h2_W8;
    Histo1DPtr _h2_W9;
    Histo1DPtr _h2_W10;
    Histo1DPtr _h2_W11;
    Histo1DPtr _h2_W12;
    //Histo1DPtr _h2_W5_R2;
    Scatter2DPtr _h_mean0;
    Scatter2DPtr _h_D2_0;
    Scatter2DPtr _h_D3_0;
    Scatter2DPtr _h_D4_0;
    Scatter2DPtr _h_C2_0;
    Scatter2DPtr _h_C3_0;
    Scatter2DPtr _h_C4_0;
    Scatter2DPtr _h_R2_0;
    Scatter2DPtr _h_R3_0;
    Scatter2DPtr _h_mean12;
    Scatter2DPtr _h_D2_12;
    Scatter2DPtr _h_D3_12;
    Scatter2DPtr _h_D4_12;
    Scatter2DPtr _h_C2_12;
    Scatter2DPtr _h_C3_12;
    Scatter2DPtr _h_C4_12;
    Scatter2DPtr _h_R2_12;
    Scatter2DPtr _h_R3_12;
    Scatter2DPtr _h_K3_12;
    Scatter2DPtr _h_mean13;
    Scatter2DPtr _h_D2_13;
    Scatter2DPtr _h_D3_13;
    Scatter2DPtr _h_D4_13;
    Scatter2DPtr _h_C2_13;
    Scatter2DPtr _h_C3_13;
    Scatter2DPtr _h_C4_13;
    Scatter2DPtr _h_R2_13;
    Scatter2DPtr _h_R3_13;
    Scatter2DPtr _h_K3_13;
    Scatter2DPtr _h_mean14;
    Scatter2DPtr _h_D2_14;
    Scatter2DPtr _h_D3_14;
    Scatter2DPtr _h_D4_14;
    Scatter2DPtr _h_C2_14;
    Scatter2DPtr _h_C3_14;
    Scatter2DPtr _h_C4_14;
    Scatter2DPtr _h_R2_14;
    Scatter2DPtr _h_R3_14;
    Scatter2DPtr _h_mean15;
    Scatter2DPtr _h_D2_15;
    Scatter2DPtr _h_D3_15;
    Scatter2DPtr _h_D4_15;
    Scatter2DPtr _h_C2_15;
    Scatter2DPtr _h_C3_15;
    Scatter2DPtr _h_C4_15;
    Scatter2DPtr _h_R2_15;
    Scatter2DPtr _h_R3_15;
    Scatter2DPtr _h_mean23;
    Scatter2DPtr _h_D2_23;
    Scatter2DPtr _h_D3_23;
    Scatter2DPtr _h_D4_23;
    Scatter2DPtr _h_C2_23;
    Scatter2DPtr _h_C3_23;
    Scatter2DPtr _h_C4_23;
    Scatter2DPtr _h_R2_23;
    Scatter2DPtr _h_R3_23;
    Scatter2DPtr _h_K3_23;
    Scatter2DPtr _h_mean34;
    Scatter2DPtr _h_D2_34;
    Scatter2DPtr _h_D3_34;
    Scatter2DPtr _h_D4_34;
    Scatter2DPtr _h_C2_34;
    Scatter2DPtr _h_C3_34;
    Scatter2DPtr _h_C4_34;
    Scatter2DPtr _h_R2_34;
    Scatter2DPtr _h_R3_34;
    Scatter2DPtr _h_K3_34;
    Scatter2DPtr _h_mean45;
    Scatter2DPtr _h_D2_45;
    Scatter2DPtr _h_D3_45;
    Scatter2DPtr _h_D4_45;
    Scatter2DPtr _h_C2_45;
    Scatter2DPtr _h_C3_45;
    Scatter2DPtr _h_C4_45;
    Scatter2DPtr _h_R2_45;
    Scatter2DPtr _h_R3_45;
    Scatter2DPtr _h_K3_45;

    CounterPtr _Nevt_after_cuts[4];

    ///@}

  };


  RIVET_DECLARE_PLUGIN(H1_1996_I422230);

}