Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ]   [ 15.*.* ] 

001 //////////////////////////////////////////////////////////////////////////////////////////////
002 ///    Author: A. Wildauer
003 ///    CERN, January 26, 2005
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 /** OLD APPROACH
034 Produce the likelihood of one tagger
035 */
036 std::vector<double> CombinerTool::simpleCombine(const JetTagInfoBase* iTagInfo) const
037 {
038     std::vector<double> likelihood;
039     // just to make sure
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         /** sum the likelihood vector for normalization */
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         // if not valid return -1. as sig and bkg
064         likelihood.push_back(-1.);
065         likelihood.push_back(-1.);
066     }
067     return likelihood;
068 }
069 
070 /** SIMPLER INTERFACE THAN old approach above
071 Produce the likelihood of one tagger
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     // no combine possible so we also dont know how many event types (normally 2: sig and bkg)
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 Combine the likelihoods from a list of taggers given in the combineTheseTaggers vector<string>
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     /// if no info object is there there is nothing to combine ...
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     /// if TruthInfo is the only object in the info map no combine is possible
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     /** The size of the likelihood vector is equal to the number of histogram files, i.e. the size of
112     the m_mapOfAllHistos vector in the LikelihoodTool (2 in case of one background and one signal).
113     Since the combiner tool shall not need to retrieve the likelihood tool this info has to be taken
114     from somewhere else. The size of the likelihood verctor of each ITagInfo object (except that of
115     the "TruthInfo" one) has also the size of the number of input files it gets it from m_mapOfAllHistos)
116     and hence we can take that on to resize *this likelihood vector.
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         /** if no InfoObjects of the requested types (combineTheseTaggers) has been found return -1. */
159         if (count == 0)
160         {
161           // no combine possible so we also dont know how many event types (normally 2: sig and bkg)
162           likelihood.clear();
163           likelihood.resize(0); // also resize because i am not 100% sure what clear() does to a resized vector :-)
164           likelihood.push_back(-1.);
165           likelihood.push_back(-1.);
166         }
167         /** sum the likelihood vector for normalization */
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         // no combine possible so we also dont know how many event types (normally 2: sig and bkg)
187         likelihood.push_back(-1.);
188         likelihood.push_back(-1.);
189     }
190     return likelihood;
191 }
192 
193 }

source navigation ] diff markup ] identifier search ] general search ]

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. Valid HTML 4.01!