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

#include <CombinerTool.h>

Inheritance diagram for Analysis::CombinerTool:
Collaboration diagram for Analysis::CombinerTool:

Public Member Functions

 CombinerTool (const std::string &, const std::string &, const IInterface *)
virtual ~CombinerTool ()
StatusCode initialize ()
 AlgTool initailize method.
StatusCode finalize ()
 AlgTool finalize method.
virtual std::vector< double > simpleCombine (const xAOD::Jet &particleJet, const std::string &infoKey) const
 all tools used same samples (1 signal, N background) to create the LH histograms
virtual std::vector< double > simpleCombine (const xAOD::Jet &particleJet, const std::vector< std::string > &combineTheseTaggers) const
 Version 2: take only one ITagInfo Use a subset of all used tag tools.
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 ()
 AlgTool interface methods.

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

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 31 of file CombinerTool.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

◆ CombinerTool()

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

Definition at line 18 of file CombinerTool.cxx.

18 :
19 AthAlgTool( t, n, p )
20{
21 declareInterface<ICombinerTool>( this );
22}
AthAlgTool()
Default constructor:

◆ ~CombinerTool()

Analysis::CombinerTool::~CombinerTool ( )
virtual

Definition at line 24 of file CombinerTool.cxx.

25{}

Member Function Documentation

◆ 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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ 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>

◆ 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

◆ finalize()

StatusCode Analysis::CombinerTool::finalize ( )

AlgTool finalize method.

Definition at line 32 of file CombinerTool.cxx.

33{
34 return StatusCode::SUCCESS;
35}

◆ initialize()

StatusCode Analysis::CombinerTool::initialize ( )

AlgTool initailize method.

Definition at line 27 of file CombinerTool.cxx.

28{
29 return StatusCode::SUCCESS;
30}

◆ 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::ICombinerTool::interfaceID ( )
inlinestaticinherited

AlgTool interface methods.

Definition at line 39 of file ICombinerTool.h.

39{ return IID_ICombinerTool; };
static const InterfaceID IID_ICombinerTool("Analysis::ICombinerTool", 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.

◆ 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 }

◆ simpleCombine() [1/2]

std::vector< double > Analysis::CombinerTool::simpleCombine ( const xAOD::Jet & particleJet,
const std::string & infoKey ) const
virtual

all tools used same samples (1 signal, N background) to create the LH histograms

OLD APPROACH Produce the likelihood of one tagger.

Version 1: take only one ITagInfo This takes an ITagInfo object created by ONE tag only and calculated the likelihood. Practical if you want to calculate the LH of a single tag (remember only the probability is stored in the info objects)

sum the likelihood vector for normalization SIMPLER INTERFACE THAN old approach above Produce the likelihood of one tagger

Implements Analysis::ICombinerTool.

Definition at line 77 of file CombinerTool.cxx.

78{
79 std::vector<double> likelihood;
80 if (particleJet.tagInfo(infoKey) == 0)
81 {
82 // no combine possible so we also dont know how many event types (normally 2: sig and bkg)
83 likelihood.push_back(-1.);
84 likelihood.push_back(-1.);
85 return likelihood;
86 }
87 else
88 {
89 return simpleCombine(particleJet.tagInfo(infoKey));
90 }
91}
virtual std::vector< double > simpleCombine(const xAOD::Jet &particleJet, const std::string &infoKey) const
all tools used same samples (1 signal, N background) to create the LH histograms

◆ simpleCombine() [2/2]

std::vector< double > Analysis::CombinerTool::simpleCombine ( const xAOD::Jet & particleJet,
const std::vector< std::string > & combineTheseTaggers ) const
virtual

Version 2: take only one ITagInfo Use a subset of all used tag tools.

Combine the likelihoods from a list of taggers given in the combineTheseTaggers vector<string>

Specify the subset by puting their instance names into the vector: combineTheseTaggers.

if no info object is there there is nothing to combine ...

if TruthInfo is the only object in the info map no combine is possible

