00001 // -*- C++ -*- 00002 // 00003 // LesHouchesEventHandler.h is a part of ThePEG - Toolkit for HEP Event Generation 00004 // Copyright (C) 1999-2007 Leif Lonnblad 00005 // 00006 // ThePEG is licenced under version 2 of the GPL, see COPYING for details. 00007 // Please respect the MCnet academic guidelines, see GUIDELINES for details. 00008 // 00009 #ifndef THEPEG_LesHouchesEventHandler_H 00010 #define THEPEG_LesHouchesEventHandler_H 00011 // 00012 // This is the declaration of the LesHouchesEventHandler class. 00013 // 00014 00015 #include "ThePEG/Handlers/EventHandler.h" 00016 #include "LesHouchesEventHandler.fh" 00017 #include "LesHouchesReader.fh" 00018 #include "ThePEG/Utilities/CompSelector.h" 00019 #include "ThePEG/Utilities/XSecStat.h" 00020 00021 namespace ThePEG { 00022 00040 class LesHouchesEventHandler: public EventHandler { 00041 00042 public: 00043 00047 typedef vector<LesHouchesReaderPtr> ReaderVector; 00048 00052 typedef CompSelector<int,CrossSection> ReaderSelector; 00053 00057 enum WeightOpt { 00058 unitweight = 1, 00059 unitnegweight = -1, 00060 varweight = 2, 00061 varnegweight = -2 00062 }; 00063 00064 public: 00065 00071 LesHouchesEventHandler() 00072 : theWeightOption(unitweight), theUnitTolerance(1.0e-6), warnPNum(true) 00073 { 00074 selector().tolerance(unitTolerance()); 00075 } 00076 00080 virtual ~LesHouchesEventHandler(); 00082 00083 public: 00084 00091 virtual void initialize(); 00092 00097 virtual void statistics(ostream &) const; 00098 00104 virtual CrossSection histogramScale() const; 00105 00111 virtual CrossSection integratedXSec() const; 00112 00118 virtual CrossSection integratedXSecErr() const; 00120 00126 virtual EventPtr generateEvent(); 00127 00132 virtual tCollPtr performCollision(); 00133 00138 virtual EventPtr continueEvent(); 00140 00149 void select(double weight); 00150 00155 void accept(); 00156 00161 void reject(double weight); 00162 00166 void increaseMaxXSec(CrossSection maxxsec); 00167 00172 void skipEvents(); 00173 00175 00181 WeightOpt weightOption() const { return theWeightOption; } 00182 00187 double unitTolerance() const { return theUnitTolerance; } 00188 00192 const ReaderVector & readers() const { return theReaders; } 00193 00198 const ReaderSelector & selector() const { return theSelector; } 00199 00203 tLesHouchesReaderPtr currentReader() const { return theCurrentReader; } 00204 00208 void currentReader(tLesHouchesReaderPtr x) { theCurrentReader = x; } 00209 00211 00212 public: 00213 00220 void persistentOutput(PersistentOStream & os) const; 00221 00227 void persistentInput(PersistentIStream & is, int version); 00229 00236 static void Init(); 00237 00238 protected: 00239 00246 virtual IBPtr clone() const; 00247 00252 virtual IBPtr fullclone() const; 00254 00255 protected: 00256 00264 virtual void doinit(); 00265 00270 virtual void doinitrun(); 00271 00276 virtual void dofinish(); 00278 00279 protected: 00280 00284 ReaderVector & readers() { return theReaders; } 00285 00290 ReaderSelector & selector() { return theSelector; } 00291 00295 void setUnitTolerance(double); 00296 00300 XSecStat stats; 00301 00306 XSecStat histStats; 00307 00308 private: 00309 00313 ReaderVector theReaders; 00314 00319 ReaderSelector theSelector; 00320 00324 WeightOpt theWeightOption; 00325 00330 double theUnitTolerance; 00331 00335 tLesHouchesReaderPtr theCurrentReader; 00336 00341 bool warnPNum; 00342 00343 public: 00344 00349 class LesHouchesInitError: public InitException {}; 00350 00355 class LesHouchesPNumException: public InitException {}; 00358 private: 00359 00364 static ClassDescription<LesHouchesEventHandler> initLesHouchesEventHandler; 00365 00370 LesHouchesEventHandler & operator=(const LesHouchesEventHandler &); 00371 00372 }; 00373 00374 } 00375 00376 // CLASSDOC OFF 00377 00378 #include "ThePEG/Utilities/ClassTraits.h" 00379 00380 namespace ThePEG { 00381 00386 template <> 00387 struct BaseClassTrait<LesHouchesEventHandler,1> { 00389 typedef EventHandler NthBase; 00390 }; 00391 00394 template <> 00395 struct ClassTraits<LesHouchesEventHandler> 00396 : public ClassTraitsBase<LesHouchesEventHandler> { 00398 static string className() { return "ThePEG::LesHouchesEventHandler"; } 00402 static string library() { return "LesHouches.so"; } 00403 }; 00404 00407 } 00408 00409 #endif /* THEPEG_LesHouchesEventHandler_H */