diff --git a/Generators/McAsciiEventSelector/CMakeLists.txt b/Generators/McAsciiEventSelector/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e25aa068e9163e4720f2f63a26f0b28c80275f67 --- /dev/null +++ b/Generators/McAsciiEventSelector/CMakeLists.txt @@ -0,0 +1,26 @@ +################################################################################ +# Package: McAsciiEventSelector +################################################################################ + +# Declare the package name: +atlas_subdir( McAsciiEventSelector ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + GaudiKernel + PRIVATE + Control/AthenaBaseComps + Control/SGTools + Event/EventInfo + PhysicsAnalysis/TruthParticleID/McParticleKernel ) + +# Component(s) in the package: +atlas_add_component( McAsciiEventSelector + src/*.cxx + src/components/*.cxx + LINK_LIBRARIES GaudiKernel AthenaBaseComps SGTools EventInfo McParticleKernel ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_joboptions( share/*.py ) + diff --git a/Generators/McAsciiEventSelector/cmt/requirements b/Generators/McAsciiEventSelector/cmt/requirements index 115a7e3ee816145c5554d252b531f3c192378d59..2fd99ae25367e1a2e86a4c48311c70e65ead3066 100644 --- a/Generators/McAsciiEventSelector/cmt/requirements +++ b/Generators/McAsciiEventSelector/cmt/requirements @@ -7,10 +7,14 @@ use AtlasPolicy AtlasPolicy-* ## For Gaudi tools, services and objects use GaudiInterface GaudiInterface-* External + +private use SGTools SGTools-* Control +use AthenaBaseComps AthenaBaseComps-* Control use EventInfo EventInfo-* Event - use McParticleKernel McParticleKernel-* PhysicsAnalysis/TruthParticleID +end_private + branches src src/components doc python share diff --git a/Generators/McAsciiEventSelector/src/McAsciiEventSelector.cxx b/Generators/McAsciiEventSelector/src/McAsciiEventSelector.cxx index df10867a35d59264fe506a0929e85039a7bdfe81..58c7a5f46c8b2851547dc7c59e2abd426a23a21c 100644 --- a/Generators/McAsciiEventSelector/src/McAsciiEventSelector.cxx +++ b/Generators/McAsciiEventSelector/src/McAsciiEventSelector.cxx @@ -41,8 +41,8 @@ McAsciiEventSelector::McAsciiEventSelector( const std::string& name, ISvcLocator* svcLoc ) : - Service( name, svcLoc ), - m_msg ( msgSvc(), name ) + AthService( name, svcLoc ), + m_asciiCnvSvc (nullptr) { declareProperty( "InputCollections", m_asciiFileNames, @@ -82,84 +82,51 @@ McAsciiEventSelector::~McAsciiEventSelector() StatusCode McAsciiEventSelector::initialize() { - // configure our MsgStream - m_msg.setLevel( m_outputLevel.value() ); + ATH_MSG_INFO( "Enter McAsciiEventSelector initialization..." ); - m_msg << MSG::INFO << "Enter McAsciiEventSelector initialization..." - << endreq; - - if ( !Service::initialize().isSuccess() ) { - m_msg << MSG::ERROR - << "Unable to initialize base class ::Service !!" - << endreq; - return StatusCode::FAILURE; - } + ATH_CHECK( AthService::initialize() ); setProperties().ignore(); const std::size_t nbrAsciiFiles = m_asciiFileNames.value().size(); if ( nbrAsciiFiles <= 0 ) { - m_msg << MSG::ERROR - << "You need to give at least 1 input file !!" << endreq - << "(Got [" << nbrAsciiFiles << "] file instead !)" - << endreq; + ATH_MSG_ERROR( "You need to give at least 1 input file !!" + << "(Got [" << nbrAsciiFiles << "] file instead !)" ); return StatusCode::FAILURE; } else { - m_msg << MSG::INFO - << "Selector configured to read [" << nbrAsciiFiles << "] file(s)..." - << endreq; + ATH_MSG_INFO( "Selector configured to read [" << nbrAsciiFiles << "] file(s)..." ); } m_asciiFiles.resize( nbrAsciiFiles ); for ( std::size_t i = 0; i != nbrAsciiFiles; ++i ) { const std::string& asciiFileName = m_asciiFileNames.value()[i]; const std::size_t evtMax = McAsciiFileHelper::evtMax( asciiFileName, - m_msg ); - m_msg << MSG::DEBUG << " [" << i << "] : " - << asciiFileName - << " => #evts = " << evtMax - << endreq; + msg() ); + ATH_MSG_DEBUG( " [" << i << "] : " + << asciiFileName + << " => #evts = " << evtMax ); m_asciiFiles[i] = std::make_pair( asciiFileName, evtMax ); } m_curEvtNbr = 0; m_curFile = m_asciiFiles.begin(); - // retrieve the McAsciiCnvSvc - const bool createIf = true; IConversionSvc* cnvSvc = 0; - if ( !service("McAsciiCnvSvc", cnvSvc, createIf).isSuccess() || - 0 == cnvSvc ) { - m_msg << MSG::ERROR - << "Could not retrieve McAsciiCnvSvc !!" - << endreq; + ATH_CHECK( service("McAsciiCnvSvc", cnvSvc, true) ); + m_asciiCnvSvc = dynamic_cast<McAsciiCnvSvc*>( cnvSvc ); + if ( 0 == m_asciiCnvSvc ) { + ATH_MSG_ERROR( "Could not dyn-cast to McAsciiCnvSvc !!" ); return StatusCode::FAILURE; - } else { - m_asciiCnvSvc = dynamic_cast<McAsciiCnvSvc*>( cnvSvc ); - if ( 0 == m_asciiCnvSvc ) { - m_msg << MSG::ERROR - << "Could not dyn-cast to McAsciiCnvSvc !!" - << endreq; - return StatusCode::FAILURE; - } else { - // configure the converter - m_asciiCnvSvc->setInputFile( m_curFile->first ); - } } + + m_asciiCnvSvc->setInputFile( m_curFile->first ); return StatusCode::SUCCESS; } StatusCode McAsciiEventSelector::stop() { - m_msg << MSG::INFO << "Stop..." << endreq; - - const bool createIf = true; - IIncidentSvc* incSvc = 0; - if ( !service("IncidentSvc", incSvc, createIf).isSuccess() || - 0 == incSvc ) { - m_msg << MSG::ERROR - << "Could not retrieve IncidentSvc " - << endreq; - return StatusCode::FAILURE; - } + ATH_MSG_INFO( "Stop..." ); + + ServiceHandle<IIncidentSvc> incSvc ("IncidentSvc", name()); + ATH_CHECK( incSvc.retrieve() ); Incident lastInputIncident(name(), "LastInput"); incSvc->fireIncident(lastInputIncident); @@ -168,7 +135,7 @@ StatusCode McAsciiEventSelector::stop() { StatusCode McAsciiEventSelector::finalize() { - m_msg << MSG::INFO << "Finalize..." << endreq; + ATH_MSG_INFO( "Finalize..." ); return StatusCode::SUCCESS; } @@ -185,7 +152,7 @@ McAsciiEventSelector::queryInterface( const InterfaceID& riid, *ppvInterface = dynamic_cast<IEvtSelector*>(this); } else { // Interface is not directly available : try out a base class - return Service::queryInterface(riid, ppvInterface); + return AthService::queryInterface(riid, ppvInterface); } addRef(); return StatusCode::SUCCESS; @@ -197,15 +164,12 @@ McAsciiEventSelector::queryInterface( const InterfaceID& riid, StatusCode McAsciiEventSelector::next( Context& ctx ) const { - m_msg << MSG::DEBUG << "............. Next Event ............." - << endreq; + ATH_MSG_DEBUG( "............. Next Event ............." ); McAsciiContext* asciiCtx = dynamic_cast<McAsciiContext*>(&ctx); if ( 0 == asciiCtx ) { - m_msg << MSG::ERROR - << "Could not dyn-cast to McAsciiContext !!" - << endreq; + ATH_MSG_ERROR( "Could not dyn-cast to McAsciiContext !!" ); return StatusCode::FAILURE; } @@ -216,13 +180,11 @@ StatusCode McAsciiEventSelector::next( Context& ctx ) const // go to next file ? ++m_curFile; if ( m_curFile == m_asciiFiles.end() ) { - m_msg << MSG::INFO << "EventSelector: End of input" << endreq; + ATH_MSG_INFO( "EventSelector: End of input" ); return StatusCode::FAILURE; } else { - m_msg << MSG::DEBUG - << "switching to next input ASCII file [" - << m_curFile->first << "]..." - << endreq; + ATH_MSG_DEBUG( "switching to next input ASCII file [" + << m_curFile->first << "]..." ); m_curEvtNbr = 0; m_asciiCnvSvc->setInputFile( m_curFile->first ); } @@ -253,8 +215,7 @@ McAsciiEventSelector::previous( Context& ctx ) const McAsciiContext* asciiCtx = dynamic_cast<McAsciiContext*>(&ctx); if ( 0 == asciiCtx ) { - m_msg << MSG::ERROR << "Could not dyn-cast to McAsciiContext !!" - << endreq; + ATH_MSG_ERROR( "Could not dyn-cast to McAsciiContext !!" ); return StatusCode::FAILURE; } @@ -281,9 +242,7 @@ McAsciiEventSelector::previous( Context& ctx, int jump ) const StatusCode McAsciiEventSelector::last( Context& /*ctxt*/ ) const { - m_msg << MSG::ERROR - << "............. Last Event Not Implemented ............." - << endreq; + ATH_MSG_ERROR( "............. Last Event Not Implemented ............." ); return StatusCode::FAILURE; } @@ -294,8 +253,7 @@ McAsciiEventSelector::rewind( Context& ctx ) const McAsciiContext* asciiCtx = dynamic_cast<McAsciiContext*>(&ctx); if ( 0 == asciiCtx ) { - m_msg << MSG::ERROR << "Could not dyn-cast to McAsciiContext !!" - << endreq; + ATH_MSG_ERROR( "Could not dyn-cast to McAsciiContext !!" ); return StatusCode::FAILURE; } @@ -326,8 +284,7 @@ McAsciiEventSelector::createAddress( const Context& refCtx, const McAsciiContext* asciiCtx = dynamic_cast<const McAsciiContext*>(&refCtx); if ( 0 == asciiCtx ) { - m_msg << MSG::ERROR << "Could not dyn-cast to a McAsciiContext !!" - << endreq; + ATH_MSG_ERROR( "Could not dyn-cast to a McAsciiContext !!" ); return StatusCode::FAILURE; } @@ -342,9 +299,7 @@ McAsciiEventSelector::createAddress( const Context& refCtx, StatusCode McAsciiEventSelector::releaseContext( Context*& /*refCtxt*/ ) const { - m_msg << MSG::ERROR - << "............. releaseContext Not Implemented ............." - << endreq; + ATH_MSG_ERROR( "............. releaseContext Not Implemented ............." ); return StatusCode::FAILURE; } @@ -352,9 +307,7 @@ McAsciiEventSelector::releaseContext( Context*& /*refCtxt*/ ) const StatusCode McAsciiEventSelector::resetCriteria( const std::string&, Context& ) const { - m_msg << MSG::ERROR - << "............. resetCriteria Not Implemented ............." - << endreq; + ATH_MSG_ERROR( "............. resetCriteria Not Implemented ............." ); return StatusCode::FAILURE; } diff --git a/Generators/McAsciiEventSelector/src/McAsciiEventSelector.h b/Generators/McAsciiEventSelector/src/McAsciiEventSelector.h index e7cc81f118497623ac7d5127848fb14fc73cdebb..0d81398abd7c63819f291ebe1f840a685f216a3a 100644 --- a/Generators/McAsciiEventSelector/src/McAsciiEventSelector.h +++ b/Generators/McAsciiEventSelector/src/McAsciiEventSelector.h @@ -17,8 +17,8 @@ #include <utility> // for std::pair // Gaudi includes +#include "AthenaBaseComps/AthService.h" #include "GaudiKernel/IEvtSelector.h" -#include "GaudiKernel/Service.h" #include "GaudiKernel/Property.h" #include "GaudiKernel/MsgStream.h" @@ -28,7 +28,7 @@ class ISvcLocator; class McAsciiCnvSvc; class McAsciiEventSelector : virtual public IEvtSelector, - virtual public Service + virtual public AthService { /////////////////////////////////////////////////////////////////// @@ -80,9 +80,6 @@ class McAsciiEventSelector : virtual public IEvtSelector, /////////////////////////////////////////////////////////////////// private: - /// MsgStream instance (a std::cout like with print-out levels) - mutable MsgStream m_msg; - /// Pointer to the converter service McAsciiCnvSvc* m_asciiCnvSvc;