001
002
003
004
005
006
007 #include "JetTagTools/CombinerTool.h"
008 #include "JetEvent/JetTagInfoBase.h"
009 #include "JetEvent/Jet.h"
010
011 namespace Analysis
012 {
013
014 CombinerTool::CombinerTool( const std::string& t, const std::string& n, const IInterface* p ) :
015 AthAlgTool( t, n, p )
016 {
017 declareInterface<ICombinerTool>( this );
018 }
019
020 CombinerTool::~CombinerTool()
021 {}
022
023 StatusCode CombinerTool::initialize()
024 {
025 return StatusCode::SUCCESS;
026 }
027
028 StatusCode CombinerTool::finalize()
029 {
030 return StatusCode::SUCCESS;
031 }
032
033
034
035
036 std::vector<double> CombinerTool::simpleCombine(const JetTagInfoBase* iTagInfo) const
037 {
038 std::vector<double> likelihood;
039
040 if (iTagInfo==0) {
041 ATH_MSG_ERROR("#BTAG# Never give a NULL pointer to JetTagTools/CombinerTool::simpleCombine(...)! Fix it! I segfault!");
042 }
043 if (iTagInfo->isValid())
044 {
045 likelihood = iTagInfo->tagLikelihood();
046
047
048 double sum( 0. );
049 for ( std::vector<double>::iterator lhItr = likelihood.begin();
050 lhItr != likelihood.end(); ++lhItr )
051 {
052 sum += ( *lhItr );
053 }
054
055 for ( std::vector<double>::iterator lhItr = likelihood.begin();
056 lhItr != likelihood.end(); ++lhItr )
057 {
058 ( *lhItr ) /= sum;
059 }
060 }
061 else
062 {
063
064 likelihood.push_back(-1.);
065 likelihood.push_back(-1.);
066 }
067 return likelihood;
068 }
069
070
071
072
073 std::vector<double> CombinerTool::simpleCombine(const Jet& particleJet, const std::string& infoKey) const
074 {
075 std::vector<double> likelihood;
076 if (particleJet.tagInfo(infoKey) == 0)
077 {
078
079 likelihood.push_back(-1.);
080 likelihood.push_back(-1.);
081 return likelihood;
082 }
083 else
084 {
085 return simpleCombine(particleJet.tagInfo(infoKey));
086 }
087 }
088
089
090
091
092 std::vector<double> CombinerTool::simpleCombine( const Jet& particleJet,
093 const std::vector<std::string>& combineTheseTaggers ) const
094 {
095 bool combine(true);
096 std::vector<double> likelihood;
097
098 if ( particleJet.jetTagInfoVector().size() == 0 )
099 {
100 ATH_MSG_WARNING("#BTAG# JetTagInfoBase vector is ZERO. Nothing to combine!");
101 combine = false;
102 }
103
104
105 if ( particleJet.tagInfo("TruthInfo") != 0 && particleJet.jetTagInfoVector().size() == 1 )
106 {
107 ATH_MSG_DEBUG("#BTAG# The only object in ITagInfo vector is TruthInfo. No combine possible.");
108 combine = false;
109 }
110
111
112
113
114
115
116
117
118 if (combine)
119 {
120 bool firstValidTagger(true);
121 int count(0);
122 for ( std::vector<std::string>::const_iterator strItr = combineTheseTaggers.begin(); strItr != combineTheseTaggers.end(); strItr++ )
123 {
124 ATH_MSG_VERBOSE("#BTAG# Combining likelihood from these taggers " << *strItr);
125 const JetTagInfoBase* infoObject(particleJet.tagInfo(*strItr));
126 if ( infoObject != 0 )
127 {
128 if (infoObject->isValid())
129 {
130 if (firstValidTagger)
131 {
132 likelihood.resize( infoObject->tagLikelihood().size() );
133 for ( std::vector<double>::iterator itr = likelihood.begin() ;
134 itr != likelihood.end() ; ++itr )
135 {
136 ( *itr ) = 1.;
137 }
138 firstValidTagger=false;
139 }
140 count++;
141 const std::vector<double>& tmpVector = infoObject->tagLikelihood();
142
143 unsigned int numInputFiles( 0 );
144 for ( std::vector<double>::const_iterator tmpItr = tmpVector.begin();
145 tmpItr != tmpVector.end(); ++tmpItr )
146 {
147 likelihood[ numInputFiles ] *= tmpVector[ numInputFiles ];
148 numInputFiles++;
149 }
150 }
151 else
152 ATH_MSG_DEBUG("#BTAG# TagTool " << *strItr << " does exist but is not valid.");
153 }
154 else
155 ATH_MSG_DEBUG("#BTAG# TagTool " << *strItr << " does not exist.");
156 }
157
158
159 if (count == 0)
160 {
161
162 likelihood.clear();
163 likelihood.resize(0);
164 likelihood.push_back(-1.);
165 likelihood.push_back(-1.);
166 }
167
168 else if (count > 0)
169 {
170 double sum( 0. );
171 for ( std::vector<double>::iterator lhItr = likelihood.begin();
172 lhItr != likelihood.end(); ++lhItr )
173 {
174 sum += ( *lhItr );
175 }
176
177 for ( std::vector<double>::iterator lhItr = likelihood.begin();
178 lhItr != likelihood.end(); ++lhItr )
179 {
180 ( *lhItr ) /= sum;
181 }
182 }
183 }
184 else
185 {
186
187 likelihood.push_back(-1.);
188 likelihood.push_back(-1.);
189 }
190 return likelihood;
191 }
192
193 }
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|