Commit e2cdfed7 authored by Gitlab CI's avatar Gitlab CI Committed by Marco Clemencic
Browse files

Apply formatting

parent 9e5ff1a9
......@@ -11,11 +11,11 @@
#ifndef SELECTION_LINE_H
#define SELECTION_LINE_H 1
#include <Kernel/IANNSvc.h>
#include <GaudiKernel/IIncidentListener.h>
#include <Gaudi/Sequence.h>
#include <GaudiAlg/GaudiCommon.h>
#include <GaudiAlg/GaudiHistos.h>
#include <GaudiKernel/IIncidentListener.h>
#include <Kernel/IANNSvc.h>
#include <array>
#include <memory>
......@@ -36,152 +36,148 @@ class IAlgManager;
namespace Selection {
class Line : public extends<GaudiHistos<GaudiCommon<Gaudi::Sequence>>, IIncidentListener>
class Line : public extends<GaudiHistos<GaudiCommon<Gaudi::Sequence>>, IIncidentListener>
{
public:
/// Standard constructor
Line( const std::string& name, ISvcLocator* pSvcLocator );
{
public:
/// Standard constructor
Line( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override; ///< Algorithm initialization
StatusCode execute( const EventContext& ctx ) const override { return const_cast<Line*>( this )->execute( ctx ); }
StatusCode execute( const EventContext& ctx );
void handle( const Incident& ) override;
// id for this line -- return 0 if error
virtual const std::pair<std::string, unsigned int>& id() const = 0;
// retrieve function which provides the numberOfCandidates for subalgo -- or nullptr if not supported
virtual std::unique_ptr<std::function<unsigned()>> numberOfCandidates( const Algorithm* ) const;
// retrieve numberOfCandidates from decision algo
virtual int numberOfCandidates() const = 0;
StatusCode initialize() override; ///< Algorithm initialization
template <class TYPE>
inline typename Gaudi::Utils::GetData<TYPE>::return_type getIfExists( const std::string& location,
const bool useRootInTES = true ) const {
return base_class::getIfExists<TYPE>( evtSvc(), location, useRootInTES );
}
StatusCode execute (const EventContext& ctx) const override {
return const_cast<Line*>(this)->execute(ctx);
class Stage {
public:
Stage( Line& parent, const std::string& name ) : m_parent( parent ), m_property( name, std::string{} ) {
m_property.declareUpdateHandler( &Stage::updateHandler, this );
}
Stage( Stage& rhs ) : m_parent( rhs.m_parent ), m_timerTool( rhs.m_timerTool ), m_property( rhs.m_property ) {
m_property.declareUpdateHandler( &Stage::updateHandler, this );
}
StatusCode execute (const EventContext& ctx);
void handle(const Incident&) override;
// id for this line -- return 0 if error
virtual const std::pair<std::string,unsigned int>& id() const = 0;
// retrieve function which provides the numberOfCandidates for subalgo -- or nullptr if not supported
virtual std::unique_ptr<std::function<unsigned()>> numberOfCandidates(const Algorithm*) const;
// retrieve numberOfCandidates from decision algo
virtual int numberOfCandidates() const = 0;
template <class TYPE>
inline typename Gaudi::Utils::GetData<TYPE>::return_type getIfExists( const std::string& location,
const bool useRootInTES = true ) const
{
return base_class::getIfExists<TYPE>( evtSvc(), location, useRootInTES );
~Stage() {
if ( m_algorithm ) m_algorithm->release();
}; ///< Destructor
bool passed( const EventContext& ctx ) const {
return algorithm() ? algorithm()->execState( ctx ).filterPassed() : true;
}
class Stage {
public:
Stage(Line& parent, const std::string& name)
: m_parent(parent)
, m_property(name, std::string{})
{ m_property.declareUpdateHandler(&Stage::updateHandler,this); }
Stage( Stage& rhs )
: m_parent(rhs.m_parent)
, m_timerTool(rhs.m_timerTool)
, m_property( rhs.m_property )
{ m_property.declareUpdateHandler(&Stage::updateHandler,this); }
~Stage() { if (m_algorithm) m_algorithm->release();}; ///< Destructor
bool passed(const EventContext& ctx) const { return algorithm()?algorithm()->execState(ctx).filterPassed():true; }
StatusCode execute(const EventContext& ctx, ISequencerTimerTool* = 0);
StatusCode initialize(ISequencerTimerTool* = 0);
std::string toString() const { return name(); }
StatusCode fromString(const std::string& name);
const std::string& name() const { return m_property.value(); }
StringProperty& property() { return m_property; }
private:
void setTimer( int nb ) { m_timer = nb; }
Gaudi::Algorithm* algorithm() const { return m_algorithm; }
bool reverse() const { return m_reverse; }
int timer() const { return m_timer; }
void updateHandler(Property& prop);
Line& m_parent;
ISequencerTimerTool* m_timerTool = nullptr; ///< Pointer to the timer tool
Gaudi::Algorithm* m_algorithm = nullptr; ///< Algorithm pointer
StringProperty m_property;
bool m_reverse = false; ///< Indicates that the flag has to be inverted
bool m_dirty = true;
bool m_initialized = false;
int m_timer; ///< Timer number for this algorithm
};
protected:
// utilities for derived classes to use...
const std::string& decisionName() { return m_decision; }
// retrieve (recursive!) list of sub algorithms
std::vector< const Gaudi::Algorithm* > algorithms() const ;
IANNSvc& annSvc() const;
StatusCode execute( const EventContext& ctx, ISequencerTimerTool* = 0 );
StatusCode initialize( ISequencerTimerTool* = 0 );
std::string toString() const { return name(); }
StatusCode fromString( const std::string& name );
const std::string& name() const { return m_property.value(); }
StringProperty& property() { return m_property; }
private:
//TODO: move into DecReport...
enum stage { initial= 0, // i.e. did not pass 'prescale
prescaled = 1, // i.e. did not pass 'seed'
odin = 2, // i.e. did not pass 'filter0'
l0du = 3, // i.e. did not pass 'filter1'
hlt = 4, // i.e. did not pass 'filter2'
hlt1 = 5, // i.e. did not pass 'filter2'
hlt2 = 6, // i.e. did not pass 'filter2'
filter1ed = 7, // i.e. did not pass 'filter3'
filter2ed = 8, // i.e. did not pass 'postscale'
postscaled = 9 ,
nStages = postscaled };
const std::string& transition( const stage &s) const {
static const std::vector<std::string> s_map = {
{"Prescale"}, {"ODIN"}, {"L0DU"}, {"HLT"}, {"HLT1"}, {"HLT2"},
{"Filter0"}, {"Filter1"}, {"Postscale"} } ;
return s_map[s];
};
typedef std::vector<std::tuple<const Algorithm*,
unsigned,
std::unique_ptr<std::function<unsigned()>>>> SubAlgos;
SubAlgos retrieveSubAlgorithms() const;
/** Decode a vector of string. */
StatusCode decodeNames( );
Gaudi::Algorithm* getSubAlgorithm(const std::string& name);
/** copy, assignment is not allowed **/
Line( const Line& a ) = delete;
Line& operator=( const Line& a ) = delete;
std::array< std::unique_ptr<Stage>, nStages > m_stages; ///< List of algorithms to process.
SubAlgos m_subAlgo; ///< list of subalgorithms and their sub-count
ISequencerTimerTool* m_timerTool; ///< Pointer to the timer tool
IJobOptionsSvc* m_jos; ///< Pointer to job options service
IAlgManager* m_algMgr; ///< Pointer to algorithm manager
AIDA::IHistogram1D* m_errorHisto;
AIDA::IHistogram1D *m_timeHisto;
AIDA::IHistogram1D *m_ncandHisto;
AIDA::IHistogram1D *m_stepHisto;
AIDA::IProfile1D *m_candHisto;
mutable IANNSvc *m_hltANNSvc;
StatEntity *m_acceptCounter;
StatEntity *m_errorCounter;
StatEntity *m_slowCounter;
std::string m_outputContainerName;
std::string m_decision;
std::string s_ANNSvc;
std::vector<std::string> m_incidents; ///< Incidents to be flagged in HltDecReport if they occurs during processing
bool m_ignoreFilter; ///< True if one continues always.
bool m_measureTime; ///< Flag to measure time
bool m_returnOK; ///< Forces the sequencer to return a good status
bool m_acceptOnError; ///< Forces accept if error
bool m_acceptOnIncident; ///< Forces accept if incident
bool m_acceptIfSlow; ///< Forces accept if event is slow
bool m_caughtIncident;
bool m_turbo; ///< Line is a 'turbo' line -- flag this in decreport
int m_timer; ///< Timer number for the sequencer
int m_maxAcceptOnError; ///< quota to avoid runaway accepts in case of persistent errors..
int m_nAcceptOnError;
unsigned m_slowThreshold;
size_t m_insertion_hint = -1;
void setTimer( int nb ) { m_timer = nb; }
Gaudi::Algorithm* algorithm() const { return m_algorithm; }
bool reverse() const { return m_reverse; }
int timer() const { return m_timer; }
void updateHandler( Property& prop );
Line& m_parent;
ISequencerTimerTool* m_timerTool = nullptr; ///< Pointer to the timer tool
Gaudi::Algorithm* m_algorithm = nullptr; ///< Algorithm pointer
StringProperty m_property;
bool m_reverse = false; ///< Indicates that the flag has to be inverted
bool m_dirty = true;
bool m_initialized = false;
int m_timer; ///< Timer number for this algorithm
};
}
protected:
// utilities for derived classes to use...
const std::string& decisionName() { return m_decision; }
// retrieve (recursive!) list of sub algorithms
std::vector<const Gaudi::Algorithm*> algorithms() const;
IANNSvc& annSvc() const;
private:
// TODO: move into DecReport...
enum stage {
initial = 0, // i.e. did not pass 'prescale
prescaled = 1, // i.e. did not pass 'seed'
odin = 2, // i.e. did not pass 'filter0'
l0du = 3, // i.e. did not pass 'filter1'
hlt = 4, // i.e. did not pass 'filter2'
hlt1 = 5, // i.e. did not pass 'filter2'
hlt2 = 6, // i.e. did not pass 'filter2'
filter1ed = 7, // i.e. did not pass 'filter3'
filter2ed = 8, // i.e. did not pass 'postscale'
postscaled = 9,
nStages = postscaled
};
const std::string& transition( const stage& s ) const {
static const std::vector<std::string> s_map = {{"Prescale"}, {"ODIN"}, {"L0DU"}, {"HLT"}, {"HLT1"},
{"HLT2"}, {"Filter0"}, {"Filter1"}, {"Postscale"}};
return s_map[s];
};
typedef std::vector<std::tuple<const Algorithm*, unsigned, std::unique_ptr<std::function<unsigned()>>>> SubAlgos;
SubAlgos retrieveSubAlgorithms() const;
/** Decode a vector of string. */
StatusCode decodeNames();
Gaudi::Algorithm* getSubAlgorithm( const std::string& name );
/** copy, assignment is not allowed **/
Line( const Line& a ) = delete;
Line& operator=( const Line& a ) = delete;
std::array<std::unique_ptr<Stage>, nStages> m_stages; ///< List of algorithms to process.
SubAlgos m_subAlgo; ///< list of subalgorithms and their sub-count
ISequencerTimerTool* m_timerTool; ///< Pointer to the timer tool
IJobOptionsSvc* m_jos; ///< Pointer to job options service
IAlgManager* m_algMgr; ///< Pointer to algorithm manager
AIDA::IHistogram1D* m_errorHisto;
AIDA::IHistogram1D* m_timeHisto;
AIDA::IHistogram1D* m_ncandHisto;
AIDA::IHistogram1D* m_stepHisto;
AIDA::IProfile1D* m_candHisto;
mutable IANNSvc* m_hltANNSvc;
StatEntity* m_acceptCounter;
StatEntity* m_errorCounter;
StatEntity* m_slowCounter;
std::string m_outputContainerName;
std::string m_decision;
std::string s_ANNSvc;
std::vector<std::string> m_incidents; ///< Incidents to be flagged in HltDecReport if they occurs during processing
bool m_ignoreFilter; ///< True if one continues always.
bool m_measureTime; ///< Flag to measure time
bool m_returnOK; ///< Forces the sequencer to return a good status
bool m_acceptOnError; ///< Forces accept if error
bool m_acceptOnIncident; ///< Forces accept if incident
bool m_acceptIfSlow; ///< Forces accept if event is slow
bool m_caughtIncident;
bool m_turbo; ///< Line is a 'turbo' line -- flag this in decreport
int m_timer; ///< Timer number for the sequencer
int m_maxAcceptOnError; ///< quota to avoid runaway accepts in case of persistent errors..
int m_nAcceptOnError;
unsigned m_slowThreshold;
size_t m_insertion_hint = -1;
};
} // namespace Selection
#endif // Line_H
......@@ -20,84 +20,78 @@
namespace {
template <typename R, typename A>
bool setAxisLabels_( A* aida, const std::string& xAxis, const std::string& yAxis ) {
if (aida==0) return false;
R *root = Gaudi::Utils::Aida2ROOT::aida2root( aida );
if (root==0) return false;
root->SetXTitle(xAxis.c_str());
root->SetYTitle(yAxis.c_str());
if ( aida == 0 ) return false;
R* root = Gaudi::Utils::Aida2ROOT::aida2root( aida );
if ( root == 0 ) return false;
root->SetXTitle( xAxis.c_str() );
root->SetYTitle( yAxis.c_str() );
return true;
}
bool setBinLabels_( TAxis* axis, const std::vector<std::pair<unsigned,std::string> >& labels ) {
if (axis==0) return false;
bool setBinLabels_( TAxis* axis, const std::vector<std::pair<unsigned, std::string>>& labels ) {
if ( axis == 0 ) return false;
unsigned nbins = axis->GetNbins();
for (std::vector<std::pair<unsigned,std::string> >::const_iterator i = labels.begin();i!=labels.end();++i ) {
//TODO: check bin exists...
if (1+i->first <= 0 || 1+i->first > nbins ) return false;
for ( std::vector<std::pair<unsigned, std::string>>::const_iterator i = labels.begin(); i != labels.end(); ++i ) {
// TODO: check bin exists...
if ( 1 + i->first <= 0 || 1 + i->first > nbins ) return false;
// Argh... ROOT bins start counting at '1' instead of '0'
axis -> SetBinLabel(1 + i->first ,i->second.c_str() );
axis->SetBinLabel( 1 + i->first, i->second.c_str() );
}
return true;
}
template <typename R, typename A>
bool setBinLabels_( A* aida, const std::vector<std::pair<unsigned,std::string> >& labels ) {
if (aida==0) return false;
R *root = Gaudi::Utils::Aida2ROOT::aida2root( aida );
if (root==0) return false;
bool setBinLabels_( A* aida, const std::vector<std::pair<unsigned, std::string>>& labels ) {
if ( aida == 0 ) return false;
R* root = Gaudi::Utils::Aida2ROOT::aida2root( aida );
if ( root == 0 ) return false;
return setBinLabels_( root->GetXaxis(), labels );
}
template <typename Histogram>
bool setBinLabels_( Histogram* hist, const std::vector<std::string>& labels ) {
std::vector<std::pair<unsigned,std::string> > l;
for (unsigned i = 0;i<labels.size();++i) l.push_back(std::make_pair( i , labels[i] ) );
return HistogramUtilities::setBinLabels(hist,l);
std::vector<std::pair<unsigned, std::string>> l;
for ( unsigned i = 0; i < labels.size(); ++i ) l.push_back( std::make_pair( i, labels[i] ) );
return HistogramUtilities::setBinLabels( hist, l );
}
}
} // namespace
namespace HistogramUtilities {
bool setBinLabels( AIDA::IHistogram1D* hist, const std::vector<std::pair<unsigned,std::string> >& labels ) {
return setBinLabels_<TH1D>(hist,labels);
bool setBinLabels( AIDA::IHistogram1D* hist, const std::vector<std::pair<unsigned, std::string>>& labels ) {
return setBinLabels_<TH1D>( hist, labels );
}
bool setBinLabels( AIDA::IProfile1D* hist, const std::vector<std::pair<unsigned,std::string> >& labels ) {
return setBinLabels_<TProfile>(hist, labels);
bool setBinLabels( AIDA::IProfile1D* hist, const std::vector<std::pair<unsigned, std::string>>& labels ) {
return setBinLabels_<TProfile>( hist, labels );
}
bool setBinLabels( AIDA::IHistogram1D* hist, const std::vector<std::string>& labels ) {
return setBinLabels_(hist,labels);
return setBinLabels_( hist, labels );
}
bool setBinLabels( AIDA::IProfile1D* hist, const std::vector<std::string>& labels ) {
return setBinLabels_(hist,labels);
return setBinLabels_( hist, labels );
}
bool setBinLabels( AIDA::IHistogram2D* hist, const std::vector<std::string>& xlabels,
const std::vector<std::string>& ylabels) {
if (hist==0) return false;
std::vector<std::pair<unsigned,std::string> > lx;
for (unsigned i = 0;i<xlabels.size();++i) {
lx.push_back(std::make_pair( i , xlabels[i] ) );
}
std::vector<std::pair<unsigned,std::string> > ly;
for (unsigned i = 0;i<ylabels.size();++i) {
ly.push_back(std::make_pair( i , ylabels[i] ) );
}
TH2D *h2d = Gaudi::Utils::Aida2ROOT::aida2root( hist );
if (h2d==0) return false;
return setBinLabels_( h2d->GetXaxis(), lx) && setBinLabels_( h2d->GetYaxis(), ly );
const std::vector<std::string>& ylabels ) {
if ( hist == 0 ) return false;
std::vector<std::pair<unsigned, std::string>> lx;
for ( unsigned i = 0; i < xlabels.size(); ++i ) { lx.push_back( std::make_pair( i, xlabels[i] ) ); }
std::vector<std::pair<unsigned, std::string>> ly;
for ( unsigned i = 0; i < ylabels.size(); ++i ) { ly.push_back( std::make_pair( i, ylabels[i] ) ); }
TH2D* h2d = Gaudi::Utils::Aida2ROOT::aida2root( hist );
if ( h2d == 0 ) return false;
return setBinLabels_( h2d->GetXaxis(), lx ) && setBinLabels_( h2d->GetYaxis(), ly );
}
bool setAxisLabels( AIDA::IHistogram1D* hist, const std::string & xAxis,const std::string & yAxis ) {
bool setAxisLabels( AIDA::IHistogram1D* hist, const std::string& xAxis, const std::string& yAxis ) {
return setAxisLabels_<TH1D>( hist, xAxis, yAxis );
}
bool setAxisLabels( AIDA::IProfile1D* hist, const std::string & xAxis,const std::string & yAxis ) {
bool setAxisLabels( AIDA::IProfile1D* hist, const std::string& xAxis, const std::string& yAxis ) {
return setAxisLabels_<TProfile>( hist, xAxis, yAxis );
}
#if 0
bool shiftBinsLeft( AIDA::IProfile1D* profile ) {
if (profile==0) return false;
......@@ -106,4 +100,4 @@ namespace HistogramUtilities {
}
#endif
}
} // namespace HistogramUtilities
......@@ -8,39 +8,28 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include <vector>
#include <string>
#include <utility>
#include <vector>
namespace AIDA
{
namespace AIDA {
class IHistogram1D;
class IHistogram2D;
class IProfile1D;
}
} // namespace AIDA
namespace HistogramUtilities
{
namespace HistogramUtilities {
bool setBinLabels( AIDA::IHistogram1D* hist,
const std::vector<std::string>& labels ) ;
bool setBinLabels( AIDA::IProfile1D* hist,
const std::vector<std::string>& labels ) ;
bool setBinLabels( AIDA::IHistogram1D* hist, const std::vector<std::string>& labels );
bool setBinLabels( AIDA::IProfile1D* hist, const std::vector<std::string>& labels );
bool setBinLabels( AIDA::IHistogram1D* hist,
const std::vector<std::pair<unsigned,std::string> >& labels ) ;
bool setBinLabels( AIDA::IProfile1D* hist,
const std::vector<std::pair<unsigned,std::string> >& labels ) ;
bool setBinLabels( AIDA::IHistogram1D* hist, const std::vector<std::pair<unsigned, std::string>>& labels );
bool setBinLabels( AIDA::IProfile1D* hist, const std::vector<std::pair<unsigned, std::string>>& labels );
bool setBinLabels( AIDA::IHistogram2D* hist,
const std::vector<std::string>& xlabels,
const std::vector<std::string>& ylabels) ;
bool setBinLabels( AIDA::IHistogram2D* hist, const std::vector<std::string>& xlabels,
const std::vector<std::string>& ylabels );
bool setAxisLabels( AIDA::IHistogram1D* hist,
const std::string & xAxis,
const std::string & yAxis ) ;
bool setAxisLabels( AIDA::IProfile1D* prof,
const std::string & xAxis,
const std::string & yAxis ) ;
bool setAxisLabels( AIDA::IHistogram1D* hist, const std::string& xAxis, const std::string& yAxis );
bool setAxisLabels( AIDA::IProfile1D* prof, const std::string& xAxis, const std::string& yAxis );
}
} // namespace HistogramUtilities
This diff is collapsed.
......@@ -13,9 +13,9 @@
// Include files
// from MicroDST
#include <MicroDST/KeyedContainerClonerAlg.h>
#include <MicroDST/ICloneCaloAdc.h>
#include "MicroDST/BindType2ClonerDef.h"
#include <MicroDST/ICloneCaloAdc.h>
#include <MicroDST/KeyedContainerClonerAlg.h>
// from LHCb
#include <Event/CaloAdc.h>
......@@ -42,7 +42,7 @@
* @see ICloneCaloAdc
* @see CaloAdcCloner
*
* <b>Example</b>: Clone CaloAdcs from "/Event/Hlt/Calo/EcalAdcs" to
* <b>Example</b>: Clone CaloAdcs from "/Event/Hlt/Calo/EcalAdcs" to
* "/Event/MyLocation/Hlt/Calo/EcalAdcs"
*
* @code
......@@ -54,20 +54,20 @@
* mySeq.Members += [copyAdcs]
* @endcode
*/
template <> struct BindType2Cloner<LHCb::CaloAdc>
{
template <>
struct BindType2Cloner<LHCb::CaloAdc> {
typedef LHCb::CaloAdc Type;
typedef ICloneCaloAdc Cloner;
};
//=============================================================================
template<> struct Defaults<LHCb::CaloAdc>
{
template <>
struct Defaults<LHCb::CaloAdc> {
const static std::string clonerType;
};
const std::string Defaults<LHCb::CaloAdc>::clonerType = "CaloAdcCloner";
//=============================================================================
template<> struct Location<LHCb::CaloAdc>
{
template <>
struct Location<LHCb::CaloAdc> {
const static std::string Default;
};
const std::string Location<LHCb::CaloAdc>::Default = "";
......
......@@ -13,9 +13,9 @@
// Include files
// from MicroDST
#include <MicroDST/KeyedContainerClonerAlg.h>
#include <MicroDST/ICloneCaloCluster.h>
#include "MicroDST/BindType2ClonerDef.h"
#include <MicroDST/ICloneCaloCluster.h>
#include <MicroDST/KeyedContainerClonerAlg.h>
// from LHCb
#include <Event/CaloCluster.h>
......@@ -42,7 +42,7 @@
* @see ICloneCaloCluster
* @see CaloClusterCloner
*
* <b>Example</b>: Clone CaloClusters from "/Event/Hlt/Calo/EcalClusters" to
* <b>Example</b>: Clone CaloClusters from "/Event/Hlt/Calo/EcalClusters" to
* "/Event/MyLocation/Hlt/Calo/EcalClusters"
*
* @code
......@@ -54,20 +54,20 @@
* mySeq.Members += [copyClusters]
* @endcode
*/
template <> struct BindType2Cloner<LHCb::CaloCluster>
{
template <>
struct BindType2Cloner<LHCb::CaloCluster> {
typedef LHCb::CaloCluster Type;
typedef ICloneCaloCluster Cloner;
};
//=============================================================================
template<> struct Defaults<LHCb::CaloCluster>
{
template <>
struct Defaults<LHCb::CaloCluster> {
const static std::string clonerType;