CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | 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 ()
 
- Public Member Functions inherited from gen::BaseHadronizer
 BaseHadronizer (edm::ParameterSet const &ps)
 
edm::EventgetEDMEvent () const
 
HepMC::GenEvent * getGenEvent ()
 
GenEventInfoProductgetGenEventInfo ()
 
GenRunInfoProductgetGenRunInfo ()
 
const boost::shared_ptr
< lhef::LHERunInfo > & 
getLHERunInfo () const
 
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
 
 ~BaseHadronizer ()
 
- Public Member Functions inherited from gen::Herwig6Instance
bool callWithTimeout (unsigned int secs, void(*fn)())
 
bool give (const std::string &line)
 
 Herwig6Instance (CLHEP::HepRandomEngine *randomEngine=0)
 
 Herwig6Instance (int dummy)
 
void openParticleSpecFile (const std::string fileName)
 
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 ()
 

Private Member Functions

void clear ()
 
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
 

Additional Inherited Members

- Static Public Member Functions inherited from gen::FortranInstance
template<typename T >
static TgetInstance ()
 
- 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)
 

Detailed Description

Definition at line 14 of file PomwigHadronizer.h.

Constructor & Destructor Documentation

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

Definition at line 89 of file PomwigHadronizer.cc.

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

89  :
90  BaseHadronizer(params),
91  needClear(false),
92  parameters(params.getParameter<edm::ParameterSet>("HerwigParameters")),
93  herwigVerbosity(params.getUntrackedParameter<int>("herwigVerbosity", 0)),
94  hepmcVerbosity(params.getUntrackedParameter<int>("hepmcVerbosity", 0)),
95  maxEventsToPrint(params.getUntrackedParameter<int>("maxEventsToPrint", 0)),
96  printCards(params.getUntrackedParameter<bool>("printCards", false)),
97  comEnergy(params.getParameter<double>("comEnergy")),
98  survivalProbability(params.getParameter<double>("survivalProbability")),
99  diffTopology(params.getParameter<int>("diffTopology")),
100  h1fit(params.getParameter<int>("h1fit")),
101  useJimmy(params.getParameter<bool>("useJimmy")),
102  doMPInteraction(params.getParameter<bool>("doMPInteraction")),
103  numTrials(params.getUntrackedParameter<int>("numTrialsMPI", 100)),
104  doPDGConvert(false)
105 {
106  if ( params.exists( "doPDGConvert" ) )
107  doPDGConvert = params.getParameter<bool>("doPDGConvert");
108 }
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 ( )

Definition at line 110 of file PomwigHadronizer.cc.

References clear().

111 {
112  clear();
113 }

Member Function Documentation

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

Definition at line 34 of file PomwigHadronizer.h.

34 { 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().

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

Definition at line 348 of file PomwigHadronizer.cc.

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

349 {
350  // hadron decays
351 
352  InstanceWrapper wrapper(this); // safe guard
353 
354  hwdhad(); // unstable particle decays
355  hwdhvy(); // heavy flavour decays
356  hwmevt(); // soft underlying event
357 
358  hwufne(); // finalize event
359 
360  if (hwevnt.IERROR)
361  return false;
362 
363  event().reset(new HepMC::GenEvent);
364  if (!conv.fill_next_event(event().get()))
365  throw cms::Exception("PomwigError")
366  << "HepMC Conversion problems in event." << std::endl;
367 
368  // do particle ID conversion Herwig->PDG, if requested
369  if(doPDGConvert){
370  for ( HepMC::GenEvent::particle_iterator part = event()->particles_begin(); part != event()->particles_end(); ++part) {
371  if ((*part)->pdg_id() != HepPID::translateHerwigtoPDT((*part)->pdg_id()))
372  (*part)->set_pdg_id(HepPID::translateHerwigtoPDT((*part)->pdg_id()));
373  }
374  }
375 
376  return true;
377 }
std::auto_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 25 of file PomwigHadronizer.h.

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

Definition at line 279 of file PomwigHadronizer.cc.

280 {
281  for(std::vector<int>::const_iterator iter = pdgIds.begin();
282  iter != pdgIds.end(); ++iter)
283  if (!markStable(*iter))
284  return false;
285  return true;
286 }
void gen::PomwigHadronizer::finalizeEvent ( )

Definition at line 339 of file PomwigHadronizer.cc.

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

340 {
342 
343  event()->set_signal_process_id(hwproc.IPROC);
344 
345  event()->weights().push_back(hwevnt.EVWGT);
346 }
static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event)
Definition: LHEEvent.cc:518
std::auto_ptr< HepMC::GenEvent > & event()
bool gen::PomwigHadronizer::generatePartonsAndHadronize ( )

