51 TVectorT<float>* tVector =
nullptr;
52 f->GetObject(
name, tVector);
55 for (
int i = 0;
i < tVector->GetNoElements(); ++
i)
56 vector.push_back((*tVector)[
i]);
63 th1->GetNbinsX(), th1->GetXaxis()->GetBinLowEdge(1), th1->GetXaxis()->GetBinUpEdge(th1->GetNbinsX()));
64 for (
int ibin = 0; ibin <= th1->GetNbinsX() + 1; ++ibin)
71 std::map<std::vector<int>, TH1*>& pdfs,
72 std::vector<int>& binNumbers,
74 if (!pdfs[binNumbers])
76 std::vector<int> neighbour = binNumbers;
78 if (--(neighbour[
index]) < 0)
80 }
while (!pdfs[neighbour]);
81 if (TString(pdfs[binNumbers]->GetTitle()) != TString(pdfs[neighbour]->GetTitle()))
102 pdfs.erase(binNumbers);
115 std::map<TString, std::vector<float>> gridOfBins;
116 for (
auto&& binVariable : {
"eta",
"pt",
"rho"}) {
118 edm::LogError(
"NoBins") <<
"Missing bin information for " << binVariable <<
" in input file" << std::endl;
126 std::map<std::vector<int>, TH1*> pdfs;
128 for (
auto&&
type : {
"gluon",
"quark"}) {
130 int qgIndex = strcmp(
type,
"gluon") == 0 ? 1 : 0;
131 for (
auto&& likelihoodVar : {
"mult",
"ptD",
"axis2"}) {
133 int varIndex = (strcmp(likelihoodVar,
"mult") == 0 ? 0 : (strcmp(likelihoodVar,
"ptD") == 0 ? 1 : 2));
134 for (
int i = 0;
i < (
int)gridOfBins[
"eta"].
size() - 1; ++
i) {
135 for (
int j = 0;
j < (
int)gridOfBins[
"pt"].
size() - 1; ++
j) {
136 for (
int k = 0;
k < (
int)gridOfBins[
"rho"].
size() - 1; ++
k) {
139 category.EtaMax = gridOfBins[
"eta"][
i + 1];
141 category.PtMax = gridOfBins[
"pt"][
j + 1];
143 category.RhoMax = gridOfBins[
"rho"][
k + 1];
147 TString
key = TString::Format(
"%s/%s_%s_eta%d_pt%d_rho%d", likelihoodVar, likelihoodVar,
type,
i,
j,
k);
148 TH1* pdf = (TH1*)
f->Get(
key);
150 edm::LogError(
"NoPDF") <<
"Could not found pdf with key " <<
key <<
" in input file" << std::endl;
154 std::vector<int> binNumbers = {qgIndex, varIndex,
i,
j,
k};
155 pdfs[binNumbers] = pdf;
160 for (
int k = 0;
k < (
int)gridOfBins[
"rho"].
size() - 1; ++
k) {
161 std::vector<int> binNumbers = {qgIndex, varIndex,
i,
j,
k};
165 for (
int j = 0;
j < (
int)gridOfBins[
"pt"].
size() - 1; ++
j) {
166 for (
int k = 0;
k < (
int)gridOfBins[
"rho"].
size() - 1; ++
k) {
167 std::vector<int> binNumbers = {qgIndex, varIndex,
i,
j,
k};
187 "%6d) var=%1d\t\tqg=%1d\t\teta={%5.2f,%5.2f}\t\tpt={%8.2f,%8.2f}\t\trho={%6.2f,%8.2f}",
201 payload.qgValidRange.EtaMin = gridOfBins[
"eta"].front();
202 payload.qgValidRange.EtaMax = gridOfBins[
"eta"].back();
203 payload.qgValidRange.PtMin = gridOfBins[
"pt"].front();
204 payload.qgValidRange.PtMax = gridOfBins[
"pt"].back();
205 payload.qgValidRange.RhoMin = gridOfBins[
"rho"].front();
206 payload.qgValidRange.RhoMax = gridOfBins[
"rho"].back();
207 payload.qgValidRange.QGIndex = -1;
208 payload.qgValidRange.VarIndex = -1;
211 edm::LogInfo(
"UserOutput") <<
"Opening PoolDBOutputService" << std::endl;
214 if (
s.isAvailable()) {
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Log< level::Error, false > LogError
void tryToMerge(std::map< std::vector< int >, QGLikelihoodCategory > &, std::map< std::vector< int >, TH1 *> &, std::vector< int > &, int)
QGLikelihoodDBWriter(const edm::ParameterSet &)
QGLikelihoodObject containing valid range and entries with category and histogram (mean is not used a...
std::string inputRootFile
QGLikelihoodObject::Histogram transformToHistogramObject(TH1 *)
Category structure: ranges associated with QGLikelihood histograms.
Log< level::Info, false > LogInfo
void analyze(const edm::Event &, const edm::EventSetup &) override
bool getVectorFromFile(TFile *, std::vector< float > &, const TString &)
~QGLikelihoodDBWriter() override