ThePEG  1.8.0
StandardEventHandler.h
1 // -*- C++ -*-
2 //
3 // StandardEventHandler.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_StandardEventHandler_H
10 #define ThePEG_StandardEventHandler_H
11 // This is the declaration of the StandardEventHandler class.
12 
13 #include "ThePEG/Config/ThePEG.h"
14 #include "ThePEG/Handlers/EventHandler.h"
15 #include "ThePEG/Repository/Strategy.fh"
16 #include "ThePEG/Handlers/SamplerBase.fh"
17 #include "ThePEG/PDF/PartonBin.fh"
18 #include "ThePEG/MatrixElement/MEBase.fh"
19 #include "SubProcessHandler.fh"
20 #include "StandardXComb.fh"
21 #include "StandardEventHandler.fh"
22 #include <fstream>
23 
24 namespace ThePEG {
25 
44 
45 public:
46 
48  typedef vector<SubHdlPtr> SubHandlerList;
49 
52 
54  typedef vector<StdXCombPtr> XVector;
55 
57  typedef vector<CrossSection> XSVector;
58 
61  typedef map<tMEPtr,XVector> MEXMap;
62 
63 public:
64 
71 
75  virtual ~StandardEventHandler();
77 
78 public:
79 
84  virtual void initialize();
85 
90  virtual void statistics(ostream &) const;
91 
97  virtual CrossSection histogramScale() const;
98 
104  virtual CrossSection integratedXSec() const;
105 
111  virtual CrossSection integratedXSecErr() const;
112 
118  virtual CrossSection integratedXSecNoReweight() const;
119 
126 
134  virtual CrossSection dSigDR(const vector<double> & r);
135 
139  virtual EventPtr generateEvent();
140 
145  virtual EventPtr continueEvent();
146 
150  void reweight(double factor) const;
151 
155  const XVector & xCombs() const { return theXCombs; }
156 
160  virtual void select(tXCombPtr newXComb);
161 
168 
176  tCutsPtr cuts() const { return theCuts; }
177 
182  int nBins() const;
183 
188  int maxDim(int bin) const { return theMaxDims[bin]; }
189 
193  bool weighted() const { return weightedEvents; }
194 
199  int lumiDim() const { return theLumiDim; }
200 
205  int nDim(int bin) const { return lumiDim() + maxDim(bin); }
207 
208 protected:
209 
223  virtual CrossSection dSigDR(const pair<double,double> ll, Energy2 maxS,
224  int ibin, int nr, const double * r);
225 
231  tStdXCombPtr select(int bin, double & weight);
232 
246  void addME(Energy maxEnergy, tSubHdlPtr sub, tPExtrPtr extractor,
247  tCutsPtr cuts, tCascHdlPtr ckkw, tMEPtr me, const PBPair & pBins,
248  const PartonPairVec& allPBins);
249 
255 
263  virtual void initGroups();
264 
272 
276  void setScale(Energy2);
277 
281  XVector & xCombs() { return theXCombs; }
282 
286  const XSVector & xSecs() const { return theXSecs; }
287 
291  XSVector & xSecs() { return theXSecs; }
292 
300  int binStrategy() const { return theBinStrategy; }
301 
302 private:
303 
307  const SubHandlerList & subProcesses() const { return theSubProcesses; }
308 
313 
314 public:
315 
321  virtual void doupdate();
322 
328  virtual void doinit();
329 
334  virtual void doinitrun();
335 
340  virtual void dofinish();
342 
349  void persistentOutput(PersistentOStream & os) const;
350 
356  void persistentInput(PersistentIStream & is, int version);
358 
362  static void Init();
363 
364 protected:
365 
372  virtual IBPtr clone() const;
373 
378  virtual IBPtr fullclone() const;
380 
385  void reject(double weight);
386 
391 
395  tcSamplerPtr sampler() const { return theSampler; }
396 
397 private:
398 
409 
414 
419 
424 
430 
439 
445 
450  vector<int> theMaxDims;
451 
457 
462 
469 
475 
480 
484  void setIncomingA(PDPtr);
485 
489  void setIncomingB(PDPtr);
490 
491 protected:
492 
498  class StandardEventHandlerUpdateException: public UpdateException {};
499 
504  class StandardEventHandlerInitError: public Exception {};
507 private:
508 
513 
514 };
515 
522 template <>
523 struct BaseClassTrait<StandardEventHandler,1>: public ClassTraitsType {
525  typedef EventHandler NthBase;
526 };
527 
532 template <>
533 struct ClassTraits<StandardEventHandler>
534  : public ClassTraitsBase<StandardEventHandler> {
538  static string className() { return "ThePEG::StandardEventHandler"; }
539 };
540 
543 }
544 
545 #endif /* ThePEG_StandardEventHandler_H */