CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
gen::PomwigHadronizer Class Reference

#include <PomwigHadronizer.h>

Inheritance diagram for gen::PomwigHadronizer:
gen::BaseHadronizer gen::Herwig6Instance gen::FortranInstance

Public Member Functions

const char * classname () const
 
bool decay ()
 
bool declareSpecialSettings (const std::vector< std::string > &)
 
bool declareStableParticles (const std::vector< int > &pdgIds)
 
void finalizeEvent ()
 
bool generatePartonsAndHadronize ()
 
bool hadronize ()
 
bool initializeForExternalPartons ()
 
bool initializeForInternalPartons ()
 
 PomwigHadronizer (const edm::ParameterSet &params)
 
bool readSettings (int)
 
bool residualDecay ()
 
void statistics ()
 
 ~PomwigHadronizer () override
 
- Public Member Functions inherited from gen::BaseHadronizer
 BaseHadronizer (edm::ParameterSet const &ps)
 
void cleanLHE ()
 
void generateLHE (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine, unsigned int ncpu)
 
edm::EventgetEDMEvent () const
 
std::unique_ptr< HepMC::GenEventgetGenEvent ()
 
std::unique_ptr
< GenEventInfoProduct
getGenEventInfo ()
 
virtual std::unique_ptr
< GenLumiInfoHeader
getGenLumiInfoHeader () const
 
GenRunInfoProductgetGenRunInfo ()
 
std::unique_ptr< lhef::LHEEventgetLHEEvent ()
 
const std::shared_ptr
< lhef::LHERunInfo > & 
getLHERunInfo () const
 
const std::string & gridpackPath () const
 
int randomIndex () const
 
const std::string & randomInitConfigDescription () const
 
