CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ThePEGLesHouchesInterface.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iostream>
3 #include <sstream>
4 #include <string>
5 #include <memory>
6 #include <set>
7 
8 #include <boost/shared_ptr.hpp>
9 
10 #include <ThePEG/Interface/ClassDocumentation.h>
11 #include <ThePEG/Interface/InterfacedBase.h>
12 #include <ThePEG/Interface/Parameter.h>
13 #include <ThePEG/Utilities/ClassTraits.h>
14 
15 #include <ThePEG/LesHouches/LesHouches.h>
16 #include <ThePEG/LesHouches/LesHouchesReader.h>
17 
19 
21 
25 
26 using namespace lhef;
27 
28 namespace ThePEG {
29 
30 class LesHouchesInterface : public LesHouchesReader {
31  public:
33  virtual ~LesHouchesInterface();
34 
35  static void Init();
36 
37  protected:
38  virtual IBPtr clone() const { return new_ptr(*this); }
39  virtual IBPtr fullclone() const { return new_ptr(*this); }
40 
41  private:
42  virtual void open();
43  virtual void close();
44  virtual long scan();
45 
46  virtual double eventWeight();
47  virtual double reweight();
48  virtual double getEvent();
49  virtual bool doReadEvent();
50 
53 
54  static ClassDescription<LesHouchesInterface> initLesHouchesInterface;
55 };
56 
57 // registration with ThePEG plugin system
58 
59 template<>
60 struct BaseClassTrait<LesHouchesInterface, 1> : public ClassTraitsType {
62  typedef LesHouchesReader NthBase;
63 };
64 
65 template<>
66 struct ClassTraits<LesHouchesInterface> :
67  public ClassTraitsBase<LesHouchesInterface> {
68  static string className() { return "ThePEG::LesHouchesInterface"; }
69  static string library() { return "pluginGeneratorInterfaceThePEGHadronisation.so"; }
70 };
71 
72 } // namespace ThePEG
73 
74 using namespace ThePEG;
75 
76 LesHouchesInterface::LesHouchesInterface() :
77  initialized(false)
78 {
79 }
80 
82 {
83 }
84 
86 {
87  return 1000000000;
88 }
89 
91 {
92  const LHERunInfo *runInfo = LHEProxy::find(proxyID)->getRunInfo().get();
93  const lhef::HEPRUP &orig = *runInfo->getHEPRUP();
94 
95  heprup.IDBMUP = orig.IDBMUP;
96  heprup.EBMUP = orig.EBMUP;
97  heprup.PDFGUP = orig.PDFGUP;
98  heprup.PDFSUP = orig.PDFSUP;
99  heprup.NPRUP = orig.NPRUP;
100  heprup.LPRUP = orig.LPRUP;
101  heprup.XSECUP = orig.XSECUP;
102  heprup.XERRUP = orig.XERRUP;
103  heprup.XMAXUP = orig.XMAXUP;
104 
105  // We are cheating here, ThePEG does not need to know the real
106  // weighting method, as it complains about anything but 3 anyway.
107  // We just need to trick ThePEG into just processing each event
108  // passed without doing anything fancy with it (and shut up).
109  heprup.IDWTUP = 1;
110 }
111 
113 {
114 }
115 
117 {
118  return 1.0;
119 }
120 
121 // no reweighting
123 {
124  preweight = 1.0;
125  return 1.0;
126 }
127 
128 // overwrite parent routine doing fancy stuff and just pass the event
130 {
131  reset();
132 
133  if (!doReadEvent())
134  return 0.0;
135 
136  if (!initialized && !checkPartonBin())
137  throw cms::Exception("ThePEGLesHouchesInterface")
138  << "Found event which cannot be handled by "
139  << "the assigned PartonExtractor." << std::endl;
140  initialized = true;
141 
142  fillEvent();
143  getSubProcess();
144 
145  return 1.0;
146 }
147 
149 {
150  reset();
151 
152  boost::shared_ptr<LHEEvent> event =
153  LHEProxy::find(proxyID)->releaseEvent();
154  if (!event)
155  throw Stop();
156 
157  hepeup.XPDWUP.first = hepeup.XPDWUP.second = 0;
158 
159  const lhef::HEPEUP &orig = *event->getHEPEUP();
160 
161  hepeup.NUP = orig.NUP;
162  hepeup.IDPRUP = orig.IDPRUP;
163  hepeup.XWGTUP = orig.XWGTUP;
164  hepeup.SCALUP = orig.SCALUP;
165  hepeup.AQEDUP = orig.AQEDUP;
166  hepeup.AQCDUP = orig.AQCDUP;
167  hepeup.resize();
168 
169  std::copy(orig.IDUP.begin(), orig.IDUP.end(), hepeup.IDUP.begin());
170  hepeup.ISTUP = orig.ISTUP;
171  hepeup.MOTHUP = orig.MOTHUP;
172  hepeup.ICOLUP = orig.ICOLUP;
173  hepeup.VTIMUP = orig.VTIMUP;
174  hepeup.SPINUP = orig.SPINUP;
175 
176  for(int i = 0; i < hepeup.NUP; i++)
177  std::copy(&orig.PUP[i].x[0], &orig.PUP[i].x[5],
178  hepeup.PUP[i].begin());
179 
180  fillEvent();
181 
182  return true;
183 }
184 
185 // register with ThePEG plugin system
186 
187 ClassDescription<LesHouchesInterface> LesHouchesInterface::initLesHouchesInterface;
188 
190  typedef LHEProxy::ProxyID ProxyID;
191 
192  static ClassDocumentation<LesHouchesInterface> documentation
193  ("ThePEG::LesHouchesInterface interfaces with LHEInterface");
194 
195  static Parameter<LesHouchesInterface, ProxyID> interfaceProxyID
196  ("ProxyID", "The ProxyID.",
197  &LesHouchesInterface::proxyID, ProxyID(),
198  ProxyID(), ProxyID(), false, false, false);
199 
200  interfaceProxyID.rank(11);
201 }
int i
Definition: DBlmapReader.cc:9
std::pair< double, double > EBMUP
Definition: LesHouches.h:78
std::vector< double > VTIMUP
Definition: LesHouches.h:254
std::pair< int, int > IDBMUP
Definition: LesHouches.h:73
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::pair< int, int > PDFGUP
Definition: LesHouches.h:84
std::vector< std::pair< int, int > > MOTHUP
Definition: LesHouches.h:236
std::vector< FiveVector > PUP
Definition: LesHouches.h:248
std::vector< double > SPINUP
Definition: LesHouches.h:261
std::vector< int > ISTUP
Definition: LesHouches.h:230
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< int > IDUP
Definition: LesHouches.h:225
std::vector< double > XERRUP
Definition: LesHouches.h:114
std::vector< double > XMAXUP
Definition: LesHouches.h:119
double AQCDUP
Definition: LesHouches.h:220
const HEPRUP * getHEPRUP() const
Definition: LHERunInfo.h:52
unsigned long ProxyID
Definition: LHEProxy.h:14
std::pair< int, int > PDFSUP
Definition: LesHouches.h:90
double AQEDUP
Definition: LesHouches.h:215
volatile std::atomic< bool > shutdown_flag false
std::vector< double > XSECUP
Definition: LesHouches.h:108
static ClassDescription< LesHouchesInterface > initLesHouchesInterface
void reset(double vett[256])
Definition: TPedValues.cc:11
double XWGTUP
Definition: LesHouches.h:196
std::vector< std::pair< int, int > > ICOLUP
Definition: LesHouches.h:242
std::vector< int > LPRUP
Definition: LesHouches.h:124
double SCALUP
Definition: LesHouches.h:210