Definition at line 304 of file PomwigHadronizer.cc.

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

305 {
306  // hard process generation, parton shower, hadron formation
307 
308  InstanceWrapper wrapper(this); // safe guard
309 
310  event().reset();
311 
312  // call herwig routines to create HEPEVT
313 
314  hwuine(); // initialize event
315 
316  if (callWithTimeout(10, hwepro)) { // process event and PS
317  // We hung for more than 10 seconds
318  int error = 199;
319  hwwarn_("HWHGUP", &error);
320  }
321 
322  hwbgen(); // parton cascades
323 
324  // call jimmy ... only if event is not killed yet by HERWIG
325  if (useJimmy && doMPInteraction && !hwevnt.IERROR && call_hwmsct())
326  return false;
327 
328  hwdhob(); // heavy quark decays
329  hwcfor(); // cluster formation
330  hwcdec(); // cluster decays
331 
332  // if event *not* killed by HERWIG, return true
333  if (!hwevnt.IERROR) return true;
334 
335  hwufne(); // finalize event
336  return false;
337 }
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 299 of file PomwigHadronizer.cc.

300 {
301  return false;
302 }
bool gen::PomwigHadronizer::initializeDPDF ( )
private

Definition at line 233 of file PomwigHadronizer.cc.

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

Referenced by initializeForInternalPartons().

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

Definition at line 128 of file PomwigHadronizer.cc.

129 {
130  return false;
131 }
bool gen::PomwigHadronizer::initializeForInternalPartons ( )

Definition at line 219 of file PomwigHadronizer.cc.

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

220 {
221 
222  call(hwuinc);
223 
224  hwusta("PI0 ",1);
225 
226  if(!initializeDPDF()) return false;
227 
228  call(hweini);
229 
230  return true;
231 }
void call(void(&fn)())
bool gen::PomwigHadronizer::readSettings ( int  )

Definition at line 133 of file PomwigHadronizer.cc.

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

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

380 {
381  return true;
382 }
void gen::PomwigHadronizer::statistics ( )

Definition at line 288 of file PomwigHadronizer.cc.

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

289 {
290  double RNWGT = 1. / hwevnt.NWGTS;
291  double AVWGT = hwevnt.WGTSUM * RNWGT;
292 
293  double xsec = 1.0e3 * AVWGT;
294  xsec = survivalProbability*xsec;
295 
296  runInfo().setInternalXSec(xsec);
297 }
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()

Member Data Documentation

double gen::PomwigHadronizer::comEnergy
private

Definition at line 48 of file PomwigHadronizer.h.

Referenced by readSettings().

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

Definition at line 59 of file PomwigHadronizer.h.

Referenced by decay().

int gen::PomwigHadronizer::diffTopology
private

Definition at line 50 of file PomwigHadronizer.h.

Referenced by initializeDPDF(), and readSettings().

bool gen::PomwigHadronizer::doMPInteraction
private

Definition at line 54 of file PomwigHadronizer.h.

Referenced by generatePartonsAndHadronize().

bool gen::PomwigHadronizer::doPDGConvert
private

Definition at line 57 of file PomwigHadronizer.h.

Referenced by decay(), and PomwigHadronizer().

int gen::PomwigHadronizer::h1fit
private

Definition at line 51 of file PomwigHadronizer.h.

Referenced by initializeDPDF().

int gen::PomwigHadronizer::hepmcVerbosity
private

Definition at line 44 of file PomwigHadronizer.h.

int gen::PomwigHadronizer::herwigVerbosity
private

Definition at line 43 of file PomwigHadronizer.h.

Referenced by readSettings().

int gen::PomwigHadronizer::maxEventsToPrint
private

Definition at line 45 of file PomwigHadronizer.h.

Referenced by readSettings().

bool gen::PomwigHadronizer::needClear
private

Definition at line 40 of file PomwigHadronizer.h.

Referenced by clear(), and readSettings().

int gen::PomwigHadronizer::numTrials
private

Definition at line 55 of file PomwigHadronizer.h.

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

Definition at line 46 of file PomwigHadronizer.h.

double gen::PomwigHadronizer::survivalProbability
private

Definition at line 49 of file PomwigHadronizer.h.

Referenced by statistics().

bool gen::PomwigHadronizer::useJimmy
private

Definition at line 53 of file PomwigHadronizer.h.

Referenced by clear(), and generatePartonsAndHadronize().