Skip to content

Commit

Permalink
refactor: rename Arbiter->Iguana and organize main.cc (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Nov 21, 2023
1 parent 653bedf commit 4b06b01
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/iguana/Arbiter.cc → src/iguana/Iguana.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "Arbiter.h"
#include "Iguana.h"

namespace iguana {

Arbiter::Arbiter() {
Iguana::Iguana() {
algo_map.insert({clas12_EventBuilderFilter, std::make_shared<clas12::EventBuilderFilter>()});
}

Expand Down
10 changes: 5 additions & 5 deletions src/iguana/Arbiter.h → src/iguana/Iguana.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@

namespace iguana {

class Arbiter {
class Iguana {

public:
Arbiter();
~Arbiter() {}
Iguana();
~Iguana() {}

// TODO: avoid listing the algos
// TODO: who should own the algorithm instances: Arbiter or the user?
// TODO: who should own the algorithm instances: Iguana or the user?
enum algo {
clas12_EventBuilderFilter
};

// TODO: make private
std::unordered_map<Arbiter::algo, std::shared_ptr<Algorithm>> algo_map;
std::unordered_map<Iguana::algo, std::shared_ptr<Algorithm>> algo_map;

};
}
4 changes: 2 additions & 2 deletions src/iguana/meson.build
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
iguana_headers = [
'Arbiter.h',
'Iguana.h',
]

iguana_sources = [
'Arbiter.cc',
'Iguana.cc',
]

iguana_lib = shared_library(
Expand Down
49 changes: 29 additions & 20 deletions src/tests/main.cc
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
#include "iguana/Arbiter.h"
#include "iguana/Iguana.h"
#include <hipo4/reader.h>

int main(int argc, char **argv) {

std::string inFile = "data.hipo";
if(argc > 1) inFile = std::string(argv[1]);
// parse arguments
int argi = 1;
std::string inFileName = argc > argi ? std::string(argv[argi++]) : "data.hipo";
int numEvents = argc > argi ? std::stoi(argv[argi++]) : 3;

// start iguana
/* TODO: will be similified when we have more sugar in `iguana::Iguana`; until then we
* use the test algorithm directly
*/
iguana::Iguana I;
auto algo = I.algo_map.at(iguana::Iguana::clas12_EventBuilderFilter);
algo->Start();

/////////////////////////////////////////////////////

// read input file
hipo::reader reader;
reader.open(inFile.c_str());
reader.open(inFileName.c_str());

// get bank schema
/* TODO: users should not have to do this; this is a workaround until
* the pattern `hipo::event::getBank("REC::Particle")` is possible
*/
hipo::dictionary factory;
reader.readDictionary(factory);
// factory.show();

hipo::bank particleBank(factory.getSchema("REC::Particle"));
hipo::event event;

iguana::Arbiter arb;
auto algo = arb.algo_map.at(iguana::Arbiter::clas12_EventBuilderFilter);
algo->Start();

int count = 0;
while(reader.next()) {
if(count > 3) break;
reader.read(event);
// event loop
hipo::event event;
int iEvent = 0;
while(reader.next(event) && (iEvent++ < numEvents || numEvents == 0)) {
event.getStructure(particleBank);

auto resultBank = algo->Run({{"particles", particleBank}});

fmt::print("BEFORE -> AFTER: {} -> {}\n", particleBank.getRows(), resultBank.at("particles").getRows());

count++;
}

/////////////////////////////////////////////////////

algo->Stop();
return 0;
}

0 comments on commit 4b06b01

Please sign in to comment.