19#include <TEfficiency.h>
28#ifndef XAOD_STANDALONE
29#include <GaudiKernel/IIncidentSvc.h>
30#include <GaudiKernel/ServiceHandle.h>
40 AnaAlgorithm (
const std::string& name,
42#ifndef XAOD_STANDALONE
58 "Name of the stream to put trees into");
67 ~AnaAlgorithm () noexcept
103#ifdef XAOD_STANDALONE
112#ifdef XAOD_STANDALONE
117 throw std::logic_error (
"no evtStore set on algorithm " + name());
123 ::StatusCode AnaAlgorithm ::
124 book (
const TH1& hist)
126 histogramWorker()->addOutput (hist.Clone());
127 return ::StatusCode::SUCCESS;
133 book (
const TEfficiency& hist)
135 histogramWorker()->addOutput (
hist.Clone());
136 return ::StatusCode::SUCCESS;
141 template<> TObject *AnaAlgorithm ::
142 hist<TObject> (
const std::string& name)
const
144 return histogramWorker()->getOutputHist (name);
150 hist2d (
const std::string& name)
const
152 return hist<TH2>(name);
158 hist3d (
const std::string& name)
const
160 return hist<TH3>(name);
165 TEfficiency *AnaAlgorithm ::
166 histeff (
const std::string& name)
const
168 return hist<TEfficiency>(name);
174 histogramWorker ()
const
176 if (!m_histogramWorker)
177 throw std::logic_error (
"no histogram worker set on algorithm " +
name());
178 return m_histogramWorker;
184 book (
const TTree&
tree)
187 ANA_CHECK( treeWorker()->addTree(
tree, m_treeStreamName ) );
188 return ::StatusCode::SUCCESS;
193 TTree *AnaAlgorithm ::
194 tree (
const std::string& name)
const
196 return treeWorker()->getOutputTree( name, m_treeStreamName );
204 if( ! m_treeWorker ) {
205 throw std::logic_error(
"no tree worker set on algorithm " +
name() );
215 return filterWorker()->filterPassed();
221 setFilterPassed (
bool val_filterPassed)
223 filterWorker()->setFilterPassed (val_filterPassed);
229 filterWorker ()
const
232 throw std::logic_error (
"no filter worker set on algorithm " +
name());
233 return m_filterWorker;
242 throw std::logic_error (
"no worker set on algorithm " +
name());
250 requestFileExecute ()
254#ifndef XAOD_STANDALONE
261 incSvc->removeListener(
this, IncidentType::BeginInputFile );
262 incSvc->addListener(
this, IncidentType::BeginInputFile, 0,
true );
265 return StatusCode::SUCCESS;
271 requestBeginInputFile ()
275#ifndef XAOD_STANDALONE
282 incSvc->removeListener(
this, IncidentType::BeginInputFile );
283 incSvc->addListener(
this, IncidentType::BeginInputFile, 0,
true );
286 return StatusCode::SUCCESS;
292 requestEndInputFile ()
296#ifndef XAOD_STANDALONE
303 incSvc->removeListener(
this, IncidentType::EndInputFile );
304 incSvc->addListener(
this, IncidentType::EndInputFile, 0,
true );
307 return StatusCode::SUCCESS;
315 return StatusCode::SUCCESS;
323 return StatusCode::SUCCESS;
331 return StatusCode::SUCCESS;
345 return StatusCode::SUCCESS;
353 return StatusCode::SUCCESS;
361 return StatusCode::SUCCESS;
366#ifdef XAOD_STANDALONE
375 ::StatusCode AnaAlgorithm ::
402 if (m_hasFileExecute ==
false)
404 ANA_MSG_FATAL (
"called fileExecute(), though it was not registered");
405 return StatusCode::FAILURE;
407 return fileExecute ();
415 if (m_hasBeginInputFile ==
false)
417 ANA_MSG_FATAL (
"called beginInputFile(), though it was not registered");
418 return StatusCode::FAILURE;
420 return beginInputFile ();
428 if (m_hasEndInputFile ==
false)
430 ANA_MSG_FATAL (
"called endInputFile(), though it was not registered");
431 return StatusCode::FAILURE;
433 return endInputFile ();
439 setEvtStore (asg::SgTEvent *val_evtStore)
442 throw std::logic_error (
"set evtStore twice on algorithm " +
name());
443 m_evtStore = val_evtStore;
445 val_evtStore->
event());
447 val_evtStore->
event());
455 if (m_histogramWorker)
456 throw std::logic_error (
"set histogram worker twice on algorithm " +
name());
457 m_histogramWorker = val_histogramWorker;
466 throw std::logic_error(
"set tree worker twice on algorithm " +
469 m_treeWorker = val_treeWorker;
478 throw std::logic_error (
"set filter worker twice on algorithm " +
name());
479 m_filterWorker = val_filterWorker;
488 throw std::logic_error (
"set wk twice on algorithm " +
name());
495 hasFileExecute () const noexcept
497 return m_hasFileExecute;
503 hasBeginInputFile () const noexcept
505 return m_hasBeginInputFile;
511 hasEndInputFile () const noexcept
513 return m_hasEndInputFile;
519#ifndef XAOD_STANDALONE
521 handle (
const Incident& inc)
523 if (inc.type() == IncidentType::BeginInputFile)
529 }
else if (inc.type() == IncidentType::EndInputFile)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
void print(char *figname, TCanvas *c1)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
AthHistogramAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
virtual::StatusCode endInputFile()
perform the action for the end of an input file
ConstMetaStorePtr_t inputMetaStore() const
virtual::StatusCode fileExecute()
perform the action exactly once for each file in the dataset
bool m_hasBeginInputFile
the value of hasBeginInputFile
bool m_hasFileExecute
the value of hasFileExecute
MetaStore_t m_outputMetaStore
Object accessing the output metadata store.
MetaStore_t m_inputMetaStore
Object accessing the input metadata store.
ServiceHandle< StoreGateSvc > & MetaStorePtr_t
Type of the metadata store pointer in standalone mode.
bool m_hasEndInputFile
the value of hasEndInputFile
const ServiceHandle< StoreGateSvc > & ConstMetaStorePtr_t
virtual::StatusCode beginInputFile()
perform the action for the beginning of an input file
ConstMetaStorePtr_t outputMetaStore() const
the interface to the filter functions in the algorithm sequence
the interface to histogram storage on the worker
The interface to TTree storage on the worker.
the interface for algorithms to access IWorker
Wrapper for TEvent to make it look like StoreGate.
xAOD::TEvent * event() const
Return the underlying event manager.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.
finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()