Skip to content
Snippets Groups Projects
Commit ecb1ea97 authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

made CaloDetTestAlgorithm functional

And dropped its header file
parent a538ff88
No related branches found
No related tags found
1 merge request!3001Towards dropping GaudiAlgorithm from LHCb
......@@ -8,84 +8,45 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
// ============================================================================
// Include files
// from Gaudi
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/SmartDataPtr.h"
// local
#include "CaloDetTestAlgorithm.h"
// ============================================================================
/** @file CaloDetTestAlgorithm.cpp
*
* Implementation file for class : CaloDetTestAlgorithm
*
* @author Vanya Belyaev Ivan.Belyaev@itep.ru
* @date 02/11/2001
*/
// ============================================================================
#include "CaloDet/DeCalorimeter.h"
#include "DetDesc/GenericConditionAccessorHolder.h"
// ============================================================================
/** Declaration of the Algorithm Factory
*/
// ============================================================================
DECLARE_COMPONENT( CaloDetTestAlgorithm )
// ============================================================================
/** Standard constructor
* @param name algorithm name
* @param svcloc pointer to service locator
*/
// ============================================================================
CaloDetTestAlgorithm::CaloDetTestAlgorithm( const std::string& name, ISvcLocator* svcloc )
: GaudiAlgorithm( name, svcloc ) {
declareProperty( "DetDataLocation", m_DetData );
#include "GaudiAlg/Consumer.h"
int index = name.find_last_of( "." ) + 1; // return 0 if '.' not found --> OK !!
std::string detectorName =
( name.compare( index, 3, "Prs" ) == 0 ? "Prs"
: name.compare( index, 3, "Spd" ) == 0 ? "Spd" : name.substr( index, 4 ) );
if ( "Ecal" == detectorName ) {
m_DetData = DeCalorimeterLocation::Ecal;
} else if ( "Hcal" == detectorName ) {
m_DetData = DeCalorimeterLocation::Hcal;
} else if ( "Prs" == detectorName ) {
m_DetData = DeCalorimeterLocation::Prs;
} else if ( "Spd" == detectorName ) {
m_DetData = DeCalorimeterLocation::Spd;
}
}
#include <mutex>
#include <string>
// ============================================================================
/** standard algorithm initialization
* @return status code
/**
* Simple Test Algorithm
*
* @author Vanya Belyaev Ivan.Belyaev@itep.ru
* @date 14/12/2001
*/
// ============================================================================
StatusCode CaloDetTestAlgorithm::initialize() {
if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) debug() << "==> Initialize" << endmsg;
StatusCode sc = GaudiAlgorithm::initialize();
if ( sc.isFailure() ) { return Error( "Could not initialize the base class!", sc ); }
auto* calo = getDet<DeCalorimeter>( m_DetData );
if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) debug() << "Detector element found at " << calo << endmsg;
// channel
const CaloVector<CellParam>& cells = calo->cellParams();
for ( const auto& cell : cells ) {
LHCb::CaloCellID id = ( cell ).cellID();
int card = ( cell ).cardNumber();
info() << " | " << id << " | " << id.all() << " | " << format( "0x%04X", id.all() ) << " | "
<< ( cell ).cardColumn() << "/" << ( cell ).cardRow() << " | " << ( cell ).cardNumber() << " ( "
<< calo->cardCode( card ) << ") | " << calo->cardCrate( card ) << " | " << calo->cardSlot( card ) << " | "
<< calo->cardToTell1( card ) << " | " << endmsg;
}
struct CaloDetTestAlgorithm
: public Gaudi::Functional::Consumer<void( const DeCalorimeter& ), LHCb::DetDesc::usesConditions<DeCalorimeter>> {
void operator()( const DeCalorimeter& ) const override;
CaloDetTestAlgorithm( const std::string& name, ISvcLocator* svcloc );
// used to run only one first event
mutable std::once_flag m_onlyFirstEvent;
};
/// Declaration of the Algorithm Factory
DECLARE_COMPONENT( CaloDetTestAlgorithm )
return StatusCode::SUCCESS;
CaloDetTestAlgorithm::CaloDetTestAlgorithm( const std::string& name, ISvcLocator* svcloc )
: Consumer( name, svcloc, {KeyValue{"DetDataLocation", ""}} ) {}
void CaloDetTestAlgorithm::operator()( const DeCalorimeter& calo ) const {
std::call_once( m_onlyFirstEvent, [&]() {
const CaloVector<CellParam>& cells = calo.cellParams();
for ( const auto& cell : cells ) {
LHCb::CaloCellID id = ( cell ).cellID();
int card = ( cell ).cardNumber();
info() << " | " << id << " | " << id.all() << " | " << format( "0x%04X", id.all() ) << " | "
<< ( cell ).cardColumn() << "/" << ( cell ).cardRow() << " | " << ( cell ).cardNumber() << " ( "
<< calo.cardCode( card ) << ") | " << calo.cardCrate( card ) << " | " << calo.cardSlot( card ) << " | "
<< calo.cardToTell1( card ) << " | " << endmsg;
}
} );
}
// ============================================================================
// The End
// ============================================================================
/*****************************************************************************\
* (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 CALODET_CALODETTESTALGORITHM_H
#define CALODET_CALODETTESTALGORITHM_H
// Include files
// from STL
#include <string>
// from CaloKernel
#include "GaudiAlg/GaudiAlgorithm.h"
// CaloDet
#include "CaloDet/DeCalorimeter.h"
/** @class CaloDetTestAlgorithm CaloDetTestAlgorithm.h
*
* Simple Test Algorithm
*
* @author Vanya Belyaev Ivan.Belyaev@itep.ru
* @date 14/12/2001
*/
class CaloDetTestAlgorithm : public GaudiAlgorithm {
public:
/** standard algorithm initialization
* @return status code
*/
StatusCode initialize() override;
/** Standard constructor
* @param name algorithm name
* @param svcloc pointer to service locator
*/
CaloDetTestAlgorithm( const std::string& name, ISvcLocator* svcloc );
private:
std::string m_DetData;
};
// ============================================================================
// The End
// ============================================================================
#endif // CaloDetTestAlgorithm_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