Commit 0bf5919d authored by Marco Clemencic's avatar Marco Clemencic
Browse files

v9r7

parent 698be69d
// $Id: DVAlgorithm.h,v 1.54 2010-05-14 15:07:10 ibelyaev Exp $
// $Id: DVAlgorithm.h,v 1.59 2010-06-18 09:42:06 jpalac Exp $
// ============================================================================
#ifndef DAVINCIKERNEL_DVALGORITHM_H
#define DAVINCIKERNEL_DVALGORITHM_H 1
......@@ -18,7 +18,6 @@
// ============================================================================
#include "Event/Particle.h"
#include "Event/Vertex.h"
#include "Event/SelResult.h"
// ============================================================================
// from DaVinciKernel
// ============================================================================
......@@ -26,13 +25,11 @@
#include "Kernel/IPhysDesktop.h"
#include "Kernel/IOnOffline.h"
#include "Kernel/IVertexFit.h"
#include "Kernel/IGeomDispCalculator.h"
#include "Kernel/IParticleFilter.h"
#include "Kernel/IFilterCriterion.h"
#include "Kernel/ICheckOverlap.h"
#include "Kernel/IBTaggingTool.h"
#include "Kernel/IParticleDescendants.h"
#include "Kernel/IWriteSelResult.h"
#include "Kernel/IDecayTreeFit.h"
#include "Kernel/IDistanceCalculator.h"
#include "Kernel/IPVReFitter.h"
#include "Kernel/IRelatedPVFinder.h"
......@@ -81,18 +78,18 @@
* - <b>PVReFitters</b> : the map for possible primary vertex re-fitters
* @see IPVReFitter
*
* - <b>ReFitPVs</b> : bool. Perform automatic PV re-fitting when asking for best PV.
* - <b>ReFitPVs</b> : bool. Perform automatic PV re-fitting when asking for best PV. Default: false.
*
* - <b>UseP2PVRelations</b> : bool. Use P2PV relations internally or calculate best PV on the fly. Forced to false for events with one PV. Forced to true if <b>ReFitPVs</b> is true, for all events. Default: true.
*
* - <b>WriteP2PVRelations</b> : bool. Write P2PV relations to output TES location "<algorithm output location>/Particle2VertexRelations". Default: true.
*
* - <b>IgnoreP2PVFromInputLocations</b> : Do not pick up <InputLocations>"/Particle2VertexRelations". Forces to calculate best PV on the fly. To be used specially if you want to use ReFitPVs when the input algorithms didn't or vice versa. Or to be sure that you are re-calculating the best PV in your own algorithm. Bear in mind this involves potentially CPU expensive calculations. Default: false.
*
* - <b>DecayDescriptor</b> : the decay descriptor ofthe algorithm
* in the spirit of (MC)DecayFinder tool by Olivier Dormond.
*
*
* - <b>AvoidSelResult</b> : the boolean flag (default value id <c>false</c>)
* to avoid the publishing of selection results in TES
*
* - <b>PrintSelResults</b> : the boolean flag (default value is <c>false</c>)
* to print the selection resulst
*
* - <b>AvoidForcedOutput</b> : the boolean flag (default value is <c>false</c>)
* to avoid the wrinting of empty containers if no output data are required.
*
......@@ -148,7 +145,8 @@ public: // IDVAlgorithm
* @param name the tool name/typename/nickname
* @return pointer to aquired tool
*/
const IDistanceCalculator* distanceCalculator
const IDistanceCalculator*
distanceCalculator
( const std::string& name = "" ) const
{
return getTool<IDistanceCalculator>
......@@ -195,6 +193,19 @@ public: // IDVAlgorithm
m_particleReFitterNames ,
m_particleReFitters , this ) ;
}
/** Accessor for IDecayTreeFit tools by name/typename/nickname
* @see IDecayTreeFit
* @param name the tool name/typename/nickname
* @return pointer to aquired tool
*/
IDecayTreeFit*
decayTreeFitter ( const std::string& name = "" ) const
{
return getTool<IDecayTreeFit>
( name ,
m_decayTreeFitterNames ,
m_decayTreeFitters , this ) ;
}
/** Accessor for IParticleCombiner tools by name/typename/nickname
* @see IParticleCombiner
* @param name the tool name/typename/nickname
......@@ -247,6 +258,19 @@ public: // IDVAlgorithm
m_pvReFitterNames ,
m_pvReFitters , this ) ;
}
/** Accessor for Particle Filter Tool
* @see IPArticleFilter
* @param name the tool name/typename/nickname
* @return pointer to aquired tool
*/
const IParticleFilter*
particleFilter ( const std::string& name = "" ) const
{
return getTool<IParticleFilter>
( name ,
m_filterNames ,
m_filters , this ) ;
}
// ==========================================================================
public:
// ==========================================================================
......@@ -361,31 +385,6 @@ public:
(this->desktop()->Particle2VertexRelations().i_removeFrom(part)).ignore();
this->desktop()->relate(part, vert);
}
public:
/// Accessor for Geometrical Displacement Calculation Tool
inline IGeomDispCalculator*
obsoleteGeomDispCalculator ( const std::string& name = "" ) const
{
Warning("You are using the obsolete IGeomDispCalculator interface. Use IDistanceCalculator instead.",
1,StatusCode::SUCCESS).ignore();
return getTool<IGeomDispCalculator>
( name ,
m_geomToolNames ,
m_geomTools , this ) ;
}
/// Accessor for Particle Filter Tool
inline IParticleFilter*
particleFilter ( const std::string& name = "" ) const
{
return getTool<IParticleFilter>
( name ,
m_filterNames ,
m_filters , this ) ;
}
public:
......@@ -402,12 +401,6 @@ public:
}
*/
/// Accessor for WriteSelResult Tool
inline IWriteSelResult* writeSelResult()const
{
return getTool<IWriteSelResult>(m_writeSelResultName,
m_writeSelResult);
}
/// Tagging Tool
inline IBTaggingTool* flavourTagging()const{
return getTool<IBTaggingTool>(m_taggingToolName,
......@@ -560,9 +553,6 @@ private:
/// The base class provides an instance of all type of tools
StatusCode loadTools() ;
/// Method to create SelResult container
StatusCode fillSelResult() ;
/// Reference to desktop tool
mutable IPhysDesktop* m_desktop;
/// Concrete type desktop
......@@ -579,8 +569,6 @@ protected:
/// Mapping of "nickname ->type/name" for Geometry Tools
ToolMap m_geomToolNames ;
/// The actual map of "nickname -> tool" for Geometry Tools
mutable GaudiUtils::VectorMap<std::string,IGeomDispCalculator*> m_geomTools ;
/// Mapping of "nickname ->type/name" for Particle Filters
ToolMap m_filterNames ;
......@@ -602,7 +590,11 @@ protected:
/// The actual map of "nickname -> tool" for Particle Refitters
mutable GaudiUtils::VectorMap<std::string,IPVReFitter*> m_pvReFitters ;
/// Mapping of "nickname ->type/name" for Decay Tree Fitters
ToolMap m_decayTreeFitterNames ;
/// The actual map of "nickname -> tool" for Decay Tree fitters
mutable GaudiUtils::VectorMap<std::string,IDecayTreeFit*> m_decayTreeFitters ;
protected:
/// Mapping of "nickname ->type/name" for mass-constrained fitters
......@@ -642,11 +634,6 @@ protected:
/// Concrete Type of ParticleDescendants tool
std::string m_descendantsName;
/// Concrete type of CheckOverlap tool
std::string m_writeSelResultName;
/// Reference to CheckOverlap
mutable IWriteSelResult* m_writeSelResult;
///
mutable IOnOffline* m_onOffline;
......@@ -687,11 +674,6 @@ public:
private:
/// Decay description (Property)
std::string m_decayDescriptor;
/// Avoid writing SelResult object in TES (Property)
bool m_avoidSelResult;
/// Avoid printing SelResult statistics
/// (cannot be switched off by OutputLevel)
bool m_printSelResult;
/// avoid the writeup of empty containers
bool m_avoidEmptyOutput ;
......@@ -716,6 +698,11 @@ private:
/// Default: true
bool m_writeP2PV;
/// Ignore Particle->PV relations from InputLocations?
/// User-defined ones are kept.
bool m_ignoreP2PVFromInputLocations;
/// Switch PreloadTools to false no to preload any tools.
/// This will have the effect that they will be loaded on demand, when needed,
/// at any event. This option is thus only recommended for use of DVAlgorithm
......
// $Id: DaVinciStringUtils.h,v 1.2 2009-11-10 13:13:19 jpalac Exp $
// $Id: DaVinciStringUtils.h,v 1.3 2010-06-21 12:17:04 jpalac Exp $
#ifndef KERNEL_DAVINCISTRINGUTILS_H
#define KERNEL_DAVINCISTRINGUTILS_H 1
......@@ -74,6 +74,25 @@ namespace DaVinci
*/
void expandLocation( std::string& location,
const std::string& prefix);
/**
* @author Juan Palacios juan.palacios@cern.ch
*
* Remove end of string starting from substring beginning with <b>ending</b>
*
* <b> Examples:</b>
*
* @code
* std::string loc = "Phys/SomeAlgorithm/Particles"
* removeEnding(loc, "/Part")
* @endcode
* transforms "loc" into "Phys/SomeAlgorithm"
*
* @date 2010-06-21
*
*/
void removeEnding(std::string& location, const std::string& ending);
}
}
#endif // KERNEL_DAVINCISTRINGUTILS_H
// $Id: DecayTree.h,v 1.1 2009-08-19 11:54:04 ibelyaev Exp $
// ============================================================================
#ifndef DAVINCIKERNEL_DECAYTREE_H
#define DAVINCIKERNEL_DECAYTREE_H
// ============================================================================
// Include files
// ============================================================================
// STD & STL
// ============================================================================
#include <map>
#include <vector>
#include <memory>
// ============================================================================
// Event
// ============================================================================
#include "Event/Particle.h"
// ============================================================================
namespace LHCb
{
// ==========================================================================
/** @class DecayTree Kernel/DecayTree.h
* Simple representation of the decay tree
* Unline the standard particles, the ownership is kept by the mother particle
*
* @attention this class have "destructive copy" semantics!
*
* @see LHCb::Particle
* @author Wouter Hulsbergen
*/
class DecayTree
{
// ========================================================================
public:
// ========================================================================
/// the helper map to keep the links ebtween original and cloned tree
typedef std::map< const LHCb::Particle*, LHCb::Particle*> CloneMap ;
// ========================================================================
public:
// ========================================================================
/** constructor from the decay head
* @attention the decay tree is cloned!
* @param head the decay tree to be cloned
*/
DecayTree ( const LHCb::Particle& head ) ;
/** copy constructor
* @attention "destructive copy" semantics:
* head&clonemap for "right" are cleared!
* @param right object to be copied (invalid after copy)
*/
DecayTree ( const DecayTree& right ) ;
/** destructor
* @attention the cloned decay tree is deleted!
*/
virtual ~DecayTree () ;
// ========================================================================
public:
// ========================================================================
/// return the const head
inline const LHCb::Particle* head () const { return m_head.get () ; }
/// return the non-const head
inline LHCb::Particle* head () { return m_head.get () ; }
// ========================================================================
public:
// ========================================================================
/// automatic dereference to a const particle
inline const LHCb::Particle* operator->() const { return head () ; }
/// automatic dereference to a non-const particle
inline LHCb::Particle* operator->() { return head () ; }
// ========================================================================
public:
// ========================================================================
/// automatic type conversion to a const particle
operator const LHCb::Particle* () const { return head () ; }
/// automatic type conversion to a non-const particle
operator LHCb::Particle* () { return head () ; }
// ========================================================================
public:
// ========================================================================
/// valid decay tree ?
bool valid () const { return 0 != head () ; }
/// check the validity of the decay tree
bool operator!() const { return ! valid () ; }
// ========================================================================
public:
// ========================================================================
/// take ownership of all particles in decay tree
LHCb::Particle* release ()
{
m_clonemap.clear() ; // clear the links
return m_head.release() ; // invalidate the head
}
// ========================================================================
public:
// ========================================================================
/// find clone of particle in original decay tree
const LHCb::Particle* findClone ( const LHCb::Particle& particle ) const ;
/// find particle based on PID
const LHCb::Particle* find ( const LHCb::ParticleID& pid ) const ;
// ========================================================================
public:
// ========================================================================
/// find a particle in a decay tree based on PID
static const LHCb::Particle* findFirstInTree
(const LHCb::Particle& particle ,
const LHCb::ParticleID& pid ) ;
/// find a particle in a decay tree based on PID
static void findInTree
( const LHCb::Particle& particle ,
const LHCb::ParticleID& pid ,
LHCb::Particle::ConstVector& result ) ;
/// get access to the map for finding the clone of a particle
const CloneMap& cloneMap() const { return m_clonemap ; }
// ========================================================================
private:
// ========================================================================
/** the actual cloning of the decay tree
* @param original the original particle
* @param cloneMap the helper map to keep the links netween original and clone
* @return the cloned tree
*/
static LHCb::Particle* cloneTree
( const LHCb::Particle& original , CloneMap& clonemap ) ;
/// delete the tree
static void deleteTree ( LHCb::Particle& particle ) ;
// ========================================================================
private:
// ========================================================================
/// the head of decay tree
mutable std::auto_ptr<LHCb::Particle> m_head ; // the head of decay tree
/// links from the original tree to the cloned tree
mutable CloneMap m_clonemap ; // links from the original tree
// ========================================================================
} ;
// ==========================================================================
} // end of namespace LHCb
// ============================================================================
// The END
// ============================================================================
#endif // DAVINCIKERNEL_DECAYTREE_H
// ============================================================================
// $Id: ParticleFilters.h,v 1.2 2010-05-15 14:46:17 ibelyaev Exp $
// $Id: ParticleFilters.h,v 1.4 2010-06-04 12:35:23 ibelyaev Exp $
// ============================================================================
#ifndef KERNEL_PARTICLEFILTERS_H
#define KERNEL_PARTICLEFILTERS_H 1
// ============================================================================
// Include files
// ============================================================================
// GaudiKernel
// ============================================================================
#include "GaudiKernel/Kernel.h"
// ============================================================================
// PhysEvent
// ============================================================================
#include "Event/Particle.h"
......@@ -26,35 +30,50 @@ namespace DaVinci
*
* ...
*
* LHCb::Particle::Range input = ... ;
* LHCb::Particle::ConstVector negative ;
* const LHCb::Particle::Range input = ... ;
*
* using namespace LoKi::Cuts ;
* DaVinci::filter ( input , Q < 0 , negative ) ;
*
* // filter negative
* LHCb::Particle::ConstVector negative ;
* DaVinci::filter ( input , Q < 0 , negative ) ;
*
* // filter pions
* LHCb::Particle::ConstVector pions ;
* DaVinci::filter ( input , "pi+" == ID , pions ) ;
*
* @endcode
*
* Also many boost::lambda idioms can be used:
* Also many <code>boost::lambda</code> idioms can be used:
*
* @code
*
* #include "boost/lambda.hpp"
* #include <boost/lambda/lambda.hpp>
* #include <boost/lambda/bind.hpp>
*
* ...
*
* LHCb::Particle::Range input = ... ;
* LHCb::Particle::ConstVector negative ;
*
* const LHCb::Particle::Range input = ... ;
*
* using namespace boost::lambda ;
* DaVinci::filter ( input , bind(&LHCb::Particle::charge,_1) < 0 , negative ) ;
*
* @endcode
*
* // filter negative
* LHCb::Particle::ConstVector negative ;
* DaVinci::filter ( input ,
* bind(&LHCb::Particle::charge,_1) < 0 , negative ) ;
*
* // filter J/psi
* LHCb::Particle::ConstVector jpsis ;
* const LHCb::ParticleID s_pid ( 443 ) ;
* DaVinci::filter ( input ,
* bind(&LHCb::Particle::particleID,_1) == s_pid , psis ) ;
*
* @endcode
*
* @param input (INPUT) the container of input particles
* @param criterion (INPUT) the selection criteria
* @param output (OUPUT) the container of selected particles
* @reutrn number of added particles
* @return number of added particles
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2010-05-14
*/
......@@ -87,35 +106,51 @@ namespace DaVinci
*
* ...
*
* LHCb::Particle::ConstVector input = ... ;
* LHCb::Particle::ConstVector negative ;
* const LHCb::Particle::ConstVector input = ... ;
*
* using namespace LoKi::Cuts ;
* DaVinci::filter ( input , Q < 0 , negative ) ;
*
* // filter negative
* LHCb::Particle::ConstVector negative ;
* DaVinci::filter ( input , Q < 0 , negative ) ;
*
* // filter pions
* LHCb::Particle::ConstVector pions ;
* DaVinci::filter ( input , "pi+" == ID , pions ) ;
*
* @endcode
*
* Also many boost::lambda idioms can be used:
* Also many <code>boost::lambda</code> idioms can be used:
*
* @code
*
* #include "boost/lambda.hpp"
* #include <boost/lambda/lambda.hpp>
* #include <boost/lambda/bind.hpp>
*
* ...
*
* LHCb::Particle::ConstVector input = ... ;
* LHCb::Particle::ConstVector negative ;
*
* const LHCb::Particle::ConstVector input = ... ;
*
* using namespace boost::lambda ;
* DaVinci::filter ( input , bind(&LHCb::Particle::charge,_1) < 0 , negative ) ;
*
*
* // filter negative
* LHCb::Particle::ConstVector negative ;
* DaVinci::filter ( input ,
* bind(&LHCb::Particle::charge,_1) < 0 , negative ) ;
*
* // filter J/psi
* LHCb::Particle::ConstVector jpsis ;
* const LHCb::ParticleID s_pid ( 443 ) ;
* DaVinci::filter ( input ,
* bind(&LHCb::Particle::particleID,_1) == s_pid , psis ) ;
*
* @endcode
*
* *
*
* @param input (INPUT) the container of input particles
* @param criterion (INPUT) the selection criteria
* @param output (OUPUT) the container of selected particles
* @reutrn number of added particles
* @return number of added particles
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2010-05-14
*/
......@@ -129,6 +164,167 @@ namespace DaVinci
( LHCb::Particle::Range ( input ) , criterion , output ) ;
}
// ==========================================================================
/** split the particles into two containers according some criteria
*
* As criteria one can use e.g. any LoKi-functor:
*
* @code
*
* #include "LoKi/ParticleCuts.h"
*
* ...
*
* const LHCb::Particle::Range input = ... ;
*
* using namespace LoKi::Cuts ;
*
* // split into negative & positive
* LHCb::Particle::ConstVector negative ;
* LHCb::Particle::ConstVector positive ;
* DaVinci::filter ( input , Q < 0 , negative , positive ) ;
*
* // split into positive pions & others
* LHCb::Particle::ConstVector pions ;
* LHCb::Particle::ConstVector other ;
* DaVinci::filter ( input , "pi+" == ID , pions , other ) ;
*
* @endcode
*
* Also many <code>boost::lambda</code> idioms can be used:
*
* @code
*
* #include <boost/lambda/lambda.hpp>
* #include <boost/lambda/bind.hpp>
*
* ...
*
* const LHCb::Particle::Range input = ... ;
*
* using namespace boost::lambda ;
*
* // split into negative & positive
* LHCb::Particle::ConstVector negative ;
* LHCb::Particle::ConstVector positive ;
* DaVinci::filter ( input ,
* bind(&LHCb::Particle::charge,_1) < 0 ,
* negative , positive ) ;
*
* // split into J/psi and others
* const LHCb::ParticleID s_pid ( 443 ) ;
* LHCb::Particle::ConstVector jpsis ;
* LHCb::Particle::ConstVector other ;
* DaVinci::filter ( input ,
* bind(&LHCb::Particle::particleID,_1) == s_pid ,
* psis , other ) ;
*
* @endcode
*
* @param input (INPUT) the container of input particles
* @param criterion (INPUT) the selection criteria
* @param output (OUPUT) the container of selected particles
* @param output2 (OUPUT) the container of non-selected particles
* @return number of added particles
* @author Vanya BELYAEV Ivan.BElyaev@nikhef.nl
* @date 2010-05-14
*/
template <class PREDICATE>
std::size_t filter
( const LHCb::Particle::Range& input ,
const PREDICATE& criterion ,
LHCb::Particle::ConstVector& output ,
LHCb::Particle::ConstVector& output2 )
{
std::size_t added = 0 ;
for ( LHCb::Particle::ConstVector::const_iterator ip = input.begin() ;
input.end () != ip ; ++ip )
{
if ( criterion (*ip) )
{
output.push_back ( *ip ) ;
++added ;
}
else { output2.push_back ( *ip ) ; }
}
return added ;
}
// ==========================================================================
/** split the particles into two containers according some criteria
*
* As criteria one can use e.g. any LoKi-functor:
*
* @code
*