agile is hosted by Hepforge, IPPP Durham

Cascade.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "AGILe/Cascade/Cascade.hh"
00003 #include "AGILe/Cascade/CascadeWrapper2.hh"
00004 #include "AGILe/Utils.hh"
00005 #include "AGILe/HepMCTools.hh"
00006 
00007 #include "HepMC/HEPEVT_Wrapper.h"
00008 
00009 
00010 //-----------------------------------------------------------------------------
00011 // Implementation file for Cascade helper class.
00012 //
00013 // Authors: Doug Gingrich
00014 //          Andy Buckley
00015 //          Holger Schulz
00016 //-----------------------------------------------------------------------------
00017 
00018 
00019 namespace AGILe {
00020 
00021 
00022   // Standard constructor
00023   Cascade::Cascade() {
00024     HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
00025     HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00026 
00027     // Start counting events at 1.
00028     _nevt = 1;
00029   }
00030 
00032   void Cascade::initialize() {
00033     Generator::initialize();
00034     //Cascade::setParam("LEPI", "2212");
00035     //Cascade::setParam("HADI", "2212");
00036       //int ISEED = 213123;
00037       //int N1 = 0;
00038       //int N2 = 0;
00039       //call_rm48in(ISEED, N1, N2);
00040 
00041     // Initialise Cascade parameters
00042     getLog() << Log::INFO << "Initialise Cascade parameters (CASINI)..." << endl;
00043     call_casini();
00044     getLog() << Log::INFO << "CASINI is done..." << endl;
00045 
00046     // Read steering file
00047     getLog() << Log::INFO << "Now calling Steer..." << endl;
00048     getLog() << Log::INFO << "In case nothing happens from this point on," << endl;
00049     getLog() << Log::INFO << "make sure you specified a cascade steering file on CL:" << endl;
00050     getLog() << Log::INFO << "agile-runmc CascadePythia6:423:HEAD < steer_pp ... " << endl;
00051     call_steer();
00052     getLog() << Log::INFO << "Steer is done..." << endl;
00053 
00054     // Change standard parameters of Cascade
00055     getLog() << Log::INFO << "Change standard Cascade parameters (CASCHA)..." << endl;
00056     call_cascha();
00057     getLog() << Log::INFO << "CASCHA is done..." << endl;
00058 
00059     // Change standard parameters of Pythia
00060     getLog() << Log::INFO << "Change standard Pythia parameters (PYTCHA)..." << endl;
00061     call_pytcha();
00062     getLog() << Log::INFO << "PYTCHA is done..." << endl;
00063     //Cascade::setParam("IFPS", 3);
00064 
00065     // Switch on QCD processes by default
00066     //getLog() << Log::INFO << "Setup basic processes..." << endl;
00067     //Cascade::setParam("IPRO", 18);
00068     //Cascade::setParam("IDIR", 0);  // Don't do DIS but diffractive stuff by default
00069     //Cascade::setParam("INTER", 2);  // Switch to charged current interaction
00073 
00074     // Perform internal Cascade remnant treatment
00075     Cascade::setParam("ILHA", 0);
00076 
00077     // Set time
00078     getLog() << Log::INFO << "Calling PTIME..." << endl;
00079     const char* name = "cascade";
00080     int j = 1;
00081     int k = 0;
00082     call_ptime(name, j, k);
00083 
00084     // Run cascade
00085     getLog() << Log::INFO << "Now performing basic cross-section integration (CASCADE)..." << endl;
00086     call_cascade();
00087     getLog() << Log::INFO << "CASCADE is done..." << endl;
00088 
00089     // Summary of integration result
00090     call_caend(1);
00091 
00092     _initialized = true;
00093   }
00094 
00095   void Cascade::setGenSpecificInitialState(PdgCode p1, double e1, PdgCode p2, double e2) {
00096     getLog() << Log::INFO << "Setting initial state..." << endl;
00097     Cascade::setParam("KBE1", p1);
00098     Cascade::setParam("KBE2", p2);
00099     Cascade::setParam("PBE1", e1);
00100     Cascade::setParam("PBE2", e2);
00101   }
00102 
00103   // Run the generator for one event
00104   void Cascade::makeEvent(HepMC::GenEvent& evt) {
00105     Generator::makeEvent(evt);
00106     getLog() << Log::DEBUG << "Fill event Nr: " << _nevt << endl;
00107     call_event();
00108     getLog() << Log::DEBUG << "Call pyhepc " << endl;
00109     call_pyhepc(1);
00110 
00111     // fill the event using HepMC
00112     Cascade::fillEvent(evt);
00113     evt.set_event_number(_nevt);
00114     // Increment an event counter (Cascade does not count for itself (?)).
00115     _nevt++;
00116   }
00117 
00118   // Fill a HepMC event
00119   void Cascade::fillEvent(HepMC::GenEvent& evt) {
00120     _hepevt.fill_next_event(&evt);
00121     fixHepMCUnitsFromGeVmm(evt);
00122     #ifdef HEPMC_HAS_CROSS_SECTION
00123     const double xsecval = getCrossSection();
00124     const double xsecerr = FC_CAEFFIC.SD;
00125     getLog() << Log::DEBUG << "Writing cross-section = " << xsecval << " +- " << xsecerr << endl;
00126     HepMC::GenCrossSection xsec;
00127     xsec.set_cross_section(xsecval, xsecerr);
00128     evt.set_cross_section(xsec);
00129     #endif
00130   }
00131 
00132   const double Cascade::getCrossSection(){
00133     _crossSection = FC_CAEFFIC.AVGI * 1000.0;
00134     return _crossSection;
00135   }
00136 
00137   // Set string parameters
00138   bool Cascade::setParam(const string& name, const string& value) {
00139     Generator::setParam(name, value);
00140 
00142     if (name == "PBE1") {
00143       getLog() << Log::INFO << "Setting ... (PBE1) = " << value << endl;
00144       FC_CABEAM.PBEAM[0] = -1*asDouble(value);
00145     }
00146     else if (name == "PBE2") {
00147       getLog() << Log::INFO << "Setting ... (PBE2) = " << value << endl;
00148       FC_CABEAM.PBEAM[1] = asDouble(value);
00149     }
00150 
00152     else if (name == "IFPS") {
00153       getLog() << Log::INFO << "Setting ... (IFPS) = " << value << endl;
00154       FC_CAINPU.IFPS = asInt(value);
00155     }
00156     else if (name == "ILHA") {
00157       getLog() << Log::INFO << "Setting ... (ILHA) = " << value << endl;
00158       FC_CAHERUP.Ilha = asInt(value);
00159     }
00160     else if (name == "KBE1") {
00161       getLog() << Log::INFO << "Setting ... (KBE1) = " << value << endl;
00162       FC_CABEAM.KBEAM[0] = asInt(value);
00163     }
00164     else if (name == "KBE2") {
00165       getLog() << Log::INFO << "Setting ... (KBE2) = " << value << endl;
00166       FC_CABEAM.KBEAM[1] = asInt(value);
00167     }
00168 
00169     else {
00170       getLog() << Log::ERROR << "Cascade doesn't have a parameter called " << name << endl;
00171       //return FAILURE;
00172     }
00173     return SUCCESS;
00174   }
00175 
00176   // Tidy up after ourselves
00177   void Cascade::finalize() {
00178     getLog() << Log::INFO << "Finalising..." << endl;
00179     // Print out stats from run
00180     call_caend(20);
00181   }
00182 
00183 }
00184 
00185 extern "C" {
00186   AGILe::Generator* create() { return new AGILe::Cascade(); }
00187   void destroy(AGILe::Generator* gen) { delete gen; }
00188 }
Generated on Tue Mar 6 10:39:38 2012 for AGILe - A Generator Interface Library (+ executable) by  doxygen 1.6.3