Skip to content
Snippets Groups Projects
Commit a5683306 authored by Sebastien Ponce's avatar Sebastien Ponce Committed by Patrick Koppenburg
Browse files

Merge branch 'pkoppenb-PrintDecay' into 'master'

Modernise PrintDecay

See merge request lhcb/Phys!865

Moved from Phys@cc8c74f0d359561cd5feee7e82e3302ce23fe4b9
parents c7a70974 def75457
No related branches found
No related tags found
No related merge requests found
......@@ -10,62 +10,50 @@
\*****************************************************************************/
// ============================================================================
// Include files
// ============================================================================
// DaVinciKernel
// ============================================================================
#include "Kernel/DaVinciAlgorithm.h"
#include "Event/Particle.h"
#include "GaudiAlg/Consumer.h"
#include "Kernel/IPrintDecay.h"
// ============================================================================
/** @class PrintDecayTree
* The simplified version of the algorithm PrintTree,
* which deals only with the reconstructed particles
* @see PrintTree
* @see IPRintDecay
* @author Vanya BELYAEV Ivan.Belayev@nikhef.nl
* @see IPrintDecay
* @author Vanya BELYAEV Ivan.Belayev@cern.ch
* @date 2008-03-30
* Adapted to Gaudi functional
* @author Patrick Koppenburg
* @date 2020-12-17
*/
class PrintDecayTree : public DaVinciAlgorithm {
class PrintDecayTree : public Gaudi::Functional::Consumer<void( const LHCb::Particles& )> {
public:
// ==========================================================================
/// the standard execution of the algorithm
StatusCode execute() override {
// get the tool
if ( !m_printDecay ) { m_printDecay = tool<IPrintDecay>( m_printDecayName, this ); }
// get the particles
const LHCb::Particle::ConstVector& parts = this->i_particles();
//
m_printDecay->printTree( parts.begin(), parts.end(), m_maxDepth );
//
setFilterPassed( m_forceFilterPassedTrue || !parts.empty() );
//
return StatusCode::SUCCESS;
}
// ==========================================================================
/** the standard constructor
* @param name algorithm instance name
* @param pSvc service locator
*/
PrintDecayTree( const std::string& name, ISvcLocator* pSvc )
: DaVinciAlgorithm( name, pSvc )
, m_printDecayName( "PrintDecayTreeTool/PrintDecay" )
, m_printDecay( NULL )
, m_maxDepth( 6 ) {
declareProperty( "PrintDecayTool", m_printDecayName, "The type/name of the IPrintDecay tool" );
declareProperty( "MaxDepth", m_maxDepth, "The maximal depth (number of levels)" );
declareProperty( "ForceFilterPassed", m_forceFilterPassedTrue = false,
"Flag to turn on the forcing of filter passed to true always" );
PrintDecayTree( const std::string& name, ISvcLocator* pSvc ) : Consumer( name, pSvc, {KeyValue{"Input", ""}} ) {}
// ==========================================================================
/// the standard execution of the algorithm
void operator()( const LHCb::Particles& parts ) const override {
// get the tool
m_printDecay->printTree( parts.begin(), parts.end(), -1 );
if ( !parts.empty() ) {
m_eventCount++;
m_candidateCount += parts.size();
}
return;
}
private:
// ==========================================================================
/// the type/name of the IPrintDecay tool
std::string m_printDecayName; // the type/name of the IPrintDecay tool
/// the IPrintDecay tool itself
IPrintDecay* m_printDecay; // the IPrintDecay tool itself
/// the maximal printout depth
int m_maxDepth; // the maximal printout depth
/// Force filter passed to true ?
bool m_forceFilterPassedTrue;
ToolHandle<IPrintDecay> m_printDecay = {this, "PrintDecayTreeTool", "PrintDecayTreeTool"};
// counters
mutable Gaudi::Accumulators::Counter<> m_eventCount{this, "Events"};
mutable Gaudi::Accumulators::Counter<> m_candidateCount{this, "Candidates"};
// ==========================================================================
};
// ============================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment