CMS 3D CMS Logo

DQMXMLFileEventSetupAnalyzer.cc
Go to the documentation of this file.
1 // C++ common header
2 #include <iostream>
3 #include <memory>
4 #include <vector>
5 #include <fstream>
6 
18 
19 namespace edmtest {
21  public:
23  explicit DQMXMLFileEventSetupAnalyzer(int i);
25  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
26  void beginRun(edm::Run const&, edm::EventSetup const&);
27 
28  private:
30  bool init_;
32  };
33 
35  : fileBlobToken_(
36  esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", ps.getParameter<std::string>("labelToGet")))),
37  labelToGet_(ps.getParameter<std::string>("labelToGet")) {
38  init_ = false;
39  edm::LogPrint("DQMXMLFileEventSetupAnalyzer")
40  << "DQMXMLFileEventSetupAnalyzer(const edm::ParameterSet &ps)" << std::endl;
41  }
42 
44  init_ = false;
45  edm::LogPrint("DQMXMLFileEventSetupAnalyzer") << "DQMXMLFileEventSetupAnalyzer(int i) " << i << std::endl;
46  }
47 
49  init_ = false;
50  edm::LogPrint("DQMXMLFileEventSetupAnalyzer") << "~DQMXMLFileEventSetupAnalyzer" << std::endl;
51  }
52 
54 
56  edm::LogPrint("DQMXMLFileEventSetupAnalyzer") << "DQMXMLFileEventSetupAnalyzer::beginRun()" << std::endl;
57  if (!init_) {
58  init_ = true;
62  throw cms::Exception("Record not found") << "Record \"DQMXMLFileRcd"
63  << "\" does not exist!" << std::endl;
64  }
65 
66  const auto& rootgeo = &iSetup.getData(fileBlobToken_);
67  edm::LogPrint("DQMXMLFileEventSetupAnalyzer") << "XML FILE IN MEMORY 1 with label " << labelToGet_ << std::endl;
68  std::unique_ptr<std::vector<unsigned char> > tb1((*rootgeo).getUncompressedBlob());
69  //here you can implement the stream for putting the TFile on disk...
70  std::string outfile1("XML1_retrieved.xml");
71  std::ofstream output1(outfile1.c_str());
72  output1.write((const char*)&(*tb1)[0], tb1->size());
73  output1.close();
74 
75  // iSetup.get<DQMXMLFileRcd>().get("XML2_mio",rootgeo);
76  // std::cout<<"ROOT FILE IN MEMORY 2"<<std::endl;
77  // std::unique_ptr<std::vector<unsigned char> > tb2( (*rootgeo).getUncompressedBlob() );
78  // //here you can implement the stream for putting the TFile on disk...
79  // std::string outfile2("XML2_retrieved.xml") ;
80  // std::ofstream output2(outfile2.c_str()) ;
81  // output2.write((const char *)&(*tb2)[0], tb2->size());
82  // output2.close() ;
83  // std::unique_ptr<std::vector<unsigned char> > tb( (*rootgeo).getUncompressedBlob() );
84  }
85  }
86 
88 } // namespace edmtest
edmtest::DQMXMLFileEventSetupAnalyzer::fileBlobToken_
const edm::ESGetToken< FileBlob, DQMXMLFileRcd > fileBlobToken_
Definition: DQMXMLFileEventSetupAnalyzer.cc:29
edm::eventsetup::heterocontainer::HCTypeTag::findType
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:121
EDAnalyzer.h
mps_fire.i
i
Definition: mps_fire.py:428
skim900GeV_StreamA_MinBiasPD_cfg.output1
output1
Definition: skim900GeV_StreamA_MinBiasPD_cfg.py:212
ESInputTag
edm::Run
Definition: Run.h:45
edmtest
Definition: AlignPCLThresholdsReader.cc:11
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
DQMStore.h
edmtest::DQMXMLFileEventSetupAnalyzer::DQMXMLFileEventSetupAnalyzer
DQMXMLFileEventSetupAnalyzer(const edm::ParameterSet &pset)
Definition: DQMXMLFileEventSetupAnalyzer.cc:34
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edmtest::DQMXMLFileEventSetupAnalyzer::analyze
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
Definition: DQMXMLFileEventSetupAnalyzer.cc:53
FileBlob.h
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edmtest::DQMXMLFileEventSetupAnalyzer::labelToGet_
std::string labelToGet_
Definition: DQMXMLFileEventSetupAnalyzer.cc:31
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
Run.h
edm::eventsetup::EventSetupRecordKey::TypeTag
heterocontainer::HCTypeTag TypeTag
Definition: EventSetupRecordKey.h:32
DQMXMLFileRcd.h
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
edmtest::DQMXMLFileEventSetupAnalyzer::~DQMXMLFileEventSetupAnalyzer
~DQMXMLFileEventSetupAnalyzer() override
Definition: DQMXMLFileEventSetupAnalyzer.cc:48
Event.h
edm::eventsetup::EventSetupRecordKey::type
const TypeTag & type() const
Definition: EventSetupRecordKey.h:40
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< FileBlob, DQMXMLFileRcd >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Exception
Definition: hltDiff.cc:245
edmtest::DQMXMLFileEventSetupAnalyzer::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQMXMLFileEventSetupAnalyzer.cc:55
EventSetup.h
Exception.h
ParameterSet.h
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edmtest::DQMXMLFileEventSetupAnalyzer
Definition: DQMXMLFileEventSetupAnalyzer.cc:20
edm::Event
Definition: Event.h:73
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edmtest::DQMXMLFileEventSetupAnalyzer::init_
bool init_
Definition: DQMXMLFileEventSetupAnalyzer.cc:30