Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // LesHouchesReader.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG 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 THEPEG_LesHouchesReader_H
0010 #define THEPEG_LesHouchesReader_H
0011 // This is the declaration of the LesHouchesReader class.
0012 
0013 #include "LesHouches.h"
0014 #include "ThePEG/Handlers/HandlerBase.h"
0015 #include "ThePEG/Utilities/ObjectIndexer.h"
0016 #include "ThePEG/Utilities/Exception.h"
0017 #include "ThePEG/Utilities/XSecStat.h"
0018 #include "ThePEG/PDF/PartonBinInstance.h"
0019 #include "ThePEG/PDF/PartonBin.fh"
0020 #include "ThePEG/MatrixElement/ReweightBase.h"
0021 #include "LesHouchesEventHandler.fh"
0022 #include "LesHouchesReader.fh"
0023 #include "ThePEG/Utilities/CFile.h"
0024 #include <cstdio>
0025 #include <cstring>
0026 
0027 namespace ThePEG {
0028 
0029 /**
0030  * LesHouchesReader is an abstract base class to be used for objects
0031  * which reads event files or streams from matrix element
0032  * generators. Derived classes must at least implement the open() and
0033  * doReadEvent() methods to read in information about the whole run into
0034  * the HEPRUP variable and next event into the HEPEUP variable
0035  * respectively. Also the close() function to close the file or stream
0036  * read must be implemented. Although these functions are named as if
0037  * we are reading from event files, they could just as well implement
0038  * the actual generation of events.
0039  *
0040  * After filling the HEPRUP and HEPEUP variables, which are protected
0041  * and easily accesible from the sub-class, this base class will then
0042  * be responsible for transforming this data to the ThePEG Event
0043  * record in the getEvent() method. <code>LesHouchesReader</code>s can
0044  * only be used inside LesHouchesEventHandler objects.
0045  *
0046  * In the initialization the virtual open() and scan() functions are
0047  * called. Here the derived class must provide the information about
0048  * the processes in the variables corresponding to the HEPRUP common
0049  * block. Note that the IDWTUP is required to be +/- 1, and sub
0050  * classes are required to change the information accordingly to
0051  * ensure the correct corss section sampling. Note also that the
0052  * controlling LesHouchesEventHandler may choose to generate weighted
0053  * events even if IDWTUP is 1.
0054  *
0055  * Note that the information given per process in e.g. the XSECUP and
0056  * XMAXUP vectors is not used by the LesHouchesEventHandler and by
0057  * default the LesHouchesReader is not assumed to be able to actively
0058  * choose between the sub-processes. Instead, the
0059  * LesHouchesEventHandler can handle several LesHouchesReader objects
0060  * and choose between them. However, a sub-class of LesHouchesReader
0061  * may set the flag isActive, in which case it is assumed to be able
0062  * to select between its sub-processes itself.
0063  *
0064  * The LesHouchesReader may be assigned a number ReweightBase objects
0065  * which either completely reweights the events produced (in the
0066  * reweights vector), or only biases the selection without influencing
0067  * the cross section (in the preweights vector). Note that it is the
0068  * responsibility of a sub-class to call the reweight() function and
0069  * multiply the weight according to its return value (typically done
0070  * in the readEvent() function).
0071  *
0072  * @see \ref LesHouchesReaderInterfaces "The interfaces"
0073  * defined for LesHouchesReader.
0074  * @see Event
0075  * @see LesHouchesEventHandler
0076  */
0077 class LesHouchesReader: public HandlerBase, public LastXCombInfo<> {
0078 
0079   /**
0080    * LesHouchesEventHandler should have access to our private parts.
0081    */
0082   friend class LesHouchesEventHandler;
0083 
0084   /**
0085    * Map for accumulating statistics of cross sections per process
0086    * number.
0087    */
0088   typedef map<int,XSecStat> StatMap;
0089 
0090   /**
0091    * Map of XComb objects describing the incoming partons indexed by
0092    * the corresponding PartonBin pair.
0093    */
0094   typedef map<tcPBPair,XCombPtr> XCombMap;
0095 
0096   /**
0097    * A vector of pointers to ReweightBase objects.
0098    */
0099   typedef vector<ReweightPtr> ReweightVector;
0100 
0101 public:
0102 
0103   /** @name Standard constructors and destructors. */
0104   //@{
0105   /**
0106    * Default constructor. If the optional argument is true, the reader
0107    * is assumed to be able to produce events on demand for a given
0108    * process.
0109    */
0110   LesHouchesReader(bool active = false);
0111 
0112   /**
0113    * Copy-constructor.
0114    */
0115   LesHouchesReader(const LesHouchesReader &);
0116 
0117   /**
0118    * Destructor.
0119    */
0120   virtual ~LesHouchesReader();
0121   //@}
0122 
0123 public:
0124 
0125   /** @name Main virtual fuctions to be overridden in
0126    *  sub-classes. They are named as if we are reading from event
0127    *  files, but could equally well implement the actual generation of
0128    *  events. */
0129   //@{
0130   /**
0131    * Open a file or stream with events and read in the run information
0132    * into the heprup variable.
0133    */
0134   virtual void open() = 0;
0135 
0136   /**
0137    * Read the next event from the file or stream into the
0138    * corresponding protected variables. Return false if there is no
0139    * more events.
0140    */
0141   virtual bool doReadEvent() = 0;
0142 
0143   /**
0144    * Close the file or stream from which events have been read.
0145    */
0146   virtual void close() = 0;
0147 
0148   /**
0149    * return the weight names 
0150    */
0151   virtual vector<string> optWeightsNamesFunc() = 0;
0152 
0153   /**
0154    * vector with the optional weights names
0155    */
0156   
0157   vector<string> optionalWeightsNames;
0158 
0159   //@}
0160 
0161   /** @name Other important function which may be overridden in
0162    *  sub-classes which wants to bypass the basic HEPRUP or HEPEUP
0163    *  variables or otherwise facilitate the conversion to ThePEG
0164    *  objects. */
0165   //@{
0166   /**
0167    * Initialize. This function is called by the LesHouchesEventHandler
0168    * to which this object is assigned.
0169    */
0170   virtual void initialize(LesHouchesEventHandler & eh);
0171 
0172   /**
0173    * Calls readEvent() or uncacheEvent() to read information into the
0174    * LesHouches common block variables. This function is called by the
0175    * LesHouchesEventHandler if this reader has been selectod to
0176    * produce an event.
0177    *
0178    * @return the weight asociated with this event. If negative weights
0179    * are allowed it should be between -1 and 1, otherwise between 0
0180    * and 1. If outside these limits the previously estimated maximum
0181    * is violated. Note that the estimated maximum then should be
0182    * updated from the outside.
0183    */
0184   virtual double getEvent();
0185 
0186   /**
0187    * Calls doReadEvent() and performs pre-defined reweightings. A
0188    * sub-class overrides this function it must make sure that the
0189    * corresponding reweightings are done.
0190    */
0191   virtual bool readEvent();
0192 
0193   /**
0194    * Skip \a n events. Used by LesHouchesEventHandler to make sure
0195    * that a file is scanned an even number of times in case the events
0196    * are not ramdomly distributed in the file.
0197    */
0198   virtual void skip(long n);
0199 
0200   /**
0201    * Get an XComb object. Converts the information in the Les Houches
0202    * common block variables to an XComb object describing the sub
0203    * process. This is the way information is conveyed from the reader
0204    * to the controlling LesHouchesEventHandler.
0205    */
0206   tXCombPtr getXComb();
0207 
0208   /**
0209    * Get a SubProcess object corresponding to the information in the
0210    * Les Houches common block variables.
0211    */
0212   tSubProPtr getSubProcess();
0213 
0214   /**
0215    * Scan the file or stream to obtain information about cross section
0216    * weights and particles etc. This function should fill the
0217    * variables corresponding to the /HEPRUP/ common block. The
0218    * function returns the number of events scanned.
0219    */
0220   virtual long scan();
0221 
0222   /**
0223    * Take the information corresponding to the HEPRUP common block and
0224    * initialize the statistics for this reader.
0225    */
0226   virtual void initStat();
0227 
0228   /**
0229    * Reweights the current event using the reweights and preweights
0230    * vectors. It is the responsibility of the sub-class to call this
0231    * function after the HEPEUP information has been retrieved.
0232    */
0233   double reweight();
0234 
0235   /**
0236    * Converts the information in the Les Houches common block
0237    * variables into a Particle objects.
0238    */
0239   virtual void fillEvent();
0240 
0241   /**
0242    * Removes the particles created in the last generated event,
0243    * preparing to produce a new one.
0244    */
0245   void reset();
0246 
0247   /**
0248    * Possibility for subclasses to recover from non-conformant
0249    * settings of XMAXUP when an event file has been scanned with \a
0250    * neve events. Should set weightScale so that the average XMAXUP
0251    * times weightScale gives the cross section for a process. (This is
0252    * needed for MadEvent).
0253    */
0254   virtual void setWeightScale(long neve);
0255 
0256   //@}
0257 
0258   /** @name Access information about the current event. */
0259   //@{
0260 
0261   /**
0262    * Return the size of this event in bytes. To be used for the cache
0263    * file. \a npart is the number of particles. If \a npart is 0, the
0264    * number is taken from NUP.
0265    */
0266   static size_t eventSize(int N) {
0267     return (N + 1)*sizeof(int) +       // IDPRUP, ISTUP
0268       (7*N + 4)*sizeof(double) +       // XWGTUP, SCALUP, AQEDUP, AQCDUP, PUP,
0269                                        // VTIMUP, SPINUP
0270       N*sizeof(long) +                 // IDUP
0271       2*N*sizeof(pair<int,int>) +      // MOTHUP, ICOLUP
0272       sizeof(pair<double,double>) +    // XPDWUP.
0273       2*sizeof(double);                // lastweight and preweight
0274   }
0275 
0276   /**
0277    * The current event weight given by XWGTUP times possible
0278    * reweighting. Note that this is not necessarily the same as what
0279    * is returned by getEvent(), which is scaled with the maximum
0280    * weight.
0281    */
0282   double eventWeight() const { return hepeup.XWGTUP*lastweight; }
0283 
0284   /**
0285    * Return the optional named weights associated to the current event.
0286    */
0287   const map<string,double>& optionalEventWeights() const { return optionalWeights; }
0288 
0289   /** 
0290    * Return the Les Houches event number associated with the current event
0291    */
0292   const long& LHEEventNum() const { return LHEeventnum; }
0293 
0294   /**
0295    * Return the optional npLO and npNLO
0296    */
0297   const int& optionalEventnpLO() const { return optionalnpLO; }
0298   const int& optionalEventnpNLO() const { return optionalnpNLO; }
0299   
0300   /**
0301    * The pair of PartonBinInstance objects describing the current
0302    * incoming partons in the event.
0303    */
0304   const PBIPair & partonBinInstances() const { return thePartonBinInstances; }
0305   /**
0306    * Return the instances of the beam particles for the current event.
0307    */
0308   const PPair & beams() const { return theBeams; }
0309   /**
0310    * Return the instances of the incoming particles to the sub process
0311    * for the current event.
0312    */
0313   const PPair & incoming() const { return theIncoming; }
0314   /**
0315    * Return the instances of the outgoing particles from the sub process
0316    * for the current event.
0317    */
0318   const PVector & outgoing() const { return theOutgoing; }
0319   /**
0320    * Return the instances of the intermediate particles in the sub
0321    * process for the current event.
0322    */
0323   const PVector & intermediates() const { return theIntermediates; }
0324   /**
0325    * If this reader is to be used (possibly together with others) for
0326    * CKKW reweighting and veto, this should give the multiplicity of
0327    * outgoing particles in the highest multiplicity matrix element in
0328    * the group.
0329    */
0330   int maxMultCKKW() const { return theMaxMultCKKW; }
0331   /**
0332    * If this reader is to be used (possibly together with others) for
0333    * CKKW reweighting and veto, this should give the multiplicity of
0334    * outgoing particles in the lowest multiplicity matrix element in
0335    * the group.
0336    */
0337   int minMultCKKW() const { return theMinMultCKKW; }  //@}
0338 
0339   /** @name Other inlined access functions. */
0340   //@{
0341   /**
0342    * The number of events found in this reader. If less than zero the
0343    * number of events are unlimited.
0344    */
0345   long NEvents() const { return theNEvents; }
0346 
0347   /**
0348    * The number of events produced so far. Is reset to zero if an
0349    * event file is reopened.
0350    */
0351   long currentPosition() const { return position; }
0352 
0353   /**
0354    * The maximum number of events to scan to collect information about
0355    * processes and cross sections. If less than 0, all events will be
0356    * scanned.
0357    */
0358   long maxScan() const { return theMaxScan; }
0359 
0360   /**
0361    * Return true if this reader is active.
0362    */
0363   bool active() const { return isActive; }
0364 
0365   /**
0366    * True if negative weights may be produced.
0367    */
0368   bool negativeWeights() const { return heprup.IDWTUP < 0; }
0369 
0370   /**
0371    * The collected cross section statistics for this reader.
0372    */
0373   const XSecStat & xSecStats() const { return stats; }
0374 
0375   /**
0376    * Collected statistics about the individual processes.
0377    */
0378   const StatMap & processStats() const { return statmap; }
0379 
0380   /**
0381    * Select the current event. It will later be rejected with a
0382    * probability given by \a weight.
0383    */
0384   void select(double weight) {
0385     stats.select(weight);
0386     statmap[hepeup.IDPRUP].select(weight);
0387   }
0388 
0389   /**
0390    * Accept the current event assuming it was previously selcted.
0391    */
0392   void accept() {
0393     stats.accept();
0394     statmap[hepeup.IDPRUP].accept();
0395   }
0396 
0397   /**
0398    * Reject the current event assuming it was previously accepted.
0399    */
0400   void reject(double w) {
0401     stats.reject(w);
0402     statmap[hepeup.IDPRUP].reject(w);
0403   }
0404 
0405   /**
0406    * Increase the overestimated cross section for this reader.
0407    */
0408   virtual void increaseMaxXSec(CrossSection maxxsec);
0409 
0410   /**
0411    * The PartonExtractor object used to construct remnants.
0412    */
0413   tPExtrPtr partonExtractor() const { return thePartonExtractor; }
0414 
0415   /**
0416    * Return a possibly null pointer to a CascadeHandler to be used for
0417    * CKKW-reweighting.
0418    */
0419   tCascHdlPtr CKKWHandler() const { return theCKKW; }
0420 
0421   /**
0422    * The pairs of PartonBin objects describing the partons which can
0423    * be extracted by the PartonExtractor object.
0424    */
0425   const PartonPairVec & partonBins() const { return thePartonBins; }
0426 
0427   /**
0428    * The map of XComb objects indexed by the corresponding PartonBin
0429    * pair.
0430    */
0431   const XCombMap & xCombs() const { return theXCombs; }
0432 
0433   /**
0434    * The Cuts object to be used for this reader.
0435    */
0436   const Cuts & cuts() const { return *theCuts; }
0437 
0438   //@}
0439 
0440 protected:
0441 
0442   /** @name Functions for manipulating cache files. */
0443   //@{
0444 
0445   /**
0446    * Name of file used to cache the events form the reader in a
0447    * fast-readable form. If empty, no cache file will be generated.
0448    */
0449   string cacheFileName() const { return theCacheFileName; }
0450 
0451   /**
0452    * Determines whether to apply cuts to events converting them to
0453    * ThePEG format.
0454    */
0455   bool cutEarly() const { return doCutEarly; }
0456 
0457   /**
0458    * File stream for the cache.
0459    */
0460   CFile cacheFile() const { return theCacheFile;}
0461 
0462   /**
0463    * Open the cache file for reading.
0464    */
0465   void openReadCacheFile();
0466 
0467   /**
0468    * Open the cache file for writing.
0469    */
0470   void openWriteCacheFile();
0471 
0472   /**
0473    * Close the cache file;
0474    */
0475   void closeCacheFile();
0476 
0477   /**
0478    * Write the current event to the cache file.
0479    */
0480   void cacheEvent() const;
0481 
0482   /**
0483    * Read an event from the cache file. Return false if something went wrong.
0484    */
0485   bool uncacheEvent();
0486 
0487   /**
0488    * Reopen a reader. If we have reached the end of an event file,
0489    * reopen it and issue a warning if we have used up a large fraction
0490    * of it.
0491    */
0492   void reopen();
0493 
0494   /**
0495    * Helper function to write a variable to a memory location
0496    */
0497   template <typename T>
0498   static char * mwrite(char * pos, const T & t, size_t n = 1) {
0499     std::memcpy(pos, &t, n*sizeof(T));
0500     return pos + n*sizeof(T);
0501   }
0502 
0503   /**
0504    * Helper function to read a variable from a memory location
0505    */
0506   template <typename T>
0507   static const char * mread(const char * pos, T & t, size_t n = 1) {
0508     std::memcpy(&t, pos, n*sizeof(T));
0509     return pos + n*sizeof(T);
0510   }
0511 
0512   //@}
0513 
0514   /** @name Auxilliary virtual methods which may be verridden by sub-classes. */
0515   //@{
0516   /**
0517    * Check the existence of a pair of PartonBin objects corresponding
0518    * to the current event.
0519    *
0520    * @return false if no pair of suitable PartonBin objects was found.
0521    */
0522   virtual bool checkPartonBin();
0523 
0524   /**
0525    * Create instances of all particles in the event and store them
0526    * in particleIndex.
0527    */
0528   virtual void createParticles();
0529 
0530   /**
0531    * Using the already created particles create a pair of
0532    * PartonBinInstance objects corresponding to the incoming
0533    * partons. Return the corresponding PartonBin objects.
0534    */
0535   virtual tcPBPair createPartonBinInstances();
0536 
0537   /**
0538    * Create instances of the incoming beams in the event and store
0539    * them in particleIndex. If no beam particles are included in the
0540    * event they are created from the run info.
0541    */
0542   virtual void createBeams();
0543 
0544   /**
0545    * Go through the mother indices and connect up the Particles.
0546    */
0547   virtual void connectMothers();
0548   //@}
0549 
0550 public:
0551 
0552   /** @name Functions used by the persistent I/O system. */
0553   //@{
0554   /**
0555    * Function used to write out object persistently.
0556    * @param os the persistent output stream written to.
0557    */
0558   void persistentOutput(PersistentOStream & os) const;
0559 
0560   /**
0561    * Function used to read in object persistently.
0562    * @param is the persistent input stream read from.
0563    * @param version the version number of the object when written.
0564    */
0565   void persistentInput(PersistentIStream & is, int version);
0566   //@}
0567 
0568   /**
0569    * Standard Init function used to initialize the interfaces.
0570    */
0571   static void Init();
0572 
0573 protected:
0574 
0575   /** @name Set functions for some variables not in the Les Houches accord. */
0576   //@{
0577   /**
0578    * The number of events in this reader. If less than zero the number
0579    * of events is unlimited.
0580    */
0581   void NEvents(long x) { theNEvents = x; }
0582 
0583   /**
0584    * The map of XComb objects indexed by the corresponding PartonBin
0585    * pair.
0586    */
0587   XCombMap & xCombs() { return theXCombs; }  
0588   //@}
0589 
0590   /** @name Standard (and non-standard) Interfaced functions. */
0591   //@{
0592   /**
0593    * Initialize this object after the setup phase before saving an
0594    * EventGenerator to disk.
0595    * @throws InitException if object could not be initialized properly.
0596    */
0597   virtual void doinit();
0598 
0599   /**
0600    * Initialize this object. Called in the run phase just before
0601    * a run begins.
0602    */
0603   virtual void doinitrun();
0604 
0605   /**
0606    * Finalize this object. Called in the run phase just after a
0607    * run has ended. Used eg. to write out statistics.
0608    */
0609   virtual void dofinish() {
0610     close();
0611     HandlerBase::dofinish();
0612   }
0613 
0614   /**
0615    * Return true if this object needs to be initialized before all
0616    * other objects because it needs to extract PDFs from the event file.
0617    */
0618   virtual bool preInitialize() const;
0619 
0620   /**
0621    * Called from doinit() to extract PDFs from the event file and add
0622    * the corresponding objects to the current EventGenerator.
0623    */
0624   virtual void initPDFs();
0625   //@}
0626 
0627 protected:
0628 
0629   /**
0630    * The HEPRUP common block.
0631    */
0632   HEPRUP heprup;
0633 
0634   /**
0635    * The HEPEUP common block.
0636    */
0637   HEPEUP hepeup;
0638 
0639   /**
0640    * The ParticleData objects corresponding to the incoming particles.
0641    */
0642   tcPDPair inData;
0643 
0644   /**
0645    * The PDFBase objects which has been used for the beam particle
0646    * when generating the events being read. Specified in the interface
0647    * or derived from PDFGUP and PDFSUP.
0648    */
0649   pair<PDFPtr,PDFPtr> inPDF;
0650 
0651   /**
0652    * The PDFBase object to be used in the subsequent generation.
0653    */
0654   pair<cPDFPtr,cPDFPtr> outPDF;
0655 
0656   /**
0657    * The PartonExtractor object used to construct remnants.
0658    */
0659   PExtrPtr thePartonExtractor;
0660 
0661   /**
0662    * A pointer to a CascadeHandler to be used for CKKW-reweighting.
0663    */
0664   tCascHdlPtr theCKKW;
0665 
0666   /**
0667    * The pairs of PartonBin objects describing the partons which can
0668    * be extracted by the PartonExtractor object.
0669    */
0670   PartonPairVec thePartonBins;
0671 
0672   /**
0673    * The map of XComb objects indexed by the corresponding PartonBin
0674    * pair.
0675    */
0676   XCombMap theXCombs;
0677 
0678   /**
0679    * The Cuts object to be used for this reader.
0680    */
0681   CutsPtr theCuts;
0682 
0683   /**
0684    * The number of events in this reader. If less than zero the number
0685    * of events is unlimited.
0686    */
0687   long theNEvents;
0688 
0689   /**
0690    * The number of events produced by this reader so far. Is reset
0691    * every time an event file is reopened.
0692    */
0693   long position;
0694 
0695   /**
0696    * The number of times this reader has been reopened.
0697    */
0698   int reopened;
0699 
0700   /**
0701    * The maximum number of events to scan to collect information about
0702    * processes and cross sections. If less than 0, all events will be
0703    * scanned.
0704    */
0705   long theMaxScan;
0706 
0707   /**
0708    * Flag to tell whether we are in the process of scanning.
0709    */
0710   bool scanning;
0711 
0712   /**
0713    * True if this is an active reader.
0714    */
0715   bool isActive;
0716 
0717   /**
0718    * Name of file used to cache the events form the reader in a
0719    * fast-readable form. If empty, no cache file will be generated.
0720    */
0721   string theCacheFileName;
0722 
0723   /**
0724    * Determines whether to apply cuts to events before converting them
0725    * to ThePEG format.
0726    */
0727   bool doCutEarly;
0728 
0729   /**
0730    * Collect statistics for this reader.
0731    */
0732   XSecStat stats;
0733 
0734   /**
0735    * Collect statistics for each individual process.
0736    */
0737   StatMap statmap;
0738 
0739   /**
0740    * The pair of PartonBinInstance objects describing the current
0741    * incoming partons in the event.
0742    */
0743   PBIPair thePartonBinInstances;
0744 
0745   /**
0746    * Association between ColourLines and colour indices in the current
0747    * translation.
0748    */
0749   ObjectIndexer<long,ColourLine> colourIndex;
0750 
0751   /**
0752    * Association between Particles and indices in the current
0753    * translation.
0754    */
0755   ObjectIndexer<long,Particle> particleIndex;
0756 
0757   /**
0758    * The instances of the beam particles for the current event.
0759    */
0760   PPair theBeams;
0761 
0762   /**
0763    * The instances of the incoming particles to the sub process for
0764    * the current event.
0765    */
0766   PPair theIncoming;
0767 
0768   /**
0769    * The instances of the outgoing particles from the sub process for
0770    * the current event.
0771    */
0772   PVector theOutgoing;
0773 
0774   /**
0775    * The instances of the intermediate particles in the sub process for
0776    * the current event.
0777    */
0778   PVector theIntermediates;
0779 
0780   /**
0781    * File stream for the cache.
0782    */
0783   CFile theCacheFile;
0784 
0785   /**
0786    * The reweight objects modifying the weights of this reader.
0787    */
0788   ReweightVector reweights;
0789 
0790   /**
0791    * The preweight objects modifying the weights of this reader.
0792    */
0793   ReweightVector preweights;
0794 
0795   /**
0796    * The factor with which this reader was last pre-weighted.
0797    */
0798   double preweight;
0799 
0800   /**
0801    * Should the event be reweighted by PDFs used by the PartonExtractor?
0802    */
0803   bool reweightPDF;
0804 
0805   /**
0806    * Should PDFBase objects be constructed from the information in the
0807    * event file in the initialization?
0808    */
0809   bool doInitPDFs;
0810 
0811   /**
0812    * If this reader is to be used (possibly together with others) for
0813    * CKKW reweighting and veto, this should give the multiplicity of
0814    * outgoing particles in the highest multiplicity matrix element in
0815    * the group.
0816    */
0817   int theMaxMultCKKW;
0818 
0819   /**
0820    * If this reader is to be used (possibly together with others) for
0821    * CKKW reweighting and veto, this should give the multiplicity of
0822    * outgoing particles in the lowest multiplicity matrix element in
0823    * the group.
0824    */
0825   int theMinMultCKKW;
0826 
0827   /**
0828    * The weight multiplying the last read event due to PDF
0829    * reweighting, CKKW reweighting or assigned reweight and preweight
0830    * objects.
0831    */
0832   double lastweight;
0833 
0834   /**
0835    * The optional weights associated to the last read events.
0836    */
0837   map<string,double> optionalWeights;
0838 
0839   /**
0840    * The event number
0841    */
0842   long LHEeventnum;
0843 
0844  
0845   /**
0846    * If the maximum cross section of this reader has been increased
0847    * with increaseMaxXSec(), this is the total factor with which it
0848    * has been increased.
0849    */
0850   double maxFactor;
0851 
0852    /**
0853    * npLO for LesHouches merging
0854    */
0855   int optionalnpLO;
0856 
0857  /**
0858    * npNLO for LesHouches merging
0859    */
0860   int optionalnpNLO;
0861 
0862   /**
0863    * The (reweighted) XWGTUP value should be scaled with this cross
0864    * section when compared to the overestimated cross section.
0865    */
0866   CrossSection weightScale;
0867 
0868   /**
0869    * Individual scales for different sub-processes if reweighted.
0870    */
0871   vector<double> xSecWeights;
0872 
0873   /**
0874    * Individual maximum weights for individual (possibly reweighted)
0875    * processes.
0876    */
0877   map<int,double> maxWeights;
0878 
0879   /**
0880    * Is set to true when getEvent() is called from skip(int).
0881    */
0882   bool skipping;
0883 
0884   /**
0885    *  Option for the treatment of the momenta supplied
0886    */
0887   unsigned int theMomentumTreatment;
0888 
0889   /**
0890    * Set to true if warnings about possible weight incompatibilities
0891    * should be issued.
0892    */
0893   bool useWeightWarnings;
0894 
0895   /**
0896    *  Option to allow reopening of the file
0897    */
0898   bool theReOpenAllowed;
0899 
0900   /**
0901    *  Use the spin information
0902    */
0903   bool theIncludeSpin;
0904 
0905 private:
0906 
0907   /** Access function for the interface. */
0908   void setBeamA(long id);
0909   /** Access function for the interface. */
0910   long getBeamA() const;
0911   /** Access function for the interface. */
0912   void setBeamB(long id);
0913   /** Access function for the interface. */
0914   long getBeamB() const;
0915   /** Access function for the interface. */
0916   void setEBeamA(Energy e);
0917   /** Access function for the interface. */
0918   Energy getEBeamA() const;
0919   /** Access function for the interface. */
0920   void setEBeamB(Energy e);
0921   /** Access function for the interface. */
0922   Energy getEBeamB() const;
0923   /** Access function for the interface. */
0924   void setPDFA(PDFPtr);
0925   /** Access function for the interface. */
0926   PDFPtr getPDFA() const;
0927   /** Access function for the interface. */
0928   void setPDFB(PDFPtr);
0929   /** Access function for the interface. */
0930   PDFPtr getPDFB() const;
0931 
0932 private:
0933 
0934   /**
0935    * Describe an abstract base class with persistent data.
0936    */
0937   static AbstractClassDescription<LesHouchesReader> initLesHouchesReader;
0938 
0939   /**
0940    * Private and non-existent assignment operator.
0941    */
0942   LesHouchesReader & operator=(const LesHouchesReader &) = delete;
0943 
0944 public:
0945 
0946   /** @cond EXCEPTIONCLASSES */
0947   /** Exception class used by LesHouchesReader in case inconsistencies
0948    *  are encountered. */
0949   class LesHouchesInconsistencyError: public Exception {};
0950   
0951   /** Exception class used by LesHouchesReader in case more events
0952       than available are requested. */
0953   class LesHouchesReopenWarning: public Exception {};
0954 
0955   /** Exception class used by LesHouchesReader in case reopening an
0956       event file fails. */
0957   class LesHouchesReopenError: public Exception {};
0958 
0959   /** Exception class used by LesHouchesReader in case there is
0960       information missing in the initialization phase. */
0961   class LesHouchesInitError: public InitException {};
0962   /** @endcond */
0963 
0964 };
0965 
0966 /// Stream output for HEPEUP
0967 ostream & operator<<(ostream & os, const HEPEUP & h);
0968 
0969 }
0970 
0971 
0972 #include "ThePEG/Utilities/ClassTraits.h"
0973 
0974 namespace ThePEG {
0975 
0976 /** @cond TRAITSPECIALIZATIONS */
0977 
0978 /**
0979  * This template specialization informs ThePEG about the
0980  * base class of LesHouchesReader.
0981  */
0982 template <>
0983 struct BaseClassTrait<LesHouchesReader,1>: public ClassTraitsType {
0984   /** Typedef of the base class of LesHouchesReader. */
0985   typedef HandlerBase NthBase;
0986 };
0987 
0988 /**
0989  * This template specialization informs ThePEG about the name of the
0990  * LesHouchesReader class and the shared object where it is
0991  * defined.
0992  */
0993 template <>
0994 struct ClassTraits<LesHouchesReader>
0995   : public ClassTraitsBase<LesHouchesReader> {
0996   /**
0997    * Return the class name.
0998    */
0999   static string className() { return "ThePEG::LesHouchesReader"; }
1000   /**
1001    * Return the name of the shared library to be loaded to get access
1002    * to the LesHouchesReader class and every other class it uses
1003    * (except the base class).
1004    */
1005   static string library() { return "LesHouches.so"; }
1006 
1007 };
1008 
1009 /** @endcond */
1010 
1011 }
1012 
1013 #endif /* THEPEG_LesHouchesReader_H */