22 m_taggerName(
"undefined"),
23 m_hypotheses(std::
vector<std::string>()),
24 m_normalizedProb(true),
27 m_vetoSmoothingOf(std::
vector<std::string>()),
28 m_histograms(std::
vector<std::string>()) {
30 declareInterface<NewLikelihoodTool>(
this);
47 return StatusCode::SUCCESS;
55 msg(MSG::INFO) <<
"#BTAG# - hypotheses : ";
58 msg(MSG::INFO) <<
"#BTAG# - histograms : " <<
endmsg;
64 const std::string delimSlash(
"/");
66 unsigned int nSlash = 0;
67 std::string::size_type slashPos;
68 for(
unsigned int i = 0;
69 (slashPos = histoName.find(delimSlash,
i)) != std::string::npos;
70 i = slashPos + 1) nSlash++;
72 slashPos = histoName.find_first_of(delimSlash);
73 std::string
newName = histoName.substr(slashPos+1);
74 slashPos =
newName.find_first_of(delimSlash);
76 std::string hhname =
newName.substr(slashPos+1);
83 const std::string delimUds(
"_");
84 std::string::size_type sPos, sEnd, sLen;
85 sPos =
grades.find_first_not_of(delimUds);
86 while ( sPos != std::string::npos ) {
87 sEnd =
grades.find_first_of(delimUds, sPos);
88 if(sEnd==std::string::npos) sEnd =
grades.length();
90 std::string word =
grades.substr(sPos,sLen);
93 sPos =
grades.find_first_not_of(delimUds, sEnd);
102 TH1* histoSum =
nullptr;
105 std::string channelName = readCdo->channelName(
hname);
106 std::string histoName = readCdo->histoName(
hname);
107 std::string actualName = hypo +
"/" + histoName;
108 std::string longName = channelName +
"#" + actualName;
116 ATH_MSG_DEBUG(
"#BTAG# Histo "<<actualName<<
" has no grade: direct retrieval");
123 ATH_MSG_DEBUG(
"#BTAG# Histo "<<actualName<<
" has only one grade: direct retrieval");
134 TH1*
histo =
nullptr;
143 <<
" has " <<
histo->GetEntries() <<
" entries.");
160 double norm =
h->Integral();
165 if(
hname.find(
v)!=std::string::npos) {
177 if(2==
h->GetDimension()) {
181 TH2 * dc_tmp =
dynamic_cast<TH2*
>(
h);
187 if(3==
h->GetDimension()) {
191 TH3 * dc_tmp =
dynamic_cast<TH3*
>(
h);
193 int Nx=dc_tmp->GetNbinsX();
194 int Ny=dc_tmp->GetNbinsY();
195 int Nz=dc_tmp->GetNbinsZ();
199 double total=dc_tmp->Integral(1,Nx,1,Ny,1,Nz,
"");
200 for(
int iz=1; iz<=Nz; iz++){
203 for(
int ix=1; ix<=Nx; ix++){
204 for(
int iy=1; iy<=Ny; iy++){
205 double cbin=dc_tmp->GetBinContent(ix,iy,iz)*dnorm; cbin= cbin>0. ? cbin : 0.1;
206 dc_tmp->SetBinContent(ix,iy,iz, cbin);
216 norm =
h->Integral();
227 std::vector<double> probDensityPerEventClassAllVariables;
228 probDensityPerEventClassAllVariables.resize(
m_hypotheses.size());
230 probDensityPerEventClassAllVariables[
i]=1.;
232 ATH_MSG_VERBOSE(
"#BTAG# -- lhVarVal size= " << lhVariableValues.size());
234 for (
const auto&
value : lhVariableValues) {
236 int ncompo =
value.composites.size();
238 <<
" has " << ncompo <<
" composites." );
241 for (
const auto& compo :
value.composites) {
243 std::vector<double> tmpVector;
245 int idim = compo.atoms.size();
252 double valuex = compo.atoms[0].value;
253 int binx = (tmpHisto->GetXaxis())->
FindBin(valuex);
254 if(valuex >= tmpHisto->GetXaxis()->GetXmax()) binx = tmpHisto->GetXaxis()->GetNbins();
255 if(valuex <= tmpHisto->GetXaxis()->GetXmin()) binx = 1;
256 double tmp = tmpHisto->GetBinContent(binx);
258 <<
" (1D) actual value= " << valuex
259 <<
" --> bin= " << binx <<
" f = " <<
tmp;
261 TH1* dc_tmp =
dynamic_cast<TH1*
>(tmpHisto);
270 double binw = tmpHisto->GetBinWidth(binx);
273 msg(MSG::ERROR) <<
"bin width is 0" <<
endmsg;
279 tmpVector.push_back(
tmp);
283 double valuex = compo.atoms[0].value;
284 double valuey = compo.atoms[1].value;
285 int binx = (tmpHisto->GetXaxis())->
FindBin(valuex);
286 int biny = (tmpHisto->GetYaxis())->
FindBin(valuey);
287 if(valuex >= tmpHisto->GetXaxis()->GetXmax()) binx = tmpHisto->GetXaxis()->GetNbins();
288 if(valuex <= tmpHisto->GetXaxis()->GetXmin()) binx = 1;
289 if(valuey >= tmpHisto->GetYaxis()->GetXmax()) biny = tmpHisto->GetYaxis()->GetNbins();
290 if(valuey <= tmpHisto->GetYaxis()->GetXmin()) biny = 1;
291 double tmp = tmpHisto->GetBinContent(binx, biny);
293 <<
" (2D) actual value= " << valuex <<
" " << valuey
294 <<
" --> bin= " << binx <<
" " << biny <<
" f = " <<
tmp;
296 TH2* dc_tmp =
dynamic_cast<TH2*
>(tmpHisto);
305 double binw = tmpHisto->GetXaxis()->GetBinWidth(binx)
306 * tmpHisto->GetYaxis()->GetBinWidth(biny);
309 msg(MSG::ERROR) <<
"bin width is 0" <<
endmsg;
315 tmpVector.push_back(
tmp);
319 double valuex = compo.atoms[0].value;
320 double valuey = compo.atoms[1].value;
321 double valuez = compo.atoms[2].value;
322 int binx = (tmpHisto->GetXaxis())->
FindBin(valuex);
323 int biny = (tmpHisto->GetYaxis())->
FindBin(valuey);
324 int binz = (tmpHisto->GetZaxis())->
FindBin(valuez);
325 if(valuex >= tmpHisto->GetXaxis()->GetXmax()) binx = tmpHisto->GetXaxis()->GetNbins();
326 if(valuex <= tmpHisto->GetXaxis()->GetXmin()) binx = 1;
327 if(valuey >= tmpHisto->GetYaxis()->GetXmax()) biny = tmpHisto->GetYaxis()->GetNbins();
328 if(valuey <= tmpHisto->GetYaxis()->GetXmin()) biny = 1;
329 if(valuez >= tmpHisto->GetZaxis()->GetXmax()) binz = tmpHisto->GetZaxis()->GetNbins();
330 if(valuez <= tmpHisto->GetZaxis()->GetXmin()) binz = 1;
331 double tmp = tmpHisto->GetBinContent(binx, biny, binz);
333 <<
" (3D) actual value= " << valuex
334 <<
" " << valuey <<
" " << valuez
335 <<
" --> bin= " << binx <<
" " << biny
336 <<
" " << binz <<
" f = " <<
tmp;
338 TH3* dc_tmp =
dynamic_cast<TH3*
>(tmpHisto);
347 double binw = tmpHisto->GetXaxis()->GetBinWidth(binx)
348 * tmpHisto->GetYaxis()->GetBinWidth(biny)
349 * tmpHisto->GetZaxis()->GetBinWidth(binz);
352 msg(MSG::ERROR) <<
"bin width is 0" <<
endmsg;
358 tmpVector.push_back(
tmp);
362 <<
" is not a correct dimensionality for pdfs !"
366 unsigned int classCount(0);
367 for (
const auto&
f : tmpVector) {
372 probDensityPerEventClassAllVariables[classCount] *=
p;
374 msg(
MSG::DEBUG) <<
"#BTAG# Empty bins for all hypothesis... "
375 <<
"The discriminating variables are not taken into "
376 <<
"account in this jet." <<
endmsg;
380 << probDensityPerEventClassAllVariables[classCount]
381 <<
" ic= " << classCount <<
endmsg;
385 << probDensityPerEventClassAllVariables
390 return probDensityPerEventClassAllVariables;
398 double nnum = numH->GetEntries();
399 double nden = denH->GetEntries();
405 msg(
MSG::DEBUG) <<
"#BTAG# Problem with Efficiency for " << hypo <<
"#" <<
hname <<
" "
409 msg(
MSG::DEBUG) <<
"#BTAG# Unknown histogram for Efficiency for " << hypo