-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dchao
committed
Sep 24, 2014
1 parent
4b457e8
commit fd08fbb
Showing
9 changed files
with
177 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
create_database/tuple_reader/bdtaunu_tuple_analyzer/TruthMatcher.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <map> | ||
#include <utility> | ||
#include <cassert> | ||
|
||
#include <boost/graph/depth_first_search.hpp> | ||
|
||
#include "TruthMatcher.h" | ||
#include "BDtaunuMcReader.h" | ||
#include "GraphDef.h" | ||
|
||
using namespace boost; | ||
|
||
TruthMatcher::TruthMatcher() : reader(nullptr) { | ||
} | ||
|
||
TruthMatcher::TruthMatcher(BDtaunuMcReader *_reader) : reader(_reader) { | ||
} | ||
|
||
bool TruthMatcher::is_truth_matched(int reco_idx) const { | ||
std::map<int, bool>::const_iterator it = truth_match.find(reco_idx); | ||
assert(it != truth_match.end()); | ||
return it->second; | ||
} | ||
|
||
void TruthMatcher::analyze() { | ||
truth_match.clear(); | ||
depth_first_search((reader->reco_graph_manager).g, visitor(TruthMatchDfsVisitor(this))); | ||
} | ||
|
||
TruthMatchDfsVisitor::TruthMatchDfsVisitor() : tm(nullptr) { | ||
} | ||
|
||
TruthMatchDfsVisitor::TruthMatchDfsVisitor(TruthMatcher *_tm) : tm(_tm) { | ||
lund_pm = get(vertex_lund_id, (tm->reader->reco_graph_manager).g); | ||
reco_idx_pm = get(vertex_reco_index, (tm->reader->reco_graph_manager).g); | ||
block_idx_pm = get(vertex_block_index, (tm->reader->reco_graph_manager).g); | ||
} | ||
|
||
void TruthMatchDfsVisitor::finish_vertex(RecoGraph::Vertex u, const RecoGraph::Graph &g) { | ||
|
||
int reco_idx = get(reco_idx_pm, u); | ||
if ((tm->reader->reco_graph_manager).reco_indexer.is_h_candidate(reco_idx)) { | ||
bool is_tm = false; | ||
if (tm->reader->hMCIdx[get(block_idx_pm, u)] >= 0) is_tm = true; | ||
(tm->truth_match).insert(std::make_pair(reco_idx, is_tm)); | ||
} else if ((tm->reader->reco_graph_manager).reco_indexer.is_l_candidate(reco_idx)) { | ||
bool is_tm = false; | ||
if (tm->reader->lMCIdx[get(block_idx_pm, u)] >= 0) is_tm = true; | ||
(tm->truth_match).insert(std::make_pair(reco_idx, is_tm)); | ||
} else if ((tm->reader->reco_graph_manager).reco_indexer.is_gamma_candidate(reco_idx)) { | ||
bool is_tm = false; | ||
if (tm->reader->gammaMCIdx[get(block_idx_pm, u)] >= 0) is_tm = true; | ||
(tm->truth_match).insert(std::make_pair(reco_idx, is_tm)); | ||
} else { | ||
bool is_tm = true; | ||
RecoGraph::AdjacencyIterator ai, ai_end; | ||
for (tie(ai, ai_end) = adjacent_vertices(u, g); ai != ai_end; ++ai) { | ||
if (!(tm->truth_match).find(get(reco_idx_pm, *ai))->second) { | ||
is_tm = false; | ||
break; | ||
} | ||
} | ||
(tm->truth_match).insert(std::make_pair(reco_idx, is_tm)); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
create_database/tuple_reader/bdtaunu_tuple_analyzer/TruthMatcher.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef _TRUTHMATCHER_H_ | ||
#define _TRUTHMATCHER_H_ | ||
|
||
#include <map> | ||
#include <boost/graph/depth_first_search.hpp> | ||
|
||
#include "GraphDef.h" | ||
|
||
class BDtaunuMcReader; | ||
|
||
class TruthMatcher { | ||
|
||
friend class TruthMatchDfsVisitor; | ||
|
||
public: | ||
TruthMatcher(); | ||
TruthMatcher(BDtaunuMcReader *reader); | ||
TruthMatcher(const TruthMatcher&) = default; | ||
TruthMatcher &operator=(const TruthMatcher&) = default; | ||
|
||
bool is_truth_matched(int reco_idx) const; | ||
|
||
void analyze(); | ||
|
||
private: | ||
|
||
std::map<int, bool> truth_match; | ||
|
||
BDtaunuMcReader *reader; | ||
}; | ||
|
||
class TruthMatchDfsVisitor : public boost::default_dfs_visitor { | ||
|
||
public: | ||
TruthMatchDfsVisitor(); | ||
TruthMatchDfsVisitor(TruthMatcher*); | ||
~TruthMatchDfsVisitor() {}; | ||
|
||
void finish_vertex(RecoGraph::Vertex u, const RecoGraph::Graph &g); | ||
|
||
private: | ||
TruthMatcher *tm; | ||
RecoGraph::LundIdPropertyMap lund_pm; | ||
RecoGraph::RecoIndexPropertyMap reco_idx_pm; | ||
RecoGraph::BlockIndexPropertyMap block_idx_pm; | ||
}; | ||
|
||
#endif |