agile is hosted by Hepforge, IPPP Durham

FHerwigJimmy.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "AGILe/FHerwig/FHerwigJimmy.hh"
00003 #include "AGILe/FHerwig/FHerwig.hh"
00004 #include "AGILe/FHerwig/FHerwigWrapper65.hh"
00005 #include "AGILe/FHerwig/JimmyWrapper.hh"
00006 #include "AGILe/Utils.hh"
00007 
00008 
00009 namespace AGILe {
00010 
00011   // Standard constructor
00012   FHerwigJimmy::FHerwigJimmy() {
00013     _myName = "HerwigJimmy";
00014 
00015     // NB. FHerwig constructor gets automatically called first.
00016     FC_JMPARM.JMBUG = 0;
00017     // Initialise Jimmy common blocks.
00018     FC_JIMMIN();
00019   }
00020 
00021 
00022   // Run generator initialization
00023   void FHerwigJimmy::initialize() {
00024     FHerwig::initialize();
00025 
00026     // Initialise Jimmy.
00027     if (FC_JMPARM.MSFLAG == 1) {
00028       FC_JMINIT();
00029     }
00030 
00031     _initialized = true;
00032   }
00033 
00034 
00035   // Set parameters.
00036   bool FHerwigJimmy::setParam(const string& name, const string& value) {
00037     Generator::setParam(name, value);
00038 
00039     // Integers.
00040     if (name == "JMUEO") {
00041       MSG_INFO("Setting JMUEO = " << asInt(value));
00042       FC_JMPARM.JMUEO = asInt(value);
00043     } else if (name == "JMBUG") {
00044       MSG_INFO("Setting JMBUG = " << asInt(value));
00045       FC_JMPARM.JMBUG = asInt(value);
00046     } else if (name == "MSFLAG") {
00047       MSG_INFO("Setting MSFLAG = " << asInt(value));
00048       FC_JMPARM.MSFLAG = asInt(value);
00049     }
00050 
00051     // Doubles.
00052     else if (name == "PTJIM") {
00053       MSG_INFO("Setting minimum PT for secondary scatters (PTJIM) = " << asDouble(value));
00054       FC_JMPARM.PTJIM = asDouble(value);
00055     } else if (name == "PHAD") {
00056       MSG_INFO("Setting hadronic photon inverse probability (PHAD) = " << asDouble(value));
00057       FC_JMPARM.PHAD = asDouble(value);
00058     } else if (name == "PRRAD") {
00059       MSG_INFO("Setting 1/(Proton radius)2 (PRRAD) = " << asDouble(value));
00060       FC_JMPARM.JMRAD[72] = asDouble(value);
00061       FC_JMPARM.JMRAD[74] = asDouble(value);
00062       FC_JMPARM.JMRAD[90] = asDouble(value);
00063       FC_JMPARM.JMRAD[92] = asDouble(value);
00064     } else if (name == "PHRAD") {
00065       MSG_INFO("Setting 1/(Photon radius)2 (PRRAD) = " << asDouble(value));
00066       FC_JMPARM.JMRAD[58]  = asDouble(value);
00067       FC_JMPARM.JMRAD[120] = asDouble(value);
00068       FC_JMPARM.JMRAD[126] = asDouble(value);
00069     }
00070 
00071     // Boolean (as int).
00072     else if (name == "ANOMOFF") {
00073       MSG_INFO("Setting MI in anomalous photon events (ANOMOFF) = " << asInt(value));
00074       FC_JMPARM.ANOMOFF = asInt(value);
00075     }
00076 
00077     // Fall back to FHerwig.
00078     else if (FHerwig::setParam(name, value) != SUCCESS) {
00079       MSG_ERROR(getName() << " doesn't have a parameter called " << name);
00080       return FAILURE;
00081     }
00082     return SUCCESS;
00083   }
00084 
00085 
00086   // Run the generator for one event
00088   void FHerwigJimmy::makeEvent(HepMC::GenEvent& evt) {
00089     Generator::makeEvent(evt);
00090     while (true) {
00091       int counter(0);
00092       // Repeat the first stages of event generation until multiple
00093       // scattering succeeds (or isn't run at all).
00094       while (true) {
00095         counter += 1;
00096 
00097         FC_HWUINE();  // Initialize event
00098         FC_HWEPRO();  // Generate hard subprocess
00099         FC_HWBGEN();  // Generate parton cascade
00100 
00101         // Call the multiple scattering routine with the abort flag.
00102         // If abort is returned with value 1 (true), then abandon the
00103         // event. This implementation makes sure that the event generation
00104         // continues if multiple scattering is disabled (MSFLAG != 1)
00105         int abort(0);
00106         if (FC_JMPARM.MSFLAG == 1) FC_HWMSCT(&abort);
00107         // If MS is okay or disabled, escape the loop and
00108         // continue with the decays and hadronisation.
00109         if (abort == 0) {
00110           MSG_DEBUG("Num attempts to make MPI = " << counter);
00111           break;
00112         }
00113 
00114         // Check for too many attempts to make MPI scatters
00115         if (counter > 100) {
00116           throw runtime_error("Too many attempts to make MPI in FHerwigJimmy");
00117         }
00118       }
00119       FC_HWDHOB();  // Do heavy quark decays
00120       if (_doHadronise) {
00121         FC_HWCFOR();  // Do cluster formation
00122         FC_HWCDEC();  // Do cluster decays
00123         FC_HWDHAD();  // Do unstable particle decays
00124         FC_HWDHVY();  // Do heavy flavor decays
00125         FC_HWMEVT();  // Add soft underlying event
00126       }
00127       FC_HWUFNE();  // Finish event
00128       if (FC_HWEVNT.IERROR == 0) break;
00129     }
00130     clearEvent(evt);
00131     fillEvent(evt);
00132   }
00133 
00134 
00136   void FHerwigJimmy::finalize() {
00137     FHerwig::finalize();
00138     if (FC_JMPARM.MSFLAG == 1) {
00139       FC_JMEFIN();
00140     }
00141   }
00142 
00143 
00144 }
00145 
00146 
00147 // Class factory
00148 extern "C" {
00149   AGILe::Generator* create() { return new AGILe::FHerwigJimmy(); }
00150   void destroy(AGILe::Generator* gen) { delete gen; }
00151 }
Generated on Tue Mar 6 10:39:38 2012 for AGILe - A Generator Interface Library (+ executable) by  doxygen 1.6.3