Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:24:27

0001 // -*- C++ -*-
0002 //
0003 // stat.h is a part of Herwig - A multi-purpose Monte Carlo event generator
0004 // Copyright (C) 2002-2019 The Herwig Collaboration
0005 //
0006 // Herwig is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef HERWIG_Stat_H
0010 #define HERWIG_Stat_H
0011 
0012 namespace Herwig{
0013 
0014 /**
0015  * Documentation for the statistics struct. 
0016  * Copied from ThePEG::StandardEventHandler.
0017  */
0018 struct Stat {
0019 
0020   /** Standard constructor */
0021   Stat() : attempted(0), accepted(0), sumw(0.0), maxXSec(CrossSection()),
0022        totsum(0.0) {}
0023 
0024   /** Constructor with arguments.*/
0025   Stat(long att, long acc, double w, CrossSection x, double sumw)
0026     : attempted(att), accepted(acc), sumw(w), maxXSec(x),
0027        totsum(sumw) {}
0028 
0029   /**
0030    * Calculation of the cross section.
0031    */
0032   inline CrossSection xSec() const {
0033     return totsum >0.0? maxXSec*sumw/totsum: maxXSec;
0034   }
0035 
0036   /** Store the number of attempts */
0037   long attempted;
0038   /** Store the number of accepted ones */
0039   long accepted;
0040   /** Sum of weights */
0041   double sumw;
0042   /** Maximal cross section */
0043   CrossSection maxXSec;
0044   /** Maximal weights */
0045   double totsum;
0046 
0047   /** Overloaded += operator */
0048   const Stat & operator+= (const Stat & s) {
0049     attempted += s.attempted;
0050     accepted += s.accepted;
0051     sumw += s.sumw;
0052     totsum = max(totsum, s.totsum);
0053     if ( totsum > 0.0 )
0054       maxXSec = max(maxXSec, s.maxXSec);
0055     else
0056       maxXSec += s.maxXSec;
0057     return *this;
0058   }
0059 };
0060 }
0061 #endif