Public Member Functions | |
const char * | classname () const |
bool | decay () |
bool | declareSpecialSettings (const std::vector< std::string >) |
bool | declareStableParticles (const std::vector< int > &pdgIds) |
void | finalizeEvent () |
bool | generatePartonsAndHadronize () |
bool | initializeForInternalPartons () |
bool | readSettings (int) |
bool | residualDecay () |
SherpaHadronizer (const edm::ParameterSet ¶ms) | |
void | statistics () |
~SherpaHadronizer () | |
Private Attributes | |
double | default_weight |
SHERPA::Sherpa | Generator |
unsigned int | maxEventsToPrint |
CLHEP::HepRandomEngine * | randomEngine |
edm::ParameterSet | SherpaParameter |
std::string | SherpaPath |
std::string | SherpaPathPiece |
std::string | SherpaResultDir |
Definition at line 26 of file SherpaHadronizer.cc.
SherpaHadronizer::SherpaHadronizer | ( | const edm::ParameterSet & | params | ) |
Definition at line 66 of file SherpaHadronizer.cc.
References gather_cfg::cout, edm::ParameterSet::getParameter(), i, SherpaParameter, SherpaPath, SherpaPathPiece, and SherpaResultDir.
: BaseHadronizer(params), SherpaPath(params.getUntrackedParameter<std::string>("Path","SherpaRun")), SherpaPathPiece(params.getUntrackedParameter<std::string>("PathPiece","SherpaRun")), SherpaResultDir(params.getUntrackedParameter<std::string>("ResultDir","Result")), default_weight(params.getUntrackedParameter<double>("default_weight",1.)), SherpaParameter(params.getParameter<edm::ParameterSet>("SherpaParameters")), maxEventsToPrint(params.getUntrackedParameter<int>("maxEventsToPrint", 0)) { // The ids (names) of parameter sets to be read (Analysis,Run) to create Analysis.dat, Run.dat //They are given as a vstring. std::vector<std::string> setNames = SherpaParameter.getParameter<std::vector<std::string> >("parameterSets"); //Loop all set names... for ( unsigned i=0; i<setNames.size(); ++i ) { // ...and read the parameters for each set given in vstrings std::vector<std::string> pars = SherpaParameter.getParameter<std::vector<std::string> >(setNames[i]); std::cout << "Write Sherpa parameter set " << setNames[i] <<" to "<<setNames[i]<<".dat "<<std::endl; std::string datfile = SherpaPath + "/" + setNames[i] +".dat"; std::ofstream os(datfile.c_str()); // Loop over all strings and write the according *.dat for(std::vector<std::string>::const_iterator itPar = pars.begin(); itPar != pars.end(); ++itPar ) { os<<(*itPar)<<std::endl; } } //To be conform to the default Sherpa usage create a command line: //name of executable (only for demonstration, could also be empty) std::string shRun = "./Sherpa"; //Path where the Sherpa libraries are stored std::string shPath = "PATH=" + SherpaPath; // new for Sherpa 1.3.0, suggested by authors std::string shPathPiece = "PATH_PIECE=" + SherpaPathPiece; //Path where results are stored std::string shRes = "RESULT_DIRECTORY=" + SherpaResultDir; // from Sherpa 1.2.0 on //Name of the external random number class std::string shRng = "EXTERNAL_RNG=CMS_SHERPA_RNG"; //create the command line char* argv[5]; argv[0]=(char*)shRun.c_str(); argv[1]=(char*)shPath.c_str(); argv[2]=(char*)shPathPiece.c_str(); argv[3]=(char*)shRes.c_str(); argv[4]=(char*)shRng.c_str(); //initialize Sherpa with the command line Generator.InitializeTheRun(5,argv); }
SherpaHadronizer::~SherpaHadronizer | ( | ) |
Definition at line 116 of file SherpaHadronizer.cc.
{ }
const char* SherpaHadronizer::classname | ( | ) | const [inline] |
Definition at line 40 of file SherpaHadronizer.cc.
{ return "SherpaHadronizer"; }
bool SherpaHadronizer::decay | ( | ) |
Definition at line 202 of file SherpaHadronizer.cc.
{ return true; }
bool SherpaHadronizer::declareSpecialSettings | ( | const std::vector< std::string > | ) | [inline] |
Definition at line 34 of file SherpaHadronizer.cc.
{ return true; }
bool SherpaHadronizer::declareStableParticles | ( | const std::vector< int > & | pdgIds | ) |
Definition at line 138 of file SherpaHadronizer.cc.
{ #if 0 for(std::vector<int>::const_iterator iter = pdgIds.begin(); iter != pdgIds.end(); ++iter) if (!markStable(*iter)) return false; return true; #else return false; #endif }
void SherpaHadronizer::finalizeEvent | ( | ) |
Definition at line 212 of file SherpaHadronizer.cc.
References gen::BaseHadronizer::event(), lhef::getStatus(), and maxEventsToPrint.
{ #if 0 for(HepMC::GenEvent::particle_iterator iter = event->particles_begin(); iter != event->particles_end(); iter++) (*iter)->set_status(getStatus(*iter)); #endif //******** Verbosity ******* if (maxEventsToPrint > 0) { maxEventsToPrint--; event()->print(); } }
bool SherpaHadronizer::generatePartonsAndHadronize | ( | ) |
Definition at line 169 of file SherpaHadronizer.cc.
References default_weight, relval_steps::gen(), gen::BaseHadronizer::resetEvent(), and CommonMethods::weight().
{ //get the next event and check if it produced if (Generator.GenerateOneEvent()) { //convert it to HepMC2 SHERPA::Input_Output_Handler* ioh = Generator.GetIOHandler(); SHERPA::HepMC2_Interface* hm2i = ioh->GetHepMC2Interface(); //get the event weight from blobs ATOOLS::Blob_List* blobs = Generator.GetEventHandler()-> GetBlobs(); ATOOLS::Blob* sp(blobs->FindFirst(ATOOLS::btp::Signal_Process)); double weight((*sp)["Weight"]->Get<double>()); double ef((*sp)["Enhance"]->Get<double>()); // in case of unweighted events sherpa puts the max weight as event weight. // this is not optimal, we want 1 for unweighted events, so we check // whether we are producing unweighted events ("EVENT_GENERATION_MODE" == "1") if ( ATOOLS::ToType<int>( ATOOLS::rpa.gen.Variable("EVENT_GENERATION_MODE") ) == 1 ) { if (ef > 0.) { weight = default_weight/ef; } else { weight = -1234.; } } //create and empty event and then hand it to SherpaIOHandler to fill it HepMC::GenEvent* evt = new HepMC::GenEvent(); hm2i->Sherpa2HepMC(blobs, *evt, weight); resetEvent(evt); return true; } else { return false; } }
bool SherpaHadronizer::initializeForInternalPartons | ( | ) |
Definition at line 120 of file SherpaHadronizer.cc.
{ //initialize Sherpa Generator.InitializeTheEventHandler(); return true; }
bool SherpaHadronizer::readSettings | ( | int | ) | [inline] |
Definition at line 31 of file SherpaHadronizer.cc.
{ return true; }
bool SherpaHadronizer::residualDecay | ( | ) |
Definition at line 207 of file SherpaHadronizer.cc.
{ return true; }
void SherpaHadronizer::statistics | ( | ) |
Definition at line 153 of file SherpaHadronizer.cc.
References gen::BaseHadronizer::runInfo(), and GenRunInfoProduct::setInternalXSec().
{ //calculate statistics Generator.SummarizeRun(); //get the xsec from EventHandler SHERPA::Event_Handler* theEventHandler = Generator.GetEventHandler(); double xsec_val = theEventHandler->TotalXS(); double xsec_err = theEventHandler->TotalErr(); //set the internal cross section in pb in GenRunInfoProduct runInfo().setInternalXSec(GenRunInfoProduct::XSec(xsec_val,xsec_err)); }
double SherpaHadronizer::default_weight [private] |
Definition at line 47 of file SherpaHadronizer.cc.
Referenced by generatePartonsAndHadronize().
SHERPA::Sherpa SherpaHadronizer::Generator [private] |
Definition at line 51 of file SherpaHadronizer.cc.
unsigned int SherpaHadronizer::maxEventsToPrint [private] |
Definition at line 49 of file SherpaHadronizer.cc.
Referenced by finalizeEvent().
CLHEP::HepRandomEngine* SherpaHadronizer::randomEngine [private] |
Definition at line 52 of file SherpaHadronizer.cc.
Definition at line 48 of file SherpaHadronizer.cc.
Referenced by SherpaHadronizer().
std::string SherpaHadronizer::SherpaPath [private] |
Definition at line 44 of file SherpaHadronizer.cc.
Referenced by SherpaHadronizer().
std::string SherpaHadronizer::SherpaPathPiece [private] |
Definition at line 45 of file SherpaHadronizer.cc.
Referenced by SherpaHadronizer().
std::string SherpaHadronizer::SherpaResultDir [private] |
Definition at line 46 of file SherpaHadronizer.cc.
Referenced by SherpaHadronizer().