The size of the likelihood vector is equal to the number of histogram files, i.e. the size of the m_mapOfAllHistos vector in the LikelihoodTool (2 in case of one background and one signal). Since the combiner tool shall not need to retrieve the likelihood tool this info has to be taken from somewhere else. The size of the likelihood verctor of each ITagInfo object (except that of the "TruthInfo" one) has also the size of the number of input files it gets it from m_mapOfAllHistos) and hence we can take that on to resize *this likelihood vector.

if no InfoObjects of the requested types (combineTheseTaggers) has been found return -1.

sum the likelihood vector for normalization

Implements Analysis::ICombinerTool.

Definition at line 96 of file CombinerTool.cxx.

98{
99 bool combine(true);
100 std::vector<double> likelihood;
102 if ( particleJet.jetTagInfoVector().size() == 0 )
103 {
104 ATH_MSG_WARNING("#BTAG# JetTagInfoBase vector is ZERO. Nothing to combine!");
105 combine = false;
106 }
107
109 if ( particleJet.tagInfo("TruthInfo") != 0 && particleJet.jetTagInfoVector().size() == 1 )
110 {
111 ATH_MSG_DEBUG("#BTAG# The only object in ITagInfo vector is TruthInfo. No combine possible.");
112 combine = false;
113 }
114
122 if (combine)
123 {
124 bool firstValidTagger(true);
125 int count(0);
126 for ( std::vector<std::string>::const_iterator strItr = combineTheseTaggers.begin(); strItr != combineTheseTaggers.end(); ++strItr )
127 {
128 ATH_MSG_VERBOSE("#BTAG# Combining likelihood from these taggers " << *strItr);
129 const JetTagInfoBase* infoObject(particleJet.tagInfo(*strItr));
130 if ( infoObject != 0 )
131 {
132 if (infoObject->isValid())
133 {
134 if (firstValidTagger)
135 {
136 likelihood.resize( infoObject->tagLikelihood().size() );
137 for ( std::vector<double>::iterator itr = likelihood.begin() ;
138 itr != likelihood.end() ; ++itr )
139 {
140 ( *itr ) = 1.;
141 }
142 firstValidTagger=false;
143 }
144 count++;
145 const std::vector<double>& tmpVector = infoObject->tagLikelihood();
146
147 unsigned int numInputFiles( 0 );
148 for ( std::vector<double>::const_iterator tmpItr = tmpVector.begin();
149 tmpItr != tmpVector.end(); ++tmpItr )
150 {
151 if (likelihood.size()>=numInputFiles+1)
152 {
153 likelihood[ numInputFiles ] *= tmpVector[ numInputFiles ];
154 }
155 numInputFiles++;
156 }
157 }
158 else
159 ATH_MSG_DEBUG("#BTAG# TagTool " << *strItr << " does exist but is not valid.");
160 }
161 else
162 ATH_MSG_DEBUG("#BTAG# TagTool " << *strItr << " does not exist.");
163 }
164
166 if (count == 0)
167 {
168 // no combine possible so we also dont know how many event types (normally 2: sig and bkg)
169 likelihood.clear();
170 likelihood.resize(0); // also resize because i am not 100% sure what clear() does to a resized vector :-)
171 likelihood.push_back(-1.);
172 likelihood.push_back(-1.);
173 }
175 else if (count > 0)
176 {
177 double sum( 0. );
178 for ( std::vector<double>::iterator lhItr = likelihood.begin();
179 lhItr != likelihood.end(); ++lhItr )
180 {
181 sum += ( *lhItr );
182 }
183
184 for ( std::vector<double>::iterator lhItr = likelihood.begin();
185 lhItr != likelihood.end(); ++lhItr )
186 {
187 ( *lhItr ) /= sum;
188 }
189 }
190 }
191 else
192 {
193 // no combine possible so we also dont know how many event types (normally 2: sig and bkg)
194 likelihood.push_back(-1.);
195 likelihood.push_back(-1.);
196 }
197 return likelihood;
198}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
size_t combine(size_t lhs, size_t rhs)
Definition hash.h:21

◆ 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_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.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: