Skip to content

Commit

Permalink
Removed Trie. Use the trie in custom_cpp_utilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
dchao committed Sep 18, 2014
1 parent b4da9ae commit f662901
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 160 deletions.
4 changes: 4 additions & 0 deletions create_database/tuple_reader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ INCFLAGS += -I$(BOOST_ROOT)
INCFLAGS += $(shell root-config --cflags)
LDFLAGS += $(shell root-config --libs)

# custom cpp utilities
CUSTOM_CPP_UTIL_ROOT = /Users/dchao/bdtaunu/v4/custom_cpp_utilities
INCFLAGS += -I$(CUSTOM_CPP_UTIL_ROOT)

# particle data file
PDT_FILE_PATHNAME = $(shell pwd | sed 's/\/[^/]*$$//')/tuple_reader/meta/pdt.dat
CXXFLAGS += -D__PDT_FILE_PATHNAME='"$(PDT_FILE_PATHNAME)"'
Expand Down
69 changes: 35 additions & 34 deletions create_database/tuple_reader/McBTypeCatalogue.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <vector>
#include <algorithm>
#include <cstdlib>

#include "McBTypeCatalogue.h"

Expand All @@ -22,184 +23,184 @@ McBTypeCatalogue::search_catalogue(std::vector<int> lund_list) const {
if (hasX) word.push_back(Alphabet::X);
word.push_back(Alphabet::null);

return trie.search_word(word);
return catalogue.find(word);
}

