Commit 077a0493 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

v15r0

parent ac9a8898
......@@ -3,7 +3,7 @@
# Maintainer :
#============================================================================
package BBDecTreeTool
version v1r4p1
version v1r5
# Structure
#============================================================================
......
......@@ -4,6 +4,16 @@
! Purpose : Decision Tree classifier for Hlt2 topological trigger
! -----------------------------------------------------------------------------
!========================= BBDecTreeTool v1r5 2012-06-28 =========================
! 2012-06-27 - Chris Jones
- Use a new getIDVAlgorithm that includes a check to make sure the tool is
a private instance, not opublic.
! 2012-06-22 - Chris Jones
- Use getIDVAlgorithm instead of getDVAlgorithm, in preparation for a future
change in the DaVInci base classes.
!========================= BBDecTreeTool v1r4p1 2012-03-01 =========================
! 2012-02-08 - Chris Jones
......
......@@ -2,17 +2,19 @@
// ============================================================================
#include "BBDTSimpleTool.h"
#include "LoKi/IHybridFactory.h"
#include "Kernel/GetIDVAlgorithm.h"
// ============================================================================
BBDTSimpleTool::BBDTSimpleTool(const std::string& type,
const std::string& name,
const IInterface* parent)
: base_class(type,name,parent), m_vars(0){
: base_class(type,name,parent), m_vars(0)
{
// declare configurable properties
declareProperty("Cuts", m_cuts, "Simple tree of cuts");
}
// ===========================================================================
StatusCode BBDTSimpleTool::initialize() {
StatusCode BBDTSimpleTool::initialize()
{
// initialize the base class (the first action)
StatusCode sc = GaudiTool::initialize();
if(sc.isFailure()) return sc;
......@@ -20,8 +22,8 @@ StatusCode BBDTSimpleTool::initialize() {
// get tools and algs
IDistanceCalculator* dist
= tool<IDistanceCalculator>("LoKi::DistanceCalculator",this);
const DVAlgorithm* dva = Gaudi::Utils::getDVAlgorithm(contextSvc());
if (0 == dva)
const IDVAlgorithm* dva = Gaudi::Utils::getIDVAlgorithm(contextSvc(),this);
if ( !dva )
return Error("Couldn't get parent DVAlgorithm", StatusCode::FAILURE);
m_vars = new BBDTVarHandler(dva, dist);
......@@ -57,7 +59,7 @@ StatusCode BBDTSimpleTool::initialize() {
if(iter != m_cuts.end()) debug() << "|";
}
debug() << "]" << endmsg;
return StatusCode::SUCCESS;
return sc;
}
// ===========================================================================
StatusCode BBDTSimpleTool::finalize() {
......
......@@ -23,7 +23,7 @@ namespace Gaudi {
*
* The tool can be used with LoKi/Bender functors :
*
* @code
* @code #include <Kernel/GetIDVAlgorithm.h>
* xxx.Code = " ... & FILTER('BBDTSimpleTool') "
* @endcode
*
......
......@@ -35,7 +35,7 @@ double totHeavyVChi2Dof(const LHCb::Particle *p){
else return 0;
}
// ============================================================================
BBDTVarHandler::BBDTVarHandler(const DVAlgorithm* dva, const IDistanceCalculator* dist):
BBDTVarHandler::BBDTVarHandler(const IDVAlgorithm* dva, const IDistanceCalculator* dist):
m_dist(dist), m_ipTool(dist), m_dva(dva), m_values(9),m_use(9,false),
m_SUMPT(LoKi::Cuts::SUMTREE(LoKi::Cuts::PT,LoKi::Cuts::ISBASIC,0.0)),
m_MINPT(LoKi::Cuts::MINTREE(LoKi::Cuts::ISBASIC,LoKi::Cuts::PT)),
......@@ -88,7 +88,7 @@ bool BBDTVarHandler::set(const LHCb::Particle* p) {
if(0 == p) return false;
// get variables we need
const LHCb::VertexBase* bpv = m_dva->bestPV(p);
const LHCb::VertexBase* bpv = m_dva->bestVertex(p);
if(m_use[0]) m_values[0] = m_SUMPT(p)/Gaudi::Units::MeV;
if(m_use[1]) m_values[1] = p->measuredMass()/Gaudi::Units::MeV;
if(m_use[2]) m_values[2] = docaMax(p,m_dist)/Gaudi::Units::mm;
......
......@@ -8,8 +8,7 @@
#include "Event/RecVertex.h"
#include "Event/Particle.h"
#include "Kernel/IParticleFilter.h"
#include "Kernel/DVAlgorithm.h"
#include "Kernel/GetDVAlgorithm.h"
#include "Kernel/IDVAlgorithm.h"
#include "Kernel/IDistanceCalculator.h"
#include "LoKi/ParticleCuts.h"
#include "LoKi/AParticleCuts.h"
......@@ -28,7 +27,7 @@
class BBDTVarHandler {
public:
BBDTVarHandler(const DVAlgorithm* dva, const IDistanceCalculator* dist);
BBDTVarHandler(const IDVAlgorithm* dva, const IDistanceCalculator* dist);
virtual ~BBDTVarHandler(){}
void setPIDs(const LoKi::PhysTypes::Cut &cut);
StatusCode initialize(const std::vector<std::string> &vars);
......@@ -59,7 +58,7 @@ private:
const IDistanceCalculator* m_dist; ///< LoKi::DistanceCalculator
const LoKi::Vertices::ImpactParamTool m_ipTool;
const DVAlgorithm* m_dva; ///< DVAlgorithm (to get BPV)
const IDVAlgorithm* m_dva; ///< IDVAlgorithm (to get BPV)
std::vector<double> m_values; ///< variables
std::vector<bool> m_use; ///< use this variable?
......
......@@ -3,17 +3,23 @@
#include "boost/filesystem/path.hpp"
#include "boost/filesystem.hpp"
#include "LoKi/IHybridFactory.h"
#include <Kernel/GetIDVAlgorithm.h>
// ============================================================================
std::string SubstituteEnvVarInPath(const std::string& in) {
std::string SubstituteEnvVarInPath(const std::string& in)
{
/* cp'd directly from $L0MUONROOT/src/component/SubstituteEnvVarInPath.cpp */
boost::filesystem::path path(in);
boost::filesystem::path::iterator i = path.begin();
boost::filesystem::path out;
while (i != path.end()) {
if ( *(i->c_str())=='$' ) {
while (i != path.end())
{
if ( *(i->c_str())=='$' )
{
std::string x = System::getEnv( i->c_str()+1 );
out /= x.empty() ? *i : x ;
} else {
}
else
{
out /= *i;
}
++i;
......@@ -23,8 +29,12 @@ std::string SubstituteEnvVarInPath(const std::string& in) {
// ============================================================================
BBDecTreeTool::BBDecTreeTool(const std::string& type, const std::string& name,
const IInterface* parent)
: base_class(type,name,parent), m_threshold(-1.0), m_key(-1), m_ntrees(-1),
m_vars(0){
: base_class(type,name,parent),
m_threshold(-1.0),
m_key(-1),
m_ntrees(-1),
m_vars(0)
{
// declare configurable properties
declareProperty("Threshold", m_threshold, "response threshold (cut)");
declareProperty("ParamFile", m_paramFile, "parameter file (full path)");
......@@ -32,32 +42,38 @@ BBDecTreeTool::BBDecTreeTool(const std::string& type, const std::string& name,
declareProperty("PIDs",m_pids, "PID names for daughter PT variables");
}
// ============================================================================
StatusCode BBDecTreeTool::readError(const std::string &msg) const {
Error("Problem with file " + m_paramFile + ": " + msg + ".");
return StatusCode::FAILURE;
StatusCode BBDecTreeTool::readError(const std::string &msg) const
{
return Error("Problem with file " + m_paramFile + " : '" + msg + "'");
}
// ===========================================================================
StatusCode BBDecTreeTool::initialize() {
StatusCode BBDecTreeTool::initialize()
{
// initialize the base class (the first action)
StatusCode sc = GaudiTool::initialize();
if(sc.isFailure()) return sc;
if ( sc.isFailure() ) return sc;
// get tools and algs
IDistanceCalculator* dist
// get tools
IDistanceCalculator * dist
= tool<IDistanceCalculator>("LoKi::DistanceCalculator",this);
const DVAlgorithm* dva = Gaudi::Utils::getDVAlgorithm(contextSvc());
if (0 == dva) {
// Get DV Alg. *must* be private to do this
const IDVAlgorithm* dva = Gaudi::Utils::getIDVAlgorithm(contextSvc(),this);
if ( !dva )
{
return Error("Couldn't get parent DVAlgorithm", StatusCode::FAILURE);
}
m_vars = new BBDTVarHandler(dva, dist);
// configure the BBDT var handler to use specified PIDs
int size = m_pids.size();
if(size > 0){
const unsigned int size = m_pids.size();
if ( size > 0 )
{
LoKi::PhysTypes::Cut cut(LoKi::Cuts::ABSID == m_pids[0]);
for(int i = 1; i < size; i++)
for ( unsigned int i = 1; i < size; ++i )
{
cut = (cut || (LoKi::Cuts::ABSID == m_pids[i]));
}
m_vars->setPIDs(cut);
}
......@@ -76,7 +92,8 @@ StatusCode BBDecTreeTool::initialize() {
m_splits.resize(nvar);
// variable names
for(unsigned int v = 0; v < nvar; v++){
for ( unsigned int v = 0; v < nvar; ++v )
{
if(!(inFile >> var_names[v]))
return this->readError("error reading in variable names");
}
......@@ -85,16 +102,19 @@ StatusCode BBDecTreeTool::initialize() {
// number of splits for each variable
unsigned int numSplits = 1;
for(unsigned int v = 0; v < nvar; v++) {
for ( unsigned int v = 0; v < nvar; ++v )
{
if(!(inFile >> value))
return this->readError("error reading no. of splits");
m_splits[v].resize(value);
numSplits *= value;
}
// split values for each variable
for(unsigned int v = 0; v < nvar; v++) {
unsigned int size = m_splits[v].size();
for(unsigned int s = 0; s < size; s++){
for ( unsigned int v = 0; v < nvar; ++v )
{
const unsigned int size = m_splits[v].size();
for ( unsigned int s = 0; s < size; ++s )
{
if(!(inFile >> dvalue)) return this->readError("error reading splits");
m_splits[v][s] = dvalue;
}
......@@ -104,7 +124,8 @@ StatusCode BBDecTreeTool::initialize() {
return this->readError("error reading no. of trees");
// actual values
m_values.resize(numSplits);
while(inFile >> index >> value){
while(inFile >> index >> value)
{
if(index > numSplits) return this->readError("error reading values");
m_values[index] = (unsigned short int)value;
}
......@@ -116,7 +137,7 @@ StatusCode BBDecTreeTool::initialize() {
<< m_paramFile << " -> " << fnam << " (" << m_ntrees << " trees,"
<< nvar << " vars," << numSplits << " splits)." << endmsg;
return StatusCode::SUCCESS ;
return sc;
}
// ===========================================================================
StatusCode BBDecTreeTool::finalize() {
......
......@@ -9,6 +9,7 @@
// ============================================================================
class IDVAlgorithm ;
class IAlgContextSvc ;
class IAlgTool ;
// ============================================================================
namespace Gaudi
{
......@@ -33,8 +34,32 @@ namespace Gaudi
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-12-04
*/
// ========================================================================
IDVAlgorithm* getIDVAlgorithm ( const IAlgContextSvc* svc ) ;
// ========================================================================
/** get the pointer to the "current" IDVAlgorithm, with a safety check on
* the object doing it to check it is a private tool, not a public one,
* for which the returned IDVAlgorithm is not well defined.
*
* @code
*
* // get the context service:
* IAlgContextSvc* svc = ... ;
*
* // get IDVAlgorithm from it:
* IDVAgorithm* alg = Gaudi::Utils::getIDVAlgorithm ( svc, this ) ;
*
* @endcode
*
* @see IDVAlgorithm
* @see IAlgContextSvc
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-12-04
*/
// ========================================================================
IDVAlgorithm* getIDVAlgorithm ( const IAlgContextSvc* svc,
const IAlgTool * tool ) ;
// ========================================================================
} // end of namespace Gaudi::Utils
// ==========================================================================
} // end of namespace Gaudi
......@@ -43,5 +68,3 @@ namespace Gaudi
// ============================================================================
#endif // KERNEL_GETIDVALGORITHM_H
// ============================================================================
......@@ -9,6 +9,8 @@
#include "GaudiKernel/IAlgTool.h"
// from LHCb
#include "Event/Particle.h"
#include "Event/CaloHypo.h"
#include "CaloUtils/CaloMomentum.h"
/** @class IBremAdder IBremAdder.h Kernel/IBremAdder.h
*
......@@ -20,17 +22,23 @@
class GAUDI_API IBremAdder : virtual public IAlgTool {
public:
DeclareInterfaceID(IBremAdder, 2, 0);
DeclareInterfaceID(IBremAdder, 4, 0);
// Add Brem
virtual bool addBrem( LHCb::Particle* particle ) const = 0 ;
virtual bool addBrem( LHCb::Particle* particle , bool force=false) = 0 ;
// Remove Brem
virtual bool removeBrem( LHCb::Particle* particle ) const = 0 ;
virtual bool removeBrem( LHCb::Particle* particle , bool force=false) = 0 ;
// Add Brem on particle pair (removing overlap)
virtual bool addBrem2Pair( LHCb::Particle* p1, LHCb::Particle* p2 , bool force=false) = 0 ;
// helper methods
virtual bool hasBrem(const LHCb::Particle* particle)=0;
virtual const LHCb::CaloMomentum bremMomentum(const LHCb::Particle* particle,std::string flag="")=0;
virtual const std::pair<LHCb::CaloMomentum,LHCb::CaloMomentum> bremMomenta(const LHCb::Particle* p1,
const LHCb::Particle*p2,
std::string flag="")=0;
protected:
virtual ~IBremAdder() ; // virtual and protected destructors
private:
};
#endif // KERNEL_IBREMADDER_H
......@@ -31,6 +31,7 @@ class IParticleReFitter ;
class IParticleCombiner ;
class IPVReFitter ;
class GaudiAlgorithm ;
class IBTaggingTool ;
// ============================================================================
/** @class IDVAlgorithm Kernel/IDVAlgorithm.h
*
......@@ -78,6 +79,8 @@ public: // tools
/// Accessor for primary vertex re-fitter tool
virtual const IPVReFitter*
primaryVertexReFitter ( const std::string& nickname = "" ) const = 0 ;
/// Access the Flavour tagging tool
virtual IBTaggingTool* flavourTagging() const = 0;
// ==========================================================================
public: // implementation
// ==========================================================================
......
......@@ -34,7 +34,7 @@ public:
virtual int getNumberOfParameters(void) = 0;
/// Get the value of calculated parameter and its name (e.g. for the tuple tool) for the given ID
virtual void getInfo(int index, double& value, std::string& name) = 0;
virtual int getInfo(int index, double& value, std::string& name) = 0;
protected:
......
......@@ -4,7 +4,7 @@
# Maintainer : Juan Palacios
#============================================================================
package DaVinciInterfaces
version v2r14
version v2r15
#============================================================================
# Structure, i.e. directories to process.
......@@ -14,6 +14,7 @@ branches cmt doc dict src Kernel
use GaudiKernel v*
use PhysEvent v* Event
use DaVinciTypes v* Phys
use CaloUtils v* Calo
#============================================================================
apply_pattern install_more_includes more =Kernel
#============================================================================
......
......@@ -59,5 +59,6 @@
#include "Kernel/IJets2Jets.h"
#include "Kernel/IDecayTreeFit.h"
#include "Kernel/IStandardParticleProvider.h"
#include "Kernel/IParticleVeto.h"
#endif // DICT_DAVINCIINTERFACESDICT_H
......@@ -50,6 +50,7 @@
<class name = "IJets2Jets"/>
<class name = "IDecayTreeFit"/>
<class name = "IStandardParticleProvider"/>
<class name = "IParticleVeto"/>
<class pattern = "extend_interfaces*"/>
......
......@@ -4,6 +4,24 @@
! Purpose : Tool interfaces and dictionaries for DaVinci
!-----------------------------------------------------------------------------
!========================= DaVinciInterfaces v2r15 2012-06-28 =========================
! 2012-06-27 - Chris Jones
- Add new getIDVAlgorithm method that includes a safety check on if the tool
is private or not. To be used if pointer is cached during initialize().
! 2012-06-22 - Chris Jones
- Add a new method to IDVAlgorithm to access the flavour tagging tool
! 2012-06-20 - Anton Poluektov
- Modify IExtraInfoTool.h to allow it to store a subset of parameters
! 2012-06-12 - Olivier Deschamps
- IBremAdder : add new interface methods
! 2012-05-14 - Olivier Deschamps
- change IBremAdder interface
!========================= DaVinciInterfaces v2r14 2012-05-03 =========================
! 2012-04-27 - Olivier Deschamps
......
......@@ -27,13 +27,14 @@
#include "Kernel/ICheckOverlap.h"
#include "Kernel/IParticleIsolation.h"
#include "Kernel/IParticleVeto.h"
#include "Kernel/IBremAdder.h"
// ============================================================================
/** @file
/** @file
* Implementation file for class some interfaces from
* Phys/DaVinciInterfaces package
* @date 2009-08-15
* @author Vanya BELYAEV Ivan.Belyaev
*/
*/
// ============================================================================
// virtual & protected desctructor
// ============================================================================
......@@ -55,7 +56,8 @@ IParticleFilter :: ~IParticleFilter () {}
IDecayTreeFit :: ~IDecayTreeFit () {}
ICheckOverlap :: ~ICheckOverlap () {}
IParticleIsolation :: ~IParticleIsolation () {}
IParticleVeto :: ~IParticleVeto () {}
IParticleVeto :: ~IParticleVeto () {}
IBremAdder :: ~IBremAdder () {}
// ============================================================================
// The END
......
......@@ -7,6 +7,9 @@
#include "GaudiKernel/IAlgContextSvc.h"
#include "GaudiKernel/IAlgorithm.h"
#include "GaudiKernel/SmartIF.h"
#include "GaudiKernel/GaudiException.h"
#include "GaudiKernel/IAlgTool.h"
#include "GaudiKernel/IToolSvc.h"
// ============================================================================
// GaudiAlg
// ============================================================================
......@@ -41,43 +44,39 @@ namespace
/// the only one essential method:
virtual bool operator() ( const IAlgorithm* alg ) const
{
if ( 0 == alg ) { return false ; }
if ( !alg ) { return false ; }
IAlgorithm* _alg = const_cast<IAlgorithm*> ( alg );
SmartIF<IDVAlgorithm> idv ( _alg );
return idv.isValid() ;
}
virtual ~IDVSelector(){};
virtual ~IDVSelector() { }
// ========================================================================
};
// ==========================================================================
}
// ============================================================================
/* get the pointer to the "current" IDVAlgorithm
*
* @code
*
* // get the context service:
* IAlgContextSvc* svc = ... ;
*
* // get IDVAlgorithm from it:
* IDVAgorithm* alg = Gaudi::Utils::getIDVAlgorithm ( svc ) ;
*
* @endcode
*
* @see IDVAlgorithm
* @see IAlgContextSvc
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-12-04
*/
// ============================================================================
IDVAlgorithm* Gaudi::Utils::getIDVAlgorithm ( const IAlgContextSvc* svc )
{
if ( 0 == svc ) { return 0 ; } // RETURN
if ( !svc ) { return NULL ; } // RETURN
// use context service:
IAlgorithm* alg = Gaudi::Utils::getAlgorithm ( svc , IDVSelector() ) ;
if ( 0 == alg ) { return 0 ; } // RETURN
if ( !alg ) { return NULL ; } // RETURN
return SmartIF<IDVAlgorithm> ( alg ) ;
}
// ============================================================================
IDVAlgorithm* Gaudi::Utils::getIDVAlgorithm ( const IAlgContextSvc* svc,
const IAlgTool * tool )
{
if ( !tool ) return NULL;
const IToolSvc* parent = dynamic_cast<const IToolSvc*>( tool->parent() );
if ( parent )
{
throw GaudiException( "Cannot safely be used with public tools",
"Gaudi::Utils::getIDVAlgorithm",
StatusCode::FAILURE );
}
return getIDVAlgorithm( svc );
}
// ============================================================================
// The END
// ============================================================================
// $Id: BestPV.h,v 1.3 2009-09-14 15:54:18 jpalac Exp $
#ifndef KERNEL_BESTPV_H
#define KERNEL_BESTPV_H 1
// Include files
#include "Kernel/DVAlgorithm.h"
#include "Kernel/GetDVAlgorithm.h"
/** @namespace DaVinci BestPV.h
*
*
* @author Juan PALACIOS
* @date 2009-08-05
*/
namespace DaVinci {
/** @class _BestPV Kernel/BestPV.h
*
* Functor that calls back to the parent DVAlgorithm in order
* to get the "best" PV for a given LHCb::Particle. Calls
* DVAlgorithm::bestPV(const LHCb::Particle*).
*
* <b>Conditions</b>
*
* T must implement T::contextSvc()
*
* The entity creating a BestPV must be owned at some level by a
* DVAlgorithm (can be a few generations removed)
*
* A DaVinci::BestPV instance can be created at any moment. It is only
* upon calling the operator() for the first time that the contextSvc()
* method is called and the DVAlgorithm used. It is therefore only necessary
* that the first call be made when all tools and services are valid.
*
* <b>Usage</b>
*
* Make an automatic DaVinci::BestPV and use it directly:
*
* @code
* // inside a GaudiTool
* const DaVinci::BestPV getBestPV(*this);
* ....
* const LHCb::Particle* p = ....
* const LHCb::VerrtexBase* bestPV = getBestPV(p);
* @endcode
*
* It is also possible to avoid the intermediate instance:
*
* @code