CMS 3D CMS Logo

LHEWriter.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iostream>
3 #include <iterator>
4 #include <fstream>
5 #include <string>
6 #include <memory>
7 
15 
18 
19 using namespace lhef;
20 
21 class LHEWriter : public edm::EDAnalyzer {
22 public:
23  explicit LHEWriter(const edm::ParameterSet &params);
24  ~LHEWriter() override;
25 
26 protected:
27  void beginRun(const edm::Run &run, const edm::EventSetup &es) override;
28  void endRun(const edm::Run &run, const edm::EventSetup &es) override;
29  void analyze(const edm::Event &event, const edm::EventSetup &es) override;
30 
31 private:
32  std::ofstream file;
33  std::ofstream file1;
34 
37 };
38 
40  : tokenLHERunInfo_(consumes<LHERunInfoProduct, edm::InRun>(
41  params.getUntrackedParameter<edm::InputTag>("moduleLabel", std::string("source")))),
42  tokenLHEEvent_(consumes<LHEEventProduct>(
43  params.getUntrackedParameter<edm::InputTag>("moduleLabel", std::string("source")))) {}
44 
46 
48  file.open("writer.lhe", std::fstream::out | std::fstream::trunc);
49  file1.open("writer1.lhe", std::fstream::out | std::fstream::trunc);
50 }
51 
52 void LHEWriter::endRun(const edm::Run &run, const edm::EventSetup &es) {
54  //run.getByLabel("source", product);
55  run.getByToken(tokenLHERunInfo_, product);
56 
57  std::copy(product->begin(), product->end(), std::ostream_iterator<std::string>(file));
58 
60  file.close();
61  file1.close();
62 
63  system("cat writer1.lhe >> writer.lhe");
64  system("rm -rf writer1.lhe");
65 }
66 
69  //event.getByLabel("source", product);
70  event.getByToken(tokenLHEEvent_, product);
71 
72  std::copy(product->begin(), product->end(), std::ostream_iterator<std::string>(file1));
73 }
74 
Ecal2004TBTDCRanges_v1_cff.endRun
endRun
Definition: Ecal2004TBTDCRanges_v1_cff.py:4
MessageLogger.h
LHEEventProduct
Definition: LHEEventProduct.h:12
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
LHEWriter::LHEWriter
LHEWriter(const edm::ParameterSet &params)
Definition: LHEWriter.cc:39
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< LHERunInfoProduct >
edm
HLT enums.
Definition: AlignableModifier.h:19
LHEWriter::tokenLHEEvent_
edm::EDGetTokenT< LHEEventProduct > tokenLHEEvent_
Definition: LHEWriter.cc:36
EDAnalyzer.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::InRun
Definition: BranchType.h:11
LHEEventProduct::end
const_iterator end() const
Definition: LHEEventProduct.h:100
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
LHEWriter::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: LHEWriter.cc:47
LHEWriter::analyze
void analyze(const edm::Event &event, const edm::EventSetup &es) override
Definition: LHEWriter.cc:67
LHERunInfoProduct.h
MakerMacros.h
LHERunInfoProduct
Definition: LHERunInfoProduct.h:13
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
LHERunInfoProduct::end
const_iterator end() const
Definition: LHERunInfoProduct.h:109
Run.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
lhef
Definition: ExhumeHadronizer.h:12
LHEWriter::endRun
void endRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: LHEWriter.cc:52
LHERunInfoProduct::begin
const_iterator begin() const
Definition: LHERunInfoProduct.cc:115
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:57
InputTag.h
LHEEventProduct.h
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
LHEWriter::tokenLHERunInfo_
edm::EDGetTokenT< LHERunInfoProduct > tokenLHERunInfo_
Definition: LHEWriter.cc:35
LHEWriter::file
std::ofstream file
Definition: LHEWriter.cc:32
LHEWriter::file1
std::ofstream file1
Definition: LHEWriter.cc:33
LHEWriter
Definition: LHEWriter.cc:21
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
LHEEventProduct::begin
const_iterator begin() const
Definition: LHEEventProduct.cc:64
LHEWriter::~LHEWriter
~LHEWriter() override
Definition: LHEWriter.cc:45
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
pileupReCalc_HLTpaths.trunc
trunc
Definition: pileupReCalc_HLTpaths.py:144
LHERunInfoProduct::endOfFile
static const std::string & endOfFile()
Definition: LHERunInfoProduct.cc:138