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());
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;
329 execute (
const EventContext& )
340 return StatusCode::SUCCESS;
354 return StatusCode::SUCCESS;
362 return StatusCode::SUCCESS;
370 return StatusCode::SUCCESS;
375#ifdef XAOD_STANDALONE
385 sysExecute (
const EventContext& ctx)
387 return execute (ctx);
411 if (m_hasFileExecute ==
false)
413 ANA_MSG_FATAL (
"called fileExecute(), though it was not registered");
414 return StatusCode::FAILURE;
416 return fileExecute ();
424 if (m_hasBeginInputFile ==
false)
426 ANA_MSG_FATAL (
"called beginInputFile(), though it was not registered");
427 return StatusCode::FAILURE;
429 return beginInputFile ();
437 if (m_hasEndInputFile ==
false)
439 ANA_MSG_FATAL (
"called endInputFile(), though it was not registered");
440 return StatusCode::FAILURE;
442 return endInputFile ();
448 setEvtStore (asg::SgEvent *val_evtStore)
451 throw std::logic_error (
"set evtStore twice on algorithm " +
name());
452 m_evtStore = val_evtStore;
454 val_evtStore->
event());
456 val_evtStore->
event());
464 if (m_histogramWorker)
465 throw std::logic_error (
"set histogram worker twice on algorithm " +
name());
466 m_histogramWorker = val_histogramWorker;
475 throw std::logic_error(
"set tree worker twice on algorithm " +
478 m_treeWorker = val_treeWorker;
487 throw std::logic_error (
"set filter worker twice on algorithm " +
name());
488 m_filterWorker = val_filterWorker;
497 throw std::logic_error (
"set wk twice on algorithm " +
name());
504 hasFileExecute () const noexcept
506 return m_hasFileExecute;
512 hasBeginInputFile () const noexcept
514 return m_hasBeginInputFile;
520 hasEndInputFile () const noexcept
522 return m_hasEndInputFile;
528#ifndef XAOD_STANDALONE
530 handle (
const Incident& inc)
532 if (inc.type() == IncidentType::BeginInputFile)
538 }
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.
virtual::StatusCode execute()
execute this algorithm
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 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()