diff --git a/create_database/tuple_reader/RecoIndexer.cc b/create_database/tuple_reader/GraphDef.cc similarity index 86% rename from create_database/tuple_reader/RecoIndexer.cc rename to create_database/tuple_reader/GraphDef.cc index 8e807b2..3bfaff9 100644 --- a/create_database/tuple_reader/RecoIndexer.cc +++ b/create_database/tuple_reader/GraphDef.cc @@ -1,16 +1,16 @@ -#include "RecoIndexer.h" #include "BDtaunuDef.h" +#include "GraphDef.h" #include #include #include #include -RecoIndexer::RecoIndexer() : +RecoGraph::RecoIndexer::RecoIndexer() : nY(0), nB(0), nD(0), nC(0), nh(0), nl(0), ngamma(0) {}; -RecoIndexer::RecoIndexer( +RecoGraph::RecoIndexer::RecoIndexer( int _nY, int _nB, int _nD, int _nC, int _nh, int _nl, int _ngamma) : nY(_nY), nB(_nB), nD(_nD), nC(_nC), @@ -23,7 +23,7 @@ RecoIndexer::RecoIndexer( // C candidates: ... continue pattern. // h candidates: ... continue pattern. // gamma candidates: ... continue pattern. -int RecoIndexer::operator()(int lund, int idx) const { +int RecoGraph::RecoIndexer::operator()(int lund, int idx) const { int abslund = std::abs(lund); switch (abslund) { @@ -54,7 +54,7 @@ int RecoIndexer::operator()(int lund, int idx) const { return -1; } -void RecoIndexer::clear() { +void RecoGraph::RecoIndexer::clear() { nY = 0; nB = 0; nD = 0; @@ -64,7 +64,7 @@ void RecoIndexer::clear() { ngamma = 0; } -void RecoIndexer::set(std::initializer_list l) { +void RecoGraph::RecoIndexer::set(std::initializer_list l) { assert(l.size() == 7); diff --git a/create_database/tuple_reader/GraphDef.h b/create_database/tuple_reader/GraphDef.h index e38c9c7..36625b3 100644 --- a/create_database/tuple_reader/GraphDef.h +++ b/create_database/tuple_reader/GraphDef.h @@ -1,8 +1,11 @@ #ifndef __GRAPHDEF_H_ #define __GRAPHDEF_H_ +#include #include +#include "BDtaunuDef.h" + namespace boost { enum vertex_lund_id_t { vertex_lund_id }; BOOST_INSTALL_PROPERTY(vertex, lund_id); @@ -33,8 +36,85 @@ typedef typename boost::property_map::type LundI typedef typename boost::property_map::type RecoIndexPropertyMap; typedef typename boost::property_map::type BlockIndexPropertyMap; +struct RecoLepton { + int l_block_idx = -1; + int pi_block_idx = -1; + int tau_mode = static_cast(bdtaunu::TauType::null); +}; + +struct RecoD { + RecoD() = default; + int D_mode = static_cast(bdtaunu::RecoDTypeCatalogue::DType::null); + int Dstar_mode = static_cast(bdtaunu::RecoDTypeCatalogue::DstarType::NoDstar); +}; + +struct RecoB { + RecoB() = default; + int flavor = static_cast(bdtaunu::BFlavor::null); + RecoD *D = nullptr; + RecoLepton *Lepton = nullptr; +}; + +struct RecoY { + RecoY() = default; + RecoB *tagB = nullptr; + RecoB *sigB = nullptr; +}; + +/** @brief This class assigns a unique index to each reconstructed particle. + * + * @detail + * # Motivation + * The need for every reconstructed particle of the event to have a unique + * index arises primarily in accessessing vertex information in the BGL graph. + * However, such an indexing is more convenient to use than the existing + * BtaTupleMaker indexing. + * + * # Implementation + * This class builds a hash function from the reco particle's index in the + * BtaTupleMaker block to a unique index. + * + * See RecoIndexer.cc for details. + */ +class RecoIndexer { + + private: + int nY, nB, nD, nC, nh, nl, ngamma; + + public: + RecoIndexer(); + RecoIndexer(int _nY, int _nB, int _nD, + int _nC, int _nh, int _nl, int _ngamma); + RecoIndexer(const RecoIndexer &r) = default; + RecoIndexer &operator=(const RecoIndexer &r) = default; + ~RecoIndexer() {}; + + //! Given the lundId and block index, return the unique reco index. + int operator()(int lund, int idx) const; + + //! Return total number of reco particles in this event. + int total() const { return nY + nB + nD + nC + nh + nl + ngamma; } + + //! Set the total number of each type of reco particle. + /*! The list order is { nY, nB, nD, nC, nh, nl, ngamma } */ + void set(std::initializer_list l); + + //! Clear cache. + void clear(); +}; + } + + + + + + + + + + namespace boost { enum vertex_mc_index_t { vertex_mc_index }; BOOST_INSTALL_PROPERTY(vertex, mc_index); @@ -56,6 +136,25 @@ typedef typename boost::graph_traits::adjacency_iterator AdjacencyIterato typedef typename boost::property_map::type LundIdPropertyMap; typedef typename boost::property_map::type McIndexPropertyMap; +struct McTau { + McTau() = default; + int mc_type = static_cast(bdtaunu::TauMcType::null); +}; + +struct McB { + McB() = default; + int flavor = static_cast(bdtaunu::BFlavor::null); + int mc_type = static_cast(bdtaunu::McBTypeCatalogue::BMcType::null); + McTau *tau = nullptr; +}; + +struct McY { + McY() = default; + bool isBBbar = true; + McB *B1 = nullptr; + McB *B2 = nullptr; +}; + } #endif diff --git a/create_database/tuple_reader/Makefile b/create_database/tuple_reader/Makefile index 5e328d1..56a05fd 100644 --- a/create_database/tuple_reader/Makefile +++ b/create_database/tuple_reader/Makefile @@ -13,10 +13,10 @@ LIBNAME = libTupleReader.so PKG_LIBPATH = lib # package Contents -SOURCES = BDtaunuDef.cc \ +SOURCES = BDtaunuDef.cc GraphDef.cc \ BDtaunuHelpers.cc UpsilonCandidate.cc \ RootReader.cc BDtaunuReader.cc BDtaunuMcReader.cc \ - RecoIndexer.cc RecoGraphVisitors.cc RecoGraphManager.cc \ + RecoGraphVisitors.cc RecoGraphManager.cc \ McGraphManager.cc McGraphVisitors.cc # Dependencies diff --git a/create_database/tuple_reader/McGraphManager.cc b/create_database/tuple_reader/McGraphManager.cc index 9c55fdf..0b2a6f1 100644 --- a/create_database/tuple_reader/McGraphManager.cc +++ b/create_database/tuple_reader/McGraphManager.cc @@ -8,7 +8,6 @@ #include "BDtaunuDef.h" #include "GraphDef.h" -#include "Particles.h" #include "BDtaunuMcReader.h" #include "McGraphManager.h" #include "BDtaunuGraphWriter.h" diff --git a/create_database/tuple_reader/McGraphManager.h b/create_database/tuple_reader/McGraphManager.h index d4e04e4..ef5e745 100644 --- a/create_database/tuple_reader/McGraphManager.h +++ b/create_database/tuple_reader/McGraphManager.h @@ -7,7 +7,6 @@ #include "GraphManager.h" #include "GraphDef.h" -#include "Particles.h" #include "McGraphVisitors.h" class BDtaunuMcReader; @@ -112,13 +111,13 @@ class McGraphManager : public GraphManager { void clear(); //! Returns pointer to the MC truth \f$\Upsilon(4S)\f$ if it exists, nullptr otherwise. - const McY* get_mcY() const; + const McGraph::McY* get_mcY() const; //! Returns pointer to one of the MC truth \f$B\f$ if it exists, nullptr otherwise. - const McB* get_mcB1() const; + const McGraph::McB* get_mcB1() const; //! Returns pointer to the other MC truth \f$B\f$ if it exists, nullptr otherwise. - const McB* get_mcB2() const; + const McGraph::McB* get_mcB2() const; private: @@ -138,9 +137,9 @@ class McGraphManager : public GraphManager { void ClearGraph(); // Graph analysis - std::map Y_map; - std::map B_map; - std::map Tau_map; + std::map Y_map; + std::map B_map; + std::map Tau_map; void ClearAnalysis(); }; diff --git a/create_database/tuple_reader/McGraphVisitors.cc b/create_database/tuple_reader/McGraphVisitors.cc index 77eba01..60ca695 100644 --- a/create_database/tuple_reader/McGraphVisitors.cc +++ b/create_database/tuple_reader/McGraphVisitors.cc @@ -4,7 +4,6 @@ #include "BDtaunuDef.h" #include "GraphDef.h" -#include "Particles.h" #include "McGraphVisitors.h" #include "McGraphManager.h" @@ -70,7 +69,7 @@ void McGraphDfsVisitor::AnalyzeY(const Vertex &u, const Graph &g) { // Analyze B meson. The quantities computed are: // 1. B flavor. // 2. Pointer to daughter tau. -// 3. MC type. See Particles.h. +// 3. MC type. See GraphDef.h. void McGraphDfsVisitor::AnalyzeB(const Vertex &u, const Graph &g) { McB mcB; @@ -98,7 +97,7 @@ void McGraphDfsVisitor::AnalyzeB(const Vertex &u, const Graph &g) { } // Analyze tau. The quantities computed are: -// 1. MC type. See Particles.h. +// 1. MC type. See GraphDef.h. void McGraphDfsVisitor::AnalyzeTau(const Vertex &u, const Graph &g) { McTau mcTau; diff --git a/create_database/tuple_reader/Particles.h b/create_database/tuple_reader/Particles.h deleted file mode 100644 index d16e5fd..0000000 --- a/create_database/tuple_reader/Particles.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _PARTICLES_H_ -#define _PARTICLES_H_ - -#include "BDtaunuDef.h" -#include "GraphDef.h" - -/** @file Particles.h - * Information of specific types of particles that are computed - * during graph traversal (see RecoGraphManager.h or McGraphManager.h). - */ - -struct RecoB; -struct RecoD; -struct RecoLepton; - -struct RecoY { - RecoY() = default; - RecoB *tagB = nullptr; - RecoB *sigB = nullptr; -}; - -struct RecoB { - RecoB() = default; - int flavor = static_cast(bdtaunu::BFlavor::null); - RecoD *D = nullptr; - RecoLepton *Lepton = nullptr; -}; - -struct RecoD { - RecoD() = default; - int D_mode = static_cast(bdtaunu::RecoDTypeCatalogue::DType::null); - int Dstar_mode = static_cast(bdtaunu::RecoDTypeCatalogue::DstarType::NoDstar); -}; - -struct RecoLepton { - int l_block_idx = -1; - int pi_block_idx = -1; - int tau_mode = static_cast(bdtaunu::TauType::null); -}; - -struct McB; -struct McTau; - -struct McY { - McY() = default; - bool isBBbar = true; - McB *B1 = nullptr; - McB *B2 = nullptr; -}; - -struct McB { - McB() = default; - int flavor = static_cast(bdtaunu::BFlavor::null); - int mc_type = static_cast(bdtaunu::McBTypeCatalogue::BMcType::null); - McTau *tau = nullptr; -}; - -struct McTau { - McTau() = default; - int mc_type = static_cast(bdtaunu::TauMcType::null); -}; - -#endif diff --git a/create_database/tuple_reader/RecoGraphManager.cc b/create_database/tuple_reader/RecoGraphManager.cc index 394f519..602b241 100644 --- a/create_database/tuple_reader/RecoGraphManager.cc +++ b/create_database/tuple_reader/RecoGraphManager.cc @@ -7,7 +7,6 @@ #include #include "GraphDef.h" -#include "Particles.h" #include "BDtaunuReader.h" #include "RecoGraphManager.h" #include "BDtaunuGraphWriter.h" @@ -127,7 +126,7 @@ void RecoGraphManager::AddCandidates( // Each vertex has the following information attached: // // 1. vertex_reco_index: The unique reco particle index assigned by - // reco_indxer (See RecoIndexer.h). This tracks which + // reco_indexer (See GraphDef.h). This tracks which // vertex a particlar reco particle is associated with. // // 2. vertex_block_index: This is the index of where this reco particle diff --git a/create_database/tuple_reader/RecoGraphManager.h b/create_database/tuple_reader/RecoGraphManager.h index b6deeef..6e29e30 100644 --- a/create_database/tuple_reader/RecoGraphManager.h +++ b/create_database/tuple_reader/RecoGraphManager.h @@ -5,10 +5,8 @@ #include #include -#include "GraphManager.h" #include "GraphDef.h" -#include "Particles.h" -#include "RecoIndexer.h" +#include "GraphManager.h" #include "RecoGraphVisitors.h" class BDtaunuReader; @@ -101,7 +99,7 @@ class BDtaunuReader; * #### Graph analysis * We use BGL's generic algorithms and visitor classes to analyze the graph. * Since we are often interested in specific reco particles, we cache `map`s - * of specific particles and its satellite data (see Particles.h); the contents of the + * of specific particles and its satellite data (see GraphDef.h); the contents of the * `map`s can be reported to the supervising class for analysis. * */ @@ -137,8 +135,8 @@ class RecoGraphManager : public GraphManager { //! Get the unique reco particle index. See RecoIndexer.h. int get_reco_index(int lund, int i) const { return reco_indexer(lund, i); } - //! Access information about the `i`th Y candidate. See Particles.h. - const RecoY* get_recoY(int i) const; + //! Access information about the `i`th Y candidate. See GraphDef.h. + const RecoGraph::RecoY* get_recoY(int i) const; private: @@ -149,7 +147,7 @@ class RecoGraphManager : public GraphManager { RecoGraph::Graph g; // Graph construction - RecoIndexer reco_indexer; + RecoGraph::RecoIndexer reco_indexer; std::map reco_vertex_map; void ClearGraph(); void AddCandidates( @@ -158,10 +156,10 @@ class RecoGraphManager : public GraphManager { std::vector &CandDauLund); // Graph analysis - std::map Y_map; - std::map B_map; - std::map D_map; - std::map Lepton_map; + std::map Y_map; + std::map B_map; + std::map D_map; + std::map Lepton_map; void ClearAnalysis(); }; diff --git a/create_database/tuple_reader/RecoGraphVisitors.cc b/create_database/tuple_reader/RecoGraphVisitors.cc index 228ace1..6377478 100644 --- a/create_database/tuple_reader/RecoGraphVisitors.cc +++ b/create_database/tuple_reader/RecoGraphVisitors.cc @@ -3,7 +3,6 @@ #include #include "GraphDef.h" -#include "Particles.h" #include "RecoGraphVisitors.h" #include "RecoGraphManager.h" @@ -113,7 +112,7 @@ void RecoGraphDfsVisitor::AnalyzeDstar(const Vertex &u, const Graph &g) { } // Analyze "Leptons". These are either actual leptons are placeholder -// hadron for the tau of the B decay. See Particles.h for more info. +// hadron for the tau of the B decay. See GraphDef.h for more info. // The quantities computed are: // 1. The tau decay mode. For actual leptons, this is what the // tau mode would have been if it were actually from a tau decay. diff --git a/create_database/tuple_reader/RecoGraphVisitors.h b/create_database/tuple_reader/RecoGraphVisitors.h index 6f26fa7..49e6737 100644 --- a/create_database/tuple_reader/RecoGraphVisitors.h +++ b/create_database/tuple_reader/RecoGraphVisitors.h @@ -24,7 +24,7 @@ class RecoGraphManager; * #Purpose * * This class computes analysis information associated with particular - * types of reconstructed particles. See Particles.h for the quantities + * types of reconstructed particles. See GraphDef.h for the quantities * computed. * * Since most quantities about a reconstructed particle can only be diff --git a/create_database/tuple_reader/RecoIndexer.h b/create_database/tuple_reader/RecoIndexer.h deleted file mode 100644 index ce7fa03..0000000 --- a/create_database/tuple_reader/RecoIndexer.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _RECOINDEXER_H_ -#define _RECOINDEXER_H_ - -/** @file RecoIndexer.h */ - -#include - -/** @brief This class assigns a unique index to each reconstructed particle. - * - * @detail - * # Motivation - * The need for every reconstructed particle of the event to have a unique - * index arises primarily in accessessing vertex information in the BGL graph. - * However, such an indexing is more convenient to use than the existing - * BtaTupleMaker indexing. - * - * # Implementation - * This class builds a hash function from the reco particle's index in the - * BtaTupleMaker block to a unique index. - * - * See RecoIndexer.cc for details. - */ -class RecoIndexer { - - private: - int nY, nB, nD, nC, nh, nl, ngamma; - - public: - RecoIndexer(); - RecoIndexer(int _nY, int _nB, int _nD, - int _nC, int _nh, int _nl, int _ngamma); - RecoIndexer(const RecoIndexer &r) = default; - RecoIndexer &operator=(const RecoIndexer &r) = default; - ~RecoIndexer() {}; - - //! Given the lundId and block index, return the unique reco index. - int operator()(int lund, int idx) const; - - //! Return total number of reco particles in this event. - int total() const { return nY + nB + nD + nC + nh + nl + ngamma; } - - //! Set the total number of each type of reco particle. - /*! The list order is { nY, nB, nD, nC, nh, nl, ngamma } */ - void set(std::initializer_list l); - - //! Clear cache. - void clear(); -}; - -#endif