Skip to content
Snippets Groups Projects
Commit 00c3fcd7 authored by Christoph Hasse's avatar Christoph Hasse :cartwheel_tone1:
Browse files

Merge branch 'cleanup-RecAlgs' into 'master'

Modernize RecAlgs

See merge request !2521
parents 802ad23b acbb55ab
No related branches found
No related tags found
1 merge request!2521Modernize RecAlgs
Pipeline #2978736 passed
Showing with 321 additions and 507 deletions
......@@ -8,17 +8,35 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
// Include files
// local
#include "AddToProcStatus.h"
#include "Event/ProcStatus.h"
#include "GaudiAlg/GaudiAlgorithm.h"
//-----------------------------------------------------------------------------
// Implementation file for class : AddToProcStatus
//
// 2011-06-15 : Patrick Koppenburg
//-----------------------------------------------------------------------------
/** @class AddToProcStatus AddToProcStatus.h
*
* Add an entry to ProcStatus if some sequeence failed
*
* @author Patrick Koppenburg
* @date 2011-06-15
*/
class AddToProcStatus final : public GaudiAlgorithm {
public:
/// Standard constructor
using GaudiAlgorithm::GaudiAlgorithm;
StatusCode initialize() override; ///< Algorithm initialization
StatusCode execute() override; ///< Algorithm execution
private:
Gaudi::Property<std::string> m_subsystem{this, "Subsystem", "", "Subsystem that has aborted"}; ///< subsystem
Gaudi::Property<std::string> m_reason{this, "Reason", "", "Reason"}; ///< Reason for error
Gaudi::Property<int> m_status{this, "Status", -3, "Status Code"}; ///< return code
Gaudi::Property<bool> m_abort{this, "Abort", true, "Abort Event?"}; ///< should processing be aborted?
};
// Declaration of the Algorithm Factory
DECLARE_COMPONENT( AddToProcStatus )
......
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#ifndef ADDTOPROCSTATUS_H
#define ADDTOPROCSTATUS_H 1
// Include files
// from Gaudi
#include "GaudiAlg/GaudiAlgorithm.h"
/** @class AddToProcStatus AddToProcStatus.h
*
* Add an entry to ProcStatus if some sequeence failed
*
* @author Patrick Koppenburg
* @date 2011-06-15
*/
class AddToProcStatus final : public GaudiAlgorithm {
public:
/// Standard constructor
using GaudiAlgorithm::GaudiAlgorithm;
StatusCode initialize() override; ///< Algorithm initialization
StatusCode execute() override; ///< Algorithm execution
private:
Gaudi::Property<std::string> m_subsystem{this, "Subsystem", "", "Subsystem that has aborted"}; ///< subsystem
Gaudi::Property<std::string> m_reason{this, "Reason", "", "Reason"}; ///< Reason for error
Gaudi::Property<int> m_status{this, "Status", -3, "Status Code"}; ///< return code
Gaudi::Property<bool> m_abort{this, "Abort", true, "Abort Event?"}; ///< should processing be aborted?
};
#endif // ADDTOPROCSTATUS_H
......@@ -8,11 +8,10 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
// Include files
// local
#include "EventTimeMonitor.h"
#include "AIDA/IHistogram1D.h"
#include "Event/ODIN.h" // event & run number
#include "GaudiAlg/Consumer.h"
#include "GaudiAlg/GaudiHistoAlg.h"
namespace {
//@FIXME: what about leapyears?
......@@ -25,6 +24,37 @@ namespace {
// 2012-04-19 : Patrick Koppenburg
//-----------------------------------------------------------------------------
/** @class EventTimeMonitor EventTimeMonitor.h
*
* Creates histograms of event time
*
* @author Patrick Koppenburg
* @date 2012-04-19
*/
class EventTimeMonitor final
: public Gaudi::Functional::Consumer<void( const LHCb::ODIN& ),
Gaudi::Functional::Traits::BaseClass_t<GaudiHistoAlg>> {
public:
/// Standard constructor
EventTimeMonitor( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override; ///< Algorithm initialization
void operator()( const LHCb::ODIN& ) const override; ///< Algorithm execution
private:
/// the histogram definition (as property)
Gaudi::Property<Gaudi::Histo1DDef> m_histoS{
this, "SecondsPlot", {"GPS Seconds", 0, 3600., 3600}, "The parameters of 'delta memory' histogram"};
Gaudi::Histo1DDef m_histoH{"GPS Hours", -0.5, 23.5, 24}; // the histogram definition (as property)
Gaudi::Histo1DDef m_histoD{"GPS Days", 0.5, 365.5, 366}; // the histogram definition (as property)
Gaudi::Histo1DDef m_histoY{"GPS Year", 2008.5, 2028.5, 20}; // the histogram definition (as property)
mutable AIDA::IHistogram1D* m_plotS = nullptr; // the histogram of seconds
mutable AIDA::IHistogram1D* m_plotH = nullptr; // the histogram of hours
mutable AIDA::IHistogram1D* m_plotD = nullptr; // the histogram of day of year
mutable AIDA::IHistogram1D* m_plotY = nullptr; // the histogram of year
};
// Declaration of the Algorithm Factory
DECLARE_COMPONENT( EventTimeMonitor )
......
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#ifndef EVENTTIMEMONITOR_H
#define EVENTTIMEMONITOR_H 1
// Include files
#include "Event/ODIN.h" // event & run number
// from Gaudi
#include "GaudiAlg/Consumer.h"
#include "GaudiAlg/GaudiHistoAlg.h"
/** @class EventTimeMonitor EventTimeMonitor.h
*
* Creates histograms of event time
*
* @author Patrick Koppenburg
* @date 2012-04-19
*/
class EventTimeMonitor final
: public Gaudi::Functional::Consumer<void( const LHCb::ODIN& ),
Gaudi::Functional::Traits::BaseClass_t<GaudiHistoAlg>> {
public:
/// Standard constructor
EventTimeMonitor( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override; ///< Algorithm initialization
void operator()( const LHCb::ODIN& ) const override; ///< Algorithm execution
private:
/// the histogram definition (as property)
Gaudi::Property<Gaudi::Histo1DDef> m_histoS{
this, "SecondsPlot", {"GPS Seconds", 0, 3600., 3600}, "The parameters of 'delta memory' histogram"};
Gaudi::Histo1DDef m_histoH{"GPS Hours", -0.5, 23.5, 24}; // the histogram definition (as property)
Gaudi::Histo1DDef m_histoD{"GPS Days", 0.5, 365.5, 366}; // the histogram definition (as property)
Gaudi::Histo1DDef m_histoY{"GPS Year", 2008.5, 2028.5, 20}; // the histogram definition (as property)
mutable AIDA::IHistogram1D* m_plotS = nullptr; // the histogram of seconds
mutable AIDA::IHistogram1D* m_plotH = nullptr; // the histogram of hours
mutable AIDA::IHistogram1D* m_plotD = nullptr; // the histogram of day of year
mutable AIDA::IHistogram1D* m_plotY = nullptr; // the histogram of year
};
#endif // EVENTTIMEMONITOR_H
......@@ -8,8 +8,11 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
// local
#include "ProcStatAbortMoni.h"
#include "AIDA/IProfile1D.h"
#include "Event/ProcStatus.h"
#include "GaudiAlg/Consumer.h"
#include "GaudiAlg/GaudiHistoAlg.h"
#include "GaudiUtils/HistoLabels.h"
//-----------------------------------------------------------------------------
// Implementation file for class : ProcStatAbortMoni
......@@ -17,6 +20,35 @@
// 2010-07-16 : Chris Jones
//-----------------------------------------------------------------------------
/** @class ProcStatAbortMoni ProcStatAbortMoni.h
*
* Monitor for abort rates in ProcStat
*
* @author Chris Jones
* @date 2010-07-16
*/
class ProcStatAbortMoni final
: public Gaudi::Functional::Consumer<void( const LHCb::ProcStatus& ),
Gaudi::Functional::Traits::BaseClass_t<GaudiHistoAlg>> {
public:
/// Standard constructor
ProcStatAbortMoni( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override; ///< Algorithm initialization
void operator()( const LHCb::ProcStatus& ) const override; ///< Algorithm execution
private:
/// List of subsystems
Gaudi::Property<std::vector<std::string>> m_subSystems{
this,
"SubSystems",
{"Overall", "Hlt", "VELO", "TT", "IT", "OT", "Tracking", "Vertex", "RICH", "CALO", "MUON", "PROTO"}};
/// cache the histogram pointer
AIDA::IProfile1D* m_h = nullptr;
};
// Declaration of the Algorithm Factory
DECLARE_COMPONENT( ProcStatAbortMoni )
......
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#ifndef RECALGS_PROCSTATABORTMONI_H
#define RECALGS_PROCSTATABORTMONI_H 1
// from Gaudi
#include "GaudiAlg/Consumer.h"
#include "GaudiAlg/GaudiHistoAlg.h"
// GaudiUtils
#include "GaudiUtils/HistoLabels.h"
// Event model
#include "Event/ProcStatus.h"
// AIDA
#include "AIDA/IProfile1D.h"
/** @class ProcStatAbortMoni ProcStatAbortMoni.h
*
* Monitor for abort rates in ProcStat
*
* @author Chris Jones
* @date 2010-07-16
*/
class ProcStatAbortMoni final
: public Gaudi::Functional::Consumer<void( const LHCb::ProcStatus& ),
Gaudi::Functional::Traits::BaseClass_t<GaudiHistoAlg>> {
public:
/// Standard constructor
ProcStatAbortMoni( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override; ///< Algorithm initialization
void operator()( const LHCb::ProcStatus& ) const override; ///< Algorithm execution
private:
/// List of subsystems
Gaudi::Property<std::vector<std::string>> m_subSystems{
this,
"SubSystems",
{"Overall", "Hlt", "VELO", "TT", "IT", "OT", "Tracking", "Vertex", "RICH", "CALO", "MUON", "PROTO"}};
/// cache the histogram pointer
AIDA::IProfile1D* m_h = nullptr;
};
#endif // RECALGS_PROCSTATABORTMONI_H
......@@ -8,21 +8,19 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "RecInit.h"
#include "Event/ODIN.h"
#include "Event/ProcStatus.h"
#include "Event/ProcessHeader.h"
#include "Event/RawBank.h"
#include "Event/RawEvent.h"
#include "Event/RecHeader.h"
#include "GaudiAlg/IGenericTool.h"
#include "GaudiKernel/GaudiException.h"
#include "GaudiKernel/IIncidentSvc.h"
#include "GaudiKernel/IOpaqueAddress.h"
#include "GaudiKernel/Incident.h"
#include "Kernel/LbAppInit.h"
#include "LHCbAlgs/Transformer.h"
//-----------------------------------------------------------------------------
// Implementation file for class : RecInit
......@@ -30,6 +28,29 @@
// Marco Cattaneo, Sebastien Ponce
//-----------------------------------------------------------------------------
/** @class RecInit RecInit.h
* Algorithm to initialize the reconstruction sequence
* Creates RecHeader and ProcStatus
*
* @author Marco Cattaneo, Sebastien Ponce
*/
class RecInit final : public LHCb::Algorithm::MultiTransformer<std::tuple<LHCb::RecHeader, LHCb::ProcStatus>(
const LHCb::ODIN&, const LHCb::RawEvent& ),
Gaudi::Functional::Traits::BaseClass_t<LbAppInit>> {
public:
/// Standard constructor
RecInit( const std::string& name, ISvcLocator* pSvcLocator );
/// Algorithm execution
std::tuple<LHCb::RecHeader, LHCb::ProcStatus> operator()( const LHCb::ODIN&, const LHCb::RawEvent& ) const override;
private:
mutable ToolHandle<IGenericTool> m_memoryTool{this, "Tool",
"MemoryTool/BrunelMemory"}; ///< (private) memory histogram tool
Gaudi::Property<bool> m_abortOnFID{this, "AbortOnFID", true, "If I can't find the raw file ID, do I abort ?"};
};
// Declaration of the Algorithm Factory
DECLARE_COMPONENT( RecInit )
......@@ -45,22 +66,6 @@ RecInit::RecInit( const std::string& name, ISvcLocator* pSvcLocator )
{KeyValue{"OutputRecHeaderName", LHCb::RecHeaderLocation::Default},
KeyValue{"OutputProcStatusName", LHCb::ProcStatusLocation::Default}} ) {}
//=============================================================================
// Initialization
//=============================================================================
StatusCode RecInit::initialize() {
// must be executed first
const StatusCode sc = LbAppInit::initialize();
if ( sc.isFailure() ) return sc;
if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Initialize" << endmsg;
// Private tool to plot the memory usage
m_memoryTool = tool<IGenericTool>( "MemoryTool", "BrunelMemory", this, true );
return sc;
}
//=============================================================================
// Main execution
//=============================================================================
......@@ -72,7 +77,7 @@ std::tuple<LHCb::RecHeader, LHCb::ProcStatus> RecInit::operator()( const LHCb::O
// memory check
LbAppInit::checkMem();
// Plot the memory usage, this call is thread safe
// Plot the memory usage, this call is thread safe (for the default configured tool, i.e. MemoryTool)
m_memoryTool->execute();
const auto runNumber = odin.runNumber();
......
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#ifndef RECINIT_H
#define RECINIT_H 1
#include "Event/ODIN.h"
#include "Event/ProcStatus.h"
#include "Event/RawEvent.h"
#include "Event/RecHeader.h"
#include "Kernel/LbAppInit.h"
#include "GaudiAlg/Transformer.h"
class IGenericTool;
class IIncidentSvc;
/** @class RecInit RecInit.h
* Algorithm to initialize the reconstruction sequence
* Creates RecHeader and ProcStatus
*
* @author Marco Cattaneo, Sebastien Ponce
*/
class RecInit final : public Gaudi::Functional::MultiTransformer<std::tuple<LHCb::RecHeader, LHCb::ProcStatus>(
const LHCb::ODIN&, const LHCb::RawEvent& ),
Gaudi::Functional::Traits::BaseClass_t<LbAppInit>> {
public:
/// Standard constructor
RecInit( const std::string& name, ISvcLocator* pSvcLocator );
/// Algorithm initialization
StatusCode initialize() override;
/// Algorithm execution
std::tuple<LHCb::RecHeader, LHCb::ProcStatus> operator()( const LHCb::ODIN&, const LHCb::RawEvent& ) const override;
private:
IGenericTool* m_memoryTool = nullptr; ///< Pointer to (private) memory histogram tool
Gaudi::Property<bool> m_abortOnFID{this, "AbortOnFID", true, "If I can't find the raw file ID, do I abort ?"};
};
#endif // RECINIT_H
......@@ -8,15 +8,45 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
// local
#include "RecProcessingTimeMoni.h"
#include "AIDA/IHistogram1D.h"
#include "GaudiAlg/GaudiHistoAlg.h"
#include <algorithm>
//-----------------------------------------------------------------------------
// Implementation file for class : RecProcessingTimeMoni
//
// 2010-07-15 : Chris Jones
//-----------------------------------------------------------------------------
/** @class RecProcessingTimeMoni RecProcessingTimeMoni.h
*
* Simple monitor making basic processing time plots for the Reconstruction
*
* @author Chris Jones
* @date 2010-07-15
*/
class RecProcessingTimeMoni final : public GaudiHistoAlg {
public:
/// Standard constructor
RecProcessingTimeMoni( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override; ///< Algorithm initialization
StatusCode execute() override; ///< Algorithm execution
private:
/// Definition of algorithm name list
typedef std::vector<std::string> AlgorithmNames;
AIDA::IHistogram1D* m_hist = nullptr; ///< Pointer to processing time histogram
Gaudi::Property<AlgorithmNames> m_algNames{this, "Algorithms"}; ///< List of algorithm(s) to include in timing
Gaudi::Property<double> m_logMaxTime{this, "LogMaxEventTime",
8.0}; ///< Job Option for log10(maximum overall processing time) for plots
Gaudi::Property<double> m_logMinTime{this, "LogMinEventTime",
-2.0}; ///< Job Option for log10(minimum overall processing time) for plots
};
// Declaration of the Algorithm Factory
DECLARE_COMPONENT( RecProcessingTimeMoni )
......@@ -51,12 +81,12 @@ StatusCode RecProcessingTimeMoni::initialize() {
StatusCode RecProcessingTimeMoni::execute() {
// Loop over algorithms to include in the timing and add them up
double time = 0;
for ( const auto& name : m_algNames ) {
const auto alg_time = chronoSvc()->chronoDelta( name + ":Execute", IChronoStatSvc::ELAPSED ) / 1000;
time += alg_time;
if ( msgLevel( MSG::VERBOSE ) ) verbose() << name << " " << alg_time << endmsg;
}
double time = std::accumulate(
m_algNames.begin(), m_algNames.end(), double{0}, [&, chrono = chronoSvc()]( double t, const auto& name ) {
const auto alg_time = chrono->chronoDelta( name + ":Execute", IChronoStatSvc::ELAPSED ) / 1000;
if ( msgLevel( MSG::VERBOSE ) ) verbose() << name << " " << alg_time << endmsg;
return t + alg_time;
} );
// only fill if algorithm(s) ran (time>0)
if ( time > 0 ) {
......
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#ifndef RECALGS_RECPROCESSINGTIMEMONI_H
#define RECALGS_RECPROCESSINGTIMEMONI_H 1
// from Gaudi
#include "GaudiAlg/GaudiHistoAlg.h"
// from Aida
#include "AIDA/IHistogram1D.h"
/** @class RecProcessingTimeMoni RecProcessingTimeMoni.h
*
* Simple monitor making basic processing time plots for the Reconstruction
*
* @author Chris Jones
* @date 2010-07-15
*/
class RecProcessingTimeMoni final : public GaudiHistoAlg {
public:
/// Standard constructor
RecProcessingTimeMoni( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override; ///< Algorithm initialization
StatusCode execute() override; ///< Algorithm execution
private:
/// Definition of algorithm name list
typedef std::vector<std::string> AlgorithmNames;
AIDA::IHistogram1D* m_hist = nullptr; ///< Pointer to processing time histogram
Gaudi::Property<AlgorithmNames> m_algNames{this, "Algorithms"}; ///< List of algorithm(s) to include in timing
Gaudi::Property<double> m_logMaxTime{this, "LogMaxEventTime",
8.0}; ///< Job Option for log10(maximum overall processing time) for plots
Gaudi::Property<double> m_logMinTime{this, "LogMinEventTime",
-2.0}; ///< Job Option for log10(minimum overall processing time) for plots
};
#endif // RECALGS_RECPROCESSINGTIMEMONI_H
/*****************************************************************************\
/***************************************************************************** \
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
......@@ -8,10 +8,23 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
// Include files
// local
#include "RecSummaryAlg.h"
#include "Event/CaloDigit.h"
#include "Event/FTLiteCluster.h"
#include "Event/MuonCoord.h"
#include "Event/RecSummary.h"
#include "Event/RecVertex.h"
#include "Event/Track.h"
#include "Event/UTCluster.h"
#include "Event/VPLightCluster.h"
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/AnyDataHandle.h"
#include "Kernel/ICountContainedObjects.h"
#include "RichFutureUtils/RichDecodedData.h"
#include <algorithm>
#include <boost/numeric/conversion/cast.hpp>
#include <map>
#include <optional>
#include <string>
//-----------------------------------------------------------------------------
// Implementation file for class : RecSummaryAlg
......@@ -19,6 +32,99 @@
// 2011-01-19 : Chris Jones
//-----------------------------------------------------------------------------
/** @class RecSummaryAlg RecSummaryAlg.h
*
* Fill the LHCb::RecSummary class with summary information from the event
* reconstruction.
*
* @author Chris Jones
* @date 2011-01-19
*/
class RecSummaryAlg final : public GaudiAlgorithm {
public:
/// Standard constructor
using GaudiAlgorithm::GaudiAlgorithm;
StatusCode execute() override final; ///< Algorithm execution
StatusCode initialize() override final; ///< Algorithm initialization
private:
/// Adds the number of objects at the given TES location to the summary object
template <class CLASS, class FALLBACK = CLASS>
inline void addSizeSummary( LHCb::RecSummary* summary, const LHCb::RecSummary::DataTypes id,
const std::string& location ) const {
std::optional<int> size;
{
const CLASS* data = getIfExists<CLASS>( location );
if ( data ) size = boost::numeric_cast<int>( data->size() );
}
if ( !size && !std::is_same<CLASS, FALLBACK>::value ) {
const FALLBACK* data = getIfExists<FALLBACK>( location );
if ( data ) size = boost::numeric_cast<int>( data->size() );
}
if ( size ) {
summary->addInfo( id, *size );
} else {
summary->addInfo( id, 0 );
Warning( "No data at '" + location + "'", StatusCode::FAILURE, 0 ).ignore();
}
}
/// Get the number of RICH hits for the given detector
inline unsigned int nRichHits( const Rich::DetectorType rich ) {
// First see if the future decoded data is available via the TES
auto base = getIfExists<AnyDataWrapperBase>( Rich::Future::DAQ::DecodedDataLocation::Default );
const auto rDH = dynamic_cast<AnyDataWrapper<Rich::Future::DAQ::DecodedData>*>( base );
const auto rD = ( rDH ? &rDH->getData() : nullptr );
if ( !rD ) { Exception( "Failed to load RICH data" ); }
return rD->nTotalHits( rich );
}
private:
/// List of sub-detectors to add
Gaudi::Property<std::vector<std::string>> m_dets{this, "Detectors", {"RICH1", "RICH2", "MUON"}};
/// List of known-detectors to add
std::vector<std::string> m_knownDets = {"RICH1", "RICH2", "MUON", "VP", "UT", "FT", "RICH1PMT", "RICH2PMT"};
/// TES location to save the summary object
Gaudi::Property<std::string> m_summaryLoc{this, "SummaryLocation", LHCb::RecSummaryLocation::Default};
/// Location in the TES to load the recosntructed tracks from
Gaudi::Property<std::string> m_trackLoc{this, "TracksLocation", LHCb::TrackLocation::Default};
/// Are split track locations used in the HLT
Gaudi::Property<bool> m_split{this, "HltSplitTracks", false};
/// Location in the TES of split long tracks in the HLT
Gaudi::Property<std::string> m_trackLongLoc{this, "SplitLongTracksLocation", LHCb::TrackLocation::Default};
/// Location in the TES of split downstream tracks in the HLT
Gaudi::Property<std::string> m_trackDownLoc{this, "SplitDownTracksLocation", LHCb::TrackLocation::Default};
/// Location in the TES to load the reconstructed PVs from
Gaudi::Property<std::string> m_pvLoc{this, "PVsLocation", LHCb::RecVertexLocation::Primary};
/// TES location of VP clusters
Gaudi::Property<std::string> m_vpLoc{this, "VPClustersLocation", LHCb::VPClusterLocation::Light};
/// TES location of UT clusters
Gaudi::Property<std::string> m_utLoc{this, "UTClustersLocation", LHCb::UTClusterLocation::UTClusters};
/// TES location of FT clusters
Gaudi::Property<std::string> m_ftLoc{this, "FTClustersLocation", LHCb::FTLiteClusterLocation::Default};
/// TES location of Muon Coords
Gaudi::Property<std::string> m_muonCoordsLoc{this, "MuonCoordsLocation", LHCb::MuonCoordLocation::MuonCoords};
/// TES location of Muon Tracks
Gaudi::Property<std::string> m_muonTracksLoc{this, "MuonTracksLocation", LHCb::TrackLocation::Muon};
/// CountVeloTracks tool
PublicToolHandle<ICountContainedObjects> m_countVeloTracks{this, "CountVeloTracks", "CountVeloTracks"};
};
// Declaration of the Algorithm Factory
DECLARE_COMPONENT( RecSummaryAlg )
......@@ -59,19 +165,26 @@ StatusCode RecSummaryAlg::execute() {
// Count each track type
int nLong( 0 ), nDownstream( 0 ), nUpstream( 0 ), nT( 0 ), nBack( 0 );
for ( const auto* tk : *tracks ) {
if ( tk->type() == LHCb::Track::Types::Long ) {
switch ( tk->type() ) {
case LHCb::Track::Types::Long:
++nLong;
} else if ( tk->type() == LHCb::Track::Types::Downstream ) {
break;
case LHCb::Track::Types::Downstream:
++nDownstream;
} else if ( tk->type() == LHCb::Track::Types::Upstream ) {
break;
case LHCb::Track::Types::Upstream:
++nUpstream;
} else if ( tk->type() == LHCb::Track::Types::Ttrack ) {
break;
case LHCb::Track::Types::Ttrack:
++nT;
} else if ( tk->type() == LHCb::Track::Types::Velo && tk->checkFlag( LHCb::Track::Flags::Backward ) ) {
++nBack;
break;
case LHCb::Track::Types::Velo:
if ( tk->checkFlag( LHCb::Track::Flags::Backward ) ) ++nBack;
break;
default:;
}
}
const int nVelo = countVeloTracks()->nObj( tracks );
const int nVelo = m_countVeloTracks->nObj( tracks );
// Save track info by type to summary
summary->addInfo( LHCb::RecSummary::DataTypes::nLongTracks, nLong );
......
/***************************************************************************** \
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#ifndef RECSUMMARYALG_H
#define RECSUMMARYALG_H 1
// STL
#include <algorithm>
#include <map>
#include <optional>
#include <string>
// from Gaudi
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/AnyDataHandle.h"
// Event Model
#include "Event/CaloDigit.h"
#include "Event/FTLiteCluster.h"
#include "Event/MuonCoord.h"
#include "Event/RecSummary.h"
#include "Event/RecVertex.h"
#include "Event/Track.h"
#include "Event/UTCluster.h"
#include "Event/VPLightCluster.h"
// RICH
#include "RichFutureUtils/RichDecodedData.h"
// tool interfaces
//#include "RichInterfaces/IRichRawBufferToSmartIDsTool.h"
#include "Kernel/ICountContainedObjects.h"
// boost
#include <boost/numeric/conversion/cast.hpp>
/** @class RecSummaryAlg RecSummaryAlg.h
*
* Fill the LHCb::RecSummary class with summary information from the event
* reconstruction.
*
* @author Chris Jones
* @date 2011-01-19
*/
class RecSummaryAlg final : public GaudiAlgorithm {
public:
/// Standard constructor
using GaudiAlgorithm::GaudiAlgorithm;
StatusCode execute() override final; ///< Algorithm execution
StatusCode initialize() override final; ///< Algorithm initialization
private:
/// Adds the number of objects at the given TES location to the summary object
template <class CLASS, class FALLBACK = CLASS>
inline void addSizeSummary( LHCb::RecSummary* summary, const LHCb::RecSummary::DataTypes id,
const std::string& location ) const {
std::optional<int> size;
{
const CLASS* data = getIfExists<CLASS>( location );
if ( data ) size = boost::numeric_cast<int>( data->size() );
}
if ( !size && !std::is_same<CLASS, FALLBACK>::value ) {
const FALLBACK* data = getIfExists<FALLBACK>( location );
if ( data ) size = boost::numeric_cast<int>( data->size() );
}
if ( size ) {
summary->addInfo( id, *size );
} else {
summary->addInfo( id, 0 );
Warning( "No data at '" + location + "'", StatusCode::FAILURE, 0 ).ignore();
}
}
/// Access on-demand the Velo track counter
inline const ICountContainedObjects* countVeloTracks() {
if ( !m_countVeloTracks ) { m_countVeloTracks = tool<ICountContainedObjects>( "CountVeloTracks" ); }
return m_countVeloTracks;
}
/// Get the number of RICH hits for the given detector
inline unsigned int nRichHits( const Rich::DetectorType rich ) {
// First see if the future decoded data is available via the TES
auto base = getIfExists<AnyDataWrapperBase>( Rich::Future::DAQ::DecodedDataLocation::Default );
const auto rDH = dynamic_cast<AnyDataWrapper<Rich::Future::DAQ::DecodedData>*>( base );
const auto rD = ( rDH ? &rDH->getData() : nullptr );
if ( !rD ) { Exception( "Failed to load RICH data" ); }
return rD->nTotalHits( rich );
}
private:
/// List of sub-detectors to add
Gaudi::Property<std::vector<std::string>> m_dets{this, "Detectors", {"RICH1", "RICH2", "MUON"}};
/// List of known-detectors to add
std::vector<std::string> m_knownDets = {"RICH1", "RICH2", "MUON", "VP", "UT", "FT", "RICH1PMT", "RICH2PMT"};
/// TES location to save the summary object
Gaudi::Property<std::string> m_summaryLoc{this, "SummaryLocation", LHCb::RecSummaryLocation::Default};
/// Location in the TES to load the recosntructed tracks from
Gaudi::Property<std::string> m_trackLoc{this, "TracksLocation", LHCb::TrackLocation::Default};
/// Are split track locations used in the HLT
Gaudi::Property<bool> m_split{this, "HltSplitTracks", false};
/// Location in the TES of split long tracks in the HLT
Gaudi::Property<std::string> m_trackLongLoc{this, "SplitLongTracksLocation", LHCb::TrackLocation::Default};
/// Location in the TES of split downstream tracks in the HLT
Gaudi::Property<std::string> m_trackDownLoc{this, "SplitDownTracksLocation", LHCb::TrackLocation::Default};
/// Location in the TES to load the reconstructed PVs from
Gaudi::Property<std::string> m_pvLoc{this, "PVsLocation", LHCb::RecVertexLocation::Primary};
/// TES location of VP clusters
Gaudi::Property<std::string> m_vpLoc{this, "VPClustersLocation", LHCb::VPClusterLocation::Light};
/// TES location of UT clusters
Gaudi::Property<std::string> m_utLoc{this, "UTClustersLocation", LHCb::UTClusterLocation::UTClusters};
/// TES location of FT clusters
Gaudi::Property<std::string> m_ftLoc{this, "FTClustersLocation", LHCb::FTLiteClusterLocation::Default};
/// TES location of Muon Coords
Gaudi::Property<std::string> m_muonCoordsLoc{this, "MuonCoordsLocation", LHCb::MuonCoordLocation::MuonCoords};
/// TES location of Muon Tracks
Gaudi::Property<std::string> m_muonTracksLoc{this, "MuonTracksLocation", LHCb::TrackLocation::Muon};
/// CountVeloTracks tool
const ICountContainedObjects* m_countVeloTracks = nullptr;
};
#endif // RECSUMMARYALG_H
......@@ -8,7 +8,14 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "TimingTuple.h"
#include "Event/ODIN.h"
#include "Event/RecSummary.h"
#include "GaudiAlg/Consumer.h"
#include "GaudiAlg/GaudiTupleAlg.h"
#include "GaudiAlg/ISequencerTimerTool.h"
#include "GaudiKernel/Memory.h"
#include <algorithm>
#include <atomic>
//-----------------------------------------------------------------------------
// Implementation file for class : TimingTuple
......@@ -16,6 +23,35 @@
// 2010-08-18 : Patrick Koppenburg
//-----------------------------------------------------------------------------
/** @class TimingTuple TimingTuple.h
*
* Fill a Tuple with timing, memory and some event variables
*
* @author Patrick Koppenburg
* @date 2010-08-18
*/
class TimingTuple final : public Gaudi::Functional::Consumer<void( const LHCb::ODIN&, const LHCb::RecSummary& ),
Gaudi::Functional::Traits::BaseClass_t<GaudiTupleAlg>> {
public:
/// Standard constructor
TimingTuple( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override; ///< Algorithm initialization
void operator()( const LHCb::ODIN&, const LHCb::RecSummary& ) const override; ///< Algorithm execution
private:
mutable PublicToolHandle<ISequencerTimerTool> m_timerTool{this, "TimerTool",
"SequencerTimerTool"}; ///< global timer tool
int m_timer = 0; ///< timer index
mutable std::atomic<unsigned long long> m_evtCounter = {0};
template <class TYPE>
void fillTuple( Tuple& tuple, const std::string& var, const TYPE number ) const {
if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Filling " << var << " with " << number << endmsg;
tuple->column( var, number ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
}
};
// Declaration of the Algorithm Factory
DECLARE_COMPONENT( TimingTuple )
......@@ -31,14 +67,10 @@ TimingTuple::TimingTuple( const std::string& name, ISvcLocator* pSvcLocator )
// Initialization
//=============================================================================
StatusCode TimingTuple::initialize() {
const StatusCode sc = GaudiTupleAlg::initialize();
if ( sc.isFailure() ) return sc;
m_timerTool = tool<ISequencerTimerTool>( "SequencerTimerTool" ); // global tool
m_timer = m_timerTool->addTimer( name() );
m_timerTool->start( m_timer ); // start it now
return sc;
return GaudiTupleAlg::initialize().andThen( [&] { return m_timerTool.retrieve(); } ).andThen( [&] {
m_timer = m_timerTool->addTimer( name() );
m_timerTool->start( m_timer ); // start it now
} );
}
//=============================================================================
......
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#ifndef TIMINGTUPLE_H
#define TIMINGTUPLE_H 1
#include <algorithm>
#include <atomic>
// from Gaudi
#include "GaudiAlg/Consumer.h"
#include "GaudiAlg/GaudiTupleAlg.h"
#include "GaudiAlg/ISequencerTimerTool.h"
#include "GaudiKernel/Memory.h"
#include "Event/ODIN.h"
#include "Event/RecSummary.h"
class ISequencerTimerTool;
/** @class TimingTuple TimingTuple.h
*
* Fill a Tuple with timing, memory and some event variables
*
* @author Patrick Koppenburg
* @date 2010-08-18
*/
class TimingTuple final : public Gaudi::Functional::Consumer<void( const LHCb::ODIN&, const LHCb::RecSummary& ),
Gaudi::Functional::Traits::BaseClass_t<GaudiTupleAlg>> {
public:
/// Standard constructor
TimingTuple( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override; ///< Algorithm initialization
void operator()( const LHCb::ODIN&, const LHCb::RecSummary& ) const override; ///< Algorithm execution
private:
ISequencerTimerTool* m_timerTool = nullptr; ///< timer tool
int m_timer = 0; ///< timer index
mutable std::atomic<unsigned long long> m_evtCounter = {0};
template <class TYPE>
void fillTuple( Tuple& tuple, const std::string& var, const TYPE number ) const {
if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Filling " << var << " with " << number << endmsg;
tuple->column( var, number ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
}
};
#endif // TIMINGTUPLE_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment