8 #include "HepMC/GenEvent.h"
10 #include "SHERPA/Main/Sherpa.H"
11 #include "ATOOLS/Org/Message.H"
12 #include "ATOOLS/Math/Random.H"
13 #include "ATOOLS/Org/Exception.H"
14 #include "ATOOLS/Org/Run_Parameter.H"
15 #include "ATOOLS/Org/MyStrStream.H"
16 #include "SHERPA/Tools/Input_Output_Handler.H"
17 #include "SHERPA/Tools/HepMC2_Interface.H"
40 const char *
classname()
const {
return "SherpaHadronizer"; }
63 double Get()
override;
69 BaseHadronizer(params),
70 SherpaParameterSet(params.getParameter<edm::
ParameterSet>(
"SherpaParameters"))
87 int retval=Fetcher.Fetch();
89 std::cout <<
"SherpaHadronizer: Preparation of Sherpack failed ... " << std::endl;
90 std::cout <<
"SherpaHadronizer: Error code: " << retval << std::endl;
98 for (
unsigned i=0;
i<setNames.size(); ++
i ) {
101 std::cout <<
"Write Sherpa parameter set " << setNames[
i] <<
" to "<<setNames[
i]<<
".dat "<<std::endl;
103 std::ofstream os(datfile.c_str());
105 for(std::vector<std::string>::const_iterator itPar = pars.begin(); itPar != pars.end(); ++itPar ) {
106 os<<(*itPar)<<std::endl;
124 argv[0]=(
char*)shRun.c_str();
125 argv[1]=(
char*)shPath.c_str();
126 argv[2]=(
char*)shPathPiece.c_str();
127 argv[3]=(
char*)shRes.c_str();
128 argv[4]=(
char*)shRng.c_str();
159 for(std::vector<int>::const_iterator iter = pdgIds.begin();
160 iter != pdgIds.end(); ++iter)
161 if (!markStable(*iter))
177 SHERPA::Event_Handler* theEventHandler =
Generator.GetEventHandler();
178 double xsec_val = theEventHandler->TotalXS();
179 double xsec_err = theEventHandler->TotalErr();
192 SHERPA::Input_Output_Handler* ioh =
Generator.GetIOHandler();
193 SHERPA::HepMC2_Interface* hm2i = ioh->GetHepMC2Interface();
195 ATOOLS::Blob_List* blobs =
Generator.GetEventHandler()-> GetBlobs();
196 ATOOLS::Blob* sp(blobs->FindFirst(ATOOLS::btp::Signal_Process));
197 double weight((*sp)[
"Weight"]->Get<double>());
198 double ef((*sp)[
"Enhance"]->Get<double>());
202 if ( ATOOLS::ToType<int>( ATOOLS::rpa->
gen.Variable(
"EVENT_GENERATION_MODE") ) == 1 ) {
210 HepMC::GenEvent* evt =
new HepMC::GenEvent();
211 hm2i->Sherpa2HepMC(blobs, *evt, weight);
233 for(HepMC::GenEvent::particle_iterator iter =
event->particles_begin();
234 iter !=
event->particles_end(); iter++)
235 (*iter)->set_status(getStatus(*iter));
245 DECLARE_GETTER(CMS_SHERPA_RNG_Getter,
"CMS_SHERPA_RNG",ATOOLS::External_RNG,ATOOLS::RNG_Key);
247 ATOOLS::External_RNG *CMS_SHERPA_RNG_Getter::operator()(
const ATOOLS::RNG_Key &)
const
250 void CMS_SHERPA_RNG_Getter::PrintInfo(std::ostream &str,
const size_t)
const
251 { str<<
"CMS_SHERPA_RNG interface"; }
T getParameter(std::string const &) const
CLHEP::HepRandomEngine * randomEngine
#define DEFINE_FWK_MODULE(type)
CLHEP::HepRandomEngine * randomEngine
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::string SherpaPathPiece
unsigned int maxEventsToPrint
edm::GeneratorFilter< SherpaHadronizer, gen::ExternalDecayDriver > SherpaGeneratorFilter
void setInternalXSec(const XSec &xsec)
bool declareStableParticles(const std::vector< int > &pdgIds)
std::auto_ptr< HepMC::GenEvent > & event()
CLHEP::HepRandomEngine & getEngineReference()
GenRunInfoProduct & runInfo()
edm::ParameterSet SherpaParameterSet
bool initializeForInternalPartons()
DECLARE_GETTER(CMS_SHERPA_RNG_Getter,"CMS_SHERPA_RNG", ATOOLS::External_RNG, ATOOLS::RNG_Key)
bool generatePartonsAndHadronize()
bool declareSpecialSettings(const std::vector< std::string > &)
double SherpaDefaultWeight
std::string SherpaProcess
std::string SherpaResultDir
SherpaHadronizer(const edm::ParameterSet ¶ms)
void resetEvent(HepMC::GenEvent *event)
const char * classname() const
std::string SherpaChecksum