void randomizeIndex (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
 
void resetEvent (std::unique_ptr< HepMC::GenEvent > event)
 
void resetEventInfo (std::unique_ptr< GenEventInfoProduct > eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (std::unique_ptr< lhef::LHEEvent > event)
 
void setLHERunInfo (std::unique_ptr< lhef::LHERunInfo > runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
virtual ~BaseHadronizer () noexcept(false)
 
- Public Member Functions inherited from gen::Herwig6Instance
bool callWithTimeout (unsigned int secs, void(*fn)())
 
bool give (const std::string &line)
 
 Herwig6Instance ()
 
void openParticleSpecFile (const std::string fileName)
 
void setHerwigRandomEngine (CLHEP::HepRandomEngine *v)
 
 ~Herwig6Instance () override
 
- Public Member Functions inherited from gen::FortranInstance
void call (void(&fn)())
 
template<typename T >
T call (T(&fn)())
 
template<typename A >
void call (void(&fn)(A), A a)
 
template<typename T , typename A >
T call (T(&fn)(A), A a)
 
template<typename A1 , typename A2 >
void call (void(&fn)(A1, A2), A1 a1, A2 a2)
 
template<typename T , typename A1 , typename A2 >
T call (T(&fn)(A1, A2), A1 a1, A2 a2)
 
virtual void enter ()
 
 FortranInstance ()
 
virtual void leave ()
 
virtual void upEvnt ()
 
virtual void upInit ()
 
virtual bool upVeto ()
 
virtual ~FortranInstance () noexcept(false)
 

Private Member Functions

void clear ()
 
void doSetRandomEngine (CLHEP::HepRandomEngine *v) override
 
std::vector< std::string > const & doSharedResources () const override
 
bool initializeDPDF ()
 

Private Attributes

double comEnergy
 
HepMC::IO_HERWIG conv
 
int diffTopology
 
bool doMPInteraction
 
bool doPDGConvert
 
int h1fit
 
int hepmcVerbosity
 
int herwigVerbosity
 
int maxEventsToPrint
 
bool needClear
 
int numTrials
 
gen::ParameterCollector parameters
 
bool printCards
 
double survivalProbability
 
bool useJimmy
 

Static Private Attributes

static const std::vector
< std::string > 
theSharedResources
 

Additional Inherited Members

- Static Public Member Functions inherited from gen::FortranInstance
template<typename T >
static TgetInstance ()
 
- Static Public Attributes inherited from gen::FortranInstance
static const std::string kFortranInstance = "FortranInstance"
 
- Protected Member Functions inherited from gen::BaseHadronizer
std::unique_ptr
< HepMC::GenEvent > & 
event ()
 
std::unique_ptr
< GenEventInfoProduct > & 
eventInfo ()
 
lhef::LHEEventlheEvent ()
 
lhef::LHERunInfolheRunInfo ()
 
GenRunInfoProductrunInfo ()
 
- Protected Member Functions inherited from gen::Herwig6Instance
virtual bool hwwarn (const std::string &fn, int code)
 
- Protected Attributes inherited from gen::BaseHadronizer
std::string lheFile_
 
int randomIndex_
 

Detailed Description

Definition at line 20 of file PomwigHadronizer.h.

Constructor & Destructor Documentation

gen::PomwigHadronizer::PomwigHadronizer ( const edm::ParameterSet params)

Definition at line 91 of file PomwigHadronizer.cc.

References doPDGConvert, edm::ParameterSet::exists(), and edm::ParameterSet::getParameter().

92  : BaseHadronizer(params),
93  needClear(false),
94  parameters(params.getParameter<edm::ParameterSet>("HerwigParameters")),
95  herwigVerbosity(params.getUntrackedParameter<int>("herwigVerbosity", 0)),
96  hepmcVerbosity(params.getUntrackedParameter<int>("hepmcVerbosity", 0)),
97  maxEventsToPrint(params.getUntrackedParameter<int>("maxEventsToPrint", 0)),
98  printCards(params.getUntrackedParameter<bool>("printCards", false)),
99  comEnergy(params.getParameter<double>("comEnergy")),
100  survivalProbability(params.getParameter<double>("survivalProbability")),
101  diffTopology(params.getParameter<int>("diffTopology")),
102  h1fit(params.getParameter<int>("h1fit")),
103  useJimmy(params.getParameter<bool>("useJimmy")),
104  doMPInteraction(params.getParameter<bool>("doMPInteraction")),
105  numTrials(params.getUntrackedParameter<int>("numTrialsMPI", 100)),
106  doPDGConvert(false) {
107  if (params.exists("doPDGConvert"))
108  doPDGConvert = params.getParameter<bool>("doPDGConvert");
109  }
T getUntrackedParameter(std::string const &, T const &) const
BaseHadronizer(edm::ParameterSet const &ps)
bool exists(std::string const &parameterName) const
checks if a parameter exists
gen::ParameterCollector parameters
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
gen::PomwigHadronizer::~PomwigHadronizer ( )
override

Definition at line 111 of file PomwigHadronizer.cc.

References clear().

111 { clear(); }

Member Function Documentation

const char* gen::PomwigHadronizer::classname ( ) const
inline

Definition at line 39 of file PomwigHadronizer.h.

39 { return "PomwigHadronizer"; }
void gen::PomwigHadronizer::clear ( void  )
private

Definition at line 115 of file PomwigHadronizer.cc.

References gen::FortranInstance::call(), jmefin, needClear, and useJimmy.

Referenced by readSettings(), and ~PomwigHadronizer().

115  {
116  if (!needClear)
117  return;
118 
119  // teminate elementary process
120  call(hwefin);
121  if (useJimmy)
122  call(jmefin);
123 
124  needClear = false;
125  }
void call(void(&fn)())
#define jmefin
Definition: herwig.h:318
bool gen::PomwigHadronizer::decay ( )

Definition at line 335 of file PomwigHadronizer.cc.

References conv, doPDGConvert, gen::BaseHadronizer::event(), and wrapper.

335  {
336  // hadron decays
337 
338  InstanceWrapper wrapper(this); // safe guard
339 
340  hwdhad(); // unstable particle decays
341  hwdhvy(); // heavy flavour decays
342  hwmevt(); // soft underlying event
343 
344  hwufne(); // finalize event
345 
346  if (hwevnt.IERROR)
347  return false;
348 
349  event() = std::make_unique<HepMC::GenEvent>();
350  if (!conv.fill_next_event(event().get()))
351  throw cms::Exception("PomwigError") << "HepMC Conversion problems in event." << std::endl;
352 
353  // do particle ID conversion Herwig->PDG, if requested
354  if (doPDGConvert) {
355  for (HepMC::GenEvent::particle_iterator part = event()->particles_begin(); part != event()->particles_end();
356  ++part) {
357  if ((*part)->pdg_id() != HepPID::translateHerwigtoPDT((*part)->pdg_id()))
358  (*part)->set_pdg_id(HepPID::translateHerwigtoPDT((*part)->pdg_id()));
359  }
360  }
361 
362  return true;
363  }
std::unique_ptr< HepMC::GenEvent > & event()
HepMC::IO_HERWIG conv
part
Definition: HCALResponse.h:20
static HepMC::HEPEVT_Wrapper wrapper
bool gen::PomwigHadronizer::declareSpecialSettings ( const std::vector< std::string > &  )
inline

Definition at line 30 of file PomwigHadronizer.h.

30 { return true; }
bool gen::PomwigHadronizer::declareStableParticles ( const std::vector< int > &  pdgIds)

Definition at line 273 of file PomwigHadronizer.cc.

273  {
274  for (std::vector<int>::const_iterator iter = pdgIds.begin(); iter != pdgIds.end(); ++iter)
275  if (!markStable(*iter))
276  return false;
277  return true;
278  }
void gen::PomwigHadronizer::doSetRandomEngine ( CLHEP::HepRandomEngine *  v)
overrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 113 of file PomwigHadronizer.cc.

References gen::Herwig6Instance::setHerwigRandomEngine().

double v[5][pyjets_maxn]
void setHerwigRandomEngine(CLHEP::HepRandomEngine *v)
std::vector<std::string> const& gen::PomwigHadronizer::doSharedResources ( ) const
inlineoverrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 43 of file PomwigHadronizer.h.

References theSharedResources.

43 { return theSharedResources; }
static const std::vector< std::string > theSharedResources
void gen::PomwigHadronizer::finalizeEvent ( )

Definition at line 327 of file PomwigHadronizer.cc.

References gen::BaseHadronizer::event(), and lhef::LHEEvent::fixHepMCEventTimeOrdering().

327  {
329 
330  event()->set_signal_process_id(hwproc.IPROC);
331 
332  event()->weights().push_back(hwevnt.EVWGT);
333  }
static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event)
Definition: LHEEvent.cc:453
std::unique_ptr< HepMC::GenEvent > & event()
bool gen::PomwigHadronizer::generatePartonsAndHadronize ( )

Definition at line 292 of file PomwigHadronizer.cc.

References gen::Herwig6Instance::callWithTimeout(), doMPInteraction, relativeConstraints::error, gen::BaseHadronizer::event(), gen::hwwarn_(), useJimmy, and wrapper.

292  {
293  // hard process generation, parton shower, hadron formation
294 
295  InstanceWrapper wrapper(this); // safe guard
296 
297  event().reset();
298 
299  // call herwig routines to create HEPEVT
300 
301  hwuine(); // initialize event
302 
303  if (callWithTimeout(10, hwepro)) { // process event and PS
304  // We hung for more than 10 seconds
305  int error = 199;
306  hwwarn_("HWHGUP", &error);
307  }
308 
309  hwbgen(); // parton cascades
310 
311  // call jimmy ... only if event is not killed yet by HERWIG
312  if (useJimmy && doMPInteraction && !hwevnt.IERROR && call_hwmsct())
313  return false;
314 
315  hwdhob(); // heavy quark decays
316  hwcfor(); // cluster formation
317  hwcdec(); // cluster decays
318 
319  // if event *not* killed by HERWIG, return true
320  if (!hwevnt.IERROR)
321  return true;
322 
323  hwufne(); // finalize event
324  return false;
325  }
bool callWithTimeout(unsigned int secs, void(*fn)())
void hwwarn_(const char *method, int *id)
std::unique_ptr< HepMC::GenEvent > & event()
static HepMC::HEPEVT_Wrapper wrapper
bool gen::PomwigHadronizer::hadronize ( )

Definition at line 290 of file PomwigHadronizer.cc.

290 { return false; }
bool gen::PomwigHadronizer::initializeDPDF ( )
private

Definition at line 225 of file PomwigHadronizer.cc.

References printConversionInfo::aux, haddnano::cl, edm::errors::Configuration, diffTopology, Exception, validate-o2o-wbm::f2, h1fit, qcd_1994, qcd_2006, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by initializeForInternalPartons().

225  {
226  // Initialize H1 pomeron/reggeon
227 
228  if (diffTopology == 3)
229  return true;
230 
231  if ((diffTopology != 0) && (diffTopology != 1) && (diffTopology != 2))
232  return false;
233 
234  int nstru = hwpram.NSTRU;
235  int ifit = h1fit;
236  if ((nstru == 9) || (nstru == 10)) {
237  if ((ifit <= 0) || (ifit >= 7)) {
238  throw edm::Exception(edm::errors::Configuration, "PomwigError")
239  << " Attempted to set non existant H1 1997 fit index. Has to be 1...6";
240  }
241  std::string aux((nstru == 9) ? "Pomeron" : "Reggeon");
242  edm::LogVerbatim("") << " H1 1997 pdf's: " << aux << "\n"
243  << " IFIT = " << ifit;
244  double xp = 0.1;
245  double Q2 = 75.0;
246  double xpq[13];
247  qcd_1994(xp, Q2, xpq, ifit);
248  } else if ((nstru >= 12) && (nstru <= 15)) {
249  bool isPom = (nstru == 12) || (nstru == 14);
250  bool isFitA = (nstru == 12) || (nstru == 13);
251  ifit = (isFitA) ? 1 : 2;
252  std::string aux_0((isFitA) ? "A" : "B");
253  std::string aux_1((isPom) ? "Pomeron" : "Reggeon");
254  edm::LogVerbatim("") << " H1 2006 Fit " << aux_0 << " " << aux_1 << "\n"
255  << " IFIT = " << ifit;
256  double xp = 0.1;
257  double Q2 = 75.0;
258  double xpq[13];
259  double f2[2];
260  double fl[2];
261  double c2[2];
262  double cl[2];
263  qcd_2006(xp, Q2, ifit, xpq, f2, fl, c2, cl);
264  } else {
265  throw edm::Exception(edm::errors::Configuration, "PomwigError")
266  << " Only running Pomeron H1 1997 (NSTRU=9), H1 2006 fit A (NSTRU=12) and H1 2006 fit B (NSTRU=14) or "
267  "Reggeon H1 1997 (NSTRU=10), H1 2006 fit A (NSTRU=13) and H1 2006 fit B (NSTRU=15)";
268  }
269 
270  return true;
271  }
Log< level::Info, true > LogVerbatim
tuple cl
Definition: haddnano.py:49
#define qcd_2006
#define qcd_1994
bool gen::PomwigHadronizer::initializeForExternalPartons ( )

Definition at line 127 of file PomwigHadronizer.cc.

127 { return false; }
bool gen::PomwigHadronizer::initializeForInternalPartons ( )

Definition at line 212 of file PomwigHadronizer.cc.

References gen::FortranInstance::call(), and initializeDPDF().

212  {
213  call(hwuinc);
214 
215  hwusta("PI0 ", 1);
216 
217  if (!initializeDPDF())
218  return false;
219 
220  call(hweini);
221 
222  return true;
223  }
void call(void(&fn)())
bool gen::PomwigHadronizer::readSettings ( int  )

Definition at line 129 of file PomwigHadronizer.cc.

References gen::ParameterCollector::begin(), gen::FortranInstance::call(), clear(), comEnergy, edm::errors::Configuration, diffTopology, gen::ParameterCollector::end(), Exception, gen::Herwig6Instance::give(), herwigVerbosity, hwdspn, hwprch, mps_fire::i, geometryCSVtoXML::line, maxEventsToPrint, needClear, and parameters.

129  {
130  clear();
131 
132  edm::LogVerbatim("") << "----------------------------------------------\n"
133  << "Initializing PomwigHadronizer\n"
134  << "----------------------------------------------\n";
135 
136  // Call hwudat to set up HERWIG block data
137  hwudat();
138 
139  // Setting basic parameters ...
140  hwproc.PBEAM1 = comEnergy / 2.;
141  hwproc.PBEAM2 = comEnergy / 2.;
142  // Choose beam particles for POMWIG depending on topology
143  switch (diffTopology) {
144  case 0: //DPE
145  hwbmch.PART1[0] = 'E';
146  hwbmch.PART1[1] = '-';
147  hwbmch.PART2[0] = 'E';
148  hwbmch.PART2[1] = '-';
149  break;
150  case 1: //SD survive PART1
151  hwbmch.PART1[0] = 'E';
152  hwbmch.PART1[1] = '-';
153  hwbmch.PART2[0] = 'P';
154  hwbmch.PART2[1] = ' ';
155  break;
156  case 2: //SD survive PART2
157  hwbmch.PART1[0] = 'P';
158  hwbmch.PART1[1] = ' ';
159  hwbmch.PART2[0] = 'E';
160  hwbmch.PART2[1] = '-';
161  break;
162  case 3: //Non diffractive
163  hwbmch.PART1[0] = 'P';
164  hwbmch.PART1[1] = ' ';
165  hwbmch.PART2[0] = 'P';
166  hwbmch.PART2[1] = ' ';
167  break;
168  default:
169  throw edm::Exception(edm::errors::Configuration, "PomwigError")
170  << " Invalid Diff. Topology. Must be DPE(diffTopology = 0), SD particle 1 (diffTopology = 1), SD particle "
171  "2 (diffTopology = 2) and Non diffractive (diffTopology = 3)";
172  break;
173  }
174  for (int i = 2; i < 8; ++i) {
175  hwbmch.PART1[i] = ' ';
176  hwbmch.PART2[i] = ' ';
177  }
178 
179  // initialize other common blocks ...
180  call(hwigin);
181 
182  hwevnt.MAXER = 100000000; // O(inf)
183  hwpram.LWSUD = 0; // don't write Sudakov form factors
184  hwdspn.LWDEC = 0; // don't write three/four body decays
185  // (no fort.77 and fort.88 ...)a
186 
187  std::memset(hwprch.AUTPDF, ' ', sizeof hwprch.AUTPDF);
188  for (unsigned int i = 0; i < 2; i++) {
189  hwpram.MODPDF[i] = -111;
190  std::memcpy(hwprch.AUTPDF[i], "HWLHAPDF", 8);
191  }
192 
193  hwevnt.MAXPR = maxEventsToPrint;
194  hwpram.IPRINT = herwigVerbosity;
195 
196  edm::LogVerbatim("") << "------------------------------------\n"
197  << "Reading HERWIG parameters\n"
198  << "------------------------------------\n";
199 
201  edm::LogVerbatim("") << " " << *line;
202  if (!give(*line))
204  << "Herwig 6 did not accept the following: \"" << *line << "\"." << std::endl;
205  }
206 
207  needClear = true;
208 
209  return true;
210  }
Log< level::Info, true > LogVerbatim
void call(void(&fn)())
gen::ParameterCollector parameters
#define hwprch
Definition: herwig.h:60
bool give(const std::string &line)
#define hwdspn
Definition: herwig.h:220
const_iterator end() const
const_iterator begin() const
bool gen::PomwigHadronizer::residualDecay ( )

Definition at line 365 of file PomwigHadronizer.cc.

365 { return true; }
void gen::PomwigHadronizer::statistics ( )

Definition at line 280 of file PomwigHadronizer.cc.

References gen::BaseHadronizer::runInfo(), GenRunInfoProduct::setInternalXSec(), and survivalProbability.

280  {
281  double RNWGT = 1. / hwevnt.NWGTS;
282  double AVWGT = hwevnt.WGTSUM * RNWGT;
283 
284  double xsec = 1.0e3 * AVWGT;
285  xsec = survivalProbability * xsec;
286 
287  runInfo().setInternalXSec(xsec);
288  }
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()

Member Data Documentation

double gen::PomwigHadronizer::comEnergy
private

Definition at line 58 of file PomwigHadronizer.h.

Referenced by readSettings().

HepMC::IO_HERWIG gen::PomwigHadronizer::conv
private

Definition at line 69 of file PomwigHadronizer.h.

Referenced by decay().

int gen::PomwigHadronizer::diffTopology
private

Definition at line 60 of file PomwigHadronizer.h.

Referenced by initializeDPDF(), and readSettings().

bool gen::PomwigHadronizer::doMPInteraction
private

Definition at line 64 of file PomwigHadronizer.h.

Referenced by generatePartonsAndHadronize().

bool gen::PomwigHadronizer::doPDGConvert
private

Definition at line 67 of file PomwigHadronizer.h.

Referenced by decay(), and PomwigHadronizer().

int gen::PomwigHadronizer::h1fit
private

Definition at line 61 of file PomwigHadronizer.h.

Referenced by initializeDPDF().

int gen::PomwigHadronizer::hepmcVerbosity
private

Definition at line 54 of file PomwigHadronizer.h.

int gen::PomwigHadronizer::herwigVerbosity
private

Definition at line 53 of file PomwigHadronizer.h.

Referenced by readSettings().

int gen::PomwigHadronizer::maxEventsToPrint
private

Definition at line 55 of file PomwigHadronizer.h.

Referenced by readSettings().

bool gen::PomwigHadronizer::needClear
private

Definition at line 50 of file PomwigHadronizer.h.

Referenced by clear(), and readSettings().

int gen::PomwigHadronizer::numTrials
private

Definition at line 65 of file PomwigHadronizer.h.

gen::ParameterCollector gen::PomwigHadronizer::parameters
private

Definition at line 52 of file PomwigHadronizer.h.

Referenced by readSettings().

bool gen::PomwigHadronizer::printCards
private

Definition at line 56 of file PomwigHadronizer.h.

double gen::PomwigHadronizer::survivalProbability
private

Definition at line 59 of file PomwigHadronizer.h.

Referenced by statistics().

const std::vector< std::string > gen::PomwigHadronizer::theSharedResources
staticprivate
bool gen::PomwigHadronizer::useJimmy
private

Definition at line 63 of file PomwigHadronizer.h.

Referenced by clear(), and generatePartonsAndHadronize().