ATLAS Offline Software
Loading...
Searching...
No Matches
Analysis::NewLikelihoodTool Class Reference

#include <NewLikelihoodTool.h>

Inheritance diagram for Analysis::NewLikelihoodTool:
Collaboration diagram for Analysis::NewLikelihoodTool:

Public Member Functions

 NewLikelihoodTool (const std::string &, const std::string &, const IInterface *)
virtual ~NewLikelihoodTool ()=default
virtual StatusCode initialize () override
void defineHypotheses (const std::vector< std::string > &)
void defineHistogram (const std::string &hname)
TH1 * prepareHistogram (const std::string &hypo, const std::string &hname) const
void smoothAndNormalizeHistogram (TH1 *histo, const std::string &hname) const
std::vector< double > calculateLikelihood (const std::vector< Slice > &lhVariableValues) const
void printStatus () const
double getEff (const std::string &hypo, const std::string &histo, const std::string &suffix) const
std::vector< std::string > gradeList (const std::string &hname) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

std::string m_taggerName
std::vector< std::string > m_hypotheses
SG::ReadCondHandleKey< JetTagCalibCondDatam_readKey {this, "HistosKey", "JetTagCalibHistosKey", "Key of input (derived) JetTag calibration data"}
 Key of calibration data:
bool m_normalizedProb
 Treatment of histograms:
bool m_interpolate
int m_smoothNTimes
std::vector< std::string > m_vetoSmoothingOf
std::vector< std::string > m_histograms
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 25 of file NewLikelihoodTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ NewLikelihoodTool()

Analysis::NewLikelihoodTool::NewLikelihoodTool ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 20 of file NewLikelihoodTool.cxx.

20 :
21 AthAlgTool(t,n,p),
22 m_taggerName("undefined"),
23 m_hypotheses(std::vector<std::string>()),
24 m_normalizedProb(true),
25 m_interpolate(false),
27 m_vetoSmoothingOf(std::vector<std::string>()),
28 m_histograms(std::vector<std::string>()) {
29
30 declareInterface<NewLikelihoodTool>(this);
31 declareProperty("taggerName", m_taggerName);
32 declareProperty("hypotheses", m_hypotheses);
33 declareProperty("normalizedProb", m_normalizedProb);
34 declareProperty("interpolate",m_interpolate);
35 declareProperty("smoothNTimes",m_smoothNTimes);
36 declareProperty("vetoSmoothingOf", m_vetoSmoothingOf);
37 m_hypotheses.push_back("B");
38 m_hypotheses.push_back("U");
39 m_hypotheses.push_back("C");
40 m_vetoSmoothingOf.push_back("/N2T");
41 m_vetoSmoothingOf.push_back("/N2TEffSV2");
42 m_vetoSmoothingOf.push_back("/Sip3D");
43 }
std::vector< std::string > m_histograms
std::vector< std::string > m_hypotheses
bool m_normalizedProb
Treatment of histograms:
std::vector< std::string > m_vetoSmoothingOf
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ ~NewLikelihoodTool()

virtual Analysis::NewLikelihoodTool::~NewLikelihoodTool ( )
virtualdefault

Member Function Documentation

◆ calculateLikelihood()

std::vector< double > Analysis::NewLikelihoodTool::calculateLikelihood ( const std::vector< Slice > & lhVariableValues) const

Definition at line 224 of file NewLikelihoodTool.cxx.

