00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <iostream>
00010 #include "time.h"
00011
00012 #include "GeneratorInterface/PyquenInterface/interface/PyquenSource.h"
00013 #include "GeneratorInterface/PyquenInterface/interface/PYR.h"
00014 #include "GeneratorInterface/PyquenInterface/interface/PyquenWrapper.h"
00015 #include "GeneratorInterface/CommonInterface/interface/PythiaCMS.h"
00016
00017 #include "SimDataFormats/HepMCProduct/interface/GenInfoProduct.h"
00018 #include "SimDataFormats/HiGenData/interface/GenHIEvent.h"
00019 #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
00020 #include "FWCore/Framework/interface/Event.h"
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 #include "FWCore/ServiceRegistry/interface/Service.h"
00023 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00024
00025 #include "HepMC/IO_HEPEVT.h"
00026 #include "HepMC/PythiaWrapper.h"
00027
00028 using namespace edm;
00029 using namespace std;
00030
00031 HepMC::IO_HEPEVT hepevtio;
00032
00033 PyquenSource :: PyquenSource(const ParameterSet & pset, InputSourceDescription const& desc):
00034 GeneratedInputSource(pset, desc), evt(0),
00035 abeamtarget_(pset.getParameter<double>("aBeamTarget")),
00036 angularspecselector_(pset.getParameter<int>("angularSpectrumSelector")),
00037 bfixed_(pset.getParameter<double>("bFixed")),
00038 cflag_(pset.getParameter<int>("cFlag")),
00039 comenergy(pset.getParameter<double>("comEnergy")),
00040 doquench_(pset.getParameter<bool>("doQuench")),
00041 doradiativeenloss_(pset.getParameter<bool>("doRadiativeEnLoss")),
00042 docollisionalenloss_(pset.getParameter<bool>("doCollisionalEnLoss")),
00043 nquarkflavor_(pset.getParameter<int>("numQuarkFlavor")),
00044 qgpt0_(pset.getParameter<double>("qgpInitialTemperature")),
00045 qgptau0_(pset.getParameter<double>("qgpProperTimeFormation")),
00046 maxEventsToPrint_(pset.getUntrackedParameter<int>("maxEventsToPrint",1)),
00047 pythiaHepMCVerbosity_(pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false)),
00048 pythiaPylistVerbosity_(pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0))
00049 {
00050
00051
00052
00053
00054 pythiaPylistVerbosity_ = pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0);
00055 LogDebug("PYLISTverbosity") << "Pythia PYLIST verbosity level = " << pythiaPylistVerbosity_ << endl;
00056
00057
00058 pythiaHepMCVerbosity_ = pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false);
00059 LogDebug("HepMCverbosity") << "Pythia HepMC verbosity = " << pythiaHepMCVerbosity_ << endl;
00060
00061
00062 maxEventsToPrint_ = pset.getUntrackedParameter<int>("maxEventsToPrint",0);
00063 LogDebug("Events2Print") << "Number of events to be printed = " << maxEventsToPrint_ << endl;
00064
00065
00066 pyqpythia_init(pset);
00067
00068
00069 pyquen_init(pset);
00070
00071
00072 call_pyinit("CMS", "p", "p", comenergy);
00073
00074 cout<<endl;
00075
00076 produces<HepMCProduct>();
00077 produces<GenInfoProduct, edm::InRun>();
00078 }
00079
00080
00081
00082 PyquenSource::~PyquenSource()
00083 {
00084
00085
00086 call_pystat(1);
00087
00088 clear();
00089 }
00090
00091
00092
00093 void PyquenSource::add_heavy_ion_rec(HepMC::GenEvent *evt)
00094 {
00095 HepMC::HeavyIon *hi = new HepMC::HeavyIon(
00096 -1,
00097 -1,
00098 -1,
00099 -1,
00100 -1,
00101 -1,
00102 -1,
00103 -1,
00104 -1,
00105 plfpar.bgen,
00106 0,
00107 0,
00108 -1
00109 );
00110
00111 evt->set_heavy_ion(*hi);
00112
00113 delete hi;
00114 }
00115
00116
00117
00118 bool PyquenSource::call_pygive(const std::string& iParm )
00119 {
00120
00121
00122 int numWarn = pydat1.mstu[26];
00123 int numErr = pydat1.mstu[22];
00124
00125 PYGIVE( iParm.c_str(), iParm.length() );
00126
00127
00128 return pydat1.mstu[26] == numWarn && pydat1.mstu[22] == numErr;
00129 }
00130
00131
00132
00133 void PyquenSource::clear()
00134 {
00135 }
00136
00137
00138
00139 bool PyquenSource::produce(Event & e)
00140 {
00141 edm::LogInfo("PYQUENabeamtarget") << "##### PYQUEN: beam/target A = " << abeamtarget_;
00142 edm::LogInfo("PYQUENcflag") << "##### PYQUEN: centrality flag cflag_ = " << cflag_;
00143 edm::LogInfo("PYQUENbfixed") << "##### PYQUEN: fixed impact parameter bFixed = " << bfixed_;
00144 edm::LogInfo("PYQUENinNFlav") << "##### PYQUEN: No active quark flavor nf = " << pyqpar.nfu;
00145 edm::LogInfo("PYQUENinTemp") << "##### PYQUEN: Initial temperature of QGP, T0 = " << pyqpar.T0u;
00146 edm::LogInfo("PYQUENinTau") << "##### PYQUEN: Proper formation time of QGP, tau0 =" << pyqpar.tau0u;
00147
00148
00149
00150 call_pyevnt();
00151
00152
00153
00154 if( doquench_ ){
00155 PYQUEN(abeamtarget_,cflag_,bfixed_);
00156 edm::LogInfo("PYQUENinAction") << "##### Calling PYQUEN("<<abeamtarget_<<","<<cflag_<<","<<bfixed_<<") ####";
00157 } else {
00158 edm::LogInfo("PYQUENinAction") << "##### Calling PYQUEN: QUENCHING OFF!! This is just PYTHIA !!!! ####";
00159 }
00160
00161
00162 PYEXEC();
00163
00164
00165 call_pyhepc(1);
00166
00167
00168 HepMC::GenEvent* evt = hepevtio.read_next_event();
00169 evt->set_signal_process_id(pypars.msti[0]);
00170 evt->set_event_scale(pypars.pari[16]);
00171 evt->set_event_number(numberEventsInRun() - remainingEvents() - 1);
00172
00173 add_heavy_ion_rec(evt);
00174
00175 auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
00176 bare_product->addHepMCData(evt );
00177 e.put(bare_product);
00178
00179
00180 if( event() <= maxEventsToPrint_ && ( pythiaPylistVerbosity_ || pythiaHepMCVerbosity_ )) {
00181
00182 if( pythiaPylistVerbosity_ ){
00183 call_pylist(pythiaPylistVerbosity_);
00184 }
00185
00186
00187 if( pythiaHepMCVerbosity_ ){
00188 cout << "Event process = " << pypars.msti[0] << endl;
00189 evt->print();
00190 }
00191 }
00192
00193 return true;
00194 }
00195
00196
00197
00198 bool PyquenSource::pyqpythia_init(const ParameterSet & pset)
00199 {
00200
00201
00202
00203 edm::Service<RandomNumberGenerator> rng;
00204 randomEngine = &(rng->getEngine());
00205 uint32_t seed = rng->mySeed();
00206 ostringstream sRandomSet;
00207 sRandomSet << "MRPY(1)=" << seed;
00208 call_pygive(sRandomSet.str());
00209
00210
00211 if(doquench_){
00212 string sHadOff("MSTP(111)=0");
00213 call_pygive(sHadOff);
00214 }
00215
00216
00217 ParameterSet pythia_params = pset.getParameter<ParameterSet>("PythiaParameters") ;
00218
00219
00220 vector<string> setNames = pythia_params.getParameter<vector<string> >("parameterSets");
00221
00222
00223 for ( unsigned i=0; i<setNames.size(); ++i ) {
00224 string mySet = setNames[i];
00225
00226
00227 vector<string> pars = pythia_params.getParameter<vector<string> >(mySet);
00228
00229 cout << "----------------------------------------------" << endl;
00230 cout << "Read PYTHIA parameter set " << mySet << endl;
00231 cout << "----------------------------------------------" << endl;
00232
00233
00234 for( vector<string>::const_iterator itPar = pars.begin(); itPar != pars.end(); ++itPar ) {
00235 static string sRandomValueSetting("MRPY(1)");
00236 if( 0 == itPar->compare(0,sRandomValueSetting.size(),sRandomValueSetting) ) {
00237 throw edm::Exception(edm::errors::Configuration,"PythiaError")
00238 << " Attempted to set random number using 'MRPY(1)'. NOT ALLOWED!\n"
00239 " Use RandomNumberGeneratorService to set the random number seed.";
00240 }
00241 if( !call_pygive(*itPar) ) {
00242 throw edm::Exception(edm::errors::Configuration,"PythiaError")
00243 << "PYTHIA did not accept \""<<*itPar<<"\"";
00244 }
00245 }
00246 }
00247
00248 return true;
00249 }
00250
00251
00252
00253 bool PyquenSource::pyquen_init(const ParameterSet &pset)
00254 {
00255
00256
00257
00258 pyqpar.ianglu = angularspecselector_;
00259
00260
00261 if( doradiativeenloss_ && docollisionalenloss_ ){
00262 edm::LogInfo("PYQUENinEnLoss") << "##### PYQUEN: Radiative AND Collisional partonic energy loss ON ####";
00263 pyqpar.ienglu = 0;
00264 } else if ( doradiativeenloss_ ) {
00265 edm::LogInfo("PYQUENinRad") << "##### PYQUEN: Only RADIATIVE partonic energy loss ON ####";
00266 pyqpar.ienglu = 1;
00267 } else if ( docollisionalenloss_ ) {
00268 edm::LogInfo("PYQUENinColl") << "##### PYQUEN: Only COLLISIONAL partonic energy loss ON ####";
00269 pyqpar.ienglu = 2;
00270 } else {
00271 edm::LogInfo("PYQUENinEnLoss") << "##### PYQUEN: Radiative AND Collisional partonic energy loss ON ####";
00272 pyqpar.ienglu = 0;
00273 }
00274
00275
00276 pyqpar.nfu = nquarkflavor_;
00277
00278
00279 pyqpar.T0u = qgpt0_;
00280
00281
00282 pyqpar.tau0u = qgptau0_;
00283
00284 return true;
00285 }
00286
00287
00288