Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:19

0001 // -*- C++ -*-
0002 #ifndef THEPEG_ProgressLog_H
0003 #define THEPEG_ProgressLog_H
0004 //
0005 // This is the declaration of the ProgressLog class.
0006 //
0007 
0008 #include "ThePEG/Handlers/AnalysisHandler.h"
0009 
0010 namespace ThePEG {
0011 
0012 /**
0013  * The ProgressLog class will not perform an actual analysis. Instead
0014  * it will write out a progress status on the standard log file. By
0015  * default it will write on event 1, 2, 5, 10, 20, 50, ... etc. But
0016  * optionally it can in addition also write out every given number of
0017  * seconds.
0018  *
0019  * The status line which is written out contains the current date and
0020  * time, the number of events processed so far and the total number of
0021  * events to be generated, two estimates of the time of completion
0022  * (one based on the current cpu usage and one based on the average
0023  * cpu usage [the usage is given in brackets]), and the host on which
0024  * the program is running, together with its process number.
0025  *
0026  * @see \ref ProgressLogInterfaces "The interfaces"
0027  * defined for ProgressLog.
0028  */
0029 class ProgressLog: public AnalysisHandler {
0030 
0031 public:
0032 
0033   /**
0034    * The default constructor.
0035    */
0036   ProgressLog();
0037 
0038 public:
0039 
0040   /** @name Virtual functions required by the AnalysisHandler class. */
0041   //@{
0042   /**
0043    * Analyze a given Event. Note that a fully generated event
0044    * may be presented several times, if it has been manipulated in
0045    * between. The default version of this function will call transform
0046    * to make a lorentz transformation of the whole event, then extract
0047    * all final state particles and call analyze(tPVector) of this
0048    * analysis object and those of all associated analysis objects. The
0049    * default version will not, however, do anything on events which
0050    * have not been fully generated, or have been manipulated in any
0051    * way.
0052    * @param event pointer to the Event to be analyzed.
0053    * @param ieve the event number.
0054    * @param loop the number of times this event has been presented.
0055    * If negative the event is now fully generated.
0056    * @param state a number different from zero if the event has been
0057    * manipulated in some way since it was last presented.
0058    */
0059   virtual void analyze(tEventPtr event, long ieve, int loop, int state);
0060   //@}
0061 
0062   /**
0063    * Return the cpu clock in seconds.
0064    */
0065   static double fclock();
0066 
0067   /**
0068    * Check if it is time to write out a status line.
0069    */
0070   bool statusTime(long i, long n) const;
0071 
0072 public:
0073 
0074   /** @name Functions used by the persistent I/O system. */
0075   //@{
0076   /**
0077    * Function used to write out object persistently.
0078    * @param os the persistent output stream written to.
0079    */
0080   void persistentOutput(PersistentOStream & os) const;
0081 
0082   /**
0083    * Function used to read in object persistently.
0084    * @param is the persistent input stream read from.
0085    * @param version the version number of the object when written.
0086    */
0087   void persistentInput(PersistentIStream & is, int version);
0088   //@}
0089 
0090   /**
0091    * The standard Init function used to initialize the interfaces.
0092    * Called exactly once for each class by the class description system
0093    * before the main function starts or
0094    * when this class is dynamically loaded.
0095    */
0096   static void Init();
0097 
0098 protected:
0099 
0100   /** @name Clone Methods. */
0101   //@{
0102   /**
0103    * Make a simple clone of this object.
0104    * @return a pointer to the new object.
0105    */
0106   virtual IBPtr clone() const;
0107 
0108   /** Make a clone of this object, possibly modifying the cloned object
0109    * to make it sane.
0110    * @return a pointer to the new object.
0111    */
0112   virtual IBPtr fullclone() const;
0113   //@}
0114 
0115 
0116 
0117 protected:
0118 
0119   /** @name Standard Interfaced functions. */
0120   //@{
0121   /**
0122    * Initialize this object. Called in the run phase just before
0123    * a run begins.
0124    */
0125   virtual void doinitrun();
0126   //@}
0127 
0128 private:
0129 
0130   /**
0131    * If larger than 0, a status line will be written every secstep second.
0132    */
0133   int secstep;
0134 
0135   /**
0136    * The clock when the run was started.
0137    */
0138   time_t time0;
0139 
0140   /**
0141    * The cpu clock when the run was started.
0142    */
0143   double fcpu0;
0144 
0145   /**
0146    * The clock the last time a status line was written out.
0147    */
0148   time_t time1;
0149 
0150   /**
0151    * The cpu clock the last time a status line was written out.
0152    */
0153   double fcpu1;
0154 
0155   /**
0156    * The host on which we are running.
0157    */
0158   string host;
0159 
0160   /**
0161    * The pid of the current process.
0162    */
0163   pid_t pid;
0164 
0165 private:
0166 
0167   /**
0168    * The static object used to initialize the description of this class.
0169    * Indicates that this is a concrete class with persistent data.
0170    */
0171   static ClassDescription<ProgressLog> initProgressLog;
0172 
0173   /**
0174    * The assignment operator is private and must never be called.
0175    * In fact, it should not even be implemented.
0176    */
0177   ProgressLog & operator=(const ProgressLog &) = delete;
0178 
0179 };
0180 
0181 }
0182 
0183 #include "ThePEG/Utilities/ClassTraits.h"
0184 
0185 namespace ThePEG {
0186 
0187 /** @cond TRAITSPECIALIZATIONS */
0188 
0189 /** This template specialization informs ThePEG about the
0190  *  base classes of ProgressLog. */
0191 template <>
0192 struct BaseClassTrait<ProgressLog,1> {
0193   /** Typedef of the first base class of ProgressLog. */
0194   typedef AnalysisHandler NthBase;
0195 };
0196 
0197 /** This template specialization informs ThePEG about the name of
0198  *  the ProgressLog class and the shared object where it is defined. */
0199 template <>
0200 struct ClassTraits<ProgressLog>
0201   : public ClassTraitsBase<ProgressLog> {
0202   /** Return a platform-independent class name */
0203   static string className() { return "ThePEG::ProgressLog"; }
0204   /**
0205    * The name of a file containing the dynamic library where the class
0206    * ProgressLog is implemented. It may also include several, space-separated,
0207    * libraries if the class ProgressLog depends on other classes (base classes
0208    * excepted). In this case the listed libraries will be dynamically
0209    * linked in the order they are specified.
0210    */
0211   static string library() { return "ProgressLog.so"; }
0212 };
0213 
0214 /** @endcond */
0215 
0216 }
0217 
0218 #endif /* THEPEG_ProgressLog_H */