CMS 3D CMS Logo

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 ()
 
virtual ~PomwigHadronizer ()
 
- 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
 
HepMC::GenEvent * getGenEvent ()
 
GenEventInfoProductgetGenEventInfo ()
 
virtual GenLumiInfoHeadergetGenLumiInfoHeader () const
 
GenRunInfoProductgetGenRunInfo ()
 
const boost::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 (HepMC::GenEvent *event)
 
void resetEventInfo (GenEventInfoProduct *eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (lhef::LHEEvent *event)
 
void setLHERunInfo (lhef::LHERunInfo *runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
virtual ~BaseHadronizer ()(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)
 
virtual ~Herwig6Instance ()
 
- 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 ()
 
virtual void doSetRandomEngine (CLHEP::HepRandomEngine *v) override
 
virtual 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::auto_ptr< HepMC::GenEvent > & event ()
 
std::auto_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 21 of file PomwigHadronizer.h.

Constructor & Destructor Documentation

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

Definition at line 94 of file PomwigHadronizer.cc.

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

94  :
95  BaseHadronizer(params),
96  needClear(false),
97  parameters(params.getParameter<edm::ParameterSet>("HerwigParameters")),
98  herwigVerbosity(params.getUntrackedParameter<int>("herwigVerbosity", 0)),
99  hepmcVerbosity(params.getUntrackedParameter<int>("hepmcVerbosity", 0)),
100  maxEventsToPrint(params.getUntrackedParameter<int>("maxEventsToPrint", 0)),
101  printCards(params.getUntrackedParameter<bool>("printCards", false)),
102  comEnergy(params.getParameter<double>("comEnergy")),
103  survivalProbability(params.getParameter<double>("survivalProbability")),
104  diffTopology(params.getParameter<int>("diffTopology")),
105  h1fit(params.getParameter<int>("h1fit")),
106  useJimmy(params.getParameter<bool>("useJimmy")),
107  doMPInteraction(params.getParameter<bool>("doMPInteraction")),
108  numTrials(params.getUntrackedParameter<int>("numTrialsMPI", 100)),
109  doPDGConvert(false)
110 {
111  if ( params.exists( "doPDGConvert" ) )
112  doPDGConvert = params.getParameter<bool>("doPDGConvert");
113 }
T getParameter(std::string const &) const
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
gen::PomwigHadronizer::~PomwigHadronizer ( )
virtual

Definition at line 115 of file PomwigHadronizer.cc.

References clear().

116 {
117  clear();
118 }

Member Function Documentation

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

Definition at line 41 of file PomwigHadronizer.h.

References findQualityFiles::v.

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

Definition at line 125 of file PomwigHadronizer.cc.

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

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

126 {
127  if (!needClear)
128  return;
129 
130  // teminate elementary process
131  call(hwefin);
132  if (useJimmy)
133  call(jmefin);
134 
135  needClear = false;
136 }
void call(void(&fn)())
#define jmefin
Definition: herwig.h:322
bool gen::PomwigHadronizer::decay ( )

Definition at line 358 of file PomwigHadronizer.cc.

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

359 {
360  // hadron decays
361 
362  InstanceWrapper wrapper(this); // safe guard
363 
364  hwdhad(); // unstable particle decays
365  hwdhvy(); // heavy flavour decays
366  hwmevt(); // soft underlying event
367 
368  hwufne(); // finalize event
369 
370  if (hwevnt.IERROR)
371  return false;
372 
373  event().reset(new HepMC::GenEvent);
374  if (!conv.fill_next_event(event().get()))
375  throw cms::Exception("PomwigError")
376  << "HepMC Conversion problems in event." << std::endl;
377 
378  // do particle ID conversion Herwig->PDG, if requested
379  if(doPDGConvert){
380  for ( HepMC::GenEvent::particle_iterator part = event()->particles_begin(); part != event()->particles_end(); ++part) {
381  if ((*part)->pdg_id() != HepPID::translateHerwigtoPDT((*part)->pdg_id()))
382  (*part)->set_pdg_id(HepPID::translateHerwigtoPDT((*part)->pdg_id()));
383  }
384  }
385 
386  return true;
387 }
std::auto_ptr< HepMC::GenEvent > & event()
HepMC::IO_HERWIG conv
part
Definition: HCALResponse.h:20
Definition: event.py:1
static HepMC::HEPEVT_Wrapper wrapper
bool gen::PomwigHadronizer::declareSpecialSettings ( const std::vector< std::string > &  )
inline

Definition at line 32 of file PomwigHadronizer.h.

References SelectingProcedure_cff::decay, and myMessageLogger_cff::statistics.

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

Definition at line 289 of file PomwigHadronizer.cc.

290 {
291  for(std::vector<int>::const_iterator iter = pdgIds.begin();
292  iter != pdgIds.end(); ++iter)
293  if (!markStable(*iter))
294  return false;
295  return true;
296 }
void gen::PomwigHadronizer::doSetRandomEngine ( CLHEP::HepRandomEngine *  v)
overrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 120 of file PomwigHadronizer.cc.

References gen::Herwig6Instance::setHerwigRandomEngine().

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

Reimplemented from gen::BaseHadronizer.

Definition at line 46 of file PomwigHadronizer.h.

References hitfit::clear().

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

Definition at line 349 of file PomwigHadronizer.cc.

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

350 {
352 
353  event()->set_signal_process_id(hwproc.IPROC);
354 
355  event()->weights().push_back(hwevnt.EVWGT);
356 }
static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event)
Definition: LHEEvent.cc:513
std::auto_ptr< HepMC::GenEvent > & event()
bool gen::PomwigHadronizer::generatePartonsAndHadronize ( )

Definition at line 314 of file PomwigHadronizer.cc.

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

315 {
316  // hard process generation, parton shower, hadron formation
317 
318  InstanceWrapper wrapper(this); // safe guard
319 
320  event().reset();
321 
322  // call herwig routines to create HEPEVT
323 
324  hwuine(); // initialize event
325 
326  if (callWithTimeout(10, hwepro)) { // process event and PS
327  // We hung for more than 10 seconds
328  int error = 199;
329  hwwarn_("HWHGUP", &error);
330  }
331 
332  hwbgen(); // parton cascades
333 
334  // call jimmy ... only if event is not killed yet by HERWIG
335  if (useJimmy && doMPInteraction && !hwevnt.IERROR && call_hwmsct())
336  return false;
337 
338  hwdhob(); // heavy quark decays
339  hwcfor(); // cluster formation
340  hwcdec(); // cluster decays
341 
342  // if event *not* killed by HERWIG, return true
343  if (!hwevnt.IERROR) return true;
344 
345  hwufne(); // finalize event
346  return false;
347 }
std::auto_ptr< HepMC::GenEvent > & event()
bool callWithTimeout(unsigned int secs, void(*fn)())
void hwwarn_(const char *method, int *id)
static HepMC::HEPEVT_Wrapper wrapper
bool gen::PomwigHadronizer::hadronize ( )

Definition at line 309 of file PomwigHadronizer.cc.

310 {
311  return false;
312 }
bool gen::PomwigHadronizer::initializeDPDF ( )
private

Definition at line 243 of file PomwigHadronizer.cc.

References printConversionInfo::aux, GetRecoTauVFromDQM_MC_cff::cl, edm::errors::Configuration, diffTopology, Exception, connectstrParser::f2, h1fit, qcd_1994, qcd_2006, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by initializeForInternalPartons().

244 {
245  // Initialize H1 pomeron/reggeon
246 
247  if(diffTopology == 3) return true;
248 
249  if((diffTopology != 0)&&(diffTopology != 1)&&(diffTopology != 2)) return false;
250 
251  int nstru = hwpram.NSTRU;
252  int ifit = h1fit;
253  if((nstru == 9)||(nstru == 10)){
254  if((ifit <= 0)||(ifit >= 7)){
255  throw edm::Exception(edm::errors::Configuration,"PomwigError")
256  <<" Attempted to set non existant H1 1997 fit index. Has to be 1...6";
257  }
258  std::string aux((nstru == 9)?"Pomeron":"Reggeon");
259  edm::LogVerbatim("") << " H1 1997 pdf's: " << aux << "\n"
260  << " IFIT = " << ifit;
261  double xp = 0.1;
262  double Q2 = 75.0;
263  double xpq[13];
264  qcd_1994(xp,Q2,xpq,ifit);
265  } else if((nstru >= 12)&&(nstru <= 15)){
266  bool isPom = (nstru == 12)||(nstru == 14);
267  bool isFitA = (nstru == 12)||(nstru == 13);
268  ifit = (isFitA)?1:2;
269  std::string aux_0((isFitA)?"A":"B");
270  std::string aux_1((isPom)?"Pomeron":"Reggeon");
271  edm::LogVerbatim("") << " H1 2006 Fit " << aux_0 << " " << aux_1 << "\n"
272  << " IFIT = "<< ifit;
273  double xp = 0.1;
274  double Q2 = 75.0;
275  double xpq[13];
276  double f2[2];
277  double fl[2];
278  double c2[2];
279  double cl[2];
280  qcd_2006(xp,Q2,ifit,xpq,f2,fl,c2,cl);
281  } else{
282  throw edm::Exception(edm::errors::Configuration,"PomwigError")
283  <<" Only running Pomeron H1 1997 (NSTRU=9), H1 2006 fit A (NSTRU=12) and H1 2006 fit B (NSTRU=14) or Reggeon H1 1997 (NSTRU=10), H1 2006 fit A (NSTRU=13) and H1 2006 fit B (NSTRU=15)";
284  }
285 
286  return true;
287 }
#define qcd_2006
#define qcd_1994
bool gen::PomwigHadronizer::initializeForExternalPartons ( )

Definition at line 138 of file PomwigHadronizer.cc.

139 {
140  return false;
141 }
bool gen::PomwigHadronizer::initializeForInternalPartons ( )

Definition at line 229 of file PomwigHadronizer.cc.

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

230 {
231 
232  call(hwuinc);
233 
234  hwusta("PI0 ",1);
235 
236  if(!initializeDPDF()) return false;
237 
238  call(hweini);
239 
240  return true;
241 }
void call(void(&fn)())
bool gen::PomwigHadronizer::readSettings ( int  )

Definition at line 143 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.

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

Definition at line 389 of file PomwigHadronizer.cc.

390 {
391  return true;
392 }
void gen::PomwigHadronizer::statistics ( )

Definition at line 298 of file PomwigHadronizer.cc.

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

299 {
300  double RNWGT = 1. / hwevnt.NWGTS;
301  double AVWGT = hwevnt.WGTSUM * RNWGT;
302 
303  double xsec = 1.0e3 * AVWGT;
304  xsec = survivalProbability*xsec;
305 
306  runInfo().setInternalXSec(xsec);
307 }
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()

Member Data Documentation

double gen::PomwigHadronizer::comEnergy
private

Definition at line 61 of file PomwigHadronizer.h.

Referenced by readSettings().

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

Definition at line 72 of file PomwigHadronizer.h.

Referenced by decay().

int gen::PomwigHadronizer::diffTopology
private

Definition at line 63 of file PomwigHadronizer.h.

Referenced by initializeDPDF(), and readSettings().

bool gen::PomwigHadronizer::doMPInteraction
private

Definition at line 67 of file PomwigHadronizer.h.

Referenced by generatePartonsAndHadronize().

bool gen::PomwigHadronizer::doPDGConvert
private

Definition at line 70 of file PomwigHadronizer.h.

Referenced by decay(), and PomwigHadronizer().

int gen::PomwigHadronizer::h1fit
private

Definition at line 64 of file PomwigHadronizer.h.

Referenced by initializeDPDF().

int gen::PomwigHadronizer::hepmcVerbosity
private

Definition at line 57 of file PomwigHadronizer.h.

int gen::PomwigHadronizer::herwigVerbosity
private

Definition at line 56 of file PomwigHadronizer.h.

Referenced by readSettings().

int gen::PomwigHadronizer::maxEventsToPrint
private

Definition at line 58 of file PomwigHadronizer.h.

Referenced by readSettings().

bool gen::PomwigHadronizer::needClear
private

Definition at line 53 of file PomwigHadronizer.h.

Referenced by clear(), and readSettings().

int gen::PomwigHadronizer::numTrials
private

Definition at line 68 of file PomwigHadronizer.h.

gen::ParameterCollector gen::PomwigHadronizer::parameters
private
bool gen::PomwigHadronizer::printCards
private

Definition at line 59 of file PomwigHadronizer.h.

double gen::PomwigHadronizer::survivalProbability
private

Definition at line 62 of file PomwigHadronizer.h.

Referenced by statistics().

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

Definition at line 66 of file PomwigHadronizer.h.

Referenced by clear(), and generatePartonsAndHadronize().