Public Member Functions | |
Herwig6Hadronisation (const edm::ParameterSet ¶ms) | |
~Herwig6Hadronisation () | |
Protected Member Functions | |
void | fillEvent () |
void | fillHeader () |
Private Member Functions | |
std::set< std::string > | capabilities () const |
void | clear () |
std::auto_ptr< HepMC::GenEvent > | doHadronisation () |
void | doInit () |
void | newRunInfo (const boost::shared_ptr< LHERunInfo > &runInfo) |
Private Attributes | |
char * | buffer |
bool | builtinPDFs |
HepMC::IO_HERWIG | conv |
bool | doMPInteraction |
int | herwigVerbosity |
std::string | lhapdfSetPath |
int | maxEventsToPrint |
bool | needClear |
int | numTrials |
std::vector< std::string > | paramLines |
bool | useJimmy |
Friends | |
struct | FortranCallback |
Classes | |
struct | FortranCallback |
Definition at line 39 of file Herwig6Hadronisation.cc.
lhef::Herwig6Hadronisation::Herwig6Hadronisation | ( | const edm::ParameterSet & | params | ) |
Definition at line 177 of file Herwig6Hadronisation.cc.
References lat::endl(), edm::ParameterSet::getParameter(), iter, parsecf::pyparsing::line(), and paramLines.
00177 : 00178 Hadronisation(params), 00179 herwigVerbosity(params.getUntrackedParameter<int>("herwigVerbosity", 0)), 00180 maxEventsToPrint(params.getUntrackedParameter<int>("maxEventsToPrint", 0)), 00181 useJimmy(params.getUntrackedParameter<bool>("useJimmy", true)), 00182 doMPInteraction(params.getUntrackedParameter<bool>("doMPInteraction", true)), 00183 numTrials(params.getUntrackedParameter<int>("numTrialsMPI", 100)), 00184 builtinPDFs(params.getUntrackedParameter<bool>("builtinPDFs", true)), 00185 lhapdfSetPath(params.getUntrackedParameter<std::string>("lhapdfSetPath", "")), 00186 needClear(false), 00187 buffer(0) 00188 { 00189 std::vector<std::string> setNames = 00190 params.getParameter< std::vector<std::string> >("parameterSets"); 00191 00192 for(std::vector<std::string>::const_iterator iter = setNames.begin(); 00193 iter != setNames.end(); ++iter) { 00194 std::vector<std::string> lines = 00195 params.getParameter< std::vector<std::string> >(*iter); 00196 00197 for(std::vector<std::string>::const_iterator 00198 line = lines.begin(); line != lines.end(); ++line) { 00199 if (line->substr(0, 6) == "NRN(1)" || 00200 line->substr(0, 6) == "NRN(2)") 00201 throw cms::Exception("HerwigError") 00202 << "Attempted to set random number" 00203 " using Herwig command 'NRN(.)'." 00204 " Please use the" 00205 " RandomNumberGeneratorService." 00206 << std::endl; 00207 00208 paramLines.push_back(*line); 00209 } 00210 } 00211 }
lhef::Herwig6Hadronisation::~Herwig6Hadronisation | ( | ) |
std::set< std::string > lhef::Herwig6Hadronisation::capabilities | ( | ) | const [private, virtual] |
Reimplemented from lhef::Hadronisation.
Definition at line 1270 of file Herwig6Hadronisation.cc.
References HLT_VtxMuL3::result.
01271 { 01272 std::set<std::string> result; 01273 result.insert("showeredEvent"); 01274 result.insert("hepevt"); 01275 return result; 01276 }
Reimplemented from lhef::Hadronisation.
Definition at line 278 of file Herwig6Hadronisation.cc.
References jmefin, needClear, and useJimmy.
Referenced by newRunInfo(), and ~Herwig6Hadronisation().
00279 { 00280 if (!needClear) 00281 return; 00282 00283 // teminate elementary process 00284 hwefin(); 00285 if (useJimmy) 00286 jmefin(); 00287 00288 needClear = false; 00289 }
std::auto_ptr< HepMC::GenEvent > lhef::Herwig6Hadronisation::doHadronisation | ( | ) | [private, virtual] |
Implements lhef::Hadronisation.
Definition at line 316 of file Herwig6Hadronisation.cc.
References buffer, conv, counter(), doMPInteraction, lat::endl(), error, event(), Exception, lhef::LHEEvent::fixHepMCEventTimeOrdering(), lhef::fixupStatus(), lhef::fortranCallback, lhef::Hadronisation::getRawEvent(), lhef::hepevtSize(), hwmsct_dummy, lhef::hwwarn_(), lhef::Herwig6Hadronisation::FortranCallback::instance, numTrials, lhef::Hadronisation::showeredEvent(), lhef::timeout(), useJimmy, lhef::Hadronisation::wantsShoweredEvent(), and lhef::Hadronisation::wantsShoweredEventAsHepMC().
00317 { 00318 std::auto_ptr<HepMC::GenEvent> event; 00319 00320 try { 00321 assert(!fortranCallback.instance); 00322 fortranCallback.instance = this; 00323 00324 int counter = 0; 00325 while(counter++ < numTrials) { 00326 // call herwig routines to create HEPEVT 00327 hwuine(); // initialize event 00328 if (timeout(10, hwepro)) { // process event and PS 00329 // We hung for more than 10 seconds 00330 int error = 199; 00331 hwwarn_("HWHGUP", &error); 00332 } 00333 00334 bool vetoed = false; // matching and veto 00335 if (wantsShoweredEvent() && !hwevnt.IERROR) { 00336 boost::shared_ptr<HepMC::GenEvent> event; 00337 00338 if (wantsShoweredEventAsHepMC()) { 00339 // save HEPEVT since repair_hepevt breaks it 00340 std::memcpy(buffer, hepevt.data, 00341 hepevtSize()); 00342 event.reset(conv.read_next_event()); 00343 std::memcpy(hepevt.data, buffer, 00344 hepevtSize()); 00345 00346 fixupStatus(event.get()); 00347 } 00348 00349 if (showeredEvent(event)) { 00350 hwevnt.IERROR = 198; 00351 vetoed = true; 00352 } 00353 } 00354 00355 hwbgen(); // parton cascades 00356 00357 // call jimmy ... only if event is not killed yet by HERWIG 00358 if (useJimmy && doMPInteraction && !hwevnt.IERROR && 00359 hwmsct_dummy(1.1) > 0.5) 00360 continue; 00361 00362 hwdhob(); // heavy quark decays 00363 hwcfor(); // cluster formation 00364 hwcdec(); // cluster decays 00365 hwdhad(); // unstable particle decays 00366 hwdhvy(); // heavy flavour decays 00367 hwmevt(); // soft underlying event 00368 hwufne(); // finalize event 00369 00370 if (vetoed) { 00371 fortranCallback.instance = 0; 00372 return event; 00373 } 00374 00375 // if event was not killed by HERWIG retry 00376 if (!hwevnt.IERROR) 00377 break; 00378 } 00379 00380 fortranCallback.instance = 0; 00381 00382 if (counter >= numTrials) { 00383 edm::LogWarning("Generator|LHEInterface") 00384 << "JIMMY could not produce MI in " 00385 << numTrials << " trials." << std::endl 00386 << "Event will be skipped to prevent" 00387 << " from deadlock." << std::endl; 00388 00389 return event; 00390 } 00391 } catch(...) { 00392 fortranCallback.instance = 0; 00393 throw; 00394 } 00395 00396 event.reset(new HepMC::GenEvent); 00397 if (!conv.fill_next_event(event.get())) 00398 throw cms::Exception("HerwigError") 00399 << "HepMC Conversion problems in event." << std::endl; 00400 00401 fixupStatus(event.get()); 00402 LHEEvent::fixHepMCEventTimeOrdering(event.get()); 00403 00404 getRawEvent()->fillEventInfo(event.get()); 00405 00406 HepMC::PdfInfo pdf; 00407 getRawEvent()->fillPdfInfo(&pdf); 00408 event->set_pdf_info(pdf); 00409 00410 return event; 00411 }
void lhef::Herwig6Hadronisation::doInit | ( | ) | [private, virtual] |
Implements lhef::Hadronisation.
Definition at line 219 of file Herwig6Hadronisation.cc.
References buffer, builtinPDFs, lat::endl(), Exception, herwigVerbosity, lhef::hwgive(), hwprop, iter, jimmin, jmparm, lhapdfSetPath, maxEventsToPrint, lhef::mysetpdfpath_(), paramLines, lhef::setherwpdf_(), lhef::setRngSeeds(), useJimmy, and lhef::Hadronisation::wantsShoweredEvent().
00220 { 00221 if (wantsShoweredEvent()) 00222 buffer = new char[sizeof hepevt]; 00223 00224 // Call hwudat to set up HERWIG block data 00225 hwudat(); 00226 00227 // Setting basic parameters (doesn't matter, overridden by LHEF) 00228 hwproc.PBEAM1 = 7000.0; 00229 hwproc.PBEAM2 = 7000.0; 00230 std::memset(hwbmch.PART1, ' ', 8); 00231 std::memset(hwbmch.PART2, ' ', 8); 00232 hwbmch.PART1[0] = 'P'; 00233 hwbmch.PART2[0] = 'P'; 00234 00235 if (useJimmy) 00236 jmparm.MSFLAG = 1; 00237 00238 // initialize other common blocks ... 00239 hwigin(); 00240 hwevnt.MAXER = 1000000; 00241 00242 if (!builtinPDFs) { 00243 // set the LHAPDF grid directory and path 00244 if (lhapdfSetPath == "") { 00245 const char *lhaPdfs = getenv("LHAPATH"); 00246 if (!lhaPdfs) 00247 throw cms::Exception("ConfigError") 00248 << "LHAPATH not set." << std::endl; 00249 lhapdfSetPath = std::string(lhaPdfs); 00250 } 00251 lhapdfSetPath.resize(232, ' '); 00252 setherwpdf_(); 00253 mysetpdfpath_(lhapdfSetPath.c_str()); 00254 } 00255 00256 if (useJimmy) 00257 jimmin(); 00258 00259 // set some 'non-herwig' defaults 00260 hwevnt.MAXPR = maxEventsToPrint; 00261 hwpram.IPRINT = herwigVerbosity; 00262 hwprop.RMASS[6] = 175.0; 00263 00264 for(std::vector<std::string>::const_iterator iter = paramLines.begin(); 00265 iter != paramLines.end(); ++iter) { 00266 if (!hwgive(*iter)) 00267 throw cms::Exception("HerwigError") 00268 << "Herwig did not accept \"" 00269 << *iter << "\"." << std::endl; 00270 } 00271 00272 edm::Service<edm::RandomNumberGenerator> rng; 00273 if (!setRngSeeds(rng->mySeed())) 00274 throw cms::Exception("HerwigError") 00275 << "Impossible error in setting 'NRN(.)'."; 00276 }
void lhef::Herwig6Hadronisation::fillEvent | ( | ) | [protected] |
Definition at line 1294 of file Herwig6Hadronisation.cc.
References lhef::CommonBlocks::fillHEPEUP(), lhef::Hadronisation::getRawEvent(), and lhef::Hadronisation::onBeforeHadronisation().
Referenced by lhef::Herwig6Hadronisation::FortranCallback::upevnt().
01295 { 01296 const HEPEUP *hepeup = getRawEvent()->getHEPEUP(); 01297 01298 CommonBlocks::fillHEPEUP(hepeup); 01299 01300 onBeforeHadronisation().emit(); 01301 }
void lhef::Herwig6Hadronisation::fillHeader | ( | ) | [protected] |
Definition at line 1278 of file Herwig6Hadronisation.cc.
References builtinPDFs, lhef::CommonBlocks::fillHEPRUP(), lhef::Hadronisation::getRawEvent(), heprup_, lhef::Hadronisation::onInit(), HEPRUP_::pdfgup, and HEPRUP_::pdfsup.
Referenced by lhef::Herwig6Hadronisation::FortranCallback::upinit().
01279 { 01280 const HEPRUP *heprup = getRawEvent()->getHEPRUP(); 01281 01282 CommonBlocks::fillHEPRUP(heprup); 01283 01284 if (builtinPDFs) { 01285 heprup_.pdfgup[0] = -1; 01286 heprup_.pdfgup[1] = -1; 01287 heprup_.pdfsup[0] = -1; 01288 heprup_.pdfsup[1] = -1; 01289 } 01290 01291 onInit().emit(); 01292 }
void lhef::Herwig6Hadronisation::newRunInfo | ( | const boost::shared_ptr< LHERunInfo > & | runInfo | ) | [private, virtual] |
Reimplemented from lhef::Hadronisation.
Definition at line 413 of file Herwig6Hadronisation.cc.
References clear(), lhef::fortranCallback, lhef::Herwig6Hadronisation::FortranCallback::instance, jminit, needClear, and useJimmy.
00415 { 00416 clear(); 00417 try { 00418 assert(!fortranCallback.instance); 00419 fortranCallback.instance = this; 00420 00421 needClear = true; 00422 00423 // set user process to LHEF reader 00424 hwproc.IPROC = -1; 00425 00426 hwuinc(); 00427 hwusta("PI0 ", 8); 00428 hweini(); 00429 if (useJimmy) 00430 jminit(); 00431 00432 fortranCallback.instance = 0; 00433 } catch(...) { 00434 fortranCallback.instance = 0; 00435 throw; 00436 } 00437 }
friend struct FortranCallback [friend] |
Definition at line 44 of file Herwig6Hadronisation.cc.
char* lhef::Herwig6Hadronisation::buffer [private] |
Definition at line 72 of file Herwig6Hadronisation.cc.
Referenced by doHadronisation(), doInit(), and ~Herwig6Hadronisation().
bool lhef::Herwig6Hadronisation::builtinPDFs [private] |
HepMC::IO_HERWIG lhef::Herwig6Hadronisation::conv [private] |
std::string lhef::Herwig6Hadronisation::lhapdfSetPath [private] |
bool lhef::Herwig6Hadronisation::needClear [private] |
int lhef::Herwig6Hadronisation::numTrials [private] |
std::vector<std::string> lhef::Herwig6Hadronisation::paramLines [private] |
Definition at line 68 of file Herwig6Hadronisation.cc.
Referenced by doInit(), and Herwig6Hadronisation().
bool lhef::Herwig6Hadronisation::useJimmy [private] |
Definition at line 63 of file Herwig6Hadronisation.cc.
Referenced by clear(), doHadronisation(), doInit(), and newRunInfo().