CondTools
DQM
plugins
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
7
#include "
FWCore/Framework/interface/EDAnalyzer.h
"
8
#include "
FWCore/Framework/interface/Run.h
"
9
#include "
FWCore/Framework/interface/Event.h
"
10
#include "
FWCore/Framework/interface/EventSetup.h
"
11
#include "
FWCore/Framework/interface/MakerMacros.h
"
12
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
13
#include "
FWCore/Framework/interface/ESHandle.h
"
14
#include "
FWCore/Utilities/interface/Exception.h
"
15
#include "
FWCore/ServiceRegistry/interface/Service.h
"
16
#include "
CondFormats/Common/interface/FileBlob.h
"
17
#include "
CondFormats/DataRecord/interface/DQMReferenceHistogramRootFileRcd.h
"
18
#include "
DQMServices/Core/interface/DQMStore.h
"
19
20
namespace
edmtest
{
21
class
DQMReferenceHistogramRootFileEventSetupAnalyzer
:
public
edm::EDAnalyzer
{
22
public
:
23
typedef
dqm::legacy::MonitorElement
MonitorElement
;
24
typedef
dqm::legacy::DQMStore
DQMStore
;
25
explicit
DQMReferenceHistogramRootFileEventSetupAnalyzer
(
const
edm::ParameterSet
&
pset
);
26
explicit
DQMReferenceHistogramRootFileEventSetupAnalyzer
(
int
i
);
27
~DQMReferenceHistogramRootFileEventSetupAnalyzer
()
override
;
28
void
analyze
(
const
edm::Event
&
event
,
const
edm::EventSetup
&
setup
)
override
;
29
void
beginRun
(
edm::Run
const
&,
edm::EventSetup
const
&)
override
;
30
31
private
:
32
bool
init_
;
33
};
34
35
DQMReferenceHistogramRootFileEventSetupAnalyzer::DQMReferenceHistogramRootFileEventSetupAnalyzer
(
36
const
edm::ParameterSet
& ps) {
37
init_
=
false
;
38
//std::cout << "DQMReferenceHistogramRootFileEventSetupAnalyzer(const edm::ParameterSet &ps)" << std::endl;
39
}
40
41
DQMReferenceHistogramRootFileEventSetupAnalyzer::DQMReferenceHistogramRootFileEventSetupAnalyzer
(
int
i
) {
42
init_
=
false
;
43
//std::cout << "DQMReferenceHistogramRootFileEventSetupAnalyzer(int i) " << i << std::endl;
44
}
45
46
DQMReferenceHistogramRootFileEventSetupAnalyzer::~DQMReferenceHistogramRootFileEventSetupAnalyzer
() {
47
init_
=
false
;
48
//std::cout << "~DQMReferenceHistogramRootFileEventSetupAnalyzer" << std::endl;
49
}
50
51
void
DQMReferenceHistogramRootFileEventSetupAnalyzer::analyze
(
const
edm::Event
&
iEvent
,
52
const
edm::EventSetup
& iSetup) {
53
return
;
54
}
55
56
void
DQMReferenceHistogramRootFileEventSetupAnalyzer::beginRun
(
edm::Run
const
&
run
,
edm::EventSetup
const
& iSetup) {
57
//std::cout << "DQMReferenceHistogramRootFileEventSetupAnalyzer::beginRun()" << std::endl;
58
if
(!
init_
) {
59
init_
=
true
;
60
edm::eventsetup::EventSetupRecordKey
recordKey(
61
edm::eventsetup::EventSetupRecordKey::TypeTag::findType
(
"DQMReferenceHistogramRootFileRcd"
));
62
if
(recordKey.
type
() ==
edm::eventsetup::EventSetupRecordKey::TypeTag
()) {
63
throw
cms::Exception
(
"Record not found"
) <<
"Record \"DQMReferenceHistogramRootFileRcd"
64
<<
"\" does not exist!"
<< std::endl;
65
}
66
edm::ESHandle<FileBlob>
rootgeo;
67
iSetup.
get
<
DQMReferenceHistogramRootFileRcd
>().
get
(rootgeo);
68
//std::cout<<"ROOT FILE IN MEMORY"<<std::endl;
69
std::unique_ptr<std::vector<unsigned char> > tb((*rootgeo).getUncompressedBlob());
70
// char filename[128];
71
// sprintf(filename, "mem:%p,%ul", &(*tb)[0], (unsigned long) tb->size());
72
// edm::Service<DQMStore>()->open(filename, false, "", "Reference");
73
74
//here you can implement the stream for putting the TFile on disk...
75
std::string
outfile
(
"dqmreference.root"
);
76
std::ofstream
output
(
outfile
.c_str());
77
output
.write((
const
char
*)&(*tb)[0], tb->size());
78
output
.close();
79
80
DQMStore
*
dqm
= &*
edm::Service<DQMStore>
();
81
dqm
->open(
outfile
,
false
,
""
,
"Reference"
);
82
remove
(
outfile
.c_str());
83
84
std::vector<MonitorElement*> mes =
dqm
->getAllContents(
""
);
85
// for (std::vector<MonitorElement *>::iterator i = mes.begin(), e = mes.end(); i != e; ++i)
86
// std::cout << "ME '" << (*i)->getFullname() << "'\n";
87
88
//std::cout<<"SIZE FILE = "<<tb->size()<<std::endl;
89
}
90
}
91
92
DEFINE_FWK_MODULE
(
DQMReferenceHistogramRootFileEventSetupAnalyzer
);
93
}
// 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
mps_fire.i
i
Definition:
mps_fire.py:355
ESHandle.h
convertSQLitetoXML_cfg.output
output
Definition:
convertSQLitetoXML_cfg.py:32
edm::Run
Definition:
Run.h:45
edmtest
Definition:
AlignPCLThresholdsReader.cc:12
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::DQMReferenceHistogramRootFileEventSetupAnalyzer
DQMReferenceHistogramRootFileEventSetupAnalyzer(const edm::ParameterSet &pset)
Definition:
DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:35
DQMStore.h
dqm::legacy::MonitorElement
Definition:
MonitorElement.h:461
EDAnalyzer.h
DQMReferenceHistogramRootFileRcd
Definition:
DQMReferenceHistogramRootFileRcd.h:24
FileBlob.h
edm::eventsetup::EventSetupRecordKey
Definition:
EventSetupRecordKey.h:30
singleTopDQM_cfi.setup
setup
Definition:
singleTopDQM_cfi.py:37
edm::EDAnalyzer
Definition:
EDAnalyzer.h:29
MakerMacros.h
edm::EventSetup::get
T get() const
Definition:
EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
dqm::legacy::DQMStore
Definition:
DQMStore.h:727
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::analyze
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
Definition:
DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:51
Service.h
Run.h
edm::ESHandle
Definition:
DTSurvey.h:22
edm::eventsetup::EventSetupRecordKey::TypeTag
heterocontainer::HCTypeTag TypeTag
Definition:
EventSetupRecordKey.h:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition:
ParameterSet.h:36
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::~DQMReferenceHistogramRootFileEventSetupAnalyzer
~DQMReferenceHistogramRootFileEventSetupAnalyzer() override
Definition:
DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:46
Event.h
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition:
DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:23
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
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition:
DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:56
edm::EventSetup
Definition:
EventSetup.h:57
DQMReferenceHistogramRootFileRcd.h
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer
Definition:
DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:21
get
#define get
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::DQMStore
dqm::legacy::DQMStore DQMStore
Definition:
DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:24
writedatasetfile.run
run
Definition:
writedatasetfile.py:27
Exception
Definition:
hltDiff.cc:246
edmtest::DQMReferenceHistogramRootFileEventSetupAnalyzer::init_
bool init_
Definition:
DQMReferenceHistogramRootFileEventSetupAnalyzer.cc:32
MatrixUtil.remove
def remove(d, key, TELL=False)
Definition:
MatrixUtil.py:212
EventSetup.h
Exception.h
timingPdfMaker.outfile
outfile
Definition:
timingPdfMaker.py:351
dqm
Definition:
DQMStore.h:18
ParameterSet.h
event
Definition:
event.py:1
edm::Event
Definition:
Event.h:73
muonDTDigis_cfi.pset
pset
Definition:
muonDTDigis_cfi.py:27
Generated for CMSSW Reference Manual by
1.8.16