CMS 3D CMS Logo

DQMReferenceHistogramRootFileEventSetupAnalyzer.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:
27  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
28  void beginRun(edm::Run const&, edm::EventSetup const&);
29 
30  private:
32  bool init_;
33  };
34 
36  const edm::ParameterSet& ps)
37  : fileBlobToken_(esConsumes<edm::Transition::BeginRun>()) {
38  init_ = false;
39  edm::LogPrint("DQMReferenceHistogramRootFileEventSetupAnalyzer")
40  << "DQMReferenceHistogramRootFileEventSetupAnalyzer(const edm::ParameterSet &ps)" << std::endl;
41  }
42 
44  : fileBlobToken_(esConsumes<edm::Transition::BeginRun>()) {
45  init_ = false;
46  edm::LogPrint("DQMReferenceHistogramRootFileEventSetupAnalyzer")
47  << "DQMReferenceHistogramRootFileEventSetupAnalyzer(int i) " << i << std::endl;
48  }
49 
51  init_ = false;
52  edm::LogPrint("DQMReferenceHistogramRootFileEventSetupAnalyzer")
53  << "~DQMReferenceHistogramRootFileEventSetupAnalyzer" << std::endl;
54  }
55 
57  const edm::EventSetup& iSetup) {
58  return;
59  }
60 
62  edm::LogPrint("DQMReferenceHistogramRootFileEventSetupAnalyzer")
63  << "DQMReferenceHistogramRootFileEventSetupAnalyzer::beginRun()" << std::endl;
64  if (!init_) {
65  init_ = true;
67  edm::eventsetup::EventSetupRecordKey::TypeTag::findType("DQMReferenceHistogramRootFileRcd"));
69  throw cms::Exception("Record not found") << "Record \"DQMReferenceHistogramRootFileRcd"
70  << "\" does not exist!" << std::endl;
71  }
72  const auto& rootgeo = &iSetup.getData(fileBlobToken_);
73  edm::LogPrint("DQMReferenceHistogramRootFileEventSetupAnalyzer") << "ROOT FILE IN MEMORY" << std::endl;
74  std::unique_ptr<std::vector<unsigned char> > tb((*rootgeo).getUncompressedBlob());
75  // char filename[128];
76  // sprintf(filename, "mem:%p,%ul", &(*tb)[0], (unsigned long) tb->size());
77  // edm::Service<DQMStore>()->open(filename, false, "", "Reference");
78 
79  //here you can implement the stream for putting the TFile on disk...
80  std::string outfile("dqmreference.root");
81  std::ofstream output(outfile.c_str());
82  output.write((const char*)&(*tb)[0], tb->size());
83  output.close();
84 
86  dqm->open(outfile, false, "", "Reference");
87  remove(outfile.c_str());
88 
89  std::vector<MonitorElement*> mes = dqm->getAllContents("");
90  for (std::vector<MonitorElement*>::iterator i = mes.begin(), e = mes.end(); i != e; ++i)
91  edm::LogPrint("DQMReferenceHistogramRootFileEventSetupAnalyzer") << "ME '" << (*i)->getFullname() << "'\n";
92 
93  edm::LogPrint("DQMReferenceHistogramRootFileEventSetupAnalyzer") << "SIZE FILE = " << tb->size() << std::endl;
94  }
95  }
96 
98 } // namespace edmtest
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
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
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
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::DQMReferenceHistogramRootFileEventSetupAnalyzer
DQMReferenceHistogramRootFileEventSetupAnalyzer(const edm::ParameterSet &pset)
Definition: DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:35
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::fileBlobToken_
const edm::ESGetToken< FileBlob, DQMReferenceHistogramRootFileRcd > fileBlobToken_
Definition: DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:31
FileBlob.h
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqm::legacy::DQMStore
Definition: DQMStore.h:728
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::analyze
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
Definition: DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:56
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:61
Service.h
Run.h
edm::eventsetup::EventSetupRecordKey::TypeTag
heterocontainer::HCTypeTag TypeTag
Definition: EventSetupRecordKey.h:32
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::~DQMReferenceHistogramRootFileEventSetupAnalyzer
~DQMReferenceHistogramRootFileEventSetupAnalyzer() override
Definition: DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:50
Event.h
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:22
edm::eventsetup::EventSetupRecordKey::type
const TypeTag & type() const
Definition: EventSetupRecordKey.h:40
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
DQMReferenceHistogramRootFileRcd.h
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer
Definition: DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:20
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::DQMStore
dqm::legacy::DQMStore DQMStore
Definition: DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:23
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< FileBlob, DQMReferenceHistogramRootFileRcd >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Exception
Definition: hltDiff.cc:245
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::init_
bool init_
Definition: DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:32
MatrixUtil.remove
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:219
EventSetup.h
Exception.h
timingPdfMaker.outfile
outfile
Definition: timingPdfMaker.py:350
dqm
Definition: DQMStore.h:18
ParameterSet.h
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
edm::Log
Definition: MessageLogger.h:70
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37