void McBTypeCatalogue::RegisterDecays() {

// nu_tau branch
trie.add_word({
catalogue.insert({
Alphabet::nu_tau, Alphabet::tau,
Alphabet::null
}, BType::SL);

trie.add_word({
catalogue.insert({
Alphabet::nu_tau, Alphabet::tau, Alphabet::D,
Alphabet::null
}, BType::Dtau);

trie.add_word({
catalogue.insert({
Alphabet::nu_tau, Alphabet::tau, Alphabet::Dstar,
Alphabet::null
}, BType::Dstartau);

trie.add_word({
catalogue.insert({
Alphabet::nu_tau, Alphabet::tau, Alphabet::Dstarstar,
Alphabet::null
}, BType::Dstarstar_res);

trie.add_word({
catalogue.insert({
Alphabet::nu_tau, Alphabet::tau, Alphabet::X,
Alphabet::null
}, BType::SL);

trie.add_word({
catalogue.insert({
Alphabet::nu_tau, Alphabet::tau,
Alphabet::D, Alphabet::X,
Alphabet::null
}, BType::Dstarstar_nonres);

trie.add_word({
catalogue.insert({
Alphabet::nu_tau, Alphabet::tau,
Alphabet::Dstar, Alphabet::X,
Alphabet::null
}, BType::Dstarstar_nonres);

trie.add_word({
catalogue.insert({
Alphabet::nu_tau, Alphabet::tau,
Alphabet::Dstarstar, Alphabet::X,
Alphabet::null
}, BType::Dstarstar_res);

// nu_ell branch
trie.add_word({
catalogue.insert({
Alphabet::nu_ell, Alphabet::ell,
Alphabet::null
}, BType::SL);

trie.add_word({
catalogue.insert({
Alphabet::nu_ell, Alphabet::ell, Alphabet::D,
Alphabet::null
}, BType::Dl);

trie.add_word({
catalogue.insert({
Alphabet::nu_ell, Alphabet::ell, Alphabet::Dstar,
Alphabet::null
}, BType::Dstarl);

trie.add_word({
catalogue.insert({
Alphabet::nu_ell, Alphabet::ell, Alphabet::Dstarstar,
Alphabet::null
}, BType::Dstarstar_res);

trie.add_word({
catalogue.insert({
Alphabet::nu_ell, Alphabet::ell, Alphabet::X,
Alphabet::null
}, BType::SL);

trie.add_word({
catalogue.insert({
Alphabet::nu_ell, Alphabet::ell,
Alphabet::D, Alphabet::X,
Alphabet::null
}, BType::Dstarstar_nonres);

trie.add_word({
catalogue.insert({
Alphabet::nu_ell, Alphabet::ell,
Alphabet::Dstar, Alphabet::X,
Alphabet::null
}, BType::Dstarstar_nonres);

trie.add_word({
catalogue.insert({
Alphabet::nu_ell, Alphabet::ell,
Alphabet::Dstarstar, Alphabet::X,
Alphabet::null
}, BType::Dstarstar_res);

// hadron branch
trie.add_word({
catalogue.insert({
Alphabet::X,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::D, Alphabet::X,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::Dstar, Alphabet::X,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::Dstarstar, Alphabet::X,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::D, Alphabet::D,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::D, Alphabet::Dstar,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::D, Alphabet::Dstarstar,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::Dstar, Alphabet::Dstar,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::Dstar, Alphabet::Dstarstar,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::Dstarstar, Alphabet::Dstarstar,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::D, Alphabet::D, Alphabet::X,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::D, Alphabet::Dstar, Alphabet::X,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::D, Alphabet::Dstarstar, Alphabet::X,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::Dstar, Alphabet::Dstar, Alphabet::X,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::Dstar, Alphabet::Dstarstar, Alphabet::X,
Alphabet::null
}, BType::Had);

trie.add_word({
catalogue.insert({
Alphabet::Dstarstar, Alphabet::Dstarstar, Alphabet::X,
Alphabet::null
}, BType::Had);

}

McBTypeCatalogue::Alphabet McBTypeCatalogue::LundToAlphabet(int lund) const {
switch (abs(lund)) {
switch (std::abs(lund)) {
case 12: // nu_e
case 14: // nu_mu
return Alphabet::nu_ell;
Expand Down
4 changes: 2 additions & 2 deletions create_database/tuple_reader/McBTypeCatalogue.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <vector>

#include "Trie.h"
#include <custom_cpp_utilities/trie.h>

class McBTypeCatalogue {

Expand All @@ -27,7 +27,7 @@ class McBTypeCatalogue {
void RegisterDecays();
Alphabet LundToAlphabet(int lund) const;

bdtaunu::Trie<Alphabet, BType, Alphabet::null, BType::null> trie;
custom_cpp_utilities::trie<Alphabet, BType, Alphabet::null, BType::null> catalogue;

};

Expand Down
48 changes: 24 additions & 24 deletions create_database/tuple_reader/RecoDTypeCatalogue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RecoDTypeCatalogue::search_d_catalogue(std::vector<int> lund_list) const {
for (auto l : lund_list) word.push_back(LundToAlphabet(l));
std::sort(word.begin(), word.end());
word.push_back(Alphabet::null);
return d_trie.search_word(word);
return d_catalogue.find(word);
}

RecoDTypeCatalogue::DstarType
Expand All @@ -20,109 +20,109 @@ RecoDTypeCatalogue::search_dstar_catalogue(std::vector<int> lund_list) const {
for (auto l : lund_list) word.push_back(LundToAlphabet(l));
std::sort(word.begin(), word.end());
word.push_back(Alphabet::null);
return dstar_trie.search_word(word);
return dstar_catalogue.find(word);
}

void RecoDTypeCatalogue::RegisterDecays() {

// D trie
d_trie.add_word({
// D catalogue
d_catalogue.insert({
Alphabet::Dc, Alphabet::K, Alphabet::pi, Alphabet::pi,
Alphabet::null
}, DType::Dc_Kpipi);

d_trie.add_word({
d_catalogue.insert({
Alphabet::Dc, Alphabet::K, Alphabet::pi, Alphabet::pi, Alphabet::pi0,
Alphabet::null
}, DType::Dc_Kpipipi0);

d_trie.add_word({
d_catalogue.insert({
Alphabet::Dc, Alphabet::Ks, Alphabet::K,
Alphabet::null
}, DType::Dc_KsK);

d_trie.add_word({
d_catalogue.insert({
Alphabet::Dc, Alphabet::Ks, Alphabet::pi,
Alphabet::null
}, DType::Dc_Kspi);

d_trie.add_word({
d_catalogue.insert({
Alphabet::Dc, Alphabet::Ks, Alphabet::pi, Alphabet::pi0,
Alphabet::null
}, DType::Dc_Kspipi0);

d_trie.add_word({
d_catalogue.insert({
Alphabet::Dc, Alphabet::Ks, Alphabet::pi, Alphabet::pi, Alphabet::pi,
Alphabet::null
}, DType::Dc_Kspipipi);

d_trie.add_word({
d_catalogue.insert({
Alphabet::Dc, Alphabet::K, Alphabet::K, Alphabet::pi,
Alphabet::null
}, DType::Dc_KKpi);

d_trie.add_word({
d_catalogue.insert({
Alphabet::D0, Alphabet::K, Alphabet::pi,
Alphabet::null
}, DType::D0_Kpi);

d_trie.add_word({
d_catalogue.insert({
Alphabet::D0, Alphabet::K, Alphabet::pi, Alphabet::pi0,
Alphabet::null
}, DType::D0_Kpipi0);

d_trie.add_word({
d_catalogue.insert({
Alphabet::D0, Alphabet::K, Alphabet::pi, Alphabet::pi, Alphabet::pi,
Alphabet::null
}, DType::D0_Kpipipi);

d_trie.add_word({
d_catalogue.insert({
Alphabet::D0, Alphabet::K, Alphabet::pi, Alphabet::pi, Alphabet::pi, Alphabet::pi0,
Alphabet::null
}, DType::D0_Kpipipipi0);

d_trie.add_word({
d_catalogue.insert({
Alphabet::D0, Alphabet::Ks, Alphabet::pi, Alphabet::pi,
Alphabet::null
}, DType::D0_Kspipi);

d_trie.add_word({
d_catalogue.insert({
Alphabet::D0, Alphabet::Ks, Alphabet::pi, Alphabet::pi, Alphabet::pi0,
Alphabet::null
}, DType::D0_Kspipipi0);

d_trie.add_word({
d_catalogue.insert({
Alphabet::D0, Alphabet::Ks, Alphabet::pi0,
Alphabet::null
}, DType::D0_Kspi0);

d_trie.add_word({
d_catalogue.insert({
Alphabet::D0, Alphabet::K, Alphabet::K,
Alphabet::null
}, DType::D0_KK);

// Dstar trie
dstar_trie.add_word({
// Dstar catalogue
dstar_catalogue.insert({
Alphabet::Dstar0, Alphabet::D0, Alphabet::pi0,
Alphabet::null
}, DstarType::Dstar0_D0pi0);

dstar_trie.add_word({
dstar_catalogue.insert({
Alphabet::Dstar0, Alphabet::D0, Alphabet::gamma,
Alphabet::null
}, DstarType::Dstar0_D0gamma);

dstar_trie.add_word({
dstar_catalogue.insert({
Alphabet::Dstarc, Alphabet::D0, Alphabet::pi,
Alphabet::null
}, DstarType::Dstarc_D0pi);

dstar_trie.add_word({
dstar_catalogue.insert({
Alphabet::Dstarc, Alphabet::Dc, Alphabet::pi0,
Alphabet::null
}, DstarType::Dstarc_Dcpi0);

dstar_trie.add_word({
dstar_catalogue.insert({
Alphabet::Dstarc, Alphabet::Dc, Alphabet::gamma,
Alphabet::null
}, DstarType::Dstarc_Dcgamma);
Expand Down
Loading

0 comments on commit f662901

Please sign in to comment.