225 {
226 ATH_MSG_VERBOSE("#BTAG# calculate called for " << m_hypotheses.size() << " hypotheses.");
227 std::vector<double> probDensityPerEventClassAllVariables;
228 probDensityPerEventClassAllVariables.resize(m_hypotheses.size());
229 for (unsigned int i = 0 ; i < m_hypotheses.size(); ++i) {
230 probDensityPerEventClassAllVariables[i]=1.;
231 }
232 ATH_MSG_VERBOSE("#BTAG# -- lhVarVal size= " << lhVariableValues.size());
233 // loop on Tracks in the Jet (IP) / Vertices in the Jet (SV)
234 for (const auto& value : lhVariableValues) {
235 ATH_MSG_VERBOSE( "#BTAG# -- element " << value.name );
236 int ncompo = value.composites.size();
237 ATH_MSG_VERBOSE( "#BTAG# -- element " << value.name
238 << " has " << ncompo << " composites." );
239 // loop on variables that make up the Tag, e.g.
240 // one 1D for IP2D, one 2D for IP3D, one 1D and one 2D for SV1, one 3D for SV2
241 for (const auto& compo : value.composites) {
242 double sum(0.);
243 std::vector<double> tmpVector;
244 std::string histName = compo.name;
245 int idim = compo.atoms.size();
246 ATH_MSG_VERBOSE( "#BTAG# -- composite histo= "
247 << histName << " dim= " << idim );
248 for (const auto& hypo : m_hypotheses) {
249 TH1* tmpHisto = this->prepareHistogram(hypo,histName);
250 if(tmpHisto) {
251 if(1==idim) {
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);
257 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << "#BTAG# For hypothesis= " << hypo
258 << " (1D) actual value= " << valuex
259 << " --> bin= " << binx << " f = " << tmp;
260 if(m_interpolate) {
261 TH1* dc_tmp = dynamic_cast<TH1*>(tmpHisto);
262 if (dc_tmp) {
263 tmp = HistoHelperRoot::Interpol1d(valuex, dc_tmp);
264 if( msgLvl(MSG::VERBOSE) )msg(MSG::VERBOSE) << " interpolated f = " << tmp;
265 }
266 }
267 if(m_normalizedProb) { // pdf are already normalized
268 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " (normalized)" << endmsg;
269 } else {
270 double binw = tmpHisto->GetBinWidth(binx);
271 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " binw= " << binw;
272 if(0==binw) {
273 msg(MSG::ERROR) << "bin width is 0" << endmsg;
274 } else {
275 tmp /= binw;
276 }
277 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " normalized f = " << tmp << endmsg;
278 }
279 tmpVector.push_back(tmp);
280 sum += tmp;
281 }
282 if(2==idim) {
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);
292 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << "#BTAG# For hypothesis= " << hypo
293 << " (2D) actual value= " << valuex << " " << valuey
294 << " --> bin= " << binx << " " << biny << " f = " << tmp;
295 if(m_interpolate) {
296 TH2* dc_tmp = dynamic_cast<TH2*>(tmpHisto);
297 if (dc_tmp) {
298 tmp = HistoHelperRoot::Interpol2d(valuex, valuey, dc_tmp);
299 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " interpolated f = " << tmp;
300 }
301 }
302 if(m_normalizedProb) { // pdf are already normalized
303 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " (normalized)" << endmsg;
304 } else {
305 double binw = tmpHisto->GetXaxis()->GetBinWidth(binx)
306 * tmpHisto->GetYaxis()->GetBinWidth(biny);
307 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " binw= " << binw;
308 if(0==binw) {
309 msg(MSG::ERROR) << "bin width is 0" << endmsg;
310 } else {
311 tmp /= binw;
312 }
313 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " normalized f = " << tmp << endmsg;
314 }
315 tmpVector.push_back(tmp);
316 sum += tmp;
317 }
318 if(3==idim) {
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);
332 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << "#BTAG# For hypothesis= " << hypo
333 << " (3D) actual value= " << valuex
334 << " " << valuey << " " << valuez
335 << " --> bin= " << binx << " " << biny
336 << " " << binz << " f = " << tmp;
337 if(m_interpolate) {
338 TH3* dc_tmp = dynamic_cast<TH3*>(tmpHisto);
339 if (dc_tmp) {
340 tmp = HistoHelperRoot::Interpol3d(valuex, valuey, valuez, dc_tmp);
341 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " interpolated f = " << tmp;
342 }
343 }
344 if(m_normalizedProb) { // pdf are already normalized
345 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " (normalized)" << endmsg;
346 } else {
347 double binw = tmpHisto->GetXaxis()->GetBinWidth(binx)
348 * tmpHisto->GetYaxis()->GetBinWidth(biny)
349 * tmpHisto->GetZaxis()->GetBinWidth(binz);
350 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " binw= " << binw;
351 if(0==binw) {
352 msg(MSG::ERROR) << "bin width is 0" << endmsg;
353 } else {
354 tmp /= binw;
355 }
356 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " normalized f = " << tmp << endmsg;
357 }
358 tmpVector.push_back(tmp);
359 sum += tmp;
360 }
361 if(idim>3 || idim<1 ) msg(MSG::DEBUG) << "#BTAG# " << idim
362 << " is not a correct dimensionality for pdfs !"
363 << endmsg;
364 }
365 } // endloop on hypotheses (B,U,C..)
366 unsigned int classCount(0);
367 for (const auto& f : tmpVector) {
368 if(sum != 0.) {
369 if( msgLvl(MSG::DEBUG) ) msg(MSG::DEBUG) << "#BTAG# sum of pX = " << sum << endmsg;
370 double p = f;
371 if(m_normalizedProb) p /= sum;
372 probDensityPerEventClassAllVariables[classCount] *= p;
373 } else {
374 msg(MSG::DEBUG) << "#BTAG# Empty bins for all hypothesis... "
375 << "The discriminating variables are not taken into "
376 << "account in this jet." << endmsg;
377 msg(MSG::DEBUG) << "#BTAG# Please check your inputs" << endmsg;
378 }
379 if( msgLvl(MSG::DEBUG) ) msg(MSG::DEBUG) << "#BTAG# probDensity= "
380 << probDensityPerEventClassAllVariables[classCount]
381 << " ic= " << classCount << endmsg;
382 classCount++;
383 }
384 if( msgLvl(MSG::DEBUG) ) msg(MSG::DEBUG) << "#BTAG# Final probDensity= "
385 << probDensityPerEventClassAllVariables
386 << endmsg;
387 }
388 }
389 if( msgLvl(MSG::DEBUG) ) msg(MSG::DEBUG) << "#BTAG# Ending ..." << endmsg;
390 return probDensityPerEventClassAllVariables;
391 }
#define endmsg
#define ATH_MSG_VERBOSE(x)
static double Interpol3d(double, double, double, TH3 *)
static double Interpol1d(double, TH1 *)
static double Interpol2d(double, double, TH2 *)
TH1 * prepareHistogram(const std::string &hypo, const std::string &hname) const
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ defineHistogram()

void Analysis::NewLikelihoodTool::defineHistogram ( const std::string & hname)

◆ defineHypotheses()

void Analysis::NewLikelihoodTool::defineHypotheses ( const std::vector< std::string > & hyp)

Definition at line 50 of file NewLikelihoodTool.cxx.

50 {
51 m_hypotheses = hyp;
52 }

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getEff()

double Analysis::NewLikelihoodTool::getEff ( const std::string & hypo,
const std::string & histo,
const std::string & suffix ) const

Definition at line 393 of file NewLikelihoodTool.cxx.

393 {
394 double eff(0.);
395 TH1* numH = this->prepareHistogram(hypo, hname+"Eff"+suffix);
396 TH1* denH = this->prepareHistogram(hypo, hname+"Norm"+suffix);
397 if(numH && denH) {
398 double nnum = numH->GetEntries();
399 double nden = denH->GetEntries();
400 if(nden!=0) {
401 eff = nnum / nden;
402 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << "#BTAG# Efficiency for " << hypo << "#" << hname << " "
403 << suffix << ": " << nnum << "/" << nden << "= " << eff << endmsg;
404 } else {
405 msg(MSG::DEBUG) << "#BTAG# Problem with Efficiency for " << hypo << "#" << hname << " "
406 << suffix << ": " << nnum << "/" << nden << "= " << eff << endmsg;
407 }
408 } else {
409 msg(MSG::DEBUG) << "#BTAG# Unknown histogram for Efficiency for " << hypo
410 << "#" << hname << " " << suffix << endmsg;
411 }
412 return eff;
413 }

◆ gradeList()

std::vector< std::string > Analysis::NewLikelihoodTool::gradeList ( const std::string & hname) const

Definition at line 62 of file NewLikelihoodTool.cxx.

62 {
63 ATH_MSG_VERBOSE("#BTAG# gradeList() called for " << histoName);
64 const std::string delimSlash("/");
65 // first count slashes:
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++;
71 // extract string before the 2nd / sign: this is for the grades, the rest is the histogram name
72 slashPos = histoName.find_first_of(delimSlash);
73 std::string newName = histoName.substr(slashPos+1);
74 slashPos = newName.find_first_of(delimSlash);
75 std::string grades = newName.substr(0,slashPos);
76 std::string hhname = newName.substr(slashPos+1);
77 if(nSlash<2) grades = "";
78 ATH_MSG_VERBOSE("#BTAG# -> grades: " << grades);
79 ATH_MSG_VERBOSE("#BTAG# -> hhname: " << hhname);
80 // now decode the grades:
81 std::vector<std::string> gradeList;
82 if(grades!="") {
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();
89 sLen = sEnd - sPos;
90 std::string word = grades.substr(sPos,sLen);
91 ATH_MSG_DEBUG("#BTAG# --> grade = " << word);
92 gradeList.push_back(std::move(word));
93 sPos = grades.find_first_not_of(delimUds, sEnd);
94 }
95 }
96 // add the histogram name at the end of the list:
97 gradeList.push_back(std::move(hhname));
98 return gradeList;
99 }
#define ATH_MSG_DEBUG(x)
std::vector< std::string > gradeList(const std::string &hname) const

◆ initialize()

StatusCode Analysis::NewLikelihoodTool::initialize ( )
overridevirtual

Definition at line 45 of file NewLikelihoodTool.cxx.

45 {
46 ATH_CHECK(m_readKey.initialize());
47 return StatusCode::SUCCESS;
48 }
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadCondHandleKey< JetTagCalibCondData > m_readKey
Key of calibration data:

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Analysis::NewLikelihoodTool::interfaceID ( )
inlinestatic

Definition at line 34 of file NewLikelihoodTool.h.

34{ return IID_NewLikelihoodTool; };
static const InterfaceID IID_NewLikelihoodTool("Analysis::NewLikelihoodTool", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ prepareHistogram()

TH1 * Analysis::NewLikelihoodTool::prepareHistogram ( const std::string & hypo,
const std::string & hname ) const

Definition at line 101 of file NewLikelihoodTool.cxx.

101 {
102 TH1* histoSum = nullptr;
103
104 SG::ReadCondHandle<JetTagCalibCondData> readCdo(m_readKey);
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;
109 ATH_MSG_VERBOSE("#BTAG# preparing histogram " << longName);
110 ATH_MSG_VERBOSE("#BTAG# -> channel is " << channelName);
111 ATH_MSG_VERBOSE("#BTAG# -> histo is " << histoName);
112 // now decode the grades:
113 std::vector<std::string> gradeList = this->gradeList(histoName);
114 // - case with no grade:
115 if(1==gradeList.size()) {
116 ATH_MSG_DEBUG("#BTAG# Histo "<<actualName<<" has no grade: direct retrieval");
117 histoSum = readCdo->retrieveHistogram(m_taggerName,
118 channelName,
119 actualName);
120 }
121 // - case with 1 grade:
122 if(2==gradeList.size()) {
123 ATH_MSG_DEBUG("#BTAG# Histo "<<actualName<<" has only one grade: direct retrieval");
124 histoSum = readCdo->retrieveHistogram(m_taggerName,
125 channelName,
126 actualName);
127 //Part not fully migrated
128 //smoothAndNormalizeHistogram should not be called here but in condition algorithm
129 ATH_MSG_VERBOSE("#BTAG# Smoothing histogram " << longName << " ...");
130 this->smoothAndNormalizeHistogram(histoSum, longName);
131 }
132 // - for many grades, get individual histos and sum them up:
133 if(gradeList.size()>2) {
134 TH1* histo = nullptr;
135 ATH_MSG_DEBUG("Histo " << actualName << " has " << (gradeList.size()-1) << " grades:");
136 for(unsigned int i=0;i<(gradeList.size()-1);i++) {
137 actualName = hypo+"/"+gradeList[i]+gradeList[gradeList.size()-1];
138 ATH_MSG_VERBOSE("#BTAG# -> retrieving histo for grade " << i << " " << gradeList[i] << ": ");
139 histo = readCdo->retrieveHistogram(m_taggerName,
140 channelName,
141 actualName);
142 if(histo) ATH_MSG_VERBOSE("#BTAG# histo " << actualName
143 << " has " << histo->GetEntries() << " entries.");
144 if(0==i) {
145 histoSum = histo;
146 } else {
147 if(histo&&histoSum) histoSum->Add(histo,1.);
148 }
149 }
150 //Part not fully migrated
151 //smoothAndNormalizeHistogram should not be called here but in condition algorithm
152 ATH_MSG_VERBOSE("#BTAG# Smoothing histogram " << longName << " ...");
153 this->smoothAndNormalizeHistogram(histoSum, longName);
154 }
155 return histoSum;
156 }
void smoothAndNormalizeHistogram(TH1 *histo, const std::string &hname) const

◆ printStatus()

void Analysis::NewLikelihoodTool::printStatus ( ) const

Definition at line 54 of file NewLikelihoodTool.cxx.

54 {
55 msg(MSG::INFO) << "#BTAG# - hypotheses : ";
56 for(const auto& hypo : m_hypotheses) msg(MSG::INFO) << hypo << ", ";
57 msg(MSG::INFO) << endmsg;
58 msg(MSG::INFO) << "#BTAG# - histograms : " << endmsg;
59 for(const auto& histo : m_histograms) msg(MSG::INFO) << histo << endmsg;
60 }

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ smoothAndNormalizeHistogram()

void Analysis::NewLikelihoodTool::smoothAndNormalizeHistogram ( TH1 * histo,
const std::string & hname = "" ) const

Definition at line 158 of file NewLikelihoodTool.cxx.

158 {
159 if(h) {
160 double norm = h->Integral();
161 if(norm) {
162 // check if smoothing of histogram is not vetoed:
163 bool veto = false;
164 for(const auto& v : m_vetoSmoothingOf) {
165 if(hname.find(v)!=std::string::npos) {
166 veto = true;
167 ATH_MSG_VERBOSE("#BTAG# Smoothing of " << hname << " is vetoed !");
168 break;
169 }
170 }
171 if(1==h->GetDimension() && m_smoothNTimes) {
172 if(!veto) {
173 if(norm>10000)h->Smooth(m_smoothNTimes);
174 else h->Smooth((int)(m_smoothNTimes*100./sqrt(norm)));
175 }
176 }
177 if(2==h->GetDimension()) {
178 int m2d=3;
179 //if(hname.find("#B/")==std::string::npos) m2d=5; //VK oversmoothing!!!
180 if(!veto) {
181 TH2 * dc_tmp = dynamic_cast<TH2*>(h);
182 if (dc_tmp) {
183 HistoHelperRoot::smoothASH2D(dc_tmp, m2d, m2d, msgLvl(MSG::DEBUG));
184 }
185 }
186 }
187 if(3==h->GetDimension()) {
188 int m3d1=3;
189 int m3d3=2;
190 if(!veto) {
191 TH3 * dc_tmp = dynamic_cast<TH3*>(h);
192 if (dc_tmp) {
193 int Nx=dc_tmp->GetNbinsX();
194 int Ny=dc_tmp->GetNbinsY();
195 int Nz=dc_tmp->GetNbinsZ();
196 if(Nz == 7) //==========Old SV2
197 HistoHelperRoot::smoothASH3D(dc_tmp, m3d1, m3d1, m3d3, msgLvl(MSG::DEBUG));
198 else if(Nz == 6){ //==========New SV2Pt
199 double total=dc_tmp->Integral(1,Nx,1,Ny,1,Nz,"");
200 for(int iz=1; iz<=Nz; iz++){
201 double content=dc_tmp->Integral(1,Nx,1,Ny,iz,iz,""); if(content==0.)content=Nz;
202 double dnorm=total/content/Nz;
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; //Protection against empty bins
206 dc_tmp->SetBinContent(ix,iy,iz, cbin);
207 }
208 }
209 }
210 HistoHelperRoot::smoothASH3D(dc_tmp, m3d1, m3d1, m3d3, msgLvl(MSG::DEBUG));
211 }
212 }
213 }
214 }
215 // normalize:
216 norm = h->Integral();
217 h->Scale(1./norm);
218 } else {
219 ATH_MSG_DEBUG("#BTAG# Histo "<<h<<" is empty!");
220 }
221 }
222 }
static void smoothASH2D(TH2 *, int m1=3, int m2=3, bool debug=false)
static void smoothASH3D(TH3 *, int m1=3, int m2=3, int m3=2, bool debug=false)
std::vector< std::string > veto
these patterns are anded
Definition listroot.cxx:191
str content
Definition grepfile.py:56

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_histograms

std::vector<std::string> Analysis::NewLikelihoodTool::m_histograms
private

Definition at line 64 of file NewLikelihoodTool.h.

◆ m_hypotheses

std::vector<std::string> Analysis::NewLikelihoodTool::m_hypotheses
private

Definition at line 53 of file NewLikelihoodTool.h.

◆ m_interpolate

bool Analysis::NewLikelihoodTool::m_interpolate
private

Definition at line 60 of file NewLikelihoodTool.h.

◆ m_normalizedProb

bool Analysis::NewLikelihoodTool::m_normalizedProb
private

Treatment of histograms:

Definition at line 59 of file NewLikelihoodTool.h.

◆ m_readKey

SG::ReadCondHandleKey<JetTagCalibCondData> Analysis::NewLikelihoodTool::m_readKey {this, "HistosKey", "JetTagCalibHistosKey", "Key of input (derived) JetTag calibration data"}
private

Key of calibration data:

Definition at line 56 of file NewLikelihoodTool.h.

56{this, "HistosKey", "JetTagCalibHistosKey", "Key of input (derived) JetTag calibration data"};

◆ m_smoothNTimes

int Analysis::NewLikelihoodTool::m_smoothNTimes
private

Definition at line 61 of file NewLikelihoodTool.h.

◆ m_taggerName

std::string Analysis::NewLikelihoodTool::m_taggerName
private

Definition at line 52 of file NewLikelihoodTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vetoSmoothingOf

std::vector<std::string> Analysis::NewLikelihoodTool::m_vetoSmoothingOf
private

Definition at line 62 of file NewLikelihoodTool.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: