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");
106#ifdef XAOD_STANDALONE
111 throw std::logic_error (
"no evtStore set on algorithm " + name());
118 book (
const TH1& hist)
120 histogramWorker()->addOutput (hist.Clone());
121 return ::StatusCode::SUCCESS;
127 book (
const TEfficiency& hist)
129 histogramWorker()->addOutput (
hist.Clone());
130 return ::StatusCode::SUCCESS;
135 template<> TObject *AnaAlgorithm ::
136 hist<TObject> (
const std::string& name)
const
138 return histogramWorker()->getOutputHist (name);
144 hist2d (
const std::string& name)
const
146 return hist<TH2>(name);
152 hist3d (
const std::string& name)
const
154 return hist<TH3>(name);
159 TEfficiency *AnaAlgorithm ::
160 histeff (
const std::string& name)
const
162 return hist<TEfficiency>(name);
168 histogramWorker ()
const
170 if (!m_histogramWorker)
171 throw std::logic_error (
"no histogram worker set on algorithm " +
name());
172 return m_histogramWorker;
178 book (
const TTree&
tree)
181 ANA_CHECK( treeWorker()->addTree(
tree, m_treeStreamName ) );
182 return ::StatusCode::SUCCESS;
187 TTree *AnaAlgorithm ::
188 tree (
const std::string& name)
const
190 return treeWorker()->getOutputTree( name, m_treeStreamName );
198 if( ! m_treeWorker ) {
199 throw std::logic_error(
"no tree worker set on algorithm " +
name() );
209 return filterWorker()->filterPassed();
215 setFilterPassed (
bool val_filterPassed)
217 filterWorker()->setFilterPassed (val_filterPassed);
223 filterWorker ()
const
226 throw std::logic_error (
"no filter worker set on algorithm " +
name());
227 return m_filterWorker;
236 throw std::logic_error (
"no worker set on algorithm " +
name());
244 requestFileExecute ()
248#ifndef XAOD_STANDALONE
255 incSvc->removeListener(
this, IncidentType::BeginInputFile );
256 incSvc->addListener(
this, IncidentType::BeginInputFile, 0,
true );
259 return StatusCode::SUCCESS;
265 requestBeginInputFile ()
269#ifndef XAOD_STANDALONE
276 incSvc->removeListener(
this, IncidentType::BeginInputFile );
277 incSvc->addListener(
this, IncidentType::BeginInputFile, 0,
true );
280 return StatusCode::SUCCESS;
286 requestEndInputFile ()
290#ifndef XAOD_STANDALONE
297 incSvc->removeListener(
this, IncidentType::EndInputFile );
298 incSvc->addListener(
this, IncidentType::EndInputFile, 0,
true );
301 return StatusCode::SUCCESS;
309 return StatusCode::SUCCESS;
317 return StatusCode::SUCCESS;
323 execute (
const EventContext& )
334 return StatusCode::SUCCESS;
348 return StatusCode::SUCCESS;
356 return StatusCode::SUCCESS;
364 return StatusCode::SUCCESS;
369#ifdef XAOD_STANDALONE
379 sysExecute (
const EventContext& ctx)
381 return execute (ctx);
405 if (m_hasFileExecute ==
false)
407 ANA_MSG_FATAL (
"called fileExecute(), though it was not registered");
408 return StatusCode::FAILURE;
410 return fileExecute ();
418 if (m_hasBeginInputFile ==
false)
420 ANA_MSG_FATAL (
"called beginInputFile(), though it was not registered");
421 return StatusCode::FAILURE;
423 return beginInputFile ();
431 if (m_hasEndInputFile ==
false)
433 ANA_MSG_FATAL (
"called endInputFile(), though it was not registered");
434 return StatusCode::FAILURE;
436 return endInputFile ();
442 setEvtStore (asg::SgEvent *val_evtStore)
445 throw std::logic_error (
"set evtStore twice on algorithm " +
name());
446 m_evtStore = val_evtStore;
448 val_evtStore->
event());
450 val_evtStore->
event());
458 if (m_histogramWorker)
459 throw std::logic_error (
"set histogram worker twice on algorithm " +
name());
460 m_histogramWorker = val_histogramWorker;
469 throw std::logic_error(
"set tree worker twice on algorithm " +
472 m_treeWorker = val_treeWorker;
481 throw std::logic_error (
"set filter worker twice on algorithm " +
name());
482 m_filterWorker = val_filterWorker;
491 throw std::logic_error (
"set wk twice on algorithm " +
name());
498 hasFileExecute () const noexcept
500 return m_hasFileExecute;
506 hasBeginInputFile () const noexcept
508 return m_hasBeginInputFile;
514 hasEndInputFile () const noexcept
516 return m_hasEndInputFile;
522#ifndef XAOD_STANDALONE
524 handle (
const Incident& inc)
526 if (inc.type() == IncidentType::BeginInputFile)
532 }
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
const ServiceHandle< StoreGateSvc > & ConstMetaStorePtr_t
bool m_hasBeginInputFile
the value of hasBeginInputFile
bool m_hasFileExecute
the value of hasFileExecute
MetaStore_t m_outputMetaStore
Object accessing the output metadata store.
ServiceHandle< StoreGateSvc > & MetaStorePtr_t
Type of the metadata store pointer in Athena.
MetaStore_t m_inputMetaStore
Object accessing the input metadata store.
virtual::StatusCode execute()
execute this algorithm
bool m_hasEndInputFile
the value of hasEndInputFile
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 Event to make it look like StoreGate.
xAOD::Event * 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()