76 MsgStream mlog(msgSvc(),name());
79 std::map<std::string, TH1*>* tmpHistoMap =
new std::map<std::string, TH1*>();
83 std::string histoName = *itr;
84 std::vector<std::string> grades;
88 std::vector<std::string> words;
92 const std::string delim(
"_");
93 std::string::size_type sPos, sEnd, sLen;
94 sPos = histoName.find_first_not_of(delim);
95 while ( sPos != std::string::npos ) {
96 sEnd = histoName.find_first_of(delim, sPos);
97 if(sEnd==std::string::npos) sEnd = histoName.length();
99 std::string word = histoName.substr(sPos,sLen);
103 words.push_back(word);
104 sPos = histoName.find_first_not_of(delim, sEnd);
107 int nGrade = words.size() - 2;
110 ATH_MSG_DEBUG(
"Histo "<<histoName<<
" has "<<nGrade<<
" grade: direct retrieval");
112 }
else if(nGrade==1) {
113 ATH_MSG_DEBUG(
"Histo "<<histoName<<
" has "<<nGrade<<
" grade: direct retrieval");
117 ATH_MSG_DEBUG(
"Histo "<<histoName<<
" has "<<nGrade<<
" grades:");
118 for(
int i=1;i<=nGrade;i++) {
119 ATH_MSG_DEBUG(
" -> retrieving histo for grade "<<i<<
" : "<<words[1]<<
" "<<words[i+1]);
125 histoSum->Add(histo,1.);
127 ATH_MSG_DEBUG(
" #entries for Sum= "<<histoSum->GetEntries());
132 double norm = histoSum->Integral();
135 if(histoName.find(
"N2T")==std::string::npos){
137 else histoSum->Smooth((
int)(
m_nSmooth1D*100./sqrt(norm)));
140 if(2==histoSum->GetDimension()) {
142 if(refFileName.find(
"Bkg/")!=std::string::npos) m2d=5;
143 bool debug = mlog.level()<=MSG::DEBUG ? true :
false;
147 if(3==histoSum->GetDimension()) {
150 bool debug = mlog.level()<=MSG::DEBUG ? true :
false;
153 norm = histoSum->Integral();
154 histoSum->Scale(1./norm);
160 std::string namemap = histoName;
162 namemap = words[0]+
"_"+words[1];
164 tmpHistoMap->insert(std::pair<std::string, TH1*>(namemap, histoSum));
166 for(
int i=1;i<=nGrade;i++) {
167 namemap = words[0] +
"_" + words[1] +
"_" + words[i+1];
169 tmpHistoMap->insert(std::pair<std::string, TH1*>(namemap, histoSum));
173 std::string namedir = refFileName; namedir = namedir.substr((namedir.erase(namedir.size()-1,1)).rfind(
'/')+1)+
"/";
174 std::string namehis = histoSum->GetName();
176 TH1* histoSumClone = (TH1*)histoSum->Clone();
177 StatusCode
sc =
m_histoSvc->regHist(
"/ControlFile/"+namedir+namehis, histoSumClone);
178 if (
sc.isFailure()) {
179 ATH_MSG_ERROR(
"Cannot store the smoothed histogram in the control file !");
189 const std::string& histoName,
190 const std::string& jetPrefix) {
191 std::string fullPath(refFileName+histoName);
193 bool is1D =
false, is2D =
false, is3D =
false;
196 if(
sc.isFailure()) {};
199 if (
sc.isSuccess()) {
200 dim = tmphisto->GetDimension();
204 }
else if (dim == 2) {
207 }
else if (dim == 3) {
211 ATH_MSG_DEBUG(
"cannot retrieve histo " << fullPath <<
" Unexpected dimension "<< dim);
219 unsigned int bins = (tmphisto->GetXaxis())->GetNbins();
220 double minx = (tmphisto->GetXaxis())->GetXmin();
221 double maxx = (tmphisto->GetXaxis())->GetXmax();
224 ATH_MSG_DEBUG(
"Histo "<< jetPrefix+
"_"+histoName <<
" properties: ");
227 unsigned int binsy = (tmphisto->GetYaxis())->GetNbins();
228 double miny = (tmphisto->GetYaxis())->GetXmin();
229 double maxy = (tmphisto->GetYaxis())->GetXmax();
231 ATH_MSG_DEBUG(
"Histo "<< jetPrefix+
"_"+histoName <<
" properties: ");
233 ATH_MSG_DEBUG(binsy <<
" bins Y between " << miny <<
" and " << maxy);
235 unsigned int binsy = (tmphisto->GetYaxis())->GetNbins();
236 double miny = (tmphisto->GetYaxis())->GetXmin();
237 double maxy = (tmphisto->GetYaxis())->GetXmax();
238 unsigned int binsz = (tmphisto->GetZaxis())->GetNbins();
239 double minz = (tmphisto->GetZaxis())->GetXmin();
240 double maxz = (tmphisto->GetZaxis())->GetXmax();
243 ATH_MSG_DEBUG(
"Histo "<< jetPrefix+
"_"+histoName <<
" properties: ");
245 ATH_MSG_DEBUG(binsy <<
" bins Y between " << miny <<
" and " << maxy);
246 ATH_MSG_DEBUG(binsz <<
" bins Z between " << minz <<
" and " << maxz);
265 std::vector<double> probDensityPerEventClassAllVariables;
269 probDensityPerEventClassAllVariables[i]=1.;
278 for (
int icompo = 0;icompo<ncompo;icompo++) {
280 std::vector<double> tmpVector;
283 ATH_MSG_VERBOSE(
" -- composite "<<icompo<<
" histo= "<<histName<<
" dim= "<<idim);
287 for (std::vector< std::map<std::string, TH1*>* >
::iterator
290 if( (*itr2)->find(histName) != (*itr2)->end() ) {
291 TH1* tmpHisto = (*((*itr2)->find(histName))).second;
293 int bin((tmpHisto->GetXaxis())->FindBin(value));
296 if(value>= histoLimits.
xmax)
bin = histoLimits.
bins;
297 if(value<= histoLimits.
xmin)
bin = 1;
298 tmp = tmpHisto->GetBinContent(
bin);
305 double binw = tmpHisto->GetBinWidth(
bin);
306 if(binw != 0.)tmp /= binw;
308 ATH_MSG_VERBOSE(
" (1D) value= "<<value<<
" bin= "<<
bin<<
" binw= "<<binw<<
" f = "<<tmp);
310 tmpVector.push_back(tmp);
314 }
else if (idim == 2) {
316 for (std::vector< std::map<std::string, TH1*>* >
::iterator
319 if( (*itr2)->find(histName) != (*itr2)->end() ) {
320 TH1* tmpHisto = (*((*itr2)->find(histName))).second;
324 int binx((tmpHisto->GetXaxis())->FindBin(valuex));
325 int biny((tmpHisto->GetYaxis())->FindBin(valuey));
326 if(valuex>= histoLimits.
xmax) binx = histoLimits.
bins;
327 if(valuex<= histoLimits.
xmin) binx = 1;
328 if(valuey>= histoLimits.
ymax) biny = histoLimits.
binsy;
329 if(valuey<= histoLimits.
ymin) biny = 1;
330 double tmp(tmpHisto->GetBinContent(binx,biny));
331 ATH_MSG_VERBOSE(
" (2D) value= "<<valuex<<
" "<<valuey<<
" bin= "<<binx<<
" "<<biny<<
" f = "<<tmp);
333 double binw = tmpHisto->GetXaxis()->GetBinWidth(binx) * tmpHisto->GetYaxis()->GetBinWidth(biny);
334 if(binw != 0.)tmp /= binw;
336 ATH_MSG_VERBOSE(
" (2D) value= "<<valuex<<
" "<<valuey<<
" bin= "<<binx<<
" "<<biny<<
" binw= "<<binw<<
" f = "<<tmp);
338 tmpVector.push_back(tmp);
342 }
else if (idim == 3) {
344 for (std::vector< std::map<std::string, TH1*>* >
::iterator
347 if( (*itr2)->find(histName) != (*itr2)->end() ) {
348 TH1* tmpHisto = (*((*itr2)->find(histName))).second;
352 int binx((tmpHisto->GetXaxis())->FindBin(valuex));
353 int biny((tmpHisto->GetYaxis())->FindBin(valuey));
354 int binz((tmpHisto->GetZaxis())->FindBin(valuez));
355 if(valuex>= histoLimits.
xmax) binx = histoLimits.
bins;
356 if(valuex<= histoLimits.
xmin) binx = 1;
357 if(valuey>= histoLimits.
ymax) biny = histoLimits.
binsy;
358 if(valuey<= histoLimits.
ymin) biny = 1;
359 if(valuez>= histoLimits.
zmax) binz = histoLimits.
binsz;
360 if(valuez<= histoLimits.
zmin) binz = 1;
361 double tmpNoInt(tmpHisto->GetBinContent(binx,biny,binz));
363 ATH_MSG_VERBOSE(
" (3D) value= "<<valuex<<
" "<<valuey<<
" "<<valuez <<
" bin= "<<binx<<
" "<<biny<<
" "<<binz<<
" binContent = "<<tmp<<
" binContentNoInt = "<< tmpNoInt);
366 tmpHisto->GetXaxis()->GetBinWidth(binx) *
367 tmpHisto->GetYaxis()->GetBinWidth(biny) *
368 tmpHisto->GetZaxis()->GetBinWidth(binz);
374 ATH_MSG_VERBOSE(
" (3D) value= "<<valuex<<
" "<<valuey<<
" "<<valuez <<
" bin= "<<binx<<
" "<<biny<<
" "<<binz<<
" binw= "<<binw<<
" binContent = "<<tmp<<
" binContentNoInt = "<< tmpNoInt);
377 tmpVector.push_back(tmp);
380 tmpVector.push_back(tmpNoInt);
388 unsigned int classCount(0);
389 for (std::vector<double>::iterator itr3 = tmpVector.begin(); itr3 != tmpVector.end(); ++itr3) {
394 probDensityPerEventClassAllVariables[classCount] *= p;
396 ATH_MSG_WARNING(
"Empty bins for all hypothesis... The discriminating variables are not taken into account in this jet");
399 ATH_MSG_VERBOSE(
" probDensity= "<<probDensityPerEventClassAllVariables[classCount]<<
" ic= "<<classCount);
402 ATH_MSG_VERBOSE(
" Final probDensity= "<<probDensityPerEventClassAllVariables);
425 std::string fullPathSel(refFileName+histoName+
"Eff"+mode);
426 std::string fullPathGen(refFileName+histoName+
"Norm"+mode);
427 ATH_MSG_VERBOSE(
"Retrieving histo for efficiency computation: " << fullPathSel);
428 ATH_MSG_VERBOSE(
"Retrieving histo for efficiency computation: " << fullPathGen);
429 TH1 *
sel(0), *gen(0);
432 if (scs.isSuccess() && scg.isSuccess()) {
435 if (
sel && gen && scs.isSuccess() && scg.isSuccess()) {
436 double nsel =
sel->GetEntries();
437 double ngen = gen->GetEntries();
439 ATH_MSG_VERBOSE(
"N RecSvx = " << nsel <<
" in a total of "<< ngen <<
" jets.");
442 ATH_MSG_ERROR(
"Pb in computing Svx efficiency " << nsel <<
" "<< ngen);
450 if (
sel && gen && scs.isSuccess() && scg.isSuccess()) {
451 double nsel =
sel->GetEntries();
452 double ngen = gen->GetEntries();
454 ATH_MSG_VERBOSE(
"N RecSvx = " << nsel <<
" in a total of "<< ngen <<
" jets.");
457 ATH_MSG_ERROR(
"Pb in computing Svx efficiency " << nsel <<
" "<< ngen);