Commit 010ceeff authored by Eduardo Rodrigues's avatar Eduardo Rodrigues
Browse files

added Event/MCEvent from LHCb (LHCb/v41r0)

parent d01b9728
......@@ -19,3 +19,6 @@
[lb-checkout "Phys.Phys/DaVinciTransporter"]
base = 589d5c26edb550bbc52183cc319709042e90434a
imported = a7c275f30404f33968419a46de8912cca9490444
[lb-checkout "LHCb.Event/MCEvent"]
base = d01b97284391813b093754763a71126fe929e0d2
imported = 26b40caca408e53f5959c238cd35d37f88411761
################################################################################
# Package: MCEvent
################################################################################
gaudi_subdir(MCEvent v3r4)
gaudi_depends_on_subdirs(Event/EventBase
GaudiObjDesc
Kernel/LHCbKernel
Kernel/PartProp)
include(GaudiObjDesc)
god_build_headers(xml/*.xml)
gaudi_add_library(MCEvent
src/*.cpp
PUBLIC_HEADERS Event
INCLUDE_DIRS Event/EventBase
LINK_LIBRARIES LHCbKernel PartPropLib)
god_build_dictionary(xml/*.xml
EXTEND dict/lcgDict.h
INCLUDE_DIRS Event/EventBase
LINK_LIBRARIES LHCbKernel PartPropLib MCEvent)
// $Id: MCCaloDataFunctor.h,v 1.1 2007-04-03 11:22:47 ibelyaev Exp $
// ============================================================================
// CVS tag $Name: not supported by cvs2svn $, version $Revision: 1.1 $
// ============================================================================
// $Log: not supported by cvs2svn $
// ============================================================================
#ifndef EVENT_MCCALODATAFUNCTOR_H
#define EVENT_MCCALODATAFUNCTOR_H 1
// ============================================================================
// Include files
// ============================================================================
// STD & STL
// ============================================================================
#include <algorithm>
#include <functional>
// ============================================================================
// (MC)Event
// ============================================================================
#include "Event/MCCaloHit.h"
#include "Event/MCCaloDigit.h"
// ============================================================================
namespace LHCb
{
namespace CaloDataFunctor
{
/** @struct InTime
* The trivial predicate which evaluates for "true" for
* MC-calo hits which are "in-time" with the given BX
*
* @code
*
* // count the number of MCHits in the current BX for the given
* size_t num =
* std::count_if ( hits->begin() , hits->end() , InTime(0) ) ;
*
* @endcode
*
* @see LHCb::MCCaloHit
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-04-03
*/
struct InTime
: public std::unary_function<const LHCb::MCCaloHit*,bool>
{
public:
InTime ( const LHCb::MCCaloHit::Time time = 0 ) : m_time ( time ) {} ;
public:
/// the only one essential method
inline bool operator () ( const LHCb::MCCaloHit* hit ) const
{ return ( 0 == hit ) ? false : m_time == hit->time() ; }
private:
// index of the time slot
LHCb::MCCaloHit::Time m_time ; ///< index of the time slot
} ;
/** @struct SumActiveEnergy
* Simple structure to perform the summation of active energy for
* hits, which satisfy certain criteria
* (e.g. in the certain time window):
*
*
* @code
*
* double energy =
* std::accumulate ( hits->begin() , // begin of the sequence
* hits->end() ) , // end of the sequence
* 0.0 , // initial value
* sumActiveEnergy( InTime(0) ) // functor
* ) ;
*
* @endcode
*
*
* @see LHCb::MCCaloHit
* @see sumActiveEnergy
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-04-03
*/
template <class PREDICATE,class TYPE=LHCb::MCCaloHit>
struct SumActiveEnergy
: public std::binary_function<double,const TYPE*,double>
{
public:
/// contructor from the predicate
SumActiveEnergy ( PREDICATE eval ) : m_eval ( eval ) {}
public:
/// the only one essential method
inline double operator() ( double& energy , const TYPE* hit ) const
{
// use the evaluator
if ( m_eval( hit ) ){ energy += hit->activeE() ; }
return energy ;
} ;
private:
PREDICATE m_eval ;
};
/** helper function for instantiation of the proper functor
* for summing of the active energy
*
* @see LHCb::MCCaloHit
* @see SumActiveEnergy
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-04-03
*/
template <class PREDICATE>
inline SumActiveEnergy<PREDICATE>
sumActiveEnergy ( PREDICATE pred ) { return SumActiveEnergy<PREDICATE>( pred ) ; }
/** simple structure ( placeholder) for the functor,
* whcih extract the active enegy of the objects,
* accumulated for a certain time-bin
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-04-03
*/
template <class TYPE> struct ActiveEnergyInTime ;
/** The full tmeplate specialization of the
* the functor, which extract the active enegy
* LHCb::MCCaloHit object
*
* @code
*
*
* const LHCb::MCCaloHit* hit = ... ;
*
* // create the functor:
* ActiveEnergyInTime<LHCb::MCCaloHit> evaluator( 0 ) ;
*
* // use it!
* const double energy = evaluator( hit ) ;
*
* @endcode
*
* @see LHCb::MCCaloHit::Time
* @see LHCb::MCCaloHit
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-04-03
*/
template <>
struct ActiveEnergyInTime<LHCb::MCCaloHit>
: public std::unary_function<const LHCb::MCCaloHit*,double>
{
public:
/// constructor from the time-bin
ActiveEnergyInTime( const LHCb::MCCaloHit::Time time = 0 ) : m_eval ( time ) {}
public:
/// the only one essential method
inline double operator() ( const LHCb::MCCaloHit* hit ) const
{
if ( 0 != hit && m_eval ( hit ) ){ return hit->activeE() ; }
return 0.0 ;
} ;
private:
// predicate, which select the proper time-bin
InTime m_eval ; ///< predicate, which select the proper time-bin
};
/** The full template specialization of the
* the functor, which extract the active enegy
* LHCb::MCCaloDigit object
*
* @code
*
* const LHCb::MCCaloDigit* digit = ... ;
*
* // create the functor:
* ActiveEnergyInTime<LHCb::MCCaloDigit> evaluator( 0 ) ;
*
* // use it!
* const double energy = evaluator( digit ) ;
*
* @endcode
*
* @see LHCb::MCCaloHit::Time
* @see LHCb::MCCaloHit
* @see LHCb::MCCaloDigit
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-04-03
*/
template <>
struct ActiveEnergyInTime<LHCb::MCCaloDigit>
: public std::unary_function<const LHCb::MCCaloDigit*,double>
{
public:
/// contructor from the time-slot
ActiveEnergyInTime( const LHCb::MCCaloHit::Time time = 0 )
: m_eval ( sumActiveEnergy( InTime( time ) ) ) {}
public:
/// the only one essential method
inline double operator() ( const LHCb::MCCaloDigit* digit ) const
{
if ( 0 == digit ) { return 0 ;}
const SmartRefVector<LHCb::MCCaloHit>& hits = digit->hits();
return std::accumulate ( hits.begin() , hits.end() , 0.0 , m_eval ) ;
} ;
private:
// the actual evaluator
SumActiveEnergy<InTime> m_eval ; ///< the actual evaluator
} ;
/** The full template specialization of the
* the functor, which extract the active energy
* of LHCb::MCCaloHit::Container object
*
* @code
*
* const LHCb::MCCaloHit::Container* hits =
* get<LHCb::MCCaloHit::Container>( LHCb::MCCaloHitLocation::Ecal ) ;
*
* // create the functor:
* ActiveEnergyInTime<LHCb::MCCaloHit::Container> evaluator( 0 ) ;
*
* // use it!
* const double energy = evaluator( hits ) ;
*
* @endcode
*
* @see LHCb::MCCaloHit::Time
* @see LHCb::MCCaloHit
* @see LHCb::MCCaloHit::Container
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-04-03
*/
template <>
struct ActiveEnergyInTime<LHCb::MCCaloHit::Container>
: public std::unary_function<const LHCb::MCCaloHit::Container*,double>
{
public:
/// contructor from the time-slot
ActiveEnergyInTime( const LHCb::MCCaloHit::Time time = 0 )
: m_eval ( sumActiveEnergy( InTime( time ) ) ) {}
public:
/// the only one essential method
inline double operator() ( const LHCb::MCCaloHit::Container* hits ) const
{
if ( 0 == hits ) { return 0 ; }
return std::accumulate ( hits->begin() , hits->end() , 0.0 , m_eval ) ;
} ;
private:
// the actual evaluator
SumActiveEnergy<InTime> m_eval ; ///< the actual evaluator
};
/** The full template specialization of the
* the functor, which extract the active energy
* of LHCb::MCCaloDigit::Container object
*
* @code
*
* const LHCb::MCCaloDigit::Container* digits =
* get<LHCb::MCCaloDigit::Container>( LHCb::MCCaloDigitLocation::Ecal ) ;
*
* // create the functor:
* ActiveEnergyInTime<LHCb::MCCaloDigit::Container> evaluator( 0 ) ;
*
* // use it!
* const double energy = evaluator( digits ) ;
*
* @endcode
*
* @see LHCb::MCCaloHit::Time
* @see LHCb::MCCaloDigit
* @see LHCb::MCCaloDigit::Container
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-04-03
*/
template <>
struct ActiveEnergyInTime<LHCb::MCCaloDigit::Container>
: public std::unary_function<const LHCb::MCCaloDigit::Container*,double>
{
public:
/// contructor from the time-slot
ActiveEnergyInTime( const LHCb::MCCaloHit::Time time = 0 ) : m_eval ( time ) {}
public:
/// the only on eessential method
inline double operator() ( const LHCb::MCCaloDigit::Container* digits ) const
{
if ( 0 == digits ) { return 0 ; }
double energy = 0.0 ;
for ( LHCb::MCCaloDigit::Container::const_iterator idigit = digits->begin() ;
digits->end() != idigit ; ++idigit ) { energy += m_eval ( *idigit ) ; }
return energy ;
} ;
private:
// the actual evaluatoe
ActiveEnergyInTime<LHCb::MCCaloDigit> m_eval ; ///< the actual evaluatoe
} ;
/** the function whcih return the active energy of the
* LHCb::MCCaloHit, LHCb::MCCaloHit::Container,
* LHCb::MCCaloDigit, LHCb::MCCaloDigit::Container objects
* for the given time slot.
*
* @code
*
* const LHCb::MCCaloDigit::Container* digits =
* get<LHCb::MCCaloDigit::Container>( LHCb::MCCaloDigitLocation::Ecal ) ;
*
* const double e1 = activeEnergyInTime ( digits , 0 ) ;
*
* const LHCb::MCCaloHit::Container* hits =
* get<LHCb::MCCaloHit::Container>( LHCb::MCCaloHitLocation::Ecal ) ;
*
* const double e2 = activeEnergyInTime ( hits , 0 ) ;
*
* const LHCb::MCCaloHit* hit = ... ;
*
* const double e3 = activeEnergyInTime ( hit , 0 ) ;
*
* const LHCb::MCCaloDigit* digit = ... ;
*
* const double e4 = activeEnergyInTime ( digit , 0 ) ;
*
* @endcode
*
* @see LHCb::MCCaloHit::Time
* @see LHCb::MCCaloHit
* @see LHCb::MCCaloHit::Container
* @see LHCb::MCCaloDigit
* @see LHCb::MCCaloDigit::Container
* @author Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-04-03
*/
template <class TYPE>
inline double activeEnergyInTime
( const TYPE* object ,
const LHCb::MCCaloHit::Time time )
{
if ( 0 == object ) { return 0.0 ; }
ActiveEnergyInTime<TYPE> evaluator ( time ) ;
return evaluator ( object ) ;
} ;
} // end of namespace CaloDataFuctor
} // end of namespace LHCb
// ============================================================================
// The END
// ============================================================================
#endif // EVENT_MCCALODATAFUNCTOR_H
// ============================================================================
#ifndef MCEVENT_MCFUN_H
#define MCEVENT_MCFUN_H 1
#include "Event/MCVertex.h"
#include "Event/MCParticle.h"
namespace LHCb{
namespace MC{
/** z of the first interaction vertex of a particle
* Silly interactions PhotoElectric, RICHPhotoElectric
Cerenkov and DeltaRay are ignored
* @param particle
* @return z of first interaction
*/
double zInteraction(const LHCb::MCParticle* aParticle);
/**
* Silly interactions PhotoElectric, RICHPhotoElectric
* Cerenkov and DeltaRay return false
* @param type
* @return true if not a silly vertex
*/
bool realInteraction(const LHCb::MCVertex::MCVertexType& type);
}
}
#endif // MCEVENT_MCFUN_H
#ifndef MCEVENT_MCTRACKGEOMCRITERIA_H
#define MCEVENT_MCTRACKGEOMCRITERIA_H 1
// Event
#include "Event/MCTrackInfo.h"
// boost
#include <boost/function.hpp>
// stl
#include <string>
#include <map>
#include <vector>
namespace LHCb
{
class MCParticle;
}
namespace LHCb{
namespace MC{
class MCTrackGeomCriteria {
public:
typedef boost::function<bool(MCTrackInfo&,
const LHCb::MCParticle*)> Criteria;
/** Constructor from vector of Criteria */
MCTrackGeomCriteria(std::vector<Criteria>& criteria);
/** Constructor from vector of strings */
MCTrackGeomCriteria(std::vector<std::string>& criteria);
/** destructor */
~MCTrackGeomCriteria();
/** fufulls Criteria or not */
bool accepted(MCTrackInfo& info, const LHCb::MCParticle* particle) const;
class FunctionMap{
public:
/// map to enum
Criteria toType(std::string& aName) const;
/// map to type
//std::string toString(const Criteria& aType) const;
/// destructer
~FunctionMap() {}
friend class MCTrackGeomCriteria;
private:
/// constructer
FunctionMap();
FunctionMap(const FunctionMap& rhs){
m_mapping = rhs.m_mapping;
}
typedef std::map<std::string, const Criteria> funMap;
mutable funMap m_mapping;
};
FunctionMap& theMap(){
static FunctionMap sMap;
return sMap;
}
private:
std::vector<Criteria> m_criteria;
};
}
}
inline LHCb::MC::MCTrackGeomCriteria::MCTrackGeomCriteria(std::vector<MCTrackGeomCriteria::Criteria>& criteria):
m_criteria(criteria){
// contructor
}
inline LHCb::MC::MCTrackGeomCriteria::~MCTrackGeomCriteria()
{
// destructor
}
inline LHCb::MC::MCTrackGeomCriteria::Criteria
LHCb::MC::MCTrackGeomCriteria::FunctionMap::toType(std::string& aName) const{
// map to enum
funMap::iterator iter = m_mapping.find(aName);
return (iter != m_mapping.end() ? iter->second : Criteria());
}
/*
inline std::string
MCTrackGeomCriteria::FunctionMap::toString(const MCTrackGeomCriteria::Criteria& fun) const{
// map to string
funMap::iterator iter = m_mapping.begin();
while (iter != m_mapping.end() && iter->second != fun ) {
++iter;
} // iter
return (iter != m_mapping.end() ? iter->first : "Unknown");
}
*/
#endif
// $Id: MCTrackInfo.h,v 1.5 2009-06-09 06:07:44 cattanem Exp $
#ifndef MCEVENT_MCTRACKINFO_H
#define MCEVENT_MCTRACKINFO_H 1
#include "Event/MCProperty.h"
// Forward declarations
class IDataProviderSvc;
class IMessageSvc;
namespace LHCb
{
class MCParticle;
}
/** @class MCTrackInfo MCTrackInfo.h Event/MCTrackInfo.h
*
*
* @author Olivier Callot revised by M. Needham
*
* @date 2004-01-08
*/
class MCTrackInfo {
public:
enum flagMasks {
maskVeloR = 0x00000001,
maskVeloPhi = 0x00000002,
maskTT1 = 0x00000004,
maskTT2 = 0x00000008,
maskT1X = 0x00000010,
maskT1S = 0x00000020,
maskT2X = 0x00000040,
maskT2S = 0x00000080,
maskT3X = 0x00000100,
maskT3S = 0x00000200,
maskHasVelo = maskVeloR | maskVeloPhi, // R + Phi
maskHasTT = maskTT1 | maskTT2, // TT1 and TT2
maskHasT1 = maskT1X | maskT1S,
maskHasT2 = maskT2X | maskT2S,
maskHasT3 = maskT3X | maskT3S,
maskHasT = maskHasT1 | maskHasT2 | maskHasT3, // all T stations
maskHasVeloAndT = maskHasVelo | maskHasT,
maskAccVeloR = 0x00000400,
maskAccVeloPhi = 0x00000800,
maskAccTT1 = 0x00001000,
maskAccTT2 = 0x00002000,
maskAccT1X = 0x00004000,
maskAccT1S = 0x00008000,
maskAccT2X = 0x00010000,
maskAccT2S = 0x00020000,
maskAccT3X = 0x00040000,
maskAccT3S = 0x00080000,
maskAccVelo = maskAccVeloR | maskAccVeloPhi, // R and Phi hits
maskAccTT = maskAccTT1 | maskAccTT2, // TT1 and TT2
maskAccT1 = maskAccT1X | maskAccT1S,
maskAccT2 = maskAccT2X | maskAccT2S,
maskAccT3 = maskAccT3X | maskAccT3S,
maskAccT = maskAccT1 | maskAccT2 | maskAccT3, // T stations
maskAccVeloAndT = maskAccVelo | maskAccT,
multVeloR = 20,
multVeloPhi = 25,
maskMultVeloR = 0x01F00000, // Velo R CLuster multiplicity
maskMultVeloPhi= 0x3E000000 // VeloPhi cluster multipliity
};
/// Standard constructor
MCTrackInfo( IDataProviderSvc* eventSvc,
IMessageSvc* msgSvc );
///< Destructor
~MCTrackInfo( ) {};
//== Main accessors: Velo, TT, T and Velo+T for cluster and acceptance
bool hasVelo( const LHCb::MCParticle* part ) const {
return testMask( part, MCTrackInfo::maskHasVelo );
}
bool hasTT( const LHCb::MCParticle* part ) const {
return testMask( part, MCTrackInfo::maskHasTT );
}