All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
core::ProcessorBlock Class Reference

A set of Processors. More...

#include <ProcessorBlock.hh>

Public Member Functions

 ProcessorBlock ()
 
virtual ~ProcessorBlock ()
 
virtual void AddProcessor (ProcessorBase *processor, fhicl::ParameterSet *config)
 
virtual void ProcessFiles (std::vector< std::string > filenames)
 
virtual void DeleteProcessors ()
 

Protected Attributes

std::vector< std::pair
< ProcessorBase
*, fhicl::ParameterSet * > > 
fProcessors
 

Detailed Description

A set of Processors.

Definition at line 25 of file ProcessorBlock.hh.

Constructor & Destructor Documentation

core::ProcessorBlock::ProcessorBlock ( )

Constructor

Definition at line 9 of file ProcessorBlock.cxx.

9 {}
core::ProcessorBlock::~ProcessorBlock ( )
virtual

Destructor

Definition at line 12 of file ProcessorBlock.cxx.

12 {}

Member Function Documentation

void core::ProcessorBlock::AddProcessor ( ProcessorBase processor,
fhicl::ParameterSet *  config 
)
virtual

Add a processor to the block.

Note that the ProcessorBlock takes ownership of the Processor.

Parameters
processorThe processor
configThe configuration, if any

Definition at line 15 of file ProcessorBlock.cxx.

16  {
17  fProcessors.push_back({processor, config});
18 }
std::vector< std::pair< ProcessorBase *, fhicl::ParameterSet * > > fProcessors
void core::ProcessorBlock::DeleteProcessors ( )
virtual

Delete all processors owned by the block.

Definition at line 76 of file ProcessorBlock.cxx.

76  {
77  for (auto it : fProcessors) {
78  delete it.first;
79  }
80 }
std::vector< std::pair< ProcessorBase *, fhicl::ParameterSet * > > fProcessors
void core::ProcessorBlock::ProcessFiles ( std::vector< std::string >  filenames)
virtual

Process a set of files.

Parameters
filenamesA list of art ROOT files to process

Definition at line 21 of file ProcessorBlock.cxx.

21  {
22  // Setup
23  for (auto it : fProcessors) {
24  it.first->Setup(it.second);
25  it.first->Initialize(it.second);
26  }
27 
28  // Event loop
29  for (gallery::Event ev(filenames); !ev.atEnd(); ev.next()) {
30  for (auto it : fProcessors) {
31  ProcessorBase* p = it.first;
32  p->BuildEventTree(ev);
33  p->SetupServices(ev);
34 
35  bool accept = p->ProcessEvent(ev, p->fEvent->truth, *p->fReco);
36 
37  // Set reco index
38  for (size_t i=0; i<p->fReco->size(); i++) {
39  p->fReco->at(i).index = i;
40  }
41  p->fEvent->nreco = p->fReco->size();
42 
43  if (accept) {
44  p->FillTree();
45 
46  // For each reco event, fill the reco output tree
47  p->fRecoEvent->experiment = p->fEvent->experiment;
48  p->fRecoEvent->metadata = p->fEvent->metadata;
49 
50  for (auto const& reco : *p->fReco) {
51  p->fRecoEvent->reco = reco;
52 
53  // Copy the associated truth interaction, if any
54  p->fRecoEvent->truth.resize(0);
55  int truthidx = p->fRecoEvent->reco.truth_index;
56  if (truthidx >= 0 && truthidx < p->fEvent->truth.size()) {
57  p->fRecoEvent->truth.push_back(p->fEvent->truth.at(truthidx));
58  }
59 
60  p->FillRecoTree();
61  }
62  }
63 
64  p->EventCleanup();
65  }
66  }
67 
68  // Finalize
69  for (auto it : fProcessors) {
70  it.first->Finalize();
71  it.first->Teardown();
72  }
73 }
std::vector< std::pair< ProcessorBase *, fhicl::ParameterSet * > > fProcessors
pdgs p
Definition: selectors.fcl:22
process_name standard_reco_uboone reco

Member Data Documentation

std::vector<std::pair<ProcessorBase*, fhicl::ParameterSet*> > core::ProcessorBlock::fProcessors
protected

Processors and their configurations.

Definition at line 55 of file ProcessorBlock.hh.


The documentation for this class was generated from the following files: