/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
GeneratorInterface/LHEInterface/plugins/LHEWriter.cc
75 строк
3 KB
Sunanda
Code check
18 мар 2022, 17:19
18 мар 2022, 17:19
8ef8b5f
Код
Авторство
О чём код?
#include <algorithm> #include <iostream> #include <iterator> #include <fstream> #include <string> #include <memory> #include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Run.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h" #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h" using namespace lhef; class LHEWriter : public edm::one::EDAnalyzer<edm::one::WatchRuns> { public: explicit LHEWriter(const edm::ParameterSet ¶ms); ~LHEWriter() override; protected: void beginRun(const edm::Run &run, const edm::EventSetup &es) override; void endRun(const edm::Run &run, const edm::EventSetup &es) override; void analyze(const edm::Event &event, const edm::EventSetup &es) override; private: std::ofstream file; std::ofstream file1; edm::EDGetTokenT<LHERunInfoProduct> tokenLHERunInfo_; edm::EDGetTokenT<LHEEventProduct> tokenLHEEvent_; }; LHEWriter::LHEWriter(const edm::ParameterSet ¶ms) : tokenLHERunInfo_(consumes<LHERunInfoProduct, edm::InRun>( params.getUntrackedParameter<edm::InputTag>("moduleLabel", std::string("source")))), tokenLHEEvent_(consumes<LHEEventProduct>( params.getUntrackedParameter<edm::InputTag>("moduleLabel", std::string("source")))) {} LHEWriter::~LHEWriter() {} void LHEWriter::beginRun(const edm::Run &run, const edm::EventSetup &es) { file.open("writer.lhe", std::fstream::out | std::fstream::trunc); file1.open("writer1.lhe", std::fstream::out | std::fstream::trunc); } void LHEWriter::endRun(const edm::Run &run, const edm::EventSetup &es) { const edm::Handle<LHERunInfoProduct> &product = run.getHandle(tokenLHERunInfo_); //run.getByLabel("source", product); //run.getByToken(tokenLHERunInfo_, product); std::copy(product->begin(), product->end(), std::ostream_iterator<std::string>(file)); file1 << LHERunInfoProduct::endOfFile(); file.close(); file1.close(); system("cat writer1.lhe >> writer.lhe"); system("rm -rf writer1.lhe"); } void LHEWriter::analyze(const edm::Event &event, const edm::EventSetup &es) { const edm::Handle<LHEEventProduct> &product = event.getHandle(tokenLHEEvent_); //event.getByLabel("source", product); //event.getByToken(tokenLHEEvent_, product); std::copy(product->begin(), product->end(), std::ostream_iterator<std::string>(file1)); } DEFINE_FWK_MODULE(LHEWriter);