Commit df6210e6 authored by Eduardo Rodrigues's avatar Eduardo Rodrigues
Browse files

Merge branch 'turbo-mdst-v41r2p3-patches' into 'DV4Strip26'

Support for Turbo MC microDST productions for Stripping26

See merge request !58
parents ba38ebf8 59103931
......@@ -37,3 +37,6 @@
[lb-checkout "LHCb.GaudiConf"]
base = 6f88dc5a9b461c38a49a258e1eb975555c7dd0ae
imported = 26b40caca408e53f5959c238cd35d37f88411761
[lb-checkout "Analysis.Phys/DaVinciMCTools"]
base = 9d32dc996bb806c082f41d09f00d003908735c40
imported = 501800938971bb57ca1cd42020d5912b45bce927
#ifndef COPYPROTOPARTICLE2MCRELATIONS_H
#define COPYPROTOPARTICLE2MCRELATIONS_H 1
// Include files
// from MicroDST
#include "MicroDST/RelationsFromParticleLocationsClonerAlg.h"
#include <MicroDST/ICloneMCParticle.h>
#include "MicroDST/BindType2ClonerDef.h"
// from DaVinci
#include "Kernel/Particle2MCParticle.h"
/** @class CopyProtoParticle2MCRelations CopyProtoParticle2MCRelations.h
*
* Near-duplicate of the CopyParticle2MCRelations microDST algorithm that
* copies weighted LHCb::ProtoParticle to LHCb:MCParticle relations, rather
* than weighted LHCb::Particle to LHCb:MCParticle relations.
*
* Another difference is that this algorithm is a specialisation of the
* MicroDST::RelationsClonerAlg template class, rather than the
* MicroDST::RelationsFromParticleLocationsClonerAlg class that
* CopyParticle2MCRelations specialises. With this difference, this class
* takes TES locations of relations tables as input, rather than taking
* particle locations and trying to deduce the relations table location from
* that. It will then take the locations of the associated LHCb::Particle
* objects by interrogating the relations table itself.
*/
typedef LHCb::RelationWeighted1D<LHCb::ProtoParticle, LHCb::MCParticle, double> PP2MCPTable;
//=============================================================================
template <> struct BindType2Cloner<PP2MCPTable>
{
typedef LHCb::MCParticle ToType;
typedef ICloneMCParticle ToCloner;
};
//=============================================================================
template<> struct Defaults<PP2MCPTable>
{
const static std::string clonerType;
const static std::string relationsName;
};
const std::string Defaults<PP2MCPTable>::clonerType = "MCParticleCloner";
//=============================================================================
template<> struct Location<PP2MCPTable>
{
const static std::string Default;
};
const std::string Location<PP2MCPTable>::Default = "NO DEFAULT LOCATION";
//=============================================================================
typedef MicroDST::RelationsClonerAlg<PP2MCPTable> CopyProtoParticle2MCRelations;
DECLARE_NAMED_ALGORITHM_FACTORY(CopyProtoParticle2MCRelations, CopyProtoParticle2MCRelations)
#endif // COPYPROTOPARTICLE2MCRELATIONS_H
......@@ -50,10 +50,12 @@ namespace MicroDST
: MicroDSTAlgorithm ( name , pSvcLocator ),
m_cloner ( NULL ),
m_clonerType ( DEFAULTS::clonerType ),
m_useOriginalFrom ( false ),
m_tableCloner( boost::bind(&RelationsClonerAlg<TABLE>::cloneFrom, &(*this), _1),
boost::bind(&RelationsClonerAlg<TABLE>::cloneTo, &(*this), _1) )
{
declareProperty( "ClonerType", m_clonerType );
declareProperty( "UseOriginalFrom", m_useOriginalFrom, "Take 'from' object from original location");
//setProperty( "OutputLevel", 1 );
}
......@@ -186,6 +188,10 @@ namespace MicroDST
inline typename TABLE::From cloneFrom(const typename TABLE::From from)
{
if ( m_useOriginalFrom )
{
return from;
}
if ( ! from )
{
error() << "FROM is NULL !!!!" << endmsg;
......@@ -219,6 +225,7 @@ namespace MicroDST
CLONER* m_cloner;
std::string m_clonerType;
bool m_useOriginalFrom;
TableCloner m_tableCloner;
};
......
################################################################################
# Package: DaVinciMCTools
################################################################################
gaudi_subdir(DaVinciMCTools v10r14)
gaudi_depends_on_subdirs(Calo/CaloInterfaces
Calo/CaloUtils
Event/GenEvent
Event/LinkerEvent
Event/MCEvent
Event/PhysEvent
Event/RecEvent
Kernel/MCInterfaces
Phys/DaVinciKernel
Phys/DaVinciMCKernel
Phys/LoKiPhysMC)
gaudi_add_module(DaVinciMCTools
src/*.cpp
INCLUDE_DIRS Kernel/MCInterfaces
LINK_LIBRARIES CaloInterfaces CaloUtils GenEvent LinkerEvent MCEvent PhysEvent RecEvent DaVinciKernelLib DaVinciMCKernelLib LoKiPhysMCLib)
# $Id: requirements,v 1.94 2010-08-02 16:48:32 jpalac Exp $
# =============================================================================
# Created : 19/05/2002
# Maintainer : DaVinci coordinator
# =============================================================================
#
# Documentation on the requirement file can be found at
# http://cern.ch/lhcb-comp/Support/html/new_structure.pdf
# =============================================================================
package DaVinciMCTools
version v10r14
# This template is an example for a standard Algorithm package
#
# Structure, i.e. directories to process.
#============================================================================
branches cmt doc src
include_path none
# Used packages.
#============================================================================
use PhysEvent v* Event
use GenEvent v* Event
use DaVinciKernel v* Phys
use DaVinciMCKernel v* Phys
use LoKiPhysMC v* Phys
use MCEvent v* Event
use LinkerEvent v* Event
use RecEvent v* Event
use CaloUtils v* Calo
use CaloInterfaces v* Calo
use MCInterfaces v* Kernel
# Extra language for translating yacc to c++
# This is used to generate once the necessary files on Linux that are
# then committed (tool not available on win)
#============================================================================
#macro yaccppflags " -l -d "
#macro yaccpp "yacc $(yaccppflags)
#make_fragment yacc_to_icpp -suffix=icpp -header=yacc_to_icpp_header
#document yacc_to_icpp MCParser mcparser.ypp
#macro mcparser_ypp_yaccpp_prefix "MCDecayFinder::"
#macro lexppflags " -L "
#macro lexpp "lex ${lexppflags}
#make_fragment lex_to_icpp -suffix=icpp -header=lex_to_icpp_header
#document lex_to_icpp MCLexer mclexer.lpp
#macro mclexer_lpp_lexpp_prefix "MCDecayFinder::"
# Component library building rule
#============================================================================
library DaVinciMCTools ../src/*.cpp
# define component library link options
#============================================================================
apply_pattern component_library library=DaVinciMCTools
# =============================================================================
# The END
# =============================================================================
This diff is collapsed.
LPP = $(${NAME}_lpp_lexpp_prefix)
$(src)${NAME}.${SUFFIX} : $(${NAME}_${FILESUFFIX}_dependencies)
$(echo) $@
cd $(src); \
$(lexpp) -t ${FILENAME} | \
sed -e 's/yylex/${LPP}ylex/g' \
-e 's/YYCLASS/${LYP}/g' \
-e 's=#include <unistd.h>=//#include <unistd.h>=g' \
-e 's=extern=//=g' \
-e 's/FILE \*yyin/static FILE \*yyin/g' \
-e 's/void yyrestart/static void yyrestart/g' \
-e 's/void yy_switch_to_buffer/static void yy_switch_to_buffer/g' \
-e 's/void yy_load_buffer_state/static void yy_load_buffer_state/g' \
-e 's/YY_BUFFER_STATE yy_create_buffer/static YY_BUFFER_STATE yy_create_buffer/g' \
-e 's/void yy_delete_buffer/static void yy_delete_buffer/g' \
-e 's/void yy_init_buffer/static void yy_init_buffer/g' \
-e 's/void yy_flush_buffer/static void yy_flush_buffer/g' \
-e 's/YY_BUFFER_STATE yy_scan_buffer/static YY_BUFFER_STATE yy_scan_buffer/g' \
-e 's/YY_BUFFER_STATE yy_scan_string/static YY_BUFFER_STATE yy_scan_string/g' \
-e 's/YY_BUFFER_STATE yy_scan_bytes/static YY_BUFFER_STATE yy_scan_bytes/g' \
-e 's/char \*yytext/static char \*yytext/g' \
-e 's/int yyleng/static int yyleng/g' \
-e 's/yylval/${LPP}ylval/g'> ${NAME}.$(SUFFIX)
${CONSTITUENT}clean ::
cd $(src); /bin/rm -f $(NAME).$(SUFFIX)
${CONSTITUENT}_output = $(src)
${CONSTITUENT} :: ${OBJS}
LYP = $(${NAME}_ypp_yaccpp_prefix)
$(src)${NAME}.${SUFFIX} : $(${NAME}_ypp_dependencies)
$(echo) $@
cd $(src); \
$(yaccpp) -p'${LYP}y' ${FILENAME}; \
sed -e 's/typedef union ./#if 0/g' \
-e 's/. YYSTYPE;/#endif/g' \
-e 's/#define YYSTYPE yystype/#define YYSTYPE ${LYP}YYSTYPE/g' \
-e 's/YYCLASS/${LYP}/g' \
-e 's/extern char \*getenv();//g' \
-e 's/^static int yygrowstack();//g' \
-e 's/static int yygrowstack/int ${LYP}yygrowstack/g' \
y.tab.c >${NAME}.$(SUFFIX); \
sed -e 's/typedef union/union YYSTYPE/g' \
-e 's/YYSTYPE;/;/g' \
-e 's/YYCLASS/${LYP}/g' \
-e 's/extern YYSTYPE .*//g' y.tab.h >${NAME}.h; /bin/rm -f y.tab.[ch]
$(CONSTITUENT)clean ::
cd $(src); /bin/rm -f $(NAME).$(SUFFIX) $(NAME).h
${CONSTITUENT}_output = $(src)
${CONSTITUENT} :: ${OBJS}
This diff is collapsed.
// $Id: BackgroundCategory.h,v 1.29 2009-11-27 07:42:26 odescham Exp $
#ifndef BACKGROUNDCATEGORY_H
#define BACKGROUNDCATEGORY_H 1
// Include files
// from Gaudi
#include "GaudiAlg/GaudiTool.h"
#include "Event/Particle.h"
#include "Kernel/IBackgroundCategory.h" // Interface
#include "Kernel/IParticleDescendants.h"
#include "Kernel/IParticle2MCWeightedAssociator.h"
#include "Kernel/IParticlePropertySvc.h"
#include "Kernel/ParticleProperty.h"
#include "CaloInterfaces/ICalo2MCTool.h"
#include "Kernel/IPrintDecay.h"
#include "Kernel/MCAssociation.h"
/** @class BackgroundCategory BackgroundCategory.h
*
* For further documentation, please see the file IBackgroundCategory.h
* Available properties:
*
* UseSoftPhotonCut - whether to ignore "soft" photons
*
* SoftPhotonCut - the maximum energy of a "soft" photon, if using the cut. (default to 300MeV or less)
*
* LowMassBackgroundCut - the mass cut used to classify background as Low Mass. For
* an explanation of usage, see IBackgroundCategory.h. It
* defaults to 100MeV.
*
* MCmatchQualityPIDoverrideLevel - At present the tool will occasionally find that
* one ProtoParticle has more than one MCParticle
* associated to it. The MCParticle with the "correct"
* PID is chosen unless its weight is lower than the
* cut. The default is 0.5, since the "weight" is the
* probability of the particle with the "correct" PID to
* be the "correct" associated MCParticle, given that at least one
* MCParticle exists which is associated to the ProtoParticle.
*
* InclusiveDecay - is this an inclusive decay? If you want to reconstruct an exclusive
* semi-leptonic decay chain, set this to 0 and the SemileptonicDecay property to 1.
*
* SemileptonicDecay - is this a smei-leptonic decay? If so, all neutrinos will be ignored when deciding if
* the decay is correctly reconstructed or not.
*
* NumNeutrinos - The number of neutrinos expected in our decay chain.
*
* ResonanceCut - The maximum lifetime at which a particle is considered a short lived resonance.
* Defaults to 10^-6 nanoseconds.
*
* @author Vladimir Gligorov
* @date 2005-11-23
*/
class BackgroundCategory : public GaudiTool,
virtual public IBackgroundCategory
{
private:
typedef std::vector<const LHCb::MCParticle*> MCParticleVector;
typedef std::vector<const LHCb::Particle*> ParticleVector;
typedef std::pair<const LHCb::Particle*, const LHCb::MCParticle*> DaughterAndPartnerPair;
typedef std::vector<DaughterAndPartnerPair> DaughterAndPartnerVector;
public:
/// Standard constructor
BackgroundCategory( const std::string& type,
const std::string& name,
const IInterface* parent );
StatusCode initialize();
virtual ~BackgroundCategory( ); ///< Destructor
public:
IBackgroundCategory::categories category( const LHCb::Particle * reconstructed_mother,
const LHCb::Particle * headP = NULL );
const LHCb::MCParticle* origin( const LHCb::Particle* );
const DaughterAndPartnerVector getDaughtersAndPartners( const LHCb::Particle* );
private:
MCParticleVector associate_particles_in_decay(const ParticleVector &, const LHCb::Particle*);
MCParticleVector get_mc_mothers(const MCParticleVector&);
MCParticleVector create_finalstatedaughterarray_for_mcmother(const LHCb::MCParticle*);
const LHCb::MCParticle* get_top_mother_of_MCParticle(const LHCb::MCParticle*);
const LHCb::MCParticle* get_lowest_common_mother(const MCParticleVector&,const ParticleVector&);
const LHCb::MCParticle* get_lowest_common_mother(const MCParticleVector&);
int topologycheck(const LHCb::MCParticle*);
int topologycheck(const LHCb::Particle*);
bool isStable(int);
bool hierarchyProblem(const MCParticleVector&);
bool foundClones(const MCParticleVector&);
bool doAllFinalStateParticlesHaveACommonMother(const MCParticleVector&, const MCParticleVector&, const ParticleVector&);
bool isTheDecayFullyReconstructed(const MCParticleVector&);
bool areAllFinalStateParticlesCorrectlyIdentified(const ParticleVector&, const MCParticleVector&);
bool isTheMotherCorrectlyIdentified(const LHCb::Particle*);
bool wereAnyResonancesMissed(const LHCb::Particle*);
bool checkLowMassBackground(const LHCb::Particle*);
bool areAnyFinalStateParticlesGhosts(const MCParticleVector&,const ParticleVector&);
bool isThisAPileup(const MCParticleVector&,const ParticleVector&);
bool isThisBBarBackground(const MCParticleVector&);
bool isThisCCbarBackground(const MCParticleVector&);
int areAnyFinalStateParticlesFromAPrimaryVertex(const MCParticleVector&);
private:
LHCb::IParticlePropertySvc* m_ppSvc;
IParticleDescendants* m_particleDescendants;
IParticle2MCWeightedAssociator* m_smartAssociator;
IPrintDecay* m_printDecay ;
ICalo2MCTool* m_calo2MC;
const LHCb::MCParticle* m_commonMother;
DaughterAndPartnerVector m_daughtersAndPartners;
bool m_ignoreQuarks; //ignore quarks in the decay tree?
bool m_inclusiveDecay; //are we studying an inclusive decay?
bool m_semileptonicDecay; //are we studying a semileptnoic decay?
int m_numNeutrinos; //How many neutrinos expected in our decay chain?
bool m_useSoftPhotonCut ; //whether to use the ignore soft photons cut
double m_softPhotonCut ; //ignore soft photons cut
double m_lowMassCut ; /// cut applied to low-mass background
double m_override; //see .cpp file for explanation
double m_caloWeight;
bool m_vetoN;
double m_minWeight; //dummy sorting variable
double m_rescut; //A cut on the minimum lifetime for a mother not to be
//considered a short-lived resonance
};
#endif // BACKGROUNDCATEGORY_H
// from Gaudi
#include "GaudiKernel/DeclareFactoryEntries.h"
// local
#include "BackgroundCategoryViaRelations.h"
//-----------------------------------------------------------------------------
// Implementation file for class : BackgroundCategoryViaRelations
//
// 2009-11-27 : Vladimir Gligorov
//-----------------------------------------------------------------------------
//=============================================================================
// Standard constructor, initializes variables
//=============================================================================
BackgroundCategoryViaRelations::
BackgroundCategoryViaRelations( const std::string& type,
const std::string& name,
const IInterface* parent )
: GaudiTool ( type, name , parent )
{
IBackgroundCategory::m_cat[-1] = "Undefined";
IBackgroundCategory::m_cat[0] = "Signal";
IBackgroundCategory::m_cat[10] = "QuasiSignal";
IBackgroundCategory::m_cat[20] = "FullyRecoPhysBkg";
IBackgroundCategory::m_cat[30] = "Reflection";
IBackgroundCategory::m_cat[40] = "PartRecoPhysBkg";
IBackgroundCategory::m_cat[50] = "LowMassBkg";
IBackgroundCategory::m_cat[60] = "Ghost";
IBackgroundCategory::m_cat[63] = "Clone";
IBackgroundCategory::m_cat[66] = "Hierarchy";
IBackgroundCategory::m_cat[70] = "FromPV";
IBackgroundCategory::m_cat[80] = "AllFromSamePV";
IBackgroundCategory::m_cat[100] = "FromDifferentPV";
IBackgroundCategory::m_cat[110] = "bbar";
IBackgroundCategory::m_cat[120] = "ccbar";
IBackgroundCategory::m_cat[130] = "uds";
IBackgroundCategory::m_cat[1000] = "LastGlobal";
declareInterface<IBackgroundCategory>(this);
declareProperty( "inputTable", m_P2BCLocation );
//setProperty( "OutputLevel", 1 );
}
//=============================================================================
// Destructor
//=============================================================================
BackgroundCategoryViaRelations::~BackgroundCategoryViaRelations() {}
//=============================================================================
IBackgroundCategory::categories
BackgroundCategoryViaRelations::category( const LHCb::Particle* reconstructed_mother,
const LHCb::Particle* headP )
{
// locations in JOs
std::vector<std::string> locs = m_P2BCLocation;
// add particle dependent locations
if ( reconstructed_mother )
{
locs.push_back( b2cLocation(reconstructed_mother->parent()) );
}
if ( headP && headP != reconstructed_mother )
{
locs.push_back( b2cLocation(headP->parent()) );
}
//std::sort( locs.begin(), locs.end() );
//locs.erase( std::unique(locs.begin(),locs.end()), locs.end() );
// Loop over the relations locations and try and find a match
for ( std::vector<std::string>::const_iterator item = locs.begin();
item != locs.end(); ++item )
{
// Try and load the table
const std::string & address = *item;
if ( msgLevel(MSG::VERBOSE) )
verbose() << "Trying to find table '" << address << "'" << endmsg;
const TableP2BC * table = getIfExists<TableP2BC>(address,false);
if ( !table ) { table = getIfExists<TableP2BC>(address); }
if ( table )
{
if ( msgLevel(MSG::VERBOSE) )
verbose() << " -> Found table ... " << endmsg;
// Try and use it ...
const TableP2BC::Range range = table->relations(reconstructed_mother);
// For the moment we only allow one category per particle so if more than one category is
// related return undefined, else just return the category we find
if ( range.empty() || range.size() > 1 )
{
continue; // to next table
}
else
{
// Found so return
const IBackgroundCategory::categories cat =
(IBackgroundCategory::categories)range.begin() -> to();
if ( msgLevel(MSG::VERBOSE) )
verbose() << " -> Found match ... " << cat << endmsg;
return cat;
}
}
}
// If we have not found anything else to return yet we return undefined,
return Undefined;
}
//=============================================================================
// Declaration of the Tool Factory
DECLARE_TOOL_FACTORY( BackgroundCategoryViaRelations )
//=============================================================================
#ifndef BACKGROUNDCATEGORYVIARELATIONS_H
#define BACKGROUNDCATEGORYVIARELATIONS_H 1
// Include files
// from Gaudi
#include "GaudiAlg/GaudiTool.h"
#include "Kernel/IBackgroundCategory.h" // Interface
#include "Relations/Relations.h"
#include "Event/Particle.h"
// boost
#include "boost/algorithm/string.hpp"
/** @class BackgroundCategoryViaRelations BackgroundCategoryViaRelations.h
*
* A tool to read a relations table of Particle->BackgroundCategory and
* return the results. Only implements the category method for now.
*
* inputTable : give the TES location of the relations table. This should be
* a relations table Particle*->int, created by the algorithm
* Particle2BackgroundCategoryRelationsAlg.
*
* @author Vladimir Gligorov
* @date 2009-11-27
*/
class BackgroundCategoryViaRelations : public GaudiTool,
virtual public IBackgroundCategory
{
private:
typedef std::pair<const LHCb::Particle*, const LHCb::MCParticle*> DaughterAndPartnerPair;
typedef std::vector<DaughterAndPartnerPair> DaughterAndPartnerVector;
public:
/// Standard constructor
BackgroundCategoryViaRelations( const std::string& type,
const std::string& name,
const IInterface* parent);
public:
IBackgroundCategory::categories category( const LHCb::Particle* reconstructed_mother ,
const LHCb::Particle* headP = NULL );
public:
const LHCb::MCParticle* origin( const LHCb::Particle* )
{
Error ( "The origin method is not applicable to this BackgroundCategory implementation" ).ignore() ;
return 0;
}
const DaughterAndPartnerVector getDaughtersAndPartners( const LHCb::Particle* )
{
Error("The getDaughtersAndPartners method is not applicable to this BackgroundCategory implementation" ).ignore() ;
return DaughterAndPartnerVector(0);
}
virtual ~BackgroundCategoryViaRelations( ); ///< Destructor
private:
/// Get the TES location of an object.
const std::string b2cLocation(const DataObject* pObject) const
{
std::string loc = (!pObject ? "Null DataObject" :
(pObject->registry() ? pObject->registry()->identifier() : "UnRegistered"));
// Form the relations TES location for this Particles location
boost::replace_all( loc, "/Particles", "/P2BCRelations" );
// return
return loc;
}
private:
typedef LHCb::Relation1D<LHCb::Particle,int> TableP2BC;
std::vector<std::string> m_P2BCLocation;
};
#endif // BACKGROUNDCATEGORYVIARELATIONS_H