JetMETCorrections
Modules
plugins
QGLikelihoodSystematicsDBWriter.cc
Go to the documentation of this file.
1
// Author: Benedikt Hegner, Tom Cornelis
2
// Email: benedikt.hegner@cern.ch, tom.cornelis@cern.ch
3
4
#include <vector>
5
#include <memory>
6
#include <string>
7
#include <fstream>
8
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
9
#include "
FWCore/Framework/interface/EDAnalyzer.h
"
10
#include "
FWCore/Framework/interface/Event.h
"
11
#include "
FWCore/Framework/interface/MakerMacros.h
"
12
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
13
#include "
FWCore/ServiceRegistry/interface/Service.h
"
14
#include "
CondCore/DBOutputService/interface/PoolDBOutputService.h
"
15
#include "
CondFormats/JetMETObjects/interface/QGLikelihoodObject.h
"
16
#include "
FWCore/ParameterSet/interface/FileInPath.h
"
17
18
class
QGLikelihoodSystematicsDBWriter
:
public
edm::EDAnalyzer
{
19
public
:
20
QGLikelihoodSystematicsDBWriter
(
const
edm::ParameterSet
&);
21
void
beginJob
()
override
;
22
void
analyze
(
const
edm::Event
&,
const
edm::EventSetup
&)
override
{}
23
void
endJob
()
override
{}
24
~QGLikelihoodSystematicsDBWriter
()
override
{}
25
26
private
:
27
std::string
fileName
;
28
std::string
payloadTag
;
29
};
30
31
// Constructor
32
QGLikelihoodSystematicsDBWriter::QGLikelihoodSystematicsDBWriter
(
const
edm::ParameterSet
& pSet) {
33
fileName
= pSet.
getParameter
<
std::string
>(
"src"
);
34
payloadTag
= pSet.
getParameter
<
std::string
>(
"payload"
);
35
}
36
37
// Begin Job
38
void
QGLikelihoodSystematicsDBWriter::beginJob
() {
39
QGLikelihoodSystematicsObject
*
payload
=
new
QGLikelihoodSystematicsObject
();
40
payload
->data.clear();
41
42
std::ifstream database;
43
database.open(
edm::FileInPath
(
fileName
.c_str()).
fullPath
().c_str(),
std::ios::in
);
44
if
(!database.is_open()) {
45
edm::LogError
(
"FileNotFound"
) <<
"Could not open file "
<<
fileName
<< std::endl;
46
return
;
47
}
48
std::string
line
;
49
while
(std::getline(database,
line
)) {
50
float
ptMin
,
ptMax
,
etaMin
,
etaMax
,
rhoMin
,
rhoMax
, a_q, b_q, a_g, b_g, lmin, lmax;
51
char
tag
[1023], leadchar;
52
sscanf(
line
.c_str(),
"%c"
, &leadchar);
53
if
((leadchar ==
'#'
) || (leadchar ==
'!'
))
54
continue
;
//Skip those lines
55
sscanf(
line
.c_str(),
56
"%s %f %f %f %f %f %f %f %f %f %f %f %f"
,
57
&
tag
[0],
58
&
ptMin
,
59
&
ptMax
,
60
&
rhoMin
,
61
&
rhoMax
,
62
&
etaMin
,
63
&
etaMax
,
64
&a_q,
65
&b_q,
66
&a_g,
67
&b_g,
68
&lmin,
69
&lmax);
70
71
QGLikelihoodCategory
category
;
72
category
.RhoMin =
rhoMin
;
73
category
.RhoMax =
rhoMax
;
74
category
.PtMin =
ptMin
;
75
category
.PtMax =
ptMax
;
76
category
.EtaMin =
etaMin
;
77
category
.EtaMax =
etaMax
;
78
category
.QGIndex = 0;
79
category
.VarIndex = -1;
80
81
//quark entry
82
QGLikelihoodSystematicsObject::Entry
quarkEntry;
83
quarkEntry.
systCategory
=
category
;
84
quarkEntry.
a
= a_q;
85
quarkEntry.
b
= b_q;
86
quarkEntry.
lmin
= lmin;
87
quarkEntry.
lmax
= lmax;
88
89
//gluon entry
90
QGLikelihoodSystematicsObject::Entry
gluonEntry = quarkEntry;
91
gluonEntry.
systCategory
.
QGIndex
= 1;
92
gluonEntry.
a
= a_g;
93
gluonEntry.
b
= b_g;
94
95
payload
->data.push_back(quarkEntry);
96
payload
->data.push_back(gluonEntry);
97
}
98
database.close();
99
100
// Now write it into the DB
101
edm::LogInfo
(
"UserOutput"
) <<
"Opening PoolDBOutputService"
<< std::endl;
102
edm::Service<cond::service::PoolDBOutputService>
s
;
103
if
(
s
.isAvailable()) {
104
edm::LogInfo
(
"UserOutput"
) <<
"Setting up payload with "
<<
payload
->data.size() <<
" entries and tag "
105
<<
payloadTag
<< std::endl;
106
if
(
s
->isNewTagRequest(
payloadTag
))
107
s
->createNewIOV<
QGLikelihoodSystematicsObject
>(
payload
,
s
->beginOfTime(),
s
->endOfTime(),
payloadTag
);
108
else
109
s
->appendSinceTime<
QGLikelihoodSystematicsObject
>(
payload
, 111,
payloadTag
);
110
}
111
edm::LogInfo
(
"UserOutput"
) <<
"Wrote in CondDB QGLikelihoodSystematic payload label: "
<<
payloadTag
<< std::endl;
112
}
113
114
DEFINE_FWK_MODULE
(
QGLikelihoodSystematicsDBWriter
);
taus_updatedMVAIds_cff.category
category
Definition:
taus_updatedMVAIds_cff.py:31
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition:
ALCARECOTkAlBeamHalo_cff.py:32
contentValuesFiles.fullPath
fullPath
Definition:
contentValuesFiles.py:64
QGLikelihoodSystematicsDBWriter
Definition:
QGLikelihoodSystematicsDBWriter.cc:18
ptMin
constexpr float ptMin
Definition:
PhotonIDValueMapProducer.cc:155
QGLikelihoodSystematicsObject::Entry
Definition:
QGLikelihoodObject.h:39
QGLikelihoodSystematicsObject::Entry::lmax
float lmax
Definition:
QGLikelihoodObject.h:41
EDAnalyzer.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition:
MessageLogger.h:125
edm::EDAnalyzer
Definition:
EDAnalyzer.h:28
QGLikelihoodSystematicsObject::Entry::b
float b
Definition:
QGLikelihoodObject.h:41
FileInPath.h
QGLikelihoodSystematicsObject::Entry::a
float a
Definition:
QGLikelihoodObject.h:41
edm::FileInPath
Definition:
FileInPath.h:64
MakerMacros.h
alignCSCRings.s
s
Definition:
alignCSCRings.py:92
PoolDBOutputService.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
AlignmentTrackSelector_cfi.ptMax
ptMax
Definition:
AlignmentTrackSelector_cfi.py:12
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition:
GlobalPosition_Frontier_DevDB_cff.py:11
Service.h
QGLikelihoodSystematicsDBWriter::beginJob
void beginJob() override
Definition:
QGLikelihoodSystematicsDBWriter.cc:38
QGLikelihoodSystematicsObject
QGLikelihoodSystematicsObject containing the parameters for the systematic smearing.
Definition:
QGLikelihoodObject.h:38
QGLikelihoodSystematicsDBWriter::~QGLikelihoodSystematicsDBWriter
~QGLikelihoodSystematicsDBWriter() override
Definition:
QGLikelihoodSystematicsDBWriter.cc:24
QGLikelihoodSystematicsObject::Entry::lmin
float lmin
Definition:
QGLikelihoodObject.h:41
jets_cff.payload
payload
Definition:
jets_cff.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
QGLikelihoodCategory
Category structure: ranges associated with QGLikelihood histograms.
Definition:
QGLikelihoodObject.h:9
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
recoMuon::in
Definition:
RecoMuonEnumerators.h:6
HLT_FULL_cff.rhoMax
rhoMax
Definition:
HLT_FULL_cff.py:15053
QGLikelihoodSystematicsDBWriter::payloadTag
std::string payloadTag
Definition:
QGLikelihoodSystematicsDBWriter.cc:28
edm::Service< cond::service::PoolDBOutputService >
QGLikelihoodCategory::QGIndex
int QGIndex
Definition:
QGLikelihoodObject.h:11
QGLikelihoodObject.h
edm::EventSetup
Definition:
EventSetup.h:57
QGLikelihoodSystematicsObject::Entry::systCategory
QGLikelihoodCategory systCategory
Definition:
QGLikelihoodObject.h:40
edm::LogError
Log< level::Error, false > LogError
Definition:
MessageLogger.h:123
Frameworkfwd.h
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition:
ALCARECOTkAlBeamHalo_cff.py:33
QGLikelihoodSystematicsDBWriter::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition:
QGLikelihoodSystematicsDBWriter.cc:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
QGLikelihoodSystematicsDBWriter::fileName
std::string fileName
Definition:
QGLikelihoodSystematicsDBWriter.cc:27
ParameterSet.h
QGLikelihoodSystematicsDBWriter::QGLikelihoodSystematicsDBWriter
QGLikelihoodSystematicsDBWriter(const edm::ParameterSet &)
Definition:
QGLikelihoodSystematicsDBWriter.cc:32
edm::Event
Definition:
Event.h:73
mps_splice.line
line
Definition:
mps_splice.py:76
electronConversionRejectionValidator.rhoMin
rhoMin
Definition:
electronConversionRejectionValidator.py:59
QGLikelihoodSystematicsDBWriter::endJob
void endJob() override
Definition:
QGLikelihoodSystematicsDBWriter.cc:23
Generated for CMSSW Reference Manual by
1.8.16